diff --git a/configure.ac b/configure.ac index 224b7f722fda80a653bd47914a0ffda3881e49f1..8409327116f6f1af519f3b065cd0e0291f4bdfb0 100644 --- a/configure.ac +++ b/configure.ac @@ -460,7 +460,6 @@ fi # Check for HDF5. This is required. AX_LIB_HDF5 - if test "$with_hdf5" != "yes"; then AC_MSG_ERROR([Could not find a working HDF5 library]) fi @@ -468,8 +467,6 @@ fi # We want to know if this HDF5 supports MPI and whether we should use it. # The default is to use MPI support if it is available, i.e. this is # a parallel HDF5. -# To do this need to ask the HDF5 compiler about its configuration, -# -showconfig should have yes/no. have_parallel_hdf5="no" if test "$with_hdf5" = "yes"; then AC_ARG_ENABLE([parallel-hdf5], @@ -482,7 +479,14 @@ if test "$with_hdf5" = "yes"; then if test "$enable_parallel_hdf5" = "yes"; then AC_MSG_CHECKING([for HDF5 parallel support]) - parallel=`$H5CC -showconfig | grep "Parallel HDF5:" | awk '{print $3}'` +# Check if the library is capable, the header should define H5_HAVE_PARALLEL. + + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + #include "hdf5.h" + #ifndef H5_HAVE_PARALLEL + # error macro not defined + #endif + ]])], [parallel="yes"], [parallel="no"]) if test "$parallel" = "yes"; then have_parallel_hdf5="yes" AC_DEFINE([HAVE_PARALLEL_HDF5],1,[HDF5 library supports parallel access]) diff --git a/m4/ax_lib_hdf5.m4 b/m4/ax_lib_hdf5.m4 index b0d04aa0bd64e0fa1f41ed20cd17b5957287038b..68528b15c083592cf76d4deb9a246b75cb2bb1c6 100644 --- a/m4/ax_lib_hdf5.m4 +++ b/m4/ax_lib_hdf5.m4 @@ -22,7 +22,10 @@ # yes - do check for HDF5 library in standard locations. # path - complete path to the HDF5 helper script h5cc or h5pcc. # -# SWIFT modification: HDF5 is required, so only path is described. +# SWIFT modifications: HDF5 is required, so only path is described, +# when the h5cc or h5pcc commands are not available, we check if +# HDF5 can be used anyway and no macros are defined except HAVE_HDF5 +# and with_hdf5. # # If HDF5 is successfully found, this macro calls # @@ -155,11 +158,37 @@ if test "$with_hdf5" = "yes"; then AC_MSG_CHECKING([Using provided HDF5 C wrapper]) AC_MSG_RESULT([$H5CC]) fi - AC_MSG_CHECKING([for HDF5 libraries]) if test ! -f "$H5CC" || test ! -x "$H5CC"; then - AC_MSG_RESULT([no]) - AC_MSG_WARN(m4_case(m4_normalize([$1]), - [serial], [ + +dnl Check if we already have HDF5 for C. + AC_CHECK_HEADER([hdf5.h], [ac_cv_hhdf5_h=yes], [ac_cv_hhdf5_h=no], [AC_INCLUDES_DEFAULT]) + AC_CHECK_LIB([hdf5], [H5Fcreate], [ac_cv_libhdf5=yes], + [ac_cv_libhdf5=no]) + if test "$ac_cv_hhdf5_h" = "yes" && test "$ac_cv_libhdf5" = "yes" ; then + +dnl Can compile and link, so we have a HDF5, just don't know which version. + AC_MSG_CHECKING([for HDF5 libraries]) + AC_MSG_RESULT([yes]) + with_hdf5="yes" + HDF5_VERSION="unknown" + HDF5_LIBS="-lhdf5" + AC_SUBST([HDF5_VERSION]) + AC_SUBST([HDF5_CC]) + AC_SUBST([HDF5_CFLAGS]) + AC_SUBST([HDF5_CPPFLAGS]) + AC_SUBST([HDF5_LDFLAGS]) + AC_SUBST([HDF5_LIBS]) + AC_SUBST([HDF5_FC]) + AC_SUBST([HDF5_FFLAGS]) + AC_SUBST([HDF5_FLIBS]) + AC_DEFINE([HAVE_HDF5], [1], [Defined if you have HDF5 support]) + else + +dnl Time to give up. + AC_MSG_CHECKING([for HDF5 libraries]) + AC_MSG_RESULT([no]) + AC_MSG_WARN(m4_case(m4_normalize([$1]), + [serial], [ Unable to locate serial HDF5 compilation helper script 'h5cc'. Please specify --with-hdf5=<LOCATION> as the full path to h5cc. HDF5 support is being disabled. @@ -172,9 +201,12 @@ Unable to locate HDF5 compilation helper scripts 'h5cc' or 'h5pcc'. Please specify --with-hdf5=<LOCATION> as the full path to h5cc or h5pcc. HDF5 support is being disabled. ])) - with_hdf5="no" - with_hdf5_fortran="no" + with_hdf5="no" + with_hdf5_fortran="no" + fi else + AC_MSG_CHECKING([for HDF5 libraries]) + dnl Get the h5cc output HDF5_SHOW=$(eval $H5CC -show)