
# ------------------------------------------------------------------------
# 	Makefile for BLT library using BCC55.
# ------------------------------------------------------------------------

.SUFFIXES: .obj .c

!include     ..\win\makedefs

prefix =	C:\Program Files\Tcl
exec_prefix =	$(prefix)
includedir =	$(prefix)\include
bindir =	$(prefix)\bin
libdir =	$(prefix)\lib
scriptdir =	$(libdir)\blt$(BLT_VERSION)
BLT_LIBRARY =	$(libdir)\blt$(BLT_VERSION)
TCLLIBPATH =	$(libdir)\tcl$(v1)

SHLIB_SUFFIX =	.dll

SHELL =		bash.exe
RM =		-del

TOOLS32       =	c:\Borland\BCC55

AR            =	$(TOOLS32)\bin\implib.exe
LD            =	$(TOOLS32)\bin\ilink32.exe
CC            =	$(TOOLS32)\bin\bcc32.exe
rc32          =	$(TOOLS32)\bin\rc.exe

!if ($(WITH_JPEG) == 0)
EXTRA_DEFINES = 
!endif
!if ($(WITH_JPEG) == 1)
EXTRA_DEFINES = -DHAVE_JPEGLIB_H=1
JPEGDIR       =	$(srcdir)\..\..\jpeg-6b
JPEGLIB =	$(JPEGDIR)\libjpeg.lib
JPEGINC	      = $(JPEGDIR)
!endif
!if ($(WITH_JPEG) == 2)
EXTRA_DEFINES = -DHAVE_IJL_H=1 
JPEGDIR       =	c:\Program\ Files\Intel\IJL
JPEGLIB	      =	$(JPEGDIR)\lib\ijl15l.lib
JPEGINC	      = $(JPEGDIR)\Include
!endif

# ------------------------------------------------------------------------
# 	C Compiler options 
# ------------------------------------------------------------------------

DEFINES       =	-D__STDC__ -DWIN32 -DCONSOLE -D_MT -DNO_STRICT -D_NO_VCL \
		$(DEBUG_DEFINES) $(SHLIB_DEFINES) $(EXTRA_DEFINES) 

!if ($(SHARED) == 1)
SHLIB_DEFINES =	-D_DLL  
SHLIB_TARGET  =	build-dll
LIBS          =	$(COMMON_LIBS) $(EXTRA_LIBS)
!else
SHLIB_CFLAGS  = 
SHLIB_DEFINES =	
LIBS          =	$(COMMON_LIBS) $(EXTRA_LIBS)
!endif

!if ($(DEBUG) == 1)
#   -Od		Disable all optimizations.
#   -k		Turn on standard stack frame.
#   -r-		Disable use of registers.
#   -v		Turn on source debugging.
#   -vG		All code guard options on.
#   -vi-	Turn off expansion of inline functions.
#   -y		Debug line numbers on.
DEBUG_CFLAGS  =	-v -k -Od -vi- -y -r- -lv -tW -tWM
#   -v		Turn on source debugging.
DEBUG_LDFLAGS =	-v
DEBUG_DEFINES = -DUSE_TCLALLOC=0
DEBUG_DEFINES = 
TK_LIB        =	$(TKDIR)\win\Debug\tk$(v2)d.lib
TCL_LIB       =	$(TCLDIR)\win\Debug\tcl$(v2)d.lib
MSVCRT        =	
!else
#   -v-		Turn off source debugging.
#   -vi-	Turn off expansion of inline functions.
#   -O2		Generate fastest code possible.
DEBUG_CFLAGS  =	-v- -vi- -O2 -D_DEBUG
DEBUG_LDFLAGS =	
TK_LIB        =	$(TKDIR)\win\Release\tk$(v2).lib
TCL_LIB       =	$(TCLDIR)\win\Release\tcl$(v2).lib
MSVCRT        =	
!endif

# Turn off the following bcc warnings:
#   -w-pro	Call to function with no prototype
#   -w-par	Parameter is never used.
#   -w-sus 	Suspicious pointer conversion (bltCanvEps.c).
#
WARNINGS      =	-w-pro -w-par -w-eff -w-sus 

#   -q		Suppress compiler identification banner.
#   -g1		Stop after the first warning.
#   -tWC	Target is a Windows console application.
#   -X		Disable compiler autodependency output.
#   -ps		Use stdcall calling convention.

EXTRA_CFLAGS  =	-q -g1 -tWC -X 

CFLAGS	      = $(WARNINGS) $(DEBUG_CFLAGS) $(SHLIB_CFLAGS) $(EXTRA_CFLAGS)

# ------------------------------------------------------------------------
# 	Linker flags and options 
# ------------------------------------------------------------------------

#   -D		Save specified description.
#   -w		Turn on warnings.
#   -c		Treate case as significant in symbols.
#   -x 	        
#   -Gi		Generate .lib file.
#   -r		Verbose linking.
#   -x		Suppresses map creation.
COMMON_LDFLAGS = -D"" -w -c -x $(DEBUG_LDFLAGS) -L$(TOOLS32)\lib

SHLIB_LDFLAGS  = $(COMMON_LDFLAGS) -x -Gi -Tpd $(TOOLS32)\lib\c0d32

LDFLAGS =	$(COMMON_LDFLAGS) -x -Tpe -S:2400000

COMMON_LIBS   =	$(TK_LIB) $(TCL_LIB) import32 cw32

EXTRA_LIBS    =	$(OLELIB) \
		$(JPEGLIB) 

TCL_ONLY_COMMON_LIBS = $(TCL_LIB) import32 cw32
TCL_ONLY_LIBS =	$(TCL_ONLY_COMMON_LIBS) $(EXTRA_LIBS)

# ------------------------------------------------------------------------
# 	Source and target installation directories 
# ------------------------------------------------------------------------

srcdir        =	.
instdirs      =	$(prefix) $(exec_prefix) $(bindir) $(libdir) $(includedir)
instdirs      =	$(exec_prefix) $(prefix) $(libdir)

# ------------------------------------------------------------------------
# 	Directories containing Tcl and Tk include files and libraries
# ------------------------------------------------------------------------

TCLDIR        =	$(srcdir)\..\..\tcl$(v3)
TKDIR         =	$(srcdir)\..\..\tk$(v3)
INCLUDES      =	-I. -I$(srcdir) \
		-I$(TOOLS32)\include \
		-I$(JPEGINC) \
		-I$(TCLDIR)\win -I$(TCLDIR)\generic \
		-I$(TKDIR)\win -I$(TKDIR)\generic -I$(TKDIR)\xlib \

SHLIB_LD_LIBS =	$(COMMON_LIBS) $(EXTRA_LIBS)
SHLIB_TCL_ONLY_LIBS =	$(COMMON_LIBS) $(EXTRA_LIBS)

# ------------------------------------------------------------------------
# 	You don't need to edit anything beyond this point
# ------------------------------------------------------------------------

N_OBJS       =	bltTed.obj
V3_OBJS       =	bltTri.obj bltGrMt.obj 

TK_OBJS       =	tkButton.obj tkFrame.obj tkScrollbar.obj 

GRAPH_OBJS =	bltGrAxis.obj \
		bltGrBar.obj \
		bltGrElem.obj \
		bltGrGrid.obj \
		bltGrHairs.obj \
		bltGrLegd.obj \
		bltGrLine.obj \
		bltGrMarker.obj \
		bltGrMisc.obj \
		bltGrPen.obj \
		bltGrPs.obj \
		bltGraph.obj 

TCL_ONLY_OBJS =	bltAlloc.obj \
		bltArrayObj.obj \
		bltBgexec.obj \
		bltChain.obj \
		bltDebug.obj \
		bltHash.obj \
		bltList.obj \
		bltNsUtil.obj \
		bltParse.obj \
		bltPool.obj \
		bltSpline.obj \
		bltSwitch.obj \
		bltTree.obj \
		bltTreeCmd.obj \
		bltUtil.obj \
		bltVecCmd.obj \
		bltVecMath.obj \
		bltVecObjCmd.obj \
		bltVector.obj \
		bltWatch.obj  \
		bltWinPipe.obj \
		bltWinUtil.obj \
		bltWinDde.obj


DEMO_OBJS     =	tkConsole.obj bltWinMain.obj

OBJS =		$(GRAPH_OBJS) \
		$(TCL_ONLY_OBJS) \
		bltBeep.obj \
		bltBind.obj \
		bltBitmap.obj \
		bltBusy.obj \
		bltCanvEps.obj \
		bltConfig.obj \
		bltContainer.obj \
		bltDragdrop.obj \
		bltHierbox.obj \
		bltHtext.obj \
		bltImage.obj \
		bltWinImage.obj \
		bltPs.obj \
		bltTable.obj \
		bltTabnotebook.obj \
		bltTabset.obj \
		bltText.obj \
		bltTile.obj \
		bltTreeView.obj \
		bltTreeViewCmd.obj \
		bltTreeViewEdit.obj \
		bltTreeViewColumn.obj \
		bltTreeViewStyle.obj \
		bltWinDraw.obj \
		bltWinPrnt.obj \
		bltWindow.obj \
		bltObjConfig.obj \
		bltWinop.obj \
		$(TK_OBJS) $(N_OBJS) 

NOT_YET       =	bltContainer.obj bltCutBuffer.obj bltColor.obj

HEADERS       =	blt.h bltChain.h bltVector.h bltTree.h bltPool.h bltHash.h

# GNU Make-specific macro
SRCS          =	$(patsubst %.obj,$(srcdir)\%.c,$(OBJS)) 

shell_name    = bltwish
version       =	$(BLT_MAJOR_VERSION)$(BLT_MINOR_VERSION)
bltwish =	bltwish.exe
bltsh =		bltsh.exe

lib_name =	BLT$(version)
lib_a =		BLT$(version).lib
lib_so =	BLT$(version).dll		
tcl_only_lib_a = BLTlite$(version).lib
tcl_only_lib_so = BLTlite$(version).dll		

CC_SWITCHES   =	$(CFLAGS) $(DEFINES) $(INCLUDES)
VPATH         =	$(srcdir)

all: build-library build-demos

build-demos: $(bltsh) $(bltwish) 

build-library: $(lib_a) $(tcl_only_lib_a)

build-dll: build-library $(lib_so) $(tcl_only_lib_so)

$(bltwish): $(lib_a) tkConsole.obj  bltWinMain.c
	-del $(bltwish) 2>nul
	$(CC) -c $(CC_SWITCHES) -DTCLLIBPATH="\"$(TCLLIBPATH)\"" \
		-obltWinMain.obj $(srcdir)\bltWinMain.c
	$(LD) $(LDFLAGS) -aa $(TOOLS32)\lib\c0w32 \
		tkConsole.obj bltWinMain.obj, \
		$(bltwish),, $(lib_a) $(LIBS) 

$(bltsh): $(tcl_only_lib_a) bltWinMain.c
	-del $(bltsh) 2>nul 
	$(CC) -c $(CC_SWITCHES) -DTCL_ONLY \
		-DTCLLIBPATH="\"$(TCLLIBPATH)\"" \
		-obltWinMain.obj $(srcdir)\bltWinMain.c
	$(LD) $(LDFLAGS) -ap $(TOOLS32)\lib\c0x32 bltWinMain.obj, \
		$(bltsh),, $(tcl_only_lib_a) $(TCL_ONLY_LIBS) 

$(lib_a):  $(lib_so) bltHash.h $(OBJS) bltInit.c
	-del bltInit.obj 2>nul
	$(CC) -c $(CC_SWITCHES)  -DBLT_LIBRARY="\"$(BLT_LIBRARY)\"" \
		-obltInit.obj $(srcdir)\bltInit.c
	-del $@ 2>nul
	$(AR) $@ $(lib_so)

$(lib_so): $(OBJS) bltInit.c
	-del bltInit.obj 2>nul
	$(CC) -c $(CC_SWITCHES) -DBLT_LIBRARY="\"$(BLT_LIBRARY)\"" \
		-obltInit.obj $(srcdir)\bltInit.c
	-del $@ 2>nul
	$(LD) $(SHLIB_LDFLAGS) bltInit.obj $(OBJS), $@,, $(LIBS) 

$(tcl_only_lib_a):  $(tcl_only_lib_so) bltHash.h $(TCL_ONLY_OBJS) bltInit.c
	-del bltInit.obj 2>nul
	$(CC) -c $(CC_SWITCHES) -DTCL_ONLY -DBLT_LIBRARY="\"$(BLT_LIBRARY)\"" \
		-obltInit.obj $(srcdir)\bltInit.c
	-del $@ 2>nul
	$(AR) $@ $(tcl_only_lib_so)

$(tcl_only_lib_so): $(TCL_ONLY_OBJS) bltInit.c
	-del bltInit.obj 2>nul
	$(CC) -c $(CC_SWITCHES) -DTCL_ONLY -DBLT_LIBRARY="\"$(BLT_LIBRARY)\"" \
		-obltInit.obj $(srcdir)\bltInit.c
	-del $@ 2>nul
	$(LD) $(SHLIB_LDFLAGS) bltInit.obj $(TCL_ONLY_OBJS), $@, -x, \
		$(TCL_ONLY_LIBS),,

bltHash.h: bltHash.h.in
	sed -e 's/@SIZEOF_VOID_P@/4/' \
	    -e 's/@SIZEOF_INT@/4/' \
	    -e 's/@SIZEOF_LONG@/4/' \
	    -e 's/@SIZEOF_LONG_LONG@/8/' \
	    -e 's/@HAVE_INTTYPES_H@/0/' \
	    bltHash.h.in > bltHash.h

clean:
	-del *.obj 2>nul
	-del *.pdb 2>nul
	-del *.exp 2>nul
	-del $(lib_a) 2>nul
	-del $(lib_so) 2>nul
	-del $(tcl_only_lib_a) 2>nul
	-del $(tcl_only_lib_so) 2>nul
	-del $(bltwish) 2>nul
	-del $(bltsh) 2>nul
	-del $(srcdir)\*.bak 2>nul
	-del $(srcdir)\*~ 2>nul 
	-del $(srcdir)\"#"* 2>nul
	-del *.pdb 2>nul
	-del *.ilf 2>nul
	-del *.ils 2>nul
	-del *.ilc 2>nul
	-del *.ild 2>nul
	-del *.tds 2>nul
	-del *.td2 2>nul
	-del *.TR2 2>nul

.c.obj:
	$(CC) -c $(CC_SWITCHES) $<

