Artifact 996a623bd2ea3dc2fac239a1b845ca51695c8012:

  • File win/rules.vc — part of check-in [b727b73d8f] at 2018-02-13 06:05:12 on branch versionhash — Add versionhash.h mechanism to Windows nmake builds (user: apnadkarni size: 57384) [more...]

     1  #------------------------------------------------------------- -*- makefile -*-
     2  # rules.vc --
     3  #
     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.
    11  #
    12  # See the file "license.terms" for information on usage and redistribution
    13  # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    14  #
    15  # Copyright (c) 2001-2003 David Gravereaux.
    16  # Copyright (c) 2003-2008 Patrick Thoyts
    17  # Copyright (c) 2017      Ashok P. Nadkarni
    18  #------------------------------------------------------------------------------
    19  
    20  !ifndef _RULES_VC
    21  _RULES_VC = 1
    22  
    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 = 1
    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
   136  
   137  #----------------------------------------------------------
   138  # Set the proper copy method to avoid overwrite questions
   139  # to the user when copying files and selecting the right
   140  # "delete all" method.
   141  #----------------------------------------------------------
   142  
   143  RMDIR	= rmdir /S /Q
   144  CPY	= xcopy /i /y >NUL
   145  CPYDIR  = xcopy /e /i /y >NUL
   146  COPY	= copy /y >NUL
   147  MKDIR   = mkdir
   148  
   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
   433  
   434  _HASH=^#
   435  _VC_MANIFEST_EMBED_EXE=
   436  _VC_MANIFEST_EMBED_DLL=
   437  VCVER=0
   438  !if ![echo VCVERSION=_MSC_VER > vercl.x] \
   439      && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
   440      && ![echo ARCH=IX86 >> vercl.x] \
   441      && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
   442      && ![echo ARCH=AMD64 >> vercl.x] \
   443      && ![echo $(_HASH)endif >> vercl.x] \
   444      && ![$(cc32) -nologo -TC -P vercl.x 2>NUL]
   445  !include vercl.i
   446  !if $(VCVERSION) < 1900
   447  !if ![echo VCVER= ^\> vercl.vc] \
   448      && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc]
   449  !include vercl.vc
   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)
   455  !endif
   456  !endif
   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  
   481  !if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86]
   482  NATIVE_ARCH=IX86
   483  !else
   484  NATIVE_ARCH=AMD64
   485  !endif
   486  
   487  # Since MSVC8 we must deal with manifest resources.
   488  !if $(VCVERSION) >= 1400
   489  _VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1
   490  _VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2
   491  !endif
   492  
   493  !ifndef CFG_ENCODING
   494  CFG_ENCODING	= \"cp1252\"
   495  !endif
   496  
   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  !if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul]
   539  !endif
   540  
   541  ################################################################
   542  # 5. Test for compiler features
   543  # Visual C++ compiler options have changed over the years. Check
   544  # which options are supported by the compiler in use.
   545  #
   546  # The following macros are set:
   547  # OPTIMIZATIONS - the compiler flags to be used for optimized builds
   548  # DEBUGFLAGS - the compiler flags to be used for debug builds
   549  # LINKERFLAGS - Flags passed to the linker 
   550  #
   551  # Note that these are the compiler settings *available*, not those
   552  # that will be *used*. The latter depends on the OPTS macro settings
   553  # which we have not yet parsed.
   554  #
   555  # Also note that some of the flags in OPTIMIZATIONS are not really
   556  # related to optimization. They are placed there only for legacy reasons
   557  # as some extensions expect them to be included in that macro.
   558  
   559  # -Op improves float consistency. Note only needed for older compilers
   560  # Newer compilers do not need or support this option.
   561  !if [nmakehlp -c -Op]
   562  FPOPTS  = -Op
   563  !endif
   564  
   565  # Strict floating point semantics - present in newer compilers in lieu of -Op
   566  !if [nmakehlp -c -fp:strict]
   567  FPOPTS  = $(FPOPTS) -fp:strict
   568  !endif
   569  
   570  !if "$(MACHINE)" == "IX86"
   571  ### test for pentium errata
   572  !if [nmakehlp -c -QI0f]
   573  !message *** Compiler has 'Pentium 0x0f fix'
   574  FPOPTS  = $(FPOPTS) -QI0f
   575  !else
   576  !message *** Compiler does not have 'Pentium 0x0f fix'
   577  !endif
   578  !endif
   579  
   580  ### test for optimizations
   581  # /O2 optimization includes /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy as per
   582  # documentation. Note we do NOT want /Gs as that inserts a _chkstk
   583  # stack probe at *every* function entry, not just those with more than
   584  # a page of stack allocation resulting in a performance hit.  However,
   585  # /O2 documentation is misleading as its stack probes are simply the
   586  # default page size locals allocation probes and not what is implied
   587  # by an explicit /Gs option.
   588  
   589  OPTIMIZATIONS = $(FPOPTS)
   590  
   591  !if [nmakehlp -c -O2]
   592  OPTIMIZING = 1
   593  OPTIMIZATIONS   = $(OPTIMIZATIONS) -O2
   594  !else
   595  # Legacy, really. All modern compilers support this
   596  !message *** Compiler does not have 'Optimizations'
   597  OPTIMIZING = 0
   598  !endif
   599  
   600  # Checks for buffer overflows in local arrays
   601  !if [nmakehlp -c -GS]
   602  OPTIMIZATIONS  = $(OPTIMIZATIONS) -GS
   603  !endif
   604  
   605  # Link time optimization. Note that this option (potentially) makes
   606  # generated libraries only usable by the specific VC++ version that
   607  # created it. Requires /LTCG linker option
   608  !if [nmakehlp -c -GL]
   609  OPTIMIZATIONS  = $(OPTIMIZATIONS) -GL
   610  CC_GL_OPT_ENABLED = 1
   611  !else
   612  # In newer compilers -GL and -YX are incompatible.
   613  !if [nmakehlp -c -YX]
   614  OPTIMIZATIONS  = $(OPTIMIZATIONS) -YX
   615  !endif
   616  !endif # [nmakehlp -c -GL]
   617  
   618  DEBUGFLAGS     = $(FPOPTS)
   619  
   620  # Run time error checks. Not available or valid in a release, non-debug build
   621  # RTC is for modern compilers, -GZ is legacy
   622  !if [nmakehlp -c -RTC1]
   623  DEBUGFLAGS     = $(DEBUGFLAGS) -RTC1
   624  !elseif [nmakehlp -c -GZ]
   625  DEBUGFLAGS     = $(DEBUGFLAGS) -GZ
   626  !endif
   627  
   628  #----------------------------------------------------------------
   629  # Linker flags
   630  
   631  # LINKER_TESTFLAGS are for internal use when we call nmakehlp to test
   632  # if the linker supports a specific option. Without these flags link will
   633  # return "LNK1561: entry point must be defined" error compiling from VS-IDE:
   634  # They are not passed through to the actual application / extension
   635  # link rules.
   636  !ifndef LINKER_TESTFLAGS
   637  LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmakehlp.out
   638  !endif
   639  
   640  LINKERFLAGS     =
   641  
   642  # If compiler has enabled link time optimization, linker must too with -ltcg
   643  !ifdef CC_GL_OPT_ENABLED
   644  !if [nmakehlp -l -ltcg $(LINKER_TESTFLAGS)]
   645  LINKERFLAGS     = $(LINKERFLAGS) -ltcg
   646  !endif
   647  !endif
   648  
   649  ########################################################################
   650  # 6. Parse the OPTS macro to work out the requested build configuration.
   651  # Based on this, we will construct the actual switches to be passed to the
   652  # compiler and linker using the macros defined in the previous section.
   653  # The following macros are defined by this section based on OPTS
   654  # STATIC_BUILD - 0 -> Tcl is to be built as a shared library
   655  #                1 -> build as a static library and shell
   656  # TCL_THREADS - legacy but always 1 on Windows since winsock requires it.
   657  # DEBUG - 1 -> debug build, 0 -> release builds
   658  # SYMBOLS - 1 -> generate PDB's, 0 -> no PDB's
   659  # PROFILE - 1 -> generate profiling info, 0 -> no profiling
   660  # PGO     - 1 -> profile based optimization, 0 -> no
   661  # MSVCRT  - 1 -> link to dynamic C runtime even when building static Tcl build
   662  #           0 -> link to static C runtime for static Tcl build.
   663  #           Does not impact shared Tcl builds (STATIC_BUILD == 0)
   664  # TCL_USE_STATIC_PACKAGES - 1 -> statically link the registry and dde extensions
   665  #           in the Tcl shell. 0 -> keep them as shared libraries
   666  #           Does not impact shared Tcl builds.
   667  # USE_THREAD_ALLOC - 1 -> Use a shared global free pool for allocation.
   668  #           0 -> Use the non-thread allocator.
   669  # UNCHECKED - 1 -> when doing a debug build with symbols, use the release
   670  #           C runtime, 0 -> use the debug C runtime.
   671  # USE_STUBS - 1 -> compile to use stubs interfaces, 0 -> direct linking
   672  # CONFIG_CHECK - 1 -> check current build configuration against Tcl
   673  #           configuration (ignored for Tcl itself)
   674  # Further, LINKERFLAGS are modified based on above.
   675  
   676  # Default values for all the above
   677  STATIC_BUILD	= 0
   678  TCL_THREADS	= 1
   679  DEBUG		= 0
   680  SYMBOLS		= 0
   681  PROFILE		= 0
   682  PGO		= 0
   683  MSVCRT		= 1
   684  TCL_USE_STATIC_PACKAGES	= 0
   685  USE_THREAD_ALLOC = 1
   686  UNCHECKED	= 0
   687  CONFIG_CHECK    = 1
   688  !if $(DOING_TCL)
   689  USE_STUBS       = 0
   690  !else
   691  USE_STUBS       = 1
   692  !endif
   693  
   694  # If OPTS is not empty AND does not contain "none" which turns off all OPTS
   695  # set the above macros based on OPTS content
   696  !if "$(OPTS)" != "" && ![nmakehlp -f "$(OPTS)" "none"]
   697  
   698  # OPTS are specified, parse them
   699  
   700  !if [nmakehlp -f $(OPTS) "static"]
   701  !message *** Doing static
   702  STATIC_BUILD	= 1
   703  !endif
   704  
   705  !if [nmakehlp -f $(OPTS) "nostubs"]
   706  !message *** Not using stubs
   707  USE_STUBS	= 0
   708  !endif
   709  
   710  !if [nmakehlp -f $(OPTS) "nomsvcrt"]
   711  !message *** Doing nomsvcrt
   712  MSVCRT		= 0
   713  !else
   714  !if [nmakehlp -f $(OPTS) "msvcrt"]
   715  !message *** Doing msvcrt
   716  MSVCRT		= 1
   717  !else
   718  !if !$(STATIC_BUILD)
   719  MSVCRT		= 1
   720  !else
   721  MSVCRT		= 0
   722  !endif
   723  !endif
   724  !endif # [nmakehlp -f $(OPTS) "nomsvcrt"]
   725  
   726  !if [nmakehlp -f $(OPTS) "staticpkg"] && $(STATIC_BUILD)
   727  !message *** Doing staticpkg
   728  TCL_USE_STATIC_PACKAGES	= 1
   729  !else
   730  TCL_USE_STATIC_PACKAGES	= 0
   731  !endif
   732  
   733  !if [nmakehlp -f $(OPTS) "nothreads"]
   734  !message *** Compile explicitly for non-threaded Tcl
   735  TCL_THREADS	= 0
   736  USE_THREAD_ALLOC= 0
   737  !else
   738  TCL_THREADS	= 1
   739  USE_THREAD_ALLOC= 1
   740  !endif
   741  
   742  !if [nmakehlp -f $(OPTS) "symbols"]
   743  !message *** Doing symbols
   744  DEBUG		= 1
   745  !else
   746  DEBUG		= 0
   747  !endif
   748  
   749  !if [nmakehlp -f $(OPTS) "pdbs"]
   750  !message *** Doing pdbs
   751  SYMBOLS		= 1
   752  !else
   753  SYMBOLS		= 0
   754  !endif
   755  
   756  !if [nmakehlp -f $(OPTS) "profile"]
   757  !message *** Doing profile
   758  PROFILE		= 1
   759  !else
   760  PROFILE		= 0
   761  !endif
   762  
   763  !if [nmakehlp -f $(OPTS) "pgi"]
   764  !message *** Doing profile guided optimization instrumentation
   765  PGO		= 1
   766  !elseif [nmakehlp -f $(OPTS) "pgo"]
   767  !message *** Doing profile guided optimization
   768  PGO		= 2
   769  !else
   770  PGO		= 0
   771  !endif
   772  
   773  !if [nmakehlp -f $(OPTS) "loimpact"]
   774  !message *** Warning: ignoring option "loimpact" - deprecated on modern Windows.
   775  !endif
   776  
   777  # TBD - should get rid of this option
   778  !if [nmakehlp -f $(OPTS) "thrdalloc"]
   779  !message *** Doing thrdalloc
   780  USE_THREAD_ALLOC = 1
   781  !endif
   782  
   783  !if [nmakehlp -f $(OPTS) "tclalloc"]
   784  USE_THREAD_ALLOC = 0
   785  !endif
   786  
   787  !if [nmakehlp -f $(OPTS) "unchecked"]
   788  !message *** Doing unchecked
   789  UNCHECKED = 1
   790  !else
   791  UNCHECKED = 0
   792  !endif
   793  
   794  !if [nmakehlp -f $(OPTS) "noconfigcheck"]
   795  CONFIG_CHECK = 1
   796  !else
   797  CONFIG_CHECK = 0
   798  !endif
   799  
   800  !endif # "$(OPTS)" != ""  && ... parsing of OPTS
   801  
   802  # Set linker flags based on above
   803  
   804  !if $(PGO) > 1
   805  !if [nmakehlp -l -ltcg:pgoptimize $(LINKER_TESTFLAGS)]
   806  LINKERFLAGS	= $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize
   807  !else
   808  MSG=^
   809  This compiler does not support profile guided optimization.
   810  !error $(MSG)
   811  !endif
   812  !elseif $(PGO) > 0
   813  !if [nmakehlp -l -ltcg:pginstrument $(LINKER_TESTFLAGS)]
   814  LINKERFLAGS	= $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument
   815  !else
   816  MSG=^
   817  This compiler does not support profile guided optimization.
   818  !error $(MSG)
   819  !endif
   820  !endif
   821  
   822  ################################################################
   823  # 7. Parse the STATS macro to configure code instrumentation
   824  # The following macros are set by this section:
   825  # TCL_MEM_DEBUG - 1 -> enables memory allocation instrumentation
   826  #                 0 -> disables
   827  # TCL_COMPILE_DEBUG - 1 -> enables byte compiler logging
   828  #                     0 -> disables
   829  
   830  # Default both are off
   831  TCL_MEM_DEBUG	    = 0
   832  TCL_COMPILE_DEBUG   = 0
   833  
   834  !if "$(STATS)" != "" && ![nmakehlp -f "$(STATS)" "none"]
   835  
   836  !if [nmakehlp -f $(STATS) "memdbg"]
   837  !message *** Doing memdbg
   838  TCL_MEM_DEBUG	    = 1
   839  !else
   840  TCL_MEM_DEBUG	    = 0
   841  !endif
   842  
   843  !if [nmakehlp -f $(STATS) "compdbg"]
   844  !message *** Doing compdbg
   845  TCL_COMPILE_DEBUG   = 1
   846  !else
   847  TCL_COMPILE_DEBUG   = 0
   848  !endif
   849  
   850  !endif
   851  
   852  ####################################################################
   853  # 8. Parse the CHECKS macro to configure additional compiler checks
   854  # The following macros are set by this section:
   855  # WARNINGS - compiler switches that control the warnings level
   856  # TCL_NO_DEPRECATED - 1 -> disable support for deprecated functions
   857  #                     0 -> enable deprecated functions
   858  
   859  # Defaults - Permit deprecated functions and warning level 3
   860  TCL_NO_DEPRECATED	    = 0
   861  WARNINGS		    = -W3
   862  
   863  !if "$(CHECKS)" != "" && ![nmakehlp -f "$(CHECKS)" "none"]
   864  
   865  !if [nmakehlp -f $(CHECKS) "nodep"]
   866  !message *** Doing nodep check
   867  TCL_NO_DEPRECATED	    = 1
   868  !endif
   869  
   870  !if [nmakehlp -f $(CHECKS) "fullwarn"]
   871  !message *** Doing full warnings check
   872  WARNINGS		    = -W4
   873  !if [nmakehlp -l -warn:3 $(LINKER_TESTFLAGS)]
   874  LINKERFLAGS		    = $(LINKERFLAGS) -warn:3
   875  !endif
   876  !endif
   877  
   878  !if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64]
   879  !message *** Doing 64bit portability warnings
   880  WARNINGS		    = $(WARNINGS) -Wp64
   881  !endif
   882  
   883  !endif
   884  
   885  ################################################################
   886  # 9. Extract various version numbers
   887  # For Tcl and Tk, version numbers are extracted from tcl.h and tk.h
   888  # respectively. For extensions, versions are extracted from the
   889  # configure.in or configure.ac from the TEA configuration if it
   890  # exists, and unset otherwise.
   891  # Sets the following macros:
   892  # TCL_MAJOR_VERSION
   893  # TCL_MINOR_VERSION
   894  # TCL_PATCH_LEVEL
   895  # TCL_VERSION
   896  # TK_MAJOR_VERSION
   897  # TK_MINOR_VERSION
   898  # TK_PATCH_LEVEL
   899  # TK_VERSION
   900  # DOTVERSION - set as (for example) 2.5
   901  # VERSION - set as (for example 25)
   902  #--------------------------------------------------------------
   903  
   904  !if [echo REM = This file is generated from rules.vc > versions.vc]
   905  !endif
   906  !if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
   907     && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
   908  !endif
   909  !if [echo TCL_MINOR_VERSION = \>> versions.vc] \
   910     && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
   911  !endif
   912  !if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
   913     && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
   914  !endif
   915  
   916  !if defined(_TK_H)
   917  !if [echo TK_MAJOR_VERSION = \>> versions.vc] \
   918     && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
   919  !endif
   920  !if [echo TK_MINOR_VERSION = \>> versions.vc] \
   921     && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
   922  !endif
   923  !if [echo TK_PATCH_LEVEL = \>> versions.vc] \
   924     && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
   925  !endif
   926  !endif # _TK_H
   927  
   928  !include versions.vc
   929  
   930  TCL_VERSION	= $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
   931  TCL_DOTVERSION	= $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
   932  !if defined(_TK_H)
   933  TK_VERSION	= $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
   934  TK_DOTVERSION	= $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
   935  !endif
   936  
   937  # Set DOTVERSION and VERSION
   938  !if $(DOING_TCL)
   939  
   940  DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
   941  VERSION = $(TCL_VERSION)
   942  
   943  !elseif $(DOING_TK)
   944  
   945  DOTVERSION = $(TK_DOTVERSION)
   946  VERSION = $(TK_VERSION)
   947  
   948  !else # Doing a non-Tk extension
   949  
   950  # If parent makefile has not defined DOTVERSION, try to get it from TEA
   951  # first from a configure.in file, and then from configure.ac
   952  !ifndef DOTVERSION
   953  !if [echo DOTVERSION = \> versions.vc] \
   954     || [nmakehlp -V $(ROOT)\configure.in ^[$(PROJECT)^] >> versions.vc]
   955  !if [echo DOTVERSION = \> versions.vc] \
   956     || [nmakehlp -V $(ROOT)\configure.ac ^[$(PROJECT)^] >> versions.vc]
   957  !error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
   958  !endif
   959  !endif
   960  !include versions.vc
   961  !endif # DOTVERSION
   962  VERSION         = $(DOTVERSION:.=)
   963  
   964  !endif # $(DOING_TCL) ... etc.
   965  
   966  ################################################################
   967  # 10. Construct output directory and file paths
   968  # Figure-out how to name our intermediate and output directories.
   969  # In order to avoid inadvertent mixing of object files built using
   970  # different compilers, build configurations etc.,
   971  #
   972  # Naming convention (suffixes):
   973  #   t = full thread support.
   974  #   s = static library (as opposed to an import library)
   975  #   g = linked to the debug enabled C run-time.
   976  #   x = special static build when it links to the dynamic C run-time.
   977  #
   978  # The following macros are set in this section:
   979  # SUFX - the suffix to use for binaries based on above naming convention
   980  # BUILDDIRTOP - the toplevel default output directory
   981  #      is of the form {Release,Debug}[_AMD64][_COMPILERVERSION]
   982  # TMP_DIR - directory where object files are created
   983  # OUT_DIR - directory where output executables are created
   984  # Both TMP_DIR and OUT_DIR are defaulted only if not defined by the
   985  # parent makefile (or command line). The default values are
   986  # based on BUILDDIRTOP.
   987  # STUBPREFIX - name of the stubs library for this project
   988  # PRJIMPLIB - output path of the generated project import library
   989  # PRJLIBNAME - name of generated project library
   990  # PRJLIB     - output path of generated project library
   991  # PRJSTUBLIBNAME - name of the generated project stubs library
   992  # PRJSTUBLIB - output path of the generated project stubs library
   993  # RESFILE - output resource file (only if not static build)
   994  
   995  SUFX	    = tsgx
   996  
   997  !if $(DEBUG)
   998  BUILDDIRTOP = Debug
   999  !else
  1000  BUILDDIRTOP = Release
  1001  !endif
  1002  
  1003  !if "$(MACHINE)" != "IX86"
  1004  BUILDDIRTOP =$(BUILDDIRTOP)_$(MACHINE)
  1005  !endif
  1006  !if $(VCVER) > 6
  1007  BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER)
  1008  !endif
  1009  
  1010  !if !$(DEBUG) || $(DEBUG) && $(UNCHECKED)
  1011  SUFX	    = $(SUFX:g=)
  1012  !endif
  1013  
  1014  TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX
  1015  
  1016  !if !$(STATIC_BUILD)
  1017  TMP_DIRFULL = $(TMP_DIRFULL:Static=)
  1018  SUFX	    = $(SUFX:s=)
  1019  EXT	    = dll
  1020  TMP_DIRFULL = $(TMP_DIRFULL:X=)
  1021  SUFX	    = $(SUFX:x=)
  1022  !else
  1023  TMP_DIRFULL = $(TMP_DIRFULL:Dynamic=)
  1024  EXT	    = lib
  1025  !if !$(MSVCRT)
  1026  TMP_DIRFULL = $(TMP_DIRFULL:X=)
  1027  SUFX	    = $(SUFX:x=)
  1028  !endif
  1029  !endif
  1030  
  1031  !if !$(TCL_THREADS)
  1032  TMP_DIRFULL = $(TMP_DIRFULL:Threaded=)
  1033  SUFX	    = $(SUFX:t=)
  1034  !endif
  1035  
  1036  !ifndef TMP_DIR
  1037  TMP_DIR	    = $(TMP_DIRFULL)
  1038  !ifndef OUT_DIR
  1039  OUT_DIR	    = .\$(BUILDDIRTOP)
  1040  !endif
  1041  !else
  1042  !ifndef OUT_DIR
  1043  OUT_DIR	    = $(TMP_DIR)
  1044  !endif
  1045  !endif
  1046  
  1047  # Relative paths -> absolute
  1048  !if [echo OUT_DIR = \> nmakehlp.out] \
  1049     || [nmakehlp -Q "$(OUT_DIR)" >> nmakehlp.out]
  1050  !error *** Could not fully qualify path OUT_DIR=$(OUT_DIR)
  1051  !endif
  1052  !if [echo TMP_DIR = \>> nmakehlp.out] \
  1053     || [nmakehlp -Q "$(TMP_DIR)" >> nmakehlp.out]
  1054  !error *** Could not fully qualify path TMP_DIR=$(TMP_DIR)
  1055  !endif
  1056  !include nmakehlp.out
  1057  
  1058  # The name of the stubs library for the project being built
  1059  STUBPREFIX      = $(PROJECT)stub
  1060  
  1061  # Set up paths to various Tcl executables and libraries needed by extensions
  1062  !if $(DOING_TCL)
  1063  
  1064  TCLSHNAME       = $(PROJECT)sh$(TCL_VERSION)$(SUFX).exe
  1065  TCLSH		= $(OUT_DIR)\$(TCLSHNAME)
  1066  TCLIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
  1067  TCLLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
  1068  TCLLIB		= $(OUT_DIR)\$(TCLLIBNAME)
  1069  
  1070  TCLSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
  1071  TCLSTUBLIB	= $(OUT_DIR)\$(TCLSTUBLIBNAME)
  1072  TCL_INCLUDES    = -I"$(WINDIR)" -I"$(GENERICDIR)"
  1073  
  1074  !else # ! $(DOING_TCL)
  1075  
  1076  !if $(TCLINSTALL) # Building against an installed Tcl
  1077  
  1078  # When building extensions, we need to locate tclsh. Depending on version
  1079  # of Tcl we are building against, this may or may not have a "t" suffix.
  1080  # Try various possibilities in turn.
  1081  TCLSH		= $(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe
  1082  !if !exist("$(TCLSH)") && $(TCL_THREADS)
  1083  TCLSH           = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe
  1084  !endif
  1085  !if !exist("$(TCLSH)")
  1086  TCLSH           = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX:t=).exe
  1087  !endif
  1088  
  1089  TCLSTUBLIB	= $(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib
  1090  TCLIMPLIB	= $(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib
  1091  # When building extensions, may be linking against Tcl that does not add
  1092  # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
  1093  !if !exist("$(TCLIMPLIB)")
  1094  TCLIMPLIB	= $(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX:t=).lib
  1095  !endif
  1096  TCL_LIBRARY	= $(_TCLDIR)\lib
  1097  TCLREGLIB	= $(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib
  1098  TCLDDELIB	= $(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib
  1099  TCLTOOLSDIR	= \must\have\tcl\sources\to\build\this\target
  1100  TCL_INCLUDES    = -I"$(_TCLDIR)\include"
  1101  
  1102  !else # Building against Tcl sources
  1103  
  1104  TCLSH		= $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe
  1105  !if !exist($(TCLSH)) && $(TCL_THREADS)
  1106  TCLSH		= $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX).exe
  1107  !endif
  1108  !if !exist($(TCLSH))
  1109  TCLSH		= $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX:t=).exe
  1110  !endif
  1111  TCLSTUBLIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib
  1112  TCLIMPLIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib
  1113  # When building extensions, may be linking against Tcl that does not add
  1114  # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
  1115  !if !exist("$(TCLIMPLIB)")
  1116  TCLIMPLIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX:t=).lib
  1117  !endif
  1118  TCL_LIBRARY	= $(_TCLDIR)\library
  1119  TCLREGLIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib
  1120  TCLDDELIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib
  1121  TCLTOOLSDIR	= $(_TCLDIR)\tools
  1122  TCL_INCLUDES	= -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
  1123  
  1124  !endif # TCLINSTALL
  1125  
  1126  tcllibs = "$(TCLSTUBLIB)" "$(TCLIMPLIB)"
  1127  
  1128  !endif # $(DOING_TCL)
  1129  
  1130  # We need a tclsh that will run on the host machine as part of the build.
  1131  # IX86 runs on all architectures.
  1132  !ifndef TCLSH_NATIVE
  1133  !if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
  1134  TCLSH_NATIVE	= $(TCLSH)
  1135  !else
  1136  !error You must explicitly set TCLSH_NATIVE for cross-compilation
  1137  !endif
  1138  !endif
  1139  
  1140  # Do the same for Tk and Tk extensions that require the Tk libraries
  1141  !if $(DOING_TK) || $(NEED_TK)
  1142  WISHNAMEPREFIX = wish
  1143  WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe
  1144  TKLIBNAME	= $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT)
  1145  TKSTUBLIBNAME	= tkstub$(TK_VERSION).lib
  1146  TKIMPLIBNAME	= tk$(TK_VERSION)$(SUFX).lib
  1147  
  1148  !if $(DOING_TK)
  1149  WISH 		= $(OUT_DIR)\$(WISHNAME)
  1150  TKSTUBLIB	= $(OUT_DIR)\$(TKSTUBLIBNAME)
  1151  TKIMPLIB	= $(OUT_DIR)\$(TKIMPLIBNAME)
  1152  TKLIB		= $(OUT_DIR)\$(TKLIBNAME)
  1153  TK_INCLUDES    = -I"$(WINDIR)" -I"$(GENERICDIR)"
  1154  
  1155  !else # effectively NEED_TK
  1156  
  1157  !if $(TKINSTALL) # Building against installed Tk
  1158  WISH		= $(_TKDIR)\bin\$(WISHNAME)
  1159  TKSTUBLIB	= $(_TKDIR)\lib\$(TKSTUBLIBNAME)
  1160  TKIMPLIB	= $(_TKDIR)\lib\$(TKIMPLIBNAME)
  1161  # When building extensions, may be linking against Tk that does not add
  1162  # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
  1163  !if !exist("$(TKIMPLIB)")
  1164  TKIMPLIBNAME	= tk$(TK_VERSION)$(SUFX:t=).lib
  1165  TKIMPLIB	= $(_TKDIR)\lib\$(TKIMPLIBNAME)
  1166  !endif
  1167  TK_INCLUDES     = -I"$(_TKDIR)\include"
  1168  !else # Building against Tk sources
  1169  WISH		= $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME)
  1170  TKSTUBLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME)
  1171  TKIMPLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
  1172  # When building extensions, may be linking against Tk that does not add
  1173  # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
  1174  !if !exist("$(TKIMPLIB)")
  1175  TKIMPLIBNAME	= tk$(TK_VERSION)$(SUFX:t=).lib
  1176  TKIMPLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
  1177  !endif
  1178  TK_INCLUDES     = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
  1179  !endif # TKINSTALL
  1180  tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)"
  1181  
  1182  !endif # $(DOING_TK)
  1183  !endif # $(DOING_TK) || $(NEED_TK)
  1184  
  1185  # Various output paths
  1186  PRJIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
  1187  PRJLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
  1188  PRJLIB		= $(OUT_DIR)\$(PRJLIBNAME)
  1189  
  1190  PRJSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
  1191  PRJSTUBLIB	= $(OUT_DIR)\$(PRJSTUBLIBNAME)
  1192  
  1193  # If extension parent makefile has not defined a resource definition file,
  1194  # we will generate one from standard template.
  1195  !if !$(DOING_TCL) && !$(DOING_TK) && !$(STATIC_BUILD)
  1196  !ifdef RCFILE
  1197  RESFILE = $(TMP_DIR)\$(RCFILE:.rc=.res)
  1198  !else
  1199  RESFILE = $(TMP_DIR)\$(PROJECT).res
  1200  !endif
  1201  !endif
  1202  
  1203  ###################################################################
  1204  # 11. Construct the paths for the installation directories
  1205  # The following macros get defined in this section:
  1206  # LIB_INSTALL_DIR - where libraries should be installed
  1207  # BIN_INSTALL_DIR - where the executables should be installed
  1208  # DOC_INSTALL_DIR - where documentation should be installed
  1209  # SCRIPT_INSTALL_DIR - where scripts should be installed
  1210  # INCLUDE_INSTALL_DIR - where C include files should be installed
  1211  # DEMO_INSTALL_DIR - where demos should be installed
  1212  # PRJ_INSTALL_DIR - where package will be installed (not set for Tcl and Tk)
  1213  
  1214  !if $(DOING_TCL) || $(DOING_TK)
  1215  LIB_INSTALL_DIR		= $(_INSTALLDIR)\lib
  1216  BIN_INSTALL_DIR		= $(_INSTALLDIR)\bin
  1217  DOC_INSTALL_DIR		= $(_INSTALLDIR)\doc
  1218  !if $(DOING_TCL)
  1219  SCRIPT_INSTALL_DIR	= $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
  1220  !else # DOING_TK
  1221  SCRIPT_INSTALL_DIR	= $(_INSTALLDIR)\lib\$(PROJECT)$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
  1222  !endif
  1223  DEMO_INSTALL_DIR	= $(SCRIPT_INSTALL_DIR)\demos
  1224  INCLUDE_INSTALL_DIR	= $(_INSTALLDIR)\include
  1225  
  1226  !else # extension other than Tk
  1227  
  1228  PRJ_INSTALL_DIR         = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
  1229  LIB_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
  1230  BIN_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
  1231  DOC_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
  1232  SCRIPT_INSTALL_DIR	= $(PRJ_INSTALL_DIR)
  1233  DEMO_INSTALL_DIR	= $(PRJ_INSTALL_DIR)\demos
  1234  INCLUDE_INSTALL_DIR	= $(_TCLDIR)\include
  1235  
  1236  !endif
  1237  
  1238  ###################################################################
  1239  # 12. Set up actual options to be passed to the compiler and linker
  1240  # Now we have all the information we need, set up the actual flags and
  1241  # options that we will pass to the compiler and linker. The main
  1242  # makefile should use these in combination with whatever other flags
  1243  # and switches are specific to it.
  1244  # The following macros are defined, names are for historical compatibility:
  1245  # OPTDEFINES - /Dxxx C macro flags based on user-specified OPTS
  1246  # COMPILERFLAGS - /Dxxx C macro flags independent of any configuration opttions
  1247  # crt - Compiler switch that selects the appropriate C runtime
  1248  # cdebug - Compiler switches related to debug AND optimizations
  1249  # cwarn - Compiler switches that set warning levels
  1250  # cflags - complete compiler switches (subsumes cdebug and cwarn)
  1251  # ldebug - Linker switches controlling debug information and optimization
  1252  # lflags - complete linker switches (subsumes ldebug) except subsystem type
  1253  # dlllflags - complete linker switches to build DLLs (subsumes lflags)
  1254  # conlflags - complete linker switches for console program (subsumes lflags)
  1255  # guilflags - complete linker switches for GUI program (subsumes lflags)
  1256  # baselibs - minimum Windows libraries required. Parent makefile can
  1257  #    define PRJ_LIBS before including rules.rc if additional libs are needed
  1258  
  1259  OPTDEFINES	= -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS
  1260  
  1261  !if $(TCL_MEM_DEBUG)
  1262  OPTDEFINES	= $(OPTDEFINES) -DTCL_MEM_DEBUG
  1263  !endif
  1264  !if $(TCL_COMPILE_DEBUG)
  1265  OPTDEFINES	= $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS
  1266  !endif
  1267  !if $(TCL_THREADS)
  1268  OPTDEFINES	= $(OPTDEFINES) -DTCL_THREADS=1
  1269  !if $(USE_THREAD_ALLOC)
  1270  OPTDEFINES	= $(OPTDEFINES) -DUSE_THREAD_ALLOC=1
  1271  !endif
  1272  !endif
  1273  !if $(STATIC_BUILD)
  1274  OPTDEFINES	= $(OPTDEFINES) -DSTATIC_BUILD
  1275  !endif
  1276  !if $(TCL_NO_DEPRECATED)
  1277  OPTDEFINES	= $(OPTDEFINES) -DTCL_NO_DEPRECATED
  1278  !endif
  1279  
  1280  !if $(USE_STUBS)
  1281  # Note we do not define USE_TCL_STUBS even when building Tk since some
  1282  # test targets in Tk do not use stubs
  1283  !if ! $(DOING_TCL)
  1284  USE_STUBS_DEFS  = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS
  1285  !if $(NEED_TK)
  1286  USE_STUBS_DEFS  = $(USE_STUBS_DEFS) -DUSE_TK_STUBS
  1287  !endif
  1288  !endif
  1289  !endif # USE_STUBS
  1290  
  1291  !if !$(DEBUG)
  1292  OPTDEFINES	= $(OPTDEFINES) -DNDEBUG
  1293  !if $(OPTIMIZING)
  1294  OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_OPTIMIZED
  1295  !endif
  1296  !endif
  1297  !if $(PROFILE)
  1298  OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_PROFILED
  1299  !endif
  1300  !if "$(MACHINE)" == "AMD64"
  1301  OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_DO64BIT
  1302  !endif
  1303  !if $(VCVERSION) < 1300
  1304  OPTDEFINES	= $(OPTDEFINES) -DNO_STRTOI64
  1305  !endif
  1306  
  1307  # _ATL_XP_TARGETING - Newer SDK's need this to build for XP
  1308  COMPILERFLAGS  = /D_ATL_XP_TARGETING
  1309  

  1310  # Following is primarily for the benefit of extensions. Tcl 8.5 builds
  1311  # Tcl without /DUNICODE, while 8.6 builds with it defined. When building
  1312  # an extension, it is advisable (but not mandated) to use the same Windows
  1313  # API as the Tcl build. This is accordingly defaulted below. A particular
  1314  # extension can override this by pre-defining USE_WIDECHAR_API.
  1315  !ifndef USE_WIDECHAR_API
  1316  !if $(TCL_VERSION) > 85
  1317  USE_WIDECHAR_API = 1
  1318  !else
  1319  USE_WIDECHAR_API = 0
  1320  !endif
  1321  !endif
  1322  
  1323  !if $(USE_WIDECHAR_API)
1324 COMPILERFLAGS = $(COMPILERFLAGS) /DUNICODE /D_UNICODE
1325 !endif 1326 1327 # Like the TEA system only set this non empty for non-Tk extensions 1328 # Note: some extensions use PACKAGE_NAME and others use PACKAGE_TCLNAME 1329 # so we pass both 1330 !if !$(DOING_TCL) && !$(DOING_TK) 1331 PKGNAMEFLAGS = -DPACKAGE_NAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \ 1332 -DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \ 1333 -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \ 1334 -DMODULE_SCOPE=extern 1335 !endif 1336 1337 # crt picks the C run time based on selected OPTS 1338 !if $(MSVCRT) 1339 !if $(DEBUG) && !$(UNCHECKED) 1340 crt = -MDd 1341 !else 1342 crt = -MD 1343 !endif 1344 !else 1345 !if $(DEBUG) && !$(UNCHECKED) 1346 crt = -MTd 1347 !else 1348 crt = -MT 1349 !endif 1350 !endif 1351 1352 # cdebug includes compiler options for debugging as well as optimization. 1353 !if $(DEBUG) 1354 1355 # In debugging mode, optimizations need to be disabled 1356 cdebug = -Zi -Od $(DEBUGFLAGS) 1357 1358 !else 1359 1360 cdebug = $(OPTIMIZATIONS) 1361 !if $(SYMBOLS) 1362 cdebug = $(cdebug) -Zi 1363 !endif 1364 1365 !endif # $(DEBUG) 1366 1367 # cwarn includes default warning levels. 1368 cwarn = $(WARNINGS) 1369 1370 !if "$(MACHINE)" == "AMD64" 1371 # Disable pointer<->int warnings related to cast between different sizes 1372 # There are a gadzillion of these due to use of ClientData and 1373 # clutter up compiler 1374 # output increasing chance of a real warning getting lost. So disable them. 1375 # Eventually some day, Tcl will be 64-bit clean. 1376 cwarn = $(cwarn) -wd4311 -wd4312 1377 !endif 1378 1379 ### Common compiler options that are architecture specific 1380 !if "$(MACHINE)" == "ARM" 1381 carch = -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE 1382 !else 1383 carch = 1384 !endif 1385 1386 !if $(DEBUG) 1387 # Turn warnings into errors 1388 cwarn = $(cwarn) -WX 1389 !endif 1390 1391 INCLUDES = $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) 1392 !if !$(DOING_TCL) && !$(DOING_TK) 1393 INCLUDES = $(INCLUDES) -I"$(GENERICDIR)" -I"$(WINDIR)" -I"$(COMPATDIR)" 1394 !endif 1395 1396 # These flags are defined roughly in the order of the pre-reform 1397 # rules.vc/makefile.vc to help visually compare that the pre- and 1398 # post-reform build logs 1399 1400 # cflags contains generic flags used for building practically all object files 1401 cflags = -nologo -c $(COMPILERFLAGS) $(carch) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug) 1402 1403 # appcflags contains $(cflags) and flags for building the application 1404 # object files (e.g. tclsh, or wish) pkgcflags contains $(cflags) plus 1405 # flags used for building shared object files The two differ in the 1406 # BUILD_$(PROJECT) macro which should be defined only for the shared 1407 # library *implementation* and not for its caller interface 1408 1409 appcflags = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) $(USE_STUBS_DEFS) 1410 appcflags_nostubs = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) 1411 pkgcflags = $(appcflags) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT) 1412 pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT) 1413 1414 # stubscflags contains $(cflags) plus flags used for building a stubs 1415 # library for the package. Note: -DSTATIC_BUILD is defined in 1416 # $(OPTDEFINES) only if the OPTS configuration indicates a static 1417 # library. However the stubs library is ALWAYS static hence included 1418 # here irrespective of the OPTS setting. 1419 # 1420 # TBD - tclvfs has a comment that stubs libs should not be compiled with -GL 1421 # without stating why. Tcl itself compiled stubs libs with this flag. 1422 # so we do not remove it from cflags. -GL may prevent extensions 1423 # compiled with one VC version to fail to link against stubs library 1424 # compiled with another VC version. Check for this and fix accordingly. 1425 stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(INCLUDES) 1426 1427 # Link flags 1428 1429 !if $(DEBUG) 1430 ldebug = -debug -debugtype:cv 1431 !else 1432 ldebug = -release -opt:ref -opt:icf,3 1433 !if $(SYMBOLS) 1434 ldebug = $(ldebug) -debug -debugtype:cv 1435 !endif 1436 !endif 1437 1438 # Note: Profiling is currently only possible with the Visual Studio Enterprise 1439 !if $(PROFILE) 1440 ldebug= $(ldebug) -profile 1441 !endif 1442 1443 ### Declarations common to all linker versions 1444 lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug) 1445 1446 !if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 1447 lflags = $(lflags) -nodefaultlib:libucrt.lib 1448 !endif 1449 1450 # Old linkers (Visual C++ 6 in particular) will link for fast loading 1451 # on Win98. Since we do not support Win98 any more, we specify nowin98 1452 # as recommended for NT and later. However, this is only required by 1453 # IX86 on older compilers and only needed if we are not doing a static build. 1454 1455 !if "$(MACHINE)" == "IX86" && !$(STATIC_BUILD) 1456 !if [nmakehlp -l -opt:nowin98 $(LINKER_TESTFLAGS)] 1457 # Align sections for PE size savings. 1458 lflags = $(lflags) -opt:nowin98 1459 !endif 1460 !endif 1461 1462 dlllflags = $(lflags) -dll 1463 conlflags = $(lflags) -subsystem:console 1464 guilflags = $(lflags) -subsystem:windows 1465 1466 # Libraries that are required for every image. 1467 # Extensions should define any additional libraries with $(PRJ_LIBS) 1468 winlibs = kernel32.lib advapi32.lib 1469 1470 !if $(NEED_TK) 1471 winlibs = $(winlibs) gdi32.lib user32.lib uxtheme.lib 1472 !endif 1473 1474 # Avoid 'unresolved external symbol __security_cookie' errors. 1475 # c.f. http://support.microsoft.com/?id=894573 1476 !if "$(MACHINE)" == "AMD64" 1477 !if $(VCVERSION) > 1399 && $(VCVERSION) < 1500 1478 winlibs = $(winlibs) bufferoverflowU.lib 1479 !endif 1480 !endif 1481 1482 baselibs = $(winlibs) $(PRJ_LIBS) 1483 1484 !if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 1485 baselibs = $(baselibs) ucrt.lib 1486 !endif 1487 1488 ################################################################ 1489 # 13. Define standard commands, common make targets and implicit rules 1490 1491 CCPKGCMD = $(cc32) $(pkgcflags) -Fo$(TMP_DIR)^\ 1492 CCAPPCMD = $(cc32) $(appcflags) -Fo$(TMP_DIR)^\ 1493 CCSTUBSCMD = $(cc32) $(stubscflags) -Fo$(TMP_DIR)^\ 1494 1495 LIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@ 1496 DLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) 1497 1498 CONEXECMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) 1499 GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) 1500 RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ 1501 $(TCL_INCLUDES) \ 1502 -DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \ 1503 -DCOMMAVERSION=$(DOTVERSION:.=,),0 \ 1504 -DDOTVERSION=\"$(DOTVERSION)\" \ 1505 -DVERSION=\"$(VERSION)\" \ 1506 -DSUFX=\"$(SUFX)\" \ 1507 -DPROJECT=\"$(PROJECT)\" \ 1508 -DPRJLIBNAME=\"$(PRJLIBNAME)\" 1509 1510 !ifndef DEFAULT_BUILD_TARGET 1511 DEFAULT_BUILD_TARGET = $(PROJECT) 1512 !endif 1513 1514 default-target: $(DEFAULT_BUILD_TARGET) 1515 1516 default-pkgindex: 1517 @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \ 1518 [list load [file join $$dir $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl 1519 1520 default-pkgindex-tea: 1521 @if exist $(ROOT)\pkgIndex.tcl.in nmakehlp -s << $(ROOT)\pkgIndex.tcl.in > $(OUT_DIR)\pkgIndex.tcl 1522 @PACKAGE_VERSION@ $(DOTVERSION) 1523 @PACKAGE_NAME@ $(PRJ_PACKAGE_TCLNAME) 1524 @PACKAGE_TCLNAME@ $(PRJ_PACKAGE_TCLNAME) 1525 @PKG_LIB_FILE@ $(PRJLIBNAME) 1526 << 1527 1528 1529 default-install: default-install-binaries default-install-libraries 1530 1531 default-install-binaries: $(PRJLIB) 1532 @echo Installing binaries to '$(SCRIPT_INSTALL_DIR)' 1533 @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)" 1534 @$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL 1535 1536 default-install-libraries: $(OUT_DIR)\pkgIndex.tcl 1537 @echo Installing libraries to '$(SCRIPT_INSTALL_DIR)' 1538 @if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)" 1539 @echo Installing package index in '$(SCRIPT_INSTALL_DIR)' 1540 @$(CPY) $(OUT_DIR)\pkgIndex.tcl $(SCRIPT_INSTALL_DIR) 1541 1542 default-install-stubs: 1543 @echo Installing stubs library to '$(SCRIPT_INSTALL_DIR)' 1544 @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)" 1545 @$(CPY) $(PRJSTUBLIB) "$(SCRIPT_INSTALL_DIR)" >NUL 1546 1547 default-install-docs-html: 1548 @echo Installing documentation files to '$(DOC_INSTALL_DIR)' 1549 @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)" 1550 @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css" "$(DOCDIR)\*.png") do @$(COPY) %f "$(DOC_INSTALL_DIR)" 1551 1552 default-install-docs-n: 1553 @echo Installing documentation files to '$(DOC_INSTALL_DIR)' 1554 @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)" 1555 @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.n") do @$(COPY) %f "$(DOC_INSTALL_DIR)" 1556 1557 default-install-demos: 1558 @echo Installing demos to '$(DEMO_INSTALL_DIR)' 1559 @if not exist "$(DEMO_INSTALL_DIR)" mkdir "$(DEMO_INSTALL_DIR)" 1560 @if exist $(DEMODIR) $(CPYDIR) "$(DEMODIR)" "$(DEMO_INSTALL_DIR)" 1561 1562 default-clean: 1563 @echo Cleaning $(TMP_DIR)\* ... 1564 @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR) 1565 @echo Cleaning $(WINDIR)\nmakehlp.obj, nmakehlp.exe ... 1566 @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj 1567 @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe 1568 @if exist $(WINDIR)\nmakehlp.out del $(WINDIR)\nmakehlp.out 1569 @echo Cleaning $(WINDIR)\nmhlp-out.txt ... 1570 @if exist $(WINDIR)\nmhlp-out.txt del $(WINDIR)\nmhlp-out.txt 1571 @echo Cleaning $(WINDIR)\_junk.pch ... 1572 @if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch 1573 @echo Cleaning $(WINDIR)\vercl.x, vercl.i ... 1574 @if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x 1575 @if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i 1576 @echo Cleaning $(WINDIR)\versions.vc, version.vc ... 1577 @if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc 1578 @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc 1579 1580 default-hose: default-clean 1581 @echo Hosing $(OUT_DIR)\* ... 1582 @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR) 1583 1584 # Only for backward compatibility 1585 default-distclean: default-hose 1586 1587 default-setup: 1588 @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) 1589 @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) 1590 1591 !if "$(TESTPAT)" != "" 1592 TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT) 1593 !endif 1594 1595 default-test: default-setup $(PROJECT) 1596 @set TCLLIBPATH=$(OUT_DIR:\=/) 1597 @if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)" 1598 cd "$(TESTDIR)" && $(DEBUGGER) $(TCLSH) all.tcl $(TESTFLAGS) 1599 1600 default-shell: default-setup $(PROJECT) 1601 @set TCLLIBPATH=$(OUT_DIR:\=/) 1602 @if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)" 1603 $(DEBUGGER) $(TCLSH) 1604 1605 # Generation of Windows version resource 1606 !ifdef RCFILE 1607 1608 # Note: don't use $** in below rule because there may be other dependencies 1609 # and only the "master" rc must be passed to the resource compiler 1610 $(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc 1611 $(RESCMD) $(RCDIR)\$(PROJECT).rc 1612 1613 !else 1614 1615 # If parent makefile has not defined a resource definition file, 1616 # we will generate one from standard template. 1617 $(TMP_DIR)\$(PROJECT).res: $(TMP_DIR)\$(PROJECT).rc 1618 1619 $(TMP_DIR)\$(PROJECT).rc: 1620 @$(COPY) << $(TMP_DIR)\$(PROJECT).rc 1621 #include <winver.h> 1622 1623 VS_VERSION_INFO VERSIONINFO 1624 FILEVERSION COMMAVERSION 1625 PRODUCTVERSION COMMAVERSION 1626 FILEFLAGSMASK 0x3fL 1627 #ifdef DEBUG 1628 FILEFLAGS VS_FF_DEBUG 1629 #else 1630 FILEFLAGS 0x0L 1631 #endif 1632 FILEOS VOS_NT_WINDOWS32 1633 FILETYPE VFT_DLL 1634 FILESUBTYPE 0x0L 1635 BEGIN 1636 BLOCK "StringFileInfo" 1637 BEGIN 1638 BLOCK "040904b0" 1639 BEGIN 1640 VALUE "FileDescription", "Tcl extension " PROJECT 1641 VALUE "OriginalFilename", PRJLIBNAME 1642 VALUE "FileVersion", DOTVERSION 1643 VALUE "ProductName", "Package " PROJECT " for Tcl" 1644 VALUE "ProductVersion", DOTVERSION 1645 END 1646 END 1647 BLOCK "VarFileInfo" 1648 BEGIN 1649 VALUE "Translation", 0x409, 1200 1650 END 1651 END 1652 1653 << 1654 1655 !endif # ifdef RCFILE 1656 1657 !ifndef DISABLE_IMPLICIT_RULES 1658 DISABLE_IMPLICIT_RULES = 0 1659 !endif 1660 1661 !if !$(DISABLE_IMPLICIT_RULES) 1662 # Implicit rule definitions - only for building library objects. For stubs and 1663 # main application, the master makefile should define explicit rules. 1664 1665 {$(ROOT)}.c{$(TMP_DIR)}.obj:: 1666 $(CCPKGCMD) @<< 1667 $< 1668 << 1669 1670 {$(WINDIR)}.c{$(TMP_DIR)}.obj:: 1671 $(CCPKGCMD) @<< 1672 $< 1673 << 1674 1675 {$(GENERICDIR)}.c{$(TMP_DIR)}.obj:: 1676 $(CCPKGCMD) @<< 1677 $< 1678 << 1679 1680 {$(COMPATDIR)}.c{$(TMP_DIR)}.obj:: 1681 $(CCPKGCMD) @<< 1682 $< 1683 << 1684 1685 {$(RCDIR)}.rc{$(TMP_DIR)}.res: 1686 $(RESCMD) $< 1687 1688 {$(WINDIR)}.rc{$(TMP_DIR)}.res: 1689 $(RESCMD) $< 1690 1691 {$(TMP_DIR)}.rc{$(TMP_DIR)}.res: 1692 $(RESCMD) $< 1693 1694 .SUFFIXES: 1695 .SUFFIXES:.c .rc 1696 1697 !endif 1698 1699 ################################################################ 1700 # 14. Sanity check selected options against Tcl build options 1701 # When building an extension, certain configuration options should 1702 # match the ones used when Tcl was built. Here we check and 1703 # warn on a mismatch. 1704 !if ! $(DOING_TCL) 1705 1706 !if $(TCLINSTALL) # Building against an installed Tcl 1707 !if exist("$(_TCLDIR)\lib\nmake\tcl.nmake") 1708 TCLNMAKECONFIG = "$(_TCLDIR)\lib\nmake\tcl.nmake" 1709 !endif 1710 !else # ! $(TCLINSTALL) - building against Tcl source 1711 !if exist("$(OUT_DIR)\tcl.nmake") 1712 TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake" 1713 !endif 1714 !endif # TCLINSTALL 1715 1716 !if $(CONFIG_CHECK) 1717 !ifdef TCLNMAKECONFIG 1718 !include $(TCLNMAKECONFIG) 1719 1720 !if defined(CORE_MACHINE) && "$(CORE_MACHINE)" != "$(MACHINE)" 1721 !error ERROR: Build target ($(MACHINE)) does not match the Tcl library architecture ($(CORE_MACHINE)). 1722 !endif 1723 !if defined(CORE_USE_THREAD_ALLOC) && $(CORE_USE_THREAD_ALLOC) != $(USE_THREAD_ALLOC) 1724 !message WARNING: Value of USE_THREAD_ALLOC ($(USE_THREAD_ALLOC)) does not match its Tcl core value ($(CORE_USE_THREAD_ALLOC)). 1725 !endif 1726 !if defined(CORE_DEBUG) && $(CORE_DEBUG) != $(DEBUG) 1727 !message WARNING: Value of DEBUG ($(DEBUG)) does not match its Tcl library configuration ($(DEBUG)). 1728 !endif 1729 !endif 1730 1731 !endif # TCLNMAKECONFIG 1732 1733 !endif # ! $(DOING_TCL) 1734 1735 1736 #---------------------------------------------------------- 1737 # Display stats being used. 1738 #---------------------------------------------------------- 1739 1740 !if !$(DOING_TCL) 1741 !message *** Building against Tcl at '$(_TCLDIR)' 1742 !endif 1743 !if !$(DOING_TK) && $(NEED_TK) 1744 !message *** Building against Tk at '$(_TKDIR)' 1745 !endif 1746 !message *** Intermediate directory will be '$(TMP_DIR)' 1747 !message *** Output directory will be '$(OUT_DIR)' 1748 !message *** Installation, if selected, will be in '$(_INSTALLDIR)' 1749 !message *** Suffix for binaries will be '$(SUFX)' 1750 !message *** Compiler version $(VCVER). Target $(MACHINE), host $(NATIVE_ARCH). 1751 1752 !endif # ifdef _RULES_VC