#
# win/common.bc  --
#
# Borland C++ 5.x common include file for 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: common.bc,v 1.1.1.1 1999/06/28 20:35:39 damon Exp $
#------------------------------------------------------------------------------
#

#
# Project directories
#
# o ROOT- Absolute path to the top of source tree.
# o TMPDIR - Location where .obj files should be stored during build.
#   This maybe absolute or relative to the win build directories.
# o TOOLS = location of compiler and other development tools
#

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

#
# Installation directory root.  They *MUST* point to the same location, only
# PREFIX should use the DOS convention of \ for path seperator and PREFIXU
# should use /.
#
PREFIX=C:\tcl
PREFIXU=C:/tcl

# 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

#
# Borland C++ tools
#

BORLAND = $(TOOLS)
IMPLIB  = $(BORLAND)\bin\Implib
BCC32   = $(BORLAND)\bin\Bcc32
TLINK32 = $(BORLAND)\bin\tlink32
RC      = $(BORLAND)\bin\brcc32
BCC     = $(BORLAND)\bin\Bcc
TLINK   = $(BORLAND)\bin\tlink
RC16    = $(BORLAND)\bin\brcc32 -31
CP      = copy
RM      = del

INCLUDES =      $(BORLAND)\include;$(ROOT)\generic;$(ROOT)\win
LIBDIRS =       $(BORLAND)\lib;$(ROOT)\win

TCLX_INCLUDES = -I$(BORLAND)\include;$(TCLX_WIN_DIR);$(TCLX_GENERIC_DIR);$(TCL_WIN_DIR);$(TCL_GENERIC_DIR)

!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 = _RTLDLL;USE_TCLALLOC=0;$(DEBUGDEFINES)
PROJECTCCFLAGS= $(DEBUGCCFLAGS) -w-par -w-stu

CFLAGS16_dll = $(PROJECTCCFLAGS) -I$(TCLX_INCLUDES) -D$(DEFINES) -WD -ml -c -3 -d -w

LNFLAGS_exe = -Tpe -aa -c $(DEBUGLDFLAGS) $(BORLAND)\lib\c0w32
LNFLAGS_CONSOLE_exe = -Tpe -ap -c $(DEBUGLDFLAGS) $(BORLAND)\lib\c0x32
LNFLAGS_dll = -Tpd -aa -c $(DEBUGLDFLAGS) $(BORLAND)\lib\c0d32
LNFLAGS16_dll = -Twd -c -C -A=16 $(DEBUGLDFLAGS16) $(BORLAND)\lib\c0dl

# 
# Global makefile settings
#

.AUTODEPEND
.CACHEAUTODEPEND
 
.suffixes: .c .tcl .dll .lib .obj .exe
 
.path.c=$(ROOT)\win;$(ROOT)\generic;$(ROOT)\compat
.path.obj=$(TMPDIR)
.path.dll=$(ROOT)\win

# Implicit Targets

.tcl.c:
	$(TCL_WIN_DIR)\$(TCL2C) -a -n $@ -o $< $@

.c.obj:
	@$(BCC32) {$< }

.dll.lib:
	$(IMPLIB) -c $@ $<

.rc.res:
	$(RC) @&&|
$(TCLX_INCLUDES) -d__WIN32__;$(DEFINES) 
| $<


#
# TclX and TkX versions.
#
TCLX_VERSION = 8.1.0
TKX_VERSION  = 8.1.0

# Comment the following line to compile with symbols
#NODEBUG=1

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

#
# Tcl build directories and files.
#
TCL_DIR          = $(ROOT)\..\tcl8.0
TCL_GENERIC_DIR  = $(TCL_DIR)\generic
TCL_WIN_DIR      = $(TCL_DIR)\win
TCL_RUNTIME_DIR  = $(TCL_DIR)\library
TCL_TESTS_DIR    = $(TCL_DIR)\tests
TCL_LIB          = $(TCL_WIN_DIR)\tcl81.lib
TCL_DLL          = $(TCL_WIN_DIR)\tcl81.dll
TCL_SALIB        = $(TCL_WIN_DIR)\tcl81sa.lib

#
# TK build directories and files.
#
TK_DIR           = $(ROOT)\..\tk8.0
TK_GENERIC_DIR   = $(TK_DIR)\generic
TK_WIN_DIR       = $(TK_DIR)\win
TK_XLIB_DIR      = $(TK_DIR)\xlib
TK_RUNTIME_DIR   = $(TK_DIR)\library
TK_TESTS_DIR     = $(TK_DIR)\tests
TK_LIB           = $(TK_WIN_DIR)\tk81.lib
TK_DLL           = $(TK_WIN_DIR)\tk81.dll
TK_SALIB         = $(TK_WIN_DIR)\tk81sa.lib

#
# TclX directories.
#
TCLX_WIN_DIR      = $(ROOT)\tcl\win
TCLX_GENERIC_DIR  = $(ROOT)\tcl\generic
TCLX_RUNTIME_DIR  = $(ROOT)\tcl\runtime
TCLX_LIB          = $(TCLX_WIN_DIR)\tclx810.lib
TCLX_SHORT_DLL    = tclx810.dll
TCLX_DLL          = $(TCLX_WIN_DIR)\$(TCLX_SHORT_DLL)
TCLX_SALIB        = $(TCLX_WIN_DIR)\tclx810s.lib
TCLX_INST_BIN     = $(PREFIX)\bin
TCLX_INST_INCL    = $(PREFIX)\include
TCLX_INST_LIB     = $(PREFIX)\lib
TCLX_INST_LIBU    = $(PREFIX)/lib
TCLX_INST_RUNTIME = $(TCLX_INST_LIBU)/tclX$(TCLX_VERSION)
TCLX_INST_RUNTIMEU= $(TCLX_INST_LIBU)/tclX$(TCLX_VERSION)

#
# TkX directories.
#
TKX_WIN_DIR      = $(ROOT)\tk\win
TKX_GENERIC_DIR  = $(ROOT)\tk\generic
TKX_RUNTIME_DIR  = $(ROOT)\tk\runtime
TKX_LIB          = $(TKX_WIN_DIR)\tkx810.lib
TKX_DLL          = $(TKX_WIN_DIR)\tkx810.dll
TKX_SALIB        = $(TKX_WIN_DIR)\tkx810sa.lib
TKX_INST_BIN     = $(PREFIX)\bin
TKX_INST_INCL    = $(PREFIX)\include
TKX_INST_LIB     = $(PREFIX)\lib
TKX_INST_LIBU    = $(PREFIX)/lib
TKX_INST_RUNTIME = $(TKX_INST_LIB)\tkX$(TKX_VERSION)
TKX_INST_RUNTIMEU= $(TKX_INST_LIB)/tkX$(TKX_VERSION)

#
# Tools used during the build.
#
RUNTCL   = $(TCLX_WIN_DIR)\runtcl.bat
INSTCOPY = $(RUNTCL) $(TCLX_WIN_DIR)\instcopy


# Make sure the VC++ tools are at the head of the path
PATH=$(TOOLS)\bin;$(PATH)

CPU=i386
CP=copy


default:	all

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

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

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

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

cfgcln:
	-@$(RM) *.cfg
