Preparing the LFS system for installing basic system software

Installing Binutils


./configure
make -e LDFLAGS=-all-static
make -e prefix=$LFS/usr install

Installing Bzip2


make -e LDFLAGS=-static
make -e PRFIX=$LFS/usr install
cd $LFS/usr/bin
mv bunzip2 bzip2 $LFS/bin

Installing Diffutils


./configure
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install

This package is known to cause static link problems on certain platforms. If you're having trouble compiling this package as well, you can download a fixed package from http://www.linuxfromscratch.org/download/diffutils-2.7-fixed.tar.gz

Installing Fileutils


./configure --disable-nls
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install
cd $LFS/usr/bin
mv chgrp chmod chown cp dd df ln $LFS/bin
mv ls mkdir mknod mv rm rmdir sync $LFS/bin

Installing GCC on the normal system if necessary

In order to compile Glibc-2.1.3 you need to have gcc-2.95.2 installed. Although any version above 2.8 would do, 2.95.2 is the highlyl recommended version to use. Many glibc-2.0 based systems have gcc-2.7.2.3 installed and you can't compile glibc-2.1.3 with that compiler. Many glibc-2.1 based systems have egcs-2.95.x installed and that version doesn't work too well either (sometimes it works fine, sometimes it doesn't The reason is still unknown).

If you normal Linux system does not have gcc-2.95.2 installed you need to install it now. We won't replace the current compiler on your system, but in stead we will install gcc in a separate directory (/usr/local/gcc2952). This way no binaries or header files will be replaced.


mkdir $LFS/usr/src/gcc-build
cd $LFS/usr/src/gcc-build
../gcc-2.95.2/configure --prefix=/usr/local/gcc2952 \
        --with-local-prefix=/usr/local/gcc2952
        --with-gxx-include-dir=/usr/local/gcc2952/include/g++ \
        --enable shared --enable-languages=c,c++
make bootstrap
make install

Installing GCC on the LFS system


mkdir $LFS/usr/src/gcc-build
cd $LFS/usr/src/gcc-build
../gcc-2.95.2/configure --enable-languages=c,++ --disable-nls
make -e LDFLAGS=-static bootstrap
make -e prefix=$LFS/usr local_prefix=$LFS/usr install

Creating necessary symlinks

The system needs a few symlinks to ensure every program is able to find the compiler and the pre-processor. Some programs run the cc program, others run the gcc program. Some programs expect the cpp program in /lib and others expect to find it in /usr/bin.

  • Create those symlinks by running:


cd $LFS/lib
ln -s ../usr/lib/gcc-lib/<host>/2.95.2/cpp cpp
cd $LFS/usr/lib
ln -s gcc-lib/<host>/2.95.2/cpp cpp
cd $LFS/usr/bin
ln -s gcc cc

Replace <host> with the directory where the gcc-2.95.2 files are installed (which is i686-unknown-linux in my case).

Installing Glibc

A note on the glibc-crypt package

An excerpt from the README file that is distributed with the glibc-crypt package:

The add-on is not included in the main distribution of the GNU C library because some governments, most notably those of France, Russia, and the US, have very restrictive rules governing the distribution and use of encryption software. Please read the node "Legal Problems" in the manual for more details.

In particular, the US does not allow export of this software without a licence, including via the Internet. So please do not download it from the main FSF FTP site at ftp.gnu.org if you are outside the US. This software was completely developed outside the US.

"This software" refers to the glibc-crypt package at ftp://ftp.gwdg.de/pub/linux/glibc/. This law only affects people who don't live in the US. It's not prohibited to import DES software, so if you live in the US you can import the file safely from Germany without breaking cryptographic laws. This law is changing lately and I don't know what the status of it is at the moment. Better be safe than sory.

Installing Glibc

  • Unpack the Glibc archive

  • Copy the Glibc-crypt and Glibc-linuxthreads archives into the unpacked glibc directory

  • Unpack the glibc-crypt and glibc-linuxthreads archives there, but don't enter the created directories. Just unpack and leave it with that.

  • Create a new file configparms containing:


# Begin configparms
slibdir=/lib
sysconfdir=/etc
# End configparms

  • For PPC only: Copy the glibc-2.1.3-ctype.patch file to the $LFS/usr/src directory and apply the patch by running:


cd $LFS/usr/src/glibc-2.1.3
patch -p1 < ../glibc-2.3.1-ctype.patch

  • If your normal already had a gcc version suitable to compile glibc with, install the package by running:


mkdir $LFS/usr/src/glib-build
cd $LFS/usr/src/glibc-build
../glibc-2.1.3/configure --enable-add-ons
make
make install_root=$LFS install

  • If your normal system didn'd had a suitable gcc version, install the package by running:


mkdir $LFS/usr/src/glibc-build
cd $LFS/usr/src/glibc-build
CC=/usr/gcc2952/bin/gcc \
          ../glibc-2.1.3/configure --enable-add-ons
make
make install_root=$LFS install

Copying old NSS library files

If your normal Linux system runs glibc-2.0, you need to copy the NSS library files to the LFS partition. Certain statically linked programs still depend on the NSS library, especially programs that need to lookup usernames,userid's and groupid's. You can check which C library version your normal Linux system uses by running:


ls /lib/libc*

Your system uses glib-2.0 if there is a file that looks like libc-2.0.7.so

Your system uses glibc-2.1 if there is a file that looks like libc-2.1.3.so

Of course, the micro version number can be different (you could have libc-2.1.2 or libc-2.1.1 for example).

If you have a libc-2.0.x file copy the NSS library files by running:


cp -av /lib/*nss* $LFS/lib

There are a few distributions that don't have files from which you can see which version of the C Library it is. If that's the case, it will be hard to determine which C library version you exactly have. Try to obtain this information using your distribution's installation tool. It often says which version it has available. If you can't figure out at all which C Library version is used, then copy the NSS files anyway and hope for the best. That's the best advise I can give I'm afraid.

Installing Grep


./configure --disable-nls
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install

This package is known to cause static linking problems on certain platforms. If you're having trouble compiling this package as well, you can download a fixed package from http://www.linuxfromscratch.org/download/grep-2.4-fixed.tar.gz

Installing Gzip


./configure
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install
cd $LFS/usr/bin
mv gunzip gzip $LFS/bin

This package is known to cause compilation problems on certain platforms. If you're having trouble compiling this package as well, you can download a fixed package from http://www.linuxfromscratch.org/download/gzip-1.2.4-fixed.tar.gz

Installing Make


./configure
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install

Installing Sed


./configure
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install

This package is known to cause static linking problems on certain platforms. If you're having trouble compiling this package as well, you can download a fixed package from http://www.linuxfromscratch.org/download/sed-3.03-fixed.tar.gz

Installing Shell Utils


./configure --disable-nls
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install
cd $LFS/usr/bin
mv date echo false pwd stty $LFS/bin
mv su true uname hostname $LFS/bin

Installing Tar


./configure --disable-nls
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install
mv $LFS/usr/bin/tar $LFS/bin

Installing Textutils


./configure --disable-nls
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install
mv $LFS/usr/bin/cat $LFS/bin

Installing Util-Linux


./configure
cd lib
make
cd ../mount
make -e LDFLAGS=-static
cp mount umount $LFS/bin
cp swapon $LFS/sbin

Installing Pmac-utils (PPC systems only)


make clock
cp clock $LFS/sbin


#!/bin/sh
# Begin /sbin/hwclock

/sbin/clock -s

# End /sbin/hwclock


chmod 755 hwclock
mv hwclock $LFS/sbin