1 # Makefile for NetHack's utility programs.
2 # SCCS Id: @(#)Makefile.utl 3.4 1997/04/19
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
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 'foo.o')
16 # if you are using gcc as your compiler,
17 # uncomment the CC definition below if it's not in your environment
20 # For Bull DPX/2 systems at B.O.S. 2.0 or higher use the following:
22 # CC = gcc -ansi -D_BULL_SOURCE -D_XOPEN_SOURCE -D_POSIX_SOURCE
24 # If you are using GCC 2.2.2 or higher on a DPX/2, just use:
28 # For HP/UX 10.20 with GCC:
29 # CC = gcc -D_POSIX_SOURCE
31 # if your make doesn't define a default SHELL properly, you may need
32 # the line below (Atari users will need a bourne work-alike)
35 # SHELL=E:/GEMINI2/MUPFEL.TTP
37 # flags may have to be changed as required
38 # flags for 286 Xenix:
39 # CFLAGS = -Ml2t16 -O -LARGE -I../include
40 # LFLAGS = -Ml -F 4000 -SEG 512
42 # flags for 286 Microport SysV-AT
43 # CFLAGS = -DDUMB -Ml -I../include
46 # flags for Atari GCC (3.2.1)
47 # CFLAGS = -O -I../include
49 # flags for Atari GCC (3.3)
50 # CFLAGS = -mshort -O2 -I../include
53 # flags for Apollos using their native cc
54 # (as long as it claims to be __STDC__ but isn't)
55 # CFLAGS = -DAPOLLO -O -I../include
57 # flags for AIX 3.1 cc on IBM RS/6000 to define
58 # a suitable subset of standard libraries
59 # (note that there is more info regarding the "-qchars=signed"
60 # switch in file Install.unx note 8)
61 # CFLAGS = -D_NO_PROTO -D_XOPEN_SOURCE -O -I../include -qchars=signed
63 # CFLAGS = -D_NO_PROTO -D_XOPEN_SOURCE -D_ALL_SOURCE -O -I../include -qchars=signed
65 # flags for A/UX 2.01 using native cc or c89
66 # gcc predefines AUX so that's not needed there
67 # CFLAGS = -ZS -D_POSIX_SOURCE -O -I../include -DAUX
69 # flags for IRIX 4.0.x using native cc
70 # SGI cc 3.10 will fail to compile makedefs with -O
71 # CFLAGS = -I../include -D__STDC__ -woff 100,293
75 # CFLAGS = -O2 -fomit-frame-pointer -I../include
76 # LFLAGS = -L/usr/X11R6/lib
77 # OR compile backwards compatible a.out format
78 # CFLAGS = -O2 -b i486-linuxaout -fomit-frame-pointer -I../include
79 # LFLAGS = -b i486-linuxaout -L/usr/X11R6/lib
81 # flags for BeOS using the command line
82 # remember to uncomment flex and bison below
83 # BeOS on a Mac/BeBox:
85 #CFLAGS = -I../include
87 # the default values are fine
89 # flags for debugging:
90 # CFLAGS = -g -I../include
92 CFLAGS = -O -I../include
97 # If you are cross-compiling, you must use this:
99 # otherwise, you can save a little bit of disk space with this:
102 # yacc/lex programs to use to generate *_comp.h, *_lex.c, and *_yacc.c.
103 # if, instead of yacc/lex you have bison/flex, comment/uncomment the following.
110 # these are the names of the output files from YACC/LEX. Under MS-DOS
111 # and similar systems, they may differ
121 # ----------------------------------------
123 # Nothing below this line should have to be changed.
125 # timestamps for primary header files, matching src/Makefile
126 CONFIG_H = ../src/config.h-t
127 HACK_H = ../src/hack.h-t
131 SPLEVSRC = lev_yacc.c lev_lex.c lev_main.c
132 DGNCOMPSRC = dgn_yacc.c dgn_lex.c dgn_main.c
135 UTILSRCS = $(MAKESRC) panic.c $(SPLEVSRC) $(DGNCOMPSRC) $(RECOVSRC) $(DLBSRC)
137 # files that define all monsters and objects
138 CMONOBJ = ../src/monst.c ../src/objects.c
139 OMONOBJ = $(OBJDIR)/monst.o $(OBJDIR)/objects.o
140 # files that provide access to NetHack's names
141 CNAMING = ../src/drawing.c ../src/decl.c $(CMONOBJ)
142 ONAMING = $(OBJDIR)/drawing.o $(OBJDIR)/decl.o $(OMONOBJ)
143 # dynamic memory allocation
144 CALLOC = ../src/alloc.c panic.c
145 OALLOC = $(OBJDIR)/alloc.o panic.o
147 # object files for makedefs
148 MAKEOBJS = makedefs.o $(OMONOBJ)
150 # object files for special levels compiler
151 SPLEVOBJS = lev_yacc.o lev_lex.o lev_main.o $(OALLOC) $(ONAMING)
153 # object files for dungeon compiler
154 DGNCOMPOBJS = dgn_yacc.o dgn_lex.o dgn_main.o $(OALLOC)
156 # object files for recovery utility
157 RECOVOBJS = recover.o
159 # object files for the data librarian
160 DLBOBJS = dlb_main.o $(OBJDIR)/dlb.o $(OALLOC)
162 # flags for creating distribution versions of sys/share/*_lex.c, using
163 # a more portable flex skeleton, which is not included in the distribution.
164 # hopefully keeping this out of the section to be edited will keep too
165 # many people from being confused by it...
166 # FLEXDIST = -L -S../sys/share/flexhack.skl
169 # flags for creating distribution versions of sys/share/*_yacc.c, without
170 # line numbers so patches from version to version are practical
175 # dependencies for makedefs
177 makedefs: $(MAKEOBJS)
178 $(CC) $(LFLAGS) -o makedefs $(MAKEOBJS)
180 makedefs.o: makedefs.c $(CONFIG_H) ../include/permonst.h \
181 ../include/objclass.h ../include/monsym.h \
182 ../include/artilist.h ../include/dungeon.h ../include/obj.h \
183 ../include/monst.h ../include/you.h ../include/flag.h \
184 ../include/dlb.h ../include/patchlevel.h ../include/qtext.h
186 ../include/onames.h: makedefs
188 ../include/pm.h: makedefs
190 ../src/monstr.c: makedefs
192 ../include/vis_tab.h: makedefs
194 # makedefs -z makes both vis_tab.h and vis_tab.c, but writes the .h first
195 ../src/vis_tab.c: ../include/vis_tab.h
198 @lint -axbh -I../include -DLINT $(MAKESRC) $(CMONOBJ) | sed '/_flsbuf/d'
201 # we defer this makedefs call to the src Makefile, since it knows all about
202 # the main src and include files date.h is a timestamp for
204 @( cd ../src ; $(MAKE) ../include/date.h )
206 # support code used by several of the utility programs (but not makedefs)
207 panic.o: panic.c $(CONFIG_H)
210 # dependencies for lev_comp
212 lev_comp: $(SPLEVOBJS)
213 $(CC) $(LFLAGS) -o lev_comp $(SPLEVOBJS) $(LIBS)
215 lev_yacc.o: lev_yacc.c $(HACK_H) ../include/sp_lev.h
216 lev_main.o: lev_main.c $(HACK_H) ../include/sp_lev.h ../include/tcap.h \
219 # see lev_comp.l for WEIRD_LEX discussion
220 # egrep will return failure if it doesn't find anything, but we know there
221 # is one "_cplusplus" inside a comment
222 lev_lex.o: lev_lex.c $(HACK_H) ../include/lev_comp.h ../include/sp_lev.h
223 @echo $(CC) -c $(CFLAGS) lev_lex.c
224 @$(CC) -c $(CFLAGS) -DWEIRD_LEX=`egrep -c _cplusplus lev_lex.c` lev_lex.c
226 ../include/lev_comp.h: lev_yacc.c
228 lev_yacc.c: lev_comp.y
229 $(YACC) $(YACCDIST) -d lev_comp.y
230 mv $(YTABC) lev_yacc.c
231 mv $(YTABH) ../include/lev_comp.h
233 lev_lex.c: lev_comp.l
234 $(LEX) $(FLEXDIST) lev_comp.l
235 mv $(LEXYYC) lev_lex.c
237 # with all of extern.h's functions to complain about, we drown in
238 # 'defined but not used' without -u
240 @lint -axhu -I../include -DLINT $(SPLEVSRC) $(CALLOC) $(CNAMING) | sed '/_flsbuf/d'
243 # dependencies for dgn_comp
245 dgn_comp: $(DGNCOMPOBJS)
246 $(CC) $(LFLAGS) -o dgn_comp $(DGNCOMPOBJS) $(LIBS)
248 dgn_yacc.o: dgn_yacc.c $(CONFIG_H) ../include/dgn_file.h ../include/date.h
249 dgn_main.o: dgn_main.c $(CONFIG_H) ../include/dlb.h
251 # see dgn_comp.l for WEIRD_LEX discussion
252 dgn_lex.o: dgn_lex.c $(CONFIG.H) ../include/dgn_comp.h ../include/dgn_file.h
253 @echo $(CC) -c $(CFLAGS) dgn_lex.c
254 @$(CC) -c $(CFLAGS) -DWEIRD_LEX=`egrep -c _cplusplus dgn_lex.c` dgn_lex.c
257 ../include/dgn_comp.h: dgn_yacc.c
259 dgn_yacc.c: dgn_comp.y
260 $(YACC) $(YACCDIST) -d dgn_comp.y
261 mv $(YTABC) dgn_yacc.c
262 mv $(YTABH) ../include/dgn_comp.h
264 dgn_lex.c: dgn_comp.l
265 $(LEX) $(FLEXDIST) dgn_comp.l
266 mv $(LEXYYC) dgn_lex.c
268 # with all of extern.h's functions to complain about, we drown in
269 # 'defined but not used' without -u
271 @lint -axhu -I../include -DLINT $(DGNCOMPSRC) $(CALLOC) | sed '/_flsbuf/d'
274 # dependencies for recover
276 recover: $(RECOVOBJS)
277 $(CC) $(LFLAGS) -o recover $(RECOVOBJS) $(LIBS)
279 recover.o: recover.c $(CONFIG_H) ../include/date.h
282 # dependencies for dlb
285 $(CC) $(LFLAGS) -o dlb $(DLBOBJS) $(LIBS)
287 dlb_main.o: dlb_main.c $(CONFIG_H) ../include/dlb.h ../include/date.h
288 $(CC) $(CFLAGS) -c dlb_main.c
292 # dependencies for tile utilities
294 TEXT_IO = tiletext.o tiletxt.o $(ONAMING)
295 GIFREADERS = gifread.o $(OALLOC)
296 PPMWRITERS = ppmwrite.o $(OALLOC)
298 tileutils: tilemap gif2txt txt2ppm tile2x11
300 gif2txt: $(GIFREADERS) $(TEXT_IO)
301 $(CC) $(LFLAGS) -o gif2txt $(GIFREADERS) $(TEXT_IO) $(LIBS)
302 txt2ppm: $(PPMWRITERS) $(TEXT_IO)
303 $(CC) $(LFLAGS) -o txt2ppm $(PPMWRITERS) $(TEXT_IO) $(LIBS)
305 tile2x11: tile2x11.o $(TEXT_IO)
306 $(CC) $(LFLAGS) -o tile2x11 tile2x11.o $(TEXT_IO) $(LIBS)
308 tile2img.ttp: tile2img.o bitmfile.o $(TEXT_IO)
309 $(CC) $(LFLAGS) -o tile2img.ttp tile2img.o bitmfile.o $(TEXT_IO) $(LIBS)
311 tile2bmp: tile2bmp.o $(TEXT_IO)
312 $(CC) $(LFLAGS) -o tile2bmp tile2bmp.o $(TEXT_IO)
314 xpm2img.ttp: xpm2img.o bitmfile.o
315 $(CC) $(LFLAGS) -o xpm2img.ttp xpm2img.o bitmfile.o $(LIBS)
317 tile2beos: tile2beos.o $(TEXT_IO)
318 $(CC) $(LFLAGS) -o tile2beos tile2beos.o $(TEXT_IO) -lbe
320 tilemap: ../win/share/tilemap.c $(HACK_H)
321 $(CC) $(CFLAGS) $(LFLAGS) -o tilemap ../win/share/tilemap.c $(LIBS)
322 ../src/tile.c: tilemap
325 ../include/tile.h: ../win/share/tile.h
326 cp ../win/share/tile.h ../include/tile.h
327 tiletext.o: ../win/share/tiletext.c $(CONFIG_H) ../include/tile.h
328 $(CC) $(CFLAGS) -c ../win/share/tiletext.c
329 tiletxt.o: ../win/share/tilemap.c $(HACK_H)
330 $(CC) $(CFLAGS) -c -DTILETEXT ../win/share/tilemap.c
331 mv tilemap.o tiletxt.o
333 gifread.o: ../win/share/gifread.c $(CONFIG_H) ../include/tile.h
334 $(CC) $(CFLAGS) -c ../win/share/gifread.c
335 ppmwrite.o: ../win/share/ppmwrite.c $(CONFIG_H) ../include/tile.h
336 $(CC) $(CFLAGS) -c ../win/share/ppmwrite.c
338 tile2bmp.o: ../win/share/tile2bmp.c $(HACK_H) ../include/tile.h
339 $(CC) $(CFLAGS) -c ../win/share/tile2bmp.c
341 tile2x11.o: ../win/X11/tile2x11.c $(HACK_H) ../include/tile.h \
342 ../include/tile2x11.h
343 $(CC) $(CFLAGS) -c ../win/X11/tile2x11.c
345 tile2img.o: ../win/gem/tile2img.c $(HACK_H) ../include/tile.h \
346 ../include/bitmfile.h
347 $(CC) $(CFLAGS) -c ../win/gem/tile2img.c
348 xpm2img.o: ../win/gem/xpm2img.c $(HACK_H) ../include/bitmfile.h
349 $(CC) $(CFLAGS) -c ../win/gem/xpm2img.c
350 bitmfile.o: ../win/gem/bitmfile.c ../include/bitmfile.h
351 $(CC) $(CFLAGS) -c ../win/gem/bitmfile.c
353 tile2beos.o: ../win/BeOS/tile2beos.cpp $(HACK_H) ../include/tile.h
354 $(CXX) $(CFLAGS) -c ../win/BeOS/tile2beos.cpp
356 # using dependencies like
358 # @( cd ../src ; $(MAKE) foo )
359 # would always force foo to be up-to-date according to the src Makefile
360 # when it's needed here. unfortunately, some makes believe this syntax
361 # means foo always changes, instead of foo should always be checked.
362 # therefore, approximate via config.h dependencies, and hope that anybody
363 # changing anything other than basic configuration also knows when not
364 # to improvise things not in the instructions, like 'make makedefs' here
367 # make sure object files from src are available when needed
369 $(OBJDIR)/alloc.o: ../src/alloc.c $(CONFIG_H)
370 $(CC) $(CFLAGS) -c ../src/alloc.c -o $@
371 $(OBJDIR)/drawing.o: ../src/drawing.c $(CONFIG_H)
372 $(CC) $(CFLAGS) -c ../src/drawing.c -o $@
373 $(OBJDIR)/decl.o: ../src/decl.c $(CONFIG_H)
374 $(CC) $(CFLAGS) -c ../src/decl.c -o $@
375 $(OBJDIR)/monst.o: ../src/monst.c $(CONFIG_H)
376 $(CC) $(CFLAGS) -c ../src/monst.c -o $@
377 $(OBJDIR)/objects.o: ../src/objects.c $(CONFIG_H)
378 $(CC) $(CFLAGS) -c ../src/objects.c -o $@
379 $(OBJDIR)/dlb.o: ../src/dlb.c $(HACK_H) ../include/dlb.h
380 $(CC) $(CFLAGS) -c ../src/dlb.c -o $@
382 # make sure hack.h dependencies get transitive information
383 $(HACK_H): $(CONFIG_H)
384 @( cd ../src ; $(MAKE) $(HACK_H) )
385 $(CONFIG_H): ../include/config.h
386 @( cd ../src ; $(MAKE) $(CONFIG_H) )
389 @ctags -tw $(UTILSRCS)
395 -rm -f lev_lex.c lev_yacc.c dgn_lex.c dgn_yacc.c
396 -rm -f ../include/lev_comp.h ../include/dgn_comp.h
397 -rm -f ../include/tile.h
398 -rm -f makedefs lev_comp dgn_comp recover dlb
399 -rm -f gif2txt txt2ppm tile2x11 tile2img.ttp xpm2img.ttp tilemap
401 tileedit: tileedit.cpp $(TEXT_IO)
402 $(QTDIR)/bin/moc -o tileedit.moc tileedit.h
403 $(CC) -o tileedit -I../include -I$(QTDIR)/include -L$(QTDIR)/lib tileedit.cpp $(TEXT_IO) -lqt