From 653c10ee03ae1c5d17bcb243c176d2dbe4cfbe37 Mon Sep 17 00:00:00 2001
From: nijtmans <nijtmans>
Date: Wed, 17 Nov 2010 21:06:44 +0000
Subject: [FRQ 491789]: "setargv() doesn't support a unicode cmdline" now
 implemented for mingw-w64

---
 ChangeLog     |  6 ++++++
 win/configure | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 win/tcl.m4    | 20 +++++++++++++++++-
 3 files changed, 92 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8388e7c..c9ecc92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-11-17  Jan Nijtmans  <nijtmans@users.sf.net>
+
+	* win/tcl.m4: [FRQ 491789]: "setargv() doesn't support a
+	unicode cmdline" now implemented for mingw-w64
+	* win/configure    (re-generated)
+
 2010-11-16  Jan Nijtmans  <nijtmans@users.sf.net>
 
 	* win/tclAppInit.c Bring compilation under mingw-w64 a bit closer
diff --git a/win/configure b/win/configure
index 46e66af..4ea242c 100755
--- a/win/configure
+++ b/win/configure
@@ -4029,7 +4029,7 @@ echo "$as_me: WARNING: 64bit mode not supported with GCC on Windows" >&2;}
 	MAKE_EXE="\${CC} -o \$@"
 	LIBPREFIX="lib"
 
-	extra_cflags="-pipe -DTCL_BROKEN_MAINARGS"
+	extra_cflags="-pipe"
 	extra_ldflags="-pipe"
 
 	if test "$ac_cv_cygwin" = "yes"; then
@@ -4047,6 +4047,72 @@ echo "$as_me: WARNING: 64bit mode not supported with GCC on Windows" >&2;}
 	  rm -f ac$$.o ac$$.c
 	fi
 
+	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -mwindows -municode -Dmain=xxmain"
+    echo "$as_me:$LINENO: checking for working -municode linker flag" >&5
+echo $ECHO_N "checking for working -municode linker flag... $ECHO_C" >&6
+if test "${ac_cv_municode+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+    #include <windows.h>
+    int APIENTRY wWinMain(HINSTANCE a, HINSTANCE b, LPWSTR c, int d) {return 0;}
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_municode=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_municode=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_municode" >&5
+echo "${ECHO_T}$ac_cv_municode" >&6
+    CFLAGS=$hold_cflags
+    if test "$ac_cv_municode" = "yes" ; then
+	extra_ldflags="$extra_ldflags -municode"
+    else
+	extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS"
+    fi
+
 	if test "${SHARED_BUILD}" = "0" ; then
 	    # static
             echo "$as_me:$LINENO: result: using static flags" >&5
diff --git a/win/tcl.m4 b/win/tcl.m4
index ff61263..88ec090 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -477,7 +477,7 @@ file for information about building with Mingw.])
 	MAKE_EXE="\${CC} -o \[$]@"
 	LIBPREFIX="lib"
 
-	extra_cflags="-pipe -DTCL_BROKEN_MAINARGS"
+	extra_cflags="-pipe"
 	extra_ldflags="-pipe"
 
 	if test "$ac_cv_cygwin" = "yes"; then
@@ -495,6 +495,24 @@ file for information about building with Mingw.])
 	  rm -f ac$$.o ac$$.c
 	fi
 
+	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -mwindows -municode -Dmain=xxmain"
+    AC_CACHE_CHECK(for working -municode linker flag,
+        ac_cv_municode,
+    AC_TRY_LINK([
+    #include <windows.h>
+    int APIENTRY wWinMain(HINSTANCE a, HINSTANCE b, LPWSTR c, int d) {return 0;}
+    ],
+    [],
+        ac_cv_municode=yes,
+        ac_cv_municode=no)
+    )
+    CFLAGS=$hold_cflags
+    if test "$ac_cv_municode" = "yes" ; then
+	extra_ldflags="$extra_ldflags -municode"
+    else
+	extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS"
+    fi
+
 	if test "${SHARED_BUILD}" = "0" ; then
 	    # static
             AC_MSG_RESULT([using static flags])
-- 
cgit v0.12