# Makefile
#
# This makefile builds tkogl.dll, a dynamically loadable Tcl extension
# that implements a Tk OpenGL widget.
# This makefile is suitable for use with
# Borland C++ 5.0.
#
#

PROJECT	= tkogl

#
# Project directories -- these may need to be customized for your site
#
# ROOT --	location of the example files.
# TMPDIR --	location for .obj files.
# BORLAND --	location of Borland compiler installation.
# TCL --	location where Tcl is installed. (binary release)
# TCLTKSRC -- location where tk4.1 and tck7.5 source directories are
# OPENGLDLL -- location where OpenGL dll's are
#

ROOT	= .
TMPDIR	= .
BORLAND	= d:\bc5
TCL	= d:\Tcl
TCLTKSRC = d:\claudio
OPENGLDLL = c:\windows\system

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

#
# Borland C++ tools
#

IMPLIB  = $(BORLAND)\bin\Implib
BCC32   = $(BORLAND)\bin\Bcc32
TLINK32 = $(BORLAND)\bin\tlink32

CP      = copy
RM      = del

INCLUDES = $(BORLAND)\include;$(TCL)\include;$(TCLTKSRC)\Tcl7.5\win;$(TCLTKSRC)\Tcl7.5\generic;$(TCLTKSRC)\Tk4.1\win;$(TCLTKSRC)\Tk4.1\generic
LIBDIRS	= $(BORLAND)\LIB;$(ROOT)

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

LNFLAGS_dll = -Tpd -aa -c $(DEBUGLDFLAGS) $(BORLAND)\lib\c0d32
LNLIBS_dll = tcl75 tk41 import32 cw32i

# 
# Global makefile settings
#

.AUTODEPEND
.CACHEAUTODEPEND

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

.path.obj=$(TMPDIR)
.path.dll=$(ROOT);$(TCL)\bin

DLLOBJS = \
	$(PROJECT).obj \
    get.obj \
    glphoto.obj \
    gencyl.obj \
    load3ds.obj \
    nurbs.obj \
    quadric.obj \
    tess.obj \
    printstr.obj \
    tkoglparse.obj


# Targets

all: pkgIndex.tcl

pkgIndex.tcl: cfgdll $(PROJECT).dll
	$(TCL)\bin\tclsh75 &&|
		pkg_mkIndex $(ROOT) $(PROJECT).dll
|

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

Opengl32.lib: $(OPENGLDLL)\Opengl32.dll
	$(IMPLIB) -c Opengl32.lib $(OPENGLDLL)\Opengl32.dll

Glu32.lib: $(OPENGLDLL)\Glu32.dll
	$(IMPLIB) -c Glu32.lib $(OPENGLDLL)\Glu32.dll

tcl75.lib: $(TCL)\bin\tcl75.dll
	$(IMPLIB) -c tcl75.lib $(TCL)\bin\tcl75.dll

tk41.lib: $(TCL)\bin\tk41.dll
	$(IMPLIB) -c tk41.lib $(TCL)\bin\tk41.dll

$(PROJECT).dll: $(DLLOBJS) Opengl32.lib tcl75.lib tk41.lib Glu32.lib
	$(TLINK32) $(LNFLAGS_dll) @&&|
        $(DLLOBJS) Opengl32.lib tcl75.lib tk41.lib Glu32.lib
$@
-x
$(LNLIBS_dll)
|,,,


# Implicit Targets

.c.obj:
	$(BCC32) -n$(TMPDIR) -d -w- $(PROJECTCCFLAGS) {$< }

clean:
	-$(RM) *.obj
	-$(RM) *.dll
	-$(RM) *.lib
	-$(RM) pkgIndex.tcl



