7.10. uClibc-snapshot

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.

7.10.1. Installation of uClibc

Since we are cross-compiling, we need to make sure when we configuration for our architecture we get the correct information. The following sed makes sure we are using the proper settings for our architecture:

cp extra/Configs/Config.in extra/Configs/Config.in.orig
sed -e "s:default TARGET_i386:default TARGET_mips:" \
   extra/Configs/Config.in.orig > extra/Configs/Config.in
cp extra/Configs/Config.mips extra/Configs/Config.mips.orig
sed -e "s:default CONFIG_MIPS_ISA_1:default CONFIG_MIPS_ISA_${CLFS_MIPS_LEVEL}:" \
   extra/Configs/Config.mips.orig > extra/Configs/Config.mips

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
[Note]

Note

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

If your MIPS system is Big Endian, you will need at add the following lines to your configuration:

echo "ARCH_ANY_ENDIAN=y" >> .config
echo "ARCH_BIG_ENDIAN=y" >> .config
echo "ARCH_WANTS_BIG_ENDIAN=y" >> .config

If your MIPS system is Little Endian, you will need at add the following lines to your configuration:

echo "ARCH_ANY_ENDIAN=y" >> .config
echo "ARCH_LITTLE_ENDIAN=y" >> .config
echo "ARCH_WANTS_LITTLE_ENDIAN=y" >> .config

We have made some changes to our config, let's make sure that we didn't miss and dependencies:

make TARGET_ARCH=mips oldconfig

Compile the package:

make CC="${CC} ${BUILD}" TARGET_ARCH=mips

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

Details on this package are located in Section , “.”