From e78a1582dc13d770bf1a9de64ff817369c741ef5 Mon Sep 17 00:00:00 2001 From: Patrik Nyblom Date: Tue, 25 Oct 2011 12:31:54 +0200 Subject: Make Win64 build work both under MSYS and Cygwin --- aclocal.m4 | 2 +- erts/aclocal.m4 | 2 +- erts/configure.in | 49 +++++++--- erts/etc/win32/cygwin_tools/vc/emu_cc.sh | 9 +- lib/erl_interface/aclocal.m4 | 2 +- lib/odbc/aclocal.m4 | 2 +- lib/wx/aclocal.m4 | 2 +- lib/wx/configure.in | 9 ++ otp_build | 152 +++++++++++++++++++++++++++++-- 9 files changed, 201 insertions(+), 28 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 34237fcb43..339a15a2bb 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -132,7 +132,7 @@ if test "X$host" = "Xwin32" -a "x$GCC" != "xyes"; then AC_MSG_RESULT([Cygwin and VC]) MIXED_CYGWIN_VC=yes CPPFLAGS="$CPPFLAGS -DERTS_MIXED_CYGWIN_VC" - elif test -x /usr/bin/i686-pc-msys-gcc.exe; then + elif test -x /usr/bin/msysinfo; then CFLAGS="-O2" MIXED_MSYS=yes AC_MSG_RESULT([MSYS and VC]) diff --git a/erts/aclocal.m4 b/erts/aclocal.m4 index 34237fcb43..339a15a2bb 100644 --- a/erts/aclocal.m4 +++ b/erts/aclocal.m4 @@ -132,7 +132,7 @@ if test "X$host" = "Xwin32" -a "x$GCC" != "xyes"; then AC_MSG_RESULT([Cygwin and VC]) MIXED_CYGWIN_VC=yes CPPFLAGS="$CPPFLAGS -DERTS_MIXED_CYGWIN_VC" - elif test -x /usr/bin/i686-pc-msys-gcc.exe; then + elif test -x /usr/bin/msysinfo; then CFLAGS="-O2" MIXED_MSYS=yes AC_MSG_RESULT([MSYS and VC]) diff --git a/erts/configure.in b/erts/configure.in index 8798adf3a5..a171c6ec2b 100644 --- a/erts/configure.in +++ b/erts/configure.in @@ -383,12 +383,6 @@ case $host_os in # The ethread library requires _WIN32_WINNT of at least 0x0403. # -D_WIN32_WINNT=* from CPPFLAGS is saved in ETHR_DEFS. CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0500 -DWINVER=0x0500" - # _USE_32BIT_TIME_T is needed when using VC++ 2005 (ctime() will fail - # otherwise since we pass it a 32-bit value). - # - # FIXME: Use time_t all the way and remove _USE_32BIT_TIME_T. - # AC_MSG_WARN([Reverting to 32-bit time_t]) - # CPPFLAGS="$CPPFLAGS -D_USE_32BIT_TIME_T" ;; darwin*) CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE" @@ -619,6 +613,19 @@ esac AC_SUBST(OPSYS) AC_SUBST(ARCH) +# Need to add this adjustment after we know the architecture, will fail on 64bit +# This should be temporary, USE_32BIT_TIME_T should go away before R15B +case $host_os in + win32) + # FIXME: Use time_t all the way and remove _USE_32BIT_TIME_T. + if test "x$ARCH" != "xamd64"; then + AC_MSG_WARN([Reverting to 32-bit time_t]) + CPPFLAGS="$CPPFLAGS -D_USE_32BIT_TIME_T" + fi + ;; + *) + ;; +esac dnl Check consistency of os and darwin-switches @@ -3703,16 +3710,23 @@ case "$erl_xcomp_without_sysroot-$with_ssl" in AC_CHECK_PROG(REGTOOL, regtool, regtool, false) if test "$ac_cv_prog_REGTOOL" != false; then wrp="/machine/software/microsoft/windows/currentversion/" - urp="uninstall/openssl_is1/inno setup: app path" + if test "x$ARCH" = "xamd64"; then + urp="uninstall/openssl (64-bit)_is1/inno setup: app path" + regtool_subsystem=-w + else + urp="uninstall/openssl (32-bit)_is1/inno setup: app path" + regtool_subsystem=-W + fi rp="$wrp$urp" - if regtool -q get "$rp" > /dev/null; then + if regtool -q $regtool_subsystem get "$rp" > /dev/null; then true else - urp="uninstall/openssl (32-bit)_is1/inno setup: app path" + # Fallback to unspecified wordlength + urp="uninstall/openssl_is1/inno setup: app path" rp="$wrp$urp" fi - if regtool -q get "$rp" > /dev/null; then - ssl_install_dir=`regtool -q get "$rp"` + if regtool -q $regtool_subsystem get "$rp" > /dev/null; then + ssl_install_dir=`regtool -q $regtool_subsystem get "$rp"` # Try hard to get rid of spaces... if cygpath -d "$ssl_install_dir" > /dev/null 2>&1; then ssl_install_dir=`cygpath -d "$ssl_install_dir"` @@ -3742,9 +3756,20 @@ case "$erl_xcomp_without_sysroot-$with_ssl" in SSL_CRYPTO_LIBNAME=crypto SSL_SSL_LIBNAME=ssl + + if test "x$MIXED_CYGWIN" = "xyes" -o "x$MIXED_MSYS" = "xyes"; then + if test "x$ARCH" = "xamd64"; then + std_win_ssl_locations="/cygdrive/c/OpenSSL-Win64 /c/OpenSSL-Win64 /opt/local64/pgm/OpenSSL" + else + std_win_ssl_locations="/cygdrive/c/OpenSSL-Win32 /c/OpenSSL-Win32 /cygdrive/c/OpenSSL /c/OpenSSL /opt/local/pgm/OpenSSL" + fi + else + std_win_ssl_locations="" + fi + AC_MSG_CHECKING(for OpenSSL >= 0.9.7 in standard locations) - for rdir in $extra_dir /cygdrive/c/OpenSSL $std_ssl_locations; do + for rdir in $extra_dir $std_win_ssl_locations $std_ssl_locations; do dir="$erl_xcomp_sysroot$rdir" if test -f "$erl_xcomp_isysroot$rdir/include/openssl/opensslv.h"; then is_real_ssl=yes diff --git a/erts/etc/win32/cygwin_tools/vc/emu_cc.sh b/erts/etc/win32/cygwin_tools/vc/emu_cc.sh index c74c35111b..f7c34a4564 100755 --- a/erts/etc/win32/cygwin_tools/vc/emu_cc.sh +++ b/erts/etc/win32/cygwin_tools/vc/emu_cc.sh @@ -17,6 +17,11 @@ # # %CopyrightEnd% # +if [ X"$CONFIG_SUBTYPE" = X"win64" ]; then + GCC="x86_64-w64-mingw32-gcc.exe" +else + GCC="gcc" +fi TOOLDIR=$ERL_TOP/erts/etc/win32/cygwin_tools/vc COFFIX=$TOOLDIR/coffix WTOOLDIR=`(cygpath -d $TOOLDIR 2>/dev/null || cygpath -w $TOOLDIR)` @@ -71,7 +76,7 @@ if [ $SKIP_COFFIX = false ]; then if [ "X$EMU_CC_SH_DEBUG_LOG" != "X" ]; then echo "gcc -o $TEMPFILE -D__WIN32__ -DWIN32 -DWINDOWS -fomit-frame-pointer $CMD" >> $EMU_CC_SH_DEBUG_LOG 2>&1 fi - eval gcc -o $TEMPFILE -D__WIN32__ -DWIN32 -DWINDOWS -fomit-frame-pointer $CMD + eval $GCC -o $TEMPFILE -D__WIN32__ -DWIN32 -DWINDOWS -fomit-frame-pointer $CMD RES=$? if [ $RES = 0 ]; then $COFFIX.exe -e `(cygpath -d $TEMPFILE 2>/dev/null || cygpath -w $TEMPFILE)` @@ -85,6 +90,6 @@ if [ $SKIP_COFFIX = false ]; then rm -f $TEMPFILE exit $RES else - eval gcc -D__WIN32__ -DWIN32 -DWINDOWS -fomit-frame-pointer -fno-tree-copyrename $CMD 2>/dev/null + eval $GCC -D__WIN32__ -DWIN32 -DWINDOWS -fomit-frame-pointer -fno-tree-copyrename $CMD 2>/dev/null exit $? fi diff --git a/lib/erl_interface/aclocal.m4 b/lib/erl_interface/aclocal.m4 index 34237fcb43..339a15a2bb 100644 --- a/lib/erl_interface/aclocal.m4 +++ b/lib/erl_interface/aclocal.m4 @@ -132,7 +132,7 @@ if test "X$host" = "Xwin32" -a "x$GCC" != "xyes"; then AC_MSG_RESULT([Cygwin and VC]) MIXED_CYGWIN_VC=yes CPPFLAGS="$CPPFLAGS -DERTS_MIXED_CYGWIN_VC" - elif test -x /usr/bin/i686-pc-msys-gcc.exe; then + elif test -x /usr/bin/msysinfo; then CFLAGS="-O2" MIXED_MSYS=yes AC_MSG_RESULT([MSYS and VC]) diff --git a/lib/odbc/aclocal.m4 b/lib/odbc/aclocal.m4 index 34237fcb43..339a15a2bb 100644 --- a/lib/odbc/aclocal.m4 +++ b/lib/odbc/aclocal.m4 @@ -132,7 +132,7 @@ if test "X$host" = "Xwin32" -a "x$GCC" != "xyes"; then AC_MSG_RESULT([Cygwin and VC]) MIXED_CYGWIN_VC=yes CPPFLAGS="$CPPFLAGS -DERTS_MIXED_CYGWIN_VC" - elif test -x /usr/bin/i686-pc-msys-gcc.exe; then + elif test -x /usr/bin/msysinfo; then CFLAGS="-O2" MIXED_MSYS=yes AC_MSG_RESULT([MSYS and VC]) diff --git a/lib/wx/aclocal.m4 b/lib/wx/aclocal.m4 index 34237fcb43..339a15a2bb 100644 --- a/lib/wx/aclocal.m4 +++ b/lib/wx/aclocal.m4 @@ -132,7 +132,7 @@ if test "X$host" = "Xwin32" -a "x$GCC" != "xyes"; then AC_MSG_RESULT([Cygwin and VC]) MIXED_CYGWIN_VC=yes CPPFLAGS="$CPPFLAGS -DERTS_MIXED_CYGWIN_VC" - elif test -x /usr/bin/i686-pc-msys-gcc.exe; then + elif test -x /usr/bin/msysinfo; then CFLAGS="-O2" MIXED_MSYS=yes AC_MSG_RESULT([MSYS and VC]) diff --git a/lib/wx/configure.in b/lib/wx/configure.in index a2e41b540e..e00d5cba98 100755 --- a/lib/wx/configure.in +++ b/lib/wx/configure.in @@ -398,6 +398,15 @@ else CWXWIN3=$CWXWIN_PROG/wxWidgets-2.8 CWXWIN4=$CWXWIN_PROG/wxMSW-2.8 CWX_DOCUMENTED="/opt/local/pgm/wxMSW-2.8.* /opt/local/pgm/wxWidgets-2.8.*" + case $ac_cv_sizeof_void_p in + 8) + CWX_DOCUMENTED="/opt/local64/pgm/wxMSW-2.8.* /opt/local64/pgm/wxWidgets-2.8.* $CWX_DOCUMENTED" + ;; + *) + true + ;; + esac + CWXPATH="$CWXWIN1 $CWXWIN2 $CWX_DOCUMENTED $CWXWIN3.* $CWXWIN4.*" for dir in $CWXPATH; do diff --git a/otp_build b/otp_build index 0222e4923b..a4e25510c1 100755 --- a/otp_build +++ b/otp_build @@ -65,9 +65,16 @@ usage () echo " installer_win32 - creates a windows installer from " echo "" echo "Before trying to build on windows, consider the following option" - echo " env_win32 - echo environment settings for win32 with visual C++, use with eval" + echo " env_win32 [] - echo environment settings for win32 with visual C++, use with eval" + echo " The optional can be x64 for 64bit Windows 7" + echo " or x86 for 32bit Windows XP+" + echo " env_win64 - echo environment settings for win32 with visual C++, use with eval" + echo " Note that env_win32 x64 gives the same result, Windows 7 64bit" echo " env_mingw32 - echo environment settings for win32 with MinGW, use with eval" - echo " env_msys64 - echo environment settings for win32 with visual C++ running msys and mingw, use with eval" + echo " - experimental!" + echo " env_msys64 - echo environment settings for win32 with visual C++ running " + echo " msys and mingw, use with eval" + echo " - experimental!" echo "" echo "Before trying to build for vxworks, consider the following option" echo " env_vxworks - echo environment settings for vxworks, use with eval" @@ -278,7 +285,10 @@ chk_eq() s=`$SUM_CMD $x | awk '{print $1}'` if test "$s" != "$master_sum"; then echo "Error: $master and $x are not equal, make sure they are!" >&2 - exit 1 + echo "Maybe you would want to:" >&2 + echo "for x in $slaves; do cp $master \$x; done" >&2 + echo "? Or something else is wrong." 2>&1 + exit 2 fi done } @@ -876,6 +886,119 @@ echo_env_mingw32 () # N.B. In Erlang, and the build system, win32 means windows, so we keep # everything as terget win32, but add the CONFIG_SUBTYPE win64, which can # be handled by configure, setting WINDOWS_64BIT in headers and such +echo_env_win64 () +{ + #echo_envinfo + if [ X"$SHELL" = X"" ]; then + echo "You need to export the shell variable first," \ + "for bourne-like shells, type:" >&2 + echo 'export SHELL' >&2 + echo "and for csh-like shells, type:" >&2 + echo 'setenv SHELL $SHELL' >&2 + echo " - then try again." >&2 + exit 1 + fi + echo_env_erltop + # Try to cope with paths containing unexpected things like stray + # mixed paths (c:/something/bin) and quotes. Only C and D drive + # handled. + CCYGPATH=`cygpath c:\\` + DCYGPATH=`cygpath d:\\` + P2=`echo :$PATH | \ + sed "s,\",,g;s,:[cC]:,:$CCYGPATH,g;s,:[dD]:,:$DCYGPATH,g;s,^:,,"` + P3="" + save_ifs=$IFS + IFS=: + for p in $P2; do + if [ -d "$p" ]; then + C1="`(cygpath -d $p 2>/dev/null || cygpath -w $p)`" 2> /dev/null + C2=`cygpath "$C1" 2> /dev/null` 2> /dev/null + else + C2="" + fi + if [ ! -z "$C2" ]; then + if [ -z "$P3" ];then + P3="$C2" + else + P3="$P3:$C2" + fi + fi + done + IFS=$save_ifs + WIN32_WRAPPER_PATH="$ERL_TOP/erts/etc/win32/cygwin_tools/vc:$ERL_TOP/erts/etc/win32/cygwin_tools" + + + echo_setenv OVERRIDE_TARGET win32 ';' + echo_setenv CONFIG_SUBTYPE win64 ';' + echo_setenv CC cc.sh ';' + echo_setenv CXX cc.sh ';' + echo_setenv AR ar.sh ';' + echo_setenv RANLIB true ';' + if [ -f "$ERL_TOP/erts/autoconf/win64.config.cache.static" ]; then + echo_setenv OVERRIDE_CONFIG_CACHE_STATIC "$ERL_TOP/erts/autoconf/win64.config.cache.static" ';' + fi + echo_setenv OVERRIDE_CONFIG_CACHE "$ERL_TOP/erts/autoconf/win64.config.cache" ';' + echo_setenv WIN32_WRAPPER_PATH "$WIN32_WRAPPER_PATH" ';' + echo_setenv PATH "$WIN32_WRAPPER_PATH:$P3" ';' + echo_envinfo +} + +echo_env_msys32 () +{ + #echo_envinfo + if [ X"$SHELL" = X"" ]; then + echo "You need to export the shell variable first," \ + "for bourne-like shells, type:" >&2 + echo 'export SHELL' >&2 + echo "and for csh-like shells, type:" >&2 + echo 'setenv SHELL $SHELL' >&2 + echo " - then try again." >&2 + exit 1 + fi + echo_env_erltop + # Try to cope with paths containing unexpected things like stray + # mixed paths (c:/something/bin) and quotes. Only C and D drive + # handled. + P2=`echo :$PATH | \ + sed "s,\",,g;s,:\([a-zA-Z]\):,:/\L\1,g;s,^:,,"` + P3="" + save_pwd=`pwd` + save_ifs=$IFS + IFS=: + for p in $P2; do + if [ -d "$p" ]; then + C1=`(cd "$p" && cmd //C "for %i in (".") do @echo %~fsi")` + C2=`echo "$C1" | sed 's,^\([a-zA-Z]\):\\\\,/\L\1/,;s,\\\\,/,g'` + else + C2="" + fi + if [ ! -z "$C2" ]; then + if [ -z "$P3" ];then + P3="$C2" + else + P3="$P3:$C2" + fi + fi + done + IFS=$save_ifs + WIN32_WRAPPER_PATH="$ERL_TOP/erts/etc/win32/msys_tools/vc:$ERL_TOP/erts/etc/win32/msys_tools" + + echo_setenv OVERRIDE_TARGET win32 ';' + echo_setenv CC cc.sh ';' + echo_setenv CXX cc.sh ';' + echo_setenv AR ar.sh ';' + echo_setenv RANLIB true ';' + if [ -f "$ERL_TOP/erts/autoconf/win32.config.cache.static" ]; then + echo_setenv OVERRIDE_CONFIG_CACHE_STATIC "$ERL_TOP/erts/autoconf/win32.config.cache.static" ';' + fi + + echo_setenv OVERRIDE_CONFIG_CACHE "$ERL_TOP/erts/autoconf/win32.config.cache" ';' + echo_setenv WIN32_WRAPPER_PATH "$WIN32_WRAPPER_PATH" ';' + echo_setenv PATH "$WIN32_WRAPPER_PATH:$P3" ';' + echo_envinfo +} + + echo_env_msys64 () { #echo_envinfo @@ -900,11 +1023,8 @@ echo_env_msys64 () IFS=: for p in $P2; do if [ -d "$p" ]; then - #echo 'p =' "|$p|" C1=`(cd "$p" && cmd //C "for %i in (".") do @echo %~fsi")` - #echo 'C1 =' "|$C1|" C2=`echo "$C1" | sed 's,^\([a-zA-Z]\):\\\\,/\L\1/,;s,\\\\,/,g'` - #echo 'C2 =' "|$C2|" else C2="" fi @@ -1178,7 +1298,7 @@ BUILDSYS=$TARGET case $TARGET in *-cygwin) if [ X"$BUILD_FOR_CYGWIN" = X"" ]; then - if [ X"$OVERRIDE_TARGET" = X"" -a X"$1" != X"env_win32" -a X"$1" != X"env_mingw32" ];then + if [ X"$OVERRIDE_TARGET" = X"" -a X"$1" != X"env_win32" -a X"$1" != X"env_win64" -a X"$1" != X"env_mingw32" ];then echo "Building for windows, you should do the " \ "following first:" >&2 echo 'eval `./otp_build env_win32`' >&2 @@ -1188,7 +1308,7 @@ case $TARGET in fi fi;; *-mingw32) - if [ X"$OVERRIDE_TARGET" = X"" -a X"$1" != X"env_msys64" ];then + if [ X"$OVERRIDE_TARGET" = X"" -a X"$1" != X"env_win32" -a X"$1" != X"env_msys32" -a X"$1" != X"env_msys64" ];then echo "Building for windows, you should do the " \ "following first:" >&2 echo 'eval `./otp_build env_msys64`' >&2 @@ -1324,9 +1444,23 @@ case "$1" in fi; do_debuginfo_win32 "$2";; env_win32) - echo_env_win32;; + if [ x"$2" = x"x64" -o x"$2" = x"amd64" ]; then + if [ -x /usr/bin/msysinfo ]; then + echo_env_msys64 + else + echo_env_win64 + fi + else + if [ -x /usr/bin/msysinfo ]; then + echo_env_msys32 + else + echo_env_win32 + fi + fi;; env_mingw32) echo_env_mingw32;; + env_win64) + echo_env_win64;; env_msys64) echo_env_msys64;; env_vxworks) -- cgit v1.2.3