2023-10-11 12:04:04 -04:00
|
|
|
SRC_DIR := src
|
|
|
|
OBJ_DIR := build
|
|
|
|
BIN_DIR := dist
|
|
|
|
LIB_DIR := lib
|
|
|
|
|
2023-10-18 14:49:39 -04:00
|
|
|
TEST_SRC_DIR := test
|
|
|
|
TEST_SRC := $(wildcard $(TEST_SRC_DIR)/*.c)
|
|
|
|
TEST_OBJ := $(TEST_SRC:$(TEST_SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
|
|
|
|
2023-10-11 12:04:04 -04:00
|
|
|
TEST_EXE := $(BIN_DIR)/lizfcm.test
|
2023-10-11 19:00:38 -04:00
|
|
|
EXE := $(BIN_DIR)/lizfcm
|
|
|
|
LIBRARY := $(LIB_DIR)/lizfcm.a
|
|
|
|
SRC := $(wildcard $(SRC_DIR)/*.c)
|
|
|
|
OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
2023-10-11 12:04:04 -04:00
|
|
|
|
|
|
|
CPPFLAGS := -Iinc -MMD -MP
|
|
|
|
CFLAGS := -Wall
|
2023-10-11 19:00:38 -04:00
|
|
|
LDFLAGS := -lm
|
2023-10-11 12:04:04 -04:00
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
|
|
|
|
all: $(TEST_EXE)
|
|
|
|
|
2023-10-18 14:49:39 -04:00
|
|
|
$(TEST_EXE): $(TEST_OBJ) $(LIBRARY) | $(BIN_DIR)
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ -o $@
|
2023-10-11 12:04:04 -04:00
|
|
|
|
2023-10-13 23:00:07 -04:00
|
|
|
$(LIBRARY): $(OBJ) | $(LIB_DIR)
|
2023-10-11 12:04:04 -04:00
|
|
|
ar rcs $(LIBRARY) $(OBJ_DIR)/*.o
|
|
|
|
ranlib $(LIBRARY)
|
|
|
|
|
2023-10-18 14:49:39 -04:00
|
|
|
$(OBJ_DIR)/%.o: $(TEST_SRC_DIR)/%.c | $(OBJ_DIR)
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2023-10-11 12:04:04 -04:00
|
|
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
$(BIN_DIR) $(OBJ_DIR) $(LIB_DIR):
|
|
|
|
mkdir -p $@
|
|
|
|
|
2023-10-18 14:49:39 -04:00
|
|
|
print-% : ; @echo $* = $($*)
|
|
|
|
|
2023-10-11 12:04:04 -04:00
|
|
|
clean:
|
2023-10-13 23:00:07 -04:00
|
|
|
@$(RM) -r $(BIN_DIR) $(OBJ_DIR) $(LIB_DIR)
|
2023-10-11 12:04:04 -04:00
|
|
|
|
|
|
|
-include $(OBJ:.o=.d)
|
2023-10-18 14:49:39 -04:00
|
|
|
-include $(TEST_OBJ:.o=.d)
|