Index: unix/tcl.m4
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tcl.m4,v
retrieving revision 1.175
diff -u -p -r1.175 tcl.m4
--- unix/tcl.m4	10 Nov 2006 01:55:58 -0000	1.175
+++ unix/tcl.m4	14 Nov 2006 00:02:27 -0000
@@ -1402,7 +1402,7 @@ dnl AC_CHECK_TOOL(AR, ar)
 	    # get rid of the warnings.
 	    #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
 
-	    SHLIB_LD="${CC} -shared"
+	    SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS="-ldl"
 	    LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
@@ -1426,6 +1426,18 @@ dnl AC_CHECK_TOOL(AR, ar)
 	    # XIM peeking works under XFree86.
 	    AC_DEFINE(PEEK_XCLOSEIM, 1, [May we use XIM peeking safely?])
 
+	    if test $do64bit = yes; then
+		AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [
+		    hold_cflags=$CFLAGS
+		    CFLAGS="$CFLAGS -m64"
+		    AC_TRY_LINK(,, tcl_cv_cc_m64=yes, tcl_cv_cc_m64=no)
+		    CFLAGS=$hold_cflags])
+		if test $tcl_cv_cc_m64 = yes; then
+		    CFLAGS="$CFLAGS -m64"
+		    do64bit_ok=yes
+		fi
+	    fi
+
 	    ;;
 	GNU*)
 	    SHLIB_CFLAGS="-fPIC"
