2022-03-05 12:43:06 -05:00
|
|
|
CC := gcc
|
|
|
|
SRCD := src
|
|
|
|
TSTD := tests
|
|
|
|
BLDD := build
|
|
|
|
BIND := bin
|
|
|
|
INCD := include
|
|
|
|
LIBD := lib
|
|
|
|
|
|
|
|
ALL_SRCF := $(shell find $(SRCD) -type f -name *.c)
|
|
|
|
ALL_LIBF := $(shell find $(LIBD) -type f -name *.o)
|
|
|
|
ALL_OBJF := $(patsubst $(SRCD)/%,$(BLDD)/%,$(ALL_SRCF:.c=.o))
|
|
|
|
FUNC_FILES := $(filter-out build/main.o, $(ALL_OBJF))
|
|
|
|
|
|
|
|
TEST_SRC := $(shell find $(TSTD) -type f -name *.c)
|
|
|
|
|
|
|
|
INC := -I $(INCD)
|
|
|
|
|
|
|
|
CFLAGS := -Wall -Werror -Wno-unused-function -MMD
|
|
|
|
COLORF := -DCOLOR
|
2022-03-26 00:23:11 -04:00
|
|
|
DFLAGS := -g -DDEBUG -DCOLOR
|
2022-03-05 12:43:06 -05:00
|
|
|
PRINT_STAMENTS := -DERROR -DSUCCESS -DWARN -DINFO
|
|
|
|
|
|
|
|
STD := -std=c99
|
|
|
|
TEST_LIB := -lcriterion
|
|
|
|
LIBS := -lm
|
|
|
|
|
|
|
|
CFLAGS += $(STD)
|
|
|
|
|
|
|
|
EXEC := sfmm
|
|
|
|
TEST := $(EXEC)_tests
|
|
|
|
|
|
|
|
.PHONY: clean all setup debug
|
|
|
|
|
|
|
|
all: setup $(BIND)/$(EXEC) $(BIND)/$(TEST)
|
|
|
|
|
|
|
|
debug: CFLAGS += $(DFLAGS) $(PRINT_STAMENTS) $(COLORF)
|
|
|
|
debug: all
|
|
|
|
|
|
|
|
setup: $(BIND) $(BLDD)
|
|
|
|
$(BIND):
|
|
|
|
mkdir -p $(BIND)
|
|
|
|
$(BLDD):
|
|
|
|
mkdir -p $(BLDD)
|
|
|
|
|
|
|
|
$(BIND)/$(EXEC): $(ALL_OBJF) $(ALL_LIBF)
|
|
|
|
$(CC) $^ -o $@ $(LIBS)
|
|
|
|
|
|
|
|
$(BIND)/$(TEST): $(FUNC_FILES) $(TEST_SRC) $(ALL_LIBF)
|
|
|
|
$(CC) $(CFLAGS) $(INC) $(FUNC_FILES) $(TEST_SRC) $(ALL_LIBF) $(TEST_LIB) $(LIBS) -o $@
|
|
|
|
|
|
|
|
$(BLDD)/%.o: $(SRCD)/%.c
|
|
|
|
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(BLDD) $(BIND)
|
|
|
|
|
|
|
|
.PRECIOUS: $(BLDD)/*.d
|
|
|
|
-include $(BLDD)/*.d
|