-- cgit v0.12 From 78a20a11b21ab416516724818432027dae27e5ac Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 19 Sep 2017 12:10:25 +0000 Subject: Remove /Gs which enables _chkstk on *every* function call. The normal default behaviour (without the option) checks only local variable space exceeds page size. This is what Microsoft recommends. Also moved -O2 to rules.vc file so as to keep all optimization flags in one location. Removed optimizations switches subsumed by -O2. --- win/makefile.vc | 2 +- win/rules.vc | 36 +++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index ada08cc..cb6d92c 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -470,7 +470,7 @@ PKGSDIR = $(ROOT)\pkgs !if !$(DEBUG) !if $(OPTIMIZING) ### This cranks the optimization level to maximize speed -cdebug = -O2 $(OPTIMIZATIONS) +cdebug = $(OPTIMIZATIONS) !else cdebug = !endif diff --git a/win/rules.vc b/win/rules.vc index 4a3ae26..3f3d077 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -113,42 +113,46 @@ CFG_ENCODING = \"cp1252\" #---------------------------------------------------------- ### test for optimizations -!if [nmakehlp -c -Ot] +# /O2 optimization includes /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy as per +# documentation. Note we do NOT want /Gs as that inserts a _chkstk +# stack probe at *every* function entry, not just those with more than +# a page of stack allocation resulting in a performance hit. However, +# /O2 documentation is misleading as its stack probes are simply the +# default page size locals allocation probes and not what is implied +# by an explicit /Gs option. + +!if [nmakehlp -c -O2] !message *** Compiler has 'Optimizations' OPTIMIZING = 1 +OPTIMIZATIONS = -O2 !else !message *** Compiler does not have 'Optimizations' OPTIMIZING = 0 +OPTIMIZATIONS = !endif -OPTIMIZATIONS = - -!if [nmakehlp -c -Ot] -OPTIMIZATIONS = $(OPTIMIZATIONS) -Ot -!endif - -!if [nmakehlp -c -Oi] -OPTIMIZATIONS = $(OPTIMIZATIONS) -Oi -!endif +# -Op improves float consistency. Note only needed for older compilers +# Newer compilers do not need or support this option. !if [nmakehlp -c -Op] OPTIMIZATIONS = $(OPTIMIZATIONS) -Op !endif +# Strict floating point semantics - present in newer compilers in lieu of -Op !if [nmakehlp -c -fp:strict] OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:strict !endif -!if [nmakehlp -c -Gs] -OPTIMIZATIONS = $(OPTIMIZATIONS) -Gs -!endif - +# Checks for buffer overflows in local arrays !if [nmakehlp -c -GS] OPTIMIZATIONS = $(OPTIMIZATIONS) -GS !endif +# Link time optimization. Note that this option (potentially) makes generated libraries +# only usable by the specific VC++ version that created it. Requires /LTCG linker option !if [nmakehlp -c -GL] OPTIMIZATIONS = $(OPTIMIZATIONS) -GL +CC_GL_OPT_ENABLED = 1 !endif DEBUGFLAGS = @@ -208,8 +212,10 @@ ALIGN98_HACK = 0 LINKERFLAGS = +!ifdef CC_GL_OPT_ENABLED !if [nmakehlp -l -ltcg $(LINKER_TESTFLAGS)] -LINKERFLAGS =-ltcg +LINKERFLAGS = $(LINKERFLAGS) -ltcg +!endif !endif #---------------------------------------------------------- -- cgit v0.12 From 0e5d15e07293f2792b0a403dcf4e2039332cbb0c Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 19 Sep 2017 12:50:25 +0000 Subject: Fix mapping of VCVERSION to VCVER. The simplistic calculation no longer holds for new versions of the compiler. Instead directly use the internal compiler version for these. --- win/rules.vc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/win/rules.vc b/win/rules.vc index 3f3d077..bca052b 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -68,11 +68,18 @@ VCVER=0 && ![echo $(_HASH)endif >> vercl.x] \ && ![cl -nologo -TC -P vercl.x $(ERRNULL)] !include vercl.i +!if $(VCVERSION) < 1900 !if ![echo VCVER= ^\> vercl.vc] \ && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc] !include vercl.vc !endif +!else +# The simple calculation above does not apply to new Visual Studio releases +# Keep the compiler version in its native form. +VCVER = $(VCVERSION) +!endif !endif + !if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc] !endif -- cgit v0.12 From b81c66b4c7d8c66becb3def11d368d1af0c059ed Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 19 Sep 2017 15:12:52 +0000 Subject: Do not permit nothreads in OPTS as sockets, registry and dde require threading. --- win/makefile.vc | 3 +-- win/rules.vc | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index cb6d92c..4de6a1c 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -71,7 +71,7 @@ the build instructions. # Sets where to install Tcl from the built binaries. # C:\Progra~1\Tcl is assumed when not specified. # -# OPTS=loimpact,msvcrt,nothreads,pdbs,profile,static,staticpkg,symbols,thrdalloc,tclalloc,unchecked,none +# OPTS=loimpact,msvcrt,pdbs,profile,static,staticpkg,symbols,thrdalloc,tclalloc,unchecked,none # Sets special options for the core. The default is for none. # Any combination of the above may be used (comma separated). # 'none' will over-ride everything to nothing. @@ -82,7 +82,6 @@ the build instructions. # using libcmt(d) as the C runtime [by default] to # msvcrt(d). This is useful for static embedding # support. -# nothreads= Turns off full multithreading support. # pdbs = Build detached symbols for release builds. # profile = Adds profiling hooks. Map file is assumed. # static = Builds a static library of the core instead of a diff --git a/win/rules.vc b/win/rules.vc index bca052b..a57c25e 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -230,6 +230,9 @@ LINKERFLAGS = $(LINKERFLAGS) -ltcg #---------------------------------------------------------- !if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"] + +# if No OPTS specified + STATIC_BUILD = 0 TCL_THREADS = 1 DEBUG = 0 @@ -241,13 +244,18 @@ LOIMPACT = 0 TCL_USE_STATIC_PACKAGES = 0 USE_THREAD_ALLOC = 1 UNCHECKED = 0 + !else + +# OPTS are specified, parse them + !if [nmakehlp -f $(OPTS) "static"] !message *** Doing static STATIC_BUILD = 1 !else STATIC_BUILD = 0 !endif + !if [nmakehlp -f $(OPTS) "nomsvcrt"] !message *** Doing nomsvcrt MSVCRT = 0 @@ -262,14 +270,17 @@ MSVCRT = 1 MSVCRT = 0 !endif !endif -!endif +!endif # [nmakehlp -f $(OPTS) "nomsvcrt"] + !if [nmakehlp -f $(OPTS) "staticpkg"] && $(STATIC_BUILD) !message *** Doing staticpkg TCL_USE_STATIC_PACKAGES = 1 !else 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 @@ -277,24 +288,28 @@ USE_THREAD_ALLOC= 0 TCL_THREADS = 1 USE_THREAD_ALLOC= 1 !endif + !if [nmakehlp -f $(OPTS) "symbols"] !message *** Doing symbols DEBUG = 1 !else DEBUG = 0 !endif + !if [nmakehlp -f $(OPTS) "pdbs"] !message *** Doing pdbs SYMBOLS = 1 !else SYMBOLS = 0 !endif + !if [nmakehlp -f $(OPTS) "profile"] !message *** Doing profile PROFILE = 1 !else PROFILE = 0 !endif + !if [nmakehlp -f $(OPTS) "pgi"] !message *** Doing profile guided optimization instrumentation PGO = 1 @@ -304,27 +319,32 @@ PGO = 2 !else PGO = 0 !endif + !if [nmakehlp -f $(OPTS) "loimpact"] !message *** Doing loimpact LOIMPACT = 1 !else LOIMPACT = 0 !endif + !if [nmakehlp -f $(OPTS) "thrdalloc"] !message *** Doing thrdalloc USE_THREAD_ALLOC = 1 !endif + !if [nmakehlp -f $(OPTS) "tclalloc"] !message *** Doing tclalloc USE_THREAD_ALLOC = 0 !endif + !if [nmakehlp -f $(OPTS) "unchecked"] !message *** Doing unchecked UNCHECKED = 1 !else UNCHECKED = 0 !endif -!endif + +!endif # "$(OPTS)" == "" ... parsing of OPTS #---------------------------------------------------------- # Figure-out how to name our intermediate and output directories. -- cgit v0.12 From 071f38c4823457396818de582f5af25884c2befe Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 19 Sep 2017 16:07:14 +0000 Subject: Eliminated some obsolete checks (Win98, IA64 etc.) to reduce the noise. --- win/makefile.vc | 19 ++++++++----------- win/rules.vc | 25 +------------------------ 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 4de6a1c..4da9da7 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -120,12 +120,12 @@ the build instructions. # nodep = Turns off compatibility macros to ensure the core # isn't being built with deprecated functions. # -# MACHINE=(ALPHA|AMD64|IA64|IX86) +# MACHINE=(AMD64|IX86) # Set the machine type used for the compiler, linker, and # resource compiler. This hook is needed to tell the tools -# when alternate platforms are requested. IX86 is the default -# when not specified. If the CPU environment variable has been -# set (ie: recent Platform SDK) then MACHINE is set from CPU. +# when alternate platforms are requested. This should normally +# NOT be set as it is automatically detected based on the +# compiler in use. # # TMP_DIR= # OUT_DIR= @@ -153,11 +153,8 @@ the build instructions. # c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl # # Building for Win64 -# c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat -# Setting environment for using Microsoft Visual C++ tools. -# c:\tcl_src\win\>c:\progra~1\platfo~1\setenv.bat /pre64 /RETAIL -# Targeting Windows pre64 RETAIL -# c:\tcl_src\win\>nmake -f makefile.vc MACHINE=IA64 +# c:\tcl_src\win\>c:\progra~1\platfo~1\setenv.bat /x64 /RETAIL +# c:\tcl_src\win\>nmake -f makefile.vc # #------------------------------------------------------------------------------ #============================================================================== @@ -476,7 +473,7 @@ cdebug = !if $(SYMBOLS) cdebug = $(cdebug) -Zi !endif -!else if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64" +!else if "$(MACHINE)" == "AMD64" ### Warnings are too many, can't support warnings into errors. cdebug = -Zi -Od $(DEBUGFLAGS) !else @@ -552,7 +549,7 @@ guilflags = $(lflags) -subsystem:windows baselibs = netapi32.lib kernel32.lib user32.lib advapi32.lib userenv.lib ws2_32.lib # Avoid 'unresolved external symbol __security_cookie' errors. # c.f. http://support.microsoft.com/?id=894573 -!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64" +!if "$(MACHINE)" == "AMD64" !if $(VCVERSION) > 1399 && $(VCVERSION) < 1500 baselibs = $(baselibs) bufferoverflowU.lib !endif diff --git a/win/rules.vc b/win/rules.vc index a57c25e..afa8c2c 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -33,23 +33,10 @@ _INSTALLDIR = $(INSTALLDIR:/=\) # "delete all" method. #---------------------------------------------------------- -!if "$(OS)" == "Windows_NT" RMDIR = rmdir /S /Q ERRNULL = 2>NUL -!if ![ver | find "4.0" > nul] -CPY = echo y | xcopy /i >NUL -COPY = copy >NUL -!else CPY = xcopy /i /y >NUL COPY = copy /y >NUL -!endif -!else # "$(OS)" != "Windows_NT" -CPY = xcopy /i >_JUNK.OUT # On Win98 NUL does not work here. -COPY = copy >_JUNK.OUT # On Win98 NUL does not work here. -RMDIR = deltree /Y -NULL = \NUL # Used in testing directory existence -ERRNULL = >NUL # Win9x shell cannot redirect stderr -!endif MKDIR = mkdir #------------------------------------------------------------------------------ @@ -189,16 +176,6 @@ COMPILERFLAGS = $(COMPILERFLAGS) -QI0f !endif !endif -!if "$(MACHINE)" == "IA64" -### test for Itanium errata -!if [nmakehlp -c -QIA64_Bx] -!message *** Compiler has 'B-stepping errata workarounds' -COMPILERFLAGS = $(COMPILERFLAGS) -QIA64_Bx -!else -!message *** Compiler does not have 'B-stepping errata workarounds' -!endif -!endif - # Prevents "LNK1561: entry point must be defined" error compiling from VS-IDE: !ifndef LINKER_TESTFLAGS LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmhlp-out.txt @@ -519,7 +496,7 @@ OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED !if $(PROFILE) OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED !endif -!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64" +!if "$(MACHINE)" == "AMD64" OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT !endif !if $(VCVERSION) < 1300 -- cgit v0.12 From 6d855646966f1a37b99033910bdacd11b743ba4e Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 19 Sep 2017 16:43:19 +0000 Subject: Disable pointer<->int warnings related to cast between different sizes There are a gadzillion of these due to use of ClientData and clutter up compiler output increasing chance of a real warning getting lost. So disable them. Eventually some day, Tcl will be 64-bit clean. --- win/makefile.vc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/win/makefile.vc b/win/makefile.vc index 4da9da7..e82b288 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -482,6 +482,13 @@ cdebug = -Zi -WX $(DEBUGFLAGS) ### Declarations common to all compiler options cwarn = $(WARNINGS) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE +!if "$(MACHINE)" == "AMD64" +# Disable pointer<->int warnings related to cast between different sizes +# There are a gadzillion of these due to use of ClientData and clutter up compiler +# output increasing chance of a real warning getting lost. So disable them. +# Eventually some day, Tcl will be 64-bit clean. +cwarn = $(cwarn) -wd4311 -wd4312 +!endif cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\ !if $(MSVCRT) -- cgit v0.12 From 4f406d752d7133e9f8d028a728e06a15ed46278a Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 20 Sep 2017 12:58:59 +0000 Subject: First cut at making application-independent compile and link flags common to all extensions defined in a single place - rules.vc - instead of having each extension cut and paste the same code. --- win/makefile.vc | 90 ++------------------------------------------- win/rules.vc | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 114 insertions(+), 88 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index e82b288..19f41ab 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -463,47 +463,12 @@ PKGSDIR = $(ROOT)\pkgs # Compile flags #--------------------------------------------------------------------- -!if !$(DEBUG) -!if $(OPTIMIZING) -### This cranks the optimization level to maximize speed -cdebug = $(OPTIMIZATIONS) -!else -cdebug = -!endif -!if $(SYMBOLS) -cdebug = $(cdebug) -Zi -!endif -!else if "$(MACHINE)" == "AMD64" -### Warnings are too many, can't support warnings into errors. -cdebug = -Zi -Od $(DEBUGFLAGS) -!else -cdebug = -Zi -WX $(DEBUGFLAGS) -!endif ### Declarations common to all compiler options -cwarn = $(WARNINGS) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE -!if "$(MACHINE)" == "AMD64" -# Disable pointer<->int warnings related to cast between different sizes -# There are a gadzillion of these due to use of ClientData and clutter up compiler -# output increasing chance of a real warning getting lost. So disable them. -# Eventually some day, Tcl will be 64-bit clean. -cwarn = $(cwarn) -wd4311 -wd4312 -!endif +cwarn = $(cwarn) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE + cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\ -!if $(MSVCRT) -!if $(DEBUG) && !$(UNCHECKED) -crt = -MDd -!else -crt = -MD -!endif -!else -!if $(DEBUG) && !$(UNCHECKED) -crt = -MTd -!else -crt = -MT -!endif -!endif TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" -I"$(TOMMATHDIR)" TCL_DEFINES = -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1 @@ -514,56 +479,9 @@ STUB_CFLAGS = $(cflags) $(cdebug) $(OPTDEFINES) #--------------------------------------------------------------------- -# Link flags +# Link libraries #--------------------------------------------------------------------- - -!if $(DEBUG) -ldebug = -debug -debugtype:cv -!else -ldebug = -release -opt:ref -opt:icf,3 -!if $(SYMBOLS) -ldebug = $(ldebug) -debug -debugtype:cv -!endif -!endif - -### Declarations common to all linker options -lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug) - -!if $(PROFILE) -lflags = $(lflags) -profile -!endif - -!if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 -lflags = $(lflags) -nodefaultlib:libucrt.lib -!endif - -!if $(ALIGN98_HACK) && !$(STATIC_BUILD) -### Align sections for PE size savings. -lflags = $(lflags) -opt:nowin98 -!else if !$(ALIGN98_HACK) && $(STATIC_BUILD) -### Align sections for speed in loading by choosing the virtual page size. -lflags = $(lflags) -align:4096 -!endif - -!if $(LOIMPACT) -lflags = $(lflags) -ws:aggressive -!endif - -dlllflags = $(lflags) -dll -conlflags = $(lflags) -subsystem:console -guilflags = $(lflags) -subsystem:windows - -baselibs = netapi32.lib kernel32.lib user32.lib advapi32.lib userenv.lib ws2_32.lib -# Avoid 'unresolved external symbol __security_cookie' errors. -# c.f. http://support.microsoft.com/?id=894573 -!if "$(MACHINE)" == "AMD64" -!if $(VCVERSION) > 1399 && $(VCVERSION) < 1500 -baselibs = $(baselibs) bufferoverflowU.lib -!endif -!endif -!if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 -baselibs = $(baselibs) ucrt.lib -!endif +extralibs = netapi32.lib user32.lib userenv.lib ws2_32.lib #--------------------------------------------------------------------- # TclTest flags diff --git a/win/rules.vc b/win/rules.vc index afa8c2c..ce17485 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -157,7 +157,7 @@ DEBUGFLAGS = $(DEBUGFLAGS) -RTC1 DEBUGFLAGS = $(DEBUGFLAGS) -GZ !endif -COMPILERFLAGS =-W3 /DUNICODE /D_UNICODE /D_ATL_XP_TARGETING +COMPILERFLAGS = /DUNICODE /D_UNICODE /D_ATL_XP_TARGETING # In v13 -GL and -YX are incompatible. !if [nmakehlp -c -YX] @@ -702,6 +702,114 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" !endif + +#----------------------------------------------------------------------------------- +# Now we have all the information we need, set up the actual flags and options that +# we will pass to the compiler and linker. The main makefile should use these in +# combination with whatever other flags and switches are specific to it. +#----------------------------------------------------------------------------------- + +# crt picks the C run time based on selected OPTS +!if $(MSVCRT) +!if $(DEBUG) && !$(UNCHECKED) +crt = -MDd +!else +crt = -MD +!endif +!else +!if $(DEBUG) && !$(UNCHECKED) +crt = -MTd +!else +crt = -MT +!endif +!endif + +# cdebug includes compiler options for debugging as well as optimization. +!if $(DEBUG) + +# In debugging mode, optimizations need to be disabled +cdebug = -Zi -Od $(DEBUGFLAGS) + +!else + +cdebug = $(OPTIMIZATIONS) +!if $(SYMBOLS) +cdebug = $(cdebug) -Zi +!endif + +!endif # $(DEBUG) + +# cwarn includes default warning levels. +cwarn = $(WARNINGS) +!if "$(MACHINE)" == "AMD64" +# Disable pointer<->int warnings related to cast between different sizes +# There are a gadzillion of these due to use of ClientData and clutter up compiler +# output increasing chance of a real warning getting lost. So disable them. +# Eventually some day, Tcl will be 64-bit clean. +cwarn = $(cwarn) -wd4311 -wd4312 +!endif +!if $(DEBUG) +# Turn warnings into errors +cwarn = $(cwarn) -WX +!endif + +# Link flags + +!if $(DEBUG) +ldebug = -debug -debugtype:cv +!else +ldebug = -release -opt:ref -opt:icf,3 +!if $(SYMBOLS) +ldebug = $(ldebug) -debug -debugtype:cv +!endif +!endif + +# Note: Profiling is currently only possible with the Enterprise version of Visual Studio +!if $(PROFILE) +ldebug= $(ldebug) -profile +!endif + +### Declarations common to all linker versions +lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug) + +!if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 +lflags = $(lflags) -nodefaultlib:libucrt.lib +!endif + +!if $(ALIGN98_HACK) && !$(STATIC_BUILD) +### Align sections for PE size savings. +lflags = $(lflags) -opt:nowin98 +!else if !$(ALIGN98_HACK) && $(STATIC_BUILD) +### Align sections for speed in loading by choosing the virtual page size. +lflags = $(lflags) -align:4096 +!endif + +!if $(LOIMPACT) +lflags = $(lflags) -ws:aggressive +!endif + +dlllflags = $(lflags) -dll +conlflags = $(lflags) -subsystem:console +guilflags = $(lflags) -subsystem:windows + +# Libraries that are required for every image. +# Extensions should define any additional libraries with $(extralibs) +winlibs = kernel32.lib advapi32.lib + +# Avoid 'unresolved external symbol __security_cookie' errors. +# c.f. http://support.microsoft.com/?id=894573 +!if "$(MACHINE)" == "AMD64" +!if $(VCVERSION) > 1399 && $(VCVERSION) < 1500 +winlibs = $(winlibs) bufferoverflowU.lib +!endif +!endif + +baselibs = $(winlibs) $(extralibs) + +!if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 +baselibs = $(baselibs) ucrt.lib +!endif + #---------------------------------------------------------- # Display stats being used. #---------------------------------------------------------- @@ -715,4 +823,4 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" !message *** Compiler options '$(COMPILERFLAGS) $(OPTIMIZATIONS) $(DEBUGFLAGS) $(WARNINGS)' !message *** Link options '$(LINKERFLAGS)' -!endif +!endif # ifdef _RULES_VC -- cgit v0.12 From d8e7cf09b1a94b351c22a6950b79c103d3be1434 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Fri, 22 Sep 2017 13:26:14 +0000 Subject: First step in complete refactoring. Breaking up into logical sections with comments. Fix floating point option selection to be the same on debug and release. Pick up nmakehlp.c from installed Tcl if available when building extensions. Mods to allow extensions to use the same exact rules.vc file. --- win/makefile.vc | 10 +- win/rules.vc | 421 ++++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 295 insertions(+), 136 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 19f41ab..49890f3 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -964,27 +964,27 @@ $(TCLOBJS) #--------------------------------------------------------------------- {$(WINDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -DBUILD_tcl -Fo$(TMP_DIR)\ @<< + $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< $< << {$(TOMMATHDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -DBUILD_tcl -Fo$(TMP_DIR)\ @<< + $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< $< << {$(GENERICDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -DBUILD_tcl -Fo$(TMP_DIR)\ @<< + $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< $< << {$(COMPATDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -DBUILD_tcl -Fo$(TMP_DIR)\ @<< + $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< $< << {$(COMPATDIR)\zlib}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -DBUILD_tcl -Fo$(TMP_DIR)\ @<< + $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< $< << diff --git a/win/rules.vc b/win/rules.vc index ce17485..d3c36d9 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -9,23 +9,33 @@ # # Copyright (c) 2001-2003 David Gravereaux. # Copyright (c) 2003-2008 Patrick Thoyts +# Copyright (c) 2017 Ashok P. Nadkarni #------------------------------------------------------------------------------ !ifndef _RULES_VC _RULES_VC = 1 -cc32 = $(CC) # built-in default. -link32 = link -lib32 = lib -rc32 = $(RC) # built-in default. +################################################################ +# Nmake is a pretty weak environment in syntax and capabilities +# so this file is necessarily verbose. It's broken down into +# the following parts. +# +# 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 +# we are building Tcl or an extension, etc. +# 3. Determine the compiler and linker versions +# 4. Build the nmakehlp helper application +# 5. Determine the supported compiler options and features +# 6. Parse the OPTS macro value for user-specified configuration +# +# One final note about the macro names used. They are as they are +# for historical reasons. We would like legacy extensions to +# continue to work with this make include file so be wary of +# changing them for consistency or clarity. -!ifndef INSTALLDIR -### Assume the normal default. -_INSTALLDIR = C:\Program Files\Tcl -!else -### Fix the path separators. -_INSTALLDIR = $(INSTALLDIR:/=\) -!endif +################################################################ +# 1. Define external programs being used #---------------------------------------------------------- # Set the proper copy method to avoid overwrite questions @@ -39,9 +49,125 @@ CPY = xcopy /i /y >NUL COPY = copy /y >NUL MKDIR = mkdir -#------------------------------------------------------------------------------ -# Determine the host and target architectures and compiler version. -#------------------------------------------------------------------------------ + +###################################################################### +# 2. Figure out our build environment in terms of what we're building. +# +# (a) Tcl itself +# (b) a Tcl extension using libraries/includes from an *installed* Tcl +# (c) a Tcl extension using libraries/includes from Tcl source directory +# +# This last is needed because some extensions (even Tk) still need +# some Tcl interfaces that have are not publicly exposed. +# +# The fragment will set the following macros: +# _TCLDIR - root of the Tcl installation OR the Tcl sources. Not set +# when building Tcl itself. +# _INSTALLDIR - native form of the installation path. For Tcl +# this will be the root of the Tcl installation. For extensions +# this will be the lib directory under the root. +# TCLINSTALL - set to 1 if an extension is being built against the +# headers and libraries from an installed Tcl, and 0 if built against +# Tcl sources. Not set when building Tcl itself. Yes, not very well +# named. +# _TCL_H - native path to the tcl.h file + +# The root directory where the built packages and binaries will be installed. +# INSTALLDIR is the (optional) path specified by the user. +# _INSTALLDIR is INSTALLDIR using the backslash separator syntax +!ifdef INSTALLDIR +### Fix the path separators. +_INSTALLDIR = $(INSTALLDIR:/=\) +!else +### Assume the normal default. +_INSTALLDIR = C:\Program Files\Tcl +!endif + +!if "$(PROJECT)" == "tcl" # Case 2(a) - Building Tcl itself + +# Only need to define _TCL_H +_TCL_H = ..\generic\tcl.h + +!else # Case 2(b) or (c) - Building an extension + +# If command line has specified Tcl location through TCLDIR, use it +# else default to the INSTALLDIR setting +!ifdef TCLDIR + +_TCLDIR = $(TCLDIR:/=\) +!if exist("$(_TCLDIR)\include\tcl.h") # Case 2(a) with TCLDIR defined +TCLINSTALL = 1 +_TCL_H = $(_TCLDIR)\include\tcl.h +!elseif exist("$(_TCLDIR)\generic\tcl.h") # Case 2(b) with TCLDIR defined +TCLINSTALL = 0 +_TCL_H = $(_TCLDIR)\generic\tcl.h +!endif + +!else # TCLDIR is not defined + +!if "$(PROJECT)" == "tk" + +!if exist("..\..\tcl\generic\tcl.h") # Special case Tk with TCLDIR undefined +TCLINSTALL = 0 +TCLDIR = ..\..\tcl +_TCLDIR = $(TCLDIR) +_TCL_H = $(_TCLDIR)\generic\tcl.h +!endif + +!elseif exist("$(_INSTALLDIR)\include\tcl.h") # Case 2(a) for non-Tk with TCLDIR undefined + +TCLINSTALL = 1 +TCLDIR = $(_INSTALLDIR) +_TCLDIR = $(_INSTALLDIR) +_TCL_H = $(_INSTALLDIR)\include\tcl.h + +!endif # $(PROJECT) == "tk" + +!endif # TCLDIR + +# If INSTALLDIR set to tcl root dir then reset to the lib dir. +!if exist("$(_INSTALLDIR)\include\tcl.h") +_INSTALLDIR=$(_INSTALLDIR)\lib +!endif + +!endif # if $(PROJECT) == "tcl" + +!ifndef _TCL_H +MSG =^ +Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and default path does not contain tcl.h. +!error $(MSG) +!endif + + + +################################################################ +# 3. Determine compiler version and architecture +# In this section, we figure out the compiler version and the +# architecture for which we are building. This sets the +# following macros: +# VCVERSION - the internal compiler version as 1200, 1400, 1910 etc. +# This is also printed by the compiler in dotted form 19.10 etc. +# VCVER - the "marketing version", for example Visual C++ 6 for internal +# compiler version 1200. This is kept only for legacy reasons as it +# does not make sense for recent Microsoft compilers. Only used for +# output directory names. +# ARCH - set to IX86 or AMD64 depending on 32- or 64-bit target +# NATIVE_ARCH - set to IX86 or AMD64 for the host machine +# MACHINE - same as $(ARCH) - legacy +# _VC_MANIFEST_EMBED_{DLL,EXE} - commands for embedding a manifest if needed +# CFG_ENCODING - set to an character encoding. +# TBD - this is passed to compiler as TCL_CFGVAL_ENCODING but can't +# see where it is used + +cc32 = $(CC) # built-in default. +link32 = link +lib32 = lib +rc32 = $(RC) # built-in default. + +#---------------------------------------------------------------- +# Figure out the compiler architecture and version by writing +# the C macros to a file, preprocessing them with the C +# preprocessor and reading back the created file _HASH=^# _VC_MANIFEST_EMBED_EXE= @@ -53,7 +179,7 @@ VCVER=0 && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \ && ![echo ARCH=AMD64 >> vercl.x] \ && ![echo $(_HASH)endif >> vercl.x] \ - && ![cl -nologo -TC -P vercl.x $(ERRNULL)] + && ![$(cc32) -nologo -TC -P vercl.x $(ERRNULL)] !include vercl.i !if $(VCVERSION) < 1900 !if ![echo VCVER= ^\> vercl.vc] \ @@ -70,6 +196,26 @@ VCVER = $(VCVERSION) !if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc] !endif +#---------------------------------------------------------------- +# The MACHINE macro is used by legacy makefiles so set it as well +!ifdef MACHINE +!if "$(MACHINE)" == "x86" +!undef MACHINE +MACHINE = IX86 +!elseif "$(MACHINE)" == "x64" +!undef MACHINE +MACHINE = AMD64 +!endif +!if "$(MACHINE)" != "$(ARCH)" +!error Specified MACHINE macro $(MACHINE) does not match detected target architecture $(ARCH). +!endif +!else +MACHINE=$(ARCH) +!endif + +#------------------------------------------------------------ +# Figure out the *host* architecture by reading the registry + !if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86] NATIVE_ARCH=IX86 !else @@ -82,29 +228,95 @@ _VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -ou _VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 !endif -!ifndef MACHINE -MACHINE=$(ARCH) -!endif - !ifndef CFG_ENCODING CFG_ENCODING = \"cp1252\" !endif -!message =============================================================================== +!message ===================================================================== -#---------------------------------------------------------- -# build the helper app we need to overcome nmake's limiting -# environment. -#---------------------------------------------------------- +################################################################ +# 4. Build the nmakehlp program +# This is a helper app we need to overcome nmake's limiting +# environment. We will call out to it to get various bits of +# information about supported compiler options etc. +# +# Tcl itself will always use the nmakehlp.c program which is +# in its own source. This is the "master" copy and kept updated. +# +# Extensions built against an installed Tcl will use the installed +# copy of Tcl's nmakehlp.c if there is one and their own version +# otherwise. In the latter case, they would also be using their own +# rules.vc. Note that older versions of Tcl do not install nmakehlp.c +# or rules.vc. +# +# 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. + +!ifndef NMAKEHLPC +# Default to the one in the current directory (the extension's own nmakehlp.c) +NMAKEHLPC = nmakehlp.c -!if !exist(nmakehlp.exe) -!if [$(cc32) -nologo nmakehlp.c -link -subsystem:console > nul] +!if "$(PROJECT)" != "tcl" +!if $(TCLINSTALL) +!if exist("$(_TCLDIR)\lib\config.nmake\nmakehlp.c") +NMAKEHLPC = $(_TCLDIR)\lib\config.nmake\nmakehlp.c !endif +!else # ! $(TCLINSTALL) +!if exist("$(_TCLDIR)\win\nmakehlp.c") +NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c !endif +!endif # $(TCLINSTALL) +!endif # $(PROJECT) != "tcl" -#---------------------------------------------------------- -# Test for compiler features -#---------------------------------------------------------- +!endif # NMAKEHLPC + +# We always build nmakehlp even if it exists since we do not know +# what source it was built from. +!message *** Using $(NMAKEHLPC) +!if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul] +!endif + +################################################################ +# 5. Test for compiler features +# Visual C++ compiler options have changed over the years. Check +# which options are supported by the compiler in use. +# +# The following macros are set: +# OPTIMIZATIONS - the compiler flags to be used for optimized builds +# DEBUGFLAGS - the compiler flags to be used for debug builds +# LINKERFLAGS - Flags passed to the linker +# +# Note that these are the compiler settings *available*, not those +# that will be *used*. The latter depends on the OPTS macro settings +# which we have not yet parsed. +# +# Also note that some of the flags in OPTIMIZATIONS are not really +# related to optimization. They are placed there only for legacy reasons +# as some extensions expect them to be included in that macro. + +# -Op improves float consistency. Note only needed for older compilers +# Newer compilers do not need or support this option. +!if [nmakehlp -c -Op] +FPOPTS = -Op +!endif + +# Strict floating point semantics - present in newer compilers in lieu of -Op +!if [nmakehlp -c -fp:strict] +FPOPTS = $(FPOPTS) -fp:strict +!endif + +!if "$(MACHINE)" == "IX86" +### test for pentium errata +!if [nmakehlp -c -QI0f] +!message *** Compiler has 'Pentium 0x0f fix' +FPOPTS = $(FPOPTS) -QI0f +!else +!message *** Compiler does not have 'Pentium 0x0f fix' +!endif +!endif ### test for optimizations # /O2 optimization includes /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy as per @@ -115,26 +327,16 @@ CFG_ENCODING = \"cp1252\" # default page size locals allocation probes and not what is implied # by an explicit /Gs option. +OPTIMIZATIONS = $(FPOPTS) + !if [nmakehlp -c -O2] !message *** Compiler has 'Optimizations' -OPTIMIZING = 1 -OPTIMIZATIONS = -O2 +OPTIMIZING = 1 +OPTIMIZATIONS = $(OPTIMIZATIONS) -O2 !else +# Legacy, really. All modern compilers support this !message *** Compiler does not have 'Optimizations' -OPTIMIZING = 0 -OPTIMIZATIONS = -!endif - - -# -Op improves float consistency. Note only needed for older compilers -# Newer compilers do not need or support this option. -!if [nmakehlp -c -Op] -OPTIMIZATIONS = $(OPTIMIZATIONS) -Op -!endif - -# Strict floating point semantics - present in newer compilers in lieu of -Op -!if [nmakehlp -c -fp:strict] -OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:strict +OPTIMIZING = 0 !endif # Checks for buffer overflows in local arrays @@ -142,60 +344,46 @@ OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:strict OPTIMIZATIONS = $(OPTIMIZATIONS) -GS !endif -# Link time optimization. Note that this option (potentially) makes generated libraries -# only usable by the specific VC++ version that created it. Requires /LTCG linker option +# Link time optimization. Note that this option (potentially) makes +# generated libraries only usable by the specific VC++ version that +# created it. Requires /LTCG linker option !if [nmakehlp -c -GL] OPTIMIZATIONS = $(OPTIMIZATIONS) -GL CC_GL_OPT_ENABLED = 1 +!else +# In newer compilers -GL and -YX are incompatible. +!if [nmakehlp -c -YX] +OPTIMIZATIONS = $(OPTIMIZATIONS) -YX !endif +!endif # [nmakehlp -c -GL] -DEBUGFLAGS = +DEBUGFLAGS = $(FPOPTS) +# Run time error checks. Not available or valid in a release, non-debug build +# RTC is for modern compilers, -GZ is legacy !if [nmakehlp -c -RTC1] DEBUGFLAGS = $(DEBUGFLAGS) -RTC1 !elseif [nmakehlp -c -GZ] DEBUGFLAGS = $(DEBUGFLAGS) -GZ !endif -COMPILERFLAGS = /DUNICODE /D_UNICODE /D_ATL_XP_TARGETING -# In v13 -GL and -YX are incompatible. -!if [nmakehlp -c -YX] -!if ![nmakehlp -c -GL] -OPTIMIZATIONS = $(OPTIMIZATIONS) -YX -!endif -!endif -!if "$(MACHINE)" == "IX86" -### test for pentium errata -!if [nmakehlp -c -QI0f] -!message *** Compiler has 'Pentium 0x0f fix' -COMPILERFLAGS = $(COMPILERFLAGS) -QI0f -!else -!message *** Compiler does not have 'Pentium 0x0f fix' -!endif -!endif +#---------------------------------------------------------------- +# Linker flags -# Prevents "LNK1561: entry point must be defined" error compiling from VS-IDE: +# LINKER_TESTFLAGS are for internal use when we call nmakehlp to test +# if the linker supports a specific option. Without these flags link will +# return "LNK1561: entry point must be defined" error compiling from VS-IDE: +# They are not passed through to the actual application / extension +# link rules. !ifndef LINKER_TESTFLAGS LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmhlp-out.txt !endif -!if "$(MACHINE)" == "IX86" -### test for -align:4096, when align:512 will do. -!if [nmakehlp -l -opt:nowin98 $(LINKER_TESTFLAGS)] -!message *** Linker has 'Win98 alignment problem' -ALIGN98_HACK = 1 -!else -!message *** Linker does not have 'Win98 alignment problem' -ALIGN98_HACK = 0 -!endif -!else -ALIGN98_HACK = 0 -!endif - LINKERFLAGS = +# If compiler has enabled link time optimization, linker must too with -ltcg !ifdef CC_GL_OPT_ENABLED !if [nmakehlp -l -ltcg $(LINKER_TESTFLAGS)] LINKERFLAGS = $(LINKERFLAGS) -ltcg @@ -503,47 +691,6 @@ OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64 !endif -#---------------------------------------------------------- -# Locate the Tcl headers to build against -#---------------------------------------------------------- - -!if "$(PROJECT)" == "tcl" - -_TCL_H = ..\generic\tcl.h - -!else - -# If INSTALLDIR set to tcl root dir then reset to the lib dir. -!if exist("$(_INSTALLDIR)\include\tcl.h") -_INSTALLDIR=$(_INSTALLDIR)\lib -!endif - -!if !defined(TCLDIR) -!if exist("$(_INSTALLDIR)\..\include\tcl.h") -TCLINSTALL = 1 -_TCLDIR = $(_INSTALLDIR)\.. -_TCL_H = $(_INSTALLDIR)\..\include\tcl.h -TCLDIR = $(_INSTALLDIR)\.. -!else -MSG=^ -Failed to find tcl.h. Set the TCLDIR macro. -!error $(MSG) -!endif -!else -_TCLDIR = $(TCLDIR:/=\) -!if exist("$(_TCLDIR)\include\tcl.h") -TCLINSTALL = 1 -_TCL_H = $(_TCLDIR)\include\tcl.h -!elseif exist("$(_TCLDIR)\generic\tcl.h") -TCLINSTALL = 0 -_TCL_H = $(_TCLDIR)\generic\tcl.h -!else -MSG =^ -Failed to find tcl.h. The TCLDIR macro does not appear correct. -!error $(MSG) -!endif -!endif -!endif #-------------------------------------------------------------- # Extract various version numbers from tcl headers @@ -703,11 +850,14 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" !endif -#----------------------------------------------------------------------------------- -# Now we have all the information we need, set up the actual flags and options that -# we will pass to the compiler and linker. The main makefile should use these in -# combination with whatever other flags and switches are specific to it. -#----------------------------------------------------------------------------------- +#---------------------------------------------------------------------- +# Now we have all the information we need, set up the actual flags and +# options that we will pass to the compiler and linker. The main +# makefile should use these in combination with whatever other flags +# and switches are specific to it. +#---------------------------------------------------------------------- + +COMPILERFLAGS = /DUNICODE /D_UNICODE /D_ATL_XP_TARGETING /DBUILD_$(PROJECT) # crt picks the C run time based on selected OPTS !if $(MSVCRT) @@ -741,13 +891,16 @@ cdebug = $(cdebug) -Zi # cwarn includes default warning levels. cwarn = $(WARNINGS) + !if "$(MACHINE)" == "AMD64" # Disable pointer<->int warnings related to cast between different sizes -# There are a gadzillion of these due to use of ClientData and clutter up compiler +# There are a gadzillion of these due to use of ClientData and +# clutter up compiler # output increasing chance of a real warning getting lost. So disable them. # Eventually some day, Tcl will be 64-bit clean. cwarn = $(cwarn) -wd4311 -wd4312 !endif + !if $(DEBUG) # Turn warnings into errors cwarn = $(cwarn) -WX @@ -764,7 +917,7 @@ ldebug = $(ldebug) -debug -debugtype:cv !endif !endif -# Note: Profiling is currently only possible with the Enterprise version of Visual Studio +# Note: Profiling is currently only possible with the Visual Studio Enterprise !if $(PROFILE) ldebug= $(ldebug) -profile !endif @@ -776,12 +929,16 @@ lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug) lflags = $(lflags) -nodefaultlib:libucrt.lib !endif -!if $(ALIGN98_HACK) && !$(STATIC_BUILD) -### Align sections for PE size savings. +# Old linkers (Visual C++ 6 in particular) will link for fast loading +# on Win98. Since we do not support Win98 any more, we specify nowin98 +# as recommended for NT and later. However, this is only required by +# IX86 on older compilers and only needed if we are not doing a static build. + +!if "$(MACHINE)" == "IX86" && !$(STATIC_BUILD) +!if [nmakehlp -l -opt:nowin98 $(LINKER_TESTFLAGS)] +# Align sections for PE size savings. lflags = $(lflags) -opt:nowin98 -!else if !$(ALIGN98_HACK) && $(STATIC_BUILD) -### Align sections for speed in loading by choosing the virtual page size. -lflags = $(lflags) -align:4096 +!endif !endif !if $(LOIMPACT) @@ -810,6 +967,8 @@ baselibs = $(winlibs) $(extralibs) baselibs = $(baselibs) ucrt.lib !endif + + #---------------------------------------------------------- # Display stats being used. #---------------------------------------------------------- -- cgit v0.12 From c7e43807bf0e2db98723fe0513e4e92ec2ab60ae Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sat, 23 Sep 2017 07:35:32 +0000 Subject: More refactoring. Moved defines that are Tcl-specific to makefile.vc as rules.vc is common to extensions. Reworked parsing of STATS and CHECKS. --- win/makefile.vc | 24 +++++ win/rules.vc | 308 ++++++++++++++++++++++++++++++-------------------------- 2 files changed, 188 insertions(+), 144 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 49890f3..5a78e9f 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -182,6 +182,30 @@ Please `cd` to its location first. PROJECT = tcl !include "rules.vc" +!if [echo PKG_HTTP_VER = \>> versions.vc] \ + && [nmakehlp -V ..\library\http\pkgIndex.tcl http >> versions.vc] +!endif +!if [echo PKG_TCLTEST_VER = \>> versions.vc] \ + && [nmakehlp -V ..\library\tcltest\pkgIndex.tcl tcltest >> versions.vc] +!endif +!if [echo PKG_MSGCAT_VER = \>> versions.vc] \ + && [nmakehlp -V ..\library\msgcat\pkgIndex.tcl msgcat >> versions.vc] +!endif +!if [echo PKG_PLATFORM_VER = \>> versions.vc] \ + && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform " >> versions.vc] +!endif +!if [echo PKG_SHELL_VER = \>> versions.vc] \ + && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform::shell" >> versions.vc] +!endif +!if [echo PKG_DDE_VER = \>> versions.vc] \ + && [nmakehlp -V ..\library\dde\pkgIndex.tcl "dde " >> versions.vc] +!endif +!if [echo PKG_REG_VER =\>> versions.vc] \ + && [nmakehlp -V ..\library\reg\pkgIndex.tcl registry >> versions.vc] +!endif + +!include versions.vc + STUBPREFIX = $(PROJECT)stub DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION) VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION) diff --git a/win/rules.vc b/win/rules.vc index d3c36d9..f58beb8 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -27,7 +27,12 @@ _RULES_VC = 1 # 3. Determine the compiler and linker versions # 4. Build the nmakehlp helper application # 5. Determine the supported compiler options and features -# 6. Parse the OPTS macro value for user-specified configuration +# 6. Parse the OPTS macro value for user-specified build configuration +# 7. Parse the STATS macro value for statistics instrumentation +# 8. Parse the CHECKS macro for additional compilation checks +# 9. Extract Tcl version numbers from the headers +# 10.Based on this specified configuration, construct the output +# directory names # # One final note about the macro names used. They are as they are # for historical reasons. We would like legacy extensions to @@ -390,14 +395,34 @@ LINKERFLAGS = $(LINKERFLAGS) -ltcg !endif !endif -#---------------------------------------------------------- -# Decode the options requested. -#---------------------------------------------------------- - -!if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"] - -# if No OPTS specified +######################################################################## +# 6. Parse the OPTS macro to work out the requested build configuration. +# Based on this, we will construct the actual switches to be passed to the +# compiler and linker using the macros defined in the previous section. +# The following macros are defined by this section based on OPTS +# STATIC_BUILD - 0 -> Tcl is to be built as a shared library +# 1 -> build as a static library and shell +# TCL_THREADS - legacy but always 1 on Windows since winsock requires it. +# DEBUG - 1 -> debug build, 0 -> release builds +# SYMBOLS - 1 -> generate PDB's, 0 -> no PDB's +# PROFILE - 1 -> generate profiling info, 0 -> no profiling +# PGO - 1 -> profile based optimization, 0 -> no +# MSVCRT - 1 -> link to dynamic C runtime even when building static Tcl build +# 0 -> link to static C runtime for static Tcl build. +# Does not impact shared Tcl builds (STATIC_BUILD == 0) +# LOIMPACT - 1 -> Ask Windows loader to aggressively trim the working set. +# Will reduce physical memory use at cost of performance. +# TCL_USE_STATIC_PACKAGES - 1 -> statically link the registry and dde extensions +# in the Tcl shell. 0 -> keep them as shared libraries +# Does not impact shared Tcl builds. +# USE_THREAD_ALLOC - 1 -> Use a shared global free pool for allocation. +# 0 -> Use the non-thread allocator. +# UNCHECKED - 1 -> when doing a debug build with symbols, use the release +# C runtime, 0 -> use the debug C runtime. +# +# Further, LINKERFLAGS are modified based on above. +# Default values for all the above STATIC_BUILD = 0 TCL_THREADS = 1 DEBUG = 0 @@ -410,7 +435,9 @@ TCL_USE_STATIC_PACKAGES = 0 USE_THREAD_ALLOC = 1 UNCHECKED = 0 -!else +# If OPTS is not empty AND does not contain "none" which turns off all OPTS +# set the above macros based on OPTS content +!if "$(OPTS)" != "" && ![nmakehlp -f "$(OPTS)" "none"] # OPTS are specified, parse them @@ -446,12 +473,6 @@ TCL_USE_STATIC_PACKAGES = 0 !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"] @@ -492,11 +513,13 @@ LOIMPACT = 1 LOIMPACT = 0 !endif +# TBD - should get rid of this option !if [nmakehlp -f $(OPTS) "thrdalloc"] !message *** Doing thrdalloc USE_THREAD_ALLOC = 1 !endif +# TBD - should get rid of this option !if [nmakehlp -f $(OPTS) "tclalloc"] !message *** Doing tclalloc USE_THREAD_ALLOC = 0 @@ -509,24 +532,135 @@ UNCHECKED = 1 UNCHECKED = 0 !endif -!endif # "$(OPTS)" == "" ... parsing of OPTS +!endif # "$(OPTS)" != "" && ... parsing of OPTS -#---------------------------------------------------------- -# Figure-out how to name our intermediate and output directories. -# We wouldn't want different builds to use the same .obj files -# by accident. -#---------------------------------------------------------- +# Set linker flags based on above + +!if $(PGO) > 1 +!if [nmakehlp -l -ltcg:pgoptimize $(LINKER_TESTFLAGS)] +LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize +!else +MSG=^ +This compiler does not support profile guided optimization. +!error $(MSG) +!endif +!elseif $(PGO) > 0 +!if [nmakehlp -l -ltcg:pginstrument $(LINKER_TESTFLAGS)] +LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument +!else +MSG=^ +This compiler does not support profile guided optimization. +!error $(MSG) +!endif +!endif + +################################################################ +# 7. Parse the STATS macro to configure code instrumentation +# The following macros are set by this section: +# TCL_MEM_DEBUG - 1 -> enables memory allocation instrumentation +# 0 -> disables +# TCL_COMPILE_DEBUG - 1 -> enables byte compiler logging +# 0 -> disables + +# Default both are off +TCL_MEM_DEBUG = 0 +TCL_COMPILE_DEBUG = 0 + +!if "$(STATS)" != "" && ![nmakehlp -f "$(STATS)" "none"] + +!if [nmakehlp -f $(STATS) "memdbg"] +!message *** Doing memdbg +TCL_MEM_DEBUG = 1 +!else +TCL_MEM_DEBUG = 0 +!endif + +!if [nmakehlp -f $(STATS) "compdbg"] +!message *** Doing compdbg +TCL_COMPILE_DEBUG = 1 +!else +TCL_COMPILE_DEBUG = 0 +!endif -#---------------------------------------- -# Naming convention: +!endif + +#################################################################### +# 8. Parse the CHECKS macro to configure additional compiler checks +# The following macros are set by this section: +# WARNINGS - compiler switches that control the warnings level +# TCL_NO_DEPRECATED - 1 -> disable support for deprecated functions +# 0 -> enable deprecated functions + +# Defaults - Permit deprecated functions and warning level 3 +TCL_NO_DEPRECATED = 0 +WARNINGS = -W3 + +!if "$(CHECKS)" != "" && ![nmakehlp -f "$(CHECKS)" "none"] + +!if [nmakehlp -f $(CHECKS) "nodep"] +!message *** Doing nodep check +TCL_NO_DEPRECATED = 1 +!endif + +!if [nmakehlp -f $(CHECKS) "fullwarn"] +!message *** Doing full warnings check +WARNINGS = -W4 +!if [nmakehlp -l -warn:3 $(LINKER_TESTFLAGS)] +LINKERFLAGS = $(LINKERFLAGS) -warn:3 +!endif +!endif + +!if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64] +!message *** Doing 64bit portability warnings +WARNINGS = $(WARNINGS) -Wp64 +!endif + +!endif + +################################################################ +# 9. Extract various version numbers from tcl headers +# Sets the following macros: +# TCL_MAJOR_VERSION +# TCL_MINOR_VERSION +# TCL_PATCH_LEVEL +#-------------------------------------------------------------- + +!if [echo REM = This file is generated from rules.vc > versions.vc] +!endif +!if [echo TCL_MAJOR_VERSION = \>> versions.vc] \ + && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc] +!endif +!if [echo TCL_MINOR_VERSION = \>> versions.vc] \ + && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc] +!endif +!if [echo TCL_PATCH_LEVEL = \>> versions.vc] \ + && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc] +!endif + +!include versions.vc + +################################################################ +# 10. Construct output directory names +# Figure-out how to name our intermediate and output directories. +# In order to avoid inadvertent mixing of object files built using +# different compilers, build configurations etc., +# +# Naming convention (suffixes): # t = full thread support. -# s = static library (as opposed to an -# import library) -# g = linked to the debug enabled C -# run-time. -# x = special static build when it -# links to the dynamic C run-time. -#---------------------------------------- +# s = static library (as opposed to an import library) +# g = linked to the debug enabled C run-time. +# x = special static build when it links to the dynamic C run-time. +# +# The following macros are set in this section: +# SUFX - the suffix to use for binaries based on above naming convention +# BUILDDIRTOP - the toplevel default output directory +# is of the form {Release,Debug}[_AMD64][_COMPILERVERSION] +# TMP_DIR - directory where object files are created +# OUT_DIR - directory where output executables are created +# 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. + SUFX = tsgx !if $(DEBUG) @@ -581,76 +715,6 @@ OUT_DIR = $(TMP_DIR) #---------------------------------------------------------- -# Decode the statistics requested. -#---------------------------------------------------------- - -!if "$(STATS)" == "" || [nmakehlp -f "$(STATS)" "none"] -TCL_MEM_DEBUG = 0 -TCL_COMPILE_DEBUG = 0 -!else -!if [nmakehlp -f $(STATS) "memdbg"] -!message *** Doing memdbg -TCL_MEM_DEBUG = 1 -!else -TCL_MEM_DEBUG = 0 -!endif -!if [nmakehlp -f $(STATS) "compdbg"] -!message *** Doing compdbg -TCL_COMPILE_DEBUG = 1 -!else -TCL_COMPILE_DEBUG = 0 -!endif -!endif - - -#---------------------------------------------------------- -# Decode the checks requested. -#---------------------------------------------------------- - -!if "$(CHECKS)" == "" || [nmakehlp -f "$(CHECKS)" "none"] -TCL_NO_DEPRECATED = 0 -WARNINGS = -W3 -!else -!if [nmakehlp -f $(CHECKS) "nodep"] -!message *** Doing nodep check -TCL_NO_DEPRECATED = 1 -!else -TCL_NO_DEPRECATED = 0 -!endif -!if [nmakehlp -f $(CHECKS) "fullwarn"] -!message *** Doing full warnings check -WARNINGS = -W4 -!if [nmakehlp -l -warn:3 $(LINKER_TESTFLAGS)] -LINKERFLAGS = $(LINKERFLAGS) -warn:3 -!endif -!else -WARNINGS = -W3 -!endif -!if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64] -!message *** Doing 64bit portability warnings -WARNINGS = $(WARNINGS) -Wp64 -!endif -!endif - -!if $(PGO) > 1 -!if [nmakehlp -l -ltcg:pgoptimize $(LINKER_TESTFLAGS)] -LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize -!else -MSG=^ -This compiler does not support profile guided optimization. -!error $(MSG) -!endif -!elseif $(PGO) > 0 -!if [nmakehlp -l -ltcg:pginstrument $(LINKER_TESTFLAGS)] -LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument -!else -MSG=^ -This compiler does not support profile guided optimization. -!error $(MSG) -!endif -!endif - -#---------------------------------------------------------- # Set our defines now armed with our options. #---------------------------------------------------------- @@ -693,50 +757,6 @@ OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64 #-------------------------------------------------------------- -# Extract various version numbers from tcl headers -# The generated file is then included in the makefile. -#-------------------------------------------------------------- - -!if [echo REM = This file is generated from rules.vc > versions.vc] -!endif -!if [echo TCL_MAJOR_VERSION = \>> versions.vc] \ - && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc] -!endif -!if [echo TCL_MINOR_VERSION = \>> versions.vc] \ - && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc] -!endif -!if [echo TCL_PATCH_LEVEL = \>> versions.vc] \ - && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc] -!endif - -# If building the tcl core then we need additional package versions -!if "$(PROJECT)" == "tcl" -!if [echo PKG_HTTP_VER = \>> versions.vc] \ - && [nmakehlp -V ..\library\http\pkgIndex.tcl http >> versions.vc] -!endif -!if [echo PKG_TCLTEST_VER = \>> versions.vc] \ - && [nmakehlp -V ..\library\tcltest\pkgIndex.tcl tcltest >> versions.vc] -!endif -!if [echo PKG_MSGCAT_VER = \>> versions.vc] \ - && [nmakehlp -V ..\library\msgcat\pkgIndex.tcl msgcat >> versions.vc] -!endif -!if [echo PKG_PLATFORM_VER = \>> versions.vc] \ - && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform " >> versions.vc] -!endif -!if [echo PKG_SHELL_VER = \>> versions.vc] \ - && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform::shell" >> versions.vc] -!endif -!if [echo PKG_DDE_VER = \>> versions.vc] \ - && [nmakehlp -V ..\library\dde\pkgIndex.tcl "dde " >> versions.vc] -!endif -!if [echo PKG_REG_VER =\>> versions.vc] \ - && [nmakehlp -V ..\library\reg\pkgIndex.tcl registry >> versions.vc] -!endif -!endif - -!include versions.vc - -#-------------------------------------------------------------- # Setup tcl version dependent stuff headers #-------------------------------------------------------------- -- cgit v0.12 From ad9a3b8b45304f8f24b7de903fcfd18394e09045 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sun, 24 Sep 2017 06:03:34 +0000 Subject: Moved generic compiler and linker flags completely into rules.vc so extensions do not have to repeat the verbage. Special case Tk as a Tcl extension and add default for locating Tcl source. Both Tcl and Tk compile with new rules. --- win/makefile.vc | 16 ++- win/rules.vc | 341 +++++++++++++++++++++++++++++++------------------------- 2 files changed, 197 insertions(+), 160 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 5a78e9f..2891e2f 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -182,6 +182,8 @@ Please `cd` to its location first. PROJECT = tcl !include "rules.vc" +!if [echo REM = This file is generated from makefile.vc > versions.vc] +!endif !if [echo PKG_HTTP_VER = \>> versions.vc] \ && [nmakehlp -V ..\library\http\pkgIndex.tcl http >> versions.vc] !endif @@ -488,18 +490,14 @@ PKGSDIR = $(ROOT)\pkgs #--------------------------------------------------------------------- -### Declarations common to all compiler options -cwarn = $(cwarn) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE - -cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\ - +cflags = $(cflags) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE +cflags = $(cflags) -Fp$(TMP_DIR)^\ TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" -I"$(TOMMATHDIR)" TCL_DEFINES = -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1 -BASE_CFLAGS = $(cflags) $(cdebug) $(crt) $(TCL_INCLUDES) $(TCL_DEFINES) -CON_CFLAGS = $(cflags) $(cdebug) $(crt) -DCONSOLE -TCL_CFLAGS = $(BASE_CFLAGS) $(OPTDEFINES) -STUB_CFLAGS = $(cflags) $(cdebug) $(OPTDEFINES) +CON_CFLAGS = $(cflags) $(crt) -DCONSOLE +TCL_CFLAGS = $(cflags) $(crt) $(TCL_INCLUDES) $(TCL_DEFINES) $(OPTDEFINES) +STUB_CFLAGS = $(cflags) $(OPTDEFINES) #--------------------------------------------------------------------- diff --git a/win/rules.vc b/win/rules.vc index f58beb8..a09e879 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -30,9 +30,11 @@ _RULES_VC = 1 # 6. Parse the OPTS macro value for user-specified build configuration # 7. Parse the STATS macro value for statistics instrumentation # 8. Parse the CHECKS macro for additional compilation checks -# 9. Extract Tcl version numbers from the headers -# 10.Based on this specified configuration, construct the output -# directory names +# 9. Extract Tcl, and possibly Tk, version numbers from the headers +# 10.Based on this selected configuration, construct the output +# directory and file paths +# 11.Set up the actual options passed to compiler and linker based +# on the information gathered above. # # One final note about the macro names used. They are as they are # for historical reasons. We would like legacy extensions to @@ -59,11 +61,12 @@ MKDIR = mkdir # 2. Figure out our build environment in terms of what we're building. # # (a) Tcl itself -# (b) a Tcl extension using libraries/includes from an *installed* Tcl -# (c) a Tcl extension using libraries/includes from Tcl source directory +# (b) Tk +# (c) a Tcl extension using libraries/includes from an *installed* Tcl +# (d) a Tcl extension using libraries/includes from Tcl source directory # -# This last is needed because some extensions (even Tk) still need -# some Tcl interfaces that have are not publicly exposed. +# This last is needed because some extensions still need +# some Tcl interfaces that are not publicly exposed. # # The fragment will set the following macros: # _TCLDIR - root of the Tcl installation OR the Tcl sources. Not set @@ -71,11 +74,17 @@ MKDIR = mkdir # _INSTALLDIR - native form of the installation path. For Tcl # this will be the root of the Tcl installation. For extensions # this will be the lib directory under the root. -# TCLINSTALL - set to 1 if an extension is being built against the +# TCLINSTALL - set to 1 if _TCLDIR refers to # headers and libraries from an installed Tcl, and 0 if built against # Tcl sources. Not set when building Tcl itself. Yes, not very well # named. # _TCL_H - native path to the tcl.h file +# +# If Tk is involved, also sets the following +# _TKDIR - native form Tk installation OR Tk source. Not set if building +# Tk itself. +# TKINSTALL - set 1 if _TKDIR refers to installed Tk and 0 if Tk sources +# _TK_H - native path to the tk.h file # The root directory where the built packages and binaries will be installed. # INSTALLDIR is the (optional) path specified by the user. @@ -88,62 +97,114 @@ _INSTALLDIR = $(INSTALLDIR:/=\) _INSTALLDIR = C:\Program Files\Tcl !endif -!if "$(PROJECT)" == "tcl" # Case 2(a) - Building Tcl itself +!if "$(PROJECT)" == "tcl" + +# BEGIN Case 2(a) - Building Tcl itself # Only need to define _TCL_H _TCL_H = ..\generic\tcl.h -!else # Case 2(b) or (c) - Building an extension +# END Case 2(a) - Building Tcl itself + +!elseif "$(PROJECT)" == "tk" + +# BEGIN Case 2(b) - Building Tk + +TCLINSTALL = 0 # Tk always builds against Tcl source, not an installed Tcl +!ifndef TCLDIR +TCLDIR = ../../tcl +!endif +_TCLDIR = $(TCLDIR:/=\) +_TCL_H = $(_TCLDIR)\generic\tcl.h +!message TCLH $(_TCL_H) +!if !exist("$(_TCL_H)") +!error Could not locate tcl.h. Please set the TCLDIR macro to point to the Tcl *source* directory. +!endif + +_TK_H = ..\generic\tk.h + +# END Case 2(b) - Building Tk + +!else + +# BEGIN Case 2(c) or (d) - Building an extension other than Tk # If command line has specified Tcl location through TCLDIR, use it # else default to the INSTALLDIR setting !ifdef TCLDIR _TCLDIR = $(TCLDIR:/=\) -!if exist("$(_TCLDIR)\include\tcl.h") # Case 2(a) with TCLDIR defined +!if exist("$(_TCLDIR)\include\tcl.h") # Case 2(c) with TCLDIR defined TCLINSTALL = 1 _TCL_H = $(_TCLDIR)\include\tcl.h -!elseif exist("$(_TCLDIR)\generic\tcl.h") # Case 2(b) with TCLDIR defined +!elseif exist("$(_TCLDIR)\generic\tcl.h") # Case 2(d) with TCLDIR defined TCLINSTALL = 0 _TCL_H = $(_TCLDIR)\generic\tcl.h !endif !else # TCLDIR is not defined -!if "$(PROJECT)" == "tk" - -!if exist("..\..\tcl\generic\tcl.h") # Special case Tk with TCLDIR undefined -TCLINSTALL = 0 -TCLDIR = ..\..\tcl -_TCLDIR = $(TCLDIR) -_TCL_H = $(_TCLDIR)\generic\tcl.h -!endif - -!elseif exist("$(_INSTALLDIR)\include\tcl.h") # Case 2(a) for non-Tk with TCLDIR undefined - +!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 - -!endif # $(PROJECT) == "tk" +!endif !endif # TCLDIR -# If INSTALLDIR set to tcl root dir then reset to the lib dir. -!if exist("$(_INSTALLDIR)\include\tcl.h") -_INSTALLDIR=$(_INSTALLDIR)\lib +!ifndef _TCL_H +MSG =^ +Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and default path does not contain tcl.h. +!error $(MSG) !endif -!endif # if $(PROJECT) == "tcl" +# Now do the same to locate Tk headers and libs if project requires Tk +!ifdef PROJECT_REQUIRES_TK -!ifndef _TCL_H +!ifdef TKDIR + +_TKDIR = $(TKDIR:/=\) +!if exist("$(_TKDIR)\include\tk.h") +TKINSTALL = 1 +_TK_H = $(_TKDIR)\include\tk.h +!elseif exist("$(_TKDIR)\generic\tk.h") +TKINSTALL = 0 +_TK_H = $(_TKDIR)\generic\tk.h +!endif + +!else # TKDIR not defined + +!if exist("$(_INSTALLDIR)\..\include\tk.h") +TKINSTALL = 1 +_TKDIR = $(_INSTALLDIR)\.. +_TK_H = $(_TKDIR)\include\tk.h +TKDIR = $(_TKDIR) +!elseif exist("$(_TCLDIR)\include\tk.h") +TKINSTALL = 1 +_TKDIR = $(_TCLDIR) +_TK_H = $(_TKDIR)\include\tk.h +TKDIR = $(_TKDIR) +!endif + +!endif # TKDIR + +!ifndef _TK_H MSG =^ -Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and default path does not contain tcl.h. +Failed to find tk.h. The TKDIR macro is set incorrectly or is not set and default path does not contain tk.h. !error $(MSG) !endif +!endif # PROJECT_REQUIRES_TK +# If INSTALLDIR set to tcl installation root dir then reset to the +# lib dir for installing extensions +!if exist("$(_INSTALLDIR)\include\tcl.h") +_INSTALLDIR=$(_INSTALLDIR)\lib +!endif + +# END Case 2(c) or (d) - Building an extension +!endif # if $(PROJECT) == "tcl" ################################################################ # 3. Determine compiler version and architecture @@ -372,8 +433,6 @@ DEBUGFLAGS = $(DEBUGFLAGS) -RTC1 DEBUGFLAGS = $(DEBUGFLAGS) -GZ !endif - - #---------------------------------------------------------------- # Linker flags @@ -623,6 +682,11 @@ WARNINGS = $(WARNINGS) -Wp64 # TCL_MAJOR_VERSION # TCL_MINOR_VERSION # TCL_PATCH_LEVEL +# TCL_VERSION +# TK_MAJOR_VERSION +# TK_MINOR_VERSION +# TK_PATCH_LEVEL +# TK_VERSION #-------------------------------------------------------------- !if [echo REM = This file is generated from rules.vc > versions.vc] @@ -637,10 +701,28 @@ WARNINGS = $(WARNINGS) -Wp64 && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc] !endif +!if defined(_TK_H) +!if [echo TK_MAJOR_VERSION = \>> versions.vc] \ + && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc] +!endif +!if [echo TK_MINOR_VERSION = \>> versions.vc] \ + && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc] +!endif +!if [echo TK_PATCH_LEVEL = \>> versions.vc] \ + && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc] +!endif +!endif # _TK_H + !include versions.vc +TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION) +!if defined(_TK_H) +TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION) +!endif + + ################################################################ -# 10. Construct output directory names +# 10. Construct output directory and file paths # Figure-out how to name our intermediate and output directories. # In order to avoid inadvertent mixing of object files built using # different compilers, build configurations etc., @@ -713,58 +795,11 @@ OUT_DIR = $(TMP_DIR) !endif !endif - -#---------------------------------------------------------- -# Set our defines now armed with our options. -#---------------------------------------------------------- - -OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS - -!if $(TCL_MEM_DEBUG) -OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG -!endif -!if $(TCL_COMPILE_DEBUG) -OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS -!endif -!if $(TCL_THREADS) -OPTDEFINES = $(OPTDEFINES) -DTCL_THREADS=1 -!if $(USE_THREAD_ALLOC) -OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1 -!endif -!endif -!if $(STATIC_BUILD) -OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD -!endif -!if $(TCL_NO_DEPRECATED) -OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED -!endif - -!if !$(DEBUG) -OPTDEFINES = $(OPTDEFINES) -DNDEBUG -!if $(OPTIMIZING) -OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED -!endif -!endif -!if $(PROFILE) -OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED -!endif -!if "$(MACHINE)" == "AMD64" -OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT -!endif -!if $(VCVERSION) < 1300 -OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64 -!endif - - -#-------------------------------------------------------------- -# Setup tcl version dependent stuff headers -#-------------------------------------------------------------- - +# Set up paths to various Tcl executables and libraries needed by extensions !if "$(PROJECT)" != "tcl" -TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION) +!if $(TCLINSTALL) # Building against an installed Tcl -!if $(TCLINSTALL) TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe" !if !exist($(TCLSH)) && $(TCL_THREADS) TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe" @@ -777,7 +812,9 @@ TCLDDELIB = "$(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib" COFFBASE = \must\have\tcl\sources\to\build\this\target TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target TCL_INCLUDES = -I"$(_TCLDIR)\include" -!else + +!else # Building against Tcl sources + TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe" !if !exist($(TCLSH)) && $(TCL_THREADS) TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX).exe" @@ -790,93 +827,94 @@ TCLDDELIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib" COFFBASE = "$(_TCLDIR)\win\coffbase.txt" TCLTOOLSDIR = $(_TCLDIR)\tools TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win" -!endif -!endif +!endif # TCLINSTALL -#------------------------------------------------------------------------- -# Locate the Tk headers to build against -#------------------------------------------------------------------------- +!endif $(PROJECT) != "tcl" -!if "$(PROJECT)" == "tk" -_TK_H = ..\generic\tk.h -_INSTALLDIR = $(_INSTALLDIR)\.. -!endif +# Do the same for Tk extensions that require the Tk libraries +!if defined(PROJECT_REQUIRES_TK) -!ifdef PROJECT_REQUIRES_TK -!if !defined(TKDIR) -!if exist("$(_INSTALLDIR)\..\include\tk.h") -TKINSTALL = 1 -_TKDIR = $(_INSTALLDIR)\.. -_TK_H = $(_TKDIR)\include\tk.h -TKDIR = $(_TKDIR) -!elseif exist("$(_TCLDIR)\include\tk.h") -TKINSTALL = 1 -_TKDIR = $(_TCLDIR) -_TK_H = $(_TKDIR)\include\tk.h -TKDIR = $(_TKDIR) -!endif -!else -_TKDIR = $(TKDIR:/=\) -!if exist("$(_TKDIR)\include\tk.h") -TKINSTALL = 1 -_TK_H = $(_TKDIR)\include\tk.h -!elseif exist("$(_TKDIR)\generic\tk.h") -TKINSTALL = 0 -_TK_H = $(_TKDIR)\generic\tk.h -!else -MSG =^ -Failed to find tk.h. The TKDIR macro does not appear correct. -!error $(MSG) -!endif -!endif -!endif - -#------------------------------------------------------------------------- -# Extract Tk version numbers -#------------------------------------------------------------------------- - -!if defined(PROJECT_REQUIRES_TK) || "$(PROJECT)" == "tk" +!if $(TKINSTALL) # Building against installed Tk -!if [echo TK_MAJOR_VERSION = \>> versions.vc] \ - && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc] -!endif -!if [echo TK_MINOR_VERSION = \>> versions.vc] \ - && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc] -!endif -!if [echo TK_PATCH_LEVEL = \>> versions.vc] \ - && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc] -!endif - -!include versions.vc - -TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION) -TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION) - -!if "$(PROJECT)" != "tk" -!if $(TKINSTALL) WISH = "$(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe" TKSTUBLIB = "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib" TKIMPLIB = "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib" TK_INCLUDES = -I"$(_TKDIR)\include" -!else + +!else # Building against Tk sources + WISH = "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe" TKSTUBLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib" TKIMPLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib" TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" -!endif -!endif -!endif +!endif # TKINSTALL +!endif # PROJECT_REQUIRES_TK -#---------------------------------------------------------------------- + +################################################################### +# 11. Set up actual options to be passed to the compiler and linker # Now we have all the information we need, set up the actual flags and # options that we will pass to the compiler and linker. The main # makefile should use these in combination with whatever other flags # and switches are specific to it. -#---------------------------------------------------------------------- +# The following macros are defined, names are for historical compatibility: +# OPTDEFINES - /Dxxx C macro flags based on user-specified OPTS +# COMPILERFLAGS - /Dxxx C macro flags independent of any configuration opttions +# crt - Compiler switch that selects the appropriate C runtime +# cdebug - Compiler switches related to debug AND optimizations +# cwarn - Compiler switches that set warning levels +# cflags - complete compiler switches (subsumes cdebug and cwarn) +# ldebug - Linker switches controlling debug information and optimization +# lflags - complete linker switches (subsumes ldebug) except subsystem type +# dlllflags - complete linker switches to build DLLs (subsumes lflags) +# conlflags - complete linker switches for console program (subsumes lflags) +# guilflags - complete linker switches for GUI program (subsumes lflags) +# baselibs - minimum Windows libraries required. Parent makefile can +# define extralibs before including rules.rc if additional libs are needed + +OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS + +!if $(TCL_MEM_DEBUG) +OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG +!endif +!if $(TCL_COMPILE_DEBUG) +OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS +!endif +!if $(TCL_THREADS) +OPTDEFINES = $(OPTDEFINES) -DTCL_THREADS=1 +!if $(USE_THREAD_ALLOC) +OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1 +!endif +!endif +!if $(STATIC_BUILD) +OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD +!endif +!if $(TCL_NO_DEPRECATED) +OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED +!endif +!if !$(DEBUG) +OPTDEFINES = $(OPTDEFINES) -DNDEBUG +!if $(OPTIMIZING) +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED +!endif +!endif +!if $(PROFILE) +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED +!endif +!if "$(MACHINE)" == "AMD64" +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT +!endif +!if $(VCVERSION) < 1300 +OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64 +!endif + +# UNICODE - Use the wide char Windows API. +# _ATL_XP_TARGETING - Newer SDK's need this to build for XP +# BUILD_xxx - defined to export the xxx_Init call from the DLL COMPILERFLAGS = /DUNICODE /D_UNICODE /D_ATL_XP_TARGETING /DBUILD_$(PROJECT) # crt picks the C run time based on selected OPTS @@ -926,6 +964,8 @@ cwarn = $(cwarn) -wd4311 -wd4312 cwarn = $(cwarn) -WX !endif +cflags = -nologo -c $(COMPILERFLAGS) $(cdebug) $(cwarn) -Fp$(TMP_DIR)^\ + # Link flags !if $(DEBUG) @@ -988,7 +1028,6 @@ baselibs = $(baselibs) ucrt.lib !endif - #---------------------------------------------------------- # Display stats being used. #---------------------------------------------------------- -- cgit v0.12 From a91099b33b6288e117d3913fb6da2800c2026758 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sun, 24 Sep 2017 12:13:29 +0000 Subject: Move installation dir macros to rules.vc --- win/makefile.vc | 20 ------------------ win/rules.vc | 63 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 29 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 2891e2f..098662b 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -13,16 +13,6 @@ # Copyright (c) 2003-2008 Pat Thoyts. #------------------------------------------------------------------------------ -# Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or -# VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir) -!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR) -MSG = ^ -You need to run vcvars32.bat from Developer Studio or setenv.bat from the^ -Platform SDK first to setup the environment. Jump to this line to read^ -the build instructions. -!error $(MSG) -!endif - #------------------------------------------------------------------------------ # HOW TO USE this makefile: # @@ -218,9 +208,6 @@ DDEVERSION = $(DDEDOTVERSION:.=) REGDOTVERSION = 1.3 REGVERSION = $(REGDOTVERSION:.=) -BINROOT = $(MAKEDIR) # originally . -ROOT = $(MAKEDIR)\.. # originally .. - TCLIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib TCLLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT) TCLLIB = $(OUT_DIR)\$(TCLLIBNAME) @@ -249,13 +236,6 @@ TCLSH_NATIVE = $(TCLSH) !endif !endif -### Make sure we use backslash only. -LIB_INSTALL_DIR = $(_INSTALLDIR)\lib -BIN_INSTALL_DIR = $(_INSTALLDIR)\bin -DOC_INSTALL_DIR = $(_INSTALLDIR)\doc -SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\tcl$(DOTVERSION) -INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\include - TCLSHOBJS = \ $(TMP_DIR)\tclAppInit.obj \ !if !$(STATIC_BUILD) diff --git a/win/rules.vc b/win/rules.vc index a09e879..3a45cd7 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -20,6 +20,7 @@ _RULES_VC = 1 # so this file is necessarily verbose. It's broken down into # the following parts. # +# 0. Sanity check that compiler environment is set up. # 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 @@ -31,16 +32,26 @@ _RULES_VC = 1 # 7. Parse the STATS macro value for statistics instrumentation # 8. Parse the CHECKS macro for additional compilation checks # 9. Extract Tcl, and possibly Tk, version numbers from the headers -# 10.Based on this selected configuration, construct the output -# directory and file paths -# 11.Set up the actual options passed to compiler and linker based -# on the information gathered above. +# 10. Based on this selected configuration, construct the output +# directory and file paths +# 11. Construct the paths where the package is to be installed +# 12. Set up the actual options passed to compiler and linker based +# on the information gathered above. # # One final note about the macro names used. They are as they are # for historical reasons. We would like legacy extensions to # continue to work with this make include file so be wary of # changing them for consistency or clarity. +# 0. Sanity check compiler environment +# Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or +# VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir) +!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR) +MSG = ^ +Visual C++ compiler environment not initialized. +!error $(MSG) +!endif + ################################################################ # 1. Define external programs being used @@ -69,6 +80,7 @@ MKDIR = mkdir # some Tcl interfaces that are not publicly exposed. # # The fragment will set the following macros: +# ROOT - root of this module sources # _TCLDIR - root of the Tcl installation OR the Tcl sources. Not set # when building Tcl itself. # _INSTALLDIR - native form of the installation path. For Tcl @@ -86,7 +98,10 @@ MKDIR = mkdir # TKINSTALL - set 1 if _TKDIR refers to installed Tk and 0 if Tk sources # _TK_H - native path to the tk.h file -# The root directory where the built packages and binaries will be installed. +# Root directory for sources +ROOT = $(MAKEDIR)\.. + +# The target directory where the built packages and binaries will be installed. # INSTALLDIR is the (optional) path specified by the user. # _INSTALLDIR is INSTALLDIR using the backslash separator syntax !ifdef INSTALLDIR @@ -116,7 +131,6 @@ TCLDIR = ../../tcl !endif _TCLDIR = $(TCLDIR:/=\) _TCL_H = $(_TCLDIR)\generic\tcl.h -!message TCLH $(_TCL_H) !if !exist("$(_TCL_H)") !error Could not locate tcl.h. Please set the TCLDIR macro to point to the Tcl *source* directory. !endif @@ -739,6 +753,7 @@ 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. @@ -795,6 +810,9 @@ OUT_DIR = $(TMP_DIR) !endif !endif +# The name of the stubs library for the project being built +STUBPREFIX = $(PROJECT)stub + # Set up paths to various Tcl executables and libraries needed by extensions !if "$(PROJECT)" != "tcl" @@ -855,7 +873,34 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" ################################################################### -# 11. Set up actual options to be passed to the compiler and linker +# 11. Construct the paths for the installation directories +# The following macros get defined in this section: +# LIB_INSTALL_DIR - where libraries should be installed +# BIN_INSTALL_DIR - where the executables should be installed +# DOC_INSTALL_DIR - where documentation should be installed +# SCRIPT_INSTALL_DIR - where scripts should be installed +# INCLUDE_INSTALL_DIR - where C include files should be installed +!if "$(PROJECT)" == "tcl" || "$(PROJECT)" == "tk" +LIB_INSTALL_DIR = $(_INSTALLDIR)\lib +BIN_INSTALL_DIR = $(_INSTALLDIR)\bin +DOC_INSTALL_DIR = $(_INSTALLDIR)\doc +!if "$(PROJECT)" == "tcl" +SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\tcl$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION) +!else +SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\tk$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION) +!endif +INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\include +!else +PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION) +LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR) +BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR) +DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR) +SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR) +INCLUDE_INSTALL_DIR = $(_TCLDIR)\include +!endif + +################################################################### +# 12. Set up actual options to be passed to the compiler and linker # Now we have all the information we need, set up the actual flags and # options that we will pass to the compiler and linker. The main # makefile should use these in combination with whatever other flags @@ -1038,7 +1083,7 @@ baselibs = $(baselibs) ucrt.lib !message *** Optional defines are '$(OPTDEFINES)' !message *** Compiler version $(VCVER). Target machine is $(MACHINE) !message *** Host architecture is $(NATIVE_ARCH) -!message *** Compiler options '$(COMPILERFLAGS) $(OPTIMIZATIONS) $(DEBUGFLAGS) $(WARNINGS)' -!message *** Link options '$(LINKERFLAGS)' +!message *** Cflags '$(cflags)' +!message *** Lflags '$(lflags)' !endif # ifdef _RULES_VC -- cgit v0.12 From 34cb030c7be20776256f30ae2545dc88805e37be Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sun, 24 Sep 2017 14:25:48 +0000 Subject: Move clean target to rules.vc to avoid repetition in every extension --- win/makefile.vc | 32 +++----------------------------- win/rules.vc | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 098662b..d08f30c 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -198,7 +198,6 @@ PROJECT = tcl !include versions.vc -STUBPREFIX = $(PROJECT)stub DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION) VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION) @@ -456,13 +455,9 @@ TCLSTUBOBJS = \ $(TMP_DIR)\tclTomMathStubLib.obj \ $(TMP_DIR)\tclOOStubLib.obj -### The following paths CANNOT have spaces in them. -COMPATDIR = $(ROOT)\compat -DOCDIR = $(ROOT)\doc -GENERICDIR = $(ROOT)\generic +### The following paths CANNOT have spaces in them as they appear on +### the left side of implicit rules. TOMMATHDIR = $(ROOT)\libtommath -TOOLSDIR = $(ROOT)\tools -WINDIR = $(ROOT)\win PKGSDIR = $(ROOT)\pkgs #--------------------------------------------------------------------- @@ -471,7 +466,6 @@ PKGSDIR = $(ROOT)\pkgs cflags = $(cflags) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE -cflags = $(cflags) -Fp$(TMP_DIR)^\ TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" -I"$(TOMMATHDIR)" TCL_DEFINES = -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1 @@ -1138,27 +1132,7 @@ tidy: @echo Removing $(TCLREGLIB) ... @if exist $(TCLREGLIB) del $(TCLREGLIB) -clean: clean-pkgs - @echo Cleaning $(TMP_DIR)\* ... - @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR) - @echo Cleaning $(WINDIR)\nmakehlp.obj ... - @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj - @echo Cleaning $(WINDIR)\nmakehlp.exe ... - @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe - @echo Cleaning $(WINDIR)\_junk.pch ... - @if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch - @echo Cleaning $(WINDIR)\vercl.x ... - @if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x - @echo Cleaning $(WINDIR)\vercl.i ... - @if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i - @echo Cleaning $(WINDIR)\versions.vc ... - @if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc - -realclean: hose - -hose: - @echo Hosing $(OUT_DIR)\* ... - @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR) +clean: basicclean clean-pkgs # Local Variables: # mode: makefile diff --git a/win/rules.vc b/win/rules.vc index 3a45cd7..7addfd0 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -81,6 +81,11 @@ MKDIR = mkdir # # The fragment will set the following macros: # ROOT - root of this module sources +# COMPATDIR - source directory that holds compatibility sources +# DOCDIR - source directory containing documentation files +# GENERICDIR - platform-independent source directory +# WINDIR - Windows-specific source directory +# TOOLSDIR - directory containing build tools # _TCLDIR - root of the Tcl installation OR the Tcl sources. Not set # when building Tcl itself. # _INSTALLDIR - native form of the installation path. For Tcl @@ -98,8 +103,16 @@ MKDIR = mkdir # TKINSTALL - set 1 if _TKDIR refers to installed Tk and 0 if Tk sources # _TK_H - native path to the tk.h file -# Root directory for sources +# Root directory for sources and assumed subdirectories ROOT = $(MAKEDIR)\.. +# The following paths CANNOT have spaces in them as they appear on the +# left side of implicit rules. +COMPATDIR = $(ROOT)\compat +DOCDIR = $(ROOT)\doc +GENERICDIR = $(ROOT)\generic +TOOLSDIR = $(ROOT)\tools +WINDIR = $(ROOT)\win + # The target directory where the built packages and binaries will be installed. # INSTALLDIR is the (optional) path specified by the user. @@ -1072,6 +1085,29 @@ baselibs = $(winlibs) $(extralibs) baselibs = $(baselibs) ucrt.lib !endif +basicclean: clean-pkgs + @echo Cleaning $(TMP_DIR)\* ... + @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR) + @echo Cleaning $(WINDIR)\nmakehlp.obj ... + @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj + @echo Cleaning $(WINDIR)\nmakehlp.exe ... + @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe + @echo Cleaning $(WINDIR)\_junk.pch ... + @if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch + @echo Cleaning $(WINDIR)\vercl.x ... + @if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x + @echo Cleaning $(WINDIR)\vercl.i ... + @if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i + @echo Cleaning $(WINDIR)\versions.vc ... + @if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc + @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc + +realclean: hose + +hose: + @echo Hosing $(OUT_DIR)\* ... + @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR) + #---------------------------------------------------------- # Display stats being used. -- cgit v0.12 From 56e2bd0be497799c08838affb375239aebfbf16d Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 25 Sep 2017 10:41:22 +0000 Subject: Added project-specific include paths and preprocessor defines. --- win/makefile.vc | 74 +++++++++++++++++++++++++++------------------------------ win/rules.vc | 42 ++++++++++++++++++++++++++++---- 2 files changed, 72 insertions(+), 44 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index d08f30c..e36f0e9 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -169,9 +169,24 @@ Please `cd` to its location first. !error $(MSG) !endif +# The PROJECT macro is used by rules.vc for generating appropriate +# macros and rules. PROJECT = tcl + +# Default target to build if no target is specified. If unspecified, the +# rules.vc file will set up "all" as the target. +DEFAULT_BUILD_TARGET = release + +# The rules.vc file does most of the hard work in terms of defining +# the build configuration, macros, output directories etc. !include "rules.vc" +# Tcl version info based on macros set up by rules.vc +DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION) +VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION) + +# We need versions of various core packages to generate appropriate +# file names during installation. !if [echo REM = This file is generated from makefile.vc > versions.vc] !endif !if [echo PKG_HTTP_VER = \>> versions.vc] \ @@ -198,9 +213,6 @@ PROJECT = tcl !include versions.vc -DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION) -VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION) - DDEDOTVERSION = 1.4 DDEVERSION = $(DDEDOTVERSION:.=) @@ -465,19 +477,20 @@ PKGSDIR = $(ROOT)\pkgs #--------------------------------------------------------------------- -cflags = $(cflags) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE +# Additional include and C macro definitions for the implicit rules +# defined in rules.vc +PRJ_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" -I"$(TOMMATHDIR)" +PRJ_DEFINES = -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1 -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE -TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" -I"$(TOMMATHDIR)" -TCL_DEFINES = -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1 -CON_CFLAGS = $(cflags) $(crt) -DCONSOLE -TCL_CFLAGS = $(cflags) $(crt) $(TCL_INCLUDES) $(TCL_DEFINES) $(OPTDEFINES) -STUB_CFLAGS = $(cflags) $(OPTDEFINES) +# Define compiler flags used in our private implicit rules that are +# not covered by rules.vc +TCL_CFLAGS = $(cflags) $(crt) $(PRJ_INCLUDES) $(PRJ_DEFINES) +STUB_CFLAGS = $(cflags) -#--------------------------------------------------------------------- -# Link libraries -#--------------------------------------------------------------------- -extralibs = netapi32.lib user32.lib userenv.lib ws2_32.lib +# Additional Link libraries needed beyond those in rules.vc +PRJ_LIBS = netapi32.lib user32.lib userenv.lib ws2_32.lib + #--------------------------------------------------------------------- # TclTest flags @@ -610,7 +623,7 @@ clean-pkgs: ) $(CAT32): $(WINDIR)\cat.c - $(cc32) $(CON_CFLAGS) -Fo$(TMP_DIR)\ $? + $(cc32) $(cflags) $(crt) -DCONSOLE -Fo$(TMP_DIR)\ $? $(link32) $(conlflags) -out:$@ -stack:16384 $(TMP_DIR)\cat.obj \ $(baselibs) $(_VC_MANIFEST_EMBED_EXE) @@ -765,6 +778,7 @@ install-docs: tclConfig: $(OUT_DIR)\tclConfig.sh +# TBD - is this tclConfig.sh file ever used? The values are incorrect! $(OUT_DIR)\tclConfig.sh: $(WINDIR)\tclConfig.sh.in @echo Creating tclConfig.sh @nmakehlp -s << $** >$@ @@ -782,7 +796,7 @@ $(OUT_DIR)\tclConfig.sh: $(WINDIR)\tclConfig.sh.in @TCL_DBGX@ $(SUFX) @TCL_LIB_FILE@ $(PROJECT)$(VERSION)$(SUFX).lib @TCL_NEEDS_EXP_FILE@ -@LIBS@ $(baselibs) +@LIBS@ $(baselibs) $(PRJ_LIBS) @prefix@ $(_INSTALLDIR) @exec_prefix@ $(BIN_INSTALL_DIR) @SHLIB_CFLAGS@ @@ -791,7 +805,7 @@ $(OUT_DIR)\tclConfig.sh: $(WINDIR)\tclConfig.sh.in @EXTRA_CFLAGS@ -YX @SHLIB_LD@ $(link32) $(dlllflags) @STLIB_LD@ $(lib32) -nologo -@SHLIB_LD_LIBS@ $(baselibs) +@SHLIB_LD_LIBS@ $(baselibs) $(PRJ_LIBS) @SHLIB_SUFFIX@ .dll @DL_LIBS@ @LDFLAGS@ @@ -905,13 +919,13 @@ $(TMP_DIR)\tclWinDde.obj: $(WINDIR)\tclWinDde.c ### specific C run-time. $(TMP_DIR)\tclStubLib.obj: $(GENERICDIR)\tclStubLib.c - $(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) -Fo$@ $? + $(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(PRJ_INCLUDES) -Fo$@ $? $(TMP_DIR)\tclTomMathStubLib.obj: $(GENERICDIR)\tclTomMathStubLib.c - $(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) -Fo$@ $? + $(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(PRJ_INCLUDES) -Fo$@ $? $(TMP_DIR)\tclOOStubLib.obj: $(GENERICDIR)\tclOOStubLib.c - $(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) -Fo$@ $? + $(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(PRJ_INCLUDES) -Fo$@ $? $(TMP_DIR)\tclsh.exe.manifest: $(WINDIR)\tclsh.exe.manifest.in @nmakehlp -s << $** >$@ @@ -932,7 +946,7 @@ depend: @echo Build tclsh first! !else $(TCLSH) $(TOOLSDIR:\=/)/mkdepend.tcl -vc32 -out:"$(OUT_DIR)\depend.mk" \ - -passthru:"-DBUILD_tcl $(TCL_INCLUDES)" $(GENERICDIR),$$(GENERICDIR) \ + -passthru:"-DBUILD_tcl $(PRJ_INCLUDES)" $(GENERICDIR),$$(GENERICDIR) \ $(COMPATDIR),$$(COMPATDIR) $(TOMMATHDIR),$$(TOMMATHDIR) $(WINDIR),$$(WINDIR) @<< $(TCLOBJS) << @@ -959,26 +973,11 @@ $(TCLOBJS) # absolute. #--------------------------------------------------------------------- -{$(WINDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< -$< -<< - {$(TOMMATHDIR)}.c{$(TMP_DIR)}.obj:: $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< $< << -{$(GENERICDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< -$< -<< - -{$(COMPATDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< -$< -<< - {$(COMPATDIR)\zlib}.c{$(TMP_DIR)}.obj:: $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< $< @@ -993,9 +992,6 @@ $< $(TMP_DIR)\tclsh.res: $(TMP_DIR)\tclsh.exe.manifest -.SUFFIXES: -.SUFFIXES:.c .rc - #--------------------------------------------------------------------- # Installation. @@ -1132,7 +1128,7 @@ tidy: @echo Removing $(TCLREGLIB) ... @if exist $(TCLREGLIB) del $(TCLREGLIB) -clean: basicclean clean-pkgs +clean: clean-pkgs # Local Variables: # mode: makefile diff --git a/win/rules.vc b/win/rules.vc index 7addfd0..47f1608 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -37,6 +37,7 @@ _RULES_VC = 1 # 11. Construct the paths where the package is to be installed # 12. Set up the actual options passed to compiler and linker based # on the information gathered above. +# 13. Define some standard build targets and implicit rules. # # One final note about the macro names used. They are as they are # for historical reasons. We would like legacy extensions to @@ -46,6 +47,7 @@ _RULES_VC = 1 # 0. Sanity check compiler environment # Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or # VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir) + !if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR) MSG = ^ Visual C++ compiler environment not initialized. @@ -931,7 +933,7 @@ INCLUDE_INSTALL_DIR = $(_TCLDIR)\include # conlflags - complete linker switches for console program (subsumes lflags) # guilflags - complete linker switches for GUI program (subsumes lflags) # baselibs - minimum Windows libraries required. Parent makefile can -# define extralibs before including rules.rc if additional libs are needed +# define PRJ_LIBS before including rules.rc if additional libs are needed OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS @@ -1022,7 +1024,7 @@ cwarn = $(cwarn) -wd4311 -wd4312 cwarn = $(cwarn) -WX !endif -cflags = -nologo -c $(COMPILERFLAGS) $(cdebug) $(cwarn) -Fp$(TMP_DIR)^\ +cflags = -nologo -c $(COMPILERFLAGS) $(cdebug) $(cwarn) -Fp$(TMP_DIR)^\ $(OPTDEFINES) # Link flags @@ -1068,7 +1070,7 @@ conlflags = $(lflags) -subsystem:console guilflags = $(lflags) -subsystem:windows # Libraries that are required for every image. -# Extensions should define any additional libraries with $(extralibs) +# Extensions should define any additional libraries with $(PRJ_LIBS) winlibs = kernel32.lib advapi32.lib # Avoid 'unresolved external symbol __security_cookie' errors. @@ -1079,13 +1081,22 @@ winlibs = $(winlibs) bufferoverflowU.lib !endif !endif -baselibs = $(winlibs) $(extralibs) +baselibs = $(winlibs) $(PRJ_LIBS) !if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 baselibs = $(baselibs) ucrt.lib !endif -basicclean: clean-pkgs +################################################################ +# 3. Define common make targets and implicit rules + +!ifndef DEFAULT_BUILD_TARGET +DEFAULT_BUILD_TARGET = all +!endif + +default_target: $(DEFAULT_BUILD_TARGET) + +clean: @echo Cleaning $(TMP_DIR)\* ... @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR) @echo Cleaning $(WINDIR)\nmakehlp.obj ... @@ -1108,6 +1119,27 @@ hose: @echo Hosing $(OUT_DIR)\* ... @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR) +# Implicit rule definitions + +{$(WINDIR)}.c{$(TMP_DIR)}.obj:: + $(cc32) $(cflags) $(crt) $(PRJ_INCLUDES) $(PRJ_DEFINES) -Fo$(TMP_DIR)\ @<< +$< +<< + +{$(GENERICDIR)}.c{$(TMP_DIR)}.obj:: + $(cc32) $(cflags) $(crt) $(PRJ_INCLUDES) $(PRJ_DEFINES) -Fo$(TMP_DIR)\ @<< +$< +<< + +{$(COMPATDIR)}.c{$(TMP_DIR)}.obj:: + $(cc32) $(cflags) $(crt) $(PRJ_INCLUDES) $(PRJ_DEFINES) -Fo$(TMP_DIR)\ @<< +$< +<< + +.SUFFIXES: +.SUFFIXES:.c .rc + + #---------------------------------------------------------- # Display stats being used. -- cgit v0.12 From b5e3779cf2ab3f4316b4229e164dc1e58c0c1611 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 25 Sep 2017 13:45:34 +0000 Subject: Move TCLSH and TCLSH_NATIVE macros to rules.vc --- win/makefile.vc | 21 ++++----------------- win/rules.vc | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index e36f0e9..2ef453b 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -226,9 +226,6 @@ TCLLIB = $(OUT_DIR)\$(TCLLIBNAME) TCLSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib TCLSTUBLIB = $(OUT_DIR)\$(TCLSTUBLIBNAME) -TCLSHNAME = $(PROJECT)sh$(VERSION)$(SUFX).exe -TCLSH = $(OUT_DIR)\$(TCLSHNAME) - TCLREGLIBNAME = $(PROJECT)reg$(REGVERSION)$(SUFX:t=).$(EXT) TCLREGLIB = $(OUT_DIR)\$(TCLREGLIBNAME) @@ -238,15 +235,6 @@ TCLDDELIB = $(OUT_DIR)\$(TCLDDELIBNAME) TCLTEST = $(OUT_DIR)\$(PROJECT)test.exe CAT32 = $(OUT_DIR)\cat32.exe -# Can we run what we build? IX86 runs on all architectures. -!ifndef TCLSH_NATIVE -!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)" -TCLSH_NATIVE = $(TCLSH) -!else -!error You must explicitly set TCLSH_NATIVE for cross-compilation -!endif -!endif - TCLSHOBJS = \ $(TMP_DIR)\tclAppInit.obj \ !if !$(STATIC_BUILD) @@ -772,6 +760,8 @@ install-docs: @$(CPY) "$(HELPCNT)" "$(DOC_INSTALL_DIR)\" !endif +# "emacs font-lock highlighting fix + #--------------------------------------------------------------------- # Build tclConfig.sh for the TEA build system. #--------------------------------------------------------------------- @@ -968,7 +958,8 @@ $(TCLOBJS) #--------------------------------------------------------------------- -# Implicit rules. A limitation exists with nmake that requires that +# Implicit rules that are not covered by the common ones defined in +# rules.vc. A limitation exists with nmake that requires that # source directory can not contain spaces in the path. This an # absolute. #--------------------------------------------------------------------- @@ -1011,8 +1002,6 @@ install-binaries: @echo Installing $(TCLSTUBLIBNAME) @$(CPY) "$(TCLSTUBLIB)" "$(LIB_INSTALL_DIR)\" -#" emacs fix - install-libraries: tclConfig install-msgs install-tzdata @if not exist "$(SCRIPT_INSTALL_DIR)$(NULL)" \ $(MKDIR) "$(SCRIPT_INSTALL_DIR)" @@ -1094,8 +1083,6 @@ install-libraries: tclConfig install-msgs install-tzdata @$(CPY) "$(ROOT)\library\encoding\*.enc" \ "$(SCRIPT_INSTALL_DIR)\encoding\" -#" emacs fix - install-tzdata: @echo Installing time zone data @set TCL_LIBRARY=$(ROOT:\=/)/library diff --git a/win/rules.vc b/win/rules.vc index 47f1608..5afcf5e 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -829,7 +829,12 @@ OUT_DIR = $(TMP_DIR) STUBPREFIX = $(PROJECT)stub # Set up paths to various Tcl executables and libraries needed by extensions -!if "$(PROJECT)" != "tcl" +!if "$(PROJECT)" == "tcl" + +TCLSHNAME = $(PROJECT)sh$(TCL_VERSION)$(SUFX).exe +TCLSH = $(OUT_DIR)\$(TCLSHNAME) + +!else # $(PROJECT) is not "tcl" !if $(TCLINSTALL) # Building against an installed Tcl @@ -865,6 +870,16 @@ TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win" !endif $(PROJECT) != "tcl" +# We need a tclsh that will run on the host machine as part of the build. +# IX86 runs on all architectures. +!ifndef TCLSH_NATIVE +!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)" +TCLSH_NATIVE = $(TCLSH) +!else +!error You must explicitly set TCLSH_NATIVE for cross-compilation +!endif +!endif + # Do the same for Tk extensions that require the Tk libraries !if defined(PROJECT_REQUIRES_TK) -- cgit v0.12 From 301208c889f2ffd4f5f8e4e7e02b06c397d0c7ae Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 25 Sep 2017 16:23:34 +0000 Subject: Unify build commands with MAKE{LIB,DLL,CON,GUI}CMD macros --- win/makefile.vc | 24 ++++++++++-------------- win/rules.vc | 5 ++++- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 2ef453b..b42257c 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -536,45 +536,42 @@ $(TCLIMPLIB): $(TCLLIB) $(TCLLIB): $(TCLOBJS) !if $(STATIC_BUILD) - $(lib32) -nologo $(LINKERFLAGS) -out:$@ @<< + $(MAKELIBCMD) @<< $** << !else - $(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcl -out:$@ \ - $(baselibs) @<< + $(MAKEDLLCMD) @<< $** << $(_VC_MANIFEST_EMBED_DLL) !endif $(TCLSTUBLIB): $(TCLSTUBOBJS) - $(lib32) -nologo $(LINKERFLAGS) -nodefaultlib -out:$@ $(TCLSTUBOBJS) + $(MAKELIBCMD) -nodefaultlib $(TCLSTUBOBJS) $(TCLSH): $(TCLSHOBJS) $(TCLSTUBLIB) $(TCLIMPLIB) - $(link32) $(conlflags) -stack:2300000 -out:$@ $(baselibs) $** + $(MAKECONCMD) -stack:2300000 $** $(_VC_MANIFEST_EMBED_EXE) $(TCLTEST): $(TCLTESTOBJS) $(TCLSTUBLIB) $(TCLIMPLIB) - $(link32) $(conlflags) -stack:2300000 -out:$@ $(baselibs) $** + $(MAKECONCMD) -stack:2300000 $** $(_VC_MANIFEST_EMBED_EXE) !if $(STATIC_BUILD) $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj - $(lib32) -nologo $(LINKERFLAGS) -out:$@ $** + $(MAKELIBCMD) $** !else $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLSTUBLIB) - $(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcldde -out:$@ \ - $** $(baselibs) + $(MAKEDLLCMD) -base:@$(WINDIR)\coffbase.txt,tcldde $** $(_VC_MANIFEST_EMBED_DLL) !endif !if $(STATIC_BUILD) $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj - $(lib32) -nologo $(LINKERFLAGS) -out:$@ $** + $(MAKELIBCMD) $** !else $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(TCLSTUBLIB) - $(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tclreg -out:$@ \ - $** $(baselibs) + $(MAKEDLLCMD) -base:@$(WINDIR)\coffbase.txt,tclreg $** $(_VC_MANIFEST_EMBED_DLL) !endif @@ -612,8 +609,7 @@ clean-pkgs: $(CAT32): $(WINDIR)\cat.c $(cc32) $(cflags) $(crt) -DCONSOLE -Fo$(TMP_DIR)\ $? - $(link32) $(conlflags) -out:$@ -stack:16384 $(TMP_DIR)\cat.obj \ - $(baselibs) + $(MAKECONCMD) -stack:16384 $(TMP_DIR)\cat.obj $(_VC_MANIFEST_EMBED_EXE) #--------------------------------------------------------------------- diff --git a/win/rules.vc b/win/rules.vc index 5afcf5e..22379c4 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1154,7 +1154,10 @@ $< .SUFFIXES: .SUFFIXES:.c .rc - +MAKELIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@ +MAKEDLLCMD = $(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcl -out:$@ $(baselibs) +MAKECONEXECMD = $(link32) $(conlflags) -out:$@ $(baselibs) +MAKEGUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) #---------------------------------------------------------- # Display stats being used. -- cgit v0.12 From f1aa04858d2ad42cdb07c9c9b080e84c399c84e5 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 25 Sep 2017 16:33:20 +0000 Subject: Eliminated /base option on linking as not recommended with ASLR --- win/makefile.vc | 4 ++-- win/rules.vc | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index b42257c..9686d26 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -562,7 +562,7 @@ $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(MAKELIBCMD) $** !else $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLSTUBLIB) - $(MAKEDLLCMD) -base:@$(WINDIR)\coffbase.txt,tcldde $** + $(MAKEDLLCMD) $** $(_VC_MANIFEST_EMBED_DLL) !endif @@ -571,7 +571,7 @@ $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(MAKELIBCMD) $** !else $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(TCLSTUBLIB) - $(MAKEDLLCMD) -base:@$(WINDIR)\coffbase.txt,tclreg $** + $(MAKEDLLCMD) $** $(_VC_MANIFEST_EMBED_DLL) !endif diff --git a/win/rules.vc b/win/rules.vc index 22379c4..f52b237 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -847,7 +847,6 @@ TCLIMPLIB = "$(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib" TCL_LIBRARY = $(_TCLDIR)\lib TCLREGLIB = "$(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib" TCLDDELIB = "$(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib" -COFFBASE = \must\have\tcl\sources\to\build\this\target TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target TCL_INCLUDES = -I"$(_TCLDIR)\include" @@ -862,7 +861,6 @@ TCLIMPLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib" TCL_LIBRARY = $(_TCLDIR)\library TCLREGLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib" TCLDDELIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib" -COFFBASE = "$(_TCLDIR)\win\coffbase.txt" TCLTOOLSDIR = $(_TCLDIR)\tools TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win" @@ -1155,9 +1153,9 @@ $< .SUFFIXES:.c .rc MAKELIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@ -MAKEDLLCMD = $(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcl -out:$@ $(baselibs) -MAKECONEXECMD = $(link32) $(conlflags) -out:$@ $(baselibs) -MAKEGUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) +MAKEDLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) +MAKECONCMD = $(link32) $(conlflags) -out:$@ $(baselibs) +MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) #---------------------------------------------------------- # Display stats being used. @@ -1169,7 +1167,5 @@ MAKEGUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) !message *** Optional defines are '$(OPTDEFINES)' !message *** Compiler version $(VCVER). Target machine is $(MACHINE) !message *** Host architecture is $(NATIVE_ARCH) -!message *** Cflags '$(cflags)' -!message *** Lflags '$(lflags)' !endif # ifdef _RULES_VC -- cgit v0.12 From 246e5991428e8da2ba868c84541901336a472ca0 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 25 Sep 2017 17:35:29 +0000 Subject: Eliminate obsolete winhelp style documentation and fix Html Help doc build to work on 64-bit systems. --- win/makefile.vc | 73 +++++---------------------------------------------------- win/rules.vc | 11 +++++++++ 2 files changed, 17 insertions(+), 67 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 9686d26..2fe5c72 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -649,7 +649,11 @@ gentommath_h: # NOTE: you can define HHC on the command-line to override this !ifndef HHC -HHC=""%ProgramFiles%\HTML Help Workshop\hhc.exe"" +!if exist("$(PROGRAMFILES_X86)\HTML Help Workshop\hhc.exe") +HHC=$(PROGRAMFILES_X86)\HTML Help Workshop\hhc.exe +!else +HHC=hhc.exe +!endif !endif HTMLDIR=$(OUT_DIR)\html HTMLBASE=TclTk$(VERSION) @@ -661,7 +665,7 @@ htmlhelp: chmsetup $(CHMFILE) $(CHMFILE): $(DOCDIR)\* @$(TCLSH) $(TOOLSDIR)\tcltk-man2html.tcl "--htmldir=$(HTMLDIR)" @echo Compiling HTML help project - -$(HHC) <<$(HHPFILE) >NUL + -"$(HHC)" <<$(HHPFILE) >NUL [OPTIONS] Compatibility=1.1 or later Compiled file=$(HTMLBASE).chm @@ -685,76 +689,11 @@ UserCmd\*.htm chmsetup: @if not exist $(HTMLDIR)\nul mkdir $(HTMLDIR) -#------------------------------------------------------------------------- -# Build the old-style Windows .hlp file -#------------------------------------------------------------------------- - -TCLHLPBASE = $(PROJECT)$(VERSION) -HELPFILE = $(OUT_DIR)\$(TCLHLPBASE).hlp -HELPCNT = $(OUT_DIR)\$(TCLHLPBASE).cnt -DOCTMP_DIR = $(OUT_DIR)\$(PROJECT)_docs -HELPRTF = $(DOCTMP_DIR)\$(PROJECT).rtf -MAN2HELP = $(DOCTMP_DIR)\man2help.tcl -MAN2HELP2 = $(DOCTMP_DIR)\man2help2.tcl -INDEX = $(DOCTMP_DIR)\index.tcl -BMP = $(DOCTMP_DIR)\feather.bmp -BMP_NOPATH = feather.bmp -MAN2TCL = $(DOCTMP_DIR)\man2tcl.exe - -winhelp: docsetup $(HELPFILE) - -docsetup: - @if not exist $(DOCTMP_DIR)\nul mkdir $(DOCTMP_DIR) - -$(MAN2HELP) $(MAN2HELP2) $(INDEX) $(BMP): $(TOOLSDIR)\$$(@F) - @$(CPY) $(TOOLSDIR)\$(@F) $(@D) - -$(HELPFILE): $(HELPRTF) $(BMP) - cd $(DOCTMP_DIR) - start /wait hcrtf.exe -x <<$(PROJECT).hpj -[OPTIONS] -COMPRESS=12 Hall Zeck -LCID=0x409 0x0 0x0 ; English (United States) -TITLE=Tcl/Tk Reference Manual -BMROOT=. -CNT=$(@B).cnt -HLP=$(@B).hlp - -[FILES] -$(PROJECT).rtf - -[WINDOWS] -main="Tcl/Tk Reference Manual",,27648,(r15263976),(r65535) - -[CONFIG] -BrowseButtons() -CreateButton(1, "Web", ExecFile("http://www.tcl.tk")) -CreateButton(2, "SF", ExecFile("http://sf.net/projects/tcl")) -CreateButton(3, "Wiki", ExecFile("http://wiki.tcl.tk")) -CreateButton(4, "FAQ", ExecFile("http://www.purl.org/NET/Tcl-FAQ/")) -<< - cd $(MAKEDIR) - @$(CPY) "$(DOCTMP_DIR)\$(@B).hlp" "$(OUT_DIR)" - @$(CPY) "$(DOCTMP_DIR)\$(@B).cnt" "$(OUT_DIR)" - -$(MAN2TCL): $(TOOLSDIR)\$$(@B).c - $(cc32) $(TCL_CFLAGS) -Fo$(@D)\ $(TOOLSDIR)\$(@B).c - $(link32) $(conlflags) -out:$@ -stack:16384 $(@D)\man2tcl.obj - $(_VC_MANIFEST_EMBED_EXE) - -$(HELPRTF): $(MAN2TCL) $(MAN2HELP) $(MAN2HELP2) $(INDEX) $(DOCDIR)\* - $(TCLSH) $(MAN2HELP) -bitmap $(BMP_NOPATH) $(PROJECT) $(VERSION) $(DOCDIR:\=/) - install-docs: !if exist("$(CHMFILE)") @echo Installing compiled HTML help @$(CPY) "$(CHMFILE)" "$(DOC_INSTALL_DIR)\" !endif -!if exist("$(HELPFILE)") - @echo Installing Windows help - @$(CPY) "$(HELPFILE)" "$(DOC_INSTALL_DIR)\" - @$(CPY) "$(HELPCNT)" "$(DOC_INSTALL_DIR)\" -!endif # "emacs font-lock highlighting fix diff --git a/win/rules.vc b/win/rules.vc index f52b237..7ae345b 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -69,6 +69,17 @@ CPY = xcopy /i /y >NUL COPY = copy /y >NUL MKDIR = mkdir +# The ProgramFiles(x86) environment variable is not accessible +# from nmake since it has the parenthesis which nmake does not like +# within a macro name. So define our own in terms of the +# ProgramFiles environment variable. +# Note: env variables are always UPPER CASE in nmake +!if defined(PROCESSOR_ARCHITECTURE) && "$(PROCESSOR_ARCHITECTURE)" == "AMD64" +PROGRAMFILES_X86 = $(PROGRAMFILES) (x86) +!else +PROGRAMFILES_X86 = $(PROGRAMFILES) +!endif + ###################################################################### # 2. Figure out our build environment in terms of what we're building. -- cgit v0.12 From 07c1c221cb6dff468b482320fb122254ab0b49ed Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 26 Sep 2017 12:22:42 +0000 Subject: Include rules.vc and nmakehlp.c as part of install. Work toward not having to keep updating extensions with the latest version of rules.vc and nmakehlp. Extension makefiles can instead use the installed files instead. Also added some basic sanity checks to rules.vc to warn if extensions are being compiled with options incompatible with those used to build Tcl. --- win/makefile.vc | 34 ++++++++++++++++++++++-------- win/rules.vc | 64 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 82 insertions(+), 16 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 2fe5c72..99d013e 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -468,7 +468,7 @@ PKGSDIR = $(ROOT)\pkgs # Additional include and C macro definitions for the implicit rules # defined in rules.vc PRJ_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" -I"$(TOMMATHDIR)" -PRJ_DEFINES = -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1 -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE +PRJ_DEFINES = -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE # Define compiler flags used in our private implicit rules that are # not covered by rules.vc @@ -698,6 +698,19 @@ install-docs: # "emacs font-lock highlighting fix #--------------------------------------------------------------------- +# Generate the tcl.nmake file which contains the options used to build +# Tcl itself. This is used when building extensions. +#--------------------------------------------------------------------- +tcl-nmake: $(OUT_DIR)\tcl.nmake +$(OUT_DIR)\tcl.nmake: + @type << >$@ +CORE_MACHINE = $(MACHINE) +CORE_DEBUG = $(DEBUG) +CORE_TCL_THREADS = $(TCL_THREADS) +CORE_USE_THREAD_ALLOC = $(USE_THREAD_ALLOC) +<< + +#--------------------------------------------------------------------- # Build tclConfig.sh for the TEA build system. #--------------------------------------------------------------------- @@ -937,19 +950,21 @@ install-binaries: @echo Installing $(TCLSTUBLIBNAME) @$(CPY) "$(TCLSTUBLIB)" "$(LIB_INSTALL_DIR)\" -install-libraries: tclConfig install-msgs install-tzdata - @if not exist "$(SCRIPT_INSTALL_DIR)$(NULL)" \ +install-libraries: tclConfig tcl-nmake install-msgs install-tzdata + @if not exist "$(SCRIPT_INSTALL_DIR)" \ $(MKDIR) "$(SCRIPT_INSTALL_DIR)" - @if not exist "$(SCRIPT_INSTALL_DIR)\..\tcl8$(NULL)" \ + @if not exist "$(SCRIPT_INSTALL_DIR)\..\tcl8" \ $(MKDIR) "$(SCRIPT_INSTALL_DIR)\..\tcl8" - @if not exist "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.4$(NULL)" \ + @if not exist "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.4" \ $(MKDIR) "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.4" - @if not exist "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.4\platform$(NULL)" \ + @if not exist "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.4\platform" \ $(MKDIR) "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.4\platform" - @if not exist "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.5$(NULL)" \ + @if not exist "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.5" \ $(MKDIR) "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.5" - @if not exist "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.6$(NULL)" \ + @if not exist "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.6" \ $(MKDIR) "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.6" + @if not exist "$(LIB_INSTALL_DIR)\nmake" \ + $(MKDIR) "$(LIB_INSTALL_DIR)\nmake" @echo Installing header files @$(CPY) "$(GENERICDIR)\tcl.h" "$(INCLUDE_INSTALL_DIR)\" @$(CPY) "$(GENERICDIR)\tclDecls.h" "$(INCLUDE_INSTALL_DIR)\" @@ -973,6 +988,9 @@ install-libraries: tclConfig install-msgs install-tzdata @$(CPY) "$(ROOT)\library\auto.tcl" "$(SCRIPT_INSTALL_DIR)\" @$(CPY) "$(OUT_DIR)\tclConfig.sh" "$(LIB_INSTALL_DIR)\" @$(CPY) "$(WINDIR)\tclooConfig.sh" "$(LIB_INSTALL_DIR)\" + @$(CPY) "$(WINDIR)\rules.vc" "$(LIB_INSTALL_DIR)\nmake\" + @$(CPY) "$(WINDIR)\nmakehlp.c" "$(LIB_INSTALL_DIR)\nmake\" + @$(CPY) "$(OUT_DIR)\tcl.nmake" "$(LIB_INSTALL_DIR)\nmake\" @echo Installing library http1.0 directory @$(CPY) "$(ROOT)\library\http1.0\*.tcl" \ "$(SCRIPT_INSTALL_DIR)\http1.0\" diff --git a/win/rules.vc b/win/rules.vc index 7ae345b..f94c894 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -38,6 +38,8 @@ _RULES_VC = 1 # 12. Set up the actual options passed to compiler and linker based # on the information gathered above. # 13. Define some standard build targets and implicit rules. +# 14. (For extensions only.) Compare the configuration of the target +# Tcl and the extensions and warn against discrepancies. # # One final note about the macro names used. They are as they are # for historical reasons. We would like legacy extensions to @@ -120,13 +122,24 @@ PROGRAMFILES_X86 = $(PROGRAMFILES) ROOT = $(MAKEDIR)\.. # The following paths CANNOT have spaces in them as they appear on the # left side of implicit rules. +!ifndef COMPATDIR COMPATDIR = $(ROOT)\compat +!endif +!ifndef DOCDIR DOCDIR = $(ROOT)\doc +!endif +!ifndef GENERICDIR GENERICDIR = $(ROOT)\generic +!endif +!ifndef TOOLSDIR TOOLSDIR = $(ROOT)\tools +!endif +# Do NOT enclose WINDIR in a !ifndef because Windows always defines +# WINDIR env var to point to c:\windows! +# TBD - This is a potentially dangerous conflict, rename WINDIR to +# something else WINDIR = $(ROOT)\win - # The target directory where the built packages and binaries will be installed. # INSTALLDIR is the (optional) path specified by the user. # _INSTALLDIR is INSTALLDIR using the backslash separator syntax @@ -367,8 +380,8 @@ NMAKEHLPC = nmakehlp.c !if "$(PROJECT)" != "tcl" !if $(TCLINSTALL) -!if exist("$(_TCLDIR)\lib\config.nmake\nmakehlp.c") -NMAKEHLPC = $(_TCLDIR)\lib\config.nmake\nmakehlp.c +!if exist("$(_TCLDIR)\lib\nmake\nmakehlp.c") +NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c !endif !else # ! $(TCLINSTALL) !if exist("$(_TCLDIR)\win\nmakehlp.c") @@ -1123,17 +1136,15 @@ default_target: $(DEFAULT_BUILD_TARGET) clean: @echo Cleaning $(TMP_DIR)\* ... @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR) - @echo Cleaning $(WINDIR)\nmakehlp.obj ... + @echo Cleaning $(WINDIR)\nmakehlp.obj, nmakehlp.exe ... @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj - @echo Cleaning $(WINDIR)\nmakehlp.exe ... @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe @echo Cleaning $(WINDIR)\_junk.pch ... @if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch - @echo Cleaning $(WINDIR)\vercl.x ... + @echo Cleaning $(WINDIR)\vercl.x, vercl.i ... @if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x - @echo Cleaning $(WINDIR)\vercl.i ... @if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i - @echo Cleaning $(WINDIR)\versions.vc ... + @echo Cleaning $(WINDIR)\versions.vc, version.vc ... @if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc @@ -1168,6 +1179,43 @@ MAKEDLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) MAKECONCMD = $(link32) $(conlflags) -out:$@ $(baselibs) MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) +################################################################ +# 14. Sanity check selected options against Tcl build options +# 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 $(TCLINSTALL) # Building against an installed Tcl +!if exist("$(_TCLDIR)\lib\nmake\tcl.nmake") +TCLNMAKECONFIG = "$(_TCLDIR)\lib\nmake\tcl.nmake" +!endif +!else # ! $(TCLINSTALL) - building against Tcl source +!if exist("$(OUT_DIR)\tcl.nmake") +TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake" +!endif +!endif # TCLINSTALL + +!if ! $(DISABLE_CONFIG_CHECKS) +!ifdef TCLNMAKECONFIG +!include $(TCLMAKECONFIG) + +!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) +!message WARNING: Value of USE_THREAD_ALLOC ($(USE_THREAD_ALLOC)) does not match its Tcl core value ($(CORE_USE_THREAD_ALLOC)). +!endif +!if defined(CORE_DEBUG) && $(CORE_DEBUG) != $(DEBUG) +!message WARNING: Value of DEBUG ($(DEBUG)) does not match its Tcl library configuration ($(DEBUG)). +!endif +!endif + +!endif # TCLNMAKECONFIG + +!endif # $(PROJECT) == "tcl" + + #---------------------------------------------------------- # Display stats being used. #---------------------------------------------------------- -- cgit v0.12 From 37349378785168cf70e452f241bc3df32d03d379 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Thu, 28 Sep 2017 12:22:41 +0000 Subject: Add pkgcflags, appcflags and stubscflags to reflect different compilation modes. Packages compile (at least) three types of objects files - the shared library extension (e.g. tk86.dll), application programs (e.g. wish) and a static stubs library (tkstub86.lib). Thus we need to construct three different sets of compilation flags accordingly. Also updated makefile header comments to reflect modern usage. --- win/makefile.vc | 117 +++++++++++++++++++++++--------------------------------- win/rules.vc | 99 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 133 insertions(+), 83 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 99d013e..015f6ba 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -1,7 +1,6 @@ -#------------------------------------------------------------- -# makefile.vc -- +#------------------------------------------------------------- -*- makefile -*- # -# Microsoft Visual C++ makefile for use with nmake.exe v1.62+ (VC++ 5.0+) +# Microsoft Visual C++ makefile for use with nmake # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -11,27 +10,28 @@ # Copyright (c) 2001-2005 ActiveState Corporation. # Copyright (c) 2001-2004 David Gravereaux. # Copyright (c) 2003-2008 Pat Thoyts. +# Copyright (c) 2017 Ashok P. Nadkarni #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # HOW TO USE this makefile: # -# 1) It is now necessary to have MSVCDir, MSDevDir or MSSDK set in the -# environment. This is used as a check to see if vcvars32.bat had been -# run prior to running nmake or during the installation of Microsoft -# Visual C++, MSVCDir had been set globally and the PATH adjusted. -# Either way is valid. +# 1) It is necessary to have the appropriate Visual C++ environment +# set up before invoking nmake. The steps required depend on which +# version of Visual Studio and/or the Windows SDK you are building +# against and are not described here. With Visual Studio, the simplest +# is to start a command shell using one of the installed short cuts. +# An alternative is to run vcvars32.bat, vcvars64.bat, vcvarsamd64_x86.bat +# etc. depending on the host and target architectures. If compiling +# with the Windows SDK instead, run (again depending on the SDK version) +# the setenv.bat or equivalent batch file from the command prompt. # -# You'll need to run vcvars32.bat contained in the MsDev's vc(98)/bin -# directory to setup the proper environment, if needed, for your -# current setup. This is a needed bootstrap requirement and allows the -# swapping of different environments to be easier. -# -# 2) To use the Platform SDK (not expressly needed), run setenv.bat after +# NOTE: For older (Visual C++ 6 or the 2003 SDK), to use the Platform +# SDK (not expressly needed), run setenv.bat after # vcvars32.bat according to the instructions for it. This can also # turn on the 64-bit compiler, if your SDK has it. # -# 3) Targets are: +# 2) Targets are: # release -- Builds the core, the shell and the dlls. (default) # dlls -- Just builds the windows extensions # shell -- Just builds the shell and the core. @@ -51,12 +51,8 @@ # troff manual pages found in $(ROOT)\doc. You need to # have installed the HTML Help Compiler package from Microsoft # to produce the .chm file. -# winhelp -- (deprecated) Builds the windows .hlp file for Tcl from -# the troff man files found in $(ROOT)\doc. This type of -# help file is deprecated by Microsoft in favour of html -# help files (.chm) # -# 4) Macros usable on the commandline: +# 3) Macros usable on the commandline: # INSTALLDIR= # Sets where to install Tcl from the built binaries. # C:\Progra~1\Tcl is assumed when not specified. @@ -67,7 +63,7 @@ # 'none' will over-ride everything to nothing. # # loimpact = Adds a flag for how NT treats the heap to keep memory -# in use, low. This is said to impact alloc performance. +# in use, low. Said to impact alloc performance. # msvcrt = Affects the static option only to switch it from # using libcmt(d) as the C runtime [by default] to # msvcrt(d). This is useful for static embedding @@ -113,15 +109,15 @@ # MACHINE=(AMD64|IX86) # Set the machine type used for the compiler, linker, and # resource compiler. This hook is needed to tell the tools -# when alternate platforms are requested. This should normally -# NOT be set as it is automatically detected based on the -# compiler in use. +# when alternate platforms are requested. THIS SHOULD NORMALLY +# NOT BE SET AS IT IS AUTOMATICALLY DETECTED BASED ON THE +# COMPILER IN USE. # # TMP_DIR= # OUT_DIR= # Hooks to allow the intermediate and output directories to be # changed. $(OUT_DIR) is assumed to be -# $(BINROOT)\(Release|Debug) based on if symbols are requested. +# .\(Release|Debug) based on if symbols are requested. # $(TMP_DIR) will de $(OUT_DIR)\ by default. # # TESTPAT= @@ -131,20 +127,20 @@ # name of encoding for configuration information. Defaults # to cp1252 # -# 5) Examples: +# 4) Examples: # # Basic syntax of calling nmake looks like this: # nmake [-nologo] -f makefile.vc [target|macrodef [target|macrodef] [...]] # # Standard (no frills) -# c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat -# Setting environment for using Microsoft Visual C++ tools. # c:\tcl_src\win\>nmake -f makefile.vc release # c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl # -# Building for Win64 -# c:\tcl_src\win\>c:\progra~1\platfo~1\setenv.bat /x64 /RETAIL -# c:\tcl_src\win\>nmake -f makefile.vc +# With symbols in release builds +# c:\tcl_src\win\>nmake -f makefile.vc release OPTS=pdbs +# +# Debug build +# c:\tcl_src\win\>nmake -f makefile.vc release OPTS=symbols # #------------------------------------------------------------------------------ #============================================================================== @@ -219,13 +215,6 @@ DDEVERSION = $(DDEDOTVERSION:.=) REGDOTVERSION = 1.3 REGVERSION = $(REGDOTVERSION:.=) -TCLIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib -TCLLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT) -TCLLIB = $(OUT_DIR)\$(TCLLIBNAME) - -TCLSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib -TCLSTUBLIB = $(OUT_DIR)\$(TCLSTUBLIBNAME) - TCLREGLIBNAME = $(PROJECT)reg$(REGVERSION)$(SUFX:t=).$(EXT) TCLREGLIB = $(OUT_DIR)\$(TCLREGLIBNAME) @@ -460,26 +449,14 @@ TCLSTUBOBJS = \ TOMMATHDIR = $(ROOT)\libtommath PKGSDIR = $(ROOT)\pkgs -#--------------------------------------------------------------------- -# Compile flags -#--------------------------------------------------------------------- - - # Additional include and C macro definitions for the implicit rules # defined in rules.vc -PRJ_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" -I"$(TOMMATHDIR)" +PRJ_INCLUDES = -I"$(TOMMATHDIR)" PRJ_DEFINES = -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -# Define compiler flags used in our private implicit rules that are -# not covered by rules.vc -TCL_CFLAGS = $(cflags) $(crt) $(PRJ_INCLUDES) $(PRJ_DEFINES) -STUB_CFLAGS = $(cflags) - - # Additional Link libraries needed beyond those in rules.vc PRJ_LIBS = netapi32.lib user32.lib userenv.lib ws2_32.lib - #--------------------------------------------------------------------- # TclTest flags #--------------------------------------------------------------------- @@ -726,7 +703,7 @@ $(OUT_DIR)\tclConfig.sh: $(WINDIR)\tclConfig.sh.in @TCL_MINOR_VERSION@ $(TCL_MINOR_VERSION) @TCL_PATCH_LEVEL@ $(TCL_PATCH_LEVEL) @CC@ $(CC) -@DEFS@ $(TCL_CFLAGS) +@DEFS@ $(pkgcflags) @CFLAGS_DEBUG@ -nologo -c -W3 -YX -Fp$(TMP_DIR)\ -MDd @CFLAGS_OPTIMIZE@ -nologo -c -W3 -YX -Fp$(TMP_DIR)\ -MD @LDFLAGS_DEBUG@ -nologo -machine:$(MACHINE) -debug -debugtype:cv @@ -794,28 +771,28 @@ gendate: #--------------------------------------------------------------------- $(TMP_DIR)\testMain.obj: $(WINDIR)\tclAppInit.c - $(cc32) $(TCL_CFLAGS) -DTCL_TEST \ + $(cc32) $(appcflags) -DTCL_TEST \ -DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \ -Fo$@ $? $(TMP_DIR)\tclMain2.obj: $(GENERICDIR)\tclMain.c - $(cc32) $(TCL_CFLAGS) -DBUILD_tcl -DTCL_ASCII_MAIN \ + $(cc32) $(pkgcflags) -DTCL_ASCII_MAIN \ -Fo$@ $? $(TMP_DIR)\tclTest.obj: $(GENERICDIR)\tclTest.c - $(cc32) $(TCL_CFLAGS) -Fo$@ $? + $(cc32) $(appcflags) -Fo$@ $? $(TMP_DIR)\tclTestObj.obj: $(GENERICDIR)\tclTestObj.c - $(cc32) $(TCL_CFLAGS) -Fo$@ $? + $(cc32) $(appcflags) -Fo$@ $? $(TMP_DIR)\tclWinTest.obj: $(WINDIR)\tclWinTest.c - $(cc32) $(TCL_CFLAGS) -Fo$@ $? + $(cc32) $(appcflags) -Fo$@ $? $(TMP_DIR)\tclZlib.obj: $(GENERICDIR)\tclZlib.c - $(cc32) $(TCL_CFLAGS) -I$(COMPATDIR)\zlib -DBUILD_tcl -Fo$@ $? + $(cc32) $(pkgcflags) -I$(COMPATDIR)\zlib -Fo$@ $? $(TMP_DIR)\tclPkgConfig.obj: $(GENERICDIR)\tclPkgConfig.c - $(cc32) -DBUILD_tcl $(TCL_CFLAGS) \ + $(cc32) $(pkgcflags) \ -DCFG_INSTALL_LIBDIR="\"$(LIB_INSTALL_DIR:\=\\)\"" \ -DCFG_INSTALL_BINDIR="\"$(BIN_INSTALL_DIR:\=\\)\"" \ -DCFG_INSTALL_SCRDIR="\"$(SCRIPT_INSTALL_DIR:\=\\)\"" \ @@ -829,7 +806,7 @@ $(TMP_DIR)\tclPkgConfig.obj: $(GENERICDIR)\tclPkgConfig.c -Fo$@ $? $(TMP_DIR)\tclAppInit.obj: $(WINDIR)\tclAppInit.c - $(cc32) $(TCL_CFLAGS) \ + $(cc32) $(appcflags) \ -DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \ -Fo$@ $? @@ -838,17 +815,17 @@ $(TMP_DIR)\tclAppInit.obj: $(WINDIR)\tclAppInit.c $(TMP_DIR)\tclWinReg.obj: $(WINDIR)\tclWinReg.c !if $(STATIC_BUILD) - $(cc32) $(TCL_CFLAGS) -DTCL_THREADS=1 -DSTATIC_BUILD -Fo$@ $? + $(cc32) $(appcflags) -DSTATIC_BUILD -Fo$@ $? !else - $(cc32) $(TCL_CFLAGS) -DTCL_THREADS=1 -DUSE_TCL_STUBS -Fo$@ $? + $(cc32) $(appcflags) -DUSE_TCL_STUBS -Fo$@ $? !endif $(TMP_DIR)\tclWinDde.obj: $(WINDIR)\tclWinDde.c !if $(STATIC_BUILD) - $(cc32) $(TCL_CFLAGS) -DTCL_THREADS=1 -DSTATIC_BUILD -Fo$@ $? + $(cc32) $(appcflags) -DSTATIC_BUILD -Fo$@ $? !else - $(cc32) $(TCL_CFLAGS) -DTCL_THREADS=1 -DUSE_TCL_STUBS -Fo$@ $? + $(cc32) $(appcflags) -DUSE_TCL_STUBS -Fo$@ $? !endif @@ -857,13 +834,13 @@ $(TMP_DIR)\tclWinDde.obj: $(WINDIR)\tclWinDde.c ### specific C run-time. $(TMP_DIR)\tclStubLib.obj: $(GENERICDIR)\tclStubLib.c - $(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(PRJ_INCLUDES) -Fo$@ $? + $(cc32) $(stubscflags) -Fo$@ $? $(TMP_DIR)\tclTomMathStubLib.obj: $(GENERICDIR)\tclTomMathStubLib.c - $(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(PRJ_INCLUDES) -Fo$@ $? + $(cc32) $(stubscflags) -Fo$@ $? $(TMP_DIR)\tclOOStubLib.obj: $(GENERICDIR)\tclOOStubLib.c - $(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(PRJ_INCLUDES) -Fo$@ $? + $(cc32) $(stubscflags) -Fo$@ $? $(TMP_DIR)\tclsh.exe.manifest: $(WINDIR)\tclsh.exe.manifest.in @nmakehlp -s << $** >$@ @@ -884,7 +861,7 @@ depend: @echo Build tclsh first! !else $(TCLSH) $(TOOLSDIR:\=/)/mkdepend.tcl -vc32 -out:"$(OUT_DIR)\depend.mk" \ - -passthru:"-DBUILD_tcl $(PRJ_INCLUDES)" $(GENERICDIR),$$(GENERICDIR) \ + -passthru:"-DBUILD_tcl $(TCL_INCLUDES) $(PRJ_INCLUDES)" $(GENERICDIR),$$(GENERICDIR) \ $(COMPATDIR),$$(COMPATDIR) $(TOMMATHDIR),$$(TOMMATHDIR) $(WINDIR),$$(WINDIR) @<< $(TCLOBJS) << @@ -913,12 +890,12 @@ $(TCLOBJS) #--------------------------------------------------------------------- {$(TOMMATHDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< + $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< $< << {$(COMPATDIR)\zlib}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -Fo$(TMP_DIR)\ @<< + $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< $< << diff --git a/win/rules.vc b/win/rules.vc index f94c894..fe5a8e7 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -139,6 +139,9 @@ TOOLSDIR = $(ROOT)\tools # TBD - This is a potentially dangerous conflict, rename WINDIR to # something else WINDIR = $(ROOT)\win +!ifndef RCDIR +RCDIR = $(WINDIR)\rc +!endif # The target directory where the built packages and binaries will be installed. # INSTALLDIR is the (optional) path specified by the user. @@ -202,6 +205,11 @@ TCLINSTALL = 1 TCLDIR = $(_INSTALLDIR) _TCLDIR = $(_INSTALLDIR) _TCL_H = $(_INSTALLDIR)\include\tcl.h +!elseif exist("..\..\tcl\generic\tcl.h") +TCLINSTALL = 0 +TCLDIR = ..\..\tcl +_TCLDIR = $(TCLDIR) +_TCL_H = $(_TCLDIR)\generic\tcl.h !endif !endif # TCLDIR @@ -531,7 +539,9 @@ LINKERFLAGS = $(LINKERFLAGS) -ltcg # 0 -> Use the non-thread allocator. # UNCHECKED - 1 -> when doing a debug build with symbols, use the release # C runtime, 0 -> use the debug C runtime. -# +# USE_STUBS - 1 -> compile to use stubs interfaces, 0 -> direct linking +# CONFIG_CHECK - 1 -> check current build configuration against Tcl +# configuration (ignored for Tcl itself) # Further, LINKERFLAGS are modified based on above. # Default values for all the above @@ -546,6 +556,12 @@ LOIMPACT = 0 TCL_USE_STATIC_PACKAGES = 0 USE_THREAD_ALLOC = 1 UNCHECKED = 0 +CONFIG_CHECK = 1 +!if "$(PROJECT)" == "tcl" || "$(PROJECT)" == "tk" +USE_STUBS = 0 +!else +USE_STUBS = 1 +!endif # If OPTS is not empty AND does not contain "none" which turns off all OPTS # set the above macros based on OPTS content @@ -556,8 +572,11 @@ UNCHECKED = 0 !if [nmakehlp -f $(OPTS) "static"] !message *** Doing static STATIC_BUILD = 1 -!else -STATIC_BUILD = 0 +!endif + +!if [nmakehlp -f $(OPTS) "nostubs"] +!message *** Not using stubs +USE_STUBS = 0 !endif !if [nmakehlp -f $(OPTS) "nomsvcrt"] @@ -644,6 +663,12 @@ UNCHECKED = 1 UNCHECKED = 0 !endif +!if [nmakehlp -f $(OPTS) "noconfigcheck"] +CONFIG_CHECK = 1 +!else +CONFIG_CHECK = 0 +!endif + !endif # "$(OPTS)" != "" && ... parsing of OPTS # Set linker flags based on above @@ -855,8 +880,15 @@ STUBPREFIX = $(PROJECT)stub # Set up paths to various Tcl executables and libraries needed by extensions !if "$(PROJECT)" == "tcl" -TCLSHNAME = $(PROJECT)sh$(TCL_VERSION)$(SUFX).exe +TCLSHNAME = $(PROJECT)sh$(TCL_VERSION)$(SUFX).exe TCLSH = $(OUT_DIR)\$(TCLSHNAME) +TCLIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib +TCLLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT) +TCLLIB = $(OUT_DIR)\$(TCLLIBNAME) + +TCLSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib +TCLSTUBLIB = $(OUT_DIR)\$(TCLSTUBLIBNAME) +TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" !else # $(PROJECT) is not "tcl" @@ -902,8 +934,17 @@ TCLSH_NATIVE = $(TCLSH) !endif !endif -# Do the same for Tk extensions that require the Tk libraries -!if defined(PROJECT_REQUIRES_TK) +# Do the same for Tk and Tk extensions that require the Tk libraries +!if "$(PROJECT)" == "tk" + +WISH = "$(OUT_DIR)\$(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe" +TKSTUBLIBNAME = $(STUBPREFIX)$(TK_VERSION).lib +TKSTUBLIB = "$(OUT_DIR)\$(TKSTUBLIBNAME)" +TKIMPLIB = "$(OUT_DIR)\$(PROJECT)$(TK_VERSION)$(SUFX).lib" +TKLIBNAME = $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT) +TK_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" + +!elseif defined(PROJECT_REQUIRES_TK) !if $(TKINSTALL) # Building against installed Tk @@ -993,6 +1034,17 @@ OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED !endif +!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" && "$(PROJECT)" != "tk" +OPTDEFINES = $(OPTDEFINES) -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS +!ifdef PROJECT_REQUIRES_TK +OPTDEFINES = $(OPTDEFINES) -DUSE_TK_STUBS +!endif +!endif +!endif # USE_STUBS + !if !$(DEBUG) OPTDEFINES = $(OPTDEFINES) -DNDEBUG !if $(OPTIMIZING) @@ -1012,7 +1064,7 @@ OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64 # UNICODE - Use the wide char Windows API. # _ATL_XP_TARGETING - Newer SDK's need this to build for XP # BUILD_xxx - defined to export the xxx_Init call from the DLL -COMPILERFLAGS = /DUNICODE /D_UNICODE /D_ATL_XP_TARGETING /DBUILD_$(PROJECT) +COMPILERFLAGS = /DUNICODE /D_UNICODE /D_ATL_XP_TARGETING # crt picks the C run time based on selected OPTS !if $(MSVCRT) @@ -1061,7 +1113,27 @@ cwarn = $(cwarn) -wd4311 -wd4312 cwarn = $(cwarn) -WX !endif -cflags = -nologo -c $(COMPILERFLAGS) $(cdebug) $(cwarn) -Fp$(TMP_DIR)^\ $(OPTDEFINES) +# These flags are defined roughly in the order of the pre-reform rules.vc/makefile.vc to help +# visually compare that the pre- and post-reform build logs + +# cflags contains generic flags to be used for building practically all object files +cflags = -nologo -c $(COMPILERFLAGS) $(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 flags used for building shared object files +# The two differ in the BUILD_$(PROJECT) macro which should be defined only for +# the shared library *implementation* and not for its caller interface +appcflags = $(cflags) $(crt) $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) +pkgcflags = $(appcflags) /DBUILD_$(PROJECT) + +# stubscflags contains $(cflags) plus flags used for building a stubs library for the +# package. +# Note: -DSTATIC_BUILD is defined in $(OPTDEFINES) only if the OPTS configuration indicates +# a static library. However the stubs library is ALWAYS static hence included here +# irrespective of the OPTS setting. +stubscflags = $(cflags) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) + # Link flags @@ -1154,20 +1226,21 @@ hose: @echo Hosing $(OUT_DIR)\* ... @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR) -# Implicit rule definitions +# Implicit rule definitions - only for building library objects. For stubs and main +# application, the master makefile should define explicit rules. {$(WINDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(cflags) $(crt) $(PRJ_INCLUDES) $(PRJ_DEFINES) -Fo$(TMP_DIR)\ @<< + $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< $< << {$(GENERICDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(cflags) $(crt) $(PRJ_INCLUDES) $(PRJ_DEFINES) -Fo$(TMP_DIR)\ @<< + $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< $< << {$(COMPATDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(cflags) $(crt) $(PRJ_INCLUDES) $(PRJ_DEFINES) -Fo$(TMP_DIR)\ @<< + $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< $< << @@ -1196,7 +1269,7 @@ TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake" !endif !endif # TCLINSTALL -!if ! $(DISABLE_CONFIG_CHECKS) +!if $(CONFIG_CHECK) !ifdef TCLNMAKECONFIG !include $(TCLMAKECONFIG) -- cgit v0.12 From e4269a71402fe87814784726463492302dfb48d8 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Fri, 29 Sep 2017 06:12:04 +0000 Subject: Updated for Tk compatibility. Removed extraneous quotes in macro definitions. Macros should be quoted at *use* time, not *definition* time. Added _nostubs versions of pkgcflags and appcflags. --- win/makefile.vc | 2 +- win/rules.vc | 91 ++++++++++++++++++++++++++++++--------------------------- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 015f6ba..f2f3208 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -118,7 +118,7 @@ # Hooks to allow the intermediate and output directories to be # changed. $(OUT_DIR) is assumed to be # .\(Release|Debug) based on if symbols are requested. -# $(TMP_DIR) will de $(OUT_DIR)\ by default. +# $(TMP_DIR) will be $(OUT_DIR)\ by default. # # TESTPAT= # Reads the tests requested to be run from this file. diff --git a/win/rules.vc b/win/rules.vc index fe5a8e7..be49672 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -557,7 +557,7 @@ TCL_USE_STATIC_PACKAGES = 0 USE_THREAD_ALLOC = 1 UNCHECKED = 0 CONFIG_CHECK = 1 -!if "$(PROJECT)" == "tcl" || "$(PROJECT)" == "tk" +!if "$(PROJECT)" == "tcl" USE_STUBS = 0 !else USE_STUBS = 1 @@ -894,29 +894,29 @@ TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" !if $(TCLINSTALL) # Building against an installed Tcl -TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe" +TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe !if !exist($(TCLSH)) && $(TCL_THREADS) -TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe" +TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe !endif -TCLSTUBLIB = "$(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib" -TCLIMPLIB = "$(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib" +TCLSTUBLIB = $(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib +TCLIMPLIB = $(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib TCL_LIBRARY = $(_TCLDIR)\lib -TCLREGLIB = "$(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib" -TCLDDELIB = "$(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib" +TCLREGLIB = $(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib +TCLDDELIB = $(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target TCL_INCLUDES = -I"$(_TCLDIR)\include" !else # Building against Tcl sources -TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe" +TCLSH = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe !if !exist($(TCLSH)) && $(TCL_THREADS) -TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX).exe" +TCLSH = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX).exe !endif -TCLSTUBLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib" -TCLIMPLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib" +TCLSTUBLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib +TCLIMPLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib TCL_LIBRARY = $(_TCLDIR)\library -TCLREGLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib" -TCLDDELIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib" +TCLREGLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib +TCLDDELIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib TCLTOOLSDIR = $(_TCLDIR)\tools TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win" @@ -937,27 +937,29 @@ TCLSH_NATIVE = $(TCLSH) # Do the same for Tk and Tk extensions that require the Tk libraries !if "$(PROJECT)" == "tk" -WISH = "$(OUT_DIR)\$(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe" +WISHNAMEPREFIX = wish +WISH = $(OUT_DIR)\$(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe TKSTUBLIBNAME = $(STUBPREFIX)$(TK_VERSION).lib -TKSTUBLIB = "$(OUT_DIR)\$(TKSTUBLIBNAME)" -TKIMPLIB = "$(OUT_DIR)\$(PROJECT)$(TK_VERSION)$(SUFX).lib" +TKSTUBLIB = $(OUT_DIR)\$(TKSTUBLIBNAME) +TKIMPLIB = $(OUT_DIR)\$(PROJECT)$(TK_VERSION)$(SUFX).lib TKLIBNAME = $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT) +TKLIB = $(OUT_DIR)\$(TKLIBNAME) TK_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" !elseif defined(PROJECT_REQUIRES_TK) !if $(TKINSTALL) # Building against installed Tk -WISH = "$(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe" -TKSTUBLIB = "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib" -TKIMPLIB = "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib" +WISH = $(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe +TKSTUBLIB = $(_TKDIR)\lib\tkstub$(TK_VERSION).lib +TKIMPLIB = $(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib TK_INCLUDES = -I"$(_TKDIR)\include" !else # Building against Tk sources -WISH = "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe" -TKSTUBLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib" -TKIMPLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib" +WISH = $(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe +TKSTUBLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib +TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" !endif # TKINSTALL @@ -978,9 +980,9 @@ LIB_INSTALL_DIR = $(_INSTALLDIR)\lib BIN_INSTALL_DIR = $(_INSTALLDIR)\bin DOC_INSTALL_DIR = $(_INSTALLDIR)\doc !if "$(PROJECT)" == "tcl" -SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\tcl$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION) +SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION) !else -SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\tk$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION) +SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION) !endif INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\include !else @@ -1037,10 +1039,10 @@ 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" && "$(PROJECT)" != "tk" -OPTDEFINES = $(OPTDEFINES) -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS +!if "$(PROJECT)" != "tcl" +USE_STUBS_DEFS = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS !ifdef PROJECT_REQUIRES_TK -OPTDEFINES = $(OPTDEFINES) -DUSE_TK_STUBS +USE_STUBS_DEFS = $(USE_STUBS_DEFS) -DUSE_TK_STUBS !endif !endif !endif # USE_STUBS @@ -1063,7 +1065,6 @@ OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64 # UNICODE - Use the wide char Windows API. # _ATL_XP_TARGETING - Newer SDK's need this to build for XP -# BUILD_xxx - defined to export the xxx_Init call from the DLL COMPILERFLAGS = /DUNICODE /D_UNICODE /D_ATL_XP_TARGETING # crt picks the C run time based on selected OPTS @@ -1113,27 +1114,31 @@ cwarn = $(cwarn) -wd4311 -wd4312 cwarn = $(cwarn) -WX !endif -# These flags are defined roughly in the order of the pre-reform rules.vc/makefile.vc to help -# visually compare that the pre- and post-reform build logs +# These flags are defined roughly in the order of the pre-reform +# rules.vc/makefile.vc to help visually compare that the pre- and +# post-reform build logs -# cflags contains generic flags to be used for building practically all object files +# cflags contains generic flags used for building practically all object files cflags = -nologo -c $(COMPILERFLAGS) $(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 flags used for building shared object files -# The two differ in the BUILD_$(PROJECT) macro which should be defined only for -# the shared library *implementation* and not for its caller interface -appcflags = $(cflags) $(crt) $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) +# appcflags contains $(cflags) and flags for building the application +# object files (e.g. tclsh, or wish) pkgcflags contains $(cflags) plus +# flags used for building shared object files The two differ in the +# BUILD_$(PROJECT) macro which should be defined only for the shared +# library *implementation* and not for its caller interface + +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) -# stubscflags contains $(cflags) plus flags used for building a stubs library for the -# package. -# Note: -DSTATIC_BUILD is defined in $(OPTDEFINES) only if the OPTS configuration indicates -# a static library. However the stubs library is ALWAYS static hence included here -# irrespective of the OPTS setting. -stubscflags = $(cflags) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) +# stubscflags contains $(cflags) plus flags used for building a stubs +# library for the package. Note: -DSTATIC_BUILD is defined in +# $(OPTDEFINES) only if the OPTS configuration indicates a static +# library. However the stubs library is ALWAYS static hence included +# here irrespective of the OPTS setting. +stubscflags = $(cflags) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) # Link flags -- cgit v0.12 From 71c784c8bc5a9a679f643f2047d5330ffd87fa08 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Fri, 29 Sep 2017 12:41:02 +0000 Subject: Added implicit rule for compiling resources. Added Tcl import libraries to link macro. --- win/makefile.vc | 9 +-------- win/rules.vc | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index f2f3208..a32549b 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -899,14 +899,7 @@ $< $< << -{$(WINDIR)}.rc{$(TMP_DIR)}.res: - $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ - -d DEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \ - -d TCL_THREADS=$(TCL_THREADS) \ - -d STATIC_BUILD=$(STATIC_BUILD) \ - $< - -$(TMP_DIR)\tclsh.res: $(TMP_DIR)\tclsh.exe.manifest +$(TMP_DIR)\tclsh.res: $(TMP_DIR)\tclsh.exe.manifest $(WINDIR)\tclsh.rc #--------------------------------------------------------------------- diff --git a/win/rules.vc b/win/rules.vc index be49672..2744330 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -922,6 +922,8 @@ TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win" !endif # TCLINSTALL +tcllibs = "$(TCLSTUBLIB)" "$(TCLIMPLIB)" + !endif $(PROJECT) != "tcl" # We need a tclsh that will run on the host machine as part of the build. @@ -1129,8 +1131,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) -DBUILD_$(PROJECT) +pkgcflags_nostubs = $(appcflags_nostubs) -DBUILD_$(PROJECT) # stubscflags contains $(cflags) plus flags used for building a stubs # library for the package. Note: -DSTATIC_BUILD is defined in @@ -1249,13 +1251,26 @@ $< $< << +{$(RCDIR)}.rc{$(TMP_DIR)}.res: + $(MAKERESCMD) + +{$(WINDIR)}.rc{$(TMP_DIR)}.res: + $(MAKERESCMD) + .SUFFIXES: .SUFFIXES:.c .rc MAKELIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@ -MAKEDLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) -MAKECONCMD = $(link32) $(conlflags) -out:$@ $(baselibs) -MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) +MAKEDLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs) +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) \ + $< + ################################################################ # 14. Sanity check selected options against Tcl build options -- cgit v0.12 From 78cf38319762a590b74fbe99f1802584e73e9db3 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Fri, 29 Sep 2017 14:23:17 +0000 Subject: Permit definition of implicit rules and standard targets to be disabled --- win/rules.vc | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 2744330..973cef9 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -37,7 +37,8 @@ _RULES_VC = 1 # 11. Construct the paths where the package is to be installed # 12. Set up the actual options passed to compiler and linker based # on the information gathered above. -# 13. Define some standard build targets and implicit rules. +# 13. Define some standard build targets and implicit rules. These may +# be optionally disabled by the parent makefile. # 14. (For extensions only.) Compare the configuration of the target # Tcl and the extensions and warn against discrepancies. # @@ -1204,7 +1205,20 @@ baselibs = $(baselibs) ucrt.lib !endif ################################################################ -# 3. Define common make targets and implicit rules +# 3. Define standard commands, common make targets and implicit rules + +MAKELIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@ +MAKEDLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs) +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) \ + $< + +!ifndef DISABLE_DEFAULT_TARGETS !ifndef DEFAULT_BUILD_TARGET DEFAULT_BUILD_TARGET = all @@ -1233,8 +1247,11 @@ hose: @echo Hosing $(OUT_DIR)\* ... @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR) -# Implicit rule definitions - only for building library objects. For stubs and main -# application, the master makefile should define explicit rules. +!endif + +!ifndef DISABLE_IMPLICIT_RULES +# Implicit rule definitions - only for building library objects. For stubs and +# main application, the master makefile should define explicit rules. {$(WINDIR)}.c{$(TMP_DIR)}.obj:: $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< @@ -1260,17 +1277,7 @@ $< .SUFFIXES: .SUFFIXES:.c .rc -MAKELIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@ -MAKEDLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs) -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) \ - $< - +!endif ################################################################ # 14. Sanity check selected options against Tcl build options -- cgit v0.12 From 457587f033b206475f695919961b1e2e83ecfc2f Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sat, 30 Sep 2017 06:20:33 +0000 Subject: Added standard macros LIBDIR and DEMODIR. Also set common Tk related names and paths --- win/rules.vc | 55 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 973cef9..5a5883b 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -135,6 +135,16 @@ GENERICDIR = $(ROOT)\generic !ifndef TOOLSDIR TOOLSDIR = $(ROOT)\tools !endif +!ifndef LIBDIR +LIBDIR = $(ROOT)\library +!endif +!ifndef DEMODIR +!if exist("$(LIBDIR)\demos") +DEMODIR = $(LIBDIR)\demos +!else +DEMODIR = $(ROOT)\demos +!endif +!endif # ifndef DEMODIR # Do NOT enclose WINDIR in a !ifndef because Windows always defines # WINDIR env var to point to c:\windows! # TBD - This is a potentially dangerous conflict, rename WINDIR to @@ -938,37 +948,36 @@ TCLSH_NATIVE = $(TCLSH) !endif # Do the same for Tk and Tk extensions that require the Tk libraries -!if "$(PROJECT)" == "tk" - +!if "$(PROJECT)" == "tk" || defined(PROJECT_REQUIRES_TK) WISHNAMEPREFIX = wish -WISH = $(OUT_DIR)\$(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe -TKSTUBLIBNAME = $(STUBPREFIX)$(TK_VERSION).lib -TKSTUBLIB = $(OUT_DIR)\$(TKSTUBLIBNAME) -TKIMPLIB = $(OUT_DIR)\$(PROJECT)$(TK_VERSION)$(SUFX).lib +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" +WISH = $(OUT_DIR)\$(WISHNAME) +TKSTUBLIB = $(OUT_DIR)\$(TKSTUBLIBNAME) +TKIMPLIB = $(OUT_DIR)\$(TKIMPLIBNAME) TKLIB = $(OUT_DIR)\$(TKLIBNAME) TK_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" -!elseif defined(PROJECT_REQUIRES_TK) +!else # effectively PROJECT_REQUIRES_TK !if $(TKINSTALL) # Building against installed Tk - -WISH = $(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe -TKSTUBLIB = $(_TKDIR)\lib\tkstub$(TK_VERSION).lib -TKIMPLIB = $(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib +WISH = $(_TKDIR)\bin\$(WISHNAME) +TKSTUBLIB = $(_TKDIR)\lib\$(TKSTUBLIBNAME) +TKIMPLIB = $(_TKDIR)\lib\$(TKIMPLIBNAME) TK_INCLUDES = -I"$(_TKDIR)\include" - !else # Building against Tk sources - -WISH = $(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe -TKSTUBLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib -TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib +WISH = $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME) +TKSTUBLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME) +TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME) TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" - !endif # TKINSTALL -!endif # PROJECT_REQUIRES_TK - +!endif # $(PROJECT) == tk +!endif # $(PROJECT) == tk || PROJECT_REQUIRES_TK ################################################################### # 11. Construct the paths for the installation directories @@ -978,6 +987,9 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" # DOC_INSTALL_DIR - where documentation should be installed # SCRIPT_INSTALL_DIR - where scripts should be installed # INCLUDE_INSTALL_DIR - where C include files should be installed +# 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" LIB_INSTALL_DIR = $(_INSTALLDIR)\lib BIN_INSTALL_DIR = $(_INSTALLDIR)\bin @@ -987,14 +999,19 @@ SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MIN !else 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 + PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION) LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR) BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR) DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR) SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR) +DEMO_INSTALL_DIR = $(PRJ_INSTALL_DIR)\demos INCLUDE_INSTALL_DIR = $(_TCLDIR)\include + !endif ################################################################### -- cgit v0.12 From 24b65fbe41afddbd86e64d6a7459d46144fe246b Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sat, 30 Sep 2017 08:34:31 +0000 Subject: Added MAKEEXTCMD macro. Fixed couple of syntax errors when building extensions. --- win/rules.vc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 5a5883b..75919d2 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -906,7 +906,7 @@ TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" !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 @@ -1225,7 +1225,13 @@ 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) +MAKEEXTCMD = $(MAKELIBCMD) +!else +MAKEEXTCMD = $(MAKEDLLCMD) +!endif MAKECONCMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) MAKERESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ @@ -1315,9 +1321,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) -- cgit v0.12 From 01201582b7a72ee2efbb6d431ef8f02becd562f1 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sat, 30 Sep 2017 14:11:08 +0000 Subject: Fix initialization of _TCLDIR and use MAKE*CMD macros in makefile.vc Fixed initialization of _TCLDIR when it is not defined by caller when building an extension. _INSTALLDIR is modified AFTER it is used to initialize _TCLDIR. However, nmake expands late so we have to init _TCLDIR relative to the *modified* _INSTALLDIR. --- win/makefile.vc | 22 +++++----------------- win/rules.vc | 16 +++++++++++----- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index a32549b..9bd91f5 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -503,25 +503,15 @@ runshell: setup $(TCLSH) dlls set TCL_LIBRARY=$(ROOT:\=/)/library $(DEBUGGER) $(TCLSH) $(SCRIPT) -setup: - @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) - @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) - !if !$(STATIC_BUILD) $(TCLIMPLIB): $(TCLLIB) !endif $(TCLLIB): $(TCLOBJS) -!if $(STATIC_BUILD) - $(MAKELIBCMD) @<< -$** -<< -!else - $(MAKEDLLCMD) @<< + $(MAKEBINCMD) @<< $** << $(_VC_MANIFEST_EMBED_DLL) -!endif $(TCLSTUBLIB): $(TCLSTUBOBJS) $(MAKELIBCMD) -nodefaultlib $(TCLSTUBOBJS) @@ -536,21 +526,19 @@ $(TCLTEST): $(TCLTESTOBJS) $(TCLSTUBLIB) $(TCLIMPLIB) !if $(STATIC_BUILD) $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj - $(MAKELIBCMD) $** !else $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLSTUBLIB) - $(MAKEDLLCMD) $** - $(_VC_MANIFEST_EMBED_DLL) !endif + $(MAKEBINCMD) $** + $(_VC_MANIFEST_EMBED_DLL) !if $(STATIC_BUILD) $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj - $(MAKELIBCMD) $** !else $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(TCLSTUBLIB) - $(MAKEDLLCMD) $** - $(_VC_MANIFEST_EMBED_DLL) !endif + $(MAKEBINCMD) $** + $(_VC_MANIFEST_EMBED_DLL) pkgs: @for /d %d in ($(PKGSDIR)\*) do \ diff --git a/win/rules.vc b/win/rules.vc index 75919d2..f62be5c 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -213,9 +213,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 @@ -1228,9 +1230,9 @@ MAKELIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@ MAKEDLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs) !if $(STATIC_BUILD) -MAKEEXTCMD = $(MAKELIBCMD) +MAKEBINCMD = $(MAKELIBCMD) !else -MAKEEXTCMD = $(MAKEDLLCMD) +MAKEBINCMD = $(MAKEDLLCMD) !endif MAKECONCMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) @@ -1249,6 +1251,10 @@ DEFAULT_BUILD_TARGET = all default_target: $(DEFAULT_BUILD_TARGET) +setup: + @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) + @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) + clean: @echo Cleaning $(TMP_DIR)\* ... @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR) -- cgit v0.12 From 35256f809ed60c7d2fe088246d90c8841686dc76 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 2 Oct 2017 17:09:56 +0000 Subject: Introduce rules-ext.vc file for extensions to select most recent rules.vc --- win/rules-ext.vc | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ win/rules.vc | 16 +++++++++--- 2 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 win/rules-ext.vc diff --git a/win/rules-ext.vc b/win/rules-ext.vc new file mode 100644 index 0000000..2a8943b --- /dev/null +++ b/win/rules-ext.vc @@ -0,0 +1,74 @@ +# This file should only be included in makefiles for Tcl extensions, +# NOT in the makefile for Tcl itself. +!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. +!ifndef TCLDIR + +# 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" +TCLDIR=$(INSTALLDIR) +!else +TCLDIR = ../../tcl +!endif + +!endif # ifndef TCLDIR + +# _TCLDIR = Windows native path format of TCLDIR +_TCLDIR = $(TCLDIR:/=\) + +# Now look for the rules.vc file under the Tcl root +!if exist("$(_TCLDIR)\lib\nmake\rules.vc") # Building against installed Tcl +_RULESDIR = $(_TCLDIR)\lib\nmake +!elseif exist("$(_TCLDIR)\win\rules.vc") # Building against Tcl sources +_RULESDIR = $(_TCLDIR)\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 + +_RULES_VC = $(_RULESDIR)\rules.vc + +!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 "$(_RULES_VC)" RULES_VERSION_MAJOR >> versions.vc] +!endif +!if [echo TCL_RULES_MINOR = \>> versions.vc] \ + && [nmakehlp -V "$(_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 +!message V $(TCL_RULES_MAJOR) $(TCL_RULES_MINOR) $(OUR_RULES_MAJOR) $(OUR_RULES_MINOR) +!if ($(TCL_RULES_MAJOR) != $(OUR_RULES_MAJOR)) || ($(TCL_RULES_MINOR) < $(OUR_RULES_MINOR)) +_RULESDIR = . +!endif + +!endif # $(_RULESDIR) != "." + + +# Get rid of our internal defines before calling rules.vc +!undef _TCLDIR +!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" diff --git a/win/rules.vc b/win/rules.vc index f62be5c..6846a32 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,6 +15,10 @@ !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 + ################################################################ # Nmake is a pretty weak environment in syntax and capabilities # so this file is necessarily verbose. It's broken down into @@ -1085,9 +1089,13 @@ 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 + +# UNICODE - Use the wide char Windows API. Tcl 8.5 does not define this. +!if $(TCL_VERSION) > 85 +COMPILERFLAGS = $(COMPILERFLAGS) /DUNICODE /D_UNICODE +!endif # crt picks the C run time based on selected OPTS !if $(MSVCRT) @@ -1299,7 +1307,7 @@ $< {$(RCDIR)}.rc{$(TMP_DIR)}.res: $(MAKERESCMD) - + {$(WINDIR)}.rc{$(TMP_DIR)}.res: $(MAKERESCMD) -- cgit v0.12 From f5c6b072469892af03a919e8c941e0426baead1f Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 3 Oct 2017 08:06:30 +0000 Subject: Remove use of any macros used in rules.vc from rules-ext.vc Added USE_WIDECHAR_API to control usage of Windows wide API's. --- win/makefile.vc | 2 ++ win/rules-ext.vc | 36 +++++++++++++++++++----------------- win/rules.vc | 15 ++++++++++++++- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 9bd91f5..7a3de6e 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -673,6 +673,7 @@ CORE_MACHINE = $(MACHINE) CORE_DEBUG = $(DEBUG) CORE_TCL_THREADS = $(TCL_THREADS) CORE_USE_THREAD_ALLOC = $(USE_THREAD_ALLOC) +CORE_USE_WIDECHAR_API = $(USE_WIDECHAR_API) << #--------------------------------------------------------------------- @@ -947,6 +948,7 @@ install-libraries: tclConfig tcl-nmake install-msgs install-tzdata @$(CPY) "$(OUT_DIR)\tclConfig.sh" "$(LIB_INSTALL_DIR)\" @$(CPY) "$(WINDIR)\tclooConfig.sh" "$(LIB_INSTALL_DIR)\" @$(CPY) "$(WINDIR)\rules.vc" "$(LIB_INSTALL_DIR)\nmake\" + @$(CPY) "$(WINDIR)\rules-ext.vc" "$(LIB_INSTALL_DIR)\nmake\" @$(CPY) "$(WINDIR)\nmakehlp.c" "$(LIB_INSTALL_DIR)\nmake\" @$(CPY) "$(OUT_DIR)\tcl.nmake" "$(LIB_INSTALL_DIR)\nmake\" @echo Installing library http1.0 directory diff --git a/win/rules-ext.vc b/win/rules-ext.vc index 2a8943b..094bc32 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -1,38 +1,40 @@ # This file should only be included in makefiles for Tcl extensions, # NOT in the makefile for Tcl itself. + +!ifndef _RULES_EXT_VC + !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. -!ifndef TCLDIR +!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" -TCLDIR=$(INSTALLDIR) +_RULESDIR=$(INSTALLDIR:/=\) !else -TCLDIR = ../../tcl +_RULESDIR = ..\..\tcl !endif !endif # ifndef TCLDIR -# _TCLDIR = Windows native path format of TCLDIR -_TCLDIR = $(TCLDIR:/=\) - # Now look for the rules.vc file under the Tcl root -!if exist("$(_TCLDIR)\lib\nmake\rules.vc") # Building against installed Tcl -_RULESDIR = $(_TCLDIR)\lib\nmake -!elseif exist("$(_TCLDIR)\win\rules.vc") # Building against Tcl sources -_RULESDIR = $(_TCLDIR)\win +!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 -_RULES_VC = $(_RULESDIR)\rules.vc - !if "$(_RULESDIR)" != "." # Potentially using Tcl's support files. Need to compare the versions. # We extract version numbers using the nmakehlp program. For this @@ -41,10 +43,10 @@ _RULES_VC = $(_RULESDIR)\rules.vc !endif !if [echo TCL_RULES_MAJOR = \> versions.vc] \ - && [nmakehlp -V "$(_RULES_VC)" RULES_VERSION_MAJOR >> versions.vc] + && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MAJOR >> versions.vc] !endif !if [echo TCL_RULES_MINOR = \>> versions.vc] \ - && [nmakehlp -V "$(_RULES_VC)" RULES_VERSION_MINOR >> versions.vc] + && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MINOR >> versions.vc] !endif !if [echo OUR_RULES_MAJOR = \>> versions.vc] \ @@ -55,7 +57,6 @@ _RULES_VC = $(_RULESDIR)\rules.vc !endif !include versions.vc # We have a newer version of the support files, use them -!message V $(TCL_RULES_MAJOR) $(TCL_RULES_MINOR) $(OUR_RULES_MAJOR) $(OUR_RULES_MINOR) !if ($(TCL_RULES_MAJOR) != $(OUR_RULES_MAJOR)) || ($(TCL_RULES_MINOR) < $(OUR_RULES_MINOR)) _RULESDIR = . !endif @@ -64,11 +65,12 @@ _RULESDIR = . # Get rid of our internal defines before calling rules.vc -!undef _TCLDIR !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" +!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 6846a32..399796f 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1092,8 +1092,21 @@ OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64 # _ATL_XP_TARGETING - Newer SDK's need this to build for XP COMPILERFLAGS = /D_ATL_XP_TARGETING -# UNICODE - Use the wide char Windows API. Tcl 8.5 does not define this. + +# 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 -- cgit v0.12 From ec0fc7f8162eaba81d27f3c3ca6fe65b0e3d0932 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 3 Oct 2017 13:41:53 +0000 Subject: Have nmakehlp return non-0 exit code if version string not located with -V option --- win/nmakehlp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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, -- cgit v0.12 From 8c50df7bbf81ebcc60be310c1dc8e08ff893fa1d Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 3 Oct 2017 13:44:49 +0000 Subject: Extract version numbers from TEA files so do not have to be separately defined. --- win/makefile.vc | 2 +- win/rules.vc | 101 ++++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 77 insertions(+), 26 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 7a3de6e..e8a91e8 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -639,7 +639,7 @@ Display compile progress=no Error log file=$(HTMLBASE).log Full-text search=Yes Language=0x409 English (United States) -Title=Tcl/Tk $(DOT_VERSION) Help +Title=Tcl/Tk $(DOTVERSION) Help [FILES] contents.htm docs.css diff --git a/win/rules.vc b/win/rules.vc index 399796f..a69c26f 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -19,6 +19,19 @@ _RULES_VC = 1 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 @@ -169,7 +182,7 @@ _INSTALLDIR = $(INSTALLDIR:/=\) _INSTALLDIR = C:\Program Files\Tcl !endif -!if "$(PROJECT)" == "tcl" +!if $(DOING_TCL) # BEGIN Case 2(a) - Building Tcl itself @@ -178,7 +191,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 @@ -282,7 +295,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 @@ -403,7 +416,7 @@ CFG_ENCODING = \"cp1252\" # 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 @@ -413,7 +426,7 @@ NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c !endif !endif # $(TCLINSTALL) -!endif # $(PROJECT) != "tcl" +!endif # !$(DOING_TCL) !endif # NMAKEHLPC @@ -574,7 +587,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 @@ -772,7 +785,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 @@ -782,6 +799,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] @@ -811,10 +830,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 @@ -895,7 +943,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) @@ -907,7 +955,7 @@ 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 @@ -941,7 +989,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. @@ -954,14 +1002,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) @@ -982,8 +1030,8 @@ 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 ################################################################### # 11. Construct the paths for the installation directories @@ -996,19 +1044,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) @@ -1065,7 +1113,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 @@ -1092,7 +1140,6 @@ OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64 # _ATL_XP_TARGETING - Newer SDK's need this to build for XP 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 @@ -1259,9 +1306,13 @@ 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 @@ -1334,7 +1385,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") @@ -1363,7 +1414,7 @@ TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake" !endif # TCLNMAKECONFIG -!endif # $(PROJECT) == "tcl" +!endif # ! $(DOING_TCL) #---------------------------------------------------------- -- cgit v0.12 From c0295836a87989ce8b73459877b76171a32eaf4e Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 4 Oct 2017 01:57:51 +0000 Subject: Add default-* targets --- win/rules.vc | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index a69c26f..6f14f67 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -37,7 +37,8 @@ DOING_TK = 1 # 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 @@ -74,6 +75,11 @@ Visual C++ compiler environment not initialized. !error $(MSG) !endif +# Defaults for built-in internal settings defined in parent makefile +!ifndef DISABLE_DEFAULT_TARGETS +DISABLE_DEFAULT_TARGETS = 0 +!endif + ################################################################ # 1. Define external programs being used @@ -882,10 +888,15 @@ VERSION = $(TK_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 @@ -1033,6 +1044,14 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" !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 # The following macros get defined in this section: @@ -1315,19 +1334,27 @@ MAKERESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ -DSUFX=\"$(SUFX)\" \ $< -!ifndef DISABLE_DEFAULT_TARGETS !ifndef DEFAULT_BUILD_TARGET DEFAULT_BUILD_TARGET = all !endif -default_target: $(DEFAULT_BUILD_TARGET) +default-target: $(DEFAULT_BUILD_TARGET) -setup: - @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) - @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) +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 -clean: +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 ... @@ -1342,12 +1369,28 @@ 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) +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) + +# Always enable this target as this is fairly standard across Tcl and all +# extensions and does the same thing everywhere. +setup: default-setup + +!if ! $(DISABLE_DEFAULT_TARGETS) +install: default-install +clean: default-clean +realclean: hose +hose: default-hose +distclean: realclean default-distclean !endif !ifndef DISABLE_IMPLICIT_RULES -- cgit v0.12 From 20730e0afb57e613514f889ef6f2f93314717f74 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Thu, 5 Oct 2017 14:19:50 +0000 Subject: Added default-pkgindex target and split DISABLE_DEFAULT_TARGETS to DISABLE_{STANDARD,CLEAN}_TARGETS. --- win/makefile.vc | 3 +++ win/rules.vc | 24 +++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index e8a91e8..dd6acca 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -173,6 +173,9 @@ PROJECT = tcl # rules.vc file will set up "all" as the target. DEFAULT_BUILD_TARGET = release +# We do not want the standard install targets defined in rules.vc +DISABLE_STANDARD_TARGETS = 1 + # The rules.vc file does most of the hard work in terms of defining # the build configuration, macros, output directories etc. !include "rules.vc" diff --git a/win/rules.vc b/win/rules.vc index 6f14f67..7f5ff3d 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -76,8 +76,11 @@ Visual C++ compiler environment not initialized. !endif # Defaults for built-in internal settings defined in parent makefile -!ifndef DISABLE_DEFAULT_TARGETS -DISABLE_DEFAULT_TARGETS = 0 +!ifndef DISABLE_STANDARD_TARGETS +DISABLE_STANDARD_TARGETS = 0 +!endif +!ifndef DISABLE_CLEAN_TARGETS +DISABLE_CLEAN_TARGETS = 0 !endif ################################################################ @@ -1341,6 +1344,18 @@ DEFAULT_BUILD_TARGET = all default-target: $(DEFAULT_BUILD_TARGET) +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) @@ -1385,8 +1400,11 @@ default-setup: # extensions and does the same thing everywhere. setup: default-setup -!if ! $(DISABLE_DEFAULT_TARGETS) +!if ! $(DISABLE_STANDARD_TARGETS) install: default-install +!endif + +!if ! $(DISABLE_CLEAN_TARGETS) clean: default-clean realclean: hose hose: default-hose -- cgit v0.12 From 65895760ea527481c4c02b11273431f1053aec5a Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Thu, 5 Oct 2017 17:00:39 +0000 Subject: Added standard target for generating pkgIndex.tcl. Added PKGNAMEFLAGS to pass PACKAGE_NAME and PACKAGE_VERSION. --- win/makefile.vc | 2 +- win/rules-ext.vc | 7 +++++++ win/rules.vc | 19 +++++++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index dd6acca..92844e5 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -480,6 +480,7 @@ dlls: setup $(TCLREGLIB) $(TCLDDELIB) all: setup $(TCLSH) $(TCLSTUBLIB) dlls $(CAT32) pkgs tcltest: setup $(TCLTEST) dlls $(CAT32) install: install-binaries install-libraries install-docs install-pkgs +setup: default-setup test: test-core test-pkgs test-core: setup $(TCLTEST) dlls $(CAT32) @@ -951,7 +952,6 @@ install-libraries: tclConfig tcl-nmake install-msgs install-tzdata @$(CPY) "$(OUT_DIR)\tclConfig.sh" "$(LIB_INSTALL_DIR)\" @$(CPY) "$(WINDIR)\tclooConfig.sh" "$(LIB_INSTALL_DIR)\" @$(CPY) "$(WINDIR)\rules.vc" "$(LIB_INSTALL_DIR)\nmake\" - @$(CPY) "$(WINDIR)\rules-ext.vc" "$(LIB_INSTALL_DIR)\nmake\" @$(CPY) "$(WINDIR)\nmakehlp.c" "$(LIB_INSTALL_DIR)\nmake\" @$(CPY) "$(OUT_DIR)\tcl.nmake" "$(LIB_INSTALL_DIR)\nmake\" @echo Installing library http1.0 directory diff --git a/win/rules-ext.vc b/win/rules-ext.vc index 094bc32..825bf1a 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -3,6 +3,13 @@ !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 diff --git a/win/rules.vc b/win/rules.vc index 7f5ff3d..0730553 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1179,6 +1179,13 @@ USE_WIDECHAR_API = 0 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) !if $(DEBUG) && !$(UNCHECKED) @@ -1241,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 @@ -1396,12 +1403,12 @@ default-setup: @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) -# Always enable this target as this is fairly standard across Tcl and all -# extensions and does the same thing everywhere. -setup: default-setup - !if ! $(DISABLE_STANDARD_TARGETS) +setup: default-setup install: default-install +pkgindex: default-pkgindex +pkgIndex: default-pkgindex +pkgindex-tea: default-pkgindex-tea !endif !if ! $(DISABLE_CLEAN_TARGETS) -- cgit v0.12 From 21379b0cf5fd2a51ee08f109d65d29636e920592 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Fri, 6 Oct 2017 13:38:26 +0000 Subject: Move standard predefined targets to targets.vc as this allows the master makefile to modify macros if required before the targets are defined. --- win/makefile.vc | 9 +++++---- win/rules-ext.vc | 2 ++ win/rules.vc | 23 ++++------------------- win/targets.vc | 21 +++++++++++++++++++++ 4 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 win/targets.vc diff --git a/win/makefile.vc b/win/makefile.vc index 92844e5..dfbf961 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -173,9 +173,6 @@ PROJECT = tcl # rules.vc file will set up "all" as the target. DEFAULT_BUILD_TARGET = release -# We do not want the standard install targets defined in rules.vc -DISABLE_STANDARD_TARGETS = 1 - # The rules.vc file does most of the hard work in terms of defining # the build configuration, macros, output directories etc. !include "rules.vc" @@ -952,6 +949,7 @@ install-libraries: tclConfig tcl-nmake install-msgs install-tzdata @$(CPY) "$(OUT_DIR)\tclConfig.sh" "$(LIB_INSTALL_DIR)\" @$(CPY) "$(WINDIR)\tclooConfig.sh" "$(LIB_INSTALL_DIR)\" @$(CPY) "$(WINDIR)\rules.vc" "$(LIB_INSTALL_DIR)\nmake\" + @$(CPY) "$(WINDIR)\targets.vc" "$(LIB_INSTALL_DIR)\nmake\" @$(CPY) "$(WINDIR)\nmakehlp.c" "$(LIB_INSTALL_DIR)\nmake\" @$(CPY) "$(OUT_DIR)\tcl.nmake" "$(LIB_INSTALL_DIR)\nmake\" @echo Installing library http1.0 directory @@ -998,6 +996,7 @@ install-libraries: tclConfig tcl-nmake install-msgs install-tzdata @echo Installing encodings @$(CPY) "$(ROOT)\library\encoding\*.enc" \ "$(SCRIPT_INSTALL_DIR)\encoding\" +# "emacs font-lock highlighting fix install-tzdata: @echo Installing time zone data @@ -1031,7 +1030,9 @@ tidy: @echo Removing $(TCLREGLIB) ... @if exist $(TCLREGLIB) del $(TCLREGLIB) -clean: clean-pkgs +clean: default-clean clean-pkgs +hose: default-hose +realclean: hose # Local Variables: # mode: makefile diff --git a/win/rules-ext.vc b/win/rules-ext.vc index 825bf1a..97c11b4 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -70,6 +70,8 @@ _RULESDIR = . !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 diff --git a/win/rules.vc b/win/rules.vc index 0730553..c0d2915 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -417,9 +417,9 @@ 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) @@ -1346,7 +1346,7 @@ MAKERESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ !ifndef DEFAULT_BUILD_TARGET -DEFAULT_BUILD_TARGET = all +DEFAULT_BUILD_TARGET = $(PROJECT) !endif default-target: $(DEFAULT_BUILD_TARGET) @@ -1403,21 +1403,6 @@ default-setup: @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) -!if ! $(DISABLE_STANDARD_TARGETS) -setup: default-setup -install: default-install -pkgindex: default-pkgindex -pkgIndex: default-pkgindex -pkgindex-tea: default-pkgindex-tea -!endif - -!if ! $(DISABLE_CLEAN_TARGETS) -clean: default-clean -realclean: hose -hose: default-hose -distclean: realclean default-distclean -!endif - !ifndef DISABLE_IMPLICIT_RULES # Implicit rule definitions - only for building library objects. For stubs and # main application, the master makefile should define explicit rules. 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 + -- cgit v0.12 From a0f84e1b737e33956703918e18ec26da6a95d224 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sat, 7 Oct 2017 13:33:13 +0000 Subject: Fix ignore glob for Visual C++ output directories. --- .fossil-settings/ignore-glob | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob index 08d388d..c85b488 100644 --- a/.fossil-settings/ignore-glob +++ b/.fossil-settings/ignore-glob @@ -18,6 +18,7 @@ */tclsh* */tcltest* */versions.vc +*/version.vc html libtommath/bn.ilg libtommath/bn.ind @@ -40,7 +41,8 @@ unix/dltest.marker unix/tcl.pc unix/tclIndex unix/pkgs/* -win/Debug_VC* -win/Release_VC* +win/Debug* +win/Release* win/pkgs/* -win/tcl.hpj \ No newline at end of file +win/tcl.hpj +win/nmhlp-out.txt -- cgit v0.12 From fdc29e53d31d86bad4fd5489197ec23e34369052 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sat, 7 Oct 2017 17:16:20 +0000 Subject: Was not setting VERSION for extensions. --- win/rules.vc | 1 + 1 file changed, 1 insertion(+) diff --git a/win/rules.vc b/win/rules.vc index c0d2915..702e313 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -870,6 +870,7 @@ VERSION = $(TK_VERSION) !endif !include versions.vc !endif # DOTVERSION +VERSION = $(DOTVERSION:.=) !endif # $(DOING_TCL) ... etc. -- cgit v0.12 From 9845cc7c9ceedb5f71e3f0223391fb952156b7d1 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sun, 8 Oct 2017 13:18:15 +0000 Subject: Add default rc template so extensions do not have to write their own --- win/rules.vc | 46 ++++++++++++++++++++++++++++++++++++++++++---- win/tcl.rc | 20 +------------------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 702e313..d5952fd 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -398,8 +398,6 @@ _VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -ou CFG_ENCODING = \"cp1252\" !endif -!message ===================================================================== - ################################################################ # 4. Build the nmakehlp program # This is a helper app we need to overcome nmake's limiting @@ -1337,12 +1335,12 @@ MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) MAKERESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ $(TCL_INCLUDES) \ -DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \ - -DTCL_THREADS=$(TCL_THREADS) \ - -DSTATIC_BUILD=$(STATIC_BUILD) \ -DCOMMAVERSION=$(DOTVERSION:.=,),0 \ -DDOTVERSION=\"$(DOTVERSION)\" \ -DVERSION=\"$(VERSION)\" \ -DSUFX=\"$(SUFX)\" \ + -DPROJECT=\"$(PROJECT)\" \ + -DPRJLIBNAME=\"$(PRJLIBNAME)\" \ $< @@ -1404,6 +1402,43 @@ default-setup: @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) +default-rc: + @$(COPY) << $(TMP_DIR)\$(PROJECT).rc +#include + +VS_VERSION_INFO VERSIONINFO + FILEVERSION COMMAVERSION + PRODUCTVERSION COMMAVERSION + FILEFLAGSMASK 0x3fL +#ifdef DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "Tcl extension " PROJECT + VALUE "OriginalFilename", PRJLIBNAME + VALUE "FileVersion", DOTVERSION + VALUE "ProductName", "Package " PROJECT " for Tcl" + VALUE "ProductVersion", DOTVERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +<< + + !ifndef DISABLE_IMPLICIT_RULES # Implicit rule definitions - only for building library objects. For stubs and # main application, the master makefile should define explicit rules. @@ -1429,6 +1464,9 @@ $< {$(WINDIR)}.rc{$(TMP_DIR)}.res: $(MAKERESCMD) +{$(TMP_DIR)}.rc{$(TMP_DIR)}.res: + $(MAKERESCMD) + .SUFFIXES: .SUFFIXES:.c .rc diff --git a/win/tcl.rc b/win/tcl.rc index be5e0a7..2ca6015 100644 --- a/win/tcl.rc +++ b/win/tcl.rc @@ -4,24 +4,6 @@ #include #include -// -// build-up the name suffix that defines the type of build this is. -// -#if TCL_THREADS -#define SUFFIX_THREADS "t" -#else -#define SUFFIX_THREADS "" -#endif - -#if DEBUG && !UNCHECKED -#define SUFFIX_DEBUG "g" -#else -#define SUFFIX_DEBUG "" -#endif - -#define SUFFIX SUFFIX_THREADS SUFFIX_DEBUG - - LANGUAGE 0x9, 0x1 /* LANG_ENGLISH, SUBLANG_DEFAULT */ VS_VERSION_INFO VERSIONINFO @@ -42,7 +24,7 @@ BEGIN BLOCK "040904b0" /* LANG_ENGLISH/SUBLANG_ENGLISH_US, Unicode CP */ BEGIN VALUE "FileDescription", "Tcl DLL\0" - VALUE "OriginalFilename", "tcl" STRINGIFY(TCL_MAJOR_VERSION) STRINGIFY(TCL_MINOR_VERSION) SUFFIX ".dll\0" + VALUE "OriginalFilename", PRJLIBNAME VALUE "CompanyName", "ActiveState Corporation\0" VALUE "FileVersion", TCL_PATCH_LEVEL VALUE "LegalCopyright", "Copyright \251 2001 by ActiveState Corporation, et al\0" -- cgit v0.12 From f4e4349cadfc93b252489357206f87c5ebfea419 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sun, 8 Oct 2017 14:25:19 +0000 Subject: Fix htmlhelp generation on 64-bit systems --- win/makefile.vc | 11 +++++------ win/rules.vc | 12 ------------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index dfbf961..62e3fa7 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -613,13 +613,12 @@ gentommath_h: # Build the Windows HTML help file. #--------------------------------------------------------------------- -# NOTE: you can define HHC on the command-line to override this -!ifndef HHC -!if exist("$(PROGRAMFILES_X86)\HTML Help Workshop\hhc.exe") -HHC=$(PROGRAMFILES_X86)\HTML Help Workshop\hhc.exe +# NOTE: you can define HHC on the command-line to override this. +# nmake does not set macro values if already set on the command line. +!if defined(PROCESSOR_ARCHITECTURE) && "$(PROCESSOR_ARCHITECTURE)" == "AMD64" +HHC="%ProgramFiles(x86)%\HTML Help Workshop\hhc.exe" !else -HHC=hhc.exe -!endif +HHC="%ProgramFiles%\HTML Help Workshop\hhc.exe" !endif HTMLDIR=$(OUT_DIR)\html HTMLBASE=TclTk$(VERSION) diff --git a/win/rules.vc b/win/rules.vc index d5952fd..6ab58f6 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -98,18 +98,6 @@ CPY = xcopy /i /y >NUL COPY = copy /y >NUL MKDIR = mkdir -# The ProgramFiles(x86) environment variable is not accessible -# from nmake since it has the parenthesis which nmake does not like -# within a macro name. So define our own in terms of the -# ProgramFiles environment variable. -# Note: env variables are always UPPER CASE in nmake -!if defined(PROCESSOR_ARCHITECTURE) && "$(PROCESSOR_ARCHITECTURE)" == "AMD64" -PROGRAMFILES_X86 = $(PROGRAMFILES) (x86) -!else -PROGRAMFILES_X86 = $(PROGRAMFILES) -!endif - - ###################################################################### # 2. Figure out our build environment in terms of what we're building. # -- cgit v0.12 From 0c646bc3d1d73a89e9a196dec828b447f224535d Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sun, 8 Oct 2017 16:12:23 +0000 Subject: Fix RC template dependency to not generate it every time --- win/rules.vc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/win/rules.vc b/win/rules.vc index 6ab58f6..d970755 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1390,7 +1390,9 @@ default-setup: @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) -default-rc: +default-rc: $(TMP_DIR)\$(PROJECT).rc + +$(TMP_DIR)\$(PROJECT).rc: @$(COPY) << $(TMP_DIR)\$(PROJECT).rc #include -- cgit v0.12 From 823edbf0abc533041ff6a572705fbafd4cbe5cfd Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sun, 15 Oct 2017 06:58:20 +0000 Subject: Permit application makefile to define RCFILE. Change PROJECT_REQUIRES_TK to use value instead of ifdef. Change MAKERESCMD macro not to specify included input files. --- win/makefile.vc | 3 +++ win/rules.vc | 54 ++++++++++++++++++++++++++++++++++-------------------- win/targets.vc | 2 +- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 62e3fa7..09b0b9f 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -173,6 +173,9 @@ PROJECT = tcl # rules.vc file will set up "all" as the target. DEFAULT_BUILD_TARGET = release +# We want to use our own resource file, not the standard template one. +RCFILE = tcl.rc + # The rules.vc file does most of the hard work in terms of defining # the build configuration, macros, output directories etc. !include "rules.vc" diff --git a/win/rules.vc b/win/rules.vc index d970755..d9bb95d 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -32,6 +32,10 @@ DOING_TCL = 1 DOING_TK = 1 !endif +!ifndef(PROJECT_REQUIRES_TK) +PROJECT_REQUIRES_TK = 0 +!endif + ################################################################ # Nmake is a pretty weak environment in syntax and capabilities # so this file is necessarily verbose. It's broken down into @@ -75,14 +79,6 @@ 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 @@ -167,6 +163,7 @@ WINDIR = $(ROOT)\win !ifndef RCDIR RCDIR = $(WINDIR)\rc !endif +RCDIR = $(RCDIR:/=\) # The target directory where the built packages and binaries will be installed. # INSTALLDIR is the (optional) path specified by the user. @@ -176,7 +173,7 @@ RCDIR = $(WINDIR)\rc _INSTALLDIR = $(INSTALLDIR:/=\) !else ### Assume the normal default. -_INSTALLDIR = C:\Program Files\Tcl +_INSTALLDIR = $(HOMEDRIVE)\Tcl !endif !if $(DOING_TCL) @@ -248,7 +245,7 @@ Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and defa !endif # Now do the same to locate Tk headers and libs if project requires Tk -!ifdef PROJECT_REQUIRES_TK +!if $(PROJECT_REQUIRES_TK) !ifdef TKDIR @@ -887,6 +884,7 @@ VERSION = $(DOTVERSION:.=) # PRJLIB - output path of generated project library # PRJSTUBLIBNAME - name of the generated project stubs library # PRJSTUBLIB - output path of the generated project stubs library +# RESFILE - output resource file (only if not static build) SUFX = tsgx @@ -1003,7 +1001,7 @@ TCLSH_NATIVE = $(TCLSH) !endif # Do the same for Tk and Tk extensions that require the Tk libraries -!if $(DOING_TK) || defined(PROJECT_REQUIRES_TK) +!if $(DOING_TK) || $(PROJECT_REQUIRES_TK) WISHNAMEPREFIX = wish WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe TKLIBNAME = $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT) @@ -1032,7 +1030,7 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" !endif # TKINSTALL !endif # $(DOING_TK) -!endif # $(DOING_TK) || PROJECT_REQUIRES_TK +!endif # $(DOING_TK) || $(PROJECT_REQUIRES_TK) # Various output paths PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib @@ -1042,6 +1040,16 @@ PRJLIB = $(OUT_DIR)\$(PRJLIBNAME) PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME) +# If extension parent makefile has not defined a resource definition file, +# we will generate one from standard template. +!if !$(DOING_TCL) && !$(DOING_TK) && !$(STATIC_BUILD) +!ifdef RCFILE +RESFILE = $(RCFILE:.rc=.res) +!else +RESFILE = $(TMP_DIR)\$(PROJECT).res +!endif +!endif + ################################################################### # 11. Construct the paths for the installation directories # The following macros get defined in this section: @@ -1124,7 +1132,7 @@ OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED # test targets in tk do not use stubs !if ! $(DOING_TCL) USE_STUBS_DEFS = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS -!ifdef PROJECT_REQUIRES_TK +!if $(PROJECT_REQUIRES_TK) USE_STUBS_DEFS = $(USE_STUBS_DEFS) -DUSE_TK_STUBS !endif !endif @@ -1328,9 +1336,7 @@ MAKERESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ -DVERSION=\"$(VERSION)\" \ -DSUFX=\"$(SUFX)\" \ -DPROJECT=\"$(PROJECT)\" \ - -DPRJLIBNAME=\"$(PRJLIBNAME)\" \ - $< - + -DPRJLIBNAME=\"$(PRJLIBNAME)\" !ifndef DEFAULT_BUILD_TARGET DEFAULT_BUILD_TARGET = $(PROJECT) @@ -1390,7 +1396,10 @@ default-setup: @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) -default-rc: $(TMP_DIR)\$(PROJECT).rc +!ifndef RCFILE +# If parent makefile has not defined a resource definition file, +# we will generate one from standard template. +$(TMP_DIR)\$(PROJECT).res: $(TMP_DIR)\$(PROJECT).rc $(TMP_DIR)\$(PROJECT).rc: @$(COPY) << $(TMP_DIR)\$(PROJECT).rc @@ -1428,8 +1437,13 @@ END << +!endif # ifndef RCFILE !ifndef DISABLE_IMPLICIT_RULES +DISABLE_IMPLICIT_RULES = 0 +!endif + +!if $(DISABLE_IMPLICIT_RULES) # Implicit rule definitions - only for building library objects. For stubs and # main application, the master makefile should define explicit rules. @@ -1449,13 +1463,13 @@ $< << {$(RCDIR)}.rc{$(TMP_DIR)}.res: - $(MAKERESCMD) + $(MAKERESCMD) $< {$(WINDIR)}.rc{$(TMP_DIR)}.res: - $(MAKERESCMD) + $(MAKERESCMD) $< {$(TMP_DIR)}.rc{$(TMP_DIR)}.res: - $(MAKERESCMD) + $(MAKERESCMD) $< .SUFFIXES: .SUFFIXES:.c .rc diff --git a/win/targets.vc b/win/targets.vc index 6844045..84ce2a4 100644 --- a/win/targets.vc +++ b/win/targets.vc @@ -6,7 +6,7 @@ $(PROJECT): setup pkgindex $(PRJLIB) # 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) +$(PRJLIB): $(PRJ_OBJS) $(RESFILE) $(MAKEBINCMD) $** $(_VC_MANIFEST_EMBED_DLL) -@del $*.exp -- cgit v0.12 From 4ef03a89506970e90d30b6b7c14ac1a6143b1161 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 16 Oct 2017 12:46:53 +0000 Subject: Fixed reversed check for implicit rules --- win/rules.vc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index d9bb95d..3a37856 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -32,7 +32,7 @@ DOING_TCL = 1 DOING_TK = 1 !endif -!ifndef(PROJECT_REQUIRES_TK) +!ifndef PROJECT_REQUIRES_TK PROJECT_REQUIRES_TK = 0 !endif @@ -845,9 +845,9 @@ VERSION = $(TK_VERSION) # 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] + || [nmakehlp -V $(ROOT)\configure.in AC_INIT >> versions.vc] !if [echo DOTVERSION = \> versions.vc] \ - || [nmakehlp -V ..\configure.ac AC_INIT >> versions.vc] + || [nmakehlp -V $(ROOT)\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 @@ -1443,7 +1443,7 @@ END DISABLE_IMPLICIT_RULES = 0 !endif -!if $(DISABLE_IMPLICIT_RULES) +!if !$(DISABLE_IMPLICIT_RULES) # Implicit rule definitions - only for building library objects. For stubs and # main application, the master makefile should define explicit rules. -- cgit v0.12 From b6f90aaf1f3d7f67c39f358e9835f6cfb4f53a9a Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 17 Oct 2017 15:01:56 +0000 Subject: Add PRJ_MANIFEST to support manifest generation. --- win/targets.vc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/win/targets.vc b/win/targets.vc index 84ce2a4..56b6427 100644 --- a/win/targets.vc +++ b/win/targets.vc @@ -1,6 +1,13 @@ #------------------------------------------------------------- -*- makefile -*- $(PROJECT): setup pkgindex $(PRJLIB) +!ifdef PRJ_MANIFEST +$(PROJECT): $(PRJLIB).manifest +$(PRJLIB).manifest: $(PRJ_MANIFEST) + @nmakehlp -s << $** >$@ +@MACHINE@ $(MACHINE:IX86=X86) +<< +!endif !if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk" # MAKEBINCMD will do shared, static and debug links as appropriate -- cgit v0.12 From 63a9fcf2e7aefe28c1dd7aeb985434addfd43013 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 18 Oct 2017 16:03:08 +0000 Subject: Fix resource file compilation when makefile specifies PRJ_RCFILE --- win/rules.vc | 64 ++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 3a37856..852b1eb 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -91,6 +91,7 @@ Visual C++ compiler environment not initialized. RMDIR = rmdir /S /Q ERRNULL = 2>NUL CPY = xcopy /i /y >NUL +CPYDIR = xcopy /e /i /y >NUL COPY = copy /y >NUL MKDIR = mkdir @@ -161,7 +162,11 @@ DEMODIR = $(ROOT)\demos # something else WINDIR = $(ROOT)\win !ifndef RCDIR +!if exist("$(WINDIR)\rc") RCDIR = $(WINDIR)\rc +!else +RCDIR = $(WINDIR) +!endif !endif RCDIR = $(RCDIR:/=\) @@ -845,9 +850,9 @@ VERSION = $(TK_VERSION) # first from a configure.in file, and then from configure.ac !ifndef DOTVERSION !if [echo DOTVERSION = \> versions.vc] \ - || [nmakehlp -V $(ROOT)\configure.in AC_INIT >> versions.vc] + || [nmakehlp -V $(ROOT)\configure.in ^[$(PROJECT)^] >> versions.vc] !if [echo DOTVERSION = \> versions.vc] \ - || [nmakehlp -V $(ROOT)\configure.ac AC_INIT >> versions.vc] + || [nmakehlp -V $(ROOT)\configure.ac ^[$(PROJECT)^] >> versions.vc] !error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc. !endif !endif @@ -1028,6 +1033,7 @@ TKSTUBLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME) TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME) TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" !endif # TKINSTALL +tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)" !endif # $(DOING_TK) !endif # $(DOING_TK) || $(PROJECT_REQUIRES_TK) @@ -1043,8 +1049,8 @@ PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME) # If extension parent makefile has not defined a resource definition file, # we will generate one from standard template. !if !$(DOING_TCL) && !$(DOING_TK) && !$(STATIC_BUILD) -!ifdef RCFILE -RESFILE = $(RCFILE:.rc=.res) +!ifdef PRJ_RCFILE +RESFILE = $(TMP_DIR)\$(PRJ_RCFILE:.rc=.res) !else RESFILE = $(TMP_DIR)\$(PROJECT).res !endif @@ -1228,6 +1234,11 @@ cwarn = $(cwarn) -wd4311 -wd4312 cwarn = $(cwarn) -WX !endif +INCLUDES = $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) +!if !$(DOING_TCL) && !$(DOING_TK) +INCLUDES = $(INCLUDES) -I$(GENERICDIR) -I$(WINDIR) -I(COMPATDIR) +!endif + # These flags are defined roughly in the order of the pre-reform # rules.vc/makefile.vc to help visually compare that the pre- and # post-reform build logs @@ -1241,8 +1252,8 @@ cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug) # BUILD_$(PROJECT) macro which should be defined only for the shared # library *implementation* and not for its caller interface -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) +appcflags = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) $(USE_STUBS_DEFS) +appcflags_nostubs = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) pkgcflags = $(appcflags) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT) pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT) @@ -1251,8 +1262,11 @@ pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT) # $(OPTDEFINES) only if the OPTS configuration indicates a static # library. However the stubs library is ALWAYS static hence included # here irrespective of the OPTS setting. - -stubscflags = $(cflags) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) +# +# TBD - tclvfs has a comment that stubs libs should not be compiled with -GL +# without stating why. Tcl itself compiled stubs libs with this flag. +# so we do not remove it from cflags. +stubscflags = $(cflags) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(INCLUDES) # Link flags @@ -1301,6 +1315,10 @@ guilflags = $(lflags) -subsystem:windows # Extensions should define any additional libraries with $(PRJ_LIBS) winlibs = kernel32.lib advapi32.lib +!if $(PROJECT_REQUIRES_TK) +winlibs = $(winlibs) gdi32.lib user32.lib uxtheme.lib +!endif + # Avoid 'unresolved external symbol __security_cookie' errors. # c.f. http://support.microsoft.com/?id=894573 !if "$(MACHINE)" == "AMD64" @@ -1319,15 +1337,15 @@ 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) $(tklibs) !if $(STATIC_BUILD) MAKEBINCMD = $(MAKELIBCMD) !else MAKEBINCMD = $(MAKEDLLCMD) !endif -MAKECONCMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) -MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) +MAKECONCMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) +MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) MAKERESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ $(TCL_INCLUDES) \ -DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \ @@ -1369,6 +1387,21 @@ 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-html: + @echo Installing documentation files to '$(DOC_INSTALL_DIR)' + @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)" + @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css") do @$(COPY) %f "$(DOC_INSTALL_DIR)" + +default-install-man: + @echo Installing documentation files to '$(DOC_INSTALL_DIR)' + @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)" + @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.n") do @$(COPY) %f "$(DOC_INSTALL_DIR)" + +default-install-demos: + @echo Installing demos to '$(DEMO_INSTALL_DIR)' + @if not exist "$(DEMO_INSTALL_DIR)" mkdir "$(DEMO_INSTALL_DIR)" + @if exist $(DEMODIR) $(CPYDIR) "$(DEMODIR)" "$(DEMO_INSTALL_DIR)" + default-clean: @echo Cleaning $(TMP_DIR)\* ... @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR) @@ -1396,7 +1429,12 @@ default-setup: @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) -!ifndef RCFILE +!ifdef PRJ_RCFILE + +$(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc + $(MAKERESCMD) $** +!else + # If parent makefile has not defined a resource definition file, # we will generate one from standard template. $(TMP_DIR)\$(PROJECT).res: $(TMP_DIR)\$(PROJECT).rc @@ -1437,7 +1475,7 @@ END << -!endif # ifndef RCFILE +!endif # ifdef PRJ_RCFILE !ifndef DISABLE_IMPLICIT_RULES DISABLE_IMPLICIT_RULES = 0 -- cgit v0.12 From fa7141288f0899b531d7dc94763423094be8608d Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 18 Oct 2017 16:04:13 +0000 Subject: Update RCFILE to PRJ_RCFILE. --- win/makefile.vc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/makefile.vc b/win/makefile.vc index 09b0b9f..675d8fc 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -174,7 +174,7 @@ PROJECT = tcl DEFAULT_BUILD_TARGET = release # We want to use our own resource file, not the standard template one. -RCFILE = tcl.rc +PRJ_RCFILE = tcl.rc # The rules.vc file does most of the hard work in terms of defining # the build configuration, macros, output directories etc. -- cgit v0.12 From 6f23316c4abdd3a5605d3aa6b558639095d75650 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Fri, 20 Oct 2017 15:32:22 +0000 Subject: Added test and shell targets. --- win/makefile.vc | 9 --------- win/rules.vc | 36 +++++++++++++++++++++++++++++++++--- win/targets.vc | 20 +++++++++++++++++++- 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 675d8fc..d09b187 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -485,19 +485,10 @@ setup: default-setup test: test-core test-pkgs test-core: setup $(TCLTEST) dlls $(CAT32) set TCL_LIBRARY=$(ROOT:\=/)/library -!if "$(OS)" == "Windows_NT" || "$(MSVCDIR)" == "IDE" $(DEBUGGER) $(TCLTEST) "$(ROOT:\=/)/tests/all.tcl" $(TESTFLAGS) -loadfile << package ifneeded dde 1.4.0 [list load "$(TCLDDELIB:\=/)" dde] package ifneeded registry 1.3.2 [list load "$(TCLREGLIB:\=/)" registry] << -!else - @echo Please wait while the tests are collected... - $(TCLTEST) "$(ROOT:\=/)/tests/all.tcl" $(TESTFLAGS) -loadfile << > tests.log - package ifneeded dde 1.4.0 "$(TCLDDELIB:\=/)" dde] - package ifneeded registry 1.3.2 "$(TCLREGLIB:\=/)" registry] -<< - type tests.log | more -!endif runtest: setup $(TCLTEST) dlls $(CAT32) set TCL_LIBRARY=$(ROOT:\=/)/library diff --git a/win/rules.vc b/win/rules.vc index 852b1eb..88b90e0 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -112,6 +112,7 @@ MKDIR = mkdir # DOCDIR - source directory containing documentation files # GENERICDIR - platform-independent source directory # WINDIR - Windows-specific source directory +# TESTDIR - directory containing test files # TOOLSDIR - directory containing build tools # _TCLDIR - root of the Tcl installation OR the Tcl sources. Not set # when building Tcl itself. @@ -146,8 +147,15 @@ GENERICDIR = $(ROOT)\generic !ifndef TOOLSDIR TOOLSDIR = $(ROOT)\tools !endif +!ifndef TESTDIR +TESTDIR = $(ROOT)\tests +!endif !ifndef LIBDIR +!if exist("$(ROOT)\library") LIBDIR = $(ROOT)\library +!else +LIBDIR = $(ROOT)\lib +!endif !endif !ifndef DEMODIR !if exist("$(LIBDIR)\demos") @@ -1265,7 +1273,9 @@ pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT) # # TBD - tclvfs has a comment that stubs libs should not be compiled with -GL # without stating why. Tcl itself compiled stubs libs with this flag. -# so we do not remove it from cflags. +# 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) # Link flags @@ -1387,12 +1397,12 @@ 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-html: +default-install-docs-html: @echo Installing documentation files to '$(DOC_INSTALL_DIR)' @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)" @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css") do @$(COPY) %f "$(DOC_INSTALL_DIR)" -default-install-man: +default-install-docs-n: @echo Installing documentation files to '$(DOC_INSTALL_DIR)' @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)" @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.n") do @$(COPY) %f "$(DOC_INSTALL_DIR)" @@ -1429,6 +1439,21 @@ default-setup: @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) +!if "$(TESTPAT)" != "" +TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT) +!endif + +default-test: default-setup $(PROJECT) + @set TCLLIBPATH=$(OUT_DIR:\=/) + @if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)" + cd "$(TESTDIR)" && $(DEBUGGER) $(TCLSH) all.tcl $(TESTFLAGS) + +default-shell: default-setup $(PROJECT) + @set TCLLIBPATH=$(OUT_DIR:\=/) + @if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)" + $(DEBUGGER) $(TCLSH) + +# Generation of Windows version resource !ifdef PRJ_RCFILE $(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc @@ -1485,6 +1510,11 @@ DISABLE_IMPLICIT_RULES = 0 # Implicit rule definitions - only for building library objects. For stubs and # main application, the master makefile should define explicit rules. +{$(ROOT)}.c{$(TMP_DIR)}.obj:: + $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< +$< +<< + {$(WINDIR)}.c{$(TMP_DIR)}.obj:: $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< $< diff --git a/win/targets.vc b/win/targets.vc index 56b6427..dbe4b82 100644 --- a/win/targets.vc +++ b/win/targets.vc @@ -1,6 +1,16 @@ #------------------------------------------------------------- -*- makefile -*- $(PROJECT): setup pkgindex $(PRJLIB) + +!ifdef PRJ_STUBOBJS +$(PROJECT): $(PRJSTUBLIB) +$(PRJSTUBLIB): $(PRJ_STUBOBJS) + $(MAKELIBCMD) $** + +$(PRJ_STUBOBJS): + $(cc32) $(stubscflags) -Fo$(TMP_DIR)\ %s +!endif + !ifdef PRJ_MANIFEST $(PROJECT): $(PRJLIB).manifest $(PRJLIB).manifest: $(PRJ_MANIFEST) @@ -9,6 +19,7 @@ $(PRJLIB).manifest: $(PRJ_MANIFEST) << !endif + !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 @@ -19,10 +30,17 @@ $(PRJLIB): $(PRJ_OBJS) $(RESFILE) -@del $*.exp !endif +!ifndef DISABLE_STANDARD_TARGETS +DISABLE_STANDARD_TARGETS = 0 +!endif + +!if !$(DISABLE_STANDARD_TARGETS) setup: default-setup install: default-install clean: default-clean realclean: hose hose: default-hose distclean: realclean default-distclean - +test: default-test +shell: default-shell +!endif -- cgit v0.12 From 7db056b75a847ee07e8c457304fec5b3c68bed4a Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sat, 21 Oct 2017 12:14:25 +0000 Subject: Fully qualify OUT_DIR and TMP_DIR paths so that the test target can change directories and not break relative paths to the built extension. --- win/makefile.vc | 7 ------- win/rules.vc | 24 ++++++++++++++++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index d09b187..2884aa3 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -158,13 +158,6 @@ #============================================================================== #------------------------------------------------------------------------------ -!if !exist("makefile.vc") -MSG = ^ -You must run this makefile only from the directory it is in.^ -Please `cd` to its location first. -!error $(MSG) -!endif - # The PROJECT macro is used by rules.vc for generating appropriate # macros and rules. PROJECT = tcl diff --git a/win/rules.vc b/win/rules.vc index 88b90e0..69f531e 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -70,6 +70,14 @@ PROJECT_REQUIRES_TK = 0 # changing them for consistency or clarity. # 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) @@ -538,7 +546,7 @@ DEBUGFLAGS = $(DEBUGFLAGS) -GZ # They are not passed through to the actual application / extension # link rules. !ifndef LINKER_TESTFLAGS -LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmhlp-out.txt +LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmakehlp.out !endif LINKERFLAGS = @@ -951,6 +959,17 @@ OUT_DIR = $(TMP_DIR) !endif !endif +# Relative paths -> absolute +!if [echo OUT_DIR = \> nmakehlp.out] \ + || [nmakehlp -Q "$(OUT_DIR)" >> nmakehlp.out] +!error *** Could not fully qualify path OUT_DIR=$(OUT_DIR) +!endif +!if [echo TMP_DIR = \>> nmakehlp.out] \ + || [nmakehlp -Q "$(TMP_DIR)" >> nmakehlp.out] +!error *** Could not fully qualify path TMP_DIR=$(TMP_DIR) +!endif +!include nmakehlp.out + # The name of the stubs library for the project being built STUBPREFIX = $(PROJECT)stub @@ -1400,7 +1419,7 @@ default-install-libraries: $(OUT_DIR)\pkgIndex.tcl default-install-docs-html: @echo Installing documentation files to '$(DOC_INSTALL_DIR)' @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)" - @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css") do @$(COPY) %f "$(DOC_INSTALL_DIR)" + @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css" "$(DOCDIR)\*.png") do @$(COPY) %f "$(DOC_INSTALL_DIR)" default-install-docs-n: @echo Installing documentation files to '$(DOC_INSTALL_DIR)' @@ -1418,6 +1437,7 @@ default-clean: @echo Cleaning $(WINDIR)\nmakehlp.obj, nmakehlp.exe ... @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)\_junk.pch ... @if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch @echo Cleaning $(WINDIR)\vercl.x, vercl.i ... -- cgit v0.12 From fe8915122a91a1f6a4ba0a1a3999ae673399b404 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 23 Oct 2017 13:53:51 +0000 Subject: Eliminate loimpact and tclalloc options. --- win/rules.vc | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 69f531e..6bdfa8a 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -573,8 +573,6 @@ LINKERFLAGS = $(LINKERFLAGS) -ltcg # MSVCRT - 1 -> link to dynamic C runtime even when building static Tcl build # 0 -> link to static C runtime for static Tcl build. # Does not impact shared Tcl builds (STATIC_BUILD == 0) -# LOIMPACT - 1 -> Ask Windows loader to aggressively trim the working set. -# Will reduce physical memory use at cost of performance. # TCL_USE_STATIC_PACKAGES - 1 -> statically link the registry and dde extensions # in the Tcl shell. 0 -> keep them as shared libraries # Does not impact shared Tcl builds. @@ -595,7 +593,6 @@ SYMBOLS = 0 PROFILE = 0 PGO = 0 MSVCRT = 1 -LOIMPACT = 0 TCL_USE_STATIC_PACKAGES = 0 USE_THREAD_ALLOC = 1 UNCHECKED = 0 @@ -681,10 +678,7 @@ PGO = 0 !endif !if [nmakehlp -f $(OPTS) "loimpact"] -!message *** Doing loimpact -LOIMPACT = 1 -!else -LOIMPACT = 0 +!message *** Warning: ignoring option "loimpact" - deprecated on modern Windows. !endif # TBD - should get rid of this option @@ -693,9 +687,8 @@ LOIMPACT = 0 USE_THREAD_ALLOC = 1 !endif -# TBD - should get rid of this option !if [nmakehlp -f $(OPTS) "tclalloc"] -!message *** Doing tclalloc +!error *** Option `tclalloc` is USE_THREAD_ALLOC = 0 !endif @@ -1332,10 +1325,6 @@ lflags = $(lflags) -opt:nowin98 !endif !endif -!if $(LOIMPACT) -lflags = $(lflags) -ws:aggressive -!endif - dlllflags = $(lflags) -dll conlflags = $(lflags) -subsystem:console guilflags = $(lflags) -subsystem:windows -- cgit v0.12 From ff1c34897080fdd52c75ac01a0e020d0e8e3c557 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 25 Oct 2017 02:59:46 +0000 Subject: Updated comments. --- win/makefile.vc | 134 +++++++++----------------------------------------------- 1 file changed, 20 insertions(+), 114 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 2884aa3..95161a8 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -1,6 +1,6 @@ #------------------------------------------------------------- -*- makefile -*- # -# Microsoft Visual C++ makefile for use with nmake +# Microsoft Visual C++ makefile for building Tcl with nmake # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -13,25 +13,13 @@ # Copyright (c) 2017 Ashok P. Nadkarni #------------------------------------------------------------------------------ -#------------------------------------------------------------------------------ -# HOW TO USE this makefile: -# -# 1) It is necessary to have the appropriate Visual C++ environment -# set up before invoking nmake. The steps required depend on which -# version of Visual Studio and/or the Windows SDK you are building -# against and are not described here. With Visual Studio, the simplest -# is to start a command shell using one of the installed short cuts. -# An alternative is to run vcvars32.bat, vcvars64.bat, vcvarsamd64_x86.bat -# etc. depending on the host and target architectures. If compiling -# with the Windows SDK instead, run (again depending on the SDK version) -# the setenv.bat or equivalent batch file from the command prompt. +# General usage: +# nmake [-nologo] -f makefile.vc [TARGET|MACRODEF [TARGET|MACRODEF] [...]] # -# NOTE: For older (Visual C++ 6 or the 2003 SDK), to use the Platform -# SDK (not expressly needed), run setenv.bat after -# vcvars32.bat according to the instructions for it. This can also -# turn on the 64-bit compiler, if your SDK has it. +# For MACRODEF, see TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) +# or examine Steps 6-8 in rules.vc. # -# 2) Targets are: +# Possible values of TARGET are: # release -- Builds the core, the shell and the dlls. (default) # dlls -- Just builds the windows extensions # shell -- Just builds the shell and the core. @@ -52,111 +40,29 @@ # have installed the HTML Help Compiler package from Microsoft # to produce the .chm file. # -# 3) Macros usable on the commandline: -# INSTALLDIR= -# Sets where to install Tcl from the built binaries. -# C:\Progra~1\Tcl is assumed when not specified. -# -# OPTS=loimpact,msvcrt,pdbs,profile,static,staticpkg,symbols,thrdalloc,tclalloc,unchecked,none -# Sets special options for the core. The default is for none. -# Any combination of the above may be used (comma separated). -# 'none' will over-ride everything to nothing. -# -# loimpact = Adds a flag for how NT treats the heap to keep memory -# in use, low. Said to impact alloc performance. -# msvcrt = Affects the static option only to switch it from -# using libcmt(d) as the C runtime [by default] to -# msvcrt(d). This is useful for static embedding -# support. -# pdbs = Build detached symbols for release builds. -# profile = Adds profiling hooks. Map file is assumed. -# static = Builds a static library of the core instead of a -# dll. The static library will contain the dde and reg -# extensions. External applications who want to use -# this, need to link with the stub library as well as -# the static Tcl library.The shell will be static (and -# large), as well. -# staticpkg = Affects the static option only to switch -# tclshXX.exe to have the dde and reg extension linked -# inside it. -# symbols = Debug build. Links to the debug C runtime, disables -# optimizations and creates pdb symbols files. -# thrdalloc = Use the thread allocator (shared global free pool) -# This is the default on threaded builds. -# tclalloc = Use the old non-thread allocator -# unchecked= Allows a symbols build to not use the debug -# enabled runtime (msvcrt.dll not msvcrtd.dll -# or libcmt.lib not libcmtd.lib). -# -# STATS=compdbg,memdbg,none -# Sets optional memory and bytecode compiler debugging code added -# to the core. The default is for none. Any combination of the -# above may be used (comma separated). 'none' will over-ride -# everything to nothing. -# -# compdbg = Enables byte compilation logging. -# memdbg = Enables the debugging memory allocator. -# -# CHECKS=64bit,fullwarn,nodep,none -# Sets special macros for checking compatibility. -# -# 64bit = Enable 64bit portability warnings (if available) -# fullwarn = Builds with full compiler and link warnings enabled. -# Very verbose. -# nodep = Turns off compatibility macros to ensure the core -# isn't being built with deprecated functions. -# -# MACHINE=(AMD64|IX86) -# Set the machine type used for the compiler, linker, and -# resource compiler. This hook is needed to tell the tools -# when alternate platforms are requested. THIS SHOULD NORMALLY -# NOT BE SET AS IT IS AUTOMATICALLY DETECTED BASED ON THE -# COMPILER IN USE. -# -# TMP_DIR= -# OUT_DIR= -# Hooks to allow the intermediate and output directories to be -# changed. $(OUT_DIR) is assumed to be -# .\(Release|Debug) based on if symbols are requested. -# $(TMP_DIR) will be $(OUT_DIR)\ by default. # -# TESTPAT= -# Reads the tests requested to be run from this file. +# The steps to setup a Visual C++ environment depend on which +# version of Visual Studio and/or the Windows SDK you are building +# against and are not described here. The simplest method is generally +# to start a command shell using one of the short cuts installed by +# Visual Studio/Windows SDK for the appropriate target architecture. # -# CFG_ENCODING=encoding -# name of encoding for configuration information. Defaults -# to cp1252 +# NOTE: For older (Visual C++ 6 or the 2003 SDK), to use the Platform +# SDK (not expressly needed), run setenv.bat after +# vcvars32.bat according to the instructions for it. This can also +# turn on the 64-bit compiler, if your SDK has it. # -# 4) Examples: -# -# Basic syntax of calling nmake looks like this: -# nmake [-nologo] -f makefile.vc [target|macrodef [target|macrodef] [...]] -# -# Standard (no frills) +# Examples: # c:\tcl_src\win\>nmake -f makefile.vc release +# c:\tcl_src\win\>nmake -f makefile.vc test # c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl -# -# With symbols in release builds # c:\tcl_src\win\>nmake -f makefile.vc release OPTS=pdbs -# -# Debug build # c:\tcl_src\win\>nmake -f makefile.vc release OPTS=symbols # -#------------------------------------------------------------------------------ -#============================================================================== -############################################################################### - -# //==================================================================\\ -# >>[ -> Do not modify below this line. <- ]<< -# >>[ Please, use the commandline macros to modify how Tcl is built. ]<< -# >>[ If you need more features, send us a patch for more macros. ]<< -# \\==================================================================// - - -############################################################################### -#============================================================================== -#------------------------------------------------------------------------------ +# NOTE: +# Before modifying this file, check whether the modification is applicable +# to building extensions as well and if so, modify rules.vc instead. # The PROJECT macro is used by rules.vc for generating appropriate # macros and rules. -- cgit v0.12 From c324bb3effc60b384c19e243194f0bd3a4a61b35 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Thu, 26 Oct 2017 15:07:16 +0000 Subject: Reworked build command macros (MAKEBINCMD, CCPKGCMD etc.) and purged old comments. --- win/makefile.vc | 40 ++++++++++++++--------- win/rules-ext.vc | 5 +++ win/rules.vc | 96 ++++++++++++++++++++++++++++++++++++++------------------ win/targets.vc | 19 ++++++++--- 4 files changed, 110 insertions(+), 50 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 95161a8..7759fc3 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -17,7 +17,7 @@ # nmake [-nologo] -f makefile.vc [TARGET|MACRODEF [TARGET|MACRODEF] [...]] # # For MACRODEF, see TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) -# or examine Steps 6-8 in rules.vc. +# or examine Sections 6-8 in rules.vc. # # Possible values of TARGET are: # release -- Builds the core, the shell and the dlls. (default) @@ -40,7 +40,6 @@ # have installed the HTML Help Compiler package from Microsoft # to produce the .chm file. # -# # The steps to setup a Visual C++ environment depend on which # version of Visual Studio and/or the Windows SDK you are building # against and are not described here. The simplest method is generally @@ -397,42 +396,53 @@ runshell: setup $(TCLSH) dlls set TCL_LIBRARY=$(ROOT:\=/)/library $(DEBUGGER) $(TCLSH) $(SCRIPT) -!if !$(STATIC_BUILD) -$(TCLIMPLIB): $(TCLLIB) -!endif +!if $(STATIC_BUILD) + +$(TCLLIB): $(TCLOBJS) + $(LIBCMD) @<< +$** +<< + +!else $(TCLLIB): $(TCLOBJS) - $(MAKEBINCMD) @<< + $(DLLCMD) @<< $** << $(_VC_MANIFEST_EMBED_DLL) +$(TCLIMPLIB): $(TCLLIB) + +!endif # $(STATIC_BUILD) + $(TCLSTUBLIB): $(TCLSTUBOBJS) - $(MAKELIBCMD) -nodefaultlib $(TCLSTUBOBJS) + $(LIBCMD) -nodefaultlib $(TCLSTUBOBJS) $(TCLSH): $(TCLSHOBJS) $(TCLSTUBLIB) $(TCLIMPLIB) - $(MAKECONCMD) -stack:2300000 $** + $(CONEXECMD) -stack:2300000 $** $(_VC_MANIFEST_EMBED_EXE) $(TCLTEST): $(TCLTESTOBJS) $(TCLSTUBLIB) $(TCLIMPLIB) - $(MAKECONCMD) -stack:2300000 $** + $(CONEXECMD) -stack:2300000 $** $(_VC_MANIFEST_EMBED_EXE) !if $(STATIC_BUILD) $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj + $(LIBCMD) $** !else $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLSTUBLIB) -!endif - $(MAKEBINCMD) $** + $(DLLCMD) $** $(_VC_MANIFEST_EMBED_DLL) +!endif !if $(STATIC_BUILD) $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj + $(LIBCMD) $** !else $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(TCLSTUBLIB) -!endif - $(MAKEBINCMD) $** + $(DLLCMD) $** $(_VC_MANIFEST_EMBED_DLL) +!endif pkgs: @for /d %d in ($(PKGSDIR)\*) do \ @@ -467,8 +477,8 @@ clean-pkgs: ) $(CAT32): $(WINDIR)\cat.c - $(cc32) $(cflags) $(crt) -DCONSOLE -Fo$(TMP_DIR)\ $? - $(MAKECONCMD) -stack:16384 $(TMP_DIR)\cat.obj + $(cc32) $(cflags) $(crt) -D_CRT_NONSTDC_NO_DEPRECATE -DCONSOLE -Fo$(TMP_DIR)\ $? + $(CONEXECMD) -stack:16384 $(TMP_DIR)\cat.obj $(_VC_MANIFEST_EMBED_EXE) #--------------------------------------------------------------------- diff --git a/win/rules-ext.vc b/win/rules-ext.vc index 97c11b4..e0a363c 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -1,5 +1,10 @@ +#------------------------------------------------------------- -*- 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 diff --git a/win/rules.vc b/win/rules.vc index 6bdfa8a..5e98d77 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1,8 +1,13 @@ #------------------------------------------------------------- -*- makefile -*- # rules.vc -- # -# Microsoft Visual C++ makefile include for decoding the commandline -# macros. This file does not need editing to build Tcl. +# Part of the nmake based build system for Tcl and its extensions. +# This file does all the hard work in terms of parsing build options, +# compiler switches, defining common targets and macros. The Tcl makefile +# directly includes this. Extensions include it via "rules-ext.vc". +# +# 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. @@ -16,6 +21,8 @@ _RULES_VC = 1 # The following macros define the version of the rules.vc nmake build system +# For modifications that are not backward-compatible, you *must* change +# the major version. RULES_VERSION_MAJOR = 1 RULES_VERSION_MINOR = 0 @@ -32,8 +39,21 @@ DOING_TCL = 1 DOING_TK = 1 !endif -!ifndef PROJECT_REQUIRES_TK -PROJECT_REQUIRES_TK = 0 +!ifndef NEED_TK +# Backwards compatibility +!ifdef PROJECT_REQUIRES_TK +NEED_TK = $(PROJECT_REQUIRES_TK) +!else +NEED_TK = 0 +!endif +!endif + +!ifndef NEED_TCL_SOURCE +NEED_TCL_SOURCE = 0 +!endif + +!ifndef NEED_TK_SOURCE +NEED_TK_SOURCE = 0 !endif ################################################################ @@ -266,7 +286,7 @@ Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and defa !endif # Now do the same to locate Tk headers and libs if project requires Tk -!if $(PROJECT_REQUIRES_TK) +!if $(NEED_TK) !ifdef TKDIR @@ -301,7 +321,24 @@ Failed to find tk.h. The TKDIR macro is set incorrectly or is not set and defaul !error $(MSG) !endif -!endif # PROJECT_REQUIRES_TK +!endif # NEED_TK + +!if $(NEED_TCL_SOURCE) && $(TCLINSTALL) +MSG = ^ +*** Warning: This extension requires the source distribution of Tcl.^ +*** Please set the TCLDIR macro to point to the Tcl sources. +!error $(MSG) +!endif + +!if $(NEED_TK_SOURCE) +!if $(TKINSTALL) +MSG = ^ +*** Warning: This extension requires the source distribution of Tk.^ +*** Please set the TKDIR macro to point to the Tk sources. +!error $(MSG) +!endif +!endif + # If INSTALLDIR set to tcl installation root dir then reset to the # lib dir for installing extensions @@ -1026,7 +1063,7 @@ TCLSH_NATIVE = $(TCLSH) !endif # Do the same for Tk and Tk extensions that require the Tk libraries -!if $(DOING_TK) || $(PROJECT_REQUIRES_TK) +!if $(DOING_TK) || $(NEED_TK) WISHNAMEPREFIX = wish WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe TKLIBNAME = $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT) @@ -1040,7 +1077,7 @@ TKIMPLIB = $(OUT_DIR)\$(TKIMPLIBNAME) TKLIB = $(OUT_DIR)\$(TKLIBNAME) TK_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)" -!else # effectively PROJECT_REQUIRES_TK +!else # effectively NEED_TK !if $(TKINSTALL) # Building against installed Tk WISH = $(_TKDIR)\bin\$(WISHNAME) @@ -1056,7 +1093,7 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)" !endif # $(DOING_TK) -!endif # $(DOING_TK) || $(PROJECT_REQUIRES_TK) +!endif # $(DOING_TK) || $(NEED_TK) # Various output paths PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib @@ -1158,7 +1195,7 @@ OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED # test targets in tk do not use stubs !if ! $(DOING_TCL) USE_STUBS_DEFS = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS -!if $(PROJECT_REQUIRES_TK) +!if $(NEED_TK) USE_STUBS_DEFS = $(USE_STUBS_DEFS) -DUSE_TK_STUBS !endif !endif @@ -1333,7 +1370,7 @@ guilflags = $(lflags) -subsystem:windows # Extensions should define any additional libraries with $(PRJ_LIBS) winlibs = kernel32.lib advapi32.lib -!if $(PROJECT_REQUIRES_TK) +!if $(NEED_TK) winlibs = $(winlibs) gdi32.lib user32.lib uxtheme.lib !endif @@ -1352,19 +1389,18 @@ baselibs = $(baselibs) ucrt.lib !endif ################################################################ -# 3. Define standard commands, common make targets and implicit rules +# 13. Define standard commands, common make targets and implicit rules -MAKELIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@ -MAKEDLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) +CCPKGCMD = $(cc32) $(pkgcflags) -Fo$(TMP_DIR)^\ +CCAPPCMD = $(cc32) $(appcflags) -Fo$(TMP_DIR)^\ +CCSTUBSCMD = $(cc32) $(stubscflags) -Fo$(TMP_DIR)^\ -!if $(STATIC_BUILD) -MAKEBINCMD = $(MAKELIBCMD) -!else -MAKEBINCMD = $(MAKEDLLCMD) -!endif -MAKECONCMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) -MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) -MAKERESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ +LIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@ +DLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) + +CONEXECMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) +GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) +RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ $(TCL_INCLUDES) \ -DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \ -DCOMMAVERSION=$(DOTVERSION:.=,),0 \ @@ -1466,7 +1502,7 @@ default-shell: default-setup $(PROJECT) !ifdef PRJ_RCFILE $(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc - $(MAKERESCMD) $** + $(RESCMD) $** !else # If parent makefile has not defined a resource definition file, @@ -1520,33 +1556,33 @@ DISABLE_IMPLICIT_RULES = 0 # main application, the master makefile should define explicit rules. {$(ROOT)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< + $(CCPKGCMD) @<< $< << {$(WINDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< + $(CCPKGCMD) @<< $< << {$(GENERICDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< + $(CCPKGCMD) @<< $< << {$(COMPATDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<< + $(CCPKGCMD) @<< $< << {$(RCDIR)}.rc{$(TMP_DIR)}.res: - $(MAKERESCMD) $< + $(RESCMD) $< {$(WINDIR)}.rc{$(TMP_DIR)}.res: - $(MAKERESCMD) $< + $(RESCMD) $< {$(TMP_DIR)}.rc{$(TMP_DIR)}.res: - $(MAKERESCMD) $< + $(RESCMD) $< .SUFFIXES: .SUFFIXES:.c .rc diff --git a/win/targets.vc b/win/targets.vc index dbe4b82..a345b4f 100644 --- a/win/targets.vc +++ b/win/targets.vc @@ -1,15 +1,21 @@ #------------------------------------------------------------- -*- makefile -*- +# targets.vc -- +# +# Part of the nmake based build system for Tcl and its extensions. +# This file defines some standard targets for the convenience of extensions +# and can be optionally included by the extension makefile. +# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for docs. $(PROJECT): setup pkgindex $(PRJLIB) !ifdef PRJ_STUBOBJS $(PROJECT): $(PRJSTUBLIB) $(PRJSTUBLIB): $(PRJ_STUBOBJS) - $(MAKELIBCMD) $** + $(LIBCMD) $** $(PRJ_STUBOBJS): - $(cc32) $(stubscflags) -Fo$(TMP_DIR)\ %s -!endif + $(CCSTUBSCMD) %s +!endif # PRJ_STUBOBJS !ifdef PRJ_MANIFEST $(PROJECT): $(PRJLIB).manifest @@ -19,13 +25,16 @@ $(PRJLIB).manifest: $(PRJ_MANIFEST) << !endif - !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) $(RESFILE) - $(MAKEBINCMD) $** +!if $(STATIC_BUILD) + $(LIBCMD) $** +!else + $(DLLCMD) $** +!endif $(_VC_MANIFEST_EMBED_DLL) -@del $*.exp !endif -- cgit v0.12 From 2318b70929448012d0488f26c5fc85fa1251aa41 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sat, 28 Oct 2017 17:18:58 +0000 Subject: Minor edits --- win/makefile.vc | 2 +- win/targets.vc | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 7759fc3..d7ea7ae 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -678,7 +678,7 @@ $(TMP_DIR)\tclTestObj.obj: $(GENERICDIR)\tclTestObj.c $(cc32) $(appcflags) -Fo$@ $? $(TMP_DIR)\tclWinTest.obj: $(WINDIR)\tclWinTest.c - $(cc32) $(appcflags) -Fo$@ $? + $(CCAPPCMD) $? $(TMP_DIR)\tclZlib.obj: $(GENERICDIR)\tclZlib.c $(cc32) $(pkgcflags) -I$(COMPATDIR)\zlib -Fo$@ $? diff --git a/win/targets.vc b/win/targets.vc index a345b4f..dd76908 100644 --- a/win/targets.vc +++ b/win/targets.vc @@ -26,16 +26,13 @@ $(PRJLIB).manifest: $(PRJ_MANIFEST) !endif !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) $(RESFILE) !if $(STATIC_BUILD) $(LIBCMD) $** !else $(DLLCMD) $** -!endif $(_VC_MANIFEST_EMBED_DLL) +!endif -@del $*.exp !endif -- cgit v0.12 From c7530621ad6451c1adfa3908a9019e7dd24e042a Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 7 Nov 2017 16:47:35 +0000 Subject: Fix inclusion of custom resource files to match TIP spec --- win/makefile.vc | 2 +- win/rules.vc | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index d7ea7ae..ff31e96 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -72,7 +72,7 @@ PROJECT = tcl DEFAULT_BUILD_TARGET = release # We want to use our own resource file, not the standard template one. -PRJ_RCFILE = tcl.rc +RCFILE = tcl.rc # The rules.vc file does most of the hard work in terms of defining # the build configuration, macros, output directories etc. diff --git a/win/rules.vc b/win/rules.vc index 5e98d77..a1c30e0 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -117,7 +117,6 @@ Visual C++ compiler environment not initialized. #---------------------------------------------------------- RMDIR = rmdir /S /Q -ERRNULL = 2>NUL CPY = xcopy /i /y >NUL CPYDIR = xcopy /e /i /y >NUL COPY = copy /y >NUL @@ -197,6 +196,7 @@ DEMODIR = $(ROOT)\demos # TBD - This is a potentially dangerous conflict, rename WINDIR to # something else WINDIR = $(ROOT)\win + !ifndef RCDIR !if exist("$(WINDIR)\rc") RCDIR = $(WINDIR)\rc @@ -388,7 +388,7 @@ VCVER=0 && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \ && ![echo ARCH=AMD64 >> vercl.x] \ && ![echo $(_HASH)endif >> vercl.x] \ - && ![$(cc32) -nologo -TC -P vercl.x $(ERRNULL)] + && ![$(cc32) -nologo -TC -P vercl.x 2>NUL] !include vercl.i !if $(VCVERSION) < 1900 !if ![echo VCVER= ^\> vercl.vc] \ @@ -402,7 +402,7 @@ VCVER = $(VCVERSION) !endif !endif -!if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc] +!if ![del 2>NUL /q/f vercl.x vercl.i vercl.vc] !endif #---------------------------------------------------------------- @@ -829,7 +829,7 @@ WARNINGS = $(WARNINGS) -Wp64 ################################################################ # 9. Extract various version numbers -# For Tcl and Tk, version numbers are exctracted from tcl.h and tk.h +# For Tcl and Tk, version numbers are extracted 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. @@ -1106,8 +1106,8 @@ PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME) # If extension parent makefile has not defined a resource definition file, # we will generate one from standard template. !if !$(DOING_TCL) && !$(DOING_TK) && !$(STATIC_BUILD) -!ifdef PRJ_RCFILE -RESFILE = $(TMP_DIR)\$(PRJ_RCFILE:.rc=.res) +!ifdef RCFILE +RESFILE = $(TMP_DIR)\$(RCFILE:.rc=.res) !else RESFILE = $(TMP_DIR)\$(PROJECT).res !endif @@ -1499,10 +1499,13 @@ default-shell: default-setup $(PROJECT) $(DEBUGGER) $(TCLSH) # Generation of Windows version resource -!ifdef PRJ_RCFILE +!ifdef RCFILE +# Note: don't use $** in below rule because there may be other dependencies +# and only the "master" rc must be passed to the resource compiler $(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc - $(RESCMD) $** + $(RESCMD) $(RCDIR)\$(PROJECT).rc + !else # If parent makefile has not defined a resource definition file, @@ -1545,7 +1548,7 @@ END << -!endif # ifdef PRJ_RCFILE +!endif # ifdef RCFILE !ifndef DISABLE_IMPLICIT_RULES DISABLE_IMPLICIT_RULES = 0 -- cgit v0.12 From ca86fd3219bf704113fa6abac8e5393fdbd38ca9 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 15 Nov 2017 07:54:08 +0000 Subject: Added default-install-stubs target. Make presence of nmake support files in extension directory optional (except for rules-ext.vc). This requires them to only build against a Tcl with the new nmake build system. --- win/rules-ext.vc | 24 ++++++++++++++---------- win/rules.vc | 5 +++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/win/rules-ext.vc b/win/rules-ext.vc index e0a363c..7de6055 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -1,10 +1,5 @@ -#------------------------------------------------------------- -*- 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 @@ -48,10 +43,13 @@ _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 +71,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 +84,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 +!endif !endif # _RULES_EXT_VC \ No newline at end of file diff --git a/win/rules.vc b/win/rules.vc index a1c30e0..fb35840 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1441,6 +1441,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)" -- cgit v0.12 From 0197a30845c7644fe45ca1a4ec1fc0b9c9ee0c20 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 15 Nov 2017 11:47:16 +0000 Subject: Include PKGNAMEFLAGS in stubscflags as some extension stubs use it --- win/rules.vc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/rules.vc b/win/rules.vc index fb35840..8db07bd 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1325,7 +1325,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 -- cgit v0.12 From c4d4363abd0a6d7f54d613ba0aa5c319c0d8bd36 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 15 Nov 2017 13:18:00 +0000 Subject: Loosen restriction on where rules-ext.vc file is located. --- win/rules-ext.vc | 22 ++++++++++++++++++---- win/rules.vc | 35 +++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/win/rules-ext.vc b/win/rules-ext.vc index 7de6055..ec84464 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -3,11 +3,25 @@ !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" diff --git a/win/rules.vc b/win/rules.vc index 8db07bd..586272d 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -52,7 +52,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 +95,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 +104,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 -- cgit v0.12 From 51319d2caea0e5bcc5b852171ddbc85901c6f845 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Fri, 17 Nov 2017 06:52:48 +0000 Subject: Add PRJ_PACKAGE_TCLNAME and other minor changes. Also: Change ifdef checks to check for empty string instead. Quote include paths. --- win/rules.vc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 586272d..425f873 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" @@ -250,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:/=\) @@ -269,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 @@ -307,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") @@ -1259,6 +1264,7 @@ COMPILERFLAGS = $(COMPILERFLAGS) /DUNICODE /D_UNICODE # Like the TEA system only set this non empty for non-Tk extensions !if !$(DOING_TCL) && !$(DOING_TK) PKGNAMEFLAGS = -DPACKAGE_NAME="\"$(PROJECT)\"" \ + -DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \ -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \ -DMODULE_SCOPE=extern !endif @@ -1312,7 +1318,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 @@ -1436,13 +1442,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_TCLNAME@ $(PRJ_PACKAGE_TCLNAME) @PKG_LIB_FILE@ $(PRJLIBNAME) << -- cgit v0.12 From 5560b9198b6cdd785cf9d82301a7fff87c0c8c1f Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Fri, 17 Nov 2017 07:05:23 +0000 Subject: Check for existence of targets.vc, not rules.vc to determine nmake support dir. --- win/rules-ext.vc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/win/rules-ext.vc b/win/rules-ext.vc index ec84464..abaaed6 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -45,13 +45,14 @@ _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 @@ -102,7 +103,7 @@ NMAKEHLPC = $(_RULESDIR)\nmakehlp.c !message *** Using $(_RULESDIR)\rules.vc !include "$(_RULESDIR)\rules.vc" !else -!error *** Could not locate rules.vc +!error *** Could not locate rules.vc in $(_RULESDIR) !endif !endif # _RULES_EXT_VC \ No newline at end of file -- cgit v0.12 From 42236b435fc3744a44500a2a63fd951f3c377afc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 17 Nov 2017 11:35:26 +0000 Subject: Fix ignore-glob versioned setting (something went wrong in previous merge). Also convert rules-ext.vc and targets.vc to CRLF line-endings. --- .fossil-settings/crlf-glob | 2 + .fossil-settings/crnl-glob | 2 + .fossil-settings/ignore-glob | 3 +- win/rules-ext.vc | 216 +++++++++++++++++++++---------------------- win/targets.vc | 104 ++++++++++----------- 5 files changed, 166 insertions(+), 161 deletions(-) diff --git a/.fossil-settings/crlf-glob b/.fossil-settings/crlf-glob index 2041cb6..56f3a03 100644 --- a/.fossil-settings/crlf-glob +++ b/.fossil-settings/crlf-glob @@ -12,6 +12,8 @@ win/buildall.vc.bat win/coffbase.txt win/makefile.vc win/rules.vc +win/rules-ext.vc +win/targets.vc win/tcl.dsp win/tcl.dsw win/tcl.hpj.in \ No newline at end of file diff --git a/.fossil-settings/crnl-glob b/.fossil-settings/crnl-glob index 2041cb6..56f3a03 100644 --- a/.fossil-settings/crnl-glob +++ b/.fossil-settings/crnl-glob @@ -12,6 +12,8 @@ win/buildall.vc.bat win/coffbase.txt win/makefile.vc win/rules.vc +win/rules-ext.vc +win/targets.vc win/tcl.dsp win/tcl.dsw win/tcl.hpj.in \ No newline at end of file diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob index d5c9a1e..c85b488 100644 --- a/.fossil-settings/ignore-glob +++ b/.fossil-settings/ignore-glob @@ -44,4 +44,5 @@ unix/pkgs/* win/Debug* win/Release* win/pkgs/* -win/tcl.hpjwin/nmhlp-out.txt +win/tcl.hpj +win/nmhlp-out.txt diff --git a/win/rules-ext.vc b/win/rules-ext.vc index abaaed6..3aba80d 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -1,109 +1,109 @@ -# This file should only be included in makefiles for Tcl extensions, -# NOT in the makefile for Tcl itself. - -!ifndef _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 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" -!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 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\targets.vc") # Building against Tcl sources -_RULESDIR = $(_RULESDIR)\win -!else -# 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. 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] \ - && [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 # if exist("rules.vc") - -!endif # if $(_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 - -!if exist("$(_RULESDIR)\rules.vc") -!message *** Using $(_RULESDIR)\rules.vc -!include "$(_RULESDIR)\rules.vc" -!else -!error *** Could not locate rules.vc in $(_RULESDIR) -!endif - +# This file should only be included in makefiles for Tcl extensions, +# NOT in the makefile for Tcl itself. + +!ifndef _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 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" +!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 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\targets.vc") # Building against Tcl sources +_RULESDIR = $(_RULESDIR)\win +!else +# 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. 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] \ + && [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 # if exist("rules.vc") + +!endif # if $(_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 + +!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/targets.vc b/win/targets.vc index dd76908..ca227d8 100644 --- a/win/targets.vc +++ b/win/targets.vc @@ -1,52 +1,52 @@ -#------------------------------------------------------------- -*- makefile -*- -# targets.vc -- -# -# Part of the nmake based build system for Tcl and its extensions. -# This file defines some standard targets for the convenience of extensions -# and can be optionally included by the extension makefile. -# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for docs. - -$(PROJECT): setup pkgindex $(PRJLIB) - -!ifdef PRJ_STUBOBJS -$(PROJECT): $(PRJSTUBLIB) -$(PRJSTUBLIB): $(PRJ_STUBOBJS) - $(LIBCMD) $** - -$(PRJ_STUBOBJS): - $(CCSTUBSCMD) %s -!endif # PRJ_STUBOBJS - -!ifdef PRJ_MANIFEST -$(PROJECT): $(PRJLIB).manifest -$(PRJLIB).manifest: $(PRJ_MANIFEST) - @nmakehlp -s << $** >$@ -@MACHINE@ $(MACHINE:IX86=X86) -<< -!endif - -!if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk" -$(PRJLIB): $(PRJ_OBJS) $(RESFILE) -!if $(STATIC_BUILD) - $(LIBCMD) $** -!else - $(DLLCMD) $** - $(_VC_MANIFEST_EMBED_DLL) -!endif - -@del $*.exp -!endif - -!ifndef DISABLE_STANDARD_TARGETS -DISABLE_STANDARD_TARGETS = 0 -!endif - -!if !$(DISABLE_STANDARD_TARGETS) -setup: default-setup -install: default-install -clean: default-clean -realclean: hose -hose: default-hose -distclean: realclean default-distclean -test: default-test -shell: default-shell -!endif +#------------------------------------------------------------- -*- makefile -*- +# targets.vc -- +# +# Part of the nmake based build system for Tcl and its extensions. +# This file defines some standard targets for the convenience of extensions +# and can be optionally included by the extension makefile. +# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for docs. + +$(PROJECT): setup pkgindex $(PRJLIB) + +!ifdef PRJ_STUBOBJS +$(PROJECT): $(PRJSTUBLIB) +$(PRJSTUBLIB): $(PRJ_STUBOBJS) + $(LIBCMD) $** + +$(PRJ_STUBOBJS): + $(CCSTUBSCMD) %s +!endif # PRJ_STUBOBJS + +!ifdef PRJ_MANIFEST +$(PROJECT): $(PRJLIB).manifest +$(PRJLIB).manifest: $(PRJ_MANIFEST) + @nmakehlp -s << $** >$@ +@MACHINE@ $(MACHINE:IX86=X86) +<< +!endif + +!if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk" +$(PRJLIB): $(PRJ_OBJS) $(RESFILE) +!if $(STATIC_BUILD) + $(LIBCMD) $** +!else + $(DLLCMD) $** + $(_VC_MANIFEST_EMBED_DLL) +!endif + -@del $*.exp +!endif + +!ifndef DISABLE_STANDARD_TARGETS +DISABLE_STANDARD_TARGETS = 0 +!endif + +!if !$(DISABLE_STANDARD_TARGETS) +setup: default-setup +install: default-install +clean: default-clean +realclean: hose +hose: default-hose +distclean: realclean default-distclean +test: default-test +shell: default-shell +!endif -- cgit v0.12 From 335305de9cd5835ff41ab2b95ca46360fe7257fc Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Fri, 17 Nov 2017 15:46:23 +0000 Subject: Added back nothreads option. --- win/rules.vc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 1351455..af39a94 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -704,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"] @@ -749,7 +754,6 @@ USE_THREAD_ALLOC = 1 !endif !if [nmakehlp -f $(OPTS) "tclalloc"] -!error *** Option `tclalloc` is USE_THREAD_ALLOC = 0 !endif -- cgit v0.12 From 9215c2610ca2f4938aa0947bcbd1ecd19a8e5009 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 21 Nov 2017 14:59:04 +0000 Subject: Drop Windows CE support, since it doesn't appear to work anyway. --- generic/tclIntPlatDecls.h | 2 ++ generic/tclStubInit.c | 2 -- win/tclWin32Dll.c | 24 ++++++++---------------- win/tclWinInit.c | 12 ++---------- win/tclWinInt.h | 13 ------------- win/tclWinPipe.c | 45 ++++++++++++++------------------------------- 6 files changed, 26 insertions(+), 72 deletions(-) diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h index ac06787..5003323 100644 --- a/generic/tclIntPlatDecls.h +++ b/generic/tclIntPlatDecls.h @@ -559,6 +559,8 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; # define TclWinGetServByName getservbyname # define TclWinGetSockOpt getsockopt # define TclWinSetSockOpt setsockopt +# undef TclWinGetPlatformId +# define TclWinGetPlatformId() (2) /* VER_PLATFORM_WIN32_NT */ #else # undef TclpGetPid # define TclpGetPid(pid) ((unsigned long) (pid)) diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index b185f04..465dacc 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -118,8 +118,6 @@ TclpIsAtty(int fd) static int TclWinGetPlatformId() { - /* Don't bother to determine the real platform on cygwin, - * because VER_PLATFORM_WIN32_NT is the only supported platform */ return 2; /* VER_PLATFORM_WIN32_NT */; } diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index 84c7a97..e482869 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -23,7 +23,6 @@ */ static HINSTANCE hInstance; /* HINSTANCE of this DLL. */ -static int platformId; /* Running under NT, or 95/98? */ /* * VC++ 5.x has no 'cpuid' assembler instruction, so we must emulate it @@ -186,18 +185,14 @@ TclWinInit( hInstance = hInst; os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); GetVersionExW(&os); - platformId = os.dwPlatformId; /* - * We no longer support Win32s or Win9x, so just in case someone manages - * to get a runtime there, make sure they know that. + * We no longer support Win32s or Win9x or Windows CE, so just in case + * someone manages to get a runtime there, make sure they know that. */ - if (platformId == VER_PLATFORM_WIN32s) { - Tcl_Panic("Win32s is not a supported platform"); - } - if (platformId == VER_PLATFORM_WIN32_WINDOWS) { - Tcl_Panic("Windows 9x is not a supported platform"); + if (os.dwPlatformId != VER_PLATFORM_WIN32_NT) { + Tcl_Panic("Windows NT is the only supported platform"); } TclWinResetInterfaces(); @@ -212,22 +207,19 @@ TclWinInit( * conditional code. * * Results: - * The return value is one of: - * VER_PLATFORM_WIN32s Win32s on Windows 3.1 (not supported) - * VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95, 98, ME (not supported) - * VER_PLATFORM_WIN32_NT Win32 on Windows NT, 2000, XP - * VER_PLATFORM_WIN32_CE Win32 on Windows CE + * The return value is: + * VER_PLATFORM_WIN32_NT Win32 on Windows NT, 2000, XP, 7, 8, 8.1, 10 * * Side effects: * None. * *---------------------------------------------------------------------- */ - +#undef TclWinGetPlatformId int TclWinGetPlatformId(void) { - return platformId; + return VER_PLATFORM_WIN32_NT; } /* diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 98c7ed5..ec5582c 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -84,15 +84,10 @@ TclWinProcs tclWinProcs; /* * The following arrays contain the human readable strings for the Windows - * platform and processor values. + * processor values. */ -#define NUMPLATFORMS 4 -static const char *const platforms[NUMPLATFORMS] = { - "Win32s", "Windows 95", "Windows NT", "Windows CE" -}; - #define NUMPROCESSORS 11 static const char *const processors[NUMPROCESSORS] = { "intel", "mips", "alpha", "ppc", "shx", "arm", "ia64", "alpha64", "msil", @@ -568,10 +563,7 @@ TclpSetVariables( Tcl_SetVar2(interp, "tcl_platform", "platform", "windows", TCL_GLOBAL_ONLY); - if (osInfo.dwPlatformId < NUMPLATFORMS) { - Tcl_SetVar2(interp, "tcl_platform", "os", - platforms[osInfo.dwPlatformId], TCL_GLOBAL_ONLY); - } + Tcl_SetVar2(interp, "tcl_platform", "os", "Windows NT", TCL_GLOBAL_ONLY); wsprintfA(buffer, "%d.%d", osInfo.dwMajorVersion, osInfo.dwMinorVersion); Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY); if (sys.oemId.wProcessorArchitecture < NUMPROCESSORS) { diff --git a/win/tclWinInt.h b/win/tclWinInt.h index 43799d0..d72cc43 100644 --- a/win/tclWinInt.h +++ b/win/tclWinInt.h @@ -40,19 +40,6 @@ typedef struct TclWinProcs { MODULE_SCOPE TclWinProcs tclWinProcs; -/* - * Some versions of Borland C have a define for the OSVERSIONINFO for - * Win32s and for NT, but not for Windows 95. - * Define VER_PLATFORM_WIN32_CE for those without newer headers. - */ - -#ifndef VER_PLATFORM_WIN32_WINDOWS -#define VER_PLATFORM_WIN32_WINDOWS 1 -#endif -#ifndef VER_PLATFORM_WIN32_CE -#define VER_PLATFORM_WIN32_CE 3 -#endif - #ifdef _WIN64 # define TCL_I_MODIFIER "I" #else diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 4b372a5..b4812ee 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -1095,40 +1095,23 @@ TclpCreateProcess( * detached processes. The GUI window will still pop up to the foreground. */ - if (TclWinGetPlatformId() == VER_PLATFORM_WIN32_NT) { - if (HasConsole()) { + if (HasConsole()) { createFlags = 0; - } else if (applType == APPL_DOS) { - /* - * Under NT, 16-bit DOS applications will not run unless they can - * be attached to a console. If we are running without a console, - * run the 16-bit program as an normal process inside of a hidden - * console application, and then run that hidden console as a - * detached process. - */ + } else if (applType == APPL_DOS) { + /* + * Under NT, 16-bit DOS applications will not run unless they can + * be attached to a console. If we are running without a console, + * run the 16-bit program as an normal process inside of a hidden + * console application, and then run that hidden console as a + * detached process. + */ - startInfo.wShowWindow = SW_HIDE; - startInfo.dwFlags |= STARTF_USESHOWWINDOW; - createFlags = CREATE_NEW_CONSOLE; - TclDStringAppendLiteral(&cmdLine, "cmd.exe /c"); - } else { - createFlags = DETACHED_PROCESS; - } + startInfo.wShowWindow = SW_HIDE; + startInfo.dwFlags |= STARTF_USESHOWWINDOW; + createFlags = CREATE_NEW_CONSOLE; + TclDStringAppendLiteral(&cmdLine, "cmd.exe /c"); } else { - if (HasConsole()) { - createFlags = 0; - } else { - createFlags = DETACHED_PROCESS; - } - - if (applType == APPL_DOS) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "DOS application process not supported on this platform", - -1)); - Tcl_SetErrorCode(interp, "TCL", "OPERATION", "EXEC", "DOS_APP", - NULL); - goto end; - } + createFlags = DETACHED_PROCESS; } /* -- cgit v0.12 From dd0e9cf6b16cf0a4331b972cb7fac3786644587d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 23 Nov 2017 12:04:33 +0000 Subject: Remove more pre-XP stuff. --- generic/tclStubInit.c | 14 ++--- win/configure | 138 ++------------------------------------------------ win/tcl.m4 | 108 ++------------------------------------- win/tclWin32Dll.c | 24 --------- 4 files changed, 13 insertions(+), 271 deletions(-) diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 1c11c61..808f5d3 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -105,6 +105,13 @@ static const char *TclGetStartupScriptFileName(void) static unsigned short TclWinNToHS(unsigned short ns) { return ntohs(ns); } +#undef TclWinGetPlatformId +#define TclWinGetPlatformId winGetPlatformId +static int +TclWinGetPlatformId() +{ + return 2; /* VER_PLATFORM_WIN32_NT */; +} #endif # define TclBNInitBignumFromWideUInt TclInitBignumFromWideUInt # define TclBNInitBignumFromWideInt TclInitBignumFromWideInt @@ -132,13 +139,6 @@ TclpIsAtty(int fd) return isatty(fd); } -#define TclWinGetPlatformId winGetPlatformId -static int -TclWinGetPlatformId() -{ - return 2; /* VER_PLATFORM_WIN32_NT */; -} - void *TclWinGetTclInstance() { void *hInstance = NULL; diff --git a/win/configure b/win/configure index fdd3adb..0ef82a5 100755 --- a/win/configure +++ b/win/configure @@ -706,7 +706,6 @@ CFLAGS_WARNING CFLAGS_OPTIMIZE CFLAGS_DEBUG DL_LIBS -CELIB_DIR CYGPATH TCL_THREADS SET_MAKE @@ -768,8 +767,6 @@ enable_threads with_encoding enable_shared enable_64bit -enable_wince -with_celib enable_symbols enable_embedded_manifest ' @@ -1392,7 +1389,6 @@ Optional Features: --enable-threads build with threads (default: on) --enable-shared build and link with shared libraries (default: on) --enable-64bit enable 64bit support (where applicable) - --enable-wince enable Win/CE support (where applicable) --enable-symbols build with debugging symbols (default: off) --enable-embedded-manifest embed manifest if possible (default: yes) @@ -1401,7 +1397,6 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-encoding encoding for configuration values - --with-celib=DIR use Windows/CE support library from DIR Some influential environment variables: CC C compiler command @@ -3811,33 +3806,6 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $do64bit" >&5 $as_echo "$do64bit" >&6; } - # Cross-compiling options for Windows/CE builds - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Windows/CE build is requested" >&5 -$as_echo_n "checking if Windows/CE build is requested... " >&6; } - # Check whether --enable-wince was given. -if test "${enable_wince+set}" = set; then : - enableval=$enable_wince; doWince=$enableval -else - doWince=no -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $doWince" >&5 -$as_echo "$doWince" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Windows/CE celib directory" >&5 -$as_echo_n "checking for Windows/CE celib directory... " >&6; } - -# Check whether --with-celib was given. -if test "${with_celib+set}" = set; then : - withval=$with_celib; CELIB_DIR=$withval -else - CELIB_DIR=NO_CELIB -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CELIB_DIR" >&5 -$as_echo "$CELIB_DIR" >&6; } - # Set some defaults (may get changed below) EXTRA_CFLAGS="" @@ -4112,7 +4080,7 @@ $as_echo_n "checking compiler flags... " >&6; } SHLIB_LD_LIBS='${LIBS}' LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32" # mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't - LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32" + LIBS_GUI="-luxtheme -lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32" STLIB_LD='${AR} cr' RC_OUT=-o RC_TYPE= @@ -4336,107 +4304,7 @@ fi LINKBIN="link" fi - if test "$doWince" != "no" ; then - # Set defaults for common evc4/PPC2003 setup - # Currently Tcl requires 300+, possibly 420+ for sockets - CEVERSION=420; # could be 211 300 301 400 420 ... - TARGETCPU=ARMV4; # could be ARMV4 ARM MIPS SH3 X86 ... - ARCH=ARM; # could be ARM MIPS X86EM ... - PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002" - if test "$doWince" != "yes"; then - # If !yes then the user specified something - # Reset ARCH to allow user to skip specifying it - ARCH= - eval `echo $doWince | awk -F "," '{ \ - if (length($1)) { printf "CEVERSION=\"%s\"\n", $1; \ - if ($1 < 400) { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \ - if (length($2)) { printf "TARGETCPU=\"%s\"\n", toupper($2) }; \ - if (length($3)) { printf "ARCH=\"%s\"\n", toupper($3) }; \ - if (length($4)) { printf "PLATFORM=\"%s\"\n", $4 }; \ - }'` - if test "x${ARCH}" = "x" ; then - ARCH=$TARGETCPU; - fi - fi - OSVERSION=WCE$CEVERSION; - if test "x${WCEROOT}" = "x" ; then - WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0" - if test ! -d "${WCEROOT}" ; then - WCEROOT="C:/Program Files/Microsoft eMbedded Tools" - fi - fi - if test "x${SDKROOT}" = "x" ; then - SDKROOT="C:/Program Files/Windows CE Tools" - if test ! -d "${SDKROOT}" ; then - SDKROOT="C:/Windows CE Tools" - fi - fi - # The space-based-path will work for the Makefile, but will - # not work if AC_TRY_COMPILE is called. - WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'` - SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'` - CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'` - if test ! -d "${CELIB_DIR}/inc"; then - as_fn_error $? "Invalid celib directory \"${CELIB_DIR}\"" "$LINENO" 5 - fi - if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"\ - -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then - as_fn_error $? "could not find PocketPC SDK or target compiler to enable WinCE mode $CEVERSION,$TARGETCPU,$ARCH,$PLATFORM" "$LINENO" 5 - else - CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include" - if test -d "${CEINCLUDE}/${TARGETCPU}" ; then - CEINCLUDE="${CEINCLUDE}/${TARGETCPU}" - fi - CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" - fi - fi - - if test "$doWince" != "no" ; then - CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin" - if test "${TARGETCPU}" = "X86"; then - CC="${CEBINROOT}/cl.exe" - else - CC="${CEBINROOT}/cl${ARCH}.exe" - fi - CC="\"${CC}\" -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\"" - RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\"" - arch=`echo ${ARCH} | awk '{print tolower($0)}'` - defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _DLL _WINDOWS" - for i in $defs ; do - cat >>confdefs.h <<_ACEOF -#define $i 1 -_ACEOF - - done -# if test "${ARCH}" = "X86EM"; then -# AC_DEFINE_UNQUOTED(_WIN32_WCE_EMULATION) -# fi - cat >>confdefs.h <<_ACEOF -#define _WIN32_WCE $CEVERSION -_ACEOF - - cat >>confdefs.h <<_ACEOF -#define UNDER_CE $CEVERSION -_ACEOF - - CFLAGS_DEBUG="-nologo -Zi -Od" - CFLAGS_OPTIMIZE="-nologo -O2" - lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'` - lflags="-nodefaultlib -MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo" - LINKBIN="\"${CEBINROOT}/link.exe\"" - - if test "${CEVERSION}" -lt 400 ; then - LIBS="coredll.lib corelibc.lib winsock.lib" - else - LIBS="coredll.lib corelibc.lib ws2.lib" - fi - # celib currently stuck at wce300 status - #LIBS="$LIBS \${CELIB_DIR}/wince-${ARCH}-pocket-${OSVERSION}-release/celib.lib" - LIBS="$LIBS \"\${CELIB_DIR}/wince-${ARCH}-pocket-wce300-release/celib.lib\"" - LIBS_GUI="commctrl.lib commdlg.lib" - else - LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib" - fi + LIBS_GUI="gdi32.lib uxtheme.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib" SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}" SHLIB_LD_LIBS='${LIBS}' @@ -4467,7 +4335,7 @@ _ACEOF # Specify linker flags depending on the type of app being # built -- Console vs. Window. - if test "$doWince" != "no" -a "${TARGETCPU}" != "X86"; then + if test "${TARGETCPU}" != "X86"; then LDFLAGS_CONSOLE="-link ${lflags}" LDFLAGS_WINDOW=${LDFLAGS_CONSOLE} else diff --git a/win/tcl.m4 b/win/tcl.m4 index b4fbcce..075cc47 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -544,17 +544,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AC_ARG_ENABLE(64bit,[ --enable-64bit enable 64bit support (where applicable)], [do64bit=$enableval], [do64bit=no]) AC_MSG_RESULT($do64bit) - # Cross-compiling options for Windows/CE builds - - AC_MSG_CHECKING([if Windows/CE build is requested]) - AC_ARG_ENABLE(wince,[ --enable-wince enable Win/CE support (where applicable)], [doWince=$enableval], [doWince=no]) - AC_MSG_RESULT($doWince) - - AC_MSG_CHECKING([for Windows/CE celib directory]) - AC_ARG_WITH(celib,[ --with-celib=DIR use Windows/CE support library from DIR], - CELIB_DIR=$withval, CELIB_DIR=NO_CELIB) - AC_MSG_RESULT([$CELIB_DIR]) - # Set some defaults (may get changed below) EXTRA_CFLAGS="" AC_DEFINE(MODULE_SCOPE, [extern], [No need to mark inidividual symbols as hidden]) @@ -675,7 +664,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ SHLIB_LD_LIBS='${LIBS}' LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32" # mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't - LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32" + LIBS_GUI="-luxtheme -lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32" STLIB_LD='${AR} cr' RC_OUT=-o RC_TYPE= @@ -871,98 +860,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ LINKBIN="link" fi - if test "$doWince" != "no" ; then - # Set defaults for common evc4/PPC2003 setup - # Currently Tcl requires 300+, possibly 420+ for sockets - CEVERSION=420; # could be 211 300 301 400 420 ... - TARGETCPU=ARMV4; # could be ARMV4 ARM MIPS SH3 X86 ... - ARCH=ARM; # could be ARM MIPS X86EM ... - PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002" - if test "$doWince" != "yes"; then - # If !yes then the user specified something - # Reset ARCH to allow user to skip specifying it - ARCH= - eval `echo $doWince | awk -F "," '{ \ - if (length([$]1)) { printf "CEVERSION=\"%s\"\n", [$]1; \ - if ([$]1 < 400) { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \ - if (length([$]2)) { printf "TARGETCPU=\"%s\"\n", toupper([$]2) }; \ - if (length([$]3)) { printf "ARCH=\"%s\"\n", toupper([$]3) }; \ - if (length([$]4)) { printf "PLATFORM=\"%s\"\n", [$]4 }; \ - }'` - if test "x${ARCH}" = "x" ; then - ARCH=$TARGETCPU; - fi - fi - OSVERSION=WCE$CEVERSION; - if test "x${WCEROOT}" = "x" ; then - WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0" - if test ! -d "${WCEROOT}" ; then - WCEROOT="C:/Program Files/Microsoft eMbedded Tools" - fi - fi - if test "x${SDKROOT}" = "x" ; then - SDKROOT="C:/Program Files/Windows CE Tools" - if test ! -d "${SDKROOT}" ; then - SDKROOT="C:/Windows CE Tools" - fi - fi - # The space-based-path will work for the Makefile, but will - # not work if AC_TRY_COMPILE is called. - WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'` - SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'` - CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'` - if test ! -d "${CELIB_DIR}/inc"; then - AC_MSG_ERROR([Invalid celib directory "${CELIB_DIR}"]) - fi - if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}"\ - -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then - AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]]) - else - CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include" - if test -d "${CEINCLUDE}/${TARGETCPU}" ; then - CEINCLUDE="${CEINCLUDE}/${TARGETCPU}" - fi - CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" - fi - fi - - if test "$doWince" != "no" ; then - CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin" - if test "${TARGETCPU}" = "X86"; then - CC="${CEBINROOT}/cl.exe" - else - CC="${CEBINROOT}/cl${ARCH}.exe" - fi - CC="\"${CC}\" -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\"" - RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\"" - arch=`echo ${ARCH} | awk '{print tolower([$]0)}'` - defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _DLL _WINDOWS" - for i in $defs ; do - AC_DEFINE_UNQUOTED($i) - done -# if test "${ARCH}" = "X86EM"; then -# AC_DEFINE_UNQUOTED(_WIN32_WCE_EMULATION) -# fi - AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION) - AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION) - CFLAGS_DEBUG="-nologo -Zi -Od" - CFLAGS_OPTIMIZE="-nologo -O2" - lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'` - lflags="-nodefaultlib -MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo" - LINKBIN="\"${CEBINROOT}/link.exe\"" - AC_SUBST(CELIB_DIR) - if test "${CEVERSION}" -lt 400 ; then - LIBS="coredll.lib corelibc.lib winsock.lib" - else - LIBS="coredll.lib corelibc.lib ws2.lib" - fi - # celib currently stuck at wce300 status - #LIBS="$LIBS \${CELIB_DIR}/wince-${ARCH}-pocket-${OSVERSION}-release/celib.lib" - LIBS="$LIBS \"\${CELIB_DIR}/wince-${ARCH}-pocket-wce300-release/celib.lib\"" - LIBS_GUI="commctrl.lib commdlg.lib" - else - LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib" - fi + LIBS_GUI="gdi32.lib uxtheme.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib" SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}" SHLIB_LD_LIBS='${LIBS}' @@ -993,7 +891,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ # Specify linker flags depending on the type of app being # built -- Console vs. Window. - if test "$doWince" != "no" -a "${TARGETCPU}" != "X86"; then + if test "${TARGETCPU}" != "X86"; then LDFLAGS_CONSOLE="-link ${lflags}" LDFLAGS_WINDOW=${LDFLAGS_CONSOLE} else diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index 74e1d00..95b8193 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -199,30 +199,6 @@ TclWinInit( } /* - *---------------------------------------------------------------------- - * - * TclWinGetPlatformId -- - * - * Determines whether running under NT, 95, or Win32s, to allow runtime - * conditional code. - * - * Results: - * The return value is: - * VER_PLATFORM_WIN32_NT Win32 on Windows NT, 2000, XP, 7, 8, 8.1, 10 - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ -#undef TclWinGetPlatformId -int -TclWinGetPlatformId(void) -{ - return VER_PLATFORM_WIN32_NT; -} - -/* *------------------------------------------------------------------------- * * TclWinNoBackslash -- -- cgit v0.12 From 160a58238a314e252d6155d20c097f56f1e7738e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 23 Nov 2017 12:21:35 +0000 Subject: If compiled with -DTCL_NO_DEPRECATED, remove stub entry for TclWinGetPlatformId() --- generic/tclStubInit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 808f5d3..355cb90 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -69,6 +69,7 @@ static int TclSockMinimumBuffersOld(int sock, int size) # define TclWinGetSockOpt 0 # define TclWinSetSockOpt 0 # define TclWinNToHS 0 +# define TclWinGetPlatformId 0 # define TclBNInitBignumFromWideUInt 0 # define TclBNInitBignumFromWideInt 0 # define TclBNInitBignumFromLong 0 @@ -101,17 +102,22 @@ static const char *TclGetStartupScriptFileName(void) #if defined(_WIN32) || defined(__CYGWIN__) #undef TclWinNToHS +#undef TclWinGetPlatformId +#ifndef TCL_NO_DEPRECATED #define TclWinNToHS winNToHS static unsigned short TclWinNToHS(unsigned short ns) { return ntohs(ns); } -#undef TclWinGetPlatformId #define TclWinGetPlatformId winGetPlatformId static int TclWinGetPlatformId() { return 2; /* VER_PLATFORM_WIN32_NT */; } +#else +#define TclWinNToHS 0 +#define TclWinGetPlatformId 0 +#endif #endif # define TclBNInitBignumFromWideUInt TclInitBignumFromWideUInt # define TclBNInitBignumFromWideInt TclInitBignumFromWideInt -- cgit v0.12 From 3e34d38b2d69b07bcdaf25c2935b750d829b4afb Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 5 Dec 2017 14:29:47 +0000 Subject: Use PRJ_PACKAGE_TCLNAME instead of PROJECT when generating TEA based pkgindex --- win/rules.vc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index af39a94..9b917b6 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1266,8 +1266,10 @@ 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 @@ -1459,7 +1461,7 @@ default-pkgindex: 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) << -- cgit v0.12 From bb1c5fe83355d454d63db62da5797204c6cec06e Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 6 Dec 2017 13:02:32 +0000 Subject: [ce3a211dcb] Failed file normalize when tail is empty string. --- generic/tclPathObj.c | 5 ++--- tests/fileSystem.test | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index a306853..87ddfb7 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -1869,7 +1869,6 @@ Tcl_FSGetNormalizedPath( */ (void) Tcl_GetStringFromObj(dir, &cwdLen); - cwdLen += (Tcl_GetString(copy)[cwdLen] == '/'); /* Normalize the combined string. */ @@ -1890,13 +1889,13 @@ Tcl_FSGetNormalizedPath( * to a normalized head, we can more efficiently normalize the * combined path by passing over only the unnormalized tail * portion. When this is sufficient, prior developers claim - * this should be much faster. We use 'cwdLen-1' so that we are + * this should be much faster. We use 'cwdLen' so that we are * already pointing at the dir-separator that we know about. * The normalization code will actually start off directly * after that separator. */ - TclFSNormalizeToUniquePath(interp, copy, cwdLen-1); + TclFSNormalizeToUniquePath(interp, copy, cwdLen); } /* Now we need to construct the new path object. */ diff --git a/tests/fileSystem.test b/tests/fileSystem.test index d34de8f..1c507e1 100644 --- a/tests/fileSystem.test +++ b/tests/fileSystem.test @@ -508,6 +508,22 @@ test filesystem-1.52.1 {bug f9f390d0fa: file join where strep is not canonical} file normalize $x file join $x } -result /foo +test filesystem-1.53 {[Bug 3559678] - normalize when tail is empty} { + string match */ [file normalize [lindex [glob -dir [pwd] {{}}] 0]] +} 0 +test filesystem-1.54 {[Bug ce3a211dcb] - normalize when tail is empty} -setup { + set save [pwd] + cd [set home [makeDirectory ce3a211dcb]] + makeDirectory A $home + cd [lindex [glob */] 0] +} -body { + string match */A [pwd] +} -cleanup { + cd $home + removeDirectory A $home + cd $save + removeDirectory ce3a211dcb +} -result 1 test filesystem-2.0 {new native path} {unix} { foreach f [lsort [glob -nocomplain /usr/bin/c*]] { -- cgit v0.12 From 21877b851cd37a74cf2bff60aeea082cdfa0bafd Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 6 Dec 2017 13:28:12 +0000 Subject: Adapt the bytearray accommodation of Tcl_CharLength() for 8.7+. --- generic/tclStringObj.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 85cac83..385ce4f 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -421,13 +421,14 @@ Tcl_GetCharLength( * Optimize the case where we're really dealing with a bytearray object; * we don't need to convert to a string to perform the get-length operation. * - * NOTE that we do not need the bytearray to be "pure". A ByteArray value - * with a string rep cannot be trusted to represent the same value as the - * string rep, but it *can* be trusted to have the same character length - * as the string rep, which is all this routine cares about. + * Starting in Tcl 8.7, we check for a "pure" bytearray, because the + * machinery behind that test is using a proper bytearray ObjType. We + * could also compute length of an improper bytearray without shimmering + * but there's no value in that. We *want* to shimmer an improper bytearray + * because improper bytearrays have worthless internal reps. */ - if (objPtr->typePtr == &tclByteArrayType) { + if (TclIsPureByteArray(objPtr)) { int length; (void) Tcl_GetByteArrayFromObj(objPtr, &length); -- cgit v0.12 From cf3348e41cba5b0d82271b5cd6f54df9912300a7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 6 Dec 2017 16:04:22 +0000 Subject: (cherry-pick from core-8-6-8-rc): Duplicate test names --- tests/scan.test | 2 +- tests/utf.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scan.test b/tests/scan.test index b36b412..98c581b 100644 --- a/tests/scan.test +++ b/tests/scan.test @@ -553,7 +553,7 @@ test scan-5.18 {bigint scanning underflow} -setup { list [scan "-207698809136909011942886895" \ %llu a] $a } -returnCodes 1 -result {unsigned bignum scans are invalid} -test scan-5.18 {bigint scanning invalid} -setup { +test scan-5.19 {bigint scanning invalid} -setup { set a {}; } -body { list [scan "207698809136909011942886895" \ diff --git a/tests/utf.test b/tests/utf.test index d0fa7be..95775a8 100644 --- a/tests/utf.test +++ b/tests/utf.test @@ -124,7 +124,7 @@ test utf-4.10 {Tcl_NumUtfChars: #u0000, calc len, overcomplete} {testnumutfchars test utf-5.1 {Tcl_UtfFindFirst} {testfindfirst testbytestring} { testfindfirst [testbytestring "abcbc"] 98 } {bcbc} -test utf-5.1 {Tcl_UtfFindLast} {testfindlast testbytestring} { +test utf-5.2 {Tcl_UtfFindLast} {testfindlast testbytestring} { testfindlast [testbytestring "abcbc"] 98 } {bc} -- cgit v0.12 From 9ba4b4f90141907cd56d190574d5b1906fbbe23a Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 6 Dec 2017 19:57:59 +0000 Subject: [0e4d88b650] Added enough refcounting to stop `make valgrind` complaints about "Invalid read". This is not a complete fix. Things are still broken. A working system of Namespace lifetime management looks like an 8.7 project. --- generic/tclBasic.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index acdcf41..79de61e 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -3112,6 +3112,7 @@ Tcl_DeleteCommandFromToken( * traces. */ + cmdPtr->nsPtr->refCount++; if (cmdPtr->tracePtr != NULL) { CommandTrace *tracePtr; CallCommandTraces(iPtr,cmdPtr,NULL,NULL,TCL_TRACE_DELETE); @@ -3139,6 +3140,7 @@ Tcl_DeleteCommandFromToken( */ TclInvalidateNsCmdLookup(cmdPtr->nsPtr); + TclNsDecrRefCount(cmdPtr->nsPtr); /* * If the command being deleted has a compile function, increment the -- cgit v0.12 From cd525c7bb12f0758dcb87189fdb884697806cef7 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 6 Dec 2017 20:44:32 +0000 Subject: Plug memleak recently put into [package require]. --- generic/tclPkg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generic/tclPkg.c b/generic/tclPkg.c index d3dd584..349bda8 100644 --- a/generic/tclPkg.c +++ b/generic/tclPkg.c @@ -432,6 +432,8 @@ PkgRequireCore( * The version of the package sought is better than the * currently selected version. */ + ckfree(bestVersion); + bestVersion = NULL; goto newbest; } } else { @@ -460,6 +462,8 @@ PkgRequireCore( * This stable version of the package sought is better * than the currently selected stable version. */ + ckfree(bestStableVersion); + bestStableVersion = NULL; goto newstable; } } else { -- cgit v0.12 From 5cddfdcda6241cdb20f0b50fe2d10293063786b9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 9 Dec 2017 15:31:58 +0000 Subject: Undo latest change to tcl.rc, since the autoconf-based windows build doesn't know about PRJLIBNAME --- win/tcl.rc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/win/tcl.rc b/win/tcl.rc index 2ca6015..be5e0a7 100644 --- a/win/tcl.rc +++ b/win/tcl.rc @@ -4,6 +4,24 @@ #include #include +// +// build-up the name suffix that defines the type of build this is. +// +#if TCL_THREADS +#define SUFFIX_THREADS "t" +#else +#define SUFFIX_THREADS "" +#endif + +#if DEBUG && !UNCHECKED +#define SUFFIX_DEBUG "g" +#else +#define SUFFIX_DEBUG "" +#endif + +#define SUFFIX SUFFIX_THREADS SUFFIX_DEBUG + + LANGUAGE 0x9, 0x1 /* LANG_ENGLISH, SUBLANG_DEFAULT */ VS_VERSION_INFO VERSIONINFO @@ -24,7 +42,7 @@ BEGIN BLOCK "040904b0" /* LANG_ENGLISH/SUBLANG_ENGLISH_US, Unicode CP */ BEGIN VALUE "FileDescription", "Tcl DLL\0" - VALUE "OriginalFilename", PRJLIBNAME + VALUE "OriginalFilename", "tcl" STRINGIFY(TCL_MAJOR_VERSION) STRINGIFY(TCL_MINOR_VERSION) SUFFIX ".dll\0" VALUE "CompanyName", "ActiveState Corporation\0" VALUE "FileVersion", TCL_PATCH_LEVEL VALUE "LegalCopyright", "Copyright \251 2001 by ActiveState Corporation, et al\0" -- cgit v0.12 From dfeacc8edb1494b531c9bdbe41a83aa89a557198 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 10 Dec 2017 14:35:02 +0000 Subject: Fix [040586323610be22f8617962377324f4ddc9bc02|0405863236]: wrong field checked in struct pollfd in TclUnixWaitForFile --- unix/tclUnixNotfy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c index 5bc753a..b7df740 100644 --- a/unix/tclUnixNotfy.c +++ b/unix/tclUnixNotfy.c @@ -532,13 +532,13 @@ TclUnixWaitForFile( numFound = poll(pollFds, 1, pollTimeout); if (numFound == 1) { result = 0; - if (pollFds[0].events & (POLLIN | POLLHUP)) { + if (pollFds[0].revents & (POLLIN | POLLHUP)) { result |= TCL_READABLE; } - if (pollFds[0].events & POLLOUT) { + if (pollFds[0].revents & POLLOUT) { result |= TCL_WRITABLE; } - if (pollFds[0].events & POLLERR) { + if (pollFds[0].revents & POLLERR) { result |= TCL_EXCEPTION; } if (result) { -- cgit v0.12 From c220b0dcfab61bd6f1d633d56dafd78171b3a457 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 11 Dec 2017 16:26:24 +0000 Subject: Allow standard targets to be selectively disabled. Automatic install for extension stubs and public headers if present. Print installation dir, remove useless partial print of preprocessor defines. --- win/rules.vc | 2 +- win/targets.vc | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 9b917b6..10bc26e 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1681,8 +1681,8 @@ TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake" !message *** Intermediate directory will be '$(TMP_DIR)' !message *** Output directory will be '$(OUT_DIR)' +!message *** Installation, if selected, will be in '$(_INSTALLDIR)' !message *** Suffix for binaries will be '$(SUFX)' -!message *** Optional defines are '$(OPTDEFINES)' !message *** Compiler version $(VCVER). Target machine is $(MACHINE) !message *** Host architecture is $(NATIVE_ARCH) diff --git a/win/targets.vc b/win/targets.vc index ca227d8..7f1d388 100644 --- a/win/targets.vc +++ b/win/targets.vc @@ -36,17 +36,63 @@ $(PRJLIB): $(PRJ_OBJS) $(RESFILE) -@del $*.exp !endif -!ifndef DISABLE_STANDARD_TARGETS +!if "$(PRJ_HEADERS)" != "" && "$(PRJ_OBJS)" != "" +$(PRJ_OBJS): $(PRJ_HEADERS) +!endif + +# If parent makefile has defined stub objects, add their installation +# to the default install +!if "$(PRJ_STUBOBJS)" != "" +default-install: default-install-stubs +!endif + +# Unlike the other default targets, these cannot be in rules.vc because +# the executed command depends on existence of macro PRJ_HEADERS_PUBLIC +# that the parent makefile will not define until after including rules-ext.vc +!if "$(PRJ_HEADERS_PUBLIC)" != "" +default-install: default-install-headers +default-install-headers: + @echo Installing headers to '$(INCLUDE_INSTALL_DIR)' + @for %f in ($(PRJ_HEADERS_PUBLIC)) do @$(COPY) %f "$(INCLUDE_INSTALL_DIR)" +!endif + +!if "$(DISABLE_STANDARD_TARGETS)" == "" DISABLE_STANDARD_TARGETS = 0 !endif +!if "$(DISABLE_TARGET_setup)" == "" +DISABLE_TARGET_setup = 0 +!endif +!if "$(DISABLE_TARGET_install)" == "" +DISABLE_TARGET_install = 0 +!endif +!if "$(DISABLE_TARGET_clean)" == "" +DISABLE_TARGET_clean = 0 +!endif +!if "$(DISABLE_TARGET_test)" == "" +DISABLE_TARGET_test = 0 +!endif +!if "$(DISABLE_TARGET_shell)" == "" +DISABLE_TARGET_shell = 0 +!endif + !if !$(DISABLE_STANDARD_TARGETS) +!if !$(DISABLE_TARGET_setup) setup: default-setup +!endif +!if !$(DISABLE_TARGET_install) install: default-install +!endif +!if !$(DISABLE_TARGET_clean) clean: default-clean realclean: hose hose: default-hose distclean: realclean default-distclean +!endif +!if !$(DISABLE_TARGET_test) test: default-test +!endif +!if !$(DISABLE_TARGET_shell) shell: default-shell !endif +!endif # DISABLE_STANDARD_TARGETS -- cgit v0.12 From 8c866ee6be6f90cf26e2a1001319046bc2cd1bd6 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 12 Dec 2017 17:32:21 +0000 Subject: Add -L option to nmakehlp to locate directories --- win/nmakehlp.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 0439d1c..16d89a1 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -39,7 +39,6 @@ #endif - /* protos */ static int CheckForCompilerFeature(const char *option); @@ -47,6 +46,7 @@ static int CheckForLinkerFeature(const char **options, int count); static int IsIn(const char *string, const char *substring); static int SubstituteFile(const char *substs, const char *filename); static int QualifyPath(const char *path); +static int LocateDependency(const char *keyfile); static const char *GetVersionFromFile(const char *filename, const char *match, int numdots); static DWORD WINAPI ReadFromPipe(LPVOID args); @@ -172,6 +172,18 @@ main( return 2; } return QualifyPath(argv[2]); + + case 'L': + if (argc != 3) { + chars = snprintf(msg, sizeof(msg) - 1, + "usage: %s -L keypath\n" + "Emit the fully qualified path of directory containing keypath\n" + "exitcodes: 0 == success, 1 == not found, 2 == error\n", argv[0]); + WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, + &dwWritten, NULL); + return 2; + } + return LocateDependency(argv[2]); } } chars = snprintf(msg, sizeof(msg) - 1, @@ -701,6 +713,93 @@ QualifyPath( } /* + * Implements LocateDependency for a single directory. See that command + * for an explanation. + * Returns 0 if found after printing the directory. + * Returns 1 if not found but no errors. + * Returns 2 on any kind of error + * Basically, these are used as exit codes for the process. + */ +static int LocateDependencyHelper(const char *dir, const char *keypath) +{ + HANDLE hSearch; + char path[MAX_PATH+1]; + int dirlen, keylen, ret; + WIN32_FIND_DATA finfo; + + if (dir == NULL || keypath == NULL) + return 2; /* Have no real error reporting mechanism into nmake */ + dirlen = strlen(dir); + if ((dirlen + 3) > sizeof(path)) + return 2; + strncpy(path, dir, dirlen); + strncpy(path+dirlen, "\\*", 3); /* Including terminating \0 */ + keylen = strlen(keypath); + +#if 0 /* This function is not available in Visual C++ 6 */ + /* + * Use numerics 0 -> FindExInfoStandard, + * 1 -> FindExSearchLimitToDirectories, + * as these are not defined in Visual C++ 6 + */ + hSearch = FindFirstFileEx(path, 0, &finfo, 1, NULL, 0); +#else + hSearch = FindFirstFile(path, &finfo); +#endif + if (hSearch == INVALID_HANDLE_VALUE) + return 1; /* Not found */ + + /* Loop through all subdirs checking if the keypath is under there */ + ret = 1; /* Assume not found */ + do { + int sublen; + /* + * We need to check it is a directory despite the + * FindExSearchLimitToDirectories in the above call. See SDK docs + */ + if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + continue; + sublen = strlen(finfo.cFileName); + if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) + continue; /* Path does not fit, assume not matched */ + strncpy(path+dirlen+1, finfo.cFileName, sublen); + path[dirlen+1+sublen] = '\\'; + strncpy(path+dirlen+1+sublen+1, keypath, keylen+1); + if (PathFileExists(path)) { + /* Found a match, print to stdout */ + path[dirlen+1+sublen] = '\0'; + QualifyPath(path); + ret = 0; + break; + } + } while (FindNextFile(hSearch, &finfo)); + FindClose(hSearch); + return ret; +} + +/* + * LocateDependency -- + * + * Locates a dependency for a package. + * keypath - a relative path within the package directory + * that is used to confirm it is the correct directory. + * The search path for the package directory is currently only + * the parent and grandparent of the current working directory. + * If found, the command prints + * name_DIRPATH= + * and returns 0. If not found, does not print anything and returns 1. + */ +static int LocateDependency(const char *keypath) +{ + int ret; + ret = LocateDependencyHelper("..", keypath); + if (ret != 0) + ret = LocateDependencyHelper("..\\..", keypath); + return ret; +} + + +/* * Local variables: * mode: c * c-basic-offset: 4 -- cgit v0.12 From 48549d55b04fb4d2eb8df460ffac8ea552676073 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 13 Dec 2017 10:03:54 +0000 Subject: Updated nmake system to make use of the new nmakehlp -L option for locating dependencies. --- win/nmakehlp.c | 12 +++++++---- win/rules-ext.vc | 19 +++++++++++----- win/rules.vc | 66 ++++++++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 72 insertions(+), 25 deletions(-) diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 16d89a1..025bb99 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -791,10 +791,14 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) */ static int LocateDependency(const char *keypath) { - int ret; - ret = LocateDependencyHelper("..", keypath); - if (ret != 0) - ret = LocateDependencyHelper("..\\..", keypath); + int i, ret; + static char *paths[] = {"..", "..\\..", "..\\..\\.."}; + + for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) { + ret = LocateDependencyHelper(paths[i], keypath); + if (ret == 0) + return ret; + } return ret; } diff --git a/win/rules-ext.vc b/win/rules-ext.vc index 3aba80d..58c70fa 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -28,6 +28,12 @@ macro to the name of the project makefile. !error The rules-ext.vc file is not intended for Tcl itself. !endif +# We extract version numbers using the nmakehlp program. For now use +# the local copy of nmakehlp. Once we locate Tcl, we will use that +# one if it is newer. +!if [$(CC) -nologo "nmakehlp.c" -link -subsystem:console > nul] +!endif + # First locate the Tcl directory that we are working with. !ifdef TCLDIR @@ -36,13 +42,20 @@ _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 +# Also Tk never builds against an installed Tcl, it needs Tcl sources !if defined(INSTALLDIR) && "$(PROJECT)" != "tk" _RULESDIR=$(INSTALLDIR:/=\) !else +# Locate Tcl sources +!if [echo _RULESDIR = \> nmakehlp.out] \ + || [nmakehlp -L generic\tcl.h >> nmakehlp.out] _RULESDIR = ..\..\tcl +!else +!include nmakehlp.out !endif +!endif # defined(INSTALLDIR).... + !endif # ifndef TCLDIR # Now look for the targets.vc file under the Tcl root. Note we check this @@ -63,10 +76,6 @@ _RULESDIR = . !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] \ && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MAJOR >> versions.vc] !endif diff --git a/win/rules.vc b/win/rules.vc index 10bc26e..7fc51c1 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -256,8 +256,13 @@ _TCL_H = ..\generic\tcl.h TCLINSTALL = 0 # Tk always builds against Tcl source, not an installed Tcl !if "$(TCLDIR)" == "" -TCLDIR = ../../tcl +!if [echo TCLDIR = \> nmakehlp.out] \ + || [nmakehlp -L generic\tcl.h >> nmakehlp.out] +!error *** Could not locate Tcl source directory. !endif +!include nmakehlp.out +!endif # TCLDIR == "" + _TCLDIR = $(TCLDIR:/=\) _TCL_H = $(_TCLDIR)\generic\tcl.h !if !exist("$(_TCL_H)") @@ -285,21 +290,32 @@ TCLINSTALL = 0 _TCL_H = $(_TCLDIR)\generic\tcl.h !endif -!else # TCLDIR is not defined +!else # # Case 2(c) for extensions with TCLDIR undefined + +# Need to locate Tcl depending on whether it needs Tcl source or not. +# If we don't, check the INSTALLDIR for an installed Tcl first + +!if exist("$(_INSTALLDIR)\include\tcl.h") && !$(NEED_TCL_SOURCE) -!if exist("$(_INSTALLDIR)\include\tcl.h") # Case 2(c) for extensions with TCLDIR undefined TCLINSTALL = 1 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") + +!else # exist(...) && ! $(NEED_TCL_SOURCE) + +!if [echo _TCLDIR = \> nmakehlp.out] \ + || [nmakehlp -L generic\tcl.h >> nmakehlp.out] +!error *** Could not locate Tcl source directory. +!endif +!include nmakehlp.out TCLINSTALL = 0 -TCLDIR = ..\..\tcl -_TCLDIR = $(TCLDIR) +TCLDIR = $(_TCLDIR) _TCL_H = $(_TCLDIR)\generic\tcl.h -!endif + +!endif # exist(...) && ! $(NEED_TCL_SOURCE) !endif # TCLDIR @@ -325,17 +341,30 @@ _TK_H = $(_TKDIR)\generic\tk.h !else # TKDIR not defined -!if exist("$(_INSTALLDIR)\..\include\tk.h") +# Need to locate Tcl depending on whether it needs Tcl source or not. +# If we don't, check the INSTALLDIR for an installed Tcl first + +!if exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE) + TKINSTALL = 1 +# NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions +# later so the \.. accounts for the /lib _TKDIR = $(_INSTALLDIR)\.. _TK_H = $(_TKDIR)\include\tk.h TKDIR = $(_TKDIR) -!elseif exist("$(_TCLDIR)\include\tk.h") -TKINSTALL = 1 -_TKDIR = $(_TCLDIR) -_TK_H = $(_TKDIR)\include\tk.h -TKDIR = $(_TKDIR) + +!else # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE) + +!if [echo _TKDIR = \> nmakehlp.out] \ + || [nmakehlp -L generic\tk.h >> nmakehlp.out] +!error *** Could not locate Tk source directory. !endif +!include nmakehlp.out +TKINSTALL = 0 +TKDIR = $(_TKDIR) +_TK_H = $(_TKDIR)\generic\tk.h + +!endif # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE) !endif # TKDIR @@ -1518,13 +1547,12 @@ default-clean: @if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc -default-hose: +default-hose: default-clean @echo Hosing $(OUT_DIR)\* ... @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR) +# Only for backward compatibility 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) @@ -1679,6 +1707,12 @@ TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake" # Display stats being used. #---------------------------------------------------------- +!if !$(DOING_TCL) +!message *** Building against Tcl at '$(_TCLDIR)' +!endif +!if !$(DOING_TK) && $(NEED_TK) +!message *** Building against Tk at '$(_TKDIR)' +!endif !message *** Intermediate directory will be '$(TMP_DIR)' !message *** Output directory will be '$(OUT_DIR)' !message *** Installation, if selected, will be in '$(_INSTALLDIR)' -- cgit v0.12 From 556dc3036e36d2449fe4feaece94487adfd745b8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 14 Dec 2017 12:02:13 +0000 Subject: Fix (harmless) compiler warning with Visual Studio --- generic/tclStubInit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 544c28e..6c20340 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -110,7 +110,7 @@ static unsigned short TclWinNToHS(unsigned short ns) { } #define TclWinGetPlatformId winGetPlatformId static int -TclWinGetPlatformId() +TclWinGetPlatformId(void) { return 2; /* VER_PLATFORM_WIN32_NT */; } -- cgit v0.12