1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
|
# -*- Autoconf -*-
#
# Configure script for the LibGridXC package
#
# Copyright (C) 2017 Y. Pouillon
#
# This file is part of the LibGridXC software package. For license information,
# please see the COPYING file in the top-level directory of the source
# distribution.
#
# ------------------------------------ #
#
# Autotools startup
#
# Init Autoconf
AC_PREREQ([2.69])
AC_INIT([LibGridXC],[2.1.0],[https://gitlab.com/siesta-project/libraries/libgridxc/issues],[libgridxc],[https://gitlab.com/siesta-project/libraries/libgridxc])
AC_REVISION([Autotools support for LibGridXC])
AC_CONFIG_AUX_DIR(config/gnu)
AC_CONFIG_MACRO_DIR([config/m4])
AC_CONFIG_SRCDIR(src/atomxc.F90)
_AC_SRCDIRS([.])
# Init Automake
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([1.14 parallel-tests tar-pax])
AC_CONFIG_HEADERS([config.h])
# Generate timestamp
gxc_timestamp=`date '+%Y%m%dT%H%M%S%z'`
AC_SUBST(gxc_timestamp)
# ------------------------------------ #
#
# System utilities
#
# Check for common programs
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_SED
AC_PROG_AWK
AC_PROG_GREP
# ------------------------------------ #
#
# Default settings
#
# Note for developers: you may edit these parameters to tune the behaviour
# of the build system. Please do it with care.
# Lists of options to manage (gxc_*_enable_def variables)
#
# Note:
# * switches (--enable-*) must be set to "yes" or "no"
# * external dependencies (--with-*) must be set to "yes", "no", or "auto"
#
gxc_cfg_switches="debug multiconfig old_cray single"
gxc_cfg_extdeps="libxc mpi"
# Optional features
gxc_debug_enable_def="no"
gxc_multiconfig_enable_def="no"
gxc_old_cray_enable_def="no"
gxc_single_enable_def="no"
# MPI
gxc_mpi_enable_def="auto"
gxc_mpi_incs_def=""
gxc_mpi_libs_def="-lmpi"
# Packaging
gxc_nec_compat_enable_def="no"
# Internal variables
ARCH_SUFFIX=""
PREC_SUFFIX=""
gxc_precision="double"
# ------------------------------------ #
#
# Check consistency of defaults
#
# Default triggers for optional features must be yes or no, and not empty
for gxc_cfg_default in ${gxc_cfg_switches}; do
tmp_default=`eval echo \$\{gxc_${gxc_cfg_default}_enable_def\}`
if test "${tmp_default}" != "no" -a \
"${tmp_default}" != "yes"; then
AC_MSG_ERROR([invalid default value: gxc_${gxc_cfg_default}_enable_def = ${tmp_default}])
fi
done
# Default triggers for external dependencies must be yes, no, or auto
for gxc_cfg_default in ${gxc_cfg_extdeps}; do
tmp_default=`eval echo \$\{gxc_${gxc_cfg_default}_enable_def\}`
AC_MSG_CHECKING([default detection behavior for ${gxc_cfg_default}])
AC_MSG_RESULT([${tmp_default}])
if test "${tmp_default}" != "" -a \
"${tmp_default}" != "auto" -a \
"${tmp_default}" != "no" -a \
"${tmp_default}" != "yes"; then
AC_MSG_ERROR([invalid default value: gxc_${gxc_cfg_default}_enable_def = ${tmp_default}])
fi
done
# Clean-up
unset tmp_default
# ------------------------------------ #
#
# Optional features
#
# Conditional compilation (alphabetical order)
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[Enable verbose debugging messages (default: ${gxc_debug_enable_def})])],
[gxc_debug_enable="${enableval}"; gxc_debug_type="yon"],
[gxc_debug_enable="${gxc_debug_enable_def}"; gxc_debug_type="def"])
AC_SUBST(enable_debug)
AC_ARG_ENABLE([multiconfig],
[AS_HELP_STRING([--enable-multiconfig],
[Change library name depending on single-/double-precision and MPI support, a la FFTW, for hosts where multiple build flavors are installed concurrently on the system (default: ${gxc_multiconfig_enable_def})])],
[gxc_multiconfig_enable="${enableval}"; gxc_multiconfig_type="yon"],
[gxc_multiconfig_enable="${gxc_multiconfig_enable_def}"; gxc_multiconfig_type="def"])
AC_SUBST(enable_multiconfig)
AC_ARG_ENABLE([old-cray],
[AS_HELP_STRING([--enable-old-cray],
[Enable legacy Cray directives in the source code (default: ${gxc_old_cray_enable_def})])],
[gxc_old_cray_enable="${enableval}"; gxc_old_cray_type="yon"],
[gxc_old_cray_enable="${gxc_old_cray_enable_def}"; gxc_old_cray_type="def"])
AC_SUBST(enable_old_cray)
AC_ARG_ENABLE([single-precision],
[AS_HELP_STRING([--enable-single-precision],
[Enable single-precision grids (default: ${gxc_single_enable_def})])],
[gxc_single_enable="${enableval}"; gxc_single_type="yon"],
[gxc_single_enable="${gxc_single_enable_def}"; gxc_single_type="def"])
AC_SUBST(enable_single_precision)
# Conditional packaging (alphabetical order)
AC_ARG_ENABLE([nec-compat],
[AS_HELP_STRING([--enable-nec-compat],
[Enable compatibility with the NEC compiler (default: ${gxc_nec_compat_enable_def})])],
[gxc_nec_compat_enable="${enableval}"; gxc_nec_compat_type="yon"],
[gxc_nec_compat_enable="${gxc_nec_compat_enable_def}"; gxc_nec_compat_type="def"])
AC_SUBST(enable_nec_compat)
# ------------------------------------ #
#
# External dependencies
#
AC_LANG_PUSH(Fortran)
AC_FC_SRCEXT(f90)
ACX_LIBXC
AC_LANG_POP(Fortran)
# MPI (optional)
AC_ARG_WITH([mpi],
[AS_HELP_STRING([--with-mpi],
[Install prefix of MPI (e.g. /usr/local). The default behaviour is to detect whether the specified compilers properly support MPI and to fall back to serial mode if not. You may use --with-mpi without argument to force MPI detection, in which case detection failures will result in errors, and --without-mpi to disable MPI support completely.])],
[ if test "${withval}" = "no" -o "${withval}" = "yes"; then
gxc_mpi_enable="${withval}"
gxc_mpi_type="yon"
else
gxc_mpi_enable="yes"
tmp_comma=`echo "${withval}" | grep ','`
if test "${tmp_comma}" = ""; then
gxc_mpi_type="pfx"
gxc_mpi_incs="-I${withval}/include"
gxc_mpi_libs="-L${withval}/lib ${gxc_mpi_libs_def}"
else
gxc_mpi_type="csv"
gxc_mpi_incs="`echo ${withval} | cut -d',' -f1`"
gxc_mpi_libs="`echo ${withval} | cut -d',' -f2`"
fi
fi],
[gxc_mpi_enable="${gxc_mpi_enable_def}"; gxc_mpi_type="def"])
AC_SUBST(with_mpi)
# ------------------------------------ #
#
# Check option consistency
#
# All --enable-* options must be yes or no
for gxc_cfg_option in ${gxc_cfg_switches}; do
tmp_option=`eval echo \$\{enable_${gxc_cfg_option}\}`
if test "${tmp_option}" != "" -a \
"${tmp_option}" != "no" -a \
"${tmp_option}" != "yes"; then
AC_MSG_ERROR([--enable-${gxc_cfg_option} must be "yes" or "no"])
fi
done
# Adjust floating-point precision depending on specified options
if test "${gxc_single_enable}" = "yes"; then
gxc_precision="single"
fi
# Clean-up
unset tmp_option
# ------------------------------------ #
#
# Substitute build-system variables
#
# Defaults
AC_SUBST(gxc_debug_enable_def)
AC_SUBST(gxc_multiconfig_enable_def)
AC_SUBST(gxc_nec_compat_enable_def)
AC_SUBST(gxc_old_cray_enable_def)
AC_SUBST(gxc_single_enable_def)
AC_SUBST(gxc_mpi_enable_def)
AC_SUBST(gxc_mpi_incs_def)
AC_SUBST(gxc_mpi_libs_def)
# Triggers
AC_SUBST(gxc_debug_enable)
AC_SUBST(gxc_multiconfig_enable)
AC_SUBST(gxc_nec_compat_enable)
AC_SUBST(gxc_old_cray_enable)
AC_SUBST(gxc_single_enable)
# Initialization types
AC_SUBST(gxc_debug_type)
AC_SUBST(gxc_multiconfig_type)
AC_SUBST(gxc_nec_compat_type)
AC_SUBST(gxc_old_cray_type)
AC_SUBST(gxc_single_type)
AC_SUBST(gxc_mpi_type)
# Build flags for external dependencies
AC_SUBST(gxc_mpi_incs)
AC_SUBST(gxc_mpi_libs)
# Internal variables
AC_SUBST(ARCH_SUFFIX)
AC_SUBST(PREC_SUFFIX)
AC_SUBST(gxc_precision)
# ------------------------------------ #
#
# Architecture setup
#
# Init MPI parameters
GXC_MPI_INIT
# ------------------------------------ #
#
# C language support
#
# Init C compiler and preprocessor
AC_PROG_CC
AC_PROG_CPP
# C compiler peculiarities (for Libtool)
AM_PROG_CC_C_O
# ------------------------------------ #
#
# Fortran language support
#
# Look for the Fortran compiler
if test "${FC}" != "" -a ! -x "${FC}"; then
gxc_fc_probe=`echo "${FC}" | sed -e 's/ .*//'`
if test ! -x "${gxc_fc_probe}"; then
AC_PATH_PROG([gxc_fc_path],[${gxc_fc_probe}])
if test "${gxc_fc_path}" = ""; then
AC_MSG_ERROR([could not run Fortran compiler "${FC}"])
fi
fi
fi
AC_PROG_FC
# Fail if no Fortran compiler is available
if test "${FC}" = ""; then
AC_MSG_ERROR([no Fortran compiler available])
fi
# Get module file case
GXC_FC_MOD_CASE
# FIXME: legacy Fortran files should be upgraded to Fortran 2003
AC_ARG_VAR([F77], [Fortran 77 compiler])
if test "${F77}" = ""; then
F77="${FC}"
fi
# ------------------------------------ #
#
# Libtool configuration
#
# Init Libtool (must be done once compilers are fully set)
LT_INIT
LT_PREREQ([2.4.2])
LT_LANG([Fortran])
LTOBJEXT="lo"
AC_SUBST(LTOBJEXT)
# ------------------------------------ #
#
# Multicore architecture support
#
# Look for MPI
if test "${gxc_mpi_enable}" != "no"; then
GXC_MPI_DETECT
if test "${gxc_mpi_ok}" = "yes"; then
AC_DEFINE([HAVE_MPI], 1, [Define to 1 to enable MPI support.])
gxc_mpi_enable="yes"
else
if test "${gxc_mpi_enable}" = "auto"; then
AC_MSG_NOTICE([disabling MPI support])
gxc_mpi_enable="no"
else
AC_MSG_FAILURE([MPI support is broken - please check your configuration])
fi
fi
fi
# From now on, the MPI trigger must be yes or no
if test "${gxc_mpi_enable}" != "no" -a "${gxc_mpi_enable}" != "yes"; then
AC_MSG_ERROR([unexpected MPI trigger value: '${gxc_mpi_enable}'])
fi
# ------------------------------------ #
#
# External dependencies (the order matters a lot)
#
# Check for mathematical functions
AC_CHECK_LIB(m, sqrt, [], [
AC_MSG_WARN([missing math library (sqrt not found)])])
# ------------------------------------ #
#
# Adjust build parameters according to configure options
#
# Conditional compilation (alphabetical order)
if test "${gxc_debug_enable}" = "yes"; then
AC_DEFINE([DEBUG_XC], 1,
[Define to 1 if you want to enable debugging.])
fi
if test "${gxc_old_cray_enable}" = "yes"; then
AC_DEFINE([OLD_CRAY], 1,
[Define to 1 if you have an oldish Cray architecture.])
fi
if test "${gxc_single_enable}" = "yes"; then
AC_DEFINE([GRID_SP], 1,
[Define to 1 if you want to use single-precision grids.])
else
AC_DEFINE([GRID_DP], 1,
[Define to 1 if you want to use double-precision grids.])
fi
if test "${gxc_mpi_enable}" = "yes"; then
AC_DEFINE([HAVE_MPI], 1,
[Define to 1 if you want to use MPI.])
fi
# Inform Automake on MPI status
AM_CONDITIONAL([GRIDXC_USES_LIBXC], [test "${acx_libxc_ok}" = "yes"])
AM_CONDITIONAL([GRIDXC_USES_MPI], [test "${gxc_mpi_enable}" = "yes"])
AM_CONDITIONAL([GRIDXC_USES_MULTICONFIG], [test "${gxc_multiconfig_enable}" = "yes"])
AM_CONDITIONAL([GRIDXC_NEC_COMPAT], [test "${gxc_nec_compat_enable}" = "yes"])
# Set architecture suffix for library name
if test "${gxc_multiconfig_enable}" = "yes" -a "${gxc_mpi_enable}" = "yes"; then
ARCH_SUFFIX="_mpi"
fi
# Set precision suffix for library name
if test "${gxc_multiconfig_enable}" = "yes"; then
case "${gxc_precision}" in
single)
PREC_SUFFIX="_sp"
;;
double)
PREC_SUFFIX="_dp"
;;
*)
AC_MSG_ERROR([invalid floating-point precision: ${gxc_precision}])
;;
esac
fi
# ------------------------------------ #
#
# Propagate configuration
#
# FIXME: copy Fortran flags for legacy source files
FFLAGS="${FCFLAGS}"
# Transmit relevant information to pkg-config
gxc_libxc_req_pc=""
if test "${acx_libxc_ok}" = "yes"; then
gxc_libxc_req_pc="libxc"
gxc_libxc_fortran_lib=""
fi
if test "${acx_libxc_vf90}" = "yes"; then
gxc_libxc_req_pc="libxcf90"
gxc_libxc_fortran_lib="-lxcf90"
fi
if test "${acx_libxc_vf03}" = "yes"; then
gxc_libxc_req_pc="libxcf03"
gxc_libxc_fortran_lib="-lxcf03"
fi
AC_SUBST(gxc_libxc_req_pc)
AC_SUBST(gxc_libxc_fortran_lib)
# Transmit LibXC information to SIESTA
gxc_siesta_libxc="0"
if test "${acx_libxc_ok}" = "yes"; then
gxc_siesta_libxc="1"
fi
AC_SUBST(gxc_siesta_libxc)
gxc_siesta_libxc_root=""
if test ! -z "$with_libxc"; then
gxc_siesta_libxc_root="$with_libxc"
fi
AC_SUBST(gxc_siesta_libxc_root)
# (AG) I am not sure whether this might ever apply
gxc_siesta_libxc_include=""
if test ! -z "$with_libxc_include"; then
gxc_siesta_libxc_include="$with_libxc_include"
fi
AC_SUBST(gxc_siesta_libxc_include)
# Transmit MPI information to SIESTA
gxc_siesta_mpi="0"
if test "${gxc_mpi_enable}" = "yes"; then
gxc_siesta_mpi="1"
fi
AC_SUBST(gxc_siesta_mpi)
# ------------------------------------ #
# Write down YAML configuration now (allows full report with deferred errors)
AC_OUTPUT([config/data/libgridxc-config.yml])
# Report configuration
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Final build parameters])
AC_MSG_NOTICE([----------------------])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([TSTAMP = ${gxc_timestamp}])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([CPP = ${CPP}])
AC_MSG_NOTICE([CPPFLAGS = ${CPPFLAGS}])
AC_MSG_NOTICE([CC = ${CC}])
AC_MSG_NOTICE([CFLAGS = ${CFLAGS}])
AC_MSG_NOTICE([FC = ${FC}])
AC_MSG_NOTICE([FCFLAGS = ${FCFLAGS}])
AC_MSG_NOTICE([LDFLAGS = ${LDFLAGS}])
AC_MSG_NOTICE([LIBS = ${LIBS}])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Debugging : ${gxc_debug_enable} (init: ${gxc_debug_type})])
AC_MSG_NOTICE([Multiconfig : ${gxc_multiconfig_enable} (init: ${gxc_multiconfig_type})])
AC_MSG_NOTICE([NEC compatibility : ${gxc_nec_compat_enable} (init: ${gxc_nec_compat_type})])
AC_MSG_NOTICE([Oldish Cray : ${gxc_old_cray_enable} (init: ${gxc_old_cray_type})])
AC_MSG_NOTICE([Single precision : ${gxc_single_enable} (init: ${gxc_single_type})])
AC_MSG_NOTICE([MPI : ${gxc_mpi_enable} (init: ${gxc_mpi_type})])
AC_MSG_NOTICE([LibXC : ${acx_libxc_ok}])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Library name : libgridxc${PREC_SUFFIX}${ARCH_SUFFIX}.a])
AC_MSG_NOTICE([])
# ------------------------------------ #
#
# Output configuration
#
AC_CONFIG_FILES([
config/data/gridxc.mk
config/data/libgridxc.pc
config/data/libxc.mk
Makefile
src/Makefile
docs/Makefile
Testers/Makefile
])
AC_OUTPUT
|