8.30. zlib-ng stage 2 2.3.3
zlib-ng provides zlib-compatible compression and decompression libraries
Input assumption:
zlib-ng-2.3.3.tar.gz is already present in LBI_SOURCES from the chapter 4 source staging step.
Licenses:
- zlib License
Dependencies:
- musl (libc)
- cmake
- ninja (samurai)
zlib-ng is a deflate compression library with a zlib-compatible API mode. This is the final build of zlib-ng.
Extract and Enter the Source Tree
cd "$LBI_SOURCES"
tar -xf zlib-ng-2.3.3.tar.gz
cd zlib-ng-2.3.3
Configure zlib-ng
lbi_cmake build \
-DCMAKE_C_COMPILER="clang" \
-DCMAKE_C_FLAGS="$LWI_CFLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$LBI_CUSTOM_LDFLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$LBI_CUSTOM_LDFLAGS" \
-DZLIB_COMPAT=ON \
-DBUILD_TESTING=OFF \
-DINSTALL_UTILS=ON \
-G Ninja
Build zlib-ng
cmake --build build $LWI_MAKE_FLAGS
Install zlib-ng
cmake --install build
Remove static library
rm -f /system/libraries/libz.a
Command Explanations
cd "$LBI_SOURCES",tar -xf, andcd zlib-ng-...: Enter the staged zlib-ng source tree.lbi_cmake build: Configures zlib-ng with the book's CMake helper.-DCMAKE_C_COMPILER="clang": Builds with the final target Clang.-DCMAKE_C_FLAGS, shared-linker flags, and exe-linker flags: Apply local compile and link tuning.-DZLIB_COMPAT=ON: Builds zlib-compatible headers and library names.-DBUILD_TESTING=OFF: Skips tests in this target build.-DINSTALL_UTILS=ON: Installs zlib-ng utilities in the final target environment.cmake --buildandcmake --install: Build and install the configured tree.rm -f /system/libraries/libz.a: Removes the static zlib archive so shared linking remains the default.