resetting manifest requested domain to floor
[platform/upstream/mpc.git] / configure.ac
1 # Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA
2 #
3 # This file is part of GNU MPC.
4 #
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.
9 #
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
13 # more details.
14 #
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/ .
17
18
19 #                                               -*- Autoconf -*-
20 # Process this file with autoconf to produce a configure script.
21
22 AC_PREREQ(2.61)
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])
26
27 AM_INIT_AUTOMAKE([1.9 -Wall -Werror])
28 AM_MAINTAINER_MODE
29
30 USER_CC=$CC
31 USER_CFLAGS=$CFLAGS
32
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])
35
36 AC_CANONICAL_HOST
37 AC_CONFIG_MACRO_DIR([m4])
38
39
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"])
49 AC_ARG_WITH([mpfr],
50             [AC_HELP_STRING([--with-mpfr=DIR],
51                            [MPFR install directory])],
52             [
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"
56             else
57                AC_MSG_FAILURE([Do not use --with-mpfr and --with-mpfr-include/--with-mpfr-lib options simultaneously.])
58             fi
59             ])
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"])
68 AC_ARG_WITH([gmp],
69             [AC_HELP_STRING([--with-gmp=DIR],
70                            [GMP install directory])],
71             [
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"
75             else
76                AC_MSG_FAILURE([Do not use --with-gmp and --with-gmp-include/--with-gmp-lib options simultaneously.])
77             fi
78             ])
79 AC_ARG_ENABLE([logging],
80              [AC_HELP_STRING([--enable-logging],
81                              [enable logging of function calls to stderr (default = no)])],
82              [case $enableval in
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])) ;;
85                  no)  ;;
86                  *)   AC_MSG_ERROR([Bad value for --enable-logging: Use yes or no]) ;;
87               esac
88              ]
89              )
90 AC_ARG_ENABLE([valgrind-tests],
91              [AC_HELP_STRING([--enable-valgrind-tests],
92                              [run checks through valgrind (default = no)])],
93              [case $enableval in
94                  yes) gl_VALGRIND_TESTS ;;
95                  no)  ;;
96                  *)   AC_MSG_ERROR([Bad value for --enable-valgrind-tests: Use yes or no]) ;;
97               esac
98              ]
99              )
100
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
104 AC_PROG_EGREP
105 AC_PROG_SED
106 if test -z "$USER_CC" && test -z "$USER_CFLAGS"; then
107    MPC_GMP_CC_CFLAGS
108 fi
109
110 # Setup CC and CFLAGS
111 AC_PROG_CC
112 AC_LANG(C)
113
114 # Set up LibTool
115 LT_INIT
116
117 # Check GMP Header
118 AC_MSG_CHECKING(for gmp.h)
119 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
120 #include "gmp.h"
121 ]])],[AC_MSG_RESULT(yes)],[
122  AC_MSG_RESULT(no)
123  AC_MSG_ERROR([gmp.h cannot be found or is unusable.])
124 ])
125
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
133 fi
134
135
136 # Checks for header files.
137 AC_HEADER_STDC
138 AC_CHECK_HEADERS([locale.h inttypes.h stdint.h limits.h unistd.h sys/time.h])
139 AC_HEADER_TIME
140 MPC_COMPLEX_H
141
142 # Checks for typedefs, structures, and compiler characteristics.
143 AC_C_CONST
144 AC_TYPE_SIZE_T
145
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])])
150
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).])])
154
155 AC_MSG_CHECKING(for MPFR)
156 LIBS="-lmpfr $LIBS"
157 AC_LINK_IFELSE(
158         [AC_LANG_PROGRAM(
159                 [[#include "mpfr.h"]],
160                 [[mpfr_t x;  mpfr_init(x) ; mpfr_clear(x);]]
161         )],
162         [AC_MSG_RESULT(yes)],
163         [
164         AC_MSG_RESULT(no)
165         AC_MSG_ERROR([libmpfr not found or uses a different ABI (including static vs shared).])
166         ])
167
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)
175 AC_COMPILE_IFELSE(
176         [AC_LANG_SOURCE(
177         [[
178 #include "gmp.h"
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"
181 error
182 #endif
183         ]])],
184         [AC_MSG_RESULT(yes)],
185         [
186         AC_MSG_RESULT(no)
187         AC_MSG_ERROR([GMP version >= 4.3.2 required])
188         ])
189
190 # Check for a recent MPFR: we require MPFR 2.4.2 so that the tests
191 # in log.dat pass
192 # The same remark as above for GMP applies.
193 AC_MSG_CHECKING(for recent MPFR)
194 AC_COMPILE_IFELSE(
195         [AC_LANG_SOURCE(
196         [[
197 #include "mpfr.h"
198 #if (MPFR_VERSION < MPFR_VERSION_NUM (2,4,2))
199 # error "Minimal MPFR version is 2.4.2"
200 error
201 #endif
202         ]])],
203         [AC_MSG_RESULT(yes)],
204         [
205          AC_MSG_RESULT(no)
206          AC_MSG_ERROR([MPFR version >= 2.4.2 required])
207          ])
208
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],
213            [
214             AC_DEFINE(HAVE_LIBDL, 1, [Library dl present])
215             LIBS="-ldl $LIBS"
216             AC_TYPE_INTPTR_T
217             AC_LIBOBJ([logging])
218             AC_SUBST([MPC_LOG_H],[src/mpc-log.h])
219            ],
220            [AC_MSG_ERROR([Library dl not found, logging impossible])])
221        ]
222      )
223
224 # Configs for Windows DLLs
225 AC_SUBST(MPC_LDFLAGS)
226 AC_LIBTOOL_WIN32_DLL
227 case $host in
228   *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
229      MPC_WINDOWS
230 esac
231
232 # Checks for gcc version, result in variables MPC_GCC etc. inside config.log
233 AX_GCC_VERSION
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])
237
238 # Looks for svn version if the version string contains "dev"
239 MPC_SVNVERSION
240
241 AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/Makefile])
242 AC_OUTPUT