1# Copyright (C) 2008, 2009, 2010, 2011, 2012, 2014, 2016, 2017, 2018, 2020, 2022 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 22AC_PREREQ([2.69]) 23AC_INIT([mpc],[1.3.1],[mpc-discuss@inria.fr]) 24AC_CONFIG_SRCDIR([src/mpc-impl.h]) 25AC_CONFIG_AUX_DIR([build-aux]) 26AC_CONFIG_HEADERS([config.h]) 27 28AM_INIT_AUTOMAKE 29AM_MAINTAINER_MODE 30 31USER_CC=$CC 32USER_CFLAGS=$CFLAGS 33 34AC_CANONICAL_HOST 35AC_CONFIG_MACRO_DIR([m4]) 36 37 38# Extra arguments to configure 39AC_ARG_WITH([mpfr_include], 40 [AS_HELP_STRING([--with-mpfr-include=DIR], 41 [MPFR include directory])], 42 [CPPFLAGS="-I$withval $CPPFLAGS"]) 43AC_ARG_WITH([mpfr_lib], 44 [AS_HELP_STRING([--with-mpfr-lib=DIR], 45 [MPFR lib directory])], 46 [LDFLAGS="-L$withval $LDFLAGS"]) 47AC_ARG_WITH([mpfr], 48 [AS_HELP_STRING([--with-mpfr=DIR], 49 [MPFR install directory])], 50 [ 51 if test -z "$with_mpfr_include" -a -z "$with_mpfr_lib" ; then 52 CPPFLAGS="-I$withval/include $CPPFLAGS" 53 LDFLAGS="-L$withval/lib $LDFLAGS" 54 else 55 AC_MSG_FAILURE([Do not use --with-mpfr and --with-mpfr-include/--with-mpfr-lib options simultaneously.]) 56 fi 57 ]) 58AC_ARG_WITH([gmp_include], 59 [AS_HELP_STRING([--with-gmp-include=DIR], 60 [GMP include directory])], 61 [CPPFLAGS="-I$withval $CPPFLAGS"]) 62AC_ARG_WITH([gmp_lib], 63 [AS_HELP_STRING([--with-gmp-lib=DIR], 64 [GMP lib directory])], 65 [LDFLAGS="-L$withval $LDFLAGS"]) 66AC_ARG_WITH([gmp], 67 [AS_HELP_STRING([--with-gmp=DIR], 68 [GMP install directory])], 69 [ 70 if test -z "$with_gmp_lib" -a -z "$with_gmp_include" ; then 71 CPPFLAGS="-I$withval/include $CPPFLAGS" 72 LDFLAGS="-L$withval/lib $LDFLAGS" 73 else 74 AC_MSG_FAILURE([Do not use --with-gmp and --with-gmp-include/--with-gmp-lib options simultaneously.]) 75 fi 76 ]) 77AC_ARG_ENABLE([logging], 78 [AS_HELP_STRING([--enable-logging], 79 [enable logging of function calls to stderr (default = no)])], 80 [case $enableval in 81 yes) AS_IF([test "x$enable_shared" = "xno"], 82 AC_MSG_ERROR([Logging works only with shared libraries; do not mix --enable-logging and --disable-shared])) ;; 83 no) ;; 84 *) AC_MSG_ERROR([Bad value for --enable-logging: Use yes or no]) ;; 85 esac 86 ] 87 ) 88AC_ARG_ENABLE([valgrind-tests], 89 [AS_HELP_STRING([--enable-valgrind-tests], 90 [run checks through valgrind (default = no)])], 91 [case $enableval in 92 yes) gl_VALGRIND_TESTS ;; 93 no) ;; 94 *) AC_MSG_ERROR([Bad value for --enable-valgrind-tests: Use yes or no]) ;; 95 esac 96 ] 97 ) 98 99# Check for CC and CFLAGS in gmp.h unless the user specified one of them 100# look for EGREP and SED here, see continued problem 101# at https://sympa.inria.fr/sympa/arc/mpc-discuss/2012-01/msg00001.html 102AC_PROG_EGREP 103AC_PROG_SED 104if test -z "$USER_CC" && test -z "$USER_CFLAGS"; then 105 MPC_GMP_CC_CFLAGS 106fi 107 108# Setup CC and CFLAGS 109AC_PROG_CC 110AC_LANG(C) 111 112# automake 1.12 seems to require this, but automake 1.11 doesn't recognize it 113m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) 114 115# Set up LibTool 116LT_INIT(win32-dll) 117 118# Check GMP Header 119AC_MSG_CHECKING(for gmp.h) 120AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 121#include "gmp.h" 122]])],[AC_MSG_RESULT(yes)],[ 123 AC_MSG_RESULT(no) 124 AC_MSG_ERROR([gmp.h cannot be found or is unusable.]) 125]) 126 127# Checks for header files. 128AC_CHECK_HEADERS([inttypes.h stdint.h sys/time.h]) 129MPC_COMPLEX_H 130 131# Checks for typedefs, structures, and compiler characteristics. 132AC_C_CONST 133AC_TYPE_SIZE_T 134 135# Checks for libraries. 136AC_CHECK_FUNCS([gettimeofday localeconv setlocale getrusage]) 137AC_CHECK_FUNCS([dup dup2],, 138 [AC_DEFINE([MPC_NO_STREAM_REDIRECTION],1,[Do not check mpc_out_str on stdout])]) 139 140AC_CHECK_LIB([m], [fesetround]) 141# Warning: up from autoconf 2.70, the following test fails with C++ 142# see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=992981 143AC_CHECK_LIB([gmp], [__gmpz_init], 144 [LIBS="-lgmp $LIBS"], 145 [AC_MSG_ERROR([libgmp not found or uses a different ABI (including static vs shared).])]) 146 147AC_MSG_CHECKING(for MPFR) 148LIBS="-lmpfr $LIBS" 149AC_LINK_IFELSE( 150 [AC_LANG_PROGRAM( 151 [[#include "mpfr.h"]], 152 [[mpfr_t x; mpfr_init(x) ; mpfr_clear(x);]] 153 )], 154 [AC_MSG_RESULT(yes)], 155 [ 156 AC_MSG_RESULT(no) 157 AC_MSG_ERROR([libmpfr not found or uses a different ABI (including static vs shared).]) 158 ]) 159 160# Check for a recent GMP 161# We only guarantee that with a *functional* and recent enough GMP version, 162# MPC will compile; we do not guarantee that GMP will compile. 163# In particular fat builds are broken in GMP 5.0.0 164# (at least on 64-bit Core 2 under GNU/Linux), 165# see http://gmplib.org/list-archives/gmp-bugs/2011-August/002345.html. 166AC_MSG_CHECKING(for recent GMP) 167AC_COMPILE_IFELSE( 168 [AC_LANG_SOURCE( 169 [[ 170#include "gmp.h" 171#if (__GNU_MP_VERSION*100 + __GNU_MP_VERSION_MINOR*10 + __GNU_MP_VERSION_PATCHLEVEL < 500) 172# error "Minimal GMP version is 5.0.0" 173error 174#endif 175 ]])], 176 [AC_MSG_RESULT(yes)], 177 [ 178 AC_MSG_RESULT(no) 179 AC_MSG_ERROR([GMP version >= 5.0.0 required]) 180 ]) 181 182# Check for a recent MPFR: we require MPFR 4.1.0 183# The same remark as above for GMP applies. 184AC_MSG_CHECKING(for recent MPFR) 185AC_COMPILE_IFELSE( 186 [AC_LANG_SOURCE( 187 [[ 188#include "mpfr.h" 189#if (MPFR_VERSION < MPFR_VERSION_NUM (4,1,0)) 190# error "Minimal MPFR version is 4.1.0" 191error 192#endif 193 ]])], 194 [AC_MSG_RESULT(yes)], 195 [ 196 AC_MSG_RESULT(no) 197 AC_MSG_ERROR([MPFR version >= 4.1.0 required]) 198 ]) 199 200# Check for logging feature 201AS_IF([test "x$enable_logging" = "xyes"], 202 [AC_CHECK_HEADERS([dlfcn.h]) 203 AC_CHECK_LIB([dl],[dlsym], 204 [ 205 AC_DEFINE(HAVE_LIBDL, 1, [Library dl present]) 206 LIBS="-ldl $LIBS" 207 AC_TYPE_INTPTR_T 208 AC_LIBOBJ([logging]) 209 AC_SUBST([MPC_LOG_H],[src/mpc-log.h]) 210 ], 211 [AC_MSG_ERROR([Library dl not found, logging impossible])]) 212 ] 213 ) 214 215# Configs for Windows DLLs 216AC_SUBST(MPC_LDFLAGS) 217case $host in 218 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) 219 MPC_WINDOWS 220esac 221 222# Checks for gcc version, result in variables MPC_GCC etc. inside config.log 223AX_GCC_VERSION 224AC_DEFINE_UNQUOTED([MPC_GCC], ["$GCC"], [Gcc yes or no]) 225AC_DEFINE_UNQUOTED([MPC_CC], ["$CC"], [C compiler]) 226AC_DEFINE_UNQUOTED([MPC_GCC_VERSION], ["$GCC_VERSION"], [Version of gcc]) 227 228# Looks for short git hash if the version string contains "dev" 229MPC_GITVERSION 230 231AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/Makefile tools/Makefile tools/bench/Makefile tools/mpcheck/Makefile]) 232AC_OUTPUT 233