-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
70 lines (54 loc) · 1.34 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# ===== Target & FLAGS =====
NAME := libft.a
CC := clang
CFLAGS := -g3 -Wall -Wextra -Werror -std=c99 -I include
#-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
AR := ar -rcs
# ===== @Packages =====
PKGS := error math string system
#FIXME: specify packages
stringV := alloc util
errorV := error
systemV := alloc dalloc write
# ===== Macros =====
define choose_modules
$(foreach pkg, $(1),\
$(foreach file, $($(pkg)V),\
src/std__$(pkg)/$(file).c\
)\
)
endef
# ===== Sources & Objects & Include =====
#FIXME: specify sources
SRC := $(wildcard src/**/*.c)
# SRC := $(call choose_modules, $(PKGS))
OBJ := $(SRC:%.c=%.o)
# ===== Rules =====
.PHONY: all re clean fclean
%.o: %.c
@echo " $(WU)$(<F)$(R) -> $(E)$(@F)"
@$(CC) $(CFLAGS) -c -o $@ $<
$(NAME): $(OBJ)
@$(AR) $@ $^
@echo 🗃️ archived with flag $(CFLAGS)
all: $(NAME)
clean:
@rm -f $(OBJ)
@echo "cleaned $(NAME)'s object files"
fclean: clean
@rm -f $(NAME)
@echo 🗑 cleaned $(NAME)
re: fclean all
# ===== Custom Rules =====
docs:
@set -e;\
for p in $(PKGS); do\
hgen -I include/std__$$p.h src/std__$$p;\
done
test_make: docs all
@$(CC) $(CFLAGS) $(wildcard test/*.c) $(NAME) -o test/test.out
#-I test/lib/theft/inc -L test/lib/theft/build/ -ltheft
test: test_make
@./test/test.out
leak: test_make
@colour-valgrind ./test/test.out