2021-04-28 15:30:18 +02:00
|
|
|
# -*- Autoconf -*-
|
|
|
|
# Process this file with autoconf to produce a configure script.
|
|
|
|
|
|
|
|
AC_PREREQ([2.69])
|
2021-05-28 13:36:39 +02:00
|
|
|
AC_INIT([trexio], [0.3.0], [https://github.com/TREX-CoE/trexio/issues])
|
2021-05-28 12:23:19 +02:00
|
|
|
AM_INIT_AUTOMAKE([subdir-objects color-tests parallel-tests silent-rules 1.11])
|
|
|
|
AM_MAINTAINER_MODE()
|
|
|
|
LT_INIT
|
|
|
|
AC_CONFIG_SRCDIR([Makefile.in])
|
2021-05-28 12:19:15 +02:00
|
|
|
AC_CONFIG_HEADERS([include/config.h])
|
2021-05-28 12:34:58 +02:00
|
|
|
AC_CONFIG_MACRO_DIR([m4])
|
|
|
|
|
|
|
|
VERSION_MAJOR=`echo ${PACKAGE_VERSION} | cut -d. -f1`
|
|
|
|
VERSION_MINOR=`echo ${PACKAGE_VERSION} | cut -d. -f2`
|
|
|
|
VERSION_PATCH=`echo ${PACKAGE_VERSION} | cut -d. -f3 | cut -d- -f1`
|
|
|
|
AC_DEFINE_UNQUOTED(TREXIO_VERSION_MAJOR, [$VERSION_MAJOR], [major version])
|
|
|
|
AC_DEFINE_UNQUOTED(TREXIO_VERSION_MINOR, [$VERSION_MINOR], [minor version])
|
|
|
|
AC_DEFINE_UNQUOTED(TREXIO_VERSION_PATCH, [$VERSION_PATCH], [patch version])
|
|
|
|
AC_SUBST([VERSION_MAJOR])
|
|
|
|
AC_SUBST([VERSION_MINOR])
|
|
|
|
AC_SUBST([VERSION_PATCH])
|
|
|
|
|
2021-04-28 15:30:18 +02:00
|
|
|
# Checks for programs.
|
2021-05-28 12:34:58 +02:00
|
|
|
AC_LANG(C)
|
2021-04-28 15:30:18 +02:00
|
|
|
AC_PROG_CC
|
2021-05-28 12:16:32 +02:00
|
|
|
# Make sure the c compiler supports C99
|
|
|
|
m4_version_prereq([2.70],[], [AC_PROG_CC_C99])
|
|
|
|
AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])])
|
2021-05-08 00:35:53 +02:00
|
|
|
AC_PROG_CC_C_O
|
|
|
|
|
2021-04-28 15:30:18 +02:00
|
|
|
AC_PROG_FC
|
2021-05-08 00:35:53 +02:00
|
|
|
AC_FC_FREEFORM
|
|
|
|
AC_FC_SRCEXT([f90])
|
|
|
|
|
|
|
|
AC_PROG_FC_C_O
|
2021-04-28 15:30:18 +02:00
|
|
|
AC_PROG_INSTALL
|
2021-05-28 13:36:39 +02:00
|
|
|
AC_PROG_LIBTOOL
|
2021-04-28 15:30:18 +02:00
|
|
|
AC_PROG_LN_S
|
2021-05-28 13:36:39 +02:00
|
|
|
PKG_PROG_PKG_CONFIG()
|
|
|
|
PKG_LIBS=""
|
|
|
|
PKG_CFLAGS=""
|
|
|
|
|
|
|
|
AC_FC_LIBRARY_LDFLAGS
|
|
|
|
|
2021-04-28 15:30:18 +02:00
|
|
|
|
2021-05-28 12:16:32 +02:00
|
|
|
|
2021-04-28 15:30:18 +02:00
|
|
|
# Configure with HDF5 (default: --with-hdf5 using pkg-config) [optional]:
|
|
|
|
# ./configure [--with-hdf5 or --with-hdf5=yes]
|
|
|
|
# Configure with user-provided path to HDF5:
|
|
|
|
# ./configure --with-hdf5=/usr/lib/x86_64-linux-gnu/hdf5/serial
|
|
|
|
# Configure without HDF5:
|
|
|
|
# ./configure --without-hdf5 [or --with-hdf5=no]
|
|
|
|
|
2021-04-28 15:57:31 +02:00
|
|
|
# when configure complains about missing install-sh or install.sh, execute:
|
|
|
|
# automake --add-missing --copy
|
|
|
|
|
2021-04-28 15:30:18 +02:00
|
|
|
# Checks for basic libraries.
|
2021-05-06 13:39:04 +02:00
|
|
|
AC_CHECK_LIB([m], [sqrt])
|
2021-04-28 15:30:18 +02:00
|
|
|
# Checks for basic header files.
|
2021-05-06 18:08:28 +02:00
|
|
|
AC_CHECK_HEADERS([fcntl.h inttypes.h stdint.h stdlib.h string.h unistd.h])
|
2021-04-28 15:30:18 +02:00
|
|
|
|
|
|
|
# Search for pthread
|
|
|
|
have_pthreads=no
|
|
|
|
AC_SEARCH_LIBS([pthread_create], [pthread], [have_pthreads=yes])
|
|
|
|
|
|
|
|
if test "x${have_pthreads}" = xyes; then
|
|
|
|
AC_CHECK_HEADERS([pthread.h], [], [have_pthreads=no])
|
2021-05-05 13:55:00 +02:00
|
|
|
PKG_LIBS="${PKG_LIBS} -lpthread"
|
2021-04-28 15:30:18 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if test "x${have_pthreads}" = xno; then
|
|
|
|
AC_MSG_ERROR([
|
|
|
|
------------------------------------------
|
|
|
|
The pthread library and header file
|
|
|
|
required to build TREXIO. Stopping...
|
|
|
|
Check 'config.log' for more information.
|
|
|
|
------------------------------------------])
|
|
|
|
fi
|
|
|
|
|
|
|
|
AC_ARG_WITH([hdf5],
|
2021-05-05 12:17:15 +02:00
|
|
|
AS_HELP_STRING([--with-hdf5],
|
2021-04-28 15:30:18 +02:00
|
|
|
[Include HDF5 functionality @<:@default: yes@:>@])],
|
|
|
|
[hdf5=${withval}],
|
|
|
|
[hdf5=yes])
|
|
|
|
|
2021-05-05 13:55:00 +02:00
|
|
|
PKG_HDF5=""
|
2021-05-05 12:17:15 +02:00
|
|
|
if test "x${hdf5}" = xno; then
|
|
|
|
AC_MSG_WARN([
|
|
|
|
------------------------------------------
|
|
|
|
Configuring with the HDF5 library is
|
|
|
|
recommended to build efficient TREXIO.
|
|
|
|
------------------------------------------])
|
|
|
|
|
2021-04-28 15:30:18 +02:00
|
|
|
elif test "x${hdf5}" = xyes; then
|
|
|
|
|
|
|
|
# Check if HDF5 is already configured (e.g. after calling `module load hdf5-<version>`)
|
|
|
|
AC_CHECK_HEADERS([hdf5_hl.h])
|
|
|
|
AC_CHECK_LIB([hdf5_hl], [H5LTfind_dataset], [], [have_hdf5_hl=no])
|
|
|
|
|
|
|
|
AC_CHECK_HEADERS([hdf5.h])
|
|
|
|
AC_CHECK_LIB([hdf5], [H5open], [], [have_hdf5=no])
|
|
|
|
|
|
|
|
# If HDF5 is not configured, try using pkg-config
|
|
|
|
if test "x${have_hdf5}" = xno; then
|
|
|
|
PKG_CHECK_MODULES([HDF5], [hdf5 >= 1.8])
|
|
|
|
CFLAGS="${HDF5_CFLAGS} ${CFLAGS}"
|
2021-05-03 15:05:54 +02:00
|
|
|
FCFLAGS="${HDF5_CFLAGS} ${FCFLAGS}"
|
2021-04-28 15:30:18 +02:00
|
|
|
LIBS="${HDF5_LIBS} -lhdf5_hl ${LIBS}"
|
2021-05-05 12:17:15 +02:00
|
|
|
PKG_HDF5="hdf5"
|
2021-05-05 17:58:58 +02:00
|
|
|
PKG_LIBS="${PKG_LIBS} -lhdf5_hl"
|
2021-05-05 12:17:15 +02:00
|
|
|
else
|
|
|
|
PKG_HDF5=""
|
2021-05-05 13:55:00 +02:00
|
|
|
PKG_LIBS="${PKG_LIBS} ${HDF5_LIBS} -lhdf5_hl"
|
|
|
|
PKG_CFLAGS="${PKG_CFLAGS} ${HDF5_CFLAGS}"
|
2021-04-28 15:30:18 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if test "x${hdf5}" = x; then
|
2021-05-05 12:17:15 +02:00
|
|
|
AC_MSG_ERROR([
|
2021-04-28 15:30:18 +02:00
|
|
|
------------------------------------------
|
|
|
|
The path to HDF5 library is required.
|
|
|
|
Maybe you forgot to pass --with-hdf5="/your/path/" to configure script.
|
|
|
|
Stopping...
|
2021-05-05 12:17:15 +02:00
|
|
|
------------------------------------------])
|
2021-04-28 15:30:18 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
CPPFLAGS="-I${hdf5}/include ${CPPFLAGS}"
|
|
|
|
LDFLAGS="-L${hdf5} ${LDFLAGS}"
|
|
|
|
|
2021-04-28 15:57:31 +02:00
|
|
|
AC_CHECK_HEADERS([hdf5_hl.h])
|
2021-04-28 15:30:18 +02:00
|
|
|
AC_CHECK_LIB([hdf5_hl], [H5LTfind_dataset], [], [have_hdf5_hl=no])
|
|
|
|
|
2021-04-28 15:57:31 +02:00
|
|
|
AC_CHECK_HEADERS([hdf5.h])
|
2021-04-28 15:30:18 +02:00
|
|
|
AC_CHECK_LIB([hdf5], [H5open], [], [have_hdf5=no])
|
|
|
|
|
2021-05-05 12:17:15 +02:00
|
|
|
PKG_HDF5=""
|
2021-05-05 13:55:00 +02:00
|
|
|
PKG_LIBS="${PKG_LIBS} -L${hdf5} -lhdf5_hl"
|
|
|
|
PKG_CFLAGS="${PKG_CFLAGS} -I${hdf5}/include"
|
2021-04-28 15:30:18 +02:00
|
|
|
fi
|
2021-05-05 12:17:15 +02:00
|
|
|
AC_SUBST([PKG_HDF5])
|
2021-05-05 13:55:00 +02:00
|
|
|
AC_SUBST([PKG_LIBS])
|
|
|
|
AC_SUBST([PKG_CFLAGS])
|
2021-05-05 12:17:15 +02:00
|
|
|
|
2021-04-28 15:30:18 +02:00
|
|
|
|
|
|
|
# add -fPIC if not present in CFLAGS, necessary to compile TREXIO
|
|
|
|
# TODO: replace with AM_CFLAGS for appropriate targer once Automake is introduced
|
|
|
|
case "${CFLAGS}" in
|
|
|
|
*-fPIC*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
AC_MSG_WARN([
|
2021-05-05 12:17:15 +02:00
|
|
|
------------------------------------------
|
2021-04-28 15:30:18 +02:00
|
|
|
Adding -fPIC option to CFLAGS.
|
|
|
|
This is necessary to build TREXIO.
|
|
|
|
------------------------------------------])
|
|
|
|
CFLAGS="${CFLAGS} -fPIC"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Checks for typedefs, structures, and compiler characteristics.
|
|
|
|
AC_TYPE_INT32_T
|
|
|
|
AC_TYPE_INT64_T
|
|
|
|
AC_TYPE_SIZE_T
|
|
|
|
AC_TYPE_UINT32_T
|
|
|
|
AC_TYPE_UINT64_T
|
|
|
|
|
|
|
|
# Checks for library functions.
|
|
|
|
AC_FUNC_MALLOC
|
|
|
|
AC_CHECK_FUNCS([memset mkdir strerror])
|
|
|
|
|
2021-05-28 13:36:39 +02:00
|
|
|
AM_CONDITIONAL([TREXIO_DEVEL],[test "x$TREXIO_DEVEL" != x])
|
|
|
|
|
2021-05-28 12:34:58 +02:00
|
|
|
if test "x${TREXIO_DEVEL}" != "x"; then
|
|
|
|
|
|
|
|
TREXIO_DEVEL=" -- Developer mode"
|
|
|
|
AC_PROG_AWK
|
|
|
|
AM_PATH_PYTHON([3.0])
|
|
|
|
|
|
|
|
AC_CHECK_PROGS([EMACS],[emacs26 emacs],[no])
|
|
|
|
if test x${EMACS} == xno ; then
|
|
|
|
AC_MSG_ERROR([
|
|
|
|
--------------------------------------
|
|
|
|
Error: Emacs is required for org-mode.
|
|
|
|
--------------------------------------
|
|
|
|
])
|
|
|
|
fi
|
|
|
|
|
|
|
|
AC_CHECK_PROGS([HAS_CPPCHECK],[cppcheck],[no])
|
|
|
|
if test x${HAS_CPPCHECK} != xno ; then
|
|
|
|
HAS_CPPCHECK=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2021-04-28 15:30:18 +02:00
|
|
|
AC_CONFIG_FILES([Makefile
|
2021-05-28 12:34:58 +02:00
|
|
|
pkgconfig/trexio.pc])
|
2021-04-28 15:30:18 +02:00
|
|
|
AC_OUTPUT
|
|
|
|
|
|
|
|
echo \
|
|
|
|
"-------------------------------------------------
|
|
|
|
|
2021-05-28 12:34:58 +02:00
|
|
|
${PACKAGE_NAME} Version ${PACKAGE_VERSION} ${TREXIO_DEVEL}
|
2021-04-28 15:30:18 +02:00
|
|
|
|
|
|
|
Prefix: '${prefix}'.
|
|
|
|
|
|
|
|
CC: ${CC}
|
|
|
|
CPPFLAGS: ${CPPFLAGS}
|
|
|
|
CFLAGS: ${CFLAGS}
|
|
|
|
FC: ${FC}
|
|
|
|
FCLAGS: ${FCFLAGS}
|
|
|
|
LDFLAGS: ${LDFLAGS}
|
|
|
|
LIBS: ${LIBS}
|
|
|
|
|
|
|
|
Package features:
|
|
|
|
Compilation with HDF5: ${hdf5}
|
|
|
|
|
|
|
|
Now type 'make @<:@<target>@:>@'
|
|
|
|
where the optional <target> is:
|
|
|
|
all - build C and Fortran APIs
|
|
|
|
check - check C and Fortran APIs
|
|
|
|
clean - clean the produced files
|
|
|
|
--------------------------------------------------"
|
|
|
|
|