Skip to content

Commit

Permalink
Unix: Build Zlib 1.2.12
Browse files Browse the repository at this point in the history
Otherwise it might not be cross-compiled. Used in HDF5.
  • Loading branch information
ax3l committed May 24, 2022
1 parent 6b87bcd commit bc458d7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
12 changes: 6 additions & 6 deletions library_builders.bat
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ exit /b 0
:build_zlib
if exist zlib-stamp exit /b 0

curl -sLo zlib-1.2.11.zip ^
https://github.com/madler/zlib/archive/v1.2.11.zip
powershell Expand-Archive zlib-1.2.11.zip -DestinationPath dep-zlib
curl -sLo zlib-1.2.12.zip ^
https://github.com/madler/zlib/archive/v1.2.12.zip
powershell Expand-Archive zlib-1.2.12.zip -DestinationPath dep-zlib

cmake -S dep-zlib/zlib-1.2.11 -B build-zlib ^
-DBUILD_SHARED_LIBS=OFF
cmake -S dep-zlib/zlib-1.2.12 -B build-zlib ^
-DBUILD_SHARED_LIBS=OFF ^
-DCMAKE_BUILD_TYPE=Release
if errorlevel 1 exit 1
:: TODO: zlib 1.2.11 ignores -DCMAKE_BUILD_TYPE=Release

cmake --build build-zlib --parallel %CPU_COUNT%
if errorlevel 1 exit 1
Expand Down
32 changes: 29 additions & 3 deletions library_builders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,30 @@ function build_zfp {
touch zfp-stamp
}

function build_zlib {
if [ -e zlib-stamp ]; then return; fi

ZLIB_VERSION="1.2.12"

curl -sLO https://zlib.net/fossils/zlib-$ZLIB_VERSION.tar.gz
file zlib*.tar.gz
tar xzf zlib-$ZLIB_VERSION.tar.gz
rm zlib*.tar.gz

PY_BIN=$(which python3)
CMAKE_BIN="$(${PY_BIN} -m pip show cmake 2>/dev/null | grep Location | cut -d' ' -f2)/cmake/data/bin/"
PATH=${CMAKE_BIN}:${PATH} cmake \
-S zlib-* \
-B build-zlib \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release

PATH=${CMAKE_BIN}:${PATH} cmake --build build-zlib --parallel ${CPU_COUNT}
PATH=${CMAKE_BIN}:${PATH} cmake --build build-zlib --target install

touch zlib-stamp
}

function build_hdf5 {
if [ -e hdf5-stamp ]; then return; fi

Expand Down Expand Up @@ -266,6 +290,7 @@ function build_hdf5 {
--disable-shared \
--enable-static \
--enable-tests=no \
--with-zlib=${BUILD_PREFIX} \
${HOST_ARG} \
--prefix=${BUILD_PREFIX}

Expand Down Expand Up @@ -296,12 +321,13 @@ export CXXFLAGS+=" -fPIC"
if [[ "${CMAKE_OSX_ARCHITECTURES-}" == "arm64" ]]; then
export CC="/usr/bin/clang"
export CXX="/usr/bin/clang++"
export CFLAGS="$CFLAGS -arch arm64"
export CPPFLAGS="$CPPFLAGS -arch arm64"
export CXXFLAGS="$CXXFLAGS -arch arm64"
export CFLAGS+=" -arch arm64"
export CPPFLAGS+=" -arch arm64"
export CXXFLAGS+=" -arch arm64"
fi

install_buildessentials
build_zlib
build_blosc
build_zfp
build_hdf5
Expand Down

0 comments on commit bc458d7

Please sign in to comment.