SourceForge.net Logo

2.3. Libraries

Service that run on this router are linked against the general purpose uClibc library and some special purpose libraries described in this section.

[Note]Note

If you can not wait to see the router boot, you may skip this section and proceed to Chapter 3, Kernel, Coreutils and Boot Loader. Just remember to compile the libraries before compiling any of the applications described in Chapter 4, Daemons and Drivers.

2.3.1. Data compression (zlib)

The Zlib data compression library implements the LZ77 algorithm and Huffman coding as defined in RFC 1951 [13].

Download and unpack the sources.

wget -P $DL_DIR http://www.zlib.net/zlib-1.2.3.tar.bz2
mkdir -p $PRJ_DIR/apps
tar -C $PRJ_DIR/apps -xvjf $DL_DIR/zlib-1.2.3.tar.bz2
cd $PRJ_DIR/apps/zlib-1.2.3

Configure zlib.

make clean
CFLAGS="-Os" \
CC=${TOOLCHAIN_CROSS}gcc \
AR="${TOOLCHAIN_CROSS}ar r" \
RANLIB=${TOOLCHAIN_CROSS}ranlib \
./configure --prefix=$ROOTFS_DIR/usr \
            --exec-prefix=$ROOTFS_DIR/usr/bin \
            --libdir=$ROOTFS_DIR/usr/lib \
            --includedir=$ROOTFS_DIR/usr/include

Compile and install to rootfs.d.

make install

2.3.2. Crypto (openssl)

OpenSSL is an implementation of the Secure Sockets Layer (SSL) and Transport Layer Security (TLS). These cryptographic protocols provide secure communications on the Internet.

Download and unpack the sources.

wget -P $DL_DIR http://www.openssl.org/source/openssl-0.9.7e.tar.gz  # was 0.9.7e, 0.9.8d caused dependance on dyn dl library from static libcrypto.a
tar -C $PRJ_DIR/apps -xvzf $DL_DIR/openssl-0.9.7e.tar.gz
cd $PRJ_DIR/apps/openssl-0.9.7e

Configure.

AR="${TOOLCHAIN_CROSS}ar"    AS=${TOOLCHAIN_CROSS}as \
LD=${TOOLCHAIN_CROSS}ld      NM=${TOOLCHAIN_CROSS}nm \
CC=${TOOLCHAIN_CROSS}gcc     GCC=${TOOLCHAIN_CROSS}gcc \
CXX=${TOOLCHAIN_CROSS}g++    RANLIB=${TOOLCHAIN_CROSS}ranlib \
CPP=${TOOLCHAIN_CROSS}cpp \
CPPFLAGS="-I$TOOLCHAIN_DIR/include -I$ROOTFS_DIR/usr/include -D_FILE_OFFSET_BITS=32" \
LDFLAGS="-L$TOOLCHAIN_DIR/lib -L$ROOTFS_DIR/usr/lib" \
# was linux-pentium instead of linux-elf
./Configure --prefix=$ROOTFS_DIR/usr \
            --openssldir=$ROOTFS_DIR/usr/openssl \
             no-shared no-asm linux-elf

Compile and install to rootfs.d. Disable large file support by forcing the _FILE_OFFSET to 32.

make AR="${TOOLCHAIN_CROSS}ar r" AS=${TOOLCHAIN_CROSS}as \
     LD=${TOOLCHAIN_CROSS}ld     NM=${TOOLCHAIN_CROSS}nm \
     CC=${TOOLCHAIN_CROSS}gcc    GCC=${TOOLCHAIN_CROSS}gcc \
     CXX=${TOOLCHAIN_CROSS}g++   RANLIB=${TOOLCHAIN_CROSS}ranlib \
     CPP=${TOOLCHAIN_CROSS}cpp   \
     CPPFLAGS="-I$TOOLCHAIN_DIR/include -I$ROOTFS_DIR/usr/include -D_FILE_OFFSET_BITS=32" \
     LDFLAGS="-L$TOOLCHAIN_DIR/lib -L$ROOTFS_DIR/usr/lib" install
rm $ROOTFS_DIR/usr/bin/openssl  # not needed, use openssl on host instead, was commented out

2.3.3. Lexical (flex)

Flex is a tool for generating programs that recognize lexical patterns in text. It is often used to customize Makefiles based on the platform characteristics.

Download and unpack the (rather old) sources.

wget -P $DL_DIR http://superb-west.dl.sourceforge.net/sourceforge/flex/flex-2.5.33.tar.bz2 # was 2.5.4a
tar -C $PRJ_DIR/apps -xvjf $DL_DIR/flex-2.5.33.tar.bz2
cd $PRJ_DIR/apps/flex-2.5.33

Configure.

rm -rf config.cache
CC=${TOOLCHAIN_CROSS}gcc CFLAGS='-Os' ./configure \
       --host=i586-linux \
       --prefix=$ROOTFS_DIR/usr \
       --exec-prefix=$ROOTFS_DIR/usr

Compile and install to rootfs.d..

make libfl.a
make INSTALL_PROGRAM="/usr/bin/install -s" install

2.3.4. Wireless Configuration (wireless_tools)

The Wireless Tools is a collection of tools to manipulate wireless drivers at runtime.

[Note]Note

To do: madwifi now contains its own wlanconfig command that might perform the function of iwconfig and iwpriv.

Download and unpack the sources.

wget -P $DL_DIR http://pcmcia-cs.sourceforge.net/ftp/contrib/wireless_tools.28.tar.gz # was 27
tar -C $PRJ_DIR/apps -xvzf $DL_DIR/wireless_tools.28.tar.gz
cd $PRJ_DIR/apps/wireless_tools.28

Compile and install to rootfs.d. For more information, see the man pages (man -M $ROOTFS_DIR/usr/man 8 iwconfig). Note that ldconfig fails, but the dynamic library is still installed correctly. The typical warning is *** Don't forget to add .../usr/lib/ to /etc/ld.so.conf, and run ldconfig

make clean
make CC=${TOOLCHAIN_CROSS}gcc PREFIX=$ROOTFS_DIR/usr BUILD_SHARED=y install
( cd $ROOTFS_DIR/usr/sbin; strip iwconfig iwpriv ; rm iwlist iwspy iwgetid iwevent ifrename )
strip $ROOTFS_DIR/usr/lib/libiw.so.28

2.3.5. IP Routing Configuration (iproute2)

Add traffic shaping. Busybox does not include the tool for configuring the traffic shapers. Instead use the full blown iproute2 sources. (Install the Linux kernel first., see Section 3.1, “Kernel - linux”.)

wget -P $DL_DIR http://developer.osdl.org/dev/iproute2/download/iproute2-2.6.23.tar.gz  # was 2.6.18-061002, 2.6.22-070710
mkdir $PRJ_DIR/apps/iproute2-2.6.23
tar -C $PRJ_DIR/apps/iproute2-2.6.23 -xvzf $DL_DIR/iproute2-2.6.23.tar.gz
cd $PRJ_DIR/apps/iproute2-2.6.23

Compile

make KERNEL_INCLUDE=$LINUX_DIR/include DBM_INCLUDE=  CC=${TOOLCHAIN_CROSS}gcc AR=${TOOLCHAIN_CROSS}ar DESTDIR=$ROOTFS_DIR SUBDIRS="lib tc" install

Reference: http://lartc.org/.