#------------------------------------------------------------- -*- makefile -*-
#
# Sample makefile for building Tcl extensions.
#
# Basic build, test and install
#   nmake /s /nologo /f makefile.vc INSTALLDIR=c:\path\to\tcl
#   nmake /s /nologo /f makefile.vc INSTALLDIR=c:\path\to\tcl test
#   nmake /s /nologo /f makefile.vc INSTALLDIR=c:\path\to\tcl install
#
#
# For other build options (debug, static etc.)
# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for
# detailed documentation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#------------------------------------------------------------------------------

# Package definitions

PROJECT = tko
NEED_TCL_SOURCE = 1
NEED_TK_SOURCE = 1
NEED_TK = 1
PRJ_LIBS = gdiplus.lib opengl32.lib glu32.lib
USE_GRAPH = 1
USE_PATH = 1

!include "rules-ext.vc"

# Define any additional compiler flags that might be required for the project
PRJ_DEFINES = -D_CRT_SECURE_NO_DEPRECATE
#PRJ_DEFINES	=  -DHAVE_INTPTR_T=1 -DNO_VIZ=/\*\*/ -DPACKAGE_PATCHLEVEL=\"$(PACKAGE_PATCHLEVEL)\" -D_CRT_SECURE_NO_WARNINGS

# Define the object files and resource file that make up the extension.
# Note the resource file does not makes sense if doing a static library build
# hence it is under that condition. TMP_DIR is the output directory
# defined by rules for object files.
PRJ_OBJS = \
	$(TMP_DIR)\tkoWidget.obj \
	$(TMP_DIR)\tkoFrame.obj
!if "$(USE_GRAPH)" == "1"
PRJ_OBJS = $(PRJ_OBJS)\
	$(TMP_DIR)\tkoGraph.obj \
	$(TMP_DIR)\tkoGraphAxis.obj \
	$(TMP_DIR)\tkoGraphBar.obj \
	$(TMP_DIR)\tkoGraphConfig.obj \
	$(TMP_DIR)\tkoGraphElem.obj \
	$(TMP_DIR)\tkoGraphGrid.obj \
	$(TMP_DIR)\tkoGraphHairs.obj \
	$(TMP_DIR)\tkoGraphLegd.obj \
	$(TMP_DIR)\tkoGraphLine.obj \
	$(TMP_DIR)\tkoGraphMarker.obj \
	$(TMP_DIR)\tkoGraphMisc.obj \
	$(TMP_DIR)\tkoGraphPen.obj \
	$(TMP_DIR)\tkoGraphPs.obj \
	$(TMP_DIR)\tkoRbcBind.obj \
	$(TMP_DIR)\tkoRbcChain.obj \
	$(TMP_DIR)\tkoRbcImage.obj \
	$(TMP_DIR)\tkoRbcText.obj \
	$(TMP_DIR)\tkoRbcTile.obj \
	$(TMP_DIR)\tkoRbcUtil.obj \
	$(TMP_DIR)\tkoRbcWindow.obj \
	$(TMP_DIR)\tkoRbcWinDraw.obj \
	$(TMP_DIR)\tkoRbcWinImage.obj \
	$(TMP_DIR)\tkoVector.obj \
	$(TMP_DIR)\tkoVectorMath.obj \
	$(TMP_DIR)\tkoVectorObjCmd.obj
PRJ_DEFINES = $(PRJ_DEFINES) -DTKO_USE_GRAPH
!endif
!if "$(USE_PATH)" == "1"
PRJ_OBJS = $(PRJ_OBJS)\
	$(TMP_DIR)\tkoPath.obj \
	$(TMP_DIR)\tkoPathCanvArrow.obj \
	$(TMP_DIR)\tkoPathCanvEllipse.obj \
	$(TMP_DIR)\tkoPathCanvGroup.obj \
	$(TMP_DIR)\tkoPathCanvImage.obj \
	$(TMP_DIR)\tkoPathCanvLine.obj \
	$(TMP_DIR)\tkoPathCanvPath.obj \
	$(TMP_DIR)\tkoPathCanvPoly.obj \
	$(TMP_DIR)\tkoPathCanvRect.obj \
	$(TMP_DIR)\tkoPathCanvText.obj \
	$(TMP_DIR)\tkoPathCanvWindow.obj \
	$(TMP_DIR)\tkoPathGeneric.obj \
	$(TMP_DIR)\tkoPathGradient.obj \
	$(TMP_DIR)\tkoPathStyle.obj \
	$(TMP_DIR)\tkoPathSurface.obj \
	$(TMP_DIR)\tkoPathUtil.obj \
	$(TMP_DIR)\tkoPath_WinGDIPlus.obj
PRJ_DEFINES = $(PRJ_DEFINES) -DTKO_USE_PATH
!endif

# Define the standard targets
!include "$(_RULESDIR)\targets.vc"

# We must define a pkgindex target that will create a pkgIndex.tcl
# file in the $(OUT_DIR) directory. We can just redirect to the
# default-pkgindex target for our sample extension.
pkgindex: default-pkgindex-tea

# The default install target only installs binaries and scripts so add
# an additional target for our documentation. Note this *adds* a target
# since no commands are listed after it. The original targets for
# install (from targets.vc) will remain.
install: default-install-docs-n
release: default-target

install-tko:
	@echo Installing images to '$(SCRIPT_INSTALL_DIR)\imgs'
	@if not exist "$(SCRIPT_INSTALL_DIR)\imgs" mkdir "$(SCRIPT_INSTALL_DIR)\imgs"
	if exist $(LIBDIR)\imgs $(CPY) $(LIBDIR)\imgs\*.png "$(SCRIPT_INSTALL_DIR)\imgs"

$(TMP_DIR)\tkoPath_WinGDIPlus.obj: $(WIN_DIR)\tkoPath_WinGDIPlus.cpp
	$(CCPKGCMD) -Fo$@ $?

