3 # Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA
5 # This file is part of GNU MPC.
7 # GNU MPC is free software; you can redistribute it and/or modify it under
8 # the terms of the GNU Lesser General Public License as published by the
9 # Free Software Foundation; either version 3 of the License, or (at your
10 # option) any later version.
12 # GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with this program. If not, see http://www.gnu.org/licenses/ .
29 # Check whether complex.h is usable; if yes, define HAVE_COMPLEX_H.
31 AC_DEFUN([MPC_COMPLEX_H], [
39 [[#include <complex.h>]],
40 [[complex double x = 1.0 + 2.0 * I; return (creal (x) + cimag (x));]]
45 AC_SEARCH_LIBS([creal], [m])
47 AC_MSG_CHECKING([whether creal, cimag and I can be used])
52 AC_DEFINE([HAVE_COMPLEX_H], [1], [complex.h present and usable])
55 AC_MSG_RESULT([no, build without support for C complex numbers])
67 # MPC_C_CHECK_FLAG([FLAG,ACCUMULATOR])
71 # Checks if the C compiler accepts the flag FLAG
72 # If yes, adds it to CFLAGS.
74 AC_DEFUN([MPC_C_CHECK_FLAG], [
75 AX_C_CHECK_FLAG($1,,,[CFLAGS="$CFLAGS $1"])
83 # MPC_C_CHECK_WARNINGFLAGS
87 # For development version only: Checks if gcc accepts warning flags.
88 # Adds accepted ones to CFLAGS.
90 AC_DEFUN([MPC_C_CHECK_WARNINGCFLAGS], [
91 AC_REQUIRE([AC_PROG_GREP])
92 if echo $VERSION | grep -c dev >/dev/null 2>&1 ; then
93 if test "x$GCC" = "xyes" -a "x$compiler" != "xicc" -a "x$compiler" != "xg++"; then
94 # enable -Werror for myself (Andreas Enge)
95 if test "x$USER" = "xenge"; then
96 MPC_C_CHECK_FLAG(-Werror)
99 MPC_C_CHECK_FLAG(-std=c99)
100 MPC_C_CHECK_FLAG(-pedantic)
101 MPC_C_CHECK_FLAG(-Wno-long-long)
102 MPC_C_CHECK_FLAG(-Wall)
103 MPC_C_CHECK_FLAG(-Wextra)
104 MPC_C_CHECK_FLAG(-Wdeclaration-after-statement)
105 MPC_C_CHECK_FLAG(-Wundef)
106 MPC_C_CHECK_FLAG(-Wshadow)
107 MPC_C_CHECK_FLAG(-Wstrict-prototypes)
108 MPC_C_CHECK_FLAG(-Wmissing-prototypes)
109 MPC_C_CHECK_FLAG(-Wno-unused-value)
123 # Checks if CC and CFLAGS can be extracted from gmp.h
124 # essentially copied from mpfr
126 AC_DEFUN([MPC_GMP_CC_CFLAGS], [
127 AC_MSG_CHECKING(for CC and CFLAGS in gmp.h)
128 # AC_PROG_CPP triggers the search for a C compiler; use hack instead
129 for cpp in /lib/cpp gcc cc c99
131 test $cpp = /lib/cpp || cpp="$cpp -E"
132 echo foo > conftest.c
133 if $cpp $CPPFLAGS conftest.c > /dev/null 2> /dev/null ; then
135 echo "#include \"gmp.h\"" > conftest.c
136 echo "MPFR_OPTION __GMP_CC" >> conftest.c
137 GMP_CC=`$cpp $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPFR_OPTION | $SED -e 's/MPFR_OPTION //g;s/ *" *//g'`
139 echo "#include \"gmp.h\"" > conftest.c
140 echo "MPFR_OPTION __GMP_CFLAGS" >> conftest.c
141 GMP_CFLAGS=`$cpp $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPFR_OPTION | $SED -e 's/MPFR_OPTION //g;s/ *" *//g'`
146 if test "x$GMP_CFLAGS" = "x__GMP_CFLAGS" -o "x$GMP_CC" = "x__GMP_CC" ; then
151 AC_MSG_RESULT(yes [CC=$GMP_CC CFLAGS=$GMP_CFLAGS])
154 # Check for validity of CC and CFLAGS obtained from gmp.h
155 if test -n "$GMP_CC$GMP_CFLAGS" ; then
156 AC_MSG_CHECKING(for CC=$GMP_CC and CFLAGS=$GMP_CFLAGS)
157 echo "int main (void) { return 0; }" > conftest.c
158 if $GMP_CC $GMP_CFLAGS -o conftest conftest.c 2> /dev/null ; then
179 # Additional checks on windows
180 # libtool requires "-no-undefined" for win32 dll
181 # It also disables the tests involving the linking with LIBGMP if DLL
183 AC_DEFUN([MPC_WINDOWS], [
184 if test "$enable_shared" = yes; then
185 MPC_LDFLAGS="$MPC_LDFLAGS -no-undefined"
186 AC_MSG_CHECKING(for DLL/static gmp)
187 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
189 #if !__GMP_LIBGMP_DLL
193 ]], [[]])],[AC_MSG_RESULT(DLL)],[
194 AC_MSG_RESULT(static)
195 AC_MSG_ERROR([gmp is not available as a DLL: use --enable-static --disable-shared]) ])
196 AC_MSG_CHECKING(for DLL/static mpfr)
197 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
199 #if !__GMP_LIBGMP_DLL
203 ]], [[]])],[AC_MSG_RESULT(DLL)],[
204 AC_MSG_RESULT(static)
205 AC_MSG_ERROR([mpfr is not available as a DLL: use --enable-static --disable-shared]) ])
207 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
213 ]], [[]])],[AC_MSG_RESULT(static)],[
215 AC_MSG_ERROR([gmp is only available as a DLL: use --disable-static --enable-shared]) ])
229 # If current version string contains "dev", substitutes svn version into
232 AC_DEFUN([MPC_SVNVERSION], [
233 if echo $VERSION | grep -c dev >/dev/null 2>&1 ; then
234 AC_CHECK_PROG([HASSVNVERSION], [svnversion], [yes], [no])
235 AS_IF([test "x$HASSVNVERSION" = "xyes"], [
236 AC_MSG_CHECKING([for current svn version])
237 SVNVERSION=esyscmd([svnversion -n])
238 AC_SUBST([SVNVERSION])
239 AC_MSG_RESULT([$SVNVERSION])