1# Process this file with autoconf to produce a configure script. 2AC_INIT(mpb, 1.11.1) 3AC_CONFIG_SRCDIR([src/matrices/matrices.c]) 4AC_CONFIG_HEADER([config.h src/mpbconf.h]) 5AC_CONFIG_MACRO_DIR([m4]) 6AM_MAINTAINER_MODE 7 8# Shared-library version number; indicates api compatibility, and is 9# not the same as the "public" version number. (Don't worry about this 10# except for public releases.) 11SHARED_VERSION_INFO="5:1:4" # CURRENT:REVISION:AGE 12 13VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d. -f1` 14VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d. -f2` 15VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d. -f3 | cut -d- -f1` 16AC_DEFINE_UNQUOTED(MPB_VERSION_MAJOR, [$VERSION_MAJOR], [major version]) 17AC_DEFINE_UNQUOTED(MPB_VERSION_MINOR, [$VERSION_MINOR], [minor version]) 18AC_DEFINE_UNQUOTED(MPB_VERSION_PATCH, [$VERSION_PATCH], [patch version]) 19 20AM_INIT_AUTOMAKE([foreign color-tests parallel-tests silent-rules 1.11]) 21AM_SILENT_RULES(yes) 22AC_SUBST(SHARED_VERSION_INFO) 23AM_ENABLE_SHARED(no) dnl shared libs cause too many headaches to be default 24AC_PROG_LIBTOOL 25 26########################################################################### 27MPB_VERSION=$PACKAGE_VERSION 28AC_SUBST(MPB_VERSION) 29AC_PROG_F77 30AC_PATH_PROG(PERL, perl perl5, $srcdir/missing) 31 32# Get C compiler. 33AC_MSG_CHECKING([for vendor cc to be used instead of gcc]) 34AC_MSG_RESULT() 35AC_CHECK_PROGS(CC, cc xlc) # prefer vendor cc, to stay in sync with Fortran 36AC_PROG_CC 37AM_PROG_CC_C_O 38 39AC_ARG_ENABLE(single, [AC_HELP_STRING([--enable-single],[compile for single precision])], enable_single=$enableval, enable_single=no) 40if test "$enable_single" = "yes"; then 41 AC_DEFINE(SCALAR_SINGLE_PREC,1,[Define to use single precision]) 42 echo "*********************** SINGLE PRECISION ***********************" 43fi 44 45AC_ARG_ENABLE(long-double, [AC_HELP_STRING([--enable-long-double],[compile for long-double precision])], enable_long_double=$enableval, enable_long_double=no) 46if test "$enable_long_double" = "yes"; then 47 AC_DEFINE(SCALAR_LONG_DOUBLE_PREC,1,[Define to use long-double precision]) 48 echo "****************** LONG-DOUBLE PRECISION ***********************" 49fi 50 51AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],[compile for debugging])], ok=$enableval, ok=no) 52if test "$ok" = "yes"; then 53 CFLAGS="-g" 54 AC_DEFINE(DEBUG,1,[Define to turn on debugging checks]) 55fi 56 57AC_ARG_ENABLE(debug-malloc, [AC_HELP_STRING([--enable-debug-malloc],[use debug malloc/free])], ok=$enableval, ok=no) 58if test "$ok" = "yes"; then 59 AC_DEFINE(DEBUG_MALLOC,1,[Define to use debugging malloc/free]) 60fi 61 62AC_ARG_ENABLE(prof, [AC_HELP_STRING([--enable-prof],[compile for profiling])], ok=$enableval, ok=no) 63if test "$ok" = "yes"; then 64 CFLAGS="$CFLAGS -pg" 65 AC_DEFINE(ENABLE_PROF,1,[Define when using the profiler tool]) 66fi 67 68AC_ARG_ENABLE(checks, [AC_HELP_STRING([--disable-checks],[disable runtime checks])], ok=$enableval, ok=yes) 69if test "$ok" = "no"; then 70 AC_DEFINE(CHECK_DISABLE,1,[Define to disable sanity checks in code]) 71fi 72 73AC_ARG_WITH(inv-symmetry,[AC_HELP_STRING([--with-inv-symmetry],[take advantage of (and require) inv. sym.])], inv_sym=$withval, inv_sym=no) 74if test "$inv_sym" = "no"; then 75 AC_DEFINE(SCALAR_COMPLEX,1,[Define to use complex fields and 76 not to require inversion symmetry]) 77 SCALAR_TYPE=complex 78else 79 SCALAR_TYPE=real 80 # Make installed program mpbi instead of mpb, but don't change mpb-data 81 MPB_SUFFIX="i" 82 echo "*********************** INVERSION SYM. ***********************" 83fi 84AC_SUBST(SCALAR_TYPE) 85 86AC_ARG_WITH(hermitian-eps,[AC_HELP_STRING([--with-hermitian-eps],[allow complex-Hermitian dielectric tensors])], hermitian_epsilon=$withval, hermitian_epsilon=no) 87if test "$hermitian_epsilon" = "yes"; then 88 AC_DEFINE(WITH_HERMITIAN_EPSILON,1,[Define to support Hermitian/complex 89 dielectric tensors.]) 90 echo "*********************** HERMITIAN EPS. ***********************" 91fi 92 93# Add lots of compiler warnings to check for if we are using gcc: 94# (The variable $GCC is set to "yes" by AC_PROG_CC if we are using gcc.) 95if test "$GCC" = "yes"; then 96 CFLAGS="$CFLAGS -Wall -W -Wbad-function-cast -Wcast-qual -Wpointer-arith -Wcast-align -pedantic" 97fi 98 99############################################################################## 100# Checks for libraries: 101############################################################################## 102 103AC_ARG_WITH(efence, [AC_HELP_STRING([--with-efence],[use ElectricFence library])], ok=$withval, ok=no) 104if test "$ok" = "yes"; then 105 AC_CHECK_LIB(efence, malloc) 106fi 107 108############################################################################## 109AC_CHECK_LIB(m, sqrt) 110 111# If we have a Fortran compiler, link to its libraries, since these 112# are probably needed to link with the BLAS/LAPACK libraries. 113if test x != x"$F77"; then 114 AC_F77_LIBRARY_LDFLAGS 115 AC_F77_WRAPPERS 116fi 117 118############################################################################## 119# In principle, we should abort if some of the following libraries are 120# missing, or perhaps only compile some of the subdirectories. For now, 121# though, we do nothing (and wait for the compilation errors). 122 123############################################################################## 124AC_ARG_WITH(mpi, [AC_HELP_STRING([--with-mpi],[enable MPI parallelization])], with_mpi=$withval, with_mpi=no) 125AC_ARG_WITH(fftw2, [AC_HELP_STRING([--with-fftw2],[prefer FFTW2 to FFTW3])], with_fftw2=$withval, with_fftw2=no) 126 127# Check for FFTW libraries 128fftw3_func=execute 129test "x$with_fftw2" = xyes && fftw3_func=notarealfunction # prefer FFTW2 130if test "$enable_single" = "yes"; then 131 AC_CHECK_LIB(fftw3f, fftwf_$fftw3_func, [], [ 132 AC_CHECK_LIB(sfftw, fftw) 133 if test x"$inv_sym" = xyes; then 134 AC_CHECK_LIB(srfftw, rfftw) 135 fi]) 136elif test "$enable_long_double" = "yes"; then 137 AC_CHECK_LIB(fftw3l, fftwl_$fftw3_func, [], [ 138 AC_CHECK_LIB(xfftw, fftw) 139 if test x"$inv_sym" = xyes; then 140 AC_CHECK_LIB(xrfftw, rfftw) 141 fi]) 142else 143 AC_CHECK_LIB(fftw3, fftw_$fftw3_func, [], [ 144 AC_CHECK_LIB(dfftw, fftw) 145 if test x"$inv_sym" = xyes; then 146 AC_CHECK_LIB(drfftw, rfftw) 147 fi]) 148fi 149 150if test x = x"`echo $LIBS | egrep 'l[[dsx]]fftw|fftw3'`"; then 151 AC_CHECK_LIB(fftw, fftw) 152 if test x"$inv_sym" = xyes; then 153 AC_CHECK_LIB(rfftw, rfftw) 154 fi 155fi 156 157if test x = x"`echo $LIBS | egrep 'l[[dsx]]*fftw'`"; then 158 AC_MSG_ERROR([The FFTW libraries could not be found. Make sure FFTW is installed, and that LDFLAGS and CPPFLAGS are set appropriately if necessary.]) 159fi 160 161if test x"$inv_sym" = xyes; then 162 if test x = x"`echo $LIBS | egrep 'l[[dsx]]*rfftw|lfftw3'`"; then 163 AC_MSG_ERROR([The FFTW3 or RFFTW libraries, which are required to compile MPB with inversion symmetry, could not be found. These should have been installed as a part of FFTW.]) 164 fi 165fi 166 167############################################################################## 168# Check for OpenMP libraries 169 170AC_ARG_WITH(openmp, [AC_HELP_STRING([--with-openmp],[enable OpenMP parallelization])], with_omp=$withval, with_omp=no) 171if test "x$with_omp" = xyes; then 172 AC_DEFINE([USE_OPENMP], [1], [Define to use OpenMP threading.]) 173 AX_OPENMP([], [AC_MSG_ERROR([Could not find OpenMP flag; configure with --without-openmp])]) 174 CFLAGS="$CFLAGS $OPENMP_CFLAGS" 175 fftw_omp=yes 176 if test "$enable_single" = "yes"; then 177 AC_CHECK_LIB(fftw3f_omp, fftwf_init_threads, [], [fftw_omp=no]) 178 elif test "$enable_long_double" = "yes"; then 179 AC_CHECK_LIB(fftw3l_omp, fftwl_init_threads, [], [fftw_omp=no]) 180 else 181 AC_CHECK_LIB(fftw3_omp, fftw_init_threads, [], [fftw_omp=no]) 182 fi 183 if test $fftw_omp = no; then 184 AC_MSG_ERROR([Could not find OpenMP FFTW3 library; configure with --without-openmp]) 185 fi 186 echo "*********************** OpenMP ***********************" 187fi 188 189############################################################################## 190# Checks for BLAS and LAPACK libraries: 191 192AX_BLAS([], [AC_MSG_ERROR([BLAS was not found!])]) 193AX_LAPACK([], [AC_MSG_ERROR([LAPACK was not found!])]) 194 195LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS" 196 197############################################################################## 198# Check for MPI library 199 200if test "x$with_mpi" = "xyes"; then 201 AX_MPI([], [AC_MSG_ERROR(could not find mpi library for --with-mpi)]) 202 CC="$MPICC" 203 LIBS="$MPILIBS $LIBS" 204 205 # Make installed program mpb-mpi instead of mpb 206 MPB_SUFFIX="${MPB_SUFFIX}_mpi" 207 208 # Check for fftw_mpi library. 209 if test "$enable_single" = "yes"; then 210 AC_CHECK_LIB(fftw3f_mpi, fftwf_mpi_${fftw3_func}_dft, [], [ 211 AC_CHECK_LIB(sfftw_mpi, fftwnd_mpi) 212 if test x"$inv_sym" = xyes; then 213 AC_CHECK_LIB(srfftw_mpi, rfftwnd_mpi) 214 fi]) 215 elif test "$enable_long_double" = "yes"; then 216 AC_CHECK_LIB(fftw3l_mpi, fftwl_mpi_${fftw3_func}_dft, [], [ 217 AC_CHECK_LIB(xfftw_mpi, fftwnd_mpi) 218 if test x"$inv_sym" = xyes; then 219 AC_CHECK_LIB(xrfftw_mpi, rfftwnd_mpi) 220 fi]) 221 else 222 AC_CHECK_LIB(fftw3_mpi, fftw_mpi_${fftw3_func}_dft, [], [ 223 AC_CHECK_LIB(dfftw_mpi, fftwnd_mpi) 224 if test x"$inv_sym" = xyes; then 225 AC_CHECK_LIB(drfftw_mpi, rfftwnd_mpi) 226 fi]) 227 fi 228 if test x = x"`echo $LIBS | egrep 'l[[ds]]fftw_mpi|lfftw3f_mpi|lfftw3l_mpi|lfftw3_mpi'`"; then 229 AC_CHECK_LIB(fftw_mpi, fftwnd_mpi) 230 if test x"$inv_sym" = xyes; then 231 AC_CHECK_LIB(rfftw_mpi, rfftwnd_mpi) 232 fi 233 fi 234 if test x = x"`echo $LIBS | egrep 'l[[ds]]*fftw_mpi|lfftw3f_mpi|lfftw3l_mpi|lfftw3_mpi'`"; then 235 AC_MSG_ERROR([couldn't find fftw MPI library for --with-mpi]) 236 fi 237 if test x"$inv_sym" = xyes; then 238 if test x = x"`echo $LIBS | egrep 'l[[ds]]*rfftw_mpi|lfftw3l_mpi|lfftw3f_mpi|lfftw3_mpi'`"; then 239 AC_MSG_ERROR([couldn't find rfftw_mpi library for --with-mpi --with-inv-symmetry]) 240 fi 241 fi 242 243 AC_DEFINE(HAVE_MPI,1,[Define if you have & link an MPI library.]) 244fi 245 246AM_CONDITIONAL(MPI, test "x$with_mpi" = "xyes") 247 248RUNCODE="" 249if test "x$with_mpi" = "xyes"; then 250 AC_CHECK_PROG(MPIRUN, mpirun, mpirun) 251 # always use 2 processes for 'make check' 252 RUNCODE="$MPIRUN -np 2" 253fi 254AC_SUBST(RUNCODE) 255 256############################################################################## 257# Check for HDF5 library 258AC_ARG_WITH(hdf5, [AC_HELP_STRING([--without-hdf5],[do not use HDF5 output])], ok=$withval, ok=yes) 259if test "$ok" = "yes"; then 260 AC_CHECK_LIB(z,deflate, [],[AC_MSG_WARN([zlib is required for HDF5!])]) 261 262 save_LIBS_0="$LIBS" # save, to check later if we found any library 263 AC_CHECK_LIB(hdf5, H5Pcreate, [ 264 AC_CHECK_HEADERS(hdf5.h, [LIBS="-lhdf5 $LIBS" 265 AC_DEFINE(HAVE_HDF5,1,[Define if we have & link HDF5])])]) 266 if test x"$save_LIBS_0" = x"$LIBS"; then 267 AC_MSG_WARN([Couldn't find the HDF5 library!! Switching to --without-hdf5.]) 268 fi 269 270 if test x != x"$MPILIBS"; then 271 AC_CHECK_FUNCS(H5Pset_mpi H5Pset_fapl_mpio) 272 fi 273fi 274 275############################################################################## 276 277AC_ARG_WITH(libctl, [AC_HELP_STRING([--with-libctl=<dir>],[specify libctl directory])], with_libctl=$withval, with_libctl=yes) 278if test "x$with_libctl" != "xyes" -a "x$with_libctl" != "xno"; then 279 LIBCTL_DIR="$with_libctl" 280 with_libctl=yes 281fi 282 283AM_CONDITIONAL(WITH_LIBCTL, test "x$with_libctl" != xno) 284 285############################################################################## 286# Check for Guile library and flags: 287 288if test "x$with_libctl" != xno; then 289 290save_LIBS=$LIBS 291save_CPPFLAGS=$CPPFLAGS 292 293AC_CHECK_PROG(guile_ok, guile, yes, no) 294if test x"$guile_ok" = xno; then 295 AC_MSG_ERROR([could not find guile program; check your PATH]) 296fi 297 298AC_CHECK_PROG(GUILE_CONFIG, guile-config, guile-config, unknown) 299if test "x$GUILE_CONFIG" = "xunknown"; then 300 AC_CHECK_LIB(readline, readline) 301 AC_CHECK_LIB(dl, dlopen) 302 AC_CHECK_LIB(guile-ltdl, scm_lt_dlinit, [], [AC_CHECK_LIB(ltdl, dlopen)]) 303 AC_CHECK_LIB(guile, gh_eval_str, [], 304 [AC_CHECK_LIB(guile, scm_eval_string, [], 305 [AC_MSG_ERROR([linking to guile failed])])]) 306 GUILE_LIBS="-lguile -lguile-ltdl -ldl -lreadline" 307else 308 GUILE_LIBS=`$GUILE_CONFIG link` 309 GUILE_CPPFLAGS=`$GUILE_CONFIG compile` 310 CPPFLAGS="$CPPFLAGS $GUILE_CPPFLAGS" 311 LIBS="$GUILE_LIBS $LIBS" 312 AC_MSG_CHECKING([if linking to guile works]) 313 AC_TRY_LINK_FUNC(gh_enter, AC_MSG_RESULT(yes), 314 [AC_TRY_LINK_FUNC(scm_boot_guile, AC_MSG_RESULT(yes), 315 [AC_MSG_RESULT(no) 316 AC_MSG_ERROR([guile-config is broken])])]) 317fi 318AC_CHECK_HEADERS([libguile.h guile/gh.h]) 319 320# Check how smob types work in this Guile version: 321 322AC_CHECK_FUNCS(scm_make_smob_type scm_array_get_handle scm_is_array) 323AC_MSG_CHECKING([for SCM_SMOB_PREDICATE]) 324AC_TRY_LINK([#if defined(HAVE_LIBGUILE_H) 325# include <libguile.h> 326#else 327# include <guile/gh.h> 328# include <libguile/smob.h> 329#endif], 330 [int x; SCM_SMOB_PREDICATE(1,x);], 331 ok=yes, ok=no) 332AC_MSG_RESULT($ok) 333if test $ok = yes; then 334 AC_DEFINE(HAVE_SCM_SMOB_PREDICATE, 1, [define if we have SCM_SMOB_PREDICATE]) 335fi 336AC_MSG_CHECKING([for SCM_SMOB_DATA]) 337AC_TRY_LINK([#if defined(HAVE_LIBGUILE_H) 338# include <libguile.h> 339#else 340# include <guile/gh.h> 341# include <libguile/smob.h> 342#endif], 343 [int x; SCM_SMOB_DATA(x);], 344 ok=yes, ok=no) 345AC_MSG_RESULT($ok) 346if test $ok = yes; then 347 AC_DEFINE(HAVE_SCM_SMOB_DATA, 1, [define if we have SCM_SMOB_DATA]) 348fi 349AC_MSG_CHECKING([for SCM_NEWSMOB]) 350AC_TRY_LINK([#if defined(HAVE_LIBGUILE_H) 351# include <libguile.h> 352#else 353# include <guile/gh.h> 354# include <libguile/smob.h> 355#endif], 356 [int x; SCM_NEWSMOB(x,1,0);], 357 ok=yes, ok=no) 358AC_MSG_RESULT($ok) 359if test $ok = yes; then 360 AC_DEFINE(HAVE_SCM_NEWSMOB, 1, [define if we have SCM_NEWSMOB]) 361fi 362 363# Check how to activate Guile readline support: 364 365ACTIVATE_READLINE="" 366if test "x$cross_compiling" = xno; then 367AC_MSG_CHECKING(how to activate readline in Guile) 368ractivate="(use-modules (readline-activator)) (activate-readline)" 369if guile -c "$ractivate" > /dev/null 2>&1; then 370 AC_MSG_RESULT(readline-activator) 371 ACTIVATE_READLINE="$ractivate" 372else 373 ractivate="(use-modules (ice-9 readline)) (activate-readline)" 374 if guile -c "$ractivate" > /dev/null 2>&1; then 375 AC_MSG_RESULT(ice-9 readline) 376 ACTIVATE_READLINE="$ractivate" 377 else 378 AC_MSG_RESULT(cannot) 379 ACTIVATE_READLINE="" 380 fi 381fi 382fi 383AC_SUBST(ACTIVATE_READLINE) 384AC_SUBST(GUILE_LIBS) 385AC_SUBST(GUILE_CPPFLAGS) 386 387LIBS=$save_LIBS 388CPPFLAGS=$save_CPPFLAGS 389 390fi # with_libctl 391 392############################################################################## 393# Check for libctl library and files 394 395if test "x$with_libctl" != xno; then 396 397save_LIBS=$LIBS 398save_CPPFLAGS=$CPPFLAGS 399LIBS="$GUILE_LIBS $LIBS" 400CPPFLAGS="$CPPFLAGS $GUILE_CPPFLAGS" 401 402AC_MSG_CHECKING([for libctl dir]) 403if test x != x"$LIBCTL_DIR" -a -r "$LIBCTL_DIR/share/libctl/base/ctl.scm"; then 404 LIBCTL_DIR="$LIBCTL_DIR/share/libctl" 405fi 406if test x != x"$LIBCTL_DIR" -a ! -r "$LIBCTL_DIR/base/ctl.scm"; then 407 LIBCTL_DIR="" 408fi 409if test x = x"$LIBCTL_DIR" -a -r /usr/local/share/libctl/base/ctl.scm; then 410 LIBCTL_DIR="/usr/local/share/libctl" 411fi 412if test x = x"$LIBCTL_DIR" -a -r /usr/share/libctl3/base/ctl.scm; then 413 LIBCTL_DIR="/usr/share/libctl3" 414fi 415if test x = x"$LIBCTL_DIR" -a -r /usr/share/libctl/base/ctl.scm; then 416 LIBCTL_DIR="/usr/share/libctl" 417fi 418if test x = x"$LIBCTL_DIR"; then 419 AC_MSG_ERROR([could not find libctl files; use --with-libctl=<dir>]) 420fi 421AC_MSG_RESULT($LIBCTL_DIR) 422AC_SUBST(LIBCTL_DIR) 423 424AC_CHECK_PROGS(GEN_CTL_IO, gen-ctl-io, echo) 425if test x"$GEN_CTL_IO" = xecho; then 426 AC_MSG_ERROR([could not find gen-ctl-io program; check your PATH]) 427fi 428 429# check for -lctl: 430AC_CHECK_LIB(ctl, ctl_get_vector3, [], [AC_MSG_ERROR([Couldn't find the required libctl library.])]) 431 432# check for ctl.h (Fedora puts it in /usr/include/ctl, grrr) 433CTL_H_CPPFLAG="" 434AC_CHECK_HEADER(ctl.h, [CTL_H_CPPFLAG=" "], [ 435 save_CPPFLAGS=$CPPFLAGS 436 AC_MSG_CHECKING([for alternate ctl.h location]) 437 for ctl_h_path in /usr/include/ctl /usr/local/include/ctl; do 438 CPPFLAGS="$save_CPPFLAGS -I$ctl_h_path" 439 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <ctl.h>]],[])], [CTL_H_CPPFLAG=-I$ctl_h_path; break]) 440 done 441 AC_MSG_RESULT([$CTL_H_CPPFLAG]) 442 CPPFLAGS="$save_CPPFLAGS $CTL_H_CPPFLAG"]) 443if test "x$CTL_H_CPPFLAG" = "x"; then 444 AC_MSG_ERROR([Couldn't find the ctl.h header file for libctl.]) 445fi 446AC_SUBST(CTL_H_CPPFLAG) 447 448# Check libctl version >= LIBCTL_MAJOR.LIBCTL_MINOR.LIBCTL_BUGFIX 449LIBCTL_MAJOR=4; LIBCTL_MINOR=0; LIBCTL_BUGFIX=0 450AC_MSG_CHECKING([whether libctl version is at least ${LIBCTL_MAJOR}.${LIBCTL_MINOR}.${LIBCTL_BUGFIX}]) 451AC_EGREP_CPP(yes, [[ 452#include <ctl.h> 453#if LIBCTL_MAJOR_VERSION > $LIBCTL_MAJOR || (LIBCTL_MAJOR_VERSION == $LIBCTL_MAJOR && (LIBCTL_MINOR_VERSION > $LIBCTL_MINOR || (LIBCTL_MINOR_VERSION == $LIBCTL_MINOR && LIBCTL_BUGFIX_VERSION >= $LIBCTL_BUGFIX))) 454 yes 455#endif 456]], [AC_MSG_RESULT(ok)], [AC_MSG_ERROR([libctl version ${LIBCTL_MAJOR}.${LIBCTL_MINOR}.${LIBCTL_BUGFIX} or later is required])]) 457 458# Check for libctl_quiet feature (in libctl 3.1.1 or later): 459AC_MSG_CHECKING([for libctl_quiet feature]) 460if grep libctl_quiet "$LIBCTL_DIR/base/main.c" 2>&1 > /dev/null; then 461 AC_MSG_RESULT(yes) 462 AC_DEFINE([HAVE_LIBCTL_QUIET], [1], [If we have the libctl_quiet variable]) 463else 464 AC_MSG_RESULT(no) 465fi 466 467LIBS=$save_LIBS 468CPPFLAGS=$save_CPPFLAGS 469 470fi # with_libctl 471 472 473############################################################################## 474# check for libctlgeom, used to build mpb-data ... doesn't require guile 475 476AC_CHECK_LIB(ctlgeom, vector3_dot, [with_libctlgeom=yes], [with_libctlgeom=no]) 477 478if test "x$with_libctlgeom" = xyes; then 479 # check for ctlgeom.h (Fedora may put it in /usr/include/ctl) 480 CTLGEOM_H_CPPFLAG="" 481 AC_CHECK_HEADER(ctlgeom.h, [CTLGEOM_H_CPPFLAG=" "], [ 482 save_CPPFLAGS=$CPPFLAGS 483 AC_MSG_CHECKING([for alternate ctlgeom.h location]) 484 for ctl_h_path in /usr/include/ctl /usr/local/include/ctl; do 485 CPPFLAGS="$save_CPPFLAGS -I$ctl_h_path" 486 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <ctlgeom.h>]],[])], [CTLGEOM_H_CPPFLAG=-I$ctl_h_path; break]) 487 done 488 AC_MSG_RESULT([$CTLGEOM_H_CPPFLAG]) 489 CPPFLAGS="$save_CPPFLAGS"]) 490 if test "x$CTLGEOM_H_CPPFLAG" = "x"; then 491 with_libctlgeom=no 492 fi 493 AC_SUBST(CTLGEOM_H_CPPFLAG) 494fi 495 496if test "x$with_libctlgeom" = xno; then 497 AC_MSG_WARN([Couldn't find libctlgeom, won't build mpb-data]) 498fi 499AM_CONDITIONAL(WITH_LIBCTLGEOM, test x"$with_libctlgeom" = "xyes") 500 501############################################################################## 502# check for nlopt library 503 504AC_CHECK_HEADERS(nlopt.h) 505NLOPT_LIB="" 506AC_CHECK_LIB(nlopt, nlopt_minimize, [AC_DEFINE(HAVE_NLOPT,[1],[Have nlopt lib]) 507 NLOPT_LIB="-lnlopt"]) 508AC_SUBST(NLOPT_LIB) 509 510############################################################################## 511# Checks for header files. 512AC_HEADER_STDC 513AC_CHECK_HEADERS(unistd.h getopt.h nlopt.h) 514 515# Checks for typedefs, structures, and compiler characteristics. 516AC_C_CONST 517AC_C_INLINE 518 519# Checks for library functions. 520AC_CHECK_FUNCS(getopt strncmp) 521 522############################################################################## 523# Check to see if calling Fortran functions (in particular, the BLAS 524# complex dot product functions) works from C: 525 526AC_MSG_CHECKING([whether calling BLAS zdotc works]) 527AC_F77_FUNC(zdotc) 528AC_TRY_RUN([ 529#include <stdio.h> 530#include <stdlib.h> 531typedef struct { double re, im; } cmplx; 532#ifdef __cplusplus 533extern "C" 534#endif 535extern cmplx $zdotc(int *, cmplx *, int *, cmplx *, int *); 536int main(void) { 537 cmplx x[2] = { {1,0}, {0,1} }, y[2] = { {1,0}, {1,0} }; 538 int n = 2, inc1 = 1, inc2 = 1; 539 cmplx result = { 0, 0 }; 540 result = $zdotc(&n, x, &inc1, y, &inc2); 541 if (result.re != 1 || result.im != -1) return EXIT_FAILURE; 542 else return EXIT_SUCCESS; 543} 544], ok="yes", ok="no", ok="no") 545AC_MSG_RESULT($ok) 546if test "$ok" = "no"; then 547 AC_DEFINE(NO_FORTRAN_FUNCTIONS,1,[Define if calling Fortran functions directly doesn't work.]) 548fi 549 550############################################################################## 551 552# grab the various EIGS_ flags from eigensolver.h and substitute them 553# into mpb.scm.in (are not regular expressions fun?): 554# (note that autoconf gets unhappy if we have newlines; we must delete them) 555EIGS_FLAGS_SCM=`grep '#define EIGS_' $srcdir/src/matrices/eigensolver.h |sed 's/#define \([A-Za-z0-9_]*\) (1<<\([0-9]*\))/(define \1 (pow2 \2))/' |sed 's/#define \([A-Za-z0-9_]*\) (\(.*\))/(define \1 (+ \2))/' |sed 's/ *| */ /g' | tr -d '\n'` 556AC_SUBST(EIGS_FLAGS_SCM) 557 558############################################################################## 559 560if test "x$with_libctl" != xno; then 561 562# Find a shell that supports job control, for mpb-split: 563AC_PATH_PROG(SH_JOB, bash ksh ash, sh) 564 565if test x"$SH_JOB" = xsh; then 566 AC_MSG_WARN([Couldn't find bash or ksh shell on your system. The mpb-split command may not work if your sh doesn't support job control.]) 567fi 568 569fi # with_libctl 570 571############################################################################## 572# The following function is used only for debugging. Note that 573# we must test for it *after* setting the compiler flags (which 574# affect whether it is declared, as it is a GNU extension). 575# We need to #include <stdio.h> because that somehow affects whether 576# the function is declared with older gcc versions. We need 577# to use AC_TRY_COMPILE because the test in AC_HAVE_DECL seems 578# to be optimized out. 579 580AC_CHECK_FUNCS(feenableexcept) dnl GNU libc fp exception control function 581AC_MSG_CHECKING([whether feenableexcept declaration is usable]) 582feenableexcept_decl_ok=yes 583AC_TRY_COMPILE([#include <stdio.h> 584#define _GNU_SOURCE 1 585#include <fenv.h>], [feenableexcept(0);], 586[AC_DEFINE([HAVE_DECL_FEENABLEEXCEPT],[1],[Define if fenv.h declares this.])], 587[feenableexcept_decl_ok=no]) 588AC_MSG_RESULT($feenableexcept_decl_ok) 589 590############################################################################## 591AC_SUBST(MPB_SUFFIX) 592program_transform_name="s,_,-,g;$program_transform_name" 593############################################################################## 594 595AC_CONFIG_FILES([ 596 Makefile 597 examples/Makefile 598 tests/Makefile 599 src/Makefile 600 src/util/Makefile 601 src/matrices/Makefile 602 src/matrixio/Makefile 603 src/maxwell/Makefile 604 mpb/Makefile 605 mpb/mpb.scm 606 mpb/mpb-split-preinstall 607 utils/Makefile 608]) 609# meb/Makefile 610# meb/meb.scm 611# meb/meb-split-preinstall 612AC_OUTPUT 613