forked from freedoom/freedoom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
349 lines (289 loc) · 13.4 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
# SPDX-License-Identifier: BSD-3-Clause
VERSION=$(shell git describe --abbrev=8 --dirty 2>/dev/null || echo v0.14.0-alpha-unknown)
WADS=wads
ASCIIDOC=asciidoc
ADOCOPTS=--backend=html5 --conf-file=.adoc-layout.conf
ASCIIDOC_MAN=a2x -f manpage
CPP=scripts/simplecpp
DEUTEX=deutex
DEUTEX_BASIC_ARGS=-v0 -rate accept
DEUTEX_ARGS=$(DEUTEX_BASIC_ARGS) -doom2 bootstrap/
NODE_BUILDER=ZenNode
NODE_BUILDER_LEVELS=e?m? dm?? map??
LEGACY_TRANSPARENCY_INDEX=255
LEGACY_TRANSPARENCY_REPLACEMENT=133
MANUAL_ADOC_FILES=$(wildcard manual/freedoom-manual-??.adoc)
MANUAL_PDF_FILES=$(subst .adoc,.pdf,$(MANUAL_ADOC_FILES))
FREEDOOM1=$(WADS)/freedoom1.wad
FREEDOOM2=$(WADS)/freedoom2.wad
FREEDM=$(WADS)/freedm.wad
OBJS=$(FREEDM) $(FREEDOOM1) $(FREEDOOM2)
.PHONY: clean dist pngs-modified-check
all: deutex-check $(OBJS)
subdirs:
$(MAKE) -C lumps/dehacked # graphics/text depends on generated dehacked files
$(MAKE) VERSION=$(VERSION) -C graphics/text
$(MAKE) -C lumps/playpal
$(MAKE) -C lumps/colormap
$(MAKE) -C lumps/genmidi
$(MAKE) -C lumps/dmxgus
$(MAKE) -C lumps/textures
$(MAKE) -C bootstrap
# this is a useless dependency to force builds
force:
lumps/freedoom.lmp lumps/freedm.lmp: force
echo $(VERSION) > $@
# deutex doesnt allow redirects for the filenames in the texture
# entries, so we have to change the texture1 symlink to point
# to whichever wad we are working on
#---------------------------------------------------------
# Build checks
# Make sure deutex supports PNG
deutex-check:
@$(DEUTEX) -h | grep -qw PNG || { \
echo "$(DEUTEX) does not support PNG. Try building deutex with the PNG"; \
echo "libraries (libpng and libpng-devel or similar packages) installed."; \
echo "deutex can be downloaded from https://github.com/Doom-Utils/deutex."; \
echo "The full path to duetex can be specified by passing"; \
echo "DEUTEX=/the/path/to/deutex to make when building Freedoom."; \
exit 1; }
# Make sure that no PNG files are modified if scripts are to modify them.
pngs-modified-check:
@{ ! git status -s | grep -q \\.png$ ; } || { \
echo "PNG fix targets can not be run if there are modified PNGs." ; \
exit 1; }
#---------------------------------------------------------
# freedm iwad
wadinfo_freedm.txt : buildcfg.txt subdirs lumps/freedoom.lmp lumps/freedm.lmp
$(CPP) -P -DFREEDM < $< > $@
$(FREEDM): wadinfo_freedm.txt subdirs
@mkdir -p $(WADS)
$(RM) $@
$(DEUTEX) $(DEUTEX_ARGS) -iwad -build wadinfo_freedm.txt $@
#---------------------------------------------------------
# phase 1 (udoom) iwad
wadinfo_phase1.txt: buildcfg.txt subdirs lumps/freedoom.lmp
$(CPP) -P -DPHASE1 < $< > $@
$(FREEDOOM1): wadinfo_phase1.txt subdirs
@mkdir -p $(WADS)
$(RM) $@
$(DEUTEX) $(DEUTEX_ARGS) -iwad -build wadinfo_phase1.txt $@
#---------------------------------------------------------
# phase 2 (doom2) iwad
wadinfo_phase2.txt: buildcfg.txt subdirs lumps/freedoom.lmp
$(CPP) -P -DPHASE2 < $< > $@
$(FREEDOOM2): wadinfo_phase2.txt subdirs
@mkdir -p $(WADS)
$(RM) $@
$(DEUTEX) $(DEUTEX_ARGS) -iwad -build wadinfo_phase2.txt $@
%.html: %.adoc
$(ASCIIDOC) $(ADOCOPTS) $<
manual/freedoom-manual-%.pdf: manual/freedoom-manual-%.adoc
$(MAKE) -C manual $(subst manual/,,$@)
COPYING.txt: COPYING.adoc
unix2dos --add-bom --newfile $< $@
CREDITS.txt: CREDITS
unix2dos --add-bom --newfile $< $@
CREDITS-LEVELS.txt: CREDITS-LEVELS
unix2dos --add-bom --newfile $< $@
CREDITS-MUSIC.txt: CREDITS-MUSIC
unix2dos --add-bom --newfile $< $@
HTMLDOCS=NEWS.html README.html
TEXTDOCS=COPYING.txt CREDITS.txt CREDITS-LEVELS.txt CREDITS-MUSIC.txt
DISTDOCS=$(HTMLDOCS) $(TEXTDOCS) $(MANUAL_PDF_FILES)
dist: $(OBJS) $(DISTDOCS)
LC_ALL=C VERSION=$(VERSION) scripts/makepkgs freedm $(FREEDM) $(DISTDOCS)
LC_ALL=C VERSION=$(VERSION) scripts/makepkgs freedoom $(FREEDOOM1) $(FREEDOOM2) $(DISTDOCS)
json: $(OBJS)
ifndef JSON
@echo "Define JSON as the file to output." >&2
@exit 1
else
JSON=$(JSON) VERSION=$(VERSION) scripts/makejson
endif
doom.gpl: lumps/playpal/playpal-base.lmp
$(MAKE) -C lumps/playpal $@
mv lumps/playpal/$@ .
gimp-palette: doom.gpl
clean:
$(RM) *.html doom.gpl $(OBJS) \
./COPYING.txt ./CREDITS.txt ./CREDITS-LEVELS.txt ./CREDITS-MUSIC.txt \
./wadinfo_phase1.txt \
./wadinfo_phase2.txt \
./wadinfo_freedm.txt \
./lumps/freedoom.lmp \
./lumps/freedm.lmp
-rmdir $(WADS)
$(MAKE) -C bootstrap clean
$(MAKE) -C dist clean
$(MAKE) -C graphics/text clean
$(MAKE) -C lumps/dehacked clean
$(MAKE) -C lumps/playpal clean
$(MAKE) -C lumps/colormap clean
$(MAKE) -C lumps/genmidi clean
$(MAKE) -C lumps/dmxgus clean
$(MAKE) -C lumps/textures clean
$(MAKE) -C manual clean
# Test targets some of which are a dependency of "test".
# Test that the level WAD files have the expected map names.
test-map-names:
scripts/test-vanilla-compliance -n levels
# Test that the level WAD files have vanilla compliance. This is a superset of
# the "test-map-names" build target.
test-vanilla-compliance:
scripts/test-vanilla-compliance levels
# Run all tests. Add test-* targets above, and then as a dependency here.
test: test-vanilla-compliance
@echo
@echo "All tests passed."
# Fix targets some of which are a dependency of "fix".
# Fix the level WAD files so that they have the expected map names.
fix-map-names:
scripts/test-vanilla-compliance -fn levels
# Fix the level WAD files so that they have vanilla compliance. This is a
# superset of the "fix-map-names" build target.
fix-vanilla-compliance:
scripts/test-vanilla-compliance -f levels
# TODO: I'm not sure we want to run this routinely, but I thought I'd put it
# here for completeness. Currently it makes a lot of changes to buildcfg.txt
# that don't have an obvious impact. Consequently "fix" does not depend on this
# target. Just delete this TODO and target if we don't want this. Maybe add a
# proper description in any case.
fix-gfx-offsets:
scripts/fix-gfx-offsets sprites/*.png
# Overwrite PNGs with what deutex extracts from the WADs produced.
fix-deutex-pngs: pngs-modified-check
scripts/fix-deutex-pngs $(OBJS)
# For each PNG replace the legacy transparency index with a similar color, but
# only if the PNG matches the playpal palette specified. It may be helpful to
# run target fix-deutex-pngs before this one.
fix-legacy-transparency-pngs: pngs-modified-check
scripts/map-color-index -p lumps/playpal/playpal-base.lmp . \
$(LEGACY_TRANSPARENCY_INDEX) $(LEGACY_TRANSPARENCY_REPLACEMENT)
# Fix targets that fix PNGs. Note that because of the interaction between the
# scripts that are run it can be necessary to run this more than once:
# make # Optional, but make sure the IWADs (wads dir) is up-to-date.
# make fix-pngs
# git commit -m 'Fix the PNGs' -- '*.png' # So the tree is clean for the next run.
# make # Required - so the IWADs are updated.
# make fix-pngs
# git commit --amend --no-edit -- '*.png'
# make # Optional - the PNGs should be stable.
# make fix-pngs # Optional - should not have an effect.
# The final invocation of "fix-pngs" is not needed, but doing so, and seeing
# a clean build tree, is reassuring. If "fix-pngs" needs to be run more than
# twice then something is wrong.
fix-pngs: fix-deutex-pngs fix-legacy-transparency-pngs
# Run all fixes. Add fix-* targets above, and then as a dependency here.
fix: fix-vanilla-compliance fix-pngs
@echo
@echo "All fixable errors fixed."
# Rebuild the nodes for the level WADs. By default this invokes "ZenNode" on
# all 100 level WADs. Override the "NODE_BUILDER" prefixed variables to
# configure.
rebuild-nodes: $(addprefix levels/,$(addsuffix .wad,$(NODE_BUILDER_LEVELS)))
for level in $^; \
do \
$(NODE_BUILDER) $$level -o $$level; \
done
# Update feed.mxl (RSS feed) on the website based on NEWS.adoc. This assumes
# that the website has the same parent directory as this build.
news-to-feed: NEWS.adoc
scripts/news-to-feed NEWS.adoc ../freedoom.github.io/feed.xml
%.6:
$(MAKE) ASCIIDOC_MAN="$(ASCIIDOC_MAN)" -C dist $@
%.png:
$(MAKE) -C dist $@
prefix?=/usr/local
bindir?=/bin
docdir?=/share/doc
mandir?=/share/man
waddir?=/share/games/doom
target=$(DESTDIR)$(prefix)
install-freedm: $(FREEDM) $(HTMLDOCS) $(MANUAL_PDF_FILES) \
freedm.6 io.github.freedoom.FreeDM.png
install -Dm 644 dist/io.github.freedoom.FreeDM.desktop \
-t "$(target)/share/applications"
install -Dm 644 dist/io.github.freedoom.FreeDM.metainfo.xml \
-t "$(target)/share/metainfo"
install -Dm 755 dist/freedoom "$(target)$(bindir)/freedm"
install -Dm 644 dist/freedm.6 -t "$(target)$(mandir)/man6"
install -Dm 644 $(FREEDM) -t "$(target)$(waddir)"
install -Dm 644 dist/io.github.freedoom.FreeDM.png \
-t "$(target)/share/icons"
install -Dm 644 CREDITS CREDITS-LEVELS CREDITS-MUSIC NEWS.html README.html -t "$(target)$(docdir)/freedm"
install -Dm 644 COPYING.adoc "$(target)$(docdir)/freedm/COPYING"
-install -Dm 644 $(MANUAL_PDF_FILES) -t "$(target)$(docdir)/freedm"
install-freedoom: $(FREEDOOM1) $(FREEDOOM2) $(HTMLDOCS) \
$(MANUAL_PDF_FILES) freedoom1.6 freedoom2.6 \
io.github.freedoom.Phase1.png \
io.github.freedoom.Phase2.png
install -Dm 644 dist/io.github.freedoom.Phase1.desktop \
-t "$(target)/share/applications"
install -Dm 644 dist/io.github.freedoom.Phase2.desktop \
-t "$(target)/share/applications"
install -Dm 644 dist/io.github.freedoom.Phase1.metainfo.xml \
-t "$(target)/share/metainfo"
install -Dm 644 dist/io.github.freedoom.Phase2.metainfo.xml \
-t "$(target)/share/metainfo"
install -Dm 755 dist/freedoom "$(target)$(bindir)/freedoom1"
install -Dm 755 dist/freedoom "$(target)$(bindir)/freedoom2"
install -Dm 644 dist/freedoom1.6 -t "$(target)$(mandir)/man6"
install -Dm 644 dist/freedoom2.6 -t "$(target)$(mandir)/man6"
install -Dm 644 $(FREEDOOM1) $(FREEDOOM2) -t "$(target)$(waddir)"
install -Dm 644 dist/io.github.freedoom.Phase1.png \
-t "$(target)/share/icons"
install -Dm 644 dist/io.github.freedoom.Phase2.png \
-t "$(target)/share/icons"
install -Dm 644 CREDITS CREDITS-LEVELS CREDITS-MUSIC NEWS.html README.html \
-t "$(target)$(docdir)/freedoom"
install -Dm 644 COPYING.adoc "$(target)$(docdir)/freedoom/COPYING"
-install -Dm 644 $(MANUAL_PDF_FILES) -t "$(target)$(docdir)/freedoom"
# For the following uninstall targets the manual arguments are intentionally
# not quoted since they are wildcards.
uninstall-freedm:
$(RM) \
"$(target)/share/applications/io.github.freedoom.FreeDM.desktop" \
"$(target)/share/metainfo/io.github.freedoom.FreeDM.metainfo.xml" \
"$(target)/share/icons/io.github.freedoom.FreeDM.png" \
"$(target)$(bindir)/freedm" \
"$(target)$(mandir)/man6/freedm.6" \
"$(target)$(waddir)/freedm.wad" \
"$(target)$(docdir)/freedm/CREDITS" \
"$(target)$(docdir)/freedm/CREDITS-LEVELS" \
"$(target)$(docdir)/freedm/CREDITS-MUSIC" \
"$(target)$(docdir)/freedm/COPYING" \
"$(target)$(docdir)/freedm/NEWS.html" \
"$(target)$(docdir)/freedm/README.html" \
$(target)$(docdir)/freedm/freedoom-manual-??.pdf
-rmdir -p "$(target)/share/applications" \
"$(target)/share/metainfo" "$(target)/share/icons" \
"$(target)$(bindir)" "$(target)$(mandir)/man6" \
"$(target)$(waddir)" "$(target)$(docdir)/freedm"
uninstall-freedoom:
$(RM) \
"$(target)/share/applications/io.github.freedoom.Phase1.desktop" \
"$(target)/share/applications/io.github.freedoom.Phase2.desktop" \
"$(target)/share/metainfo/io.github.freedoom.Phase1.metainfo.xml" \
"$(target)/share/metainfo/io.github.freedoom.Phase2.metainfo.xml" \
"$(target)/share/icons/io.github.freedoom.Phase1.png" \
"$(target)/share/icons/io.github.freedoom.Phase2.png" \
"$(target)$(bindir)/freedoom1" \
"$(target)$(bindir)/freedoom2" \
"$(target)$(mandir)/man6/freedoom1.6" \
"$(target)$(mandir)/man6/freedoom2.6" \
"$(target)$(waddir)/freedoom1.wad" \
"$(target)$(waddir)/freedoom2.wad" \
"$(target)$(docdir)/freedoom/CREDITS" \
"$(target)$(docdir)/freedoom/CREDITS-LEVELS" \
"$(target)$(docdir)/freedoom/CREDITS-MUSIC" \
"$(target)$(docdir)/freedoom/COPYING" \
"$(target)$(docdir)/freedoom/NEWS.html" \
"$(target)$(docdir)/freedoom/README.html" \
$(target)$(docdir)/freedoom/freedoom-manual-??.pdf
-rmdir -p "$(target)/share/applications" \
"$(target)/share/metainfo" "$(target)/share/icons" \
"$(target)$(bindir)" "$(target)$(mandir)/man6" \
"$(target)$(waddir)" "$(target)$(docdir)/freedoom"
install: install-freedm install-freedoom
uninstall: uninstall-freedm uninstall-freedoom