# Generated automatically from Makefile.vc.in by configure.
#
# XOTcl Makefile for Visual C++ 6.0
#

# Be sure to adapt the "makefile.vc" file in the toplevel directory
# to your system settings.
!include "..\makefile.vc"

# Set NODEBUG to 0 to compile with symbols
NODEBUG=1

#
# VCC tools program names (and sub dirs)
#
cc32		= $(TOOLS32)\bin\cl.exe
link32		= $(TOOLS32)\bin\link.exe
lib32		= $(TOOLS32)\bin\link.exe -lib
rc32		= $(TOOLS32_rc)\bin\rc.exe
include32	= -I$(TOOLS32)\include

#
# libs
#
TCLLIB		= $(TCLDIR)\win\Release\$(TCLPREFIX)$(DBGX).lib
TCLDLL		= $(TCLDIR)\win\Release\$(TCLPREFIX)$(DBGX).dll
TKLIB       = $(TKDIR)\win\$(OUTDIR)\$(TKPREFIX)$(DBGX).lib
TKDLL       = $(TKDIR)\win\$(OUTDIR)\$(TKPREFIX)$(DBGX).dll

# uncomment one of the following lines to compile with TCL_MEM_DEBUG, 
# TCL_MEM_DEBUG, or TCL_COMPILE_DEBUG
#DEBUGDEFINES	= -DTCL_MEM_DEBUG
#DEBUGDEFINES	= -DTCL_MEM_DEBUG -DTCL_COMPILE_DEBUG
#DEBUGDEFINES	= -DTCL_MEM_DEBUG -DTCL_COMPILE_STATS
#DEBUGDEFINES	= -DTCL_MEM_DEBUG -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS

BINROOT=.
!IF "$(NODEBUG)" == "1"
TMPDIR		= $(BINROOT)\Release
DBGX		=
!ELSE
TMPDIR		= $(BINROOT)\Debug
DBGX		= 
!ENDIF
OUTDIR		= $(TMPDIR)

#
# file names
#
XOTCLLIB	= $(OUTDIR)\xotcl$(DBGX).lib
XOTCLDLLNAME	= xotcl$(DBGX).dll
XOTCLDLL	= $(OUTDIR)\$(XOTCLDLLNAME)
XOTCLSH		= $(OUTDIR)\xotclsh$(DBGX).exe
XOWISH		= $(OUTDIR)\xowish$(DBGX).exe
DUMPEXTS 	= $(TMPDIR)\dumpexts.exe


#
# install dirs
#
LIB_INSTALL_DIR	= $(INSTALLDIR)\lib
BIN_INSTALL_DIR	= $(INSTALLDIR)\bin
INCLUDE_INSTALL_DIR	= $(INSTALLDIR)\include

#
# obj specs
#
XOTCLSHOBJS = \
	$(TMPDIR)\xotclAppInit.obj
XOTCLOBJS = \
	$(TMPDIR)\xotcl.obj \
	$(TMPDIR)\dllEntryPoint.obj \
	$(TMPDIR)\xotclError.obj \
	$(TMPDIR)\xotclTrace.obj \
	$(TMPDIR)\xotclProfile.obj \
	$(TMPDIR)\xotclReference.obj \
	$(TMPDIR)\xotclMetaData.obj

XOWISH_SHELLOBJS = \
	$(TMPDIR)\winMain.obj
XOWISHOBJS = $(XOTCLOBJS)


XOTCL_INCLUDES	= -I. -I$(TCLDIR)\generic -I$(TKDIR)\generic -I$(TKDIR)\win -I$(TKDIR)\xlib
XOTCL_DEFINES	= -D__WIN32__ -DVISUAL_CC $(DEBUGDEFINES) -DXOLIBPKG=$(INST_XOLIBPKG)


XOTCL_CFLAGS	= $(cdebug) $(cflags) $(cvarsdll) $(include32) \
			$(XOTCL_INCLUDES) $(XOTCL_DEFINES) \
			-DLIBPKG=$(INST_XOLIBPKG) -DXOTCLVERSION=$(XOTCLVERSION)



######################################################################
# Link flags
######################################################################

!IF "$(NODEBUG)" == "1"
ldebug = /RELEASE
!ELSE
ldebug = -debug:full -debugtype:cv
!ENDIF

# declarations common to all linker options
lcommon = /NODEFAULTLIB /RELEASE /NOLOGO

# declarations for use on Intel i386, i486, and Pentium systems
!IF "$(MACHINE)" == "IX86"
DLLENTRY = @12
lflags   = $(lcommon) /MACHINE:$(MACHINE)
!ELSE
lflags   = $(lcommon) /MACHINE:$(MACHINE)
!ENDIF

conlflags = $(lflags) -subsystem:console -entry:mainCRTStartup
guilflags = $(lflags) -subsystem:windows -entry:WinMainCRTStartup
dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll

!IF "$(MACHINE)" == "PPC"
libc = libc.lib
libcdll = crtdll.lib
!ELSE
libc = libc.lib oldnames.lib
libcdll = msvcrt.lib oldnames.lib
!ENDIF

baselibs   = kernel32.lib $(optlibs) advapi32.lib user32.lib
winlibs    = $(baselibs) gdi32.lib comdlg32.lib winspool.lib

guilibs	   = $(libc) $(winlibs)
conlibs	   = $(libc) $(baselibs)
guilibsdll = $(libcdll) $(winlibs)
conlibsdll = $(libcdll) $(baselibs)



######################################################################
# Compile flags
######################################################################

!IF "$(NODEBUG)" == "1"
!IF "$(MACHINE)" == "ALPHA"
# MSVC on Alpha doesn't understand -Ot
cdebug = -O2i -Gs -GD
!ELSE
cdebug = -Oti -Gs -GD
!ENDIF
!ELSE
cdebug = -Z7 -Od -WX
!ENDIF

# declarations common to all compiler options
ccommon = -c -W3 -nologo -YX -Fp$(TMPDIR)\ -Dtry=__try -Dexcept=__except

!IF "$(MACHINE)" == "IX86"
cflags = $(ccommon) -D_X86_=1
!ELSE
!IF "$(MACHINE)" == "MIPS"
cflags = $(ccommon) -D_MIPS_=1
!ELSE
!IF "$(MACHINE)" == "PPC"
cflags = $(ccommon) -D_PPC_=1
!ELSE
!IF "$(MACHINE)" == "ALPHA"
cflags = $(ccommon) -D_ALPHA_=1
!ENDIF
!ENDIF
!ENDIF
!ENDIF

cvars      = -DWIN32 -D_WIN32
cvarsmt    = $(cvars) -D_MT
cvarsdll   = $(cvarsmt) -D_DLL

!IF "$(NODEBUG)" == "1"
cvarsdll   = $(cvarsdll) -MD
!ELSE
cvarsdll   = $(cvarsdll) -MDd
!ENDIF

CON_CFLAGS	= $(cdebug) $(cflags) $(cvars) $(include32) -DCONSOLE


######################################################################
# Project specific targets
######################################################################

src-xotclsh:    setup $(XOTCLSH)
src-xowish:     setup $(XOWISH)

setup:
	if not exist $(TMPDIR) mkdir $(TMPDIR)
	if not exist $(OUTDIR) mkdir $(OUTDIR)

$(XOTCLLIB): $(XOTCLDLL)
#	$(lib32) /out:$@ $(XOTCLOBJS)

#$(XOTCLDLL): $(XOTCLOBJS) $(TCLLIB) $(TMPDIR)\xotclvc.def $(TMPDIR)\xotcl.res
#	set LIB=$(TOOLS32)\lib
#	$(link32) $(ldebug) $(dlllflags) -def:$(TMPDIR)\xotclvc.def \
#		-out:$@ $(TMPDIR)\xotcl.res $(guilibsdll) @<<
#$(XOTCLOBJS) $(TCLLIB)
#<<

$(XOTCLDLL): $(XOTCLOBJS) $(TCLLIB) $(TMPDIR)\xotclvc.def
	set LIB=$(TOOLS32)\lib
	$(link32) $(ldebug) $(dlllflags) -def:$(TMPDIR)\xotclvc.def \
		-out:$@ $(guilibsdll) @<<
$(XOTCLOBJS) $(TCLLIB)
<<
	copy $(OUTDIR)\xotcl.dll .\xotcl.dll
	del $(OUTDIR)\xotcl.dll

#$(XOTCLSH): $(XOTCLSHOBJS) $(XOTCLOBJS) $(XOTCLLIB) $(TCLLIB) $(TMPDIR)\xotclsh.res
#	set LIB=$(TOOLS32)\lib
#	$(link32) $(ldebug) $(conlflags) $(TMPDIR)\xotclsh.res -stack:2300000 \
#		-out:$@ $(conlibsdll) $(XOTCLLIB) $(TCLLIB) $(XOTCLSHOBJS) $(XOTCLOBJS)

$(XOTCLSH): $(XOTCLSHOBJS) $(TCLLIB) $(XOTCLDLL) $(XOTCLLIB)
	set LIB=$(TOOLS32)\lib
	$(link32) $(ldebug) $(conlflags) -stack:2300000 \
		-out:$@ $(conlibsdll) $(TCLLIB) $(XOTCLSHOBJS) $(XOTCLLIB)
	copy $(OUTDIR)\xotclsh$(DBGX).exe .\xotclsh$(DBGX).exe
	del $(OUTDIR)\xotclsh$(DBGX).exe

$(XOWISH): $(XOWISHOBJS) $(XOWISH_SHELLOBJS) $(TCLLIB) $(TKLIB) $(XOTCLDLL) $(XOTCLLIB)
	set LIB=$(TOOLS32)\lib
	$(link32) $(ldebug) $(guilflags) -out:$@ \
		$(guilibsdll) $(TCLLIB) $(TKLIB) $(XOTCLLIB) $(XOWISH_SHELLOBJS)
	copy $(OUTDIR)\xowish$(DBGX).exe .\xowish$(DBGX).exe
	del $(OUTDIR)\xowish$(DBGX).exe

$(TMPDIR)\xotclvc.def: $(DUMPEXTS) $(XOTCLOBJS)
	$(DUMPEXTS) -o $@ $(XOTCLDLLNAME) @<<
$(XOTCLOBJS)
<<

$(DUMPEXTS): .\winDumpExts.c
	$(cc32) $(CON_CFLAGS) -Fo$(TMPDIR)\ $?
	set LIB=$(TOOLS32)\lib
	$(link32) $(ldebug) $(conlflags) $(guilibs) -out:$@ \
		$(TMPDIR)\winDumpExts.obj 

src-install: src-xotclsh
	if not exist $(INSTALLDIR) mkdir $(INSTALLDIR)
	if not exist $(BIN_INSTALL_DIR) mkdir $(BIN_INSTALL_DIR)
	if not exist $(LIB_INSTALL_DIR) mkdir $(LIB_INSTALL_DIR)
	if not exist $(INCLUDE_INSTALL_DIR) mkdir $(INCLUDE_INSTALL_DIR)
	copy .\xotclsh$(DBGX).exe "$(BIN_INSTALL_DIR)"
	copy .\xowish$(DBGX).exe "$(BIN_INSTALL_DIR)"
	copy .\xotcl.dll "$(BIN_INSTALL_DIR)"
	copy xotcl.h "$(INCLUDE_INSTALL_DIR)"

src-install_xowish: src-xowish
	if not exist $(INSTALLDIR) mkdir $(INSTALLDIR)
	if not exist $(BIN_INSTALL_DIR) mkdir $(BIN_INSTALL_DIR)
	if not exist $(LIB_INSTALL_DIR) mkdir $(LIB_INSTALL_DIR)
	if not exist $(INCLUDE_INSTALL_DIR) mkdir $(INCLUDE_INSTALL_DIR)
	copy .\xowish$(DBGX).exe "$(BIN_INSTALL_DIR)"
	copy .\xotcl.dll "$(BIN_INSTALL_DIR)"
	copy xotcl.h "$(INCLUDE_INSTALL_DIR)"


#
# Special case object file targets
#

#$(TMPDIR)\xotclAppInit.obj : 
#	$(cc32) -DBUILD_tcl $(XOTCL_CFLAGS) -Fo$@ xotclAppInit.c

#$(TMPDIR)\winMain.obj: 
#	$(cc32) -DBUILD_tcl -DBUILD_tk $(XOTCL_CFLAGS) -Fo$@ winMain.c

#
# Implicit rules
#

{$(WINDIR)}.c{$(TMPDIR)}.obj:
    $(cc32) -DDLL_BUILD $(XOTCL_CFLAGS) -Fo$(TMPDIR)\ $<

{$(GENERICDIR)}.c{$(TMPDIR)}.obj:
    $(cc32) -DDLL_BUILD $(XOTCL_CFLAGS) -Fo$(TMPDIR)\ $<

{$(WINDIR)}.rc{$(TMPDIR)}.res:
	$(rc32) -fo $@ -r -i $(GENERICDIR) -i $(WINDIR) -i $(TCLDIR)\generic -D__WIN32__ \
		$(XOTCL_DEFINES) $<

src-clean:
	-@del $(OUTDIR)\*.exp
	-@del $(OUTDIR)\*.lib
	-@del $(OUTDIR)\*.dll
	-@del $(OUTDIR)\*.exe
	-@del $(OUTDIR)\*.pdb
	-@del $(TMPDIR)\*.pch
	-@del $(TMPDIR)\*.obj
	-@del $(TMPDIR)\*.res
	-@del $(TMPDIR)\*.def
	-@del $(TMPDIR)\*.exe
	-@del .\*.exe
	-@del .\*.dll
	-@rmdir $(OUTDIR)
	-@rmdir $(TMPDIR)
