forked from Chris-plus-alphanumericgibberish/dNAO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGNUmakefile
238 lines (189 loc) · 8.15 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
GAMEDIR = dnethackdir
CFLAGS = -g
GAMELIBS = -lncurses -lm
-include local.mk
CPPFLAGS += -Iinclude
CPPFLAGS += -DDLB
.DELETE_ON_ERROR:
.PHONY: all
all: src/dnethack util/recover dat/nhdat dat/license
ATOMIC_LN = ln $(1) $(2).new && mv $(2).new $(2)
.PHONY: install
install: all
mkdir -p $(GAMEDIR)
install src/dnethack $(GAMEDIR)
install util/recover $(GAMEDIR)
install -m 644 dat/nhdat dat/license $(GAMEDIR)
touch $(GAMEDIR)/perm
touch $(GAMEDIR)/record
touch $(GAMEDIR)/logfile
touch $(GAMEDIR)/xlogfile
touch $(GAMEDIR)/livelog
mkdir -p $(GAMEDIR)/save
##### BINARIES #####
SRCOBJ = allmain.o alloc.o apply.o artifact.o attrib.o ball.o bones.o \
botl.o cmd.o dbridge.o decl.o detect.o dig.o display.o dlb.o \
do.o do_name.o do_wear.o dog.o dogmove.o dokick.o dothrow.o \
drawing.o dungeon.o eat.o end.o engrave.o exper.o explode.o \
extralev.o files.o fountain.o hack.o hacklib.o invent.o \
light.o lock.o mail.o makemon.o mapglyph.o mcastu.o mhitm.o \
mhitu.o minion.o mklev.o mkmap.o mkmaze.o mkobj.o mkroom.o \
mon.o mondata.o monmove.o monst.o monstr.o mplayer.o \
mthrowu.o muse.o music.o o_init.o objects.o objnam.o \
options.o pager.o pickup.o pline.o polyself.o potion.o \
pray.o priest.o quest.o questpgr.o read.o recover.o rect.o \
region.o restore.o rip.o rnd.o role.o rumors.o save.o shk.o \
shknam.o sit.o sounds.o sp_lev.o spell.o steal.o steed.o \
teleport.o tile.o timeout.o topten.o track.o trap.o u_init.o \
uhitm.o unicode.o vault.o version.o vision.o weapon.o were.o \
wield.o windows.o wizard.o worm.o worn.o write.o zap.o
SYSUNIXOBJ = unixmain.o unixres.o unixunix.o
SYSSHAREOBJ = ioctl.o unixtty.o
WINTTYOBJ = getline.o termcap.o topl.o wintty.o
WINCURSESOBJ = cursdial.o cursinit.o cursmain.o cursmesg.o cursmisc.o \
cursstat.o curswins.o cursinvt.o
GAME_O = $(SRCOBJ:%.o=src/%.o) $(SYSUNIXOBJ:%.o=sys/unix/%.o) \
$(SYSSHAREOBJ:%.o=sys/share/%.o) \
$(WINTTYOBJ:%.o=win/tty/%.o) \
$(WINCURSESOBJ:%.o=win/curses/%.o)
src/dnethack: $(GAME_O)
$(CC) $(LDFLAGS) $^ $(LDLIBS) $(GAMELIBS) -o $@
AUTO_BIN += src/dnethack
RECOVER_O = util/recover_main.o src/recover.o
util/recover: $(RECOVER_O)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
AUTO_BIN += util/recover
MAKEDEFS_O = util/makedefs.o src/alloc.o src/monst.o src/objects.o \
util/panic.o
util/makedefs: $(MAKEDEFS_O)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
AUTO_BIN += util/makedefs
DLB_O = util/dlb_main.o src/alloc.o src/dlb.o util/panic.o
util/dlb: $(DLB_O)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
AUTO_BIN += util/dlb
DGN_COMP_O = util/dgn_main.o util/dgn_lex.o util/dgn_yacc.o \
src/alloc.o util/panic.o
util/dgn_comp: $(DGN_COMP_O)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
AUTO_BIN += util/dgn_comp
LEV_COMP_O = util/lev_main.o util/lev_lex.o util/lev_yacc.o \
src/alloc.o src/decl.o src/drawing.o src/monst.o \
src/objects.o util/panic.o
util/lev_comp: $(LEV_COMP_O)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
AUTO_BIN += util/lev_comp
TILEMAP_O = win/share/tilemap.o
util/tilemap: $(TILEMAP_O)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
AUTO_BIN += util/tilemap
ALL_O = $(GAME_O) $(RECOVER_O) $(MAKEDEFS_O) $(DLB_O) $(DGN_COMP_O) \
$(LEV_COMP_O) $(TILEMAP_O)
##### BASIC RULES AND AUTOMATIC DEPENDENCY GENERATION #####
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
%.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MP -c -o $@ $<
%.d:
$(CC) $(CFLAGS) $(CPPFLAGS) -MM -MP -MG -MT $*.o -MF $@ $*.c
ALL_D = $(ALL_O:%.o=%.d)
-include $(ALL_D)
##### AUTOGENERATED SOURCE FILES #####
export COMMIT_DESC := $(shell git describe --always)
include/date.h: util/makedefs .git/index $(filter-out src/version.o,$(GAME_O))
cd util && ./makedefs -a # include/date.h
include/onames.h: util/makedefs
cd util && ./makedefs -o # include/onames.h
include/pm.h: util/makedefs
cd util && ./makedefs -p # include/pm.h
include/verinfo.h: util/makedefs
cd util && ./makedefs -w # include/verinfo.h
AUTO_H += include/date.h include/onames.h include/pm.h include/verinfo.h
# generating the dependencies of source files requires them to exist,
# so the dependencies of the autogenerated source files have to be
# declared explicitly instead
src/monstr.c: util/makedefs
cd util && ./makedefs -m # src/monstr.c
AUTO_C += src/monstr.c
include/dgn_comp.h include/lev_comp.h: include/%_comp.h: util/%_yacc.c
util/dgn_yacc.c util/lev_yacc.c: util/%_yacc.c: util/%_comp.y
bison --defines=include/$*_comp.h -o util/$*_yacc.c util/$*_comp.y
AUTO_H += include/dgn_comp.h include/lev_comp.h
AUTO_C += util/dgn_yacc.c util/lev_yacc.c
util/dgn_yacc.o: include/verinfo.h
util/lev_yacc.o: include/onames.h include/pm.h
util/dgn_lex.c util/lev_lex.c: util/%_lex.c: util/%_comp.l
flex -o$@ $<
AUTO_C += util/dgn_lex.c util/lev_lex.c
util/dgn_lex.o: include/dgn_comp.h
util/lev_lex.o: include/lev_comp.h include/onames.h include/pm.h
src/tile.c: util/tilemap
cd util && ./tilemap # src/tile.c
AUTO_C += src/tile.c
src/tile.o: include/pm.h include/onames.h
# to bootstrap the dependency generation, we want to not depend on
# autogenerated header files or source files, but we'll still need the
# correct dependencies on and for those when compiling, at least for
# the first time; missing headers are added to the initial dependency
# files without the correct prefix, so we add those here, and we
# already specified the dependencies to the autogenerated header files
# from the autogenerated source files above, so we don't need to
# bootstrap the dependency files for the autogenerated source files
# because they'll be created whenever they're actually compiled
$(AUTO_H:include/%.h=%.h): %.h: include/%.h ;
$(AUTO_C:%.c=%.d): ;
##### DATA FILES #####
QUEST_DES = Arch.des Anachrononaut.des Android.des Barb.des Bard.des Binder.des Caveman.des \
Convict.des Drow.des DrowNoble.des Elf.des Erebor.des GnomeRanger.des \
Healer.des Hedrow.des HedrowNoble.des Knight.des Monk.des Moria.des \
Noble.des Pirate.des Priest.des Ranger.des Rogue.des \
Samurai.des Tourist.des Valkyrie.des Wizard.des
SPEC_DES = bigroom.des blacktemple.des castle.des chaos.des chaos2.des chaos3.des \
endgame.des gehennom.des knox.des labr.des law.des \
medusa.des grue.des mines.des neutrality.des oracle.des sokoban.des \
storage.des sunlesssea.des tomb.des tower.des yendor.des
ALL_TAG = $(QUEST_DES:%.des=dat/%.tag) $(SPEC_DES:%.des=dat/%.tag)
$(ALL_TAG): dat/%.tag: dat/%.des util/lev_comp
cd dat && ../util/lev_comp $(<F) && touch $(@F)
AUTO_DAT += $(ALL_TAG)
DAT_NHDAT = cmdhelp data dngnch1 dngnch2 dngnch3 help hh history opthelp options \
oracles quest.dat rumors wizhelp
dat/nhdat: util/dlb $(DAT_NHDAT:%=dat/%) $(ALL_TAG)
cd dat && ../util/dlb cf nhdat $(DAT_NHDAT) *.lev
AUTO_DAT += dat/nhdat
dat/data: dat/data.base util/makedefs
cd util && ./makedefs -d # dat/data
dat/options: util/makedefs
cd util && ./makedefs -t # dat/options
dat/oracles: dat/oracles.txt util/makedefs
cd util && ./makedefs -h # dat/oracles
dat/quest.dat: dat/quest.txt util/makedefs
cd util && ./makedefs -q # dat/quest.dat
dat/rumors: dat/rumors.tru dat/rumors.fal util/makedefs
cd util && ./makedefs -r # dat/rumors
AUTO_DAT += dat/data dat/options dat/oracles dat/quest.dat dat/rumors
dat/dngnch1: dat/dngnch1.pdf util/dgn_comp
cd dat && ../util/dgn_comp dngnch1.pdf # dat/dngnch1
dat/dngnch1.pdf: dat/dngnch1.def util/makedefs
cd util && ./makedefs -e # dat/dngnch1.pdf
dat/dngnch2: dat/dngnch2.pdf util/dgn_comp
cd dat && ../util/dgn_comp dngnch2.pdf # dat/dngnch2
dat/dngnch2.pdf: dat/dngnch2.def util/makedefs
cd util && ./makedefs -e # dat/dngnch2.pdf
dat/dngnch3: dat/dngnch3.pdf util/dgn_comp
cd dat && ../util/dgn_comp dngnch3.pdf # dat/dngnch3
dat/dngnch3.pdf: dat/dngnch3.def util/makedefs
cd util && ./makedefs -e # dat/dngnch3.pdf
AUTO_DAT += dat/dngnch1 dat/dngnch1.pdf dat/dngnch2 dat/dngnch2.pdf dat/dngnch3 dat/dngnch3.pdf
##### CLEANING UP #####
.PHONY: clean
clean:
rm -f $(AUTO_BIN)
rm -f $(ALL_O)
rm -f $(AUTO_H)
rm -f $(AUTO_C)
rm -f $(AUTO_DAT)
rm -f dat/*.lev
.PHONY: cleandeps
cleandeps: clean
rm -f $(ALL_D)