#
# tk/win/makefile.vc  --
#
# Visual C++ 2.x and 4.0 makefile for Extended Tk on Windows.
#------------------------------------------------------------------------------
# Copyright 1996-1999 Karl Lehenbauer and Mark Diekhans.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies.  Karl Lehenbauer and
# Mark Diekhans make no representations about the suitability of this
# software for any purpose.  It is provided "as is" without express or
# implied warranty.
#------------------------------------------------------------------------------
# $Id: makefile.vc,v 1.1.1.1 1999/06/28 20:35:37 damon Exp $
#------------------------------------------------------------------------------
#

!include "..\..\win\common.vc"

TKX_INCLUDES = \
	-I"$(TOOLS32)\include" -I$(TK_XLIB_DIR)\
	-I$(TKX_WIN_DIR) -I$(TKX_GENERIC_DIR) \
        -I$(TCLX_WIN_DIR) -I$(TCLX_GENERIC_DIR) \
        -I$(TK_GENERIC_DIR) -I$(TK_WIN_DIR) \
	-I$(TCL_GENERIC_DIR) -I$(TCL_WIN_DIR)

TKX_DEFINES = \
    -nologo $(DEBUGDEFINES)

WISHXOBJS = \
        $(TMP_DIR)\tkXAppInit.obj

TKXTESTOBJS = \
        $(TMP_DIR)\tkTest.obj \
        $(TMP_DIR)\tkSquare.obj \
        $(TMP_DIR)\tkXwinTest.obj

TKXOBJS = \
        $(TMP_DIR)\tkXinit.obj \
        $(TMP_DIR)\tkXshell.obj \
        $(TMP_DIR)\tkXwinUtil.obj

WISHX = wishx.exe
TKTEST = tktest.exe
DUMPEXTS = $(TCLX_WIN_DIR)\dumpexts.exe

#------------------------------------------------------------------------------
# Targets
#
all: $(TKX_DLL) $(WISHX) RUNTIME $(TKTEST) runwishx.bat runtest.bat runtest.tcl

test: all $(TKTEST) runtest.bat runtest.tcl
        .\runtest -geometry +0+0 runtest.tcl

tkXvc.def: $(TKXOBJS)
        $(DUMPEXTS) -o $@ $(TKX_DLL_NAME) $(TKXOBJS)

$(TKX_DLL): $(TKXOBJS) tkXvc.def $(TMP_DIR)\tkx.res
        set LIB=$(LIB)
        $(link) $(linkdebug) $(dlllflags) -def:tkXvc.def \
                $(TMP_DIR)\tkx.res $(guilibsdll) -out:$(TKX_DLL) @<<
                $(TKXOBJS) $(TK_LIB) $(TCLX_LIB) $(TCL_LIB) Wsock32.lib
<<


$(WISHX): $(WISHXOBJS) $(TKX_LIB) $(TCLX_LIB) $(TMP_DIR)\wishx.res
        set LIB=$(LIB)
        $(link) $(linkdebug) $(guilflags) \
                $(WISHXOBJS) $(TMP_DIR)\wishx.res $(TKX_LIB) $(TK_LIB) \
		$(TCLX_LIB) $(TCL_LIB) \
		$(guilibsdll) -out:$(WISHX)

$(TKTEST): $(TKXTESTOBJS) $(TKX_LIB) $(TCLX_LIB) $(TMP_DIR)\wishx.res
        set LIB=$(LIB)
        $(link) $(linkdebug) $(guiflags) \
                $(TKXTESTOBJS) $(TMP_DIR)\wishx.res $(TKX_LIB) $(TK_LIB) \
		$(TCLX_LIB) $(TCL_LIB) \
		$(guilibsdll) -out:$(TKTEST)

#------------------------------------------------------------------------------
# Copyruntime files into this directory so it can be used as a temporary
# runtime directory before installation.
#
RUNTIME: tkx.tcl

tkx.tcl: $(TKX_RUNTIME_DIR)\tkx.tcl
        -del tkx.tcl
	copy $(TKX_RUNTIME_DIR)\tkx.tcl tkx.tcl

#------------------------------------------------------------------------------
# Generate script used to run programs before DLLs and runtime is installed.
#
runwishx.bat: makefile.vc ..\..\win\common.vc
        -del runwishx.bat
        @echo echo off>>runwishx.bat
        @echo PATH $(TKX_WIN_DIR);$(TK_BUILD_DIR);$(TCLX_WIN_DIR);$(TCL_BUILD_DIR);%PATH%>>runwishx.bat
        @echo set TCL_LIBRARY=$(TCL_RUNTIME_DIR)>>runwishx.bat
        @echo set TK_LIBRARY=$(TK_RUNTIME_DIR)>>runwishx.bat
        @echo set TCLX_LIBRARY=$(TCLX_WIN_DIR)>>runwishx.bat
        @echo set TKX_LIBRARY=$(TKX_WIN_DIR)>>runwishx.bat
        @echo $(TKX_WIN_DIR)\wishx.exe %1 %2 %3 %4>>runwishx.bat
        @echo runwishx.bat created

runtest.bat: makefile.vc ..\..\win\common.vc
        -del runtest.bat
        @echo echo off>>runtest.bat
        @echo PATH $(TKX_WIN_DIR);$(TK_BUILD_DIR);$(TCLX_WIN_DIR);$(TCL_BUILD_DIR);%PATH%>>runtest.bat
        @echo set TCL_LIBRARY=$(TCL_RUNTIME_DIR)>>runtest.bat
        @echo set TK_LIBRARY=$(TK_RUNTIME_DIR)>>runtest.bat
        @echo set TCLX_LIBRARY=$(TCLX_WIN_DIR)>>runtest.bat
        @echo set TKX_LIBRARY=$(TKX_WIN_DIR)>>runtest.bat
        @echo $(TKX_WIN_DIR)\tktest.exe %1 %2 %3 %4>>runtest.bat
        @echo runtest.bat created

#------------------------------------------------------------------------------
# Tcl script to actually run the tests.
#
runtest.tcl: makefile.vc
        -del runtest.tcl
	echo cd {$(TK_TESTS_DIR)}>>runtest.tcl
        echo source all>>runtest.tcl
        echo exit>>runtest.tcl

#------------------------------------------------------------------------------
# Installation.

install:
        $(INSTCOPY) $(WISHX) "$(TKX_INST_BIN)"
        $(INSTCOPY) $(TKX_DLL) "$(TCLX_INST_BIN)"
        $(INSTCOPY) $(TKX_LIB) "$(TKX_INST_LIB)"
        $(INSTCOPY) tkx.tcl "$(TKX_INST_RUNTIME)"
        $(INSTCOPY) ..\help "$(TKX_INST_RUNTIME)\help"

#------------------------------------------------------------------------------
clean:
        -del *.exp
        -del *.lib
        -del *.dll
        -del *.exe
        -del $(TMP_DIR)\*.obj
        -del *.def
        -del *.res
        -del tkx.tcl
        -del runwishx.bat
        -del runtest.bat
        -del runtest.tcl

#------------------------------------------------------------------------------
# Special case object file targets
#
$(TMP_DIR)\tkXinit.obj: $(TKX_GENERIC_DIR)\tkXinit.c
        $(cc32) $(cdebug) $(cflags) $(cvarsdll) $(TKX_INCLUDES) \
            $(TKX_DEFINES) -DTKX_LIBRARY="\"$(TKX_INST_RUNTIMEU)\"" \
            -DBUILD_tkx -Fo$(TMP_DIR)\ $?

$(TMP_DIR)\tkXAppInit.obj: $(TKX_WIN_DIR)\tkXAppInit.c
        $(cc32) $(cdebug) $(cflags) $(cvars) $(TKX_INCLUDES) \
            $(TKX_DEFINES) -Fo$(TMP_DIR)\ $?

$(TMP_DIR)\tkXwinTest.obj: $(TKX_WIN_DIR)\tkXwinTest.c
        $(cc32) $(cdebug) $(cflags) $(cvars) $(TKX_INCLUDES) \
            $(TKX_DEFINES) -Fo$(TMP_DIR)\ $?

$(TMP_DIR)\tkTest.obj: $(TK_GENERIC_DIR)\tkTest.c
        $(cc32) $(cdebug) $(cflags) $(cvars) $(TKX_INCLUDES) \
                $(TKX_DEFINES) -Fo$(TMP_DIR)\ $?

$(TMP_DIR)\tkSquare.obj: $(TK_GENERIC_DIR)\tkSquare.c
        $(cc32) $(cdebug) $(cflags) $(cvars) $(TKX_INCLUDES) \
                $(TKX_DEFINES) -Fo$(TMP_DIR)\ $?

#------------------------------------------------------------------------------
# Implicit rules
#
{$(TKX_GENERIC_DIR)}.c{$(TMP_DIR)}.obj:
    $(cc32) $(cdebug) $(cflags) $(cvarsdll) $(TKX_INCLUDES) \
          $(TKX_DEFINES) -DBUILD_tkx -Fo$(TMP_DIR)\ $<

{$(TKX_WIN_DIR)}.c{$(TMP_DIR)}.obj:
    $(cc32) $(cdebug) $(cflags) $(cvarsdll) $(TKX_INCLUDES) \
          $(TKX_DEFINES) -DBUILD_tkx -Fo$(TMP_DIR)\ $<

{$(TKX_WIN_DIR)}.rc{$(TMP_DIR)}.res:
        $(rc32) -fo $@ -r -i $(TCLX_GENERIC_DIR) -i $(TCLX_WIN_DIR) $<



