# Borland C++ 4.5 makefile for Tk
#
# Copyright (c) 1995-1996 by Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# SCCS: @(#) makefile.bc 1.73 97/11/05 16:12:27


#
# Project directories
#
# ROOT = top of source tree
# TMPDIR = location where .obj files should be stored during build
# TCLDIR = location of top of Tcl source heirarchy
#

ROOT	= ..
TMPDIR	= .
TOOLS	= c:\bc45
TCLDIR	= ..\..\tcl8.0

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

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

#
# Borland C++ tools
#

BORLAND = $(TOOLS)
IMPLIB  = $(BORLAND)\bin\Implib
BCC32   = $(BORLAND)\bin\Bcc32
TLINK32 = $(BORLAND)\bin\tlink32
RC	= $(BORLAND)\bin\brcc32
CP      = copy
RM      = del

INCLUDES =	$(BORLAND)\include;$(ROOT)\generic;$(ROOT)\bitmaps;$(ROOT)\xlib;$(ROOT)\win;$(TCLDIR)\generic
LIBDIRS =	$(BORLAND)\lib;$(ROOT)\win
TCLLIBDIR =	$(TCLDIR)\win


!ifndef DEBUG

# these macros cause maximum optimization and no symbols
DEBUGLDFLAGS = 
DEBUGCCFLAGS = -v- -vi- -O2

!else

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

!endif

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

LNFLAGS_exe = -Tpe -aa -c $(DEBUGLDFLAGS) $(BORLAND)\lib\c0w32
LNFLAGS_dll = -Tpd -aa -c $(DEBUGLDFLAGS) $(BORLAND)\lib\c0d32

LNLIBS_exe =	$(TKLIB) $(TCLLIBDIR)\$(TCLLIB) import32 cw32mti
LNLIBS_dll =	$(TCLLIBDIR)\$(TCLLIB) import32 cw32mti

# 
# Global makefile settings
#

.AUTODEPEND
.CACHEAUTODEPEND

.suffixes: .c .dll .lib .obj .exe

.path.c=$(ROOT)\win;$(ROOT)\generic;$(ROOT)\xlib;$(ROOT)\unix
.path.obj=$(TMPDIR)

WISHOBJS = \
	$(TMPDIR)\tkConsole.obj \
	$(TMPDIR)\winMain.obj

TKTESTOBJS = \
	$(TMPDIR)\tkConsole.obj \
	$(TMPDIR)\tkTest.obj \
	$(TMPDIR)\tkSquare.obj \
	$(TMPDIR)\testMain.obj

XLIBOBJS = \
	$(TMPDIR)\xcolors.obj \
	$(TMPDIR)\xdraw.obj \
	$(TMPDIR)\xgc.obj \
	$(TMPDIR)\ximage.obj \
	$(TMPDIR)\xutil.obj

TKOBJS = \
	$(TMPDIR)\tkUnixMenubu.obj \
	$(TMPDIR)\tkUnixScale.obj \
	$(XLIBOBJS) \
	$(TMPDIR)\tkWin3d.obj \
	$(TMPDIR)\tkWin32Dll.obj \
	$(TMPDIR)\tkWinButton.obj \
	$(TMPDIR)\tkWinClipboard.obj \
	$(TMPDIR)\tkWinColor.obj \
	$(TMPDIR)\tkWinCursor.obj \
	$(TMPDIR)\tkWinDialog.obj \
	$(TMPDIR)\tkWinDraw.obj \
	$(TMPDIR)\tkWinEmbed.obj \
	$(TMPDIR)\tkWinFont.obj \
	$(TMPDIR)\tkWinImage.obj \
	$(TMPDIR)\tkWinInit.obj \
	$(TMPDIR)\tkWinKey.obj \
	$(TMPDIR)\tkWinMenu.obj \
	$(TMPDIR)\tkWinPixmap.obj \
	$(TMPDIR)\tkWinPointer.obj \
	$(TMPDIR)\tkWinRegion.obj \
	$(TMPDIR)\tkWinScrlbr.obj \
	$(TMPDIR)\tkWinSend.obj \
	$(TMPDIR)\tkWinWindow.obj \
	$(TMPDIR)\tkWinWm.obj \
	$(TMPDIR)\tkWinX.obj \
	$(TMPDIR)\stubs.obj \
	$(TMPDIR)\tk3d.obj \
	$(TMPDIR)\tkArgv.obj \
	$(TMPDIR)\tkAtom.obj \
	$(TMPDIR)\tkBind.obj \
	$(TMPDIR)\tkBitmap.obj \
	$(TMPDIR)\tkButton.obj \
	$(TMPDIR)\tkCanvArc.obj \
	$(TMPDIR)\tkCanvBmap.obj \
	$(TMPDIR)\tkCanvImg.obj \
	$(TMPDIR)\tkCanvLine.obj \
	$(TMPDIR)\tkCanvPoly.obj \
	$(TMPDIR)\tkCanvPs.obj \
	$(TMPDIR)\tkCanvText.obj \
	$(TMPDIR)\tkCanvUtil.obj \
	$(TMPDIR)\tkCanvWind.obj \
	$(TMPDIR)\tkCanvas.obj \
	$(TMPDIR)\tkClipboard.obj \
	$(TMPDIR)\tkCmds.obj \
	$(TMPDIR)\tkColor.obj \
	$(TMPDIR)\tkConfig.obj \
	$(TMPDIR)\tkCursor.obj \
	$(TMPDIR)\tkEntry.obj \
	$(TMPDIR)\tkError.obj \
	$(TMPDIR)\tkEvent.obj \
	$(TMPDIR)\tkFileFilter.obj \
	$(TMPDIR)\tkFocus.obj \
	$(TMPDIR)\tkFont.obj \
	$(TMPDIR)\tkFrame.obj \
	$(TMPDIR)\tkGC.obj \
	$(TMPDIR)\tkGeometry.obj \
	$(TMPDIR)\tkGet.obj \
	$(TMPDIR)\tkGrab.obj \
	$(TMPDIR)\tkGrid.obj \
	$(TMPDIR)\tkImage.obj \
	$(TMPDIR)\tkImgBmap.obj \
	$(TMPDIR)\tkImgGIF.obj \
	$(TMPDIR)\tkImgPPM.obj \
	$(TMPDIR)\tkImgPhoto.obj \
	$(TMPDIR)\tkImgUtil.obj \
	$(TMPDIR)\tkListbox.obj \
	$(TMPDIR)\tkMacWinMenu.obj \
	$(TMPDIR)\tkMain.obj \
	$(TMPDIR)\tkMenu.obj \
	$(TMPDIR)\tkMenubutton.obj \
	$(TMPDIR)\tkMenuDraw.obj \
	$(TMPDIR)\tkMessage.obj \
	$(TMPDIR)\tkOption.obj \
	$(TMPDIR)\tkPack.obj \
	$(TMPDIR)\tkPlace.obj \
	$(TMPDIR)\tkPointer.obj \
	$(TMPDIR)\tkRectOval.obj \
	$(TMPDIR)\tkScale.obj \
	$(TMPDIR)\tkScrollbar.obj \
	$(TMPDIR)\tkSelect.obj \
	$(TMPDIR)\tkText.obj \
	$(TMPDIR)\tkTextBTree.obj \
	$(TMPDIR)\tkTextDisp.obj \
	$(TMPDIR)\tkTextImage.obj \
	$(TMPDIR)\tkTextIndex.obj \
	$(TMPDIR)\tkTextMark.obj \
	$(TMPDIR)\tkTextTag.obj \
	$(TMPDIR)\tkTextWind.obj \
	$(TMPDIR)\tkTrig.obj \
	$(TMPDIR)\tkUtil.obj \
	$(TMPDIR)\tkVisual.obj \
	$(TMPDIR)\tkWindow.obj

TCLDLL = tcl80.dll
TCLLIB = tcl80.lib
TKDLL = tk80.dll
TKLIB = tk80.lib
WISH = wish80.exe
TKTEST = tktest.exe

#
# Targets
#

all: cfgdll $(TKDLL) cfgexe $(WISH) cfgcln
tktest: cfgdll $(TKDLL) cfgtest $(TKTEST) cfgcln

test: tktest
	$(TKTEST) &&|
		cd ../tests
		console show
		update
		source all
|

# Implicit Targets

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

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

.rc.res:
	$(RC) -i$(INCLUDES) $<

#
# Special case object file targets
#

$(TMPDIR)\testMain.obj : $(ROOT)\win\winMain.c
	$(BCC32) -c -o$@ $(ROOT)\win\winMain.c

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

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

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

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

cfgcln:
	@$(RM) bcc32.cfg

#
# Executable targets
#

$(TKDLL): $(TKOBJS) tk.def rc\tk.res
	$(TLINK32) @&&|
$(LNFLAGS_dll) $(TKOBJS)
$@
-x
$(LNLIBS_dll)
tk.def
rc\tk.res
|

$(WISH): $(WISHOBJS) $(TKLIB) rc\wish.res
	$(TLINK32) @&&|
$(LNFLAGS_exe) $(WISHOBJS)
$@
-x
$(LNLIBS_exe)
|, &&|
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
|, rc\wish.res

$(TKTEST): $(TKTESTOBJS) $(TKLIB)
	$(TLINK32) $(LNFLAGS_exe) @&&|
$(TKTESTOBJS)
$@
-x
$(LNLIBS_exe)
|, &&|
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
|, 

# 
# Other dependencies
#

rc\wish.res: rc\wish.ico
rc\tk.res: rc\tk.ico rc\*.cur

# The following rule automatically generates a tk.def file containing
# an export entry for every public symbol in the $(TKDLL) library.

tk.def: $(TKOBJS)
	$(TCLLIBDIR)\dumpexts.exe -o $@ $(TKDLL) @&&|
		$(TKOBJS)
|

# rule to build library object files

# debugging rules, the .dll and .exe files must be in the same
# directory as the object files for debugging purposes

$(TMPDIR)\$(TKDLL): $(TKDLL)
	$(CP) $(TKDLL) $(TMPDIR)

$(TMPDIR)\$(TCLDLL): $(TCLLIBDIR)\$(TCLDLL)
	$(CP) $(TCLLIBDIR)\$(TCLDLL) $(TMPDIR)

$(TMPDIR)\$(WISH): $(WISH)
	$(CP) $(WISH) $(TMPDIR)

$(TMPDIR)\$(TKTEST): $(TKTEST)
	$(CP) $(TKTEST) $(TMPDIR)

debug: $(TMPDIR)\$(TKDLL) $(TMPDIR)\$(TCLDLL) $(TMPDIR)\$(TKTEST)


# remove all generated files

clean:
	$(RM) $(WISH)
	$(RM) $(TKTEST)
	$(RM) $(TKLIB) 
	$(RM) $(TKDLL)  
	$(RM) rc\*.res  
	$(RM) tk.def
	$(RM) $(TMPDIR)\*.obj
	$(RM) *.cfg
