summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2017-12-09 07:36:44 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2017-12-09 07:36:44 (GMT)
commit7dc10143da6e38ffaf9c6bfcfc493d1c8adfdab8 (patch)
tree45b89ccf44322f9c599cae389b2f99e6e7d8b6f2 /win
parent4499c71658a794dea442302083be37dddfc6a061 (diff)
downloadtk-7dc10143da6e38ffaf9c6bfcfc493d1c8adfdab8.zip
tk-7dc10143da6e38ffaf9c6bfcfc493d1c8adfdab8.tar.gz
tk-7dc10143da6e38ffaf9c6bfcfc493d1c8adfdab8.tar.bz2
Final nmake support files from Tcl
Diffstat (limited to 'win')
-rw-r--r--win/nmakehlp.c2
-rw-r--r--win/rules-ext.vc55
-rw-r--r--win/rules.vc90
3 files changed, 106 insertions, 41 deletions
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index 42034c6..0439d1c 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -160,7 +160,7 @@ main(
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
index e0a363c..abaaed6 100644
--- a/win/rules-ext.vc
+++ b/win/rules-ext.vc
@@ -1,18 +1,27 @@
-#------------------------------------------------------------- -*- makefile -*-
-# rules-ext.vc --
-#
-# Part of the nmake based build system for Tcl and its extensions.
# This file should only be included in makefiles for Tcl extensions,
# NOT in the makefile for Tcl itself.
-# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for docs.
!ifndef _RULES_EXT_VC
-!if !exist("rules-ext.vc")
+# We need to run from the directory the parent makefile is located in.
+# nmake does not tell us what makefile was used to invoke it so parent
+# makefile has to set the MAKEFILEVC macro or we just make a guess and
+# warn if we think that is not the case.
+!if "$(MAKEFILEVC)" == ""
+
+!if exist("$(PROJECT).vc")
+MAKEFILEVC = $(PROJECT).vc
+!elseif exist("makefile.vc")
+MAKEFILEVC = makefile.vc
+!endif
+!endif # "$(MAKEFILEVC)" == ""
+
+!if !exist("$(MAKEFILEVC)")
MSG = ^
-You must run this makefile only from the directory it is in.^
-Please `cd` to its location first.
-!error $(MSG)
+You must run nmake from the directory containing the project makefile.^
+If you are doing that and getting this message, set the MAKEFILEVC^
+macro to the name of the project makefile.
+!message WARNING: $(MSG)
!endif
!if "$(PROJECT)" == "tcl"
@@ -36,22 +45,26 @@ _RULESDIR = ..\..\tcl
!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
+# Now look for the targets.vc file under the Tcl root. Note we check this
+# file and not rules.vc because the latter also exists on older systems.
+!if exist("$(_RULESDIR)\lib\nmake\targets.vc") # Building against installed Tcl
_RULESDIR = $(_RULESDIR)\lib\nmake
-!elseif exist("$(_RULESDIR)\win\rules.vc") # Building against Tcl sources
+!elseif exist("$(_RULESDIR)\win\targets.vc") # Building against Tcl sources
_RULESDIR = $(_RULESDIR)\win
!else
-# If we have not located Tcl's rules file, most likely we are compiling
+# If we have not located Tcl's targets 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]
+# Potentially using Tcl's support files. If this extension has its own
+# nmake support files, need to compare the versions and pick newer.
+
+!if exist("rules.vc") # The extension has its own copy
+
+# We extract version numbers using the nmakehlp program.
+!if [$(CC) -nologo "$(_RULESDIR)\nmakehlp.c" -link -subsystem:console > nul]
!endif
!if [echo TCL_RULES_MAJOR = \> versions.vc] \
@@ -73,7 +86,9 @@ _RULESDIR = .
_RULESDIR = .
!endif
-!endif # $(_RULESDIR) != "."
+!endif # if exist("rules.vc")
+
+!endif # if $(_RULESDIR) != "."
# Let rules.vc know what copy of nmakehlp.c to use.
NMAKEHLPC = $(_RULESDIR)\nmakehlp.c
@@ -84,7 +99,11 @@ NMAKEHLPC = $(_RULESDIR)\nmakehlp.c
!undef OUR_RULES_MAJOR
!undef OUR_RULES_MINOR
+!if exist("$(_RULESDIR)\rules.vc")
!message *** Using $(_RULESDIR)\rules.vc
!include "$(_RULESDIR)\rules.vc"
+!else
+!error *** Could not locate rules.vc in $(_RULESDIR)
+!endif
!endif # _RULES_EXT_VC \ No newline at end of file
diff --git a/win/rules.vc b/win/rules.vc
index a1c30e0..9b917b6 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -27,10 +27,15 @@ 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
+!if "$(PROJECT)" == ""
!error *** Error: Macro PROJECT not defined! Please define it before including rules.vc
!endif
+
+!if "$(PRJ_PACKAGE_TCLNAME)" == ""
+PRJ_PACKAGE_TCLNAME = $(PROJECT)
+!endif
+
+# Also special case Tcl and Tk to save some typing later
DOING_TCL = 0
DOING_TK = 0
!if "$(PROJECT)" == "tcl"
@@ -52,7 +57,11 @@ NEED_TK = 0
NEED_TCL_SOURCE = 0
!endif
-!ifndef NEED_TK_SOURCE
+!ifdef NEED_TK_SOURCE
+!if $(NEED_TK_SOURCE)
+NEED_TK = 1
+!endif
+!else
NEED_TK_SOURCE = 0
!endif
@@ -91,13 +100,6 @@ NEED_TK_SOURCE = 0
# 0. Sanity check compiler environment
-!if !exist("rules-ext.vc")
-MSG = ^
-You must run nmake from the directory containing the makefile and rules-ext.vc.^
-Please `cd` to its location first.
-!error $(MSG)
-!endif
-
# Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or
# VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir)
@@ -107,6 +109,28 @@ Visual C++ compiler environment not initialized.
!error $(MSG)
!endif
+# We need to run from the directory the parent makefile is located in.
+# nmake does not tell us what makefile was used to invoke it so parent
+# makefile has to set the MAKEFILEVC macro or we just make a guess and
+# warn if we think that is not the case.
+!if "$(MAKEFILEVC)" == ""
+
+!if exist("$(PROJECT).vc")
+MAKEFILEVC = $(PROJECT).vc
+!elseif exist("makefile.vc")
+MAKEFILEVC = makefile.vc
+!endif
+!endif # "$(MAKEFILEVC)" == ""
+
+!if !exist("$(MAKEFILEVC)")
+MSG = ^
+You must run nmake from the directory containing the project makefile.^
+If you are doing that and getting this message, set the MAKEFILEVC^
+macro to the name of the project makefile.
+!message WARNING: $(MSG)
+!endif
+
+
################################################################
# 1. Define external programs being used
@@ -231,7 +255,7 @@ _TCL_H = ..\generic\tcl.h
# BEGIN Case 2(b) - Building Tk
TCLINSTALL = 0 # Tk always builds against Tcl source, not an installed Tcl
-!ifndef TCLDIR
+!if "$(TCLDIR)" == ""
TCLDIR = ../../tcl
!endif
_TCLDIR = $(TCLDIR:/=\)
@@ -250,7 +274,7 @@ _TK_H = ..\generic\tk.h
# If command line has specified Tcl location through TCLDIR, use it
# else default to the INSTALLDIR setting
-!ifdef TCLDIR
+!if "$(TCLDIR)" != ""
_TCLDIR = $(TCLDIR:/=\)
!if exist("$(_TCLDIR)\include\tcl.h") # Case 2(c) with TCLDIR defined
@@ -288,7 +312,7 @@ Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and defa
# Now do the same to locate Tk headers and libs if project requires Tk
!if $(NEED_TK)
-!ifdef TKDIR
+!if "$(TKDIR)" != ""
_TKDIR = $(TKDIR:/=\)
!if exist("$(_TKDIR)\include\tk.h")
@@ -680,7 +704,12 @@ TCL_USE_STATIC_PACKAGES = 0
!endif
!if [nmakehlp -f $(OPTS) "nothreads"]
-!error Option "nothreads" no longer supported. Threads required for sockets, registry and dde to work.
+!message *** Compile explicitly for non-threaded tcl
+TCL_THREADS = 0
+USE_THREAD_ALLOC= 0
+!else
+TCL_THREADS = 1
+USE_THREAD_ALLOC= 1
!endif
!if [nmakehlp -f $(OPTS) "symbols"]
@@ -725,7 +754,6 @@ USE_THREAD_ALLOC = 1
!endif
!if [nmakehlp -f $(OPTS) "tclalloc"]
-!error *** Option `tclalloc` is
USE_THREAD_ALLOC = 0
!endif
@@ -1238,8 +1266,11 @@ COMPILERFLAGS = $(COMPILERFLAGS) /DUNICODE /D_UNICODE
!endif
# Like the TEA system only set this non empty for non-Tk extensions
+# Note: some extensions use PACKAGE_NAME and others use PACKAGE_TCLNAME
+# so we pass both
!if !$(DOING_TCL) && !$(DOING_TK)
-PKGNAMEFLAGS = -DPACKAGE_NAME="\"$(PROJECT)\"" \
+PKGNAMEFLAGS = -DPACKAGE_NAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
+ -DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
-DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
-DMODULE_SCOPE=extern
!endif
@@ -1286,6 +1317,13 @@ cwarn = $(WARNINGS)
cwarn = $(cwarn) -wd4311 -wd4312
!endif
+### Common compiler options that are architecture specific
+!if "$(MACHINE)" == "ARM"
+carch = -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
+!else
+carch =
+!endif
+
!if $(DEBUG)
# Turn warnings into errors
cwarn = $(cwarn) -WX
@@ -1293,7 +1331,7 @@ cwarn = $(cwarn) -WX
INCLUDES = $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES)
!if !$(DOING_TCL) && !$(DOING_TK)
-INCLUDES = $(INCLUDES) -I$(GENERICDIR) -I$(WINDIR) -I(COMPATDIR)
+INCLUDES = $(INCLUDES) -I"$(GENERICDIR)" -I"$(WINDIR)" -I"$(COMPATDIR)"
!endif
# These flags are defined roughly in the order of the pre-reform
@@ -1301,7 +1339,7 @@ INCLUDES = $(INCLUDES) -I$(GENERICDIR) -I$(WINDIR) -I(COMPATDIR)
# post-reform build logs
# cflags contains generic flags used for building practically all object files
-cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug)
+cflags = -nologo -c $(COMPILERFLAGS) $(carch) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug)
# appcflags contains $(cflags) and flags for building the application
# object files (e.g. tclsh, or wish) pkgcflags contains $(cflags) plus
@@ -1325,7 +1363,7 @@ pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
# so we do not remove it from cflags. -GL may prevent extensions
# compiled with one VC version to fail to link against stubs library
# compiled with another VC version. Check for this and fix accordingly.
-stubscflags = $(cflags) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(INCLUDES)
+stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(INCLUDES)
# Link flags
@@ -1417,13 +1455,14 @@ DEFAULT_BUILD_TARGET = $(PROJECT)
default-target: $(DEFAULT_BUILD_TARGET)
default-pkgindex:
- @echo package ifneeded $(PROJECT) $(DOTVERSION) \
- [list load [file join $$dir $(PRJLIBNAME)]] >> $(OUT_DIR)\pkgIndex.tcl
+ @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(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)
+@PACKAGE_NAME@ $(PRJ_PACKAGE_TCLNAME)
+@PACKAGE_TCLNAME@ $(PRJ_PACKAGE_TCLNAME)
@PKG_LIB_FILE@ $(PRJLIBNAME)
<<
@@ -1441,6 +1480,11 @@ default-install-libraries: $(OUT_DIR)\pkgIndex.tcl
@echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
@$(CPY) $(OUT_DIR)\pkgIndex.tcl $(SCRIPT_INSTALL_DIR)
+default-install-stubs:
+ @echo Installing stubs library to '$(SCRIPT_INSTALL_DIR)'
+ @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
+ @$(CPY) $(PRJSTUBLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
+
default-install-docs-html:
@echo Installing documentation files to '$(DOC_INSTALL_DIR)'
@if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)"
@@ -1463,6 +1507,8 @@ default-clean:
@if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj
@if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
@if exist $(WINDIR)\nmakehlp.out del $(WINDIR)\nmakehlp.out
+ @echo Cleaning $(WINDIR)\nmhlp-out.txt ...
+ @if exist $(WINDIR)\nmhlp-out.txt del $(WINDIR)\nmhlp-out.txt
@echo Cleaning $(WINDIR)\_junk.pch ...
@if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch
@echo Cleaning $(WINDIR)\vercl.x, vercl.i ...