#------------------------------------------------------------- -*- makefile -*-
#
# Makefile
#
# Basic build, test and install
#   nmake /f makefile.vc INSTALLDIR=c:\tcl TCLDIR=c:\path\to\tcl\sources TKDIR=c:\path\to\tk\sources
#   nmake /f makefile.vc INSTALLDIR=c:\tcl test TCLDIR=c:\path\to\tcl\sources TKDIR=c:\path\to\tk\sources
#   nmake /f makefile.vc INSTALLDIR=c:\tcl install TCLDIR=c:\path\to\tcl\sources TKDIR=c:\path\to\tk\sources
# Note this extension needs both Tcl and Tk *source* to build.
#
# For other build options (debug, static etc.),
# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for
# detailed documentation.
#
#------------------------------------------------------------------------------


PROJECT = tkimg
PRJ_PACKAGE_NAME = img::base

NEED_TK_SOURCE = 1
NEED_TCL_SOURCE = 1

!include "..\..\win\rules-ext.vc"

PRJ_OBJS = \
	$(TMP_DIR)\tkimg.obj \
	$(TMP_DIR)\tkimgIO.obj \
	$(TMP_DIR)\tkimgMap.obj \
	$(TMP_DIR)\tkimgPPB.obj \
	$(TMP_DIR)\tkimgUtils.obj \
	$(TMP_DIR)\tkimgStubInit.obj \
	$(TMP_DIR)\tkimgStubLib.obj

PRJ_STUBOBJS = $(TMP_DIR)\tkimgStubLib.obj

PRJ_DEFINES = -DTKIMGAPI=MODULE_SCOPE
PRJ_DEFINES = $(PRJ_DEFINES) -I$(TMP_DIR)

DISABLE_TARGET_install = 1
!include "$(_RULESDIR)\targets.vc"

# We define our own install target because the built-in install target
# will install to a directory named after the project (tkimg) while we
# want it to be named Img. We cannot change the PROJECT=tkimg
# definition above because the configure.ac script above uses that
# name and we extract versioning information from it.
!ifdef TKIMG_INSTALL_SUBDIR
IMG_INSTALL_DIR = $(_INSTALLDIR)\$(TKIMG_INSTALL_SUBDIR)
!else
IMG_INSTALL_DIR = $(SCRIPT_INSTALL_DIR)
!endif

$(TMP_DIR)\manifest.uuid:
	copy svnmanifest.in $(TMP_DIR)\manifest.uuid
        @if exist "manifest.uuid" copy manifest.uuid $(TMP_DIR)\manifest.uuid
        @if not exist "manifest.uuid" svn info --show-item last-changed-revision >>$(TMP_DIR)\manifest.uuid

$(TMP_DIR)\tkimgUuid.h:	$(TMP_DIR)\manifest.uuid
	copy tkimgUuid.h.in+$(TMP_DIR)\manifest.uuid $(TMP_DIR)\tkimgUuid.h

$(TMP_DIR)\tkimg.obj: $(TMP_DIR)\tkimgUuid.h

install:
	@echo Installing binaries to '$(IMG_INSTALL_DIR)'
	@if not exist "$(IMG_INSTALL_DIR)" mkdir "$(IMG_INSTALL_DIR)"
	@$(CPY) $(PRJLIB) "$(IMG_INSTALL_DIR)" >NUL
	@echo Installing libraries to '$(IMG_INSTALL_DIR)'
	@if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(IMG_INSTALL_DIR)"
	@echo Installing package index in '$(IMG_INSTALL_DIR)'
	@$(CPY) $(OUT_DIR)\pkgIndex.tcl $(IMG_INSTALL_DIR)
	@echo Installing stubs library to '$(IMG_INSTALL_DIR)'
	@if not exist "$(IMG_INSTALL_DIR)" mkdir "$(IMG_INSTALL_DIR)"
	@$(CPY) $(PRJSTUBLIB) "$(IMG_INSTALL_DIR)" >NUL

pkgindex: default-pkgindex-tea
