untermud/DOC/
untermud/DOC/U/
untermud/DOC/U/U-examples/
untermud/DOC/internals/
untermud/DOC/wizard/
untermud/MISC/
untermud/MISC/dbchk/
untermud/RWHO/
untermud/RWHO/rwhod/
#
# Whatever you put in for $(CC) must be able to grok ANSI C.
#
CC = cl
LD = cl
AR = link /LIB
YACC = yacc
YFLAGS = -l -d
WINZIP = C:\apps\Winzip\wzzip

# The suffix appended to executables.  
# This should be set for Cygwin and Windows.
EXE = .exe 
#EXE =

# Compiler directives for debugging
!ifdef DEBUG
DEBUG_CFLAGS = /MTd /ZI /Od /FD /GZ /D "DEBUG" 
DEBUG_LFLAGS = /DEBUG /PDBTYPE:SEPT 
LIBS= libcmtd.lib kernel32.lib ws2_32.lib 
!else
DEBUG_CFLAGS = /MT /Ot /Oy /Ob1 /Gs /Gy /D "NDEBUG" 
DEBUG_LFLAGS = 
LIBS= libcmt.lib kernel32.lib ws2_32.lib 
!endif

DEFS= /D "WIN32" /D "WIN32_LEAN_AND_MEAN" /D "_CONSOLE" /D "_MBCS" /D "TRACE"
OPTIM= /nologo /GX /W1 $(DEBUG_CFLAGS) /G$(PROCESSOR_LEVEL) 
CFLAGS= $(OPTIM) $(DEFS)
LFLAGS = /link /NOLOGO /NODEFAULTLIB /SUBSYSTEM:CONSOLE $(DEBUG_LFLAGS) 

# Include directories 
INCS = /I.\ /I.\U 
DBMLIBS = os.obj gdbm.lib ndbm.lib dbm.lib

#if building with combat, include this
#COMBAT=
COMBAT = combat.c

HDR = config.h mud.h comp.h vars.h look.h match.h cmd.h sbuf.h trans.h sym.h xact.h \
	combat.h os.h
SRC = mud.c $(COMBAT) cron.c net.c do_go.c do_look.c login.c trans.c version.c \
	run.c sym.c activ.c vars.c cmd.c xact.c xmit.c cache.c bool.c util.c \
	match.c obj.c sbuf.c list.c rot.c alloc.c errors.c misc2.c misc.c os.c
# .obj versions of above
OBJ = $(SRC:.c=.obj)
XTRA = README README_2.0a README_COMBAT CHANGES COPYRIGHT Makefile INSTALL_NOTES \
       untermud-2.4-orig.tar.gz makefile.bor makefile.vc \
       bootup buildh buildd buildg bootup.cmd buildh.cmd buildd.cmd buildg.cmd

CMDLIB = CMD\cmd.lib
CMDSRC = CMD\_dump.c CMD\_echo.c CMD\_wall.c CMD\_force.c CMD\_if.c CMD\_mark.c \
	CMD\_rand.c CMD\build.c CMD\destroy.c CMD\do.c CMD\drop.c CMD\examine.c \
	CMD\go.c CMD\inv.c CMD\kill.c CMD\look.c CMD\news.c CMD\page.c \
	CMD\passwd.c CMD\quit.c CMD\read.c CMD\say.c CMD\take.c CMD\use.c \
	CMD\which.c CMD\telep.c CMD\wear.c CMD\whisper.c CMD\wizard.c
CMDOBJ = $(CMDSRC:.c=.obj)
CMDXTRA = CMD\README

DBLIB = DB\db.lib
DBSRC = DB\oif.c DB\expr.c DB\dbmchunk.c DB\dbmconf.c DB\gdbmchunk.c \
	DB\gdbmconf.c DB\hashconf.c DB\hashdir.c
DBOBJ = $(DBSRC:.c=.obj)
DBXTRA = DB\README DB\dumpdb.c DB\loaddb.c DB\comp.c DB\bigrams.c \
	DB\config DB\startup DB\minimal_db.oif
DBUTIL = misc.obj alloc.obj obj.obj sbuf.obj list.obj


ULIB = U\u.lib
UHDR = U\u.h
USRC = U\bltin.c U\uinterp.y U\u_util.c U\b_cmd.c U\b_echo.c U\b_err.c \
	U\b_lst.c U\b_match.c U\b_misc.c U\b_int.c U\b_oid.c U\b_rnd.c \
	U\b_time.c U\b_str.c
UOBJ = U\bltin.obj U\uinterp.obj U\u_util.obj U\b_cmd.obj U\b_echo.obj U\b_err.obj U\b_lst.obj \
	U\b_match.obj U\b_misc.obj U\b_int.obj U\b_oid.obj U\b_rnd.obj \
	U\b_time.obj U\b_str.obj
UXTRA = U\README

MISCSRC = MISC\bonk.c MISC\oif2set.c
MISCOBJ = $(MISCSRC:.c=.obj)
MISCXTRA = $(MISCSRC:.c=.doc)
MISCDBCHKSRC = MISC\dbchk\dbchk.c MISC\dbchk\dbchk_cache.c
MISCDBCHKOBJ = $(MISCDBCHKSRC:.c=.obj)

#if building without RWHO support, change RWHOLIB to nothing:
#RWHOLIB =
RWHOLIB = RWHO\rwho.lib
RWHOHDR = RWHO\rwho.h
RWHOSRC = RWHO\updat.c RWHO\clilib.c
RWHOOBJ = $(RWHOSRC:.c=.obj)
RWHOXTRA = RWHO\mudwho.c RWHO\mwhoforvm RWHO\HOW_TO RWHO\rwhodoc RWHO\README

# RWHO daemon
RWHOD = RWHO\rwhod
RWHODSRC = $(RWHOD)\mwhod.c
RWHODOBJ = $(RWHODSRC:.c=.obj)
RWHODXTRA = $(RWHOD)\mwhod.doc $(RWHOD)\README

# Files in the standard distribution
DISTFILES = $(SRC) $(HDR) $(XTRA) 
!ifndef RELEASE
RELEASE=dist
!endif

# Dependency information
OBJDEPENDS = $(OBJ) $(CMDOBJ) $(DBOBJ) $(UOBJ) $(RWHOOBJ) \
	DB\dumpdb.obj DB\loaddb.obj DB\comp.obj DB\bigrams.obj \
	RWHO\mudwho.obj $(MISCOBJ) $(MISCDBCHKOBJ) $(RWHODOBJ)

ALLLIBS = $(CMDLIB) $(DBLIB) $(ULIB) $(RWHOLIB)
TARGETS = mud$(EXE) mudwho$(EXE) dumpdb$(EXE) loaddb$(EXE) bigrams$(EXE) \
	comp$(EXE) bonk$(EXE) oif2set$(EXE) dbchk$(EXE) mwhod$(EXE)

all: $(TARGETS)

mud$(EXE) : $(OBJ) $(CMDLIB) $(DBLIB) $(ULIB) $(RWHOLIB) $(DBMLIBS)
	$(LD) $** $(LIBS)  /Fe$@ $(LFLAGS)

mudwho$(EXE) : RWHO\mudwho.obj getopt.lib
	$(LD) $** $(LIBS) /Fe$@ $(LFLAGS)

dumpdb$(EXE) : DB\dumpdb.obj $(DBUTIL) $(DBLIB) getopt.lib $(DBMLIBS)
	$(LD) $** $(LIBS) /Fe$@ $(LFLAGS)

loaddb$(EXE) : DB\loaddb.obj $(DBUTIL) $(DBLIB) getopt.lib $(DBMLIBS)
	$(LD) $** $(LIBS) /Fe$@ $(LFLAGS)

comp$(EXE) : DB\comp.obj 
	$(LD) $** $(LIBS) /Fe$@ $(LFLAGS)

bigrams$(EXE) : DB\bigrams.obj
	$(LD) $** $(LIBS) /Fe$@ $(LFLAGS)

$(CMDLIB) : $(CMDOBJ)
	@echo "making CMD library..."
	-@del $@ 2>NUL
	$(AR) /OUT:$@ $**

$(DBLIB) : $(DBOBJ)
	@echo "making DB library..."
	-@del $@ 2>NUL
	$(AR) /OUT:$@ $**

$(ULIB) : $(UOBJ) 
	@echo "making U library..."
	-@del $@ 2>NUL
	$(AR) /OUT:$@ $**

U\uinterp.c y.tab.h : U\uinterp.y 
	$(YACC) $(YFLAGS) U\uinterp.y
	-move y.tab.c U\uinterp.c

$(RWHOLIB) : $(RWHOOBJ)
	@echo "making RWHO library..."
	-@del $@ 2>NUL
	$(AR) /OUT:$@ $**

mwhod$(EXE) : $(RWHODOBJ) getopt.lib
	$(LD) $** $(LIBS) /Fe$@ $(LFLAGS)

bonk$(EXE) : MISC\bonk.obj
	$(LD) $** $(LIBS) /Fe$@ $(LFLAGS)

oif2set$(EXE) : MISC\oif2set.obj
	$(LD) $** $(LIBS) /Fe$@ $(LFLAGS)

dbchk$(EXE) : $(MISCDBCHKOBJ) $(DBUTIL) $(DBLIB) getopt.lib $(DBMLIBS) 
	$(LD) $** $(LIBS) /Fe$@ $(LFLAGS)

clean :
	@echo "Cleaning..."
	@-del *.pdb *.ilk *.idb $(TARGETS) $(ALLLIBS)  DB\dumpdb.obj DB\loaddb.obj \
	DB\comp.obj DB\bigrams.obj U\uinterp.c y.tab.h  RWHO\mudwho.obj \
	$(OBJDEPENDS) 2>NUL
	@echo "Done."

dist : $(DISTFILES)
	@echo "Building distribution..."
	@-md untermud
	@!copy /y $** untermud 1>NUL
	@echo .svn > ex.tmp
        @xcopy CMD untermud\CMD /I /E /Y /Q /EXCLUDE:ex.tmp 
        @xcopy MISC untermud\MISC /I /E /Y /Q /EXCLUDE:ex.tmp 
        @xcopy DB untermud\DB /I /E /Y /Q /EXCLUDE:ex.tmp 
        @xcopy DOC untermud\DOC /I /E /Y /Q /EXCLUDE:ex.tmp 
        @xcopy HELP untermud\HELP /I /E /Y /Q /EXCLUDE:ex.tmp 
        @xcopy RWHO untermud\RWHO /I /E /Y /Q /EXCLUDE:ex.tmp 
        @xcopy U untermud\U /I /E /Y /Q /EXCLUDE:ex.tmp 
        @del ex.tmp
	@$(WINZIP) -Pr untermud-$(RELEASE).zip untermud 1>NUL 2>NUL
	@rd /s /q untermud
	@echo "Done."

.c.obj:
	$(CC) $(CFLAGS) $(INCS) /c /Tc$< /Fo$@