mpc.m4 revision 1.1.1.2
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(-Wno-long-long) 101 MPC_C_CHECK_FLAG(-Wall) 102 MPC_C_CHECK_FLAG(-Wextra) 103 MPC_C_CHECK_FLAG(-Wdeclaration-after-statement) 104 MPC_C_CHECK_FLAG(-Wshadow) 105 MPC_C_CHECK_FLAG(-Wstrict-prototypes) 106 MPC_C_CHECK_FLAG(-Wmissing-prototypes) 107 MPC_C_CHECK_FLAG(-Wno-unused-value) 108 fi 109 fi 110]) 111 112 113# 114# SYNOPSIS 115# 116# 117# MPC_GMP_CC_CFLAGS 118# 119# DESCRIPTION 120# 121# Checks if CC and CFLAGS can be extracted from gmp.h 122# essentially copied from mpfr 123# 124AC_DEFUN([MPC_GMP_CC_CFLAGS], [ 125 AC_MSG_CHECKING(for CC and CFLAGS in gmp.h) 126 # AC_PROG_CPP triggers the search for a C compiler; use hack instead 127 for cpp in /lib/cpp gcc cc c99 128 do 129 test $cpp = /lib/cpp || cpp="$cpp -E" 130 echo foo > conftest.c 131 if $cpp $CPPFLAGS conftest.c > /dev/null 2> /dev/null ; then 132 # Get CC 133 echo "#include \"gmp.h\"" > conftest.c 134 echo "MPFR_OPTION __GMP_CC" >> conftest.c 135 GMP_CC=`$cpp $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPFR_OPTION | $SED -e 's/MPFR_OPTION //g;s/ *" *//g'` 136 # Get CFLAGS 137 echo "#include \"gmp.h\"" > conftest.c 138 echo "MPFR_OPTION __GMP_CFLAGS" >> conftest.c 139 GMP_CFLAGS=`$cpp $CPPFLAGS conftest.c 2> /dev/null | $EGREP MPFR_OPTION | $SED -e 's/MPFR_OPTION //g;s/ *" *//g'` 140 break 141 fi 142 done 143 144 if test "x$GMP_CFLAGS" = "x__GMP_CFLAGS" -o "x$GMP_CC" = "x__GMP_CC" ; then 145 AC_MSG_RESULT(no) 146 GMP_CC= 147 GMP_CFLAGS= 148 else 149 AC_MSG_RESULT(yes [CC=$GMP_CC CFLAGS=$GMP_CFLAGS]) 150 fi 151 152 # Check for validity of CC and CFLAGS obtained from gmp.h 153 if test -n "$GMP_CC$GMP_CFLAGS" ; then 154 AC_MSG_CHECKING(for CC=$GMP_CC and CFLAGS=$GMP_CFLAGS) 155 echo "int main (void) { return 0; }" > conftest.c 156 if $GMP_CC $GMP_CFLAGS -o conftest conftest.c 2> /dev/null ; then 157 AC_MSG_RESULT(yes) 158 CC=$GMP_CC 159 CFLAGS=$GMP_CFLAGS 160 else 161 AC_MSG_RESULT(no) 162 fi 163 fi 164 165 rm -f conftest* 166]) 167 168 169# 170# SYNOPSIS 171# 172# 173# MPC_WINDOWS 174# 175# DESCRIPTION 176# 177# Additional checks on windows 178# libtool requires "-no-undefined" for win32 dll 179# It also disables the tests involving the linking with LIBGMP if DLL 180# 181AC_DEFUN([MPC_WINDOWS], [ 182 if test "$enable_shared" = yes; then 183 MPC_LDFLAGS="$MPC_LDFLAGS -no-undefined" 184 AC_MSG_CHECKING(for DLL/static gmp) 185 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 186#include "gmp.h" 187#if !__GMP_LIBGMP_DLL 188#error 189error 190#endif 191 ]], [[]])],[AC_MSG_RESULT(DLL)],[ 192 AC_MSG_RESULT(static) 193 AC_MSG_ERROR([gmp is not available as a DLL: use --enable-static --disable-shared]) ]) 194 AC_MSG_CHECKING(for DLL/static mpfr) 195 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 196#include "mpfr.h" 197#if !__GMP_LIBGMP_DLL 198#error 199error 200#endif 201 ]], [[]])],[AC_MSG_RESULT(DLL)],[ 202 AC_MSG_RESULT(static) 203 AC_MSG_ERROR([mpfr is not available as a DLL: use --enable-static --disable-shared]) ]) 204 else 205 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 206#include "gmp.h" 207#if __GMP_LIBGMP_DLL 208#error 209error 210#endif 211 ]], [[]])],[AC_MSG_RESULT(static)],[ 212 AC_MSG_RESULT(DLL) 213 AC_MSG_ERROR([gmp is only available as a DLL: use --disable-static --enable-shared]) ]) 214 fi 215 ;; 216]) 217 218 219# 220# SYNOPSIS 221# 222# 223# MPC_GITVERSION 224# 225# DESCRIPTION 226# 227# If current version string contains "dev", substitutes the short git hash 228# into GITVERSION 229# 230AC_DEFUN([MPC_GITVERSION], [ 231 if echo $VERSION | grep -c dev >/dev/null 2>&1 ; then 232 AC_CHECK_PROG([HASGIT], [git], [yes], [no]) 233 AS_IF([test "x$HASGIT" = "xyes"], [ 234 AC_MSG_CHECKING([for current git version]) 235 GITVERSION=esyscmd([git rev-parse --short HEAD]) 236 AC_SUBST([GITVERSION]) 237 AC_MSG_RESULT([$GITVERSION]) 238 ]) 239 fi 240]) 241