Tcl UDP

Check-in [662e3bac62]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge vc-reform: new nmake build system
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 662e3bac62864c8556aa267f8ca6280379a8d26ae6e4bec76d3360567e8b6194
User & Date: apnadkarni 2017-12-14 11:40:23
Context
2017-12-14
11:45
Do not generate / install documentation. This is as per hypnotoad's commit on the closed trunk which commented out that code, presumably because it requires doctools to be installed. check-in: d4b9c796de user: apnadkarni tags: trunk
11:40
Merge vc-reform: new nmake build system check-in: 662e3bac62 user: apnadkarni tags: trunk
11:34
Latest version of nmake reform from Tcl Closed-Leaf check-in: 41602b0e71 user: apnadkarni tags: vc-reform
2017-09-16
12:25
Enable optimizations for nmake builds check-in: 50e2268a77 user: apnadkarni tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to win/makefile.vc.

     1         -# makefile.vc --                                               -*- Makefile -*-
            1  +#------------------------------------------------------------- -*- makefile -*-
     2      2   #
     3         -# Microsoft Visual C++ makefile for use with nmake.exe v1.62+ (VC++ 5.0+)
            3  +# Makefile for tcludp
     4      4   #
     5         -# This makefile is based upon the Tcl 8.4 Makefile.vc and modified to 
     6         -# make it suitable as a general package makefile. Look for the word EDIT
     7         -# which marks sections that may need modification. As a minumum you will
     8         -# need to change the PROJECT, DOTVERSION and DLLOBJS variables to values
     9         -# relevant to your package.
            5  +# Basic build, test and install
            6  +#   nmake /f makefile.vc INSTALLDIR=c:\tcl
            7  +#   nmake /f makefile.vc INSTALLDIR=c:\tcl test
            8  +#   nmake /f makefile.vc INSTALLDIR=c:\tcl install
    10      9   #
           10  +# For other build options (debug, static etc.),
           11  +# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for
           12  +# detailed documentation.
           13  +# 
    11     14   # See the file "license.terms" for information on usage and redistribution
    12     15   # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    13         -# 
    14         -# Copyright (c) 1995-1996 Sun Microsystems, Inc.
    15         -# Copyright (c) 1998-2000 Ajuba Solutions.
    16         -# Copyright (c) 2001 ActiveState Corporation.
    17         -# Copyright (c) 2001-2002 David Gravereaux.
    18         -# Copyright (c) 2003-2006 Pat Thoyts
    19         -#
    20         -#-------------------------------------------------------------------------
    21         -# RCS: @(#)$Id$
    22         -#-------------------------------------------------------------------------
    23         -
    24         -# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
    25         -# or with the MS Platform SDK (MSSDK). Visual Studio .NET 2003 and 2005 define
    26         -# VCINSTALLDIR instead. The MSVC Toolkit release defines yet another.
    27         -!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK) && !defined(VCINSTALLDIR) && !defined(VCToolkitInstallDir)
    28         -MSG = ^
    29         -You need to run vcvars32.bat from Developer Studio or setenv.bat from the^
    30         -Platform SDK first to setup the environment.  Jump to this line to read^
    31         -the build instructions.
    32         -!error $(MSG)
    33         -!endif
    34         -
    35         -#------------------------------------------------------------------------------
    36         -# HOW TO USE this makefile:
    37         -#
    38         -# 1)  It is now necessary to have %MSVCDir% set in the environment.  This is
    39         -#     used  as a check to see if vcvars32.bat had been run prior to running
    40         -#     nmake or during the installation of Microsoft Visual C++, MSVCDir had
    41         -#     been set globally and the PATH adjusted.  Either way is valid.
    42         -#
    43         -#     You'll need to run vcvars32.bat contained in the MsDev's vc(98)/bin
    44         -#     directory to setup the proper environment, if needed, for your current
    45         -#     setup.  This is a needed bootstrap requirement and allows the swapping of
    46         -#     different environments to be easier.
    47         -#
    48         -# 2)  To use the Platform SDK (not expressly needed), run setenv.bat after
    49         -#     vcvars32.bat according to the instructions for it.  This can also turn on
    50         -#     the 64-bit compiler, if your SDK has it.
    51         -#
    52         -# 3)  Targets are:
    53         -#	all       -- Builds everything.
    54         -#       <project> -- Builds the project (eg: nmake sample)
    55         -#	test      -- Builds and runs the test suite.
    56         -#	install   -- Installs the built binaries and libraries to $(INSTALLDIR)
    57         -#		     in an appropriate subdirectory.
    58         -#	clean/realclean/distclean -- varying levels of cleaning.
    59         -#
    60         -# 4)  Macros usable on the commandline:
    61         -#	INSTALLDIR=<path>
    62         -#		Sets where to install Tcl from the built binaries.
    63         -#		C:\Progra~1\Tcl is assumed when not specified.
    64         -#
    65         -#	OPTS=static,msvcrt,staticpkg,threads,symbols,profile,loimpact,none
    66         -#		Sets special options for the core.  The default is for none.
    67         -#		Any combination of the above may be used (comma separated).
    68         -#		'none' will over-ride everything to nothing.
    69         -#
    70         -#		static  =  Builds a static library of the core instead of a
    71         -#			   dll.  The shell will be static (and large), as well.
    72         -#		msvcrt  =  Effects the static option only to switch it from
    73         -#			   using libcmt(d) as the C runtime [by default] to
    74         -#			   msvcrt(d). This is useful for static embedding
    75         -#			   support.
    76         -#		staticpkg = Effects the static option only to switch
    77         -#			   tclshXX.exe to have the dde and reg extension linked
    78         -#			   inside it.
    79         -#		nothreads = Turns off multithreading support (not recommended)
    80         -#		thrdalloc = Use the thread allocator (shared global free pool).
    81         -#		symbols =  Adds symbols for step debugging.
    82         -#		profile =  Adds profiling hooks.  Map file is assumed.
    83         -#		loimpact =  Adds a flag for how NT treats the heap to keep memory
    84         -#			   in use, low.  This is said to impact alloc performance.
    85         -#
    86         -#	STATS=memdbg,compdbg,none
    87         -#		Sets optional memory and bytecode compiler debugging code added
    88         -#		to the core.  The default is for none.  Any combination of the
    89         -#		above may be used (comma separated).  'none' will over-ride
    90         -#		everything to nothing.
    91         -#
    92         -#		memdbg   = Enables the debugging memory allocator.
    93         -#		compdbg  = Enables byte compilation logging.
    94         -#
    95         -#	MACHINE=(IX86|IA64|ALPHA|AMD64)
    96         -#		Set the machine type used for the compiler, linker, and
    97         -#		resource compiler.  This hook is needed to tell the tools
    98         -#		when alternate platforms are requested.  IX86 is the default
    99         -#		when not specified. If the CPU environment variable has been
   100         -#		set (ie: recent Platform SDK) then MACHINE is set from CPU.
   101         -#
   102         -#	TMP_DIR=<path>
   103         -#	OUT_DIR=<path>
   104         -#		Hooks to allow the intermediate and output directories to be
   105         -#		changed.  $(OUT_DIR) is assumed to be 
   106         -#		$(BINROOT)\(Release|Debug) based on if symbols are requested.
   107         -#		$(TMP_DIR) will de $(OUT_DIR)\<buildtype> by default.
   108         -#
   109         -#	TESTPAT=<file>
   110         -#		Reads the tests requested to be run from this file.
   111         -#
   112         -#	CFG_ENCODING=encoding
   113         -#		name of encoding for configuration information. Defaults
   114         -#		to cp1252
   115         -#
   116         -# 5)  Examples:
   117         -#
   118         -#	Basic syntax of calling nmake looks like this:
   119         -#	nmake [-nologo] -f makefile.vc [target|macrodef [target|macrodef] [...]]
   120         -#
   121         -#                        Standard (no frills)
   122         -#       c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
   123         -#       Setting environment for using Microsoft Visual C++ tools.
   124         -#       c:\tcl_src\win\>nmake -f makefile.vc all
   125         -#       c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl
   126         -#
   127         -#                         Building for Win64
   128         -#       c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
   129         -#       Setting environment for using Microsoft Visual C++ tools.
   130         -#       c:\tcl_src\win\>c:\progra~1\platfo~1\setenv.bat /pre64 /RETAIL
   131         -#       Targeting Windows pre64 RETAIL
   132         -#       c:\tcl_src\win\>nmake -f makefile.vc MACHINE=IA64
   133     16   #
   134     17   #------------------------------------------------------------------------------
   135         -#==============================================================================
   136         -###############################################################################
   137         -#------------------------------------------------------------------------------
   138         -
   139         -!if !exist("makefile.vc")
   140         -MSG = ^
   141         -You must run this makefile only from the directory it is in.^
   142         -Please `cd` to its location first.
   143         -!error $(MSG)
   144         -!endif
   145         -
   146         -#-------------------------------------------------------------------------
   147         -# Project specific information (EDIT)
   148         -#
   149         -# You should edit this with the name and version of your project. This
   150         -# information is used to generate the name of the package library and
   151         -# it's install location.
   152         -#
   153         -# For example, the sample extension is  going to build sample04.dll and
   154         -# would install it into $(INSTALLDIR)\lib\sample04
   155         -#
   156         -# You need to specify the object files that need to be linked into your
   157         -# binary here.
   158         -#
   159         -#-------------------------------------------------------------------------
   160     18   
   161     19   PROJECT = udp
   162         -!include "rules.vc"
           20  +!include "rules-ext.vc"
           21  +
           22  +PRJ_OBJS = $(TMP_DIR)\udp_tcl.obj
           23  +PRJ_DEFINES     = -D_CRT_SECURE_NO_WARNINGS \
           24  +		  -D_WINSOCK_DEPRECATED_NO_WARNINGS
           25  +PRJ_LIBS	= ws2_32.lib
   163     26   
   164         -DOTVERSION      = 1.0.11
   165         -VERSION         = $(DOTVERSION:.=)
           27  +PRJ_DOCS = $(OUT_DIR)\udp.html
           28  +
   166     29   
   167         -DLLOBJS = \
   168         -	$(TMP_DIR)\udp_tcl.obj \
   169         -	$(TMP_DIR)\tcludp.res
           30  +# Define the standard targets
           31  +!include "$(_RULESDIR)\targets.vc"
   170     32   
   171         -PRJDOCS = \
   172         -	$(OUT_DIR)\udp.html
           33  +# Project specific targets
   173     34   
   174         -#-------------------------------------------------------------------------
   175         -# Target names and paths ( shouldn't need changing )
   176         -#-------------------------------------------------------------------------
   177         -
   178         -BINROOT		= .
   179         -ROOT            = ..
           35  +install:    install-docs default-install-demos
           36  +pkgindex:   default-pkgindex
   180     37   
   181         -PRJIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
   182         -PRJLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
   183         -PRJLIB		= $(OUT_DIR)\$(PRJLIBNAME)
   184         -
   185         -PRJSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
   186         -PRJSTUBLIB	= $(OUT_DIR)\$(PRJSTUBLIBNAME)
   187         -
   188         -### Make sure we use backslash only.
   189         -PRJ_INSTALL_DIR         = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
   190         -LIB_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
   191         -BIN_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
   192         -DOC_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
   193         -SCRIPT_INSTALL_DIR	= $(PRJ_INSTALL_DIR)
   194         -DEMO_INSTALL_DIR	= $(PRJ_INSTALL_DIR)\demos
   195         -INCLUDE_INSTALL_DIR	= $(_TCLDIR)\include
   196         -
   197         -### The following paths CANNOT have spaces in them.
   198         -GENERICDIR	= $(ROOT)\generic
   199         -WINDIR		= $(ROOT)\win
   200         -LIBDIR          = $(ROOT)\library
   201         -DOCDIR		= $(ROOT)\doc
   202         -DEMODIR		= $(ROOT)\demos
   203         -TOOLSDIR	= $(ROOT)\tools
   204         -COMPATDIR	= $(ROOT)\compat
   205         -EXPATDIR        = $(ROOT)\expat
   206         -
   207         -
   208         -#---------------------------------------------------------------------
   209         -# Compile flags
   210         -#---------------------------------------------------------------------
   211         -
   212         -!if !$(DEBUG)
   213         -!if $(OPTIMIZING)
   214         -### This cranks the optimization level to maximize speed
   215         -cdebug	= $(OPTIMIZATIONS)
   216         -!else
   217         -cdebug	=
   218         -!endif
   219         -!else if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
   220         -### Warnings are too many, can't support warnings into errors.
   221         -cdebug	= -Zi -Od $(DEBUGFLAGS)
   222         -!else
   223         -cdebug	= -Zi -WX $(DEBUGFLAGS)
   224         -!endif
   225         -
   226         -### Declarations common to all compiler options
   227         -cwarn = $(WARNINGS) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE -D _WINSOCK_DEPRECATED_NO_WARNINGS
   228         -cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\
   229         -
   230         -!if $(MSVCRT)
   231         -!if $(DEBUG) && !$(UNCHECKED)
   232         -crt = -MDd
   233         -!else
   234         -crt = -MD
   235         -!endif
   236         -!else
   237         -!if $(DEBUG) && !$(UNCHECKED)
   238         -crt = -MTd
   239         -!else
   240         -crt = -MT
   241         -!endif
   242         -!endif
   243         -
   244         -!if !$(STATIC_BUILD)
   245         -cflags = $(cflags) -DUSE_TCL_STUBS
   246         -!if defined(TKSTUBLIB)
   247         -cflags = $(cflags) -DUSE_TK_STUBS
   248         -!endif
   249         -!endif
   250         -
   251         -DEFS            =-DHAVE_MEMMOVE=1 
   252         -DEFS_EXPAT	=-DXMLIMPORT=__declspec(dllexport)
   253         -INCLUDES	= -I"$(WINDIR)" -I"$(GENERICDIR)" -I"$(EXPATDIR)" $(TCL_INCLUDES)
   254         -BASE_CFLAGS	= $(cflags) $(cdebug) $(crt) $(INCLUDES)
   255         -CON_CFLAGS	= $(cflags) $(cdebug) $(crt) -DCONSOLE
   256         -TCL_CFLAGS      = -DPACKAGE_NAME="\"$(PROJECT)\"" \
   257         -		  -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
   258         -		  $(BASE_CFLAGS) $(OPTDEFINES) $(DEFS)
   259         -
   260         -#---------------------------------------------------------------------
   261         -# Link flags
   262         -#---------------------------------------------------------------------
   263         -
   264         -!if $(DEBUG)
   265         -ldebug	= -debug:full -debugtype:cv
   266         -!if $(MSVCRT)
   267         -ldebug = $(ldebug) -nodefaultlib:msvcrt
   268         -!endif
   269         -!else
   270         -ldebug	= -release -opt:ref -opt:icf,3
   271         -!endif
   272         -
   273         -### Declarations common to all linker options
   274         -lflags	= -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug)
   275         -
   276         -!if $(PROFILE)
   277         -lflags	= $(lflags) -profile
   278         -!endif
   279         -
   280         -!if $(ALIGN98_HACK) && !$(STATIC_BUILD)
   281         -### Align sections for PE size savings.
   282         -lflags	= $(lflags) -opt:nowin98
   283         -!else if !$(ALIGN98_HACK) && $(STATIC_BUILD)
   284         -### Align sections for speed in loading by choosing the virtual page size.
   285         -lflags	= $(lflags) -align:4096
   286         -!endif
   287         -
   288         -!if $(LOIMPACT)
   289         -lflags	= $(lflags) -ws:aggressive
   290         -!endif
   291         -
   292         -dlllflags = $(lflags) -dll
   293         -conlflags = $(lflags) -subsystem:console
   294         -guilflags = $(lflags) -subsystem:windows
   295         -!if !$(STATIC_BUILD)
   296         -baselibs  = $(TCLSTUBLIB)
   297         -!if defined(TKSTUBLIB)
   298         -baselibs  = $(baselibs) $(TKSTUBLIB)
   299         -!endif
   300         -!endif
   301         -
   302         -baselibs = $(baselibs) ws2_32.lib
   303         -
   304         -# Avoid 'unresolved external symbol __security_cookie' errors.
   305         -# c.f. http://support.microsoft.com/?id=894573
   306         -!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
   307         -baselibs   = $(baselibs) bufferoverflowU.lib
   308         -!endif
   309         -
   310         -#---------------------------------------------------------------------
   311         -# TclTest flags
   312         -#---------------------------------------------------------------------
   313         -
   314         -!IF "$(TESTPAT)" != ""
   315         -TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
   316         -!ENDIF
   317         -
   318         -#---------------------------------------------------------------------
   319         -# Project specific targets (EDIT)
   320         -#---------------------------------------------------------------------
   321         -
   322         -all:	    setup $(PROJECT)
   323         -$(PROJECT): setup $(PRJLIB)
   324         -doc:        setup $(PRJDOCS)
   325         -install:    install-binaries install-libraries install-docs install-demos
   326         -
   327         -
   328         -# Tests need to ensure we load the right dll file we
   329         -# have to handle the output differently on Win9x.
   330         -#
   331         -!if "$(OS)" == "Windows_NT"  || "$(MSVCDIR)" == "IDE"
   332         -test: setup $(PROJECT)
   333         -        $(TCLSH) <<
   334         -load $(PRJLIB:\=/)
   335         -cd "$(ROOT)/tests"
   336         -set argv "$(TESTFLAGS)"
   337         -source all.tcl
   338         -<<
   339         -!else
   340         -test: setup $(PROJECT)
   341         -        echo Please wait while the test results are collected
   342         -        $(TCLSH) << >tests.log
   343         -load $(PRJLIB:\=/)
   344         -cd "$(ROOT)/tests"
   345         -set argv "$(TESTFLAGS)"
   346         -source all.tcl
   347         -<<
   348         -        type tests.log | more
   349         -!endif
   350         -
   351         -setup:
   352         -	@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
   353         -	@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
   354         -
   355         -$(PRJLIB): $(DLLOBJS)
   356         -!if $(STATIC_BUILD)
   357         -	$(lib32) -nologo -out:[email protected] @<<
   358         -$**
   359         -<<
   360         -!else
   361         -	$(link32) $(dlllflags) -base:0x109E0000 -out:[email protected] $(baselibs) @<<
   362         -$**
   363         -<<
   364         -	$(_VC_MANIFEST_EMBED_DLL)
   365         -	[email protected] $*.exp
   366         -!endif
   367         -
   368         -#---------------------------------------------------------------------
   369         -# Implicit rules
   370         -#---------------------------------------------------------------------
   371         -
   372         -{$(WINDIR)}.c{$(TMP_DIR)}.obj::
   373         -    $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
   374         -$<
   375         -<<
   376         -
   377         -{$(GENERICDIR)}.c{$(TMP_DIR)}.obj::
   378         -    $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
   379         -$<
   380         -<<
   381         -
   382         -{$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
   383         -    $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
   384         -$<
   385         -<<
   386         -
   387         -{$(WINDIR)}.rc{$(TMP_DIR)}.res:
   388         -	$(rc32) -fo [email protected] -r -i "$(GENERICDIR)" -D__WIN32__ \
   389         -                -DCOMMAVERSION=$(DOTVERSION:.=,),0 \
   390         -                -DDOTVERSION=\"$(DOTVERSION)\" \
   391         -                -DVERSION=\"$(VERSION)$(SUFX)\" \
   392         -!if $(DEBUG)
   393         -	-d DEBUG \
   394         -!endif
   395         -!if $(TCL_THREADS)
   396         -	-d TCL_THREADS \
   397         -!endif
   398         -!if $(STATIC_BUILD)
   399         -	-d STATIC_BUILD \
   400         -!endif
   401         -	$<
   402         -
   403         -DOC2HTML = $(TCLSH) "$(TOOLSDIR)\mpexpand.tcl" html
   404         -
           38  +# Implicit rule to generate html from man files
           39  +DOC2HTML = $(TCLSH) "$(TOOLSDIR)\mpexpand.tcl" html
   405     40   {$(DOCDIR)}.man{$(OUT_DIR)}.html:
   406     41   	$(DOC2HTML) $< [email protected]
   407     42           @$(TCLSH) <<
   408     43   set name $(@:\=/)
   409     44   set f [open $$name r]; set d [read $$f]; close $$f
   410     45   set d [regsub {</head>} $$d {<link rel="stylesheet" href="manpage.css" type="text/css"></head>}]
   411     46   set f [open $$name w]; puts -nonewline $$f $$d; close $$f
   412     47   <<
   413     48   
   414         -.SUFFIXES:
   415         -.SUFFIXES:.c .rc .man
           49  +.SUFFIXES: .man
   416     50   
   417         -#---------------------------------------------------------------------
   418         -# Installation. (EDIT)
   419         -#
   420         -# You may need to modify this section to reflect the final distribution
   421         -# of your files and possibly to generate documentation.
   422         -#
   423         -#---------------------------------------------------------------------
   424         -
   425         -install-binaries:
   426         -	@echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
   427         -	@if not exist $(SCRIPT_INSTALL_DIR)\nul mkdir "$(SCRIPT_INSTALL_DIR)"
   428         -	@$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
   429         -
   430         -install-libraries:
   431         -        @echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
   432         -        @if exist $(LIBDIR)\NUL $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)" >NUL
   433         -        @echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
   434         -        @type << >"$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
   435         -    package ifneeded $(PROJECT) $(DOTVERSION) "[list load [file join $$dir $(PROJECT)$(VERSION)$(SUFX).$(EXT)] $(PROJECT)]"
   436         -<<
   437         -
   438         -install-docs: $(PRJDOCS)
           51  +# Cannot use default-install-docs because we generate docs on the fly
           52  +doc:        setup $(PRJ_DOCS)
           53  +install-docs: doc
   439     54   	@echo Installing documentation to '$(DOC_INSTALL_DIR)'
   440     55   	@if not exist $(DOC_INSTALL_DIR)\NUL mkdir "$(DOC_INSTALL_DIR)"
   441     56   	@$(CPY) "$(DOCDIR)\manpage.css" "$(DOC_INSTALL_DIR)\" >NUL
   442         -	@for %i in ($(PRJDOCS)) do @$(CPY) %i "$(DOC_INSTALL_DIR)\" > NUL
           57  +	@for %i in ($(PRJ_DOCS)) do @$(CPY) %i "$(DOC_INSTALL_DIR)\" > NUL
   443     58   
   444         -install-demos:
   445         -	@echo Installing demos to '$(DEMO_INSTALL_DIR)'
   446         -	@if not exist $(DEMO_INSTALL_DIR)\nul mkdir "$(DEMO_INSTALL_DIR)"
   447         -	@$(CPY) $(DEMODIR)\*.tcl "$(DEMO_INSTALL_DIR)" >NUL
   448     59   
   449         -#---------------------------------------------------------------------
   450         -# Clean up
   451         -#---------------------------------------------------------------------
   452         -
   453         -clean:
   454         -	@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
   455         -	@if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc
   456         -	@if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
   457         -	@if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
   458         -	@if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch
   459         -
   460         -realclean: clean
   461         -	@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
   462         -
   463         -distclean: realclean
   464         -	@if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
   465         -	@if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj

Changes to win/nmakehlp.c.

    35     35   
    36     36   /* ISO hack for dumb VC++ */
    37     37   #ifdef _MSC_VER
    38     38   #define   snprintf	_snprintf
    39     39   #endif
    40     40   
    41     41   
    42         -
    43     42   /* protos */
    44     43   
    45     44   static int CheckForCompilerFeature(const char *option);
    46     45   static int CheckForLinkerFeature(const char **options, int count);
    47     46   static int IsIn(const char *string, const char *substring);
    48     47   static int SubstituteFile(const char *substs, const char *filename);
    49     48   static int QualifyPath(const char *path);
           49  +static int LocateDependency(const char *keyfile);
    50     50   static const char *GetVersionFromFile(const char *filename, const char *match, int numdots);
    51     51   static DWORD WINAPI ReadFromPipe(LPVOID args);
    52     52   
    53     53   /* globals */
    54     54   
    55     55   #define CHUNK	25
    56     56   #define STATICBUFFERSIZE    1000
................................................................................
    70     70   main(
    71     71       int argc,
    72     72       char *argv[])
    73     73   {
    74     74       char msg[300];
    75     75       DWORD dwWritten;
    76     76       int chars;
           77  +    char *s;
    77     78   
    78     79       /*
    79     80        * Make sure children (cl.exe and link.exe) are kept quiet.
    80     81        */
    81     82   
    82     83       SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
    83     84   
................................................................................
   149    150   		    "Extract a version from a file:\n"
   150    151   		    "eg: pkgIndex.tcl \"package ifneeded http\"",
   151    152   		    argv[0]);
   152    153   		WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
   153    154   		    &dwWritten, NULL);
   154    155   		return 0;
   155    156   	    }
   156         -	    printf("%s\n", GetVersionFromFile(argv[2], argv[3], *(argv[1]+2) - '0'));
   157         -	    return 0;
          157  +	    s = GetVersionFromFile(argv[2], argv[3], *(argv[1]+2) - '0');
          158  +	    if (s && *s) {
          159  +		printf("%s\n", s);
          160  +		return 0;
          161  +	    } else
          162  +		return 1; /* Version not found. Return non-0 exit code */
          163  +
   158    164   	case 'Q':
   159    165   	    if (argc != 3) {
   160    166   		chars = snprintf(msg, sizeof(msg) - 1,
   161    167   		    "usage: %s -Q path\n"
   162    168   		    "Emit the fully qualified path\n"
   163    169   		    "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
   164    170   		WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
   165    171   		    &dwWritten, NULL);
   166    172   		return 2;
   167    173   	    }
   168    174   	    return QualifyPath(argv[2]);
          175  +
          176  +	case 'L':
          177  +	    if (argc != 3) {
          178  +		chars = snprintf(msg, sizeof(msg) - 1,
          179  +		    "usage: %s -L keypath\n"
          180  +		    "Emit the fully qualified path of directory containing keypath\n"
          181  +		    "exitcodes: 0 == success, 1 == not found, 2 == error\n", argv[0]);
          182  +		WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
          183  +		    &dwWritten, NULL);
          184  +		return 2;
          185  +	    }
          186  +	    return LocateDependency(argv[2]);
   169    187   	}
   170    188       }
   171    189       chars = snprintf(msg, sizeof(msg) - 1,
   172    190   	    "usage: %s -c|-f|-l|-Q|-s|-V ...\n"
   173    191   	    "This is a little helper app to equalize shell differences between WinNT and\n"
   174    192   	    "Win9x and get nmake.exe to accomplish its job.\n",
   175    193   	    argv[0]);
................................................................................
   689    707       while ((p = strchr(szPath, '/')) && *p)
   690    708   	*p = '\\';
   691    709       PathCombine(szTmp, szCwd, szPath);
   692    710       PathCanonicalize(szCwd, szTmp);
   693    711       printf("%s\n", szCwd);
   694    712       return 0;
   695    713   }
          714  +
          715  +/*
          716  + * Implements LocateDependency for a single directory. See that command
          717  + * for an explanation.
          718  + * Returns 0 if found after printing the directory.
          719  + * Returns 1 if not found but no errors.
          720  + * Returns 2 on any kind of error
          721  + * Basically, these are used as exit codes for the process.
          722  + */
          723  +static int LocateDependencyHelper(const char *dir, const char *keypath)
          724  +{
          725  +    HANDLE hSearch;
          726  +    char path[MAX_PATH+1];
          727  +    int dirlen, keylen, ret;
          728  +    WIN32_FIND_DATA finfo;
          729  +
          730  +    if (dir == NULL || keypath == NULL)
          731  +	return 2; /* Have no real error reporting mechanism into nmake */
          732  +    dirlen = strlen(dir);
          733  +    if ((dirlen + 3) > sizeof(path))
          734  +	return 2;
          735  +    strncpy(path, dir, dirlen);
          736  +    strncpy(path+dirlen, "\\*", 3);	/* Including terminating \0 */
          737  +    keylen = strlen(keypath);
          738  +
          739  +#if 0 /* This function is not available in Visual C++ 6 */
          740  +    /*
          741  +     * Use numerics 0 -> FindExInfoStandard,
          742  +     * 1 -> FindExSearchLimitToDirectories, 
          743  +     * as these are not defined in Visual C++ 6
          744  +     */
          745  +    hSearch = FindFirstFileEx(path, 0, &finfo, 1, NULL, 0);
          746  +#else
          747  +    hSearch = FindFirstFile(path, &finfo);
          748  +#endif
          749  +    if (hSearch == INVALID_HANDLE_VALUE)
          750  +	return 1; /* Not found */
          751  +
          752  +    /* Loop through all subdirs checking if the keypath is under there */
          753  +    ret = 1; /* Assume not found */
          754  +    do {
          755  +	int sublen;
          756  +	/*
          757  +	 * We need to check it is a directory despite the 
          758  +	 * FindExSearchLimitToDirectories in the above call. See SDK docs
          759  +	 */
          760  +	if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
          761  +	    continue;
          762  +	sublen = strlen(finfo.cFileName);
          763  +	if ((dirlen+1+sublen+1+keylen+1) > sizeof(path))
          764  +	    continue;		/* Path does not fit, assume not matched */
          765  +	strncpy(path+dirlen+1, finfo.cFileName, sublen);
          766  +	path[dirlen+1+sublen] = '\\';
          767  +	strncpy(path+dirlen+1+sublen+1, keypath, keylen+1);
          768  +	if (PathFileExists(path)) {
          769  +	    /* Found a match, print to stdout */
          770  +	    path[dirlen+1+sublen] = '\0';
          771  +	    QualifyPath(path);
          772  +	    ret = 0;
          773  +	    break;
          774  +	}
          775  +    } while (FindNextFile(hSearch, &finfo));
          776  +    FindClose(hSearch);
          777  +    return ret;
          778  +}
          779  +
          780  +/*
          781  + * LocateDependency --
          782  + *
          783  + *	Locates a dependency for a package.
          784  + *        keypath - a relative path within the package directory
          785  + *          that is used to confirm it is the correct directory.
          786  + *	The search path for the package directory is currently only
          787  + *      the parent and grandparent of the current working directory.
          788  + *      If found, the command prints 
          789  + *         name_DIRPATH=<full path of located directory>
          790  + *      and returns 0. If not found, does not print anything and returns 1.
          791  + */
          792  +static int LocateDependency(const char *keypath)
          793  +{
          794  +    int i, ret;
          795  +    static char *paths[] = {"..", "..\\..", "..\\..\\.."};
          796  +    
          797  +    for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) {
          798  +	ret = LocateDependencyHelper(paths[i], keypath);
          799  +	if (ret == 0)
          800  +	    return ret;
          801  +    }
          802  +    return ret;
          803  +}
          804  +
   696    805   
   697    806   /*
   698    807    * Local variables:
   699    808    *   mode: c
   700    809    *   c-basic-offset: 4
   701    810    *   fill-column: 78
   702    811    *   indent-tabs-mode: t
   703    812    *   tab-width: 8
   704    813    * End:
   705    814    */

Added win/rules-ext.vc.

            1  +# This file should only be included in makefiles for Tcl extensions,
            2  +# NOT in the makefile for Tcl itself.
            3  +
            4  +!ifndef _RULES_EXT_VC
            5  +
            6  +# We need to run from the directory the parent makefile is located in.
            7  +# nmake does not tell us what makefile was used to invoke it so parent
            8  +# makefile has to set the MAKEFILEVC macro or we just make a guess and
            9  +# warn if we think that is not the case.
           10  +!if "$(MAKEFILEVC)" == ""
           11  +
           12  +!if exist("$(PROJECT).vc")
           13  +MAKEFILEVC = $(PROJECT).vc
           14  +!elseif exist("makefile.vc")
           15  +MAKEFILEVC = makefile.vc
           16  +!endif
           17  +!endif # "$(MAKEFILEVC)" == ""
           18  +
           19  +!if !exist("$(MAKEFILEVC)")
           20  +MSG = ^
           21  +You must run nmake from the directory containing the project makefile.^
           22  +If you are doing that and getting this message, set the MAKEFILEVC^
           23  +macro to the name of the project makefile.
           24  +!message WARNING: $(MSG)
           25  +!endif
           26  +
           27  +!if "$(PROJECT)" == "tcl"
           28  +!error The rules-ext.vc file is not intended for Tcl itself.
           29  +!endif
           30  +
           31  +# We extract version numbers using the nmakehlp program. For now use
           32  +# the local copy of nmakehlp. Once we locate Tcl, we will use that
           33  +# one if it is newer.
           34  +!if [$(CC) -nologo "nmakehlp.c" -link -subsystem:console > nul]
           35  +!endif
           36  +
           37  +# First locate the Tcl directory that we are working with.
           38  +!ifdef TCLDIR
           39  +
           40  +_RULESDIR = $(TCLDIR:/=\)
           41  +
           42  +!else
           43  +
           44  +# If an installation path is specified, that is also the Tcl directory.
           45  +# Also Tk never builds against an installed Tcl, it needs Tcl sources
           46  +!if defined(INSTALLDIR) && "$(PROJECT)" != "tk"
           47  +_RULESDIR=$(INSTALLDIR:/=\)
           48  +!else
           49  +# Locate Tcl sources
           50  +!if [echo _RULESDIR = \> nmakehlp.out] \
           51  +   || [nmakehlp -L generic\tcl.h >> nmakehlp.out]
           52  +_RULESDIR = ..\..\tcl
           53  +!else
           54  +!include nmakehlp.out
           55  +!endif
           56  +
           57  +!endif # defined(INSTALLDIR)....
           58  +
           59  +!endif # ifndef TCLDIR
           60  +
           61  +# Now look for the targets.vc file under the Tcl root. Note we check this
           62  +# file and not rules.vc because the latter also exists on older systems.
           63  +!if exist("$(_RULESDIR)\lib\nmake\targets.vc") # Building against installed Tcl
           64  +_RULESDIR = $(_RULESDIR)\lib\nmake
           65  +!elseif exist("$(_RULESDIR)\win\targets.vc")   # Building against Tcl sources
           66  +_RULESDIR = $(_RULESDIR)\win
           67  +!else
           68  +# If we have not located Tcl's targets file, most likely we are compiling
           69  +# against an older version of Tcl and so must use our own support files.
           70  +_RULESDIR = .
           71  +!endif
           72  +
           73  +!if "$(_RULESDIR)" != "."
           74  +# Potentially using Tcl's support files. If this extension has its own
           75  +# nmake support files, need to compare the versions and pick newer.
           76  +
           77  +!if exist("rules.vc") # The extension has its own copy
           78  +
           79  +!if [echo TCL_RULES_MAJOR = \> versions.vc] \
           80  +   && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MAJOR >> versions.vc]
           81  +!endif
           82  +!if [echo TCL_RULES_MINOR = \>> versions.vc] \
           83  +   && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MINOR >> versions.vc]
           84  +!endif
           85  +
           86  +!if [echo OUR_RULES_MAJOR = \>> versions.vc] \
           87  +   && [nmakehlp -V "rules.vc" RULES_VERSION_MAJOR >> versions.vc]
           88  +!endif
           89  +!if [echo OUR_RULES_MINOR = \>> versions.vc] \
           90  +   && [nmakehlp -V "rules.vc" RULES_VERSION_MINOR >> versions.vc]
           91  +!endif
           92  +!include versions.vc
           93  +# We have a newer version of the support files, use them
           94  +!if ($(TCL_RULES_MAJOR) != $(OUR_RULES_MAJOR)) || ($(TCL_RULES_MINOR) < $(OUR_RULES_MINOR))
           95  +_RULESDIR = .
           96  +!endif
           97  +
           98  +!endif # if exist("rules.vc")
           99  +
          100  +!endif # if $(_RULESDIR) != "."
          101  +
          102  +# Let rules.vc know what copy of nmakehlp.c to use.
          103  +NMAKEHLPC = $(_RULESDIR)\nmakehlp.c
          104  +
          105  +# Get rid of our internal defines before calling rules.vc
          106  +!undef TCL_RULES_MAJOR
          107  +!undef TCL_RULES_MINOR
          108  +!undef OUR_RULES_MAJOR
          109  +!undef OUR_RULES_MINOR
          110  +
          111  +!if exist("$(_RULESDIR)\rules.vc")
          112  +!message *** Using $(_RULESDIR)\rules.vc
          113  +!include "$(_RULESDIR)\rules.vc"
          114  +!else
          115  +!error *** Could not locate rules.vc in $(_RULESDIR)
          116  +!endif
          117  +
          118  +!endif # _RULES_EXT_VC

Changes to win/rules.vc.

     1         -
            1  +#------------------------------------------------------------- -*- makefile -*-
     2      2   # rules.vc --
     3      3   #
     4         -#	Microsoft Visual C++ makefile include for decoding the commandline
     5         -#	macros.  This file does not need editing to build Tcl.
            4  +# Part of the nmake based build system for Tcl and its extensions.
            5  +# This file does all the hard work in terms of parsing build options,
            6  +# compiler switches, defining common targets and macros. The Tcl makefile
            7  +# directly includes this. Extensions include it via "rules-ext.vc".
            8  +#
            9  +# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for
           10  +# detailed documentation.
     6     11   #
     7     12   # See the file "license.terms" for information on usage and redistribution
     8     13   # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     9     14   #
    10     15   # Copyright (c) 2001-2003 David Gravereaux.
    11     16   # Copyright (c) 2003-2008 Patrick Thoyts
           17  +# Copyright (c) 2017      Ashok P. Nadkarni
    12     18   #------------------------------------------------------------------------------
    13     19   
    14     20   !ifndef _RULES_VC
    15     21   _RULES_VC = 1
    16     22   
    17         -cc32		= $(CC)   # built-in default.
    18         -link32		= link
    19         -lib32		= lib
    20         -rc32		= $(RC)   # built-in default.
    21         -
    22         -!ifndef INSTALLDIR
    23         -### Assume the normal default.
    24         -_INSTALLDIR	= C:\Program Files\Tcl
    25         -!else
    26         -### Fix the path separators.
    27         -_INSTALLDIR	= $(INSTALLDIR:/=\)
    28         -!endif
           23  +# The following macros define the version of the rules.vc nmake build system
           24  +# For modifications that are not backward-compatible, you *must* change
           25  +# the major version.
           26  +RULES_VERSION_MAJOR = 1
           27  +RULES_VERSION_MINOR = 0
           28  +
           29  +# The PROJECT macro must be defined by parent makefile.
           30  +!if "$(PROJECT)" == ""
           31  +!error *** Error: Macro PROJECT not defined! Please define it before including rules.vc
           32  +!endif
           33  +
           34  +!if "$(PRJ_PACKAGE_TCLNAME)" == ""
           35  +PRJ_PACKAGE_TCLNAME = $(PROJECT)
           36  +!endif
           37  +
           38  +# Also special case Tcl and Tk to save some typing later
           39  +DOING_TCL = 0
           40  +DOING_TK  = 0
           41  +!if "$(PROJECT)" == "tcl"
           42  +DOING_TCL = 1
           43  +!elseif "$(PROJECT)" == "tk"
           44  +DOING_TK = 1
           45  +!endif
           46  +
           47  +!ifndef NEED_TK
           48  +# Backwards compatibility
           49  +!ifdef PROJECT_REQUIRES_TK
           50  +NEED_TK = $(PROJECT_REQUIRES_TK)
           51  +!else
           52  +NEED_TK = 0
           53  +!endif
           54  +!endif
           55  +
           56  +!ifndef NEED_TCL_SOURCE
           57  +NEED_TCL_SOURCE = 0
           58  +!endif
           59  +
           60  +!ifdef NEED_TK_SOURCE
           61  +!if $(NEED_TK_SOURCE)
           62  +NEED_TK = 1
           63  +!endif
           64  +!else
           65  +NEED_TK_SOURCE = 0
           66  +!endif
           67  +
           68  +################################################################
           69  +# Nmake is a pretty weak environment in syntax and capabilities
           70  +# so this file is necessarily verbose. It's broken down into
           71  +# the following parts.
           72  +#
           73  +# 0. Sanity check that compiler environment is set up and initialize
           74  +#    any built-in settings from the parent makefile
           75  +# 1. First define the external tools used for compiling, copying etc.
           76  +#    as this is independent of everything else.
           77  +# 2. Figure out our build structure in terms of the directory, whether
           78  +#    we are building Tcl or an extension, etc.
           79  +# 3. Determine the compiler and linker versions
           80  +# 4. Build the nmakehlp helper application
           81  +# 5. Determine the supported compiler options and features
           82  +# 6. Parse the OPTS macro value for user-specified build configuration
           83  +# 7. Parse the STATS macro value for statistics instrumentation
           84  +# 8. Parse the CHECKS macro for additional compilation checks
           85  +# 9. Extract Tcl, and possibly Tk, version numbers from the headers
           86  +# 10. Based on this selected configuration, construct the output
           87  +#     directory and file paths
           88  +# 11. Construct the paths where the package is to be installed
           89  +# 12. Set up the actual options passed to compiler and linker based
           90  +#     on the information gathered above.
           91  +# 13. Define some standard build targets and implicit rules. These may
           92  +#     be optionally disabled by the parent makefile.
           93  +# 14. (For extensions only.) Compare the configuration of the target
           94  +#     Tcl and the extensions and warn against discrepancies.
           95  +#
           96  +# One final note about the macro names used. They are as they are
           97  +# for historical reasons. We would like legacy extensions to
           98  +# continue to work with this make include file so be wary of
           99  +# changing them for consistency or clarity.
          100  +
          101  +# 0. Sanity check compiler environment
          102  +
          103  +# Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or
          104  +# VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir)
          105  +
          106  +!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR)
          107  +MSG = ^
          108  +Visual C++ compiler environment not initialized.
          109  +!error $(MSG)
          110  +!endif
          111  +
          112  +# We need to run from the directory the parent makefile is located in.
          113  +# nmake does not tell us what makefile was used to invoke it so parent
          114  +# makefile has to set the MAKEFILEVC macro or we just make a guess and
          115  +# warn if we think that is not the case.
          116  +!if "$(MAKEFILEVC)" == ""
          117  +
          118  +!if exist("$(PROJECT).vc")
          119  +MAKEFILEVC = $(PROJECT).vc
          120  +!elseif exist("makefile.vc")
          121  +MAKEFILEVC = makefile.vc
          122  +!endif
          123  +!endif # "$(MAKEFILEVC)" == ""
          124  +
          125  +!if !exist("$(MAKEFILEVC)")
          126  +MSG = ^
          127  +You must run nmake from the directory containing the project makefile.^
          128  +If you are doing that and getting this message, set the MAKEFILEVC^
          129  +macro to the name of the project makefile.
          130  +!message WARNING: $(MSG)
          131  +!endif
          132  +
          133  +
          134  +################################################################
          135  +# 1. Define external programs being used
    29    136   
    30    137   #----------------------------------------------------------
    31    138   # Set the proper copy method to avoid overwrite questions
    32    139   # to the user when copying files and selecting the right
    33    140   # "delete all" method.
    34    141   #----------------------------------------------------------
    35    142   
    36         -!if "$(OS)" == "Windows_NT"
    37    143   RMDIR	= rmdir /S /Q
    38         -ERRNULL  = 2>NUL
    39         -!if ![ver | find "4.0" > nul]
    40         -CPY	= echo y | xcopy /i >NUL
    41         -COPY	= copy >NUL
    42         -!else
    43    144   CPY	= xcopy /i /y >NUL
          145  +CPYDIR  = xcopy /e /i /y >NUL
    44    146   COPY	= copy /y >NUL
    45         -!endif
    46         -!else # "$(OS)" != "Windows_NT"
    47         -CPY	= xcopy /i >_JUNK.OUT # On Win98 NUL does not work here.
    48         -COPY	= copy >_JUNK.OUT # On Win98 NUL does not work here.
    49         -RMDIR	= deltree /Y
    50         -NULL    = \NUL # Used in testing directory existence
    51         -ERRNULL = >NUL # Win9x shell cannot redirect stderr
    52         -!endif
    53    147   MKDIR   = mkdir
    54    148   
    55         -#------------------------------------------------------------------------------
    56         -# Determine the host and target architectures and compiler version.
    57         -#------------------------------------------------------------------------------
          149  +######################################################################
          150  +# 2. Figure out our build environment in terms of what we're building.
          151  +#
          152  +# (a) Tcl itself
          153  +# (b) Tk
          154  +# (c) a Tcl extension using libraries/includes from an *installed* Tcl
          155  +# (d) a Tcl extension using libraries/includes from Tcl source directory
          156  +#
          157  +# This last is needed because some extensions still need
          158  +# some Tcl interfaces that are not publicly exposed.
          159  +#
          160  +# The fragment will set the following macros:
          161  +# ROOT - root of this module sources
          162  +# COMPATDIR - source directory that holds compatibility sources
          163  +# DOCDIR - source directory containing documentation files
          164  +# GENERICDIR - platform-independent source directory
          165  +# WINDIR - Windows-specific source directory
          166  +# TESTDIR - directory containing test files
          167  +# TOOLSDIR - directory containing build tools
          168  +# _TCLDIR - root of the Tcl installation OR the Tcl sources. Not set
          169  +#    when building Tcl itself.
          170  +# _INSTALLDIR - native form of the installation path. For Tcl
          171  +#    this will be the root of the Tcl installation. For extensions
          172  +#    this will be the lib directory under the root.
          173  +# TCLINSTALL  - set to 1 if _TCLDIR refers to
          174  +#    headers and libraries from an installed Tcl, and 0 if built against
          175  +#    Tcl sources. Not set when building Tcl itself. Yes, not very well
          176  +#    named.
          177  +# _TCL_H - native path to the tcl.h file
          178  +#
          179  +# If Tk is involved, also sets the following
          180  +# _TKDIR - native form Tk installation OR Tk source. Not set if building
          181  +#    Tk itself.
          182  +# TKINSTALL - set 1 if _TKDIR refers to installed Tk and 0 if Tk sources
          183  +# _TK_H - native path to the tk.h file
          184  +
          185  +# Root directory for sources and assumed subdirectories
          186  +ROOT = $(MAKEDIR)\..
          187  +# The following paths CANNOT have spaces in them as they appear on the
          188  +# left side of implicit rules.
          189  +!ifndef COMPATDIR
          190  +COMPATDIR	= $(ROOT)\compat
          191  +!endif
          192  +!ifndef DOCDIR
          193  +DOCDIR		= $(ROOT)\doc
          194  +!endif
          195  +!ifndef GENERICDIR
          196  +GENERICDIR	= $(ROOT)\generic
          197  +!endif
          198  +!ifndef TOOLSDIR
          199  +TOOLSDIR	= $(ROOT)\tools
          200  +!endif
          201  +!ifndef TESTDIR
          202  +TESTDIR	= $(ROOT)\tests
          203  +!endif
          204  +!ifndef LIBDIR
          205  +!if exist("$(ROOT)\library")
          206  +LIBDIR          = $(ROOT)\library
          207  +!else
          208  +LIBDIR          = $(ROOT)\lib
          209  +!endif
          210  +!endif
          211  +!ifndef DEMODIR
          212  +!if exist("$(LIBDIR)\demos")
          213  +DEMODIR		= $(LIBDIR)\demos
          214  +!else
          215  +DEMODIR		= $(ROOT)\demos
          216  +!endif
          217  +!endif # ifndef DEMODIR
          218  +# Do NOT enclose WINDIR in a !ifndef because Windows always defines
          219  +# WINDIR env var to point to c:\windows!
          220  +# TBD - This is a potentially dangerous conflict, rename WINDIR to
          221  +# something else
          222  +WINDIR		= $(ROOT)\win
          223  +
          224  +!ifndef RCDIR
          225  +!if exist("$(WINDIR)\rc")
          226  +RCDIR           = $(WINDIR)\rc
          227  +!else
          228  +RCDIR           = $(WINDIR)
          229  +!endif
          230  +!endif
          231  +RCDIR = $(RCDIR:/=\)
          232  +
          233  +# The target directory where the built packages and binaries will be installed.
          234  +# INSTALLDIR is the (optional) path specified by the user.
          235  +# _INSTALLDIR is INSTALLDIR using the backslash separator syntax
          236  +!ifdef INSTALLDIR
          237  +### Fix the path separators.
          238  +_INSTALLDIR	= $(INSTALLDIR:/=\)
          239  +!else
          240  +### Assume the normal default.
          241  +_INSTALLDIR	= $(HOMEDRIVE)\Tcl
          242  +!endif
          243  +
          244  +!if $(DOING_TCL)
          245  +
          246  +# BEGIN Case 2(a) - Building Tcl itself
          247  +
          248  +# Only need to define _TCL_H
          249  +_TCL_H = ..\generic\tcl.h
          250  +
          251  +# END Case 2(a) - Building Tcl itself
          252  +
          253  +!elseif $(DOING_TK)
          254  +
          255  +# BEGIN Case 2(b) - Building Tk
          256  +
          257  +TCLINSTALL = 0 # Tk always builds against Tcl source, not an installed Tcl
          258  +!if "$(TCLDIR)" == ""
          259  +!if [echo TCLDIR = \> nmakehlp.out] \
          260  +   || [nmakehlp -L generic\tcl.h >> nmakehlp.out]
          261  +!error *** Could not locate Tcl source directory.
          262  +!endif
          263  +!include nmakehlp.out
          264  +!endif # TCLDIR == ""
          265  +
          266  +_TCLDIR	= $(TCLDIR:/=\)
          267  +_TCL_H  = $(_TCLDIR)\generic\tcl.h
          268  +!if !exist("$(_TCL_H)")
          269  +!error Could not locate tcl.h. Please set the TCLDIR macro to point to the Tcl *source* directory.
          270  +!endif
          271  +
          272  +_TK_H = ..\generic\tk.h
          273  +
          274  +# END Case 2(b) - Building Tk
          275  +
          276  +!else
          277  +
          278  +# BEGIN Case 2(c) or (d) - Building an extension other than Tk
          279  +
          280  +# If command line has specified Tcl location through TCLDIR, use it
          281  +# else default to the INSTALLDIR setting
          282  +!if "$(TCLDIR)" != ""
          283  +
          284  +_TCLDIR	= $(TCLDIR:/=\)
          285  +!if exist("$(_TCLDIR)\include\tcl.h") # Case 2(c) with TCLDIR defined
          286  +TCLINSTALL	= 1
          287  +_TCL_H          = $(_TCLDIR)\include\tcl.h
          288  +!elseif exist("$(_TCLDIR)\generic\tcl.h") # Case 2(d) with TCLDIR defined
          289  +TCLINSTALL	= 0
          290  +_TCL_H          = $(_TCLDIR)\generic\tcl.h
          291  +!endif
          292  +
          293  +!else  #  # Case 2(c) for extensions with TCLDIR undefined
          294  +
          295  +# Need to locate Tcl depending on whether it needs Tcl source or not.
          296  +# If we don't, check the INSTALLDIR for an installed Tcl first
          297  +
          298  +!if exist("$(_INSTALLDIR)\include\tcl.h") && !$(NEED_TCL_SOURCE)
          299  +
          300  +TCLINSTALL	= 1
          301  +TCLDIR          = $(_INSTALLDIR)\..
          302  +# NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions
          303  +# later so the \.. accounts for the /lib
          304  +_TCLDIR		= $(_INSTALLDIR)\..
          305  +_TCL_H          = $(_TCLDIR)\include\tcl.h
          306  +
          307  +!else # exist(...) && ! $(NEED_TCL_SOURCE)
          308  +
          309  +!if [echo _TCLDIR = \> nmakehlp.out] \
          310  +   || [nmakehlp -L generic\tcl.h >> nmakehlp.out]
          311  +!error *** Could not locate Tcl source directory.
          312  +!endif
          313  +!include nmakehlp.out
          314  +TCLINSTALL      = 0
          315  +TCLDIR         = $(_TCLDIR)
          316  +_TCL_H          = $(_TCLDIR)\generic\tcl.h
          317  +
          318  +!endif # exist(...) && ! $(NEED_TCL_SOURCE)
          319  +
          320  +!endif # TCLDIR
          321  +
          322  +!ifndef _TCL_H
          323  +MSG =^
          324  +Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and default path does not contain tcl.h.
          325  +!error $(MSG)
          326  +!endif
          327  +
          328  +# Now do the same to locate Tk headers and libs if project requires Tk
          329  +!if $(NEED_TK)
          330  +
          331  +!if "$(TKDIR)" != ""
          332  +
          333  +_TKDIR = $(TKDIR:/=\)
          334  +!if exist("$(_TKDIR)\include\tk.h")
          335  +TKINSTALL      = 1
          336  +_TK_H          = $(_TKDIR)\include\tk.h
          337  +!elseif exist("$(_TKDIR)\generic\tk.h")
          338  +TKINSTALL      = 0
          339  +_TK_H          = $(_TKDIR)\generic\tk.h
          340  +!endif
          341  +
          342  +!else # TKDIR not defined
          343  +
          344  +# Need to locate Tcl depending on whether it needs Tcl source or not.
          345  +# If we don't, check the INSTALLDIR for an installed Tcl first
          346  +
          347  +!if exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE)
          348  +
          349  +TKINSTALL      = 1
          350  +# NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions
          351  +# later so the \.. accounts for the /lib
          352  +_TKDIR         = $(_INSTALLDIR)\..
          353  +_TK_H          = $(_TKDIR)\include\tk.h
          354  +TKDIR          = $(_TKDIR)
          355  +
          356  +!else # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE)
          357  +
          358  +!if [echo _TKDIR = \> nmakehlp.out] \
          359  +   || [nmakehlp -L generic\tk.h >> nmakehlp.out]
          360  +!error *** Could not locate Tk source directory.
          361  +!endif
          362  +!include nmakehlp.out
          363  +TKINSTALL      = 0
          364  +TKDIR          = $(_TKDIR)
          365  +_TK_H          = $(_TKDIR)\generic\tk.h
          366  +
          367  +!endif # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE)
          368  +
          369  +!endif # TKDIR
          370  +
          371  +!ifndef _TK_H
          372  +MSG =^
          373  +Failed to find tk.h. The TKDIR macro is set incorrectly or is not set and default path does not contain tk.h.
          374  +!error $(MSG)
          375  +!endif
          376  +
          377  +!endif # NEED_TK
          378  +
          379  +!if $(NEED_TCL_SOURCE) && $(TCLINSTALL)
          380  +MSG = ^
          381  +*** Warning: This extension requires the source distribution of Tcl.^
          382  +*** Please set the TCLDIR macro to point to the Tcl sources.
          383  +!error $(MSG)
          384  +!endif
          385  +
          386  +!if $(NEED_TK_SOURCE)
          387  +!if $(TKINSTALL)
          388  +MSG = ^
          389  +*** Warning: This extension requires the source distribution of Tk.^
          390  +*** Please set the TKDIR macro to point to the Tk sources.
          391  +!error $(MSG)
          392  +!endif
          393  +!endif
          394  +
          395  +
          396  +# If INSTALLDIR set to tcl installation root dir then reset to the
          397  +# lib dir for installing extensions 
          398  +!if exist("$(_INSTALLDIR)\include\tcl.h")
          399  +_INSTALLDIR=$(_INSTALLDIR)\lib
          400  +!endif
          401  +
          402  +# END Case 2(c) or (d) - Building an extension
          403  +!endif # if $(DOING_TCL)
          404  +
          405  +################################################################
          406  +# 3. Determine compiler version and architecture
          407  +# In this section, we figure out the compiler version and the
          408  +# architecture for which we are building. This sets the
          409  +# following macros:
          410  +# VCVERSION - the internal compiler version as 1200, 1400, 1910 etc.
          411  +#     This is also printed by the compiler in dotted form 19.10 etc.
          412  +# VCVER - the "marketing version", for example Visual C++ 6 for internal
          413  +#     compiler version 1200. This is kept only for legacy reasons as it
          414  +#     does not make sense for recent Microsoft compilers. Only used for
          415  +#     output directory names.
          416  +# ARCH - set to IX86 or AMD64 depending on 32- or 64-bit target
          417  +# NATIVE_ARCH - set to IX86 or AMD64 for the host machine
          418  +# MACHINE - same as $(ARCH) - legacy
          419  +# _VC_MANIFEST_EMBED_{DLL,EXE} - commands for embedding a manifest if needed
          420  +# CFG_ENCODING - set to an character encoding.
          421  +#   TBD - this is passed to compiler as TCL_CFGVAL_ENCODING but can't
          422  +#   see where it is used
          423  +
          424  +cc32		= $(CC)   # built-in default.
          425  +link32		= link
          426  +lib32		= lib
          427  +rc32		= $(RC)   # built-in default.
          428  +
          429  +#----------------------------------------------------------------
          430  +# Figure out the compiler architecture and version by writing
          431  +# the C macros to a file, preprocessing them with the C
          432  +# preprocessor and reading back the created file
    58    433   
    59    434   _HASH=^#
    60    435   _VC_MANIFEST_EMBED_EXE=
    61    436   _VC_MANIFEST_EMBED_DLL=
    62    437   VCVER=0
    63    438   !if ![echo VCVERSION=_MSC_VER > vercl.x] \
    64    439       && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
    65    440       && ![echo ARCH=IX86 >> vercl.x] \
    66    441       && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
    67    442       && ![echo ARCH=AMD64 >> vercl.x] \
    68    443       && ![echo $(_HASH)endif >> vercl.x] \
    69         -    && ![cl -nologo -TC -P vercl.x $(ERRNULL)]
          444  +    && ![$(cc32) -nologo -TC -P vercl.x 2>NUL]
    70    445   !include vercl.i
          446  +!if $(VCVERSION) < 1900
    71    447   !if ![echo VCVER= ^\> vercl.vc] \
    72    448       && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc]
    73    449   !include vercl.vc
    74    450   !endif
          451  +!else
          452  +# The simple calculation above does not apply to new Visual Studio releases
          453  +# Keep the compiler version in its native form.
          454  +VCVER = $(VCVERSION)
    75    455   !endif
    76         -!if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc]
    77    456   !endif
    78    457   
          458  +!if ![del 2>NUL /q/f vercl.x vercl.i vercl.vc]
          459  +!endif
          460  +
          461  +#----------------------------------------------------------------
          462  +# The MACHINE macro is used by legacy makefiles so set it as well
          463  +!ifdef MACHINE
          464  +!if "$(MACHINE)" == "x86"
          465  +!undef MACHINE
          466  +MACHINE = IX86
          467  +!elseif "$(MACHINE)" == "x64"
          468  +!undef MACHINE
          469  +MACHINE = AMD64
          470  +!endif
          471  +!if "$(MACHINE)" != "$(ARCH)"
          472  +!error Specified MACHINE macro $(MACHINE) does not match detected target architecture $(ARCH).
          473  +!endif
          474  +!else
          475  +MACHINE=$(ARCH)
          476  +!endif
          477  +
          478  +#------------------------------------------------------------
          479  +# Figure out the *host* architecture by reading the registry
          480  +
    79    481   !if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86]
    80    482   NATIVE_ARCH=IX86
    81    483   !else
    82    484   NATIVE_ARCH=AMD64
    83    485   !endif
    84    486   
    85    487   # Since MSVC8 we must deal with manifest resources.
    86    488   !if $(VCVERSION) >= 1400
    87    489   _VC_MANIFEST_EMBED_EXE=if exist [email protected] mt -nologo -manifest [email protected] -outputresource:[email protected];1
    88    490   _VC_MANIFEST_EMBED_DLL=if exist [email protected] mt -nologo -manifest [email protected] -outputresource:[email protected];2
    89    491   !endif
    90    492   
    91         -!ifndef MACHINE
    92         -MACHINE=$(ARCH)
    93         -!endif
    94         -
    95    493   !ifndef CFG_ENCODING
    96    494   CFG_ENCODING	= \"cp1252\"
    97    495   !endif
    98    496   
    99         -!message ===============================================================================
   100         -
   101         -#----------------------------------------------------------
   102         -# build the helper app we need to overcome nmake's limiting
   103         -# environment.
   104         -#----------------------------------------------------------
   105         -
   106         -!if !exist(nmakehlp.exe)
   107         -!if [$(cc32) -nologo nmakehlp.c -link -subsystem:console > nul]
   108         -!endif
   109         -!endif
   110         -
   111         -#----------------------------------------------------------
   112         -# Test for compiler features
   113         -#----------------------------------------------------------
   114         -
   115         -### test for optimizations
   116         -!if [nmakehlp -c -O2]
   117         -!message *** Compiler has 'Optimizations'
   118         -OPTIMIZING	= 1
   119         -!else
   120         -!message *** Compiler does not have 'Optimizations'
   121         -OPTIMIZING	= 0
   122         -!endif
   123         -
          497  +################################################################
          498  +# 4. Build the nmakehlp program
          499  +# This is a helper app we need to overcome nmake's limiting
          500  +# environment. We will call out to it to get various bits of
          501  +# information about supported compiler options etc.
          502  +#
          503  +# Tcl itself will always use the nmakehlp.c program which is
          504  +# in its own source. This is the "master" copy and kept updated.
          505  +#
          506  +# Extensions built against an installed Tcl will use the installed
          507  +# copy of Tcl's nmakehlp.c if there is one and their own version
          508  +# otherwise. In the latter case, they would also be using their own
          509  +# rules.vc. Note that older versions of Tcl do not install nmakehlp.c
          510  +# or rules.vc.
          511  +#
          512  +# Extensions built against Tcl sources will use the one from the Tcl source.
          513  +#
          514  +# When building an extension using a sufficiently new version of Tcl,
          515  +# rules-ext.vc will define NMAKEHLPC appropriately to point to the
          516  +# copy of nmakehlp.c to be used.
          517  +
          518  +!ifndef NMAKEHLPC
          519  +# Default to the one in the current directory (the extension's own nmakehlp.c)
          520  +NMAKEHLPC = nmakehlp.c
          521  +
          522  +!if !$(DOING_TCL)
          523  +!if $(TCLINSTALL)
          524  +!if exist("$(_TCLDIR)\lib\nmake\nmakehlp.c")
          525  +NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c
          526  +!endif
          527  +!else # ! $(TCLINSTALL)
          528  +!if exist("$(_TCLDIR)\win\nmakehlp.c")
          529  +NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c
          530  +!endif
          531  +!endif # $(TCLINSTALL)
          532  +!endif # !$(DOING_TCL)
          533  +
          534  +!endif # NMAKEHLPC
          535  +
          536  +# We always build nmakehlp even if it exists since we do not know
          537  +# what source it was built from.
          538  +!message *** Using $(NMAKEHLPC)
          539  +!if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul]
          540  +!endif
          541  +
          542  +################################################################
          543  +# 5. Test for compiler features
          544  +# Visual C++ compiler options have changed over the years. Check
          545  +# which options are supported by the compiler in use.
          546  +#
          547  +# The following macros are set:
          548  +# OPTIMIZATIONS - the compiler flags to be used for optimized builds
          549  +# DEBUGFLAGS - the compiler flags to be used for debug builds
          550  +# LINKERFLAGS - Flags passed to the linker 
          551  +#
          552  +# Note that these are the compiler settings *available*, not those
          553  +# that will be *used*. The latter depends on the OPTS macro settings
          554  +# which we have not yet parsed.
          555  +#
          556  +# Also note that some of the flags in OPTIMIZATIONS are not really
          557  +# related to optimization. They are placed there only for legacy reasons
          558  +# as some extensions expect them to be included in that macro.
          559  +
          560  +# -Op improves float consistency. Note only needed for older compilers
          561  +# Newer compilers do not need or support this option.
          562  +!if [nmakehlp -c -Op]
          563  +FPOPTS  = -Op
          564  +!endif
          565  +
          566  +# Strict floating point semantics - present in newer compilers in lieu of -Op
          567  +!if [nmakehlp -c -fp:strict]
          568  +FPOPTS  = $(FPOPTS) -fp:strict
          569  +!endif
          570  +
          571  +!if "$(MACHINE)" == "IX86"
          572  +### test for pentium errata
          573  +!if [nmakehlp -c -QI0f]
          574  +!message *** Compiler has 'Pentium 0x0f fix'
          575  +FPOPTS  = $(FPOPTS) -QI0f
          576  +!else
          577  +!message *** Compiler does not have 'Pentium 0x0f fix'
          578  +!endif
          579  +!endif
          580  +
          581  +### test for optimizations
   124    582   # /O2 optimization includes /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy as per
   125    583   # documentation. Note we do NOT want /Gs as that inserts a _chkstk
   126    584   # stack probe at *every* function entry, not just those with more than
   127    585   # a page of stack allocation resulting in a performance hit.  However,
   128    586   # /O2 documentation is misleading as its stack probes are simply the
   129    587   # default page size locals allocation probes and not what is implied
   130    588   # by an explicit /Gs option.
   131    589   
   132         -OPTIMIZATIONS   = -O2
          590  +OPTIMIZATIONS = $(FPOPTS)
   133    591   
   134         -# -Op improves float consistency. Note only needed for older compilers
   135         -# Newer compilers do not need or support this option.
   136         -!if [nmakehlp -c -Op]
   137         -OPTIMIZATIONS  = $(OPTIMIZATIONS) -Op
          592  +!if [nmakehlp -c -O2]
          593  +!message *** Compiler has 'Optimizations'
          594  +OPTIMIZING = 1
          595  +OPTIMIZATIONS   = $(OPTIMIZATIONS) -O2
          596  +!else
          597  +# Legacy, really. All modern compilers support this
          598  +!message *** Compiler does not have 'Optimizations'
          599  +OPTIMIZING = 0
   138    600   !endif
   139    601   
   140         -# Strict floating point semantics
   141         -!if [nmakehlp -c -fp:strict]
   142         -OPTIMIZATIONS  = $(OPTIMIZATIONS) -fp:strict
   143         -!endif
   144         -
   145         -# Enable security checks for buffer overflows
          602  +# Checks for buffer overflows in local arrays
   146    603   !if [nmakehlp -c -GS]
   147    604   OPTIMIZATIONS  = $(OPTIMIZATIONS) -GS
   148    605   !endif
   149    606   
   150         -# Whole program optimization. Note this makes the generated libraries
   151         -# potentially incompatible with other versions of Visual C++
          607  +# Link time optimization. Note that this option (potentially) makes
          608  +# generated libraries only usable by the specific VC++ version that
          609  +# created it. Requires /LTCG linker option
   152    610   !if [nmakehlp -c -GL]
   153    611   OPTIMIZATIONS  = $(OPTIMIZATIONS) -GL
          612  +CC_GL_OPT_ENABLED = 1
          613  +!else
          614  +# In newer compilers -GL and -YX are incompatible.
          615  +!if [nmakehlp -c -YX]
          616  +OPTIMIZATIONS  = $(OPTIMIZATIONS) -YX
   154    617   !endif
          618  +!endif # [nmakehlp -c -GL]
   155    619   
   156         -DEBUGFLAGS     =
          620  +DEBUGFLAGS     = $(FPOPTS)
   157    621   
          622  +# Run time error checks. Not available or valid in a release, non-debug build
          623  +# RTC is for modern compilers, -GZ is legacy
   158    624   !if [nmakehlp -c -RTC1]
   159    625   DEBUGFLAGS     = $(DEBUGFLAGS) -RTC1
   160    626   !elseif [nmakehlp -c -GZ]
   161    627   DEBUGFLAGS     = $(DEBUGFLAGS) -GZ
   162    628   !endif
   163    629   
   164         -COMPILERFLAGS  =-W3 /DUNICODE /D_UNICODE /D_ATL_XP_TARGETING
          630  +#----------------------------------------------------------------
          631  +# Linker flags
   165    632   
   166         -# In v13 -GL and -YX are incompatible.
   167         -!if [nmakehlp -c -YX]
   168         -!if ![nmakehlp -c -GL]
   169         -OPTIMIZATIONS  = $(OPTIMIZATIONS) -YX
   170         -!endif
   171         -!endif
   172         -
   173         -!if "$(MACHINE)" == "IX86"
   174         -### test for pentium errata
   175         -!if [nmakehlp -c -QI0f]
   176         -!message *** Compiler has 'Pentium 0x0f fix'
   177         -COMPILERFLAGS  = $(COMPILERFLAGS) -QI0f
   178         -!else
   179         -!message *** Compiler does not have 'Pentium 0x0f fix'
   180         -!endif
   181         -!endif
   182         -
   183         -!if "$(MACHINE)" == "IA64"
   184         -### test for Itanium errata
   185         -!if [nmakehlp -c -QIA64_Bx]
   186         -!message *** Compiler has 'B-stepping errata workarounds'
   187         -COMPILERFLAGS   = $(COMPILERFLAGS) -QIA64_Bx
   188         -!else
   189         -!message *** Compiler does not have 'B-stepping errata workarounds'
   190         -!endif
   191         -!endif
   192         -
   193         -# Prevents "LNK1561: entry point must be defined" error compiling from VS-IDE:
          633  +# LINKER_TESTFLAGS are for internal use when we call nmakehlp to test
          634  +# if the linker supports a specific option. Without these flags link will
          635  +# return "LNK1561: entry point must be defined" error compiling from VS-IDE:
          636  +# They are not passed through to the actual application / extension
          637  +# link rules.
   194    638   !ifndef LINKER_TESTFLAGS
   195         -LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmhlp-out.txt
   196         -!endif
   197         -
   198         -!if "$(MACHINE)" == "IX86"
   199         -### test for -align:4096, when align:512 will do.
   200         -!if [nmakehlp -l -opt:nowin98 $(LINKER_TESTFLAGS)]
   201         -!message *** Linker has 'Win98 alignment problem'
   202         -ALIGN98_HACK	= 1
   203         -!else
   204         -!message *** Linker does not have 'Win98 alignment problem'
   205         -ALIGN98_HACK	= 0
   206         -!endif
   207         -!else
   208         -ALIGN98_HACK	= 0
          639  +LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmakehlp.out
   209    640   !endif
   210    641   
   211    642   LINKERFLAGS     =
   212    643   
          644  +# If compiler has enabled link time optimization, linker must too with -ltcg
          645  +!ifdef CC_GL_OPT_ENABLED
   213    646   !if [nmakehlp -l -ltcg $(LINKER_TESTFLAGS)]
   214         -LINKERFLAGS     =-ltcg
          647  +LINKERFLAGS     = $(LINKERFLAGS) -ltcg
          648  +!endif
   215    649   !endif
   216    650   
   217         -#----------------------------------------------------------
   218         -# Decode the options requested.
   219         -#----------------------------------------------------------
          651  +########################################################################
          652  +# 6. Parse the OPTS macro to work out the requested build configuration.
          653  +# Based on this, we will construct the actual switches to be passed to the
          654  +# compiler and linker using the macros defined in the previous section.
          655  +# The following macros are defined by this section based on OPTS
          656  +# STATIC_BUILD - 0 -> Tcl is to be built as a shared library
          657  +#                1 -> build as a static library and shell
          658  +# TCL_THREADS - legacy but always 1 on Windows since winsock requires it.
          659  +# DEBUG - 1 -> debug build, 0 -> release builds
          660  +# SYMBOLS - 1 -> generate PDB's, 0 -> no PDB's
          661  +# PROFILE - 1 -> generate profiling info, 0 -> no profiling
          662  +# PGO     - 1 -> profile based optimization, 0 -> no
          663  +# MSVCRT  - 1 -> link to dynamic C runtime even when building static Tcl build
          664  +#           0 -> link to static C runtime for static Tcl build.
          665  +#           Does not impact shared Tcl builds (STATIC_BUILD == 0)
          666  +# TCL_USE_STATIC_PACKAGES - 1 -> statically link the registry and dde extensions
          667  +#           in the Tcl shell. 0 -> keep them as shared libraries
          668  +#           Does not impact shared Tcl builds.
          669  +# USE_THREAD_ALLOC - 1 -> Use a shared global free pool for allocation.
          670  +#           0 -> Use the non-thread allocator.
          671  +# UNCHECKED - 1 -> when doing a debug build with symbols, use the release
          672  +#           C runtime, 0 -> use the debug C runtime.
          673  +# USE_STUBS - 1 -> compile to use stubs interfaces, 0 -> direct linking
          674  +# CONFIG_CHECK - 1 -> check current build configuration against Tcl
          675  +#           configuration (ignored for Tcl itself)
          676  +# Further, LINKERFLAGS are modified based on above.
   220    677   
   221         -!if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"]
          678  +# Default values for all the above
   222    679   STATIC_BUILD	= 0
   223    680   TCL_THREADS	= 1
   224    681   DEBUG		= 0
   225    682   SYMBOLS		= 0
   226    683   PROFILE		= 0
   227    684   PGO		= 0
   228    685   MSVCRT		= 1
   229         -LOIMPACT	= 0
   230    686   TCL_USE_STATIC_PACKAGES	= 0
   231    687   USE_THREAD_ALLOC = 1
   232    688   UNCHECKED	= 0
          689  +CONFIG_CHECK    = 1
          690  +!if $(DOING_TCL)
          691  +USE_STUBS       = 0
   233    692   !else
          693  +USE_STUBS       = 1
          694  +!endif
          695  +
          696  +# If OPTS is not empty AND does not contain "none" which turns off all OPTS
          697  +# set the above macros based on OPTS content
          698  +!if "$(OPTS)" != "" && ![nmakehlp -f "$(OPTS)" "none"]
          699  +
          700  +# OPTS are specified, parse them
          701  +
   234    702   !if [nmakehlp -f $(OPTS) "static"]
   235    703   !message *** Doing static
   236    704   STATIC_BUILD	= 1
   237         -!else
   238         -STATIC_BUILD	= 0
   239    705   !endif
          706  +
          707  +!if [nmakehlp -f $(OPTS) "nostubs"]
          708  +!message *** Not using stubs
          709  +USE_STUBS	= 0
          710  +!endif
          711  +
   240    712   !if [nmakehlp -f $(OPTS) "nomsvcrt"]
   241    713   !message *** Doing nomsvcrt
   242    714   MSVCRT		= 0
   243    715   !else
   244    716   !if [nmakehlp -f $(OPTS) "msvcrt"]
   245    717   !message *** Doing msvcrt
   246    718   MSVCRT		= 1
................................................................................
   247    719   !else
   248    720   !if !$(STATIC_BUILD)
   249    721   MSVCRT		= 1
   250    722   !else
   251    723   MSVCRT		= 0
   252    724   !endif
   253    725   !endif
   254         -!endif
          726  +!endif # [nmakehlp -f $(OPTS) "nomsvcrt"]
          727  +
   255    728   !if [nmakehlp -f $(OPTS) "staticpkg"] && $(STATIC_BUILD)
   256    729   !message *** Doing staticpkg
   257    730   TCL_USE_STATIC_PACKAGES	= 1
   258    731   !else
   259    732   TCL_USE_STATIC_PACKAGES	= 0
   260    733   !endif
          734  +
   261    735   !if [nmakehlp -f $(OPTS) "nothreads"]
   262    736   !message *** Compile explicitly for non-threaded tcl
   263    737   TCL_THREADS	= 0
   264    738   USE_THREAD_ALLOC= 0
   265    739   !else
   266    740   TCL_THREADS	= 1
   267    741   USE_THREAD_ALLOC= 1
   268    742   !endif
          743  +
   269    744   !if [nmakehlp -f $(OPTS) "symbols"]
   270    745   !message *** Doing symbols
   271    746   DEBUG		= 1
   272    747   !else
   273    748   DEBUG		= 0
   274    749   !endif
          750  +
   275    751   !if [nmakehlp -f $(OPTS) "pdbs"]
   276    752   !message *** Doing pdbs
   277    753   SYMBOLS		= 1
   278    754   !else
   279    755   SYMBOLS		= 0
   280    756   !endif
          757  +
   281    758   !if [nmakehlp -f $(OPTS) "profile"]
   282    759   !message *** Doing profile
   283    760   PROFILE		= 1
   284    761   !else
   285    762   PROFILE		= 0
   286    763   !endif
          764  +
   287    765   !if [nmakehlp -f $(OPTS) "pgi"]
   288    766   !message *** Doing profile guided optimization instrumentation
   289    767   PGO		= 1
   290    768   !elseif [nmakehlp -f $(OPTS) "pgo"]
   291    769   !message *** Doing profile guided optimization
   292    770   PGO		= 2
   293    771   !else
   294    772   PGO		= 0
   295    773   !endif
          774  +
   296    775   !if [nmakehlp -f $(OPTS) "loimpact"]
   297         -!message *** Doing loimpact
   298         -LOIMPACT	= 1
   299         -!else
   300         -LOIMPACT	= 0
          776  +!message *** Warning: ignoring option "loimpact" - deprecated on modern Windows.
   301    777   !endif
          778  +
          779  +# TBD - should get rid of this option
   302    780   !if [nmakehlp -f $(OPTS) "thrdalloc"]
   303    781   !message *** Doing thrdalloc
   304    782   USE_THREAD_ALLOC = 1
   305    783   !endif
          784  +
   306    785   !if [nmakehlp -f $(OPTS) "tclalloc"]
   307         -!message *** Doing tclalloc
   308    786   USE_THREAD_ALLOC = 0
   309    787   !endif
          788  +
   310    789   !if [nmakehlp -f $(OPTS) "unchecked"]
   311    790   !message *** Doing unchecked
   312    791   UNCHECKED = 1
   313    792   !else
   314    793   UNCHECKED = 0
   315    794   !endif
   316         -!endif
   317         -
   318         -#----------------------------------------------------------
          795  +
          796  +!if [nmakehlp -f $(OPTS) "noconfigcheck"]
          797  +CONFIG_CHECK = 1
          798  +!else
          799  +CONFIG_CHECK = 0
          800  +!endif
          801  +
          802  +!endif # "$(OPTS)" != ""  && ... parsing of OPTS
          803  +
          804  +# Set linker flags based on above
          805  +
          806  +!if $(PGO) > 1
          807  +!if [nmakehlp -l -ltcg:pgoptimize $(LINKER_TESTFLAGS)]
          808  +LINKERFLAGS	= $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize
          809  +!else
          810  +MSG=^
          811  +This compiler does not support profile guided optimization.
          812  +!error $(MSG)
          813  +!endif
          814  +!elseif $(PGO) > 0
          815  +!if [nmakehlp -l -ltcg:pginstrument $(LINKER_TESTFLAGS)]
          816  +LINKERFLAGS	= $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument
          817  +!else
          818  +MSG=^
          819  +This compiler does not support profile guided optimization.
          820  +!error $(MSG)
          821  +!endif
          822  +!endif
          823  +
          824  +################################################################
          825  +# 7. Parse the STATS macro to configure code instrumentation
          826  +# The following macros are set by this section:
          827  +# TCL_MEM_DEBUG - 1 -> enables memory allocation instrumentation
          828  +#                 0 -> disables
          829  +# TCL_COMPILE_DEBUG - 1 -> enables byte compiler logging
          830  +#                     0 -> disables
          831  +
          832  +# Default both are off
          833  +TCL_MEM_DEBUG	    = 0
          834  +TCL_COMPILE_DEBUG   = 0
          835  +
          836  +!if "$(STATS)" != "" && ![nmakehlp -f "$(STATS)" "none"]
          837  +
          838  +!if [nmakehlp -f $(STATS) "memdbg"]
          839  +!message *** Doing memdbg
          840  +TCL_MEM_DEBUG	    = 1
          841  +!else
          842  +TCL_MEM_DEBUG	    = 0
          843  +!endif
          844  +
          845  +!if [nmakehlp -f $(STATS) "compdbg"]
          846  +!message *** Doing compdbg
          847  +TCL_COMPILE_DEBUG   = 1
          848  +!else
          849  +TCL_COMPILE_DEBUG   = 0
          850  +!endif
          851  +
          852  +!endif
          853  +
          854  +####################################################################
          855  +# 8. Parse the CHECKS macro to configure additional compiler checks
          856  +# The following macros are set by this section:
          857  +# WARNINGS - compiler switches that control the warnings level
          858  +# TCL_NO_DEPRECATED - 1 -> disable support for deprecated functions
          859  +#                     0 -> enable deprecated functions
          860  +
          861  +# Defaults - Permit deprecated functions and warning level 3
          862  +TCL_NO_DEPRECATED	    = 0
          863  +WARNINGS		    = -W3
          864  +
          865  +!if "$(CHECKS)" != "" && ![nmakehlp -f "$(CHECKS)" "none"]
          866  +
          867  +!if [nmakehlp -f $(CHECKS) "nodep"]
          868  +!message *** Doing nodep check
          869  +TCL_NO_DEPRECATED	    = 1
          870  +!endif
          871  +
          872  +!if [nmakehlp -f $(CHECKS) "fullwarn"]
          873  +!message *** Doing full warnings check
          874  +WARNINGS		    = -W4
          875  +!if [nmakehlp -l -warn:3 $(LINKER_TESTFLAGS)]
          876  +LINKERFLAGS		    = $(LINKERFLAGS) -warn:3
          877  +!endif
          878  +!endif
          879  +
          880  +!if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64]
          881  +!message *** Doing 64bit portability warnings
          882  +WARNINGS		    = $(WARNINGS) -Wp64
          883  +!endif
          884  +
          885  +!endif
          886  +
          887  +################################################################
          888  +# 9. Extract various version numbers
          889  +# For Tcl and Tk, version numbers are extracted from tcl.h and tk.h
          890  +# respectively. For extensions, versions are extracted from the
          891  +# configure.in or configure.ac from the TEA configuration if it
          892  +# exists, and unset otherwise.
          893  +# Sets the following macros:
          894  +# TCL_MAJOR_VERSION
          895  +# TCL_MINOR_VERSION
          896  +# TCL_PATCH_LEVEL
          897  +# TCL_VERSION
          898  +# TK_MAJOR_VERSION
          899  +# TK_MINOR_VERSION
          900  +# TK_PATCH_LEVEL
          901  +# TK_VERSION
          902  +# DOTVERSION - set as (for example) 2.5
          903  +# VERSION - set as (for example 25)
          904  +#--------------------------------------------------------------
          905  +
          906  +!if [echo REM = This file is generated from rules.vc > versions.vc]
          907  +!endif
          908  +!if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
          909  +   && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
          910  +!endif
          911  +!if [echo TCL_MINOR_VERSION = \>> versions.vc] \
          912  +   && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
          913  +!endif
          914  +!if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
          915  +   && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
          916  +!endif
          917  +
          918  +!if defined(_TK_H)
          919  +!if [echo TK_MAJOR_VERSION = \>> versions.vc] \
          920  +   && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
          921  +!endif
          922  +!if [echo TK_MINOR_VERSION = \>> versions.vc] \
          923  +   && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
          924  +!endif
          925  +!if [echo TK_PATCH_LEVEL = \>> versions.vc] \
          926  +   && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
          927  +!endif
          928  +!endif # _TK_H
          929  +
          930  +!include versions.vc
          931  +
          932  +TCL_VERSION	= $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
          933  +TCL_DOTVERSION	= $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
          934  +!if defined(_TK_H)
          935  +TK_VERSION	= $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
          936  +TK_DOTVERSION	= $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
          937  +!endif
          938  +
          939  +# Set DOTVERSION and VERSION
          940  +!if $(DOING_TCL)
          941  +
          942  +DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
          943  +VERSION = $(TCL_VERSION)
          944  +
          945  +!elseif $(DOING_TK)
          946  +
          947  +DOTVERSION = $(TK_DOTVERSION)
          948  +VERSION = $(TK_VERSION)
          949  +
          950  +!else # Doing a non-Tk extension
          951  +
          952  +# If parent makefile has not defined DOTVERSION, try to get it from TEA
          953  +# first from a configure.in file, and then from configure.ac
          954  +!ifndef DOTVERSION
          955  +!if [echo DOTVERSION = \> versions.vc] \
          956  +   || [nmakehlp -V $(ROOT)\configure.in ^[$(PROJECT)^] >> versions.vc]
          957  +!if [echo DOTVERSION = \> versions.vc] \
          958  +   || [nmakehlp -V $(ROOT)\configure.ac ^[$(PROJECT)^] >> versions.vc]
          959  +!error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
          960  +!endif
          961  +!endif
          962  +!include versions.vc
          963  +!endif # DOTVERSION
          964  +VERSION         = $(DOTVERSION:.=)
          965  +
          966  +!endif # $(DOING_TCL) ... etc.
          967  +
          968  +################################################################
          969  +# 10. Construct output directory and file paths
   319    970   # Figure-out how to name our intermediate and output directories.
   320         -# We wouldn't want different builds to use the same .obj files
   321         -# by accident.
   322         -#----------------------------------------------------------
   323         -
   324         -#----------------------------------------
   325         -# Naming convention:
          971  +# In order to avoid inadvertent mixing of object files built using
          972  +# different compilers, build configurations etc.,
          973  +#
          974  +# Naming convention (suffixes):
   326    975   #   t = full thread support.
   327         -#   s = static library (as opposed to an
   328         -#	import library)
   329         -#   g = linked to the debug enabled C
   330         -#	run-time.
   331         -#   x = special static build when it
   332         -#	links to the dynamic C run-time.
   333         -#----------------------------------------
          976  +#   s = static library (as opposed to an import library)
          977  +#   g = linked to the debug enabled C run-time.
          978  +#   x = special static build when it links to the dynamic C run-time.
          979  +#
          980  +# The following macros are set in this section:
          981  +# SUFX - the suffix to use for binaries based on above naming convention
          982  +# BUILDDIRTOP - the toplevel default output directory
          983  +#      is of the form {Release,Debug}[_AMD64][_COMPILERVERSION]
          984  +# TMP_DIR - directory where object files are created
          985  +# OUT_DIR - directory where output executables are created
          986  +# Both TMP_DIR and OUT_DIR are defaulted only if not defined by the
          987  +# parent makefile (or command line). The default values are
          988  +# based on BUILDDIRTOP.
          989  +# STUBPREFIX - name of the stubs library for this project
          990  +# PRJIMPLIB - output path of the generated project import library
          991  +# PRJLIBNAME - name of generated project library
          992  +# PRJLIB     - output path of generated project library
          993  +# PRJSTUBLIBNAME - name of the generated project stubs library
          994  +# PRJSTUBLIB - output path of the generated project stubs library
          995  +# RESFILE - output resource file (only if not static build)
          996  +
   334    997   SUFX	    = tsgx
   335    998   
   336    999   !if $(DEBUG)
   337   1000   BUILDDIRTOP = Debug
   338   1001   !else
   339   1002   BUILDDIRTOP = Release
   340   1003   !endif
................................................................................
   379   1042   !endif
   380   1043   !else
   381   1044   !ifndef OUT_DIR
   382   1045   OUT_DIR	    = $(TMP_DIR)
   383   1046   !endif
   384   1047   !endif
   385   1048   
   386         -
   387         -#----------------------------------------------------------
   388         -# Decode the statistics requested.
   389         -#----------------------------------------------------------
   390         -
   391         -!if "$(STATS)" == "" || [nmakehlp -f "$(STATS)" "none"]
   392         -TCL_MEM_DEBUG	    = 0
   393         -TCL_COMPILE_DEBUG   = 0
   394         -!else
   395         -!if [nmakehlp -f $(STATS) "memdbg"]
   396         -!message *** Doing memdbg
   397         -TCL_MEM_DEBUG	    = 1
   398         -!else
   399         -TCL_MEM_DEBUG	    = 0
   400         -!endif
   401         -!if [nmakehlp -f $(STATS) "compdbg"]
   402         -!message *** Doing compdbg
   403         -TCL_COMPILE_DEBUG   = 1
   404         -!else
   405         -TCL_COMPILE_DEBUG   = 0
   406         -!endif
   407         -!endif
   408         -
   409         -
   410         -#----------------------------------------------------------
   411         -# Decode the checks requested.
   412         -#----------------------------------------------------------
   413         -
   414         -!if "$(CHECKS)" == "" || [nmakehlp -f "$(CHECKS)" "none"]
   415         -TCL_NO_DEPRECATED	    = 0
   416         -WARNINGS		    = -W3
         1049  +# Relative paths -> absolute
         1050  +!if [echo OUT_DIR = \> nmakehlp.out] \
         1051  +   || [nmakehlp -Q "$(OUT_DIR)" >> nmakehlp.out]
         1052  +!error *** Could not fully qualify path OUT_DIR=$(OUT_DIR)
         1053  +!endif
         1054  +!if [echo TMP_DIR = \>> nmakehlp.out] \
         1055  +   || [nmakehlp -Q "$(TMP_DIR)" >> nmakehlp.out]
         1056  +!error *** Could not fully qualify path TMP_DIR=$(TMP_DIR)
         1057  +!endif
         1058  +!include nmakehlp.out
         1059  +
         1060  +# The name of the stubs library for the project being built
         1061  +STUBPREFIX      = $(PROJECT)stub
         1062  +
         1063  +# Set up paths to various Tcl executables and libraries needed by extensions
         1064  +!if $(DOING_TCL)
         1065  +
         1066  +TCLSHNAME       = $(PROJECT)sh$(TCL_VERSION)$(SUFX).exe
         1067  +TCLSH		= $(OUT_DIR)\$(TCLSHNAME)
         1068  +TCLIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
         1069  +TCLLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
         1070  +TCLLIB		= $(OUT_DIR)\$(TCLLIBNAME)
         1071  +
         1072  +TCLSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
         1073  +TCLSTUBLIB	= $(OUT_DIR)\$(TCLSTUBLIBNAME)
         1074  +TCL_INCLUDES    = -I"$(WINDIR)" -I"$(GENERICDIR)"
         1075  +
         1076  +!else # ! $(DOING_TCL)
         1077  +
         1078  +!if $(TCLINSTALL) # Building against an installed Tcl
         1079  +
         1080  +TCLSH		= $(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe
         1081  +!if !exist("$(TCLSH)") && $(TCL_THREADS)
         1082  +TCLSH           = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe
         1083  +!endif
         1084  +TCLSTUBLIB	= $(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib
         1085  +TCLIMPLIB	= $(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib
         1086  +TCL_LIBRARY	= $(_TCLDIR)\lib
         1087  +TCLREGLIB	= $(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib
         1088  +TCLDDELIB	= $(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib
         1089  +TCLTOOLSDIR	= \must\have\tcl\sources\to\build\this\target
         1090  +TCL_INCLUDES    = -I"$(_TCLDIR)\include"
         1091  +
         1092  +!else # Building against Tcl sources
         1093  +
         1094  +TCLSH		= $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe
         1095  +!if !exist($(TCLSH)) && $(TCL_THREADS)
         1096  +TCLSH		= $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX).exe
         1097  +!endif
         1098  +TCLSTUBLIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib
         1099  +TCLIMPLIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib
         1100  +TCL_LIBRARY	= $(_TCLDIR)\library
         1101  +TCLREGLIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib
         1102  +TCLDDELIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib
         1103  +TCLTOOLSDIR	= $(_TCLDIR)\tools
         1104  +TCL_INCLUDES	= -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
         1105  +
         1106  +!endif # TCLINSTALL
         1107  +
         1108  +tcllibs = "$(TCLSTUBLIB)" "$(TCLIMPLIB)"
         1109  +
         1110  +!endif # $(DOING_TCL)
         1111  +
         1112  +# We need a tclsh that will run on the host machine as part of the build.
         1113  +# IX86 runs on all architectures.
         1114  +!ifndef TCLSH_NATIVE
         1115  +!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
         1116  +TCLSH_NATIVE	= $(TCLSH)
   417   1117   !else
   418         -!if [nmakehlp -f $(CHECKS) "nodep"]
   419         -!message *** Doing nodep check
   420         -TCL_NO_DEPRECATED	    = 1
   421         -!else
   422         -TCL_NO_DEPRECATED	    = 0
   423         -!endif
   424         -!if [nmakehlp -f $(CHECKS) "fullwarn"]
   425         -!message *** Doing full warnings check
   426         -WARNINGS		    = -W4
   427         -!if [nmakehlp -l -warn:3 $(LINKER_TESTFLAGS)]
   428         -LINKERFLAGS		    = $(LINKERFLAGS) -warn:3
   429         -!endif
         1118  +!error You must explicitly set TCLSH_NATIVE for cross-compilation
         1119  +!endif
         1120  +!endif
         1121  +
         1122  +# Do the same for Tk and Tk extensions that require the Tk libraries
         1123  +!if $(DOING_TK) || $(NEED_TK)
         1124  +WISHNAMEPREFIX = wish
         1125  +WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe
         1126  +TKLIBNAME	= $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT)
         1127  +TKSTUBLIBNAME	= tkstub$(TK_VERSION).lib
         1128  +TKIMPLIBNAME	= tk$(TK_VERSION)$(SUFX).lib
         1129  +
         1130  +!if $(DOING_TK)
         1131  +WISH 		= $(OUT_DIR)\$(WISHNAME)
         1132  +TKSTUBLIB	= $(OUT_DIR)\$(TKSTUBLIBNAME)
         1133  +TKIMPLIB	= $(OUT_DIR)\$(TKIMPLIBNAME)
         1134  +TKLIB		= $(OUT_DIR)\$(TKLIBNAME)
         1135  +TK_INCLUDES    = -I"$(WINDIR)" -I"$(GENERICDIR)"
         1136  +
         1137  +!else # effectively NEED_TK
         1138  +
         1139  +!if $(TKINSTALL) # Building against installed Tk
         1140  +WISH		= $(_TKDIR)\bin\$(WISHNAME)
         1141  +TKSTUBLIB	= $(_TKDIR)\lib\$(TKSTUBLIBNAME)
         1142  +TKIMPLIB	= $(_TKDIR)\lib\$(TKIMPLIBNAME)
         1143  +TK_INCLUDES     = -I"$(_TKDIR)\include"
         1144  +!else # Building against Tk sources
         1145  +WISH		= $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME)
         1146  +TKSTUBLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME)
         1147  +TKIMPLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
         1148  +TK_INCLUDES     = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
         1149  +!endif # TKINSTALL
         1150  +tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)"
         1151  +
         1152  +!endif # $(DOING_TK)
         1153  +!endif # $(DOING_TK) || $(NEED_TK)
         1154  +
         1155  +# Various output paths
         1156  +PRJIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
         1157  +PRJLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
         1158  +PRJLIB		= $(OUT_DIR)\$(PRJLIBNAME)
         1159  +
         1160  +PRJSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
         1161  +PRJSTUBLIB	= $(OUT_DIR)\$(PRJSTUBLIBNAME)
         1162  +
         1163  +# If extension parent makefile has not defined a resource definition file,
         1164  +# we will generate one from standard template.
         1165  +!if !$(DOING_TCL) && !$(DOING_TK) && !$(STATIC_BUILD)
         1166  +!ifdef RCFILE
         1167  +RESFILE = $(TMP_DIR)\$(RCFILE:.rc=.res)
   430   1168   !else
   431         -WARNINGS		    = -W3
   432         -!endif
   433         -!if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64]
   434         -!message *** Doing 64bit portability warnings
   435         -WARNINGS		    = $(WARNINGS) -Wp64
   436         -!endif
   437         -!endif
   438         -
   439         -!if $(PGO) > 1
   440         -!if [nmakehlp -l -ltcg:pgoptimize $(LINKER_TESTFLAGS)]
   441         -LINKERFLAGS	= $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize
   442         -!else
   443         -MSG=^
   444         -This compiler does not support profile guided optimization.
   445         -!error $(MSG)
   446         -!endif
   447         -!elseif $(PGO) > 0
   448         -!if [nmakehlp -l -ltcg:pginstrument $(LINKER_TESTFLAGS)]
   449         -LINKERFLAGS	= $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument
   450         -!else
   451         -MSG=^
   452         -This compiler does not support profile guided optimization.
   453         -!error $(MSG)
   454         -!endif
   455         -!endif
   456         -
   457         -#----------------------------------------------------------
   458         -# Set our defines now armed with our options.
   459         -#----------------------------------------------------------
         1169  +RESFILE = $(TMP_DIR)\$(PROJECT).res
         1170  +!endif
         1171  +!endif
         1172  +
         1173  +###################################################################
         1174  +# 11. Construct the paths for the installation directories
         1175  +# The following macros get defined in this section:
         1176  +# LIB_INSTALL_DIR - where libraries should be installed
         1177  +# BIN_INSTALL_DIR - where the executables should be installed
         1178  +# DOC_INSTALL_DIR - where documentation should be installed
         1179  +# SCRIPT_INSTALL_DIR - where scripts should be installed
         1180  +# INCLUDE_INSTALL_DIR - where C include files should be installed
         1181  +# DEMO_INSTALL_DIR - where demos should be installed
         1182  +# PRJ_INSTALL_DIR - where package will be installed (not set for tcl and tk)
         1183  +
         1184  +!if $(DOING_TCL) || $(DOING_TK)
         1185  +LIB_INSTALL_DIR		= $(_INSTALLDIR)\lib
         1186  +BIN_INSTALL_DIR		= $(_INSTALLDIR)\bin
         1187  +DOC_INSTALL_DIR		= $(_INSTALLDIR)\doc
         1188  +!if $(DOING_TCL)
         1189  +SCRIPT_INSTALL_DIR	= $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
         1190  +!else # DOING_TK
         1191  +SCRIPT_INSTALL_DIR	= $(_INSTALLDIR)\lib\$(PROJECT)$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
         1192  +!endif
         1193  +DEMO_INSTALL_DIR	= $(SCRIPT_INSTALL_DIR)\demos
         1194  +INCLUDE_INSTALL_DIR	= $(_INSTALLDIR)\include
         1195  +
         1196  +!else # extension other than Tk
         1197  +
         1198  +PRJ_INSTALL_DIR         = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
         1199  +LIB_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
         1200  +BIN_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
         1201  +DOC_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
         1202  +SCRIPT_INSTALL_DIR	= $(PRJ_INSTALL_DIR)
         1203  +DEMO_INSTALL_DIR	= $(PRJ_INSTALL_DIR)\demos
         1204  +INCLUDE_INSTALL_DIR	= $(_TCLDIR)\include
         1205  +
         1206  +!endif
         1207  +
         1208  +###################################################################
         1209  +# 12. Set up actual options to be passed to the compiler and linker
         1210  +# Now we have all the information we need, set up the actual flags and
         1211  +# options that we will pass to the compiler and linker. The main
         1212  +# makefile should use these in combination with whatever other flags
         1213  +# and switches are specific to it.
         1214  +# The following macros are defined, names are for historical compatibility:
         1215  +# OPTDEFINES - /Dxxx C macro flags based on user-specified OPTS
         1216  +# COMPILERFLAGS - /Dxxx C macro flags independent of any configuration opttions
         1217  +# crt - Compiler switch that selects the appropriate C runtime
         1218  +# cdebug - Compiler switches related to debug AND optimizations
         1219  +# cwarn - Compiler switches that set warning levels
         1220  +# cflags - complete compiler switches (subsumes cdebug and cwarn)
         1221  +# ldebug - Linker switches controlling debug information and optimization
         1222  +# lflags - complete linker switches (subsumes ldebug) except subsystem type
         1223  +# dlllflags - complete linker switches to build DLLs (subsumes lflags)
         1224  +# conlflags - complete linker switches for console program (subsumes lflags)
         1225  +# guilflags - complete linker switches for GUI program (subsumes lflags)
         1226  +# baselibs - minimum Windows libraries required. Parent makefile can
         1227  +#    define PRJ_LIBS before including rules.rc if additional libs are needed
   460   1228   
   461   1229   OPTDEFINES	= -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS
   462   1230   
   463   1231   !if $(TCL_MEM_DEBUG)
   464   1232   OPTDEFINES	= $(OPTDEFINES) -DTCL_MEM_DEBUG
   465   1233   !endif
   466   1234   !if $(TCL_COMPILE_DEBUG)
................................................................................
   475   1243   !if $(STATIC_BUILD)
   476   1244   OPTDEFINES	= $(OPTDEFINES) -DSTATIC_BUILD
   477   1245   !endif
   478   1246   !if $(TCL_NO_DEPRECATED)
   479   1247   OPTDEFINES	= $(OPTDEFINES) -DTCL_NO_DEPRECATED
   480   1248   !endif
   481   1249   
         1250  +!if $(USE_STUBS)
         1251  +# Note we do not define USE_TCL_STUBS even when building tk since some
         1252  +# test targets in tk do not use stubs
         1253  +!if ! $(DOING_TCL)
         1254  +USE_STUBS_DEFS  = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS
         1255  +!if $(NEED_TK)
         1256  +USE_STUBS_DEFS  = $(USE_STUBS_DEFS) -DUSE_TK_STUBS
         1257  +!endif
         1258  +!endif
         1259  +!endif # USE_STUBS
         1260  +
   482   1261   !if !$(DEBUG)
   483   1262   OPTDEFINES	= $(OPTDEFINES) -DNDEBUG
   484   1263   !if $(OPTIMIZING)
   485   1264   OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_OPTIMIZED
   486   1265   !endif
   487   1266   !endif
   488   1267   !if $(PROFILE)
   489   1268   OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_PROFILED
   490   1269   !endif
   491         -!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
         1270  +!if "$(MACHINE)" == "AMD64"
   492   1271   OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_DO64BIT
   493   1272   !endif
   494   1273   !if $(VCVERSION) < 1300
   495   1274   OPTDEFINES	= $(OPTDEFINES) -DNO_STRTOI64
   496   1275   !endif
   497   1276   
   498         -#----------------------------------------------------------
   499         -# Locate the Tcl headers to build against
   500         -#----------------------------------------------------------
   501         -
   502         -!if "$(PROJECT)" == "tcl"
   503         -
   504         -_TCL_H          = ..\generic\tcl.h
         1277  +# _ATL_XP_TARGETING - Newer SDK's need this to build for XP
         1278  +COMPILERFLAGS  = /D_ATL_XP_TARGETING
         1279  +
         1280  +# Following is primarily for the benefit of extensions. Tcl 8.5 builds
         1281  +# Tcl without /DUNICODE, while 8.6 builds with it defined. When building
         1282  +# an extension, it is advisable (but not mandated) to use the same Windows
         1283  +# API as the Tcl build. This is accordingly defaulted below. A particular
         1284  +# extension can override this by pre-definining USE_WIDECHAR_API.
         1285  +!ifndef USE_WIDECHAR_API
         1286  +!if $(TCL_VERSION) > 85
         1287  +USE_WIDECHAR_API = 1
         1288  +!else
         1289  +USE_WIDECHAR_API = 0
         1290  +!endif
         1291  +!endif
         1292  +
         1293  +!if $(USE_WIDECHAR_API)
         1294  +COMPILERFLAGS = $(COMPILERFLAGS) /DUNICODE /D_UNICODE 
         1295  +!endif
         1296  +
         1297  +# Like the TEA system only set this non empty for non-Tk extensions
         1298  +# Note: some extensions use PACKAGE_NAME and others use PACKAGE_TCLNAME
         1299  +# so we pass both
         1300  +!if !$(DOING_TCL) && !$(DOING_TK)
         1301  +PKGNAMEFLAGS = -DPACKAGE_NAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
         1302  +               -DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
         1303  +               -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
         1304  +               -DMODULE_SCOPE=extern 
         1305  +!endif
         1306  +
         1307  +# crt picks the C run time based on selected OPTS
         1308  +!if $(MSVCRT)
         1309  +!if $(DEBUG) && !$(UNCHECKED)
         1310  +crt = -MDd
         1311  +!else
         1312  +crt = -MD
         1313  +!endif
         1314  +!else
         1315  +!if $(DEBUG) && !$(UNCHECKED)
         1316  +crt = -MTd
         1317  +!else
         1318  +crt = -MT
         1319  +!endif
         1320  +!endif
         1321  +
         1322  +# cdebug includes compiler options for debugging as well as optimization.
         1323  +!if $(DEBUG)
         1324  +
         1325  +# In debugging mode, optimizations need to be disabled
         1326  +cdebug = -Zi -Od $(DEBUGFLAGS)
         1327  +
         1328  +!else
         1329  +
         1330  +cdebug = $(OPTIMIZATIONS)
         1331  +!if $(SYMBOLS)
         1332  +cdebug = $(cdebug) -Zi
         1333  +!endif
         1334  +
         1335  +!endif # $(DEBUG)
         1336  +
         1337  +# cwarn includes default warning levels.
         1338  +cwarn = $(WARNINGS)
         1339  +
         1340  +!if "$(MACHINE)" == "AMD64"
         1341  +# Disable pointer<->int warnings related to cast between different sizes
         1342  +# There are a gadzillion of these due to use of ClientData and
         1343  +# clutter up compiler
         1344  +# output increasing chance of a real warning getting lost. So disable them.
         1345  +# Eventually some day, Tcl will be 64-bit clean.
         1346  +cwarn = $(cwarn) -wd4311 -wd4312
         1347  +!endif
         1348  +
         1349  +### Common compiler options that are architecture specific
         1350  +!if "$(MACHINE)" == "ARM"
         1351  +carch = -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
         1352  +!else
         1353  +carch =
         1354  +!endif
         1355  +
         1356  +!if $(DEBUG)
         1357  +# Turn warnings into errors
         1358  +cwarn = $(cwarn) -WX
         1359  +!endif
         1360  +
         1361  +INCLUDES = $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES)
         1362  +!if !$(DOING_TCL) && !$(DOING_TK)
         1363  +INCLUDES = $(INCLUDES) -I"$(GENERICDIR)" -I"$(WINDIR)" -I"$(COMPATDIR)"
         1364  +!endif
         1365  +
         1366  +# These flags are defined roughly in the order of the pre-reform
         1367  +# rules.vc/makefile.vc to help visually compare that the pre- and
         1368  +# post-reform build logs
         1369  +
         1370  +# cflags contains generic flags used for building practically all object files
         1371  +cflags = -nologo -c $(COMPILERFLAGS) $(carch) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug)
         1372  +
         1373  +# appcflags contains $(cflags) and flags for building the application
         1374  +# object files (e.g. tclsh, or wish) pkgcflags contains $(cflags) plus
         1375  +# flags used for building shared object files The two differ in the
         1376  +# BUILD_$(PROJECT) macro which should be defined only for the shared
         1377  +# library *implementation* and not for its caller interface
         1378  +
         1379  +appcflags = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) $(USE_STUBS_DEFS)
         1380  +appcflags_nostubs = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES)
         1381  +pkgcflags = $(appcflags) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
         1382  +pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
         1383  +
         1384  +# stubscflags contains $(cflags) plus flags used for building a stubs
         1385  +# library for the package.  Note: -DSTATIC_BUILD is defined in
         1386  +# $(OPTDEFINES) only if the OPTS configuration indicates a static
         1387  +# library. However the stubs library is ALWAYS static hence included
         1388  +# here irrespective of the OPTS setting.
         1389  +#
         1390  +# TBD - tclvfs has a comment that stubs libs should not be compiled with -GL
         1391  +# without stating why. Tcl itself compiled stubs libs with this flag.
         1392  +# so we do not remove it from cflags. -GL may prevent extensions
         1393  +# compiled with one VC version to fail to link against stubs library
         1394  +# compiled with another VC version. Check for this and fix accordingly.
         1395  +stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(INCLUDES)
         1396  +
         1397  +# Link flags 
         1398  +
         1399  +!if $(DEBUG)
         1400  +ldebug	= -debug -debugtype:cv
         1401  +!else
         1402  +ldebug	= -release -opt:ref -opt:icf,3
         1403  +!if $(SYMBOLS)
         1404  +ldebug	= $(ldebug) -debug -debugtype:cv
         1405  +!endif
         1406  +!endif
         1407  +
         1408  +# Note: Profiling is currently only possible with the Visual Studio Enterprise
         1409  +!if $(PROFILE)
         1410  +ldebug= $(ldebug) -profile
         1411  +!endif
         1412  +
         1413  +### Declarations common to all linker versions 
         1414  +lflags	= -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug)
         1415  +
         1416  +!if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900
         1417  +lflags	= $(lflags) -nodefaultlib:libucrt.lib
         1418  +!endif
         1419  +
         1420  +# Old linkers (Visual C++ 6 in particular) will link for fast loading
         1421  +# on Win98. Since we do not support Win98 any more, we specify nowin98
         1422  +# as recommended for NT and later. However, this is only required by
         1423  +# IX86 on older compilers and only needed if we are not doing a static build.
         1424  +
         1425  +!if "$(MACHINE)" == "IX86" && !$(STATIC_BUILD)
         1426  +!if [nmakehlp -l -opt:nowin98 $(LINKER_TESTFLAGS)]
         1427  +# Align sections for PE size savings.
         1428  +lflags	= $(lflags) -opt:nowin98
         1429  +!endif
         1430  +!endif
         1431  +
         1432  +dlllflags = $(lflags) -dll
         1433  +conlflags = $(lflags) -subsystem:console
         1434  +guilflags = $(lflags) -subsystem:windows
         1435  +
         1436  +# Libraries that are required for every image.
         1437  +# Extensions should define any additional libraries with $(PRJ_LIBS)
         1438  +winlibs   = kernel32.lib advapi32.lib
         1439  +
         1440  +!if $(NEED_TK)
         1441  +winlibs = $(winlibs) gdi32.lib user32.lib uxtheme.lib
         1442  +!endif
         1443  +
         1444  +# Avoid 'unresolved external symbol __security_cookie' errors.
         1445  +# c.f. http://support.microsoft.com/?id=894573
         1446  +!if "$(MACHINE)" == "AMD64"
         1447  +!if $(VCVERSION) > 1399 && $(VCVERSION) < 1500
         1448  +winlibs   = $(winlibs) bufferoverflowU.lib
         1449  +!endif
         1450  +!endif
         1451  +
         1452  +baselibs = $(winlibs) $(PRJ_LIBS)
         1453  +
         1454  +!if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900
         1455  +baselibs   = $(baselibs) ucrt.lib
         1456  +!endif
         1457  +
         1458  +################################################################
         1459  +# 13. Define standard commands, common make targets and implicit rules
         1460  +
         1461  +CCPKGCMD = $(cc32) $(pkgcflags) -Fo$(TMP_DIR)^\
         1462  +CCAPPCMD = $(cc32) $(appcflags) -Fo$(TMP_DIR)^\
         1463  +CCSTUBSCMD = $(cc32) $(stubscflags) -Fo$(TMP_DIR)^\
         1464  +
         1465  +LIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:[email protected]
         1466  +DLLCMD = $(link32) $(dlllflags) -out:[email protected] $(baselibs) $(tcllibs) $(tklibs)
         1467  +
         1468  +CONEXECMD = $(link32) $(conlflags) -out:[email protected] $(baselibs) $(tcllibs) $(tklibs)
         1469  +GUIEXECMD = $(link32) $(guilflags) -out:[email protected] $(baselibs) $(tcllibs) $(tklibs)
         1470  +RESCMD  = $(rc32) -fo [email protected] -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \
         1471  +	    $(TCL_INCLUDES) \
         1472  +	    -DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
         1473  +	    -DCOMMAVERSION=$(DOTVERSION:.=,),0 \
         1474  +	    -DDOTVERSION=\"$(DOTVERSION)\" \
         1475  +	    -DVERSION=\"$(VERSION)\" \
         1476  +	    -DSUFX=\"$(SUFX)\" \
         1477  +            -DPROJECT=\"$(PROJECT)\" \
         1478  +            -DPRJLIBNAME=\"$(PRJLIBNAME)\" 
         1479  +
         1480  +!ifndef DEFAULT_BUILD_TARGET
         1481  +DEFAULT_BUILD_TARGET = $(PROJECT)
         1482  +!endif
         1483  +
         1484  +default-target: $(DEFAULT_BUILD_TARGET)
         1485  +
         1486  +default-pkgindex:
         1487  +	@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
         1488  +	    [list load [file join $$dir $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
         1489  +
         1490  +default-pkgindex-tea:
         1491  +	@if exist $(ROOT)\pkgIndex.tcl.in nmakehlp -s << $(ROOT)\pkgIndex.tcl.in > $(OUT_DIR)\pkgIndex.tcl
         1492  +@[email protected]    $(DOTVERSION)
         1493  +@[email protected]       $(PRJ_PACKAGE_TCLNAME)
         1494  +@[email protected]    $(PRJ_PACKAGE_TCLNAME)
         1495  +@[email protected]       $(PRJLIBNAME)
         1496  +<<
         1497  +
         1498  +
         1499  +default-install: default-install-binaries default-install-libraries
         1500  +
         1501  +default-install-binaries: $(PRJLIB)
         1502  +	@echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
         1503  +	@if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
         1504  +	@$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
         1505  +
         1506  +default-install-libraries: $(OUT_DIR)\pkgIndex.tcl
         1507  +	@echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
         1508  +	@if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
         1509  +	@echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
         1510  +	@$(CPY) $(OUT_DIR)\pkgIndex.tcl $(SCRIPT_INSTALL_DIR)
         1511  +
         1512  +default-install-stubs:
         1513  +	@echo Installing stubs library to '$(SCRIPT_INSTALL_DIR)'
         1514  +	@if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
         1515  +	@$(CPY) $(PRJSTUBLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
         1516  +
         1517  +default-install-docs-html:
         1518  +	@echo Installing documentation files to '$(DOC_INSTALL_DIR)'
         1519  +	@if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)"
         1520  +	@if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css" "$(DOCDIR)\*.png") do @$(COPY) %f "$(DOC_INSTALL_DIR)"
         1521  +
         1522  +default-install-docs-n:
         1523  +	@echo Installing documentation files to '$(DOC_INSTALL_DIR)'
         1524  +	@if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)"
         1525  +	@if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.n") do @$(COPY) %f "$(DOC_INSTALL_DIR)"
         1526  +
         1527  +default-install-demos:
         1528  +	@echo Installing demos to '$(DEMO_INSTALL_DIR)'
         1529  +	@if not exist "$(DEMO_INSTALL_DIR)" mkdir "$(DEMO_INSTALL_DIR)"
         1530  +	@if exist $(DEMODIR) $(CPYDIR) "$(DEMODIR)" "$(DEMO_INSTALL_DIR)"
         1531  +
         1532  +default-clean:
         1533  +	@echo Cleaning $(TMP_DIR)\* ...
         1534  +	@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
         1535  +	@echo Cleaning $(WINDIR)\nmakehlp.obj, nmakehlp.exe ...
         1536  +	@if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj
         1537  +	@if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
         1538  +	@if exist $(WINDIR)\nmakehlp.out del $(WINDIR)\nmakehlp.out
         1539  +	@echo Cleaning $(WINDIR)\nmhlp-out.txt ...
         1540  +	@if exist $(WINDIR)\nmhlp-out.txt del $(WINDIR)\nmhlp-out.txt
         1541  +	@echo Cleaning $(WINDIR)\_junk.pch ...
         1542  +	@if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch
         1543  +	@echo Cleaning $(WINDIR)\vercl.x, vercl.i ...
         1544  +	@if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
         1545  +	@if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
         1546  +	@echo Cleaning $(WINDIR)\versions.vc, version.vc ...
         1547  +	@if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc
         1548  +	@if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc
         1549  +
         1550  +default-hose: default-clean
         1551  +	@echo Hosing $(OUT_DIR)\* ...
         1552  +	@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
         1553  +
         1554  +# Only for backward compatibility
         1555  +default-distclean: default-hose
         1556  +
         1557  +default-setup:
         1558  +	@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
         1559  +	@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
         1560  +
         1561  +!if "$(TESTPAT)" != ""
         1562  +TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
         1563  +!endif
         1564  +
         1565  +default-test: default-setup $(PROJECT)
         1566  +	@set TCLLIBPATH=$(OUT_DIR:\=/)
         1567  +	@if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)"
         1568  +	cd "$(TESTDIR)" && $(DEBUGGER) $(TCLSH) all.tcl $(TESTFLAGS)
         1569  +
         1570  +default-shell: default-setup $(PROJECT)
         1571  +	@set TCLLIBPATH=$(OUT_DIR:\=/)
         1572  +	@if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)"
         1573  +	$(DEBUGGER) $(TCLSH)
         1574  +
         1575  +# Generation of Windows version resource 
         1576  +!ifdef RCFILE
         1577  +
         1578  +# Note: don't use $** in below rule because there may be other dependencies
         1579  +# and only the "master" rc must be passed to the resource compiler
         1580  +$(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc
         1581  +	$(RESCMD) $(RCDIR)\$(PROJECT).rc
   505   1582   
   506   1583   !else
   507   1584   
   508         -# If INSTALLDIR set to tcl root dir then reset to the lib dir.
   509         -!if exist("$(_INSTALLDIR)\include\tcl.h")
   510         -_INSTALLDIR=$(_INSTALLDIR)\lib
         1585  +# If parent makefile has not defined a resource definition file,
         1586  +# we will generate one from standard template.
         1587  +$(TMP_DIR)\$(PROJECT).res: $(TMP_DIR)\$(PROJECT).rc
         1588  +
         1589  +$(TMP_DIR)\$(PROJECT).rc:
         1590  +	@$(COPY) << $(TMP_DIR)\$(PROJECT).rc
         1591  +#include <winver.h>
         1592  +
         1593  +VS_VERSION_INFO VERSIONINFO
         1594  + FILEVERSION	COMMAVERSION
         1595  + PRODUCTVERSION	COMMAVERSION
         1596  + FILEFLAGSMASK	0x3fL
         1597  +#ifdef DEBUG
         1598  + FILEFLAGS	VS_FF_DEBUG
         1599  +#else
         1600  + FILEFLAGS	0x0L
         1601  +#endif
         1602  + FILEOS		VOS_NT_WINDOWS32
         1603  + FILETYPE	VFT_DLL
         1604  + FILESUBTYPE	0x0L
         1605  +BEGIN
         1606  +    BLOCK "StringFileInfo"
         1607  +    BEGIN
         1608  +        BLOCK "040904b0"
         1609  +        BEGIN
         1610  +            VALUE "FileDescription",  "Tcl extension " PROJECT
         1611  +            VALUE "OriginalFilename", PRJLIBNAME
         1612  +            VALUE "FileVersion",      DOTVERSION
         1613  +            VALUE "ProductName",      "Package " PROJECT " for Tcl"
         1614  +            VALUE "ProductVersion",   DOTVERSION 
         1615  +        END
         1616  +    END
         1617  +    BLOCK "VarFileInfo"
         1618  +    BEGIN
         1619  +        VALUE "Translation", 0x409, 1200
         1620  +    END
         1621  +END
         1622  +
         1623  +<<
         1624  +
         1625  +!endif # ifdef RCFILE
         1626  +
         1627  +!ifndef DISABLE_IMPLICIT_RULES
         1628  +DISABLE_IMPLICIT_RULES = 0
         1629  +!endif
         1630  +
         1631  +!if !$(DISABLE_IMPLICIT_RULES)
         1632  +# Implicit rule definitions - only for building library objects. For stubs and
         1633  +# main application, the master makefile should define explicit rules.
         1634  +
         1635  +{$(ROOT)}.c{$(TMP_DIR)}.obj::
         1636  +	$(CCPKGCMD) @<<
         1637  +$<
         1638  +<<
         1639  +
         1640  +{$(WINDIR)}.c{$(TMP_DIR)}.obj::
         1641  +	$(CCPKGCMD) @<<
         1642  +$<
         1643  +<<
         1644  +
         1645  +{$(GENERICDIR)}.c{$(TMP_DIR)}.obj::
         1646  +	$(CCPKGCMD) @<<
         1647  +$<
         1648  +<<
         1649  +
         1650  +{$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
         1651  +	$(CCPKGCMD) @<<
         1652  +$<
         1653  +<<
         1654  +
         1655  +{$(RCDIR)}.rc{$(TMP_DIR)}.res:
         1656  +	$(RESCMD) $<
         1657  +
         1658  +{$(WINDIR)}.rc{$(TMP_DIR)}.res:
         1659  +	$(RESCMD) $<
         1660  +
         1661  +{$(TMP_DIR)}.rc{$(TMP_DIR)}.res:
         1662  +	$(RESCMD) $<
         1663  +
         1664  +.SUFFIXES:
         1665  +.SUFFIXES:.c .rc
         1666  +
   511   1667   !endif
   512   1668   
   513         -!if !defined(TCLDIR)
   514         -!if exist("$(_INSTALLDIR)\..\include\tcl.h")
   515         -TCLINSTALL	= 1
   516         -_TCLDIR		= $(_INSTALLDIR)\..
   517         -_TCL_H          = $(_INSTALLDIR)\..\include\tcl.h
   518         -TCLDIR          = $(_INSTALLDIR)\..
   519         -!else
   520         -MSG=^
   521         -Failed to find tcl.h.  Set the TCLDIR macro.
   522         -!error $(MSG)
   523         -!endif
   524         -!else
   525         -_TCLDIR	= $(TCLDIR:/=\)
   526         -!if exist("$(_TCLDIR)\include\tcl.h")
   527         -TCLINSTALL	= 1
   528         -_TCL_H          = $(_TCLDIR)\include\tcl.h
   529         -!elseif exist("$(_TCLDIR)\generic\tcl.h")
   530         -TCLINSTALL	= 0
   531         -_TCL_H          = $(_TCLDIR)\generic\tcl.h
   532         -!else
   533         -MSG =^
   534         -Failed to find tcl.h.  The TCLDIR macro does not appear correct.
   535         -!error $(MSG)
   536         -!endif
   537         -!endif
   538         -!endif
         1669  +################################################################
         1670  +# 14. Sanity check selected options against Tcl build options
         1671  +# When building an extension, certain configuration options should
         1672  +# match the ones used when Tcl was built. Here we check and
         1673  +# warn on a mismatch.
         1674  +!if ! $(DOING_TCL)
   539   1675   
   540         -#--------------------------------------------------------------
   541         -# Extract various version numbers from tcl headers
   542         -# The generated file is then included in the makefile.
   543         -#--------------------------------------------------------------
   544         -
   545         -!if [echo REM = This file is generated from rules.vc > versions.vc]
         1676  +!if $(TCLINSTALL) # Building against an installed Tcl
         1677  +!if exist("$(_TCLDIR)\lib\nmake\tcl.nmake")
         1678  +TCLNMAKECONFIG = "$(_TCLDIR)\lib\nmake\tcl.nmake"
         1679  +!endif
         1680  +!else # ! $(TCLINSTALL) - building against Tcl source
         1681  +!if exist("$(OUT_DIR)\tcl.nmake")
         1682  +TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake"
   546   1683   !endif
   547         -!if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
   548         -   && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
   549         -!endif
   550         -!if [echo TCL_MINOR_VERSION = \>> versions.vc] \
   551         -   && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
   552         -!endif
   553         -!if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
   554         -   && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
   555         -!endif
         1684  +!endif # TCLINSTALL
   556   1685   
   557         -# If building the tcl core then we need additional package versions
   558         -!if "$(PROJECT)" == "tcl"
   559         -!if [echo PKG_HTTP_VER = \>> versions.vc] \
   560         -   && [nmakehlp -V ..\library\http\pkgIndex.tcl http >> versions.vc]
   561         -!endif
   562         -!if [echo PKG_TCLTEST_VER = \>> versions.vc] \
   563         -   && [nmakehlp -V ..\library\tcltest\pkgIndex.tcl tcltest >> versions.vc]
   564         -!endif
   565         -!if [echo PKG_MSGCAT_VER = \>> versions.vc] \
   566         -   && [nmakehlp -V ..\library\msgcat\pkgIndex.tcl msgcat >> versions.vc]
   567         -!endif
   568         -!if [echo PKG_PLATFORM_VER = \>> versions.vc] \
   569         -   && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform " >> versions.vc]
   570         -!endif
   571         -!if [echo PKG_SHELL_VER = \>> versions.vc] \
   572         -   && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform::shell" >> versions.vc]
   573         -!endif
   574         -!if [echo PKG_DDE_VER = \>> versions.vc] \
   575         -   && [nmakehlp -V ..\library\dde\pkgIndex.tcl "dde " >> versions.vc]
   576         -!endif
   577         -!if [echo PKG_REG_VER =\>> versions.vc] \
   578         -   && [nmakehlp -V ..\library\reg\pkgIndex.tcl registry >> versions.vc]
   579         -!endif
   580         -!endif
   581         -
   582         -!include versions.vc
         1686  +!if $(CONFIG_CHECK)
         1687  +!ifdef TCLNMAKECONFIG
         1688  +!include $(TCLNMAKECONFIG)
   583   1689   
   584         -#--------------------------------------------------------------
   585         -# Setup tcl version dependent stuff headers
   586         -#--------------------------------------------------------------
   587         -
   588         -!if "$(PROJECT)" != "tcl"
   589         -
   590         -TCL_VERSION	= $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
   591         -
   592         -!if $(TCLINSTALL)
   593         -TCLSH		= "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe"
   594         -!if !exist($(TCLSH)) && $(TCL_THREADS)
   595         -TCLSH           = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION).exe"
         1690  +!if defined(CORE_MACHINE) && "$(CORE_MACHINE)" != "$(MACHINE)"
         1691  +!error ERROR: Build target ($(MACHINE)) does not match the Tcl library architecture ($(CORE_MACHINE)).
         1692  +!endif
         1693  +!if defined(CORE_USE_THREAD_ALLOC) && $(CORE_USE_THREAD_ALLOC) != $(USE_THREAD_ALLOC)
         1694  +!message WARNING: Value of USE_THREAD_ALLOC ($(USE_THREAD_ALLOC)) does not match its Tcl core value ($(CORE_USE_THREAD_ALLOC)).
   596   1695   !endif
   597         -TCLSTUBLIB	= "$(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib"
   598         -TCLIMPLIB	= "$(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib"
   599         -TCL_LIBRARY	= $(_TCLDIR)\lib
   600         -TCLREGLIB	= "$(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib"
   601         -TCLDDELIB	= "$(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib"
   602         -COFFBASE	= \must\have\tcl\sources\to\build\this\target
   603         -TCLTOOLSDIR	= \must\have\tcl\sources\to\build\this\target
   604         -TCL_INCLUDES    = -I"$(_TCLDIR)\include"
   605         -!else
   606         -TCLSH		= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe"
   607         -!if !exist($(TCLSH)) && $(TCL_THREADS)
   608         -TCLSH		= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION).exe"
   609         -!endif
   610         -TCLSTUBLIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib"
   611         -TCLIMPLIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib"
   612         -TCL_LIBRARY	= $(_TCLDIR)\library
   613         -TCLREGLIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib"
   614         -TCLDDELIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib"
   615         -COFFBASE	= "$(_TCLDIR)\win\coffbase.txt"
   616         -TCLTOOLSDIR	= $(_TCLDIR)\tools
   617         -TCL_INCLUDES	= -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
   618         -!endif
   619         -
   620         -!endif
   621         -
   622         -#-------------------------------------------------------------------------
   623         -# Locate the Tk headers to build against
   624         -#-------------------------------------------------------------------------
   625         -
   626         -!if "$(PROJECT)" == "tk"
   627         -_TK_H          = ..\generic\tk.h
   628         -_INSTALLDIR    = $(_INSTALLDIR)\..
   629         -!endif
   630         -
   631         -!ifdef PROJECT_REQUIRES_TK
   632         -!if !defined(TKDIR)
   633         -!if exist("$(_INSTALLDIR)\..\include\tk.h")
   634         -TKINSTALL      = 1
   635         -_TKDIR         = $(_INSTALLDIR)\..
   636         -_TK_H          = $(_TKDIR)\include\tk.h
   637         -TKDIR          = $(_TKDIR)
   638         -!elseif exist("$(_TCLDIR)\include\tk.h")
   639         -TKINSTALL      = 1
   640         -_TKDIR         = $(_TCLDIR)
   641         -_TK_H          = $(_TKDIR)\include\tk.h
   642         -TKDIR          = $(_TKDIR)
   643         -!endif
   644         -!else
   645         -_TKDIR = $(TKDIR:/=\)
   646         -!if exist("$(_TKDIR)\include\tk.h")
   647         -TKINSTALL      = 1
   648         -_TK_H          = $(_TKDIR)\include\tk.h
   649         -!elseif exist("$(_TKDIR)\generic\tk.h")
   650         -TKINSTALL      = 0
   651         -_TK_H          = $(_TKDIR)\generic\tk.h
   652         -!else
   653         -MSG =^
   654         -Failed to find tk.h. The TKDIR macro does not appear correct.
   655         -!error $(MSG)
   656         -!endif
         1696  +!if defined(CORE_DEBUG) && $(CORE_DEBUG) != $(DEBUG)
         1697  +!message WARNING: Value of DEBUG ($(DEBUG)) does not match its Tcl library configuration ($(DEBUG)).
   657   1698   !endif
   658   1699   !endif
   659   1700   
   660         -#-------------------------------------------------------------------------
   661         -# Extract Tk version numbers
   662         -#-------------------------------------------------------------------------
         1701  +!endif # TCLNMAKECONFIG
   663   1702   
   664         -!if defined(PROJECT_REQUIRES_TK) || "$(PROJECT)" == "tk"
         1703  +!endif # ! $(DOING_TCL)
   665   1704   
   666         -!if [echo TK_MAJOR_VERSION = \>> versions.vc] \
   667         -   && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
   668         -!endif
   669         -!if [echo TK_MINOR_VERSION = \>> versions.vc] \
   670         -   && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
   671         -!endif
   672         -!if [echo TK_PATCH_LEVEL = \>> versions.vc] \
   673         -   && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
   674         -!endif
   675         -
   676         -!include versions.vc
   677         -
   678         -TK_DOTVERSION	= $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
   679         -TK_VERSION	= $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
   680         -
   681         -!if "$(PROJECT)" != "tk"
   682         -!if $(TKINSTALL)
   683         -WISH		= "$(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe"
   684         -TKSTUBLIB	= "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib"
   685         -TKIMPLIB	= "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib"
   686         -TK_INCLUDES     = -I"$(_TKDIR)\include"
   687         -!else
   688         -WISH		= "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe"
   689         -TKSTUBLIB	= "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib"
   690         -TKIMPLIB	= "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib"
   691         -TK_INCLUDES     = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
   692         -!endif
   693         -!endif
   694         -
   695         -!endif
   696   1705   
   697   1706   #----------------------------------------------------------
   698   1707   # Display stats being used.
   699   1708   #----------------------------------------------------------
   700   1709   
         1710  +!if !$(DOING_TCL)
         1711  +!message *** Building against Tcl at '$(_TCLDIR)'
         1712  +!endif
         1713  +!if !$(DOING_TK) && $(NEED_TK)
         1714  +!message *** Building against Tk at '$(_TKDIR)'
         1715  +!endif
   701   1716   !message *** Intermediate directory will be '$(TMP_DIR)'
   702   1717   !message *** Output directory will be '$(OUT_DIR)'
         1718  +!message *** Installation, if selected, will be in '$(_INSTALLDIR)'
   703   1719   !message *** Suffix for binaries will be '$(SUFX)'
   704         -!message *** Optional defines are '$(OPTDEFINES)'
   705   1720   !message *** Compiler version $(VCVER). Target machine is $(MACHINE)
   706   1721   !message *** Host architecture is $(NATIVE_ARCH)
   707         -!message *** Compiler options '$(COMPILERFLAGS) $(OPTIMIZATIONS) $(DEBUGFLAGS) $(WARNINGS)'
   708         -!message *** Link options '$(LINKERFLAGS)'
   709   1722   
   710         -!endif
         1723  +!endif # ifdef _RULES_VC

Added win/targets.vc.

            1  +#------------------------------------------------------------- -*- makefile -*-
            2  +# targets.vc --
            3  +#
            4  +# Part of the nmake based build system for Tcl and its extensions.
            5  +# This file defines some standard targets for the convenience of extensions
            6  +# and can be optionally included by the extension makefile.
            7  +# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for docs.
            8  +
            9  +$(PROJECT): setup pkgindex $(PRJLIB)
           10  +
           11  +!ifdef PRJ_STUBOBJS
           12  +$(PROJECT): $(PRJSTUBLIB)
           13  +$(PRJSTUBLIB): $(PRJ_STUBOBJS)
           14  +	$(LIBCMD) $**
           15  +
           16  +$(PRJ_STUBOBJS):
           17  +	$(CCSTUBSCMD) %s
           18  +!endif # PRJ_STUBOBJS
           19  +
           20  +!ifdef PRJ_MANIFEST
           21  +$(PROJECT): $(PRJLIB).manifest
           22  +$(PRJLIB).manifest: $(PRJ_MANIFEST)
           23  +	@nmakehlp -s << $** >[email protected]
           24  +@[email protected]	  $(MACHINE:IX86=X86)
           25  +<<
           26  +!endif
           27  +
           28  +!if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk"
           29  +$(PRJLIB): $(PRJ_OBJS) $(RESFILE)
           30  +!if $(STATIC_BUILD)
           31  +       $(LIBCMD) $**
           32  +!else
           33  +       $(DLLCMD) $**
           34  +       $(_VC_MANIFEST_EMBED_DLL)
           35  +!endif
           36  +       [email protected] $*.exp
           37  +!endif
           38  +
           39  +!if "$(PRJ_HEADERS)" != "" && "$(PRJ_OBJS)" != ""
           40  +$(PRJ_OBJS): $(PRJ_HEADERS)
           41  +!endif
           42  +
           43  +# If parent makefile has defined stub objects, add their installation
           44  +# to the default install
           45  +!if "$(PRJ_STUBOBJS)" != ""
           46  +default-install: default-install-stubs
           47  +!endif
           48  +
           49  +# Unlike the other default targets, these cannot be in rules.vc because
           50  +# the executed command depends on existence of macro PRJ_HEADERS_PUBLIC
           51  +# that the parent makefile will not define until after including rules-ext.vc
           52  +!if "$(PRJ_HEADERS_PUBLIC)" != ""
           53  +default-install: default-install-headers
           54  +default-install-headers:
           55  +	@echo Installing headers to '$(INCLUDE_INSTALL_DIR)'
           56  +	@for %f in ($(PRJ_HEADERS_PUBLIC)) do @$(COPY) %f "$(INCLUDE_INSTALL_DIR)"
           57  +!endif
           58  +
           59  +!if "$(DISABLE_STANDARD_TARGETS)" == ""
           60  +DISABLE_STANDARD_TARGETS = 0
           61  +!endif
           62  +
           63  +!if "$(DISABLE_TARGET_setup)" == ""
           64  +DISABLE_TARGET_setup = 0
           65  +!endif
           66  +!if "$(DISABLE_TARGET_install)" == ""
           67  +DISABLE_TARGET_install = 0
           68  +!endif
           69  +!if "$(DISABLE_TARGET_clean)" == ""
           70  +DISABLE_TARGET_clean = 0
           71  +!endif
           72  +!if "$(DISABLE_TARGET_test)" == ""
           73  +DISABLE_TARGET_test = 0
           74  +!endif
           75  +!if "$(DISABLE_TARGET_shell)" == ""
           76  +DISABLE_TARGET_shell = 0
           77  +!endif
           78  +
           79  +!if !$(DISABLE_STANDARD_TARGETS)
           80  +!if !$(DISABLE_TARGET_setup)
           81  +setup: default-setup
           82  +!endif
           83  +!if !$(DISABLE_TARGET_install)
           84  +install: default-install
           85  +!endif
           86  +!if !$(DISABLE_TARGET_clean)
           87  +clean: default-clean
           88  +realclean: hose
           89  +hose: default-hose
           90  +distclean: realclean default-distclean
           91  +!endif
           92  +!if !$(DISABLE_TARGET_test)
           93  +test: default-test
           94  +!endif
           95  +!if !$(DISABLE_TARGET_shell)
           96  +shell: default-shell
           97  +!endif
           98  +!endif # DISABLE_STANDARD_TARGETS

Deleted win/tcludp.rc.

     1         -// RCS: @(#) $Id: tcludp.rc,v 1.4 2004/11/22 23:48:48 patthoyts Exp $
     2         -//
     3         -// Version Resource Script
     4         -//
     5         -
     6         -#include <winver.h>
     7         -
     8         -LANGUAGE 0x9, 0x1	/* LANG_ENGLISH, SUBLANG_DEFAULT */
     9         -
    10         -VS_VERSION_INFO VERSIONINFO
    11         - FILEVERSION    COMMAVERSION
    12         - PRODUCTVERSION COMMAVERSION
    13         - FILEFLAGSMASK 	0x3fL
    14         -#ifdef DEBUG
    15         - FILEFLAGS 	VS_FF_DEBUG
    16         -#else
    17         - FILEFLAGS 	0x0L
    18         -#endif
    19         - FILEOS 	VOS__WINDOWS32
    20         - FILETYPE 	VFT_DLL
    21         - FILESUBTYPE 	0x0L
    22         -BEGIN
    23         -    BLOCK "StringFileInfo"
    24         -    BEGIN
    25         -        BLOCK "040904b0" /* LANG_ENGLISH/SUBLANG_ENGLISH_US, Unicode CP */
    26         -        BEGIN
    27         -            VALUE "FileDescription", "Tcl UDP " DOTVERSION " for Windows\0"
    28         -            VALUE "OriginalFilename", "udp" VERSION ".dll\0"
    29         -            VALUE "FileVersion",      DOTVERSION "\0"
    30         -            VALUE "LegalCopyright",   "Copyright \251 1999-2000 Columbia University; all rights reserved\0"
    31         -            VALUE "ProductName",      "TclUDP " DOTVERSION " for Windows\0"
    32         -            VALUE "ProductVersion",   DOTVERSION "\0"
    33         -        END		    
    34         -    END
    35         -    BLOCK "VarFileInfo"
    36         -    BEGIN
    37         -        VALUE "Translation", 0x409, 1200
    38         -    END
    39         -END
    40         -