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
|
# Copyright (C) 2017 Yann Pouillon <devops@materialsevolution.es>
#
# Process this file with autoconf to produce a configure script.
#
# Enhance help message (must be set before anything else)
m4_divert_text([HELP_END], [
More information on how to configure the build of LibFDF is available
in the doc/ subdirectory of the source tree, in particular in the
configuring-libfdf.md file.])
# Init Autoconf
AC_PREREQ([2.69])
AC_INIT([LibFDF], [0.5.1],
[https://gitlab.com/siesta-project/libraries/libfdf/-/issues],
[libfdf],
[https://gitlab.com/siesta-project/libraries/libfdf])
AC_CONFIG_AUX_DIR([config/gnu])
AC_CONFIG_MACRO_DIR([config/m4])
AC_CONFIG_SRCDIR([src/fdf.F90])
# Init Automake (assume GNU Make for now)
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([1.14 tar-pax parallel-tests color-tests])
AM_CONFIG_HEADER([config.h])
# Generate timestamp
fdf_timestamp=`date '+%Y%m%dT%H%M%S%z'`
AC_SUBST(fdf_timestamp)
# ------------------------------------ #
#
# System utilities
#
# Check for common programs and features
AC_PROG_AWK
AC_PROG_GREP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_SED
# Workaround for the wrong path to install-sh on Mac systems
AX_PROG_MKDIR_P
# Init variables
fdf_core_incs=""
AC_SUBST(fdf_core_incs)
# ------------------------------------ #
#
# Default settings
#
# Note for developers: you may edit these parameters to tune the behaviour
# of the build system. Please do it with care.
# Optional features
fdf_debug_enable_def="no"
# ------------------------------------ #
#
# Check consistency of defaults
#
# Default triggers for optional features must be yes or no, and not empty
for fdf_cfg_default in debug; do
tmp_default=`eval echo \$\{fdf_${fdf_cfg_default}_enable_def\}`
if test "${tmp_default}" != "no" -a \
"${tmp_default}" != "yes"; then
AC_MSG_ERROR([invalid default value: fdf_${fdf_cfg_default}_enable_def = ${tmp_default}])
fi
done
# Clean-up
unset tmp_default
# ------------------------------------ #
#
# Optional features
#
# Debugging
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[Enable verbose function output (default: ${fdf_debug_enable_def})])],
[fdf_debug_enable="${enableval}"; fdf_debug_type="yon"],
[fdf_debug_enable="${fdf_debug_enable_def}"; fdf_debug_type="def"])
AC_SUBST(enable_debug)
# ------------------------------------ #
#
# Check option consistency
#
# All --enable-* options must be yes or no
for fdf_cfg_option in debug; do
tmp_option=`eval echo \$\{enable_${fdf_cfg_option}\}`
if test "${tmp_option}" != "" -a \
"${tmp_option}" != "no" -a \
"${tmp_option}" != "yes"; then
AC_MSG_ERROR([--enable-${fdf_cfg_option} must be "yes" or "no"])
fi
done
unset tmp_option
# ------------------------------------ #
#
# Substitute build-system variables
#
# Defaults
AC_SUBST(fdf_debug_enable_def)
# Triggers
AC_SUBST(fdf_debug_enable)
# Initialization types
AC_SUBST(fdf_debug_type)
# ------------------------------------ #
#
# C language support
#
# Init C compiler and preprocessor
if test "${CC}" != "" -a ! -x "${CC}"; then
fdf_cc_probe=`echo "${CC}" | sed -e 's/ .*//'`
if test ! -x "${fdf_cc_probe}"; then
AC_PATH_PROG([fdf_cc_path],[${fdf_cc_probe}])
if test "${fdf_cc_path}" = ""; then
AC_MSG_ERROR([could not run C compiler "${CC}"])
fi
fi
fi
AC_PROG_CC
AC_PROG_CPP
# ------------------------------------ #
#
# Fortran language support
#
# Init Fortran compiler
if test "${FC}" != "" -a ! -x "${FC}"; then
fdf_fc_probe=`echo "${FC}" | sed -e 's/ .*//'`
if test ! -x "${fdf_fc_probe}"; then
AC_PATH_PROG([fdf_fc_path], [${fdf_fc_probe}])
if test "${fdf_fc_path}" = ""; then
AC_MSG_ERROR([could not run Fortran compiler "${FC}"])
fi
fi
fi
AC_PROG_FC
# Enforce strict file extensions
fdf_fc_src_ok="unknown"
AC_FC_SRCEXT([F90], [fdf_fc_src_ok="yes"], [fdf_fc_src_ok="no"])
if test "${fdf_fc_src_ok}" != "yes"; then
AC_MSG_WARN([Fortran file extension could not be changed])
AC_MSG_WARN([Fortran tests may fail])
fi
# Look for the iso_c_binding module
fdf_fc_iso_c_binding="unknown"
AC_MSG_CHECKING([for the ISO_C_BINDING Fortran module])
AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[use iso_c_binding]])],
[fdf_fc_iso_c_binding="yes"],
[fdf_fc_iso_c_binding="no"])
AC_LANG_POP([Fortran])
AC_MSG_RESULT([${fdf_fc_iso_c_binding}])
if test "${fdf_fc_iso_c_binding}" != "yes"; then
AC_MSG_ERROR([the Fortran compiler does not provide
the iso_c_binding module.
This probably happens because this compiler
is an antiquity.
Please disable Fortran support or use a modern
Fortran compiler.])
fi
# Fortran compiler peculiarities
AX_F90_MODULE_EXTENSION
AC_SUBST(ax_cv_f90_modext)
AX_F90_MODULE_CASE
# Language mixing
#AC_FC_WRAPPERS
# Inform Automake
AM_CONDITIONAL([F90_MOD_UPPERCASE],
[test "${ax_cv_f90_mod_uppercase}" = "yes"])
# ------------------------------------ #
#
# Libtool configuration
#
# Init Libtool (must be done once compilers are fully set)
LT_INIT
LT_PREREQ([2.4])
LT_LANG([Fortran])
LTOBJEXT="lo"
AC_SUBST(LTOBJEXT)
# ------------------------------------ #
#
# Build-system configuration checkpoint
#
# Write down YAML configuration before any final check
AC_OUTPUT([config/data/libfdf-config.yml])
# ------------------------------------ #
#
# Adjust build parameters according to configure options
#
# Debugging support
if test "${fdf_debug_enable}" = "yes"; then
AC_DEFINE([FDF_DEBUG], 1, [Define to 1 to enable internal debugging.])
fi
# ------------------------------------ #
# Output configuration
AC_CONFIG_FILES([
Makefile
config/data/libfdf.pc
doc/Makefile
src/Makefile
tests/Makefile])
AC_OUTPUT
# Report configuration
AC_MSG_NOTICE([
Final build parameters
----------------------
TSTAMP = ${fdf_timestamp}
DEBUG = ${fdf_debug_enable} (init: ${fdf_debug_type})
CPP = ${CPP}
CPPFLAGS = ${CPPFLAGS}
CC = ${CC}
CFLAGS = ${CFLAGS}
FC = ${FC}
FCFLAGS = ${FCFLAGS}
LDFLAGS = ${LDFLAGS}
LIBS = ${LIBS}
])
|