-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (43 loc) · 963 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
58
59
# DIRECTORIES
DEP_DIR = dep
INC_DIR = inc
OBJ_DIR = obj
SRC_DIR = src
# FILES
INC := $(wildcard $(INC_DIR)/*.h)
SRC := $(wildcard $(SRC_DIR)/*.c)
OBJ := $(notdir $(SRC))
DEP := $(OBJ:%.c=$(DEP_DIR)/%.d)
OBJ := $(OBJ:%.c=$(OBJ_DIR)/%.o)
LIB = libsnafuENG.a
# COMPILATION
CC = gcc
CFLAGS = -Wall -Wextra -Werror -g
DFLAGS = -MP -MMD -MF $(DEP_DIR)/$*.d -MT '$@'
LDFLAGS = -L. -lsnafuENG
# TEST
MAIN = test/main.c
EXEC = $(MAIN:.c=.out)
DEBUG = valgrind
$(LIB): $(OBJ)
ar -rcs $@ $(OBJ)
all: $(LIB)
test: $(EXEC)
./$<
debug: $(EXEC)
$(DEBUG) ./$<
clean:
rm -rf $(DEP_DIR) $(OBJ_DIR)
fclean: clean
rm -f $(LIB) $(EXEC)
re: fclean all
$(DEP_DIR):
mkdir $@
$(OBJ_DIR):
mkdir $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(DEP_DIR) $(OBJ_DIR)
$(CC) $(CFLAGS) $(DFLAGS) -c -I./$(INC_DIR) $< -o $@
$(EXEC): $(MAIN) $(INC_DIR)/snafuENG.h $(LIB)
$(CC) $(CFLAGS) -I./$(INC_DIR) $< -o $@ $(LDFLAGS)
-include $(DEP)
.PHONY: all test debug clean fclean re