forked from y-salnikov/ironseed_fpc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
321 lines (259 loc) · 17.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
DESTDIR ?=
prefix ?= /usr/local
bindir ?= $(prefix)/games
libdir ?= $(prefix)/lib/games/ironseed
sharedir ?= $(prefix)/share/games/ironseed
docdir ?= $(prefix)/share/doc/ironseed
CC ?= gcc
p_compiler:= fpc
d_compiler = gdc -g -o $@
#d_compiler = ldc2 -g -check-printf-calls
PFLAGS:= -Mtp -g -gl -gv
#-Aas -ap
fpc_debug:= -C3 -Ci -Co -CO -O1 -gw -godwarfsets -gt -vewnhiq -Sa -Sy -Sewnh -vm4049
# -O- -Cr -CR -Ct -gh -gc -dDEBUG -dTrace
p_link:= -k-lSDL_mixer -k-lSDL -k-lm
c_includes:=`sdl-config --cflags` -I /usr/X11R6/include
CFLAGS += -g -Wall -W -pedantic -Wno-unused-parameter -Wconversion $(c_includes)
# PIE etc. hardening wanted by Debian - see https://wiki.debian.org/Hardening
p_link += -k'-z relro' -k'-z now' -k-pie
PFLAGS += -fPIC
CFLAGS += -fpic -D_FORTIFY_SOURCE=2
rebuild: clean all cleantmp
# default target to build, best is debug_sdl / debug_ogl (NOT "release_xxx" AKA "no-checks" versions!)
all: clearpaths debug_sdl1
cleanbuild: clean build cleantmp
# OpenGL no-checks version
release_ogl debug_ogl1: p_link += -k-lGL -k-lGLU
release_ogl: CFLAGS += -O -DNDEBUG
release_ogl: cleanbuild
# OpenGL debug version
debug_ogl: clean debug_ogl1 cleantmp
debug_ogl1: CFLAGS += -O1 -Werror
debug_ogl1: PFLAGS += $(fpc_debug)
debug_ogl1: build
# SDL no-checks version
release_sdl: CFLAGS += -O -DNDEBUG -DNO_OGL
release_sdl: cleanbuild
# SDL debug version
debug_sdl1 demo_sdl1 data_build Data_Generators/makedata/iconmake Data_Generators/makedata/makeani Data_Generators/makedata/shp2make: CFLAGS += -O1 -DNO_OGL -Werror
debug_sdl: clean debug_sdl1 cleantmp
debug_sdl1: PFLAGS += $(fpc_debug)
debug_sdl1: build
# DEMO SDL debug version
demo_sdl: clean demo_sdl1 cleantmp
demo_sdl1: PFLAGS += $(fpc_debug) -dDEMO
demo_sdl1: build
PROG_FILES = is crewgen intro main
DATA_TOOLS_D = Data_Generators/makedata/convmake Data_Generators/makedata/logmake
DATA_TOOLS_P = Data_Generators/makedata/aliemake Data_Generators/makedata/artimake Data_Generators/makedata/cargmake Data_Generators/makedata/creamake Data_Generators/makedata/crewmake Data_Generators/makedata/elemmake Data_Generators/makedata/eventmak Data_Generators/makedata/itemmake Data_Generators/makedata/makename Data_Generators/makedata/scanmake Data_Generators/makedata/shipmake Data_Generators/makedata/sysmake Data_Generators/makedata/weapmake Data_Generators/makedata/iconmake Data_Generators/makedata/namemake Data_Generators/makedata/makeani Data_Generators/makedata/shp2make Data_Generators/misc/scr2cpr Data_Generators/misc/cpr2scr Data_Generators/misc/cpr2tga Data_Generators/misc/tga2cpr
CREWCONVS := data/conv0001.dta data/conv0002.dta data/conv0003.dta data/conv0004.dta data/conv0005.dta data/conv0006.dta
RACECONVS := data/conv1001.dta data/conv1002.dta data/conv1003.dta data/conv1004.dta data/conv1005.dta data/conv1006.dta data/conv1007.dta data/conv1008.dta data/conv1009.dta data/conv1010.dta data/conv1011.dta
SPECCONVS := data/conv1100.dta data/conv1101.dta data/conv1102.dta data/conv1103.dta data/conv1000.dta
CPR_CREW0 := data/image01.cpr data/image02.cpr data/image03.cpr data/image04.cpr data/image05.cpr data/image06.cpr data/image07.cpr data/image08.cpr data/image09.cpr data/image10.cpr data/image11.cpr data/image12.cpr data/image13.cpr data/image14.cpr data/image15.cpr data/image16.cpr data/image17.cpr data/image18.cpr data/image19.cpr data/image20.cpr data/image21.cpr data/image22.cpr data/image23.cpr data/image24.cpr data/image25.cpr data/image26.cpr data/image27.cpr data/image28.cpr data/image29.cpr data/image30.cpr data/image31.cpr data/image32.cpr
CPR_MISC0 := data/trade.cpr data/end6.cpr data/waricon.cpr data/cloud.cpr Data_Generators/makedata/charani.cpr Data_Generators/makedata/shippart.cpr
CPR_SELFPAL1 := data/main.cpr data/main3.cpr data/end1.cpr data/end2.cpr data/end3.cpr data/end4.cpr data/end5.cpr data/alien.cpr data/alien1.cpr data/alien2.cpr data/alien3.cpr data/alien4.cpr data/alien5.cpr data/alien6.cpr data/alien7.cpr data/alien8.cpr data/alien9.cpr data/alien10.cpr data/demoscr2.cpr data/demoscr3.cpr data/demoscr4.cpr data/demoscrn.cpr data/cargo.cpr data/channel7.cpr data/fight.cpr data/intro2.cpr data/intro3.cpr data/intro5.cpr data/intro6.cpr data/battle1.cpr data/charcom.cpr data/saver.cpr data/ship1.cpr data/world.cpr data/char.cpr data/tech1.cpr data/sector.cpr data/landform.cpr data/psyche.cpr data/char2.cpr data/com.cpr data/log.cpr data/back1.cpr data/back2.cpr data/back3.cpr data/back4.cpr data/back5.cpr data/back6.cpr data/back7.cpr data/back8.cpr data/back9.cpr data/back10.cpr data/back11.cpr Data_Generators/makedata/planicon.cpr
IMG_FILES := data/main.pal $(CPR_SELFPAL1) $(CPR_CREW0) $(CPR_MISC0)
DATA_FILES := data/log.dta data/titles.dta $(CREWCONVS) $(RACECONVS) $(SPECCONVS) $(IMG_FILES) data/iteminfo.dta data/cargo.dta data/creation.dta data/scan.dta data/sysname.dta data/contact0.dta data/crew.dta data/artifact.dta data/elements.dta data/event.dta data/weapon.dta data/weapicon.dta data/planicon.dta data/ships.dta data/planname.txt data/icons.vga data/charani.dta data/shippix.dta data/plan1.dta data/sysset.dta
build: $(PROG_FILES) $(DATA_FILES)
c_utils.o: Makefile c_utils.c
$(CC) $(CFLAGS) -c c_utils.c
$(PROG_FILES): Makefile c_utils.o _paths_.pas *.pas
$(p_compiler) $(PFLAGS) $(p_link) $@.pas
test/test_0_c: clean Makefile c_utils.c test/test_0_c.c
$(CC) $(CFLAGS) -O1 -Werror `sdl-config --libs` -lSDL_mixer -lm -lGL -lGLU test/test_0_c.c -o test/test_0_c
test/test_0_pas: CFLAGS += -O1 -Werror
test/test_0_pas: PFLAGS += $(fpc_debug)
test/test_0_pas: p_link += -k-lGL -k-lGLU
test/test_0_pas: clean Makefile c_utils.o test/test_0_pas.pas
$(p_compiler) $(PFLAGS) $(p_link) test/test_0_pas.pas
# needed because fpc does not have gcc-like -dVAR=VALUE syntax :(
_paths_.pas: Makefile
echo "{ Autogenerated by Makefile, do not modify directly! }" > $@
echo "Unit _paths_;" >> $@
echo "INTERFACE" >> $@
echo "function prog_libdir:string;" >> $@
echo "function prog_sharedir:string;" >> $@
echo "IMPLEMENTATION" >> $@
echo "function prog_libdir:string; begin; prog_libdir:='$(libdir)'; end;" >> $@
echo "function prog_sharedir:string; begin; prog_sharedir:='$(sharedir)'; end;" >> $@
echo "begin end." >> $@
clearpaths:
rm -f _paths_.pas
cleantmp: clearpaths
find . -iname "*.ppu" -print0 | xargs -0r rm -f
find . -iname "*.s" -print0 | xargs -0r rm -f
clean: cleantmp
rm -f $(PROG_FILES)
rm -f link.res
find . -iname "*.o" -print0 | xargs -0r rm -f
cleanbak:
find . -iname "*~" -print0 | xargs -0r rm -f
find . -iname "*.bak" -print0 | xargs -0r rm -f
distclean: clean cleanbak
rm -f $(DATA_TOOLS_D) $(DATA_TOOLS_P) tags
rm -f test/test_0_c test/test_0_pas test/testdiv0 test/testkey1 test/testsize test/test_write test/filename
rm -f LPT1 TEMP/* Data_Generators/misc/tga_head.bin
touch TEMP/keep.c
reallyclean: distclean data_destroy
mrproper: reallyclean
rm -rf data/savegame.dir save?
tags: *.c *.pas
ctags $^
Data_Generators/makedata/convmake: Data_Generators/makedata/convmake.d Data_Generators/makedata/data.d
Data_Generators/makedata/logmake: Data_Generators/makedata/logmake.d Data_Generators/makedata/data.d
$(DATA_TOOLS_D):
$(d_compiler) $^
Data_Generators/makedata/aliemake: Data_Generators/makedata/aliemake.pas
Data_Generators/makedata/artimake: Data_Generators/makedata/artimake.pas
Data_Generators/makedata/cargmake: Data_Generators/makedata/cargmake.pas
Data_Generators/makedata/creamake: Data_Generators/makedata/creamake.pas
Data_Generators/makedata/crewmake: Data_Generators/makedata/crewmake.pas
Data_Generators/makedata/elemmake: Data_Generators/makedata/elemmake.pas
Data_Generators/makedata/eventmak: Data_Generators/makedata/eventmak.pas
Data_Generators/makedata/itemmake: Data_Generators/makedata/itemmake.pas
Data_Generators/makedata/makename: Data_Generators/makedata/makename.pas
Data_Generators/makedata/scanmake: Data_Generators/makedata/scanmake.pas
Data_Generators/makedata/shipmake: Data_Generators/makedata/shipmake.pas
Data_Generators/makedata/sysmake: Data_Generators/makedata/sysmake.pas
Data_Generators/makedata/weapmake: Data_Generators/makedata/weapmake.pas
Data_Generators/makedata/iconmake: Data_Generators/makedata/iconmake.pas c_utils.o data.pas utils_.pas _paths_.pas
Data_Generators/makedata/namemake: Data_Generators/makedata/namemake.pas
Data_Generators/makedata/makeani: Data_Generators/makedata/makeani.pas c_utils.o data.pas utils_.pas _paths_.pas
Data_Generators/makedata/shp2make: Data_Generators/makedata/shp2make.pas c_utils.o data.pas utils_.pas _paths_.pas
Data_Generators/misc/scr2cpr: Data_Generators/misc/scr2cpr.pas Data_Generators/misc/data2.pas
Data_Generators/misc/cpr2scr: Data_Generators/misc/cpr2scr.pas Data_Generators/misc/data2.pas
Data_Generators/misc/cpr2tga: Data_Generators/misc/cpr2tga.pas Data_Generators/misc/data2.pas
Data_Generators/misc/tga2cpr: Data_Generators/misc/tga2cpr.pas Data_Generators/misc/data2.pas
$(DATA_TOOLS_P):
$(p_compiler) $(PFLAGS) $(p_link) $<
data/log.dta data/titles.dta: Data_Generators/makedata/logmake Data_Generators/makedata/logs.txt
Data_Generators/makedata/logmake Data_Generators/makedata/logs.txt data/titles.dta data/log.dta
data/conv%.dta:
Data_Generators/makedata/convmake $< $(subst .dta,,$@)
data/conv1000.dta:
touch data/conv1000.dta data/conv1000.ind
data/conv0001.dta: Data_Generators/makedata/crewcon1.txt Data_Generators/makedata/convmake
data/conv0002.dta: Data_Generators/makedata/crewcon2.txt Data_Generators/makedata/convmake
data/conv0003.dta: Data_Generators/makedata/crewcon3.txt Data_Generators/makedata/convmake
data/conv0004.dta: Data_Generators/makedata/crewcon4.txt Data_Generators/makedata/convmake
data/conv0005.dta: Data_Generators/makedata/crewcon5.txt Data_Generators/makedata/convmake
data/conv0006.dta: Data_Generators/makedata/crewcon6.txt Data_Generators/makedata/convmake
data/conv1001.dta: Data_Generators/makedata/sengcon1.txt Data_Generators/makedata/convmake
data/conv1002.dta: Data_Generators/makedata/dpahcon1.txt Data_Generators/makedata/convmake
data/conv1003.dta: Data_Generators/makedata/aardcon1.txt Data_Generators/makedata/convmake
data/conv1004.dta: Data_Generators/makedata/ermicon1.txt Data_Generators/makedata/convmake
data/conv1005.dta: Data_Generators/makedata/titecon1.txt Data_Generators/makedata/convmake
data/conv1006.dta: Data_Generators/makedata/quacon1.txt Data_Generators/makedata/convmake
data/conv1007.dta: Data_Generators/makedata/scavcon1.txt Data_Generators/makedata/convmake
data/conv1008.dta: Data_Generators/makedata/iconcon1.txt Data_Generators/makedata/convmake
data/conv1009.dta: Data_Generators/makedata/guilcon1.txt Data_Generators/makedata/convmake
data/conv1010.dta: Data_Generators/makedata/mochcon1.txt Data_Generators/makedata/convmake
data/conv1011.dta: Data_Generators/makedata/voidcon1.txt Data_Generators/makedata/convmake
data/conv1100.dta: Data_Generators/makedata/tek2con1.txt Data_Generators/makedata/convmake
data/conv1101.dta: Data_Generators/makedata/tek3con1.txt Data_Generators/makedata/convmake
data/conv1102.dta: Data_Generators/makedata/tek4con1.txt Data_Generators/makedata/convmake
data/conv1103.dta: Data_Generators/makedata/tek5con1.txt Data_Generators/makedata/convmake
data/charani.dta: Data_Generators/makedata/makeani data/char.cpr Data_Generators/makedata/charani.cpr
Data_Generators/makedata/makeani
data/shippix.dta: Data_Generators/makedata/shp2make Data_Generators/makedata/shippart.cpr
Data_Generators/makedata/shp2make
data/iteminfo.dta: Data_Generators/makedata/itemmake Data_Generators/makedata/iteminfo.txt
Data_Generators/makedata/itemmake > /dev/null
data/creation.dta: Data_Generators/makedata/creamake Data_Generators/makedata/creation.txt data/cargo.dta
Data_Generators/makedata/creamake > /dev/null
data/cargo.dta: Data_Generators/makedata/cargmake Data_Generators/makedata/cargo.txt
Data_Generators/makedata/cargmake > /dev/null
data/scan.dta: Data_Generators/makedata/scanmake Data_Generators/makedata/scandata.txt
Data_Generators/makedata/scanmake
data/sysname.dta data/sysset.dta Data_Generators/other/sysdata.txt: Data_Generators/makedata/sysmake Data_Generators/makedata/names.txt Data_Generators/makedata/sysset.txt
Data_Generators/makedata/sysmake > /dev/null
data/contact0.dta: Data_Generators/makedata/aliemake Data_Generators/makedata/contact.txt
Data_Generators/makedata/aliemake > /dev/null
data/crew.dta: Data_Generators/makedata/crewmake Data_Generators/makedata/crew.txt
Data_Generators/makedata/crewmake > /dev/null
data/artifact.dta: Data_Generators/makedata/artimake Data_Generators/makedata/anom.txt
Data_Generators/makedata/artimake > /dev/null
data/elements.dta: Data_Generators/makedata/elemmake Data_Generators/makedata/element.txt
Data_Generators/makedata/elemmake > /dev/null
data/event.dta: Data_Generators/makedata/eventmak Data_Generators/makedata/event.txt
Data_Generators/makedata/eventmak > /dev/null
data/weapon.dta: Data_Generators/makedata/weapmake Data_Generators/makedata/weapon.txt
Data_Generators/makedata/weapmake > /dev/null
data/ships.dta: Data_Generators/makedata/shipmake Data_Generators/makedata/alienshp.txt
Data_Generators/makedata/shipmake > /dev/null
data/weapicon.dta data/planicon.dta: Data_Generators/makedata/iconmake Data_Generators/makedata/planicon.cpr
Data_Generators/makedata/iconmake > /dev/null
data/planname.txt: Data_Generators/makedata/namemake Data_Generators/makedata/newnames.txt
Data_Generators/makedata/namemake > /dev/null
data/icons.vga: Graphics_Assets/icons.png Data_Generators/misc/ppm2icons.pl data/main.pal
convert $< ppm:- | Data_Generators/misc/ppm2icons.pl data/main.pal > $@
data/main.pal: data/main.cpr Data_Generators/misc/cpr_extract_pal Data_Generators/misc/cpr2scr
Data_Generators/misc/cpr_extract_pal $<
mv -f TEMP/main.pal $@
# canned command sequence -- PNG with embedded PAL=CPR with embedded PAL
define build-cpr1-via-self
Data_Generators/misc/png_to_cpr $< $@
endef
dep-build-cpr1-via-self := Makefile Data_Generators/misc/tga2cpr Data_Generators/misc/png_to_cpr
# canned command sequence -- PNG+PAL(from CPR w/PAL)=CPR without embedded PAL
define build-cpr0-via-cpr1
Data_Generators/misc/png_to_cprnopal $(word 2,$^) $< $@
endef
dep-build-cpr0-via-cpr1 := Makefile Data_Generators/misc/ppmpal2scr.pl Data_Generators/misc/scr2cpr Data_Generators/misc/cpr2scr Data_Generators/misc/cpr_extract_pal Data_Generators/misc/pngpal_to_cpr Data_Generators/misc/png_to_cprnopal
data/plan1.dta: Graphics_Assets/plan1.png $(dep-build-cpr1-via-self) Data_Generators/misc/cpr2scr
Data_Generators/misc/png_to_cpr $< TEMP/_plan1.cpr
Data_Generators/misc/cpr2scr TEMP/_plan1
dd bs=240 count=120 if=TEMP/_plan1.scr of=$@
rm -f TEMP/_plan1.*
data/image%.cpr: data/char.cpr Graphics_Assets/image%.png $(dep-build-cpr0-via-cpr1)
WIDTH=70 HEIGHT=70 $(build-cpr0-via-cpr1)
data/trade.cpr: data/com.cpr Graphics_Assets/trade.png $(dep-build-cpr0-via-cpr1)
$(build-cpr0-via-cpr1)
data/end6.cpr: data/end5.cpr Graphics_Assets/end6.png $(dep-build-cpr0-via-cpr1)
$(build-cpr0-via-cpr1)
data/waricon.cpr: data/fight.cpr Graphics_Assets/waricon.png $(dep-build-cpr0-via-cpr1)
$(build-cpr0-via-cpr1)
# NB - maybe should use main.cpr instead of fight.cpr for PAL temple for cloud? it is used elsewhere, but first colors are the same...
data/cloud.cpr: data/fight.cpr Graphics_Assets/cloud.png $(dep-build-cpr0-via-cpr1)
$(build-cpr0-via-cpr1)
Data_Generators/makedata/charani.cpr: data/char.cpr Graphics_Assets/charani.png $(dep-build-cpr0-via-cpr1)
$(build-cpr0-via-cpr1)
Data_Generators/makedata/shippart.cpr: data/char.cpr Graphics_Assets/shippart.png $(dep-build-cpr0-via-cpr1)
$(build-cpr0-via-cpr1)
Data_Generators/makedata/planicon.cpr: Graphics_Assets/planicon.png $(dep-build-cpr1-via-self)
$(build-cpr1-via-self)
# if none of the above rules for .cpr match, use this one (CPR with it's own independent pallete)
data/%.cpr: Graphics_Assets/%.png $(dep-build-cpr1-via-self)
$(build-cpr1-via-self)
data_destroy:
rm -f $(DATA_TOOLS_D) $(DATA_TOOLS_P) $(DATA_FILES) data/conv*.ind
data_build: $(DATA_TOOLS_D) $(DATA_TOOLS_P) $(DATA_FILES)
data_rebuild: data_destroy data_build
install: cleanbak
test -d $(DESTDIR)$(libdir) || mkdir -p $(DESTDIR)$(libdir)
install $(PROG_FILES) $(DESTDIR)$(libdir)
test -d $(DESTDIR)$(bindir) || mkdir -p $(DESTDIR)$(bindir)
mv -f $(DESTDIR)$(libdir)/is $(DESTDIR)$(bindir)
test -d $(DESTDIR)$(sharedir)/data || mkdir -p $(DESTDIR)$(sharedir)/data
install -m 0644 data/* $(DESTDIR)$(sharedir)/data
rm -f $(DESTDIR)$(sharedir)/data/savegame.dir
test -d $(DESTDIR)$(sharedir)/sound || mkdir -p $(DESTDIR)$(sharedir)/sound
install -m 0644 sound/*.SAM sound/*.MOD $(DESTDIR)$(sharedir)/sound
test -d $(DESTDIR)$(docdir) || mkdir -p $(DESTDIR)$(docdir)
install -m 0644 README.md Documents/* $(DESTDIR)$(docdir)
uninstall:
cd $(DESTDIR)$(bindir) && rm -f is
cd $(DESTDIR)$(libdir) && rm -f $(PROG_FILES)
rmdir $(DESTDIR)$(libdir)
cd $(DESTDIR)$(sharedir) && rm -f README.md $(wildcard data/* sound/*)
rmdir $(DESTDIR)$(sharedir)/data $(DESTDIR)$(sharedir)/sound $(DESTDIR)$(sharedir)
cd $(DESTDIR)$(docdir) && rm -f README.md $(notdir $(wildcard Documents/*))
rmdir $(DESTDIR)$(docdir)
deb:
debuild
lintian --check --fail-on-warnings --info
dh clean
.PHONY: all build cleanbuild cleantmp clean reallyclean release_sdl release_ogl debug_sdl debug_sdl1 debug_ogl debug_ogl1 demo_sdl demo_sdl1 data_destroy data_build data_rebuild cleanbak mrproper distclean rebuild install uninstall clearpaths deb
# fpc does not really work nicely with parallel builds, as for example `fpc main` and `fpc intro` can try to produce 'data.ppu' etc. simultaneously
.NOTPARALLEL: