summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/makefile.vc17
-rw-r--r--win/nmakehlp.c10
-rw-r--r--win/rules-ext.vc85
-rw-r--r--win/rules.vc237
-rw-r--r--win/targets.vc21
5 files changed, 309 insertions, 61 deletions
diff --git a/win/makefile.vc b/win/makefile.vc
index e1cad48..97d07dc 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -174,13 +174,11 @@ DEFAULT_BUILD_TARGET = release
# The rules.vc file does much of the hard work in terms of defining
# the build configuration, macros, output directories etc.
-!include "../../tcl/win/rules.vc"
-
-TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
-TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
+!include "rules-ext.vc"
# TCLINSTALL is set to 1 by rules.vc to indicate we are building against
# an installed Tcl and 0 if building against Tcl source. Tk needs the latter.
+!message TCLINSTALL=$(TCLINSTALL)
!if $(TCLINSTALL)
!message *** Warning: Tk requires the source distribution of Tcl to build from,
!message *** at this time, sorry. Please set the TCLDIR macro to point to the
@@ -206,7 +204,7 @@ TTK_SQUARE_WIDGET = 0
!endif
!endif
-WISHC = "$(OUT_DIR)\$(WISHNAMEPREFIX)c$(TK_VERSION)$(SUFX).exe"
+WISHC = "$(OUT_DIR)\$(WISHNAMEPREFIX)c$(VERSION)$(SUFX).exe"
TKTEST = "$(OUT_DIR)\$(PROJECT)test.exe"
CAT32 = "$(OUT_DIR)\cat32.exe"
@@ -419,6 +417,7 @@ TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
!endif
+!include targets.vc
#---------------------------------------------------------------------
# Project specific targets
#---------------------------------------------------------------------
@@ -562,7 +561,7 @@ HHC=hhc.exe
!endif
!endif
HTMLDIR=$(ROOT)\html
-HTMLBASE=TclTk$(VERSION)
+HTMLBASE=TclTk$(TCL_VERSION)
HHPFILE=$(HTMLDIR)\$(HTMLBASE).hhp
CHMFILE=$(HTMLDIR)\$(HTMLBASE).chm
@@ -578,7 +577,7 @@ Compiled file=$(HTMLBASE).chm
Display compile progress=no
Error log file=$(HTMLBASE).log
Language=0x409 English (United States)
-Title=Tcl/Tk $(DOT_VERSION) Help
+Title=Tcl/Tk $(TCL_DOTVERSION) Help
[FILES]
contents.htm
docs.css
@@ -640,7 +639,7 @@ $(TMP_DIR)\tkStubLib.obj : $(GENERICDIR)\tkStubLib.c
$(TMP_DIR)\wish.exe.manifest: $(WINDIR)\wish.exe.manifest.in
@nmakehlp -s << $** >$@
@MACHINE@ $(MACHINE:IX86=X86)
-@TK_WIN_VERSION@ $(TK_DOTVERSION).0.0
+@TK_WIN_VERSION@ $(DOTVERSION).0.0
<<
#---------------------------------------------------------------------
@@ -727,7 +726,7 @@ install-binaries:
if {[catch {package present Tcl 8.6.0}]} { return }
if {($$::tcl_platform(platform) eq "unix") && ([info exists ::env(DISPLAY)]
|| ([info exists ::argv] && ("-display" in $$::argv)))} {
- package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin libtk$(TK_DOTVERSION).dll] Tk]
+ package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin libtk$(DOTVERSION).dll] Tk]
} else {
package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin $(TKLIBNAME)] Tk]
}
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index 22b7b06..42034c6 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -74,6 +74,7 @@ main(
char msg[300];
DWORD dwWritten;
int chars;
+ char *s;
/*
* Make sure children (cl.exe and link.exe) are kept quiet.
@@ -153,8 +154,13 @@ main(
&dwWritten, NULL);
return 0;
}
- printf("%s\n", GetVersionFromFile(argv[2], argv[3], *(argv[1]+2) - '0'));
- return 0;
+ s = GetVersionFromFile(argv[2], argv[3], *(argv[1]+2) - '0');
+ if (s && *s) {
+ printf("%s\n", s);
+ return 0;
+ } else
+ return 1; /* Version not found. Return non-0 exit code */
+
case 'Q':
if (argc != 3) {
chars = snprintf(msg, sizeof(msg) - 1,
diff --git a/win/rules-ext.vc b/win/rules-ext.vc
new file mode 100644
index 0000000..97c11b4
--- /dev/null
+++ b/win/rules-ext.vc
@@ -0,0 +1,85 @@
+# This file should only be included in makefiles for Tcl extensions,
+# NOT in the makefile for Tcl itself.
+
+!ifndef _RULES_EXT_VC
+
+!if !exist("rules-ext.vc")
+MSG = ^
+You must run this makefile only from the directory it is in.^
+Please `cd` to its location first.
+!error $(MSG)
+!endif
+
+!if "$(PROJECT)" == "tcl"
+!error The rules-ext.vc file is not intended for Tcl itself.
+!endif
+
+# First locate the Tcl directory that we are working with.
+!ifdef TCLDIR
+
+_RULESDIR = $(TCLDIR:/=\)
+
+!else
+
+# If an installation path is specified, that is also the Tcl directory.
+# Also, tk never builds against an installed Tcl, it needs Tcl sources
+!if defined(INSTALLDIR) && "$(PROJECT)" != "tk"
+_RULESDIR=$(INSTALLDIR:/=\)
+!else
+_RULESDIR = ..\..\tcl
+!endif
+
+!endif # ifndef TCLDIR
+
+# Now look for the rules.vc file under the Tcl root
+!if exist("$(_RULESDIR)\lib\nmake\rules.vc") # Building against installed Tcl
+_RULESDIR = $(_RULESDIR)\lib\nmake
+!elseif exist("$(_RULESDIR)\win\rules.vc") # Building against Tcl sources
+_RULESDIR = $(_RULESDIR)\win
+!else
+# If we have not located Tcl's rules file, most likely we are compiling
+# against an older version of Tcl and so must use our own support files.
+_RULESDIR = .
+!endif
+
+!if "$(_RULESDIR)" != "."
+# Potentially using Tcl's support files. Need to compare the versions.
+# We extract version numbers using the nmakehlp program. For this
+# purpose, we use the version of nmakehlp that we have.
+!if [$(CC) -nologo nmakehlp.c -link -subsystem:console > nul]
+!endif
+
+!if [echo TCL_RULES_MAJOR = \> versions.vc] \
+ && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MAJOR >> versions.vc]
+!endif
+!if [echo TCL_RULES_MINOR = \>> versions.vc] \
+ && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MINOR >> versions.vc]
+!endif
+
+!if [echo OUR_RULES_MAJOR = \>> versions.vc] \
+ && [nmakehlp -V "rules.vc" RULES_VERSION_MAJOR >> versions.vc]
+!endif
+!if [echo OUR_RULES_MINOR = \>> versions.vc] \
+ && [nmakehlp -V "rules.vc" RULES_VERSION_MINOR >> versions.vc]
+!endif
+!include versions.vc
+# We have a newer version of the support files, use them
+!if ($(TCL_RULES_MAJOR) != $(OUR_RULES_MAJOR)) || ($(TCL_RULES_MINOR) < $(OUR_RULES_MINOR))
+_RULESDIR = .
+!endif
+
+!endif # $(_RULESDIR) != "."
+
+# Let rules.vc know what copy of nmakehlp.c to use.
+NMAKEHLPC = $(_RULESDIR)\nmakehlp.c
+
+# Get rid of our internal defines before calling rules.vc
+!undef TCL_RULES_MAJOR
+!undef TCL_RULES_MINOR
+!undef OUR_RULES_MAJOR
+!undef OUR_RULES_MINOR
+
+!message *** Using $(_RULESDIR)\rules.vc
+!include "$(_RULESDIR)\rules.vc"
+
+!endif # _RULES_EXT_VC \ No newline at end of file
diff --git a/win/rules.vc b/win/rules.vc
index 5a5883b..c0d2915 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -1,4 +1,4 @@
-#------------------------------------------------------------------------------
+#------------------------------------------------------------- -*- makefile -*-
# rules.vc --
#
# Microsoft Visual C++ makefile include for decoding the commandline
@@ -15,12 +15,30 @@
!ifndef _RULES_VC
_RULES_VC = 1
+# The following macros define the version of the rules.vc nmake build system
+RULES_VERSION_MAJOR = 1
+RULES_VERSION_MINOR = 0
+
+# The PROJECT macro must be defined by parent makefile.
+# Also special case Tcl and Tk to save some typing later
+!ifndef PROJECT
+!error *** Error: Macro PROJECT not defined! Please define it before including rules.vc
+!endif
+DOING_TCL = 0
+DOING_TK = 0
+!if "$(PROJECT)" == "tcl"
+DOING_TCL = 1
+!elseif "$(PROJECT)" == "tk"
+DOING_TK = 1
+!endif
+
################################################################
# Nmake is a pretty weak environment in syntax and capabilities
# so this file is necessarily verbose. It's broken down into
# the following parts.
#
-# 0. Sanity check that compiler environment is set up.
+# 0. Sanity check that compiler environment is set up and initialize
+# any built-in settings from the parent makefile
# 1. First define the external tools used for compiling, copying etc.
# as this is independent of everything else.
# 2. Figure out our build structure in terms of the directory, whether
@@ -57,6 +75,14 @@ Visual C++ compiler environment not initialized.
!error $(MSG)
!endif
+# Defaults for built-in internal settings defined in parent makefile
+!ifndef DISABLE_STANDARD_TARGETS
+DISABLE_STANDARD_TARGETS = 0
+!endif
+!ifndef DISABLE_CLEAN_TARGETS
+DISABLE_CLEAN_TARGETS = 0
+!endif
+
################################################################
# 1. Define external programs being used
@@ -165,7 +191,7 @@ _INSTALLDIR = $(INSTALLDIR:/=\)
_INSTALLDIR = C:\Program Files\Tcl
!endif
-!if "$(PROJECT)" == "tcl"
+!if $(DOING_TCL)
# BEGIN Case 2(a) - Building Tcl itself
@@ -174,7 +200,7 @@ _TCL_H = ..\generic\tcl.h
# END Case 2(a) - Building Tcl itself
-!elseif "$(PROJECT)" == "tk"
+!elseif $(DOING_TK)
# BEGIN Case 2(b) - Building Tk
@@ -213,9 +239,11 @@ _TCL_H = $(_TCLDIR)\generic\tcl.h
!if exist("$(_INSTALLDIR)\include\tcl.h") # Case 2(c) for extensions with TCLDIR undefined
TCLINSTALL = 1
-TCLDIR = $(_INSTALLDIR)
-_TCLDIR = $(_INSTALLDIR)
-_TCL_H = $(_INSTALLDIR)\include\tcl.h
+TCLDIR = $(_INSTALLDIR)\..
+# NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions
+# later so the \.. accounts for the /lib
+_TCLDIR = $(_INSTALLDIR)\..
+_TCL_H = $(_TCLDIR)\include\tcl.h
!elseif exist("..\..\tcl\generic\tcl.h")
TCLINSTALL = 0
TCLDIR = ..\..\tcl
@@ -276,7 +304,7 @@ _INSTALLDIR=$(_INSTALLDIR)\lib
!endif
# END Case 2(c) or (d) - Building an extension
-!endif # if $(PROJECT) == "tcl"
+!endif # if $(DOING_TCL)
################################################################
# 3. Determine compiler version and architecture
@@ -389,15 +417,15 @@ CFG_ENCODING = \"cp1252\"
#
# Extensions built against Tcl sources will use the one from the Tcl source.
#
-# This can all be overridden by defining the NMAKEHLPC macro to point
-# to the nmakehlp.c file to be used, either from the command line or
-# the containing makefile.
+# When building an extension using a sufficiently new version of Tcl,
+# rules-ext.vc will define NMAKEHLPC appropriately to point to the
+# copy of nmakehlp.c to be used.
!ifndef NMAKEHLPC
# Default to the one in the current directory (the extension's own nmakehlp.c)
NMAKEHLPC = nmakehlp.c
-!if "$(PROJECT)" != "tcl"
+!if !$(DOING_TCL)
!if $(TCLINSTALL)
!if exist("$(_TCLDIR)\lib\nmake\nmakehlp.c")
NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c
@@ -407,7 +435,7 @@ NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c
NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c
!endif
!endif # $(TCLINSTALL)
-!endif # $(PROJECT) != "tcl"
+!endif # !$(DOING_TCL)
!endif # NMAKEHLPC
@@ -568,7 +596,7 @@ TCL_USE_STATIC_PACKAGES = 0
USE_THREAD_ALLOC = 1
UNCHECKED = 0
CONFIG_CHECK = 1
-!if "$(PROJECT)" == "tcl"
+!if $(DOING_TCL)
USE_STUBS = 0
!else
USE_STUBS = 1
@@ -766,7 +794,11 @@ WARNINGS = $(WARNINGS) -Wp64
!endif
################################################################
-# 9. Extract various version numbers from tcl headers
+# 9. Extract various version numbers
+# For Tcl and Tk, version numbers are exctracted from tcl.h and tk.h
+# respectively. For extensions, versions are extracted from the
+# configure.in or configure.ac from the TEA configuration if it
+# exists, and unset otherwise.
# Sets the following macros:
# TCL_MAJOR_VERSION
# TCL_MINOR_VERSION
@@ -776,6 +808,8 @@ WARNINGS = $(WARNINGS) -Wp64
# TK_MINOR_VERSION
# TK_PATCH_LEVEL
# TK_VERSION
+# DOTVERSION - set as (for example) 2.5
+# VERSION - set as (for example 25)
#--------------------------------------------------------------
!if [echo REM = This file is generated from rules.vc > versions.vc]
@@ -805,10 +839,39 @@ WARNINGS = $(WARNINGS) -Wp64
!include versions.vc
TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
+TCL_DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
!if defined(_TK_H)
TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
+TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
+!endif
+
+# Set DOTVERSION and VERSION
+!if $(DOING_TCL)
+
+DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
+VERSION = $(TCL_VERSION)
+
+!elseif $(DOING_TK)
+
+DOTVERSION = $(TK_DOTVERSION)
+VERSION = $(TK_VERSION)
+
+!else # Doing a non-Tk extension
+
+# If parent makefile has not defined DOTVERSION, try to get it from TEA
+# first from a configure.in file, and then from configure.ac
+!ifndef DOTVERSION
+!if [echo DOTVERSION = \> versions.vc] \
+ || [nmakehlp -V ..\configure.in AC_INIT >> versions.vc]
+!if [echo DOTVERSION = \> versions.vc] \
+ || [nmakehlp -V ..\configure.ac AC_INIT >> versions.vc]
+!error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
+!endif
!endif
+!include versions.vc
+!endif # DOTVERSION
+!endif # $(DOING_TCL) ... etc.
################################################################
# 10. Construct output directory and file paths
@@ -828,10 +891,15 @@ TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
# is of the form {Release,Debug}[_AMD64][_COMPILERVERSION]
# TMP_DIR - directory where object files are created
# OUT_DIR - directory where output executables are created
-# STUBPREFIX - name of the stubs library for this project
# Both TMP_DIR and OUT_DIR are defaulted only if not defined by the
# parent makefile (or command line). The default values are
# based on BUILDDIRTOP.
+# STUBPREFIX - name of the stubs library for this project
+# PRJIMPLIB - output path of the generated project import library
+# PRJLIBNAME - name of generated project library
+# PRJLIB - output path of generated project library
+# PRJSTUBLIBNAME - name of the generated project stubs library
+# PRJSTUBLIB - output path of the generated project stubs library
SUFX = tsgx
@@ -889,7 +957,7 @@ OUT_DIR = $(TMP_DIR)
STUBPREFIX = $(PROJECT)stub
# Set up paths to various Tcl executables and libraries needed by extensions
-!if "$(PROJECT)" == "tcl"
+!if $(DOING_TCL)
TCLSHNAME = $(PROJECT)sh$(TCL_VERSION)$(SUFX).exe
TCLSH = $(OUT_DIR)\$(TCLSHNAME)
@@ -901,12 +969,12 @@ TCLSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
TCLSTUBLIB = $(OUT_DIR)\$(TCLSTUBLIBNAME)
TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)"
-!else # $(PROJECT) is not "tcl"
+!else # ! $(DOING_TCL)
!if $(TCLINSTALL) # Building against an installed Tcl
TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe
-!if !exist($(TCLSH)) && $(TCL_THREADS)
+!if !exist("$(TCLSH)") && $(TCL_THREADS)
TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe
!endif
TCLSTUBLIB = $(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib
@@ -935,7 +1003,7 @@ TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
tcllibs = "$(TCLSTUBLIB)" "$(TCLIMPLIB)"
-!endif $(PROJECT) != "tcl"
+!endif # $(DOING_TCL)
# We need a tclsh that will run on the host machine as part of the build.
# IX86 runs on all architectures.
@@ -948,14 +1016,14 @@ TCLSH_NATIVE = $(TCLSH)
!endif
# Do the same for Tk and Tk extensions that require the Tk libraries
-!if "$(PROJECT)" == "tk" || defined(PROJECT_REQUIRES_TK)
+!if $(DOING_TK) || defined(PROJECT_REQUIRES_TK)
WISHNAMEPREFIX = wish
WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe
TKLIBNAME = $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT)
TKSTUBLIBNAME = tkstub$(TK_VERSION).lib
TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX).lib
-!if "$(PROJECT)" == "tk"
+!if $(DOING_TK)
WISH = $(OUT_DIR)\$(WISHNAME)
TKSTUBLIB = $(OUT_DIR)\$(TKSTUBLIBNAME)
TKIMPLIB = $(OUT_DIR)\$(TKIMPLIBNAME)
@@ -976,8 +1044,16 @@ TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
!endif # TKINSTALL
-!endif # $(PROJECT) == tk
-!endif # $(PROJECT) == tk || PROJECT_REQUIRES_TK
+!endif # $(DOING_TK)
+!endif # $(DOING_TK) || PROJECT_REQUIRES_TK
+
+# Various output paths
+PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
+PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
+PRJLIB = $(OUT_DIR)\$(PRJLIBNAME)
+
+PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
+PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME)
###################################################################
# 11. Construct the paths for the installation directories
@@ -990,19 +1066,19 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
# DEMO_INSTALL_DIR - where demos should be installed
# PRJ_INSTALL_DIR - where package will be installed (not set for tcl and tk)
-!if "$(PROJECT)" == "tcl" || "$(PROJECT)" == "tk"
+!if $(DOING_TCL) || $(DOING_TK)
LIB_INSTALL_DIR = $(_INSTALLDIR)\lib
BIN_INSTALL_DIR = $(_INSTALLDIR)\bin
DOC_INSTALL_DIR = $(_INSTALLDIR)\doc
-!if "$(PROJECT)" == "tcl"
+!if $(DOING_TCL)
SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
-!else
+!else # DOING_TK
SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
!endif
DEMO_INSTALL_DIR = $(SCRIPT_INSTALL_DIR)\demos
INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\include
-!else
+!else # extension other than Tk
PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)
@@ -1059,7 +1135,7 @@ OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED
!if $(USE_STUBS)
# Note we do not define USE_TCL_STUBS even when building tk since some
# test targets in tk do not use stubs
-!if "$(PROJECT)" != "tcl"
+!if ! $(DOING_TCL)
USE_STUBS_DEFS = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS
!ifdef PROJECT_REQUIRES_TK
USE_STUBS_DEFS = $(USE_STUBS_DEFS) -DUSE_TK_STUBS
@@ -1083,9 +1159,32 @@ OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT
OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64
!endif
-# UNICODE - Use the wide char Windows API.
# _ATL_XP_TARGETING - Newer SDK's need this to build for XP
-COMPILERFLAGS = /DUNICODE /D_UNICODE /D_ATL_XP_TARGETING
+COMPILERFLAGS = /D_ATL_XP_TARGETING
+
+# Following is primarily for the benefit of extensions. Tcl 8.5 builds
+# Tcl without /DUNICODE, while 8.6 builds with it defined. When building
+# an extension, it is advisable (but not mandated) to use the same Windows
+# API as the Tcl build. This is accordingly defaulted below. A particular
+# extension can override this by pre-definining USE_WIDECHAR_API.
+!ifndef USE_WIDECHAR_API
+!if $(TCL_VERSION) > 85
+USE_WIDECHAR_API = 1
+!else
+USE_WIDECHAR_API = 0
+!endif
+!endif
+
+!if $(USE_WIDECHAR_API)
+COMPILERFLAGS = $(COMPILERFLAGS) /DUNICODE /D_UNICODE
+!endif
+
+# Like the TEA system only set this non empty for non-Tk extensions
+!if !$(DOING_TCL) && !$(DOING_TK)
+PKGNAMEFLAGS = -DPACKAGE_NAME="\"$(PROJECT)\"" \
+ -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
+ -DMODULE_SCOPE=extern
+!endif
# crt picks the C run time based on selected OPTS
!if $(MSVCRT)
@@ -1149,8 +1248,8 @@ cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug)
appcflags = $(cflags) $(crt) $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) $(USE_STUBS_DEFS)
appcflags_nostubs = $(cflags) $(crt) $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES)
-pkgcflags = $(appcflags) -DBUILD_$(PROJECT)
-pkgcflags_nostubs = $(appcflags_nostubs) -DBUILD_$(PROJECT)
+pkgcflags = $(appcflags) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
+pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
# stubscflags contains $(cflags) plus flags used for building a stubs
# library for the package. Note: -DSTATIC_BUILD is defined in
@@ -1225,25 +1324,59 @@ baselibs = $(baselibs) ucrt.lib
# 3. Define standard commands, common make targets and implicit rules
MAKELIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@
-MAKEDLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs)
+MAKEDLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs)
+
+!if $(STATIC_BUILD)
+MAKEBINCMD = $(MAKELIBCMD)
+!else
+MAKEBINCMD = $(MAKEDLLCMD)
+!endif
MAKECONCMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs)
MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs)
MAKERESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \
$(TCL_INCLUDES) \
- -d DEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
- -d TCL_THREADS=$(TCL_THREADS) \
- -d STATIC_BUILD=$(STATIC_BUILD) \
+ -DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
+ -DTCL_THREADS=$(TCL_THREADS) \
+ -DSTATIC_BUILD=$(STATIC_BUILD) \
+ -DCOMMAVERSION=$(DOTVERSION:.=,),0 \
+ -DDOTVERSION=\"$(DOTVERSION)\" \
+ -DVERSION=\"$(VERSION)\" \
+ -DSUFX=\"$(SUFX)\" \
$<
-!ifndef DISABLE_DEFAULT_TARGETS
!ifndef DEFAULT_BUILD_TARGET
-DEFAULT_BUILD_TARGET = all
+DEFAULT_BUILD_TARGET = $(PROJECT)
!endif
-default_target: $(DEFAULT_BUILD_TARGET)
+default-target: $(DEFAULT_BUILD_TARGET)
-clean:
+default-pkgindex:
+ @echo package ifneeded $(PROJECT) $(DOTVERSION) \
+ [list load [file join $$dir $(PRJLIBNAME)]] >> $(OUT_DIR)\pkgIndex.tcl
+
+default-pkgindex-tea:
+ @if exist $(ROOT)\pkgIndex.tcl.in nmakehlp -s << $(ROOT)\pkgIndex.tcl.in > $(OUT_DIR)\pkgIndex.tcl
+@PACKAGE_VERSION@ $(DOTVERSION)
+@PACKAGE_NAME@ $(PROJECT)
+@PKG_LIB_FILE@ $(PRJLIBNAME)
+<<
+
+
+default-install: default-install-binaries default-install-libraries
+
+default-install-binaries: $(PRJLIB)
+ @echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
+ @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
+ @$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
+
+default-install-libraries: $(OUT_DIR)\pkgIndex.tcl
+ @echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
+ @if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
+ @echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
+ @$(CPY) $(OUT_DIR)\pkgIndex.tcl $(SCRIPT_INSTALL_DIR)
+
+default-clean:
@echo Cleaning $(TMP_DIR)\* ...
@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
@echo Cleaning $(WINDIR)\nmakehlp.obj, nmakehlp.exe ...
@@ -1258,13 +1391,17 @@ clean:
@if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc
@if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc
-realclean: hose
-
-hose:
+default-hose:
@echo Hosing $(OUT_DIR)\* ...
@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
-!endif
+default-distclean: default-hose
+ @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
+ @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj
+
+default-setup:
+ @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
+ @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
!ifndef DISABLE_IMPLICIT_RULES
# Implicit rule definitions - only for building library objects. For stubs and
@@ -1287,7 +1424,7 @@ $<
{$(RCDIR)}.rc{$(TMP_DIR)}.res:
$(MAKERESCMD)
-
+
{$(WINDIR)}.rc{$(TMP_DIR)}.res:
$(MAKERESCMD)
@@ -1301,7 +1438,7 @@ $<
# When building an extension, certain configuration options should
# match the ones used when Tcl was built. Here we check and
# warn on a mismatch.
-!if "$(PROJECT)" != "tcl"
+!if ! $(DOING_TCL)
!if $(TCLINSTALL) # Building against an installed Tcl
!if exist("$(_TCLDIR)\lib\nmake\tcl.nmake")
@@ -1315,9 +1452,9 @@ TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake"
!if $(CONFIG_CHECK)
!ifdef TCLNMAKECONFIG
-!include $(TCLMAKECONFIG)
+!include $(TCLNMAKECONFIG)
-!if defined(CORE_MACHINE) && $(CORE_MACHINE) != $(MACHINE)
+!if defined(CORE_MACHINE) && "$(CORE_MACHINE)" != "$(MACHINE)"
!error ERROR: Build target ($(MACHINE)) does not match the Tcl library architecture ($(CORE_MACHINE)).
!endif
!if defined(CORE_USE_THREAD_ALLOC) && $(CORE_USE_THREAD_ALLOC) != $(USE_THREAD_ALLOC)
@@ -1330,7 +1467,7 @@ TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake"
!endif # TCLNMAKECONFIG
-!endif # $(PROJECT) == "tcl"
+!endif # ! $(DOING_TCL)
#----------------------------------------------------------
diff --git a/win/targets.vc b/win/targets.vc
new file mode 100644
index 0000000..6844045
--- /dev/null
+++ b/win/targets.vc
@@ -0,0 +1,21 @@
+#------------------------------------------------------------- -*- makefile -*-
+
+$(PROJECT): setup pkgindex $(PRJLIB)
+
+!if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk"
+# MAKEBINCMD will do shared, static and debug links as appropriate
+# _VC_MANIFEST_EMBED_DLL embeds the manifest for shared libraries
+# and is a no-op for static libraries
+$(PRJLIB): $(PRJ_OBJS)
+ $(MAKEBINCMD) $**
+ $(_VC_MANIFEST_EMBED_DLL)
+ -@del $*.exp
+!endif
+
+setup: default-setup
+install: default-install
+clean: default-clean
+realclean: hose
+hose: default-hose
+distclean: realclean default-distclean
+