-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (55 loc) · 1.54 KB
/
Makefile
File metadata and controls
70 lines (55 loc) · 1.54 KB
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
ifeq ($(HOSTTYPE),)
HOSTTYPE := $(shell uname -m)_$(shell uname -s)
endif
DEBUG =
ifdef TEST
DEBUG = -g -fsanitize=undefined
else
DEBUG =
endif
ifdef LEAKS
DEBUG = -g
endif
IS_DEBUG =
NAME = libft_malloc_$(HOSTTYPE).so
TESTNAME = malloc_test
TESTS = test0 test1 test2 test3 test3_1 test4 test5
CFLAGS = -Wall -Wextra -Werror -Wpedantic
DYLIB = -shared -exported_symbols_list exported.syms
TESTFLAGS = -I./includes -L. -lft_malloc
CORE = malloc realloc free chunks show_alloc log utils
FILES = $(addprefix src/, $(CORE))
SRC = $(addsuffix .c, $(FILES))
OBJ = $(SRC:.c=.o)
.PHONY = all clean fclean re
all: $(NAME)
$(OBJ): %.o: %.c
@$(CC) -c $(DEBUG) $(IS_DEBUG) -I. $(CFLAGS) $< -o $@
$(NAME): $(OBJ)
@echo -n 'Compiling ft_malloc... '
@$(CC) $(DEBUG) $(CFLAGS) $(DYLIB) $^ -o $@
@rm -f libft_malloc.so
@ln -s $(NAME) libft_malloc.so
@echo "\033[32mdone\033[0m"
debug: set-debug all
set-debug:
$(eval IS_DEBUG='-D__DEBUG__')
test-debug: set-debug all
@$(CC) $(IS_DEBUG) $(DEBUG) $(TESTFLAGS) $(LDFLAGS) test/$(CASE) -o $(TESTNAME)
test-logs: set-debug all
@$(CC) $(IS_DEBUG) $(DEBUG) $(TESTFLAGS) $(LDFLAGS) test/$(CASE) -o $(TESTNAME)
test: all
@$(CC) $(IS_DEBUG) $(DEBUG) $(TESTFLAGS) $(LDFLAGS) test/$(CASE) -o $(TESTNAME)
compile-tests:
@./test/compile.sh
clean-tests:
@rm $(TESTS)
clean:
@echo -n 'Cleaning ft_malloc object files... '
@rm -rf $(OBJ) *.dSYM *.DS_Store *.so $(TESTNAME)
@echo "\033[32mdone\033[0m"
fclean: clean
@echo -n 'Cleaning ft_malloc executable... '
@rm -rf *.so $(NAME)
@echo "\033[32mdone\033[0m"
re: fclean all