The uClibc package contains the main C library. This library provides the basic routines for allocating memory, searching directories, opening and closing files, reading and writing files, string handling, pattern matching, arithmetic, and so on.
By default uClibc symlinks the headers to the source directory. This is not acceptable in our build scenario, so we modify the Makefiles so that the headers will be copied instead:
cp Makefile Makefile.orig
sed -e 's/$(LN) -fs/cp/g' Makefile.orig > Makefile
for file in `find libc/sysdeps/linux -name Makefile`; do
cp $file $file.orig
sed -e 's/$(LN) -fs/cp/g' -e 's@../libc/@$(TOPDIR)libc/@g' $file.orig > $file
done
Below we are just telling uClibc to use its default configuration. For those for more adventureous, you can use make menuconfig, and do a more custom build for your uClibc installation.
Create the default configuration:
make defconfig
We will need to edit the configuration file, to make sure everything gets compiled and put into its proper location:
cp .config .config.orig
sed -e "/^CROSS_COMPILER_PREFIX/s:=.*:=\"${CLFS_TARGET}-\":" \
-e "/^KERNEL_SOURCE/s:=.*:=\"${CLFS}/usr\":" \
-e "/^SHARED_LIB_LOADER_PREFIX/s:=.*:=\"/lib\":" \
-e "/^DEVEL_PREFIX/s:=.*:=\"/usr\":" \
-e "/^RUNTIME_PREFIX/s:=.*:=\"/\":" \
.config.orig > .config
We will need to make sure that some settings in uClibc are set so we can utilize all the features of BusyBox:
UCLIBC_OPTIONS="DO_C99_MATH UCLIBC_HAS_RPC UCLIBC_HAS_CTYPE_CHECKED
UCLIBC_HAS_WCHAR UCLIBC_HAS_HEXADECIMAL_FLOATS UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE
UCLIBC_HAS_PRINTF_M_SPEC UCLIBC_HAS_FTW UCLIBC_HAS_IPV6 UCLIBC_HAS_GLIBC_CUSTOM_PRINTF
UCLIBC_USE_NETLINK LDSO_PRELOAD_FILE_SUPPORT"
for config in $UCLIBC_OPTIONS; do
cp .config .config.orig
sed -e "s:# ${config} is not set:${config}=y:" .config.orig > .config
done
echo "UCLIBC_HAS_FULL_RPC=y" >> .config
echo "UCLIBC_HAS_REENTRANT_RPC=y" >> .config
We have made some changes to our config, let's make sure that we didn't miss and dependencies:
make TARGET_ARCH=i386 oldconfig
Compile the package:
make CC="${CC} ${BUILD}" TARGET_ARCH=i386
The uClibc build system creates symlinks in its include directory pointing to ${CLFS}/usr/include. We will need to remove these symlinks from the source dir:
rm include/{asm,asm-generic,linux}
Install the package:
make PREFIX=${CLFS} install