1 # Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA
3 # This file is part of GNU MPC.
5 # GNU MPC is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the
7 # Free Software Foundation; either version 3 of the License, or (at your
8 # option) any later version.
10 # GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see http://www.gnu.org/licenses/ .
20 # Process this file with autoconf to produce a configure script.
23 AC_INIT(mpc, 1.0, mpc-discuss@lists.gforge.inria.fr)
24 AC_CONFIG_SRCDIR([src/mpc-impl.h])
25 AC_CONFIG_HEADER([config.h])
27 AM_INIT_AUTOMAKE([1.9 -Wall -Werror])
33 # automake 1.12 seems to require this, but automake 1.11 doesn't recognize it
34 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
37 AC_CONFIG_MACRO_DIR([m4])
40 # Extra arguments to configure
41 AC_ARG_WITH([mpfr_include],
42 [AC_HELP_STRING([--with-mpfr-include=DIR],
43 [MPFR include directory])],
44 [CPPFLAGS="-I$withval $CPPFLAGS"])
45 AC_ARG_WITH([mpfr_lib],
46 [AC_HELP_STRING([--with-mpfr-lib=DIR],
47 [MPFR lib directory])],
48 [LDFLAGS="-L$withval $LDFLAGS"])
50 [AC_HELP_STRING([--with-mpfr=DIR],
51 [MPFR install directory])],
53 if test -z "$with_mpfr_include" -a -z "$with_mpfr_lib" ; then
54 CPPFLAGS="-I$withval/include $CPPFLAGS"
55 LDFLAGS="-L$withval/lib $LDFLAGS"
57 AC_MSG_FAILURE([Do not use --with-mpfr and --with-mpfr-include/--with-mpfr-lib options simultaneously.])
60 AC_ARG_WITH([gmp_include],
61 [AC_HELP_STRING([--with-gmp-include=DIR],
62 [GMP include directory])],
63 [CPPFLAGS="-I$withval $CPPFLAGS"])
64 AC_ARG_WITH([gmp_lib],
65 [AC_HELP_STRING([--with-gmp-lib=DIR],
66 [GMP lib directory])],
67 [LDFLAGS="-L$withval $LDFLAGS"])
69 [AC_HELP_STRING([--with-gmp=DIR],
70 [GMP install directory])],
72 if test -z "$with_gmp_lib" -a -z "$with_gmp_include" ; then
73 CPPFLAGS="-I$withval/include $CPPFLAGS"
74 LDFLAGS="-L$withval/lib $LDFLAGS"
76 AC_MSG_FAILURE([Do not use --with-gmp and --with-gmp-include/--with-gmp-lib options simultaneously.])
79 AC_ARG_ENABLE([logging],
80 [AC_HELP_STRING([--enable-logging],
81 [enable logging of function calls to stderr (default = no)])],
83 yes) AS_IF([test "x$enable_shared" = "xno"],
84 AC_MSG_ERROR([Logging works only with shared libraries; do not mix --enable-logging and --disable-shared])) ;;
86 *) AC_MSG_ERROR([Bad value for --enable-logging: Use yes or no]) ;;
90 AC_ARG_ENABLE([valgrind-tests],
91 [AC_HELP_STRING([--enable-valgrind-tests],
92 [run checks through valgrind (default = no)])],
94 yes) gl_VALGRIND_TESTS ;;
96 *) AC_MSG_ERROR([Bad value for --enable-valgrind-tests: Use yes or no]) ;;
101 # Check for CC and CFLAGS in gmp.h unless the user specified one of them
102 # look for EGREP and SED here, see continued problem
103 # at http://lists.gforge.inria.fr/pipermail/mpc-discuss/2012-January/001056.html
106 if test -z "$USER_CC" && test -z "$USER_CFLAGS"; then
110 # Setup CC and CFLAGS
118 AC_MSG_CHECKING(for gmp.h)
119 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
121 ]])],[AC_MSG_RESULT(yes)],[
123 AC_MSG_ERROR([gmp.h cannot be found or is unusable.])
126 # Check (only in development versions) if the compiler accepts warning
127 # flags and add them to CFLAGS
128 # Note: don't do this if the user defined CFLAGS, since adding new flags
129 # might override the user's settings, see
130 # http://lists.gforge.inria.fr/pipermail/mpc-discuss/2012-May/001115.html
131 if test -z "$USER_CFLAGS"; then
132 MPC_C_CHECK_WARNINGCFLAGS
136 # Checks for header files.
138 AC_CHECK_HEADERS([locale.h inttypes.h stdint.h limits.h unistd.h sys/time.h])
142 # Checks for typedefs, structures, and compiler characteristics.
146 # Checks for libraries.
147 AC_CHECK_FUNCS([gettimeofday localeconv setlocale])
148 AC_CHECK_FUNCS([dup dup2],,
149 [AC_DEFINE([MPC_NO_STREAM_REDIRECTION],1,[Do not check mpc_out_str on stdout])])
151 AC_CHECK_LIB([gmp], [__gmpz_init],
152 [LIBS="-lgmp $LIBS"],
153 [AC_MSG_ERROR([libgmp not found or uses a different ABI (including static vs shared).])])
155 AC_MSG_CHECKING(for MPFR)
159 [[#include "mpfr.h"]],
160 [[mpfr_t x; mpfr_init(x) ; mpfr_clear(x);]]
162 [AC_MSG_RESULT(yes)],
165 AC_MSG_ERROR([libmpfr not found or uses a different ABI (including static vs shared).])
168 # Check for a recent GMP
169 # We only guarantee that with a *functional* and recent enough GMP version,
170 # MPC will compile; we do not guarantee that GMP will compile.
171 # In particular fat builds are broken in GMP 4.3.2 and GMP 5.0.0
172 # (at least on 64-bit Core 2 under GNU/Linux),
173 # see http://gmplib.org/list-archives/gmp-bugs/2011-August/002345.html.
174 AC_MSG_CHECKING(for recent GMP)
179 #if (__GNU_MP_VERSION*100 + __GNU_MP_VERSION_MINOR*10 + __GNU_MP_VERSION_PATCHLEVEL < 432)
180 # error "Minimal GMP version is 4.3.2"
184 [AC_MSG_RESULT(yes)],
187 AC_MSG_ERROR([GMP version >= 4.3.2 required])
190 # Check for a recent MPFR: we require MPFR 2.4.2 so that the tests
192 # The same remark as above for GMP applies.
193 AC_MSG_CHECKING(for recent MPFR)
198 #if (MPFR_VERSION < MPFR_VERSION_NUM (2,4,2))
199 # error "Minimal MPFR version is 2.4.2"
203 [AC_MSG_RESULT(yes)],
206 AC_MSG_ERROR([MPFR version >= 2.4.2 required])
209 # Check for logging feature
210 AS_IF([test "x$enable_logging" = "xyes"],
211 [AC_CHECK_HEADERS([dlfcn.h])
212 AC_CHECK_LIB([dl],[dlsym],
214 AC_DEFINE(HAVE_LIBDL, 1, [Library dl present])
218 AC_SUBST([MPC_LOG_H],[src/mpc-log.h])
220 [AC_MSG_ERROR([Library dl not found, logging impossible])])
224 # Configs for Windows DLLs
225 AC_SUBST(MPC_LDFLAGS)
228 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
232 # Checks for gcc version, result in variables MPC_GCC etc. inside config.log
234 AC_DEFINE_UNQUOTED([MPC_GCC], ["$GCC"], [Gcc yes or no])
235 AC_DEFINE_UNQUOTED([MPC_CC], ["$CC"], [C compiler])
236 AC_DEFINE_UNQUOTED([MPC_GCC_VERSION], ["$GCC_VERSION"], [Version of gcc])
238 # Looks for svn version if the version string contains "dev"
241 AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/Makefile])