Check-in [fe79338a36]
Bounty program for improvements to Tcl and certain Tcl packages.
Overview
Comment: * win/makefile.vc: Added the MSVC build system (from the Tcl * win/rules.vc: sampleextension). * win/nmakehlp.c: * win/tls.rc Added Windows resource file. * tls.tcl: From patch #948155, added support for alternate socket commands. * tls.c: Quieten some MSVC warnings. Prefer ckalloc over Tcl_Alloc. (David Graveraux).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fe79338a36de2b2b953a427cf5c4b4110ae4191e
User & Date: patthoyts on 2004-12-17 16:01:43
Other Links: manifest | tags
Context
2004-12-23
01:26
Incremented minor version to 1.5.1 check-in: fa0664ed31 user: patthoyts tags: trunk
2004-12-17
16:01
* win/makefile.vc: Added the MSVC build system (from the Tcl * win/rules.vc: sampleextension). * win/nmakehlp.c: * win/tls.rc Added Windows resource file. * tls.tcl: From patch #948155, added support for alternate socket commands. * tls.c: Quieten some MSVC warnings. Prefer ckalloc over Tcl_Alloc. (David Graveraux). check-in: fe79338a36 user: patthoyts tags: trunk
2004-06-29
11:07
* tls.c: Fixup to build against tcl 8.3.3. Handle * tlsIO.c: 8.4 constification. check-in: 9633ce0e5c user: patthoyts tags: trunk
Changes

Modified ChangeLog from [fec6460738] to [22aa1345a6].

            1  +2004-12-17  Pat Thoyts  <[email protected]>
            2  +
            3  +	* win/makefile.vc:  Added the MSVC build system (from the Tcl
            4  +	* win/rules.vc:     sampleextension).
            5  +	* win/nmakehlp.c:
            6  +	* win/tls.rc        Added Windows resource file.
            7  +	
            8  +	* tls.tcl:          From patch #948155, added support for
            9  +	                    alternate socket commands.
           10  +	* tls.c:            Quieten some MSVC warnings. Prefer ckalloc
           11  +	                    over Tcl_Alloc. (David Graveraux).
           12  +
     1     13   2004-06-29  Pat Thoyts  <[email protected]>
     2     14   
     3     15   	* tls.c:            Fixup to build against tcl 8.3.3. Handle
     4     16   	* tlsIO.c:          8.4 constification.
     5     17   
     6     18   	* tlsInt.h:         Added headers required with MSVC on Win32.
     7     19   	* tlsX509.c:        undef min and max if defined (win32).

Modified tls.c from [823c68fcb0] to [c3a95bcf2f].

     1      1   /*
     2      2    * Copyright (C) 1997-1999 Matt Newman <[email protected]>
     3      3    * some modifications:
     4      4    *	Copyright (C) 2000 Ajuba Solutions
     5      5    *	Copyright (C) 2002 ActiveState Corporation
     6      6    *	Copyright (C) 2004 Starfish Systems 
     7      7    *
     8         - * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.c,v 1.23 2004/06/29 11:07:08 patthoyts Exp $
            8  + * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.c,v 1.24 2004/12/17 16:01:44 patthoyts Exp $
     9      9    *
    10     10    * TLS (aka SSL) Channel - can be layered on any bi-directional
    11     11    * Tcl_Channel (Note: Requires Trf Core Patch)
    12     12    *
    13     13    * This was built (almost) from scratch based upon observation of
    14     14    * OpenSSL 0.9.2B
    15     15    *
................................................................................
    35     35    * Forward declarations
    36     36    */
    37     37   
    38     38   #define F2N( key, dsp) \
    39     39   	(((key) == NULL) ? (char *) NULL : \
    40     40   		Tcl_TranslateFileName(interp, (key), (dsp)))
    41     41   #define REASON()	ERR_reason_error_string(ERR_get_error())
           42  +
           43  +static void	InfoCallback _ANSI_ARGS_ ((CONST SSL *ssl, int where, int ret));
    42     44   
    43     45   static int	CiphersObjCmd _ANSI_ARGS_ ((ClientData clientData,
    44     46   			Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
    45     47   
    46     48   static int	HandshakeObjCmd _ANSI_ARGS_ ((ClientData clientData,
    47     49   			Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
    48     50   
................................................................................
   112    114    */
   113    115   
   114    116   #ifdef BSAFE
   115    117   #define PRE_OPENSSL_0_9_4 1
   116    118   #endif
   117    119   
   118    120   /*
   119         - * Per OpenSSL 0.9.4 Compat
          121  + * Pre OpenSSL 0.9.4 Compat
   120    122    */
   121    123   
   122    124   #ifndef STACK_OF
   123    125   #define STACK_OF(x)			STACK
   124    126   #define sk_SSL_CIPHER_num(sk)		sk_num((sk))
   125    127   #define sk_SSL_CIPHER_value( sk, index)	(SSL_CIPHER*)sk_value((sk), (index))
   126    128   #endif
................................................................................
   137    139    *	None
   138    140    *
   139    141    * Side effects:
   140    142    *	Calls callback (if defined)
   141    143    *-------------------------------------------------------------------
   142    144    */
   143    145   static void
   144         -InfoCallback(SSL *ssl, int where, int ret)
          146  +InfoCallback(CONST SSL *ssl, int where, int ret)
   145    147   {
   146         -    State *statePtr = (State*)SSL_get_app_data(ssl);
          148  +    State *statePtr = (State*)SSL_get_app_data((SSL *)ssl);
   147    149       Tcl_Obj *cmdPtr;
   148    150       char *major; char *minor;
   149    151   
   150    152       if (statePtr->callback == (Tcl_Obj*)NULL)
   151    153   	return;
   152    154   
   153    155       cmdPtr = Tcl_DuplicateObj(statePtr->callback);
................................................................................
   732    734       if (cert && !*cert)		cert	= NULL;
   733    735       if (key && !*key)		key	= NULL;
   734    736       if (ciphers && !*ciphers)	ciphers	= NULL;
   735    737       if (CAfile && !*CAfile)	CAfile	= NULL;
   736    738       if (CAdir && !*CAdir)	CAdir	= NULL;
   737    739   
   738    740       /* new SSL state */
   739         -    statePtr		= (State *) Tcl_Alloc((unsigned) sizeof(State));
          741  +    statePtr		= (State *) ckalloc((unsigned) sizeof(State));
   740    742       statePtr->self	= (Tcl_Channel)NULL;
   741    743       statePtr->timer	= (Tcl_TimerToken)NULL;
   742    744   
   743    745       statePtr->flags	= flags;
   744    746       statePtr->watchMask	= 0;
   745    747       statePtr->mode	= 0;
   746    748   
................................................................................
   849    851        * SSL Callbacks
   850    852        */
   851    853   
   852    854       SSL_set_app_data(statePtr->ssl, (VOID *)statePtr);	/* point back to us */
   853    855   
   854    856       SSL_set_verify(statePtr->ssl, verify, VerifyCallback);
   855    857   
   856         -    SSL_CTX_set_info_callback(statePtr->ctx, (void (*)())InfoCallback);
          858  +    SSL_CTX_set_info_callback(statePtr->ctx, InfoCallback);
   857    859   
   858    860       /* Create Tcl_Channel BIO Handler */
   859    861       statePtr->p_bio	= BIO_new_tcl(statePtr, BIO_CLOSE);
   860    862       statePtr->bio	= BIO_new(BIO_f_ssl());
   861    863   
   862    864       if (server) {
   863    865   	statePtr->flags |= TLS_TCL_SERVER;
................................................................................
  1328   1330    */
  1329   1331   void
  1330   1332   Tls_Free( char *blockPtr )
  1331   1333   {
  1332   1334       State *statePtr = (State *)blockPtr;
  1333   1335   
  1334   1336       Tls_Clean(statePtr);
  1335         -    Tcl_Free(blockPtr);
         1337  +    ckfree(blockPtr);
  1336   1338   }
  1337   1339   
  1338   1340   /*
  1339   1341    *-------------------------------------------------------------------
  1340   1342    *
  1341   1343    * Tls_Clean --
  1342   1344    *

Modified tls.tcl from [cf05a5fb78] to [e85b1d9a97].

     1      1   #
     2      2   # Copyright (C) 1997-2000 Matt Newman <[email protected]> 
     3      3   #
     4         -# $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.tcl,v 1.6 2004/02/11 22:36:31 razzell Exp $
            4  +# $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.tcl,v 1.7 2004/12/17 16:02:03 patthoyts Exp $
     5      5   #
     6      6   namespace eval tls {
     7      7       variable logcmd tclLog
     8      8       variable debug 0
     9      9    
    10     10       # Default flags passed to tls::import
    11     11       variable defaults {}
    12     12   
    13     13       # Maps UID to Server Socket
    14     14       variable srvmap
    15     15       variable srvuid 0
           16  +
           17  +    # Over-ride this if you are using a different socket command
           18  +    variable socketCmd
           19  +    if {![info exists socketCmd]} {
           20  +        set socketCmd [info command ::socket]
           21  +    }
    16     22   }
    17     23   #
    18     24   # Backwards compatibility, also used to set the default
    19     25   # context options
    20     26   #
    21     27   proc tls::init {args} {
    22     28       variable defaults
................................................................................
    23     29   
    24     30       set defaults $args
    25     31   }
    26     32   #
    27     33   # Helper function - behaves exactly as the native socket command.
    28     34   #
    29     35   proc tls::socket {args} {
           36  +    variable socketCmd
    30     37       set idx [lsearch $args -server]
    31     38       if {$idx != -1} {
    32     39   	set server 1
    33     40   	set callback [lindex $args [expr {$idx+1}]]
    34     41   	set args [lreplace $args $idx [expr {$idx+1}]]
    35     42   
    36     43   	set usage "wrong # args: should be \"tls::socket -server command ?options? port\""
................................................................................
    85     92   	set host [lindex $args [expr {$argc-2}]]
    86     93   	set port [lindex $args [expr {$argc-1}]]
    87     94   	lappend sopts $host $port
    88     95       }
    89     96       #
    90     97       # Create TCP/IP socket
    91     98       #
    92         -    set chan [eval ::socket $sopts]
           99  +    set chan [eval $socketCmd $sopts]
    93    100       if {!$server && [catch {
    94    101   	#
    95    102   	# Push SSL layer onto socket
    96    103   	#
    97    104   	eval [list tls::import] $chan $iopts
    98    105       } err]} {
    99    106   	set info ${::errorInfo}

Added win/makefile.vc version [ded96baf4e].

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

Added win/nmakehlp.c version [5a07dd3536].

            1  +/* ----------------------------------------------------------------------------
            2  + * nmakehlp.c --
            3  + *
            4  + *	This is used to fix limitations within nmake and the environment.
            5  + *
            6  + * Copyright (c) 2002 by David Gravereaux.
            7  + * Copyright (c) 2003 by Patrick Thoyts
            8  + *
            9  + * See the file "license.terms" for information on usage and redistribution
           10  + * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
           11  + *
           12  + * ----------------------------------------------------------------------------
           13  + * RCS: @(#) $Id: nmakehlp.c,v 1.1 2004/12/17 16:02:06 patthoyts Exp $
           14  + * ----------------------------------------------------------------------------
           15  + */
           16  +#include <windows.h>
           17  +#include <stdio.h>
           18  +#pragma comment (lib, "user32.lib")
           19  +#pragma comment (lib, "kernel32.lib")
           20  +
           21  +/* protos */
           22  +int CheckForCompilerFeature (const char *option);
           23  +int CheckForLinkerFeature (const char *option);
           24  +int IsIn (const char *string, const char *substring);
           25  +DWORD WINAPI ReadFromPipe (LPVOID args);
           26  +int GetVersionFromHeader(const char *tclh, const char *tkh);
           27  +
           28  +/* globals */
           29  +typedef struct {
           30  +    HANDLE pipe;
           31  +    char buffer[1000];
           32  +} pipeinfo;
           33  +
           34  +pipeinfo Out = {INVALID_HANDLE_VALUE, '\0'};
           35  +pipeinfo Err = {INVALID_HANDLE_VALUE, '\0'};
           36  +
           37  +
           38  +
           39  +/* exitcodes: 0 == no, 1 == yes, 2 == error */
           40  +int
           41  +main (int argc, char *argv[])
           42  +{
           43  +    char msg[300];
           44  +    DWORD dwWritten;
           45  +    int chars;
           46  +
           47  +    if (argc > 1 && *argv[1] == '-') {
           48  +	switch (*(argv[1]+1)) {
           49  +	case 'c':
           50  +	    if (argc != 3) {
           51  +		chars = wsprintf(msg, "usage: %s -c <compiler option>\n"
           52  +			"Tests for whether cl.exe supports an option\n"
           53  +			"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
           54  +		WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
           55  +		return 2;
           56  +	    }
           57  +	    return CheckForCompilerFeature(argv[2]);
           58  +	case 'l':
           59  +	    if (argc != 3) {
           60  +		chars = wsprintf(msg, "usage: %s -l <linker option>\n"
           61  +			"Tests for whether link.exe supports an option\n"
           62  +			"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
           63  +		WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
           64  +		return 2;
           65  +	    }
           66  +	    return CheckForLinkerFeature(argv[2]);
           67  +	case 'f':
           68  +	    if (argc == 2) {
           69  +		chars = wsprintf(msg, "usage: %s -f <string> <substring>\n"
           70  +		    "Find a substring within another\n"
           71  +		    "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
           72  +		WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
           73  +		return 2;
           74  +	    } else if (argc == 3) {
           75  +		/* if the string is blank, there is no match */
           76  +		return 0;
           77  +	    } else {
           78  +		return IsIn(argv[2], argv[3]);
           79  +	    }
           80  +	case 'v':
           81  +	    if (argc != 4) {
           82  +		chars = wsprintf(msg, "usage: %s -v <tcl.h> <tk.h>\n"
           83  +		    "Search for versions from the tcl and tk headers.",
           84  +		    argv[0]);
           85  +		WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
           86  +		return 0;
           87  +	    }
           88  +	    return GetVersionFromHeader(argv[2], argv[3]);
           89  +	}
           90  +    }
           91  +    chars = wsprintf(msg, "usage: %s -c|-l|-f ...\n"
           92  +	    "This is a little helper app to equalize shell differences between WinNT and\n"
           93  +	    "Win9x and get nmake.exe to accomplish its job.\n",
           94  +	    argv[0]);
           95  +    WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
           96  +    return 2;
           97  +}
           98  +
           99  +int
          100  +CheckForCompilerFeature (const char *option)
          101  +{
          102  +    STARTUPINFO si;
          103  +    PROCESS_INFORMATION pi;
          104  +    SECURITY_ATTRIBUTES sa;
          105  +    DWORD threadID;
          106  +    char msg[300];
          107  +    BOOL ok;
          108  +    HANDLE hProcess, h, pipeThreads[2];
          109  +    char cmdline[100];
          110  +
          111  +    hProcess = GetCurrentProcess();
          112  +
          113  +    ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
          114  +    ZeroMemory(&si, sizeof(STARTUPINFO));
          115  +    si.cb = sizeof(STARTUPINFO);
          116  +    si.dwFlags   = STARTF_USESTDHANDLES;
          117  +    si.hStdInput = INVALID_HANDLE_VALUE;
          118  +
          119  +    ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
          120  +    sa.nLength = sizeof(SECURITY_ATTRIBUTES);
          121  +    sa.lpSecurityDescriptor = NULL;
          122  +    sa.bInheritHandle = FALSE;
          123  +
          124  +    /* create a non-inheritible pipe. */
          125  +    CreatePipe(&Out.pipe, &h, &sa, 0);
          126  +
          127  +    /* dupe the write side, make it inheritible, and close the original. */
          128  +    DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 
          129  +	    0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
          130  +
          131  +    /* Same as above, but for the error side. */
          132  +    CreatePipe(&Err.pipe, &h, &sa, 0);
          133  +    DuplicateHandle(hProcess, h, hProcess, &si.hStdError, 
          134  +	    0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
          135  +
          136  +    /* base command line */
          137  +    strcpy(cmdline, "cl.exe -nologo -c -TC -Fdtemp ");
          138  +    /* append our option for testing */
          139  +    strcat(cmdline, option);
          140  +    /* filename to compile, which exists, but is nothing and empty. */
          141  +    strcat(cmdline, " nul");
          142  +
          143  +    ok = CreateProcess(
          144  +	    NULL,	    /* Module name. */
          145  +	    cmdline,	    /* Command line. */
          146  +	    NULL,	    /* Process handle not inheritable. */
          147  +	    NULL,	    /* Thread handle not inheritable. */
          148  +	    TRUE,	    /* yes, inherit handles. */
          149  +	    DETACHED_PROCESS, /* No console for you. */
          150  +	    NULL,	    /* Use parent's environment block. */
          151  +	    NULL,	    /* Use parent's starting directory. */
          152  +	    &si,	    /* Pointer to STARTUPINFO structure. */
          153  +	    &pi);	    /* Pointer to PROCESS_INFORMATION structure. */
          154  +
          155  +    if (!ok) {
          156  +	DWORD err = GetLastError();
          157  +	int chars = wsprintf(msg, "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
          158  +
          159  +	FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
          160  +		FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID) &msg[chars],
          161  +		(300-chars), 0);
          162  +	WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, strlen(msg), &err, NULL);
          163  +	return 2;
          164  +    }
          165  +
          166  +    /* close our references to the write handles that have now been inherited. */
          167  +    CloseHandle(si.hStdOutput);
          168  +    CloseHandle(si.hStdError);
          169  +
          170  +    WaitForInputIdle(pi.hProcess, 5000);
          171  +    CloseHandle(pi.hThread);
          172  +
          173  +    /* start the pipe reader threads. */
          174  +    pipeThreads[0] = CreateThread(NULL, 0, ReadFromPipe, &Out, 0, &threadID);
          175  +    pipeThreads[1] = CreateThread(NULL, 0, ReadFromPipe, &Err, 0, &threadID);
          176  +
          177  +    /* block waiting for the process to end. */
          178  +    WaitForSingleObject(pi.hProcess, INFINITE);
          179  +    CloseHandle(pi.hProcess);
          180  +
          181  +    /* clean up temporary files before returning */
          182  +    DeleteFile("temp.idb");
          183  +    DeleteFile("temp.pdb");
          184  +
          185  +    /* wait for our pipe to get done reading, should it be a little slow. */
          186  +    WaitForMultipleObjects(2, pipeThreads, TRUE, 500);
          187  +    CloseHandle(pipeThreads[0]);
          188  +    CloseHandle(pipeThreads[1]);
          189  +
          190  +    /* look for the commandline warning code in both streams. */
          191  +    return !(strstr(Out.buffer, "D4002") != NULL || strstr(Err.buffer, "D4002") != NULL);
          192  +}
          193  +
          194  +int
          195  +CheckForLinkerFeature (const char *option)
          196  +{
          197  +    STARTUPINFO si;
          198  +    PROCESS_INFORMATION pi;
          199  +    SECURITY_ATTRIBUTES sa;
          200  +    DWORD threadID;
          201  +    char msg[300];
          202  +    BOOL ok;
          203  +    HANDLE hProcess, h, pipeThreads[2];
          204  +    char cmdline[100];
          205  +
          206  +    hProcess = GetCurrentProcess();
          207  +
          208  +    ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
          209  +    ZeroMemory(&si, sizeof(STARTUPINFO));
          210  +    si.cb = sizeof(STARTUPINFO);
          211  +    si.dwFlags   = STARTF_USESTDHANDLES;
          212  +    si.hStdInput = INVALID_HANDLE_VALUE;
          213  +
          214  +    ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
          215  +    sa.nLength = sizeof(SECURITY_ATTRIBUTES);
          216  +    sa.lpSecurityDescriptor = NULL;
          217  +    sa.bInheritHandle = TRUE;
          218  +
          219  +    /* create a non-inheritible pipe. */
          220  +    CreatePipe(&Out.pipe, &h, &sa, 0);
          221  +
          222  +    /* dupe the write side, make it inheritible, and close the original. */
          223  +    DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 
          224  +	    0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
          225  +
          226  +    /* Same as above, but for the error side. */
          227  +    CreatePipe(&Err.pipe, &h, &sa, 0);
          228  +    DuplicateHandle(hProcess, h, hProcess, &si.hStdError, 
          229  +	    0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
          230  +
          231  +    /* base command line */
          232  +    strcpy(cmdline, "link.exe -nologo ");
          233  +    /* append our option for testing */
          234  +    strcat(cmdline, option);
          235  +    /* filename to compile, which exists, but is nothing and empty. */
          236  +//    strcat(cmdline, " nul");
          237  +
          238  +    ok = CreateProcess(
          239  +	    NULL,	    /* Module name. */
          240  +	    cmdline,	    /* Command line. */
          241  +	    NULL,	    /* Process handle not inheritable. */
          242  +	    NULL,	    /* Thread handle not inheritable. */
          243  +	    TRUE,	    /* yes, inherit handles. */
          244  +	    DETACHED_PROCESS, /* No console for you. */
          245  +	    NULL,	    /* Use parent's environment block. */
          246  +	    NULL,	    /* Use parent's starting directory. */
          247  +	    &si,	    /* Pointer to STARTUPINFO structure. */
          248  +	    &pi);	    /* Pointer to PROCESS_INFORMATION structure. */
          249  +
          250  +    if (!ok) {
          251  +	DWORD err = GetLastError();
          252  +	int chars = wsprintf(msg, "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
          253  +
          254  +	FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
          255  +		FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID) &msg[chars],
          256  +		(300-chars), 0);
          257  +	WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, strlen(msg), &err, NULL);
          258  +	return 2;
          259  +    }
          260  +
          261  +    /* close our references to the write handles that have now been inherited. */
          262  +    CloseHandle(si.hStdOutput);
          263  +    CloseHandle(si.hStdError);
          264  +
          265  +    WaitForInputIdle(pi.hProcess, 5000);
          266  +    CloseHandle(pi.hThread);
          267  +
          268  +    /* start the pipe reader threads. */
          269  +    pipeThreads[0] = CreateThread(NULL, 0, ReadFromPipe, &Out, 0, &threadID);
          270  +    pipeThreads[1] = CreateThread(NULL, 0, ReadFromPipe, &Err, 0, &threadID);
          271  +
          272  +    /* block waiting for the process to end. */
          273  +    WaitForSingleObject(pi.hProcess, INFINITE);
          274  +    CloseHandle(pi.hProcess);
          275  +
          276  +    /* wait for our pipe to get done reading, should it be a little slow. */
          277  +    WaitForMultipleObjects(2, pipeThreads, TRUE, 500);
          278  +    CloseHandle(pipeThreads[0]);
          279  +    CloseHandle(pipeThreads[1]);
          280  +
          281  +    /* look for the commandline warning code in the stderr stream. */
          282  +    return !(strstr(Out.buffer, "LNK1117") != NULL || strstr(Err.buffer, "LNK1117") != NULL);
          283  +}
          284  +
          285  +DWORD WINAPI
          286  +ReadFromPipe (LPVOID args)
          287  +{
          288  +    pipeinfo *pi = (pipeinfo *) args;
          289  +    char *lastBuf = pi->buffer;
          290  +    DWORD dwRead;
          291  +    BOOL ok;
          292  +
          293  +again:
          294  +    ok = ReadFile(pi->pipe, lastBuf, 25, &dwRead, 0L);
          295  +    if (!ok || dwRead == 0) {
          296  +	CloseHandle(pi->pipe);
          297  +	return 0;
          298  +    }
          299  +    lastBuf += dwRead;
          300  +    goto again;
          301  +
          302  +    return 0;  /* makes the compiler happy */
          303  +}
          304  +
          305  +int
          306  +IsIn (const char *string, const char *substring)
          307  +{
          308  +    return (strstr(string, substring) != NULL);
          309  +}
          310  +
          311  +	
          312  +static double
          313  +ReadVersionFromHeader(const char *file, const char *macro)
          314  +{
          315  +    double d = 0.0;
          316  +    CHAR szBuffer[100];
          317  +    LPSTR p;
          318  +    DWORD cbBuffer = 100;
          319  +    FILE *fp = fopen(file, "r");
          320  +    if (fp != NULL) {
          321  +	while (fgets(szBuffer, cbBuffer, fp) != NULL) {
          322  +	    if ((p = strstr(szBuffer, macro)) != NULL) {
          323  +		while (*p && !isdigit(*p)) ++p;
          324  +		d = strtod(p, NULL);
          325  +		break;
          326  +	    }
          327  +	}
          328  +	fclose(fp);
          329  +    }
          330  +    return d;
          331  +}
          332  +
          333  +int
          334  +GetVersionFromHeader(const char *tclh, const char *tkh)
          335  +{
          336  +    double dTcl = 0.0, dTk = 0.0;
          337  +    
          338  +    if (tclh != NULL)
          339  +	dTcl = ReadVersionFromHeader(tclh, "TCL_VERSION");
          340  +    if (tkh != NULL)
          341  +	dTk = ReadVersionFromHeader(tkh, "TK_VERSION");
          342  +
          343  +    if (dTcl > 0 || dTk > 0) {
          344  +	FILE *ofp = fopen("version.vc", "w");
          345  +	if (dTcl > 0)
          346  +	    fprintf(ofp, "TCL_DOTVERSION\t= %0.1f\nTCL_VERSION\t= %u\n",
          347  +		    dTcl, (int)(dTcl * 10.0));
          348  +	if (dTk > 0)
          349  +	    fprintf(ofp, "TK_DOTVERSION\t= %0.1f\nTK_VERSION\t= %u\n",
          350  +		    dTk, (int)(dTk * 10.0));
          351  +	fclose(ofp);
          352  +	return 0;
          353  +    }
          354  +    return 1;
          355  +}

Added win/rules.vc version [f7a656a7f6].

            1  +#------------------------------------------------------------------------------
            2  +# rules.vc --
            3  +#
            4  +#	Microsoft Visual C++ makefile include for decoding the commandline
            5  +#	macros.  This file does not need editing to build Tcl.
            6  +#
            7  +#	This version is modified from the Tcl source version to support
            8  +#	building extensions using nmake.
            9  +#
           10  +# See the file "license.terms" for information on usage and redistribution
           11  +# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
           12  +# 
           13  +# Copyright (c) 2001-2002 David Gravereaux.
           14  +# Copyright (c) 2003 Patrick Thoyts
           15  +#
           16  +#------------------------------------------------------------------------------
           17  +# RCS: @(#) $Id: rules.vc,v 1.1 2004/12/17 16:02:06 patthoyts Exp $
           18  +#------------------------------------------------------------------------------
           19  +
           20  +!ifndef _RULES_VC
           21  +_RULES_VC = 1
           22  +
           23  +cc32		= $(CC)   # built-in default.
           24  +link32		= link
           25  +lib32		= lib
           26  +rc32		= $(RC)   # built-in default.
           27  +
           28  +!ifndef INSTALLDIR
           29  +### Assume the normal default.
           30  +_INSTALLDIR	= C:\Program Files\Tcl
           31  +!else
           32  +### Fix the path separators.
           33  +_INSTALLDIR	= $(INSTALLDIR:/=\)
           34  +!endif
           35  +
           36  +!ifndef MACHINE
           37  +MACHINE		= IX86
           38  +!endif
           39  +
           40  +!ifndef CFG_ENCODING
           41  +CFG_ENCODING	= \"cp1252\"
           42  +!endif
           43  +
           44  +#----------------------------------------------------------
           45  +# Set the proper copy method to avoid overwrite questions
           46  +# to the user when copying files and selecting the right
           47  +# "delete all" method.
           48  +#----------------------------------------------------------
           49  +
           50  +!if "$(OS)" == "Windows_NT"
           51  +RMDIR	= rmdir /S /Q
           52  +!if ![ver | find "4.0" > nul]
           53  +CPY	= echo y | xcopy /i
           54  +!else
           55  +CPY	= xcopy /i /y
           56  +!endif
           57  +!else
           58  +CPY	= xcopy /i
           59  +RMDIR	= deltree /Y
           60  +!endif
           61  +
           62  +
           63  +!message ===============================================================================
           64  +
           65  +#----------------------------------------------------------
           66  +# build the helper app we need to overcome nmake's limiting
           67  +# environment.
           68  +#----------------------------------------------------------
           69  +
           70  +!if !exist(nmakehlp.exe)
           71  +!if [$(cc32) -nologo -ML nmakehlp.c -link -subsystem:console > nul]
           72  +!endif
           73  +!endif
           74  +
           75  +#----------------------------------------------------------
           76  +# Test for compiler features
           77  +#----------------------------------------------------------
           78  +
           79  +### test for optimizations
           80  +!if [nmakehlp -c -Otip]
           81  +!message *** Compiler has 'Optimizations'
           82  +OPTIMIZING	= 1
           83  +!else
           84  +!message *** Compiler doesn't have 'Optimizations'
           85  +OPTIMIZING	= 0
           86  +!endif
           87  +
           88  +!if "$(MACHINE)" == "IX86"
           89  +### test for pentium errata
           90  +!if [nmakehlp -c -QI0f]
           91  +!message *** Compiler has 'Pentium 0x0f fix'
           92  +PENT_0F_ERRATA	= 1
           93  +!else
           94  +!message *** Compiler doesn't have 'Pentium 0x0f fix'
           95  +PENT_0F_ERRATA	= 0
           96  +!endif
           97  +### test for -align:4096, when align:512 will do.
           98  +!if [nmakehlp -l -opt:nowin98]
           99  +!message *** Linker has 'Win98 alignment problem'
          100  +ALIGN98_HACK	= 1
          101  +!else
          102  +!message *** Linker doesn't have 'Win98 alignment problem'
          103  +ALIGN98_HACK	= 0
          104  +!endif
          105  +!else
          106  +PENT_0F_ERRATA	= 0
          107  +ALIGN98_HACK	= 0
          108  +!endif
          109  +
          110  +!if "$(MACHINE)" == "IA64"
          111  +### test for Itanium errata
          112  +!if [nmakehlp -c -QIA64_Bx]
          113  +!message *** Compiler has 'B-stepping errata workarounds'
          114  +ITAN_B_ERRATA	= 1
          115  +!else
          116  +!message *** Compiler doesn't have 'B-stepping errata workarounds'
          117  +ITAN_B_ERRATA	= 0
          118  +!endif
          119  +!else
          120  +ITAN_B_ERRATA	= 0
          121  +!endif
          122  +
          123  +#----------------------------------------------------------
          124  +# Decode the options requested.
          125  +#----------------------------------------------------------
          126  +
          127  +!if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"]
          128  +STATIC_BUILD	= 0
          129  +TCL_THREADS	= 0
          130  +DEBUG		= 0
          131  +PROFILE		= 0
          132  +MSVCRT		= 0
          133  +LOIMPACT	= 0
          134  +TCL_USE_STATIC_PACKAGES	= 0
          135  +USE_THREAD_ALLOC = 0
          136  +!else
          137  +!if [nmakehlp -f $(OPTS) "static"]
          138  +!message *** Doing static
          139  +STATIC_BUILD	= 1
          140  +!else
          141  +STATIC_BUILD	= 0
          142  +!endif
          143  +!if [nmakehlp -f $(OPTS) "msvcrt"]
          144  +!message *** Doing msvcrt
          145  +MSVCRT		= 1
          146  +!else
          147  +MSVCRT		= 0
          148  +!endif
          149  +!if [nmakehlp -f $(OPTS) "staticpkg"]
          150  +!message *** Doing staticpkg
          151  +TCL_USE_STATIC_PACKAGES	= 1
          152  +!else
          153  +TCL_USE_STATIC_PACKAGES	= 0
          154  +!endif
          155  +!if [nmakehlp -f $(OPTS) "threads"]
          156  +!message *** Doing threads
          157  +TCL_THREADS	= 1
          158  +!else
          159  +TCL_THREADS	= 0
          160  +!endif
          161  +!if [nmakehlp -f $(OPTS) "symbols"]
          162  +!message *** Doing symbols
          163  +DEBUG		= 1
          164  +!else
          165  +DEBUG		= 0
          166  +!endif
          167  +!if [nmakehlp -f $(OPTS) "profile"]
          168  +!message *** Doing profile
          169  +PROFILE		= 1
          170  +!else
          171  +PROFILE		= 0
          172  +!endif
          173  +!if [nmakehlp -f $(OPTS) "loimpact"]
          174  +!message *** Doing loimpact
          175  +LOIMPACT	= 1
          176  +!else
          177  +LOIMPACT	= 0
          178  +!endif
          179  +!if [nmakehlp -f $(OPTS) "thrdalloc"]
          180  +!message *** Doing thrdalloc
          181  +USE_THREAD_ALLOC = 1
          182  +!else
          183  +USE_THREAD_ALLOC = 0
          184  +!endif
          185  +!endif
          186  +
          187  +
          188  +!if !$(STATIC_BUILD)
          189  +# Make sure we don't build overly fat DLLs.
          190  +MSVCRT		= 1
          191  +# We shouldn't statically put the extensions inside the shell when dynamic.
          192  +TCL_USE_STATIC_PACKAGES = 0
          193  +!endif
          194  +
          195  +
          196  +#----------------------------------------------------------
          197  +# Figure-out how to name our intermediate and output directories.
          198  +# We wouldn't want different builds to use the same .obj files
          199  +# by accident.
          200  +#----------------------------------------------------------
          201  +
          202  +SUFX	    = tsgx
          203  +
          204  +!if $(DEBUG)
          205  +BUILDDIRTOP = Debug
          206  +DBGX	    = g
          207  +!else
          208  +BUILDDIRTOP = Release
          209  +DBGX	    =
          210  +SUFX	    = $(SUFX:g=)
          211  +!endif
          212  +
          213  +TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX
          214  +
          215  +!if !$(STATIC_BUILD)
          216  +TMP_DIRFULL = $(TMP_DIRFULL:Static=)
          217  +SUFX	    = $(SUFX:s=)
          218  +EXT	    = dll
          219  +!if $(MSVCRT)
          220  +TMP_DIRFULL = $(TMP_DIRFULL:X=)
          221  +SUFX	    = $(SUFX:x=)
          222  +!endif
          223  +!else
          224  +TMP_DIRFULL = $(TMP_DIRFULL:Dynamic=)
          225  +EXT	    = lib
          226  +!if !$(MSVCRT)
          227  +TMP_DIRFULL = $(TMP_DIRFULL:X=)
          228  +SUFX	    = $(SUFX:x=)
          229  +!endif
          230  +!endif
          231  +
          232  +!if !$(TCL_THREADS)
          233  +TMP_DIRFULL = $(TMP_DIRFULL:Threaded=)
          234  +SUFX	    = $(SUFX:t=)
          235  +!endif
          236  +
          237  +!ifndef TMP_DIR
          238  +TMP_DIR	    = $(TMP_DIRFULL)
          239  +!ifndef OUT_DIR
          240  +OUT_DIR	    = .\$(BUILDDIRTOP)
          241  +!endif
          242  +!else
          243  +!ifndef OUT_DIR
          244  +OUT_DIR	    = $(TMP_DIR)
          245  +!endif
          246  +!endif
          247  +
          248  +
          249  +#----------------------------------------------------------
          250  +# Decode the statistics requested.
          251  +#----------------------------------------------------------
          252  +
          253  +!if "$(STATS)" == "" || [nmakehlp -f "$(STATS)" "none"]
          254  +TCL_MEM_DEBUG	    = 0
          255  +TCL_COMPILE_DEBUG   = 0
          256  +!else
          257  +!if [nmakehlp -f $(STATS) "memdbg"]
          258  +!message *** Doing memdbg
          259  +TCL_MEM_DEBUG	    = 1
          260  +!else
          261  +TCL_MEM_DEBUG	    = 0
          262  +!endif
          263  +!if [nmakehlp -f $(STATS) "compdbg"]
          264  +!message *** Doing compdbg
          265  +TCL_COMPILE_DEBUG   = 1
          266  +!else
          267  +TCL_COMPILE_DEBUG   = 0
          268  +!endif
          269  +!endif
          270  +
          271  +
          272  +#----------------------------------------------------------
          273  +# Set our defines now armed with our options.
          274  +#----------------------------------------------------------
          275  +
          276  +OPTDEFINES	= -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING)
          277  +
          278  +!if $(TCL_MEM_DEBUG)
          279  +OPTDEFINES	= -DTCL_MEM_DEBUG
          280  +!endif
          281  +!if $(TCL_COMPILE_DEBUG)
          282  +OPTDEFINES	= $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS
          283  +!endif
          284  +!if $(TCL_THREADS)
          285  +OPTDEFINES	= $(OPTDEFINES) -DTCL_THREADS=1
          286  +!if $(USE_THREAD_ALLOC)
          287  +OPTDEFINES	= $(OPTDEFINES) -DUSE_THREAD_ALLOC=1
          288  +!endif
          289  +!endif
          290  +!if $(STATIC_BUILD)
          291  +OPTDEFINES	= $(OPTDEFINES) -DSTATIC_BUILD
          292  +!endif
          293  +
          294  +!if $(DEBUG)
          295  +OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_DEBUG
          296  +!elseif $(OPTIMIZING)
          297  +OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_OPTIMIZED
          298  +!endif
          299  +!if $(PROFILE)
          300  +OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_PROFILED
          301  +!endif
          302  +!if "$(MACHINE)" == "IA64"
          303  +OPTDEFINES	= $(OPTDEFINES) -DTCL_CFG_DO64BIT
          304  +!endif
          305  +
          306  +
          307  +#----------------------------------------------------------
          308  +# Get common info used when building extensions.
          309  +#----------------------------------------------------------
          310  +
          311  +!if "$(PROJECT)" != "tcl"
          312  +
          313  +# If INSTALLDIR set to tcl root dir then reset to the lib dir.
          314  +!if exist("$(_INSTALLDIR)\include\tcl.h")
          315  +_INSTALLDIR=$(_INSTALLDIR)\lib
          316  +!endif
          317  +
          318  +!if !defined(TCLDIR)
          319  +!if exist("$(_INSTALLDIR)\..\include\tcl.h")
          320  +TCLINSTALL	= 1
          321  +_TCLDIR		= $(_INSTALLDIR)\..
          322  +_TCL_H          = $(_INSTALLDIR)\..\include\tcl.h
          323  +TCLDIR          = $(_INSTALLDIR)\..
          324  +!else
          325  +MSG=^
          326  +Failed to find tcl.h.  Set the TCLDIR macro.
          327  +!error $(MSG)
          328  +!endif
          329  +!else
          330  +_TCLDIR	= $(TCLDIR:/=\)
          331  +!if exist("$(_TCLDIR)\include\tcl.h")
          332  +TCLINSTALL	= 1
          333  +_TCL_H          = $(_TCLDIR)\include\tcl.h
          334  +!elseif exist("$(_TCLDIR)\generic\tcl.h")
          335  +TCLINSTALL	= 0
          336  +_TCL_H          = $(_TCLDIR)\generic\tcl.h
          337  +!else
          338  +MSG =^
          339  +Failed to find tcl.h.  The TCLDIR macro does not appear correct.
          340  +!error $(MSG)
          341  +!endif
          342  +!endif
          343  +
          344  +!if [nmakehlp -v $(_TCL_H) ""] == 0
          345  +!include version.vc
          346  +!else
          347  +TCL_DOTVERSION  = 8.5
          348  +TCL_VERSION	= $(TCL_DOTVERSION:.=)
          349  +!endif
          350  +
          351  +!if $(TCLINSTALL)
          352  +TCLSH		= "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe"
          353  +TCLSTUBLIB	= "$(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib"
          354  +TCLIMPLIB	= "$(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib"
          355  +TCL_LIBRARY	= $(_TCLDIR)\lib
          356  +TCL_INCLUDES    = -I"$(_TCLDIR)\include"
          357  +!else
          358  +TCLSH		= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe"
          359  +TCLSTUBLIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib"
          360  +TCLIMPLIB	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib"
          361  +TCL_LIBRARY	= $(_TCLDIR)\library
          362  +TCL_INCLUDES	= -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
          363  +!endif
          364  +
          365  +!endif
          366  +
          367  +#----------------------------------------------------------
          368  +# Get Tk info for building extensions.
          369  +#----------------------------------------------------------
          370  +
          371  +!if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk"
          372  +
          373  +!if !defined(TKDIR)
          374  +!if exist("$(_INSTALLDIR)\..\include\tk.h")
          375  +TKINSTALL      = 1
          376  +_TKDIR         = $(_INSTALLDIR)\..
          377  +_TK_H          = $(_TKDIR)\include\tk.h
          378  +TKDIR          = $(_TKDIR)
          379  +!elseif exist("$(_TCLDIR)\include\tk.h")
          380  +TKINSTALL      = 1
          381  +_TKDIR         = $(_TCLDIR)
          382  +_TK_H          = $(_TKDIR)\include\tk.h
          383  +TKDIR          = $(_TKDIR)
          384  +!else
          385  +MSG =^
          386  +Failed to find tk.h. Set the TKDIR macro.
          387  +!error $(MSG)
          388  +!endif
          389  +!else
          390  +_TKDIR = $(TKDIR:/=\)
          391  +!if exist("$(_TKDIR)\include\tk.h")
          392  +TKINSTALL      = 1
          393  +_TK_H          = $(_TKDIR)\include\tk.h
          394  +!elseif exist("$(_TKDIR)\generic\tk.h")
          395  +TKINSTALL      = 0
          396  +_TK_H          = $(_TKDIR)\generic\tk.h
          397  +!else
          398  +MSG =^
          399  +Failed to find tk.h. The TKDIR macro does not appear correct.
          400  +!error $(MSG)
          401  +!endif
          402  +!endif
          403  +
          404  +!if [nmakehlp -v $(_TCL_H) $(_TK_H)] == 0
          405  +!include version.vc
          406  +!else
          407  +TK_DOTVERSION	= 8.5
          408  +TK_VERSION	= $(TK_DOTVERSION:.=)
          409  +!endif
          410  +
          411  +!if $(TKINSTALL)
          412  +WISH		= "$(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe"
          413  +TKSTUBLIB	= "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib"
          414  +TKIMPLIB	= "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib"
          415  +TK_INCLUDES     = -I"$(_TKDIR)\include"
          416  +!else
          417  +WISH		= "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe"
          418  +TKSTUBLIB	= "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib"
          419  +TKIMPLIB	= "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib"
          420  +TK_INCLUDES     = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
          421  +!endif
          422  +
          423  +!endif
          424  +
          425  +
          426  +
          427  +#----------------------------------------------------------
          428  +# Display stats being used.
          429  +#----------------------------------------------------------
          430  +
          431  +!message *** Intermediate directory will be '$(TMP_DIR)'
          432  +!message *** Output directory will be '$(OUT_DIR)'
          433  +!message *** Suffix for binaries will be '$(SUFX)'
          434  +!message *** Optional defines are '$(OPTDEFINES)'
          435  +
          436  +!endif

Added win/tls.rc version [93d9423ff3].

            1  +// tls.rc - Copyright (C) 2004 Pat Thoyts <[email protected]>
            2  +//
            3  +// Note: the version numbers in here are all provided from the makefile.
            4  +//       No editing required.
            5  +//
            6  +// $Id: tls.rc,v 1.1 2004/12/17 16:02:06 patthoyts Exp $
            7  +
            8  +#include <winver.h>
            9  +
           10  +VS_VERSION_INFO VERSIONINFO
           11  + FILEVERSION	COMMAVERSION
           12  + PRODUCTVERSION	COMMAVERSION
           13  + FILEFLAGSMASK	0x3fL
           14  +#ifdef DEBUG
           15  + FILEFLAGS	VS_FF_DEBUG
           16  +#else
           17  + FILEFLAGS	0x0L
           18  +#endif
           19  + FILEOS		VOS__WINDOWS32
           20  + FILETYPE	VFT_DLL
           21  + FILESUBTYPE	0x0L
           22  +BEGIN
           23  +    BLOCK "StringFileInfo"
           24  +    BEGIN
           25  +        BLOCK "040904b0"   /* LANG_ENGLISH/SUBLANG_ENGLISH_US, Unicode CP */
           26  +        BEGIN
           27  +            VALUE "FileDescription",  "SSL and TLS support for Tcl\0"
           28  +            VALUE "OriginalFilename", "tls" VERSION ".dll\0"
           29  +            VALUE "FileVersion",      DOTVERSION "\0"
           30  +            VALUE "LegalCopyright",   "Copyright \251 1997-1999 Matt Newman, et al.\0"
           31  +            VALUE "ProductName",      "TLS " DOTVERSION " for Windows\0"
           32  +            VALUE "ProductVersion",   DOTVERSION "\0"
           33  +            VALUE "Comments",         "http://sourceforge.net/projects/tls\0"
           34  +        END
           35  +    END
           36  +    BLOCK "VarFileInfo"
           37  +    BEGIN
           38  +        VALUE "Translation", 0x409, 1200
           39  +    END
           40  +END