Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve autoconf handling for HDF5 library. #1598

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -219,24 +219,34 @@ AC_CHECK_LIB([gsl],[gsl_sf_bessel_Jn], [],
# Check for HDF5 library
AC_ARG_WITH(hdf5, [AC_HELP_STRING([--without-hdf5],[do not allow HDF5 output])], ok=$withval, ok=yes)
if test "$ok" = "yes"; then
AC_CHECK_LIB(z,deflate, [],[AC_MSG_WARN([zlib is required for HDF5!])])

save_CC=$CC
if test "x$with_mpi" = "xyes"; then
CC=$MPICXX
fi
save_LIBS_0="$LIBS" # save, to check later if we found any library
AC_CHECK_LIB(hdf5, H5Pcreate, [
AC_CHECK_HEADERS(hdf5.h, [LIBS="-lhdf5 $LIBS"
AC_DEFINE(HAVE_HDF5,1,[Define if we have & link HDF5])])])
if test x"$save_LIBS_0" = x"$LIBS"; then
AC_MSG_WARN([Couldn't find the HDF5 library!! Switching to --without-hdf5.])
fi
CC=$save_CC

if test "x$with_mpi" = "xyes"; then
AC_CHECK_FUNCS(H5Pset_mpi H5Pset_fapl_mpio)
fi
AC_CHECK_LIB(z,deflate, [],[AC_MSG_WARN([zlib is required for HDF5!])])

save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"

# Check whether linking with "-lhdf5" just works (installation in default
# location or due to user-provided flags). If not, try to locate HDF5 via
# pkg-config. Optimistically update LIBS and CPPFLAGS. Revert if any
# AC_CHECKs fail.
AC_CHECK_LIB(hdf5, H5Pcreate, [], [
PKG_CHECK_MODULES(HDF5, hdf5, [
CPPFLAGS="$CPPFLAGS $HDF5_CFLAGS"
LIBS="$HDF5_LIBS $LIBS"
], [])
])

AC_CHECK_FUNC(H5Pcreate, [
AC_CHECK_HEADER(hdf5.h, [
AC_DEFINE(HAVE_HDF5,1,[Define if we have & link HDF5])
AC_CHECK_FUNCS(H5Pset_mpi H5Pset_fapl_mpio)
])
])

if test "x$ac_cv_header_hdf5_h" != "xyes"; then
AC_MSG_WARN([Couldn't find the HDF5 header or library!! Switching to --without-hdf5.])
CPPFLAGS="$save_CPPFLAGS"
LIBS="$save_LIBS"
fi
fi

##############################################################################
Expand Down