diff options
author | knarf <knarf@fb53df36-e548-4a1e-8150-ab98cbd5e786> | 2015-06-09 14:18:59 +0000 |
---|---|---|
committer | knarf <knarf@fb53df36-e548-4a1e-8150-ab98cbd5e786> | 2015-06-09 14:18:59 +0000 |
commit | 4aa5efb8c536c262124cf9d57e59b529d2f28d5f (patch) | |
tree | c4c2c67ad86ef955e5fc91422c6c7a263b74a2a2 | |
parent | f4f5bf1ec0104f2c7cdaa7ef03e0040cd5fff3ee (diff) |
use bash utility scripts for configuring. Might need tweaking, but works for Debian and a couple of clusters
git-svn-id: http://svn.cactuscode.org/projects/ExternalLibraries/HDF5/trunk@111 fb53df36-e548-4a1e-8150-ab98cbd5e786
-rwxr-xr-x | src/detect.sh | 283 |
1 files changed, 142 insertions, 141 deletions
diff --git a/src/detect.sh b/src/detect.sh index 7bef01a..047e2dd 100755 --- a/src/detect.sh +++ b/src/detect.sh @@ -10,7 +10,7 @@ if [ "$(echo ${VERBOSE} | tr '[:upper:]' '[:lower:]')" = 'yes' ]; then fi set -e # Abort on errors - +. $CCTK_HOME/lib/make/bash_utils.sh ################################################################################ # Check for old mechanism @@ -23,115 +23,100 @@ if [ -n "${HDF5}" ]; then exit 1 fi +# Take care of requests to build the library in any case +HDF5_DIR_INPUT=$HDF5_DIR +if [ "$(echo "${HDF5_DIR}" | tr '[a-z]' '[A-Z]')" = 'BUILD' ]; then + HDF5_BUILD=yes + HDF5_DIR= +else + HDF5_BUILD= +fi - -################################################################################ -# Decide which libraries to link with -################################################################################ - -# Set up names of the libraries based on configuration variables. Also -# assign default values to variables. +# HDF5 can be configures in different ways HDF5_C_LIBS='hdf5_hl hdf5' if [ "${HDF5_ENABLE_CXX:=no}" = 'yes' ]; then HDF5_CXX_LIBS='hdf5_hl_cpp hdf5_cpp' + HDF5_REQ='C++' fi if [ "${HDF5_ENABLE_FORTRAN:=yes}" = 'yes' ]; then if [ "${F90}" != "none" ]; then HDF5_FORTRAN_LIBS='hdf5hl_fortran hdf5_fortran' + HDF5_REQ="$HDF5_REQ Fortran" fi fi +if [ -n "$HDF5_REQ" ]; then + echo "BEGIN MESSAGE" + echo "Additional requested language support: $HDF5_REQ" + echo "END MESSAGE" +fi - +HDF5_REQ_LIBS="${HDF5_CXX_LIBS} ${HDF5_FORTRAN_LIBS} ${HDF5_C_LIBS}" ################################################################################ # Search ################################################################################ - -if [ -z "${HDF5_DIR}" ]; then - echo "BEGIN MESSAGE" - echo "HDF5 selected, but HDF5_DIR not set. Checking some places..." - echo "END MESSAGE" - - # We look in these directories - DIRS="/usr /usr/local /usr/local/hdf5 /usr/local/packages/hdf5 /usr/local/apps/hdf5 /opt/local ${HOME} ${HOME}/hdf5 c:/packages/hdf5" - # look into each directory - for dir in $DIRS; do - # libraries might have different file extensions - for libext in a so dylib; do - # libraries can be in /lib or /lib64 - for libdir in lib64 lib; do - # These files must exist - FILES="include/hdf5.h $(for lib in ${HDF5_CXX_LIBS} ${HDF5_FORTRAN_LIBS} ${HDF5_C_LIBS}; do echo ${libdir}/lib${lib}.${libext}; done)" - # assume this is the one and check all needed files - HDF5_DIR="$dir" - for file in $FILES; do - # discard this directory if one file was not found - if [ ! -r "$dir/$file" ]; then - unset HDF5_DIR - break - fi - done - # don't look further if all files have been found - if [ -n "$HDF5_DIR" ]; then - break - fi - done - # don't look further if all files have been found - if [ -n "$HDF5_DIR" ]; then - break - fi - done - # don't look further if all files have been found - if [ -n "$HDF5_DIR" ]; then - break +if [[ -z "$HDF5_BUILD" ]]; then + find_lib HDF5 hdf5 1 1.0 "$HDF5_REQ_LIBS" "hdf5.h" "$HDF5_DIR" + + # Sadly, pkg-config for HDF5 is good for paths, but bad for the list of + # available (and necessary) library names, so we have to fix things + if [ -n "$PKG_CONFIG_SUCCESS" ]; then + HDF5_LIBS="hdf5_hl $HDF5_LIBS" + find_libs "$HDF5_LIB_DIRS" "hdf5_hl" + if [ -z "$FOUND" ]; then + echo 'BEGIN ERROR' + echo 'Detected problem with HDF5 libary at' + echo " $HDF5_DIR ($HDF5_LIB_DIRS)" + echo 'Library hdf5_hl not found.' + echo 'END ERROR' + exit 1 + fi + if [ "${HDF5_ENABLE_CXX:=no}" = 'yes' ]; then + HDF5_LIBS="hdf5_hl_cpp hdf5_cpp $HDF5_LIBS" + find_libs "$HDF5_LIB_DIRS" "hdf5_hl_cpp hdf5_cpp" + if [ -z "$FOUND" ]; then + echo 'BEGIN ERROR' + echo 'HDF5 Installation found at ' + echo " $HDF5_DIR ($HDF5_LIB_DIRS)" + echo ' does not provide requested C++ support. Either specify the ' + echo ' location of a different HDF5 installation, or do not ' + echo ' require the HDF5 C++ interface if you do not need it ' + echo ' (set HDF5_ENABLE_CXX to "no").' + echo 'END ERROR' + exit 1 + fi + fi + if [ "${HDF5_ENABLE_FORTRAN:=yes}" = 'yes' ]; then + HDF5_LIBS="hdf5hl_fortran hdf5_fortran $HDF5_LIBS" + find_libs "$HDF5_LIB_DIRS" "hdf5hl_fortran hdf5_fortran" + if [ -z "$FOUND" ]; then + echo 'BEGIN ERROR' + echo 'HDF5 Installation found at ' + echo " $HDF5_DIR ($HDF5_LIB_DIRS)" + echo ' does not provide requested Fortran support. Either specify ' + echo ' location of a different HDF5 installation, or do not ' + echo ' require the HDF5 Fortran interface if you do not need it ' + echo ' (set HDF5_ENABLE_FORTRAN to "no").' + echo 'END ERROR' + exit 1 + fi fi - done - - if [ -z "$HDF5_DIR" ]; then - echo "BEGIN MESSAGE" - echo "Did not find HDF5" - echo "END MESSAGE" - else - echo "BEGIN MESSAGE" - echo "Found HDF5 in ${HDF5_DIR}" - echo "END MESSAGE" fi fi - - ################################################################################ # Build ################################################################################ +THORN=HDF5 -if [ -z "${HDF5_DIR}" \ - -o "$(echo "${HDF5_DIR}" | tr '[a-z]' '[A-Z]')" = 'BUILD' ] -then +if [ -n "$HDF5_BUILD" -o -z "${HDF5_DIR}" ]; then echo "BEGIN MESSAGE" echo "Using bundled HDF5..." echo "END MESSAGE" - # Check for required tools. Do this here so that we don't require - # them when using the system library. - if [ "x$TAR" = x ] ; then - echo 'BEGIN ERROR' - echo 'Could not find tar command.' - echo 'Please make sure that the (GNU) tar command is present,' - echo 'and that the TAR variable is set to its location.' - echo 'END ERROR' - exit 1 - fi - if [ "x$PATCH" = x ] ; then - echo 'BEGIN ERROR' - echo 'Could not find patch command.' - echo 'Please make sure that the patch command is present,' - echo 'and that the PATCH variable is set to its location.' - echo 'END ERROR' - exit 1 - fi + check_tools "tar patch" # Set locations - THORN=HDF5 NAME=hdf5-1.8.14 SRCDIR="$(dirname $0)" BUILD_DIR=${SCRATCH_BUILD}/build/${THORN} @@ -143,29 +128,33 @@ then echo "END MESSAGE" INSTALL_DIR=${HDF5_INSTALL_DIR} fi - DONE_FILE=${SCRATCH_BUILD}/done/${THORN} HDF5_DIR=${INSTALL_DIR} -else - THORN=HDF5 - DONE_FILE=${SCRATCH_BUILD}/done/${THORN} - mkdir ${SCRATCH_BUILD}/done 2> /dev/null || true - date > ${DONE_FILE} + # Fortran modules may be located in the lib directory + HDF5_INC_DIRS="${HDF5_DIR}/include ${HDF5_DIR}/lib" + HDF5_LIB_DIRS="${HDF5_DIR}/lib" + HDF5_LIBS="${HDF5_CXX_LIBS} ${HDF5_FORTRAN_LIBS} ${HDF5_C_LIBS}" fi +if [ -n "$HDF5_DIR" ]; then + # Fortran modules may be located in the lib directory + : ${HDF5_RAW_LIB_DIRS:="$HDF5_LIB_DIRS"} + HDF5_INC_DIRS="$HDF5_RAW_LIB_DIRS $HDF5_INC_DIRS" + # We need the un-scrubbed inc dirs to look for a header file below. + : ${HDF5_RAW_INC_DIRS:="$HDF5_INC_DIRS"} +else + echo 'BEGIN ERROR' + echo 'ERROR in HDF5 configuration: Could neither find nor build library.' + echo 'END ERROR' +fi +mkdir ${SCRATCH_BUILD}/done 2> /dev/null || true +DONE_FILE=${SCRATCH_BUILD}/done/${THORN} +date > ${DONE_FILE} ################################################################################ # Check for additional libraries ################################################################################ -# Set options -# Fortran modules may be located in the lib directory -HDF5_INC_DIRS="${HDF5_DIR}/include ${HDF5_DIR}/lib" -HDF5_LIB_DIRS="${HDF5_DIR}/lib" -HDF5_LIBS="${HDF5_CXX_LIBS} ${HDF5_FORTRAN_LIBS} ${HDF5_C_LIBS}" - - - # Check whether we are running on Windows if perl -we 'exit (`uname` =~ /^CYGWIN/)'; then is_windows=0 @@ -180,48 +169,62 @@ else is_macos=1 fi - - -# Check whether we have to link with libsz.a -if grep -qe '#define H5_HAVE_LIBSZ 1' ${HDF5_DIR}/include/H5pubconf.h 2> /dev/null; then - test_szlib=0 -else - test_szlib=1 -fi -if [ $test_szlib -eq 0 ]; then - HDF5_LIB_DIRS="$HDF5_LIB_DIRS $LIBSZ_DIR" - if [ $is_windows -eq 0 ]; then - HDF5_LIBS="$HDF5_LIBS sz" - else - HDF5_LIBS="$HDF5_LIBS szlib" - fi -fi - -# Check whether we have to link with libz.a -if grep -qe '#define H5_HAVE_LIBZ 1' ${HDF5_DIR}/include/H5pubconf.h 2> /dev/null; then - test_zlib=0 -else - test_zlib=1 -fi -if [ $test_zlib -eq 0 ]; then - HDF5_LIB_DIRS="$HDF5_LIB_DIRS $LIBZ_DIR" - if [ $is_windows -eq 0 ]; then - HDF5_LIBS="$HDF5_LIBS z" - else - HDF5_LIBS="$HDF5_LIBS zlib" - fi -fi - -# Check whether we have to link with MPI -if grep -qe '#define H5_HAVE_PARALLEL 1' ${HDF5_DIR}/include/H5pubconf.h 2> /dev/null; then - test_mpi=0 -else - test_mpi=1 -fi -if [ $test_mpi -eq 0 ]; then - HDF5_LIB_DIRS="$HDF5_LIB_DIRS $MPI_LIB_DIRS" - HDF5_INC_DIRS="$HDF5_INC_DIRS $MPI_INC_DIRS" - HDF5_LIBS="$HDF5_LIBS $MPI_LIBS" +# check installed library, assume that everything is fine if we build +if [ -z "$HDF5_BUILD" -a -n "${HDF5_DIR}" ]; then + # find public include file + for dir in $HDF5_RAW_INC_DIRS; do + if [ -r "$dir/H5pubconf.h" ]; then + H5PUBCONF="$H5PUBCONF $dir/H5pubconf.h" + fi + done + if [ -z "$H5PUBCONF" ]; then + echo 'BEGIN ERROR' + echo 'ERROR in HDF5 configuration: ' + echo "H5pubconf.h not found in $HDF5_RAW_INC_DIRS" + echo 'END ERROR' + fi + + # Check whether we have to link with libsz.a + if grep -qe '#define H5_HAVE_LIBSZ 1' $H5PUBCONF 2> /dev/null; then + test_szlib=0 + else + test_szlib=1 + fi + if [ $test_szlib -eq 0 ]; then + HDF5_LIB_DIRS="$HDF5_LIB_DIRS $LIBSZ_DIR" + if [ $is_windows -eq 0 ]; then + HDF5_LIBS="$HDF5_LIBS sz" + else + HDF5_LIBS="$HDF5_LIBS szlib" + fi + fi + + # Check whether we have to link with libz.a + if grep -qe '#define H5_HAVE_LIBZ 1' $H5PUBCONF 2> /dev/null; then + test_zlib=0 + else + test_zlib=1 + fi + if [ $test_zlib -eq 0 ]; then + HDF5_LIB_DIRS="$HDF5_LIB_DIRS $LIBZ_DIR" + if [ $is_windows -eq 0 ]; then + HDF5_LIBS="$HDF5_LIBS z" + else + HDF5_LIBS="$HDF5_LIBS zlib" + fi + fi + + # Check whether we have to link with MPI + if grep -qe '#define H5_HAVE_PARALLEL 1' $H5PUBCONF 2> /dev/null; then + test_mpi=0 + else + test_mpi=1 + fi + if [ $test_mpi -eq 0 ]; then + HDF5_LIB_DIRS="$HDF5_LIB_DIRS $MPI_LIB_DIRS" + HDF5_INC_DIRS="$HDF5_INC_DIRS $MPI_INC_DIRS" + HDF5_LIBS="$HDF5_LIBS $MPI_LIBS" + fi fi # Add the math library which might not be linked by default @@ -230,7 +233,6 @@ if [ $is_windows -eq 0 ]; then fi - ################################################################################ # Configure Cactus ################################################################################ @@ -244,9 +246,7 @@ echo "LIBZ_DIR = ${LIBZ_DIR}" echo "HDF5_INSTALL_DIR = ${HDF5_INSTALL_DIR}" echo "END MAKE_DEFINITION" -HDF5_INC_DIRS="$(${CCTK_HOME}/lib/sbin/strip-incdirs.sh ${HDF5_INC_DIRS})" -HDF5_LIB_DIRS="$(${CCTK_HOME}/lib/sbin/strip-libdirs.sh ${HDF5_LIB_DIRS})" - +# Is this necessary? Shouldn't the ZLIB thorn already take care of this? ZLIB_INC_DIRS="$(${CCTK_HOME}/lib/sbin/strip-incdirs.sh ${ZLIB_INC_DIRS})" ZLIB_LIB_DIRS="$(${CCTK_HOME}/lib/sbin/strip-libdirs.sh ${ZLIB_LIB_DIRS})" @@ -263,3 +263,4 @@ echo "END MAKE_DEFINITION" echo 'INCLUDE_DIRECTORY $(HDF5_INC_DIRS)' echo 'LIBRARY_DIRECTORY $(HDF5_LIB_DIRS)' echo 'LIBRARY $(HDF5_LIBS)' + |