# Makefile da library pen (categoria "Caneta")
# Constroi build/libtinyblocks-pen.a e build/libtinyblocks-pen.so
# Depende do palco do editor (tb_stage.h); o .so resolve tb_stage_* no host.
CC     := gcc
BUILD  := build

CFLAGS := -std=c11 -Wall -Wextra -pedantic -fvisibility=hidden \
          -D_POSIX_C_SOURCE=200809L -I../../include -Iinclude

OBJ    := $(BUILD)/tb_pen.o
LIB_A  := $(BUILD)/libtinyblocks-pen.a
LIB_SO := $(BUILD)/libtinyblocks-pen.so

.PHONY: all static shared clean
all: static shared
static: $(LIB_A)
shared: $(LIB_SO)

$(OBJ): src/tb_pen.c include/tb_pen.h
	@mkdir -p $(BUILD)
	$(CC) $(CFLAGS) -fPIC -c $< -o $@

$(LIB_A): $(OBJ)
	ar rcs $@ $^

$(LIB_SO): $(OBJ)
	$(CC) -shared -o $@ $^

clean:
	$(RM) -r $(BUILD)
