-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (39 loc) · 1.16 KB
/
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
CC = gcc
NAME = mysh
SRC_DIR = src
BUILD_DIR = obj
LIB_DIR = lib/node
INCLUDE_DIR = include $(LIB_DIR)/include
SRC = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/builtins/*.c) $(wildcard $(SRC_DIR)/utils/*.c)
OBJ = $(SRC:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
# Flags généraux
CFLAGS = -W -Wall -Wextra -Wshadow -Wconversion -pedantic
CPPFLAGS = $(addprefix -I, $(INCLUDE_DIR))
LDFLAGS = $(LIB_DIR)/libnode.a
# Debug and release flags
# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
CFLAGS_RELEASE = -O2
CFLAGS_DEBUG = -g3 -O0
all: $(NAME)
debug: CFLAGS += $(CFLAGS_DEBUG)
debug: re
# --suppressions=valgrind.supp
valgrind: debug
valgrind --leak-check=full --track-origins=yes --show-leak-kinds=all ./$(NAME)
release: CFLAGS += $(CFLAGS_RELEASE)
release: re
$(NAME): $(OBJ) $(LIB_DIR)/libnode.a
$(CC) $(OBJ) $(LDFLAGS) -o $(NAME)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(LIB_DIR)/libnode.a:
$(MAKE) -C $(LIB_DIR)
clean:
$(MAKE) -C $(LIB_DIR) clean
rm -rf $(BUILD_DIR)
fclean: clean
$(MAKE) -C $(LIB_DIR) fclean
rm -f $(NAME)
re: fclean all
.PHONY: all debug release clean fclean re