forked from bacnet-stack/bacnet-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
384 lines (301 loc) · 8.25 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# Main Makefile for BACnet-stack applications, tests, and sample ports
# Export the variables defined here to all subprocesses
# (see http://www.gnu.org/software/automake/manual/make/Special-Targets.html)
.EXPORT_ALL_VARIABLES:
# all: demos router-ipv6 ${DEMO_LINUX}
.PHONY: all
all: apps
.PHONY: bsd
bsd:
$(MAKE) BACNET_PORT=bsd -s -C apps all
.PHONY: win32
win32:
$(MAKE) BACNET_PORT=win32 -s -C apps all
.PHONY: mstpwin32
mstpwin32:
$(MAKE) BACDL=mstp BACNET_PORT=win32 -s -C apps all
.PHONY: mstp
mstp:
$(MAKE) BACDL=mstp -s -C apps all
.PHONY: bip6-win32
bip6-win32:
$(MAKE) BACDL=bip6 BACNET_PORT=win32 -s -C apps all
.PHONY: bip6
bip6:
$(MAKE) BACDL=bip6 -s -C apps all
.PHONY: bip
bip:
$(MAKE) BACDL=bip -s -C apps all
.PHONY: bip-client
bip-client:
$(MAKE) BACDL=bip BBMD=client -s -C apps all
.PHONY: ethernet
ethernet:
$(MAKE) BACDL=ethernet -s -C apps all
.PHONY: apps
apps:
$(MAKE) -s -C apps all
.PHONY: lib
lib:
$(MAKE) -s -C apps $@
CMAKE_BUILD_DIR=build
.PHONY: cmake
cmake:
[ -d $(CMAKE_BUILD_DIR) ] || mkdir -p $(CMAKE_BUILD_DIR)
[ -d $(CMAKE_BUILD_DIR) ] && cd $(CMAKE_BUILD_DIR) && cmake .. -DBUILD_SHARED_LIBS=ON && cmake --build . --clean-first
.PHONY: cmake-win32
cmake-win32:
mkdir -p $(CMAKE_BUILD_DIR)
cd $(CMAKE_BUILD_DIR) && cmake ../ -DBACNET_STACK_BUILD_APPS=ON && cmake --build ./ --clean-first
cp $(CMAKE_BUILD_DIR)/Debug/*.exe ./bin/.
.PHONY: abort
abort:
$(MAKE) -s -C apps $@
.PHONY: ack-alarm
ack-alarm:
$(MAKE) -s -C apps $@
.PHONY: add-list-element
add-list-element:
$(MAKE) -s -C apps $@
.PHONY: blinkt
blinkt:
$(MAKE) -s -C apps $@
.PHONY: dcc
dcc:
$(MAKE) -s -C apps $@
.PHONY: epics
epics:
$(MAKE) -s -C apps $@
.PHONY: error
error:
$(MAKE) -s -C apps $@
.PHONY: event
event:
$(MAKE) -s -C apps $@
.PHONY: iam
iam:
$(MAKE) -s -C apps $@
.PHONY: getevent
getevent:
$(MAKE) -s -C apps $@
.PHONY: gateway
gateway:
$(MAKE) -s -C apps $@
.PHONY: gateway-win32
gateway-win32:
$(MAKE) BACNET_PORT=win32 -s -C apps gateway
.PHONY: piface
piface:
$(MAKE) CSTANDARD="-std=gnu11" LEGACY=true -s -C apps $@
.PHONY: readbdt
readbdt:
$(MAKE) -s -C apps $@
.PHONY: readfdt
readfdt:
$(MAKE) -s -C apps $@
.PHONY: readprop
readprop:
$(MAKE) -s -C apps $@
.PHONY: readpropm
readpropm:
$(MAKE) -s -C apps $@
.PHONY: remove-list-element
remove-list-element:
$(MAKE) -s -C apps $@
.PHONY: writebdt
writebdt:
$(MAKE) -s -C apps $@
.PHONY: whatisnetnum
whatisnetnum:
$(MAKE) -s -C apps $@
.PHONY: netnumis
netnumis:
$(MAKE) -s -C apps $@
.PHONY: server
server:
$(MAKE) -s -C apps $@
.PHONY: mstpcap
mstpcap:
$(MAKE) -s -C apps $@
.PHONY: mstpcrc
mstpcrc:
$(MAKE) -s -C apps $@
.PHONY: uevent
uevent:
$(MAKE) -s -C apps $@
.PHONY: whois
whois:
$(MAKE) -s -C apps $@
.PHONY: writepropm
writepropm:
$(MAKE) -s -C apps $@
.PHONY: router
router:
$(MAKE) -s -C apps $@
.PHONY: router-ipv6
router-ipv6:
$(MAKE) -s -C apps $@
.PHONY: router-mstp
router-mstp:
$(MAKE) -s -C apps $@
.PHONY: fuzz-libfuzzer
fuzz-libfuzzer:
$(MAKE) -s -C apps $@
.PHONY: fuzz-afl
fuzz-afl:
$(MAKE) -s -C apps $@
# Add "ports" to the build, if desired
.PHONY: ports
ports: atmega168 bdk-atxx4-mstp at91sam7s stm32f10x stm32f4xx
@echo "Built the ARM7 and AVR ports"
.PHONY: ports-clean
ports-clean: atmega168-clean bdk-atxx4-mstp-clean at91sam7s-clean \
stm32f10x-clean stm32f4xx-clean xplained-clean
.PHONY: atmega168
atmega168: ports/atmega168/Makefile
$(MAKE) -s -C ports/atmega168 clean all
.PHONY: atmega168-clean
atmega168-clean: ports/atmega168/Makefile
$(MAKE) -s -C ports/atmega168 clean
.PHONY: bdk-atxx4-mstp
bdk-atxx4-mstp: ports/bdk-atxx4-mstp/Makefile
$(MAKE) -s -C ports/bdk-atxx4-mstp clean all
.PHONY: bdk-atxx4-mstp-clean
bdk-atxx4-mstp-clean: ports/bdk-atxx4-mstp/Makefile
$(MAKE) -s -C ports/bdk-atxx4-mstp clean
.PHONY: at91sam7s
at91sam7s: ports/at91sam7s/Makefile
$(MAKE) -s -C ports/at91sam7s clean all
.PHONY: at91sam7s-clean
at91sam7s-clean: ports/at91sam7s/Makefile
$(MAKE) -s -C ports/at91sam7s clean
.PHONY: stm32f10x
stm32f10x: ports/stm32f10x/Makefile
$(MAKE) -s -C ports/stm32f10x clean all
.PHONY: stm32f10x-clean
stm32f10x-clean: ports/stm32f10x/Makefile
$(MAKE) -s -C ports/stm32f10x clean
.PHONY: stm32f4xx
stm32f4xx: ports/stm32f4xx/Makefile
$(MAKE) -s -C ports/stm32f4xx clean all
.PHONY: stm32f4xx-clean
stm32f4xx-clean: ports/stm32f4xx/Makefile
$(MAKE) -s -C ports/stm32f4xx clean
.PHONY: xplained
xplained: ports/xplained/Makefile
$(MAKE) -s -C ports/xplained clean all
.PHONY: xplained-clean
xplained-clean: ports/xplained/Makefile
$(MAKE) -s -C ports/xplained clean
.PHONY: mstpsnap
mstpsnap: ports/linux/mstpsnap.mak
$(MAKE) -s -C ports/linux -f mstpsnap.mak clean all
.PHONY: lwip
lwip: ports/lwip/Makefile
$(MAKE) -s -C ports/lwip clean all
.PHONY: pretty
pretty:
find ./src -iname *.h -o -iname *.c -exec \
clang-format -i -style=file -fallback-style=none {} \;
find ./apps -iname *.h -o -iname *.c -exec \
clang-format -i -style=file -fallback-style=none {} \;
.PHONY: pretty-apps
pretty-apps:
find ./apps -iname *.h -o -iname *.c -exec \
clang-format -i -style=file -fallback-style=none {} \;
.PHONY: pretty-ports
pretty-ports:
find ./ports -maxdepth 2 -type f -iname *.h -o -iname *.c -exec \
clang-format -i -style=file -fallback-style=none {} \;
.PHONY: pretty-test
pretty-test:
find ./test/bacnet -maxdepth 2 -type f -iname *.h -o -iname *.c -exec \
clang-format -i -style=file -fallback-style=none {} \;
CLANG_TIDY_OPTIONS = -fix-errors -checks="readability-braces-around-statements"
CLANG_TIDY_OPTIONS += -- -Isrc -Iports/linux
.PHONY: tidy
tidy:
find ./src -iname *.h -o -iname *.c -exec clang-tidy {} $(CLANG_TIDY_OPTIONS) \;
find ./apps -iname *.c -exec clang-tidy {} $(CLANG_TIDY_OPTIONS) \;
.PHONY: scan-build
scan-build:
scan-build --status-bugs -analyze-headers make -j2 LEGACY=true server
SPLINT_OPTIONS := -weak +posixlib +quiet \
-D__signed__=signed -D__gnuc_va_list=va_list \
-Isrc -Iports/linux \
+matchanyintegral +ignoresigns -unrecog -preproc \
+error-stream-stderr +warning-stream-stderr -warnposix \
-bufferoverflowhigh
SPLINT_FIND_OPTIONS := ./src -path ./src/bacnet/basic/ucix -prune -o -name "*.c"
.PHONY: splint
splint:
find $(SPLINT_FIND_OPTIONS) -exec splint $(SPLINT_OPTIONS) {} \;
CPPCHECK_OPTIONS = --enable=warning,portability
CPPCHECK_OPTIONS += --template=gcc
CPPCHECK_OPTIONS += --inline-suppr
CPPCHECK_OPTIONS += --suppress=selfAssignment
CPPCHECK_OPTIONS += --suppress=integerOverflow
CPPCHECK_OPTIONS += --error-exitcode=1
.PHONY: cppcheck
cppcheck:
cppcheck $(CPPCHECK_OPTIONS) --quiet --force ./src/
.PHONY: flawfinder
flawfinder:
flawfinder --minlevel 5 --error-level=5 ./src/
IGNORE_WORDS = ba,statics
CODESPELL_OPTIONS = --write-changes --interactive 3 --enable-colors
CODESPELL_OPTIONS += --ignore-words-list $(IGNORE_WORDS)
.PHONY: codespell
codespell:
codespell $(CODESPELL_OPTIONS) ./src
SPELL_OPTIONS = --enable-colors --ignore-words-list $(IGNORE_WORDS)
.PHONY: spell
spell:
codespell $(SPELL_OPTIONS) ./src
# McCabe's Cyclomatic Complexity Scores
# sudo apt install pmccable
COMPLEXITY_SRC = \
$(wildcard ./src/bacnet/*.c) \
$(wildcard ./src/bacnet/basic/*.c) \
$(wildcard ./src/bacnet/basic/binding/*.c) \
$(wildcard ./src/bacnet/basic/service/*.c) \
$(wildcard ./src/bacnet/basic/sys/*.c) \
./src/bacnet/basic/npdu/h_npdu.c \
./src/bacnet/basic/npdu/s_router.c \
./src/bacnet/basic/tsm/tsm.c
.PHONY: pmccabe
pmccabe:
pmccabe $(COMPLEXITY_SRC) | awk '{print $$2,$$6,$$7}' | sort -nr | head -20
# sudo apt install complexity
# 0-9 Easily maintained code.
# 10-19 Maintained with little trouble.
# 20-29 Maintained with some effort.
# 30-39 Difficult to maintain code.
# 40-49 Hard to maintain code.
# 50-99 Unmaintainable code.
# 100-199 Crazy making difficult code.
# 200+ I only wish I were kidding.
.PHONY: complexity
complexity:
complexity $(COMPLEXITY_SRC)
# sudo apt install sloccount
.PHONY: sloccount
sloccount:
sloccount .
.PHONY: clean
clean: ports-clean
$(MAKE) -s -C src clean
$(MAKE) -s -C apps clean
$(MAKE) -s -C apps/router clean
$(MAKE) -s -C apps/router-ipv6 clean
$(MAKE) -s -C apps/router-mstp clean
$(MAKE) -s -C apps/gateway clean
$(MAKE) -s -C apps/fuzz-afl clean
$(MAKE) -s -C apps/fuzz-libfuzzer clean
$(MAKE) -s -C ports/lwip clean
$(MAKE) -s -C test clean
rm -rf ./build
.PHONY: test
test:
$(MAKE) -s -C test clean
$(MAKE) -s -j -C test all