Tcl Extension Architecture (TEA) Sample Extension

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

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

Overview
Comment:Update to latest rules from Tcl. Use automatic resource file generation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | vc-reform
Files: files | file ages | folders
SHA1: 9132b5cd845425550c8ebcba4c1257363ce2e165
User & Date: ashok 2017-10-16 13:06:36
Context
2017-10-26
15:13
Purged old comments check-in: 21a6aa24b9 user: ashok tags: vc-reform
2017-10-16
13:06
Update to latest rules from Tcl. Use automatic resource file generation. check-in: 9132b5cd84 user: ashok tags: vc-reform
2017-10-08
15:28
Replace sample.rc with default resource template check-in: 46bab6aa51 user: ashok tags: vc-reform
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to win/makefile.vc.

   148    148   
   149    149   # Define the object files and resource file that make up the extension.
   150    150   # Note the resource file does not makes sense if doing a static library build
   151    151   # hence it is under that condition. TMP_DIR is the output directory
   152    152   # defined by rules for object files.
   153    153   PRJ_OBJS = \
   154    154   	$(TMP_DIR)\tclsample.obj \
   155         -	$(TMP_DIR)\sample.obj \
   156         -!if !$(STATIC_BUILD)
   157         -	$(TMP_DIR)\sample.res
   158         -!endif
          155  +	$(TMP_DIR)\sample.obj
   159    156   
   160    157   # Define any additional compiler flags that might be required for the project
   161    158   PRJ_DEFINES = -D_CRT_SECURE_NO_DEPRECATE
   162    159   
   163    160   # Define the standard targets
   164    161   !include "$(_RULESDIR)\targets.vc"
   165    162   
   166         -# We will use the standard resource template instead of writing our own
   167         -$(TMP_DIR)\$(PROJECT).res: default-rc
   168         -
   169    163   # We must define a pkgindex target that will create a pkgIndex.tcl
   170    164   # file in the $(OUT_DIR) directory. We can just redirect to the
   171    165   # default-pkgindex target for our sample extension.
   172    166   pkgindex: default-pkgindex
   173    167   
   174    168   # The default install target only installs binaries and scripts so add
   175    169   # an additional target for our documentation. Note this *adds* a target

Changes to win/rules.vc.

    27     27   DOING_TCL = 0
    28     28   DOING_TK  = 0
    29     29   !if "$(PROJECT)" == "tcl"
    30     30   DOING_TCL = 1
    31     31   !elseif "$(PROJECT)" == "tk"
    32     32   DOING_TK = 1
    33     33   !endif
           34  +
           35  +!ifndef PROJECT_REQUIRES_TK
           36  +PROJECT_REQUIRES_TK = 0
           37  +!endif
    34     38   
    35     39   ################################################################
    36     40   # Nmake is a pretty weak environment in syntax and capabilities
    37     41   # so this file is necessarily verbose. It's broken down into
    38     42   # the following parts.
    39     43   #
    40     44   # 0. Sanity check that compiler environment is set up and initialize
................................................................................
    71     75   
    72     76   !if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR)
    73     77   MSG = ^
    74     78   Visual C++ compiler environment not initialized.
    75     79   !error $(MSG)
    76     80   !endif
    77     81   
    78         -# Defaults for built-in internal settings defined in parent makefile
    79         -!ifndef DISABLE_STANDARD_TARGETS
    80         -DISABLE_STANDARD_TARGETS = 0
    81         -!endif
    82         -!ifndef DISABLE_CLEAN_TARGETS
    83         -DISABLE_CLEAN_TARGETS = 0
    84         -!endif
    85         -
    86     82   ################################################################
    87     83   # 1. Define external programs being used
    88     84   
    89     85   #----------------------------------------------------------
    90     86   # Set the proper copy method to avoid overwrite questions
    91     87   # to the user when copying files and selecting the right
    92     88   # "delete all" method.
................................................................................
   163    159   # WINDIR env var to point to c:\windows!
   164    160   # TBD - This is a potentially dangerous conflict, rename WINDIR to
   165    161   # something else
   166    162   WINDIR		= $(ROOT)\win
   167    163   !ifndef RCDIR
   168    164   RCDIR           = $(WINDIR)\rc
   169    165   !endif
          166  +RCDIR = $(RCDIR:/=\)
   170    167   
   171    168   # The target directory where the built packages and binaries will be installed.
   172    169   # INSTALLDIR is the (optional) path specified by the user.
   173    170   # _INSTALLDIR is INSTALLDIR using the backslash separator syntax
   174    171   !ifdef INSTALLDIR
   175    172   ### Fix the path separators.
   176    173   _INSTALLDIR	= $(INSTALLDIR:/=\)
   177    174   !else
   178    175   ### Assume the normal default.
   179         -_INSTALLDIR	= C:\Program Files\Tcl
          176  +_INSTALLDIR	= $(HOMEDRIVE)\Tcl
   180    177   !endif
   181    178   
   182    179   !if $(DOING_TCL)
   183    180   
   184    181   # BEGIN Case 2(a) - Building Tcl itself
   185    182   
   186    183   # Only need to define _TCL_H
................................................................................
   244    241   !ifndef _TCL_H
   245    242   MSG =^
   246    243   Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and default path does not contain tcl.h.
   247    244   !error $(MSG)
   248    245   !endif
   249    246   
   250    247   # Now do the same to locate Tk headers and libs if project requires Tk
   251         -!ifdef PROJECT_REQUIRES_TK
          248  +!if $(PROJECT_REQUIRES_TK)
   252    249   
   253    250   !ifdef TKDIR
   254    251   
   255    252   _TKDIR = $(TKDIR:/=\)
   256    253   !if exist("$(_TKDIR)\include\tk.h")
   257    254   TKINSTALL      = 1
   258    255   _TK_H          = $(_TKDIR)\include\tk.h
................................................................................
   844    841   
   845    842   !else # Doing a non-Tk extension
   846    843   
   847    844   # If parent makefile has not defined DOTVERSION, try to get it from TEA
   848    845   # first from a configure.in file, and then from configure.ac
   849    846   !ifndef DOTVERSION
   850    847   !if [echo DOTVERSION = \> versions.vc] \
   851         -   || [nmakehlp -V ..\configure.in AC_INIT >> versions.vc]
          848  +   || [nmakehlp -V $(ROOT)\configure.in AC_INIT >> versions.vc]
   852    849   !if [echo DOTVERSION = \> versions.vc] \
   853         -   || [nmakehlp -V ..\configure.ac AC_INIT >> versions.vc]
          850  +   || [nmakehlp -V $(ROOT)\configure.ac AC_INIT >> versions.vc]
   854    851   !error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
   855    852   !endif
   856    853   !endif
   857    854   !include versions.vc
   858    855   !endif # DOTVERSION
   859    856   VERSION         = $(DOTVERSION:.=)
   860    857   
................................................................................
   883    880   # based on BUILDDIRTOP.
   884    881   # STUBPREFIX - name of the stubs library for this project
   885    882   # PRJIMPLIB - output path of the generated project import library
   886    883   # PRJLIBNAME - name of generated project library
   887    884   # PRJLIB     - output path of generated project library
   888    885   # PRJSTUBLIBNAME - name of the generated project stubs library
   889    886   # PRJSTUBLIB - output path of the generated project stubs library
          887  +# RESFILE - output resource file (only if not static build)
   890    888   
   891    889   SUFX	    = tsgx
   892    890   
   893    891   !if $(DEBUG)
   894    892   BUILDDIRTOP = Debug
   895    893   !else
   896    894   BUILDDIRTOP = Release
................................................................................
   999    997   TCLSH_NATIVE	= $(TCLSH)
  1000    998   !else
  1001    999   !error You must explicitly set TCLSH_NATIVE for cross-compilation
  1002   1000   !endif
  1003   1001   !endif
  1004   1002   
  1005   1003   # Do the same for Tk and Tk extensions that require the Tk libraries
  1006         -!if $(DOING_TK) || defined(PROJECT_REQUIRES_TK)
         1004  +!if $(DOING_TK) || $(PROJECT_REQUIRES_TK)
  1007   1005   WISHNAMEPREFIX = wish
  1008   1006   WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe
  1009   1007   TKLIBNAME	= $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT)
  1010   1008   TKSTUBLIBNAME	= tkstub$(TK_VERSION).lib
  1011   1009   TKIMPLIBNAME	= tk$(TK_VERSION)$(SUFX).lib
  1012   1010   
  1013   1011   !if $(DOING_TK)
................................................................................
  1028   1026   WISH		= $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME)
  1029   1027   TKSTUBLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME)
  1030   1028   TKIMPLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
  1031   1029   TK_INCLUDES     = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
  1032   1030   !endif # TKINSTALL
  1033   1031   
  1034   1032   !endif # $(DOING_TK)
  1035         -!endif # $(DOING_TK) || PROJECT_REQUIRES_TK
         1033  +!endif # $(DOING_TK) || $(PROJECT_REQUIRES_TK)
  1036   1034   
  1037   1035   # Various output paths
  1038   1036   PRJIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
  1039   1037   PRJLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
  1040   1038   PRJLIB		= $(OUT_DIR)\$(PRJLIBNAME)
  1041   1039   
  1042   1040   PRJSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
  1043   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
  1044   1052   
  1045   1053   ###################################################################
  1046   1054   # 11. Construct the paths for the installation directories
  1047   1055   # The following macros get defined in this section:
  1048   1056   # LIB_INSTALL_DIR - where libraries should be installed
  1049   1057   # BIN_INSTALL_DIR - where the executables should be installed
  1050   1058   # DOC_INSTALL_DIR - where documentation should be installed
................................................................................
  1120   1128   !endif
  1121   1129   
  1122   1130   !if $(USE_STUBS)
  1123   1131   # Note we do not define USE_TCL_STUBS even when building tk since some
  1124   1132   # test targets in tk do not use stubs
  1125   1133   !if ! $(DOING_TCL)
  1126   1134   USE_STUBS_DEFS  = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS
  1127         -!ifdef PROJECT_REQUIRES_TK
         1135  +!if $(PROJECT_REQUIRES_TK)
  1128   1136   USE_STUBS_DEFS  = $(USE_STUBS_DEFS) -DUSE_TK_STUBS
  1129   1137   !endif
  1130   1138   !endif
  1131   1139   !endif # USE_STUBS
  1132   1140   
  1133   1141   !if !$(DEBUG)
  1134   1142   OPTDEFINES	= $(OPTDEFINES) -DNDEBUG
................................................................................
  1324   1332   	    $(TCL_INCLUDES) \
  1325   1333   	    -DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
  1326   1334   	    -DCOMMAVERSION=$(DOTVERSION:.=,),0 \
  1327   1335   	    -DDOTVERSION=\"$(DOTVERSION)\" \
  1328   1336   	    -DVERSION=\"$(VERSION)\" \
  1329   1337   	    -DSUFX=\"$(SUFX)\" \
  1330   1338               -DPROJECT=\"$(PROJECT)\" \
  1331         -            -DPRJLIBNAME=\"$(PRJLIBNAME)\" \
  1332         -	    $<
  1333         -
         1339  +            -DPRJLIBNAME=\"$(PRJLIBNAME)\" 
  1334   1340   
  1335   1341   !ifndef DEFAULT_BUILD_TARGET
  1336   1342   DEFAULT_BUILD_TARGET = $(PROJECT)
  1337   1343   !endif
  1338   1344   
  1339   1345   default-target: $(DEFAULT_BUILD_TARGET)
  1340   1346   
................................................................................
  1386   1392   	@if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
  1387   1393   	@if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj
  1388   1394   
  1389   1395   default-setup:
  1390   1396   	@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
  1391   1397   	@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
  1392   1398   
  1393         -default-rc:
         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:
  1394   1405   	@$(COPY) << $(TMP_DIR)\$(PROJECT).rc
  1395   1406   #include <winver.h>
  1396   1407   
  1397   1408   VS_VERSION_INFO VERSIONINFO
  1398   1409    FILEVERSION	COMMAVERSION
  1399   1410    PRODUCTVERSION	COMMAVERSION
  1400   1411    FILEFLAGSMASK	0x3fL
................................................................................
  1422   1433       BEGIN
  1423   1434           VALUE "Translation", 0x409, 1200
  1424   1435       END
  1425   1436   END
  1426   1437   
  1427   1438   <<
  1428   1439   
         1440  +!endif # ifndef RCFILE
  1429   1441   
  1430   1442   !ifndef DISABLE_IMPLICIT_RULES
         1443  +DISABLE_IMPLICIT_RULES = 0
         1444  +!endif
         1445  +
         1446  +!if !$(DISABLE_IMPLICIT_RULES)
  1431   1447   # Implicit rule definitions - only for building library objects. For stubs and
  1432   1448   # main application, the master makefile should define explicit rules.
  1433   1449   
  1434   1450   {$(WINDIR)}.c{$(TMP_DIR)}.obj::
  1435   1451   	$(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<<
  1436   1452   $<
  1437   1453   <<
................................................................................
  1443   1459   
  1444   1460   {$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
  1445   1461   	$(cc32) $(pkgcflags) -Fo$(TMP_DIR)\ @<<
  1446   1462   $<
  1447   1463   <<
  1448   1464   
  1449   1465   {$(RCDIR)}.rc{$(TMP_DIR)}.res:
  1450         -	$(MAKERESCMD)
         1466  +	$(MAKERESCMD) $<
  1451   1467   
  1452   1468   {$(WINDIR)}.rc{$(TMP_DIR)}.res:
  1453         -	$(MAKERESCMD)
         1469  +	$(MAKERESCMD) $<
  1454   1470   
  1455   1471   {$(TMP_DIR)}.rc{$(TMP_DIR)}.res:
  1456         -	$(MAKERESCMD)
         1472  +	$(MAKERESCMD) $<
  1457   1473   
  1458   1474   .SUFFIXES:
  1459   1475   .SUFFIXES:.c .rc
  1460   1476   
  1461   1477   !endif
  1462   1478   
  1463   1479   ################################################################

Changes to win/targets.vc.

     2      2   
     3      3   $(PROJECT): setup pkgindex $(PRJLIB)
     4      4   
     5      5   !if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk"
     6      6   # MAKEBINCMD will do shared, static and debug links as appropriate
     7      7   # _VC_MANIFEST_EMBED_DLL embeds the manifest for shared libraries
     8      8   # and is a no-op for static libraries
     9         -$(PRJLIB): $(PRJ_OBJS)
            9  +$(PRJLIB): $(PRJ_OBJS) $(RESFILE)
    10     10          $(MAKEBINCMD) $**
    11     11          $(_VC_MANIFEST_EMBED_DLL)
    12     12          [email protected] $*.exp
    13     13   !endif
    14     14   
    15     15   setup: default-setup
    16     16   install: default-install
    17     17   clean: default-clean
    18     18   realclean: hose
    19     19   hose: default-hose
    20     20   distclean: realclean default-distclean
    21     21