# Makefile for Windows version of Golly using wxWidgets (3.1.5 or later is required).
#
# Use local-win-template.mk to create local-win.mk with paths to your installed libraries.
#
# Compile wxWidgets and Golly as below:
#
# On 32-bit Windows: (from a Visual Studio command prompt)
#
#   Build wxWidgets:
#    cd \wxWidgets\build\msw
#    nmake -f makefile.vc BUILD=release RUNTIME_LIBS=static DEBUG_INFO=0 DEBUG_FLAG=0 UNICODE=1 USE_OPENGL=1
#   Build Golly:
#    cd \golly\gui-wx
#    nmake -f makefile-win BUILD=release RUNTIME_LIBS=static DEBUG_INFO=0 DEBUG_FLAG=0 UNICODE=1 USE_OPENGL=1
#
# On 64-bit Windows: (from a Visual Studio 64-bit command prompt)
#
#   Build wxWidgets:
#    cd \wxWidgets\build\msw
#    nmake -f makefile.vc BUILD=release RUNTIME_LIBS=static DEBUG_INFO=0 DEBUG_FLAG=0 UNICODE=1 USE_OPENGL=1 TARGET_CPU=X64
#   Build Golly:
#    cd \golly\gui-wx
#    nmake -f makefile-win BUILD=release RUNTIME_LIBS=static DEBUG_INFO=0 DEBUG_FLAG=0 UNICODE=1 USE_OPENGL=1 TARGET_CPU=X64
# 
# If you only build one wxWidgets configuration (e.g. a 32-bit release) then you can edit
# \wxWidgets\build\msw\config.vc and set all those options. Then you can build wxWidgets and Golly
# simply with:
#
#   Build wxWidgets:
#    cd \wxWidgets\build\msw
#    nmake -f makefile.vc
#   Build Golly:
#    cd \golly\gui-wx
#    nmake -f makefile-win

#   All system-dependent changes belong in local-win.mk
!include local-win.mk

### Golly-related variables: ###

APP_VERSION = 4.3

# these directory paths are relative to the location of this makefile:
EXEDIR = ..
DOCSDIR = ..\docs
BASEDIR = ..\gollybase
CMDDIR = ..\cmdline
LUADIR = ..\lua
SOUNDDIR = ..\sound

!if "$(ENABLE_SOUND)" == "1"
SOUND_FLAGS = /I$(SOUNDDIR) /DENABLE_SOUND
SOUND_LIB = dsound.lib
!endif

# for building binary and source distributions:
RELEASENAME = $(EXEDIR)\golly-$(APP_VERSION)
GUIFILES = makefile-gtk makefile-mac makefile-win local-win-template.mk local-gtk-template.mk \
   golly.rc Info.plist.in wx*.h wx*.cpp
GUIDIRS = bitmaps icons
LUAFILES = $(LUADIR)\*.h $(LUADIR)\*.c $(LUADIR)\*.hpp $(LUADIR)\Makefile $(LUADIR)\ReadMe.html
SOUNDFILES = $(SOUNDDIR)\cute_sound.h $(SOUNDDIR)\stb_vorbis.c
BINFILES = $(EXEDIR)\Golly.exe $(EXEDIR)\bgolly.exe $(DOCSDIR)\ReadMe.html $(DOCSDIR)\License.html

!if "$(TARGET_CPU)" == "X64"
LIBDIRNAME = $(WX_DIR)\lib\vc_x64_$(LIBTYPE_SUFFIX)$(CFG)
WX_CPU_DEF = WX_CPU_AMD64   # ensures include/wx/msw/amd64.manifest is included in golly.res
BINNAME = $(RELEASENAME)-win-64bit
!else
LIBDIRNAME = $(WX_DIR)\lib\vc_$(LIBTYPE_SUFFIX)$(CFG)
WX_CPU_DEF = WX_CPU_X86
BINNAME = $(RELEASENAME)-win-32bit
!endif

SETUPHDIR = $(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)

### note that /wd4100 turns off annoying warnings about "unreferenced formal parameter"
### in wx 2.9 when debugging assertions are disabled
CXXFLAGS = /M$(__RUNTIME_LIBS_8)$(__DEBUGRUNTIME_3) /DWIN32 \
	$(__DEBUGINFO_0) /Fdgolly.pdb $(____DEBUGRUNTIME_2_p) \
	$(__OPTIMIZEFLAG_4) $(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) \
	$(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
	$(__THREAD_DEFINE_p) $(__UNICODE_DEFINE_p) /I$(WX_DIR)\include /I$(SETUPHDIR) \
	/W4 /wd4100 /I. $(__DLLFLAG_p) /D_WINDOWS /I$(WX_DIR)\samples /DNOPCH $(__RTTIFLAG_9) \
	$(__EXCEPTIONSFLAG_10) $(CPPFLAGS) \
	/D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS \
	/EHsc /DVERSION=$(APP_VERSION) /DZLIB /I$(WX_DIR)\src\zlib /I$(BASEDIR) $(EXTRACXXFLAGS) $(SOUND_FLAGS) \
	/wd4459 /wd4458 /wd4457 /wd4456

LDFLAGS = /STACK:32000000

OBJDIR = ObjWin
BASEH = $(BASEDIR)/bigint.h $(BASEDIR)/ghashbase.h $(BASEDIR)/hlifealgo.h $(BASEDIR)/jvnalgo.h \
    $(BASEDIR)/platform.h $(BASEDIR)/lifealgo.h $(BASEDIR)/lifepoll.h $(BASEDIR)/liferender.h $(BASEDIR)/liferules.h \
    $(BASEDIR)/qlifealgo.h $(BASEDIR)/ltlalgo.h $(BASEDIR)/readpattern.h $(BASEDIR)/util.h $(BASEDIR)/viewport.h \
    $(BASEDIR)/writepattern.h $(BASEDIR)/ruletreealgo.h $(BASEDIR)/generationsalgo.h $(BASEDIR)/ruletable_algo.h \
    $(BASEDIR)/ruleloaderalgo.h $(BASEDIR)/superalgo.h
BASEO = $(OBJDIR)/bigint.obj $(OBJDIR)/lifealgo.obj $(OBJDIR)/hlifealgo.obj \
    $(OBJDIR)/hlifedraw.obj $(OBJDIR)/qlifealgo.obj $(OBJDIR)/qlifedraw.obj \
    $(OBJDIR)/ltlalgo.obj $(OBJDIR)/ltldraw.obj $(OBJDIR)/jvnalgo.obj $(OBJDIR)/ruletreealgo.obj \
    $(OBJDIR)/ruletable_algo.obj $(OBJDIR)/ghashbase.obj $(OBJDIR)/ruleloaderalgo.obj \
    $(OBJDIR)/ghashdraw.obj $(OBJDIR)/readpattern.obj \
    $(OBJDIR)/writepattern.obj $(OBJDIR)/liferules.obj $(OBJDIR)/util.obj \
    $(OBJDIR)/liferender.obj $(OBJDIR)/viewport.obj $(OBJDIR)/lifepoll.obj \
    $(OBJDIR)/generationsalgo.obj $(OBJDIR)/superalgo.obj
WXH = wxalgos.h wxedit.h wxgolly.h wxhelp.h wxinfo.h wxlayer.h wxmain.h wxprefs.h \
    wxlua.h wxpython.h wxrender.h wxrule.h wxscript.h wxselect.h wxstatus.h \
    wxtimeline.h wxundo.h wxutils.h wxview.h wxoverlay.h
WXO = $(OBJDIR)/wxutils.obj $(OBJDIR)/wxprefs.obj $(OBJDIR)/wxalgos.obj \
    $(OBJDIR)/wxrule.obj $(OBJDIR)/wxinfo.obj $(OBJDIR)/wxhelp.obj \
    $(OBJDIR)/wxstatus.obj $(OBJDIR)/wxview.obj $(OBJDIR)/wxoverlay.obj $(OBJDIR)/wxrender.obj \
    $(OBJDIR)/wxscript.obj $(OBJDIR)/wxlua.obj $(OBJDIR)/wxpython.obj \
    $(OBJDIR)/wxfile.obj $(OBJDIR)/wxedit.obj $(OBJDIR)/wxcontrol.obj \
    $(OBJDIR)/wxtimeline.obj $(OBJDIR)/wxundo.obj $(OBJDIR)/wxlayer.obj \
    $(OBJDIR)/wxmain.obj $(OBJDIR)/wxselect.obj $(OBJDIR)/wxgolly.obj
LUAO = $(LUADIR)\lapi.obj \
    $(LUADIR)\lauxlib.obj \
    $(LUADIR)\lbaselib.obj \
    $(LUADIR)\lcode.obj \
    $(LUADIR)\lcorolib.obj \
    $(LUADIR)\lctype.obj \
    $(LUADIR)\ldblib.obj \
    $(LUADIR)\ldebug.obj \
    $(LUADIR)\ldo.obj \
    $(LUADIR)\ldump.obj \
    $(LUADIR)\lfunc.obj \
    $(LUADIR)\lgc.obj \
    $(LUADIR)\linit.obj \
    $(LUADIR)\liolib.obj \
    $(LUADIR)\llex.obj \
    $(LUADIR)\lmathlib.obj \
    $(LUADIR)\lmem.obj \
    $(LUADIR)\loadlib.obj \
    $(LUADIR)\lobject.obj \
    $(LUADIR)\lopcodes.obj \
    $(LUADIR)\loslib.obj \
    $(LUADIR)\lparser.obj \
    $(LUADIR)\lstate.obj \
    $(LUADIR)\lstring.obj \
    $(LUADIR)\lstrlib.obj \
    $(LUADIR)\ltable.obj \
    $(LUADIR)\ltablib.obj \
    $(LUADIR)\ltm.obj \
    $(LUADIR)\lundump.obj \
    $(LUADIR)\lutf8lib.obj \
    $(LUADIR)\lvm.obj \
    $(LUADIR)\lzio.obj \
    $(LUADIR)\utf8_wrappers.obj

### Conditionally set variables: ###

PORTNAME = msw
!if "$(BUILD)" == "debug" && "$(DEBUG_FLAG)" == "default"
WXDEBUGFLAG = d
!endif
!if "$(DEBUG_FLAG)" == "1"
WXDEBUGFLAG = d
!endif
!if "$(UNICODE)" == "1"
WXUNICODEFLAG = u
!endif
!if "$(WXUNIV)" == "1"
WXUNIVNAME = univ
!endif
!if "$(SHARED)" == "1"
WXDLLFLAG = dll
!endif
!if "$(SHARED)" == "0"
LIBTYPE_SUFFIX = lib
!endif
!if "$(SHARED)" == "1"
LIBTYPE_SUFFIX = dll
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_0 = /Zi
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_0 = 
!endif
!if "$(DEBUG_INFO)" == "0"
__DEBUGINFO_0 = 
!endif
!if "$(DEBUG_INFO)" == "1"
__DEBUGINFO_0 = /Zi
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_1 = /DEBUG
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_1 = 
!endif
!if "$(DEBUG_INFO)" == "0"
__DEBUGINFO_1 = 
!endif
!if "$(DEBUG_INFO)" == "1"
__DEBUGINFO_1 = /DEBUG
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
____DEBUGRUNTIME_2_p = /D_DEBUG
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
____DEBUGRUNTIME_2_p = 
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
____DEBUGRUNTIME_2_p = 
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
____DEBUGRUNTIME_2_p = /D_DEBUG
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
____DEBUGRUNTIME_2_p_1 = /d _DEBUG
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
____DEBUGRUNTIME_2_p_1 = 
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
____DEBUGRUNTIME_2_p_1 = 
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
____DEBUGRUNTIME_2_p_1 = /d _DEBUG
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
__DEBUGRUNTIME_3 = d
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
__DEBUGRUNTIME_3 = 
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
__DEBUGRUNTIME_3 = 
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
__DEBUGRUNTIME_3 = d
!endif
!if "$(BUILD)" == "debug"
__OPTIMIZEFLAG_4 = /Od
!endif
!if "$(BUILD)" == "release"
__OPTIMIZEFLAG_4 = /O2
!endif
!if "$(USE_THREADS)" == "0"
__THREADSFLAG_7 = L
!endif
!if "$(USE_THREADS)" == "1"
__THREADSFLAG_7 = T
!endif
!if "$(RUNTIME_LIBS)" == "dynamic"
__RUNTIME_LIBS_8 = D
!endif
!if "$(RUNTIME_LIBS)" == "static"
__RUNTIME_LIBS_8 = $(__THREADSFLAG_7)
!endif
!if "$(USE_RTTI)" == "0"
__RTTIFLAG_9 = 
!endif
!if "$(USE_RTTI)" == "1"
__RTTIFLAG_9 = /GR
!endif
!if "$(USE_EXCEPTIONS)" == "0"
__EXCEPTIONSFLAG_10 = 
!endif
!if "$(USE_EXCEPTIONS)" == "1"
__EXCEPTIONSFLAG_10 = /EHsc
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
__NO_VC_CRTDBG_p = /D__NO_VC_CRTDBG__
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_FLAG)" == "1"
__NO_VC_CRTDBG_p = /D__NO_VC_CRTDBG__
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
__NO_VC_CRTDBG_p_1 = /d __NO_VC_CRTDBG__
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_FLAG)" == "1"
__NO_VC_CRTDBG_p_1 = /d __NO_VC_CRTDBG__
!endif
!if "$(WXUNIV)" == "1"
__WXUNIV_DEFINE_p = /D__WXUNIVERSAL__
!endif
!if "$(WXUNIV)" == "1"
__WXUNIV_DEFINE_p_1 = /d __WXUNIVERSAL__
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_FLAG)" == "default"
__DEBUG_DEFINE_p = /D__WXDEBUG__
!endif
!if "$(DEBUG_FLAG)" == "1"
__DEBUG_DEFINE_p = /D__WXDEBUG__
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_FLAG)" == "default"
__DEBUG_DEFINE_p_1 = /d __WXDEBUG__
!endif
!if "$(DEBUG_FLAG)" == "1"
__DEBUG_DEFINE_p_1 = /d __WXDEBUG__
!endif


### following is needed for wxMSW 2.9.x
!if "$(DEBUG_FLAG)" == "0"
__DEBUG_DEFINE_p = /DwxDEBUG_LEVEL=0
!endif
!if "$(DEBUG_FLAG)" == "0"
__DEBUG_DEFINE_p_1 = /d wxDEBUG_LEVEL=0
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
__NDEBUG_DEFINE_p = /DNDEBUG
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
__NDEBUG_DEFINE_p = /DNDEBUG
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
__NDEBUG_DEFINE_p_1 = /d NDEBUG
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
__NDEBUG_DEFINE_p_1 = /d NDEBUG
!endif


!if "$(USE_EXCEPTIONS)" == "0"
__EXCEPTIONS_DEFINE_p = /DwxNO_EXCEPTIONS
!endif
!if "$(USE_EXCEPTIONS)" == "0"
__EXCEPTIONS_DEFINE_p_1 = /d wxNO_EXCEPTIONS
!endif
!if "$(USE_RTTI)" == "0"
__RTTI_DEFINE_p = /DwxNO_RTTI
!endif
!if "$(USE_RTTI)" == "0"
__RTTI_DEFINE_p_1 = /d wxNO_RTTI
!endif
!if "$(USE_THREADS)" == "0"
__THREAD_DEFINE_p = /DwxNO_THREADS
!endif
!if "$(USE_THREADS)" == "0"
__THREAD_DEFINE_p_1 = /d wxNO_THREADS
!endif
!if "$(UNICODE)" == "1"
__UNICODE_DEFINE_p = /D_UNICODE
!endif
!if "$(UNICODE)" == "1"
__UNICODE_DEFINE_p_1 = /d _UNICODE
!endif
!if "$(SHARED)" == "1"
__DLLFLAG_p = /DWXUSINGDLL
!endif
!if "$(SHARED)" == "1"
__DLLFLAG_p_1 = /d WXUSINGDLL
!endif
!if "$(MONOLITHIC)" == "0"
__WXLIB_HTML_p = \
	wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_html.lib
!endif
!if "$(MONOLITHIC)" == "0"
__WXLIB_ADV_p = \
	wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_adv.lib
!endif
!if "$(MONOLITHIC)" == "0"
__WXLIB_CORE_p = \
	wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core.lib
!endif
!if "$(MONOLITHIC)" == "0"
__WXLIB_BASE_p = \
	wxbase$(WX_RELEASE)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR).lib
!endif
!if "$(MONOLITHIC)" == "0"
__WXLIB_NET_p = \
	wxbase$(WX_RELEASE)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net.lib
!endif
!if "$(MONOLITHIC)" == "1"
__WXLIB_MONO_p = \
	wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR).lib
!endif
!if "$(MSLU)" == "1"
__UNICOWS_LIB_p = unicows.lib
!endif

__LIB_TIFF_p = wxtiff$(WXDEBUGFLAG).lib
__LIB_JPEG_p = wxjpeg$(WXDEBUGFLAG).lib
__LIB_PNG_p = wxpng$(WXDEBUGFLAG).lib

### Targets: ###

all: $(OBJDIR) $(EXEDIR)\Golly.exe $(EXEDIR)\bgolly.exe $(EXEDIR)\RuleTableToTree.exe

$(BASEO): $(BASEH)

$(WXO): $(BASEH) $(WXH) icons\*.ico bitmaps\*.xpm

$(LUAO):
	cd "$(LUADIR)"
	cl /MP8 /MT /O2 /c /nologo $(LUA_DEFS) *.c
	cd "$(MAKEDIR)"

$(OBJDIR):
	mkdir $(OBJDIR)

clean: 
	-if exist $(OBJDIR)\*.obj del $(OBJDIR)\*.obj
	-if exist *.res del *.res
	-if exist $(EXEDIR)\Golly.exe del $(EXEDIR)\Golly.exe
	-if exist $(EXEDIR)\bgolly.exe del $(EXEDIR)\bgolly.exe
	-if exist $(EXEDIR)\RuleTableToTree.exe del $(EXEDIR)\RuleTableToTree.exe
	-if exist golly.pdb del golly.pdb
	-if exist $(LUADIR)\*.obj del $(LUADIR)\*.obj

$(EXEDIR)\Golly.exe: $(BASEO) $(WXO) $(LUAO) golly.res
	link /LARGEADDRESSAWARE /NOLOGO /OUT:$(EXEDIR)\Golly.exe $(LDFLAGS) $(__DEBUGINFO_1) /pdb:"golly.pdb" \
	/MANIFEST:NO /LIBPATH:$(LIBDIRNAME) /SUBSYSTEM:WINDOWS $(BASEO) $(WXO) $(LUAO) golly.res \
	$(__WXLIB_HTML_p) $(__WXLIB_ADV_p) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_NET_p) \
	$(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib \
	wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib \
	wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib \
	$(__UNICOWS_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib \
	winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib \
	rpcrt4.lib advapi32.lib wsock32.lib wininet.lib opengl32.lib $(SOUND_LIB)

golly.res: golly.rc
	rc /fo$@ /d $(WX_CPU_DEF) /d WIN32 $(____DEBUGRUNTIME_2_p_1) $(__NO_VC_CRTDBG_p_1)  /d __WXMSW__ $(__WXUNIV_DEFINE_p_1) \
	$(__DEBUG_DEFINE_p_1) $(__NDEBUG_DEFINE_p_1) $(__EXCEPTIONS_DEFINE_p_1) $(__RTTI_DEFINE_p_1) $(__THREAD_DEFINE_p_1) \
	$(__UNICODE_DEFINE_p_1) /i $(WX_DIR)\include /i $(SETUPHDIR) /i . $(__DLLFLAG_p_1) /d _WINDOWS \
	/i $(WX_DIR)\samples /d NOPCH golly.rc

$(EXEDIR)\bgolly.exe: $(BASEO) $(OBJDIR)/bgolly.obj
	link /LARGEADDRESSAWARE /NOLOGO /OUT:$(EXEDIR)\bgolly.exe $(LDFLAGS) /LIBPATH:$(LIBDIRNAME) \
	$(OBJDIR)/bgolly.obj $(BASEO) wxzlib$(WXDEBUGFLAG).lib

$(EXEDIR)\RuleTableToTree.exe: $(BASEO) $(OBJDIR)/RuleTableToTree.obj
	link /LARGEADDRESSAWARE /NOLOGO /OUT:$(EXEDIR)\RuleTableToTree.exe $(LDFLAGS) /LIBPATH:$(LIBDIRNAME) \
	$(OBJDIR)/RuleTableToTree.obj $(BASEO) wxzlib$(WXDEBUGFLAG).lib

$(OBJDIR)/bgolly.obj: $(CMDDIR)/bgolly.cpp
	$(CXX) /c /nologo /Fo$@ $(CXXFLAGS) $(CMDDIR)/bgolly.cpp

$(OBJDIR)/RuleTableToTree.obj: $(CMDDIR)/RuleTableToTree.cpp
	$(CXX) /c /nologo /Fo$@ $(CXXFLAGS) $(CMDDIR)/RuleTableToTree.cpp

MBASEO = $(OBJDIR)/bigint.obj $(OBJDIR)/lifealgo.obj $(OBJDIR)/hlifealgo.obj \
    $(OBJDIR)/hlifedraw.obj $(OBJDIR)/qlifealgo.obj $(OBJDIR)/qlifedraw.obj \
    $(OBJDIR)/ltlalgo.obj $(OBJDIR)/ltldraw.obj $(OBJDIR)/jvnalgo.obj $(OBJDIR)/ruletreealgo.obj \
    $(OBJDIR)/ruletable_algo.obj $(OBJDIR)/ghashbase.obj $(OBJDIR)/ruleloaderalgo.obj \
    $(OBJDIR)/ghashdraw.obj $(OBJDIR)/readpattern.obj \
    $(OBJDIR)/writepattern.obj $(OBJDIR)/liferules.obj $(OBJDIR)/util.obj \
    $(OBJDIR)/liferender.obj $(OBJDIR)/viewport.obj $(OBJDIR)/lifepoll.obj \
    $(OBJDIR)/generationsalgo.obj $(OBJDIR)/superalgo.obj

MBASES = $(BASEDIR)/bigint.cpp $(BASEDIR)/lifealgo.cpp $(BASEDIR)/hlifealgo.cpp \
    $(BASEDIR)/hlifedraw.cpp $(BASEDIR)/qlifealgo.cpp $(BASEDIR)/qlifedraw.cpp \
    $(BASEDIR)/ltlalgo.cpp $(BASEDIR)/ltldraw.cpp $(BASEDIR)/jvnalgo.cpp $(BASEDIR)/ruletreealgo.cpp \
    $(BASEDIR)/ruletable_algo.cpp $(BASEDIR)/ghashbase.cpp $(BASEDIR)/ruleloaderalgo.cpp \
    $(BASEDIR)/ghashdraw.cpp $(BASEDIR)/readpattern.cpp \
    $(BASEDIR)/writepattern.cpp $(BASEDIR)/liferules.cpp $(BASEDIR)/util.cpp \
    $(BASEDIR)/liferender.cpp $(BASEDIR)/viewport.cpp $(BASEDIR)/lifepoll.cpp \
    $(BASEDIR)/generationsalgo.cpp $(BASEDIR)/superalgo.cpp

$(MBASEO): $(MBASES)
	-$(CXX) /MP8 /Fo$(OBJDIR)/ /c /nologo $(CXXFLAGS) $(MBASES)

MWXO = $(OBJDIR)/wxutils.obj $(OBJDIR)/wxprefs.obj $(OBJDIR)/wxalgos.obj \
    $(OBJDIR)/wxrule.obj $(OBJDIR)/wxinfo.obj $(OBJDIR)/wxhelp.obj \
    $(OBJDIR)/wxstatus.obj \
    $(OBJDIR)/wxedit.obj $(OBJDIR)/wxcontrol.obj \
    $(OBJDIR)/wxtimeline.obj $(OBJDIR)/wxundo.obj $(OBJDIR)/wxlayer.obj \
    $(OBJDIR)/wxselect.obj

MWXS = wxutils.cpp wxprefs.cpp wxalgos.cpp \
    wxrule.cpp wxinfo.cpp wxhelp.cpp \
    wxstatus.cpp \
    wxedit.cpp wxcontrol.cpp \
    wxtimeline.cpp wxundo.cpp wxlayer.cpp \
    wxselect.cpp

$(MWXO): $(MWXS)
	-$(CXX) /MP8 /Fo$(OBJDIR)/ /c /nologo $(CXXFLAGS) $(MWXS)

MWXLUAO = $(OBJDIR)/wxoverlay.obj $(OBJDIR)/wxlua.obj $(OBJDIR)/wxfile.obj \
	$(OBJDIR)/wxmain.obj $(OBJDIR)/wxrender.obj $(OBJDIR)/wxscript.obj \
	$(OBJDIR)/wxview.obj

MWXLUAS = wxoverlay.cpp wxlua.cpp wxfile.cpp wxmain.cpp \
	wxrender.cpp wxscript.cpp wxview.cpp

$(MWXLUAO): $(MWXLUAS)
	-$(CXX) /MP8 /Fo$(OBJDIR)/ /c /nologo $(CXXFLAGS) $(LUA_DEFS) /I$(LUADIR) $(MWXLUAS)

$(OBJDIR)/wxpython.obj: wxpython.cpp
	$(CXX) /c /nologo /Fo$@ $(CXXFLAGS) $(PYTHON_INCLUDE) wxpython.cpp

$(OBJDIR)/wxgolly.obj: wxgolly.cpp
	$(CXX) /c /TP /nologo /Fo$@ $(CXXFLAGS) wxgolly.cpp

srcdist:
	-rmdir /s /q $(RELEASENAME)-src
	mkdir $(RELEASENAME)-src
	mkdir $(RELEASENAME)-src\Help
	mkdir $(RELEASENAME)-src\Patterns
	mkdir $(RELEASENAME)-src\Rules
	mkdir $(RELEASENAME)-src\Scripts
	mkdir $(RELEASENAME)-src\docs
	mkdir $(RELEASENAME)-src\gollybase
	mkdir $(RELEASENAME)-src\cmdline
	xcopy /S /I $(EXEDIR)\Help $(RELEASENAME)-src\Help
	xcopy /S /I $(EXEDIR)\Patterns $(RELEASENAME)-src\Patterns
	xcopy /S /I $(EXEDIR)\Rules $(RELEASENAME)-src\Rules
	xcopy /S /I $(EXEDIR)\Scripts $(RELEASENAME)-src\Scripts
	xcopy /S /I $(EXEDIR)\docs $(RELEASENAME)-src\docs
	xcopy /S /I $(EXEDIR)\gollybase $(RELEASENAME)-src\gollybase
	xcopy /S /I $(EXEDIR)\cmdline $(RELEASENAME)-src\cmdline	
	mkdir $(RELEASENAME)-src\lua
	mkdir $(RELEASENAME)-src\sound
	mkdir $(RELEASENAME)-src\gui-wx
	mkdir $(RELEASENAME)-src\gui-wx\bitmaps
	mkdir $(RELEASENAME)-src\gui-wx\icons
	for %%F IN ($(LUAFILES)) do xcopy %F $(RELEASENAME)-src\lua
	for %%F IN ($(SOUNDFILES)) do xcopy %F $(RELEASENAME)-src\sound
	for %%F IN ($(GUIFILES)) do xcopy %F $(RELEASENAME)-src\gui-wx
	for %%F IN ($(GUIDIRS)) do xcopy /S /I %F $(RELEASENAME)-src\gui-wx\%F
	echo Now zip $(RELEASENAME)-src into $(RELEASENAME)-src.zip

bindist: all
	-rmdir /s /q $(BINNAME)
	mkdir $(BINNAME)
	mkdir $(BINNAME)\Help
	mkdir $(BINNAME)\Patterns
	mkdir $(BINNAME)\Rules
	mkdir $(BINNAME)\Scripts
	xcopy /S /I $(EXEDIR)\Help $(BINNAME)\Help
	xcopy /S /I $(EXEDIR)\Patterns $(BINNAME)\Patterns
	xcopy /S /I $(EXEDIR)\Rules $(BINNAME)\Rules
	xcopy /S /I $(EXEDIR)\Scripts $(BINNAME)\Scripts	
	for %%F IN ($(BINFILES)) do xcopy %F $(BINNAME)
	echo Now zip $(BINNAME) into $(BINNAME).zip
