-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGNUmakefile
328 lines (282 loc) · 14.6 KB
/
GNUmakefile
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
# DPS8M simulator: GNUmakefile
# vim: nocp:filetype=make:tabstop=4:ai:noet:cc=78:list:listchars=tab\:\>\-
# SPDX-License-Identifier: MIT-0
# scspell-id: bfdf848e-f631-11ec-9b72-80ee73e9b8e7
# Copyright (c) 2016 Charles Anthony
# Copyright (c) 2021-2024 Jeffrey H. Johnson
# Copyright (c) 2021-2025 The DPS8M Development Team
##############################################################################
# Build flags:
#
# <------------------- Maintain spacing and formatting -------------------->
#
# Build flag (ex: make V=1) Description of build flag
# #########################################################################
#
# ATOMICS=AIX|BSD|GNU|SYNC Define specific atomic operations
# CROSS=MINGW64 Enable MinGW-64 cross-compilation
# WITH_BACKTRACE=1 Enable building with libbacktrace
# NEED_128=1 Enable provided 128-bit int types
# NATIVE=1 Enable native arch/cpu via CFLAGS
# NO_LOCKLESS=1 Enable legacy (non-lockless) code
# NO_LTO=1 Disables the use of LTO for build
# NO_C_ELLIPSIS=1 Disables the C ellipsis extension
# PANEL68=1 Enable custom L68 panel interface
# PERF_STRIP=1 Enable CPU-only benchmarking mode
# ROUND_ROBIN=1 Enable non-threaded multiple CPUs
# TESTING=1 Enable developmental testing mode
# WITH_MGP_DEV=1 Enable (UNSTABLE) Chaosnet device
# WITH_ABSI_DEV=1 Enable (UNSTABLE) ABSI/IMP device
# DUMA=1 Enable the libDUMA malloc library
# V=1 Enable verbose compilation output
# W=1 Enable extra compilation warnings
#
# <------------------- Maintain spacing and formatting -------------------->
#
##############################################################################
.DEFAULT_GOAL := all
##############################################################################
# Pre-build setup
MAKE_TOPLEVEL = 1
ifneq (,$(wildcard src/Makefile.pre))
include src/Makefile.pre
ifdef OS_IBMAIX
export OS_IBMAIX
endif
endif
ifneq (,$(wildcard src/Makefile.mk))
include src/Makefile.mk
endif
export MAKE
export MAKE_TOPLEVEL
##############################################################################
# DPS8M Simulator
# XXXX: # ---------------------- DPS8/M Simulator --------------------
##############################################################################
##############################################################################
# Builds everything
.PHONY: build default all dps8 .rebuild.env
build default all dps8: .rebuild.env \
# build: # Builds the DPS8/M simulator and tools
-@$(PRINTF) '%s\n' "BUILD: Starting simulator and tools build" \
2> /dev/null || $(TRUE)
@$(SETV); $(MAKE) -s -C "." ".rebuild.env"; \
$(TEST) -f ".needrebuild" && $(MAKE) -C "." "clean" || $(TRUE); \
$(MAKE) -C "src/dps8" "all" && \
$(PRINTF) '%s\n' "BUILD: Successful simulator and tools build" \
2> /dev/null || $(TRUE)
##############################################################################
# Print build flags help
.PHONY: flags options .rebuild.env
ifneq (,$(findstring flags,$(MAKECMDGOALS)))
.NOTPARALLEL: flags
endif
ifneq (,$(findstring options,$(MAKECMDGOALS)))
.NOTPARALLEL: options
endif
options: \
# options: # Display help for optional build flags
-@$(PRINTF) '%s\n' "Optional build flags:" 2> /dev/null || $(TRUE)
-@$(PRINTF) '\n %s\n' "Usage: $(MAKE) { FLAG=VALUE ... }" \
2> /dev/null || $(TRUE)
-@$(PRINTF) '%s\n' " e.g. \"$(MAKE) TESTING=1 V=1 W=1\"" \
2> /dev/null || $(TRUE)
-@$(PRINTF) '\n%s\n' \
" Build flag (ex: make V=1) Description of build flag" \
2> /dev/null || $(TRUE)
-@$(PRINTF) ' %s ' \
"----------------------------------" \
" -------------------------------------" \
2> /dev/null || $(TRUE)
-@$(PRINTF) '\n%s\n' "" 2> /dev/null || $(TRUE)
@$(GREP) '^#.*=' "GNUmakefile" 2> /dev/null | \
$(GREP) -v 'vim:' 2> /dev/null | $(GREP) -v 'Build flag' \
2> /dev/null | $(SED) 's/^# //' 2> /dev/null || \
$(PRINTF) '%s\n' "Error: Unable to display help." || $(TRUE)
-@$(PRINTF) '%s\n' "" 2> /dev/null || $(TRUE)
##############################################################################
# Builds punutil tool
.PHONY: punutil .rebuild.env
punutil: .rebuild.env \
# punutil: # Builds the punch card conversion tool
-@$(PRINTF) '%s\n' "BUILD: Starting punutil build" 2> /dev/null || \
$(TRUE)
@$(MAKE) -s -C "." ".rebuild.env"; \
$(TEST) -f ".needrebuild" && $(MAKE) -C "." "clean" || $(TRUE); \
$(MAKE) -C "src/punutil" "all" && \
$(PRINTF) '%s\n' "BUILD: Successful punutil build" 2> /dev/null || \
$(TRUE)
##############################################################################
# Builds prt2pdf tool
.PHONY: prt2pdf .rebuild.env
prt2pdf: .rebuild.env \
# prt2pdf: # Builds the prt2pdf PDF rendering tool
-@$(PRINTF) '%s\n' "BUILD: Starting prt2pdf build" 2> /dev/null || \
$(TRUE)
@$(MAKE) -s -C "." ".rebuild.env"; \
$(TEST) -f ".needrebuild" && $(MAKE) -C "." "clean" || $(TRUE); \
$(MAKE) -C "src/prt2pdf" "all" && \
$(PRINTF) '%s\n' "BUILD: Successful prt2pdf build" 2> /dev/null || \
$(TRUE)
##############################################################################
# Builds mcmb tool
.PHONY: mcmb .rebuild.env
mcmb: .rebuild.env \
# mcmb: # Builds the minicmb combinatorics tool
-@$(PRINTF) '%s\n' "BUILD: Starting mcmb build" 2> /dev/null || $(TRUE)
-@$(MAKE) -s -C "." ".rebuild.env"; \
$(TEST) -f ".needrebuild" && $(MAKE) -C "." "clean" || $(TRUE); \
$(MAKE) -C "src/mcmb" "all" && \
$(PRINTF) '%s\n' "BUILD: Successful mcmb build" 2> /dev/null || \
$(TRUE)
##############################################################################
# Builds libsir
.PHONY: libsir .rebuild.env
libsir: .rebuild.env \
# libsir: # Builds the libsir logging library
-@$(PRINTF) '%s\n' "BUILD: Starting libsir build" 2> /dev/null || \
$(TRUE)
-@$(MAKE) -s -C "." ".rebuild.env"; \
$(TEST) -f ".needrebuild" && $(MAKE) -C "." "clean" || $(TRUE); \
$(MAKE) -C "src/dps8" "libsir" && \
$(PRINTF) '%s\n' "BUILD: Successful libsir build" \
2> /dev/null || $(TRUE)
##############################################################################
# Builds blinkenLights2
.PHONY: blinkenLights2 .rebuild.env
blinkenLights2: .rebuild.env \
# blinkenLights2: # Builds the blinkenLights2 front panel
-@$(PRINTF) '%s\n' "BUILD: Starting blinkenLights2 build" \
2> /dev/null || $(TRUE)
ifeq ($(V),1)
@$(SETV); $(MAKE) -s -C "." ".rebuild.env"; \
$(TEST) -f ".needrebuild" && $(RMF) blinkenLights2 || $(TRUE); \
( cd src/blinkenLights2 && $(ENV) VERBOSE=1 \
$(MAKE) ) && \
$(PRINTF) '%s\n' "BUILD: Successful blinkenLights2 build" \
2> /dev/null || $(TRUE)
else
@$(MAKE) -s -C "." ".rebuild.env"; \
$(TEST) -f ".needrebuild" && $(RMF) blinkenLights2 || $(TRUE); \
( cd src/blinkenLights2 && $(MAKE) ) && \
$(PRINTF) '%s\n' "BUILD: Successful blinkenLights2 build" \
2> /dev/null || $(TRUE)
endif
##############################################################################
# Install
.PHONY: install
ifneq (,$(findstring install,$(MAKECMDGOALS)))
.NOTPARALLEL: install
endif
install: \
# install: # Builds and installs the sim and tools
-@$(PRINTF) '%s\n' "BUILD: Starting install" || $(TRUE)
@$(MAKE) -C "src/dps8" "install" && \
$(PRINTF) '%s\n' "BUILD: Successful install" || $(TRUE)
##############################################################################
# Clean up compiled objects and executables
.PHONY: clean
ifneq (,$(findstring clean,$(MAKECMDGOALS)))
.NOTPARALLEL: clean
endif
clean: \
# clean: # Cleans up executable and object files
-@$(PRINTF) '%s\n' "BUILD: Starting clean" 2> /dev/null || $(TRUE)
@$(RMF) ".needrebuild" || $(TRUE)
@$(RMF) ".rebuild.vne" || $(TRUE)
@$(MAKE) -C "src/dps8" "clean" && \
$(PRINTF) '%s\n' "BUILD: Successful clean" 2> /dev/null || $(TRUE)
##############################################################################
# Cleans everything `clean` does, plus version info, logs, and state files
.PHONY: distclean
ifneq (,$(findstring clean,$(MAKECMDGOALS)))
.NOTPARALLEL: distclean
endif
distclean: clean \
# distclean: # Cleans up tree to pristine conditions
-@$(PRINTF) '%s\n' "BUILD: Starting distclean" 2> /dev/null || $(TRUE)
@$(RMF) ".needrebuild" || $(TRUE)
@$(RMF) ".rebuild.env" || $(TRUE)
@$(RMF) ".rebuild.vne" || $(TRUE)
@$(RMF) -rf "./out" || $(TRUE)
@$(RMF) "cppcheck.txt" || $(TRUE)
@$(RMF) "./orstlint.txt" || $(TRUE)
@$(RMF) -rf "./cppcheck" || $(TRUE)
@$(RMF) -rf "./pvsreport" || $(TRUE)
@$(RMF) -rf "./cov-int" || $(TRUE)
@$(RMF) -rf "./.coverity" || $(TRUE)
@$(RMF) -f "./log.pvs" || $(TRUE)
@$(RMF) -f "./compile_commands.json" || $(TRUE)
@$(RMF) "./"*".xml" || $(TRUE)
@$(RMDIR) "./.cppbdir" > /dev/null 2>&1 || $(TRUE)
@$(MAKE) -C "src/dps8" "distclean" && \
$(PRINTF) '%s\n' "BUILD: Successful distclean" 2> /dev/null || $(TRUE)
##############################################################################
# Cleans everything `distclean` does, plus attempts to flush compiler caches
.PHONY: superclean realclean reallyclean
ifneq (,$(findstring clean,$(MAKECMDGOALS)))
.NOTPARALLEL: superclean realclean reallyclean
endif
superclean realclean reallyclean: distclean \
# superclean: # Cleans up tree fully and flush ccache
-@$(PRINTF) '%s\n' "BUILD: Starting superclean" 2> /dev/null || $(TRUE)
@$(MAKE) -C "src/dps8" "superclean" && \
$(PRINTF) '%s\n' "BUILD: Successful superclean" 2> /dev/null || $(TRUE)
##############################################################################
ifneq (,$(wildcard src/Makefile.env))
include src/Makefile.env
endif
##############################################################################
# Help and Debugging Targets \
# XXXX: # --------------------- Help and Debugging -------------------
##############################################################################
ifneq (,$(wildcard src/Makefile.scc))
include src/Makefile.scc
endif
##############################################################################
ifneq (,$(wildcard src/Makefile.loc))
include src/Makefile.loc
endif
##############################################################################
ifneq (,$(wildcard src/Makefile.dev))
include src/Makefile.dev
endif
##############################################################################
ifneq (,$(wildcard src/Makefile.doc))
include src/Makefile.doc
endif
##############################################################################
ifneq (,$(wildcard src/Makefile.dep))
include src/Makefile.dep
endif
##############################################################################
# Print help output
.PHONY: help info
ifneq (,$(findstring help,$(MAKECMDGOALS)))
.NOTPARALLEL: help
endif
ifneq (,$(findstring info,$(MAKECMDGOALS)))
.NOTPARALLEL: info
endif
help info: \
# help: # Display this list of Makefile targets
@$(GREP) -E '^.* # .*: # .*$$' $(MAKEFILE_LIST) 2> /dev/null | \
$(AWK) 'BEGIN { FS = " # " }; \
{ printf "%s%-18s %-40s (%-19s)\n", $$1, $$2, $$3, $$1 }' \
2> /dev/null | $(CUT) -d ':' -f 2- 2> /dev/null | \
$(SED) -e 's/:\ \+)$$/)/' -e 's/XXXX:/\n/g' 2> /dev/null | \
$(SED) -e 's/---- (.*)$$/------------\n/' \
-e 's/: )/)/g' -e 's/: )/)/g' \
-e 's/ ---/-------------/' 2> /dev/null | \
$(GREP) -v 'GREP' 2> /dev/null | \
$(GREP) -v '_LIST' 2> /dev/null | $(SED) 's/^n//g' | \
$(SED) 's/n$$//g' || \
{ $(PRINTF) '%s\n' "Error: Unable to display help."; \
$(TRUE) > /dev/null 2>&1; } || \
$(TRUE) > /dev/null 2>&1
@$(PRINTF) '%s\n' "" 2> /dev/null || $(TRUE) > /dev/null 2>&1
##############################################################################
# Local Variables:
# mode: make
# tab-width: 4
# End: