6.11. zlib-ng 2.3.3
zlib-ng provides zlib-compatible compression and decompression libraries for the target system.
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
zlib-ng is a deflate compression library with a zlib-compatible API mode. we need it to provide libz for packages in later chapters that depend on zlib-compatible compression support.
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="$LBI_ROOT/system/tools/bin/$LBI_TARGET-clang" \
-DCMAKE_AR="$LBI_ROOT/system/tools/bin/$LBI_TARGET-ar" \
-DCMAKE_RANLIB="$LBI_ROOT/system/tools/bin/$LBI_TARGET-ranlib" \
-DCMAKE_C_FLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LWI_CFLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LBI_CUSTOM_LDFLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LBI_CUSTOM_LDFLAGS" \
-DZLIB_COMPAT=ON \
-DBUILD_TESTING=OFF \
-DINSTALL_UTILS=OFF
Build zlib-ng
cmake --build build $LWI_MAKE_FLAGS
Install zlib-ng
DESTDIR="$LBI_ROOT" cmake --install build
Command Explanations
lbi_cmake build: Configures zlib-ng with the book's CMake helper and writes generated files into thebuilddirectory.-DCMAKE_C_COMPILER="$LBI_ROOT/system/tools/bin/$LBI_TARGET-clang": Uses the target-prefixed Clang compiler.-DCMAKE_ARand-DCMAKE_RANLIB: Use the matching target-prefixed archive tools.-DCMAKE_C_FLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LWI_CFLAGS": Targets the selected triple and sysroot while preserving local C flag tuning.-DCMAKE_SHARED_LINKER_FLAGSand-DCMAKE_EXE_LINKER_FLAGS: Keep shared-library and executable link steps pointed at the target sysroot.-DZLIB_COMPAT=ON: Builds zlib-ng in zlib-compatible API and library-name mode.-DBUILD_TESTING=OFF: Skips test programs that are not needed for the target bootstrap.-DINSTALL_UTILS=OFF: Installs the library and headers without zlib-ng's optional command-line utilities.cmake --build build $LWI_MAKE_FLAGS: Builds the configured tree using the shared parallel build setting.DESTDIR="$LBI_ROOT" cmake --install build: Installs into the target root instead of the host filesystem.