From 7035fd60088016c75814d08cf69c2d9492bba90a Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 13 Jul 2010 11:58:58 +0000 Subject: * configure.in (RUBY_DEFAULT_ARCH): adjust for target cpu. [ruby-core:31243] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- configure.in | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index a7c9610cca..e5c259f520 100644 --- a/configure.in +++ b/configure.in @@ -136,9 +136,20 @@ AC_ARG_WITH(arch, target platform]), [target_archs="$withval"], [unset target_archs]) +AC_DEFUN([RUBY_DEFAULT_ARCH], [ +AC_MSG_CHECKING([arch option]) +AS_CASE([$1], + [*64], [ARCH_FLAG=-m64], + [[i[3-6]86]], [ARCH_FLAG=-m32], + [AC_MSG_ERROR(unknown target architecture: $target_archs)] + ) +AC_MSG_RESULT([$ARCH_FLAG]) +]) + AC_DEFUN([RUBY_UNIVERSAL_ARCH], [ -test ${CFLAGS+set} && CFLAGS=`echo "$CFLAGS" | sed 's/ *-arch *[^ ]*//g'` -test ${LDFLAGS+set} && LDFLAGS=`echo "$LDFLAGS" | sed 's/ *-arch *[^ ]*//g'` +# RUBY_UNIVERSAL_ARCH begin +test ${CFLAGS+set} && CFLAGS=`echo "$CFLAGS" | sed -e 's/ *-arch *[^ ]*//g' -e 's/ *-m32//g' -e 's/ *-m64//g'` +test ${LDFLAGS+set} && LDFLAGS=`echo "$LDFLAGS" | sed 's/ *-arch *[^ ]*//g' -e 's/ *-m32//g' -e 's/ *-m64//g'` unset ARCH_FLAG universal_binary universal_archnames if test ${target_archs+set}; then AC_MSG_CHECKING([target architectures]) @@ -172,6 +183,14 @@ if test ${target_archs+set}; then target_cpu=universal real_cross_compiling=$cross_compiling else + if test x"$target_cpu" != x"${target_archs}"; then + echo 'int main(){return 0;}' > conftest.c + if $CC $CFLAGS $ARCH_FLAG conftest.c > /dev/null 2>&1; then + rm -f conftest.* a.out + else + RUBY_DEFAULT_ARCH("$target_archs") + fi + fi target_cpu=${target_archs} fi AS_CASE(["$target"], [-*], [ target="$target_cpu${target}"]) @@ -210,6 +229,7 @@ if test "${target_archs}" != "${rb_cv_target_archs-${target_archs}}"; then else rb_cv_target_archs=${target_archs} fi +# RUBY_UNIVERSAL_ARCH end ]) AC_ARG_ENABLE(load-relative, @@ -264,6 +284,9 @@ AC_SUBST(COUTFLAG) RUBY_MINGW32 RUBY_UNIVERSAL_ARCH +if test "$target_cpu" != "$host_cpu" -a "$GCC" = yes -a "$cross_compiling" = no; then + RUBY_DEFAULT_ARCH("$target_cpu") +fi AC_CHECK_TOOL(RANLIB, ranlib, :) AC_CHECK_TOOL(AR, ar) -- cgit v1.2.3