-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
171 lines (137 loc) · 3.38 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: lportay <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2017/09/13 10:52:14 by lportay #+# #+# #
# Updated: 2019/04/10 12:25:19 by lportay ### ########.fr #
# #
# **************************************************************************** #
.PHONY: clean fclean re all tags rules
NMDIR= src_nm/
OTOOLDIR= src_otool/
vpath %.h includes/
CFLAGS= -Wall -Wextra -Werror $(INCLUDE)
DEBUG=no
OPT=LIB
ARCH:= $(shell uname)
ifeq ($(ARCH), Darwin)
CC= clang
else ifeq ($(ARCH), Linux)
CC=gcc-8
endif
ifeq ($(BIN), 32)
CFLAGS+= -m32
endif
ifeq ($(DEBUG), yes)
CFLAGS+= -g3
else ifeq ($(DEBUG), sanitize)
CFLAGS+= -g3 -fsanitize=address
endif
INCLUDE=\
-Iincludes\
-Iincludes/system\
-I$(LIBDIR)bridge\
-I$(LIBDIR)is\
-I$(LIBDIR)maths\
-I$(LIBDIR)err\
-I$(LIBDIR)buf\
-I$(LIBDIR)mem\
-I$(LIBDIR)bytes\
-I$(LIBDIR)str\
-I$(LIBDIR)array\
SRC_NM= \
ar.c\
fat.c\
ndian.c\
nm.c\
main.c\
print.c\
s32.c\
s64.c\
sort.c\
utils.c\
utils2.c\
SRC_OTOOL= \
ar.c\
main.c\
otool.c\
ndian.c\
utils.c\
s32.c\
s64.c\
fat.c\
print.c\
OBJDIR= obj/
NM_OBJDIR= $(OBJDIR)nm
OTOOL_OBJDIR= $(OBJDIR)otool
OBJ_NM= $(addprefix $(NM_OBJDIR)/, $(SRC_NM:%.c=%.o))
OBJ_OTOOL= $(addprefix $(OTOOL_OBJDIR)/, $(SRC_OTOOL:%.c=%.o))
LIBDIR= libft/
LIB= libft.a
NM= ft_nm
OTOOL = ft_otool
NAME= $(NM) $(OTOOL)
GREEN="\033[32m"
RESET="\033[0m"
all: $(LIB) $(NAME)
$(NM): $(LIBDIR)$(LIB) $(OBJ_NM)
$(CC) $(CFLAGS) -o $@ $(OBJ_NM) -L$(LIBDIR) -lft
@echo $(GREEN)$@" Successfully created"$(RESET)
$(OTOOL): $(LIBDIR)$(LIB) $(OBJ_OTOOL)
$(CC) $(CFLAGS) -o $@ $(OBJ_OTOOL) -L$(LIBDIR) -lft
@echo $(GREEN)$@" Successfully created"$(RESET)
$(NM_OBJDIR)/%.o: $(NMDIR)%.c nm.h | $(NM_OBJDIR)
$(COMPILE.c) $< -o $@
$(OTOOL_OBJDIR)/%.o: $(OTOOLDIR)%.c otool.h | $(OTOOL_OBJDIR)
$(COMPILE.c) $< -o $@
$(NM_OBJDIR):
-mkdir -p $@
$(OTOOL_OBJDIR):
-mkdir -p $@
$(LIB):
@$(MAKE) -C $(LIBDIR)
$(LIBDIR)$(LIB):
@$(MAKE) -C $(LIBDIR)
main: $(LIB)
$(CC) $(CFLAGS) -o test $(main) -L$(LIBDIR) -lft
-rm -f $(main:.c=.o)
tags:
ctags -R *
ndiff:
@./ft_nm $(f) >ft
@nm $(f) >o
@diff ft o
odiff:
@./ft_otool $(f) >ft
@otool -t $(f) >o
@diff ft o
rules:
@echo 'lportay' > auteur
@echo "Here are the things to review before turning in your work\n\
1. Leaks\n\
2. Forbidden Functions\n\
3. Drop Useless Libraries\n\
3. Norme\n\
4. Adequate Compilation Flags\n\
5. Squash Commits\n\
6. Test properly and thoroughly your project\n\
7. Ask someone to review/test your project"
clean:
ifeq ($(OPT), LIB)
@$(MAKE) clean -C $(LIBDIR)
endif
$(RM) -r $(OBJDIR)
@$(RM) test a.out
@$(RM) -r test.dSYM
fclean: clean
ifeq ($(OPT), LIB)
@$(MAKE) fclean -C $(LIBDIR)
endif
$(RM) $(NAME) $(SYMLINK)
@$(RM) -r $(NAME).dSYM
re:
$(MAKE) fclean
$(MAKE) all