1# $Id$ 2# File: Makefile 3 4# This is not a very "nice" Makefile, but it usually works. 5 6 7# --------------------------------- READ THIS --------------------------------- 8# 9# Currently, only 4 target builds are supported for building the client: 10# 11# -DWIN32 for Windows 12# -DUSE_X11 (optionally with USE_GCU) for X11 client 13# -DUSE_X11 )optionally with USE_GCU) with -DOSX for a Mac OSX client 14# -DUSE_GCU for a linux ncurses command-line client 15# 16# The below paragraph that mentions a bunch of other targets such as 17# Mac/IBM/LSL/ACN/XAW is long outdated. 18# 19# Additionally, -DSOUND_SDL and the according sdl-config call for both compiler 20# and linker flags and linking against -lSDL_mixer should be added so the 21# client provides SDL sound/music support. 22 23 24# 25# Note that you may have to make modifications below according 26# to your machine, available libraries, compilation options, 27# and your "visual module" of choice. This Makefile is intended 28# for use with Unix machines running X11, Curses, Ncurses, or Vt100, 29# or possibly for "Atari" or "Amiga" computers with "Curses" ports, 30# see below for more information. 31# 32# Note that "main-mac.c", the visual module for the Macintosh, 33# must be compiled in a special way, see elsewhere. 34# 35# Note that "main-win.c", the visual module for Windows, 36# must be compiled in a special way, see elsewhere. 37# 38# Note that "main-ibm.c", "main-emx.c", and "main-286.c", 39# the visual modules for various types of IBM-PC computers, 40# must be compiled with special Makefiles, see elsewhere. 41# 42# Note that "main-lsl.c", the visual module for ???, 43# must be compiled with "Makefile.lsl", see elsewhere. 44# 45# Note that "main-acn.c", the visual module for Risc Acorn, 46# must be compiled with "Makefile.acn", see elsewhere. 47# 48# Note that "Makefile.w31" and "Makefile.wat" are slight variations 49# on "Makefile.win" and "Makefile.ibm", respectively, which allow 50# the use of the "main-win.c" and "main-ibm.c" files, respectively, 51# with special compilers. 52# 53# If you are able to construct "main-xxx.c" and/or "Makefile.xxx" 54# files for a currently unsupported system, please send them to me 55# (benh@voicenet.com) for inclusion in future versions. 56# 57# This Makefile comes with "default" dependancies that may be obsolete. 58# 59# You may want to run "make depend" if you are planning on changing 60# anything. 61# 62 63 64# 65# The "source" and "object" files. 66# 67 68SERV_SRCS = \ 69 common/z-util.c common/z-virt.c common/z-form.c common/z-rand.c \ 70 common/net-unix.c common/sockbuf.c common/common.c \ 71 server/variable.c server/control.c server/hooks.c \ 72 server/party.c server/tables.c server/util.c server/cave.c \ 73 server/object1.c server/object2.c server/monster2.c \ 74 server/xtra1.c server/xtra2.c server/spells1.c server/spells2.c \ 75 server/melee1.c server/melee2.c server/save.c server/files.c \ 76 server/cmd1.c server/cmd2.c server/cmd3.c server/cmd4.c server/cmd5.c \ 77 server/cmd6.c server/store.c server/birth.c server/load2.c server/randart.c \ 78 server/sched.c server/generate.c server/wild.c server/dungeon.c \ 79 server/init1.c server/init2.c server/nserver.c server/printout.c \ 80 server/main.c server/traps.c server/csfunc.c server/skills.c server/bldg.c \ 81 common/files.c common/w_z_pack.c server/world.c server/slash.c \ 82 server/runecraft.c server/auction.c server/quests.c common/SFMT.c \ 83 server/go.c server/metaclient.c common/tables.c 84 85SERV_OBJS = \ 86 common/z-util.o common/z-virt.o common/z-form.o common/z-rand.o \ 87 common/net-unix.o common/sockbuf.o common/common.o \ 88 server/variable.o server/control.o server/hooks.o \ 89 server/party.o server/tables.o server/util.o server/cave.o \ 90 server/object1.o server/object2.o server/monster2.o \ 91 server/xtra1.o server/xtra2.o server/spells1.o server/spells2.o \ 92 server/melee1.o server/melee2.o server/save.o server/files.o \ 93 server/cmd1.o server/cmd2.o server/cmd3.o server/cmd4.o server/cmd5.o \ 94 server/cmd6.o server/store.o server/birth.o server/load2.o server/randart.o \ 95 server/sched.o server/generate.o server/wild.o server/dungeon.o \ 96 server/init1.o server/init2.o server/nserver.o server/printout.o \ 97 server/main.o server/traps.o server/csfunc.o server/skills.o server/bldg.o \ 98 common/files.o common/w_z_pack.o server/world.o server/slash.o \ 99 server/runecraft.o server/auction.o server/quests.o common/SFMT.o \ 100 server/go.o server/metaclient.o common/tables.o 101 102 103CLI_SRCS = \ 104 common/z-util.c common/z-virt.c common/z-form.c common/z-rand.c \ 105 common/net-unix.c common/sockbuf.c common/net-ibm.c common/common.c \ 106 client/z-term.c client/c-util.c client/c-cmd.c client/c-inven.c \ 107 client/c-files.c client/c-tables.c client/c-store.c client/c-init.c \ 108 client/variable.c client/main-ibm.c client/main-cap.c client/main-gcu.c \ 109 client/main-x11.c client/main-xaw.c client/nclient.c client/c-birth.c \ 110 client/c-xtra1.c client/c-xtra2.c client/c-spell.c client/client.c \ 111 client/skills.c common/files.c common/SFMT.c client/snd-sdl.c \ 112 common/tables.c 113 114CLI_OBJS = \ 115 common/z-util.o common/z-virt.o common/z-form.o common/z-rand.o \ 116 common/net-unix.o common/sockbuf.o common/net-ibm.o common/common.o \ 117 client/z-term.o client/c-util.o client/c-cmd.o client/c-inven.o \ 118 client/c-files.o client/c-tables.o client/c-store.o client/c-init.o \ 119 client/variable.o client/main-ibm.o client/main-cap.o client/main-gcu.o \ 120 client/main-x11.o client/main-xaw.o client/nclient.o client/c-birth.o \ 121 client/c-xtra1.o client/c-xtra2.o client/c-spell.o client/client.o \ 122 client/skills.o common/files.o common/SFMT.o client/snd-sdl.o \ 123 common/tables.o 124 125 126CONS_SRCS = \ 127 common/z-util.c common/z-virt.c common/z-form.c common/net-unix.c \ 128 common/sockbuf.c common/net-ibm.c common/common.c \ 129 console/z-term.c common/z-rand.c \ 130 client/main-ibm.c client/main-cap.c client/main-gcu.c \ 131 client/main-x11.c client/main-xaw.c client/c-tables.c \ 132 console/variable.c console/c-util.c console/console.c console/c-init.c \ 133 common/SFMT.c 134 135CONS_OBJS = \ 136 common/z-util.o common/z-virt.o common/z-form.o common/net-unix.o \ 137 common/sockbuf.o common/net-ibm.o common/common.o \ 138 console/z-term.o common/z-rand.o \ 139 client/main-ibm.o client/main-cap.o client/main-gcu.o \ 140 client/main-x11.o client/main-xaw.o client/c-tables.o \ 141 console/variable.o console/c-util.o console/console.o console/c-init.o \ 142 common/SFMT.o 143 144 145LUASRCS = \ 146 server/script.c client/lua_bind.c \ 147 server/w_util.c server/w_play.c server/w_spells.c 148 149# TODO: lua directory should be under common/ and not server/ 150TOLUASRCS = \ 151 server/lua/lapi.c server/lua/lcode.c server/lua/ldebug.c server/lua/ldo.c server/lua/lfunc.c server/lua/lgc.c \ 152 server/lua/llex.c server/lua/lmem.c server/lua/lobject.c server/lua/lparser.c server/lua/lstate.c server/lua/lstring.c \ 153 server/lua/ltable.c server/lua/ltests.c server/lua/ltm.c server/lua/lundump.c server/lua/lvm.c server/lua/lzio.c \ 154 server/lua/lauxlib.c server/lua/lbaselib.c server/lua/ldblib.c server/lua/liolib.c server/lua/lstrlib.c \ 155 server/lua/tolua_lb.c server/lua/tolua_rg.c server/lua/tolua_tt.c server/lua/tolua_tm.c server/lua/tolua_gp.c \ 156 server/lua/tolua_eh.c server/lua/tolua_bd.c server/lua/lmathlib.c 157 158LUAOBJS = \ 159 server/script.o server/lua_bind.o \ 160 server/w_util.o server/w_play.o server/w_spells.o 161 162TOLUAOBJS = \ 163 server/lua/lapi.o server/lua/lcode.o server/lua/ldebug.o server/lua/ldo.o server/lua/lfunc.o server/lua/lgc.o \ 164 server/lua/llex.o server/lua/lmem.o server/lua/lobject.o server/lua/lparser.o server/lua/lstate.o server/lua/lstring.o \ 165 server/lua/ltable.o server/lua/ltests.o server/lua/ltm.o server/lua/lundump.o server/lua/lvm.o server/lua/lzio.o \ 166 server/lua/lauxlib.o server/lua/lbaselib.o server/lua/ldblib.o server/lua/liolib.o server/lua/lstrlib.o \ 167 server/lua/tolua_lb.o server/lua/tolua_rg.o server/lua/tolua_tt.o server/lua/tolua_tm.o server/lua/tolua_gp.o \ 168 server/lua/tolua_eh.o server/lua/tolua_bd.o server/lua/lmathlib.o 169 170CLI_LUASRCS = \ 171 client/c-script.c client/lua_bind.c \ 172 client/w_play.c client/w_util.c client/w_spells.c 173 174# server/lua_bind.c \ 175# server/w_util.c server/w_play.c 176 177CLI_LUAOBJS = \ 178 client/c-script.o client/lua_bind.o \ 179 client/w_play.o client/w_util.o client/w_spells.o 180 181## 182## Following are some "system" definitions 183## 184## No changes are needed to compile a version that will run on both 185## X11 and Curses, in debugging mode, with maximal warnings, on many 186## normal Unix machines of the Sun OS variety (non-solaris). 187## 188## To use an "alternative" definition, simply "modify" (or "replace") 189## the definition below with one that you like. For example, you can 190## change the compiler to "cc", or remove the "debugging" options, or 191## remove the X11 or Curses support, etc, as desired. 192## 193## See also "config.h" and "h-config.h" for important information. 194## 195## Some "examples" are given below, they can be used by simply 196## removing the FIRST column of "#" signs from the "block" of lines 197## you wish to use, and commenting out "standard" block below. 198## 199## This is not intended to be a "good" Makefile, just a "simple" one. 200## 201 202 203# 204# This is my compiler of choice, it seems to work most everywhere 205# 206CC ?= cc 207 208# For allowing #if..#else..#endif constructs in LUA files - C. Blue 209# Note: The flags must contain 210# 1) the option that turns off elimination of comment lines (ie cpp 211# must just copy comments 1:1). Usually this is '-C'. 212# 2) the option that turns off generation of a preprocessor header 213# (lines starting on '# '). Usually this is '-P'. 214# Also, if your system doesnt have a dedicated cpp command, you might 215# need to use the gcc invocation below instead. 216# 217# cpp variant: 218CPP = cpp 219CPPFLAGS = -C -P 220# gcc variant: 221#CPP = gcc 222#CPPFLAGS = -x c -E -Wp,-C,-P 223 224 225# For variations with X11 226X11BASE = /usr/X11R6 227 228 229## 230## Standard version -- supports X11 (main-x11.c) 231## Standard client for X11 usage. 232## 233# You may have to add various X11 include/library directories to the 234# "CFLAGS", if your machine places files in a weird location. 235# 236## With SDL 237#CFLAGS = -g -pipe -Wall -DUSE_X11 -I${X11BASE}/include -D_XOPEN_SOURCE -D_BSD_SOURCE -DMEXP=19937 -DSOUND_SDL `sdl-config --cflags` 238#LIBS = -L${X11BASE}/lib -L/usr/pkg/lib -lX11 -lcrypt -lm `sdl-config --libs` -lSDL_mixer 239## 240## Without SDL 241#CFLAGS = -g -pipe -Wall -DUSE_X11 -I${X11BASE}/include -D_XOPEN_SOURCE -D_BSD_SOURCE -DMEXP=19937 242#LIBS = -L${X11BASE}/lib -L/usr/pkg/lib -lX11 -lcrypt -lm 243 244## 245## Variation: main-x11.c and main-gcu.c 246## This version supports both "X11" and "curses" in a single executable. 247## 248# You may be able to remove "-ltermcap" on some machines (ex: Solaris). 249# 250# You may have to replace "-lcurses" with "-lncurses" to use the 251# "new curses" library instead of the "old curses" library, and 252# you may have to add "-l/usr/include/ncurses" to the "CFLAGS". 253# 254# See "main-gcu.c" and "config.h" for some optional "curses" defines, 255# including "USE_GETCH" and "USE_CURS_SET". Note that "config.h" will 256# attempt to "guess" at many of these flags based on your system. 257# 258## With SDL 259#CFLAGS = -g -pipe -Wall -DUSE_X11 -DUSE_GCU -I${X11BASE}/include -D_XOPEN_SOURCE -D_BSD_SOURCE -DMEXP=19937 -DSOUND_SDL `sdl-config --cflags` -D_DEFAULT_SOURCE -DACC32 260#LIBS = -L${X11BASE}/lib -L/usr/pkg/lib -lX11 -lncurses -lcrypt -lm `sdl-config --libs` -lSDL_mixer 261## 262## Without SDL 263#CFLAGS = -g -pipe -Wall -DUSE_X11 -DUSE_GCU -I${X11BASE}/include -D_XOPEN_SOURCE -D_BSD_SOURCE -DMEXP=19937 264#LIBS = -L${X11BASE}/lib -L/usr/pkg/lib -lX11 -lncurses -lcrypt -lm 265 266 267## 268## Variation -- Only support "main-gcu.c" (not "main-x11.c") 269## This is a command-line client that relies on ncurses. 270## 271## With SDL 272#CFLAGS = -g -pipe -Wall -DUSE_GCU -D_XOPEN_SOURCE -D_BSD_SOURCE -DMEXP=19937 -DSOUND_SDL `sdl-config --cflags` 273#LIBS = -L/usr/pkg/lib -lncurses -lcrypt -lm `sdl-config --libs` -lSDL_mixer 274## 275## Without SDL 276#CFLAGS = -g -pipe -Wall -DUSE_GCU -D_XOPEN_SOURCE -D_BSD_SOURCE -DMEXP=19937 277#LIBS = -L/usr/pkg/lib -lncurses -lcrypt -lm 278 279 280## 281## Variation -- OS X : See makefile.osx 282## 283 284 285## 286## Variation -- Windows : See makefile.mingw (MinGW32) or makefile.win (Cygwin) 287## 288 289 290## 291## Variation -- Linux / FreeBSD 292## 293## Add -msse2 -DHAVE_SSE2=1 to CFLAGS to enable SSE2 support in SFMT. 294## 295## You can compile the client without X11 support by removing -DUSE_X11 from 296## CFLAGS and -lX11 from LIBS 297## 298## With SDL 299#CFLAGS = -g -pipe -Wall -DUSE_X11 -DUSE_GCU -I${X11BASE}/include -D_XOPEN_SOURCE -D_BSD_SOURCE -DMEXP=19937 -DSOUND_SDL `sdl-config --cflags` 300#tomenet.test: CFLAGS += -DTEST_CLIENT 301#LIBS = -L${X11BASE}/lib -L/usr/pkg/lib -lX11 -lncurses -lcrypt -lm `sdl-config --libs` -lSDL_mixer 302#-lXtst (for numlock - obsolete) 303## Uncomment this if you want to bundle libraries with the client 304#LDFLAGS = -Wl,-rpath,\$$ORIGIN 305## 306## Without SDL 307CFLAGS += -g -pipe -Wall -DUSE_GCU -D_XOPEN_SOURCE -D_BSD_SOURCE -DMEXP=19937 308LIBS += -lncurses -lcrypt -lm -lexecinfo 309 310 311## Added by thaler, 6/28/97 312## Variation -- Only support "main-gcu.c" (not "main-x11.c") on localhost 313## 314## NOTE -- Using this variation requires that the server and client run 315## on the same machine! Also define META_ADDRESS to be an empty string 316## in config.h. --Keldon 317## 318#CFLAGS = -Wall -pipe -g -DUSE_GCU -DUNIX_SOCKETS 319#LIBS = -lncurses -ltermcap 320 321 322## 323## Variation -- Use "main-xaw.c" instead of "main-x11.c" 324## 325#CFLAGS = -Wall -pipe -g -DUSE_XAW -DUSE_GCU 326#LIBS = -lXaw -lXmu -lXt -lX11 -lcurses -ltermcap 327 328 329## 330## Variation -- Use "main-cap.c" instead of "main-gcu.c" 331## 332#CFLAGS = -Wall -pipe -g -DUSE_X11 -DUSE_CAP 333#LIBS = -lX11 -ltermcap 334 335 336## 337## Variation -- Only work on simple vt100 terminals 338## 339#CFLAGS = -Wall -pipe -g -DUSE_CAP -DUSE_HARDCODE 340 341 342## 343## Variation -- FreeBSD 4.3R 344## 345#PREFIX = /usr/local 346#CFLAGS = -Wall -g -DUSE_X11 -DUSE_GCU -I${X11BASE}/include -DDEFAULT_PATH="\"${PREFIX}/lib/tomenet\"" 347#LIBS = -L${X11BASE}/lib -lX11 -lcurses 348 349 350## 351## Variation -- compile for Solaris 352## 353#CFLAGS = -Wall -pipe -g -DUSE_X11 -DUSE_GCU -DSOLARIS -I/usr/openwin/include 354#LIBS = -L/usr/openwin/lib -R/usr/openwin/lib -lX11 -lsocket -lnsl -lcurses 355 356 357# Compile a client with 'test client' version/tag 358tomenet.test: CFLAGS += -DTEST_CLIENT -O0 359 360# Normal release build 361tomenet: CFLAGS += -O2 362 363 364# Lua 365SRCS += $(LUASRCS) 366SRCS += $(CLI_LUASRCS) 367SERV_OBJS += $(LUAOBJS) 368SERV_SRCS += $(TOLUASRCS) 369SERV_OBJS += $(TOLUAOBJS) 370CLI_OBJS += $(CLI_LUAOBJS) 371CLI_SRCS += $(TOLUASRCS) 372CLI_OBJS += $(TOLUAOBJS) 373CFLAGS += $(LUAFLAGS) -Iserver -Iserver/lua 374 375TOLUA = server/tolua 376 377all: tomenet tomenet.server accedit 378 @echo Now you need to copy the binaries out of the src directory or run \"make install\". 379 380# sorry. install on every make is a real pain ;) 381 382install: all 383 install -b tomenet .. 384 install -b tomenet.server .. 385 install -b accedit .. 386 touch ../tomenet.acc 387 388 389mini_install: install 390 391date: 392 touch common/common.c 393 394 395# 396# Build the account editor 397# 398 399accedit: account/accedit.o 400 $(CC) $(CFLAGS) $(LDFLAGS) -o accedit account/accedit.o -lncurses -lcrypt 401 402 403# 404# Build the custom LUA preprocessor 405# 406 407preproc/preproc: preproc/preproc.o 408 $(CC) $(CFLAGS) -o preproc/preproc preproc/preproc.o 409 410 411# 412# Build the TomeNET server 413# 414 415tomenet.server: $(SERV_OBJS) $(TOLUA) 416 $(CC) $(CFLAGS) $(LDFLAGS) -o tomenet.server $(SERV_OBJS) $(LIBS) 417 418 419# 420# Build the evileye meta client 421# Note: evilmeta is outdated, server has a built-in meta client 422# 423evilmeta: server/evilmeta.o 424 $(CC) $(CFLAGS) $(LDFLAGS) -o evilmeta server/evilmeta.c 425 426 427# 428# Build the TomeNET client 429# 430 431tomenet: $(CLI_OBJS) 432 $(CC) $(CFLAGS) $(LDFLAGS) -o tomenet $(CLI_OBJS) $(LIBS) 433 434tomenet.test: $(CLI_OBJS) 435 $(CC) $(CFLAGS) $(LDFLAGS) -o tomenet $(CLI_OBJS) $(LIBS) 436 437 438# 439# Build the TomeNET remote console 440# 441 442tomenet.console: $(CONS_OBJS) 443 $(CC) $(CFLAGS) $(LDFLAGS) -o tomenet.console $(CONS_OBJS) $(LIBS) 444 445 446$(TOLUA): $(TOLUAOBJS) server/lua/tolua.c server/lua/tolualua.c 447 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TOLUAOBJS) server/lua/tolua.c server/lua/tolualua.c $(LIBS) 448 449# 450# Rule for making a '.o' 451# 452.c.o: 453 $(CC) $(CFLAGS) -o $*.o -c $*.c 454 455 456# 457# Clean up old junk 458# 459 460clean: 461 cd server/lua; rm -f *.o 462 cd server; rm -f *.o w_play.c w_util.c w_spells.c *.pkg 463 cd client; rm -f *.o w_play.c w_util.c w_spells.c *.pkg 464 cd common; rm -f *.o w_z_pack.c 465 cd console; rm -f *.o 466 rm -f account/accedit.o preproc/preproc.o 467 468re: clean all 469 470# 471# Lua library compilation rules 472# 473 474server/util.pkg: server/util.pre preproc/preproc 475 cd server; ../preproc/preproc util.pre util.pkg $(CPP) $(CPPFLAGS); cd .. 476 477server/player.pkg: server/player.pre preproc/preproc 478 cd server; ../preproc/preproc player.pre player.pkg $(CPP) $(CPPFLAGS); cd .. 479 480server/spells.pkg: server/spells.pre preproc/preproc 481 cd server; ../preproc/preproc spells.pre spells.pkg $(CPP) $(CPPFLAGS); cd .. 482 483client/util.pkg: client/util.pre preproc/preproc 484 cd client; ../preproc/preproc util.pre util.pkg $(CPP) $(CPPFLAGS); cd .. 485 486client/player.pkg: client/player.pre preproc/preproc 487 cd client; ../preproc/preproc player.pre player.pkg $(CPP) $(CPPFLAGS); cd .. 488 489client/spells.pkg: client/spells.pre preproc/preproc 490 cd client; ../preproc/preproc spells.pre spells.pkg $(CPP) $(CPPFLAGS); cd .. 491 492server/w_util.c: server/util.pkg $(TOLUA) 493 cd server; ./tolua -n util -o w_util.c util.pkg; cd .. 494 495server/w_play.c: server/player.pkg $(TOLUA) 496 cd server; ./tolua -n player -o w_play.c player.pkg; cd .. 497 498server/w_spells.c: server/spells.pkg $(TOLUA) 499 cd server; ./tolua -n spells -o w_spells.c spells.pkg; cd .. 500 501common/w_z_pack.c: common/z_pack.pkg $(TOLUA) 502 cd common; ../server/tolua -n z_pack -o w_z_pack.c z_pack.pkg; cd .. 503 504client/w_play.c: client/player.pkg $(TOLUA) 505 cd client; ../server/tolua -n player -o w_play.c player.pkg; cd .. 506 507client/w_util.c: client/util.pkg $(TOLUA) 508 cd client; ../server/tolua -n util -o w_util.c util.pkg; cd .. 509 510client/w_spells.c: client/spells.pkg $(TOLUA) 511 cd client; ../server/tolua -n spells -o w_spells.c spells.pkg; cd .. 512 513 514# 515# Generate dependancies automatically 516# 517 518depend: 519 makedepend -- $(CFLAGS) -D__MAKEDEPEND__ -- $(SERV_SRCS) $(CLI_SRCS) 520 521 522# DO NOT ADD ANYTHING BELOW THIS LINE. 523 524# DO NOT DELETE THIS LINE -- make depend depends on it. 525 526