Linux From Scratch: Version 5.0-pre1
Prev | Chapter 6. Installing basic system software | Next

# Installing Glibc-2.3.2

    Estimated build time:           14.0 SBU
    Estimated required disk space:  369 MB

## Contents of Glibc

(Last checked against version 2.2.5.)

Glibc is the C library that provides the system calls and basic functions such as open, malloc, printf, etc. The C library is used by all dynamically linked programs.

Glibc installs the following files:

### Program Files

catchsegv, gencat, getconf, getent, glibcbug, iconv, iconvconfig, ldconfig, ldd, lddlibc4, locale, localedef, mtrace, nscd, nscd_nischeck, pcprofiledump, pt_chown, rpcgen, rpcinfo, sln, sprof, tzselect, xtrace, zdump and zic

### Library Files

ld.so, libBrokenLocale.[a,so], libSegFault.so, libanl.[a,so], libbsd-compat.a, libc.[a,so], libc_nonshared.a, libcrypt.[a,so], libdl.[a,so], libg.a, libieee.a, libm.[a,so], libmcheck.a, libmemusage.so, libnsl.a, libnss_compat.so, libnss_dns.so, libnss_files.so, libnss_hesiod.so, libnss_nis.so, libnss_nisplus.so, libpcprofile.so, libpthread.[a,so], libresolv.[a,so], librpcsvc.a, librt.[a,so], libthread_db.so and libutil.[a,so]

##

## Glibc Installation Dependencies

(Last checked against version 2.2.5.)

Bash: sh
Binutils: ar, as, ld, ranlib, readelf
Coreutils: cat, chmod, cp, cut, date, expr, hostname, install, ln,
mknod, mv, mkdir, rm, pwd, sort, touch, tr, uname
Diffutils: cmp
Gawk: gawk
GCC: cc, cc1, collect2, cpp, gcc
Grep: egrep, grep
Gzip: gzip
Make: make
Sed: sed
Texinfo: install-info, makeinfo

##

## Glibc installation

The Glibc build system is very well self-contained and will install perfectly, even though our compiler specs file and linker are still pointing at `/tools`. We cannot adjust the specs and linker before the Glibc install, because the Glibc autoconf tests would then give bogus results and thus defeat our goal of achieving a clean build.

> Note: The testsuite for Glibc in this chapter is considered critical. Do not skip it under any circumstances.

Before starting to build Glibc, remember to unpack the Glibc-linuxthreads again inside the `glibc-2.3.2` directory, and to unset any environment variables that override the default optimization flags.

Then apply the same patch we used previously:

    patch -Np1 -i ../glibc-2.3.2-sscanf-1.patch

The documentation that comes with Glibc recommends to build the package not in the source directory but in a separate, dedicated directory:

    mkdir ../glibc-build
    cd ../glibc-build

Now prepare Glibc for compilation:

    ../glibc-2.3.2/configure --prefix=/usr \
        --disable-profile --enable-add-ons \
        --libexecdir=/usr/bin --with-headers=/usr/include

The meaning of the configure options:

- `--disable-profile`: This disables the building of the libraries with profiling information. Omit this option if you plan to do profiling.

- `--enable-add-ons`: This enables any add-ons that we installed with Glibc, in our case Linuxthreads.

- `--libexecdir=/usr/bin`: This will cause the `pt_chown` program to be installed in the `/usr/bin` directory.

- `--with-headers=/usr/include`: This ensures that the kernel headers in `/usr/include` are used for this build. If you don't pass this switch then the headers from `/tools/include` are used which of course is not ideal (although they should be identical). Using the switch has the advantage that you will be informed immediately should you have forgotten to install the kernel headers into `/usr/include`.

Compile the package:

    make

Test the results:

    make check

And install the package:

    make install

The locales that can make your system respond in a different language weren't installed by the above command. Do it with this:

    make localedata/install-locales

An alternative to running the previous command is to install only those locales which you need or want. This can be achieved using the `localedef` command. Information on this can be found in the `INSTALL` file in the `glibc-2.3.2` tree. However, there are a number of locales that are essential for the tests of future packages to pass correctly. The following instructions, in place of the install-locales command above, will install the minimum set of locales necessary for the tests to run successfully:

    mkdir -p /usr/lib/locale
    localedef -i de_DE -f ISO-8859-1 de_DE
    localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
    localedef -i en_HK -f ISO-8859-1 en_HK
    localedef -i en_PH -f ISO-8859-1 en_PH
    localedef -i en_US -f ISO-8859-1 en_US
    localedef -i es_MX -f ISO-8859-1 es_MX
    localedef -i fr_FR -f ISO-8859-1 fr_FR
    localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
    localedef -i it_IT -f ISO-8859-1 it_IT
    localedef -i ja_JP -f EUC-JP ja_JP

Finally, build the linuxthreads man pages:

    make -C ../glibc-2.3.2/linuxthreads/man

And install these pages:

    make -C ../glibc-2.3.2/linuxthreads/man install

##

## Configuring Glibc

We need to create the `/etc/nsswitch.conf` file, because, although Glibc provides defaults when this file is missing or corrupt, the Glibc defaults don't work well with networking. Also, our timezone needs to be set up.

Create a new file `/etc/nsswitch.conf` by running the following:

    cat > /etc/nsswitch.conf << "EOF"
    # Begin /etc/nsswitch.conf

    passwd: files
    group: files
    shadow: files

    publickey: files

    hosts: files dns
    networks: files

    protocols: db files
    services: db files
    ethers: db files
    rpc: db files

    netgroup: db files

    # End /etc/nsswitch.conf
    EOF

To find out what timezone you're in, run the following script:

    tzselect

When you've answered a few questions about your location, the script will output the name of your timezone, something like EST5EDT or Canada/Eastern. Then create the `/etc/localtime` file by running:

    cp --remove-destination /usr/share/zoneinfo/Canada/Eastern /etc/localtime

Of course, instead of Canada/Eastern, fill in the name of the timezone that the `tzselect` script gave you.

##

## Configuring Dynamic Loader

By default, the dynamic loader (`/lib/ld-linux.so.2`) searches through `/lib` and `/usr/lib` for dynamic libraries that are needed by programs when you run them. However, if there are libraries in directories other than `/lib` and `/usr/lib`, you need to add them to the `/etc/ld.so.conf` file for the dynamic loader to find them. Two directories that are commonly known to contain additional libraries are `/usr/local/lib` and `/opt/lib`, so we add those directories to the dynamic loader's search path.

Create a new file `/etc/ld.so.conf` by running the following:

    cat > /etc/ld.so.conf << "EOF"
    # Begin /etc/ld.so.conf

    /usr/local/lib
    /opt/lib

    # End /etc/ld.so.conf
    EOF

Prev | Home | Next
Installing Man-pages-1.60 | Up | Re-adjusting the toolchain