# NetHack 3.6	Makefile.MSC	$NHDT-Date: 1432512792 2015/05/25 00:13:12 $  $NHDT-Branch: master $:$NHDT-Revision: 1.21 $
#	Copyright (c) NetHack PC Development Team 1997 - 2012.
#	PC NetHack 3.4x Makefile for MSC V1.52c (16 bit compiler)
#
#	For questions or comments: nethack-bugs@nethack.org
#
#	In addition to your C compiler,
#
#       if you want to change        you will need a
#       files with suffix            workalike for
#	      .y	                yacc
#	      .l	                lex
#
#

# Game Installation Variables
# NOTE: Make sure GAMEDIR exists before make is started.

GAME = nethack
GAMEDIR =..\binary

#
# Directories
#

DAT  = ..\dat
DOC  = ..\doc
INCL = ..\include
MSYS = ..\sys\msdos
SRC  = ..\src
SSHR = ..\sys\share
UTIL = ..\util
WIN  = ..\win\tty
WSHR = ..\win\share

#
#  Executables.

CC    = cl
LINK  = link
MAKEBIN  = nmake

# if you have a uudecode program, add its name here
# otherwise leave blank
UUDECODE =

#
#  Yacc/Lex ... if you got 'em.
#
# If you have yacc/lex or a work-alike set YACC_LEX to Y
#
YACC_LEX = N

# If YACC_LEX is Y above, set the following to values appropriate for
# your tools.
#
YACC   = bison -y
LEX    = flex
YTABC  = y_tab.c
YTABH  = y_tab.h
LEXYYC = lexyy.c


#
# Uncomment this line if you want to include support for ALT-numeric
# sequences, such as ALT-2 for toggling #twoweapon mode.  
# Note that this code did not get a thorough testing prior to 3.4.x
#NEWALT=/DNEW_ALT

#
# Uncomment this line if your shell doesn't support FOR bat syntax (DOSBOX).
NO_FOR=Y

#############################################################################
#
# nothing below this line should have to be changed
#

LNKOPT = SCHEMA35.DEF

#
# Controls whether MOVE tracing is enabled in the executable
# This should be left commented unless you are tinkering with the
# overlay structure of NetHack.  The executable runs _very_
# slowly when the movetr.lib is linked in.
#

#MOVETR= movetr.lib

# do not change this
! IF ("$(MOVETR)"!="")
MVTRCL = /DMOVE_PROF
! ELSE
MVTRCL =
! ENDIF

#
# Uncomment the line below if you want to store all the level files,
# help files, etc. in a single library file.

USE_DLB = Y

! IF ("$(USE_DLB)"=="Y")
DLBFLG = -DDLB
! ELSE
DLBFLG =
! ENDIF

LIBRARIES = $(LIBS) $(TERMLIB)

GAMEFILE = $(GAMEDIR)\$(GAME).exe

#
#  Flags.
#
# Debugging
#CFLAGS = /Zi /DFUNCTION_LEVEL_LINKING /DTILES_IN_GLYPHMAP /DDLB
#LFLAGS = /CODEVIEW /NOI/MAP /CPARM:1 /INFO

#    Normal
LFLAGS = /NOI/MAP /CPARM:1 /INFO
CFLAGS = /DFUNCTION_LEVEL_LINKING /DTILES_IN_GLYPHMAP /DDLB
SPECOPTS =
#
# Leaving MACHINE_CODE undefined will allow it to run
# on any Intel 8088 machines and above.
# Set to 1 for 80186 and above only
# Set to 2 for 80286 and above only
# Set to 3 for 80386 and above only
# 
MACHINE_CODE = 

#
#  Utility Objects.
#
#
# Shorten up the location for some files
#

O  = $(OBJ)\				# comment so \ isn't last char

U  = $(UTIL)\				# comment so \ isn't last char

VGAOBJ      = vidvga.o

MAKESRC	    = $(U)makedefs.c

MAKEOBJS    = makedefs.o  monst.o	 objects.o

RECOVOBJS   = recover.o


#  Tile related object files.

TILOBJ      = tile.o pctiles.o $(VGAOBJ)

TEXTIO      = tiletext.o tiletxt.o drawing.o decl.o monst.o objects.o stubvid.o

TEXTIO2     = tiletex2.o tiletxt2.o drawing.o decl.o monst.o objects.o stubvid.o


PLANAR_TIB  = NetHack1.tib

OVERVIEW_TIB = NetHacko.tib

TILEUTIL    = $(TILOBJ) tile2bin.exe til2bin2.exe $(PLANAR_TIB) $(OVERVIEW_TIB)

TILEFILES   = $(WSHR)\monsters.txt $(WSHR)\objects.txt $(WSHR)\other.txt

TILEFILES2  = $(WSHR)\monthin.txt $(WSHR)\objthin.txt $(WSHR)\oththin.txt

GIFREADERS  = gifread.o alloc.o panic.o

GIFREAD2    = gifread2.o alloc.o panic.o

PPMWRITERS  = ppmwrite.o alloc.o panic.o

PPMWRIT2    = ppmwrit2.o alloc.o panic.o

DLBOBJS     = dlb_main.o dlb.o alloc.o panic.o

#  Object files for the game itself.

VOBJ01 = allmain.o  alloc.o    apply.o	  artifact.o attrib.o
VOBJ02 = ball.o	    bones.o    botl.o	  cmd.o	     dbridge.o
VOBJ03 = decl.o	    detect.o   display.o  do.o	     do_name.o
VOBJ04 = do_wear.o  dog.o      dogmove.o  dokick.o   dothrow.o
VOBJ05 = drawing.o  dungeon.o  eat.o	  end.o	     engrave.o
VOBJ06 = exper.o    explode.o  extralev.o files.o    fountain.o
VOBJ07 = getline.o  hack.o     hacklib.o  invent.o   lock.o
VOBJ08 = mail.o	    main.o     makemon.o  mapglyph.o mcastu.o   mhitm.o
VOBJ09 = mhitu.o    minion.o   mkmap.o	  mklev.o    mkmaze.o
VOBJ10 = mkobj.o    mkroom.o   mon.o	  mondata.o  monmove.o
VOBJ11 = monst.o    mplayer.o  mthrowu.o  muse.o
VOBJ12 = music.o    o_init.o   objects.o  objnam.o   options.o
VOBJ13 = pickup.o   pline.o    polyself.o potion.o   quest.o
VOBJ14 = questpgr.o pager.o    pray.o	  priest.o   read.o
VOBJ15 = rect.o	    restore.o  rip.o	  rnd.o	     role.o
VOBJ16 = rumors.o   save.o	   shk.o      shknam.o	 sit.o
VOBJ17 = sounds.o   sp_lev.o   spell.o    steal.o	 steed.o
VOBJ18 = termcap.o  timeout.o  topl.o	  topten.o   track.o
VOBJ19 = trap.o     u_init.o   uhitm.o    vault.o    vision.o
VOBJ20 = weapon.o   were.o	  wield.o    windows.o
VOBJ21 = wintty.o   wizard.o   worm.o	  worn.o     write.o
VOBJ22 = zap.o	    light.o    dlb.o      dig.o      teleport.o
VOBJ23 = random.o   region.o   sys.o

SOBJ   = msdos.o    pcsys.o	  tty.o	     unix.o    video.o \
	vidtxt.o    pckeys.o

VVOBJ  = version.o

VOBJ   = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
	$(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \
	$(VOBJ11) $(VOBJ12) $(VOBJ13) $(VOBJ14) $(VOBJ15) \
	$(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \
	$(VOBJ21) $(VOBJ22) $(VOBJ23)

ALLOBJ = $(VOBJ) $(SOBJ) $(TILOBJ) $(VVOBJ)

#
#  Header Objects.
#

DGN_FILE_H = $(INCL)\align.h	$(INCL)\dgn_file.h
DUNGEON_H  = $(INCL)\align.h	$(INCL)\dungeon.h
MONDATA_H  = $(INCL)\align.h	$(INCL)\mondata.h
MONST_H	   = $(INCL)\mextra.h   $(INCL)\align.h	$(INCL)\monst.h
PERMONST_H = $(INCL)\monattk.h	$(INCL)\monflag.h   $(INCL)\align.h   \
	    $(INCL)\permonst.h
RM_H	   = $(INCL)\align.h	$(INCL)\rm.h
SP_LEV_H   = $(INCL)\align.h	$(INCL)\sp_lev.h
YOUPROP_H  = $(PERMONST_H)	$(MONDATA_H)	    $(INCL)\prop.h    \
	    $(INCL)\pm.h       $(INCL)\youprop.h
YOU_H	   = $(MONST_H)		$(YOUPROP_H)	    $(INCL)\align.h   \
	     $(INCL)\attrib.h	$(INCL)\you.h
DISPLAY_H  = $(MONDATA_H)	$(INCL)\vision.h    $(INCL)\display.h
PCCONF_H   = $(INCL)\micro.h	$(INCL)\system.h    $(INCL)\pcconf.h \
	    $(MSYS)\pcvideo.h
CONFIG_H   = $(GLOBAL_H)	$(INCL)\tradstdc.h  $(INCL)\config1.h \
	    $(INCL)\config.h
DECL_H	   = $(YOU_H)		$(INCL)\spell.h	    $(INCL)\color.h   \
	     $(INCL)\obj.h	$(INCL)\onames.h    $(INCL)\pm.h      \
	      $(INCL)\decl.h
GLOBAL_H   = $(PCCONF_H)	$(INCL)\coord.h	    $(INCL)\global.h
HACK_H	   = $(CONFIG_H)	$(INCL)\context.h   $(DUNGEON_H) $(DECL_H) \
	       $(DISPLAY_H)	  $(INCL)\monsym.h    $(INCL)\mkroom.h	\
	      $(INCL)\objclass.h $(INCL)\trap.h	     $(INCL)\flag.h    \
	      $(RM_H)		 $(INCL)\vision.h    $(INCL)\wintype.h \
	      $(INCL)\engrave.h	 $(INCL)\rect.h	     $(INCL)\sys.h \
	       $(INCL)\trampoli.h $(INCL)\hack.h
DLB_H      = $(INCL)\dlb.h
TILE_H	   = $(WSHR)\tile.h $(MSYS)\pctiles.h


# Make Roolz dude.
# Due to the inadequacy of some makes these must accord with a
# topological sort of the generated-from relation... output on
# the left, input on the right. Trust me.
#

.SUFFIXES:  .exe .o .til .uu .c .y .l

#
# Rules for files in src
#


.c{$(OBJ)}.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

.c.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

{$(SRC)}.c{$(OBJ)}.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

{$(SRC)}.c.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

#
# Rules for files in sys\share
#

{$(SYS)}.c{$(OBJ)}.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

{$(SYS)}.c.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

#
# Rules for files in sys\msdos
#

{$(MSYS)}.c{$(OBJ)}.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

{$(MSYS)}.c.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

{$(MSYS)}.h{$(INCL)}.h:
	@copy $< $@

#
# Rules for files in util
#

{$(UTIL)}.c{$(OBJ)}.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

{$(UTIL)}.c.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

#
# Rules for files in win\share
#

{$(WSHR)}.c.o:
	@@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

{$(WSHR)}.c{$(OBJ)}.o:
	@@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

{$(WSHR)}.h{$(INCL)}.h:
	@copy $< $@

{$(WSHR)}.txt{$(DAT)}.txt:
	@copy $< $@

#
# Rules for files in win\tty
#

{$(WTTY)}.c{$(OBJ)}.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<

{$(WTTY)}.c.o:
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $<


! IF ("$(USE_DLB)"=="Y")
DLB = nhdat
! ELSE
DLB =
! ENDIF

########################################################
#  
# TARGETS


#
#  The default make target (so just typing 'nmake' is useful).
#
default : envchk $(GAMEFILE)

#  The default target.

$(GAME): $(O)utility.tag $(GAMEFILE)
	@echo $(GAME) is up to date.

#
#  Everything
#

all: install

install: envchk $(GAME) $(O)install.tag
	@echo Done.

$(O)install.tag: 	$(DAT)\data	$(DAT)\rumors	 $(DAT)\dungeon \
	 	$(DAT)\oracles	$(DAT)\quest.dat $(DLB)
! IF ("$(USE_DLB)"=="Y")
	copy $(SRC)\nhdat         $(GAMEDIR)
	copy $(DAT)\license       $(GAMEDIR)
! ELSE
	copy $(DAT)\*.            $(GAMEDIR)
	copy $(DAT)\*.dat         $(GAMEDIR)
	copy $(DAT)\*.lua         $(GAMEDIR)
	if exist $(GAMEDIR)\makefile del $(GAMEDIR)\makefile
! ENDIF
	if exist $(DAT)\symbols copy $(DAT)\symbols $(GAMEDIR)
	copy $(SSHR)\termcap	  $(GAMEDIR)
	copy *.tib                $(GAMEDIR)
	copy $(SSHR)\NetHack.cnf  $(GAMEDIR)\defaults.nh
	copy $(MSYS)\NHAccess.nh  $(GAMEDIR)
	copy $(U)recover.exe          $(GAMEDIR)
	if exist $(DOC)\guideb*.txt copy $(DOC)\guideb*.txt $(GAMEDIR)
	if exist $(DOC)\recover.txt copy $(DOC)\recover.txt $(GAMEDIR)
	if exist $(DOC)\nethack.txt copy $(DOC)\nethack.txt $(GAMEDIR)
	echo install done > $@

$(O)utility.tag: $(INCL)\date.h $(INCL)\trap.h  \
        $(INCL)\onames.h $(INCL)\pm.h $(U)recover.exe $(TILEUTIL)
	-@if exist $(O)utility.tag del $(O)utility.tag
	@echo utilities made > $@

tileutil: gif2txt.exe txt2ppm.exe
	@echo Optional tile development utilities are up to date.

.PHONEY: envchk

envchk:
! 	IF ("$(MACHINE_CODE)"!="")
	   @SET MC=/G$(MACHINE_CODE)
!	ELSE
	   @SET MC=
!	ENDIF
!	IF ("$(CL)"=="")
	   @echo CL Environment variable is defined as follows:
	   SET CL=/AL $(MC) /Oo /Gy /Gs /Gt10 /Gf /Zp1 /W2 /I$(INCL) /I$(MSYS) /I$(WSHR) /nologo /c
!	ELSE
	   @echo Warning CL Environment variable is defined:
	   @echo CL=$(CL)
	   @echo Overriding that definition as follows:
	   SET CL=/AL $(MC) /Oo /Gy /Gs /Gt10 /Gf /Zp1 /W2 /I$(INCL) /I$(MSYS) /I$(WSHR) /nologo /c
!	ENDIF

#  The main target.

$(GAMEFILE) :  $(LNKOPT) $(ALLOBJ)
	@echo Linking....
	$(LINK) $(LFLAGS) /SE:1000 /DYNAMIC:2650 /NOE /ST:6000 @<<$(GAME).lnk
		$(ALLOBJ:^	=+^
		)
		$(GAMEFILE)
		$(GAME)
		$(TERMLIB) $(MOVETR) $(CLIB) $(BCOVL) $(BCMDL)
		$(LNKOPT);
<<
	@if exist $(O)install.tag del $(O)install.tag
	@if exist $(GAMEDIR)\$(GAME).bak del $(GAMEDIR)\$(GAME).bak

#
#  Housekeeping.
#

clean:
	del *.o
	del *.map
	del $(U)dlb_main.exe

spotless: clean
	if exist $(O)utility.tag	   del $(O)utility.tag
	if exist $(O)install.tag   del $(O)install.tag
	if exist $(GAME).lnk	   del $(GAME).lnk
	if exist $(U)makedefs.exe  del $(U)makedefs.exe
	if exist $(U)recover.exe   del $(U)recover.exe
	if exist $(INCL)\onames.h  del $(INCL)\onames.h
	if exist $(INCL)\pm.h	   del $(INCL)\pm.h
	if exist $(INCL)\pcvideo.h del $(INCL)\pcvideo.h
	if exist $(MSYS)\pctiles.h del $(MSYS)\pctiles.h
	if exist $(INCL)\portio.h  del $(MSYS)\portio.h
	if exist $(WSHR)\tile.h	   del $(WSHR)\tile.h
	if exist $(SRC)\panic.c	   del $(SRC)\panic.c
	if exist $(SRC)\makedefs.c del $(SRC)\makedefs.c
	if exist $(SRC)\recover.c  del $(SRC)\recover.c
	if exist $(SRC)\dlb_main.c del $(SRC)\dlb_main.c
	if exist $(SRC)\wintty.c   del $(SRC)\wintty.c
	if exist $(SRC)\topl.c	   del $(SRC)\topl.c
	if exist $(SRC)\getline.c  del $(SRC)\getline.c
	if exist $(SRC)\termcap.c  del $(SRC)\termcap.c
	if exist $(SRC)\tile2bin.c del $(SRC)\tile2bin.c
	if exist $(SRC)\msdos.c	   del $(SRC)\msdos.c
	if exist $(SRC)\pckeys.c   del $(SRC)\pckeys.c
	if exist $(SRC)\video.c	   del $(SRC)\video.c
	if exist $(SRC)\tilemap.c  del $(SRC)\tilemap.c
	if exist $(SRC)\gifread.c  del $(SRC)\gifread.c
	if exist $(SRC)\ppmwrite.c del $(SRC)\ppmwrite.c
	if exist $(SRC)\pcmain.c   del $(SRC)\pcmain.c
	if exist $(SRC)\pcunix.c   del $(SRC)\pcunix.c
	if exist $(SRC)\pcsys.c	   del $(SRC)\pcsys.c
	if exist $(SRC)\pctty.c	   del $(SRC)\pctty.c
	if exist $(SRC)\tile.c	   del $(SRC)\tile.c
	if exist $(INCL)\date.h	   del $(INCL)\date.h
	if exist $(INCL)\onames.h  del $(INCL)\onames.h
	if exist $(INCL)\pm.h	   del $(INCL)\pm.h
	if exist *.lnk		   del *.lnk
	if exist *.def		   del *.def
	if exist *.map		   del *.map
	if exist a.out		   del a.out
	if exist tilemap.exe       del tilemap.exe
	if exist tile2bin.exe      del tile2bin.exe
	if exist $(DAT)\data	   del $(DAT)\data
	if exist $(DAT)\data	   del $(DAT)\data
	if exist $(DAT)\dungeon	   del $(DAT)\dungeon
	if exist $(DAT)\options	   del $(DAT)\options
	if exist $(DAT)\oracles	   del $(DAT)\oracles
	if exist $(DAT)\rumors	   del $(DAT)\rumors
	if exist $(DAT)\quest.dat  del $(DAT)\quest.dat
	if exist $(SRC)\nhdat      del $(SRC)\nhdat
	if exist $(DAT)\dlb.lst    del $(DAT)\dlb.lst
	if exist $(DAT)\msdoshlp.txt del $(DAT)\msdoshlp.txt
	if exist $(DAT)\dlb_main.exe del $(DAT)\dlb_main.exe
	if exist $(PLANAR_TIB)	   del $(PLANAR_TIB)
	if exist $(OVERVIEW_TIB)   del $(OVERVIEW_TIB)


#
#  Secondary Targets.
#
#
#  Makedefs Stuff
#

$(U)makedefs.exe:  $(MAKEOBJS)
        @echo Linking....
        @$(LINK) $(LFLAGS) @<<$(@B).lnk
                $(MAKEOBJS:^      =+^
                )
                $@
                $(@B)
                ;
<<

makedefs.o:  $(CONFIG_H)	$(PERMONST_H)	   $(INCL)\objclass.h \
		$(INCL)\monsym.h   $(UTIL)\makedefs.c

#  The following include files depend on makedefs to be created.
#
#  date.h should be remade every time any of the source or include
#  files is modified.


$(INCL)\date.h : $(U)makedefs.exe
	-$(U)makedefs -v

$(INCL)\onames.h: $(U)makedefs.exe
	-$(U)makedefs -o

$(INCL)\pm.h: $(U)makedefs.exe
	-$(U)makedefs -p

#
#  Recover Utility
#

$(U)recover.exe:   $(RECOVOBJS)
        @echo Linking....
        @$(LINK) $(LFLAGS) @<<$(@B).lnk
                $(RECOVOBJS:^      =+^
                )
                $@
                $(@B)
                ;
<<

recover.o:   $(CONFIG_H) $(UTIL)\recover.c

#
#  Header file moves required for tile support
#

#$(WSHR)\tile.h: $(WSHR)\tile.h
#	copy $(WSHR)\tile.h $@

#$(MSYS)\pctiles.h: $(MSYS)\pctiles.h
#	copy $(MSYS)\pctiles.h $@

#$(INCL)\pcvideo.h: $(MSYS)\pcvideo.h
#	copy $(MSYS)\pcvideo.h $@

#$(MSYS)\portio.h: $(MSYS)\portio.h
#	copy $(MSYS)\portio.h $@

#
#  Tile Mapping
#

tile.c: tilemap.exe
	@tilemap
	@echo A new $@ has been created

tilemap.exe: tilemap.o
        @echo Linking....
        @$(LINK) $(LFLAGS) @<<$(@B).lnk
		tilemap.o
                $@
                $(@B)
                ;
<<

tilemap.c: $(WSHR)\tilemap.c
	copy $(WSHR)\tilemap.c .

tilemap.o: tilemap.c $(HACK_H) $(TILE_H)

#
#   Tile Utilities
#
#
#  Required for tile support
#

NetHack1.tib: $(TILEFILES) tile2bin.exe
	@echo Creating binary tile files (this may take some time)
	@tile2bin

NetHacko.tib: thintile.tag $(TILEFILES2) til2bin2.exe
	@echo Creating overview binary tile files (this may take some time)
	@til2bin2

tile2bin.exe: tile2bin.o $(TEXTIO)
	@$(LINK) $(LFLAGS) tile2bin.o $(TEXTIO),$@,$(@B);

til2bin2.exe: til2bin2.o $(TEXTIO2)
	@$(LINK) $(LFLAGS) til2bin2.o $(TEXTIO2),$@,$(@B);

thintile.exe: thintile.o 
	@$(LINK) $(LFLAGS) thintile.o,$@,$(@B);

thintile.o:  $(HACK_H) $(WSHR)\tile.h $(WSHR)\thintile.c

thintile.tag: thintile.exe $(TILEFILES)
	thintile
	@echo thintiles created >thintile.tag

tile2bin.o:  $(HACK_H) $(WSHR)\tile.h $(MSYS)\pctiles.h $(MSYS)\pcvideo.h \
	$(MSYS)\tile2bin.c

til2bin2.o:  $(HACK_H) $(WSHR)\tile.h $(MSYS)\pctiles.h $(MSYS)\pcvideo.h \
	$(MSYS)\tile2bin.c
	-@$(CC) $(CFLAGS) $(SPECOPTS) -DTILE_X=8 -DOVERVIEW_FILE /Zg $(MSYS)\tile2bin.c >$(@B).pro
	@$(CC) $(CFLAGS) $(SPECOPTS) -DTILE_X=8 -DOVERVIEW_FILE /Fo$@ $(MSYS)\tile2bin.c

tiletext.o:  $(CONFIG_H) $(WSHR)\tile.h $(WSHR)\tiletext.c

tiletex2.o:  $(CONFIG_H) $(WSHR)\tile.h $(WSHR)\tiletext.c
	-@$(CC) $(CFLAGS) $(SPECOPTS) -DTILE_X=8 /Zg $(WSHR)\tiletext.c >$(@B).pro
	@$(CC) $(CFLAGS) $(SPECOPTS) -DTILE_X=8 /Fo$@ $(WSHR)\tiletext.c

tiletxt.o: $(CONFIG_H)	$(WSHR)\tile.h tilemap.c
	-@$(CC) $(CFLAGS) $(SPECOPTS) -DTILETEXT /Zg tilemap.c >$(@B).pro
	@$(CC) $(CFLAGS) $(SPECOPTS) -DTILETEXT /Fo$@ tilemap.c
  
tiletxt2.o: $(CONFIG_H)	$(WSHR)\tile.h tilemap.c
	-@$(CC) $(CFLAGS) $(SPECOPTS) -DTILETEXT /Zg tilemap.c >$(@B).pro
	@$(CC) $(CFLAGS) $(SPECOPTS) -DTILETEXT -DTILE_X=8 /Fo$@ tilemap.c
#
# Optional GIF Utilities (for development)
#

gif2txt.exe: $(GIFREADERS) $(TEXTIO)
	@$(LINK) $(LFLAGS) $(GIFREADERS) $(TEXTIO),$@,$(@B);

gif2txt2.exe: $(GIFREAD2) $(TEXTIO2)
	@$(LINK) $(LFLAGS) $(GIFREAD2) $(TEXTIO2),$@,$(@B);

txt2ppm.exe: $(PPMWRITERS) $(TEXTIO)
	@$(LINK) $(LFLAGS) $(PPMWRITERS) $(TEXTIO),$@,$(@B);

txt2ppm2.exe: $(PPMWRIT2) $(TEXTIO2)
	@$(LINK) $(LFLAGS) $(PPMWRIT2) $(TEXTIO2),$@,$(@B);

gifread.o: $(CONFIG_H) $(WSHR)\tile.h

gifread2.o: $(CONFIG_H) $(WSHR)\tile.h $(WSHR)\gifread.c
	-@$(CC) $(CFLAGS) $(SPECOPTS) -DTILE_X=8 /Zg gifread.c >$(@B).pro
	@$(CC) $(CFLAGS) $(SPECOPTS) -DTILE_X=8 $(WSHR)\gifread.c

ppmwrite.o: $(CONFIG_H)	$(WSHR)\tile.h $(WSHR)\ppmwrite.c

ppmwrit2.o:  $(CONFIG_H) $(WSHR)\tile.h $(WSHR)\ppmwrite.c
	-@$(CC) $(CFLAGS) $(SPECOPTS) -DTILE_X=8 /Zg ppmwrite.c >$(@B).pro
	@$(CC) $(CFLAGS) $(SPECOPTS) -DTILE_X=8 $(WSHR)\ppmwrite.c

#
#  Optional tile viewer (development sources only)
#

viewtib.exe: viewtib.o
	@$(LINK) $(LFLAGS) -oviewtib.exe viewtib.o $(LIBRARIES)

viewtib.o: $(MSYS)\viewtib.c

#
#  Other Util Dependencies.
#

alloc.o: $(CONFIG_H)	 alloc.c
drawing.o: $(CONFIG_H) drawing.c $(MSYS)\pcvideo.h
decl.o: $(CONFIG_H) decl.c
monst.o: $(CONFIG_H)	     $(PERMONST_H)	$(INCL)\monsym.h   \
	$(INCL)\color.h	 monst.c

objects.o: $(CONFIG_H)	      $(INCL)\obj.h	 $(INCL)\objclass.h \
	$(INCL)\prop.h	    $(INCL)\color.h    objects.c

panic.o:   $(CONFIG_H)	  $(UTIL)\panic.c



#
# make data.base an 8.3 filename to prevent an nmake warning
#

DATABASE = $(DAT)\data.bas

$(DAT)\data:	 $(O)utility.tag	$(DATABASE)
	$(U)makedefs -d

$(DAT)\rumors:	     $(O)utility.tag    $(DAT)\rumors.tru	$(DAT)\rumors.fal
	$(U)makedefs -r

$(DAT)\quest.dat: $(O)utility.tag  $(DAT)\quest.txt
	$(U)makedefs -q

$(DAT)\oracles:	     $(O)utility.tag    $(DAT)\oracles.txt
	$(U)makedefs -h

$(DAT)\dungeon: $(O)utility.tag  $(DAT)\dungeon.def
	$(U)makedefs -e
	cd $(DAT)
	$(U)dgn_comp dungeon.pdf
	cd $(SRC)

#
# DLB stuff
#
#
nhdat:	$(U)dlb_main.exe $(DAT)\data $(DAT)\oracles $(DAT)\options \
	$(DAT)\quest.dat $(DAT)\rumors $(DAT)\help $(DAT)\hh $(DAT)\cmdhelp \
	$(DAT)\history $(DAT)\opthelp $(DAT)\wizhelp $(DAT)\dungeon \
	$(DAT)\license
	@copy $(MSYS)\msdoshlp.txt $(DAT)
	@cd $(DAT)
	@echo data >dlb.lst
	@echo oracles >>dlb.lst
	@echo options >>dlb.lst
	@echo quest.dat >>dlb.lst
	@echo rumors >>dlb.lst
	@echo help >>dlb.lst
	@echo hh >>dlb.lst
	@echo cmdhelp >>dlb.lst
	@echo history >>dlb.lst
	@echo opthelp >>dlb.lst
	@echo wizhelp >>dlb.lst
	@echo dungeon >>dlb.lst
	@echo license >>dlb.lst
	@echo msdoshlp.txt >>dlb.lst
! IF ("$(NO_FOR)"=="Y")
	@echo air.lua >>dlb.lst
	@echo Arc-fila.lua >>dlb.lst
	@echo Arc-filb.lua >>dlb.lst
	@echo Arc-goal.lua >>dlb.lst
	@echo Arc-loca.lua >>dlb.lst
	@echo Arc-strt.lua >>dlb.lst
	@echo asmodeus.lua >>dlb.lst
	@echo astral.lua >>dlb.lst
	@echo baalz.lua >>dlb.lst
	@echo Bar-fila.lua >>dlb.lst
	@echo Bar-filb.lua >>dlb.lst
	@echo Bar-goal.lua >>dlb.lst
	@echo Bar-loca.lua >>dlb.lst
	@echo Bar-strt.lua >>dlb.lst
	@echo bigrm-1.lua >>dlb.lst
	@echo bigrm-10.lua >>dlb.lst
	@echo bigrm-2.lua >>dlb.lst
	@echo bigrm-3.lua >>dlb.lst
	@echo bigrm-4.lua >>dlb.lst
	@echo bigrm-5.lua >>dlb.lst
	@echo bigrm-6.lua >>dlb.lst
	@echo bigrm-7.lua >>dlb.lst
	@echo bigrm-8.lua >>dlb.lst
	@echo bigrm-9.lua >>dlb.lst
	@echo castle.lua >>dlb.lst
	@echo Cav-fila.lua >>dlb.lst
	@echo Cav-filb.lua >>dlb.lst
	@echo Cav-goal.lua >>dlb.lst
	@echo Cav-loca.lua >>dlb.lst
	@echo Cav-strt.lua >>dlb.lst
	@echo dungeon.lua >>dlb.lst
	@echo earth.lua >>dlb.lst
	@echo fakewiz1.lua >>dlb.lst
	@echo fakewiz2.lua >>dlb.lst
	@echo fire.lua >>dlb.lst
	@echo Hea-fila.lua >>dlb.lst
	@echo Hea-filb.lua >>dlb.lst
	@echo Hea-goal.lua >>dlb.lst
	@echo Hea-loca.lua >>dlb.lst
	@echo Hea-strt.lua >>dlb.lst
	@echo juiblex.lua >>dlb.lst
	@echo Kni-fila.lua >>dlb.lst
	@echo Kni-filb.lua >>dlb.lst
	@echo Kni-goal.lua >>dlb.lst
	@echo Kni-loca.lua >>dlb.lst
	@echo Kni-strt.lua >>dlb.lst
	@echo knox.lua >>dlb.lst
	@echo medusa-1.lua >>dlb.lst
	@echo medusa-2.lua >>dlb.lst
	@echo medusa-3.lua >>dlb.lst
	@echo medusa-4.lua >>dlb.lst
	@echo minefill.lua >>dlb.lst
	@echo minend-1.lua >>dlb.lst
	@echo minend-2.lua >>dlb.lst
	@echo minend-3.lua >>dlb.lst
	@echo minetn-1.lua >>dlb.lst
	@echo minetn-2.lua >>dlb.lst
	@echo minetn-3.lua >>dlb.lst
	@echo minetn-4.lua >>dlb.lst
	@echo minetn-5.lua >>dlb.lst
	@echo minetn-6.lua >>dlb.lst
	@echo minetn-7.lua >>dlb.lst
	@echo Mon-fila.lua >>dlb.lst
	@echo Mon-filb.lua >>dlb.lst
	@echo Mon-goal.lua >>dlb.lst
	@echo Mon-loca.lua >>dlb.lst
	@echo Mon-strt.lua >>dlb.lst
	@echo nhlib.lua >>dlb.lst
	@echo oracle.lua >>dlb.lst
	@echo orcus.lua >>dlb.lst
	@echo Pri-fila.lua >>dlb.lst
	@echo Pri-filb.lua >>dlb.lst
	@echo Pri-goal.lua >>dlb.lst
	@echo Pri-loca.lua >>dlb.lst
	@echo Pri-strt.lua >>dlb.lst
	@echo quest.lua >>dlb.lst
	@echo Ran-fila.lua >>dlb.lst
	@echo Ran-filb.lua >>dlb.lst
	@echo Ran-goal.lua >>dlb.lst
	@echo Ran-loca.lua >>dlb.lst
	@echo Ran-strt.lua >>dlb.lst
	@echo Rog-fila.lua >>dlb.lst
	@echo Rog-filb.lua >>dlb.lst
	@echo Rog-goal.lua >>dlb.lst
	@echo Rog-loca.lua >>dlb.lst
	@echo Rog-strt.lua >>dlb.lst
	@echo Sam-fila.lua >>dlb.lst
	@echo Sam-filb.lua >>dlb.lst
	@echo Sam-goal.lua >>dlb.lst
	@echo Sam-loca.lua >>dlb.lst
	@echo Sam-strt.lua >>dlb.lst
	@echo sanctum.lua >>dlb.lst
	@echo soko1-1.lua >>dlb.lst
	@echo soko1-2.lua >>dlb.lst
	@echo soko2-1.lua >>dlb.lst
	@echo soko2-2.lua >>dlb.lst
	@echo soko3-1.lua >>dlb.lst
	@echo soko3-2.lua >>dlb.lst
	@echo soko4-1.lua >>dlb.lst
	@echo soko4-2.lua >>dlb.lst
	@echo themerms.lua >>dlb.lst
	@echo Tou-fila.lua >>dlb.lst
	@echo Tou-filb.lua >>dlb.lst
	@echo Tou-goal.lua >>dlb.lst
	@echo Tou-loca.lua >>dlb.lst
	@echo Tou-strt.lua >>dlb.lst
	@echo tower1.lua >>dlb.lst
	@echo tower2.lua >>dlb.lst
	@echo tower3.lua >>dlb.lst
	@echo Val-fila.lua >>dlb.lst
	@echo Val-filb.lua >>dlb.lst
	@echo Val-goal.lua >>dlb.lst
	@echo Val-loca.lua >>dlb.lst
	@echo Val-strt.lua >>dlb.lst
	@echo valley.lua >>dlb.lst
	@echo water.lua >>dlb.lst
	@echo Wiz-fila.lua >>dlb.lst
	@echo Wiz-filb.lua >>dlb.lst
	@echo Wiz-goal.lua >>dlb.lst
	@echo Wiz-loca.lua >>dlb.lst
	@echo Wiz-strt.lua >>dlb.lst
	@echo wizard1.lua >>dlb.lst
	@echo wizard2.lua >>dlb.lst
	@echo wizard3.lua >>dlb.lst
! ELSE
	@for %%N in (*.lua) do echo %%N >>dlb.lst
! ENDIF
	$(U)dlb_main cvIf dlb.lst $(SRC)\nhdat
	@cd $(SRC)

$(U)dlb_main.exe: $(DLBOBJS)
	link $(LFLAGS) /ST:5120 $(DLBOBJS),$@,$(@B);

dlb_main.o: $(U)dlb_main.c $(INCL)\config.h $(DLB_H)
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(U)dlb_main.c

# Game Dependencies

# sys/share
main.o: $(SSHR)\pcmain.c $(HACK_H) $(INCL)\dlb.h \
		#$(INCL)\win32api.h
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(SSHR)\pcmain.c
pcsys.o: $(SSHR)\pcsys.c $(HACK_H)
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(SSHR)\pcsys.c
tty.o: $(SSHR)\pctty.c $(HACK_H)
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(SSHR)\pctty.c
unix.o: $(SSHR)\pcunix.c $(HACK_H)
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(SSHR)\pcunix.c
random.o: $(SSHR)\random.c $(HACK_H)
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(SSHR)\random.c

# sys/msdos
msdos.o : $(HACK_H)  $(MSYS)\msdos.c
	@$(CC) $(CFLAGS) $(SPECOPTS) $(NEWALT) /Fo$@ $(MSYS)\msdos.c
pckeys.o : $(HACK_H)  $(MSYS)\pckeys.c
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(MSYS)\pckeys.c
pctiles.o : $(HACK_H)  $(MSYS)\pctiles.c $(MSYS)\portio.h
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(MSYS)\pctiles.c
video.o : $(HACK_H)  $(MSYS)\pcvideo.h $(MSYS)\portio.h $(MSYS)\video.c
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(MSYS)\video.c
vidvga.o : $(HACK_H)  $(MSYS)\pcvideo.h $(MSYS)\portio.h $(TILE_H) \
	$(MSYS)\vidvga.c
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(MSYS)\vidvga.c
vidtxt.o : $(HACK_H)  $(MSYS)\pcvideo.h $(MSYS)\portio.h $(TILE_H) \
	$(MSYS)\vidtxt.c
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(MSYS)\vidtxt.c
stubvid.o : $(HACK_H) $(MSYS)\video.c
	@$(CC) $(CFLAGS) $(SPECOPTS) -DSTUBVIDEO /Fo$@ $(MSYS)\video.c

# win/tty
getline.o: $(WIN)\getline.c $(HACK_H) $(INCL)\func_tab.h
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(WIN)\getline.c
termcap.o: $(WIN)\termcap.c $(HACK_H) $(INCL)\tcap.h
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(WIN)\termcap.c
topl.o: $(WIN)\topl.c $(HACK_H) $(INCL)\tcap.h
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(WIN)\topl.c
wintty.o: $(WIN)\wintty.c $(HACK_H) $(INCL)\dlb.h \
		$(INCL)\date.h $(INCL)\patchlev.h $(INCL)\tcap.h
	@$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(WIN)\wintty.c

# src dependencies
allmain.o: allmain.c $(HACK_H)
alloc.o: alloc.c $(CONFIG_H)
apply.o: apply.c $(HACK_H)
artifact.o: artifact.c $(HACK_H) $(INCL)\artifact.h $(INCL)\artilist.h
attrib.o: attrib.c $(HACK_H) $(INCL)\artifact.h
ball.o: ball.c $(HACK_H)
bones.o: bones.c $(HACK_H)
botl.o: botl.c $(HACK_H)
cmd.o: cmd.c $(HACK_H) $(INCL)\func_tab.h
dbridge.o: dbridge.c $(HACK_H)
decl.o: decl.c $(HACK_H)
detect.o: detect.c $(HACK_H) $(INCL)\artifact.h
dig.o: dig.c $(HACK_H)
display.o: display.c $(HACK_H)
dlb.o: dlb.c $(CONFIG_H) $(INCL)\dlb.h
do.o: do.c $(HACK_H)
do_name.o: do_name.c $(HACK_H)
do_wear.o: do_wear.c $(HACK_H)
dog.o: dog.c $(HACK_H)
dogmove.o: dogmove.c $(HACK_H) $(INCL)\mfndpos.h
dokick.o: dokick.c $(HACK_H)
dothrow.o: dothrow.c $(HACK_H)
drawing.o: drawing.c $(HACK_H) $(INCL)\tcap.h
dungeon.o: dungeon.c $(HACK_H) $(INCL)\dgn_file.h $(INCL)\dlb.h
eat.o: eat.c $(HACK_H)
end.o: end.c $(HACK_H) $(INCL)\dlb.h
engrave.o: engrave.c $(HACK_H)
exper.o: exper.c $(HACK_H)
explode.o: explode.c $(HACK_H)
extralev.o: extralev.c $(HACK_H)
files.o: files.c $(HACK_H) $(INCL)\dlb.h
fountain.o: fountain.c $(HACK_H)
hack.o: hack.c $(HACK_H)
hacklib.o: hacklib.c $(HACK_H)
invent.o: invent.c $(HACK_H) $(INCL)\artifact.h
light.o: light.c $(HACK_H)
lock.o: lock.c $(HACK_H)
mail.o: mail.c $(HACK_H) $(INCL)\mail.h
makemon.o: makemon.c $(HACK_H)
mapglyph.o: mapglyph.c $(HACK_H)
mcastu.o: mcastu.c $(HACK_H)
mhitm.o: mhitm.c $(HACK_H) $(INCL)\artifact.h
mhitu.o: mhitu.c $(HACK_H) $(INCL)\artifact.h
minion.o: minion.c $(HACK_H)
mklev.o: mklev.c $(HACK_H)
mkmap.o: mkmap.c $(HACK_H) $(INCL)\sp_lev.h
mkmaze.o: mkmaze.c $(HACK_H) $(INCL)\sp_lev.h
mkobj.o: mkobj.c $(HACK_H) $(INCL)\artifact.h
mkroom.o: mkroom.c $(HACK_H)
mon.o: mon.c $(HACK_H) $(INCL)\mfndpos.h
mondata.o: mondata.c $(HACK_H)
monmove.o: monmove.c $(HACK_H) $(INCL)\mfndpos.h $(INCL)\artifact.h
monst.o: monst.c $(CONFIG_H) $(INCL)\permonst.h $(INCL)\align.h \
		$(INCL)\monattk.h $(INCL)\monflag.h $(INCL)\monsym.h \
		$(INCL)\dungeon.h $(INCL)\color.h
mplayer.o: mplayer.c $(HACK_H)
mthrowu.o: mthrowu.c $(HACK_H)
muse.o: muse.c $(HACK_H)
music.o: music.c $(HACK_H) #interp.c
o_init.o: o_init.c $(HACK_H)
objects.o: objects.c $(CONFIG_H) $(INCL)\obj.h $(INCL)\objclass.h \
		$(INCL)\prop.h $(INCL)\skills.h $(INCL)\color.h
objnam.o: objnam.c $(HACK_H)
options.o: options.c $(CONFIG_H) $(INCL)\objclass.h $(INCL)\flag.h \
		$(HACK_H) $(INCL)\tcap.h
pager.o: pager.c $(HACK_H) $(INCL)\dlb.h
	@$(CC) $(CFLAGS) $(SPECOPTS) /f- /Od /Fo$@ pager.c
pickup.o: pickup.c $(HACK_H)
pline.o: pline.c $(HACK_H)
polyself.o: polyself.c $(HACK_H)
potion.o: potion.c $(HACK_H)
pray.o: pray.c $(HACK_H)
priest.o: priest.c $(HACK_H) $(INCL)\mfndpos.h
quest.o: quest.c $(HACK_H)
questpgr.o: questpgr.c $(HACK_H) $(INCL)\dlb.h
read.o: read.c $(HACK_H)
rect.o: rect.c $(HACK_H)
region.o: region.c $(HACK_H)
restore.o: restore.c $(HACK_H) $(INCL)\tcap.h
rip.o: rip.c $(HACK_H)
rnd.o: rnd.c $(HACK_H)
role.o: role.c $(HACK_H)
rumors.o: rumors.c $(HACK_H) $(INCL)\dlb.h
save.o: save.c $(HACK_H)
shk.o: shk.c $(HACK_H)
shknam.o: shknam.c $(HACK_H)
sit.o: sit.c $(HACK_H) $(INCL)\artifact.h
sounds.o: sounds.c $(HACK_H)
sp_lev.o: sp_lev.c $(HACK_H) $(INCL)\dlb.h $(INCL)\sp_lev.h
spell.o: spell.c $(HACK_H)
steal.o: steal.c $(HACK_H)
steed.o: steed.c $(HACK_H)
sys.o: sys.c $(HACK_H)
teleport.o: teleport.c $(HACK_H)
timeout.o: timeout.c $(HACK_H)
topten.o: topten.c $(HACK_H) $(INCL)\dlb.h $(INCL)\patchlev.h
track.o: track.c $(HACK_H)
trap.o: trap.c $(HACK_H)
u_init.o: u_init.c $(HACK_H)
uhitm.o: uhitm.c $(HACK_H)
vault.o: vault.c $(HACK_H)
version.o: version.c $(HACK_H) $(INCL)\date.h $(INCL)\patchlev.h
vision.o: vision.c $(HACK_H)
weapon.o: weapon.c $(HACK_H)
were.o: were.c $(HACK_H)
wield.o: wield.c $(HACK_H)
windows.o: windows.c $(HACK_H) $(INCL)\wingem.h
wizard.o: wizard.c $(HACK_H)
worm.o: worm.c $(HACK_H)
worn.o: worn.c $(HACK_H)
write.o: write.c $(HACK_H)
zap.o: zap.c $(HACK_H)

# end of file
