# Windows makefile for tclblend and jacl
# the tclblend target requires Visual C++
#
# Copyright (c) 1998 by Moses DeJong
# see license.tems file more copyright info

# Modify the settings below to match your system
#
# TOP_DIR         -  Full path for root directory of the whole dist (ie ..)
# TOOLS32	  -  The location of the VC++ 32-bit development tools.
# JAVA_DIR	  -  The location of the JDK top directory.
# TCL_DIR	  -  The location of the Tcl binary installation.


# Specify which system to build.  (either jacl or tclblend)
TCLJAVA		= tclblend
TCLJAVA_VERSION	= 1.2.5

# Location you will be installing into
TCL_DIR		= D:\Tcl
#TCL_DIR	= C:\Program Files\tcl

# Root directory of the distribution
TOP_DIR		= C:\Tcl\$(TCLJAVA)$(TCLJAVA_VERSION)
#TOP_DIR	= C:\users\cxh\java\tb\$(TCLJAVA)$(TCLJAVA_VERSION)

# The root directory of your MS dev tools
TOOLS32		= C:\Program Files\Microsoft Visual Studio\vc98
#TOOLS32	= D:\Program Files\DevStudio\Vc

# JDK1.1 users should uncomment this section
JAVA_DIR	= C:\jdk1.1.8
JAVA_VERSION	= 1.1
JAVA_CLASSPATH	= $(JAVA_DIR)\lib\classes.zip;.

# JDK1.2 users should uncomment this section
#JAVA_DIR	= C:\jdk1.2
#JAVA_VERSION	= 1.2
#JAVA_CLASSPATH	= $(JAVA_DIR)\lib\tools.jar;$(JAVA_DIR)\jre\lib\rt.jar;.


#Tcl version info needed by the rest of the scripts
#TCL_DOTVERSION	= 8.2.1
TCL_DOTVERSION	= 8.0.5
#TCL_VERSION	= 82
TCL_VERSION	= 80


# If you are compiling from the Tcl Blast 8.0.3 cd, then uncomment these lines
#TCLSH		= tclsh80.exe
#TCLLIB		= $(TCL_DIR)\lib\tcl$(TCL_VERSION)VC.LIB

# If you are compiling from the Tcl Pro product, then uncomment these lines
#TCLSH		= $(TCL_DIR)\win32-ix86\bin\protclsh$(TCL_VERSION)$(DBGX).exe
#TCLLIB		= $(TCL_DIR)\win32-ix86\lib\tcl$(TCL_VERSION)$(DBGX).lib


TCL_SRC		= ..\..\tcl$(TCL_DOTVERSION)


# Comment the following line to compile with symbols (java and C symbols)
NODEBUG=1

# uncomment the following line to compile with TCL_MEM_DEBUG
#DEBUGDEFINES	=-DTCL_MEM_DEBUG

# Set this to the appropriate value of /MACHINE: for your platform
MACHINE	= IX86



######################################################################
# You should not have to modify below here
######################################################################

# Dos commands to copy and remove directories
COPYDIR			= xcopy /e /i /k
DELETEDIR		= deltree /y

# Directory in which to install tclblend.dll:
LIB_INSTALL_DIR 	= $(TCL_DIR)\lib

# Directory containing platform dependent binaries
BIN_INSTALL_DIR 	= $(TCL_DIR)\bin

# Directory from which applications will reference the
# scripts used by tclblend (location of pkgIndex.tcl)
TCLBLEND_LIBRARY	= $(TCL_DIR)\lib\tclblend


JAVA_INC_DIR		= $(JAVA_DIR)\include
JAVA_BIN_DIR		= $(JAVA_DIR)\bin
JAVA_LIB_DIR		= $(JAVA_DIR)\lib


# Location of java, javac, and javah
JAVA			= $(JAVA_BIN_DIR)\java
JAVAC			= $(JAVA_BIN_DIR)\javac
JAVAH			= $(JAVA_BIN_DIR)\javah
JAR			= $(JAVA_BIN_DIR)\jar
JAVA_FLAGS		=
#JAVA_FLAGS		= -Djava.compiler=NONE
JAR_COMPRESS_FLAGS	= -cf0
JAR_EXTRACT_FLAGS	= -xf



!IFDEF NODEBUG
JAVAC_FLAGS		= -O
TMPDIRNAME		= \Release
DBGX			=	
!ELSE
JAVAC_FLAGS		= -g
TMPDIRNAME		= \Debug
DBGX			= d
!ENDIF


# If you compile 8.0.4 from scratch, then executables in a sub dir of win.
# If you use the prebuilt libs from the Tcl Blast CD, the library
# is in C:\Program Files\Tcl\lib

!IF "$(TCL_DOTVERSION)" == "8.0"
TMPDIRNAME	=
DBGX		=
!ENDIF


# These are defined when compiling tclblend with tcl source
!IF "$(TCLLIB)"  == ""
TCLSH	= $(TCL_SRC)\win$(TMPDIRNAME)\tclsh$(TCL_VERSION)$(DBGX).exe
TCLLIB	= $(TCL_SRC)\win$(TMPDIRNAME)\tcl$(TCL_VERSION)$(DBGX).lib
!ENDIF



# If you are running under JDK1.2 then include some extra
# directories at runtime so that the java .dlls can be found

!IF "$(JAVA_VERSION)" == "1.2"
JAVA_RUNTIME_LIBS=$(JAVA_DIR)\jre\bin;$(JAVA_DIR)\jre\bin\classic
!ELSE
JAVA_RUNTIME_LIBS=
!ENDIF



# If you want to build in s directory other than win change the
# value of the variable to that directory .
BUILD_DIR		= $(TOP_DIR)\win

WIN_DIR			= $(TOP_DIR)\win
TOOLS_DIR		= $(TOP_DIR)\tools
TCLBLEND_SRC_DIR	= $(TOP_DIR)\src\tclblend
TCLBLEND_BUILD_DIR	= $(BUILD_DIR)\tclblend
JACL_SRC_DIR		= $(TOP_DIR)\src\jacl
JACL_BUILD_DIR		= $(BUILD_DIR)\jacl
TCLJAVA_SRC_DIR		= $(TOP_DIR)\src\tcljava
TCLJAVA_BUILD_DIR	= $(BUILD_DIR)\tcljava
NATIVE_SRC_DIR		= $(TOP_DIR)\src\native
DEMOS_SRC_DIR		= $(TOP_DIR)\demos
DEMOS_BUILD_DIR		= $(BUILD_DIR)\demos
TEST_SRC_DIR		= $(TOP_DIR)\src\tests
TEST_TCLBLEND_SRC_DIR	= $(TEST_SRC_DIR)\tclblend
TEST_JACL_SRC_DIR	= $(TEST_SRC_DIR)\jacl
TEST_TCLJAVA_SRC_DIR	= $(TEST_SRC_DIR)\tcljava
TEST_BUILD_DIR		= $(BUILD_DIR)\tests
MISC_DIR		= $(TOP_DIR)\src


TCLBLEND_LIB_FILE	= tclblend.dll


TCLBLEND_CLASSPATH	= $(TCLJAVA_BUILD_DIR);$(TCLBLEND_BUILD_DIR);$(JAVA_CLASSPATH)

JACL_CLASSPATH		= $(TCLJAVA_BUILD_DIR);$(JACL_BUILD_DIR);$(JAVA_CLASSPATH)

TCLJAVA_CLASSPATH	= $(TCLJAVA_BUILD_DIR);$(MISC_DIR)\empty\empty.jar;$(JAVA_CLASSPATH)

DEMOS_CLASSPATH		= $(BUILD_DIR)\$(TCLJAVA).jar;$(BUILD_DIR)\tcljava.jar;$(JAVA_CLASSPATH)

TEST_CLASSPATH		= $(TEST_BUILD_DIR);$(BUILD_DIR)\$(TCLJAVA).jar;$(BUILD_DIR)\tcljava.jar;$(JAVA_CLASSPATH)







#----------------------------------------------------------------
# Rules that are commonly called
#----------------------------------------------------------------

# Default is to build the tcljava target
# then build jacl or tclblend depending on
# what the variable TCLJAVA is set to

all: tcljava $(TCLJAVA) test.build


install: tcljava.install $(TCLJAVA).install



#----------------------------------------------------------------
# Build regression tests files for jacl and tclblend
#----------------------------------------------------------------

test: test_$(TCLJAVA).exec

test.build: test.clean test_tcljava.build test_$(TCLJAVA).build

test_tcljava.check:
#HOW can we do this under windows?
#      @if test ! -f $(BUILD_DIR)\tests\.tcljava ; then \
#              $(MAKE) TCLJAVA=$(TCLJAVA) test_tcljava.build ; \
#      fi

test_$(TCLJAVA).check:
#HOW can we do this under windows?
#      @if test ! -f $(BUILD_DIR)\tests\.$(TCLJAVA) ; then \
#              $(MAKE) TCLJAVA=$(TCLJAVA) test_$(TCLJAVA).build ; \
#      fi


test_jacl.build: jacl.check test_tcljava.check
	-@echo #
	-@echo # Making test_jacl.build
	-@echo #
	cd $(TEST_JACL_SRC_DIR)
	set CLASSPATH=$(TEST_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) \
		-d $(TEST_BUILD_DIR) tcl\lang\*.java

test_tclblend.build: tclblend.check test_tcljava.check
	-@echo #
	-@echo # Making test_tclblend.build
	-@echo #
	cd $(TEST_TCLBLEND_SRC_DIR)
	set CLASSPATH=$(TEST_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) \
		-d $(TEST_BUILD_DIR) tests\*.java tcl\lang\*.java


# only use test.clean on make clean or on test.build so that a shared
# build of tclblend and jacl tests can co-exist in the tests directory

test_tcljava.build: $(TCLJAVA).check
	-@echo #
	-@echo # Making test_tcljava.build
	-@echo #
	-mkdir $(TEST_BUILD_DIR)
	cd $(TEST_TCLJAVA_SRC_DIR)
	set CLASSPATH=$(TEST_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) \
		-d $(TEST_BUILD_DIR) pkg1\*.java pkg2\*.java \
		tcl\lang\*.java tests\*.java tests\invoke\*.java \
		tests\javainfo\*.java tests\signature\*.java \
		tests\exec\*.java 
	-mkdir $(TEST_BUILD_DIR)\javaload
	-@rem # workaround for bug in jikes (extra mkdir)
	-mkdir $(TEST_BUILD_DIR)\javaload\tests\javaload
	-@rem # workaround for bug in jikes (extra dir on CLASSPATH)
	cd $(TEST_TCLJAVA_SRC_DIR)
	set CLASSPATH=$(TEST_CLASSPATH);$(TEST_BUILD_DIR)\javaload
	$(JAVAC) $(JAVAC_FLAGS) \
		-d $(TEST_BUILD_DIR)\javaload javaload\*.java
	cd $(TEST_BUILD_DIR)\javaload
	set CLASSPATH=$(JAVA_CLASSPATH)
	$(JAR) $(JAR_COMPRESS_FLAGS) test9.jar Test9Extension.class
	-@del Test9Extension.class
	cd $(TEST_BUILD_DIR)\javaload
	set CLASSPATH=$(JAVA_CLASSPATH)
	$(JAR) $(JAR_COMPRESS_FLAGS) test10.jar Test10Extension.class
	-@del Test10Extension.class






clean: 	tclblend.clean jacl.clean tcljava.clean \
	demos.clean test.clean tmp.clean

tclblend.clean: tmp.clean
	-@del javaNative.h
	-@$(DELETEDIR) $(TCLBLEND_BUILD_DIR)
	del $(BUILD_DIR)\tclblend.jar
	del pkgIndex.tcl

jacl.clean:
	-@$(DELETEDIR) $(JACL_BUILD_DIR)
	del $(BUILD_DIR)\jacl.jar

tcljava.clean:
	-@$(DELETEDIR) $(TCLJAVA_BUILD_DIR)
	-@del $(BUILD_DIR)\tcljava.jar

demos.clean: 
	-@$(DELETEDIR) $(DEMOS_BUILD_DIR)

test.clean:
	cd $(BUILD_DIR)
	-@$(DELETEDIR) $(TEST_BUILD_DIR)


tmp.clean:
	-@cd $(BUILD_DIR)
	-@del *.exp
	-@del *.lib
	del   *.dll
	del   *.exe
        del   *.obj
        -@del *.res
        -@del *.class
        -@del *.pdb
        -@del *.pch

distclean: clean



#----------------------------------------------------------------------
# Running the Tcl Blend test suite
#----------------------------------------------------------------------

# Note that if TCLSH is an absolute path, then under JDK1.2beta4
# your are likely to get a crash.  Instead, set TCLSH = tclsh80.exe

test_tclblend.exec: test_tclblend.check
	cd $(BUILD_DIR)
	set JAVA=$(JAVA)
	set BUILD_DIR=$(BUILD_DIR)
	set CLASSPATH=$(TEST_CLASSPATH)
	set PATH=$(BUILD_DIR);$(JAVA_RUNTIME_LIBS);$(PATH)
	$(TCLSH) <<
		set auto_path [concat [pwd] [set auto_path]]
		cd {$(TOP_DIR)\tests}
		puts "pwd is [pwd]"
		puts "CLASSPATH is [set env(CLASSPATH)]"
		puts "auto_path is [set auto_path]"
		source all
		puts "Tests done."
		exit
<<


#----------------------------------------------------------------------
# Running the Jacl test suite
#----------------------------------------------------------------------

test_jacl.exec: test_jacl.check
	cd $(BUILD_DIR)
	set CLASSPATH=$(TEST_CLASSPATH)
	$(JAVA) $(JAVA_FLAGS) \
		-DBUILD_DIR=$(BUILD_DIR) -DJAVA=$(JAVA) tcl.lang.Shell <<
		set auto_path [concat [pwd] [set auto_path]]
		cd {$(TOP_DIR)\tests}
		puts "pwd is [pwd]"
		puts "CLASSPATH is [set env(CLASSPATH)]"
		puts "auto_path is [set auto_path]"
		source all
		puts "Tests done."
		exit
<<








#----------------------------------------------------------------
# shell : used to drop the user into a jacl or tclblend shell
#----------------------------------------------------------------


shell: shell_$(TCLJAVA).exec

shell_jacl.exec: jacl.check
	cd $(BUILD_DIR)
	set CLASSPATH=$(TEST_CLASSPATH)
	$(JAVA) $(JAVA_FLAGS) \
		-DBUILD_DIR=$(BUILD_DIR) -DJAVA=$(JAVA) tcl.lang.Shell

shell_tclblend.exec: tclblend.check
	cd $(BUILD_DIR)
	set TCLLIBPATH={$(BUILD_DIR)}
	set JAVA=$(JAVA)
	set BUILD_DIR=$(BUILD_DIR)
	set CLASSPATH=$(TEST_CLASSPATH)
	set PATH=$(BUILD_DIR);$(JAVA_RUNTIME_LIBS);$(PATH)
	$(TCLSH)


#----------------------------------------------------------------
# Build rules for the Demo files
#----------------------------------------------------------------

demos: $(TCLJAVA).check demos.build

demos.build:
	-mkdir $(DEMOS_BUILD_DIR)
	$(COPYDIR) $(DEMOS_SRC_DIR)\gluepkg \
		$(DEMOS_BUILD_DIR)\gluepkg
	$(COPYDIR) $(DEMOS_SRC_DIR)\gridDemo \
		$(DEMOS_BUILD_DIR)\gridDemo
	$(COPYDIR) $(DEMOS_SRC_DIR)\packDemo \
		$(DEMOS_BUILD_DIR)\packDemo
	$(COPYDIR) $(DEMOS_SRC_DIR)\pyramidpkg \
		$(DEMOS_BUILD_DIR)\pyramidpkg
	$(COPYDIR) $(DEMOS_SRC_DIR)\simplepkg \
		$(DEMOS_BUILD_DIR)\simplepkg
	$(COPYDIR) $(DEMOS_SRC_DIR)\watchpkg \
		$(DEMOS_BUILD_DIR)\watchpkg
	cd $(DEMOS_BUILD_DIR)\gluepkg
	set CLASSPATH=$(DEMOS_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) *.java
	cd $(DEMOS_BUILD_DIR)\packDemo
	set CLASSPATH=$(DEMOS_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) *.java
	cd $(DEMOS_BUILD_DIR)\pyramidpkg
	set CLASSPATH=$(DEMOS_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) *.java
	cd $(DEMOS_BUILD_DIR)\simplepkg
	set CLASSPATH=$(DEMOS_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) *.java
	cd $(DEMOS_BUILD_DIR)\watchpkg
	set CLASSPATH=$(DEMO_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) *.java





#-------------------------------------------------------------------
# Build rules for the tcljava package
#-------------------------------------------------------------------

tcljava: tcljava.jar

tcljava.build: tcljava.clean
	-@echo #
	-@echo # Making tcljava.build
	-@echo #
	-mkdir $(TCLJAVA_BUILD_DIR)
	cd $(TCLJAVA_SRC_DIR)
	set CLASSPATH=$(TCLJAVA_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) \
		-d $(TCLJAVA_BUILD_DIR) \
		tcl\lang\reflect\*.java
	cd $(TCLJAVA_SRC_DIR)
	set CLASSPATH=$(TCLJAVA_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) \
		-d $(TCLJAVA_BUILD_DIR) \
		tcl\lang\*.java
	$(COPYDIR) $(TCLJAVA_SRC_DIR)\tcl\lang\library \
		$(TCLJAVA_BUILD_DIR)\tcl\lang\library

tcljava.jar: tcljava.build
	cd $(TCLJAVA_BUILD_DIR)
	set CLASSPATH=$(JAVA_CLASSPATH)
	$(JAR) $(JAR_COMPRESS_FLAGS) $(BUILD_DIR)\tcljava.jar tcl


#
# Install tcljava, if the user did not build already
# then this rule will do a regular build before installing
#

tcljava.install: tcljava.check
	-@echo #
	-@echo # Installing tcljava
	-@echo #
	-@mkdir $(LIB_INSTALL_DIR)
	-@mkdir $(BIN_INSTALL_DIR)
	-@echo Installing tcljava.jar in $(LIB_INSTALL_DIR)
	copy $(BUILD_DIR)\tcljava.jar $(LIB_INSTALL_DIR)


#
# Check to make sure tcljava is built
#

tcljava.check:
#HOW can we do this check in windows ??
#	@if test ! -f $(BUILD_DIR)\tcljava.jar ; then \
#		$(MAKE) TCLJAVA=$(TCLJAVA) tcljava ; \
#	fi



#-------------------------------------------------------------------
# Build rules for the jacl package
#-------------------------------------------------------------------

jacl: jacl.jar

jacl.build: jacl.clean tcljava.check
	-@echo #
	-@echo # Making jacl.build
	-@echo #
	-mkdir $(JACL_BUILD_DIR)
	cd $(JACL_BUILD_DIR)
	set CLASSPATH=$(JAVA_CLASSPATH)
	$(JAR) $(JAR_EXTRACT_FLAGS) $(JACL_SRC_DIR)\oro.jar
	cd $(JACL_SRC_DIR)
	set CLASSPATH=$(JACL_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) \
		-d $(JACL_BUILD_DIR) tcl\lang\*.java tcl\regex\*.java
	$(COPYDIR) $(JACL_SRC_DIR)\tcl\lang\library \
		$(JACL_BUILD_DIR)\tcl\lang\library


jacl.jar: jacl.build
	cd $(JACL_BUILD_DIR)
	set CLASSPATH=$(JAVA_CLASSPATH)
	$(JAR) $(JAR_COMPRESS_FLAGS) $(BUILD_DIR)\jacl.jar tcl com



#
# Install jacl, if the user did not build jacl already
# it would have been built by the jacl.check rule
#
jacl.install: jacl.check
	-@echo #
	-@echo # Installing jacl
	-@echo #
	-@echo Installing jacl.jar in $(LIB_INSTALL_DIR)
	copy $(BUILD_DIR)\jacl.jar $(LIB_INSTALL_DIR)
	-@echo Installing jaclsh.bat in $(BIN_INSTALL_DIR)
	copy $(BUILD_DIR)\jaclsh.bat $(BIN_INSTALL_DIR)
	-@echo Please edit $(BIN_INSTALL_DIR)\jaclsh.bat for your site


#
# Check to make sure jacl is built
#

jacl.check: tcljava.check
#HOW can we do this check in windows ??
#	@if test ! -f $(BUILD_DIR)\jacl.jar ; then \
#		$(MAKE) TCLJAVA=$(TCLJAVA) jacl ; \
#	fi




#-------------------------------------------------------------------
# Build rules for the tclblend package
#-------------------------------------------------------------------

tclblend.build: tclblend.clean tcljava.check
	-@echo #
	-@echo # Making tclblend.build
	-@echo #
	-mkdir $(TCLBLEND_BUILD_DIR)
	cd $(TCLBLEND_SRC_DIR)
	set CLASSPATH=$(TCLBLEND_CLASSPATH)
	$(JAVAC) $(JAVAC_FLAGS) \
		-d $(TCLBLEND_BUILD_DIR) tcl\lang\*.java

tclblend.jar: tclblend.build
	cd $(TCLBLEND_BUILD_DIR)
	set CLASSPATH=$(JAVA_CLASSPATH)
	$(JAR) $(JAR_COMPRESS_FLAGS) $(BUILD_DIR)\tclblend.jar tcl


tclblend: tclblend.jar tclblend.lib
	copy $(MISC_DIR)\pkgIndex.tcl $(BUILD_DIR)

#
# Install tclBlend, if the user did not build tclblend already
# it would have been built by the tcljava.install rule
#

tclblend.install: tclblend.check
	-@echo #
	-@echo # Installing tclblend
	-@echo #
	-@echo Installing $(TCLBLEND_LIB_FILE) in $(BIN_INSTALL_DIR)
	-@copy $(BUILD_DIR)\$(TCLBLEND_LIB_FILE) $(BIN_INSTALL_DIR)
	-@echo Installing tclblend.jar in $(LIB_INSTALL_DIR)
	-@copy $(BUILD_DIR)\tclblend.jar $(LIB_INSTALL_DIR)
	-@mkdir $(TCLBLEND_LIBRARY)
	-@echo Installing pkgIndex.tcl in $(TCLBLEND_LIBRARY)
	-@copy $(MISC_DIR)\pkgIndex.tcl $(TCLBLEND_LIBRARY)


#
# Check to make sure tclblend is built
#

tclblend.check: tcljava.check
#HOW can we do this check in windows ??
#	@if test ! -f tclblend.jar ; then \
#		$(MAKE) TCLJAVA=$(TCLJAVA) tclblend.jar ; \
#	fi
#	@ if test ! -f $(TCLBLEND_LIB_FILE) ; then \
#		$(MAKE) TCLJAVA=$(TCLJAVA) $(TCLBLEND_LIB_FILE) ; \
#		copy $(MISC_DIR)\pkgIndex.tcl $(BUILD_DIR) ; \
#	fi





TCLBLEND_OBJS = \
	$(BUILD_DIR)\javaCmd.obj \
	$(BUILD_DIR)\javaIdle.obj \
	$(BUILD_DIR)\javaInterp.obj \
	$(BUILD_DIR)\javaNotifier.obj \
	$(BUILD_DIR)\javaObj.obj \
	$(BUILD_DIR)\javaList.obj \
	$(BUILD_DIR)\javaTimer.obj \
	$(BUILD_DIR)\javaUtil.obj \
	$(BUILD_DIR)\tclResult.obj \
	$(BUILD_DIR)\winNotifier.obj


TCLBLEND_CLASS_NAMES = \
	tcl.lang.CObject \
	tcl.lang.IdleHandler \
	tcl.lang.Interp \
	tcl.lang.Notifier \
	tcl.lang.TclList \
	tcl.lang.TimerHandler \
	tcl.lang.Util


cc32		= $(TOOLS32)\bin\cl.exe
link32		= $(TOOLS32)\bin\link.exe
include32	= -I$(TOOLS32)\include

INCLUDES	= -I$(TCL_DIR)\include -I$(TCL_SRC)\generic -I$(WIN_DIR)  \
		  -I$(NATIVE_SRC_DIR) -I$(JAVA_DIR)\include -I$(JAVA_DIR)\include\win32 
DEFINES		= $(DEBUGDEFINES) -DWIN32 -D_WIN32 -D_MT -D_DLL

CFLAGS		= $(cdebug) $(cflags) $(include32) $(INCLUDES) $(DEFINES) 




#----------------------------------------------------------------------
# Tcl Blend link flags
#----------------------------------------------------------------------

!IFDEF NODEBUG
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) /align:0x1000 /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$(DBGX).lib oldnames.lib
!ENDIF

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

guilibsdll = $(libcdll) $(winlibs)

#----------------------------------------------------------------------
# Tcl Blend compile flags
#----------------------------------------------------------------------

!IFDEF NODEBUG
cdebug =
!ELSE
#cdebug = /Z7 /Od /WX
cdebug = /Z7 /Od
!ENDIF

# declarations common to all compiler options
ccommon = /c /W3 /nologo /YX

!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




#----------------------------------------------------------------------
# Building the Tcl Blend library.
#----------------------------------------------------------------------

tclblend.lib: $(TCLBLEND_LIB_FILE)

!IF "$(JAVA_VERSION)" == "1.1"
JAVA_LIB = 	$(JAVA_LIB_DIR)\javai.lib
!ELSE
JAVA_LIB = 	$(JAVA_LIB_DIR)\jvm.lib
!ENDIF

$(TCLBLEND_LIB_FILE): $(TCLBLEND_OBJS)
	-@cd $(BUILD_DIR)
	set LIB=$(TOOLS32)\lib
        $(link32) $(ldebug) $(dlllflags) /out:$@ $(TCLLIB) \
		$(JAVA_LIB) $(guilibsdll) @<<
			$(TCLBLEND_OBJS)
<<

$(TCLBLEND_OBJS): $(BUILD_DIR)\javaNative.h

$(BUILD_DIR)\javaNative.h:
	-@cd $(BUILD_DIR)
	-@del javaNative.h
	set CLASSPATH=$(TCLBLEND_CLASSPATH)
	$(JAVAH) -jni -o javaNative.h $(TCLBLEND_CLASS_NAMES)


#----------------------------------------------------------------------
# Tcl Blend implicit targets
#----------------------------------------------------------------------

{$(NATIVE_SRC_DIR)}.c{$(BUILD_DIR)}.obj:
	-@cd $(BUILD_DIR)
	$(cc32) $(CFLAGS) /Fo$(BUILD_DIR)\ $<

{$(WIN_DIR)}.c{$(BUILD_DIR)}.obj:
	-@cd $(BUILD_DIR)
	$(cc32) $(CFLAGS) /Fo$(BUILD_DIR)\ $<

