aboutsummaryrefslogtreecommitdiff
path: root/src/build.sh
blob: 20938b5d6b2d07760afbc57fcbca8069d06d279a (plain)
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
#! /bin/bash

################################################################################
# Build
################################################################################

# Set up shell
if [ "$(echo ${VERBOSE} | tr '[:upper:]' '[:lower:]')" = 'yes' ]; then
    set -x                      # Output commands
fi
set -e                          # Abort on errors



# Set locations
THORN=HDF5
NAME=hdf5-1.8.14
SRCDIR="$(dirname $0)"
BUILD_DIR=${SCRATCH_BUILD}/build/${THORN}
if [ -z "${HDF5_INSTALL_DIR}" ]; then
    INSTALL_DIR=${SCRATCH_BUILD}/external/${THORN}
else
    echo "BEGIN MESSAGE"
    echo "Installing HDF5 into ${HDF5_INSTALL_DIR}"
    echo "END MESSAGE"
    INSTALL_DIR=${HDF5_INSTALL_DIR}
fi
DONE_FILE=${SCRATCH_BUILD}/done/${THORN}
HDF5_DIR=${INSTALL_DIR}

# Set up environment
if [ "${F90}" = "none" ]; then
    echo 'BEGIN MESSAGE'
    echo 'No Fortran 90 compiler available. Building HDF5 library without Fortran support.'
    echo 'END MESSAGE'
    unset FC
    unset FCFLAGS
else
    export FC="${F90}"
    export FCFLAGS="${F90FLAGS}"
fi
for dir in $SYS_INC_DIRS; do
    CPPFLAGS="$CPPFLAGS -I$dir"
done
export CPPFLAGS
export LDFLAGS
unset CPP
unset LIBS
unset RPATH
if echo '' ${ARFLAGS} | grep 64 > /dev/null 2>&1; then
    export OBJECT_MODE=64
fi

echo "HDF5: Preparing directory structure..."
cd ${SCRATCH_BUILD}
mkdir build external done 2> /dev/null || true
rm -rf ${BUILD_DIR} ${INSTALL_DIR}
mkdir ${BUILD_DIR} ${INSTALL_DIR}

# Build core library
echo "HDF5: Unpacking archive..."
pushd ${BUILD_DIR}
${TAR?} xzf ${SRCDIR}/../dist/${NAME}.tar.gz

echo "HDF5: Configuring..."
cd ${NAME}
# Do not build Fortran API if it has been disabled, or if there is no
# Fortran 90 compiler.
# Do not build C++ API if it has been disabled.
./configure --prefix=${HDF5_DIR} --with-zlib=${ZLIB_DIR} --enable-cxx=${HDF5_ENABLE_CXX} $(if [ -n "${FC}" ]; then echo '' "--enable-fortran=${HDF5_ENABLE_FORTRAN} --enable-fortran2003=${HDF5_ENABLE_FORTRAN}"; fi) --disable-shared --enable-static-exec

echo "HDF5: Building..."
${MAKE}

echo "HDF5: Installing..."
${MAKE} install
popd

# Build checker
echo "HDF5: Unpacking checker archive..."
pushd ${BUILD_DIR}
${TAR?} xzf ${SRCDIR}/../dist/h5check_2_0.tar.gz

echo "HDF5: Configuring checker..."
cd h5check_2_0
# Point the checker to the just-installed library
export CPPFLAGS="${CPPFLAGS} -I${HDF5_DIR}/include"
export LDFLAGS="${LDFLAGS} ${LIBDIR_PREFIX}${HDF5_DIR}/lib ${RUNDIR_PREFIX}${HDF5_DIR}/lib"
export H5CC="${CC}"
export H5CC_PP="${CPP}"
export H5FC="${FC}"
export H5FC_PP="${FPP}"
export H5CPP="${CXX}"
./configure --prefix=${HDF5_DIR} --with-zlib=${ZLIB_DIR}

echo "HDF5: Building checker..."
#${MAKE}
(cd src && ${MAKE})
(cd tool && ${MAKE})

echo "HDF5: Installing checker..."
# The build fails in the "test" subdirectory, because
# /usr/include/hdf5.h (if it exists) is used instead of the the one we
# just installed. We therefore skip the build in the "test"
# subdirectory.
#${MAKE} install
(cd src && ${MAKE} install)
(cd tool && ${MAKE} install)
popd

echo "HDF5: Cleaning up..."
rm -rf ${BUILD_DIR}

date > ${DONE_FILE}
echo "HDF5: Done."