-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (44 loc) · 1.69 KB
/
Copy pathMakefile
File metadata and controls
57 lines (44 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
################### Configuration ###################
CFLAGS = -O3 -std=c99 -g -Wall -Wextra -Wformat-security -Werror=implicit-function-declaration
INCLUDE = include
SRC = src
OBJ = obj
CC = gcc
################### Fichiers sources ###################
# Fichiers principaux (exclure main.c pour les tests)
MAIN_SRCS = $(filter-out $(SRC)/main.c, $(wildcard $(SRC)/*.c))
MAIN_OBJS = $(patsubst $(SRC)/%.c,$(OBJ)/%.o,$(MAIN_SRCS))
# Fichiers utilitaires de test
TEST_TOOLS_SRC = $(SRC)/tests/test_tools.c
TEST_TOOLS_OBJ = $(OBJ)/test_tools.o
# Fichiers de test (exclure test_tools.c)
TEST_SRCS = $(filter-out $(TEST_TOOLS_SRC), $(wildcard $(SRC)/tests/*.c))
TEST_BINS = $(patsubst $(SRC)/tests/%.c, %, $(TEST_SRCS))
################### Cibles principales ###################
all: jpeg2ppm
test: $(TEST_BINS)
################### Règles de compilation ###################
# Programme principal
jpeg2ppm: $(OBJ)/main.o $(MAIN_OBJS)
$(CC) $^ -o $@ -lm
# Fichier utilitaire de test
$(TEST_TOOLS_OBJ): $(TEST_TOOLS_SRC) $(INCLUDE)/test_tools.h
$(CC) -I$(INCLUDE) -c $< -o $@ $(CFLAGS)
# Règle générique pour les fichiers objets principaux
$(OBJ)/%.o: $(SRC)/%.c
$(CC) -I$(INCLUDE) -c $< -o $@ $(CFLAGS)
# Règle générique pour les tests
%: $(SRC)/tests/%.c $(MAIN_OBJS) $(TEST_TOOLS_OBJ)
$(CC) -I$(INCLUDE) $^ -o $@ $(CFLAGS) -lm
# Règle pour faire tourner tous les tests
run_tests:
@for test in $(TEST_BINS); do \
echo ""; \
echo "[EXECUTION TEST] $$test..."; \
./$$test || exit 1; \
done; \
echo "";
################### Nettoyage ###################
clean:
rm -f $(TEST_BINS) $(OBJ)/*.o jpeg2ppm images/*.ppm images/*.pgm
.PHONY: all test clean