1# Makefile for NetHack's utility programs. 2# SCCS Id: @(#)Makefile.utl 3.4 1997/04/19 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 'foo.o') 14# MAKE = make 15 16# if you are using gcc as your compiler, 17# uncomment the CC definition below if it's not in your environment 18# CC = gcc 19# 20# For Bull DPX/2 systems at B.O.S. 2.0 or higher use the following: 21# 22# CC = gcc -ansi -D_BULL_SOURCE -D_XOPEN_SOURCE -D_POSIX_SOURCE 23# 24# If you are using GCC 2.2.2 or higher on a DPX/2, just use: 25# 26# CC = gcc -ansi 27# 28# For HP/UX 10.20 with GCC: 29# CC = gcc -D_POSIX_SOURCE 30# 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) 33# SHELL = /bin/sh 34# for Atari 35# SHELL=E:/GEMINI2/MUPFEL.TTP 36 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 41 42# flags for 286 Microport SysV-AT 43# CFLAGS = -DDUMB -Ml -I../include 44# LFLAGS = -Ml 45 46# flags for Atari GCC (3.2.1) 47# CFLAGS = -O -I../include 48# LFLAGS = -s 49# flags for Atari GCC (3.3) 50# CFLAGS = -mshort -O2 -I../include 51# LFLAGS = -mshort -s 52 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 56 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 62# and for AIX 3.2: 63# CFLAGS = -D_NO_PROTO -D_XOPEN_SOURCE -D_ALL_SOURCE -O -I../include -qchars=signed 64 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 68 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 72 73# flags for Linux 74# compile normally 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 80 81# flags for BeOS using the command line 82# remember to uncomment flex and bison below 83# BeOS on a Mac/BeBox: 84#CC = mwcc 85#CFLAGS = -I../include 86# BeOS on Intel: 87# the default values are fine 88 89# flags for debugging: 90# CFLAGS = -g -I../include 91 92CFLAGS = -O -I../include 93LFLAGS = 94 95LIBS = 96 97# If you are cross-compiling, you must use this: 98#OBJDIR = . 99# otherwise, you can save a little bit of disk space with this: 100OBJDIR = ../src 101 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. 104YACC = yacc 105LEX = lex 106# YACC = bison -y 107# YACC = byacc 108# LEX = flex 109 110# these are the names of the output files from YACC/LEX. Under MS-DOS 111# and similar systems, they may differ 112YTABC = y.tab.c 113YTABH = y.tab.h 114LEXYYC = lex.yy.c 115# YTABC = y_tab.c 116# YTABH = y_tab.h 117# LEXYYC = lexyy.c 118 119 120 121# ---------------------------------------- 122# 123# Nothing below this line should have to be changed. 124 125# timestamps for primary header files, matching src/Makefile 126CONFIG_H = ../src/config.h-t 127HACK_H = ../src/hack.h-t 128 129# utility .c files 130MAKESRC = makedefs.c 131SPLEVSRC = lev_yacc.c lev_lex.c lev_main.c 132DGNCOMPSRC = dgn_yacc.c dgn_lex.c dgn_main.c 133RECOVSRC = recover.c 134DLBSRC = dlb_main.c 135UTILSRCS = $(MAKESRC) panic.c $(SPLEVSRC) $(DGNCOMPSRC) $(RECOVSRC) $(DLBSRC) 136 137# files that define all monsters and objects 138CMONOBJ = ../src/monst.c ../src/objects.c 139OMONOBJ = $(OBJDIR)/monst.o $(OBJDIR)/objects.o 140# files that provide access to NetHack's names 141CNAMING = ../src/drawing.c ../src/decl.c $(CMONOBJ) 142ONAMING = $(OBJDIR)/drawing.o $(OBJDIR)/decl.o $(OMONOBJ) 143# dynamic memory allocation 144CALLOC = ../src/alloc.c panic.c 145OALLOC = $(OBJDIR)/alloc.o panic.o 146 147# object files for makedefs 148MAKEOBJS = makedefs.o $(OMONOBJ) 149 150# object files for special levels compiler 151SPLEVOBJS = lev_yacc.o lev_lex.o lev_main.o $(OALLOC) $(ONAMING) 152 153# object files for dungeon compiler 154DGNCOMPOBJS = dgn_yacc.o dgn_lex.o dgn_main.o $(OALLOC) 155 156# object files for recovery utility 157RECOVOBJS = recover.o 158 159# object files for the data librarian 160DLBOBJS = dlb_main.o $(OBJDIR)/dlb.o $(OALLOC) 161 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 167FLEXDIST = 168# 169# flags for creating distribution versions of sys/share/*_yacc.c, without 170# line numbers so patches from version to version are practical 171# YACCDIST = -l 172YACCDIST = 173 174 175# dependencies for makedefs 176# 177makedefs: $(MAKEOBJS) 178 $(CC) $(LFLAGS) -o makedefs $(MAKEOBJS) 179 180makedefs.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 185 186../include/onames.h: makedefs 187 ./makedefs -o 188../include/pm.h: makedefs 189 ./makedefs -p 190../src/monstr.c: makedefs 191 ./makedefs -m 192../include/vis_tab.h: makedefs 193 ./makedefs -z 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 196 197lintdefs: 198 @lint -axbh -I../include -DLINT $(MAKESRC) $(CMONOBJ) | sed '/_flsbuf/d' 199 200 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 203../include/date.h:: 204 @( cd ../src ; $(MAKE) ../include/date.h ) 205 206# support code used by several of the utility programs (but not makedefs) 207panic.o: panic.c $(CONFIG_H) 208 209 210# dependencies for lev_comp 211# 212lev_comp: $(SPLEVOBJS) 213 $(CC) $(LFLAGS) -o lev_comp $(SPLEVOBJS) $(LIBS) 214 215lev_yacc.o: lev_yacc.c $(HACK_H) ../include/sp_lev.h 216lev_main.o: lev_main.c $(HACK_H) ../include/sp_lev.h ../include/tcap.h \ 217 ../include/date.h 218 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 222lev_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 225 226../include/lev_comp.h: lev_yacc.c 227 228lev_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 232 233lev_lex.c: lev_comp.l 234 $(LEX) $(FLEXDIST) lev_comp.l 235 mv $(LEXYYC) lev_lex.c 236 237# with all of extern.h's functions to complain about, we drown in 238# 'defined but not used' without -u 239lintlev: 240 @lint -axhu -I../include -DLINT $(SPLEVSRC) $(CALLOC) $(CNAMING) | sed '/_flsbuf/d' 241 242 243# dependencies for dgn_comp 244# 245dgn_comp: $(DGNCOMPOBJS) 246 $(CC) $(LFLAGS) -o dgn_comp $(DGNCOMPOBJS) $(LIBS) 247 248dgn_yacc.o: dgn_yacc.c $(CONFIG_H) ../include/dgn_file.h ../include/date.h 249dgn_main.o: dgn_main.c $(CONFIG_H) ../include/dlb.h 250 251# see dgn_comp.l for WEIRD_LEX discussion 252dgn_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 255 256 257../include/dgn_comp.h: dgn_yacc.c 258 259dgn_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 263 264dgn_lex.c: dgn_comp.l 265 $(LEX) $(FLEXDIST) dgn_comp.l 266 mv $(LEXYYC) dgn_lex.c 267 268# with all of extern.h's functions to complain about, we drown in 269# 'defined but not used' without -u 270lintdgn: 271 @lint -axhu -I../include -DLINT $(DGNCOMPSRC) $(CALLOC) | sed '/_flsbuf/d' 272 273 274# dependencies for recover 275# 276recover: $(RECOVOBJS) 277 $(CC) $(LFLAGS) -o recover $(RECOVOBJS) $(LIBS) 278 279recover.o: recover.c $(CONFIG_H) ../include/date.h 280 281 282# dependencies for dlb 283# 284dlb: $(DLBOBJS) 285 $(CC) $(LFLAGS) -o dlb $(DLBOBJS) $(LIBS) 286 287dlb_main.o: dlb_main.c $(CONFIG_H) ../include/dlb.h ../include/date.h 288 $(CC) $(CFLAGS) -c dlb_main.c 289 290 291 292# dependencies for tile utilities 293# 294TEXT_IO = tiletext.o tiletxt.o $(ONAMING) 295GIFREADERS = gifread.o $(OALLOC) 296PPMWRITERS = ppmwrite.o $(OALLOC) 297 298tileutils: tilemap gif2txt txt2ppm tile2x11 299 300gif2txt: $(GIFREADERS) $(TEXT_IO) 301 $(CC) $(LFLAGS) -o gif2txt $(GIFREADERS) $(TEXT_IO) $(LIBS) 302txt2ppm: $(PPMWRITERS) $(TEXT_IO) 303 $(CC) $(LFLAGS) -o txt2ppm $(PPMWRITERS) $(TEXT_IO) $(LIBS) 304 305tile2x11: tile2x11.o $(TEXT_IO) 306 $(CC) $(LFLAGS) -o tile2x11 tile2x11.o $(TEXT_IO) $(LIBS) 307 308tile2img.ttp: tile2img.o bitmfile.o $(TEXT_IO) 309 $(CC) $(LFLAGS) -o tile2img.ttp tile2img.o bitmfile.o $(TEXT_IO) $(LIBS) 310 311tile2bmp: tile2bmp.o $(TEXT_IO) 312 $(CC) $(LFLAGS) -o tile2bmp tile2bmp.o $(TEXT_IO) 313 314xpm2img.ttp: xpm2img.o bitmfile.o 315 $(CC) $(LFLAGS) -o xpm2img.ttp xpm2img.o bitmfile.o $(LIBS) 316 317tile2beos: tile2beos.o $(TEXT_IO) 318 $(CC) $(LFLAGS) -o tile2beos tile2beos.o $(TEXT_IO) -lbe 319 320tilemap: ../win/share/tilemap.c $(HACK_H) 321 $(CC) $(CFLAGS) $(LFLAGS) -o tilemap ../win/share/tilemap.c $(LIBS) 322../src/tile.c: tilemap 323 ./tilemap 324 325../include/tile.h: ../win/share/tile.h 326 cp ../win/share/tile.h ../include/tile.h 327tiletext.o: ../win/share/tiletext.c $(CONFIG_H) ../include/tile.h 328 $(CC) $(CFLAGS) -c ../win/share/tiletext.c 329tiletxt.o: ../win/share/tilemap.c $(HACK_H) 330 $(CC) $(CFLAGS) -c -DTILETEXT ../win/share/tilemap.c 331 mv tilemap.o tiletxt.o 332 333gifread.o: ../win/share/gifread.c $(CONFIG_H) ../include/tile.h 334 $(CC) $(CFLAGS) -c ../win/share/gifread.c 335ppmwrite.o: ../win/share/ppmwrite.c $(CONFIG_H) ../include/tile.h 336 $(CC) $(CFLAGS) -c ../win/share/ppmwrite.c 337 338tile2bmp.o: ../win/share/tile2bmp.c $(HACK_H) ../include/tile.h 339 $(CC) $(CFLAGS) -c ../win/share/tile2bmp.c 340 341tile2x11.o: ../win/X11/tile2x11.c $(HACK_H) ../include/tile.h \ 342 ../include/tile2x11.h 343 $(CC) $(CFLAGS) -c ../win/X11/tile2x11.c 344 345tile2img.o: ../win/gem/tile2img.c $(HACK_H) ../include/tile.h \ 346 ../include/bitmfile.h 347 $(CC) $(CFLAGS) -c ../win/gem/tile2img.c 348xpm2img.o: ../win/gem/xpm2img.c $(HACK_H) ../include/bitmfile.h 349 $(CC) $(CFLAGS) -c ../win/gem/xpm2img.c 350bitmfile.o: ../win/gem/bitmfile.c ../include/bitmfile.h 351 $(CC) $(CFLAGS) -c ../win/gem/bitmfile.c 352 353tile2beos.o: ../win/BeOS/tile2beos.cpp $(HACK_H) ../include/tile.h 354 $(CXX) $(CFLAGS) -c ../win/BeOS/tile2beos.cpp 355 356# using dependencies like 357# ../src/foo:: 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 365# in util... 366 367# make sure object files from src are available when needed 368# 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 $@ 381 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) ) 387 388tags: $(UTILSRCS) 389 @ctags -tw $(UTILSRCS) 390 391clean: 392 -rm -f *.o 393 394spotless: clean 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 400 401tileedit: 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 404