8.8. bc 7.0.3
Build and install bc in the final target environment for standards-compatible calculator functionality.
Input assumption: bc-7.0.3.tar.xz is already present in /sources from the chapter 4 source staging step.
Source URL: https://github.com/gavinhoward/bc/releases/download/7.0.3/bc-7.0.3.tar.xz
Upstream build note: this package uses its own configure.sh build system and upstream documents ./configure.sh + make + make install for POSIX-compatible systems.
Licenses:
- BSD-2-Clause
Dependencies:
- musl (libc)
- make
bc is a POSIX arbitrary-precision calculator implementation with integrated dc mode. we need it to provide a standards-compatible calculator for scripts and interactive numeric work in chapter 8.
Extract and Enter the Source Tree
cd /sources
tar -xf bc-7.0.3.tar.xz
cd bc-7.0.3
Configure bc
bc does not use autotools configure, so lbi_configure is not applicable here.
CC="cc -std=c99" ./configure.sh \
--prefix=/system \
--bindir=/system/binaries \
--libdir=/system/libraries \
--datarootdir=/system/documentation \
--datadir=/system/documentation \
--mandir=/system/documentation/man-pages \
--man1dir=/system/documentation/man-pages/man1 \
--man3dir=/system/documentation/man-pages/man3 \
--disable-nls
Build bc
make $LWI_MAKE_FLAGS
Install bc
make install
After this step is complete, you can remove the extracted source directory and source tarball from
/sources if you do not plan to rebuild bc again.
Command Explanations
cd /sources,tar -xf, andcd bc-...: Enter the staged bc source tree.CC="cc -std=c99" ./configure.sh: Runs bc's custom configure script with a C99 compiler mode.--prefix,--bindir,--libdir, and documentation directories: Install bc into the book's/systemlayout.--disable-nls: Skips native language support for this target build.make $LWI_MAKE_FLAGS: Builds with shared make parallelism.make install: Installs bc and dc into the target filesystem.