summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-12-13 21:23:59 (GMT)
committernijtmans <nijtmans>2010-12-13 21:23:59 (GMT)
commit716be31fd7cb8acae5bba8b10425b904f8ace0dc (patch)
treeb2163166f4f1a1b642799c861fc05ecf29b4d279
parent899c51483b58eceb78b4fc34ae8b0c6ff59d8db6 (diff)
downloadtk-716be31fd7cb8acae5bba8b10425b904f8ace0dc.zip
tk-716be31fd7cb8acae5bba8b10425b904f8ace0dc.tar.gz
tk-716be31fd7cb8acae5bba8b10425b904f8ace0dc.tar.bz2
Cross-compile support for Win and UNIX (backported)
-rw-r--r--ChangeLog10
-rwxr-xr-xunix/configure53
-rw-r--r--unix/tcl.m47
-rwxr-xr-xwin/configure11
-rw-r--r--win/tcl.m410
-rw-r--r--win/tkWin32Dll.c87
-rw-r--r--win/tkWinX.c4
7 files changed, 152 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index fda28fd..a6e32a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-12-13 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * unix/tcl.m4: Cross-compile support for Win and UNIX (backported)
+ * unix/configure: (autoconf-2.59)
+ * win/tcl.m4:
+ * win/configure.in:
+ * win/configure: (autoconf-2.59)
+ * win/tkWin32Dll.c: SEH-emulation for AMD64
+ * win/tkWinX.c: mingw-w64 does not accept _WIN32_IE < 0x0501
+
2010-12-12 Stuart Cassoff <stwo@users.sourceforge.net>
* unix/tcl.m4: Better building on OpenBSD.
diff --git a/unix/configure b/unix/configure
index 9e29f18..d4da75b 100755
--- a/unix/configure
+++ b/unix/configure
@@ -308,7 +308,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS TCL_VERSION TCL_PATCH_LEVEL TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCLSH_PROG BUILD_TCLSH MAN_FLAGS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP TCL_THREADS RANLIB ac_ct_RANLIB AR TCL_LIBS DL_LIBS DL_OBJS PLAT_OBJS PLAT_SRCS LDAIX_SRC CFLAGS_DEBUG CFLAGS_OPTIMIZE CFLAGS_WARNING LDFLAGS_DEBUG LDFLAGS_OPTIMIZE CC_SEARCH_FLAGS LD_SEARCH_FLAGS STLIB_LD SHLIB_LD TCL_SHLIB_LD_EXTRAS TK_SHLIB_LD_EXTRAS SHLIB_LD_LIBS SHLIB_CFLAGS SHLIB_SUFFIX MAKE_LIB MAKE_STUB_LIB INSTALL_LIB INSTALL_STUB_LIB CFLAGS_DEFAULT LDFLAGS_DEFAULT LIBOBJS XFT_CFLAGS XFT_LIBS UNIX_FONT_OBJS TK_VERSION TK_MAJOR_VERSION TK_MINOR_VERSION TK_PATCH_LEVEL TK_YEAR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC TK_STUB_LIB_PATH TK_INCLUDE_SPEC TK_BUILD_STUB_LIB_SPEC TK_BUILD_STUB_LIB_PATH TK_SRC_DIR TK_SHARED_BUILD LD_LIBRARY_PATH_VAR TK_BUILD_LIB_SPEC TCL_STUB_FLAGS XINCLUDES XLIBSW LOCALES TK_WINDOWINGSYSTEM TK_PKG_DIR TK_LIBRARY PRIVATE_INCLUDE_DIR HTML_DIR EXTRA_CC_SWITCHES EXTRA_APP_CC_SWITCHES EXTRA_INSTALL EXTRA_INSTALL_BINARIES EXTRA_BUILD_HTML EXTRA_WISH_LIBS CFBUNDLELOCALIZATIONS TK_RSRC_FILE WISH_RSRC_FILE LIB_RSRC_FILE APP_RSRC_FILE REZ REZ_FLAGS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS TCL_VERSION TCL_PATCH_LEVEL TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCLSH_PROG BUILD_TCLSH MAN_FLAGS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP TCL_THREADS RANLIB ac_ct_RANLIB AR ac_ct_AR TCL_LIBS DL_LIBS DL_OBJS PLAT_OBJS PLAT_SRCS LDAIX_SRC CFLAGS_DEBUG CFLAGS_OPTIMIZE CFLAGS_WARNING LDFLAGS_DEBUG LDFLAGS_OPTIMIZE CC_SEARCH_FLAGS LD_SEARCH_FLAGS STLIB_LD SHLIB_LD TCL_SHLIB_LD_EXTRAS TK_SHLIB_LD_EXTRAS SHLIB_LD_LIBS SHLIB_CFLAGS SHLIB_SUFFIX MAKE_LIB MAKE_STUB_LIB INSTALL_LIB INSTALL_STUB_LIB CFLAGS_DEFAULT LDFLAGS_DEFAULT LIBOBJS XFT_CFLAGS XFT_LIBS UNIX_FONT_OBJS TK_VERSION TK_MAJOR_VERSION TK_MINOR_VERSION TK_PATCH_LEVEL TK_YEAR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC TK_STUB_LIB_PATH TK_INCLUDE_SPEC TK_BUILD_STUB_LIB_SPEC TK_BUILD_STUB_LIB_PATH TK_SRC_DIR TK_SHARED_BUILD LD_LIBRARY_PATH_VAR TK_BUILD_LIB_SPEC TCL_STUB_FLAGS XINCLUDES XLIBSW LOCALES TK_WINDOWINGSYSTEM TK_PKG_DIR TK_LIBRARY PRIVATE_INCLUDE_DIR HTML_DIR EXTRA_CC_SWITCHES EXTRA_APP_CC_SWITCHES EXTRA_INSTALL EXTRA_INSTALL_BINARIES EXTRA_BUILD_HTML EXTRA_WISH_LIBS CFBUNDLELOCALIZATIONS TK_RSRC_FILE WISH_RSRC_FILE LIB_RSRC_FILE APP_RSRC_FILE REZ REZ_FLAGS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -4855,8 +4855,9 @@ else
CFLAGS_WARNING=""
fi
- # Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_AR+set}" = set; then
@@ -4872,7 +4873,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_AR="ar"
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -4890,12 +4891,47 @@ else
echo "${ECHO_T}no" >&6
fi
- if test "${AR}" = ""; then
+fi
+if test -z "$ac_cv_prog_AR"; then
+ ac_ct_AR=$AR
+ # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_AR="ar"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
- { { echo "$as_me:$LINENO: error: Required archive tool 'ar' not found on PATH." >&5
-echo "$as_me: error: Required archive tool 'ar' not found on PATH." >&2;}
- { (exit 1); exit 1; }; }
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
+echo "${ECHO_T}$ac_ct_AR" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+ AR=$ac_ct_AR
+else
+ AR="$ac_cv_prog_AR"
fi
STLIB_LD='${AR} cr'
@@ -12000,6 +12036,7 @@ s,@TCL_THREADS@,$TCL_THREADS,;t t
s,@RANLIB@,$RANLIB,;t t
s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
s,@AR@,$AR,;t t
+s,@ac_ct_AR@,$ac_ct_AR,;t t
s,@TCL_LIBS@,$TCL_LIBS,;t t
s,@DL_LIBS@,$DL_LIBS,;t t
s,@DL_OBJS@,$DL_OBJS,;t t
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index bb3ea1a..2f2f317 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -1134,12 +1134,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
AS_IF([test "$GCC" = yes], [
CFLAGS_WARNING="-Wall"
], [CFLAGS_WARNING=""])
-dnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
-dnl AC_CHECK_TOOL(AR, ar)
- AC_CHECK_PROG(AR, ar, ar)
- AS_IF([test "${AR}" = ""], [
- AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
- ])
+ AC_CHECK_TOOL(AR, ar)
STLIB_LD='${AR} cr'
LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
PLAT_OBJS=""
diff --git a/win/configure b/win/configure
index dec3ff5..ebb3eb5 100755
--- a/win/configure
+++ b/win/configure
@@ -3390,10 +3390,6 @@ echo "${ECHO_T}yes" >&6
echo "$as_me:$LINENO: checking compiler flags" >&5
echo $ECHO_N "checking compiler flags... $ECHO_C" >&6
if test "${GCC}" = "yes" ; then
- if test "$do64bit" != "no" ; then
- { echo "$as_me:$LINENO: WARNING: 64bit mode not supported with GCC on Windows" >&5
-echo "$as_me: WARNING: 64bit mode not supported with GCC on Windows" >&2;}
- fi
SHLIB_LD=""
SHLIB_LD_LIBS=""
LIBS="-lws2_32"
@@ -3501,8 +3497,11 @@ echo "$as_me: error: ${CC} does not support the -shared option.
LDFLAGS_CONSOLE="-mconsole ${extra_ldflags}"
LDFLAGS_WINDOW="-mwindows ${extra_ldflags}"
- # gcc under Windows supports only 32bit builds
- MACHINE="X86"
+ if test "$do64bit" != "no" ; then
+ MACHINE="AMD64"
+ else
+ MACHINE="X86"
+ fi
else
if test "${SHARED_BUILD}" = "0" ; then
# static
diff --git a/win/tcl.m4 b/win/tcl.m4
index 77bf2ca..4de8400 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -441,9 +441,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
AC_MSG_CHECKING([compiler flags])
if test "${GCC}" = "yes" ; then
- if test "$do64bit" != "no" ; then
- AC_MSG_WARN([64bit mode not supported with GCC on Windows])
- fi
SHLIB_LD=""
SHLIB_LD_LIBS=""
LIBS="-lws2_32"
@@ -546,8 +543,11 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
LDFLAGS_CONSOLE="-mconsole ${extra_ldflags}"
LDFLAGS_WINDOW="-mwindows ${extra_ldflags}"
- # gcc under Windows supports only 32bit builds
- MACHINE="X86"
+ if test "$do64bit" != "no" ; then
+ MACHINE="AMD64"
+ else
+ MACHINE="X86"
+ fi
else
if test "${SHARED_BUILD}" = "0" ; then
# static
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index 3978f1c..733d2b1 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWin32Dll.c,v 1.12 2005/12/02 00:19:04 dkf Exp $
+ * RCS: @(#) $Id: tkWin32Dll.c,v 1.12.4.1 2010/12/13 21:23:59 nijtmans Exp $
*/
#include "tkWinInt.h"
@@ -90,13 +90,22 @@ DllEntryPoint(
* Always TRUE.
*
* Side effects:
- * This might call some sycronization functions, but MSDN documentation
+ * This might call some synchronization functions, but MSDN documentation
* states: "Waiting on synchronization objects in DllMain can cause a
* deadlock."
*
*----------------------------------------------------------------------
*/
+#if defined(HAVE_NO_SEH) && defined(_WIN64)
+/* A little trick to make the assembler code below
+ * compile on Win64 with gcc: It appears that Win64
+ * does not decorate compiled functions with "_"
+ */
+static void _TkFinalize(ClientData clientData) __attribute__((used));
+static void _TkFinalize(ClientData clientData) {TkFinalize(clientData);}
+#endif
+
BOOL APIENTRY
DllMain(
HINSTANCE hInstance,
@@ -125,6 +134,77 @@ DllMain(
*/
#ifdef HAVE_NO_SEH
+# ifdef __WIN64
+ __asm__ __volatile__ (
+
+ /*
+ * Construct an EXCEPTION_REGISTRATION to protect the call to
+ * TkFinalize
+ */
+
+ "leaq %[registration], %%rdx" "\n\t"
+ "movq %%gs:0, %%rax" "\n\t"
+ "movq %%rax, 0x0(%%edx)" "\n\t" /* link */
+ "leaq 1f, %%rax" "\n\t"
+ "movq %%rax, 0x8(%%rdx)" "\n\t" /* handler */
+ "movq %%rbp, 0x10(%%rdx)" "\n\t" /* ebp */
+ "movq %%rsp, 0x18(%%rdx)" "\n\t" /* esp */
+ "movl %[error], 0x20(%%rdx)" "\n\t" /* status */
+
+ /*
+ * Link the EXCEPTION_REGISTRATION on the chain
+ */
+
+ "movq %%rdx, %%gs:0" "\n\t"
+
+ /*
+ * Call TkFinalize
+ */
+
+ "movq $0x0, 0x0(%%esp)" "\n\t"
+ "call _TkFinalize" "\n\t"
+
+ /*
+ * Come here on a normal exit. Recover the EXCEPTION_REGISTRATION
+ * and store a TCL_OK status
+ */
+
+ "movq %%gs:0, %%rdx" "\n\t"
+ "movl %[ok], %%eax" "\n\t"
+ "movl %%eax, 0x20(%%rdx)" "\n\t"
+ "jmp 2f" "\n"
+
+ /*
+ * Come here on an exception. Get the EXCEPTION_REGISTRATION that
+ * we previously put on the chain.
+ */
+
+ "1:" "\t"
+ "movq %%gs:0, %%rdx" "\n\t"
+ "movq 0x10(%%rdx), %%rdx" "\n\t"
+
+ /*
+ * Come here however we exited. Restore context from the
+ * EXCEPTION_REGISTRATION in case the stack is unbalanced.
+ */
+
+ "2:" "\t"
+ "movq 0x18(%%rdx), %%rsp" "\n\t"
+ "movq 0x10(%%rdx), %%rbp" "\n\t"
+ "movq 0x0(%%rdx), %%rax" "\n\t"
+ "movq %%rax, %%gs:0" "\n\t"
+
+ :
+ /* No outputs */
+ :
+ [registration] "m" (registration),
+ [ok] "i" (TCL_OK),
+ [error] "i" (TCL_ERROR)
+ :
+ "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", "memory"
+ );
+
+# else
__asm__ __volatile__ (
/*
@@ -193,8 +273,9 @@ DllMain(
[error] "i" (TCL_ERROR)
:
"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"
- );
+ );
+# endif
#else /* HAVE_NO_SEH */
__try {
/*
diff --git a/win/tkWinX.c b/win/tkWinX.c
index d99f1ec..62b2670 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinX.c,v 1.57.2.3 2010/05/20 22:43:23 dkf Exp $
+ * RCS: @(#) $Id: tkWinX.c,v 1.57.2.4 2010/12/13 21:23:59 nijtmans Exp $
*/
/*
@@ -30,7 +30,7 @@
*/
#ifndef _WIN32_IE
-#define _WIN32_IE 0x0300
+#define _WIN32_IE 0x0501 /* IE 5 */
#endif
#include <commctrl.h>