-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
96 lines (79 loc) · 2.48 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: qdequele <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2015/12/15 14:57:05 by qdequele #+# #+# #
# Updated: 2017/10/25 13:08:16 by qdequele ### ########.fr #
# #
# **************************************************************************** #
ifeq ($(HOSTTYPE),)
HOSTTYPE := $(shell uname -m)_$(shell uname -s)
endif
#Define the program
NAME = libft_malloc_$(HOSTTYPE).so
LINKNAME = libft_malloc.so
_SRC = free.c\
interface.c\
malloc.c\
math.c\
print.c\
printhex.c\
realloc.c\
show.c\
test.c\
tools.c
_TEST = main.c
_INC = malloc.h
INC = $(addprefix includes/,$(_INC))
SRC = $(addprefix srcs/,$(_SRC))
TEST = $(addprefix test/,$(_TEST))
OBJ = $(SRC:.c=.o)
CFLAGS = -Wall -Wextra -Werror -fPIC -O3
INCLUDES = -I ./includes/
%.o: %.c
@echo -n .
@$gcc $(CFLAGS) -c $< -o $@ $(INCLUDES)
all: $(NAME) $(INC)
$(NAME): $(OBJ)
@gcc $(CFLAGS) $(OBJ) -shared -o $(NAME)
@ln -sF $(NAME) $(LINKNAME)
@echo $(NAME) " - compiled"
clean:
@/bin/rm -rf $(OBJ)
@echo $(NAME) " - Clean all .o files"
fclean: clean
@/bin/rm -rf *.so
@echo $(NAME) " - Clean executable"
re: fclean all
test: $(NAME)
@gcc $(NAME) $(TEST)
@echo $(NAME) and test exec" - compiled and ready to test"
@sh run.sh
@./a.out
correct: re
@echo "- Test 0"
@gcc test/test0.c 2>&-
@./run.sh /usr/bin/time -l ./a.out 2>&1 | grep "page reclaims"
@echo "- Test 1"
@gcc test/test1.c 2>&-
@./run.sh /usr/bin/time -l ./a.out 2>&1 | grep "page reclaims"
@echo "- Test 2"
@gcc test/test2.c 2>&-
@./run.sh /usr/bin/time -l ./a.out 2>&1 | grep "page reclaims"
@echo "- Test 3"
@gcc test/test3.c 2>&-
@./run.sh ./a.out
@echo "- Test 3.2"
@gcc test/test3.2.c 2>&-
@./run.sh ./a.out
@echo "- Test 4"
@gcc test/test4.c 2>&-
@./run.sh ./a.out
@echo "- Test 5"
@gcc test/test5.c libft_malloc.so 2>&-
@./run.sh ./a.out
@rm a.out
.PHONY: all, clean, fclean, re