Tcl UDP

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

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

Overview
Comment:Updated to latest Tcl rules
Timelines: family | ancestors | descendants | both | vc-reform
Files: files | file ages | folders
SHA1:b01a44a88a3915ff076aa956f507d6610c752b74
User & Date: apnadkarni 2017-10-16 13:17:18
Context
2017-10-26
15:13
Purged old comments check-in: 9ce8fa7778 user: apnadkarni tags: vc-reform
2017-10-16
13:17
Updated to latest Tcl rules check-in: b01a44a88a user: apnadkarni tags: vc-reform
2017-10-08
16:05
Get rid of tcludp.rc and use the default rc template instead check-in: b43da5b57b user: apnadkarni tags: vc-reform
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to win/makefile.vc.

   139    139   !if !exist("makefile.vc")
   140    140   MSG = ^
   141    141   You must run this makefile only from the directory it is in.^
   142    142   Please `cd` to its location first.
   143    143   !error $(MSG)
   144    144   !endif
   145    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         -
   161    146   PROJECT = udp
   162    147   !include "rules-ext.vc"
   163    148   
   164         -PRJ_OBJS = \
   165         -	$(TMP_DIR)\udp_tcl.obj \
   166         -	$(TMP_DIR)\$(PROJECT).res
          149  +PRJ_OBJS = $(TMP_DIR)\udp_tcl.obj
   167    150   
   168         -PRJDOCS = \
   169         -	$(OUT_DIR)\udp.html
          151  +PRJ_DOCS = $(OUT_DIR)\udp.html
   170    152   
   171    153   #-------------------------------------------------------------------------
   172    154   # Target names and paths ( shouldn't need changing )
   173    155   #-------------------------------------------------------------------------
   174    156   
   175    157   
   176    158   PRJ_DEFINES     = -D_CRT_SECURE_NO_WARNINGS \
   177    159   		  -D_WINSOCK_DEPRECATED_NO_WARNINGS
   178    160   PRJ_LIBS	= ws2_32.lib
   179    161   
   180    162   # Define the standard targets
   181    163   !include "$(_RULESDIR)\targets.vc"
   182    164   
   183         -# We will use the standard resource template instead of writing our own
   184         -$(TMP_DIR)\$(PROJECT).res: default-rc
   185         -
   186    165   #---------------------------------------------------------------------
   187    166   # Project specific targets (EDIT)
   188    167   #---------------------------------------------------------------------
   189    168   
   190         -all:	    setup $(PROJECT)
   191         -doc:        setup $(PRJDOCS)
          169  +doc:        setup $(PRJ_DOCS)
   192    170   install:    install-docs install-demos
   193    171   pkgindex:   default-pkgindex
   194    172   
   195    173   test: setup $(PROJECT)
   196    174           $(TCLSH) <<
   197    175   load $(PRJLIB:\=/)
   198    176   cd {$(ROOT)/tests}
................................................................................
   213    191   set f [open $$name r]; set d [read $$f]; close $$f
   214    192   set d [regsub {</head>} $$d {<link rel="stylesheet" href="manpage.css" type="text/css"></head>}]
   215    193   set f [open $$name w]; puts -nonewline $$f $$d; close $$f
   216    194   <<
   217    195   
   218    196   .SUFFIXES: .man
   219    197   
   220         -install-docs: $(PRJDOCS)
          198  +install-docs: $(PRJ_DOCS)
   221    199   	@echo Installing documentation to '$(DOC_INSTALL_DIR)'
   222    200   	@if not exist $(DOC_INSTALL_DIR)\NUL mkdir "$(DOC_INSTALL_DIR)"
   223    201   	@$(CPY) "$(DOCDIR)\manpage.css" "$(DOC_INSTALL_DIR)\" >NUL
   224         -	@for %i in ($(PRJDOCS)) do @$(CPY) %i "$(DOC_INSTALL_DIR)\" > NUL
          202  +	@for %i in ($(PRJ_DOCS)) do @$(CPY) %i "$(DOC_INSTALL_DIR)\" > NUL
   225    203   
   226    204   install-demos:
   227    205   	@echo Installing demos to '$(DEMO_INSTALL_DIR)'
   228    206   	@if not exist $(DEMO_INSTALL_DIR)\nul mkdir "$(DEMO_INSTALL_DIR)"
   229    207   	@$(CPY) $(DEMODIR)\*.tcl "$(DEMO_INSTALL_DIR)" >NUL
   230    208   

Changes to win/nmakehlp.c.

    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,

Changes to win/rules.vc.

    14     14   
    15     15   !ifndef _RULES_VC
    16     16   _RULES_VC = 1
    17     17   
    18     18   # The following macros define the version of the rules.vc nmake build system
    19     19   RULES_VERSION_MAJOR = 1
    20     20   RULES_VERSION_MINOR = 0
           21  +
           22  +# The PROJECT macro must be defined by parent makefile.
           23  +# Also special case Tcl and Tk to save some typing later
           24  +!ifndef PROJECT
           25  +!error *** Error: Macro PROJECT not defined! Please define it before including rules.vc
           26  +!endif
           27  +DOING_TCL = 0
           28  +DOING_TK  = 0
           29  +!if "$(PROJECT)" == "tcl"
           30  +DOING_TCL = 1
           31  +!elseif "$(PROJECT)" == "tk"
           32  +DOING_TK = 1
           33  +!endif
           34  +
           35  +!ifndef PROJECT_REQUIRES_TK
           36  +PROJECT_REQUIRES_TK = 0
           37  +!endif
    21     38   
    22     39   ################################################################
    23     40   # Nmake is a pretty weak environment in syntax and capabilities
    24     41   # so this file is necessarily verbose. It's broken down into
    25     42   # the following parts.
    26     43   #
    27         -# 0. Sanity check that compiler environment is set up.
           44  +# 0. Sanity check that compiler environment is set up and initialize
           45  +#    any built-in settings from the parent makefile
    28     46   # 1. First define the external tools used for compiling, copying etc.
    29     47   #    as this is independent of everything else.
    30     48   # 2. Figure out our build structure in terms of the directory, whether
    31     49   #    we are building Tcl or an extension, etc.
    32     50   # 3. Determine the compiler and linker versions
    33     51   # 4. Build the nmakehlp helper application
    34     52   # 5. Determine the supported compiler options and features
................................................................................
    71     89   #----------------------------------------------------------
    72     90   
    73     91   RMDIR	= rmdir /S /Q
    74     92   ERRNULL  = 2>NUL
    75     93   CPY	= xcopy /i /y >NUL
    76     94   COPY	= copy /y >NUL
    77     95   MKDIR   = mkdir
    78         -
    79         -# The ProgramFiles(x86) environment variable is not accessible
    80         -# from nmake since it has the parenthesis which nmake does not like
    81         -# within a macro name. So define our own in terms of the
    82         -# ProgramFiles environment variable.
    83         -# Note: env variables are always UPPER CASE in nmake
    84         -!if defined(PROCESSOR_ARCHITECTURE) && "$(PROCESSOR_ARCHITECTURE)" == "AMD64"
    85         -PROGRAMFILES_X86 = $(PROGRAMFILES) (x86)
    86         -!else
    87         -PROGRAMFILES_X86 = $(PROGRAMFILES)
    88         -!endif
    89         -
    90     96   
    91     97   ######################################################################
    92     98   # 2. Figure out our build environment in terms of what we're building.
    93     99   #
    94    100   # (a) Tcl itself
    95    101   # (b) Tk
    96    102   # (c) a Tcl extension using libraries/includes from an *installed* Tcl
................................................................................
   153    159   # WINDIR env var to point to c:\windows!
   154    160   # TBD - This is a potentially dangerous conflict, rename WINDIR to
   155    161   # something else
   156    162   WINDIR		= $(ROOT)\win
   157    163   !ifndef RCDIR
   158    164   RCDIR           = $(WINDIR)\rc
   159    165   !endif
          166  +RCDIR = $(RCDIR:/=\)
   160    167   
   161    168   # The target directory where the built packages and binaries will be installed.
   162    169   # INSTALLDIR is the (optional) path specified by the user.
   163    170   # _INSTALLDIR is INSTALLDIR using the backslash separator syntax
   164    171   !ifdef INSTALLDIR
   165    172   ### Fix the path separators.
   166    173   _INSTALLDIR	= $(INSTALLDIR:/=\)
   167    174   !else
   168    175   ### Assume the normal default.
   169         -_INSTALLDIR	= C:\Program Files\Tcl
          176  +_INSTALLDIR	= $(HOMEDRIVE)\Tcl
   170    177   !endif
   171    178   
   172         -!if "$(PROJECT)" == "tcl" 
          179  +!if $(DOING_TCL)
   173    180   
   174    181   # BEGIN Case 2(a) - Building Tcl itself
   175    182   
   176    183   # Only need to define _TCL_H
   177    184   _TCL_H = ..\generic\tcl.h
   178    185   
   179    186   # END Case 2(a) - Building Tcl itself
   180    187   
   181         -!elseif "$(PROJECT)" == "tk"
          188  +!elseif $(DOING_TK)
   182    189   
   183    190   # BEGIN Case 2(b) - Building Tk
   184    191   
   185    192   TCLINSTALL = 0 # Tk always builds against Tcl source, not an installed Tcl
   186    193   !ifndef TCLDIR
   187    194   TCLDIR  = ../../tcl
   188    195   !endif
................................................................................
   234    241   !ifndef _TCL_H
   235    242   MSG =^
   236    243   Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and default path does not contain tcl.h.
   237    244   !error $(MSG)
   238    245   !endif
   239    246   
   240    247   # Now do the same to locate Tk headers and libs if project requires Tk
   241         -!ifdef PROJECT_REQUIRES_TK
          248  +!if $(PROJECT_REQUIRES_TK)
   242    249   
   243    250   !ifdef TKDIR
   244    251   
   245    252   _TKDIR = $(TKDIR:/=\)
   246    253   !if exist("$(_TKDIR)\include\tk.h")
   247    254   TKINSTALL      = 1
   248    255   _TK_H          = $(_TKDIR)\include\tk.h
................................................................................
   278    285   # If INSTALLDIR set to tcl installation root dir then reset to the
   279    286   # lib dir for installing extensions 
   280    287   !if exist("$(_INSTALLDIR)\include\tcl.h")
   281    288   _INSTALLDIR=$(_INSTALLDIR)\lib
   282    289   !endif
   283    290   
   284    291   # END Case 2(c) or (d) - Building an extension
   285         -!endif # if $(PROJECT) == "tcl"
          292  +!endif # if $(DOING_TCL)
   286    293   
   287    294   ################################################################
   288    295   # 3. Determine compiler version and architecture
   289    296   # In this section, we figure out the compiler version and the
   290    297   # architecture for which we are building. This sets the
   291    298   # following macros:
   292    299   # VCVERSION - the internal compiler version as 1200, 1400, 1910 etc.
................................................................................
   372    379   _VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2
   373    380   !endif
   374    381   
   375    382   !ifndef CFG_ENCODING
   376    383   CFG_ENCODING	= \"cp1252\"
   377    384   !endif
   378    385   
   379         -!message =====================================================================
   380         -
   381    386   ################################################################
   382    387   # 4. Build the nmakehlp program
   383    388   # This is a helper app we need to overcome nmake's limiting
   384    389   # environment. We will call out to it to get various bits of
   385    390   # information about supported compiler options etc.
   386    391   #
   387    392   # Tcl itself will always use the nmakehlp.c program which is
................................................................................
   391    396   # copy of Tcl's nmakehlp.c if there is one and their own version
   392    397   # otherwise. In the latter case, they would also be using their own
   393    398   # rules.vc. Note that older versions of Tcl do not install nmakehlp.c
   394    399   # or rules.vc.
   395    400   #
   396    401   # Extensions built against Tcl sources will use the one from the Tcl source.
   397    402   #
   398         -# This can all be overridden by defining the NMAKEHLPC macro to point
   399         -# to the nmakehlp.c file to be used, either from the command line or
   400         -# the containing makefile.
          403  +# When building an extension using a sufficiently new version of Tcl,
          404  +# rules-ext.vc will define NMAKEHLPC appropriately to point to the
          405  +# copy of nmakehlp.c to be used.
   401    406   
   402    407   !ifndef NMAKEHLPC
   403    408   # Default to the one in the current directory (the extension's own nmakehlp.c)
   404    409   NMAKEHLPC = nmakehlp.c
   405    410   
   406         -!if "$(PROJECT)" != "tcl"
          411  +!if !$(DOING_TCL)
   407    412   !if $(TCLINSTALL)
   408    413   !if exist("$(_TCLDIR)\lib\nmake\nmakehlp.c")
   409    414   NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c
   410    415   !endif
   411    416   !else # ! $(TCLINSTALL)
   412    417   !if exist("$(_TCLDIR)\win\nmakehlp.c")
   413    418   NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c
   414    419   !endif
   415    420   !endif # $(TCLINSTALL)
   416         -!endif # $(PROJECT) != "tcl"
          421  +!endif # !$(DOING_TCL)
   417    422   
   418    423   !endif # NMAKEHLPC
   419    424   
   420    425   # We always build nmakehlp even if it exists since we do not know
   421    426   # what source it was built from.
   422    427   !message *** Using $(NMAKEHLPC)
   423    428   !if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul]
................................................................................
   570    575   PGO		= 0
   571    576   MSVCRT		= 1
   572    577   LOIMPACT	= 0
   573    578   TCL_USE_STATIC_PACKAGES	= 0
   574    579   USE_THREAD_ALLOC = 1
   575    580   UNCHECKED	= 0
   576    581   CONFIG_CHECK    = 1
   577         -!if "$(PROJECT)" == "tcl"
          582  +!if $(DOING_TCL)
   578    583   USE_STUBS       = 0
   579    584   !else
   580    585   USE_STUBS       = 1
   581    586   !endif
   582    587   
   583    588   # If OPTS is not empty AND does not contain "none" which turns off all OPTS
   584    589   # set the above macros based on OPTS content
................................................................................
   768    773   !message *** Doing 64bit portability warnings
   769    774   WARNINGS		    = $(WARNINGS) -Wp64
   770    775   !endif
   771    776   
   772    777   !endif
   773    778   
   774    779   ################################################################
   775         -# 9. Extract various version numbers from tcl headers
          780  +# 9. Extract various version numbers
          781  +# For Tcl and Tk, version numbers are exctracted from tcl.h and tk.h
          782  +# respectively. For extensions, versions are extracted from the
          783  +# configure.in or configure.ac from the TEA configuration if it
          784  +# exists, and unset otherwise.
   776    785   # Sets the following macros:
   777    786   # TCL_MAJOR_VERSION
   778    787   # TCL_MINOR_VERSION
   779    788   # TCL_PATCH_LEVEL
   780    789   # TCL_VERSION
   781    790   # TK_MAJOR_VERSION
   782    791   # TK_MINOR_VERSION
   783    792   # TK_PATCH_LEVEL
   784    793   # TK_VERSION
          794  +# DOTVERSION - set as (for example) 2.5
          795  +# VERSION - set as (for example 25)
   785    796   #--------------------------------------------------------------
   786    797   
   787    798   !if [echo REM = This file is generated from rules.vc > versions.vc]
   788    799   !endif
   789    800   !if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
   790    801      && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
   791    802   !endif
................................................................................
   807    818      && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
   808    819   !endif
   809    820   !endif # _TK_H
   810    821   
   811    822   !include versions.vc
   812    823   
   813    824   TCL_VERSION	= $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
          825  +TCL_DOTVERSION	= $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
   814    826   !if defined(_TK_H)
   815    827   TK_VERSION	= $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
          828  +TK_DOTVERSION	= $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
   816    829   !endif
   817    830   
          831  +# Set DOTVERSION and VERSION
          832  +!if $(DOING_TCL)
          833  +
          834  +DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
          835  +VERSION = $(TCL_VERSION)
          836  +
          837  +!elseif $(DOING_TK)
          838  +
          839  +DOTVERSION = $(TK_DOTVERSION)
          840  +VERSION = $(TK_VERSION)
          841  +
          842  +!else # Doing a non-Tk extension
          843  +
          844  +# If parent makefile has not defined DOTVERSION, try to get it from TEA
          845  +# first from a configure.in file, and then from configure.ac
          846  +!ifndef DOTVERSION
          847  +!if [echo DOTVERSION = \> versions.vc] \
          848  +   || [nmakehlp -V $(ROOT)\configure.in AC_INIT >> versions.vc]
          849  +!if [echo DOTVERSION = \> versions.vc] \
          850  +   || [nmakehlp -V $(ROOT)\configure.ac AC_INIT >> versions.vc]
          851  +!error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
          852  +!endif
          853  +!endif
          854  +!include versions.vc
          855  +!endif # DOTVERSION
          856  +VERSION         = $(DOTVERSION:.=)
          857  +
          858  +!endif # $(DOING_TCL) ... etc.
   818    859   
   819    860   ################################################################
   820    861   # 10. Construct output directory and file paths
   821    862   # Figure-out how to name our intermediate and output directories.
   822    863   # In order to avoid inadvertent mixing of object files built using
   823    864   # different compilers, build configurations etc.,
   824    865   #
................................................................................
   830    871   #
   831    872   # The following macros are set in this section:
   832    873   # SUFX - the suffix to use for binaries based on above naming convention
   833    874   # BUILDDIRTOP - the toplevel default output directory
   834    875   #      is of the form {Release,Debug}[_AMD64][_COMPILERVERSION]
   835    876   # TMP_DIR - directory where object files are created
   836    877   # OUT_DIR - directory where output executables are created
   837         -# STUBPREFIX - name of the stubs library for this project
   838    878   # Both TMP_DIR and OUT_DIR are defaulted only if not defined by the
   839    879   # parent makefile (or command line). The default values are
   840    880   # based on BUILDDIRTOP.
          881  +# STUBPREFIX - name of the stubs library for this project
          882  +# PRJIMPLIB - output path of the generated project import library
          883  +# PRJLIBNAME - name of generated project library
          884  +# PRJLIB     - output path of generated project library
          885  +# PRJSTUBLIBNAME - name of the generated project stubs library
          886  +# PRJSTUBLIB - output path of the generated project stubs library
          887  +# RESFILE - output resource file (only if not static build)
   841    888   
   842    889   SUFX	    = tsgx
   843    890   
   844    891   !if $(DEBUG)
   845    892   BUILDDIRTOP = Debug
   846    893   !else
   847    894   BUILDDIRTOP = Release
................................................................................
   891    938   !endif
   892    939   !endif
   893    940   
   894    941   # The name of the stubs library for the project being built
   895    942   STUBPREFIX      = $(PROJECT)stub
   896    943   
   897    944   # Set up paths to various Tcl executables and libraries needed by extensions
   898         -!if "$(PROJECT)" == "tcl"
          945  +!if $(DOING_TCL)
   899    946   
   900    947   TCLSHNAME       = $(PROJECT)sh$(TCL_VERSION)$(SUFX).exe
   901    948   TCLSH		= $(OUT_DIR)\$(TCLSHNAME)
   902    949   TCLIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
   903    950   TCLLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
   904    951   TCLLIB		= $(OUT_DIR)\$(TCLLIBNAME)
   905    952   
   906    953   TCLSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
   907    954   TCLSTUBLIB	= $(OUT_DIR)\$(TCLSTUBLIBNAME)
   908    955   TCL_INCLUDES    = -I"$(WINDIR)" -I"$(GENERICDIR)"
   909    956   
   910         -!else # $(PROJECT) is not "tcl"
          957  +!else # ! $(DOING_TCL)
   911    958   
   912    959   !if $(TCLINSTALL) # Building against an installed Tcl
   913    960   
   914    961   TCLSH		= $(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe
   915    962   !if !exist("$(TCLSH)") && $(TCL_THREADS)
   916    963   TCLSH           = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe
   917    964   !endif
................................................................................
   937    984   TCLTOOLSDIR	= $(_TCLDIR)\tools
   938    985   TCL_INCLUDES	= -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
   939    986   
   940    987   !endif # TCLINSTALL
   941    988   
   942    989   tcllibs = "$(TCLSTUBLIB)" "$(TCLIMPLIB)"
   943    990   
   944         -!endif $(PROJECT) != "tcl"
          991  +!endif # $(DOING_TCL)
   945    992   
   946    993   # We need a tclsh that will run on the host machine as part of the build.
   947    994   # IX86 runs on all architectures.
   948    995   !ifndef TCLSH_NATIVE
   949    996   !if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
   950    997   TCLSH_NATIVE	= $(TCLSH)
   951    998   !else
   952    999   !error You must explicitly set TCLSH_NATIVE for cross-compilation
   953   1000   !endif
   954   1001   !endif
   955   1002   
   956   1003   # Do the same for Tk and Tk extensions that require the Tk libraries
   957         -!if "$(PROJECT)" == "tk" || defined(PROJECT_REQUIRES_TK)
         1004  +!if $(DOING_TK) || $(PROJECT_REQUIRES_TK)
   958   1005   WISHNAMEPREFIX = wish
   959   1006   WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe
   960   1007   TKLIBNAME	= $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT)
   961   1008   TKSTUBLIBNAME	= tkstub$(TK_VERSION).lib
   962   1009   TKIMPLIBNAME	= tk$(TK_VERSION)$(SUFX).lib
   963   1010   
   964         -!if "$(PROJECT)" == "tk"
         1011  +!if $(DOING_TK)
   965   1012   WISH 		= $(OUT_DIR)\$(WISHNAME)
   966   1013   TKSTUBLIB	= $(OUT_DIR)\$(TKSTUBLIBNAME)
   967   1014   TKIMPLIB	= $(OUT_DIR)\$(TKIMPLIBNAME)
   968   1015   TKLIB		= $(OUT_DIR)\$(TKLIBNAME)
   969   1016   TK_INCLUDES    = -I"$(WINDIR)" -I"$(GENERICDIR)"
   970   1017   
   971   1018   !else # effectively PROJECT_REQUIRES_TK
................................................................................
   978   1025   !else # Building against Tk sources
   979   1026   WISH		= $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME)
   980   1027   TKSTUBLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME)
   981   1028   TKIMPLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
   982   1029   TK_INCLUDES     = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
   983   1030   !endif # TKINSTALL
   984   1031   
   985         -!endif # $(PROJECT) == tk
   986         -!endif # $(PROJECT) == tk || PROJECT_REQUIRES_TK
         1032  +!endif # $(DOING_TK)
         1033  +!endif # $(DOING_TK) || $(PROJECT_REQUIRES_TK)
         1034  +
         1035  +# Various output paths
         1036  +PRJIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
         1037  +PRJLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
         1038  +PRJLIB		= $(OUT_DIR)\$(PRJLIBNAME)
         1039  +
         1040  +PRJSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
         1041  +PRJSTUBLIB	= $(OUT_DIR)\$(PRJSTUBLIBNAME)
         1042  +
         1043  +# If extension parent makefile has not defined a resource definition file,
         1044  +# we will generate one from standard template.
         1045  +!if !$(DOING_TCL) && !$(DOING_TK) && !$(STATIC_BUILD)
         1046  +!ifdef RCFILE
         1047  +RESFILE = $(RCFILE:.rc=.res)
         1048  +!else
         1049  +RESFILE = $(TMP_DIR)\$(PROJECT).res
         1050  +!endif
         1051  +!endif
   987   1052   
   988   1053   ###################################################################
   989   1054   # 11. Construct the paths for the installation directories
   990   1055   # The following macros get defined in this section:
   991   1056   # LIB_INSTALL_DIR - where libraries should be installed
   992   1057   # BIN_INSTALL_DIR - where the executables should be installed
   993   1058   # DOC_INSTALL_DIR - where documentation should be installed
   994   1059   # SCRIPT_INSTALL_DIR - where scripts should be installed
   995   1060   # INCLUDE_INSTALL_DIR - where C include files should be installed
   996   1061   # DEMO_INSTALL_DIR - where demos should be installed
   997   1062   # PRJ_INSTALL_DIR - where package will be installed (not set for tcl and tk)
   998   1063   
   999         -!if "$(PROJECT)" == "tcl" || "$(PROJECT)" == "tk"
         1064  +!if $(DOING_TCL) || $(DOING_TK)
  1000   1065   LIB_INSTALL_DIR		= $(_INSTALLDIR)\lib
  1001   1066   BIN_INSTALL_DIR		= $(_INSTALLDIR)\bin
  1002   1067   DOC_INSTALL_DIR		= $(_INSTALLDIR)\doc
  1003         -!if "$(PROJECT)" == "tcl"
         1068  +!if $(DOING_TCL)
  1004   1069   SCRIPT_INSTALL_DIR	= $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
  1005         -!else
         1070  +!else # DOING_TK
  1006   1071   SCRIPT_INSTALL_DIR	= $(_INSTALLDIR)\lib\$(PROJECT)$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
  1007   1072   !endif
  1008   1073   DEMO_INSTALL_DIR	= $(SCRIPT_INSTALL_DIR)\demos
  1009   1074   INCLUDE_INSTALL_DIR	= $(_INSTALLDIR)\include
  1010   1075   
  1011         -!else
         1076  +!else # extension other than Tk
  1012   1077   
  1013   1078   PRJ_INSTALL_DIR         = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
  1014   1079   LIB_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
  1015   1080   BIN_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
  1016   1081   DOC_INSTALL_DIR		= $(PRJ_INSTALL_DIR)
  1017   1082   SCRIPT_INSTALL_DIR	= $(PRJ_INSTALL_DIR)
  1018   1083   DEMO_INSTALL_DIR	= $(PRJ_INSTALL_DIR)\demos
................................................................................
  1061   1126   !if $(TCL_NO_DEPRECATED)
  1062   1127   OPTDEFINES	= $(OPTDEFINES) -DTCL_NO_DEPRECATED
  1063   1128   !endif
  1064   1129   
  1065   1130   !if $(USE_STUBS)
  1066   1131   # Note we do not define USE_TCL_STUBS even when building tk since some
  1067   1132   # test targets in tk do not use stubs
  1068         -!if "$(PROJECT)" != "tcl"
         1133  +!if ! $(DOING_TCL)
  1069   1134   USE_STUBS_DEFS  = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS
  1070         -!ifdef PROJECT_REQUIRES_TK
         1135  +!if $(PROJECT_REQUIRES_TK)
  1071   1136   USE_STUBS_DEFS  = $(USE_STUBS_DEFS) -DUSE_TK_STUBS
  1072   1137   !endif
  1073   1138   !endif
  1074   1139   !endif # USE_STUBS
  1075   1140   
  1076   1141   !if !$(DEBUG)
  1077   1142   OPTDEFINES	= $(OPTDEFINES) -DNDEBUG
................................................................................
  1088   1153   !if $(VCVERSION) < 1300
  1089   1154   OPTDEFINES	= $(OPTDEFINES) -DNO_STRTOI64
  1090   1155   !endif
  1091   1156   
  1092   1157   # _ATL_XP_TARGETING - Newer SDK's need this to build for XP
  1093   1158   COMPILERFLAGS  = /D_ATL_XP_TARGETING
  1094   1159   
  1095         -
  1096   1160   # Following is primarily for the benefit of extensions. Tcl 8.5 builds
  1097   1161   # Tcl without /DUNICODE, while 8.6 builds with it defined. When building
  1098   1162   # an extension, it is advisable (but not mandated) to use the same Windows
  1099   1163   # API as the Tcl build. This is accordingly defaulted below. A particular
  1100   1164   # extension can override this by pre-definining USE_WIDECHAR_API.
  1101   1165   !ifndef USE_WIDECHAR_API
  1102   1166   !if $(TCL_VERSION) > 85
................................................................................
  1105   1169   USE_WIDECHAR_API = 0
  1106   1170   !endif
  1107   1171   !endif
  1108   1172   
  1109   1173   !if $(USE_WIDECHAR_API)
  1110   1174   COMPILERFLAGS = $(COMPILERFLAGS) /DUNICODE /D_UNICODE 
  1111   1175   !endif
         1176  +
         1177  +# Like the TEA system only set this non empty for non-Tk extensions
         1178  +!if !$(DOING_TCL) && !$(DOING_TK)
         1179  +PKGNAMEFLAGS = -DPACKAGE_NAME="\"$(PROJECT)\"" \
         1180  +               -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
         1181  +               -DMODULE_SCOPE=extern 
         1182  +!endif
  1112   1183   
  1113   1184   # crt picks the C run time based on selected OPTS
  1114   1185   !if $(MSVCRT)
  1115   1186   !if $(DEBUG) && !$(UNCHECKED)
  1116   1187   crt = -MDd
  1117   1188   !else
  1118   1189   crt = -MD
................................................................................
  1168   1239   # object files (e.g. tclsh, or wish) pkgcflags contains $(cflags) plus
  1169   1240   # flags used for building shared object files The two differ in the
  1170   1241   # BUILD_$(PROJECT) macro which should be defined only for the shared
  1171   1242   # library *implementation* and not for its caller interface
  1172   1243   
  1173   1244   appcflags = $(cflags) $(crt) $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) $(USE_STUBS_DEFS)
  1174   1245   appcflags_nostubs = $(cflags) $(crt) $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES)
  1175         -pkgcflags = $(appcflags) -DBUILD_$(PROJECT)
  1176         -pkgcflags_nostubs = $(appcflags_nostubs) -DBUILD_$(PROJECT)
         1246  +pkgcflags = $(appcflags) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
         1247  +pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
  1177   1248   
  1178   1249   # stubscflags contains $(cflags) plus flags used for building a stubs
  1179   1250   # library for the package.  Note: -DSTATIC_BUILD is defined in
  1180   1251   # $(OPTDEFINES) only if the OPTS configuration indicates a static
  1181   1252   # library. However the stubs library is ALWAYS static hence included
  1182   1253   # here irrespective of the OPTS setting.
  1183   1254   
................................................................................
  1255   1326   !else
  1256   1327   MAKEBINCMD = $(MAKEDLLCMD)
  1257   1328   !endif
  1258   1329   MAKECONCMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs)
  1259   1330   MAKEGUICMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs)
  1260   1331   MAKERESCMD  = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \
  1261   1332   	    $(TCL_INCLUDES) \
  1262         -	    -d DEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
  1263         -	    -d TCL_THREADS=$(TCL_THREADS) \
  1264         -	    -d STATIC_BUILD=$(STATIC_BUILD) \
  1265         -	    $<
  1266         -
  1267         -!ifndef DISABLE_DEFAULT_TARGETS
         1333  +	    -DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
         1334  +	    -DCOMMAVERSION=$(DOTVERSION:.=,),0 \
         1335  +	    -DDOTVERSION=\"$(DOTVERSION)\" \
         1336  +	    -DVERSION=\"$(VERSION)\" \
         1337  +	    -DSUFX=\"$(SUFX)\" \
         1338  +            -DPROJECT=\"$(PROJECT)\" \
         1339  +            -DPRJLIBNAME=\"$(PRJLIBNAME)\" 
  1268   1340   
  1269   1341   !ifndef DEFAULT_BUILD_TARGET
  1270         -DEFAULT_BUILD_TARGET = all
         1342  +DEFAULT_BUILD_TARGET = $(PROJECT)
  1271   1343   !endif
  1272   1344   
  1273         -default_target: $(DEFAULT_BUILD_TARGET)
         1345  +default-target: $(DEFAULT_BUILD_TARGET)
  1274   1346   
  1275         -setup:
  1276         -	@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
  1277         -	@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
         1347  +default-pkgindex:
         1348  +	@echo package ifneeded $(PROJECT) $(DOTVERSION) \
         1349  +	    [list load [file join $$dir $(PRJLIBNAME)]] >> $(OUT_DIR)\pkgIndex.tcl
  1278   1350   
  1279         -clean:
         1351  +default-pkgindex-tea:
         1352  +	@if exist $(ROOT)\pkgIndex.tcl.in nmakehlp -s << $(ROOT)\pkgIndex.tcl.in > $(OUT_DIR)\pkgIndex.tcl
         1353  +@PACKAGE_VERSION@    $(DOTVERSION)
         1354  +@PACKAGE_NAME@       $(PROJECT)
         1355  +@PKG_LIB_FILE@       $(PRJLIBNAME)
         1356  +<<
         1357  +
         1358  +
         1359  +default-install: default-install-binaries default-install-libraries
         1360  +
         1361  +default-install-binaries: $(PRJLIB)
         1362  +	@echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
         1363  +	@if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
         1364  +	@$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
         1365  +
         1366  +default-install-libraries: $(OUT_DIR)\pkgIndex.tcl
         1367  +	@echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
         1368  +	@if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
         1369  +	@echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
         1370  +	@$(CPY) $(OUT_DIR)\pkgIndex.tcl $(SCRIPT_INSTALL_DIR)
         1371  +
         1372  +default-clean:
  1280   1373   	@echo Cleaning $(TMP_DIR)\* ...
  1281   1374   	@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
  1282   1375   	@echo Cleaning $(WINDIR)\nmakehlp.obj, nmakehlp.exe ...
  1283   1376   	@if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj
  1284   1377   	@if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
  1285   1378   	@echo Cleaning $(WINDIR)\_junk.pch ...
  1286   1379   	@if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch
................................................................................
  1287   1380   	@echo Cleaning $(WINDIR)\vercl.x, vercl.i ...
  1288   1381   	@if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
  1289   1382   	@if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
  1290   1383   	@echo Cleaning $(WINDIR)\versions.vc, version.vc ...
  1291   1384   	@if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc
  1292   1385   	@if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc
  1293   1386   
  1294         -realclean: hose
  1295         -
  1296         -hose:
         1387  +default-hose:
  1297   1388   	@echo Hosing $(OUT_DIR)\* ...
  1298   1389   	@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
  1299   1390   
  1300         -!endif
         1391  +default-distclean: default-hose
         1392  +	@if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
         1393  +	@if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj
         1394  +
         1395  +default-setup:
         1396  +	@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
         1397  +	@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
         1398  +
         1399  +!ifndef RCFILE
         1400  +# If parent makefile has not defined a resource definition file,
         1401  +# we will generate one from standard template.
         1402  +$(TMP_DIR)\$(PROJECT).res: $(TMP_DIR)\$(PROJECT).rc
         1403  +
         1404  +$(TMP_DIR)\$(PROJECT).rc:
         1405  +	@$(COPY) << $(TMP_DIR)\$(PROJECT).rc
         1406  +#include <winver.h>
         1407  +
         1408  +VS_VERSION_INFO VERSIONINFO
         1409  + FILEVERSION	COMMAVERSION
         1410  + PRODUCTVERSION	COMMAVERSION
         1411  + FILEFLAGSMASK	0x3fL
         1412  +#ifdef DEBUG
         1413  + FILEFLAGS	VS_FF_DEBUG
         1414  +#else
         1415  + FILEFLAGS	0x0L
         1416  +#endif
         1417  + FILEOS		VOS_NT_WINDOWS32
         1418  + FILETYPE	VFT_DLL
         1419  + FILESUBTYPE	0x0L
         1420  +BEGIN
         1421  +    BLOCK "StringFileInfo"
         1422  +    BEGIN
         1423  +        BLOCK "040904b0"
         1424  +        BEGIN
         1425  +            VALUE "FileDescription",  "Tcl extension " PROJECT
         1426  +            VALUE "OriginalFilename", PRJLIBNAME
         1427  +            VALUE "FileVersion",      DOTVERSION
         1428  +            VALUE "ProductName",      "Package " PROJECT " for Tcl"
         1429  +            VALUE "ProductVersion",   DOTVERSION 
         1430  +        END
         1431  +    END
         1432  +    BLOCK "VarFileInfo"
         1433  +    BEGIN
         1434  +        VALUE "Translation", 0x409, 1200
         1435  +    END
         1436  +END
         1437  +
         1438  +<<
         1439  +
         1440  +!endif # ifndef RCFILE
  1301   1441   
  1302   1442   !ifndef DISABLE_IMPLICIT_RULES
         1443  +DISABLE_IMPLICIT_RULES = 0
         1444  +!endif
         1445  +
         1446  +!if !$(DISABLE_IMPLICIT_RULES)
  1303   1447   # Implicit rule definitions - only for building library objects. For stubs and
  1304   1448   # main application, the master makefile should define explicit rules.
  1305   1449   
  1306   1450   {$(WINDIR)}.c{$(TMP_DIR)}.obj::
  1307   1451   	$(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<<
  1308   1452   $<
  1309   1453   <<
................................................................................
  1315   1459   
  1316   1460   {$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
  1317   1461   	$(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<<
  1318   1462   $<
  1319   1463   <<
  1320   1464   
  1321   1465   {$(RCDIR)}.rc{$(TMP_DIR)}.res:
  1322         -	$(MAKERESCMD)
         1466  +	$(MAKERESCMD) $<
  1323   1467   
  1324   1468   {$(WINDIR)}.rc{$(TMP_DIR)}.res:
  1325         -	$(MAKERESCMD)
         1469  +	$(MAKERESCMD) $<
         1470  +
         1471  +{$(TMP_DIR)}.rc{$(TMP_DIR)}.res:
         1472  +	$(MAKERESCMD) $<
  1326   1473   
  1327   1474   .SUFFIXES:
  1328   1475   .SUFFIXES:.c .rc
  1329   1476   
  1330   1477   !endif
  1331   1478   
  1332   1479   ################################################################
  1333   1480   # 14. Sanity check selected options against Tcl build options
  1334   1481   # When building an extension, certain configuration options should
  1335   1482   # match the ones used when Tcl was built. Here we check and
  1336   1483   # warn on a mismatch.
  1337         -!if "$(PROJECT)" != "tcl"
         1484  +!if ! $(DOING_TCL)
  1338   1485   
  1339   1486   !if $(TCLINSTALL) # Building against an installed Tcl
  1340   1487   !if exist("$(_TCLDIR)\lib\nmake\tcl.nmake")
  1341   1488   TCLNMAKECONFIG = "$(_TCLDIR)\lib\nmake\tcl.nmake"
  1342   1489   !endif
  1343   1490   !else # ! $(TCLINSTALL) - building against Tcl source
  1344   1491   !if exist("$(OUT_DIR)\tcl.nmake")
................................................................................
  1359   1506   !if defined(CORE_DEBUG) && $(CORE_DEBUG) != $(DEBUG)
  1360   1507   !message WARNING: Value of DEBUG ($(DEBUG)) does not match its Tcl library configuration ($(DEBUG)).
  1361   1508   !endif
  1362   1509   !endif
  1363   1510   
  1364   1511   !endif # TCLNMAKECONFIG
  1365   1512   
  1366         -!endif # $(PROJECT) ==  "tcl"
         1513  +!endif # ! $(DOING_TCL)
  1367   1514   
  1368   1515   
  1369   1516   #----------------------------------------------------------
  1370   1517   # Display stats being used.
  1371   1518   #----------------------------------------------------------
  1372   1519   
  1373   1520   !message *** Intermediate directory will be '$(TMP_DIR)'