1# Copyright (C) 2013, 2014, 2015, 2016, 2018, 2019, 2020, 2021 INRIA 2# 3# This file is part of CMH. 4# 5# CMH is free software; you can redistribute it and/or modify it under 6# the terms of the GNU 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# CMH 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 General Public License for 13# more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see http://www.gnu.org/licenses/ . 17 18AC_PREREQ([2.69]) 19AC_INIT([cmh],[1.1.0],[andreas.enge@inria.fr]) 20AC_CONFIG_SRCDIR([src/cm2.h]) 21AC_CONFIG_AUX_DIR([config]) 22AC_CONFIG_HEADER([config.h]) 23 24# In development checkouts, the scm-level version is used, and can be 25# update in-place by the config/checkversion.sh script. The data here, 26# for non-development tarballs, is superseded by the exported version 27# number. 28if [[ -f $srcdir/version_stamp.sh ]] ; then 29 source $srcdir/version_stamp.sh 30fi 31AC_SUBST([CMH_LONG_VERSION], [AC_PACKAGE_VERSION]) 32 33AM_INIT_AUTOMAKE([1.9 -Wall -Werror]) 34# AM_MAINTAINER_MODE([enable]) 35 36AC_CANONICAL_HOST 37AC_CONFIG_MACRO_DIR([config/m4]) 38 39# Regarding the amount of autotools crap: we have to live with aclocal at 40# the top level, see: 41# http://lists.gnu.org/archive/html/automake/2013-04/msg00021.html 42# 43# For autom4te.cache, I understand that it's used very early on, has a 44# potential to only very marginally speedup the config step (here 45# we don't care), and can be disabled altogether by tweaking ~/.autom4te.cfg 46 47# Extra arguments to configure 48AC_ARG_WITH([gmp], 49 [AS_HELP_STRING([--with-gmp=DIR],[GMP installation directory])], 50 [ 51 CPPFLAGS="$CPPFLAGS -I$withval/include" 52 LDFLAGS="$LDFLAGS -L$withval/lib" 53 ]) 54AC_ARG_WITH([mpfr], 55 [AS_HELP_STRING([--with-mpfr=DIR],[MPFR installation directory])], 56 [ 57 CPPFLAGS="$CPPFLAGS -I$withval/include" 58 LDFLAGS="$LDFLAGS -L$withval/lib" 59 ]) 60AC_ARG_WITH([mpc], 61 [AS_HELP_STRING([--with-mpc=DIR],[MPC installation directory])], 62 [ 63 CPPFLAGS="$CPPFLAGS -I$withval/include" 64 LDFLAGS="$LDFLAGS -L$withval/lib" 65 ]) 66AC_ARG_WITH([mpfrcx], 67 [AS_HELP_STRING([--with-mpfrcx=DIR],[MPFRCX installation directory])], 68 [ 69 CPPFLAGS="$CPPFLAGS -I$withval/include" 70 LDFLAGS="$LDFLAGS -L$withval/lib" 71 ]) 72AC_ARG_WITH([fplll], 73 [AS_HELP_STRING([--with-fplll=DIR],[FPLLL installation directory])], 74 [ 75 CPPFLAGS="$CPPFLAGS -I$withval/include" 76 LDFLAGS="$LDFLAGS -L$withval/lib" 77 ]) 78AC_ARG_WITH([pari], 79 [AS_HELP_STRING([--with-pari=DIR],[PARI installation directory])], 80 [ 81 AC_SUBST([PARI_PREFIX], [$withval]) 82 CPPFLAGS="$CPPFLAGS -I$withval/include" 83 LDFLAGS="$LDFLAGS -L$withval/lib" 84 ]) 85AC_ARG_ENABLE([mpi], 86 [AS_HELP_STRING([--enable-mpi],[use mpi to compile a parallel version [default=no]])], 87 , 88 [enable_mpi=no]) 89AC_ARG_ENABLE([debug], 90 [AS_HELP_STRING([--enable-debug],[enable extra features facilitating debugging, notably stack backtraces on failure [default=no]])], 91 , 92 [enable_debug=no]) 93 94 95# Languages and compilers, including checks for MPI 96AC_PROG_CXX 97AC_LANG(C) 98AM_CONDITIONAL([MPI], [test x"$enable_mpi" = xyes]) 99AS_IF([test x"$enable_mpi" = xyes], [ 100 AC_LANG(C) # no idea why this is necessary, but otherwise, tests 101 # are carried out with g++ 102 LX_FIND_MPI() 103 AC_LANG_PUSH([C++]) 104 LX_FIND_MPI() 105 AC_LANG_POP([C++]) 106 ]) 107AM_PROG_AR 108LT_INIT 109 110# Libraries 111# Gmp 112AC_MSG_CHECKING(for GMP) 113LIBS="-lgmp $LIBS" 114AC_LINK_IFELSE( 115 [AC_LANG_PROGRAM( 116 [[#include "gmp.h"]], 117 [[mpz_t x; mpz_init(x) ; mpz_clear(x);]] 118 )], 119 [AC_MSG_RESULT(yes)], 120 [ 121 AC_MSG_RESULT(no) 122 AC_MSG_ERROR([libgmp not found or uses a different API. Please see the README file for issues with missing dependencies.]) 123 ]) 124AC_MSG_CHECKING(for recent GMP) 125AC_COMPILE_IFELSE( 126 [AC_LANG_SOURCE( 127 [[ 128#include "gmp.h" 129#if (__GNU_MP_VERSION*100 + __GNU_MP_VERSION_MINOR*10 + __GNU_MP_VERSION_PATCHLEVEL < 432) 130# error "Minimal GMP version is 4.3.2" 131error 132#endif 133 ]])], 134 [AC_MSG_RESULT(yes)], 135 [ 136 AC_MSG_RESULT(no) 137 AC_MSG_ERROR([GMP version >= 4.3.2 required]) 138 ]) 139 140# Mpfr 141AC_MSG_CHECKING(for MPFR) 142LIBS="-lmpfr $LIBS" 143AC_LINK_IFELSE( 144 [AC_LANG_PROGRAM( 145 [[#include "mpfr.h"]], 146 [[mpfr_t x; mpfr_init(x) ; mpfr_clear(x);]] 147 )], 148 [AC_MSG_RESULT(yes)], 149 [ 150 AC_MSG_RESULT(no) 151 AC_MSG_ERROR([libmpfr not found or uses a different API. Please see the README file for issues with missing dependencies.]) 152 ]) 153AC_MSG_CHECKING(for recent MPFR) 154AC_COMPILE_IFELSE( 155 [AC_LANG_SOURCE( 156 [[ 157#include "mpfr.h" 158#if (MPFR_VERSION < MPFR_VERSION_NUM (2,4,2)) 159# error "Minimal MPFR version is 2.4.2" 160error 161#endif 162 ]])], 163 [AC_MSG_RESULT(yes)], 164 [ 165 AC_MSG_RESULT(no) 166 AC_MSG_ERROR([MPFR version >= 2.4.2 required]) 167 ]) 168 169# Mpc 170AC_MSG_CHECKING(for MPC) 171LIBS="-lmpc $LIBS" 172AC_LINK_IFELSE( 173 [AC_LANG_PROGRAM( 174 [[#include "mpc.h"]], 175 [[mpc_t x; mpc_init2(x, 2) ; mpc_clear(x);]] 176 )], 177 [AC_MSG_RESULT(yes)], 178 [ 179 AC_MSG_RESULT(no) 180 AC_MSG_ERROR([libmpc not found or uses a different API. Please see the README file for issues with missing dependencies.]) 181 ]) 182AC_MSG_CHECKING(for recent MPC) 183AC_COMPILE_IFELSE( 184 [AC_LANG_SOURCE( 185 [[ 186#include "mpc.h" 187#if (MPC_VERSION < MPC_VERSION_NUM (1,0,0)) 188# error "Minimal MPC version is 1.0.0" 189error 190#endif 191 ]])], 192 [AC_MSG_RESULT(yes)], 193 [ 194 AC_MSG_RESULT(no) 195 AC_MSG_ERROR([MPC version >= 1.0.0 required]) 196 ]) 197 198# Mpfrcx 199AC_MSG_CHECKING(for MPFRCX) 200LIBS="-lmpfrcx $LIBS" 201AC_LINK_IFELSE( 202 [AC_LANG_PROGRAM( 203 [[#include "mpfrcx.h"]], 204 [[mpcx_t x; mpcx_init(x, 2, 2) ; mpcx_clear(x);]] 205 )], 206 [AC_MSG_RESULT(yes)], 207 [ 208 AC_MSG_RESULT(no) 209 AC_MSG_ERROR([libmpfrcx not found or uses a different API. Please see the README file for issues with missing dependencies.]) 210 ]) 211AC_MSG_CHECKING(for recent MPFRCX) 212AC_COMPILE_IFELSE( 213 [AC_LANG_SOURCE( 214 [[ 215#include "mpfrcx.h" 216#if (100*MPFRCX_VERSION_MAJOR + 100*MPFRCX_VERSION_MINOR + MPFRCX_VERSION_PATCHLEVEL < 42) 217# error "Minimal MPFRCX version is 0.4.2" 218error 219#endif 220 ]])], 221 [AC_MSG_RESULT(yes)], 222 [ 223 AC_MSG_RESULT(no) 224 AC_MSG_ERROR([MPFRCX version >= 0.4.2 required]) 225 ]) 226 227# Pari 228AC_MSG_CHECKING(for PARI) 229AC_LANG_PUSH(C++) 230LIBS="-lpari $LIBS" 231AC_LINK_IFELSE( 232 [AC_LANG_PROGRAM( 233 [[#include "pari/pari.h"]], 234 [[pari_init(100000,0);pari_close();]] 235 )], 236 [AC_MSG_RESULT(yes)], 237 [ 238 AC_MSG_RESULT(no) 239 AC_MSG_ERROR([libpari not found or uses a different API. Please see the README file for issues with missing dependencies.]) 240 ]) 241AC_LANG_POP(C++) 242 243AC_MSG_CHECKING(for recent PARI) 244AC_COMPILE_IFELSE( 245 [AC_LANG_SOURCE( 246 [[ 247#include "pari/pari.h" 248#if PARI_VERSION_CODE < PARI_VERSION (2,9,0) 249# error "Minimal PARI version is 2.9.0" 250error 251#endif 252 ]])], 253 [AC_MSG_RESULT(yes)], 254 [ 255 AC_MSG_RESULT(no) 256 AC_MSG_ERROR([PARI version >= 2.9.0 required]) 257 ]) 258 259# Fplll 260AC_MSG_CHECKING(for FPLLL 4) 261AC_LANG_PUSH(C++) 262OLDLIBS="$LIBS" 263LIBS="-lfplll $LIBS" 264AC_LINK_IFELSE( 265 [AC_LANG_PROGRAM( 266 [[#include "fplll.h"]], 267 [[#include "fplll/matrix.h"]], 268 [[ZZ_mat<mpz_t> M(3,3);]] 269 )], 270 [ 271 AC_MSG_RESULT(yes) 272 AC_DEFINE([HAVE_FPLLL_4],[1],[Define to 1 if FPLLL 4 is present.]) 273 ], 274 [ 275 AC_MSG_RESULT(no) 276 AC_MSG_CHECKING(for FPLLL 5) 277 AC_LINK_IFELSE( 278 [AC_LANG_PROGRAM( 279 [[#include "fplll.h"]], 280 [[#include "fplll/nr/matrix.h"]], 281 [[ZZ_mat<mpz_t> M(3,3);]] 282 )], 283 [ 284 AC_MSG_RESULT(yes) 285 AC_DEFINE([HAVE_FPLLL_5],[1],[Define to 1 if FPLLL 5 is present.]) 286 ], 287 [ 288 AC_MSG_RESULT(no) 289 LIBS="$OLDLIBS" 290 AC_MSG_WARN([libfplll not found or uses a different API; using pari instead, which is slower.]) 291 ]) 292 ]) 293AC_LANG_POP(C++) 294 295want_custom_stack_backtraces=no # default 296want_stack_backtraces=no #default 297AS_IF([test x"$enable_debug" = xyes], [ 298 # In plural form, this also exposes the HAVE_BFD_H and 299 # HAVE_EXECINFO_H flag in config.h.in 300 AC_CHECK_HEADERS([execinfo.h bfd.h]) 301 AS_IF([test x"$ac_cv_header_bfd_h" = xyes],[ 302 # bfd.h found. We will use our custom backtrace code. In fact, 303 # this code includes more stuff. But we assume for now that if 304 # bfd.h is found, we are in something sufficiently gnu-like, so 305 # that we expect the code to compile properly. 306 AC_MSG_CHECKING([for libbfd]) 307 saved_LIBS="$LIBS" 308 LIBS="-lbfd -liberty -ldl -lz $LIBS" 309 AC_LINK_IFELSE([AC_LANG_PROGRAM( 310 [[#include <bfd.h>]], 311 [[bfd_init();]] 312 ) 313 ],[AC_MSG_RESULT(yes) 314 want_custom_stack_backtraces=yes 315 ],[ 316 AC_MSG_RESULT(no) 317 AC_MSG_WARN([libbfd not found or uses a different API. Please see the README file for issues with missing dependencies.]) 318 want_custom_stack_backtraces=no 319 LIBS="$saved_LIBS" 320 ]) 321 ],[ 322 AC_MSG_WARN([BFD headers not found; install the development 323 package of binutils for nicer stack traces.]) 324 ]) 325 AS_IF([test x"$want_custom_stack_backtraces" = xyes],[ 326 want_stack_backtraces=yes 327 ],[ 328 # bfd.h was not found, or libbfd is unusable. Fall back on 329 # something else. 330 AS_IF([test x"$ac_cv_header_execinfo_h" = xyes],[ 331 want_stack_backtraces=yes 332 ],[ 333 AC_MSG_WARN([None of the required headers for the extended 334 stack backtraces could be used, feature disabled]) 335 ]) 336 ]) 337 AS_IF([test x"$want_stack_backtraces" = xyes],[ 338 AC_DEFINE([WANT_STACK_BACKTRACES], [], [Enabled if we intend to 339 compile code for catching stack backtraces]) 340 ]) 341]) 342AM_CONDITIONAL([WANT_CUSTOM_STACK_BACKTRACES], [test x"$want_custom_stack_backtraces" = xyes]) 343 344 345# Default to noisy rules, but make silent rules an option. 346AM_SILENT_RULES([no]) 347 348# Export installation directories, see 349# http://lists.gnu.org/archive/html/autoconf/2005-01/msg00027.html 350if test "x$prefix" = xNONE ; then 351 prefix=$ac_default_prefix 352fi 353if test "x$exec_prefix" = xNONE ; then 354 exec_prefix='${prefix}' 355fi 356eval "eval CMH_BINDIR=$bindir" 357AC_SUBST(CMH_BINDIR) 358eval "eval CMH_PKGDATADIR=$datadir/$PACKAGE" 359AC_SUBST(CMH_PKGDATADIR) 360eval "eval CMH_PKGLIBDIR=$libdir/$PACKAGE" 361AC_SUBST(CMH_PKGLIBDIR) 362 363AC_CONFIG_FILES([src/version.c]) 364AC_CONFIG_FILES([Makefile src/Makefile scripts/Makefile tests/Makefile]) 365AC_CONFIG_FILES([scripts/cmh-classpol.sh], [chmod +x scripts/cmh-classpol.sh]) 366AC_OUTPUT 367