-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (43 loc) · 1.07 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
MAKEFLAGS += "-s"
NAME = ft_ls
CC = cc
CFLAGS := -Wall -Wextra -Werror
SOURCE_DIR := source
SOURCES := main.c ls.c stack.c print.c str.c qsort.c
INCLUDE_DIR = include
OBJ_DIR := obj
OBJECTS := $(addprefix $(OBJ_DIR)/, $(notdir $(SOURCES:.c=.o)))
$(shell mkdir -p $(OBJ_DIR))
#NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
NPROCS := 4
target asan_flags: CFLAGS += -fsanitize=address,undefined -g
target debug_flags: CFLAGS += -gdwarf-4 -fstandalone-debug
target bench_flags: CFLAGS += -O3 -DBENCH
all: $(NAME)
$(NAME): $(OBJECTS)
@echo $(CFLAGS)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
$(OBJ_DIR)/%.o: $(SOURCE_DIR)/%.c
@echo [+] $<
$(CC) $(CFLAGS) -I$(INCLUDE_DIR) -c $< -o $@
clean:
rm -f $(OBJECTS)
fclean: clean
rm -f $(NAME)
re:
@make fclean
@make all -j$(NPROCS)
bench_flags: all
asan_flags: all
debug_flags: all
bench:
@make fclean
@make bench_flags -j$(NPROCS)
debug:
@make fclean
@make debug_flags -j$(NPROCS)
asan:
@echo [ASAN]
@make fclean
@make asan_flags -j$(NPROCS)
.PHONY: all re clean fclean bench bench_flags asan debug asan_flags debug_flags