#!/usr/bin/env bash # Build libhdf5 1.8.23 (the last 1.8 release) with its command-line tools, as # the oracle for files written with `LibVer::V18` (the `libver_v18` test in # clawhdf5-tools finds h5dump through CLAWHDF5_H5DUMP18 or this default prefix). # # bash scripts/build-hdf5-1.8.sh [PREFIX] # # PREFIX defaults to ~/.cache/hdf5-1.8.23; sources go to PREFIX-src and the # build tree to PREFIX-build. Reuses an existing install. Needs git, cmake, a C # compiler and zlib headers. set -euo pipefail PREFIX="${1:-$HOME/.cache/hdf5-1.8.23}" SRC="$PREFIX-src" BUILD="$PREFIX-build" if [ -x "$PREFIX/bin/h5dump" ]; then echo "reusing $PREFIX/bin/h5dump" "$PREFIX/bin/h5dump" --version exit 0 fi if [ ! -d "$SRC" ]; then git clone --depth 1 --branch hdf5-1_8_23 https://github.com/HDFGroup/hdf5.git "$SRC" fi # 1.8 predates current compilers (GCC 14 turns its pointer-type mismatches in # the tools into errors): pin gnu99 and demote those errors to warnings. CFLAGS18="-w -std=gnu99 -Wno-error=incompatible-pointer-types" CFLAGS18="$CFLAGS18 -Wno-error=implicit-function-declaration -Wno-error=int-conversion" cmake -S "$SRC" -B "$BUILD" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="$PREFIX" \ -DCMAKE_C_FLAGS="$CFLAGS18" \ -DBUILD_SHARED_LIBS=ON \ -DBUILD_TESTING=OFF \ -DHDF5_BUILD_TOOLS=ON \ -DHDF5_BUILD_EXAMPLES=OFF \ -DHDF5_BUILD_CPP_LIB=OFF \ -DHDF5_BUILD_FORTRAN=OFF \ -DHDF5_BUILD_HL_LIB=OFF \ -DHDF5_BUILD_JAVA=OFF \ -DHDF5_ENABLE_Z_LIB_SUPPORT=ON \ -DHDF5_ENABLE_SZIP_SUPPORT=OFF cmake --build "$BUILD" -j "${JOBS:-6}" cmake --install "$BUILD" "$PREFIX/bin/h5dump" --version