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