dnl Process this file with autoconf to produce a configure script. AC_COPYRIGHT([ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. The MPFR Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The MPFR Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ]) dnl If MPFR becomes GNU MPFR, change the MPFR below to GNU MPFR dnl Add check-news when it checks for more than 15 lines AC_INIT(MPFR, 2.2.0) AM_INIT_AUTOMAKE([no-define dist-zip dist-bzip2]) dnl AM_MAINTAINER_MODE dnl AC_CONFIG_HEADERS([mpfrconf.h:mpfrconf.in]) dnl Extra arguments to configure AC_ARG_WITH(gmp_include, [ --with-gmp-include=DIR GMP include directory ], CPPFLAGS="$CPPFLAGS -I$withval") AC_ARG_WITH(gmp_lib, [ --with-gmp-lib=DIR GMP lib directory ], LDFLAGS="-L$withval $LDFLAGS") AC_ARG_WITH(gmp_build, [ --with-gmp-build=DIR GMP build directory], [ CPPFLAGS="$CPPFLAGS -I$withval -I$withval/tune" LDFLAGS="-L$withval -L$withval/.libs -L$withval/tune/ $LDFLAGS" if test -r $withval/Makefile ; then GMP_CFLAGS=`grep -w "CFLAGS =" $withval/Makefile | sed 's/CFLAGS = //'` GMP_CC=`grep -w "CC =" $withval/Makefile | sed 's/CC = //'` fi ]) AC_ARG_WITH(gmp, [ --with-gmp=DIR GMP install directory ], [ CPPFLAGS="$CPPFLAGS -I$withval/include" LDFLAGS="-L$withval/lib $LDFLAGS" ]) AC_ARG_WITH(irix64, [ --with-irix64=on/off Irix 32/64 bits support ], with_irix64=$withval, with_irix64=off) AC_ARG_WITH(mulhigh_size, [ --with-mulhigh-size=NUM Internal threshold table for mulhigh], AC_DEFINE_UNQUOTED([MPFR_MULHIGH_SIZE],$withval, [Mulhigh size])) AC_ARG_ENABLE(assert, [ --enable-assert enable ASSERT checking [[default=no]]], [ case $enableval in yes) AC_DEFINE([WANT_ASSERT],1,[Want assertion]) ;; no) ;; full) AC_DEFINE([WANT_ASSERT],2,[Want assertion]) ;; *) AC_MSG_ERROR([bad value for --enable-assert: yes, no or full]) ;; esac]) AC_ARG_ENABLE(logging, [ --enable-logging enable MPFR Logging [[default=no]]], [ disable_gcc_format_warning=yes case $enableval in yes) AC_DEFINE([MPFR_USE_LOGGING],1,[Log what MPFR does]) ;; no) ;; *) AC_MSG_ERROR([bad value for --enable-logging: yes or no]) ;; esac]) AC_ARG_ENABLE(thread-safe, [ --enable-thread-safe Build MPFR as thread safe [[default=no]]], [ case $enableval in yes) AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe]) ;; no) ;; *) AC_MSG_ERROR([bad value for --enable-thread-safe: yes or no]) ;; esac]) test_CFLAGS=${CFLAGS+set} 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 dnl Autoconf detection AC_PROG_CC AC_LANG(C) 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([[]],[[]])], [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" #endif ]])], [ GCC=yes ]) fi dnl Check if compiler is ICC, and if such a case, disable GCC dnl And add some specific flags. dnl Don't add Warnings Flags (Otherwise you'll get more than 20000 warnings). dnl Add -long_double flags? Don't use -pc64 ! AC_MSG_CHECKING(for ICC) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if !defined(__ICC) # error "ICC Not Found" #endif ]], [[]])],[AC_MSG_RESULT(yes) GCC= CFLAGS="-fp_port -mp -wd1572 -wd265 -wd186 -wd239 $CFLAGS" ],[AC_MSG_RESULT(no)]) dnl If compiler is gcc, then use some specific flags. dnl But don't touch user other flags. if test "$test_CFLAGS" != set && test -n "$GCC"; then CFLAGS="-Wall -Wmissing-prototypes $CFLAGS" if test -n "$disable_gcc_format_warning" ; then CFLAGS="$CFLAGS -Wno-format" fi fi AM_C_PROTOTYPES AC_CANONICAL_HOST AC_CHECK_OS AC_CHECK_MACHTYPE dnl Set the OS-dependent flags. case $OS_TYPE in HP-UX*) if test -n "$GCC"; then LDFLAGS="-Xlinker +allowunsats $LDFLAGS" fi ;; IRIX64) if [[ "$irix64" = "on" ]]; then CFLAGS ="-mabi=64 $CFLAGS" else CFLAGS ="-mabi=n32 $CFLAGS" fi ;; esac AC_C_CONST AC_C_VOLATILE MPFR_CONFIGS dnl Must be checked with the LIBM dnl but we don't want to add the LIBM to MPFR dependency. dnl Can't use AC_CHECK_FUNCS since the function may be in LIBM but dnl not exported in math.h saved_LIBS="$LIBS" LIBS="$LIBS $MPFR_LIBM" dnl AC_CHECK_FUNCS([round trunc floor ceil nearbyint]) AC_MSG_CHECKING(for math/round) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include int f (double (*func)(double)) { return 0;} ]], [[ double a = 17.42; a = f (round); return 0; ]])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_ROUND, 1,[Have ISO-C99 round function]) ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING(for math/trunc) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include int f (double (*func)(double)) { return 0;} ]], [[ double a = 17.42; a = f(trunc); return 0; ]])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_TRUNC, 1,[Have ISO-C99 trunc function]) ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING(for math/floor) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include int f (double (*func)(double)) { return 0;} ]], [[ double a = 17.42; a = f(floor); return 0; ]])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_FLOOR, 1,[Have ISO-C99 floor function]) ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING(for math/ceil) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include int f (double (*func)(double)) { return 0;} ]], [[ double a = 17.42; a = f(ceil); return 0; ]])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_CEIL, 1,[Have ISO-C99 ceil function]) ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING(for math/rint) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include int f (double (*func)(double)) { return 0;} ]], [[ double a = 17.42; a = f(nearbyint); return 0; ]])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_NEARBYINT, 1,[Have ISO-C99 rint function]) ],[AC_MSG_RESULT(no)]) LIBS="$saved_LIBS" dnl dnl Setup LIBTOOL dnl dnl Currently libtool always want to detect a C++ and fortran compiler dnl Remove this by hacking a few: AC_PROG_CXX, AC_PROG_F77 are defined dnl but they are never called. Set with_tag to '' dnl Set am__fastdepCXX to something dnl Remove this when Libtool >= 2.0 is used if test -n "$variable_indefinie" ; then AC_PROG_CXX([g++]) AC_PROG_F77([g77]) AC_PROG_CXXCPP fi am__fastdepCXX_FALSE='#' if test "${with_tags+set}" != set; then with_tags= fi dnl Configs for Windows DLLs. dnl libtool requires "-no-undefined" for win32 dll AC_DISABLE_SHARED AC_LIBTOOL_WIN32_DLL case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) AC_MSG_CHECKING(for DLL/static GMP) if test "$enable_shared" = yes; then LDFLAGS="$LDFLAGS -no-undefined" dont_link_with_gmp="yes" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include "gmp.h" #if !__GMP_LIBGMP_DLL # error "Dead man" #endif ]], [[]])],[AC_MSG_RESULT(DLL)],[ AC_MSG_RESULT(static) AC_MSG_ERROR([gmp.h isn't a DLL: use --enable-static --disable-shared]) ]) else AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include "gmp.h" #if __GMP_LIBGMP_DLL # error "Dead man" #endif ]], [[]])],[AC_MSG_RESULT(static)],[ AC_MSG_RESULT(DLL) AC_MSG_ERROR([gmp.h is a DLL: use --disable-static --enable-shared]) ]) fi ;; esac dnl Finally set up LibTool AC_PROG_LIBTOOL dnl dnl Setup GMP detection dnl dnl Check GMP Header AC_MSG_CHECKING(for gmp.h) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #include "gmp.h" ]])],[AC_MSG_RESULT(yes)],[ AC_MSG_RESULT(no) AC_MSG_ERROR([gmp.h can't be found, or is unusable.]) ]) AC_MSG_CHECKING(for recent GMP) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #include "gmp.h" #if (__GNU_MP_VERSION*100+__GNU_MP_VERSION_MINOR*10 < 410) # error "min GMP version is 4.1.0" #endif ]])],[AC_MSG_RESULT(yes)],[ AC_MSG_RESULT(no) AC_MSG_ERROR([GMP 4.1.0 min required]) ]) dnl Check if we can use internal header files of GMP. AC_MSG_CHECKING(for gmp internal files) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" ]])],[ AC_MSG_RESULT(yes) AC_DEFINE([MPFR_HAVE_GMP_IMPL],1,[Use GMP Internal Files]) gmp_internal_file_check=yes ],[ AC_MSG_RESULT(no) AC_FUNC_ALLOCA ]) dnl Check for valid BITS_PER_MP_LIMB and BYTES_PER_MP_LIMB dnl This test doesn't need to link with libgmp (at least it should). if test -n "$gmp_internal_file_check" ; then AC_MSG_CHECKING(for valid BITS_PER_MP_LIMB and BYTES_PER_MP_LIMB) AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include #include "gmp.h" #include "gmp-impl.h" ]], [[ return BITS_PER_MP_LIMB == BYTES_PER_MP_LIMB * CHAR_BIT && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB ? 0 : 1; ]])], [AC_MSG_RESULT(yes)], [ AC_MSG_RESULT(no) AC_MSG_ERROR([BITS_PER_MP_LIMB or BYTES_PER_MP_LIMB are incorrect. You probably need to change some of the GMP or MPFR compile options.])], [AC_MSG_RESULT([can't test])]) fi dnl We really need to link using libtool. But it is impossible with the current dnl libtool. dnl The practical problems appear only under MS Windows. The best solution dnl is to believe it works under MSWin. if test "$dont_link_with_gmp" = yes ; then LIBS="-lgmp $LIBS" else dnl Check if we can link with GMP AC_CHECK_LIB(gmp, __gmp_version, [LIBS="-lgmp $LIBS"], [AC_MSG_ERROR(libgmp not found)]) dnl Check if we can use mpn_sub_nc if test -n "$gmp_internal_file_check" ; then AC_CHECK_FUNC([__gmpn_sub_nc], [AC_DEFINE([MPFR_HAVE_MPN_SUB_NC],1,[Function mpn_sub_nc is available])]) fi dnl Check for corresponding 'gmp.h' and libgmp.a AC_MSG_CHECKING(if gmp.h version and libgmp version are the same) AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include #include #include "gmp.h" ]], [[ char buffer[100]; if (__GNU_MP_VERSION_PATCHLEVEL != 0) sprintf (buffer, "%d.%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL); else sprintf (buffer, "%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR); printf ("(%s/%s) ", buffer, gmp_version); return (strcmp (buffer, gmp_version) != 0) ? 1 : 0; ]])], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) AC_MSG_WARN(['gmp.h' and 'libgmp' seems to have different versions.])], AC_MSG_RESULT([can't test]) ) dnl End of tests which need to link with GMP. fi dnl Remove also many MACROS (AC_DEFINE) which are unused by MPFR dnl and polluate (and slow down) the build. if test -f confdefs.h; then sed '/#define PACKAGE_/d' confdefs.tmp sed '/#define HAVE_STRING/d' confdefs.h sed '/#define HAVE_ALLOCA /d' confdefs.tmp sed '/#define HAVE_DLFCN_H/d' confdefs.h sed '/#define HAVE_MEM/d' confdefs.tmp sed '/#define STDC_HEADERS/d' confdefs.h sed '/#define HAVE_STRTOL/d' confdefs.tmp sed '/#define HAVE_STDLIB_H/d' confdefs.h sed '/#define HAVE_UNISTD_H/d' confdefs.tmp sed '/#define HAVE_STDC_HEADERS/d' confdefs.h sed '/#define HAVE_LONG_DOUBLE/d' confdefs.tmp sed '/#define HAVE_SYS_STAT_H/d' confdefs.h sed '/#define HAVE_SYS_TYPES_H/d' confdefs.tmp sed '/#define PROTOTYPES/d' confdefs.h sed '/#define __PROTOTYPES/d' confdefs.tmp mv confdefs.tmp confdefs.h fi dnl Output AC_CONFIG_FILES([Makefile tests/Makefile mparam.h:mparam_h.in]) AC_OUTPUT dnl NEWS README AUTHORS Changelog