-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
163 lines (127 loc) · 4.21 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
# include
CWD_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
include mk/config.mk # base config
include mk/utils.mk # utils function / var
include mk/srcs.mk # srcs.mk
include mk/pb.mk # ui thing, progress bar etc
$(call PB_INIT)
# rule
## config
.SILENT:
.PHONY: setup
.DEFAULT: all
all: setup $(TARGET) print_usage
integer: all
string: all
memory: all
parsing: all
check: all
list: all
print: all
input: all
random: all
linux: all
net: all
net_ipv4: all
net_pack: all
unit_test: all
$(TARGET): $(OBJ_C)
> $(call P_INF,Creating $(R)$(TARGET)$(RST))
> $(PRINTF) "\n\n"
> $(call PB_PRINT_ELAPSED)
> $(AR) rcs $(TARGET) $(OBJ_C)
> $(call PB_TARGET_DONE)
## objs
# https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html#Automatic-Variables
# $(<) : dependencies
# $(@) : full target
# $(@D) : dir target
$(OBJ_C): $(OBJ_DIR)/%.o:$(SRC_DIR)/%.c
> $(call PB_PRINT,$(@))
> $(CC) $(CFLAGS) -o $@ -c $<
setup: $(BIN_DIR) print_logo print_debug helper
help:
> $(PRINTF) "$$USAGE"
$(BIN_DIR):
> $(call MKDIR,$(BIN_DIR))
print_usage:
ifeq ($(DO_PRINT_USAGE),1)
> $(PRINTF) "%b" "$$USAGE"
endif
print_debug:
ifeq ($(shell [ $(DEBUG_MAKE) -ge 1 ] && echo 1 || echo 0),1)
> $(call P_INF,RUNTIME INFOS)
> $(PRINTF) "\t%s"
> $(call P_WAR,DEBUG: $(DEBUG))
> $(PRINTF) "\t%s"
> $(call P_WAR,CFLAGS:)
> $(PRINTF) "\t\t%s\n" $(CFLAGS)
> $(PRINTF) "\t%s"
> $(call P_WAR,.SHELLFLAGS:)
> $(PRINTF) "\t\t%s\n" $(.SHELLFLAGS)
> $(PRINTF) "\t%s"
> $(call P_WAR,OBJ_C:)
> $(PRINTF) "\t\t%s\n" $(OBJ_C)
> $(PRINTF) "\t%s"
> $(call P_WAR,SRC_C:)
> $(PRINTF) "\t\t%s\n" $(SRC_C)
> $(PRINTF) "\t$(bold)Switch$(reset)\n"
> $(PRINTF) " $(font_color)INTEGER $(bold)%d$(reset)\n" $(INTEGER)
> $(PRINTF) " $(font_color)STRING $(bold)%d$(reset)\n" $(STRING)
> $(PRINTF) " $(font_color)MEMORY $(bold)%d$(reset)\n" $(MEMORY)
> $(PRINTF) " $(font_color)CHECK $(bold)%d$(reset)\n" $(CHECK)
> $(PRINTF) " $(font_color)LIST $(bold)%d$(reset)\n" $(LIST)
> $(PRINTF) " $(font_color)PRINT $(bold)%d$(reset)\n" $(PRINT)
> $(PRINTF) " $(font_color)INPUT $(bold)%d$(reset)\n" $(INPUT)
> $(PRINTF) " $(font_color)RANDOM $(bold)%d$(reset)\n" $(RANDOM)
> $(PRINTF) " $(font_color)LINUX $(bold)%d$(reset)\n" $(LINUX)
> $(PRINTF) " $(font_color)NET $(bold)%d$(reset)\n" $(NET)
> $(PRINTF) " $(font_color)NET_IPV4 $(bold)%d$(reset)\n" $(NET_IPV4)
> $(PRINTF) " $(font_color)NET_PACK $(bold)%d$(reset)\n" $(NET_PACK)
> $(PRINTF) "\n"
> $(PRINTF) " $(orange_star) $(font_color)ALL $(bold)%d$(reset)\n" $(ALL)
> $(PRINTF) " $(orange_star) $(font_color)TARGET $(bold)%s$(reset)\n" $(TARGET)
> $(PRINTF) " $(orange_star) $(bold)SRC_C$(reset)\n"
> $(PRINTF) " $(orange_star) $(font_color)%s$(reset)\n" $(SRC_C)
> $(PRINTF) " $(orange_star) $(bold)OBJ_C$(reset)\n"
> $(PRINTF) " $(orange_star) $(font_color)%s$(reset)\n" $(OBJ_C)
> $(PRINTF) "$(orange_star) $(font_color)Building$(reset)\n"
endif
print_logo:
ifeq ($(LOGO_PRINTED),)
> $(PRINTF) "%b\n" "$(ASCII_COLOR)$$ASCII_BANNER$(RST)"
> $(eval export LOGO_PRINTED=1)
endif
### HELPER
helper:
ifneq ($(DISABLE_HELPER),1)
> ./rsc/helper/helper -S ft_libft
endif
### CLEAN
clean:
> $(call P_FAI,Removing obj)
> rm -rf $(OBJ_DIR)
fclean: clean
> $(call P_FAI,Removing $(TARGET))
> rm -rf $(TARGET)
### RE
re: fclean all
## CI TEST
so:
> $(CC) $(OBJ_C) --shared -o libft.so
$(CI_BIN_DIR):
> $(call MKDIR,$@)
ci-compile: all $(CI_BIN_DIR)
> $(call MKDIR,$(CI_BIN_DIR)/$$(dirname $(CI_TARGET)))
> $(CC) -DCI_TEST=1 $(CFLAGS) $(CI_SRC_DIR)/$(CI_TARGET) $(TARGET) -o $(CI_BIN_DIR)/$(CI_TARGET:%.c=%)
> $(call P_PAS,compilation pass) \
ci-run: ci-compile
> $(CWD_DIR)/$(CI_BIN_DIR)/$(CI_TARGET:%.c=%) 420>exec.log
> $(call P_PAS,return value $(font_color)$(CI_BIN_DIR)/$(CI_TARGET:%.c=%)$(RST) [$(G)$${?}$(RST)])
test-compile: all $(CI_BIN_DIR)
> $(call MKDIR,$(CI_BIN_DIR)/$$(dirname $(CI_TARGET)))
> $(CC) $(CFLAGS) $(CI_SRC_DIR)/$(CI_TARGET) $(TARGET) -o $(CI_BIN_DIR)/$(CI_TARGET:%.c=%)
> $(call P_PAS,compilation pass) \
test-run: test-compile
> $(CWD_DIR)/$(CI_BIN_DIR)/$(CI_TARGET:%.c=%) 420>exec.log
> $(call P_PAS,return value $(font_color)$(CI_BIN_DIR)/$(CI_TARGET:%.c=%)$(RST) [$(G)$${?}$(RST)])