1#	NetHack Makefile.
2#	SCCS Id: @(#)Makefile.top	3.4	1995/01/05
3
4# newer makes predefine $(MAKE) to 'make' and do smarter processing of
5# recursive make calls if $(MAKE) is used
6# these makes allow $(MAKE) to be overridden by the environment if someone
7# wants to (or has to) use something other than the standard make, so we do
8# not want to unconditionally set $(MAKE) here
9#
10# unfortunately, some older makes do not predefine $(MAKE); if you have one of
11# these, uncomment the following line
12# (you will know that you have one if you get complaints about unable to
13# execute things like 'data' and 'rumors')
14# MAKE = make
15
16# make NetHack
17GAME     = nethack34
18# GAME     = nethack.prg
19GAMEUID  = games
20GAMEGRP  = games
21
22# Permissions - some places use setgid instead of setuid, for instance
23# See also the option "SECURE" in include/config.h
24GAMEPERM = 02755
25FILEPERM = 0664
26EXEPERM  = 0755
27DIRPERM  = 0775
28
29# GAMEDIR also appears in config.h as "HACKDIR".
30# VARDIR may also appear in unixconf.h as "VAR_PLAYGROUND" else GAMEDIR
31#
32# note that 'make install' believes in creating a nice tidy GAMEDIR for
33# installation, free of debris from previous NetHack versions --
34# therefore there should not be anything in GAMEDIR that you want to keep
35# (if there is, you'll have to do the installation by hand or modify the
36# instructions)
37GAMEDIR  = ${PREFIX}/share/nethack34
38VARDIR  = $(GAMEDIR)
39SHELLDIR = ${PREFIX}/bin
40
41# per discussion in Install.X11 and Install.Qt
42# VARDATND =
43# VARDATND = x11tiles NetHack.ad pet_mark.xbm
44# VARDATND = x11tiles NetHack.ad pet_mark.xbm rip.xpm
45# for Atari/Gem
46# VARDATND = nh16.img title.img GEM_RSC.RSC rip.img
47# for BeOS
48# VARDATND = beostiles
49# for Gnome
50VARDATND = x11tiles pet_mark.xbm rip.xpm mapbg.xpm
51
52VARDATD = data oracles options quest.dat rumors
53VARDAT = $(VARDATD) $(VARDATND)
54
55# Some versions of make use the SHELL environment variable as the shell
56# for running commands.  We need this to be a Bourne shell.
57# SHELL = /bin/sh
58# for Atari
59# SHELL=E:/GEMINI2/MUPFEL.TTP
60
61# Commands for setting the owner and group on files during installation.
62# Some systems fail with one or the other when installing over NFS or for
63# other permission-related reasons.  If that happens, you may want to set the
64# command to "true", which is a no-op. Note that disabling chown or chgrp
65# will only work if setuid (or setgid) behavior is not desired or required.
66CHOWN = chown
67CHGRP = chgrp
68
69#
70# end of configuration
71#
72
73DATHELP = help hh cmdhelp history opthelp wizhelp
74
75SPEC_LEVS = asmodeus.lev baalz.lev bigrm-?.lev castle.lev fakewiz?.lev \
76	juiblex.lev knox.lev medusa-?.lev minend-?.lev minefill.lev \
77	minetn-?.lev oracle.lev orcus.lev sanctum.lev soko?-?.lev \
78	tower?.lev valley.lev wizard?.lev \
79	astral.lev air.lev earth.lev fire.lev water.lev
80QUEST_LEVS = ???-goal.lev ???-fil?.lev ???-loca.lev ???-strt.lev
81
82DATNODLB = $(VARDATND) license
83DATDLB = $(DATHELP) dungeon $(SPEC_LEVS) $(QUEST_LEVS) $(VARDATD)
84DAT = $(DATNODLB) $(DATDLB)
85
86$(GAME):
87	( cd src ; $(MAKE) )
88
89all:	$(GAME) recover Guidebook $(VARDAT) dungeon spec_levs check-dlb
90	@echo "Done."
91
92# Note: many of the dependencies below are here to allow parallel make
93# to generate valid output
94
95Guidebook:
96	( cd doc ; $(MAKE) Guidebook )
97
98manpages:
99	( cd doc ; $(MAKE) manpages )
100
101data: $(GAME)
102	( cd dat ; $(MAKE) data )
103
104rumors: $(GAME)
105	( cd dat ; $(MAKE) rumors )
106
107oracles: $(GAME)
108	( cd dat ; $(MAKE) oracles )
109
110#	Note: options should have already been made with make, but...
111options: $(GAME)
112	( cd dat ; $(MAKE) options )
113
114quest.dat: $(GAME)
115	( cd dat ; $(MAKE) quest.dat )
116
117spec_levs: dungeon
118	( cd util ; $(MAKE) lev_comp )
119	( cd dat ; $(MAKE) spec_levs )
120	( cd dat ; $(MAKE) quest_levs )
121
122dungeon: $(GAME)
123	( cd util ; $(MAKE) dgn_comp )
124	( cd dat ; $(MAKE) dungeon )
125
126nhtiles.bmp: $(GAME)
127	( cd dat ; $(MAKE) nhtiles.bmp )
128
129x11tiles: $(GAME)
130	( cd util ; $(MAKE) tile2x11 )
131	( cd dat ; $(MAKE) x11tiles )
132
133beostiles: $(GAME)
134	( cd util ; $(MAKE) tile2beos )
135	( cd dat ; $(MAKE) beostiles )
136
137NetHack.ad: $(GAME)
138	( cd dat ; $(MAKE) NetHack.ad )
139
140pet_mark.xbm:
141	( cd dat ; $(MAKE) pet_mark.xbm )
142
143rip.xpm:
144	( cd dat ; $(MAKE) rip.xpm )
145
146mapbg.xpm:
147	(cd dat ; $(MAKE) mapbg.xpm )
148
149nhsplash.xpm:
150	( cd dat ; $(MAKE) nhsplash.xpm )
151
152nh16.img: $(GAME)
153	( cd util ; $(MAKE) tile2img.ttp )
154	( cd dat ; $(MAKE) nh16.img )
155
156rip.img:
157	( cd util ; $(MAKE) xpm2img.ttp )
158	( cd dat ; $(MAKE) rip.img )
159GEM_RSC.RSC:
160	( cd dat ; $(MAKE) GEM_RSC.RSC )
161
162title.img:
163	( cd dat ; $(MAKE) title.img )
164
165check-dlb: options
166	@if egrep -s librarian dat/options ; then $(MAKE) dlb ; else true ; fi
167
168dlb:
169	( cd util ; $(MAKE) dlb )
170	( cd dat ; ../util/dlb cf nhdat $(DATDLB) )
171
172# recover can be used when INSURANCE is defined in include/config.h
173# and the checkpoint option is true
174recover: $(GAME)
175	( cd util ; $(MAKE) recover )
176
177dofiles:
178	target=`sed -n					\
179		-e '/librarian/{' 			\
180		-e	's/.*/dlb/p' 			\
181		-e	'q' 				\
182		-e '}' 					\
183	  	-e '$$s/.*/nodlb/p' < dat/options` ;	\
184	$(MAKE) dofiles-$${target-nodlb}
185	cp src/$(GAME) ${DESTDIR}$(GAMEDIR)/$(GAME)
186	cp util/recover ${DESTDIR}$(GAMEDIR)
187	-rm -f ${DESTDIR}$(SHELLDIR)/$(GAME)
188	sed -e 's;/usr/games/lib/nethackdir;$(GAMEDIR);' \
189		-e 's;HACKDIR/nethack;HACKDIR/$(GAME);' \
190		< sys/unix/nethack.sh \
191		> ${DESTDIR}$(SHELLDIR)/$(GAME)
192
193dofiles-dlb: check-dlb
194	( cd dat ; cp nhdat $(DATNODLB) ${DESTDIR}$(GAMEDIR) )
195
196dofiles-nodlb:
197# copy over the game files
198	( cd dat ; cp $(DAT) ${DESTDIR}$(GAMEDIR) )
199
200update: $(GAME) recover $(VARDAT) dungeon spec_levs
201#	(don't yank the old version out from under people who're playing it)
202	-mv ${DESTDIR}$(GAMEDIR)/$(GAME) ${DESTDIR}$(GAMEDIR)/$(GAME).old
203#	quest.dat is also kept open and has the same problems over NFS
204#	(quest.dat may be inside nhdat if dlb is in use)
205	-mv ${DESTDIR}$(GAMEDIR)/quest.dat ${DESTDIR}$(GAMEDIR)/quest.dat.old
206	-mv ${DESTDIR}$(GAMEDIR)/nhdat ${DESTDIR}$(GAMEDIR)/nhdat.old
207# set up new versions of the game files
208	( $(MAKE) dofiles )
209# touch time-sensitive files
210	-touch -c $(VARDIR)/bones* $(VARDIR)/?lock* $(VARDIR)/wizard*
211	touch $(VARDIR)/perm $(VARDIR)/record
212# and a reminder
213	@echo You may also want to install the man pages via the doc Makefile.
214
215install: $(GAME) recover $(VARDAT) dungeon spec_levs
216# set up the directories
217# not all mkdirs have -p; those that don't will create a -p directory
218	-mkdir -p ${DESTDIR}$(SHELLDIR)
219	-rm -rf ${DESTDIR}$(GAMEDIR) ${DESTDIR}$(VARDIR)
220	-mkdir -p ${DESTDIR}$(GAMEDIR) ${DESTDIR}$(VARDIR)
221	-rmdir ./-p
222# set up the game files
223	( $(MAKE) dofiles )
224# set up some additional files
225	touch ${DESTDIR}$(VARDIR)/perm ${DESTDIR}$(VARDIR)/record ${DESTDIR}$(VARDIR)/logfile
226# and a reminder
227	@echo You may also want to reinstall the man pages via the doc Makefile.
228
229
230# 'make clean' removes all the .o files, but leaves around all the executables
231# and compiled data files
232clean:
233	( cd src ; $(MAKE) clean )
234	( cd util ; $(MAKE) clean )
235
236# 'make spotless' returns the source tree to near-distribution condition.
237# it removes .o files, executables, and compiled data files
238spotless:
239	( cd src ; $(MAKE) spotless )
240	( cd util ; $(MAKE) spotless )
241	( cd dat ; $(MAKE) spotless )
242	( cd doc ; $(MAKE) spotless )
243