-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
189 lines (162 loc) · 5.18 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#-------------------------------------------------->
# makefile autogenerated by python script
# customize it following your own needs <3
#-------------------------------------------------->
# compiler / linker
CC := gcc
# flags for compilation & linking
CFLAGS := -Wall -Werror -Wpedantic -Wextra -MMD -MP
LDFLAGS :=
# folders
SRCDIR := .
BUILDDIR := build
# executables
EXEC1 := $(BUILDDIR)/samples/sample-one-exe-complex/main
EXEC2 := $(BUILDDIR)/samples/sample-multi-exe/main
EXEC3 := $(BUILDDIR)/samples/sample-multi-exe/test/buffer_test
EXEC4 := $(BUILDDIR)/samples/sample-multi-exe/test/memset_test
EXEC5 := $(BUILDDIR)/samples/sample-multi-exe/test/canbus_test
EXEC6 := $(BUILDDIR)/samples/sample-one-exe/test/canbus_test
# folders to include on compilation time
INCS := $(addprefix -I,$(shell find $(SRCDIR) -type f -name "*.h" | xargs dirname | sort | uniq))
# source files
SRC1 := samples/sample-one-exe-complex/lib/buffer/buffer.c \
samples/sample-one-exe-complex/lib/canbus/canbus.c \
samples/sample-one-exe-complex/lib/memset/memset.c \
samples/sample-one-exe-complex/main.c
SRC2 := samples/sample-multi-exe/main.c \
samples/sample-one-exe-complex/lib/buffer/buffer.c \
samples/sample-one-exe-complex/lib/canbus/canbus.c \
samples/sample-one-exe-complex/lib/memset/memset.c
SRC3 := samples/sample-multi-exe/test/buffer_test.c \
samples/sample-one-exe-complex/lib/buffer/buffer.c \
samples/sample-one-exe-complex/lib/unity/unity.c
SRC4 := samples/sample-multi-exe/test/memset_test.c \
samples/sample-one-exe-complex/lib/memset/memset.c \
samples/sample-one-exe-complex/lib/unity/unity.c
SRC5 := samples/sample-multi-exe/test/canbus_test.c \
samples/sample-one-exe-complex/lib/buffer/buffer.c \
samples/sample-one-exe-complex/lib/canbus/canbus.c \
samples/sample-one-exe-complex/lib/unity/unity.c
SRC6 := samples/sample-one-exe/test/canbus_test.c \
samples/sample-one-exe-complex/lib/buffer/buffer.c \
samples/sample-one-exe-complex/lib/canbus/canbus.c \
samples/sample-one-exe-complex/lib/unity/unity.c
# objects
OBJ1 := $(SRC1:%.c=$(BUILDDIR)/%.o)
OBJ2 := $(SRC2:%.c=$(BUILDDIR)/%.o)
OBJ3 := $(SRC3:%.c=$(BUILDDIR)/%.o)
OBJ4 := $(SRC4:%.c=$(BUILDDIR)/%.o)
OBJ5 := $(SRC5:%.c=$(BUILDDIR)/%.o)
OBJ6 := $(SRC6:%.c=$(BUILDDIR)/%.o)
OBJS := $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) $(OBJ5) $(OBJ6)
# targets ########################
# build all
build: $(EXEC1) $(EXEC2) $(EXEC3) $(EXEC4) $(EXEC5) $(EXEC6)
# run all
run: build
@echo "**************************************************"
@echo "Running all executables..."
@echo "**************************************************"
@echo ""
@./$(EXEC1)
@echo ""
@./$(EXEC2)
@echo ""
@./$(EXEC3)
@echo ""
@./$(EXEC4)
@echo ""
@./$(EXEC5)
@echo ""
@./$(EXEC6)
# compile/link: main
$(EXEC1): $(OBJ1)
@$(CC) $^ $(LDFLAGS) -o $@
# compile/link: main2
$(EXEC2): $(OBJ2)
@$(CC) $^ $(LDFLAGS) -o $@
# compile/link: buffer_test
$(EXEC3): $(OBJ3)
@$(CC) $^ $(LDFLAGS) -o $@
# compile/link: memset_test
$(EXEC4): $(OBJ4)
@$(CC) $^ $(LDFLAGS) -o $@
# compile/link: canbus_test
$(EXEC5): $(OBJ5)
@$(CC) $^ $(LDFLAGS) -o $@
# compile/link: canbus_test2
$(EXEC6): $(OBJ6)
@$(CC) $^ $(LDFLAGS) -o $@
# targets for each object
$(BUILDDIR)/%.o: %.c
@mkdir -p $(dir $@)
@$(CC) -c $< -o $@ $(CFLAGS) $(INCS)
# run: main
main: $(EXEC1)
@echo ""
@echo "**************************************************"
@echo "Running main..."
@echo "**************************************************"
@echo ""
@./$(EXEC1)
# run: main2
main2: $(EXEC2)
@echo ""
@echo "**************************************************"
@echo "Running main2..."
@echo "**************************************************"
@echo ""
@./$(EXEC2)
# run: buffer_test
buffer_test: $(EXEC3)
@echo ""
@echo "**************************************************"
@echo "Running buffer_test..."
@echo "**************************************************"
@echo ""
@./$(EXEC3)
# run: memset_test
memset_test: $(EXEC4)
@echo ""
@echo "**************************************************"
@echo "Running memset_test..."
@echo "**************************************************"
@echo ""
@./$(EXEC4)
# run: canbus_test
canbus_test: $(EXEC5)
@echo ""
@echo "**************************************************"
@echo "Running canbus_test..."
@echo "**************************************************"
@echo ""
@./$(EXEC5)
# run: canbus_test2
canbus_test2: $(EXEC6)
@echo ""
@echo "**************************************************"
@echo "Running canbus_test2..."
@echo "**************************************************"
@echo ""
@./$(EXEC6)
help:
@clear
@echo "******************** Targets *********************"
@echo "help: to print this menu"
@echo "build: to compile and link all sources (default)"
@echo "run: to run all the executables"
@echo "main: to run main"
@echo "main2: to run main2"
@echo "buffer_test: to run buffer_test"
@echo "memset_test: to run memset_test"
@echo "canbus_test: to run canbus_test"
@echo "canbus_test2: to run canbus_test2"
@echo "clean: to remove the build folder"
@echo "**************************************************"
@echo ""
clean:
@rm -rf $(BUILDDIR)
.PHONY: help build run main main2 buffer_test memset_test canbus_test \
canbus_test2 clean
-include $(OBJS:.o=.d)