# -----------------------------------------------------------------------------
# VC binaries & libs
# -----------------------------------------------------------------------------

VCDIR		= C:\program files\microsoft visual studio\VC98
TOOLS32		= "$(VCDIR)\bin"
VCLIBDIR	= -libpath:"$(VCDIR)\lib"

# -----------------------------------------------------------------------------
# BuildTools
# -----------------------------------------------------------------------------

CC		= cl.exe -nologo -TC
LIB		= lib.exe -nologo
LINK		= link.exe -nologo
MAKE		= nmake.exe -nologo
CP		= copy
RM		= del
MKDIR		= mkdir

# -----------------------------------------------------------------------------
# Tcl instalation
# -----------------------------------------------------------------------------

TCLDIR		= C:\tcl83
TCLVER		= 83
#TCLDIR		= D:\tcl84cvs
#TCLVER		= 84
TCLFLAGS	= -DUSE_TCL_STUBS -DUSE_TK_STUBS
TCLLIBS		= tclstub$(TCLVER).lib tkstub$(TCLVER).lib
TCLINCDIR	= -I$(TCLDIR)\include -I. -ID:\tcl83\src\tcl8.3.1\generic -ID:\tcl83\src\tk8.3.1\win -ID:\tcl83\src\tk8.3.1\generic
# -IZ:\misc\tcl-tk\src\tk\generic
TCLLIBDIR	= -libpath:$(TCLDIR)\lib
TCLSH		= $(TCLDIR)\bin\tclsh$(TCLVER).exe
WISH		= $(TCLDIR)\bin\wish$(TCLVER).exe


LIBS =  glu32.lib opengl32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

# -----------------------------------------------------------------------------
# Link flags
# -----------------------------------------------------------------------------

# declarations common to all linker options
LIBDIRS	= $(VCLIBDIR) $(TCLLIBDIR)
LFLAGS	= -nodefaultlib -release -machine:IX86 $(LIBDIRS)
# -align:0x1000

# declarations for use on Intel i386, i486, and Pentium systems
DLLENTRY 	= @12
DLLLFLAGS	= $(LFLAGS) -entry:_DllMainCRTStartup$(DLLENTRY) -dll
EXELFLAGS	= $(LFLAGS) -entry:_WinMain
LIBCDLL 	= msvcrt.lib
CONLIBSDLL	= libc.lib kernel32.lib
DLLLIBS		= $(TCLLIBS) $(CONLIBSDLL)

# -----------------------------------------------------------------------------
# Compile flags
# -----------------------------------------------------------------------------

INCDIRS 	= $(TCLINCDIR)
CFLAGS		= $(TCLFLAGS) -Ox -ML -DWIN32 -W3 -DDEBUG -DLOADABLE -DUSE_LOCAL_TK_H $(INCDIRS)

DEMOS	= togl.dll texture.dll index.dll gears.dll double.dll

.c.obj:
	$(CC) $(CFLAGS) -c $< -Fo$@

all: $(DEMOS)

togl.dll: togl.obj
	$(LINK) $(DLLLFLAGS) togl.obj -out:$@ $(LIBS) $(DLLLIBS)

double.dll: togl.obj double.obj
	$(LINK) $(DLLLFLAGS) togl.obj double.obj -out:$@ $(LIBS) $(DLLLIBS)

texture.dll: togl.obj image.obj texture.obj
	$(LINK) $(DLLLFLAGS) togl.obj image.obj texture.obj -out:$@ $(LIBS) $(DLLLIBS)

index.dll: togl.obj index.obj
	$(LINK) $(DLLLFLAGS) togl.obj index.obj -out:$@ $(LIBS) $(DLLLIBS)

overlay.dll: togl.obj overlay.obj
	$(LINK) $(DLLLFLAGS) togl.obj overlay.obj -out:$@ $(LIBS) $(DLLLIBS)

gears.dll: togl.obj gears.obj
	$(LINK) $(DLLLFLAGS) togl.obj gears.obj -out:$@ $(LIBS) $(DLLLIBS)

load: togl.dll
	echo load togl.dll ; exit | $(WISH)

rundemos: index.dll
	$(WISH) index.tcl
	

pkgIndex.tcl: togl.dll
	echo pkg_mkIndex . togl.dll | $(TCLSH)

clean:
	erase *.obj
	erase *.dll
	erase *.lib
	erase *.exp

all: togl.dll

