mpc.m4 revision 1.1.1.1
1# mpc.m4 2# 3# Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA 4# 5# This file is part of GNU MPC. 6# 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. 11# 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 15# more details. 16# 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/ . 19 20 21# 22# SYNOPSIS 23# 24# 25# MPC_COMPLEX_H 26# 27# DESCRIPTION 28# 29# Check whether complex.h is usable; if yes, define HAVE_COMPLEX_H. 30# 31AC_DEFUN([MPC_COMPLEX_H], [ 32 AC_CHECK_HEADER( 33 [complex.h], 34 [ 35 m4_define( 36 [MPC_CONFTEST], 37 [ 38 AC_LANG_PROGRAM( 39 [[#include <complex.h>]], 40 [[complex double x = 1.0 + 2.0 * I; return (creal (x) + cimag (x));]] 41 ) 42 ] 43 ) 44 45 AC_SEARCH_LIBS([creal], [m]) 46# needed on Solaris 47 AC_MSG_CHECKING([whether creal, cimag and I can be used]) 48 AC_LINK_IFELSE( 49 [MPC_CONFTEST], 50 [ 51 AC_MSG_RESULT([yes]) 52 AC_DEFINE([HAVE_COMPLEX_H], [1], [complex.h present and usable]) 53 ], 54 [ 55 AC_MSG_RESULT([no, build without support for C complex numbers]) 56 ] 57 ) 58 ] 59 ) 60]) 61 62 63# 64# SYNOPSIS 65# 66# 67# MPC_C_CHECK_FLAG([FLAG,ACCUMULATOR]) 68# 69# DESCRIPTION 70# 71# Checks if the C compiler accepts the flag FLAG 72# If yes, adds it to CFLAGS. 73 74AC_DEFUN([MPC_C_CHECK_FLAG], [ 75 AX_C_CHECK_FLAG($1,,,[CFLAGS="$CFLAGS $1"]) 76]) 77 78 79# 80# SYNOPSIS 81# 82# 83# MPC_C_CHECK_WARNINGFLAGS 84# 85# DESCRIPTION 86# 87# For development version only: Checks if gcc accepts warning flags. 88# Adds accepted ones to CFLAGS. 89# 90AC_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) 97 fi 98 MPC_C_CHECK_FLAG(-g) 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) 110 fi 111 fi 112]) 113 114 115# 116# SYNOPSIS 117# 118# 119# MPC_GMP_CC_CFLAGS 120# 121# DESCRIPTION 122# 123# Checks if CC and CFLAGS can be extracted from gmp.h 124# essentially copied from mpfr 125# 126AC_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 130 do 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 134 # Get CC 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'` 138 # Get CFLAGS 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'` 142 break 143 fi 144 done 145 146 if test "x$GMP_CFLAGS" = "x__GMP_CFLAGS" -o "x$GMP_CC" = "x__GMP_CC" ; then 147 AC_MSG_RESULT(no) 148 GMP_CC= 149 GMP_CFLAGS= 150 else 151 AC_MSG_RESULT(yes [CC=$GMP_CC CFLAGS=$GMP_CFLAGS]) 152 fi 153 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 159 AC_MSG_RESULT(yes) 160 CC=$GMP_CC 161 CFLAGS=$GMP_CFLAGS 162 else 163 AC_MSG_RESULT(no) 164 fi 165 fi 166 167 rm -f conftest* 168]) 169 170 171# 172# SYNOPSIS 173# 174# 175# MPC_WINDOWS 176# 177# DESCRIPTION 178# 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 182# 183AC_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([[ 188#include "gmp.h" 189#if !__GMP_LIBGMP_DLL 190#error 191error 192#endif 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([[ 198#include "mpfr.h" 199#if !__GMP_LIBGMP_DLL 200#error 201error 202#endif 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]) ]) 206 else 207 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 208#include "gmp.h" 209#if __GMP_LIBGMP_DLL 210#error 211error 212#endif 213 ]], [[]])],[AC_MSG_RESULT(static)],[ 214 AC_MSG_RESULT(DLL) 215 AC_MSG_ERROR([gmp is only available as a DLL: use --disable-static --enable-shared]) ]) 216 fi 217 ;; 218]) 219 220 221# 222# SYNOPSIS 223# 224# 225# MPC_SVNVERSION 226# 227# DESCRIPTION 228# 229# If current version string contains "dev", substitutes svn version into 230# SVNVERSION 231# 232AC_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]) 240 ]) 241 fi 242]) 243