# NetHack 3.7 Makefile.nmake
#       Copyright (c) NetHack Development Team 1993-2023
#
#==============================================================================
# Build Tools Environment
#
#       NetHack 3.7 Work-in-progress Makefile for
#       MS Visual Studio Visual C++ compiler
#
#       Visual Studio Compilers Tested:
#            - Microsoft Visual Studio 2017 Community Edition v 15.9.58
#            - Microsoft Visual Studio 2019 Community Edition v 16.11.31
#            - Microsoft Visual Studio 2022 Community Edition v 17.7.6
#
#==============================================================================
#   This is used for building two distinct executables of NetHack:
#
#   A tty port utilizing the Win32 Console I/O subsystem, Console
#       NetHack.exe
#
#   A Win32 native port built on the Windows API, Graphical NetHack or
#       NetHackW.exe
#
#   If you have any questions about building NetHack for the Windows platform
#   please read sys/windows/Install.windows file included in the distribution.
#
#==============================================================================
#
# The default make target (so just typing 'nmake' is useful).
#

default : install

#
#------------------------------------------------------------------------------
# Where do you want the game to be built (which folder)?
#

GAMEDIR = ..\binary               # Default game build directory

#
#
#------------------------------------------------------------------------------
# Do you want to include integration with any sound libraries that work with
# this Makefile?  Add the list below. If you change the list do 'nmake clean'.
#
# There is glue in here for the following: windsound fmod
# Obtaining the 3rd party library, including its .h files, is up to you.
#
# windsound uses built-in Microsoft API's, no 3rd party download is required.

SOUND_LIBRARIES = windsound
#SOUND_LIBRARIES = windsound fmod

#------------------------------------------------------------------------------
# Curses options.
#
# Do you want console curses included?

CURSES_CONSOLE = Y

# Do you want graphical curses included?

CURSES_GRAPHICAL = Y

#
#------------------------------------------------------------------------------
# Do you want debug information available to the executable?
#

DEBUGINFO = Y

#------------------------------------------------------------------------------
#
#
# Do you have a connection to the internet available that you want
# to utilize for obtaining prerequisite Lua source code and pdcurses source code?
#

INTERNET_AVAILABLE = N

#------------------------------------------------------------------------------
#
# Do you have git commands available and NetHack in a git repository?

GIT_AVAILABLE = N

# If not, because you obtained the NetHack sources in a zip file download,
# set GIT_AVAILABLE = N
# You can override INTERNET_AVAILABLE and GIT_AVAILABLE on the nmake command
# line by adding GIT=1
#   for example:
#      nmake GIT=1 install
#
#------------------------------------------------------------------------------
# This Makefile will attempt to auto-detect your selected target architecture
# based on Visual Studio command prompt configuration settins etc.
# However, if you want to manually override generation of a
# 32-bit or 64-bit build target, you can uncomment the apppropriate
# TARGET_CPU line below.
#

#TARGET_CPU=x64
#TARGET_CPU=x86

#==============================================================================
#======================== End of Modification Section =========================
#==============================================================================
#
#       #################################################
#       #                                               #
#       # Nothing below here should have to be changed. #
#       #                                               #
#       #################################################
#
#==============================================================================
#
# if next line is commented out, full compiler command lines will be output
Q=@

SKIP_NETHACKW = N

!IFNDEF LUA_VERSION
LUAVER=5.4.6
!ELSE
LUAVER=$(LUA_VERSION)
!ENDIF

# if GIT=1 is passed on the make command, allow use of git and internet
!IF "$(GIT)" == "1"
INTERNET_AVAILABLE=Y
GIT_AVAILABLE=Y
!ENDIF
!IF "$(git)" == "1"
INTERNET_AVAILABLE=Y
GIT_AVAILABLE=Y
!ENDIF

#==============================================================================
#
#  The version of the game this Makefile was designed for
NETHACK_VERSION="3.7.0"

# A brief version for use in macros
NHV=$(NETHACK_VERSION:.=)
NHV=$(NHV:"=)

#
#  Source directories.    Makedefs hardcodes these, don't change them.
#

INCL    = ..\include     # NetHack include files
DAT     = ..\dat         # NetHack data files
DOC     = ..\doc         # NetHack documentation files
UTIL    = ..\util        # Utility source
SRC     = ..\src         # Main source
SSYS    = ..\sys\share   # Shared system files
MSWSYS  = ..\sys\windows # MS windows specific files
TTY     = ..\win\tty     # window port files (tty)
MSWIN   = ..\win\win32   # window port files (win32)
WCURSES = ..\win\curses  # window port files (curses)
WSHR    = ..\win\share   # Tile support files
QT      = ..\win\Qt      # QT support files
X11     = ..\win\X11     # X11 support files
LIBDIR  = ..\lib         # libraries and external bits
SUBM    = ..\submodules  # NetHack git submodules
SndWavDir = ..\sound\wav # sound files that get integrated

#==============================================================================
# Sanity checks for prerequisite Lua and pdcurses
#
LUA_MAY_PROCEED=N
ADD_CURSES=N

# First, Lua
!IF "$(INTERNET_AVAILABLE)" == "Y"
!IF "$(GIT_AVAILABLE)" == "Y"
LUATOP=$(SUBM)\lua
LUASRC=$(LUATOP)
LUA_MAY_PROCEED=Y
!ELSE   # GIT_AVAILABLE
LUATOP = $(LIBDIR)\lua-$(LUAVER)
LUASRC = $(LUATOP)\src
LUA_MAY_PROCEED=Y
!ENDIF  # GIT_AVAILABLE
!ELSE   # INTERNET_AVAILABLE is not Y below
# The internet is not available for obtaining Lua using either
# method (git or download). Check to see if it is available already, with
# precedence given to ../submodules, then ../lib.
#
!IF EXIST("$(SUBM)\lua\lua.h")
LUATOP=$(SUBM)\lua
LUASRC=$(LUATOP)
LUA_MAY_PROCEED=Y
!ELSEIF EXIST("$(LIBDIR)\lua-$(LUAVER)\src\lua.h")
LUATOP = $(LIBDIR)\lua-$(LUAVER)
LUASRC = $(LUATOP)\src
LUA_MAY_PROCEED=Y
!ENDIF  # Lua sources
!IF "$(LUA_MAY_PROCEED)" == "Y"
!MESSAGE No internet connection was authorized in the Makefile,
!MESSAGE but a copy of lua-$(LUAVER) was found in $(LUATOP), so that will be used.
!ENDIF  # LUA_MAY_PROCEED
!ENDIF  # INTERNET_AVAILABLE

!IF "$(LUA_MAY_PROCEED)" != "Y"
!IF "$(INTERNET_AVAILABLE)" != "Y"
!MESSAGE Your Makefile settings do not allow use of the internet to obtain Lua
!ENDIF  # INTERNET_AVAILABLE
!MESSAGE and no copy of Lua was found in either $(SUBM)\lua or $(LIBDIR)\lua-$(LUAVER).
!MESSAGE Change your nmake command line to include:
!MESSAGE     GIT=1
!MESSAGE or modify your Makefile to set the following:
!MESSAGE     INTERNET_AVAILABLE=Y
!MESSAGE     GIT_AVAILABLE=Y
!ERROR Stopping because NetHack 3.7 requires Lua for its build.
!ENDIF  # LUA_MAY_PROCEED

# Now, pdcurses
!IF "$(CURSES_CONSOLE)" == "Y"
WANT_CURSES=Y
!ENDIF
!IF "$(CURSES_GRAPHICAL)" == "Y"
WANT_CURSES=Y
!ENDIF

# Now, pdcurses
!IF "$(WANT_CURSES)" == "Y"
PDCDIST=pdcursesmod
!IF "$(INTERNET_AVAILABLE)" == "Y"
!IF "$(GIT_AVAILABLE)" == "Y"
PDCURSES_TOP=$(SUBM)\$(PDCDIST)
ADD_CURSES=Y
!ELSE  # GIT_AVAILABLE
PDCURSES_TOP=$(LIBDIR)\$(PDCDIST)
ADD_CURSES=Y
!ENDIF # GIT_AVAILABLE
!ELSE  # INTERNET_AVAILABLE is not Y below
# Your Makefile settings do not allow $(PDCDIST) to be obtained by
# git or by download. Check to see if it is available at one of
# the expected locations already, with precedence given to ../submodules,
# then ../lib.
#
!IF EXIST("$(SUBM)\$(PDCDIST)\curses.h")
PDCURSES_TOP=$(SUBM)\$(PDCDIST)
ADD_CURSES=Y
!ELSEIF EXIST("$(LIBDIR)\$(PDCDIST)\curses.h")
PDCURSES_TOP=$(LIBDIR)\$(PDCDIST)
ADD_CURSES=Y
!ENDIF  # pdcurses sources available somewhere
!IF "$(ADD_CURSES)" == "Y"
!MESSAGE Your Makefile settings do not allow $(PDCDIST) to be
!MESSAGE obtained by git or by download, but a copy of pdcurses was
!MESSAGE found in $(PDCURSES_TOP),
!MESSAGE so that will be used.
!ENDIF  # ADD_CURSES == Y
!ENDIF  # INTERNET_AVAILABLE
!ENDIF  # WANT_CURSES

!IF "$(ADD_CURSES)" != "Y"
!MESSAGE NetHack 3.7 will be built without support for the curses window-port.
!ENDIF

#These will be in the environment variables with one of the Visual Studio
#developer command prompts.
#VSCMD_ARG_HOST_ARCH=x64
#VSCMD_ARG_TGT_ARCH=x86

# We need to do this here, so some output files can
# incorporate TARGET_CPU into their names.
#
!IFDEF VSCMD_ARG_HOST_ARCH
!MESSAGE Host architecture is $(VSCMD_ARG_HOST_ARCH)
!MESSAGE Target architecture is $(VSCMD_ARG_TGT_ARCH)
! IFNDEF TARGET_CPU
!  IF "$(VSCMD_ARG_TGT_ARCH)"=="x64"
TARGET_CPU=x64
!  ELSE
TARGET_CPU=x86
!  ENDIF
! ENDIF
!ENDIF

!IF "$(TARGET_CPU)" == ""
TARGET_CPU=x86
!ENDIF

#TEST_CROSSCOMPILE=Y

#
#==========================================
# Exe File Info.
#==========================================

#
# Optional high-quality BSD random number generation routines
# (see pcconf.h). Set to nothing if not used.
#

#RANDOM	=
BCRYPT=bcrypt.lib

# To store all the level files,
# help files, etc. in a single library file.
# USE_DLB = Y is left uncommented

USE_DLB = Y

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

#
# If you defined ZLIB_COMP in include/config.h and you need
# to link with the zlib.lib library, uncomment the line below.
# If necessary, prefix explicit path information to the file name
# otherwise it assumes the NetHack src directory.
#

#ZLIB = zlib.lib


#==========================================
#================ MACROS ==================
#==========================================
# This section creates shorthand macros for many objects
# referenced later on in the Makefile.
#
#
#  Object file directories.
#

OBJTTY_B    = objtty
OBJGUI_B    = objgui
OBJUTIL_B   = objutil
OBJLUA_B    = objlua
OBJPDC_B    = objpdc

OBJTTY      = $(OBJTTY_B)\$(TARGET_CPU)
OBJGUI      = $(OBJGUI_B)\$(TARGET_CPU)
OBJUTIL     = $(OBJUTIL_B)\$(TARGET_CPU)
OBJLUA      = $(OBJLUA_B)\$(TARGET_CPU)
OBJPDC      = $(OBJPDC_B)\$(TARGET_CPU)

#
# Shorten up the location for some files
#

OTTY   = $(OBJTTY)^\
OGUI   = $(OBJGUI)^\
OUTL   = $(OBJUTIL)^\
OLUA   = $(OBJLUA)^\
OPDC   = $(OBJPDC)^\

U  = $(UTIL)^\

!IFDEF TEST_CROSSCOMPILE
HOST=_host
CROSSCOMPILE_TARGET= -DCROSSCOMPILE_TARGET
CROSSCOMPILE= -DCROSSCOMPILE
!ELSE
HOST=
CROSSCOMPILE_TARGET=
CROSSCOMPILE=
!ENDIF

!IFDEF GIT_HASH
GITHASH = -DNETHACK_GIT_SHA=\"$(GIT_HASH)\"
!ENDIF

!IFDEF GIT_BRANCH
GITBRANCH = -DNETHACK_GIT_BRANCH=\"$(GIT_BRANCH)\"
!ENDIF

#===============-=================================================
# LUA library
# Official source for Lua is http://www.lua.org/ftp/lua-5.4.6.tar.gz
#
# Source for the NetHack repository submodule in ../submodules/lua
# is https://github.com/lua/lua.git
#=================================================================
#
# Location of LUA
#
# Original source needs to be obtained from:
#    http://www.lua.org/ftp/lua-5.4.6.tar.gz
#
#    This build assumes that the LUA sources are located
#    at the specified location. If they are actually elsewhere
#    you'll need to specify the correct spot below in order to
#    successfully build NetHack-3.7.  You cannot build a functional
#    version of NetHack-3.7 Work-in-progress without including Lua.
#

!IFNDEF LUAVER
LUAVER=5.4.6
!ENDIF

LUALIB   = $(LIBDIR)\lua$(LUAVER)-$(TARGET_CPU)-static.lib
LUADLL   = $(LIBDIR)\lua$(LUAVER)-$(TARGET_CPU).dll
LUAINCL  = /I$(LUASRC)
LUATARGETS = lua.exe $(LUADLL) $(LUALIB)

LUASRCFILES =   lapi.c lauxlib.c lbaselib.c lcode.c              \
		lcorolib.c lctype.c ldblib.c ldebug.c ldo.c      \
		ldump.c lfunc.c lgc.c linit.c liolib.c llex.c    \
		lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c \
		loslib.c lparser.c lstate.c lstring.c lstrlib.c  \
		ltable.c ltablib.c ltm.c lundump.c lutf8lib.c    \
		lvm.c lzio.c

LUAOBJFILES =   $(OLUA)lapi.o $(OLUA)lauxlib.o $(OLUA)lbaselib.o                \
		$(OLUA)lcode.o $(OLUA)lcorolib.o $(OLUA)lctype.o $(OLUA)ldblib.o   \
		$(OLUA)ldebug.o $(OLUA)ldo.o $(OLUA)ldump.o $(OLUA)lfunc.o         \
		$(OLUA)lgc.o $(OLUA)linit.o $(OLUA)liolib.o $(OLUA)llex.o          \
		$(OLUA)lmathlib.o $(OLUA)lmem.o $(OLUA)loadlib.o $(OLUA)lobject.o  \
		$(OLUA)lopcodes.o $(OLUA)loslib.o $(OLUA)lparser.o $(OLUA)lstate.o \
		$(OLUA)lstring.o $(OLUA)lstrlib.o $(OLUA)ltable.o $(OLUA)ltablib.o \
		$(OLUA)ltm.o $(OLUA)lundump.o $(OLUA)lutf8lib.o $(OLUA)lvm.o $(OLUA)lzio.o

!IF "$(LUAVER)" == "5.3.5"
LUASRCFILES = $(LUASRCFILES) lbitlib.c
LUAOBJFILES =   $(LUAOBJFILES) $(OLUA)lbitlib.o
!ELSE
#  5.4.0 added header files ljumptab.h and lopnames.h
#        and removes lbitlib.c
!ENDIF
#===============-=================================================
# PDCurses build macros
# Source for the NetHack repository submodule in
#        ../submodules/pdcurses
# is https://github.com/wmcbrine/PDCurses.git
#        ../submodules/pdcursesmod
# is https://github.com/Bill-Gray/PDCursesMod
#=================================================================

!IF "$(ADD_CURSES)" == "Y"
PDCURSES_CURSES_H	= $(PDCURSES_TOP)\curses.h
PDCURSES_CURSPRIV_H	= $(PDCURSES_TOP)\curspriv.h
PDCURSES_HEADERS	= $(PDCURSES_CURSES_H) $(PDCURSES_CURSPRIV_H)
PDCSRC                  = $(PDCURSES_TOP)\pdcurses
PDCWINCON               = $(PDCURSES_TOP)\wincon
PDCWINGUI               = $(PDCURSES_TOP)\wingui
PDCDEP                  = $(PDCURSES_TOP)\curses.h

PDCCOMMONOBJS = $(OPDC)addch.o $(OPDC)addchstr.o $(OPDC)addstr.o $(OPDC)attr.o $(OPDC)beep.o \
	$(OPDC)bkgd.o $(OPDC)border.o $(OPDC)clear.o $(OPDC)color.o $(OPDC)debug.o \
	$(OPDC)delch.o $(OPDC)deleteln.o $(OPDC)getch.o $(OPDC)getstr.o \
	$(OPDC)getyx.o $(OPDC)inch.o $(OPDC)inchstr.o $(OPDC)initscr.o \
	$(OPDC)inopts.o $(OPDC)insch.o $(OPDC)insstr.o $(OPDC)instr.o \
	$(OPDC)kernel.o $(OPDC)keyname.o $(OPDC)mouse.o $(OPDC)move.o \
	$(OPDC)outopts.o $(OPDC)overlay.o $(OPDC)pad.o $(OPDC)panel.o \
	$(OPDC)printw.o $(OPDC)refresh.o $(OPDC)scanw.o $(OPDC)scr_dump.o \
	$(OPDC)scroll.o $(OPDC)slk.o $(OPDC)termattr.o $(OPDC)touch.o \
	$(OPDC)util.o $(OPDC)window.o

#PDCOBJS = $(OPDC)pdcclip.o $(OPDC)pdcdisp.o $(OPDC)pdcgetsc.o $(OPDC)pdckbd.o $(OPDC)pdcscrn.o \
#	$(OPDC)pdcsetsc.o $(OPDC)pdcutil.o

PDCWINCONOBJS = $(OPDC)pdcclip_wincon.o $(OPDC)pdcdisp_wincon.o \
	$(OPDC)pdcgetsc_wincon.o $(OPDC)pdckbd_wincon.o \
	$(OPDC)pdcscrn_wincon.o $(OPDC)pdcsetsc_wincon.o \
	$(OPDC)pdcutil_wincon.o

PDCWINGUIOBJS = $(OPDC)pdcclip_wingui.o $(OPDC)pdcdisp_wingui.o \
	$(OPDC)pdcgetsc_wingui.o $(OPDC)pdckbd_wingui.o \
	$(OPDC)pdcscrn_wingui.o $(OPDC)pdcsetsc_wingui.o \
	$(OPDC)pdcutil_wingui.o

PDCLIB = $(LIBDIR)\$(PDCDIST)-$(TARGET_CPU).lib

PDCINCL = /I$(PDCURSES_TOP) /I$(PDCSRC)
PDCINCLGUI = /I$(PDCWINCON)
PDCINCLCON = /I$(PDCWINGUI)
!ELSE
PDCLIB =
PDCDEP =
!ENDIF


#=================================================================
HACKINCL = $(INCL)\align.h $(INCL)\artifact.h $(INCL)\artilist.h \
	$(INCL)\attrib.h $(INCL)\botl.h $(INCL)\color.h $(INCL)\config.h \
	$(INCL)\config1.h $(INCL)\context.h $(INCL)\coord.h $(INCL)\decl.h \
	$(INCL)\display.h $(INCL)\dlb.h $(INCL)\dungeon.h $(INCL)\engrave.h \
	$(INCL)\extern.h $(INCL)\flag.h $(INCL)\fnamesiz.h $(INCL)\func_tab.h \
	$(INCL)\global.h $(INCL)\warnings.h $(INCL)\hack.h $(INCL)\lint.h \
	$(INCL)\mextra.h $(INCL)\mfndpos.h $(INCL)\micro.h $(INCL)\mkroom.h \
	$(INCL)\monattk.h $(INCL)\mondata.h $(INCL)\monflag.h $(INCL)\monst.h \
	$(INCL)\monsters.h $(INCL)\obj.h $(INCL)\objects.h $(INCL)\objclass.h \
	$(INCL)\optlist.h $(INCL)\patchlevel.h $(INCL)\pcconf.h \
	$(INCL)\permonst.h $(INCL)\prop.h $(INCL)\rect.h $(INCL)\region.h \
	$(INCL)\sym.h $(INCL)\defsym.h $(INCL)\rm.h $(INCL)\sp_lev.h \
	$(INCL)\spell.h $(INCL)\sys.h $(INCL)\cstd.h $(INCL)\tcap.h \
	$(INCL)\timeout.h $(INCL)\tradstdc.h $(INCL)\trap.h \
	$(INCL)\unixconf.h $(INCL)\vision.h $(INCL)\vmsconf.h \
	$(INCL)\wintty.h $(INCL)\wincurs.h $(INCL)\winX.h \
	$(INCL)\winprocs.h $(INCL)\sndprocs.h $(INCL)\seffects.h \
	$(INCL)\wintype.h $(INCL)\you.h $(INCL)\youprop.h

# all .c that are part of the main NetHack program and are not operating- or
# windowing-system specific
HACKCSRC = allmain.c alloc.c apply.c artifact.c attrib.c ball.c bones.c \
	   botl.c cmd.c dbridge.c decl.c detect.c dig.c display.c dlb.c do.c \
	   do_name.c do_wear.c dog.c dogmove.c dokick.c dothrow.c drawing.c \
	   dungeon.c eat.c end.c engrave.c exper.c explode.c extralev.c \
	   files.c fountain.c hack.c hacklib.c \
	   insight.c invent.c isaac64.c light.c \
	   lock.c mail.c makemon.c mcastu.c mdlib.c mhitm.c \
	   mhitu.c minion.c mklev.c mkmap.c mkmaze.c mkobj.c mkroom.c mon.c \
	   mondata.c monmove.c monst.c mplayer.c mthrowu.c muse.c music.c \
	   nhlua.c nhlsel.c nhlobj.c o_init.c objects.c objnam.c \
	   options.c pager.c pickup.c pline.c polyself.c potion.c pray.c \
	   priest.c quest.c questpgr.c read.c rect.c region.c restore.c \
	   rip.c rnd.c role.c rumors.c save.c sfstruct.c \
	   shk.c shknam.c sit.c sounds.c \
	   sp_lev.c spell.c steal.c steed.c symbols.c sys.c teleport.c \
	   timeout.c topten.c track.c trap.c u_init.c uhitm.c utf8map.c \
	   vault.c version.c vision.c weapon.c were.c wield.c \
	   windows.c wizard.c worm.c worn.c write.c zap.c

LUA_FILES = $(DAT)\air.lua  $(DAT)\Arc-fila.lua $(DAT)\Arc-filb.lua \
	$(DAT)\Arc-goal.lua $(DAT)\Arc-loca.lua $(DAT)\Arc-strt.lua \
	$(DAT)\asmodeus.lua $(DAT)\astral.lua   $(DAT)\baalz.lua \
	$(DAT)\Bar-fila.lua $(DAT)\Bar-filb.lua $(DAT)\Bar-goal.lua \
	$(DAT)\Bar-loca.lua $(DAT)\Bar-strt.lua $(DAT)\bigrm-1.lua \
	$(DAT)\bigrm-10.lua $(DAT)\bigrm-11.lua $(DAT)\bigrm-2.lua \
	$(DAT)\bigrm-3.lua  $(DAT)\bigrm-4.lua  $(DAT)\bigrm-5.lua \
	$(DAT)\bigrm-6.lua  $(DAT)\bigrm-7.lua  $(DAT)\bigrm-8.lua \
	$(DAT)\bigrm-9.lua  $(DAT)\castle.lua   $(DAT)\Cav-fila.lua \
	$(DAT)\Cav-filb.lua $(DAT)\Cav-goal.lua $(DAT)\Cav-loca.lua \
	$(DAT)\Cav-strt.lua $(DAT)\dungeon.lua  $(DAT)\earth.lua \
	$(DAT)\fakewiz1.lua $(DAT)\fakewiz2.lua $(DAT)\fire.lua \
	$(DAT)\Hea-fila.lua $(DAT)\Hea-filb.lua $(DAT)\Hea-goal.lua \
	$(DAT)\Hea-loca.lua $(DAT)\Hea-strt.lua $(DAT)\hellfill.lua \
	$(DAT)\juiblex.lua  $(DAT)\Kni-fila.lua $(DAT)\Kni-filb.lua \
	$(DAT)\Kni-goal.lua $(DAT)\Kni-loca.lua $(DAT)\Kni-strt.lua \
	$(DAT)\knox.lua     $(DAT)\medusa-1.lua $(DAT)\medusa-2.lua \
	$(DAT)\medusa-3.lua $(DAT)\medusa-4.lua $(DAT)\minefill.lua \
	$(DAT)\minend-1.lua $(DAT)\minend-2.lua $(DAT)\minend-3.lua \
	$(DAT)\minetn-1.lua $(DAT)\minetn-2.lua $(DAT)\minetn-3.lua \
	$(DAT)\minetn-4.lua $(DAT)\minetn-5.lua $(DAT)\minetn-6.lua \
	$(DAT)\minetn-7.lua $(DAT)\Mon-fila.lua $(DAT)\Mon-filb.lua \
	$(DAT)\Mon-goal.lua $(DAT)\Mon-loca.lua $(DAT)\Mon-strt.lua \
	$(DAT)\nhcore.lua   $(DAT)\nhlib.lua    $(DAT)\oracle.lua \
	$(DAT)\orcus.lua    $(DAT)\Pri-fila.lua $(DAT)\Pri-filb.lua \
	$(DAT)\Pri-goal.lua $(DAT)\Pri-loca.lua $(DAT)\Pri-strt.lua \
	$(DAT)\quest.lua    $(DAT)\Ran-fila.lua $(DAT)\Ran-filb.lua \
	$(DAT)\Ran-goal.lua $(DAT)\Ran-loca.lua $(DAT)\Ran-strt.lua \
	$(DAT)\Rog-fila.lua $(DAT)\Rog-filb.lua $(DAT)\Rog-goal.lua \
	$(DAT)\Rog-loca.lua $(DAT)\Rog-strt.lua $(DAT)\Sam-fila.lua \
	$(DAT)\Sam-filb.lua $(DAT)\Sam-goal.lua $(DAT)\Sam-loca.lua \
	$(DAT)\Sam-strt.lua $(DAT)\sanctum.lua  $(DAT)\soko1-1.lua \
	$(DAT)\soko1-2.lua  $(DAT)\soko2-1.lua  $(DAT)\soko2-2.lua \
	$(DAT)\soko3-1.lua  $(DAT)\soko3-2.lua  $(DAT)\soko4-1.lua \
	$(DAT)\soko4-2.lua  $(DAT)\themerms.lua $(DAT)\Tou-fila.lua \
	$(DAT)\Tou-filb.lua $(DAT)\Tou-goal.lua $(DAT)\Tou-loca.lua \
	$(DAT)\Tou-strt.lua $(DAT)\tower1.lua   $(DAT)\tower2.lua \
	$(DAT)\tower3.lua   $(DAT)\Val-fila.lua $(DAT)\Val-filb.lua \
	$(DAT)\Val-goal.lua $(DAT)\Val-loca.lua $(DAT)\Val-strt.lua \
	$(DAT)\valley.lua   $(DAT)\water.lua    $(DAT)\Wiz-fila.lua \
	$(DAT)\Wiz-filb.lua $(DAT)\Wiz-goal.lua $(DAT)\Wiz-loca.lua \
	$(DAT)\Wiz-strt.lua $(DAT)\wizard1.lua  $(DAT)\wizard2.lua \
	$(DAT)\wizard3.lua  $(DAT)\tut-1.lua    $(DAT)\tut-2.lua
#
# Utility Objects.
#

MAKESRC       = $(U)makedefs.c

MAKEDEFSOBJS  = $(OUTL)makedefs.o $(OUTL)monst$(HOST).o $(OUTL)objects$(HOST).o \
		$(OUTL)date.o $(OUTL)alloc.o $(OUTL)panic.o

RECOVOBJS      = $(OUTL)recover.o

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

#
# These are not invoked during a normal game build in 3.7
#

TEXT_IO   = $(OUTL)tiletext.o	$(OUTL)tiletxt.o	$(OUTL)drawing$(HOST).o \
		 $(OUTL)monst$(HOST).o	$(OUTL)objects$(HOST).o

TEXT_IO32 = $(OUTL)tilete32.o $(OUTL)tiletx32.o $(OUTL)drawing$(HOST).o \
		 $(OUTL)monst$(HOST).o $(OUTL)objects$(HOST).o

GIFREADERS_HOST     = $(OUTL)gifread.o	$(OUTL)alloc$(HOST).o $(OUTL)panic$(HOST).o
GIFREADERS32_HOST   = $(OUTL)gifrd32.o $(OUTL)alloc$(HOST).o $(OUTL)panic$(HOST).o

PPMWRITERS     = $(OUTL)ppmwrite.o $(OUTL)alloc$(HOST).o $(OUTL)panic$(HOST).o

WINDHDR = $(MSWSYS)\win10.h $(MSWSYS)\winos.h $(MSWSYS)\win32api.h

#
# - Curses
#

!IF "$(ADD_CURSES)" == "Y"
PDCURSESFLAGS = -DPDC_WIDE
CURSESOBJ= $(OTTY)cursdial.o $(OTTY)cursinit.o $(OTTY)cursinvt.o \
	$(OTTY)cursmain.o $(OTTY)cursmesg.o $(OTTY)cursmisc.o \
	$(OTTY)cursstat.o $(OTTY)curswins.o
!IF "$(CURSES_CONSOLE)" == "Y"
CURSESWINCONOBJS = $(CURSESOBJ)
PDCWINCONLIB = $(PDCLIB)
CURSESDEF1=-D"CURSES_GRAPHICS" -DPDC_NCMOUSE
#CURSESDEF2=-D"CURSES_BRIEF_INCLUDE" -DCHTYPE_32
CURSESDEF2=-DCURSES_UNICODE $(PDCURSESFLAGS)
!ENDIF
!IF "$(CURSES_GRAPHICAL)" == "Y"
CURSESWINGUIOBJS = $(CURSESOBJ) $(OGUI)guitty.o
PDCWINGUILIB = $(PDCLIB)
CURSESDEF1=-D"CURSES_GRAPHICS" -DPDC_NCMOUSE
#CURSESDEF2=-D"CURSES_BRIEF_INCLUDE" -DCHTYPE_32
CURSESDEF2=-DCURSES_UNICODE $(PDCURSESFLAGS)
!ENDIF
!ELSE
!UNDEF CURSDEF
!UNDEF CURSESLIB
!UNDEF CURSESOBJ
!UNDEF CURSESWINCONOBJS
!UNDEF CURSESWINGUIOBJS
!UNDEF PDCWINCONLIB
!UNDEF PDCWINGUILIB
!ENDIF

#
# - TTY
#

TTYDEF=  -D"_CONSOLE" -DWIN32CON $(CURSESDEF1)

RANDOMTTY = $(OTTY)random.o
MDLIBTTY  = $(OTTY)mdlib.o
DLBOBJTTY = $(OTTY)dlb.o
REGEXTTY  = $(OTTY)cppregex.o
LUAOBJTTY = $(OTTY)nhlua.o    $(OTTY)nhlsel.o    $(OTTY)nhlobj.o
VVOBJTTY  = $(OTTY)version.o

SOBJTTY   = $(OTTY)windmain.o $(OTTY)windsys.o $(OTTY)win10.o \
		$(OTTY)safeproc.o

TTYOBJ = $(OTTY)topl.o $(OTTY)getline.o  $(OTTY)wintty.o

VTTYOBJ01 = $(OTTY)allmain.o  $(OTTY)alloc.o    $(OTTY)apply.o    $(OTTY)artifact.o
VTTYOBJ02 = $(OTTY)attrib.o   $(OTTY)ball.o     $(OTTY)bones.o    $(OTTY)botl.o
VTTYOBJ03 = $(OTTY)cmd.o      $(OTTY)dbridge.o  $(OTTY)decl.o     $(OTTY)detect.o
VTTYOBJ04 = $(OTTY)dig.o      $(OTTY)display.o  $(OTTY)do.o       $(OTTY)do_name.o
VTTYOBJ05 = $(OTTY)do_wear.o  $(OTTY)dog.o      $(OTTY)dogmove.o  $(OTTY)dokick.o
VTTYOBJ06 = $(OTTY)dothrow.o  $(OTTY)drawing.o  $(OTTY)dungeon.o  $(OTTY)eat.o
VTTYOBJ07 = $(OTTY)end.o      $(OTTY)engrave.o  $(OTTY)exper.o    $(OTTY)explode.o
VTTYOBJ08 = $(OTTY)extralev.o $(OTTY)files.o    $(OTTY)fountain.o $(OTTY)hack.o
VTTYOBJ09 = $(OTTY)hacklib.o  $(OTTY)insight.o  $(OTTY)invent.o   $(OTTY)isaac64.o
VTTYOBJ10 = $(OTTY)light.o    $(OTTY)lock.o     $(OTTY)mail.o     $(OTTY)makemon.o
VTTYOBJ11 = $(OTTY)mcastu.o   $(OTTY)mhitm.o    $(OTTY)mhitu.o    $(OTTY)minion.o
VTTYOBJ12 = $(OTTY)mklev.o    $(OTTY)mkmap.o    $(OTTY)mkmaze.o   $(OTTY)mkobj.o
VTTYOBJ13 = $(OTTY)mkroom.o   $(OTTY)mon.o      $(OTTY)mondata.o  $(OTTY)monmove.o
VTTYOBJ14 = $(OTTY)monst.o    $(OTTY)mplayer.o  $(OTTY)mthrowu.o  $(OTTY)muse.o
VTTYOBJ15 = $(OTTY)music.o    $(OTTY)o_init.o   $(OTTY)objects.o  $(OTTY)objnam.o
VTTYOBJ16 = $(OTTY)options.o  $(OTTY)pager.o    $(OTTY)pickup.o   $(OTTY)pline.o
VTTYOBJ17 = $(OTTY)polyself.o $(OTTY)potion.o   $(OTTY)pray.o     $(OTTY)priest.o
VTTYOBJ18 = $(OTTY)quest.o    $(OTTY)questpgr.o $(RANDOM)      $(OTTY)read.o
VTTYOBJ19 = $(OTTY)rect.o     $(OTTY)region.o   $(OTTY)restore.o  $(OTTY)rip.o
VTTYOBJ20 = $(OTTY)rnd.o      $(OTTY)role.o     $(OTTY)rumors.o   $(OTTY)save.o
VTTYOBJ21 = $(OTTY)sfstruct.o $(OTTY)shk.o      $(OTTY)shknam.o   $(OTTY)sit.o
VTTYOBJ22 = $(OTTY)sounds.o   $(OTTY)sp_lev.o   $(OTTY)spell.o    $(OTTY)steal.o
VTTYOBJ23 = $(OTTY)steed.o    $(OTTY)symbols.o  $(OTTY)sys.o      $(OTTY)teleport.o
VTTYOBJ24 = $(OTTY)timeout.o  $(OTTY)topten.o   $(OTTY)track.o    $(OTTY)trap.o
VTTYOBJ25 = $(OTTY)u_init.o   $(OTTY)uhitm.o    $(OTTY)utf8map.o  $(OTTY)vault.o
VTTYOBJ26 = $(OTTY)vision.o   $(OTTY)weapon.o   $(OTTY)were.o     $(OTTY)wield.o
VTTYOBJ27 = $(OTTY)windows.o  $(OTTY)wizard.o   $(OTTY)worm.o     $(OTTY)worn.o
VTTYOBJ28 = $(OTTY)write.o    $(OTTY)zap.o

OBJSTTY   = $(MDLIBTTY) \
	$(VTTYOBJ01) $(VTTYOBJ02) $(VTTYOBJ03) $(VTTYOBJ04) $(VTTYOBJ05) \
	$(VTTYOBJ06) $(VTTYOBJ07) $(VTTYOBJ08) $(VTTYOBJ09) $(VTTYOBJ10) \
	$(VTTYOBJ11) $(VTTYOBJ12) $(VTTYOBJ13) $(VTTYOBJ14) $(VTTYOBJ15) \
	$(VTTYOBJ16) $(VTTYOBJ17) $(VTTYOBJ18) $(VTTYOBJ19) $(VTTYOBJ20) \
	$(VTTYOBJ21) $(VTTYOBJ22) $(VTTYOBJ23) $(VTTYOBJ24) $(VTTYOBJ25) \
	$(VTTYOBJ26) $(VTTYOBJ27) $(VTTYOBJ28) $(VTTYOBJ29) $(VTTYOBJ30) \
	$(REGEXTTY)

ALLOBJTTY  = $(SOBJTTY) $(DLBOBJTTY) $(OBJSTTY) $(VVOBJTTY) $(LUAOBJTTY)

#
# - GUI
#

GUIDEF= -DTILES -DMSWIN_GRAPHICS -DNOTTYGRAPHICS $(CURSESDEF1)

ALL_GUIHDR = $(MSWIN)\mhaskyn.h $(MSWIN)\mhdlg.h $(MSWIN)\mhfont.h \
	$(MSWIN)\mhinput.h $(MSWIN)\mhmain.h $(MSWIN)\mhmap.h $(MSWIN)\mhmenu.h \
	$(MSWIN)\mhmsg.h $(MSWIN)\mhmsgwnd.h $(MSWIN)\mhrip.h \
	$(MSWIN)\mhsplash.h $(MSWIN)\mhstatus.h \
	$(MSWIN)\mhtext.h $(MSWIN)\resource.h $(MSWIN)\winMS.h

RANDOMGUI = $(OGUI)random.o
MDLIBGUI  = $(OGUI)mdlib.o
DLBOBJGUI = $(OGUI)dlb.o
REGEXGUI  = $(OGUI)cppregex.o
LUAOBJGUI = $(OGUI)nhlua.o    $(OGUI)nhlsel.o   $(OGUI)nhlobj.o
VVOBJGUI  = $(OGUI)version.o

SOBJGUI   = $(OGUI)windmain.o $(OGUI)windsys.o $(OGUI)win10.o \
		$(OGUI)safeproc.o

GUIOBJ	= $(OGUI)mhaskyn.o $(OGUI)mhdlg.o \
	$(OGUI)mhfont.o $(OGUI)mhinput.o $(OGUI)mhmain.o $(OGUI)mhmap.o \
	$(OGUI)mhmenu.o $(OGUI)mhmsgwnd.o $(OGUI)mhrip.o $(OGUI)mhsplash.o \
	$(OGUI)mhstatus.o $(OGUI)mhtext.o $(OGUI)mswproc.o $(OGUI)NetHackW.o

VGUIOBJ01 = $(OGUI)allmain.o  $(OGUI)alloc.o    $(OGUI)apply.o    $(OGUI)artifact.o
VGUIOBJ02 = $(OGUI)attrib.o   $(OGUI)ball.o     $(OGUI)bones.o    $(OGUI)botl.o
VGUIOBJ03 = $(OGUI)cmd.o      $(OGUI)dbridge.o  $(OGUI)decl.o     $(OGUI)detect.o
VGUIOBJ04 = $(OGUI)dig.o      $(OGUI)display.o  $(OGUI)do.o       $(OGUI)do_name.o
VGUIOBJ05 = $(OGUI)do_wear.o  $(OGUI)dog.o      $(OGUI)dogmove.o  $(OGUI)dokick.o
VGUIOBJ06 = $(OGUI)dothrow.o  $(OGUI)drawing.o  $(OGUI)dungeon.o  $(OGUI)eat.o
VGUIOBJ07 = $(OGUI)end.o      $(OGUI)engrave.o  $(OGUI)exper.o    $(OGUI)explode.o
VGUIOBJ08 = $(OGUI)extralev.o $(OGUI)files.o    $(OGUI)fountain.o $(OGUI)hack.o
VGUIOBJ09 = $(OGUI)hacklib.o  $(OGUI)insight.o  $(OGUI)invent.o   $(OGUI)isaac64.o
VGUIOBJ10 = $(OGUI)light.o    $(OGUI)lock.o     $(OGUI)mail.o     $(OGUI)makemon.o
VGUIOBJ11 = $(OGUI)mcastu.o   $(OGUI)mhitm.o    $(OGUI)mhitu.o    $(OGUI)minion.o
VGUIOBJ12 = $(OGUI)mklev.o    $(OGUI)mkmap.o    $(OGUI)mkmaze.o   $(OGUI)mkobj.o
VGUIOBJ13 = $(OGUI)mkroom.o   $(OGUI)mon.o      $(OGUI)mondata.o  $(OGUI)monmove.o
VGUIOBJ14 = $(OGUI)monst.o    $(OGUI)mplayer.o  $(OGUI)mthrowu.o  $(OGUI)muse.o
VGUIOBJ15 = $(OGUI)music.o    $(OGUI)o_init.o   $(OGUI)objects.o  $(OGUI)objnam.o
VGUIOBJ16 = $(OGUI)options.o  $(OGUI)pager.o    $(OGUI)pickup.o   $(OGUI)pline.o
VGUIOBJ17 = $(OGUI)polyself.o $(OGUI)potion.o   $(OGUI)pray.o     $(OGUI)priest.o
VGUIOBJ18 = $(OGUI)quest.o    $(OGUI)questpgr.o $(RANDOMGUI)      $(OGUI)read.o
VGUIOBJ19 = $(OGUI)rect.o     $(OGUI)region.o   $(OGUI)restore.o  $(OGUI)rip.o
VGUIOBJ20 = $(OGUI)rnd.o      $(OGUI)role.o     $(OGUI)rumors.o   $(OGUI)save.o
VGUIOBJ21 = $(OGUI)sfstruct.o $(OGUI)shk.o      $(OGUI)shknam.o   $(OGUI)sit.o
VGUIOBJ22 = $(OGUI)sounds.o   $(OGUI)sp_lev.o   $(OGUI)spell.o    $(OGUI)steal.o
VGUIOBJ23 = $(OGUI)steed.o    $(OGUI)symbols.o  $(OGUI)sys.o      $(OGUI)teleport.o
VGUIOBJ24 = $(OGUI)timeout.o  $(OGUI)topten.o   $(OGUI)track.o    $(OGUI)trap.o
VGUIOBJ25 = $(OGUI)u_init.o   $(OGUI)uhitm.o    $(OGUI)utf8map.o  $(OGUI)vault.o
VGUIOBJ26 = $(OGUI)vision.o   $(OGUI)weapon.o   $(OGUI)were.o     $(OGUI)wield.o
VGUIOBJ27 = $(OGUI)windows.o  $(OGUI)wizard.o   $(OGUI)worm.o     $(OGUI)worn.o
VGUIOBJ28 = $(OGUI)write.o    $(OGUI)zap.o

OBJSGUI   = $(MDLIBGUI) \
	$(VGUIOBJ01) $(VGUIOBJ02) $(VGUIOBJ03) $(VGUIOBJ04) $(VGUIOBJ05) \
	$(VGUIOBJ06) $(VGUIOBJ07) $(VGUIOBJ08) $(VGUIOBJ09) $(VGUIOBJ10) \
	$(VGUIOBJ11) $(VGUIOBJ12) $(VGUIOBJ13) $(VGUIOBJ14) $(VGUIOBJ15) \
	$(VGUIOBJ16) $(VGUIOBJ17) $(VGUIOBJ18) $(VGUIOBJ19) $(VGUIOBJ20) \
	$(VGUIOBJ21) $(VGUIOBJ22) $(VGUIOBJ23) $(VGUIOBJ24) $(VGUIOBJ25) \
	$(VGUIOBJ26) $(VGUIOBJ27) $(VGUIOBJ28) $(VGUIOBJ29) $(VGUIOBJ30) \
	$(REGEXGUI)

ALLOBJGUI  = $(SOBJGUI) $(DLBOBJGUI) $(OBJSGUI) $(VVOBJGUI) $(LUAOBJGUI)

#
# - other
#
COMCTRL = comctl32.lib

OPTIONS_FILE = $(DAT)\options

!IFDEF TEST_CROSSCOMPILE
DLBOBJ_HOST = $(OTTY)dlb$(HOST).o
!ENDIF

#===============-=================================================
# SOUND_LIBRARIES
#=================================================================

# +-------------------------------+
# | windsound (uses built-in api) |
# +-------------------------------+
#
SNDTEMP = $(SOUND_LIBRARIES:windsound=)
!IF "$(SOUND_LIBRARIES)" != "$(SNDTEMP)"
!MESSAGE Including windsound integration
SOUND_WINDSOUND=Y
HAVE_SOUNDLIB=Y
NEED_USERSOUNDS=Y
NEED_SEAUTOMAP=Y
NEED_WAV=Y
SOUNDLIBINCL = $(SOUNDLIBINCL)
SOUNDLIBDEFS = $(SOUNDLIBDEFS) -DSND_LIB_WINDSOUND
TTYSOUNDOBJS = $(TTYSOUNDOBJS) $(OTTY)windsound.o
GUISOUNDOBJS = $(GUISOUNDOBJS) $(OGUI)windsound.o
#WINDSOUNDLIBDIR = 
#TTYSOUNDLIBS = $(TTYSOUNDLIBS)
#GUISOUNDLIBS = $(GUISOUNDLIBS)
#WINDSOUNDLIBDIR =
#WINDSOUNDLIBDLL =
WINDSOUNDDIR = ..\sound\windsound
SOUNDSRCS = $(SOUNDSRCS) $(WINDSOUNDDIR)\windsound.c
#GAMEDIRDLLS = $(GAMEDIRDLLS) $(GAMEDIR\$(WINDSOUNDLIBDLL)
!ENDIF
SNDTEMP=

# +--------------------------------+
# | fmod? (requires 3rd party lib) |
# +--------------------------------+
#

SNDTEMP = $(SOUND_LIBRARIES:fmod=)
!IF "$(SOUND_LIBRARIES)" != "$(SNDTEMP)"
!MESSAGE Including fmod integration
SOUND_FMOD=Y
HAVE_SOUNDLIB=Y
NEED_USERSOUNDS=Y
NEED_SEAUTOMAP=Y
NEED_WAV=Y
FMODROOT=..\lib\fmod\api\core
FMODDLLBASENAME = fmod.dll
SOUNDLIBINCL = $(SOUNDLIBINCL) -I$(FMODROOT)/inc
SOUNDLIBDEFS = $(SOUNDLIBDEFS) -DSND_LIB_FMOD
TTYSOUNDOBJS = $(TTYSOUNDOBJS) $(OTTY)fmod.o
GUISOUNDOBJS = $(GUISOUNDOBJS) $(OGUI)fmod.o
FMODLIBDIR = $(FMODROOT)\lib\$(TARGET_CPU)
FMODLIBDLL = $(FMODLIBDIR)\$(FMODDLLBASENAME)
FMODFLAGS = -wd4201
TTYSOUNDLIBS = $(TTYSOUNDLIBS) $(FMODLIBDIR)\fmod_vc.lib
GUISOUNDLIBS = $(GUISOUNDLIBS) $(FMODLIBDIR)\fmod_vc.lib
GAMEDIRDLLS = $(GAMEDIRDLLS) $(GAMEDIR)\$(FMODDLLBASENAME)
FMODDIR = ..\sound\fmod
SOUNDSRCS = $(SOUNDSRCS) $(FMODDIR)\fmod.c
!MESSAGE ---------------------------------------------------------------------
!MESSAGE ** NOTES for fmod sound library integration **
!MESSAGE For fmod integration, this Makefile expects:
!MESSAGE fmod include directory    : $(FMODROOT)\inc
!MESSAGE fmod library directory    : $(FMODLIBDIR)
!MESSAGE fmod library to link with : $(FMODLIBDIR)\fmod_vc.lib
!MESSAGE fmod library dll          : $(FMODLIBDLL)
!MESSAGE ---------------------------------------------------------------------
FMOD_MISSING=
!IF !EXIST("$(FMODROOT)\inc")
FMOD_MISSING= $(FMOD_MISSING) $(FMODROOT)\inc
!MESSAGE Error: missing $(FMODROOT)\inc
!ENDIF
!IF !EXIST("$(FMODLIBDIR)")
FMOD_MISSING= $(FMOD_MISSING) $(FMODLIBDIR)
!MESSAGE Error: missing $(FMODLIBDIR)
!ENDIF
!IF !EXIST("$(FMODLIBDIR)\fmod_vc.lib")
FMOD_MISSING= $(FMOD_MISSING) $(FMODLIBDIR)\fmod_vc.lib
!MESSAGE Error: missing $(FMODLIBDIR)\fmod_vc.lib
!ENDIF
!IF !EXIST("$(FMODLIBDLL)")
FMOD_MISSING= $(FMOD_MISSING) $(FMODLIBDLL)
!MESSAGE Error: missing $(FMODLIBDLL)
!ENDIF
!IF "$(FMOD_MISSING)" != ""
!ERROR Error: Cannot proceed with fmod integration included
!ENDIF
!ENDIF
SNDTEMP=

#===============-=================================================
# SOUND Support
#=================================================================

WAVS = $(SndWavDir)\se_squeak_A.wav $(SndWavDir)\se_squeak_B.wav \
	$(SndWavDir)\se_squeak_B_flat.wav $(SndWavDir)\se_squeak_C.wav \
	$(SndWavDir)\se_squeak_D.wav $(SndWavDir)\se_squeak_D_flat.wav \
	$(SndWavDir)\se_squeak_E.wav $(SndWavDir)\se_squeak_E_flat.wav \
	$(SndWavDir)\se_squeak_F.wav $(SndWavDir)\se_squeak_F_sharp.wav \
	$(SndWavDir)\se_squeak_G.wav $(SndWavDir)\se_squeak_G_sharp.wav \
	$(SndWavDir)\sound_Bell.wav $(SndWavDir)\sound_Bugle_A.wav \
	$(SndWavDir)\sound_Bugle_B.wav $(SndWavDir)\sound_Bugle_C.wav \
	$(SndWavDir)\sound_Bugle_D.wav $(SndWavDir)\sound_Bugle_E.wav \
	$(SndWavDir)\sound_Bugle_F.wav $(SndWavDir)\sound_Bugle_G.wav \
	$(SndWavDir)\sound_Drum_Of_Earthquake.wav \
	$(SndWavDir)\sound_Fire_Horn.wav $(SndWavDir)\sound_Frost_Horn.wav \
	$(SndWavDir)\sound_Leather_Drum.wav $(SndWavDir)\sound_Magic_Harp_A.wav \
	$(SndWavDir)\sound_Magic_Harp_B.wav $(SndWavDir)\sound_Magic_Harp_C.wav \
	$(SndWavDir)\sound_Magic_Harp_D.wav $(SndWavDir)\sound_Magic_Harp_E.wav \
	$(SndWavDir)\sound_Magic_Harp_F.wav $(SndWavDir)\sound_Magic_Harp_G.wav \
	$(SndWavDir)\sound_Magic_Flute_A.wav \
	$(SndWavDir)\sound_Magic_Flute_B.wav $(SndWavDir)\sound_Magic_Flute_C.wav \
	$(SndWavDir)\sound_Magic_Flute_D.wav $(SndWavDir)\sound_Magic_Flute_E.wav \
	$(SndWavDir)\sound_Magic_Flute_F.wav $(SndWavDir)\sound_Magic_Flute_G.wav \
	$(SndWavDir)\sound_Tooled_Horn_A.wav $(SndWavDir)\sound_Tooled_Horn_B.wav \
	$(SndWavDir)\sound_Tooled_Horn_C.wav $(SndWavDir)\sound_Tooled_Horn_D.wav \
	$(SndWavDir)\sound_Tooled_Horn_E.wav $(SndWavDir)\sound_Tooled_Horn_F.wav \
	$(SndWavDir)\sound_Tooled_Horn_G.wav $(SndWavDir)\sound_Wooden_Flute_A.wav \
	$(SndWavDir)\sound_Wooden_Flute_B.wav $(SndWavDir)\sound_Wooden_Flute_C.wav \
	$(SndWavDir)\sound_Wooden_Flute_D.wav $(SndWavDir)\sound_Wooden_Flute_E.wav \
	$(SndWavDir)\sound_Wooden_Flute_F.wav $(SndWavDir)\sound_Wooden_Flute_G.wav \
	$(SndWavDir)\sound_Wooden_Harp_A.wav $(SndWavDir)\sound_Wooden_Harp_B.wav \
	$(SndWavDir)\sound_Wooden_Harp_C.wav $(SndWavDir)\sound_Wooden_Harp_D.wav \
	$(SndWavDir)\sound_Wooden_Harp_E.wav $(SndWavDir)\sound_Wooden_Harp_F.wav \
	$(SndWavDir)\sound_Wooden_Harp_G.wav $(SndWavDir)\sa2_xpleveldown.wav \
	$(SndWavDir)\sa2_xplevelup.wav

!IF "$(HAVE_SOUNDLIB)" == "Y"
!IF "$(NEED_USERSOUNDS)" == "Y"
SOUNDLIBDEFS = $(SOUNDLIBDEFS) -DUSER_SOUNDS
!ENDIF
!IF "$(NEED_SEAUTOMAP)" == "Y"
SOUNDLIBDEFS = $(SOUNDLIBDEFS) -DSND_SOUNDEFFECTS_AUTOMAP
!ENDIF
WAV = $(WAVS)
RCFLAGS = $(RCFLAGS) -dRCWAV
!ENDIF   #HAVE_SOUNDLIB

#==========================================
# Header file macros
#==========================================

CONFIG_H = $(INCL)\config.h $(INCL)\config1.h $(INCL)\patchlevel.h \
		$(INCL)\tradstdc.h $(INCL)\global.h $(INCL)\coord.h \
		$(INCL)\vmsconf.h $(INCL)\cstd.h $(INCL)\nhlua.h \
		$(INCL)\unixconf.h $(INCL)\pcconf.h $(INCL)\micro.h \
		$(INCL)\windconf.h $(INCL)\warnings.h \
		$(INCL)\fnamesiz.h

HACK_H = $(INCL)\hack.h $(CONFIG_H) $(INCL)\lint.h $(INCL)\align.h \
		$(INCL)\dungeon.h $(INCL)\sym.h $(INCL)\defsym.h \
		$(INCL)\mkroom.h $(INCL)\artilist.h \
		$(INCL)\objclass.h $(INCL)\objects.h \
		$(INCL)\youprop.h $(INCL)\prop.h $(INCL)\permonst.h \
		$(INCL)\monattk.h $(INCL)\monflag.h \
		$(INCL)\monsters.h $(INCL)\mondata.h \
		$(INCL)\wintype.h $(INCL)\context.h $(INCL)\rm.h \
		$(INCL)\botl.h $(INCL)\rect.h $(INCL)\region.h \
		$(INCL)\display.h $(INCL)\vision.h $(INCL)\color.h \
		$(INCL)\decl.h $(INCL)\quest.h $(INCL)\spell.h \
		$(INCL)\obj.h $(INCL)\engrave.h $(INCL)\you.h \
		$(INCL)\attrib.h $(INCL)\monst.h $(INCL)\mextra.h \
		$(INCL)\skills.h $(INCL)\timeout.h $(INCL)\trap.h \
		$(INCL)\flag.h $(INCL)\winprocs.h $(INCL)\sndprocs.h \
		$(INCL)\seffects.h $(INCL)\sys.h

TILE_H      = ..\win\share\tile.h

#==========================================
# Miscellaneous
#==========================================

DATABASE = $(DAT)\data.base

#==========================================
#==========================================
# Setting up the compiler and linker
#==========================================
#==========================================

#
# ctags options
#
#CTAGSCMD=ctags-orig.exe
!IF "$(CI_BUILD_DIR)" != ""
CTAGSCMD=$(LIBDIR)\ctags\ctags.exe
!ELSE
CTAGSCMD=..\..\..\ctags\ctags.exe
!ENDIF

CTAGSOPT =--language-force=c --sort=no -D"Bitfield(x,n)=unsigned x : n" --excmd=pattern
#
# ctags wants unix-style pathnames
#
TINC = $(INCL:\=/)
TSRC = $(SRC:\=/)

cc=cl.exe
cpp=cpp.exe
link=link.exe
librarian=lib.exe
rc=Rc.exe

# Before we get started, this section is used to determine the version of
# Visual Studio we are using.  We set VSVER to 0000 to flag any version that
# is too old or untested.
#
# Recently tested versions:
TESTEDVS2017 = 14.16.27051.0
TESTEDVS2019 = 14.29.30152.0
TESTEDVS2022 = 14.37.32824.0
TESTEDVS2022 = 14.37.32825.0

VS2017CUR = $(TESTEDVS2017:.=)
VS2019CUR = $(TESTEDVS2019:.=)
VS2022CUR = $(TESTEDVS2022:.=)
VS2017UP1 = $(VS2017CUR) + 1
VS2019UP1 = $(VS2019CUR) + 1
VS2022UP1 = $(VS2022CUR) + 1
VS20171ST = 1411000000
VS20191ST = $(VS2017UP1)
VS20221ST = $(VS2019UP1)

#!MESSAGE $(MAKEFLAGS)
#!MESSAGE $(MAKEDIR)
#!MESSAGE $(MAKE)

MAKEVERSION=$(_NMAKE_VER:.= )
MAKEVERSION=$(MAKEVERSION: =)
#!MESSAGE $(_NMAKE_VER)
#!MESSAGE $(MAKEVERSION)

VSSPECIAL=
VSNEWEST=2022
!IF ($(MAKEVERSION) < 1000000000)
VSVER=0000		#untested ancient version
!ELSEIF ($(MAKEVERSION) > 1000000000) && ($(MAKEVERSION) < 1100000000)
VSVER=2010
!ELSEIF ($(MAKEVERSION) > 1100000000) && ($(MAKEVERSION) < 1200000000)
VSVER=2012
!ELSEIF ($(MAKEVERSION) > 1200000000) && ($(MAKEVERSION) < 1400000000)
VSVER=2013
!ELSEIF ($(MAKEVERSION) > 1400000000) && ($(MAKEVERSION) < 1411000000)
VSVER=2015
!ELSEIF ($(MAKEVERSION) > $(VS20171ST)) && ($(MAKEVERSION) < $(VS2017UP1))
VSVER=2017
!ELSEIF ($(MAKEVERSION) > $(VS20191ST)) && ($(MAKEVERSION) < $(VS2019UP1))
VSVER=2019
!ELSEIF ($(MAKEVERSION) > $(VS20221ST)) && ($(MAKEVERSION) < $(VS2022UP1))
VSVER=2022
!ELSEIF ($(MAKEVERSION) > $(VS2022CUR))
VSVER=2999              #untested future version
!ENDIF

!IF ($(VSVER) >= 2012)
!IF ($(VSVER) <= $(VSNEWEST))
!MESSAGE Autodetected Visual Studio $(VSVER) $(VSSPECIAL)
!ENDIF
!ENDIF
!IF ($(VSVER) == 2999)
!MESSAGE The NMAKE version of this Visual Studio $(_NMAKE_VER) is newer than the
!MESSAGE most recent at the time this Makefile was crafted (Visual Studio $(VSNEWEST)).
!MESSAGE Because it is newer we'll proceed expecting that the VS$(VSNEWEST) processing
!MESSAGE will still work.
!ELSEIF ($(VSVER) == 0000)
!MESSAGE The version of Visual Studio appears to be quite old, older
!MESSAGE than VS2010 which is the oldest supported version by this
!MESSAGE Makefile, so we'll stop now.
!ERROR Untested old Visual Studio version with NMAKE $(_NMAKE_VER).
!ENDIF

!IF ($(VSVER) == 2010)
# For VS2010 use "setenv /x86" or "setenv /x64" before invoking make process
# DO NOT DELETE THE FOLLOWING LINE
!include <win32.mak>
! ENDIF

!IF ($(VSVER) == 2010)
CL_RECENT=
!ELSE
! IF ($(VSVER) > 2010)
CL_RECENT=-sdl
! ENDIF
!ENDIF

!IF ($(VSVER) >= 2019)
ASAN=/fsanitize=address
!ELSE
ASAN=
!ENDIF

#==========================================
# More compiler setup post-macros
#==========================================
#----------------------------------------------------------------

ccommon= -c -nologo -D"_CRT_NONSTDC_NO_DEPRECATE" -D"_CRT_SECURE_NO_DEPRECATE" \
	-D"_LIB" -D"_SCL_SECURE_NO_DEPRECATE" -D"_VC80_UPGRADE=0x0600" -D"_MBCS" \
	-DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -D"NDEBUG" -D"YY_NO_UNISTD_H" \
	-DHAS_STDINT_H -DHAS_INLINE $(RUNTIMEOPTDEF) \
	-EHsc -fp:precise -Gd -GF -GS -Gy \
	$(CL_RECENT) -WX- -Zc:forScope -Zc:wchar_t -Zi
cdebug= -analyze- -D"_DEBUG" -MTd -RTC1 -Od $(ASAN)
crelease= -analyze- -D"_MBCS" -errorReport:prompt -MT -O2 -Ot -Ox -Oy

lcommon= /NOLOGO /INCREMENTAL:NO

!IF "$(DEBUGINFO)" == "Y"
ldebug = /DEBUG
ctmpflags1=$(ccommon) $(cdebug)
lflags1=$(lcommon) $(ldebug)
!ELSE
ldebug= /DEBUG
ctmpflags1=$(ccommon) $(crelease)
lflags1=$(lcommon) $(ldebug)
!ENDIF

lflags= $(lflags1)

!IF "$(TARGET_CPU)" == "x86"
ctmpflags = $(ctmpflags1) -D_X86_=1  -DWIN32 -D_WIN32 -W3
scall  = -Gz

!ELSEIF "$(TARGET_CPU)" == "x64"
ctmpflags = $(ctmpflags1) -D_AMD64_=1 -DWIN64 -D_WIN64  -DWIN32 -D_WIN32 -W4
scall  =
!ENDIF

!IF ($(VSVER) >= 2012)
#
# 4100 unreferenced formal parameter
# 4131 old-style declarator
# 4244 conversion possible loss of data
# 4245 conversion from 'char' to 'uchar', signed/unsigned mismatch
# 4310 a constant value is cast to a smaller type
# 4706 assignment within conditional
# 4774 format string is not a string literal (default is off at W4)
# 4777 format string requires an argument of type 'type',
#      but variadic argument 'position' has type 'type'
# 4820 padding in struct
ctmpflags = $(ctmpflags:-W3=-W4) -wd4100 -wd4244 -wd4245 -wd4310 -wd4706 -w44777 -wd4820
!IF ($(VSVER) >= 2019)
ctmpflags = $(ctmpflags) -w44774
!ENDIF
!ENDIF

#More verbose warning output options below
#ctmpflags = $(ctmpflags:-W4=-wd4131
#ctmpflags = $(ctmpflags:-W4=-Wall)
#ctmpflags = $(ctmpflags:-W3=-wd4131
#ctmpflags = $(ctmpflags:-W3=-Wall)

cpptmpflags = $(ctmpflags)

# declarations for use on Intel x86 systems
!IF "$(TARGET_CPU)" == "x86"
DLLENTRY = @12
EXEVER=5.01
MACHINE=/MACHINE:X86
!ENDIF

# declarations for use on AMD64 systems
!IF "$(TARGET_CPU)" == "x64"
DLLENTRY =
EXEVER=5.02
MACHINE=/MACHINE:X64
!ENDIF

# for Windows applications
conlflags = $(lflags) -subsystem:console,$(EXEVER)
guilflags = $(lflags) -subsystem:windows,$(EXEVER)

# basic subsystem specific libraries, less the C Run-Time
baselibs    = kernel32.lib $(optlibs) $(winsocklibs) advapi32.lib gdi32.lib \
		ole32.lib Shell32.lib
winlibs     = $(baselibs) user32.lib comdlg32.lib winspool.lib

# for Windows applications that use the C Run-Time libraries
conlibs     = $(baselibs)
guilibs     = $(winlibs)
#

INCLDIR= /I..\include /I..\sys\windows $(LUAINCL) $(SOUNDLIBINCL)

#==========================================
# Util and console builds
#==========================================

CFLAGS   = $(ctmpflags) $(INCLDIR) $(DLBDEF) -DSAFEPROCS $(SOUNDLIBDEFS)
CPPFLAGS = $(cpptmpflags) $(INCLDIR) $(DLBDEF) -DSAFEPROCS $(SOUNDLIBDEFS)
LFLAGS   = $(lflags) $(conlibs) $(MACHINE)

#==========================================
# - Game build
#==========================================

LIBS= user32.lib winmm.lib $(ZLIB)

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

#==========================================
#================ RULES ==================
#==========================================

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

#==========================================
# Rules for files in src
#==========================================

.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

.c{$(OBJGUI)}.o:
	$(Q)$(CC) $(CFLAGS) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

.c{$(OBJUTIL)}.o:
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(SRC)}.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(SRC)}.c{$(OBJGUI)}.o:
	$(Q)$(CC) $(CFLAGS) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(SRC)}.c{$(OBJUTIL)}.o:
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

#==========================================
# Rules for files in sound\windsound
#==========================================

{..\sound\windsound}.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{..\sound\windsound}.c{$(OBJGUI)}.o:
	$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

#==========================================
# Rules for files in sound\sample
#==========================================

{..\sound\sample}.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{..\sound\sample}.c{$(OBJGUI)}.o:
	$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

#==========================================
# Rules for files in sys\share
#==========================================

{$(SSYS)}.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(SSYS)}.c{$(OBJGUI)}.o:
	$(Q)$(CC) $(CFLAGS) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(SSYS)}.c{$(OBJUTIL)}.o:
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(SSYS)}.cpp{$(OBJTTY)}.o:
	$(Q)$(CC) $(CPPFLAGS) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) /EHsc -Fo$@ $<

{$(SSYS)}.cpp{$(OBJGUI)}.o:
	$(Q)$(CC) $(CPPFLAGS) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) /EHsc -Fo$@ $<

{$(SSYS)}.cpp{$(OBJUTIL)}.o:
	$(Q)$(CC) $(CPPFLAGS) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) /EHsc -Fo$@ $<

#==========================================
# Rules for files in sys\windows
#==========================================

{$(MSWSYS)}.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) -Fo$@ $<

{$(MSWSYS)}.c{$(OBJGUI)}.o:
	$(Q)$(CC) $(CFLAGS) -I$(MSWSYS) $(GUIDEF) -Fo$@ $<

{$(MSWSYS)}.uu{$(MSWSYS)}.bmp:
	$(U)uudecode.exe $<
	move $(SRC)\$(@B).bmp $@

#==========================================
# Rules for files in util
#==========================================

{$(UTIL)}.c{$(OBJUTIL)}.o:
	$(Q)$(CC) $(CFLAGS) -Fo$@ $<

#==========================================
# Rules for files in win\share
#==========================================

{$(WSHR)}.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(WSHR)}.c{$(OBJGUI)}.o:
	$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(WSHR)}.c{$(OBJUTIL)}.o:
	$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

#==========================================
# Rules for files in win\tty
#==========================================

{$(TTY)}.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) -I$(MSWSYS) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

#==========================================
# Rules for files in win\win32
#==========================================

{$(MSWIN)}.c{$(OBJGUI)}.o:
	$(Q)$(CC) $(CFLAGS) $(GUIDEF) -I$(MSWSYS) -I$(MSWIN) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(MSWIN)}.uu{$(MSWIN)}.bmp:
	$(U)uudecode.exe $<
	move $(SRC)\$(@B).bmp $@

#==========================================
# Rules for files in win\curses
#==========================================

{$(WCURSES)}.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(PDCINCL) $(CFLAGS) $(CURSESDEF1) $(CURSESDEF2) $(TTYDEF) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

#==========================================
# Rules for files in PDCurses
#==========================================

#
{$(PDCURSES_TOP)}.c{$(OBJPDC)}.o:
	$(Q)$(CC) /wd4244 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(PDCSRC)}.c{$(OBJPDC)}.o:
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS:-w44774= ) $(CURSESDEF2) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(PDCWINCON)}.c{$(OBJPDC)}.o:
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(PDCINCLCON) $(CFLAGS) $(CURSESDEF2) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(PDCWINGUI)}.c{$(OBJPDC)}.o:
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(PDCINCLGUI) $(CFLAGS) $(CURSESDEF2) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

#==========================================
# Rules for LUA files
#==========================================

{$(LUASRC)}.c{$(OBJLUA)}.o:
	$(Q)$(CC) $(CFLAGS) -wd4701 -wd4702 -wd4774 -wd4324 $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

#===============================================================================
# Rules for integrated sound files in sound/wav
#===============================================================================

{$(SndWavDir)}.uu{$(SndWavDir)}.wav:
	$(U)uudecode.exe $(SndWavDir)\$(@B).uu
	move $(SRC)\$(@B).wav $(SndWavDir)\$(@B).wav

#==========================================
# Rules for files in sound\windsound
#==========================================

{$(WINDSOUNDDIR)}.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(WINDSOUNDDIR)}.c{$(OBJGUI)}.o:
	$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

#==========================================
# Rules for files in sound\fmod
#==========================================

{$(FMODDIR)}.c{$(OBJTTY)}.o:
	$(Q)$(CC) $(CFLAGS) $(FMODFLAGS) -I$(WSHR) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

{$(FMODDIR)}.c{$(OBJGUI)}.o:
	$(Q)$(CC) $(CFLAGS) $(FMODFLAGS) -I$(WSHR) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<

#==========================================
#=============== TARGETS ==================
#==========================================

#
#  The game target.
#
#
#  Everything
#

all :	install

install:  envchk.tag libdir.tag ottydir$(TARGET_CPU).tag \
		outldir$(TARGET_CPU).tag oguidir$(TARGET_CPU).tag \
		oluadir$(TARGET_CPU).tag opdcdir$(TARGET_CPU).tag \
		$(LUASRC)\lua.h $(PDCDEP) \
		$(INCL)\nhlua.h $(OUTL)utility.tag \
		$(DAT)\data $(DAT)\rumors $(DAT)\oracles $(DAT)\engrave \
		$(DAT)\epitaph $(DAT)\bogusmon $(GAMEDIR)\NetHack.exe \
		$(GAMEDIR)\NetHackW.exe $(GAMEDIRDLLS) install.tag
	@echo Done.

!IF "$(INTERNET_AVAILABLE)" == "Y"
!IF "$(GIT_AVAILABLE)" == "Y"
$(LUASRC)\lua.h:
	git submodule init ../submodules/lua
	git submodule update ../submodules/lua
#	git submodule update --remote ../submodules/lua
#
#aka PDCDEP
$(PDCURSES_TOP)\curses.h:
	git submodule init ../submodules/$(PDCDIST)
	git submodule update ../submodules/$(PDCDIST)
#	git submodule update --remote ../submodules/$(PDCDIST)

!ELSE  # GIT_AVAILABLE no
CURLLUASRC=http://www.lua.org/ftp/lua-5.4.6.tar.gz
CURLLUADST=lua-5.4.6.tar.gz

#CURLPDCSRC=https://github.com/wmcbrine/PDCurses/archive/refs/tags/3.9.zip
CURLPDCSRC=https://github.com/Bill-Gray/PDCursesMod/archive/refs/tags/v4.3.5.zip
CURLPDCDST=pdcurses.zip

$(LUASRC)\lua.h:
	cd $(LIBDIR)
	curl -L $(CURLLUASRC) -o $(CURLLUADST)
	tar -xvf $(CURLLUADST)
	cd ..\src
$(PDCURSES_TOP)\curses.h:
	cd $(LIBDIR)
	curl -L $(CURLPDCSRC) -o $(CURLPDCDST)
	if not exist $(PDCDIST)\*.* mkdir $(PDCDIST)
	tar -C $(PDCDIST) --strip-components=1 -xvf $(CURLPDCDST)
	cd ..\src
!ENDIF  # GIT_AVAILABLE
!ELSE   # INTERNET_AVAILABLE
$(LUASRC)\lua.h:
$(PDCURSES_TOP)\curses.h:
!ENDIF  # INTERNET_AVAILABLE

#==========================================
#  Main game targets.
#==========================================

#  The section for linking the NetHack image looks a little strange at
#  first, especially if you are used to UNIX makes, or NDMAKE.  It is
#  Microsoft nmake specific, and it gets around the problem of the
#  link command line being too long for the linker.  An "in-line" linker
#  response file is generated temporarily.
#
#  It takes advantage of the following features of nmake:
#
#  Inline files :
#			Specifying the "<<" means to start an inline file.
#                 	Another "<<" at the start of a line closes the
#                 	inline file.
#
#  Substitution within Macros:
#                       $(mymacro:string1=string2) replaces every
#                       occurrence of string1 with string2 in the
#                       macro mymacro.  Special ascii key codes may be
#                       used in the substitution text by preceding it
#                       with ^ as we have done below.  Every occurence
#                       of a <tab> in $(ALLOBJ) is replaced by
#                       <+><return><tab>.

GAMEOBJ=$(ALLOBJ:^	=^
)
GAMEOBJ=$(GAMEOBJ:^ =^
)

#
#  DO NOT INDENT THE << below!
#

#--------
# NetHack
#--------
#

$(GAMEDIR)\NetHack.exe : gamedir.tag $(OTTY)consoletty.o \
			$(ALLOBJTTY) $(CURSESWINCONOBJS) \
			$(TTYSOUNDOBJS) $(OTTY)date.o $(OTTY)console.res \
			$(LUALIB) $(TTYOBJ) $(PDCWINCONLIB) $(PDCWINCONOBJS)
	@if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
	@echo Linking $(@:\=/)
	$(link) $(LFLAGS) $(conlflags) /STACK:2048 /PDB:$(GAMEDIR)\$(@B).PDB /MAP:$(OTTY)$(@B).MAP \
		$(LIBS) $(PDCWINCONLIB) $(LUALIB) $(TTYSOUNDLIBS) \
		$(conlibs) $(BCRYPT) -out:$@ @<<$(@B).lnk
		$(GAMEOBJTTY)
		$(ALLOBJTTY)
		$(TTYOBJ)
		$(TTYSOUNDOBJS) $(CURSESWINCONOBJS) $(PDCWINCONOBJS)
		$(OTTY)consoletty.o
		$(OTTY)date.o
		$(OTTY)console.res
<< keep
	@if exist install.tag del install.tag

#---------
# NetHackW
#---------
#
$(GAMEDIR)\NetHackW.exe : gamedir.tag $(OGUI)tile.o \
			$(ALLOBJGUI) $(GAMEOBJGUI) $(GUIOBJ) $(GUISOUNDOBJS) \
			$(CURSESWINGUIOBJS) $(OGUI)date.o \
			$(OGUI)NetHackW.res \
			$(LUALIB) $(PDCWINGUILIB) $(PDCWINGUIOBJS)
	@if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
	@echo   Linking $(@:\=/)
	$(link) $(LFLAGS) $(guilflags) /STACK:2048 /PDB:$(GAMEDIR)\$(@B).PDB \
		/MAP:$(OGUI)$(@B).MAP $(LIBS) $(PDCWINGUILIB) $(LUALIB) \
		$(GUISOUNDLIBS) \
		$(guilibs) $(COMCTRL) $(BCRYPT) -out:$@ @<<$(@B).lnk
		$(GAMEOBJGUI)
		$(ALLOBJGUI)
		$(GUIOBJ)
		$(GUISOUNDOBJS) $(CURSESWINGUIOBJS) $(PDCWINGUIOBJS)
		$(OGUI)tile.o
		$(OGUI)date.o
		$(OGUI)NetHackW.res
<< keep

#--------
# install
#--------
#
install.tag: 	$(DAT)\data $(DAT)\rumors $(DAT)\oracles $(DLB) \
		$(HACKCSRC) $(SOUNDSRCS)
! IF ("$(USE_DLB)"=="Y")
	copy nhdat$(NHV)          $(GAMEDIR)
	copy $(DAT)\license       $(GAMEDIR)
	copy $(DAT)\opthelp       $(GAMEDIR)
! ELSE
	copy $(DAT)\bogusmon $(GAMEDIR)
	copy $(DAT)\cmdhelp $(GAMEDIR)
	copy $(DAT)\data $(GAMEDIR)
	copy $(DAT)\dungeon $(GAMEDIR)
	copy $(DAT)\engrave $(GAMEDIR)
	copy $(DAT)\epitaph $(GAMEDIR)
	copy $(DAT)\help $(GAMEDIR)
	copy $(DAT)\hh $(GAMDEDIR)
	copy $(DAT)\history $(GAMEDIR)
	copy $(DAT)\license $(GAMEDIR)
	copy $(DAT)\optmenu $(GAMEDIR)
	copy $(DAT)\oracles $(GAMEDIR)
	copy $(DAT)\rumors $(GAMEDIR)
	copy $(DAT)\symbols $(GAMEDIR)
	copy $(DAT)\tribute $(GAMEDIR)
	copy $(DAT)\wizhelp $(GAMEDIR)
	copy $(DAT)\*.lua $(GAMEDIR)
	if exist $(DAT)\guioptions copy $(DAT)\guioptions $(GAMEDIR)
	if exist $(DAT)\keyhelp copy $(DAT)\keyhelp $(GAMEDIR)
	if exist $(DAT)\opthelp copy $(DAT)\opthelp $(GAMEDIR)
	if exist $(DAT)\options copy $(DAT)\options $(GAMEDIR)
	if exist $(DAT)\porthelp copy $(DAT)\porthelp $(GAMEDIR)
	if exist $(DAT)\ttyoptions copy $(DAT)\ttyoptions $(GAMEDIR)
! ENDIF
	if exist $(MSWSYS)\sysconf.template copy $(MSWSYS)\sysconf.template $(GAMEDIR)
	if exist $(DAT)\symbols copy $(DAT)\symbols $(GAMEDIR)\symbols
	if exist $(DOC)\guidebook.txt copy $(DOC)\guidebook.txt $(GAMEDIR)\Guidebook.txt
	if exist $(DOC)\nethack.txt copy $(DOC)\nethack.txt $(GAMEDIR)\NetHack.txt
	@if exist $(GAMEDIR)\NetHack.PDB echo NOTE: You may want to remove $(GAMEDIR:\=/)/NetHack.PDB to conserve space
	@if exist $(GAMEDIR)\NetHackW.PDB echo NOTE: You may want to remove $(GAMEDIR:\=/)/NetHackW.PDB to conserve space
	-if exist $(MSWSYS)\.nethackrc.template copy $(MSWSYS)\.nethackrc.template   $(GAMEDIR)
	-if not exist $(GAMEDIR)\record. goto>$(GAMEDIR)\record.
	echo install done > $@

#	copy $(MSWSYS)\windsyshlp    $(GAMEDIR)

recover: $(U)recover.exe
	if exist $(U)recover.exe copy $(U)recover.exe  $(GAMEDIR)
	if exist $(DOC)\recover.txt copy $(DOC)\recover.txt $(GAMEDIR)\recover.txt

$(OUTL)utility.tag: $(INCL)\nhlua.h outldir$(TARGET_CPU).tag $(U)tile2bmp.exe $(U)makedefs.exe
	     @echo utilities made >$@
	     @echo utilities made.

$(INCL)\nhlua.h:
	@echo  /* nhlua.h - generated by Makefile from Makefile.nmake */ > $@
	@echo #include "lua.h" >> $@
	@echo LUA_API int   (lua_error) (lua_State *L) NORETURN; >> $@
	@echo #include "lualib.h" >> $@
	@echo #include "lauxlib.h" >> $@
	@echo /*nhlua.h*/ >> $@

tileutil: $(U)gif2txt.exe $(U)gif2tx32.exe $(U)txt2ppm.exe
	@echo Optional tile development utilities are up to date.

$(OGUI)NetHackW.res: $(SRC)\tiles.bmp $(MSWIN)\NetHackW.rc $(MSWIN)\NetHack.ico \
	$(MSWIN)\mnsel.bmp $(MSWIN)\mnselcnt.bmp $(MSWIN)\mnunsel.bmp \
	$(MSWIN)\petmark.bmp $(MSWIN)\pilemark.bmp $(MSWIN)\NetHack.ico \
	$(MSWIN)\rip.bmp $(MSWIN)\splash.bmp $(WAV)
	@echo Building resource file $@ from $**
	$(rc) -nologo -r -fo$@ -i$(MSWIN) -i$(SndWavDir) -dNDEBUG $(RCFLAGS) $(MSWIN)\NetHackW.rc

$(OTTY)console.res: $(MSWSYS)\console.rc $(MSWSYS)\NetHack.ico $(WAV)
	@echo Building resource file $@ from $**
	$(rc) -nologo -r -fo$@ -i$(MSWSYS) -i$(SndWavDir) -dNDEBUG $(RCFLAGS) $(MSWSYS)\console.rc

#
#  Secondary Targets.
#

#==========================================
# Makedefs Stuff
#==========================================
$(U)nhsizes3.exe: $(OUTL)nhsizes3.o
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) -out:$@ $(OUTL)nhsizes.o $(OUTL)panic$(HOST).o $(OUTL)alloc$(HOST).o

$(OUTL)nhsizes3.o: $(CONFIG_H) nhsizes3.c
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) -Fo$@ nhsizes3.c

$(U)makedefs.exe:	$(MAKEDEFSOBJS)
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ $(MAKEDEFSOBJS)

$(OUTL)makedefs.o: $(U)makedefs.c $(SRC)\mdlib.c $(CONFIG_H) $(INCL)\permonst.h \
		$(INCL)\objclass.h $(INCL)\sym.h $(INCL)\defsym.h \
		$(INCL)\artilist.h $(INCL)\dungeon.h $(INCL)\obj.h \
		$(INCL)\monst.h $(INCL)\you.h $(INCL)\flag.h \
		$(INCL)\dlb.h
	@if not exist $(OBJTTY)\*.* echo creating directory $(OBJTTY:\=/)
	@if not exist $(OBJTTY)\*.* mkdir $(OBJTTY)
	$(Q)$(CC) -DENUM_PM $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) -Fo$@ $(U)makedefs.c
#	$(Q)$(CC) -DENUM_PM $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) /EP -Fo$@ $(U)makedefs.c >$(OUTL)makedefs.c.preproc

#
# This is awful, but it allows the GITHASH and GITBRANCH macros to be
# defined and utilized, using only build-in Windows and nmake commands,
# as well as the necessary git commands.
#
# We build a temporary Makefile on-the-fly for compiling date.c and
# invoke nmake again.
#
$(OTTY)date.o: $(HACKINCL) $(HACKSRC) $(HACKOBJ) $(ALLOBJTTY) $(CURSESOBJ)
!IF "$(GIT_AVAILABLE)" == "1"
	@git rev-parse --verify HEAD 2>&1 >$(OTTY)date1.tmp
	@git rev-parse --abbrev-ref HEAD 2>&1 >$(OTTY)date2.tmp
	@echo.>date.nmk
	@echo OBJ = $(OBJTTY)>>date.nmk
	@echo O = ^$(OBJTTY)^^^\>>date.nmk
	@echo cc = $(cc)>>date.nmk
	@echo CFLAGS = $(CFLAGS) ^\>>date.nmk
	@for /F "usebackq" %%A IN ("$(OTTY)date1.tmp") DO @echo.	-DNETHACK_GIT_SHA=\"%%A\" ^\>>date.nmk
	@for /F "usebackq" %%A IN ("$(OTTY)date2.tmp") DO @echo.	-DNETHACK_GIT_BRANCH=\"%%A\">>date.nmk
	@echo.>>date.nmk
	@echo default: ^$(OTTY)date.o>>date.nmk
	@echo.>>date.nmk
	@echo ^$(OTTY)date.o: >>date.nmk
	@echo. 	^$(cc) ^$(CFLAGS) -Fo^$@ date.c>>date.nmk
	@echo.>>date.nmk
	@$(MAKE) /NOLOGO /A -f date.nmk
!ENDIF

$(OGUI)date.o: $(HACKINCL) $(HACKSRC) $(HACKOBJ) $(ALLOBJGUI)
!IF "$(GIT_AVAILABLE)" == "1"
	@git rev-parse --verify HEAD 2>&1 >$(OGUI)date1.tmp
	@git rev-parse --abbrev-ref HEAD 2>&1 >$(OGUI)date2.tmp
	@echo.>date.nmk
	@echo OBJ = $(OBJGUI)>>date.nmk
	@echo O = ^$(OBJGUI)^^^\>>date.nmk
	@echo cc = $(cc)>>date.nmk
	@echo CFLAGS = $(CFLAGS) ^\>>date.nmk
	@for /F "usebackq" %%A IN ("$(OGUI)date1.tmp") DO @echo.	-DNETHACK_GIT_SHA=\"%%A\" ^\>>date.nmk
	@for /F "usebackq" %%A IN ("$(OGUI)date2.tmp") DO @echo.	-DNETHACK_GIT_BRANCH=\"%%A\">>date.nmk
	@echo.>>date.nmk
	@echo default: ^$(OGUI)date.o>>date.nmk
	@echo.>>date.nmk
	@echo ^$(OGUI)date.o: >>date.nmk
	@echo. 	^$(cc) ^$(CFLAGS) -Fo^$@ date.c>>date.nmk
	@echo.>>date.nmk
	@$(MAKE) /NOLOGO /A -f date.nmk
!ENDIF

#
#  date.h is not used with NetHack 3.7
#  onames.h is not used with NetHack 3.7
#  pm.h is not used with NetHack 3.7

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

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

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

#==========================================
# uudecode utility and uuencoded targets
#==========================================

$(U)uudecode.exe: $(OUTL)uudecode.o
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ $(OUTL)uudecode.o

$(OUTL)uudecode.o: $(SSYS)\uudecode.c
	$(Q)$(CC) $(CFLAGS) -wd4702 $(TTYDEF) $(CROSSCOMPILE) /D_CRT_SECURE_NO_DEPRECATE  -Fo$@ $(SSYS)\uudecode.c

$(MSWIN)\mnsel.bmp: $(U)uudecode.exe $(MSWIN)\mnsel.uu
$(MSWIN)\mnselcnt.bmp: $(U)uudecode.exe $(MSWIN)\mnselcnt.uu
$(MSWIN)\mnunsel.bmp: $(U)uudecode.exe $(MSWIN)\mnunsel.uu
$(MSWIN)\petmark.bmp: $(U)uudecode.exe $(MSWIN)\petmark.uu
$(MSWIN)\pilemark.bmp: $(U)uudecode.exe $(MSWIN)\pilemark.uu
$(MSWIN)\rip.bmp: $(U)uudecode.exe $(MSWIN)\rip.uu
$(MSWIN)\splash.bmp: $(U)uudecode.exe $(MSWIN)\splash.uu

$(MSWIN)\NetHack.ico: $(U)uudecode.exe $(MSWSYS)\nhico.uu
	$(U)uudecode.exe $(MSWSYS)\nhico.uu
	move nethack.ico $@

$(MSWSYS)\NetHack.ico: $(U)uudecode.exe $(MSWSYS)\nhico.uu
	$(U)uudecode.exe $(MSWSYS)\nhico.uu
	move nethack.ico $@

#=================================================
# Create directories for holding output files
#=================================================

gamedir.tag:
	@if not exist $(GAMEDIR)\*.* echo creating directory $(GAMEDIR:\=/)
	@if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
	@echo directory created > $@

ottydir$(TARGET_CPU).tag:
	@if not exist $(OBJTTY)\*.* echo creating directory $(OBJTTY:\=/)
	@if not exist $(OBJTTY)\*.* mkdir $(OBJTTY)
	@echo directory created >$@

oguidir$(TARGET_CPU).tag:
	@if not exist $(OBJGUI)\*.* echo creating directory $(OBJGUI:\=/)
	@if not exist $(OBJGUI)\*.* mkdir $(OBJGUI)
	@echo directory created >$@

outldir$(TARGET_CPU).tag:
	@if not exist $(OBJUTIL)\*.* echo creating directory $(OBJUTIL:\=/)
	@if not exist $(OBJUTIL)\*.* mkdir $(OBJUTIL)
	@echo directory created >$@

oluadir$(TARGET_CPU).tag:
	@if not exist $(OBJLUA)\*.* echo creating directory $(OBJLUA:\=/)
	@if not exist $(OBJLUA)\*.* mkdir $(OBJLUA)
	@echo directory created >$@

opdcdir$(TARGET_CPU).tag:
	@if not exist $(OBJPDC)\*.* echo creating directory $(OBJPDC:\=/)
	@if not exist $(OBJPDC)\*.* mkdir $(OBJPDC)
	@echo directory created >$@

libdir.tag:
	@if not exist $(LIBDIR)\*.* echo creating directory $(LIB:\=/)
	@if not exist $(LIBDIR)\*.* mkdir $(LIBDIR)
	@echo directory created >$@

#==========================================
# Notify of any CL environment variables
# in effect since they change the compiler
# options.
#==========================================

envchk.tag: cpu.tag
!IFDEF TTYOBJ
	@echo tty window support included
! IF "$(ADD_CURSES)"=="Y"
	@echo curses window support also included
! ENDIF
!ENDIF
!	IF "$(CL)"!=""
#	   @echo Warning, the CL Environment variable is defined:
#	   @echo CL=$(CL)
!	ENDIF
	@echo "cflags=$(CFLAGS) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET)"
	@echo envchk >$@

cpu.tag:
!	IF "$(TARGET_CPU)"=="x64"
	@echo Windows x64 64-bit target build
!	ELSE
	@echo Windows x86 32-bit target build
!	ENDIF
	@echo cpu >$@

#==========================================
#=========== SECONDARY TARGETS ============
#==========================================
fetch-lua: fetch-actual-Lua

fetch-Lua: fetch-actual-Lua

fetch-actual-Lua:
	@if not exist $(LIBDIR)\*.* mkdir $(LIBDIR)
	cd $(LIBDIR)
	curl -R -O http://www.lua.org/ftp/lua-$(LUAVER).tar.gz
	tar zxf lua-$(LUAVER).tar.gz
	if exist lua-$(LUAVER).tar.gz del lua-$(LUAVER).tar.gz
	if exist lua-$(LUAVER).tar del lua-$(LUAVER).tar
	cd ..\src
	@echo Lua has been fetched into $(LIBDIR)\lua-$(LUAVER)

fetch-pdcurses:
	@if not exist $(LIBDIR)\*.* mkdir $(LIBDIR)
	cd $(LIBDIR)
#	curl -L -R https://codeload.github.com/wmcbrine/PDCurses/zip/master -o pdcurses.zip
	curl -L -R https://github.com/Bill-Gray/PDCursesMod/archive/refs/tags/v4.3.5.zip -o $(PDCDIST).zip
	powershell -command "Expand-Archive -Path .\$(PDCDIST).zip -DestinationPath ./$(PDCDIST)-temp"
	if exist .\$(PDCDIST)\* rd .\$(PDCDIST) /s /Q
	move .\$(PDCDIST)-temp\PDCurses-master .
	ren PDCurses-master $(PDCDIST)
	if exist .\$(PDCDIST)-temp\* rd .\$(PDCDIST)-temp /s /Q
	if exist .\$(PDCDIST).zip del .\$(PDCDIST).zip
	cd ..\src
	@echo $(PDCDIST) has been fetched into $(LIBDIR)\$(PDCDIST)

#==========================================
# DLB utility and nhdatNNN file creation
#==========================================

$(U)dlb.exe: $(DLBOBJ_HOST) $(OUTL)dlb$(HOST).o
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ @<<$(@B).lnk
		$(OUTL)dlb_main$(HOST).o
		$(OUTL)dlb$(HOST).o
		$(OUTL)alloc$(HOST).o
		$(OUTL)panic$(HOST).o
<<

!IFDEF TEST_CROSSCOMPILE
$(OUTL)dlb$(HOST).o: $(OUTL)dlb_main$(HOST).o $(OUTL)alloc$(HOST).o $(OUTL)panic$(HOST).o $(INCL)\dlb.h
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) /Fo$@ $(SRC)\dlb.c
!ENDIF

$(OUTL)dlb.o: $(OUTL)dlb_main.o $(OUTL)alloc.o $(OUTL)panic.o $(INCL)\dlb.h
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) /Fo$@ $(SRC)\dlb.c

$(OTTY)dlb.o: $(OTTY)dlb_main.o $(OTTY)alloc.o $(OTTY)panic.o $(INCL)\dlb.h
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) /Fo$@ $(SRC)\dlb.c

$(OGUI)dlb.o: $(OGUI)dlb_main.o $(OGUI)alloc.o $(OGUI)panic.o $(INCL)\dlb.h
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) /Fo$@ $(SRC)\dlb.c

$(OUTL)dlb_main.o: $(UTIL)\dlb_main.c $(INCL)\config.h $(INCL)\dlb.h
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) /Fo$@ $(UTIL)\dlb_main.c

$(OTTY)dlb_main.o: $(UTIL)\dlb_main.c $(INCL)\config.h $(INCL)\dlb.h
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) /Fo$@ $(UTIL)\dlb_main.c

$(OGUI)dlb_main.o: $(UTIL)\dlb_main.c $(INCL)\config.h $(INCL)\dlb.h
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) /Fo$@ $(UTIL)\dlb_main.c

$(DAT)\porthelp: $(MSWSYS)\porthelp
	@copy $(MSWSYS)\porthelp $@ >nul

nhdat$(NHV):	$(U)dlb.exe $(DAT)\data $(DAT)\oracles $(OPTIONS_FILE) $(LUA_FILES) \
	$(DAT)\rumors $(DAT)\help $(DAT)\hh $(DAT)\cmdhelp $(DAT)\keyhelp \
	$(DAT)\history $(DAT)\opthelp $(DAT)\optmenu $(DAT)\wizhelp $(DAT)\porthelp \
	$(DAT)\license $(DAT)\engrave $(DAT)\epitaph $(DAT)\bogusmon $(DAT)\tribute
	@echo Building $@
	@cd $(DAT)
	@echo data >dlb.lst
	@echo oracles >>dlb.lst
	@if exist options @echo options >>dlb.lst
	@if exist ttyoptions @echo ttyoptions >>dlb.lst
	@if exist guioptions @echo guioptions >>dlb.lst
	@if exist porthelp @echo porthelp >>dlb.lst
	@echo rumors >>dlb.lst
	@echo help >>dlb.lst
	@echo hh >>dlb.lst
	@echo cmdhelp >>dlb.lst
	@echo keyhelp >>dlb.lst
	@echo history >>dlb.lst
	@echo opthelp >>dlb.lst
	@echo optmenu >>dlb.lst
	@echo wizhelp >>dlb.lst
	@echo license >>dlb.lst
	@echo engrave >>dlb.lst
	@echo epitaph >>dlb.lst
	@echo bogusmon >>dlb.lst
	@echo tribute >>dlb.lst
	@for %%N in (*.lua) do @echo %%N >>dlb.lst
	@$(U)dlb cIf dlb.lst $(SRC)\nhdat
	@cd $(SRC)

#==========================================
#  Recover Utility
#==========================================

$(U)recover.exe: $(RECOVOBJS)
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ $(RECOVOBJS)

$(OUTL)recover.o: $(CONFIG_H) $(U)recover.c $(MSWSYS)\win32api.h
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) -Fo$@ $(U)recover.c

#==========================================
#  Tile Mapping
#==========================================

tile.c: $(U)tilemap.exe
	@$(U)tilemap
	@echo A new $(@:\=/) has been created

$(U)tilemap.exe: $(OUTL)tilemap.o $(OUTL)monst.o $(OUTL)objects.o $(OUTL)drawing.o
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ \
		$(OUTL)tilemap.o $(OUTL)monst.o $(OUTL)objects.o $(OUTL)drawing.o

$(OUTL)tilemap.o: $(WSHR)\tilemap.c $(HACK_H)
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) -Fo$@ $(WSHR)\tilemap.c

$(OUTL)tiletx32.o: $(WSHR)\tilemap.c $(HACK_H)
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) /DTILETEXT /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tilemap.c

$(OUTL)tiletxt.o: $(WSHR)\tilemap.c $(HACK_H)
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) /DTILETEXT -Fo$@ $(WSHR)\tilemap.c

$(OUTL)gifread.o: $(WSHR)\gifread.c  $(CONFIG_H) $(TILE_H)
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) -I$(WSHR) -Fo$@ $(WSHR)\gifread.c

$(OUTL)gifrd32.o: $(WSHR)\gifread.c  $(CONFIG_H) $(TILE_H)
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\gifread.c

$(OUTL)ppmwrite.o: $(WSHR)\ppmwrite.c $(CONFIG_H) $(TILE_H)
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) -I$(WSHR) -Fo$@ $(WSHR)\ppmwrite.c

$(OUTL)tiletext.o: $(WSHR)\tiletext.c  $(CONFIG_H) $(TILE_H)
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) -I$(WSHR) -Fo$@ $(WSHR)\tiletext.c

$(OUTL)tilete32.o: $(WSHR)\tiletext.c  $(CONFIG_H) $(TILE_H)
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tiletext.c

#==========================================
# Optional Tile Utilities
#==========================================

$(U)gif2txt.exe: $(GIFREADERS_HOST) $(TEXT_IO)
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ @<<$(@B).lnk
		$(GIFREADERS_HOST:^	=^
		)
		$(TEXT_IO:^	=^
		)
<<

$(U)gif2tx32.exe: $(GIFREADERS32_HOST) $(TEXT_IO32)
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ @<<$(@B).lnk
		$(GIFREADERS32_HOST:^	=^
		)
		$(TEXT_IO32:^	=^
		)
<<

$(U)txt2ppm.exe: $(PPMWRITERS) $(TEXT_IO)
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ @<<$(@B).lnk
		$(PPMWRITERS:^	=^
		)
		$(TEXT_IO:^	=^
		)
<<

$(SRC)\tiles.bmp: $(U)tile2bmp.exe $(TILEFILES)
	@echo Creating 16x16 binary tile files (this may take some time)
	@$(U)tile2bmp $@

$(U)tile2bmp.exe: $(OUTL)tile2bmp.o $(TEXT_IO)
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ @<<$(@B).lnk
		$(OUTL)tile2bmp.o
		$(TEXT_IO:^  =^
		)
<<

$(U)til2bm32.exe: $(OUTL)til2bm32.o $(TEXT_IO32)
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ @<<$(@B).lnk
		$(OUTL)til2bm32.o
		$(TEXT_IO32:^  =^
		)
<<

$(OUTL)tile2bmp.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(MSWSYS)\win32api.h
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) -I$(WSHR) /DPACKED_FILE /Fo$@ $(WSHR)\tile2bmp.c

#$(OUTL)til2bm32.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(MSWSYS)\win32api.h
#	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) -I$(WSHR) /DPACKED_FILE /DTILE_X=32 /DTILE_Y=32 /Fo$@ $(WSHR)\tile2bmp.c

$(U)tile2x11.exe: $(OUTL)tile2x11.o $(OUTL)tiletext.o $(OUTL)tiletxt.o $(OUTL)alloc.o \
		$(OUTL)panic.o $(OUTL)monst.o $(OUTL)objects.o
	@echo Linking $(@:\=/)
	@$(link) $(LFLAGS) /PDB:"$(OUTL)$(@B).PDB" /MAP:"$(OUTL)$(@B).MAP" -out:$@ @<<$(@B).lnk
		$(OUTL)tile2x11.o
		$(OUTL)tiletext.o
		$(OUTL)tiletxt.o
		$(OUTL)drawing.o
		$(OUTL)monst.o
		$(OUTL)objects.o
		$(OUTL)alloc.o
		$(OUTL)panic.o
<<

$(OUTL)tile2x11.o: $(X11)\tile2x11.c $(HACK_H) $(TILE_H) $(INCL)\tile2x11.h
	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) -I$(WSHR) /DPACKED_FILE /Fo$@ $(X11)\tile2x11.c

$(SRC)\x11tiles: $(U)tile2x11.exe $(WSHR)\monsters.txt $(WSHR)\objects.txt \
				$(WSHR)\other.txt \
				$(WSHR)\monsters.txt
	$(U)tile2x11 $(WSHR)\monsters.txt $(WSHR)\objects.txt \
				$(WSHR)\other.txt \
				-grayscale $(WSHR)\monsters.txt

#===============================================================================
# PDCurses
#===============================================================================

$(LIBDIR)\$(PDCDIST)-$(TARGET_CPU).lib : $(PDCCOMMONOBJS)
	@echo Building library $@ from $**
	@$(librarian) -nologo /out:$@ $(PDCCOMMONOBJS)

$(OPDC)pdcclip_wincon.o: $(PDCWINCON)\pdcclip.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINCON)\pdcclip.c
$(OPDC)pdcdisp_wincon.o: $(PDCWINCON)\pdcdisp.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINCON)\pdcdisp.c
$(OPDC)pdcgetsc_wincon.o: $(PDCWINCON)\pdcgetsc.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINCON)\pdcgetsc.c
$(OPDC)pdckbd_wincon.o: $(PDCWINCON)\pdckbd.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINCON)\pdckbd.c
$(OPDC)pdcscrn_wincon.o: $(PDCWINCON)\pdcscrn.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINCON)\pdcscrn.c
$(OPDC)pdcsetsc_wincon.o: $(PDCWINCON)\pdcsetsc.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINCON)\pdcsetsc.c
$(OPDC)pdcutil_wincon.o: $(PDCWINCON)\pdcutil.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINCON)\pdcutil.c

$(OPDC)pdcclip_wingui.o: $(PDCWINGUI)\pdcclip.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINGUI)\pdcclip.c
$(OPDC)pdcdisp_wingui.o: $(PDCWINGUI)\pdcdisp.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINGUI)\pdcdisp.c
$(OPDC)pdcgetsc_wingui.o: $(PDCWINGUI)\pdcgetsc.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINGUI)\pdcgetsc.c
$(OPDC)pdckbd_wingui.o: $(PDCWINGUI)\pdckbd.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINGUI)\pdckbd.c
$(OPDC)pdcscrn_wingui.o: $(PDCWINGUI)\pdcscrn.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINGUI)\pdcscrn.c
$(OPDC)pdcsetsc_wingui.o: $(PDCWINGUI)\pdcsetsc.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINGUI)\pdcsetsc.c
$(OPDC)pdcutil_wingui.o: $(PDCWINGUI)\pdcutil.c
	$(Q)$(CC) /wd4244 /wd4267 /wd4774 $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -Fo$@ $(PDCWINGUI)\pdcutil.c

$(OGUI)guitty.o: $(MSWSYS)\guitty.c $(WINDHDR) $(HACK_H) $(TILE_H)

#$(OPDC)pdcscrn.o : $(PDCURSES_HEADERS) $(PDCWINCON)\pdcscrn.c
#	$(Q)$(CC) $(PDCINCL) $(CFLAGS) $(CURSESDEF2) -wd4996 $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) \
#		-Fo$@ $(PDCWINCON)\pdcscrn.c

#===============================================================================
# LUA
#===============================================================================

lua.exe: $(OLUA)lua.o $(LUALIB)
	@echo Linking $(@:\=/)
	@$(link) /OUT:$@ $(OLUA)lua.o $(LUALIB)

#luac.exe: $(OLUA)luac.o $(LUALIB)
#	@echo Linking $(@:\=/)
#	@$(link) /OUT:$@ $(OLUA)luac.o $(LUALIB)

$(LIBDIR)\lua$(LUAVER)-$(TARGET_CPU).dll: $(LUAOBJFILES)
	@echo Linking $(@:\=/)
	@$(link) /DLL /IMPLIB:$(LIBDIR)\lua$(LUAVER).lib /OUT:$@ $(LUAOBJFILES)

$(LIBDIR)\lua$(LUAVER)-$(TARGET_CPU)-static.lib: $(LUAOBJFILES)
	@echo Building library $@ from $**
	@$(librarian) /OUT:$@ $(LUAOBJFILES)

$(OLUA)lua.o: $(LUASRC)\lua.c
#$(OLUA)luac.o: $(LUASRC)\luac.c
$(OLUA)lapi.o: $(LUASRC)\lapi.c
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -wd4244 -wd4701 -wd4702 -Fo$@ $(LUASRC)\lapi.c

#===================================================================
# windsound dependencies
#===================================================================
!IF "$(SOUND_WINDSOUND)" == "Y"
$(OTTY)windsound.o: ..\sound\windsound\windsound.c $(HACK_H)
$(OGUI)windsound.o: ..\sound\windsound\windsound.c $(HACK_H)
!ENDIF
#===================================================================
# fmod dependencies
#===================================================================
!IF "$(SOUND_FMOD)" == "Y"
$(OTTY)fmod.o: $(FMODDIR)\fmod.c $(HACK_H)
$(OGUI)fmod.o: $(FMODDIR)\fmod.c $(HACK_H)

# Copy the DLL to GAMEDIR
$(GAMEDIR)\$(FMODDLLBASENAME):
	copy $(FMODLIBDLL) $@
!ENDIF
#===================================================================
# sys/windows dependencies
#===================================================================

$(OTTY)consoletty.o:   $(MSWSYS)\consoletty.c $(WINDHDR) $(HACK_H) $(TILE_H)
$(OTTY)win10.o:  $(MSWSYS)\win10.c $(WINDHDR) $(HACK_H)
$(OTTY)windsys.o:  $(MSWSYS)\windsys.c $(WINDHDR) $(HACK_H)
$(OTTY)windsound.o: ..\sound\windsound\windsound.c $(HACK_H)
#$(OTTY)sample.o: ..\sound\sample\sample.c $(HACK_H)
$(OTTY)windmain.o: $(MSWSYS)\windmain.c $(WINDHDR) $(HACK_H)
$(OTTY)safeproc.o: $(WSHR)\safeproc.c $(WINDHDR) $(HACK_H)

$(OGUI)consoletty.o:   $(MSWSYS)\consoletty.c $(WINDHDR) $(HACK_H) $(TILE_H)
$(OGUI)win10.o:  $(MSWSYS)\win10.c $(WINDHDR) $(HACK_H)
$(OGUI)windsys.o:  $(MSWSYS)\windsys.c $(WINDHDR) $(HACK_H)
$(OGUI)windsound.o: ..\sound\windsound\windsound.c $(HACK_H)
$(OGUI)windmain.o: $(MSWSYS)\windmain.c $(WINDHDR) $(HACK_H)
$(OGUI)safeproc.o: $(WSHR)\safeproc.c $(WINDHDR) $(HACK_H)

#===================================================================
# win/win32 dependencies
#===================================================================

$(OGUI)mhaskyn.o: $(MSWIN)\mhaskyn.c $(MSWIN)\$(@B).h $(WINDHDR) $(HACK_H)
$(OGUI)mhdlg.o: $(MSWIN)\mhdlg.c $(MSWIN)\$(@B).h $(MSWIN)\resource.h $(WINDHDR) $(HACK_H)
$(OGUI)mhfont.o: $(MSWIN)\mhfont.c $(MSWIN)\$(@B).h $(WINDHDR) $(HACK_H)
$(OGUI)mhinput.o: $(MSWIN)\mhinput.c $(MSWIN)\$(@B).h $(MSWIN)\winMS.h $(WINDHDR) $(HACK_H)
$(OGUI)mhmain.o: $(MSWIN)\mhmain.c $(ALL_GUIHDR) $(WINDHDR) $(HACK_H)
$(OGUI)mhmap.o: $(MSWIN)\mhmap.c $(MSWIN)\$(@B).h $(MSWIN)\mhfont.h $(MSWIN)\mhinput.h \
		$(MSWIN)\mhmsg.h $(MSWIN)\resource.h $(WINDHDR) $(HACK_H)
$(OGUI)mhmenu.o: $(MSWIN)\mhmenu.c $(MSWIN)\$(@B).h $(MSWIN)\mhmain.h $(MSWIN)\mhmsg.h \
		$(MSWIN)\mhfont.h $(MSWIN)\mhdlg.h $(MSWIN)\resource.h $(WINDHDR) $(HACK_H)
$(OGUI)mhmsgwnd.o: $(MSWIN)\mhmsgwnd.c $(MSWIN)\$(@B).h $(MSWIN)\mhmsg.h $(MSWIN)\mhfont.h \
		$(MSWIN)\winMS.h $(WINDHDR) $(HACK_H)
$(OGUI)mhrip.o: $(MSWIN)\mhrip.c $(MSWIN)\$(@B).h $(MSWIN)\mhmsg.h $(MSWIN)\mhfont.h \
		$(MSWIN)\resource.h $(WINDHDR) $(HACK_H)
$(OGUI)mhsplash.o: $(MSWIN)\mhsplash.c $(MSWIN)\$(@B).h $(MSWIN)\mhmsg.h $(MSWIN)\mhfont.h \
		$(MSWIN)\resource.h $(WINDHDR) $(HACK_H)
$(OGUI)mhstatus.o: $(MSWIN)\mhstatus.c $(MSWIN)\$(@B).h $(MSWIN)\mhmsg.h $(MSWIN)\mhfont.h \
		$(WINDHDR) $(HACK_H)
$(OGUI)mhtext.o: $(MSWIN)\mhtext.c $(MSWIN)\$(@B).h $(MSWIN)\mhmsg.h $(MSWIN)\mhfont.h \
		$(WINDHDR) $(HACK_H)
$(OGUI)mswproc.o: $(MSWIN)\mswproc.c $(ALL_GUIHDR) $(MSWIN)\resource.h $(WINDHDR) $(HACK_H)
$(OGUI)NetHackW.o: $(MSWIN)\NetHackW.c $(ALL_GUIHDR) $(MSWIN)\resource.h $(WINDHDR) $(HACK_H)

#===================================================================
# sys/share dependencies
#===================================================================

#$(OTTY)cppregex.o: $(SSYS)\cppregex.cpp $(HACK_H)
#	$(Q)$(CC) $(CPPFLAGS) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $(SSYS)\cppregex.cpp

#$(OGUI)cppregex.o: $(SSYS)\cppregex.cpp $(HACK_H)
#	$(Q)$(CC) $(CPPFLAGS) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $(SSYS)\cppregex.cpp

#===============================================================================
# CROSSCOMPILE
#===============================================================================

# Under a cross-compile, some of the values stored statically into
# text files cannot be trusted as being representative of the
# settings and features used on the build of the target binaries.
#
# We move some of that stuff into the game run-time by separating
# out the functions into src\mdlib.c to get some of the required
# functionality at game runtime instead of from a previously written
# data file.
#

!IFDEF TEST_CROSSCOMPILE
$(OUTL)mdlib$(HOST).o: $(SRC)\mdlib.c
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) -Fo$@ $(SRC)\mdlib.c
!ENDIF

$(OUTL)mdlib.o: $(SRC)\mdlib.c
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) -Fo$@ $(SRC)\mdlib.c
#	$(Q)$(CC) $(CFLAGS) $(TTYDEF) /EP -Fo$@ $(SRC)\mdlib.c >$(OUTL)mdlib.c.preproc

#============================================
# util dual-role CROSSCOMPILE dependencies
#============================================
#
# These have dual-roles and need to be build for host and target platforms.
#
#$(OUTL)panic_host.o:  $(U)panic.c $(CONFIG_H)
#	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) -Fo$@ $(U)panic.c

$(OUTL)panic.o:  $(U)panic.c $(CONFIG_H)
	$(Q)$(CC) $(CFLAGS) -Fo$@ $(U)panic.c
$(OTTY)panic.o:  $(U)panic.c $(CONFIG_H)
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) -Fo$@ $(U)panic.c
$(OGUI)panic.o:  $(U)panic.c $(CONFIG_H)
	$(Q)$(CC) $(CFLAGS) $(GUIDEF) -Fo$@ $(U)panic.c

#$(OUTL)drawing_host.o: drawing.c $(CONFIG_H)
#	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) -Fo$@ drawing.c

$(OUTL)drawing.o: drawing.c $(CONFIG_H) $(INCL)\color.h \
		$(INCL)\sym.h $(INCL)\defsym.h $(INCL)\rm.h \
		$(INCL)\objclass.h
	$(Q)$(CC) $(CFLAGS) -Fo$@ drawing.c

#$(OUTL)monst_host.o: monst.c $(CONFIG_H) $(INCL)\permonst.h $(INCL)\align.h \
#		$(INCL)\monattk.h $(INCL)\monflag.h $(INCL)\sym.h \
#		$(INCL)\defsym.h $(INCL)\color.h
#	$(Q)$(CC) $(CFLAGS) $(TTYDEF) -Fo$@ monst.c

$(OUTL)monst.o: monst.c $(CONFIG_H) $(INCL)\permonst.h $(INCL)\align.h \
		$(INCL)\monattk.h $(INCL)\monflag.h $(INCL)\sym.h \
		$(INCL)\defsym.h $(INCL)\color.h
	$(Q)$(CC) $(CFLAGS) -Fo$@ monst.c

#$(OUTL)objects_host.o: objects.c $(CONFIG_H) $(INCL)\obj.h $(INCL)\objclass.h \
#		$(INCL)\prop.h $(INCL)\skills.h $(INCL)\color.h
#	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) /EP  $(@B).c > $(OUTL)$(@B).c.preproc
#	$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $(@B).c

$(OUTL)objects.o: objects.c $(CONFIG_H) $(INCL)\obj.h $(INCL)\objclass.h \
		$(INCL)\prop.h $(INCL)\skills.h $(INCL)\color.h
	$(Q)$(CC) $(CFLAGS) /EP  $(@B).c > $(OUTL)$(@B).c.preproc
	$(Q)$(CC) $(CFLAGS) -Fo$@ $(@B).c

#$(OUTL)alloc_host.o: alloc.c $(CONFIG_H)
#	$(Q)$(CC) $(CFLAGS) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ alloc.c

$(OUTL)alloc.o: alloc.c $(CONFIG_H)
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) -Fo$@ alloc.c

#===================================================================
# DAT dependencies
#===================================================================

#
# dat dependencies
#

$(DAT)\data: $(U)makedefs.exe $(DATABASE)
	$(U)makedefs -d

$(DAT)\rumors: $(U)makedefs.exe $(DAT)\rumors.tru   $(DAT)\rumors.fal
	$(U)makedefs -r

$(DAT)\oracles: $(U)makedefs.exe $(DAT)\oracles.txt
	$(U)makedefs -h

$(DAT)\engrave: $(U)makedefs.exe $(DAT)\engrave.txt
	$(U)makedefs -s

$(DAT)\epitaph: $(U)makedefs.exe $(DAT)\epitaph.txt
	$(U)makedefs -s

$(DAT)\bogusmon: $(U)makedefs.exe $(DAT)\bogusmon.txt
	$(U)makedefs -s

#===============================================================================
# Integrated sound files
#===============================================================================
$(SndWavDir)\se_squeak_A.wav: $(SndWavDir)\se_squeak_A.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_B.wav: $(SndWavDir)\se_squeak_B.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_B_flat.wav: $(SndWavDir)\se_squeak_B_flat.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_C.wav: $(SndWavDir)\se_squeak_C.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_D.wav: $(SndWavDir)\se_squeak_D.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_D_flat.wav: $(SndWavDir)\se_squeak_D_flat.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_E.wav: $(SndWavDir)\se_squeak_E.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_E_flat.wav: $(SndWavDir)\se_squeak_E_flat.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_F.wav: $(SndWavDir)\se_squeak_F.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_F_sharp.wav: $(SndWavDir)\se_squeak_F_sharp.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_G.wav: $(SndWavDir)\se_squeak_G.uu $(U)uudecode.exe
$(SndWavDir)\se_squeak_G_sharp.wav: $(SndWavDir)\se_squeak_G_sharp.uu $(U)uudecode.exe
$(SndWavDir)\sound_Bell.wav: $(SndWavDir)\sound_Bell.uu $(U)uudecode.exe
$(SndWavDir)\sound_Bugle_A.wav: $(SndWavDir)\sound_Bugle_A.uu $(U)uudecode.exe
$(SndWavDir)\sound_Bugle_B.wav: $(SndWavDir)\sound_Bugle_B.uu $(U)uudecode.exe
$(SndWavDir)\sound_Bugle_C.wav: $(SndWavDir)\sound_Bugle_C.uu $(U)uudecode.exe
$(SndWavDir)\sound_Bugle_D.wav: $(SndWavDir)\sound_Bugle_D.uu $(U)uudecode.exe
$(SndWavDir)\sound_Bugle_E.wav: $(SndWavDir)\sound_Bugle_E.uu $(U)uudecode.exe
$(SndWavDir)\sound_Bugle_F.wav: $(SndWavDir)\sound_Bugle_F.uu $(U)uudecode.exe
$(SndWavDir)\sound_Bugle_G.wav: $(SndWavDir)\sound_Bugle_G.uu $(U)uudecode.exe
$(SndWavDir)\sound_Drum_Of_Earthquake.wav: $(SndWavDir)\sound_Drum_Of_Earthquake.uu $(U)uudecode.exe
$(SndWavDir)\sound_Fire_Horn.wav: $(SndWavDir)\sound_Fire_Horn.uu $(U)uudecode.exe
$(SndWavDir)\sound_Frost_Horn.wav: $(SndWavDir)\sound_Frost_Horn.uu $(U)uudecode.exe
$(SndWavDir)\sound_Leather_Drum.wav: $(SndWavDir)\sound_Leather_Drum.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Harp_A.wav: $(SndWavDir)\sound_Magic_Harp_A.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Harp_B.wav: $(SndWavDir)\sound_Magic_Harp_B.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Harp_C.wav: $(SndWavDir)\sound_Magic_Harp_C.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Harp_D.wav: $(SndWavDir)\sound_Magic_Harp_D.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Harp_E.wav: $(SndWavDir)\sound_Magic_Harp_E.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Harp_F.wav: $(SndWavDir)\sound_Magic_Harp_F.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Harp_G.wav: $(SndWavDir)\sound_Magic_Harp_G.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Flute_A.wav: $(SndWavDir)\sound_Magic_Flute_A.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Flute_B.wav: $(SndWavDir)\sound_Magic_Flute_B.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Flute_C.wav: $(SndWavDir)\sound_Magic_Flute_C.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Flute_D.wav: $(SndWavDir)\sound_Magic_Flute_D.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Flute_E.wav: $(SndWavDir)\sound_Magic_Flute_E.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Flute_F.wav: $(SndWavDir)\sound_Magic_Flute_F.uu $(U)uudecode.exe
$(SndWavDir)\sound_Magic_Flute_G.wav: $(SndWavDir)\sound_Magic_Flute_G.uu $(U)uudecode.exe
$(SndWavDir)\sound_Tooled_Horn_A.wav: $(SndWavDir)\sound_Tooled_Horn_A.uu $(U)uudecode.exe
$(SndWavDir)\sound_Tooled_Horn_B.wav: $(SndWavDir)\sound_Tooled_Horn_B.uu $(U)uudecode.exe
$(SndWavDir)\sound_Tooled_Horn_C.wav: $(SndWavDir)\sound_Tooled_Horn_C.uu $(U)uudecode.exe
$(SndWavDir)\sound_Tooled_Horn_D.wav: $(SndWavDir)\sound_Tooled_Horn_D.uu $(U)uudecode.exe
$(SndWavDir)\sound_Tooled_Horn_E.wav: $(SndWavDir)\sound_Tooled_Horn_E.uu $(U)uudecode.exe
$(SndWavDir)\sound_Tooled_Horn_F.wav: $(SndWavDir)\sound_Tooled_Horn_F.uu $(U)uudecode.exe
$(SndWavDir)\sound_Tooled_Horn_G.wav: $(SndWavDir)\sound_Tooled_Horn_G.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Flute_A.wav: $(SndWavDir)\sound_Wooden_Flute_A.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Flute_B.wav: $(SndWavDir)\sound_Wooden_Flute_B.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Flute_C.wav: $(SndWavDir)\sound_Wooden_Flute_C.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Flute_D.wav: $(SndWavDir)\sound_Wooden_Flute_D.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Flute_E.wav: $(SndWavDir)\sound_Wooden_Flute_E.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Flute_F.wav: $(SndWavDir)\sound_Wooden_Flute_F.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Flute_G.wav: $(SndWavDir)\sound_Wooden_Flute_G.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Harp_A.wav: $(SndWavDir)\sound_Wooden_Harp_A.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Harp_B.wav: $(SndWavDir)\sound_Wooden_Harp_B.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Harp_C.wav: $(SndWavDir)\sound_Wooden_Harp_C.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Harp_D.wav: $(SndWavDir)\sound_Wooden_Harp_D.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Harp_E.wav: $(SndWavDir)\sound_Wooden_Harp_E.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Harp_F.wav: $(SndWavDir)\sound_Wooden_Harp_F.uu $(U)uudecode.exe
$(SndWavDir)\sound_Wooden_Harp_G.wav: $(SndWavDir)\sound_Wooden_Harp_G.uu $(U)uudecode.exe
$(SndWavDir)\sa2_xpleveldown.wav: $(SndWavDir)\sa2_xpleveldown.uu $(U)uudecode.exe
$(SndWavDir)\sa2_xplevelup.wav: $(SndWavDir)\sa2_xplevelup.uu $(U)uudecode.exe

#===============================================================================
# Housekeeping
#===============================================================================

spotless: clean
	if exist $(GAMEDIR)\NetHack.exe del $(GAMEDIR)\NetHack.exe
	if exist $(GAMEDIR)\NetHack.pdb del $(GAMEDIR)\NetHack.pdb
	if exist $(GAMEDIR)\nhdat$(NHV) del $(GAMEDIR)\nhdat$(NHV)
	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 $(U)*.lnk              del $(U)*.lnk
	if exist $(U)*.map              del $(U)*.map
	if exist $(DAT)\data            del $(DAT)\data
	if exist $(DAT)\rumors          del $(DAT)\rumors
	if exist $(DAT)\engrave         del $(DAT)\engrave
	if exist $(DAT)\epitaph         del $(DAT)\epitaph
	if exist $(DAT)\bogusmon        del $(DAT)\bogusmon
	if exist $(DAT)\porthelp	del $(DAT)\porthelp
	if exist nhdat$(NHV).	        del nhdat$(NHV).
	if exist outldirx86.tag         del outldirx86.tag
	if exist ottydirx86.tag         del ottydirx86.tag
	if exist oguidirx86.tag         del oguidirx86.tag
	if exist oluadirx86.tag         del oluadirx86.tag
	if exist opdcdirx86.tag         del opdcdirx86.tag
	if exist outldirx64.tag         del outldirx64.tag
	if exist ottydirx64.tag         del ottydirx64.tag
	if exist oguidirx64.tag         del oguidirx64.tag
	if exist oluadirx64.tag         del oluadirx64.tag
	if exist opdcdirx64.tag         del opdcdirx64.tag
	if exist libdir.tag             del libdir.tag
	if exist gamedir.tag            del gamedir.tag
	if exist $(MSWIN)\mnsel.bmp     del $(MSWIN)\mnsel.bmp
	if exist $(MSWIN)\mnselcnt.bmp  del $(MSWIN)\mnselcnt.bmp
	if exist $(MSWIN)\mnunsel.bmp   del $(MSWIN)\mnunsel.bmp
	if exist $(MSWIN)\petmark.bmp   del $(MSWIN)\petmark.bmp
	if exist $(MSWIN)\pilemark.bmp  del $(MSWIN)\pilemark.bmp
	if exist $(MSWIN)\rip.bmp       del $(MSWIN)\rip.bmp
	if exist $(MSWIN)\splash.bmp    del $(MSWIN)\splash.bmp
	if exist $(MSWIN)\nethack.ico   del $(MSWIN)\nethack.ico
	if exist $(MSWSYS)\nethack.ico  del $(MSWSYS)\nethack.ico
	if exist $(U)recover.exe        del $(U)recover.exe
	if exist $(U)tile2bmp.exe       del $(U)tile2bmp.exe
	if exist $(U)tilemap.exe        del $(U)tilemap.exe
	if exist $(U)uudecode.exe       del $(U)uudecode.exe
	if exist $(U)dlb.exe            del $(U)dlb.exe
!IF "$(ADD_CURSES)" == "Y"
	if exist $(PDCLIB)              del $(PDCLIB)
!ENDIF
        if exist $(LUALIB)              del $(LUALIB)
	if exist $(DAT)\oracles		del $(DAT)\oracles
	if exist $(DAT)\rumors		del $(DAT)\rumors
	if exist $(DAT)\options		del $(DAT)\options
	if exist $(DAT)\ttyoptions	del $(DAT)\ttyoptions
	if exist $(DAT)\guioptions	del $(DAT)\guioptions
	if exist $(DAT)\data		del $(DAT)\data
	if exist tilemappings.lst       del tilemappings.lst
	if exist $(SndWavDir)\*.wav     del $(SndWavDir)\*.wav
	if exist $(OBJTTY)\*            rmdir $(OBJTTY) /s /Q
	if exist $(OBJGUI)\*            rmdir $(OBJGUI) /s /Q
	if exist $(OBJUTIL)\*           rmdir $(OBJUTIL) /s /Q
	if exist $(OBJLUA)\*            rmdir $(OBJLUA) /s /Q
	if exist $(OBJPDC)\*            rmdir $(OBJPDC) /s /Q
	if exist $(OBJTTY_B)\*          rmdir $(OBJTTY_B) /s /Q
	if exist $(OBJGUI_B)\*          rmdir $(OBJGUI_B) /s /Q
	if exist $(OBJUTIL_B)\*         rmdir $(OBJUTIL_B) /s /Q
	if exist $(OBJLUA_B)\*          rmdir $(OBJLUA_B) /s /Q
	if exist $(OBJPDC_B)\*          rmdir $(OBJPDC_B) /s /Q

clean:
	if exist install.tag            del install.tag
	if exist gamedir.tag            del gamedir.tag
	if exist envchk.tag             del envchk.tag
	if exist cpu.tag                del cpu.tag
	if exist envchk.tag             del envchk.tag
	if exist $(OUTL)utility.tag     del $(OUTL)utility.tag
	if exist $(OTTY)sp_lev.tag      del $(OTTY)sp_lev.tag
	if exist $(OGUI)sp_lev.tag      del $(OGUI)sp_lev.tag
	if exist $(SRC)\tile.c          del $(SRC)\tile.c
	if exist $(INCL)\nhlua.h        del $(INCL)\nhlua.h
	if exist $(U)makedefs.exe       del $(U)makedefs.exe
	if exist $(U)dlb_main.exe       del $(U)dlb_main.exe
	if exist $(U)tile2bmp.exe       del $(U)tile2bmp.exe
	if exist $(U)tilemap.exe        del $(U)tilemap.exe
	if exist $(SRC)\*.lnk           del $(SRC)\*.lnk
	if exist $(DAT)\dlb.lst         del $(DAT)\dlb.lst
	if exist $(OUTL)*.o             del $(OUTL)*.o
	if exist $(OTTY)*.o             del $(OTTY)*.o
	if exist $(OGUI)*.o             del $(OGUI)*.o
	if exist $(OLUA)*.o             del $(OLUA)*.o
	if exist $(OPDC)*.o             del $(OPDC)*.o
	if exist $(OUTL)*.PDB           del $(OUTL)*.PDB
	if exist $(OTTY)*.PDB           del $(OTTY)*.PDB
	if exist $(OGUI)*.PDB           del $(OGUI)*.PDB
	if exist $(OLUA)*.PDB           del $(OLUA)*.PDB
	if exist $(OPDC)*.PDB           del $(OPDC)*.PDB
	if exist $(OUTL)*.MAP           del $(OUTL)*.MAP
	if exist $(OTTY)*.MAP           del $(OTTY)*.MAP
	if exist $(OGUI)*.MAP           del $(OGUI)*.MAP
	if exist $(OLUA)*.MAP           del $(OLUA)*.MAP
	if exist $(OPDC)*.MAP           del $(OPDC)*.MAP
	if exist $(OUTL)*.LIB           del $(OUTL)*.LIB
	if exist $(OTTY)*.LIB           del $(OTTY)*.LIB
	if exist $(OGUI)*.LIB           del $(OGUI)*.LIB
	if exist $(OLUA)*.LIB           del $(OLUA)*.LIB
	if exist $(OPDC)*.LIB           del $(OPDC)*.LIB
	if exist $(OUTL)*.EXP           del $(OUTL)*.EXP
	if exist $(OTTY)*.EXP           del $(OTTY)*.EXP
	if exist $(OGUI)*.EXP           del $(OGUI)*.EXP
	if exist $(OLUA)*.EXP           del $(OLUA)*.EXP
	if exist $(OPDC)*.EXP           del $(OPDC)*.EXP
	if exist $(SRC)\tiles.bmp       del $(SRC)\tiles.bmp
	if exist $(OTTY)console.res     del $(OTTY)console.res
	if exist $(OTTY)NetHack.res     del $(OTTY)NetHack.res
	if exist $(OGUI)NetHackW.res    del $(OGUI)NetHackW.res

#===================================================================
# OTHER DEPENDENCIES
#===================================================================
# The rest are stolen from sys/unix/Makefile.src,
# twice, with the following changes:
#   * the CONFIG_H and HACK_H sections comment out or removed completely
#   * ../include/ changed to $(INCL)\
#   * slashes changed to back-slashes
#   * -c (which is included in cflagsBuild) substituted with -Fo$@
#   * "-o $@ " is removed
#   * win/X11/Window.o commented due to conflict with pdcurses
#   * win/share/cppregex.o commented out due to earlier rule
#   * commented out $(TARGETPFX)tile.o: tile.c $(HACK_H)
#   * commented out $(TARGETPFX)cppregex.o because it has its own rule already
#   * $(TARGETPFX) becomes $(OTTY) in 1st batch with $(TTYDEF)
#   * $(TARGETPFX) becomes $(OGUI) in 2nd batch with $(GUIDEF)
#   * commented out the lines starting with
#	$(TARGET_CC) so the rules in this Makefile will be used instead
#   * add compile recipe for nhlua.c to add -wd4324 to suppress a
#     warning during x64 build related to padding due to alignment
# but otherwise untouched.
# That means that there is some irrelevant stuff
# in here, but maintenance should be easier.
#

TARGET_CC=$(cc)
TARGET_CFLAGS=$(CFLAGS) $(TTYDEF)
TARGET_CXX=$(cc)
TARGET_CXXFLAGS=$(CPPFLAGS) $(TTYDEF)
MOCPATH = moc.exe

$(OTTY)pcmain.o: ..\sys\share\pcmain.c $(HACK_H) $(INCL)\dlb.h
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\pcmain.c
$(OTTY)pcsys.o: ..\sys\share\pcsys.c $(HACK_H) $(INCL)\wintty.h
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\pcsys.c
$(OTTY)pctty.o: ..\sys\share\pctty.c $(HACK_H) $(INCL)\wintty.h
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\pctty.c
$(OTTY)pcunix.o: ..\sys\share\pcunix.c $(HACK_H) $(INCL)\wintty.h
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\pcunix.c
$(OTTY)pmatchregex.o: ..\sys\share\pmatchregex.c $(HACK_H)
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\pmatchregex.c
$(OTTY)posixregex.o: ..\sys\share\posixregex.c $(HACK_H)
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\posixregex.c
$(OTTY)random.o: ..\sys\share\random.c $(HACK_H)
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\random.c
$(OTTY)ioctl.o: ..\sys\share\ioctl.c $(HACK_H) $(INCL)\tcap.h
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\ioctl.c
$(OTTY)unixtty.o: ..\sys\share\unixtty.c $(HACK_H)
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\unixtty.c
$(OTTY)unixmain.o: ..\sys\unix\unixmain.c $(HACK_H) $(INCL)\dlb.h
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\unix\unixmain.c
$(OTTY)unixunix.o: ..\sys\unix\unixunix.c $(HACK_H)
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\unix\unixunix.c
$(OTTY)unixres.o: ..\sys\unix\unixres.c $(CONFIG_H)
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\unix\unixres.c
$(OTTY)getline.o: ..\win\tty\getline.c $(HACK_H) $(INCL)\wintty.h \
		$(INCL)\func_tab.h
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\tty\getline.c
$(OTTY)termcap.o: ..\win\tty\termcap.c $(HACK_H) $(INCL)\wintty.h \
		$(INCL)\tcap.h
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\tty\termcap.c
$(OTTY)topl.o: ..\win\tty\topl.c $(HACK_H) $(INCL)\tcap.h \
		$(INCL)\wintty.h
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\tty\topl.c
$(OTTY)wintty.o: ..\win\tty\wintty.c $(HACK_H) $(INCL)\dlb.h \
		$(INCL)\tcap.h $(INCL)\wintty.h
	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\tty\wintty.c
$(OTTY)cursmain.o: ..\win\curses\cursmain.c $(HACK_H) $(INCL)\wincurs.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursmain.c
$(OTTY)curswins.o: ..\win\curses\curswins.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\curswins.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\curswins.c
$(OTTY)cursmisc.o: ..\win\curses\cursmisc.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursmisc.h \
		$(INCL)\func_tab.h $(INCL)\dlb.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursmisc.c
$(OTTY)cursdial.o: ..\win\curses\cursdial.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursdial.h \
		$(INCL)\func_tab.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursdial.c
$(OTTY)cursstat.o: ..\win\curses\cursstat.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursstat.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursstat.c
$(OTTY)cursinit.o: ..\win\curses\cursinit.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursinit.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursinit.c
$(OTTY)cursmesg.o: ..\win\curses\cursmesg.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursmesg.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursmesg.c
$(OTTY)cursinvt.o: ..\win\curses\cursinvt.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursinvt.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursinvt.c
#$(OTTY)Window.o: ..\win\X11\Window.c $(INCL)\xwindowp.h \
#		$(INCL)\xwindow.h $(CONFIG_H) $(INCL)\lint.h \
#		$(INCL)\winX.h $(INCL)\color.h $(INCL)\wintype.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\Window.c
$(OTTY)dialogs.o: ..\win\X11\dialogs.c $(CONFIG_H) $(INCL)\lint.h \
		$(INCL)\winX.h $(INCL)\color.h $(INCL)\wintype.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\dialogs.c
$(OTTY)winX.o: ..\win\X11\winX.c $(HACK_H) $(INCL)\winX.h \
		$(INCL)\dlb.h $(INCL)\xwindow.h ..\win\X11\nh72icon \
		..\win\X11\nh56icon ..\win\X11\nh32icon
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winX.c
$(OTTY)winmap.o: ..\win\X11\winmap.c $(INCL)\xwindow.h $(HACK_H) \
		$(INCL)\dlb.h $(INCL)\winX.h $(INCL)\tile2x11.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winmap.c
$(OTTY)winmenu.o: ..\win\X11\winmenu.c $(HACK_H) $(INCL)\winX.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winmenu.c
$(OTTY)winmesg.o: ..\win\X11\winmesg.c $(INCL)\xwindow.h $(HACK_H) \
		$(INCL)\winX.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winmesg.c
$(OTTY)winmisc.o: ..\win\X11\winmisc.c $(HACK_H) $(INCL)\func_tab.h \
		$(INCL)\winX.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winmisc.c
$(OTTY)winstat.o: ..\win\X11\winstat.c $(HACK_H) $(INCL)\winX.h \
		$(INCL)\xwindow.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winstat.c
$(OTTY)wintext.o: ..\win\X11\wintext.c $(HACK_H) $(INCL)\winX.h \
		$(INCL)\xwindow.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\wintext.c
$(OTTY)winval.o: ..\win\X11\winval.c $(HACK_H) $(INCL)\winX.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winval.c
#$(OTTY)tile.o: tile.c $(HACK_H)
$(OTTY)winshim.o: ..\win\shim\winshim.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\shim\winshim.c
#$(OTTY)cppregex.o: ..\sys\share\cppregex.cpp $(CONFIG_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\sys\share\cppregex.cpp
$(OTTY)qt_bind.o: ..\win\Qt\qt_bind.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h \
		..\win\Qt\qt_kde0.h ..\win\Qt\qt_click.h ..\win\Qt\qt_delay.h \
		..\win\Qt\qt_xcmd.h ..\win\Qt\qt_key.h ..\win\Qt\qt_map.h \
		..\win\Qt\qt_win.h ..\win\Qt\qt_clust.h ..\win\Qt\qt_menu.h \
		..\win\Qt\qt_rip.h ..\win\Qt\qt_msg.h ..\win\Qt\qt_plsel.h \
		..\win\Qt\qt_svsel.h ..\win\Qt\qt_set.h ..\win\Qt\qt_stat.h \
		..\win\Qt\qt_icon.h ..\win\Qt\qt_streq.h ..\win\Qt\qt_line.h \
		..\win\Qt\qt_yndlg.h ..\win\Qt\qt_str.h $(INCL)\dlb.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_bind.cpp
$(OTTY)qt_click.o: ..\win\Qt\qt_click.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_click.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_click.cpp
$(OTTY)qt_clust.o: ..\win\Qt\qt_clust.cpp ..\win\Qt\qt_clust.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_clust.cpp
$(OTTY)qt_delay.o: ..\win\Qt\qt_delay.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_delay.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_delay.cpp
$(OTTY)qt_glyph.o: ..\win\Qt\qt_glyph.cpp $(HACK_H) \
		$(INCL)\tile2x11.h ..\win\Qt\qt_pre.h ..\win\Qt\qt_post.h \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h \
		..\win\Qt\qt_kde0.h ..\win\Qt\qt_set.h ..\win\Qt\qt_inv.h \
		..\win\Qt\qt_map.h ..\win\Qt\qt_win.h ..\win\Qt\qt_clust.h \
		..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_glyph.cpp
$(OTTY)qt_icon.o: ..\win\Qt\qt_icon.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_icon.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_icon.cpp
$(OTTY)qt_inv.o: ..\win\Qt\qt_inv.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_inv.h ..\win\Qt\qt_glyph.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_set.h \
		..\win\Qt\qt_bind.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_inv.cpp
$(OTTY)qt_key.o: ..\win\Qt\qt_key.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_key.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_key.cpp
$(OTTY)qt_line.o: ..\win\Qt\qt_line.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_line.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_line.cpp
$(OTTY)qt_main.o: ..\win\Qt\qt_main.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h \
		qt_main.moc ..\win\Qt\qt_bind.h ..\win\Qt\qt_glyph.h \
		..\win\Qt\qt_inv.h ..\win\Qt\qt_key.h ..\win\Qt\qt_map.h \
		..\win\Qt\qt_win.h ..\win\Qt\qt_clust.h ..\win\Qt\qt_msg.h \
		..\win\Qt\qt_set.h ..\win\Qt\qt_stat.h ..\win\Qt\qt_icon.h \
		..\win\Qt\qt_str.h qt_kde0.moc $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_main.cpp
$(OTTY)qt_map.o: ..\win\Qt\qt_map.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_map.h ..\win\Qt\qt_win.h \
		..\win\Qt\qt_clust.h qt_map.moc ..\win\Qt\qt_click.h \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_map.cpp
$(OTTY)qt_menu.o: ..\win\Qt\qt_menu.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_menu.h ..\win\Qt\qt_win.h \
		..\win\Qt\qt_rip.h qt_menu.moc ..\win\Qt\qt_key.h \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_streq.h \
		..\win\Qt\qt_line.h ..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_menu.cpp
$(OTTY)qt_msg.o: ..\win\Qt\qt_msg.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_msg.h ..\win\Qt\qt_win.h \
		qt_msg.moc ..\win\Qt\qt_map.h ..\win\Qt\qt_clust.h \
		..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h \
		..\win\Qt\qt_kde0.h ..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_msg.cpp
$(OTTY)qt_plsel.o: ..\win\Qt\qt_plsel.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_plsel.h qt_plsel.moc \
		..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_set.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_plsel.cpp
$(OTTY)qt_rip.o: ..\win\Qt\qt_rip.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_rip.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_rip.cpp
$(OTTY)qt_set.o: ..\win\Qt\qt_set.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h qt_set.moc \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_xcmd.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_set.cpp
$(OTTY)qt_stat.o: ..\win\Qt\qt_stat.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_stat.h ..\win\Qt\qt_win.h \
		..\win\Qt\qt_icon.h qt_stat.moc ..\win\Qt\qt_set.h \
		..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h \
		..\win\Qt\qt_str.h ..\win\Qt\qt_xpms.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_stat.cpp
$(OTTY)qt_str.o: ..\win\Qt\qt_str.cpp ..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_str.cpp
$(OTTY)qt_streq.o: ..\win\Qt\qt_streq.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_streq.h ..\win\Qt\qt_line.h \
		..\win\Qt\qt_str.h ..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_streq.cpp
$(OTTY)qt_svsel.o: ..\win\Qt\qt_svsel.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_svsel.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_svsel.cpp
$(OTTY)qt_win.o: ..\win\Qt\qt_win.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_win.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_click.h \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_inv.h ..\win\Qt\qt_key.h \
		..\win\Qt\qt_icon.h ..\win\Qt\qt_map.h ..\win\Qt\qt_clust.h \
		..\win\Qt\qt_menu.h ..\win\Qt\qt_rip.h ..\win\Qt\qt_msg.h \
		..\win\Qt\qt_set.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_win.cpp
$(OTTY)qt_xcmd.o: ..\win\Qt\qt_xcmd.cpp $(HACK_H) $(INCL)\func_tab.h \
		..\win\Qt\qt_pre.h ..\win\Qt\qt_post.h ..\win\Qt\qt_xcmd.h \
		qt_xcmd.moc ..\win\Qt\qt_key.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_set.h \
		..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_xcmd.cpp
$(OTTY)qt_yndlg.o: ..\win\Qt\qt_yndlg.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_yndlg.h qt_yndlg.moc \
		..\win\Qt\qt_key.h ..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_yndlg.cpp
qt_kde0.moc: ..\win\Qt\qt_kde0.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_kde0.h
qt_main.moc: ..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_main.h
qt_map.moc: ..\win\Qt\qt_map.h ..\win\Qt\qt_win.h ..\win\Qt\qt_clust.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_map.h
qt_menu.moc: ..\win\Qt\qt_menu.h ..\win\Qt\qt_win.h ..\win\Qt\qt_rip.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_menu.h
qt_msg.moc: ..\win\Qt\qt_msg.h ..\win\Qt\qt_win.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_msg.h
qt_plsel.moc: ..\win\Qt\qt_plsel.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_plsel.h
qt_set.moc: ..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h \
		..\win\Qt\qt_kde0.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_set.h
qt_stat.moc: ..\win\Qt\qt_stat.h ..\win\Qt\qt_win.h ..\win\Qt\qt_icon.h \
		$(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_stat.h
qt_xcmd.moc: ..\win\Qt\qt_xcmd.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_xcmd.h
qt_yndlg.moc: ..\win\Qt\qt_yndlg.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_yndlg.h
#$(OTTY)tile.o: tile.c $(HACK_H)
$(OTTY)wc_chainin.o: ..\win\chain\wc_chainin.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\chain\wc_chainin.c
$(OTTY)wc_chainout.o: ..\win\chain\wc_chainout.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\chain\wc_chainout.c
$(OTTY)wc_trace.o: ..\win\chain\wc_trace.c $(HACK_H) $(INCL)\wintty.h \
		$(INCL)\func_tab.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\chain\wc_trace.c
$(OTTY)allmain.o: allmain.c $(HACK_H)
$(OTTY)alloc.o: alloc.c $(CONFIG_H) $(INCL)\nhlua.h
$(OTTY)apply.o: apply.c $(HACK_H)
$(OTTY)artifact.o: artifact.c $(HACK_H) $(INCL)\artifact.h
$(OTTY)attrib.o: attrib.c $(HACK_H)
$(OTTY)ball.o: ball.c $(HACK_H)
$(OTTY)bones.o: bones.c $(HACK_H)
$(OTTY)botl.o: botl.c $(HACK_H)
$(OTTY)cmd.o: cmd.c $(HACK_H) $(INCL)\func_tab.h
$(OTTY)dbridge.o: dbridge.c $(HACK_H)
$(OTTY)decl.o: decl.c $(HACK_H)
$(OTTY)detect.o: detect.c $(HACK_H) $(INCL)\artifact.h
$(OTTY)dig.o: dig.c $(HACK_H)
$(OTTY)display.o: display.c $(HACK_H)
$(OTTY)dlb.o: dlb.c $(CONFIG_H) $(INCL)\dlb.h
$(OTTY)do.o: do.c $(HACK_H)
$(OTTY)do_name.o: do_name.c $(HACK_H)
$(OTTY)do_wear.o: do_wear.c $(HACK_H)
$(OTTY)dog.o: dog.c $(HACK_H)
$(OTTY)dogmove.o: dogmove.c $(HACK_H) $(INCL)\mfndpos.h
$(OTTY)dokick.o: dokick.c $(HACK_H)
$(OTTY)dothrow.o: dothrow.c $(HACK_H)
$(OTTY)drawing.o: drawing.c $(CONFIG_H) $(INCL)\color.h \
		$(INCL)\rm.h $(INCL)\objclass.h $(INCL)\defsym.h \
		$(INCL)\objects.h $(INCL)\wintype.h $(INCL)\sym.h
$(OTTY)dungeon.o: dungeon.c $(HACK_H) $(INCL)\dgn_file.h \
		$(INCL)\dlb.h
$(OTTY)eat.o: eat.c $(HACK_H)
$(OTTY)end.o: end.c $(HACK_H) $(INCL)\dlb.h
$(OTTY)engrave.o: engrave.c $(HACK_H)
$(OTTY)exper.o: exper.c $(HACK_H)
$(OTTY)explode.o: explode.c $(HACK_H)
$(OTTY)extralev.o: extralev.c $(HACK_H)
$(OTTY)files.o: files.c $(HACK_H) $(INCL)\dlb.h $(INCL)\wintty.h \
		#zlib.h
$(OTTY)fountain.o: fountain.c $(HACK_H)
$(OTTY)hack.o: hack.c $(HACK_H)
$(OTTY)hacklib.o: hacklib.c $(HACK_H)
$(OTTY)insight.o: insight.c $(HACK_H)
$(OTTY)invent.o: invent.c $(HACK_H)
$(OTTY)isaac64.o: isaac64.c $(CONFIG_H) $(INCL)\isaac64.h
$(OTTY)light.o: light.c $(HACK_H)
$(OTTY)lock.o: lock.c $(HACK_H)
$(OTTY)mail.o: mail.c $(HACK_H) $(INCL)\mail.h
$(OTTY)makemon.o: makemon.c $(HACK_H)
$(OTTY)mcastu.o: mcastu.c $(HACK_H)
$(OTTY)mdlib.o: mdlib.c $(CONFIG_H) $(INCL)\permonst.h \
		$(INCL)\align.h $(INCL)\monattk.h $(INCL)\monflag.h \
		$(INCL)\monsters.h $(INCL)\objclass.h \
		$(INCL)\defsym.h $(INCL)\objects.h $(INCL)\wintype.h \
		$(INCL)\sym.h $(INCL)\artilist.h $(INCL)\dungeon.h \
		$(INCL)\sndprocs.h $(INCL)\seffects.h $(INCL)\obj.h \
		$(INCL)\monst.h $(INCL)\mextra.h $(INCL)\you.h \
		$(INCL)\attrib.h $(INCL)\prop.h $(INCL)\skills.h \
		$(INCL)\context.h $(INCL)\flag.h $(INCL)\dlb.h
$(OTTY)mhitm.o: mhitm.c $(HACK_H) $(INCL)\artifact.h
$(OTTY)mhitu.o: mhitu.c $(HACK_H) $(INCL)\artifact.h
$(OTTY)minion.o: minion.c $(HACK_H)
$(OTTY)mklev.o: mklev.c $(HACK_H)
$(OTTY)mkmap.o: mkmap.c $(HACK_H) $(INCL)\sp_lev.h
$(OTTY)mkmaze.o: mkmaze.c $(HACK_H) $(INCL)\sp_lev.h
$(OTTY)mkobj.o: mkobj.c $(HACK_H)
$(OTTY)mkroom.o: mkroom.c $(HACK_H)
$(OTTY)mon.o: mon.c $(HACK_H) $(INCL)\mfndpos.h
$(OTTY)mondata.o: mondata.c $(HACK_H)
$(OTTY)monmove.o: monmove.c $(HACK_H) $(INCL)\mfndpos.h \
		$(INCL)\artifact.h
$(OTTY)monst.o: monst.c $(CONFIG_H) $(INCL)\permonst.h \
		$(INCL)\align.h $(INCL)\monattk.h $(INCL)\monflag.h \
		$(INCL)\monsters.h $(INCL)\wintype.h $(INCL)\sym.h \
		$(INCL)\defsym.h $(INCL)\color.h
$(OTTY)mplayer.o: mplayer.c $(HACK_H)
$(OTTY)mthrowu.o: mthrowu.c $(HACK_H)
$(OTTY)muse.o: muse.c $(HACK_H)
$(OTTY)music.o: music.c $(HACK_H)
$(OTTY)nhlua.o: nhlua.c $(HACK_H) $(INCL)\dlb.h
	$(Q)$(CC) $(CFLAGS) $(TTYDEF) -wd4324 $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $(@B).c
$(OTTY)nhlsel.o: nhlsel.c $(HACK_H) $(INCL)\sp_lev.h
$(OTTY)nhlobj.o: nhlobj.c $(HACK_H) $(INCL)\sp_lev.h
$(OTTY)o_init.o: o_init.c $(HACK_H)
$(OTTY)objects.o: objects.c $(CONFIG_H) $(INCL)\obj.h \
		$(INCL)\prop.h $(INCL)\skills.h $(INCL)\color.h \
		$(INCL)\objclass.h $(INCL)\defsym.h $(INCL)\objects.h
$(OTTY)objnam.o: objnam.c $(HACK_H)
$(OTTY)options.o: options.c $(CONFIG_H) $(INCL)\objclass.h \
		$(INCL)\defsym.h $(INCL)\objects.h $(INCL)\flag.h \
		$(HACK_H) $(INCL)\tcap.h $(INCL)\optlist.h
$(OTTY)pager.o: pager.c $(HACK_H) $(INCL)\dlb.h
$(OTTY)pickup.o: pickup.c $(HACK_H)
$(OTTY)pline.o: pline.c $(HACK_H)
$(OTTY)polyself.o: polyself.c $(HACK_H)
$(OTTY)potion.o: potion.c $(HACK_H)
$(OTTY)pray.o: pray.c $(HACK_H)
$(OTTY)priest.o: priest.c $(HACK_H) $(INCL)\mfndpos.h
$(OTTY)quest.o: quest.c $(HACK_H)
$(OTTY)questpgr.o: questpgr.c $(HACK_H) $(INCL)\dlb.h \
		$(INCL)\wintty.h
$(OTTY)read.o: read.c $(HACK_H)
$(OTTY)rect.o: rect.c $(HACK_H)
$(OTTY)region.o: region.c $(HACK_H)
$(OTTY)restore.o: restore.c $(HACK_H) $(INCL)\tcap.h
$(OTTY)rip.o: rip.c $(HACK_H)
$(OTTY)rnd.o: rnd.c $(HACK_H) $(INCL)\isaac64.h
$(OTTY)role.o: role.c $(HACK_H)
$(OTTY)rumors.o: rumors.c $(HACK_H) $(INCL)\dlb.h
$(OTTY)save.o: save.c $(HACK_H)
$(OTTY)sfstruct.o: sfstruct.c $(HACK_H)
$(OTTY)shk.o: shk.c $(HACK_H)
$(OTTY)shknam.o: shknam.c $(HACK_H)
$(OTTY)sit.o: sit.c $(HACK_H) $(INCL)\artifact.h
$(OTTY)sounds.o: sounds.c $(HACK_H)
$(OTTY)sp_lev.o: sp_lev.c $(HACK_H) $(INCL)\sp_lev.h
$(OTTY)spell.o: spell.c $(HACK_H)
$(OTTY)steal.o: steal.c $(HACK_H)
$(OTTY)steed.o: steed.c $(HACK_H)
$(OTTY)symbols.o: symbols.c $(HACK_H) $(INCL)\tcap.h
$(OTTY)sys.o: sys.c $(HACK_H)
$(OTTY)teleport.o: teleport.c $(HACK_H)
$(OTTY)timeout.o: timeout.c $(HACK_H)
$(OTTY)topten.o: topten.c $(HACK_H) $(INCL)\dlb.h
$(OTTY)track.o: track.c $(HACK_H)
$(OTTY)trap.o: trap.c $(HACK_H)
$(OTTY)u_init.o: u_init.c $(HACK_H)
$(OTTY)utf8map.o: utf8map.c $(HACK_H)
$(OTTY)uhitm.o: uhitm.c $(HACK_H)
$(OTTY)vault.o: vault.c $(HACK_H)
$(OTTY)version.o: version.c $(HACK_H) $(INCL)\dlb.h
$(OTTY)vision.o: vision.c $(HACK_H)
$(OTTY)weapon.o: weapon.c $(HACK_H)
$(OTTY)were.o: were.c $(HACK_H)
$(OTTY)wield.o: wield.c $(HACK_H)
$(OTTY)windows.o: windows.c $(HACK_H) $(INCL)\dlb.h $(INCL)\wintty.h
$(OTTY)wizard.o: wizard.c $(HACK_H)
$(OTTY)worm.o: worm.c $(HACK_H)
$(OTTY)worn.o: worn.c $(HACK_H)
$(OTTY)write.o: write.c $(HACK_H)
$(OTTY)zap.o: zap.c $(HACK_H)
#
#
#---------------------------------------------
# GUI
#
TARGET_CC=$(cc)
TARGET_CFLAGS=$(CFLAGS) $(GUIDEF)
TARGET_CXX=$(cc)
TARGET_CXXFLAGS=$(CPPFLAGS) $(GUIDEF)
MOCPATH = moc.exe

$(OGUI)pcmain.o: ..\sys\share\pcmain.c $(HACK_H) $(INCL)\dlb.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\pcmain.c
$(OGUI)pcsys.o: ..\sys\share\pcsys.c $(HACK_H) $(INCL)\wintty.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\pcsys.c
$(OGUI)pctty.o: ..\sys\share\pctty.c $(HACK_H) $(INCL)\wintty.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\pctty.c
$(OGUI)pcunix.o: ..\sys\share\pcunix.c $(HACK_H) $(INCL)\wintty.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\pcunix.c
$(OGUI)pmatchregex.o: ..\sys\share\pmatchregex.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\pmatchregex.c
$(OGUI)posixregex.o: ..\sys\share\posixregex.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\posixregex.c
$(OGUI)random.o: ..\sys\share\random.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\random.c
$(OGUI)ioctl.o: ..\sys\share\ioctl.c $(HACK_H) $(INCL)\tcap.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\ioctl.c
$(OGUI)unixtty.o: ..\sys\share\unixtty.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\share\unixtty.c
$(OGUI)unixmain.o: ..\sys\unix\unixmain.c $(HACK_H) $(INCL)\dlb.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\unix\unixmain.c
$(OGUI)unixunix.o: ..\sys\unix\unixunix.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\unix\unixunix.c
$(OGUI)unixres.o: ..\sys\unix\unixres.c $(CONFIG_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\sys\unix\unixres.c
$(OGUI)getline.o: ..\win\tty\getline.c $(HACK_H) $(INCL)\wintty.h \
		$(INCL)\func_tab.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\tty\getline.c
$(OGUI)termcap.o: ..\win\tty\termcap.c $(HACK_H) $(INCL)\wintty.h \
		$(INCL)\tcap.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\tty\termcap.c
$(OGUI)topl.o: ..\win\tty\topl.c $(HACK_H) $(INCL)\tcap.h \
		$(INCL)\wintty.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\tty\topl.c
$(OGUI)wintty.o: ..\win\tty\wintty.c $(HACK_H) $(INCL)\dlb.h \
		$(INCL)\tcap.h $(INCL)\wintty.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\tty\wintty.c
$(OGUI)cursmain.o: ..\win\curses\cursmain.c $(HACK_H) $(INCL)\wincurs.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursmain.c
$(OGUI)curswins.o: ..\win\curses\curswins.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\curswins.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\curswins.c
$(OGUI)cursmisc.o: ..\win\curses\cursmisc.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursmisc.h \
		$(INCL)\func_tab.h $(INCL)\dlb.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursmisc.c
$(OGUI)cursdial.o: ..\win\curses\cursdial.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursdial.h \
		$(INCL)\func_tab.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursdial.c
$(OGUI)cursstat.o: ..\win\curses\cursstat.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursstat.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursstat.c
$(OGUI)cursinit.o: ..\win\curses\cursinit.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursinit.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursinit.c
$(OGUI)cursmesg.o: ..\win\curses\cursmesg.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursmesg.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursmesg.c
$(OGUI)cursinvt.o: ..\win\curses\cursinvt.c $(HACK_H) \
		$(INCL)\wincurs.h ..\win\curses\cursinvt.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\curses\cursinvt.c
#$(OGUI)Window.o: ..\win\X11\Window.c $(INCL)\xwindowp.h \
#		$(INCL)\xwindow.h $(CONFIG_H) $(INCL)\lint.h \
#		$(INCL)\winX.h $(INCL)\color.h $(INCL)\wintype.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\Window.c
$(OGUI)dialogs.o: ..\win\X11\dialogs.c $(CONFIG_H) $(INCL)\lint.h \
		$(INCL)\winX.h $(INCL)\color.h $(INCL)\wintype.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\dialogs.c
$(OGUI)winX.o: ..\win\X11\winX.c $(HACK_H) $(INCL)\winX.h \
		$(INCL)\dlb.h $(INCL)\xwindow.h ..\win\X11\nh72icon \
		..\win\X11\nh56icon ..\win\X11\nh32icon
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winX.c
$(OGUI)winmap.o: ..\win\X11\winmap.c $(INCL)\xwindow.h $(HACK_H) \
		$(INCL)\dlb.h $(INCL)\winX.h $(INCL)\tile2x11.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winmap.c
$(OGUI)winmenu.o: ..\win\X11\winmenu.c $(HACK_H) $(INCL)\winX.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winmenu.c
$(OGUI)winmesg.o: ..\win\X11\winmesg.c $(INCL)\xwindow.h $(HACK_H) \
		$(INCL)\winX.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winmesg.c
$(OGUI)winmisc.o: ..\win\X11\winmisc.c $(HACK_H) $(INCL)\func_tab.h \
		$(INCL)\winX.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winmisc.c
$(OGUI)winstat.o: ..\win\X11\winstat.c $(HACK_H) $(INCL)\winX.h \
		$(INCL)\xwindow.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winstat.c
$(OGUI)wintext.o: ..\win\X11\wintext.c $(HACK_H) $(INCL)\winX.h \
		$(INCL)\xwindow.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\wintext.c
$(OGUI)winval.o: ..\win\X11\winval.c $(HACK_H) $(INCL)\winX.h
#	$(TARGET_CC) $(TARGET_CFLAGS) $(X11CFLAGS) -Fo$@ ..\win\X11\winval.c
#$(OGUI)tile.o: tile.c $(HACK_H)
$(OGUI)winshim.o: ..\win\shim\winshim.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\shim\winshim.c
#$(OGUI)cppregex.o: ..\sys\share\cppregex.cpp $(CONFIG_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\sys\share\cppregex.cpp
$(OGUI)qt_bind.o: ..\win\Qt\qt_bind.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h \
		..\win\Qt\qt_kde0.h ..\win\Qt\qt_click.h ..\win\Qt\qt_delay.h \
		..\win\Qt\qt_xcmd.h ..\win\Qt\qt_key.h ..\win\Qt\qt_map.h \
		..\win\Qt\qt_win.h ..\win\Qt\qt_clust.h ..\win\Qt\qt_menu.h \
		..\win\Qt\qt_rip.h ..\win\Qt\qt_msg.h ..\win\Qt\qt_plsel.h \
		..\win\Qt\qt_svsel.h ..\win\Qt\qt_set.h ..\win\Qt\qt_stat.h \
		..\win\Qt\qt_icon.h ..\win\Qt\qt_streq.h ..\win\Qt\qt_line.h \
		..\win\Qt\qt_yndlg.h ..\win\Qt\qt_str.h $(INCL)\dlb.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_bind.cpp
$(OGUI)qt_click.o: ..\win\Qt\qt_click.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_click.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_click.cpp
$(OGUI)qt_clust.o: ..\win\Qt\qt_clust.cpp ..\win\Qt\qt_clust.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_clust.cpp
$(OGUI)qt_delay.o: ..\win\Qt\qt_delay.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_delay.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_delay.cpp
$(OGUI)qt_glyph.o: ..\win\Qt\qt_glyph.cpp $(HACK_H) \
		$(INCL)\tile2x11.h ..\win\Qt\qt_pre.h ..\win\Qt\qt_post.h \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h \
		..\win\Qt\qt_kde0.h ..\win\Qt\qt_set.h ..\win\Qt\qt_inv.h \
		..\win\Qt\qt_map.h ..\win\Qt\qt_win.h ..\win\Qt\qt_clust.h \
		..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_glyph.cpp
$(OGUI)qt_icon.o: ..\win\Qt\qt_icon.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_icon.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_icon.cpp
$(OGUI)qt_inv.o: ..\win\Qt\qt_inv.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_inv.h ..\win\Qt\qt_glyph.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_set.h \
		..\win\Qt\qt_bind.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_inv.cpp
$(OGUI)qt_key.o: ..\win\Qt\qt_key.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_key.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_key.cpp
$(OGUI)qt_line.o: ..\win\Qt\qt_line.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_line.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_line.cpp
$(OGUI)qt_main.o: ..\win\Qt\qt_main.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h \
		qt_main.moc ..\win\Qt\qt_bind.h ..\win\Qt\qt_glyph.h \
		..\win\Qt\qt_inv.h ..\win\Qt\qt_key.h ..\win\Qt\qt_map.h \
		..\win\Qt\qt_win.h ..\win\Qt\qt_clust.h ..\win\Qt\qt_msg.h \
		..\win\Qt\qt_set.h ..\win\Qt\qt_stat.h ..\win\Qt\qt_icon.h \
		..\win\Qt\qt_str.h qt_kde0.moc $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_main.cpp
$(OGUI)qt_map.o: ..\win\Qt\qt_map.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_map.h ..\win\Qt\qt_win.h \
		..\win\Qt\qt_clust.h qt_map.moc ..\win\Qt\qt_click.h \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_map.cpp
$(OGUI)qt_menu.o: ..\win\Qt\qt_menu.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_menu.h ..\win\Qt\qt_win.h \
		..\win\Qt\qt_rip.h qt_menu.moc ..\win\Qt\qt_key.h \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_streq.h \
		..\win\Qt\qt_line.h ..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_menu.cpp
$(OGUI)qt_msg.o: ..\win\Qt\qt_msg.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_msg.h ..\win\Qt\qt_win.h \
		qt_msg.moc ..\win\Qt\qt_map.h ..\win\Qt\qt_clust.h \
		..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h \
		..\win\Qt\qt_kde0.h ..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_msg.cpp
$(OGUI)qt_plsel.o: ..\win\Qt\qt_plsel.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_plsel.h qt_plsel.moc \
		..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_set.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_plsel.cpp
$(OGUI)qt_rip.o: ..\win\Qt\qt_rip.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_rip.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_rip.cpp
$(OGUI)qt_set.o: ..\win\Qt\qt_set.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h qt_set.moc \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_xcmd.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_set.cpp
$(OGUI)qt_stat.o: ..\win\Qt\qt_stat.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_stat.h ..\win\Qt\qt_win.h \
		..\win\Qt\qt_icon.h qt_stat.moc ..\win\Qt\qt_set.h \
		..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h \
		..\win\Qt\qt_str.h ..\win\Qt\qt_xpms.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_stat.cpp
$(OGUI)qt_str.o: ..\win\Qt\qt_str.cpp ..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_str.cpp
$(OGUI)qt_streq.o: ..\win\Qt\qt_streq.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_streq.h ..\win\Qt\qt_line.h \
		..\win\Qt\qt_str.h ..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_streq.cpp
$(OGUI)qt_svsel.o: ..\win\Qt\qt_svsel.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_svsel.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_str.h \
		$(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_svsel.cpp
$(OGUI)qt_win.o: ..\win\Qt\qt_win.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_win.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_click.h \
		..\win\Qt\qt_glyph.h ..\win\Qt\qt_inv.h ..\win\Qt\qt_key.h \
		..\win\Qt\qt_icon.h ..\win\Qt\qt_map.h ..\win\Qt\qt_clust.h \
		..\win\Qt\qt_menu.h ..\win\Qt\qt_rip.h ..\win\Qt\qt_msg.h \
		..\win\Qt\qt_set.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_win.cpp
$(OGUI)qt_xcmd.o: ..\win\Qt\qt_xcmd.cpp $(HACK_H) $(INCL)\func_tab.h \
		..\win\Qt\qt_pre.h ..\win\Qt\qt_post.h ..\win\Qt\qt_xcmd.h \
		qt_xcmd.moc ..\win\Qt\qt_key.h ..\win\Qt\qt_bind.h \
		..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h ..\win\Qt\qt_set.h \
		..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_xcmd.cpp
$(OGUI)qt_yndlg.o: ..\win\Qt\qt_yndlg.cpp $(HACK_H) ..\win\Qt\qt_pre.h \
		..\win\Qt\qt_post.h ..\win\Qt\qt_yndlg.h qt_yndlg.moc \
		..\win\Qt\qt_key.h ..\win\Qt\qt_str.h $(QTn_H)
#	$(TARGET_CXX) $(TARGET_CXXFLAGS) -Fo$@ ..\win\Qt\qt_yndlg.cpp
qt_kde0.moc: ..\win\Qt\qt_kde0.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_kde0.h
qt_main.moc: ..\win\Qt\qt_main.h ..\win\Qt\qt_kde0.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_main.h
qt_map.moc: ..\win\Qt\qt_map.h ..\win\Qt\qt_win.h ..\win\Qt\qt_clust.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_map.h
qt_menu.moc: ..\win\Qt\qt_menu.h ..\win\Qt\qt_win.h ..\win\Qt\qt_rip.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_menu.h
qt_msg.moc: ..\win\Qt\qt_msg.h ..\win\Qt\qt_win.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_msg.h
qt_plsel.moc: ..\win\Qt\qt_plsel.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_plsel.h
qt_set.moc: ..\win\Qt\qt_set.h ..\win\Qt\qt_bind.h ..\win\Qt\qt_main.h \
		..\win\Qt\qt_kde0.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_set.h
qt_stat.moc: ..\win\Qt\qt_stat.h ..\win\Qt\qt_win.h ..\win\Qt\qt_icon.h \
		$(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_stat.h
qt_xcmd.moc: ..\win\Qt\qt_xcmd.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_xcmd.h
qt_yndlg.moc: ..\win\Qt\qt_yndlg.h $(QTn_H)
	$(MOCPATH)  ..\win\Qt\qt_yndlg.h
#$(OGUI)tile.o: tile.c $(HACK_H)
$(OGUI)wc_chainin.o: ..\win\chain\wc_chainin.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\chain\wc_chainin.c
$(OGUI)wc_chainout.o: ..\win\chain\wc_chainout.c $(HACK_H)
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\chain\wc_chainout.c
$(OGUI)wc_trace.o: ..\win\chain\wc_trace.c $(HACK_H) $(INCL)\wintty.h \
		$(INCL)\func_tab.h
#	$(TARGET_CC) $(TARGET_CFLAGS) -Fo$@ ..\win\chain\wc_trace.c
$(OGUI)allmain.o: allmain.c $(HACK_H)
$(OGUI)alloc.o: alloc.c $(CONFIG_H) $(INCL)\nhlua.h
$(OGUI)apply.o: apply.c $(HACK_H)
$(OGUI)artifact.o: artifact.c $(HACK_H) $(INCL)\artifact.h
$(OGUI)attrib.o: attrib.c $(HACK_H)
$(OGUI)ball.o: ball.c $(HACK_H)
$(OGUI)bones.o: bones.c $(HACK_H)
$(OGUI)botl.o: botl.c $(HACK_H)
$(OGUI)cmd.o: cmd.c $(HACK_H) $(INCL)\func_tab.h
$(OGUI)dbridge.o: dbridge.c $(HACK_H)
$(OGUI)decl.o: decl.c $(HACK_H)
$(OGUI)detect.o: detect.c $(HACK_H) $(INCL)\artifact.h
$(OGUI)dig.o: dig.c $(HACK_H)
$(OGUI)display.o: display.c $(HACK_H)
$(OGUI)dlb.o: dlb.c $(CONFIG_H) $(INCL)\dlb.h
$(OGUI)do.o: do.c $(HACK_H)
$(OGUI)do_name.o: do_name.c $(HACK_H)
$(OGUI)do_wear.o: do_wear.c $(HACK_H)
$(OGUI)dog.o: dog.c $(HACK_H)
$(OGUI)dogmove.o: dogmove.c $(HACK_H) $(INCL)\mfndpos.h
$(OGUI)dokick.o: dokick.c $(HACK_H)
$(OGUI)dothrow.o: dothrow.c $(HACK_H)
$(OGUI)drawing.o: drawing.c $(CONFIG_H) $(INCL)\color.h \
		$(INCL)\rm.h $(INCL)\objclass.h $(INCL)\defsym.h \
		$(INCL)\objects.h $(INCL)\wintype.h $(INCL)\sym.h
$(OGUI)dungeon.o: dungeon.c $(HACK_H) $(INCL)\dgn_file.h \
		$(INCL)\dlb.h
$(OGUI)eat.o: eat.c $(HACK_H)
$(OGUI)end.o: end.c $(HACK_H) $(INCL)\dlb.h
$(OGUI)engrave.o: engrave.c $(HACK_H)
$(OGUI)exper.o: exper.c $(HACK_H)
$(OGUI)explode.o: explode.c $(HACK_H)
$(OGUI)extralev.o: extralev.c $(HACK_H)
$(OGUI)files.o: files.c $(HACK_H) $(INCL)\dlb.h $(INCL)\wintty.h \
		#zlib.h
$(OGUI)fountain.o: fountain.c $(HACK_H)
$(OGUI)hack.o: hack.c $(HACK_H)
$(OGUI)hacklib.o: hacklib.c $(HACK_H)
$(OGUI)insight.o: insight.c $(HACK_H)
$(OGUI)invent.o: invent.c $(HACK_H)
$(OGUI)isaac64.o: isaac64.c $(CONFIG_H) $(INCL)\isaac64.h
$(OGUI)light.o: light.c $(HACK_H)
$(OGUI)lock.o: lock.c $(HACK_H)
$(OGUI)mail.o: mail.c $(HACK_H) $(INCL)\mail.h
$(OGUI)makemon.o: makemon.c $(HACK_H)
$(OGUI)mcastu.o: mcastu.c $(HACK_H)
$(OGUI)mdlib.o: mdlib.c $(CONFIG_H) $(INCL)\permonst.h \
		$(INCL)\align.h $(INCL)\monattk.h $(INCL)\monflag.h \
		$(INCL)\monsters.h $(INCL)\objclass.h \
		$(INCL)\defsym.h $(INCL)\objects.h $(INCL)\wintype.h \
		$(INCL)\sym.h $(INCL)\artilist.h $(INCL)\dungeon.h \
		$(INCL)\sndprocs.h $(INCL)\seffects.h $(INCL)\obj.h \
		$(INCL)\monst.h $(INCL)\mextra.h $(INCL)\you.h \
		$(INCL)\attrib.h $(INCL)\prop.h $(INCL)\skills.h \
		$(INCL)\context.h $(INCL)\flag.h $(INCL)\dlb.h
$(OGUI)mhitm.o: mhitm.c $(HACK_H) $(INCL)\artifact.h
$(OGUI)mhitu.o: mhitu.c $(HACK_H) $(INCL)\artifact.h
$(OGUI)minion.o: minion.c $(HACK_H)
$(OGUI)mklev.o: mklev.c $(HACK_H)
$(OGUI)mkmap.o: mkmap.c $(HACK_H) $(INCL)\sp_lev.h
$(OGUI)mkmaze.o: mkmaze.c $(HACK_H) $(INCL)\sp_lev.h
$(OGUI)mkobj.o: mkobj.c $(HACK_H)
$(OGUI)mkroom.o: mkroom.c $(HACK_H)
$(OGUI)mon.o: mon.c $(HACK_H) $(INCL)\mfndpos.h
$(OGUI)mondata.o: mondata.c $(HACK_H)
$(OGUI)monmove.o: monmove.c $(HACK_H) $(INCL)\mfndpos.h \
		$(INCL)\artifact.h
$(OGUI)monst.o: monst.c $(CONFIG_H) $(INCL)\permonst.h \
		$(INCL)\align.h $(INCL)\monattk.h $(INCL)\monflag.h \
		$(INCL)\monsters.h $(INCL)\wintype.h $(INCL)\sym.h \
		$(INCL)\defsym.h $(INCL)\color.h
$(OGUI)mplayer.o: mplayer.c $(HACK_H)
$(OGUI)mthrowu.o: mthrowu.c $(HACK_H)
$(OGUI)muse.o: muse.c $(HACK_H)
$(OGUI)music.o: music.c $(HACK_H)
$(OGUI)nhlua.o: nhlua.c $(HACK_H) $(INCL)\dlb.h
	$(Q)$(CC) $(CFLAGS) $(GUIDEF) -wd4324 $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $(@B).c
$(OGUI)nhlsel.o: nhlsel.c $(HACK_H) $(INCL)\sp_lev.h
$(OGUI)nhlobj.o: nhlobj.c $(HACK_H) $(INCL)\sp_lev.h
$(OGUI)o_init.o: o_init.c $(HACK_H)
$(OGUI)objects.o: objects.c $(CONFIG_H) $(INCL)\obj.h \
		$(INCL)\prop.h $(INCL)\skills.h $(INCL)\color.h \
		$(INCL)\objclass.h $(INCL)\defsym.h $(INCL)\objects.h
$(OGUI)objnam.o: objnam.c $(HACK_H)
$(OGUI)options.o: options.c $(CONFIG_H) $(INCL)\objclass.h \
		$(INCL)\defsym.h $(INCL)\objects.h $(INCL)\flag.h \
		$(HACK_H) $(INCL)\tcap.h $(INCL)\optlist.h
$(OGUI)pager.o: pager.c $(HACK_H) $(INCL)\dlb.h
$(OGUI)pickup.o: pickup.c $(HACK_H)
$(OGUI)pline.o: pline.c $(HACK_H)
$(OGUI)polyself.o: polyself.c $(HACK_H)
$(OGUI)potion.o: potion.c $(HACK_H)
$(OGUI)pray.o: pray.c $(HACK_H)
$(OGUI)priest.o: priest.c $(HACK_H) $(INCL)\mfndpos.h
$(OGUI)quest.o: quest.c $(HACK_H)
$(OGUI)questpgr.o: questpgr.c $(HACK_H) $(INCL)\dlb.h \
		$(INCL)\wintty.h
$(OGUI)read.o: read.c $(HACK_H)
$(OGUI)rect.o: rect.c $(HACK_H)
$(OGUI)region.o: region.c $(HACK_H)
$(OGUI)restore.o: restore.c $(HACK_H) $(INCL)\tcap.h
$(OGUI)rip.o: rip.c $(HACK_H)
$(OGUI)rnd.o: rnd.c $(HACK_H) $(INCL)\isaac64.h
$(OGUI)role.o: role.c $(HACK_H)
$(OGUI)rumors.o: rumors.c $(HACK_H) $(INCL)\dlb.h
$(OGUI)save.o: save.c $(HACK_H)
$(OGUI)sfstruct.o: sfstruct.c $(HACK_H)
$(OGUI)shk.o: shk.c $(HACK_H)
$(OGUI)shknam.o: shknam.c $(HACK_H)
$(OGUI)sit.o: sit.c $(HACK_H) $(INCL)\artifact.h
$(OGUI)sounds.o: sounds.c $(HACK_H)
$(OGUI)sp_lev.o: sp_lev.c $(HACK_H) $(INCL)\sp_lev.h
$(OGUI)spell.o: spell.c $(HACK_H)
$(OGUI)steal.o: steal.c $(HACK_H)
$(OGUI)steed.o: steed.c $(HACK_H)
$(OGUI)symbols.o: symbols.c $(HACK_H) $(INCL)\tcap.h
$(OGUI)sys.o: sys.c $(HACK_H)
$(OGUI)teleport.o: teleport.c $(HACK_H)
$(OGUI)timeout.o: timeout.c $(HACK_H)
$(OGUI)topten.o: topten.c $(HACK_H) $(INCL)\dlb.h
$(OGUI)track.o: track.c $(HACK_H)
$(OGUI)trap.o: trap.c $(HACK_H)
$(OGUI)u_init.o: u_init.c $(HACK_H)
$(OGUI)utf8map.o: utf8map.c $(HACK_H)
$(OGUI)uhitm.o: uhitm.c $(HACK_H)
$(OGUI)vault.o: vault.c $(HACK_H)
$(OGUI)version.o: version.c $(HACK_H) $(INCL)\dlb.h
$(OGUI)vision.o: vision.c $(HACK_H)
$(OGUI)weapon.o: weapon.c $(HACK_H)
$(OGUI)were.o: were.c $(HACK_H)
$(OGUI)wield.o: wield.c $(HACK_H)
$(OGUI)windows.o: windows.c $(HACK_H) $(INCL)\dlb.h $(INCL)\wintty.h
$(OGUI)wizard.o: wizard.c $(HACK_H)
$(OGUI)worm.o: worm.c $(HACK_H)
$(OGUI)worn.o: worn.c $(HACK_H)
$(OGUI)write.o: write.c $(HACK_H)
$(OGUI)zap.o: zap.c $(HACK_H)
# DEPENDENCIES MUST END AT END OF FILE
