labfy-investigation/Makefile
2026-07-13 16:14:41 +02:00

79 lines
1.8 KiB
Makefile

CC = gcc
PKG_CONFIG = pkg-config
.DEFAULT_GOAL := all
CFLAGS = -std=c17 \
-Wall \
-Wextra \
-Werror \
-g \
-Iinclude \
$(shell $(PKG_CONFIG) --cflags gtk4 sqlite3)
LDFLAGS = $(shell $(PKG_CONFIG) --libs gtk4 sqlite3)
TEST_CFLAGS = -std=c17 \
-Wall \
-Wextra \
-Werror \
-Iinclude \
$(shell $(PKG_CONFIG) --cflags glib-2.0 gio-2.0)
TEST_LDFLAGS = $(shell $(PKG_CONFIG) --libs glib-2.0 gio-2.0)
SRC := $(shell find src -name "*.c")
OBJ := $(SRC:.c=.o)
TARGET = labfy-investigation
TEST_NODE = tests/test_investigation_node
TEST_TREE_MODEL = tests/test_investigation_tree_model
TEST_TREE_BUILDER = tests/test_investigation_tree_builder
all: $(TARGET)
$(TARGET): $(OBJ)
$(CC) $(OBJ) -o $@ $(LDFLAGS)
$(TEST_NODE): \
tests/test_investigation_node.c \
src/core/investigation_node.c
$(CC) $(TEST_CFLAGS) $^ -o $@ $(TEST_LDFLAGS)
$(TEST_TREE_MODEL): \
tests/test_investigation_tree_model.c \
src/core/investigation_node.c \
src/core/investigation_tree_model.c
$(CC) $(TEST_CFLAGS) $^ -o $@ $(TEST_LDFLAGS)
$(TEST_TREE_BUILDER): \
tests/test_investigation_tree_builder.c \
src/core/investigation_node.c \
src/core/investigation_tree_model.c \
src/core/investigation_tree_builder.c
$(CC) $(TEST_CFLAGS) $^ -o $@ $(TEST_LDFLAGS) \
$(shell $(PKG_CONFIG) --libs gio-2.0)
test: $(TEST_NODE) $(TEST_TREE_MODEL) $(TEST_TREE_BUILDER)
@echo "Exécution des tests..."
@./$(TEST_NODE)
@./$(TEST_TREE_MODEL)
@./$(TEST_TREE_BUILDER)
@echo "Tous les tests sont valides."
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
run: $(TARGET)
./$(TARGET)
clean:
rm -f $(OBJ) $(TARGET) \
$(TEST_NODE) \
$(TEST_TREE_MODEL) \
$(TEST_TREE_BUILDER)
.PHONY: clean run test