Subject: Only build the threaded builds by default. Backport some improvements from Tcl 8.6

From: "jan.nijtmans" <[email-masked]>
Date: Wed, 15 Aug 2012 08:12:39 +0000

---
 ChangeLog           |   6 +++
 win/buildall.vc.bat |  68 +++++++++--------------
 win/makefile.vc     | 153 +++++++++++++++++++++++++++++++++++-----------------
 win/rules.vc        |  63 ++++++++++++++--------
 4 files changed, 175 insertions(+), 115 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5374478..9956dd0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-08-15  Jan Nijtmans  <[email-masked]>
+
+	* win/buildall.vc.bat: Only build the threaded builds by default
+	* win/rules.vc:        Backport some improvements from Tcl 8.6
+	* win/makefile.vc:
+
 2010-08-13  Stuart Cassoff  <[email-masked]>
 
 	* unix/tclUnixCompat.c: [Bug 3555454] Rearrange a bit
diff --git a/win/buildall.vc.bat b/win/buildall.vc.bat
index 55b29ae..0c9b3ac 100644
--- a/win/buildall.vc.bat
+++ b/win/buildall.vc.bat
@@ -1,4 +1,5 @@
 @echo off
+
 ::  This is an example batchfile for building everything. Please
 ::  edit this (or make your own) for your needs and wants using
 ::  the instructions for calling makefile.vc found in makefile.vc
@@ -22,17 +23,25 @@ goto OPTIONS_DONE
 :: reset errorlevel
 cd > nul
 
+:: You might have installed your developer studio to add itself to the
+:: path or have already run vcvars32.bat.  Testing these envars proves
+:: cl.exe and friends are in your path.
+::
+if defined VCINSTALLDIR  (goto :startBuilding)
+if defined MSDEVDIR      (goto :startBuilding)
+if defined MSVCDIR       (goto :startBuilding)
+if defined MSSDK         (goto :startBuilding)
+if defined WINDOWSSDKDIR (goto :startBuilding)
+
 :: We need to run the development environment batch script that comes
-:: with developer studio (v4,5,6,7,etc...)  All have it.  These paths
-:: might not be correct.  You may need to edit these.
+:: with developer studio (v4,5,6,7,etc...)  All have it.  This path
+:: might not be correct.  You should call it yourself prior to running
+:: this batchfile.
 ::
-if not defined MSDevDir (
-    call "C:\Program Files\Microsoft Developer Studio\vc98\bin\vcvars32.bat"
-    ::call "C:\Program Files\Microsoft Developer Studio\vc\bin\vcvars32.bat"
-    ::call c:\dev\devstudio60\vc98\bin\vcvars32.bat
-    if errorlevel 1 goto no_vcvars
-)
+call "C:\Program Files\Microsoft Developer Studio\vc98\bin\vcvars32.bat"
+if errorlevel 1 (goto no_vcvars)
 
+:startBuilding
 
 echo.
 echo Sit back and have a cup of coffee while this grinds through ;)
@@ -50,45 +59,16 @@ if "%INSTALLDIR%" == "" set INSTALLDIR=C:\Program Files\Tcl
 
 :: Build the normal stuff along with the help file.
 ::
-set OPTS=none
-if not %SYMBOLS%.==. set OPTS=symbols
-nmake -nologo -f makefile.vc release winhelp OPTS=%OPTS% %1
-if errorlevel 1 goto error
-
-:: Build the static core, dlls and shell.
-::
-set OPTS=static
-if not %SYMBOLS%.==. set OPTS=symbols,static
-nmake -nologo -f makefile.vc release OPTS=%OPTS% %1
-if errorlevel 1 goto error
-
-:: Build the special static libraries that use the dynamic runtime.
-::
-set OPTS=static,msvcrt
-if not %SYMBOLS%.==. set OPTS=symbols,static,msvcrt
-nmake -nologo -f makefile.vc core dlls OPTS=%OPTS% %1
-if errorlevel 1 goto error
-
-:: Build the core and shell for thread support.
-::
 set OPTS=threads
 if not %SYMBOLS%.==. set OPTS=symbols,threads
-nmake -nologo -f makefile.vc shell OPTS=%OPTS% %1
-if errorlevel 1 goto error
-
-:: Build a static, thread support core library with a shell.
-::
-set OPTS=static,threads
-if not %SYMBOLS%.==. set OPTS=symbols,static,threads
-nmake -nologo -f makefile.vc shell OPTS=%OPTS% %1
+nmake -nologo -f makefile.vc release winhelp OPTS=%OPTS% %1
 if errorlevel 1 goto error
 
-:: Build the special static libraries that use the dynamic runtime,
-:: but now with thread support.
+:: Build the static core and shell.
 ::
 set OPTS=static,msvcrt,threads
 if not %SYMBOLS%.==. set OPTS=symbols,static,msvcrt,threads
-nmake -nologo -f makefile.vc core dlls OPTS=%OPTS% %1
+nmake -nologo -f makefile.vc shell OPTS=%OPTS% %1
 if errorlevel 1 goto error
 
 set OPTS=
@@ -100,15 +80,15 @@ echo *** BOOM! ***
 goto end
 
 :no_vcvars
-echo vcvars32.bat not found.  You'll need to edit this batch script.
+echo vcvars32.bat was not run prior to this batchfile, nor are the MS tools in your path.
 goto out
 
 :help
 title buildall.vc.bat help message
 echo usage:
-echo   %0           : builds Tcl for all build types (do this first)
-echo   %0 install   : installs all the release builds (do this second)
-echo   %0 symbols   : builds Tcl for all debugging build types
+echo   %0                 : builds Tcl for all build types (do this first)
+echo   %0 install         : installs all the release builds (do this second)
+echo   %0 symbols         : builds Tcl for all debugging build types
 echo   %0 symbols install : install all the debug builds.
 echo.
 goto out
diff --git a/win/makefile.vc b/win/makefile.vc
index 5db8143..3d17331 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -5,7 +5,7 @@
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# 
+#
 # Copyright (c) 1995-1996 Sun Microsystems, Inc.
 # Copyright (c) 1998-2000 Ajuba Solutions.
 # Copyright (c) 2001-2005 ActiveState Corporation.
@@ -58,67 +58,72 @@ the build instructions.
 #		    makefile.  Helpful to avoid problems when the sources are
 #		    refreshed and you rebuild, but can "overbuild" when common
 #		    headers like tclInt.h just get small changes.
+#	htmlhelp -- Builds a Windows .chm help file for Tcl and Tk from the
+#		    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  -- Builds the windows .hlp file for Tcl from the troff man
-#		    files found in $(ROOT)\doc .
+#		    files found in $(ROOT)\doc.
 #
 # 4)  Macros usable on the commandline:
 #	INSTALLDIR=<path>
 #		Sets where to install Tcl from the built binaries.
 #		C:\Progra~1\Tcl is assumed when not specified.
 #
-#	OPTS=static,msvcrt,staticpkg,threads,symbols,profile,loimpact,unchecked,none
+#	OPTS=loimpact,msvcrt,static,staticpkg,symbols,threads,profile,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.
 #
-#		static  =  Builds a static library of the core instead of a
-#			   dll.  The shell will be static (and large), as well.
-#		msvcrt  =  Affects the static option only to switch it from
+#		loimpact = Adds a flag for how NT treats the heap to keep memory
+#			   in use, low.  This is 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.
-#		staticpkg = Affects the static option only to switch
+#		static   = Builds a static library of the core instead of a
+#			   dll.  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.
-#		threads =  Turns on full multithreading support.
+#		threads  = Turns on full multithreading support.
 #		thrdalloc = Use the thread allocator (shared global free pool).
 #		thrdstorage = Use the generic thread storage support.
 #		symbols =  Adds symbols for step debugging.
 #		profile =  Adds profiling hooks.  Map file is assumed.
-#		loimpact =  Adds a flag for how NT treats the heap to keep memory
-#			   in use, low.  This is said to impact alloc performance.
 #		unchecked = Allows a symbols build to not use the debug
 #			   enabled runtime (msvcrt.dll not msvcrtd.dll
 #			   or libcmt.lib not libcmtd.lib).
 #
-#	STATS=memdbg,compdbg,none
+#	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.
 #
-#		memdbg   = Enables the debugging memory allocator.
 #		compdbg  = Enables byte compilation logging.
+#		memdbg   = Enables the debugging memory allocator.
 #
-#	CHECKS=nodep,fullwarn,64bit,none
+#	CHECKS=64bit,fullwarn,nodep,none
 #		Sets special macros for checking compatability.
 #
-#		nodep	 = Turns off compatability macros to ensure the core
-#			    isn't being built with deprecated functions. 
+#		64bit    = Enable 64bit portability warnings (if available)
 #		fullwarn = Builds with full compiler and link warnings enabled.
 #			    Very verbose.
-#		64bit    = Enable 64bit portability warnings (if available)
+#		nodep	 = Turns off compatability macros to ensure the core
+#			    isn't being built with deprecated functions.
 #
-#	MACHINE=(IX86|IA64|AMD64|ALPHA)
+#	MACHINE=(ALPHA|AMD64|IA64|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.
+#		when not specified. If the CPU environment variable has been
+#		set (ie: recent Platform SDK) then MACHINE is set from CPU.
 #
 #	TMP_DIR=<path>
 #	OUT_DIR=<path>
 #		Hooks to allow the intermediate and output directories to be
-#		changed.  $(OUT_DIR) is assumed to be 
+#		changed.  $(OUT_DIR) is assumed to be
 #		$(BINROOT)\(Release|Debug) based on if symbols are requested.
 #		$(TMP_DIR) will de $(OUT_DIR)\<buildtype> by default.
 #
@@ -170,7 +175,7 @@ Please `cd` to its location first.
 !error $(MSG)
 !endif
 
-PROJECT	= tcl
+PROJECT = tcl
 !include "rules.vc"
 
 STUBPREFIX      = $(PROJECT)stub
@@ -397,7 +402,8 @@ TCLOBJS = \
 	$(TMP_DIR)\tcl.res
 !endif
 
-TCLSTUBOBJS = $(TMP_DIR)\tclStubLib.obj
+TCLSTUBOBJS = \
+	$(TMP_DIR)\tclStubLib.obj
 
 ### The following paths CANNOT have spaces in them.
 COMPATDIR	= $(ROOT)\compat
@@ -407,7 +413,6 @@ TOMMATHDIR	= $(ROOT)\libtommath
 TOOLSDIR	= $(ROOT)\tools
 WINDIR		= $(ROOT)\win
 
-
 #---------------------------------------------------------------------
 # Compile flags
 #---------------------------------------------------------------------
@@ -452,8 +457,7 @@ TCL_DEFINES	= -DTCL_PIPE_DLL=\"$(TCLPIPEDLLNAME)\" -DTCL_TOMMATH -DMP_PREC=4 -Di
 BASE_CFLAGS	= $(cflags) $(cdebug) $(crt) $(TCL_INCLUDES) $(TCL_DEFINES)
 CON_CFLAGS	= $(cflags) $(cdebug) $(crt) -DCONSOLE
 TCL_CFLAGS	= $(BASE_CFLAGS) $(OPTDEFINES)
-### Stubs files should not be compiled with -GL
-STUB_CFLAGS     = $(cflags) $(cdebug:-GL=) $(OPTDEFINES)
+STUB_CFLAGS     = $(cflags) $(cdebug) $(OPTDEFINES)

 #---------------------------------------------------------------------
@@ -522,17 +526,17 @@ all:	    setup $(TCLSH) $(TCLSTUBLIB) dlls $(CAT32)
 tcltest:    setup $(TCLTEST) dlls $(CAT32)
 install:    install-binaries install-libraries install-docs
 
-
-test: setup $(TCLTEST) dlls $(CAT32)
-	set TCL_LIBRARY=$(ROOT)/library
+test: test-core
+test-core: setup $(TCLTEST) dlls $(CAT32)
+	set TCL_LIBRARY=$(ROOT:\=/)/library
 !if "$(OS)" == "Windows_NT"  || "$(MSVCDIR)" == "IDE"
-	$(TCLTEST) "$(ROOT)/tests/all.tcl" $(TESTFLAGS) -loadfile <<
+	$(DEBUGGER) $(TCLTEST) "$(ROOT:\=/)/tests/all.tcl" $(TESTFLAGS) -loadfile <<
 		package ifneeded dde 1.3.3 [list load "$(TCLDDELIB:\=/)" dde]
 		package ifneeded registry 1.2.2 [list load "$(TCLREGLIB:\=/)" registry]
 <<
 !else
 	@echo Please wait while the tests are collected...
-	$(TCLTEST) "$(ROOT)/tests/all.tcl" $(TESTFLAGS) -loadfile << > tests.log
+	$(TCLTEST) "$(ROOT:\=/)/tests/all.tcl" $(TESTFLAGS) -loadfile << > tests.log
 		package ifneeded dde 1.3.3 "$(TCLDDELIB:\=/)" dde]
 		package ifneeded registry 1.2.2 "$(TCLREGLIB:\=/)" registry]
 <<
@@ -540,8 +544,12 @@ test: setup $(TCLTEST) dlls $(CAT32)
 !endif
 
 runtest: setup $(TCLTEST) dlls $(CAT32)
-	set TCL_LIBRARY=$(ROOT)/library
-	$(DEBUGGER) $(TCLTEST)
+	set TCL_LIBRARY=$(ROOT:\=/)/library
+	$(DEBUGGER) $(TCLTEST) $(SCRIPT)
+
+runshell: setup $(TCLSH) dlls
+	set TCL_LIBRARY=$(ROOT:\=/)/library
+	$(DEBUGGER) $(TCLSH) $(SCRIPT)
 
 setup:
 	@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
@@ -553,7 +561,7 @@ $(TCLIMPLIB): $(TCLLIB)
 
 $(TCLLIB): $(TCLOBJS)
 !if $(STATIC_BUILD)
-	$(lib32) -nologo -out:$@ @<<
+	$(lib32) -nologo $(LINKERFLAGS) -out:$@ @<<
 $**
 <<
 !else
@@ -566,13 +574,13 @@ $**
 !endif
 
 $(TCLSTUBLIB): $(TCLSTUBOBJS)
-	$(lib32) -nologo -out:$@ $(TCLSTUBOBJS)
+	$(lib32) -nologo $(LINKERFLAGS) -out:$@ $(TCLSTUBOBJS)
 
-$(TCLSH): $(TCLSHOBJS) $(TCLIMPLIB)
+$(TCLSH): $(TCLSHOBJS) $(TCLSTUBLIB) $(TCLIMPLIB)
 	$(link32) $(conlflags) -stack:2300000 -out:$@ $(baselibs) $**
 	$(_VC_MANIFEST_EMBED_EXE)
 
-$(TCLTEST): $(TCLTESTOBJS) $(TCLIMPLIB)
+$(TCLTEST): $(TCLTESTOBJS) $(TCLSTUBLIB) $(TCLIMPLIB)
 	$(link32) $(conlflags) -stack:2300000 -out:$@ $(baselibs) $**
 	$(_VC_MANIFEST_EMBED_EXE)
 
@@ -583,7 +591,7 @@ $(TCLPIPEDLL): $(WINDIR)\stub16.c
 
 !if $(STATIC_BUILD)
 $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj
-	$(lib32) -nologo -out:$@ $**
+	$(lib32) -nologo $(LINKERFLAGS) -out:$@ $**
 !else
 $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLSTUBLIB)
 	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcldde -out:$@ \
@@ -595,7 +603,7 @@ $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLSTUBLIB)
 
 !if $(STATIC_BUILD)
 $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj
-	$(lib32) -nologo -out:$@ $**
+	$(lib32) -nologo $(LINKERFLAGS) -out:$@ $**
 !else
 $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(TCLSTUBLIB)
 	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tclreg -out:$@ \
@@ -641,9 +649,49 @@ gentommath_h:
 !endif
 
 #---------------------------------------------------------------------
-# Build the windows help file.
+# Build the Windows HTML help file.
 #---------------------------------------------------------------------
 
+# NOTE: you can define HHC on the command-line to override this
+!ifndef HHC
+HHC=""%ProgramFiles%\HTML Help Workshop\hhc.exe""
+!endif
+HTMLDIR=$(ROOT)\html
+HTMLBASE=TclTk$(VERSION)
+HHPFILE=$(HTMLDIR)\$(HTMLBASE).hhp
+CHMFILE=$(HTMLDIR)\$(HTMLBASE).chm
+
+htmlhelp: chmsetup $(CHMFILE)
+
+$(CHMFILE): $(DOCDIR)\*
+	@$(TCLSH) $(TOOLSDIR)\tcltk-man2html.tcl
+	@echo Compiling HTML help project
+	@$(HHC) <<$(HHPFILE) >NUL
+[OPTIONS]
+Compatibility=1.1 or later
+Compiled file=$(HTMLBASE).chm
+Display compile progress=no
+Error log file=$(HTMLBASE).log
+Language=0x409 English (United States)
+Title=Tcl/Tk $(DOT_VERSION) Help
+[FILES]
+contents.htm
+docs.css
+Keywords
+TclCmd
+TclLib
+TkCmd
+TkLib
+UserCmd
+<<
+
+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
@@ -701,7 +749,12 @@ $(HELPRTF): $(MAN2TCL) $(MAN2HELP) $(MAN2HELP2) $(INDEX) $(DOCDIR)\*
 	$(TCLSH) $(MAN2HELP) -bitmap $(BMP_NOPATH) $(PROJECT) $(VERSION) $(DOCDIR:\=/)
 
 install-docs:
-!if exist($(HELPFILE))
+!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
@@ -732,8 +785,8 @@ $(OUT_DIR)\tclConfig.sh: $(WINDIR)\tclConfig.sh.in
 @LIBS@               $(baselibs)
 @prefix@             $(_INSTALLDIR)
 @exec_prefix@        $(BIN_INSTALL_DIR)
-@SHLIB_CFLAGS@       
-@STLIB_CFLAGS@       
+@SHLIB_CFLAGS@
+@STLIB_CFLAGS@
 @CFLAGS_WARNING@     -W3
 @EXTRA_CFLAGS@       -YX
 @SHLIB_LD@           $(link32) $(dlllflags)
@@ -751,7 +804,7 @@ $(OUT_DIR)\tclConfig.sh: $(WINDIR)\tclConfig.sh.in
 @TCL_INCLUDE_SPEC@   -I$(INCLUDE_INSTALL_DIR)
 @TCL_LIB_VERSIONS_OK@
 @TCL_SRC_DIR@        $(ROOT)
-@TCL_PACKAGE_PATH@   
+@TCL_PACKAGE_PATH@
 @TCL_STUB_LIB_FILE@  $(TCLSTUBLIBNAME)
 @TCL_STUB_LIB_FLAG@  $(TCLSTUBLIBNAME)
 @TCL_STUB_LIB_SPEC@  -L$(LIB_INSTALL_DIR) $(TCLSTUBLIBNAME)
@@ -771,7 +824,7 @@ $(OUT_DIR)\tclConfig.sh: $(WINDIR)\tclConfig.sh.in

 #---------------------------------------------------------------------
-# The following target generates the file generic/tclDate.c 
+# The following target generates the file generic/tclDate.c
 # from the yacc grammar found in generic/tclGetDate.y.  This is
 # only run by hand as yacc is not available in all environments.
 # The name of the .c file is different than the name of the .y file
@@ -1023,15 +1076,15 @@ install-libraries: tclConfig install-msgs install-tzdata
 
 install-tzdata:
 	@echo Installing time zone data
-	@set TCL_LIBRARY=$(ROOT)/library
-	@$(TCLSH_NATIVE) "$(ROOT)/tools/installData.tcl" \
-	    "$(ROOT)/library/tzdata" "$(SCRIPT_INSTALL_DIR)/tzdata"
+	@set TCL_LIBRARY=$(ROOT:\=/)/library
+	@$(TCLSH_NATIVE) "$(ROOT:\=/)/tools/installData.tcl" \
+	    "$(ROOT:\=/)/library/tzdata" "$(SCRIPT_INSTALL_DIR)/tzdata"
 
 install-msgs:
 	@echo Installing message catalogs
-	@set TCL_LIBRARY=$(ROOT)/library
-	@$(TCLSH_NATIVE) "$(ROOT)/tools/installData.tcl" \
-	    "$(ROOT)/library/msgs" "$(SCRIPT_INSTALL_DIR)/msgs"
+	@set TCL_LIBRARY=$(ROOT:\=/)/library
+	@$(TCLSH_NATIVE) "$(ROOT:\=/)/tools/installData.tcl" \
+	    "$(ROOT:\=/)/library/msgs" "$(SCRIPT_INSTALL_DIR)/msgs"
 
 #---------------------------------------------------------------------
 # Clean up
@@ -1069,6 +1122,8 @@ clean:
 	@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)
diff --git a/win/rules.vc b/win/rules.vc
index 20c967a..bbf7485 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -6,9 +6,9 @@
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# 
+#
 # Copyright (c) 2001-2003 David Gravereaux.
-# Copyright (c) 2003-2007 Patrick Thoyts
+# Copyright (c) 2003-2008 Patrick Thoyts
 #------------------------------------------------------------------------------
 
 !ifndef _RULES_VC
@@ -217,7 +217,8 @@ TCL_THREADS	= 0
 DEBUG		= 0
 SYMBOLS		= 0
 PROFILE		= 0
-MSVCRT		= 0
+PGO		= 0
+MSVCRT		= 1
 LOIMPACT	= 0
 TCL_USE_STATIC_PACKAGES	= 0
 USE_THREAD_ALLOC = 0
@@ -233,9 +234,13 @@ STATIC_BUILD	= 0
 !message *** Doing msvcrt
 MSVCRT		= 1
 !else
+!if !$(STATIC_BUILD)
+MSVCRT		= 1
+!else
 MSVCRT		= 0
 !endif
-!if [nmakehlp -f $(OPTS) "staticpkg"]
+!endif
+!if [nmakehlp -f $(OPTS) "staticpkg"] && $(STATIC_BUILD)
 !message *** Doing staticpkg
 TCL_USE_STATIC_PACKAGES	= 1
 !else
@@ -244,8 +249,10 @@ TCL_USE_STATIC_PACKAGES	= 0
 !if [nmakehlp -f $(OPTS) "threads"]
 !message *** Doing threads
 TCL_THREADS	= 1
+USE_THREAD_ALLOC = 1
 !else
 TCL_THREADS	= 0
+USE_THREAD_ALLOC = 0
 !endif
 !if [nmakehlp -f $(OPTS) "symbols"]
 !message *** Doing symbols
@@ -265,6 +272,15 @@ PROFILE		= 1
 !else
 PROFILE		= 0
 !endif
+!if [nmakehlp -f $(OPTS) "pgi"]
+!message *** Doing profile guided optimization instrumentation
+PGO		= 1
+!elseif [nmakehlp -f $(OPTS) "pgo"]
+!message *** Doing profile guided optimization
+PGO		= 2
+!else
+PGO		= 0
+!endif
 !if [nmakehlp -f $(OPTS) "loimpact"]
 !message *** Doing loimpact
 LOIMPACT	= 1
@@ -274,7 +290,9 @@ LOIMPACT	= 0
 !if [nmakehlp -f $(OPTS) "thrdalloc"]
 !message *** Doing thrdalloc
 USE_THREAD_ALLOC = 1
-!else
+!endif
+!if [nmakehlp -f $(OPTS) "tclalloc"]
+!message *** Doing tclalloc
 USE_THREAD_ALLOC = 0
 !endif
 !if [nmakehlp -f $(OPTS) "unchecked"]
@@ -285,15 +303,6 @@ UNCHECKED = 0
 !endif
 !endif
 
-
-!if !$(STATIC_BUILD)
-# Make sure we don't build overly fat DLLs.
-MSVCRT		= 1
-# We shouldn't statically put the extensions inside the shell when dynamic.
-TCL_USE_STATIC_PACKAGES = 0
-!endif
-
-
 #----------------------------------------------------------
 # Figure-out how to name our intermediate and output directories.
 # We wouldn't want different builds to use the same .obj files
@@ -335,10 +344,8 @@ TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX
 TMP_DIRFULL = $(TMP_DIRFULL:Static=)
 SUFX	    = $(SUFX:s=)
 EXT	    = dll
-!if $(MSVCRT)
 TMP_DIRFULL = $(TMP_DIRFULL:X=)
 SUFX	    = $(SUFX:x=)
-!endif
 !else
 TMP_DIRFULL = $(TMP_DIRFULL:Dynamic=)
 EXT	    = lib
@@ -417,6 +424,24 @@ WARNINGS		    = $(WARNINGS) -Wp64
 !endif
 !endif
 
+!if $(PGO) > 1
+!if [nmakehlp -l -ltcg:pgoptimize]
+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]
+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.
 #----------------------------------------------------------
@@ -552,12 +577,6 @@ Failed to find tcl.h.  The TCLDIR macro does not appear correct.
 
 TCL_VERSION	= $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
 
-!if $(TCL_VERSION) < 81
-TCL_DOES_STUBS	= 0
-!else
-TCL_DOES_STUBS	= 1
-!endif
-
 !if $(TCLINSTALL)
 TCLSH		= "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe"
 !if !exist($(TCLSH)) && $(TCL_THREADS)
-- 
cgit v0.12