summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2007-10-12 14:14:53 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2007-10-12 14:14:53 (GMT)
commitc2d66a489db4404a14f95e330f3a3cbdd5309053 (patch)
treebfdf06a29c93308f871ba376c1939872baa0a594
parent18f54d77cde108f63f96c93cee5b8171d9d9fc1f (diff)
downloadtk-c2d66a489db4404a14f95e330f3a3cbdd5309053.zip
tk-c2d66a489db4404a14f95e330f3a3cbdd5309053.tar.gz
tk-c2d66a489db4404a14f95e330f3a3cbdd5309053.tar.bz2
Mine all version information from headers. Sync tcl and tk and bring
extension versions closer together. Try and avoid using tclsh to do substitutions as we may cross compile.
-rw-r--r--ChangeLog5
-rw-r--r--win/makefile.vc113
-rw-r--r--win/nmakehlp.c154
-rw-r--r--win/rules.vc230
4 files changed, 377 insertions, 125 deletions
diff --git a/ChangeLog b/ChangeLog
index e7b68cb..1692572 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2007-10-12 Pat Thoyts <patthoyts@users.sourceforge.net>
+ * win/makefile.vc: Mine all version information from headers.
+ * win/rules.vc: Sync tcl and tk and bring extension versions
+ * win/nmakehlp.c: closer together. Try and avoid using tclsh
+ to do substitutions as we may cross compile.
+
* library/console.tcl: Use TkFixedFont and ttk widgets
2007-10-12 Daniel Steffen <das@users.sourceforge.net>
diff --git a/win/makefile.vc b/win/makefile.vc
index e413fd5..adfcc13 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -12,7 +12,7 @@
# Copyright (c) 2001-2004 David Gravereaux.
#
#------------------------------------------------------------------------------
-# RCS: @(#) $Id: makefile.vc,v 1.107 2007/09/18 16:12:19 dgp Exp $
+# RCS: @(#) $Id: makefile.vc,v 1.108 2007/10/12 14:14:54 patthoyts Exp $
#------------------------------------------------------------------------------
# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
@@ -184,19 +184,26 @@ PROJECT = tk
!message *** Tcl sources.
!endif
-STUBPREFIX = $(PROJECT)stub
-!if [nmakehlp -g ../generic/tk.h TK_VERSION] == 85
-DOTVERSION = 8.5
-!elseif [nmakehlp -g ../generic/tk.h TK_VERSION] == 86
-DOTVERSION = 8.6
-!elseif [nmakehlp -g ../generic/tk.h TK_VERSION] == 90
-DOTVERSION = 9.0
-!elseif [nmakehlp -g ../generic/tk.h TK_VERSION] == 0
-MSG =^
-Cannot get version string from ../generic/tk.h
-!error $(MSG)
+# Extra makefile options processing...
+!if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"]
+HAVE_UXTHEME = 1
+TTK_SQUARE_WIDGET = 0
+!else
+!if [nmakehlp -f $(OPTS) "noxp"]
+!message *** Exclude support for XP theme
+HAVE_UXTHEME_H = 0
+!else
+HAVE_UXTHEME_H = 1
!endif
-VERSION = $(DOTVERSION:.=)
+!if [nmakehlp -f "$(OPTS)" "square"]
+!message *** Include ttk square demo widget
+TTK_SQUARE_WIDGET = 1
+!else
+TTK_SQUARE_WIDGET = 0
+!endif
+!endif
+
+STUBPREFIX = $(PROJECT)stub
WISHNAMEPREFIX = wish
BINROOT = .
@@ -204,15 +211,15 @@ ROOT = ..
TK_LIBRARY = $(ROOT)\library
-TKIMPLIB = "$(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib"
-TKLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
+TKIMPLIB = "$(OUT_DIR)\$(PROJECT)$(TK_VERSION)$(SUFX).lib"
+TKLIBNAME = $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT)
TKLIB = "$(OUT_DIR)\$(TKLIBNAME)"
-TKSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
+TKSTUBLIBNAME = $(STUBPREFIX)$(TK_VERSION).lib
TKSTUBLIB = "$(OUT_DIR)\$(TKSTUBLIBNAME)"
-WISH = "$(OUT_DIR)\$(WISHNAMEPREFIX)$(VERSION)$(SUFX).exe"
-WISHC = "$(OUT_DIR)\$(WISHNAMEPREFIX)c$(VERSION)$(SUFX).exe"
+WISH = "$(OUT_DIR)\$(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe"
+WISHC = "$(OUT_DIR)\$(WISHNAMEPREFIX)c$(TK_VERSION)$(SUFX).exe"
TKTEST = "$(OUT_DIR)\$(PROJECT)test.exe"
CAT32 = "$(OUT_DIR)\cat32.exe"
@@ -220,7 +227,7 @@ CAT32 = "$(OUT_DIR)\cat32.exe"
LIB_INSTALL_DIR = $(_INSTALLDIR)\lib
BIN_INSTALL_DIR = $(_INSTALLDIR)\bin
DOC_INSTALL_DIR = $(_INSTALLDIR)\doc
-SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(DOTVERSION)
+SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TK_DOTVERSION)
INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\include
WISHOBJS = \
@@ -416,13 +423,12 @@ CONFIG_DEFS =-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 \
!if $(HAVE_UXTHEME_H)
-DHAVE_UXTHEME_H=1 \
!endif
-!if [nmakehlp -f "$(OPTS)" "square"]
+!if $(TTK_SQUARE_WIDGET)
-DTTK_SQUARE_WIDGET=1 \
!endif
TK_DEFINES =-DBUILD_ttk $(OPTDEFINES) $(CONFIG_DEFS)
-
#---------------------------------------------------------------------
# Compile flags
#---------------------------------------------------------------------
@@ -435,23 +441,17 @@ cdebug = $(OPTIMIZATIONS)
!else
cdebug =
!endif
-!else if "$(MACHINE)" == "IA64"
+!else if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
### Warnings are too many, can't support warnings into errors.
-cdebug = -Z7 -Od $(DEBUGFLAGS)
+cdebug = -Zi -Od $(DEBUGFLAGS)
!else
-cdebug = -Z7 -WX $(DEBUGFLAGS)
+cdebug = -Zi -WX $(DEBUGFLAGS)
!endif
### Declarations common to all compiler options
-cwarn = -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE
+cwarn = $(WARNINGS) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE
cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\
-!if $(FULLWARNINGS)
-cflags = $(cflags) -W4
-!else
-cflags = $(cflags) -W3
-!endif
-
!if $(MSVCRT)
!if $(DEBUG) && !$(UNCHECKED)
crt = -MDd
@@ -486,10 +486,6 @@ ldebug = -release -opt:ref -opt:icf,3
### Declarations common to all linker options
lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug)
-!if $(FULLWARNINGS)
-lflags = $(lflags) -warn:3
-!endif
-
!if $(PROFILE)
lflags = $(lflags) -profile
!endif
@@ -680,7 +676,7 @@ $(TKOBJS)
# Regenerate the windows help files.
#---------------------------------------------------------------------
-HLPBASE = $(PROJECT)$(VERSION)
+HLPBASE = $(PROJECT)$(TK_VERSION)
HELPFILE = $(OUT_DIR)\$(HLPBASE).hlp
HELPCNT = $(OUT_DIR)\$(HLPBASE).cnt
DOCTMP_DIR = $(OUT_DIR)\$(PROJECT)_docs
@@ -737,7 +733,7 @@ $(MAN2TCL): $(TCLTOOLSDIR)\$$(@B).c
$(_VC_MANIFEST_EMBED_EXE)
$(HELPRTF): $(MAN2TCL) $(MAN2HELP) $(MAN2HELP2) $(INDEX)
- $(TCLSH) $(MAN2HELP) -bitmap $(BMP_NOPATH) $(PROJECT) $(VERSION) $(DOCDIR:\=/)
+ $(TCLSH) $(MAN2HELP) -bitmap $(BMP_NOPATH) $(PROJECT) $(TK_VERSION) $(DOCDIR:\=/)
install-docs:
!if exist($(HELPFILE))
@@ -745,25 +741,25 @@ install-docs:
$(CPY) "$(HELPCNT)" "$(DOC_INSTALL_DIR)\"
$(TCLSH) <<
puts "Installing $(PROJECT)'s helpfile contents into Tcl's ..."
-set f [open "$(DOC_INSTALL_DIR:\=/)/tcl$(VERSION).cnt" r]
+set f [open "$(DOC_INSTALL_DIR:\=/)/tcl$(TK_VERSION).cnt" r]
while {![eof $$f]} {
if {[regexp {:Include $(PROJECT)([0-9]{2}).cnt} [gets $$f] dummy ver]} {
- if {$$ver == $(VERSION)} {
+ if {$$ver == $(TK_VERSION)} {
puts "Already installed."
exit
} else {
# do something here logical to remove (or replace) it.
- puts "$$ver != $(VERSION), unfinished code path, die, die!"
+ puts "$$ver != $(TK_VERSION), unfinished code path, die, die!"
exit 1
}
}
}
close $$f
-set f [open "$(DOC_INSTALL_DIR:\=/)/tcl$(VERSION).cnt" a]
+set f [open "$(DOC_INSTALL_DIR:\=/)/tcl$(TK_VERSION).cnt" a]
puts $$f {:Include $(HLPBASE).cnt}
close $$f
<<
- start /wait winhlp32 -g $(DOC_INSTALL_DIR)\tcl$(VERSION).hlp
+ start /wait winhlp32 -g $(DOC_INSTALL_DIR)\tcl$(TK_VERSION).hlp
!endif
#---------------------------------------------------------------------
@@ -805,27 +801,10 @@ $(TMP_DIR)\tkStubLib.obj : $(GENERICDIR)\tkStubLib.c
#---------------------------------------------------------------------
$(TMP_DIR)\wish.exe.manifest: $(WINDIR)\wish.exe.manifest.in
-!if ![sed "1d" < NUL > NUL]
- sed -f << $** > $@
-s/@MACHINE@/$(MACHINE:IX86=X86)/
-s/@TK_WIN_VERSION@/$(DOTVERSION).0.0/
+ @nmakehlp -s << $** >$@
+@MACHINE@ $(MACHINE:IX86=X86)
+@TK_WIN_VERSION@ $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION).0.0
<<
-!else
- $(TCLSH) <<
-set f [open {$(WINDIR:\=/)/wish.exe.manifest.in} r]
-set data [read $$f]
-close $$f
-set mach {$(MACHINE)}
-if {[regexp -nocase {$(IX86)$$} $mach ]} {set mach X86}
-set winver "$(DOTVERSION).0.0"
-set data [string map [list @MACHINE@ $$mach @TK_WIN_VERSION@ $$winver] $$data]
-puts {Creating $(TMP_DIR:\=/)/wish.exe.manifest}
-set f [open {$(TMP_DIR:\=/)/wish.exe.manifest} w]
-puts -nonewline $$f $$data
-close $$f
-exit
-<<
-!endif
$(TMP_DIR)\tk.res: \
$(RCDIR)\buttons.bmp \
@@ -963,8 +942,8 @@ install-binaries:
!if !$(STATIC_BUILD)
@echo creating package index
@type << > $(OUT_DIR)\pkgIndex.tcl
-if {[catch {package present Tcl $(TCL_DOTVERSION)$(TCL_PATCHLEVEL)}]} { return }
-package ifneeded Tk $(DOTVERSION)$(TCL_PATCHLEVEL) [list load [file join $$dir .. .. bin $(TKLIBNAME)] Tk]
+if {[package vcompare [package provide Tcl] $(TCL_PATCH_LEVEL)] != 0} { return }
+package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin $(TKLIBNAME)] Tk]
<<
@$(CPY) $(OUT_DIR)\pkgIndex.tcl "$(SCRIPT_INSTALL_DIR)\"
!endif
@@ -1019,6 +998,12 @@ clean:
@if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
@echo Cleaning $(WINDIR)\_junk.pch ...
@if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch
+ @echo Cleaning $(WINDIR)\vercl.x ...
+ @if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
+ @echo Cleaning $(WINDIR)\vercl.i ...
+ @if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
+ @echo Cleaning $(WINDIR)\versions.vc ...
+ @if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc
hose:
@echo Hosing $(OUT_DIR)\* ...
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index 21191a5..f0168ac 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -11,7 +11,7 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* ----------------------------------------------------------------------------
- * RCS: @(#) $Id: nmakehlp.c,v 1.8 2007/05/04 18:20:45 patthoyts Exp $
+ * RCS: @(#) $Id: nmakehlp.c,v 1.9 2007/10/12 14:14:54 patthoyts Exp $
* ----------------------------------------------------------------------------
*/
@@ -38,6 +38,7 @@ 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);
+int SubstituteFile(const char *substs, const char *filename);
const char * GetVersionFromFile(const char *filename, const char *match);
DWORD WINAPI ReadFromPipe(LPVOID args);
@@ -133,6 +134,18 @@ main(
return 2;
}
return GrepForDefine(argv[2], argv[3]);
+ case 's':
+ if (argc == 2) {
+ chars = snprintf(msg, sizeof(msg) - 1,
+ "usage: %s -s <substitutions file> <file>\n"
+ "Perform a set of string map type substutitions on a file\n"
+ "exitcodes: 0\n",
+ argv[0]);
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
+ &dwWritten, NULL);
+ return 2;
+ }
+ return SubstituteFile(argv[2], argv[3]);
case 'V':
if (argc != 4) {
chars = snprintf(msg, sizeof(msg) - 1,
@@ -286,7 +299,9 @@ CheckForCompilerFeature(
return !(strstr(Out.buffer, "D4002") != NULL
|| strstr(Err.buffer, "D4002") != NULL
|| strstr(Out.buffer, "D9002") != NULL
- || strstr(Err.buffer, "D9002") != NULL);
+ || strstr(Err.buffer, "D9002") != NULL
+ || strstr(Out.buffer, "D2021") != NULL
+ || strstr(Err.buffer, "D2021") != NULL);
}
int
@@ -558,6 +573,141 @@ GetVersionFromFile(
}
return szResult;
}
+
+/*
+ * List helpers for the SubstituteFile function
+ */
+
+typedef struct list_item_t {
+ struct list_item_t *nextPtr;
+ char * key;
+ char * value;
+} list_item_t;
+
+/* insert a list item into the list (list may be null) */
+static list_item_t *
+list_insert(list_item_t **listPtrPtr, const char *key, const char *value)
+{
+ list_item_t *itemPtr = malloc(sizeof(list_item_t));
+ if (itemPtr) {
+ itemPtr->key = strdup(key);
+ itemPtr->value = strdup(value);
+ itemPtr->nextPtr = NULL;
+
+ while(*listPtrPtr) {
+ listPtrPtr = &(*listPtrPtr)->nextPtr;
+ }
+ *listPtrPtr = itemPtr;
+ }
+ return itemPtr;
+}
+
+static void
+list_free(list_item_t **listPtrPtr)
+{
+ list_item_t *tmpPtr, *listPtr = *listPtrPtr;
+ while (listPtr) {
+ tmpPtr = listPtr;
+ listPtr = listPtr->nextPtr;
+ free(tmpPtr->key);
+ free(tmpPtr->value);
+ free(tmpPtr);
+ }
+}
+
+/*
+ * SubstituteFile --
+ * As windows doesn't provide anything useful like sed and it's unreliable
+ * to use the tclsh you are building against (consider x-platform builds -
+ * eg compiling AMD64 target from IX86) we provide a simple substitution
+ * option here to handle autoconf style substitutions.
+ * The substitution file is whitespace and line delimited. The file should
+ * consist of lines matching the regular expression:
+ * \s*\S+\s+\S*$
+ *
+ * Usage is something like:
+ * nmakehlp -S << $** > $@
+ * @PACKAGE_NAME@ $(PACKAGE_NAME)
+ * @PACKAGE_VERSION@ $(PACKAGE_VERSION)
+ * <<
+ */
+
+int
+SubstituteFile(
+ const char *substitutions,
+ const char *filename)
+{
+ size_t cbBuffer = 1024;
+ static char szBuffer[1024], szCopy[1024];
+ char *szResult = NULL;
+ list_item_t *substPtr = NULL;
+ FILE *fp, *sp;
+
+ fp = fopen(filename, "rt");
+ if (fp != NULL) {
+
+ /*
+ * Build a list of substutitions from the first filename
+ */
+
+ sp = fopen(substitutions, "rt");
+ if (sp != NULL) {
+ while (fgets(szBuffer, cbBuffer, sp) != NULL) {
+ char *ks, *ke, *vs, *ve;
+ ks = szBuffer;
+ while (ks && *ks && isspace(*ks)) ++ks;
+ ke = ks;
+ while (ke && *ke && !isspace(*ke)) ++ke;
+ vs = ke;
+ while (vs && *vs && isspace(*vs)) ++vs;
+ ve = vs;
+ while (ve && *ve && !(*ve == '\r' || *ve == '\n')) ++ve;
+ *ke = 0, *ve = 0;
+ list_insert(&substPtr, ks, vs);
+ }
+ fclose(sp);
+ }
+
+ /* debug: dump the list */
+#ifdef _DEBUG
+ {
+ int n = 0;
+ list_item_t *p = NULL;
+ for (p = substPtr; p != NULL; p = p->nextPtr, ++n) {
+ fprintf(stderr, "% 3d '%s' => '%s'\n", n, p->key, p->value);
+ }
+ }
+#endif
+
+ /*
+ * Run the substitutions over each line of the input
+ */
+
+ while (fgets(szBuffer, cbBuffer, fp) != NULL) {
+ list_item_t *p = NULL;
+ for (p = substPtr; p != NULL; p = p->nextPtr) {
+ char *m = strstr(szBuffer, p->key);
+ if (m) {
+ char *cp, *op, *sp;
+ cp = szCopy;
+ op = szBuffer;
+ while (op != m) *cp++ = *op++;
+ sp = p->value;
+ while (sp && *sp) *cp++ = *sp++;
+ op += strlen(p->key);
+ while (*op) *cp++ = *op++;
+ *cp = 0;
+ memcpy(szBuffer, szCopy, sizeof(szCopy));
+ }
+ }
+ printf(szBuffer);
+ }
+
+ list_free(&substPtr);
+ }
+ fclose(fp);
+ return 0;
+}
/*
* Local variables:
diff --git a/win/rules.vc b/win/rules.vc
index cc1b278..eeb5f9f 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -8,10 +8,10 @@
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# Copyright (c) 2001-2003 David Gravereaux.
-# Copyright (c) 2003-2006 Patrick Thoyts
+# Copyright (c) 2003-2007 Patrick Thoyts
#
#------------------------------------------------------------------------------
-# RCS: @(#) $Id: rules.vc,v 1.16 2007/08/21 20:35:11 patthoyts Exp $
+# RCS: @(#) $Id: rules.vc,v 1.17 2007/10/12 14:14:54 patthoyts Exp $
#------------------------------------------------------------------------------
!ifndef _RULES_VC
@@ -88,7 +88,7 @@ MKDIR = mkdir
!message *** Compiler has 'Optimizations'
OPTIMIZING = 1
!else
-!message *** Compiler doesn't have 'Optimizations'
+!message *** Compiler does not have 'Optimizations'
OPTIMIZING = 0
!endif
@@ -106,13 +106,19 @@ OPTIMIZATIONS = $(OPTIMIZATIONS) -Oi
OPTIMIZATIONS = $(OPTIMIZATIONS) -Op
!endif
+# Tk doesnt seem to be able to use -fp:strict.
+!if "$(PROJECT)" != "tk"
+!if [nmakehlp -c -fp:strict]
+OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:strict
+!endif
+!else
!if [nmakehlp -c -fp:precise]
OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:precise
!endif
-
!if [nmakehlp -c -fp:except]
OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:except
!endif
+!endif
!if [nmakehlp -c -Gs]
OPTIMIZATIONS = $(OPTIMIZATIONS) -Gs
@@ -149,7 +155,7 @@ OPTIMIZATIONS = $(OPTIMIZATIONS) -YX
!message *** Compiler has 'Pentium 0x0f fix'
COMPILERFLAGS = $(COMPILERFLAGSS) -QI0f
!else
-!message *** Compiler doesn't have 'Pentium 0x0f fix'
+!message *** Compiler does not have 'Pentium 0x0f fix'
!endif
!endif
@@ -169,7 +175,7 @@ COMPILERFLAGS = $(COMPILERFLAGS) -QIA64_Bx
!message *** Linker has 'Win98 alignment problem'
ALIGN98_HACK = 1
!else
-!message *** Linker doesn't have 'Win98 alignment problem'
+!message *** Linker does not have 'Win98 alignment problem'
ALIGN98_HACK = 0
!endif
!else
@@ -218,7 +224,6 @@ LOIMPACT = 0
TCL_USE_STATIC_PACKAGES = 0
USE_THREAD_ALLOC = 0
UNCHECKED = 0
-HAVE_UXTHEME_H = 1
!else
!if [nmakehlp -f $(OPTS) "static"]
!message *** Doing static
@@ -274,12 +279,6 @@ UNCHECKED = 1
!else
UNCHECKED = 0
!endif
-!if [nmakehlp -f $(OPTS) "noxp"]
-!message *** Exclude support for XP theme
-HAVE_UXTHEME_H = 0
-!else
-HAVE_UXTHEME_H = 1
-!endif
!endif
@@ -391,7 +390,7 @@ TCL_COMPILE_DEBUG = 0
!if "$(CHECKS)" == "" || [nmakehlp -f "$(CHECKS)" "none"]
TCL_NO_DEPRECATED = 0
-FULLWARNINGS = 0
+WARNINGS = -W3
!else
!if [nmakehlp -f $(CHECKS) "nodep"]
!message *** Doing nodep check
@@ -401,12 +400,18 @@ TCL_NO_DEPRECATED = 0
!endif
!if [nmakehlp -f $(CHECKS) "fullwarn"]
!message *** Doing full warnings check
-FULLWARNINGS = 1
+WARNINGS = -W4
+!if [nmakehlp -l -warn:3]
+LINKERFLAGS = $(LINKERFLAGS) -warn:3
+!endif
!else
-FULLWARNINGS = 0
+WARNINGS = -W3
+!endif
+!if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64]
+!message *** Doing 64bit portability warnings
+WARNINGS = $(WARNINGS) -Wp64
!endif
!endif
-
#----------------------------------------------------------
# Set our defines now armed with our options.
@@ -447,16 +452,26 @@ OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT
#----------------------------------------------------------
-# Get common info used when building extensions.
+# Locate the Tcl headers to build against
#----------------------------------------------------------
-!if "$(PROJECT)" != "tcl"
+!if "$(PROJECT)" == "tcl"
-!if !defined(TCLDIR)
+_TCL_H = ..\generic\tcl.h
+
+!else
+
+# If INSTALLDIR set to tcl root dir then reset to the lib dir.
!if exist("$(_INSTALLDIR)\include\tcl.h")
-TCLH = "$(_INSTALLDIR)\include\tcl.h"
+_INSTALLDIR=$(_INSTALLDIR)\lib
+!endif
+
+!if !defined(TCLDIR)
+!if exist("$(_INSTALLDIR)\..\include\tcl.h")
TCLINSTALL = 1
-_TCLDIR = $(_INSTALLDIR)
+_TCLDIR = $(_INSTALLDIR)\..
+_TCL_H = $(_INSTALLDIR)\..\include\tcl.h
+TCLDIR = $(_INSTALLDIR)\..
!else
MSG=^
Failed to find tcl.h. Set the TCLDIR macro.
@@ -465,48 +480,64 @@ Failed to find tcl.h. Set the TCLDIR macro.
!else
_TCLDIR = $(TCLDIR:/=\)
!if exist("$(_TCLDIR)\include\tcl.h")
-TCLH = "$(_TCLDIR)\include\tcl.h"
TCLINSTALL = 1
+_TCL_H = $(_TCLDIR)\include\tcl.h
!elseif exist("$(_TCLDIR)\generic\tcl.h")
-TCLH = "$(_TCLDIR)\generic\tcl.h"
TCLINSTALL = 0
+_TCL_H = $(_TCLDIR)\generic\tcl.h
!else
MSG =^
Failed to find tcl.h. The TCLDIR macro does not appear correct.
!error $(MSG)
!endif
!endif
+!endif
-#----------------------------------------------------------
-# Get the version from the header file. Try all possibles
-# even though some aren't fully valid.
-#----------------------------------------------------------
+#--------------------------------------------------------------
+# Extract various version numbers from tcl headers
+# The generated file is then included in the makefile.
+#--------------------------------------------------------------
-!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)
+!if [echo REM = This file is generated from rules.vc > versions.vc]
+!endif
+!if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
+ && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
+!endif
+!if [echo TCL_MINOR_VERSION = \>> versions.vc] \
+ && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
+!endif
+!if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
+ && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
+!endif
+
+# If building the tcl core then we need additional package versions
+!if "$(PROJECT)" == "tcl"
+!if [echo PKG_HTTP_VER = \>> versions.vc] \
+ && [nmakehlp -V ..\library\http\pkgIndex.tcl http >> versions.vc]
+!endif
+!if [echo PKG_TCLTEST_VER = \>> versions.vc] \
+ && [nmakehlp -V ..\library\tcltest\pkgIndex.tcl tcltest >> versions.vc]
+!endif
+!if [echo PKG_MSGCAT_VER = \>> versions.vc] \
+ && [nmakehlp -V ..\library\msgcat\pkgIndex.tcl msgcat >> versions.vc]
+!endif
+!if [echo PKG_PLATFORM_VER = \>> versions.vc] \
+ && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform " >> versions.vc]
+!endif
+!if [echo PKG_SHELL_VER = \>> versions.vc] \
+ && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform::shell" >> versions.vc]
!endif
+!endif
+
+!include versions.vc
+
+#--------------------------------------------------------------
+# Setup tcl version dependent stuff headers
+#--------------------------------------------------------------
+
+!if "$(PROJECT)" != "tcl"
-TCL_VERSION = $(TCL_DOTVERSION:.=)
+TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
!if $(TCL_VERSION) < 81
TCL_DOES_STUBS = 0
@@ -515,16 +546,23 @@ TCL_DOES_STUBS = 1
!endif
!if $(TCLINSTALL)
-TCLSH = "$(_INSTALLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe"
-TCLSTUBLIB = "$(_INSTALLDIR)\lib\tclstub$(TCL_VERSION).lib"
-TCLIMPLIB = "$(_INSTALLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib"
-TCL_LIBRARY = $(_INSTALLDIR)\lib
-TCLREGLIB = "$(_INSTALLDIR)\lib\tclreg11$(SUFX:t=).lib"
-TCLDDELIB = "$(_INSTALLDIR)\lib\tcldde12$(SUFX:t=).lib"
+TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe"
+!if !exist($(TCLSH)) && $(TCL_THREADS)
+TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe"
+!endif
+TCLSTUBLIB = "$(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib"
+TCLIMPLIB = "$(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib"
+TCL_LIBRARY = $(_TCLDIR)\lib
+TCLREGLIB = "$(_TCLDIR)\lib\tclreg11$(SUFX:t=).lib"
+TCLDDELIB = "$(_TCLDIR)\lib\tcldde12$(SUFX:t=).lib"
COFFBASE = \must\have\tcl\sources\to\build\this\target
TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target
+TCL_INCLUDES = -I"$(_TCLDIR)\include"
!else
TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe"
+!if !exist($(TCLSH)) && $(TCL_THREADS)
+TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX).exe"
+!endif
TCLSTUBLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib"
TCLIMPLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib"
TCL_LIBRARY = $(_TCLDIR)\library
@@ -532,10 +570,84 @@ TCLREGLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg11$(SUFX:t=).lib"
TCLDDELIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde12$(SUFX:t=).lib"
COFFBASE = "$(_TCLDIR)\win\coffbase.txt"
TCLTOOLSDIR = $(_TCLDIR)\tools
+TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
+!endif
+
!endif
+#-------------------------------------------------------------------------
+# Locate the Tk headers to build against
+#-------------------------------------------------------------------------
+
+!if "$(PROJECT)" == "tk"
+_TK_H = ..\generic\tk.h
!endif
+!ifdef PROJECT_REQUIRES_TK
+!if !defined(TKDIR)
+!if exist("$(_INSTALLDIR)\..\include\tk.h")
+TKINSTALL = 1
+_TKDIR = $(_INSTALLDIR)\..
+_TK_H = $(_TKDIR)\include\tk.h
+TKDIR = $(_TKDIR)
+!elseif exist("$(_TCLDIR)\include\tk.h")
+TKINSTALL = 1
+_TKDIR = $(_TCLDIR)
+_TK_H = $(_TKDIR)\include\tk.h
+TKDIR = $(_TKDIR)
+!endif
+!else
+_TKDIR = $(TKDIR:/=\)
+!if exist("$(_TKDIR)\include\tk.h")
+TKINSTALL = 1
+_TK_H = $(_TKDIR)\include\tk.h
+!elseif exist("$(_TKDIR)\generic\tk.h")
+TKINSTALL = 0
+_TK_H = $(_TKDIR)\generic\tk.h
+!else
+MSG =^
+Failed to find tk.h. The TKDIR macro does not appear correct.
+!error $(MSG)
+!endif
+!endif
+!endif
+
+#-------------------------------------------------------------------------
+# Extract Tk version numbers
+#-------------------------------------------------------------------------
+
+!if defined(PROJECT_REQUIRES_TK) || "$(PROJECT)" == "tk"
+
+!if [echo TK_MAJOR_VERSION = \>> versions.vc] \
+ && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
+!endif
+!if [echo TK_MINOR_VERSION = \>> versions.vc] \
+ && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
+!endif
+!if [echo TK_PATCH_LEVEL = \>> versions.vc] \
+ && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
+!endif
+
+!include versions.vc
+
+TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
+TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
+
+!if "$(PROJECT)" != "tk"
+!if $(TKINSTALL)
+WISH = "$(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe"
+TKSTUBLIB = "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib"
+TKIMPLIB = "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib"
+TK_INCLUDES = -I"$(_TKDIR)\include"
+!else
+WISH = "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe"
+TKSTUBLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib"
+TKIMPLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib"
+TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
+!endif
+!endif
+
+!endif
#----------------------------------------------------------
# Display stats being used.
@@ -545,8 +657,8 @@ TCLTOOLSDIR = $(_TCLDIR)\tools
!message *** Output directory will be '$(OUT_DIR)'
!message *** Suffix for binaries will be '$(SUFX)'
!message *** Optional defines are '$(OPTDEFINES)'
-!message *** Compiler version $(VCVER)
-!message *** Compiler options '$(OPTIMIZATIONS) $(DEBUGFLAGS)'
+!message *** Compiler version $(VCVER). Target machine is $(MACHINE)
+!message *** Compiler options '$(COMPILERFLAGS) $(OPTIMIZATIONS) $(DEBUGFLAGS) $(WARNINGS)'
!message *** Link options '$(LINKERFLAGS)'
!endif