diff options
author | davygrvy <davygrvy> | 2003-12-23 02:48:29 (GMT) |
---|---|---|
committer | davygrvy <davygrvy> | 2003-12-23 02:48:29 (GMT) |
commit | 0e3a07c07d29699926cef5613c8367a3705be20b (patch) | |
tree | d6c2fb40aebc905f98b8859a128e90f64fe8a9a6 | |
parent | 70c0aa3a264e05b161911b60743a94c175be179d (diff) | |
download | tk-0e3a07c07d29699926cef5613c8367a3705be20b.zip tk-0e3a07c07d29699926cef5613c8367a3705be20b.tar.gz tk-0e3a07c07d29699926cef5613c8367a3705be20b.tar.bz2 |
sync'd to Tcl.
-rw-r--r-- | win/nmakehlp.c | 53 | ||||
-rw-r--r-- | win/rules.vc | 69 |
2 files changed, 108 insertions, 14 deletions
diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 9a27028..6373b08 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -9,17 +9,19 @@ * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * ---------------------------------------------------------------------------- - * RCS: @(#) $Id: nmakehlp.c,v 1.1 2002/03/28 23:23:03 davygrvy Exp $ + * RCS: @(#) $Id: nmakehlp.c,v 1.2 2003/12/23 02:48:29 davygrvy Exp $ * ---------------------------------------------------------------------------- */ #include <windows.h> #pragma comment (lib, "user32.lib") #pragma comment (lib, "kernel32.lib") +#include <stdio.h> /* protos */ int CheckForCompilerFeature (const char *option); int CheckForLinkerFeature (const char *option); int IsIn (const char *string, const char *substring); +int GrepForDefine (const char *file, const char *string); DWORD WINAPI ReadFromPipe (LPVOID args); /* globals */ @@ -74,6 +76,15 @@ main (int argc, char *argv[]) } else { return IsIn(argv[2], argv[3]); } + case 'g': + if (argc == 2) { + chars = wsprintf(msg, "usage: %s -g <file> <string>\n" + "grep for a #define\n" + "exitcodes: integer of the found string (no decimals)\n", argv[0]); + WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL); + return 2; + } + return GrepForDefine(argv[2], argv[3]); } } chars = wsprintf(msg, "usage: %s -c|-l|-f ...\n" @@ -295,3 +306,43 @@ IsIn (const char *string, const char *substring) { return (strstr(string, substring) != NULL); } + +/* + * Find a specified #define by name. + * + * If the line is '#define TCL_VERSION "8.5"', it returns + * 85 as the result. + */ + +int +GrepForDefine (const char *file, const char *string) +{ + FILE *f; + char s1[50], s2[50], s3[50]; + int r = 0; + double d1; + + f = fopen(file, "rt"); + if (f == NULL) { + return 0; + } + + do { + r = fscanf(f, "%s", s1); + if (r == 1 && !strcmp(s1, "#define")) { + /* get next two words */ + r = fscanf(f, "%s %s", s2, s3); + if (r != 2) continue; + /* is the first word what we're looking for? */ + if (!strcmp(s2, string)) { + fclose(f); + /* add 1 past double quote char. "8.5" */ + d1 = atof(s3 + 1); /* 8.5 */ + return ((int) (d1 * 10) & 0xFF); /* 85 */ + } + } + } while (!feof(f)); + + fclose(f); + return 0; +} diff --git a/win/rules.vc b/win/rules.vc index 305bc42..aef7371 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -7,10 +7,10 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# Copyright (c) 2001-2002 David Gravereaux. +# Copyright (c) 2001-2003 David Gravereaux. # #------------------------------------------------------------------------------ -# RCS: @(#) $Id: rules.vc,v 1.7 2003/03/23 02:17:44 kennykb Exp $ +# RCS: @(#) $Id: rules.vc,v 1.8 2003/12/23 02:48:29 davygrvy Exp $ #------------------------------------------------------------------------------ !ifndef _RULES_VC @@ -33,6 +33,9 @@ _INSTALLDIR = $(INSTALLDIR:/=\) MACHINE = IX86 !endif +!ifndef CFG_ENCODING +CFG_ENCODING = \"cp1252\" +!endif #---------------------------------------------------------- # Set the proper copy method to avoid overwrite questions @@ -266,9 +269,10 @@ TCL_COMPILE_DEBUG = 0 # Set our defines now armed with our options. #---------------------------------------------------------- -OPTDEFINES = +OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) + !if $(TCL_MEM_DEBUG) -OPTDEFINES = -DTCL_MEM_DEBUG +OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG !endif !if $(TCL_COMPILE_DEBUG) OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS @@ -283,6 +287,18 @@ OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1 OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD !endif +!if $(DEBUG) +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DEBUG +!elseif $(OPTIMIZING) +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED +!endif +!if $(PROFILE) +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED +!endif +!if "$(MACHINE)" == "IA64" +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT +!endif + #---------------------------------------------------------- # Get common info used when building extensions. @@ -292,6 +308,7 @@ OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD !if !defined(TCLDIR) !if exist("$(_INSTALLDIR)\include\tcl.h") +TCLH = "$(_INSTALLDIR)\include\tcl.h" TCLINSTALL = 1 _TCLDIR = $(_INSTALLDIR) !else @@ -302,8 +319,10 @@ Don't know where tcl.h is. Set the TCLDIR macro. !else _TCLDIR = $(TCLDIR:/=\) !if exist("$(_TCLDIR)\include\tcl.h") +TCLH = "$(_TCLDIR)\include\tcl.h" TCLINSTALL = 1 !elseif exist("$(_TCLDIR)\generic\tcl.h") +TCLH = "$(_TCLDIR)\generic\tcl.h" TCLINSTALL = 0 !else MSG =^ @@ -312,19 +331,43 @@ Don't know where tcl.h is. The TCLDIR macro doesn't appear correct. !endif !endif -### TODO: add a command to nmakehlp.c to grep for Tcl's version from tcl.h. -### Because nmake can't return a string, we'll need to play games with return -### codes. It might look something like this: -#!if [nmakehlp -g $(TCL.H)] == 81 -#TCL_DOTVERSION = 8.1 -#!elseif [nmakehlp -g $(TCL.H)] == 82 -#TCL_DOTVERSION = 8.2 -#... -#!endif +#---------------------------------------------------------- +# Get the version from the header file. Try all possibles +# even though some aren't fully valid. +#---------------------------------------------------------- +!if [nmakehlp -g $(TCLH) TCL_VERSION] == 76 +TCL_DOTVERSION = 7.6 +!elseif [nmakehlp -g $(TCLH) TCL_VERSION] == 80 +TCL_DOTVERSION = 8.0 +!elseif [nmakehlp -g $(TCLH) TCL_VERSION] == 81 +TCL_DOTVERSION = 8.1 +!elseif [nmakehlp -g $(TCLH) TCL_VERSION] == 82 +TCL_DOTVERSION = 8.2 +!elseif [nmakehlp -g $(TCLH) TCL_VERSION] == 83 +TCL_DOTVERSION = 8.3 +!elseif [nmakehlp -g $(TCLH) TCL_VERSION] == 84 +TCL_DOTVERSION = 8.4 +!elseif [nmakehlp -g $(TCLH) TCL_VERSION] == 85 TCL_DOTVERSION = 8.5 +!elseif [nmakehlp -g $(TCLH) TCL_VERSION] == 86 +TCL_DOTVERSION = 8.6 +!elseif [nmakehlp -g $(TCLH) TCL_VERSION] == 90 +TCL_DOTVERSION = 9.0 +!elseif [nmakehlp -g $(TCLH) TCL_VERSION] == 0 +MSG =^ +Can't get version string from $(TCLH) +!error $(MSG) +!endif + TCL_VERSION = $(TCL_DOTVERSION:.=) +!if $(TCL_VERSION) < 81 +TCL_DOES_STUBS = 0 +!else +TCL_DOES_STUBS = 1 +!endif + !if $(TCLINSTALL) TCLSH = "$(_INSTALLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe" TCLSTUBLIB = "$(_INSTALLDIR)\lib\tclstub$(TCL_VERSION).lib" |