From f7f46df1f120a54420f4fd2b4ea32e1003eeea22 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Wed, 25 Nov 2009 10:17:56 +0000 Subject: configure.in: fixed the GMP CC/CFLAGS detection and replaced "test ... -o ..." (obsolete in POSIX) by "test ... || test ..." and "test ... -a ..." (obsolete in POSIX) by "test ... && test ...". git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/2.4@6581 280ebfd0-de03-0410-8827-d642c229c3f4 --- configure.in | 102 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 47 deletions(-) diff --git a/configure.in b/configure.in index ab33711af..06eaf232b 100644 --- a/configure.in +++ b/configure.in @@ -60,7 +60,7 @@ AC_ARG_WITH(gmp_lib, ]) AC_ARG_WITH(gmp, [ --with-gmp=DIR GMP install directory ], [ - if test -z "$with_gmp_lib" -a -z "$with_gmp_include" ; then + if test -z "$with_gmp_lib" && test -z "$with_gmp_include" ; then CPPFLAGS="$CPPFLAGS -I$withval/include" LDFLAGS="$LDFLAGS -L$withval/lib" gmp_lib_path="$withval/lib" @@ -72,7 +72,7 @@ AC_ARG_WITH(gmp, AC_ARG_WITH(gmp_build, [ --with-gmp-build=DIR GMP build directory (please read INSTALL file)], [ - if test -z "$gmp_lib_path" -a -z "$with_gmp_include" ; then + if test -z "$gmp_lib_path" && test -z "$with_gmp_include" ; then CPPFLAGS="$CPPFLAGS -I$withval -I$withval/tune" LDFLAGS="$LDFLAGS -L$withval -L$withval/.libs -L$withval/tune/" gmp_lib_path="$withval$PATH_SEPARATOR$withval/.libs$PATH_SEPARATOR$withval/tune" @@ -145,26 +145,43 @@ if test -n "$CFLAGS" || test -n "$CC" ; then user_redefine_cc=yes fi dnl Autoconf detection -AC_PROG_CC -AC_PROG_CPP AC_PROG_EGREP AC_PROG_SED -AC_LANG(C) -dnl Check for GMP CFLAGS in gmp.h -if test -z "$GMP_CFLAGS" -a -z "$user_redefine_cc" ; then +dnl ******************************************************************** +dnl Check for CC and CFLAGS in gmp.h + +if test -z "$user_redefine_cc" && test "$cross_compiling" != yes ; then + +dnl We need to guess the C preprocessor instead of using AC_PROG_CPP, +dnl since AC_PROG_CPP implies AC_PROG_CC, which chooses a compiler +dnl (before we have the chance to get it from gmp.h) and does some +dnl checking related to this compiler (such as dependency tracking +dnl options); if the compiler changes due to __GMP_CC in gmp.h, one +dnl would have incorrect settings. +dnl FIXME: Move this in aclocal ? +if test -z "$GMP_CC$GMP_CFLAGS" ; then AC_MSG_CHECKING(for CC and CFLAGS in gmp.h) - # FIXME: Move this in aclocal ? - # Get CC - echo "#include \"gmp.h\"" > conftest.c - echo "MPFR_OPTION __GMP_CC" >> conftest.c - GMP_CC=`$CPP $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPFR_OPTION | $SED -e 's/MPFR_OPTION //g' | $SED -e 's/"//g'` - #Get CFLAGS - echo "#include \"gmp.h\"" > conftest.c - echo "MPFR_OPTION __GMP_CFLAGS" >> conftest.c - GMP_CFLAGS=`$CPP $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPFR_OPTION | $SED -e 's/MPFR_OPTION //g'| $SED -e 's/"//g'` + GMP_CC=__GMP_CC + GMP_CFLAGS=__GMP_CFLAGS + for cpp in /lib/cpp gcc cc c99 + do + test $cpp = /lib/cpp || cpp="$cpp -E" + echo foo > conftest.c + if $cpp $CPPFLAGS conftest.c > /dev/null 2> /dev/null ; then + # Get CC + echo "#include \"gmp.h\"" > conftest.c + echo "MPFR_OPTION __GMP_CC" >> conftest.c + GMP_CC=`$cpp $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPFR_OPTION | $SED -e 's/MPFR_OPTION //g' | $SED -e 's/"//g'` + # Get CFLAGS + echo "#include \"gmp.h\"" > conftest.c + echo "MPFR_OPTION __GMP_CFLAGS" >> conftest.c + GMP_CFLAGS=`$cpp $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPFR_OPTION | $SED -e 's/MPFR_OPTION //g'| $SED -e 's/"//g'` + break + fi + done rm -f conftest* - if test "x$GMP_CFLAGS" = "x__GMP_CFLAGS" -o "x$GMP_CC" = "x__GMP_CC" ; then + if test "x$GMP_CC" = "x__GMP_CC" || test "x$GMP_CFLAGS" = "x__GMP_CFLAGS" ; then AC_MSG_RESULT(no) GMP_CFLAGS= GMP_CC= @@ -173,38 +190,29 @@ if test -z "$GMP_CFLAGS" -a -z "$user_redefine_cc" ; then fi fi -dnl Check for GMP CFLAGS and CC (More optimized for the target) -dnl But they may be invalid, so we must check them first -dnl Don't redefine it if the user force them! -if test -n "$GMP_CFLAGS" && test -z "$user_redefine_cc" ; then - old_cflags=$CFLAGS - old_cc=$CC - CFLAGS=$GMP_CFLAGS - CC=$GMP_CC - AC_MSG_CHECKING(for CC=$GMP_CC and CFLAGS=$GMP_CFLAGS) - AC_RUN_IFELSE(AC_LANG_PROGRAM([[/*hello*/]],[[/*world*/]]), [ - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - CFLAGS=$old_cflags - CC=$old_cc - ], [ - AC_MSG_RESULT([can't test]) - CFLAGS=$old_cflags - CC=$old_cc - ]) - dnl CC may have change. Recheck for GCC. - GCC= - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#ifndef __GNUC__ -# error "GCC Not Found" -error -#endif - ]])], [ - GCC=yes - ]) +dnl But these variables may be invalid, so we must check them first. +dnl Note: we do not use AC_RUN_IFELSE, as it implies AC_PROG_CC. +if test -n "$GMP_CC$GMP_CFLAGS" ; then + AC_MSG_CHECKING(for CC=$GMP_CC and CFLAGS=$GMP_CFLAGS) + echo "int main (void) { return 0; }" > conftest.c + if $GMP_CC $GMP_CFLAGS -o conftest conftest.c 2> /dev/null ; then + AC_MSG_RESULT(yes) + CFLAGS=$GMP_CFLAGS + CC=$GMP_CC + else + AC_MSG_RESULT(no) + fi + rm -f conftest* fi +fi + +dnl ******************************************************************** + +AC_PROG_CC +AC_PROG_CPP +AC_LANG(C) + AC_ARG_ENABLE(decimal-float, [ --enable-decimal-float build conversion functions from/to decimal floats [[default=no]]], -- cgit v1.2.1