6.21. xz 5.8.3
xz provides liblzma and command-line tools for .xz and .lzma compression workflows in the target userspace.
Input assumption:
xz-5.8.3.tar.xz is already present in LBI_SOURCES from the chapter 4 source staging step.
Licenses:
- 0BSD
Dependencies:
- musl (libc)
- cmake
- make
xz is a compression toolkit that provides liblzma and .xz/.lzma command-line tools. we need it to provide xz and liblzma for compression workflows and later package dependencies.
Extract and Enter the Source Tree
cd "$LBI_SOURCES"
tar -xf xz-5.8.3.tar.xz
cd xz-5.8.3
Configure xz (CMake Path)
Upstream note:
INSTALL documents the CMake options for this package (XZ_*, TUKLIB_*, and CMAKE_*), including XZ_NLS and tool toggles.
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_INSTALL_PREFIX=/system \
-DCMAKE_INSTALL_BINDIR=binaries \
-DCMAKE_INSTALL_SBINDIR=systembinaries \
-DCMAKE_INSTALL_LIBDIR=libraries \
-DCMAKE_INSTALL_LIBEXECDIR=systembinaries \
-DCMAKE_INSTALL_INCLUDEDIR=headers \
-DCMAKE_INSTALL_SYSCONFDIR=configuration \
-DCMAKE_INSTALL_LOCALSTATEDIR=variable \
-DCMAKE_INSTALL_MANDIR=documentation/man-pages \
-DCMAKE_INSTALL_INFODIR=documentation/info \
-DCMAKE_INSTALL_DATAROOTDIR=documentation \
-DCMAKE_INSTALL_DOCDIR=documentation/xz \
-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" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTING=OFF \
-DXZ_NLS=OFF \
-DXZ_DOXYGEN=OFF
Build xz
cmake --build build $LWI_MAKE_FLAGS
Install xz
DESTDIR="$LBI_ROOT" cmake --install build
Command Explanations
lbi_cmake build: Configures xz with the book's CMake helper and writes generated files into thebuilddirectory.-DCMAKE_C_COMPILER,-DCMAKE_AR, and-DCMAKE_RANLIB: Use the target-prefixed LLVM compiler and archive tools.-DCMAKE_INSTALL_PREFIX=/systemand theCMAKE_INSTALL_*DIRsettings: Keep xz's install paths aligned with the book's/systemlayout.-DCMAKE_INSTALL_DATAROOTDIR=documentationand-DCMAKE_INSTALL_DOCDIR=documentation/xz: Place package documentation under the documentation tree instead ofshare.-DCMAKE_C_FLAGS,-DCMAKE_SHARED_LINKER_FLAGS, and-DCMAKE_EXE_LINKER_FLAGS: Target the selected triple/sysroot and preserve local compile/link tuning.-DCMAKE_BUILD_TYPE=Release: Uses the release build profile.-DBUILD_SHARED_LIBS=ON: Builds shared liblzma libraries for the target.-DBUILD_TESTING=OFF: Skips test programs during the bootstrap build.-DXZ_NLS=OFF: Disables native language support so this pass does not depend on gettext.-DXZ_DOXYGEN=OFF: Skips generated API documentation.cmake --build build $LWI_MAKE_FLAGS: Builds the configured tree with the shared parallel build setting.DESTDIR="$LBI_ROOT" cmake --install build: Installs into the target root instead of the host filesystem.