-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (79 loc) · 2.71 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
##
# leadwasp
#
# @file makefile
# @version 0.2
# ============================== NAME ============================== #
NAME = leadwasp
NAME_BONUS = leadwasp_bonus
DIR_LIBUNIT = external/libunit/libunit
# ============================== CMP ============================== #
CC = gcc
CFLAGS = -Wall -Wextra -Werror -g3
DFLAG = -MMD -MP
# ============================== INCLUDE ============================== #
DIR_INC = inc/ ${DIR_LIBUNIT}/inc
IFLAGS = $(DIR_INC:%=-I%)
# ============================== SRC ============================== #
SRC_DIR = src/
SRC_SUBDIR_LST = strlen strcpy strcmp strdup write read atoi_base list_size list_sort list_remove_if list_push_front
SRC_SUBDIR = ${addprefix ${SRC_DIR}, ${SRC_SUBDIR_LST}}
SRC_FILE = src.mk
-include ${SRC_FILE}
SRC_LST = main.c \
${STRLEN_SRC} ${STRCPY_SRC} ${STRCMP_SRC} ${STRDUP_SRC} ${WRITE_SRC} ${READ_SRC}
SRC_BONUS_LST = main_bonus.c list_utils.c \
${ATOI_BASE_SRC} ${LIST_PUSH_FRONT_SRC} ${LIST_REMOVE_IF_SRC} ${LIST_SORT_SRC} ${LIST_SIZE_SRC}
SRC = ${addprefix ${SRC_DIR}, ${SRC_LST}}
SRC_BONUS = ${addprefix ${SRC_DIR}, ${SRC_BONUS_LST}}
# ============================== OBJ ============================== #
OBJ_DIR = .obj/
OBJ_SUBDIR = ${addprefix ${OBJ_DIR}, ${SRC_SUBDIR}}
OBJ_TMP = ${addprefix ${OBJ_DIR}, ${SRC}}
OBJ_TMP_B = ${addprefix ${OBJ_DIR}, ${SRC_BONUS}}
OBJ = ${OBJ_TMP:.c=.o}
OBJ_BONUS = ${OBJ_TMP_B:.c=.o}
DEPS = ${OBJ:.o=.d}
# ============================== LIB ============================== #
LIBUNIT = ${DIR_LIBUNIT}/libunit.a
LIBASM = ../libasm.a
# /*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\ RULES /*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\ #
.PHONY: mandatory bonus all m b a clean fclean
# ============================== BASE ============================== #
mandatory: ${NAME}
m: mandatory
bonus: ${NAME_BONUS}
b: bonus
all: mandatory bonus
a: all
strlen: mandatory
strcpy: mandatory
strcmp: mandatory
strdup: mandatory
read: mandatory
write: mandatory
atoi_base: bonus
list_size: bonus
list_push_front: bonus
list_sort: bonus
list_remove_if: bonus
clean:
@rm -rf ${OBJ_DIR}
fclean: clean
@rm -f ${NAME} ${NAME_BONUS}
@make -C external/libunit/libunit fclean
re: fclean all
# ============================== COMPILATION ============================== #
${NAME}: ${LIBUNIT} ${OBJ_SUBDIR} ${OBJ}
${CC} ${IFLAGS} ${CFLAGS} ${OBJ} ${LIBUNIT} ${LIBASM} -o $@
${NAME_BONUS}: ${LIBUNIT} ${OBJ_SUBDIR} ${OBJ_BONUS}
${CC} ${IFLAGS} ${CFLAGS} ${OBJ_BONUS} ${LIBUNIT} ${LIBASM} -o $@
${OBJ_DIR}%.o: %.c
${CC} ${IFLAGS} ${CFLAGS} ${DFLAG} -c $< -o $@
${LIBUNIT}:
make -C ${DIR_LIBUNIT}
-include ${DEPS}
# ============================== UTILS ============================== #
${OBJ_SUBDIR}:
@mkdir -p ${OBJ_SUBDIR}
# end