-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (54 loc) · 1.57 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
##################################################
# GLOBAL VARIABLES DEFINITION #
##################################################
TARGET = ft_nm
CFLAGS = -Wall -Wextra -Werror
CC = gcc
INC = -I ./include -I ./libft
HEADERS = ft_nm.h
DEPS = ${addprefix include/, ${HEADERS}}
SRCDIR = ./src/
SRC = main.c sections.c list_helpers.c symbols.c options.c sort.c
OBJDIR = ./objs/
OBJS = ${addprefix ${OBJDIR}, ${SRC:.c=.o}}
LIBFT = libft/libft.a
##################################################
# OUTPUT VARIABLES DEFINITION #
##################################################
RED = \e[1;31m
GREEN = \e[1;32m
BLUE = \e[1;34m
PURPLE = \e[1;35m
RESET = \e[0;0m
COMPILE = ${GREEN}Compiling${RESET}
BUILD = ${BLUE}Building${RESET}
CLEAN = ${RED}Cleaning${RESET}
##################################################
# COMPILATION RULES #
##################################################
${OBJDIR}%.o: ${SRCDIR}%.c ${DEPS}
@echo "${COMPILE} $<"
@${CC} ${CFLAGS} -c $< ${INC} -o $@
${TARGET}: ${OBJDIR} ${OBJS} ${LIBFT}
@echo "${BUILD} $@"
@${CC} ${OBJS} ${LIBFT} -o $@
@echo "${PURPLE}Done !"
${OBJDIR}:
@mkdir -p ${OBJDIR}
${LIBFT}:
@echo "${BUILD} libft"
@${MAKE} --no-print-directory -C libft
##################################################
# USUAL RULES #
##################################################
all: ${TARGET}
clean:
@echo "${CLEAN} objects"
rm -rf ${OBJDIR}
fclean: clean
@echo "${CLEAN} ${TARGET}"
rm -rf ${TARGET}
@echo "${CLEAN} libft"
@${MAKE} --no-print-directory fclean -C libft
re: fclean all
.PHONY: all clean fclean re