-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
57 lines (41 loc) · 932 Bytes
/
Makefile
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
# --------
# Makefile
# --------
# Project to compile (use a preprocessor definition)
PROJECT_TO_COMPILE = TEST_COMMANDS
TRACES = _ #TRACE_ALLOC
# Executable name
EXE = prog.exe
# Directories
SRC_DIR = .
OBJ_DIR = obj
# Compiler
CC = gcc
# Compiler options
CFLAGS = -D $(PROJECT_TO_COMPILE) -D $(TRACES) -std=c99 -W -Wall -Wextra -g # -Werror
# Linker options
LDFLAGS =
# ----
SRC = $(wildcard $(SRC_DIR)/[^N]*.c)
OBJS = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
all : $(EXE)
.PHONY: tests
tests :
cd tests ; make
$(EXE) : $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^
# Create obj directory if needed
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c $(OBJ_DIR)
$(CC) $(CFLAGS) -o $@ -c $<
.PHONY: clean
clean :
@rm $(OBJS)
.PHONY: cleaner
cleaner : clean
# The || avoid errors if OBJ_DIR does not exist
@rmdir "$(OBJ_DIR)" || echo ; \
rm "$(EXE)"
$(PPM_DIR)/tests/%.ppm : $(CONF_DIR)/%.txt
./$(EXE) $< $@