1 # Makefile for aNetHack's utility programs.
2 # aNetHack 0.0.1 Makefile.utl $ANH-Date: 1454712070 2016/02/05 22:41:10 $ $ANH-Branch: master $:$ANH-Revision: 1.29 $
7 # newer makes predefine $(MAKE) to 'make' and do smarter processing of
8 # recursive make calls if $(MAKE) is used
9 # these makes allow $(MAKE) to be overridden by the environment if someone
10 # wants to (or has to) use something other than the standard make, so we do
11 # not want to unconditionally set $(MAKE) here
13 # unfortunately, some older makes do not predefine $(MAKE); if you have one of
14 # these, uncomment the following line
15 # (you will know that you have one if you get complaints about unable to
16 # execute things like 'foo.o')
19 # if you are using gcc as your compiler,
20 # uncomment the CC definition below if it's not in your environment
23 # For Bull DPX/2 systems at B.O.S. 2.0 or higher use the following:
25 # CC = gcc -ansi -D_BULL_SOURCE -D_XOPEN_SOURCE -D_POSIX_SOURCE
27 # If you are using GCC 2.2.2 or higher on a DPX/2, just use:
31 # For HP/UX 10.20 with GCC:
32 # CC = gcc -D_POSIX_SOURCE
34 # if your make doesn't define a default SHELL properly, you may need
35 # the line below (Atari users will need a bourne work-alike)
38 # SHELL=E:/GEMINI2/MUPFEL.TTP
40 # flags may have to be changed as required
41 # flags for 286 Xenix:
42 # CFLAGS = -Ml2t16 -O -LARGE -I../include
43 # LFLAGS = -Ml -F 4000 -SEG 512
45 # flags for 286 Microport SysV-AT
46 # CFLAGS = -DDUMB -Ml -I../include
49 # flags for Atari GCC (3.2.1)
50 # CFLAGS = -O -I../include
52 # flags for Atari GCC (3.3)
53 # CFLAGS = -mshort -O2 -I../include
56 # flags for Apollos using their native cc
57 # (as long as it claims to be __STDC__ but isn't)
58 # CFLAGS = -DAPOLLO -O -I../include
60 # flags for AIX 3.1 cc on IBM RS/6000 to define
61 # a suitable subset of standard libraries
62 # (note that there is more info regarding the "-qchars=signed"
63 # switch in file Install.unx note 8)
64 # CFLAGS = -D_NO_PROTO -D_XOPEN_SOURCE -O -I../include -qchars=signed
66 # CFLAGS = -D_NO_PROTO -D_XOPEN_SOURCE -D_ALL_SOURCE -O -I../include -qchars=signed
68 # flags for A/UX 2.01 using native cc or c89
69 # gcc predefines AUX so that's not needed there
70 # CFLAGS = -ZS -D_POSIX_SOURCE -O -I../include -DAUX
72 # flags for IRIX 4.0.x using native cc
73 # SGI cc 3.10 will fail to compile makedefs with -O
74 # CFLAGS = -I../include -D__STDC__ -woff 100,293
78 # CFLAGS = -O2 -fomit-frame-pointer -I../include
79 # LFLAGS = -L/usr/X11R6/lib
80 # OR compile backwards compatible a.out format
81 # CFLAGS = -O2 -b i486-linuxaout -fomit-frame-pointer -I../include
82 # LFLAGS = -b i486-linuxaout -L/usr/X11R6/lib
84 # flags for BeOS using the command line
85 # remember to uncomment flex and bison below
86 # BeOS on a Mac/BeBox:
88 #CFLAGS = -I../include
90 # the default values are fine
92 # flags for debugging:
93 # CFLAGS = -g -I../include
95 #CFLAGS = -O -I../include
98 # we specify C preprocessor flags via CFLAGS; files built with default rules
99 # might include $(CPPFLAGS) which could get a value from user's environment;
100 # we avoid that by forcing it empty rather than by overriding default rules
105 # If you are cross-compiling, you must use this:
107 # otherwise, you can save a little bit of disk space with this:
110 # yacc/lex programs to use to generate *_comp.h, *_lex.c, and *_yacc.c.
111 # if, instead of yacc/lex you have bison/flex, comment/uncomment the following.
118 # these are the names of the output files from YACC/LEX. Under MS-DOS
119 # and similar systems, they may differ
129 # ----------------------------------------
131 # Nothing below this line should have to be changed.
133 # timestamps for primary header files, matching src/Makefile
134 CONFIG_H = ../src/config.h-t
135 HACK_H = ../src/hack.h-t
139 SPLEVSRC = lev_yacc.c lev_lex.c lev_main.c
140 DGNCOMPSRC = dgn_yacc.c dgn_lex.c dgn_main.c
143 UTILSRCS = $(MAKESRC) panic.c $(SPLEVSRC) $(DGNCOMPSRC) $(RECOVSRC) $(DLBSRC)
145 # files that define all monsters and objects
146 CMONOBJ = ../src/monst.c ../src/objects.c
147 OMONOBJ = $(OBJDIR)/monst.o $(OBJDIR)/objects.o
148 # files that provide access to aNetHack's names
149 CNAMING = ../src/drawing.c ../src/decl.c $(CMONOBJ)
150 ONAMING = $(OBJDIR)/drawing.o $(OBJDIR)/decl.o $(OMONOBJ)
151 # dynamic memory allocation
152 CALLOC = ../src/alloc.c panic.c
153 OALLOC = $(OBJDIR)/alloc.o panic.o
155 # object files for makedefs
156 MAKEOBJS = makedefs.o $(OMONOBJ)
158 # object files for special levels compiler
159 SPLEVOBJS = lev_yacc.o lev_lex.o lev_main.o $(OALLOC) $(ONAMING)
161 # object files for dungeon compiler
162 DGNCOMPOBJS = dgn_yacc.o dgn_lex.o dgn_main.o $(OALLOC)
164 # object files for recovery utility
165 RECOVOBJS = recover.o
167 # object files for the data librarian
168 DLBOBJS = dlb_main.o $(OBJDIR)/dlb.o $(OALLOC)
170 # flags for creating distribution versions of sys/share/*_lex.c, using
171 # a more portable flex skeleton, which is not included in the distribution.
172 # hopefully keeping this out of the section to be edited will keep too
173 # many people from being confused by it...
174 # FLEXDIST = -L -S../sys/share/flexhack.skl
177 # flags for creating distribution versions of sys/share/*_yacc.c, without
178 # line numbers so patches from version to version are practical
183 # dependencies for makedefs
185 makedefs: $(MAKEOBJS) mdgrep.h
186 $(CC) $(LFLAGS) -o makedefs $(MAKEOBJS)
188 makedefs.o: makedefs.c $(CONFIG_H) ../include/permonst.h \
189 ../include/objclass.h ../include/monsym.h \
190 ../include/artilist.h ../include/dungeon.h ../include/obj.h \
191 ../include/monst.h ../include/you.h ../include/flag.h \
192 ../include/dlb.h ../include/patchlevel.h ../include/qtext.h
194 # Don't require perl to build; that is why mdgrep.h is spelled wrong below.
198 ../include/onames.h: makedefs
200 ../include/pm.h: makedefs
202 ../src/monstr.c: makedefs
204 ../include/vis_tab.h: makedefs
206 # makedefs -z makes both vis_tab.h and vis_tab.c, but writes the .h first
207 ../src/vis_tab.c: ../include/vis_tab.h
210 @lint -axbh -I../include -DLINT $(MAKESRC) $(CMONOBJ) | sed '/_flsbuf/d'
213 # we defer this makedefs call to the src Makefile, since it knows all about
214 # the main src and include files date.h is a timestamp for
216 @( cd ../src ; $(MAKE) ../include/date.h )
218 # support code used by several of the utility programs (but not makedefs)
219 panic.o: panic.c $(CONFIG_H)
222 # dependencies for lev_comp
224 lev_comp: $(SPLEVOBJS)
225 $(CC) $(LFLAGS) -o lev_comp $(SPLEVOBJS) $(LIBS)
227 lev_yacc.o: lev_yacc.c $(HACK_H) ../include/sp_lev.h
228 lev_main.o: lev_main.c $(HACK_H) ../include/sp_lev.h ../include/tcap.h \
231 # see lev_comp.l for WEIRD_LEX discussion
232 # egrep will return failure if it doesn't find anything, but we know there
233 # is one "_cplusplus" inside a comment
234 lev_lex.o: lev_lex.c $(HACK_H) ../include/lev_comp.h ../include/sp_lev.h
235 @echo $(CC) -c $(CFLAGS) lev_lex.c
236 @$(CC) -c $(CFLAGS) -DWEIRD_LEX=`egrep -c _cplusplus lev_lex.c` lev_lex.c
238 # '$(YACC) -d' generates both $(YTABC) and $(YTABH) in one run
239 ../include/lev_comp.h: lev_yacc.c
241 lev_yacc.c: lev_comp.y
242 $(YACC) $(YACCDIST) -d lev_comp.y
243 sed -e 's#"$(YTABC)"#"$@"#' -e 's#$(YTABC):#$@:#' $(YTABC) > $@ \
245 sed -e 's#"$(YTABH)"#"lev_comp.h"#' $(YTABH) > ../include/lev_comp.h \
248 lev_lex.c: lev_comp.l
249 $(LEX) $(FLEXDIST) lev_comp.l
250 sed -e 's#"$(LEXYYC)"#"$@"#' -e 's# *$$##' $(LEXYYC) > $@ \
252 # note: flex code construction using m4 macros results in some trailing
253 # spaces; <space><space><star> is basic RE substitute for <space><plus>
254 # and we don't bother stripping trailing tabs because that gets messy;
255 # make expands <dollar><dollar> into <dollar> which is RE end-of-line.
257 # with all of extern.h's functions to complain about, we drown in
258 # 'defined but not used' without -u
260 @lint -axhu -I../include -DLINT $(SPLEVSRC) $(CALLOC) $(CNAMING) | sed '/_flsbuf/d'
263 # dependencies for dgn_comp
265 dgn_comp: $(DGNCOMPOBJS)
266 $(CC) $(LFLAGS) -o dgn_comp $(DGNCOMPOBJS) $(LIBS)
268 dgn_yacc.o: dgn_yacc.c $(CONFIG_H) ../include/dgn_file.h ../include/date.h
269 dgn_main.o: dgn_main.c $(CONFIG_H) ../include/dlb.h
271 # see dgn_comp.l for WEIRD_LEX discussion
272 dgn_lex.o: dgn_lex.c $(CONFIG_H) ../include/dgn_comp.h ../include/dgn_file.h
273 @echo $(CC) -c $(CFLAGS) dgn_lex.c
274 @$(CC) -c $(CFLAGS) -DWEIRD_LEX=`egrep -c _cplusplus dgn_lex.c` dgn_lex.c
276 # '$(YACC) -d' generates both $(YTABC) and $(YTABH) in one run
277 ../include/dgn_comp.h: dgn_yacc.c
279 dgn_yacc.c: dgn_comp.y
280 $(YACC) $(YACCDIST) -d dgn_comp.y
281 sed -e 's#"$(YTABC)"#"$@"#' -e 's#$(YTABC):#$@:#' $(YTABC) > $@ \
283 sed -e 's#"$(YTABH)"#"dgn_comp.h"#' $(YTABH) > ../include/dgn_comp.h \
286 dgn_lex.c: dgn_comp.l
287 $(LEX) $(FLEXDIST) dgn_comp.l
288 sed -e 's#"$(LEXYYC)"#"$@"#' -e 's# *$$##' $(LEXYYC) > $@ \
290 # note: <space><space><star> is basic RE substitute for <space><plus>
292 # with all of extern.h's functions to complain about, we drown in
293 # 'defined but not used' without -u
295 @lint -axhu -I../include -DLINT $(DGNCOMPSRC) $(CALLOC) | sed '/_flsbuf/d'
298 # dependencies for recover
300 recover: $(RECOVOBJS)
301 $(CC) $(LFLAGS) -o recover $(RECOVOBJS) $(LIBS)
303 recover.o: recover.c $(CONFIG_H) ../include/date.h
306 # dependencies for dlb
309 $(CC) $(LFLAGS) -o dlb $(DLBOBJS) $(LIBS)
311 dlb_main.o: dlb_main.c $(CONFIG_H) ../include/dlb.h ../include/date.h
312 $(CC) $(CFLAGS) -c dlb_main.c
316 # dependencies for tile utilities
318 TEXT_IO = tiletext.o tiletxt.o $(OALLOC) $(ONAMING)
319 GIFREADERS = gifread.o $(OALLOC)
320 PPMWRITERS = ppmwrite.o $(OALLOC)
322 tileutils: tilemap gif2txt txt2ppm tile2x11
324 gif2txt: $(GIFREADERS) $(TEXT_IO)
325 $(CC) $(LFLAGS) -o gif2txt $(GIFREADERS) $(TEXT_IO) $(LIBS)
326 txt2ppm: $(PPMWRITERS) $(TEXT_IO)
327 $(CC) $(LFLAGS) -o txt2ppm $(PPMWRITERS) $(TEXT_IO) $(LIBS)
329 tile2x11: tile2x11.o $(TEXT_IO)
330 $(CC) $(LFLAGS) -o tile2x11 tile2x11.o $(TEXT_IO) $(LIBS)
332 tile2img.ttp: tile2img.o bitmfile.o $(TEXT_IO)
333 $(CC) $(LFLAGS) -o tile2img.ttp tile2img.o bitmfile.o $(TEXT_IO) $(LIBS)
335 tile2bmp: tile2bmp.o $(TEXT_IO)
336 $(CC) $(LFLAGS) -o tile2bmp tile2bmp.o $(TEXT_IO)
338 xpm2img.ttp: xpm2img.o bitmfile.o
339 $(CC) $(LFLAGS) -o xpm2img.ttp xpm2img.o bitmfile.o $(LIBS)
341 tile2beos: tile2beos.o $(TEXT_IO)
342 $(CC) $(LFLAGS) -o tile2beos tile2beos.o $(TEXT_IO) -lbe
344 #--compiling and linking in one step leaves extra debugging files (in their
345 # own subdirectories!) on OSX; compile and link separately to suppress
346 # that without mucking about with extra OS-specific CFLAGS and/or LFLAGS
347 #tilemap: ../win/share/tilemap.c $(HACK_H)
348 # $(CC) $(CFLAGS) $(LFLAGS) -o tilemap ../win/share/tilemap.c $(LIBS)
350 $(CC) $(LFLAGS) -o tilemap tilemap.o $(LIBS)
351 ../src/tile.c: tilemap
354 ../include/tile.h: ../win/share/tile.h
355 cp ../win/share/tile.h ../include/tile.h
356 tiletext.o: ../win/share/tiletext.c $(CONFIG_H) ../include/tile.h
357 $(CC) $(CFLAGS) -c ../win/share/tiletext.c
358 tiletxt.c: ./Makefile
359 @echo '/* alternate compilation for tilemap.c to create tiletxt.o' > tiletxt.c
360 @echo ' that does not rely on "cc -c -o tiletxt.o tilemap.c"' >> tiletxt.c
361 @echo ' since many pre-POSIX compilers did not support that */' >> tiletxt.c
362 echo '#define TILETEXT' >> tiletxt.c
363 echo '#include "../win/share/tilemap.c"' >> tiletxt.c
364 @echo '/*tiletxt.c*/' >> tiletxt.c
365 tiletxt.o: tiletxt.c ../win/share/tilemap.c $(HACK_H)
366 $(CC) $(CFLAGS) -c tiletxt.c
367 tilemap.o: ../win/share/tilemap.c $(HACK_H)
368 $(CC) $(CFLAGS) -c ../win/share/tilemap.c
370 gifread.o: ../win/share/gifread.c $(CONFIG_H) ../include/tile.h
371 $(CC) $(CFLAGS) -c ../win/share/gifread.c
372 ppmwrite.o: ../win/share/ppmwrite.c $(CONFIG_H) ../include/tile.h
373 $(CC) $(CFLAGS) -c ../win/share/ppmwrite.c
375 tile2bmp.o: ../win/share/tile2bmp.c $(HACK_H) ../include/tile.h
376 $(CC) $(CFLAGS) -c ../win/share/tile2bmp.c
378 tile2x11.o: ../win/X11/tile2x11.c $(HACK_H) ../include/tile.h \
379 ../include/tile2x11.h
380 $(CC) $(CFLAGS) -c ../win/X11/tile2x11.c
382 tile2img.o: ../win/gem/tile2img.c $(HACK_H) ../include/tile.h \
383 ../include/bitmfile.h
384 $(CC) $(CFLAGS) -c ../win/gem/tile2img.c
385 xpm2img.o: ../win/gem/xpm2img.c $(HACK_H) ../include/bitmfile.h
386 $(CC) $(CFLAGS) -c ../win/gem/xpm2img.c
387 bitmfile.o: ../win/gem/bitmfile.c ../include/bitmfile.h
388 $(CC) $(CFLAGS) -c ../win/gem/bitmfile.c
390 tile2beos.o: ../win/BeOS/tile2beos.cpp $(HACK_H) ../include/tile.h
391 $(CXX) $(CFLAGS) -c ../win/BeOS/tile2beos.cpp
393 tileedit: tileedit.cpp $(TEXT_IO)
394 $(QTDIR)/bin/moc -o tileedit.moc tileedit.h
395 $(CC) -o tileedit -I../include -I$(QTDIR)/include -L$(QTDIR)/lib \
396 tileedit.cpp $(TEXT_IO) -lqt
398 # using dependencies like
400 # @( cd ../src ; $(MAKE) foo )
401 # would always force foo to be up-to-date according to the src Makefile
402 # when it's needed here. unfortunately, some makes believe this syntax
403 # means foo always changes, instead of foo should always be checked.
404 # therefore, approximate via config.h dependencies, and hope that anybody
405 # changing anything other than basic configuration also knows when not
406 # to improvise things not in the instructions, like 'make makedefs' here
409 # make sure object files from src are available when needed
411 $(OBJDIR)/alloc.o: ../src/alloc.c $(CONFIG_H)
412 $(CC) $(CFLAGS) -c ../src/alloc.c -o $@
413 $(OBJDIR)/drawing.o: ../src/drawing.c $(CONFIG_H)
414 $(CC) $(CFLAGS) -c ../src/drawing.c -o $@
415 $(OBJDIR)/decl.o: ../src/decl.c $(CONFIG_H)
416 $(CC) $(CFLAGS) -c ../src/decl.c -o $@
417 $(OBJDIR)/monst.o: ../src/monst.c $(CONFIG_H)
418 $(CC) $(CFLAGS) -c ../src/monst.c -o $@
419 $(OBJDIR)/objects.o: ../src/objects.c $(CONFIG_H)
420 $(CC) $(CFLAGS) -c ../src/objects.c -o $@
421 $(OBJDIR)/dlb.o: ../src/dlb.c $(CONFIG_H) ../include/dlb.h
422 $(CC) $(CFLAGS) -c ../src/dlb.c -o $@
424 # make sure hack.h dependencies get transitive information
425 $(HACK_H): $(CONFIG_H)
426 @( cd ../src ; $(MAKE) $(HACK_H) )
427 $(CONFIG_H): ../include/config.h
428 @( cd ../src ; $(MAKE) $(CONFIG_H) )
430 # 'make dist' => put generated lex and yacc sources into place for distribution
431 SYSSHARE=../sys/share/
432 $(SYSSHARE)lev_lex.c: lev_lex.c
434 $(SYSSHARE)lev_yacc.c: lev_yacc.c
436 $(SYSSHARE)lev_comp.h: ../include/lev_comp.h
437 cp ../include/lev_comp.h $@
438 $(SYSSHARE)dgn_lex.c: dgn_lex.c
440 $(SYSSHARE)dgn_yacc.c: dgn_yacc.c
442 $(SYSSHARE)dgn_comp.h: ../include/dgn_comp.h
443 cp ../include/dgn_comp.h $@
445 dist: $(SYSSHARE)lev_lex.c $(SYSSHARE)lev_yacc.c $(SYSSHARE)lev_comp.h \
446 $(SYSSHARE)dgn_lex.c $(SYSSHARE)dgn_yacc.c $(SYSSHARE)dgn_comp.h
447 @echo 'pre-generated lex and yacc sources are in place in sys/share'
450 @ctags -tw $(UTILSRCS)
456 -rm -f lev_lex.c lev_yacc.c dgn_lex.c dgn_yacc.c
457 -rm -f ../include/lev_comp.h ../include/dgn_comp.h
458 -rm -f ../include/tile.h tiletxt.c
459 -rm -f makedefs lev_comp dgn_comp recover dlb
460 -rm -f gif2txt txt2ppm tile2x11 tile2img.ttp xpm2img.ttp \