8.6. zstd stage 2 1.5.7
Build and install zstd in the final target environment so zstd compression libraries and tools are available to later packages.
Input assumption: zstd-1.5.7.tar.gz is already present in /sources from the chapter 4 source staging step.
Source URL: https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz
Upstream build note: upstream documents GNU make as the maintained build system and supports staged install variables such as PREFIX, BINDIR, LIBDIR, INCLUDEDIR, and PKGCONFIGDIR.
Licenses:
- BSD-3-Clause
Dependencies:
- musl (libc)
- clang
- make
- zlib-ng
- xz
zstd is a lossless compression library and command-line tool. we need it to provide libzstd and the zstd utilities used by LLVM and other target packages.
Extract and Enter the Source Tree
cd /sources
rm -rf zstd-1.5.7
tar -xf zstd-1.5.7.tar.gz
cd zstd-1.5.7
Build zstd
CC=clang \
CFLAGS="$LWI_CFLAGS" \
LDFLAGS="$LBI_CUSTOM_LDFLAGS" \
make $LWI_MAKE_FLAGS
Install zstd
CC=clang \
CFLAGS="$LWI_CFLAGS" \
LDFLAGS="$LBI_CUSTOM_LDFLAGS" \
make install \
PREFIX=/system \
BINDIR=/system/binaries \
LIBDIR=/system/libraries \
INCLUDEDIR=/system/headers \
MANDIR=/system/documentation/man-pages \
PKGCONFIGDIR=/system/libraries/pkgconfig
Verify zstd
zstd --version
ls /system/binaries/zstd
Command Explanations
rm -rf zstd-1.5.7: Removes any previous extracted source tree before rebuilding.tar -xf zstd-1.5.7.tar.gz: Extracts the staged zstd source archive.CC=clang: Builds zstd with the target Clang compiler.CFLAGSandLDFLAGS: Apply local compile and link tuning through the environment so zstd's Makefiles can still append required flags such as-fPIC,-shared, and-pthread.make $LWI_MAKE_FLAGS: Builds zstd with the shared make parallelism setting.make install PREFIX=/system ...: Installs commands, libraries, headers, man pages, and pkg-config metadata into the book's layout.zstd --versionandls /system/binaries/zstd: Verify that the command and library are available in the correct locations.