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

Enable native builds of szip via libaec #1334

Merged
merged 11 commits into from
Mar 20, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Build HDF5 with support for SZIP enabled ([pull #1334](https://github.com/bytedeco/javacpp-presets/pull/1334))
* Map missing functions from `mkl_trans.h` in presets for MKL ([issue #1331](https://github.com/bytedeco/javacpp-presets/issues/1331))
* Bundle the official Java API of HDF5 via the `hdf5_java` library ([pull #1327](https://github.com/bytedeco/javacpp-presets/pull/1327))
* Map missing `cblas_?axpby()` functions in presets for MKL ([issue #1326](https://github.com/bytedeco/javacpp-presets/issues/1326))
Expand Down
122 changes: 106 additions & 16 deletions hdf5/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,69 @@ fi

ZLIB=zlib-1.2.13
HDF5_VERSION=1.14.0
AEC_VERSION=1.0.6
download "http://zlib.net/$ZLIB.tar.gz" $ZLIB.tar.gz
download "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-$HDF5_VERSION/src/hdf5-$HDF5_VERSION.tar.bz2" hdf5-$HDF5_VERSION.tar.bz2
# Use Github mirror repo rather than Gitlab repo for download speed
#download "https://gitlab.dkrz.de/k202009/libaec/uploads/45b10e42123edd26ab7b3ad92bcf7be2/libaec-$AEC_VERSION.tar.gz" libaec-$AEC_VERSION.tar.gz
download "https://github.com/MathisRosenhauer/libaec/releases/download/v$AEC_VERSION/libaec-$AEC_VERSION.tar.gz" libaec-$AEC_VERSION.tar.gz

mkdir -p $PLATFORM
cd $PLATFORM
pushd $PLATFORM
INSTALL_PATH=`pwd`
echo "Decompressing archives..."
tar --totals -xf ../hdf5-$HDF5_VERSION.tar.bz2
cd hdf5-$HDF5_VERSION
tar --totals -xf ../libaec-$AEC_VERSION.tar.gz
pushd hdf5-$HDF5_VERSION

#sedinplace '/cmake_minimum_required/d' $(find ./ -iname CMakeLists.txt)
sedinplace 's/# *cmakedefine/#cmakedefine/g' config/cmake/H5pubconf.h.in
sedinplace 's/COMPATIBILITY SameMinorVersion/COMPATIBILITY AnyNewerVersion/g' CMakeInstallation.cmake
sedinplace '/C_RUN (/{N;N;d;}' config/cmake/ConfigureChecks.cmake

# As of 1.14.0 the integrated cmake process for building aec/szip is broken
# Revisit integrated szip build with 1.14.1

case $PLATFORM in
# HDF5 does not currently support cross-compiling:
# https://support.hdfgroup.org/HDF5/faq/compile.html
# android-arm)
# # Build libaec for szip first
# mkdir -p ../libaec-$AEC_VERSION/build
# pushd ../libaec-$AEC_VERSION/build
# "$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
# make -j $MAKEJ
# make install
# popd
#
# patch -Np1 < ../../../hdf5-android.patch
# ./configure --prefix=$INSTALL_PATH --host="arm-linux-androideabi" --with-sysroot="$ANDROID_ROOT" AR="$ANDROID_BIN-ar" RANLIB="$ANDROID_BIN-ranlib" CPP="$ANDROID_BIN-cpp" CC="$ANDROID_BIN-gcc" CXX="$ANDROID_BIN-g++" STRIP="$ANDROID_BIN-strip" CPPFLAGS="--sysroot=$ANDROID_ROOT -DANDROID -I$ANDROID_CPP/include/ -I$ANDROID_CPP/include/backward/ -I$ANDROID_CPP/libs/armeabi/include/ -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" LDFLAGS="-L$ANDROID_ROOT/usr/lib/ -L$ANDROID_CPP/libs/armeabi/ -nostdlib -Wl,--fix-cortex-a8 -z text -L./" LIBS="-lgnustl_static -lgcc -ldl -lz -lm -lc" --enable-cxx --enable-java
# make -j $MAKEJ
# make install-strip
# ;;
# android-x86)
# # Build libaec for szip first
# mkdir -p ../libaec-$AEC_VERSION/build
# pushd ../libaec-$AEC_VERSION/build
# "$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
# make -j $MAKEJ
# make install
# popd
#
# patch -Np1 < ../../../hdf5-android.patch
# ./configure --prefix=$INSTALL_PATH --host="i686-linux-android" --with-sysroot="$ANDROID_ROOT" AR="$ANDROID_BIN-ar" RANLIB="$ANDROID_BIN-ranlib" CPP="$ANDROID_BIN-cpp" CC="$ANDROID_BIN-gcc" CXX="$ANDROID_BIN-g++" STRIP="$ANDROID_BIN-strip" CPPFLAGS="--sysroot=$ANDROID_ROOT -DANDROID -I$ANDROID_CPP/include/ -I$ANDROID_CPP/include/backward/ -I$ANDROID_CPP/libs/x86/include/ -fPIC -ffunction-sections -funwind-tables -mssse3 -mfpmath=sse -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" LDFLAGS="-L$ANDROID_ROOT/usr/lib/ -L$ANDROID_CPP/libs/x86/ -nostdlib -z text -L." LIBS="-lgnustl_static -lgcc -ldl -lz -lm -lc" --enable-cxx --enable-java
# make -j $MAKEJ
# make install-strip
# ;;
linux-armhf)
# Build libaec for szip first
mkdir -p ../libaec-$AEC_VERSION/build
pushd ../libaec-$AEC_VERSION/build
"$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
make -j $MAKEJ
make install
popd

MACHINE_TYPE=$( uname -m )
if [[ "$MACHINE_TYPE" =~ arm ]]; then
./configure --prefix=$INSTALL_PATH CC="gcc" CXX="g++" --enable-cxx --enable-java
Expand All @@ -57,6 +89,14 @@ case $PLATFORM in
fi
;;
linux-arm64)
# Build libaec for szip first
mkdir -p ../libaec-$AEC_VERSION/build
pushd ../libaec-$AEC_VERSION/build
"$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
make -j $MAKEJ
make install
popd

MACHINE_TYPE=$( uname -m )
if [[ "$MACHINE_TYPE" =~ arm ]]; then
./configure --prefix=$INSTALL_PATH CC="gcc -m64" CXX="g++ -m64" --enable-cxx --enable-java
Expand All @@ -74,63 +114,112 @@ case $PLATFORM in
fi
;;
linux-x86)
./configure --prefix=$INSTALL_PATH CC="gcc -m32" CXX="g++ -m32" --enable-cxx --enable-java
# Build libaec for szip first
mkdir -p ../libaec-$AEC_VERSION/build
pushd ../libaec-$AEC_VERSION/build
"$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
make -j $MAKEJ
make install
popd

./configure --prefix=$INSTALL_PATH CC="gcc -m32" CXX="g++ -m32" --enable-cxx --enable-java --with-szlib
make -j $MAKEJ
make install-strip
;;
linux-x86_64)
./configure --prefix=$INSTALL_PATH CC="gcc -m64" CXX="g++ -m64" --enable-cxx --enable-java
# Build libaec for szip first
mkdir -p ../libaec-$AEC_VERSION/build
pushd ../libaec-$AEC_VERSION/build
"$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
make -j $MAKEJ
make install
popd

./configure --prefix=$INSTALL_PATH CC="gcc -m64" CXX="g++ -m64" --enable-cxx --enable-java --with-szlib
make -j $MAKEJ
make install-strip
;;
linux-ppc64le)
MACHINE_TYPE=$( uname -m )
if [[ "$MACHINE_TYPE" =~ ppc64 ]]; then
./configure --prefix=$INSTALL_PATH CC="gcc -m64" CXX="g++ -m64" --enable-cxx --enable-java
# Build libaec for szip first
mkdir -p ../libaec-$AEC_VERSION/build
pushd ../libaec-$AEC_VERSION/build
"$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
make -j $MAKEJ
make install
popd

./configure --prefix=$INSTALL_PATH CC="gcc -m64" CXX="g++ -m64" --enable-cxx --enable-java --with-szlib
make -j $MAKEJ
make install-strip
else
echo "Not native ppc so assume cross compiling"
patch -Np1 < ../../../hdf5-linux-ppc64le.patch || true
#need this to run twice, first run fails so we fake the exit code too
for x in 1 2; do
"$CMAKE" -DCMAKE_TOOLCHAIN_FILE=`pwd`/ppc.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DBUILD_TESTING=false -DHDF5_BUILD_EXAMPLES=false -DHDF5_BUILD_TOOLS=false -DCMAKE_CXX_FLAGS="-D_GNU_SOURCE" -DCMAKE_C_FLAGS="-D_GNU_SOURCE" -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING="TGZ" -DZLIB_TGZ_NAME:STRING="$ZLIB.tar.gz" -DTGZPATH:STRING="$INSTALL_PATH/.." -DHDF5_ENABLE_Z_LIB_SUPPORT=ON -DHDF5_BUILD_CPP_LIB=ON -DHDF5_BUILD_JAVA=ON . || true
"$CMAKE" -DCMAKE_TOOLCHAIN_FILE=`pwd`/ppc.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DBUILD_TESTING=false -DHDF5_BUILD_EXAMPLES=false -DHDF5_BUILD_TOOLS=false -DCMAKE_CXX_FLAGS="-D_GNU_SOURCE" -DCMAKE_C_FLAGS="-D_GNU_SOURCE" -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING="TGZ" -DZLIB_TGZ_NAME:STRING="$ZLIB.tar.gz" -DTGZPATH:STRING="$INSTALL_PATH/.." -DHDF5_ENABLE_Z_LIB_SUPPORT=ON -DSZAEC_TGZ_NAME:STRING="libaec-$AEC_VERSION.tar.gz" -DHDF5_ENABLE_SZIP_SUPPORT=ON -DHDF5_ENABLE_SZIP_ENCODING=ON -DUSE_LIBAEC=ON -DHDF5_BUILD_CPP_LIB=ON -DHDF5_BUILD_JAVA=ON . || true
done
make -j $MAKEJ
make install
fi
;;
macosx-*)
# Build libaec for szip first
mkdir -p ../libaec-$AEC_VERSION/build
pushd ../libaec-$AEC_VERSION/build
"$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
make -j $MAKEJ
make install
popd

patch -Np1 < ../../../hdf5-macosx.patch
./configure --prefix=$INSTALL_PATH --enable-cxx --enable-java
./configure --prefix=$INSTALL_PATH --enable-cxx --enable-java --with-szlib
make -j $MAKEJ
make install-strip
;;
windows-x86)
mkdir -p build
cd build
export CC="cl.exe"
export CXX="cl.exe"
"$CMAKE" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DBUILD_TESTING=false -DHDF5_BUILD_EXAMPLES=false -DHDF5_BUILD_TOOLS=false -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING="TGZ" -DZLIB_TGZ_NAME:STRING="$ZLIB.tar.gz" -DTGZPATH:STRING="$INSTALL_PATH/.." -DHDF5_ENABLE_Z_LIB_SUPPORT=ON -DHDF5_BUILD_CPP_LIB=ON -DHDF5_BUILD_JAVA=ON ..

mkdir -p ../libaec-$AEC_VERSION/build
pushd ../libaec-$AEC_VERSION/build
"$CMAKE" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
ninja -j $MAKEJ
ninja install
popd

mkdir -p build
pushd build
"$CMAKE" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DBUILD_TESTING=false -DHDF5_BUILD_EXAMPLES=false -DHDF5_BUILD_TOOLS=false -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING="TGZ" -DZLIB_TGZ_NAME:STRING="$ZLIB.tar.gz" -DTGZPATH:STRING="$INSTALL_PATH/.." -DHDF5_ENABLE_Z_LIB_SUPPORT=ON -DHDF5_ENABLE_SZIP_SUPPORT=ON -DHDF5_ENABLE_SZIP_ENCODING=ON -DUSE_LIBAEC=ON -DSZIP_LIBRARY:FILEPATH="$INSTALL_PATH/lib/szip_static.lib" -DSZIP_INCLUDE_DIR="$INSTALL_PATH/include" -DSZIP_USE_EXTERNAL:BOOL=OFF -DHDF5_BUILD_CPP_LIB=ON -DHDF5_BUILD_JAVA=ON ..
sedinplace 's/Release\\libz.lib/zlibstatic.lib/g' build.ninja
ninja -j $MAKEJ HDF5_ZLIB
ninja -j $MAKEJ
ninja install
cp bin/zlib* ../../lib/
cd ..
popd
;;
windows-x86_64)
mkdir -p build
cd build
export CC="cl.exe"
export CXX="cl.exe"
"$CMAKE" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DBUILD_TESTING=false -DHDF5_BUILD_EXAMPLES=false -DHDF5_BUILD_TOOLS=false -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING="TGZ" -DZLIB_TGZ_NAME:STRING="$ZLIB.tar.gz" -DTGZPATH:STRING="$INSTALL_PATH/.." -DHDF5_ENABLE_Z_LIB_SUPPORT=ON -DHDF5_BUILD_CPP_LIB=ON -DHDF5_BUILD_JAVA=ON ..

mkdir -p ../libaec-$AEC_VERSION/build
pushd ../libaec-$AEC_VERSION/build
"$CMAKE" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
ninja -j $MAKEJ
ninja install
popd

mkdir -p build
pushd build
"$CMAKE" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DBUILD_TESTING=false -DHDF5_BUILD_EXAMPLES=false -DHDF5_BUILD_TOOLS=false -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING="TGZ" -DZLIB_TGZ_NAME:STRING="$ZLIB.tar.gz" -DTGZPATH:STRING="$INSTALL_PATH/.." -DHDF5_ENABLE_Z_LIB_SUPPORT=ON -DHDF5_ENABLE_SZIP_SUPPORT=ON -DHDF5_ENABLE_SZIP_ENCODING=ON -DUSE_LIBAEC=ON -DSZIP_LIBRARY:FILEPATH="$INSTALL_PATH/lib/szip_static.lib" -DSZIP_INCLUDE_DIR="$INSTALL_PATH/include" -DSZIP_USE_EXTERNAL:BOOL=OFF -DHDF5_BUILD_CPP_LIB=ON -DHDF5_BUILD_JAVA=ON ..

sedinplace 's/Release\\libz.lib/zlibstatic.lib/g' build.ninja
ninja -j $MAKEJ HDF5_ZLIB
ninja -j $MAKEJ
ninja install
cp bin/zlib* ../../lib/
cd ..
popd
;;
*)
echo "Error: Platform \"$PLATFORM\" is not supported"
Expand All @@ -140,4 +229,5 @@ esac
[ -d "../java" ] && rm -r ../java
cp -r java/src ../java

cd ../..
# Return to cppbuild directory
popd
6 changes: 3 additions & 3 deletions hdf5/src/gen/java/org/bytedeco/hdf5/global/hdf5.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public class hdf5 extends org.bytedeco.hdf5.presets.hdf5 {
public static final int H5_HAVE_FILTER_DEFLATE = 1;

/* Define if support for szip filter is enabled */
/* #undef H5_HAVE_FILTER_SZIP */
public static final int H5_HAVE_FILTER_SZIP = 1;

/* Determine if __float128 is available */
/* #undef H5_HAVE_FLOAT128 */
Expand Down Expand Up @@ -207,7 +207,7 @@ public class hdf5 extends org.bytedeco.hdf5.presets.hdf5 {
/* #undef H5_HAVE_LIBPTHREAD */

/* Define to 1 if you have the `sz' library (-lsz). */
/* #undef H5_HAVE_LIBSZ */
public static final int H5_HAVE_LIBSZ = 1;

/* Define to 1 if you have the `ws2_32' library (-lws2_32). */
/* #undef H5_HAVE_LIBWS2_32 */
Expand Down Expand Up @@ -352,7 +352,7 @@ public class hdf5 extends org.bytedeco.hdf5.presets.hdf5 {
public static final int H5_HAVE_SYS_TYPES_H = 1;

/* Define to 1 if you have the <szlib.h> header file. */
/* #undef H5_HAVE_SZLIB_H */
public static final int H5_HAVE_SZLIB_H = 1;

/* Define if we have thread safe support */
/* #undef H5_HAVE_THREADSAFE */
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/main/java/org/bytedeco/hdf5/presets/hdf5.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"H5FaccProp.h", "H5FcreatProp.h", "H5AtomType.h", "H5PredType.h", "H5EnumType.h", "H5IntType.h", "H5FloatType.h", "H5StrType.h", "H5CompType.h",
"H5ArrayType.h", "H5VarLenType.h", "H5DataSet.h", "H5Group.h", "H5File.h", "H5Library.h"},
link = {"hdf5@.310", "hdf5_cpp@.310", "hdf5_hl@.310", "hdf5_hl_cpp@.310"}, resource = {"include", "lib"}),
@Platform(value = "windows", link = {"zlibstatic", "libhdf5", "libhdf5_cpp", "libhdf5_hl", "libhdf5_hl_cpp"}) })
@Platform(value = "windows", link = {"zlibstatic", "libhdf5", "libhdf5_cpp", "libhdf5_hl", "libhdf5_hl_cpp", "szip_static"}) })
public class hdf5 implements InfoMapper {
static { Loader.checkVersion("org.bytedeco", "hdf5"); }

Expand Down