summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorthevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2009-03-19 14:10:37 +0000
committerthevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2009-03-19 14:10:37 +0000
commitb7c96fbbf7a1c01d907c4c35b3ba81c87d25cc3b (patch)
tree84e7ca3e7b217caade0044b2181a0356e92612b4 /configure.ac
parent161e969d7764052785e04536c08c571ab058bec2 (diff)
downloadmpc-b7c96fbbf7a1c01d907c4c35b3ba81c87d25cc3b.tar.gz
configure.ac NEWS: configure can get CFLAGS and CC from gmp.h (copied from MPFR)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@480 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac67
1 files changed, 66 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 583821f..a9cc9eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,12 +84,77 @@ AC_ARG_ENABLE([logging],
esac
])
+dnl
+dnl Setup CC and CFLAGS
+dnl
+
+dnl Check if user request its CC and CFLAGS
+if test -n "$CFLAGS" || test -n "$CC" ; then
+ user_redefine_cc=yes
+fi
# Checks for programs.
AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_EGREP
AC_PROG_SED
+AC_LANG(C)
+
+dnl Check for GMP CFLAGS in gmp.h
+dnl copied from MPFR's configure.in
+if test -z "$GMP_CFLAGS" -a -z "$user_redefine_cc" ; 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 "MPC_OPTION __GMP_CC" >> conftest.c
+ GMP_CC="`$CPP $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPC_OPTION | $SED -e 's/MPC_OPTION //g' | $SED -e 's/"//g'`"
+ #Get CFLAGS
+ echo "#include \"gmp.h\"" > conftest.c
+ echo "MPC_OPTION __GMP_CFLAGS" >> conftest.c
+ GMP_CFLAGS="`$CPP $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPC_OPTION | $SED -e 's/MPC_OPTION //g'| $SED -e 's/"//g'`"
+ rm -f conftest*
+ if test "x$GMP_CFLAGS" = "x__GMP_CFLAGS" -o "x$GMP_CC" = "x__GMP_CC" ; then
+ AC_MSG_RESULT(no)
+ GMP_CFLAGS=
+ GMP_CC=
+ else
+ AC_MSG_RESULT(yes [CC=$GMP_CC CFLAGS=$GMP_CFLAGS])
+ 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
+ ])
+fi
-dnl Configs for Windows DLLs (copied from MPFR)
+dnl Configs for Windows DLLs (copied from MPFR).
dnl libtool requires "-no-undefined" for win32 dll
dnl It also disables the tests involving the linking with LIBGMP if DLL
case $host in