# Copyright (c) 1995-1996 Sun Microsystems, Inc.
# SCCS: @(#) makefile.bc 1.82 97/11/20 15:52:39
#
# Borland C++ 4.5 makefile
#

#
# Project directories
#
# ROOT = top of source tree
# TMPDIR = location where .obj files should be stored during build
# TOOLS = location of compiler and other development tools
#

ROOT	= ..
TMPDIR	= .
TOOLS	= c:\bc45

# uncomment the following line to compile with symbols
#DEBUG=1

# uncomment one of the following lines to compile with TCL_MEM_DEBUG,
# TCL_COMPILE_DEBUG, or TCL_COMPILE_STATS
#DEBUGDEFINES   =TCL_MEM_DEBUG 
#DEBUGDEFINES   =TCL_MEM_DEBUG;TCL_COMPILE_DEBUG
#DEBUGDEFINES   =TCL_MEM_DEBUG;TCL_COMPILE_STATS
#DEBUGDEFINES   =TCL_MEM_DEBUG;TCL_COMPILE_DEBUG;TCL_COMPILE_STATS


######################################################################
# Do not modify below this line
######################################################################

STACKSIZE = 1f0001

VERSION = 80

TCLLIB 		= tcl$(VERSION).lib
TCLDLL 		= tcl$(VERSION).dll
TCL16DLL 	= tcl16$(VERSION).dll
TCLSH 		= tclsh$(VERSION).exe
TCLTEST 	= tcltest.exe
DUMPEXTS 	= dumpexts.exe
TCLPIPEDLL 	= tclpip$(VERSION).dll
TCLREGDLL 	= tclreg$(VERSION).dll
CAT16 		= cat16.exe
CAT32 		= cat32.exe

TCLSHOBJS = \
	$(TMPDIR)\tclAppInit.obj

TCLTESTOBJS = \
	$(TMPDIR)\tclTest.obj \
	$(TMPDIR)\tclTestObj.obj \
	$(TMPDIR)\tclWinTest.obj \
	$(TMPDIR)\testMain.obj

TCLOBJS = \
	$(TMPDIR)\panic.obj \
	$(TMPDIR)\regexp.obj \
	$(TMPDIR)\strftime.obj \
	$(TMPDIR)\tclAlloc.obj \
	$(TMPDIR)\tclAsync.obj \
	$(TMPDIR)\tclBasic.obj \
	$(TMPDIR)\tclBinary.obj \
	$(TMPDIR)\tclCkalloc.obj \
	$(TMPDIR)\tclClock.obj \
	$(TMPDIR)\tclCmdAH.obj \
	$(TMPDIR)\tclCmdIL.obj \
	$(TMPDIR)\tclCmdMZ.obj \
	$(TMPDIR)\tclCompExpr.obj \
	$(TMPDIR)\tclCompile.obj \
	$(TMPDIR)\tclDate.obj \
	$(TMPDIR)\tclEnv.obj \
	$(TMPDIR)\tclEvent.obj \
	$(TMPDIR)\tclExecute.obj \
	$(TMPDIR)\tclFCmd.obj \
	$(TMPDIR)\tclFileName.obj \
	$(TMPDIR)\tclGet.obj \
	$(TMPDIR)\tclHash.obj \
	$(TMPDIR)\tclHistory.obj \
	$(TMPDIR)\tclIndexObj.obj \
	$(TMPDIR)\tclInterp.obj \
	$(TMPDIR)\tclIO.obj \
	$(TMPDIR)\tclIOCmd.obj \
	$(TMPDIR)\tclIOSock.obj \
	$(TMPDIR)\tclIOUtil.obj \
	$(TMPDIR)\tclLink.obj \
	$(TMPDIR)\tclListObj.obj \
	$(TMPDIR)\tclLoad.obj \
	$(TMPDIR)\tclMain.obj \
	$(TMPDIR)\tclNamesp.obj \
	$(TMPDIR)\tclNotify.obj \
	$(TMPDIR)\tclObj.obj \
	$(TMPDIR)\tclParse.obj \
	$(TMPDIR)\tclPipe.obj \
	$(TMPDIR)\tclPkg.obj \
	$(TMPDIR)\tclPosixStr.obj \
	$(TMPDIR)\tclPreserve.obj \
	$(TMPDIR)\tclProc.obj \
	$(TMPDIR)\tclStringObj.obj \
	$(TMPDIR)\tclTimer.obj \
	$(TMPDIR)\tclUtil.obj \
	$(TMPDIR)\tclVar.obj \
	$(TMPDIR)\tclWin32Dll.obj \
	$(TMPDIR)\tclWinChan.obj \
	$(TMPDIR)\tclWinError.obj \
	$(TMPDIR)\tclWinFCmd.obj \
	$(TMPDIR)\tclWinFile.obj \
	$(TMPDIR)\tclWinInit.obj \
	$(TMPDIR)\tclWinLoad.obj \
	$(TMPDIR)\tclWinMtherr.obj \
	$(TMPDIR)\tclWinNotify.obj \
	$(TMPDIR)\tclWinPipe.obj \
	$(TMPDIR)\tclWinSock.obj \
	$(TMPDIR)\tclWinTime.obj

cc32		= $(TOOLS)\bin\bcc32.exe
link32		= $(TOOLS)\bin\tlink32.exe
rc32		= $(TOOLS)\bin\brcc32.exe
implib		= $(TOOLS)\bin\implib.exe

cc16		= $(TOOLS)\bin\bcc.exe
link16		= $(TOOLS)\bin\tlink.exe
rc16		= $(TOOLS)\bin\brcc32.exe -31

CP		= copy
RM		= del

WINDIR          = $(ROOT)\win
GENERICDIR	= $(ROOT)\generic

INCLUDES	= $(TOOLS)\include;$(WINDIR);$(GENERICDIR)
LIBDIRS		= $(TOOLS)\lib;$(WINDIR)

CON_CFLAGS	= +cfgexe.cfg -WC
TEST_CFLAGS	= +cfgtest.cfg
DLL16_CFLAGS	= $(PROJECTCCFLAGS) -I$(INCLUDES) -D$(DEFINES) -WD -ml -c \
			-3 -d -w
TCL_CFLAGS	= +cfgdll.cfg

CON_LFLAGS	= -Tpe -ap -c $(DEBUGLDFLAGS) $(TOOLS)\lib\c0x32
DLL_LFLAGS	= -Tpd -aa -c $(DEBUGLDFLAGS) $(TOOLS)\lib\c0d32
GUI_LFLAGS	= -Tpe -aa -c $(DEBUGLDFLAGS) $(TOOLS)\lib\c0w32
DLL16_LFLAGS	= -Twd -c -C -A=16 $(DEBUGLDFLAGS16) $(TOOLS)\lib\c0dl

DLL_LIBS	= import32 cw32mti
CON_LIBS	= $(TCLLIB) import32 cw32mti
DLL16_LIBS	= import cwl

!ifndef DEBUG

# these macros cause maximum optimization and no symbols
DEBUGLDFLAGS = 
DEBUGCCFLAGS = -v- -vi- -O2
DEBUGLDFLAGS16 = -Oc -Oi -Oa -Or
!else

# these macros enable debugging
DEBUGLDFLAGS = -v
DEBUGCCFLAGS = -k -Od -v
DEBUGLDFLAGS16 = 

!endif

DEFINES = MT;_RTLDLL;$(DEBUGDEFINES)
PROJECTCCFLAGS = $(DEBUGCCFLAGS) -w-par -w-stu


# 
# Global makefile settings
#

.AUTODEPEND
.CACHEAUTODEPEND

.suffixes:

#.path.c=$(ROOT)\win;$(ROOT)\generic;$(ROOT)\compat
#.path.obj=$(TMPDIR)
#.path.dll=$(ROOT)\win

#
# Targets
#

release:    $(TCLSH) dlls
all:	    $(TCLSH) dlls $(CAT16) $(CAT32) 
tcltest:    $(TCLTEST) dlls $(CAT16) $(CAT32)
dlls:	    $(TCL16DLL) $(TCLPIPEDLL) $(TCLREGDLL)

test:	    tcltest
	$(TCLTEST) &&|
		cd ../tests
		source all
|


$(DUMPEXTS): cfgexe.cfg $(WINDIR)\winDumpExts.c
	$(cc32) $(CON_CFLAGS) $(WINDIR)\winDumpExts.c
	$(link32) $(CON_LFLAGS) \
		$(TMPDIR)\winDumpExts.obj,$@,,import32 cw32mti,,

$(TCLLIB): $(TCLDLL)
	$(implib) -c $@ $(TCLDLL)

$(TCLDLL): cfgdll.cfg $(TCLOBJS) $(TMPDIR)\tcl.def $(TMPDIR)\tcl.res
	$(link32) $(DLL_LFLAGS) @&&|
		$(TCLOBJS)
$@
-x
$(DLL_LIBS)
|, $(TMPDIR)\tcl.def, $(TMPDIR)\tcl.res


$(TCLSH): cfgexe.cfg $(TCLSHOBJS) $(TCLLIB) $(TMPDIR)\tclsh.res
	$(link32) -S:$(STACKSIZE) $(CON_LFLAGS) @&&|
		$(TCLSHOBJS)
$@
-x
$(CON_LIBS)
|, &&|
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
|, $(TMPDIR)\tclsh.res

$(TCLTEST): cfgtest.cfg $(TCLTESTOBJS) $(TCLLIB) $(TMPDIR)\tclsh.res
	$(link32) -S:$(STACKSIZE) $(CON_LFLAGS) @&&|
		$(TCLTESTOBJS)
$@
-x
$(CON_LIBS)
|, &&|
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
|, $(TMPDIR)\tclsh.res


$(TCL16DLL): tcl16.rc $(ROOT)\win\tclWin16.c
	$(cc16) @&&|
$(DLL16_CFLAGS) -n$(TMPDIR) 
| $(ROOT)\win\tclWin16.c
	$(rc16) @&&|
-i$(INCLUDES) -d__WIN32__;$(DEFINES) -fo$(TMPDIR)\tcl16.res
| tcl16.rc
	@copy >nul &&|
LIBRARY $&;dll
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 1024
EXPORTS
	WEP @1 RESIDENTNAME
	UTPROC @2 
| $(TMPDIR)\tclWin16.def
	$(link16) $(DLL16_LFLAGS) @&&|
$(TMPDIR)\tclWin16.obj
$@
nul
$(DLL16_LIBS)
$(TMPDIR)\tclWin16.def
|
	$(TOOLS)\bin\rlink $(TMPDIR)\tcl16.res $@

$(TCLPIPEDLL): cfgexe.cfg stub16.c
	$(cc32) -c -tWC stub16.c
	$(link32) $(CON_LFLAGS) -L$(TOOLS)\lib \
		stub16.obj,$@,,import32 cw32,,

$(TCLREGDLL): extdll.cfg $(TMPDIR)\tclWinReg.obj
	$(link32) $(DLL_LFLAGS) @&&|
		$(TMPDIR)\tclWinReg.obj
$@
-x
$(DLL_LIBS) $(TCLLIB)
|,,

#
# Special test targets
#

$(CAT32): cat.c
	$(cc32) -c -Ox -tWC -ocat32.obj cat.c
	$(link32) $(CON_LFLAGS) -L$(TOOLS)\lib \
		cat32.obj,$@,,import32 cw32,,

$(CAT16): cat.c
	$(cc16) -W- -ml -Ox -c -ocat16.obj cat.c
	$(link16) -Tde -c -L$(TOOLS)\lib $(TOOLS)\lib\c0l.obj cat16.obj,cat16.exe,,cl.lib,,

#######################################################################
# Implicit Targets
#######################################################################


{$(WINDIR)}.c{$(TMPDIR)}.obj:
	@$(cc32) $(TCL_CFLAGS) {$< }

{$(GENERICDIR)}.c{$(TMPDIR)}.obj:
	@$(cc32) $(TCL_CFLAGS) {$< }

{$(ROOT)\compat}.c{$(TMPDIR)}.obj:
	@$(cc32) $(TCL_CFLAGS) {$< }

{$(WINDIR)}.rc{$(TMPDIR)}.res:
	$(rc32) -i$(INCLUDES) -fo$@ @&&|
-d__WIN32__;$(DEFINES) $<
|

#
# Special case object file targets
#

$(TMPDIR)\tclWinReg.obj : extdll.cfg $(ROOT)\win\tclWinReg.c
	$(cc32) +extdll.cfg -o$@ $(ROOT)\win\tclWinReg.c

$(TMPDIR)\tclAppInit.obj : cfgexe.cfg $(ROOT)\win\tclAppInit.c
	$(cc32) $(CON_CFLAGS) -o$@ $(ROOT)\win\tclAppInit.c

$(TMPDIR)\testMain.obj : cfgexe.cfg $(ROOT)\win\tclAppInit.c
	$(cc32) $(TEST_CFLAGS) -o$@ $(ROOT)\win\tclAppInit.c

$(TMPDIR)\tclWin16.obj : $(ROOT)\win\tclWin16.c
	$(cc16) $(DLL16_CFLAGS) -o$@ $(ROOT)\win\tclWin16.c

#
# Configuration file targets - these files are implicitly used by the compiler
#

cfgdll.cfg:
	@$(CP) &&|
		-n$(TMPDIR) -I$(INCLUDES) -c -WM
		-D$(DEFINES) -3 -d -w $(PROJECTCCFLAGS)
| cfgdll.cfg >NUL

extdll.cfg:
	@$(CP) &&|
		-n$(TMPDIR) -I$(INCLUDES) -c -WD
		-D_RTLDLL;$(DEBUGDEFINES) -3 -d -w $(PROJECTCCFLAGS)
| extdll.cfg >NUL

cfgexe.cfg:
	@$(CP) &&|
		-n$(TMPDIR) -I$(INCLUDES) -c -W
		-D$(DEFINES) -3 -d -w $(PROJECTCCFLAGS)
| cfgexe.cfg >NUL

cfgtest.cfg:
	@$(CP) &&|
		-n$(TMPDIR) -I$(INCLUDES) -c -W
		-D$(DEFINES);TCL_TEST -3 -d -w $(PROJECTCCFLAGS)
| cfgtest.cfg >NUL

cfgcln:
	-@$(RM) *.cfg


# The following rule automatically generates a tcl.def file containing
# an export entry for every public symbol in the tcl.dll library.

$(TMPDIR)\tcl.def: $(TCLOBJS) $(DUMPEXTS)
	$(DUMPEXTS) -o $(TMPDIR)\tcl.def $(TCLDLL) @&&|
		$(TCLOBJS)
|


# the following two rules are a hack to get around the fact that the
# 16-bit compiler doesn't handle long file names :-(

$(ROOT)\win\tclWinIn.h: $(ROOT)\win\tclWinInt.h
	$(CP) $(ROOT)\win\tclWinInt.h $(ROOT)\win\tclWinIn.h

$(ROOT)\win\tclWin16.c: $(ROOT)\win\tclWinIn.h

# remove all generated files

clean:
	-@$(RM) *.exe
	-@$(RM) *.lib
	-@$(RM) *.dll
	-@$(RM) $(TMPDIR)\*.res
	-@$(RM) $(TMPDIR)\*.def
	-@$(RM) $(TMPDIR)\*.obj
	-@$(RM) $(TMPDIR)\*.cfg
	-@$(RM) $(ROOT)\win\tclWinIn.h
