From 88de4c824e53243f5015876e241c4bcc32de14a3 Mon Sep 17 00:00:00 2001
From: "jan.nijtmans" <nijtmans@users.sourceforge.net>
Date: Fri, 6 Apr 2012 22:04:03 +0000
Subject: some more cygwin compatibility improvements

---
 ChangeLog          |  0
 doc/canvas.n       |  0
 generic/default.h  |  0
 generic/tkColor.c  |  0
 generic/tkMenu.c   |  4 ++--
 generic/tkMenu.h   |  2 +-
 tests/color.test   |  0
 unix/tcl.m4        |  0
 unix/tkUnixColor.c |  0
 win/tcl.m4         | 20 ++++++++++++--------
 win/tkWinDraw.c    | 11 ++++++-----
 win/tkWinInt.h     |  4 ++--
 xlib/rgb.txt       |  0
 xlib/xcolors.c     |  2 +-
 14 files changed, 24 insertions(+), 19 deletions(-)
 mode change 100644 => 100755 ChangeLog
 mode change 100644 => 100755 doc/canvas.n
 mode change 100644 => 100755 generic/default.h
 mode change 100644 => 100755 generic/tkColor.c
 mode change 100644 => 100755 generic/tkMenu.c
 mode change 100644 => 100755 tests/color.test
 mode change 100644 => 100755 unix/tcl.m4
 mode change 100644 => 100755 unix/tkUnixColor.c
 mode change 100644 => 100755 win/tcl.m4
 mode change 100644 => 100755 win/tkWinDraw.c
 mode change 100644 => 100755 win/tkWinInt.h
 mode change 100644 => 100755 xlib/rgb.txt
 mode change 100644 => 100755 xlib/xcolors.c

diff --git a/ChangeLog b/ChangeLog
old mode 100644
new mode 100755
diff --git a/doc/canvas.n b/doc/canvas.n
old mode 100644
new mode 100755
diff --git a/generic/default.h b/generic/default.h
old mode 100644
new mode 100755
diff --git a/generic/tkColor.c b/generic/tkColor.c
old mode 100644
new mode 100755
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
old mode 100644
new mode 100755
index c996df8..19031c5
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -101,7 +101,7 @@ TCL_DECLARE_MUTEX(menuMutex)
  * to update code in TkpMenuInit that changes the font string entry.
  */
 
-char *tkMenuStateStrings[] = {"active", "normal", "disabled", (char *) NULL};
+CONST char *tkMenuStateStrings[] = {"active", "normal", "disabled", (char *) NULL};
 
 static CONST char *menuEntryTypeStrings[] = {
     "cascade", "checkbutton", "command", "radiobutton", "separator",
@@ -113,7 +113,7 @@ static CONST char *menuEntryTypeStrings[] = {
  * It is used with the "enum compound" declaration in tkMenu.h
  */
 
-static char *compoundStrings[] = {
+static const char *compoundStrings[] = {
     "bottom", "center", "left", "none", "right", "top", (char *) NULL
 };
 
diff --git a/generic/tkMenu.h b/generic/tkMenu.h
index 767e3fc..a428d4c 100644
--- a/generic/tkMenu.h
+++ b/generic/tkMenu.h
@@ -238,7 +238,7 @@ typedef struct TkMenuEntry {
  * Menu states
  */
 
-EXTERN char *tkMenuStateStrings[];
+EXTERN CONST char *tkMenuStateStrings[];
 
 #define ENTRY_ACTIVE 0
 #define ENTRY_NORMAL 1
diff --git a/tests/color.test b/tests/color.test
old mode 100644
new mode 100755
diff --git a/unix/tcl.m4 b/unix/tcl.m4
old mode 100644
new mode 100755
diff --git a/unix/tkUnixColor.c b/unix/tkUnixColor.c
old mode 100644
new mode 100755
diff --git a/win/tcl.m4 b/win/tcl.m4
old mode 100644
new mode 100755
index 752f022..ab47afc
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -34,7 +34,11 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [
 	AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist)
     fi
     if test ! -f $TCL_BIN_DIR/tclConfig.sh; then
-	AC_MSG_ERROR(There is no tclConfig.sh in $TCL_BIN_DIR:  perhaps you did not specify the Tcl *build* directory (not the toplevel Tcl directory) or you forgot to configure Tcl?)
+	if test ! -f $TCL_BIN_DIR/../unix/tclConfig.sh; then
+	    AC_MSG_ERROR(There is no tclConfig.sh in $TCL_BIN_DIR:  perhaps you did not specify the Tcl *build* directory (not the toplevel Tcl directory) or you forgot to configure Tcl?)
+	fi
+	TCL_BIN_DIR=`cd ${TCL_BIN_DIR}/../unix; pwd`
+	CFLAGS="$CFLAGS -mwin32"
     fi
     AC_MSG_RESULT($TCL_BIN_DIR/tclConfig.sh)
 ])
@@ -413,12 +417,12 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
       AC_CACHE_CHECK(for cross-compile version of gcc,
 	ac_cv_cross,
 	AC_TRY_COMPILE([
-	    #ifdef __WIN32__
+	    #ifndef __WIN32__
 		#error cross-compiler
 	    #endif
 	], [],
-	ac_cv_cross=yes,
-	ac_cv_cross=no)
+	ac_cv_cross=no,
+	ac_cv_cross=yes)
       )
 
       if test "$ac_cv_cross" = "yes"; then
@@ -589,12 +593,12 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
 		;;
 	    *)
 		AC_TRY_COMPILE([
-		    #ifdef _WIN64
-			#error 64-bit
+		    #ifndef _WIN64
+			#error 32-bit
 		    #endif
 		], [],
-			tcl_win_64bit=no,
-			tcl_win_64bit=yes
+			tcl_win_64bit=yes,
+			tcl_win_64bit=no
 		)
 		if test "$tcl_win_64bit" = "yes" ; then
 			do64bit=amd64
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
old mode 100644
new mode 100755
index d0a609f..805dde3
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -24,7 +24,7 @@
  * Translation table between X gc functions and Win32 raster op modes.
  */
 
-int tkpWinRopModes[] = {
+CONST int tkpWinRopModes[] = {
     R2_BLACK,			/* GXclear */
     R2_MASKPEN,			/* GXand */
     R2_MASKPENNOT,		/* GXandReverse */
@@ -55,7 +55,7 @@ int tkpWinRopModes[] = {
 #define SRCORREVERSE	(DWORD)0x00DD0228 /* dest = source OR (NOT dest) */
 #define SRCNAND		(DWORD)0x007700E6 /* dest = NOT (source AND dest) */
 
-int tkpWinBltModes[] = {
+CONST int tkpWinBltModes[] = {
     BLACKNESS,			/* GXclear */
     SRCAND,			/* GXand */
     SRCERASE,			/* GXandReverse */
@@ -93,9 +93,10 @@ int tkpWinBltModes[] = {
 /*
  * Macros used later in the file.
  */
-
-#define MIN(a,b)	((a>b) ? b : a)
-#define MAX(a,b)	((a<b) ? b : a)
+#ifndef MIN
+#   define MIN(a,b)	((a>b) ? b : a)
+#   define MAX(a,b)	((a<b) ? b : a)
+#endif
 
 /*
  * The followng typedef is used to pass Windows GDI drawing functions.
diff --git a/win/tkWinInt.h b/win/tkWinInt.h
old mode 100644
new mode 100755
index efff755..7ab4ff4
--- a/win/tkWinInt.h
+++ b/win/tkWinInt.h
@@ -128,8 +128,8 @@ typedef struct {
  * Win32 raster and BitBlt op modes.
  */
 
-extern int tkpWinRopModes[];
-extern int tkpWinBltModes[];
+extern CONST int tkpWinRopModes[];
+extern CONST int tkpWinBltModes[];
 
 /*
  * The following defines are used with TkWinGetBorderPixels to get the
diff --git a/xlib/rgb.txt b/xlib/rgb.txt
old mode 100644
new mode 100755
diff --git a/xlib/xcolors.c b/xlib/xcolors.c
old mode 100644
new mode 100755
index 04cb1af..9e10175
--- a/xlib/xcolors.c
+++ b/xlib/xcolors.c
@@ -230,7 +230,7 @@ static const elem xColors[] = {
  *----------------------------------------------------------------------
  */
 
-#ifdef __WIN32__
+#if defined(__WIN32__) && !defined(__CYGWIN__)
 #   ifdef NO_STRTOI64
 /* This version only handles hex-strings without 0x prefix */
 static __int64
-- 
cgit v0.12