Cross-Compiled Linux From Scratch

Version 2.0.0-x86_64-Multilib

Copyright © 2005-2013, Joe Ciccone, Jim Gifford, & Ryan Oliver

All rights reserved.

This material may be distributed only subject to the terms and conditions set forth in the Open Publication License v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/).

Linux® is a registered trademark of Linus Torvalds.

This book is based on the "Linux From Scratch" book, that was released under the following license:

Copyright © 1999–2013, Gerard Beekmans

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions in any form must retain the above copyright notice, this list of conditions and the following disclaimer

  • Neither the name of “Linux From Scratch” nor the names of its contributors may be used to endorse or promote products derived from this material without specific prior written permission

  • Any material derived from Linux From Scratch must contain a reference to the “Linux From Scratch” project

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Table of Contents

Preface

Foreword

The Linux From Scratch Project has seen many changes in the few years of its existence. I personally became involved with the project in 1999, around the time of the 2.x releases. At that time, the build process was to create static binaries with the host system, then chroot and build the final binaries on top of the static ones.

Later came the use of the /static directory to hold the initial static builds, keeping them separated from the final system, then the PureLFS process developed by Ryan Oliver and Greg Schafer, introducing a new toolchain build process that divorces even our initial builds from the host. Finally, LFS 6 brought Linux Kernel 2.6, the udev dynamic device structure, sanitized kernel headers, and other improvements to the Linux From Scratch system.

The one "flaw" in LFS is that it has always been based on an x86 class processor. With the advent of the Athlon 64 and Intel EM64T processors, the x86-only LFS is no longer ideal. Throughout this time, Ryan Oliver developed and documented a process by which you could build Linux for any system and from any system, by use of cross-compilation techniques. Thus, the Cross-Compiled LFS (CLFS) was born.

CLFS follows the same guiding principles the LFS project has always followed, e.g., knowing your system inside and out by virtue of having built the system yourself. Additionally, during a CLFS build, you will learn advanced techniques such as cross-build toolchains, multilib support (32 & 64-bit libraries side-by-side), alternative architectures such as Sparc, MIPS, and Alpha, and much more.

We hope you enjoy building your own CLFS system, and the benefits that come from a system tailored to your needs.

--
Jeremy Utley, CLFS 1.x Release Manager (Page Author)
Jonathan Norman, Release Manager
Jim Gifford, CLFS Project Co-leader
Ryan Oliver, CLFS Project Co-leader
Joe Ciccone, CLFS Project Co-leader
Jonathan Norman, Justin Knierim, Chris Staub, Matt Darcy, Ken Moffat,
Manuel Canales Esparcia, Nathan Coulson and William Harrington - CLFS Developers

Audience

There are many reasons why somebody would want to read this book. The principal reason is to install a Linux system from the source code. A question many people raise is, “why go through all the hassle of manually building a Linux system from scratch when you can just download and install an existing one?” That is a good question and is the impetus for this section of the book.

One important reason for the existence of CLFS is to help people understand how a Linux system works. Building an CLFS system helps demonstrate what makes Linux tick, and how things work together and depend on each other. One of the best things this learning experience provides is the ability to customize Linux to your own tastes and needs.

A key benefit of CLFS is that it allows users to have more control over their system without any reliance on a Linux implementation designed by someone else. With CLFS, you are in the driver's seat and dictate every aspect of the system, such as the directory layout and bootscript setup. You also dictate where, why, and how programs are installed.

Another benefit of CLFS is the ability to create a very compact Linux system. When installing a regular distribution, one is often forced to include several programs which are probably never used. These programs waste disk space or CPU cycles. It is not difficult to build an CLFS system of less than 100 megabytes (MB), which is substantially smaller than the majority of existing installations. Does this still sound like a lot of space? A few of us have been working on creating a very small embedded CLFS system. We successfully built a system that was specialized to run the Apache web server with approximately 8MB of disk space used. Further stripping could bring this down to 5 MB or less. Try that with a regular distribution! This is only one of the many benefits of designing your own Linux implementation.

We could compare Linux distributions to a hamburger purchased at a fast-food restaurant—you have no idea what might be in what you are eating. CLFS, on the other hand, does not give you a hamburger. Rather, CLFS provides the recipe to make the exact hamburger desired. This allows users to review the recipe, omit unwanted ingredients, and add your own ingredients to enhance the flavor of the burger. When you are satisfied with the recipe, move on to preparing it. It can be made to exact specifications—broil it, bake it, deep-fry it, or barbecue it.

Another analogy that we can use is that of comparing CLFS with a finished house. CLFS provides the skeletal plan of a house, but it is up to you to build it. CLFS maintains the freedom to adjust plans throughout the process, customizing it to the needs and preferences of the user.

Security is an additional advantage of a custom built Linux system. By compiling the entire system from source code, you are empowered to audit everything and apply all the security patches desired. It is no longer necessary to wait for somebody else to compile binary packages that fix a security hole. Unless you examine the patch and implement it yourself, you have no guarantee that the new binary package was built correctly and adequately fixes the problem.

The goal of Cross Linux From Scratch is to build a complete and usable foundation-level system. Readers who do not wish to build their own Linux system from scratch may not benefit from the information in this book. If you only want to know what happens while the computer boots, we recommend the “From Power Up To Bash Prompt” HOWTO located at http://axiom.anu.edu.au/~okeefe/p2b/ or on The Linux Documentation Project's (TLDP) website at http://www.tldp.org/HOWTO/From-PowerUp-To-Bash-Prompt-HOWTO.html. The HOWTO builds a system which is similar to that of this book, but it focuses strictly on creating a system capable of booting to a BASH prompt. Consider your objective. If you wish to build a Linux system and learn along the way, this book is your best choice.

There are too many good reasons to build your own CLFS system to list them all here. This section is only the tip of the iceberg. As you continue in your CLFS experience, you will find the power that information and knowledge truly bring.

Prerequisites

Building a CLFS system is not a simple task. It requires a certain level of existing knowledge of Unix system administration in order to resolve problems, and correctly execute the commands listed. In particular, as an absolute minimum, the reader should already have the ability to use the command line (shell) to copy or move files and directories, list directory and file contents, and change the current directory. It is also expected that the reader has a reasonable knowledge of using and installing Linux software. A basic knowledge of the architectures being used in the Cross LFS process and the host operating systems in use is also required.

Because the CLFS book assumes at least this basic level of skill, the various CLFS support forums are unlikely to be able to provide you with much assistance. Your questions regarding such basic knowledge will likely go unanswered, or you will be referred to the CLFS essential pre-reading list.

Before building a CLFS system, we recommend reading the following HOWTOs:

Host System Requirements

You should be able to build a CLFS system from just about any Unix-type operating system. Your host system should have the following software with the minimum versions indicated. Also note that many distributions will place software headers into separate packages, often in the form of “[package-name]-devel” or “[package-name]-dev”. Be sure to install those if your distribution provides them.

  • Bash-2.05a

  • Binutils-2.12 (Versions greater than 2.23 are not recommended as they have not been tested)

  • Bison-1.875

  • Bzip2-1.0.2

  • Coreutils-5.0

  • Diffutils-2.8

  • Findutils-4.1.20

  • Gawk-3.1.5

  • GCC 4.1 (Versions greater than 4.6.3 are not recommended as they have not been tested)

  • Glibc-2.2.5 (Versions greater than 2.15 are not recommended as they have not been tested)

  • Grep-2.5

  • Gzip-1.2.4

  • Linux 2.6.32 (Built with GCC 4.1.2 or later)

  • Make-3.80

  • Ncurses-5.3

  • Patch-2.5.4

  • Sed-3.0.2

  • Tar-1.22

  • Texinfo-4.7

  • XZ-Utils-4.999.8beta

To see whether your host system has all the appropriate versions, create and run the following script. Read the output carefully for any errors, and make sure to install any packages that are reported as not found.

cat > version-check.sh << "EOF"
#!/bin/bash

# Simple script to list version numbers of critical development tools

bash --version | head -n1 | cut -d" " -f2-4
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-
bison --version | head -n1
bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
diff --version | head -n1
find --version | head -n1
gawk --version | head -n1
gcc --version | head -n1
ldd $(which ${SHELL}) | grep libc.so | cut -d ' ' -f 3 | ${SHELL} | head -n 1 | cut -d ' ' -f 1-7
grep --version | head -n1
gzip --version | head -n1
uname -s -r
make --version | head -n1
tic -V
patch --version | head -n1
sed --version | head -n1
tar --version | head -n1
makeinfo --version | head -n1
xz --version | head -n1
echo 'main(){}' | gcc -v -o /dev/null -x c - > dummy.log 2>&1
if ! grep -q ' error' dummy.log; then
  echo "Compilation successful" && rm dummy.log
else
  echo 1>&2  "Compilation FAILED - more development packages may need to be \
installed. If you like, you can also view dummy.log for more details."
fi
EOF

bash version-check.sh 2>errors.log &&
[ -s errors.log ] && echo -e "\nThe following packages could not be found:\n$(cat errors.log)"

Typography

To make things easier to follow, there are a few typographical conventions used throughout this book. This section contains some examples of the typographical format found throughout Cross-Compiled Linux From Scratch.

./configure --prefix=/usr

This form of text is designed to be typed exactly as seen unless otherwise noted in the surrounding text. It is also used in the explanation sections to identify which of the commands is being referenced.

install-info: unknown option '--dir-file=/mnt/clfs/usr/info/dir'

This form of text (fixed-width text) shows screen output, probably as the result of commands issued. This format is also used to show filenames, such as /etc/ld.so.conf.

Emphasis

This form of text is used for several purposes in the book. Its main purpose is to emphasize important points or items.

http://cross-lfs.org/

This format is used for hyperlinks, both within the CLFS community and to external pages. It includes HOWTOs, download locations, and websites.

cat > ${CLFS}/etc/group << "EOF"
root:x:0:
bin:x:1:
......
EOF

This format is used when creating configuration files. The first command tells the system to create the file ${CLFS}/etc/group from whatever is typed on the following lines until the sequence end of file (EOF) is encountered. Therefore, this entire section is generally typed as seen.

[REPLACED TEXT]

This format is used to encapsulate text that is not to be typed as seen or copied-and-pasted.

passwd(5)

This format is used to refer to a specific manual page (hereinafter referred to simply as a “man” page). The number inside parentheses indicates a specific section inside of man. For example, passwd has two man pages. Per CLFS installation instructions, those two man pages will be located at /usr/share/man/man1/passwd.1 and /usr/share/man/man5/passwd.5. Both man pages have different information in them. When the book uses passwd(5) it is specifically referring to /usr/share/man/man5/passwd.5. man passwd will print the first man page it finds that matches “passwd”, which will be /usr/share/man/man1/passwd.1. For this example, you will need to run man 5 passwd in order to read the specific page being referred to. It should be noted that most man pages do not have duplicate page names in different sections. Therefore, man [program name] is generally sufficient.

Structure

This book is divided into the following parts.

Part I - Introduction

Part I explains a few important notes on how to proceed with the Cross-LFS installation. This section also provides meta-information about the book.

Part II - Preparing for the Build

Part II describes how to prepare for the building process—making a partition and downloading the packages.

Part III - Make the Cross-Compile Tools

Part III shows you how to make a set of Cross-Compiler tools. These tools can run on your host system but allow you to build packages that will run on your target system.

Part IV - Building the Basic Tools

Part IV explains how to build a tool chain designed to operate on your target system. These are the tools that will allow you to build a working system on your target computer.

Part V - Building the CLFS System

Part V guides the reader through the building of the CLFS system—compiling and installing all the packages one by one, setting up the boot scripts, and installing the kernel. The resulting Linux system is the foundation on which other software can be built to expand the system as desired. At the end of this book, there is an easy to use reference listing all of the programs, libraries, and important files that have been installed.

Appendices

The appendices contain information that doesn't really fit anywhere else in the book. Appendix A contains definitions of acronyms and terms used in the book; Appendices B and C have information about package dependencies and the build order. Some architectures may have additional appendices for arch-specific issues.

Errata

The software used to create a CLFS system is constantly being updated and enhanced. Security warnings and bug fixes may become available after the CLFS book has been released. Some host systems may also have problems building CLFS. To check whether the package versions or instructions in this release of CLFS need any modifications to accommodate security vulnerabilities, other bug fixes, or host-specific issues, please visit http://trac.cross-lfs.org/wiki/errata before proceeding with your build. You should note any changes shown and apply them to the relevant section of the book as you progress with building the CLFS system.

Part I. Introduction

Chapter 1. Introduction

1.1. Cross-LFS Acknowledgements

The CLFS team would like to acknowledge people who have assisted in making the book what it is today.

Our Leaders:

  • Ryan Oliver - Build Process Developer.

  • Jim Gifford - Lead Developer.

  • Joe Ciccone - Lead Developer.

  • Jeremy Utley - Release Manager 1.x Series.

Our CLFS Team:

  • Nathan Coulson - Bootscripts.

  • Matt Darcy - x86, X86_64, and Sparc builds.

  • Manuel Canales Esparcia - Book XML.

  • Karen McGuiness - Proofreader.

  • Jonathan Norman - x86, x86_64, PowerPC & UltraSPARC.

  • Jeremy Huntwork - PowerPC, x86, Sparc builds.

  • Justin Knierim - Website Architect.

  • Ken Moffat - PowerPC and X86_64 builds. Developer of Pure 64 Hint.

  • Alexander E. Patrakov - Udev/Hotplug Integration

  • Chris Staub - x86 builds. Leader of Quality Control.

  • Zack Winkles - Unstable book work.

  • William Harrington - x86, x86_64, PowerPC, Sparc, Mips builds.

Outside the Development Team

  • Jürg Billeter - Testing and assisting in the development of the Linux Headers Package

  • Richard Downing - Testing, typo, and content fixes.

  • Peter Ennis - Typo and content fixes.

  • Tony Morgan - Typo and content fixes.

The CLFS team would also like to acknowledge contributions of people from clfs-dev@lists.cross-lfs.org and associated mailing lists who have provided valuable technical and editorial corrections while testing the Cross-LFS book.

  • G. Moko - Text updates and Typos

  • Maxim Osipov - MIPS Testing.

  • Doug Ronne - Various x86_64 fixes.

  • William Zhou - Text updates and Typos

  • Theo Schneider - Testing of the Linux Headers Package

The Linux From Scratch Project

  • Gerard Beekmans <gerard AT linuxfromscratch D0T org> – Creator of Linux From Scratch, on which Cross-LFS is based

Thank you all for your support.

1.2. How to Build a CLFS System

The CLFS system will be built by using a previously installed Unix system or Linux distribution (such as Debian, Fedora, Mandriva, SUSE, or Ubuntu). This existing system (the host) will be used as a starting point to provide necessary programs, including a compiler, linker, and shell, to build the new system. Select the “development” option during the distribution installation to be able to access these tools.

As an alternative to installing an entire separate distribution onto your machine, you may wish to use a livecd. Most distributions provide a livecd, which provides an environment to which you can add the required tools onto, allowing you to successfully follow the instructions in this book. Remember that if you reboot the livecd you will need to reconfigure the host environment before continuing with your build.

Preparing a New Partition of this book describes how to create a new Linux native partition and file system, the place where the new CLFS system will be compiled and installed. Packages and Patches explains which packages and patches need to be downloaded to build a CLFS system and how to store them on the new file system. Final Preparations discusses the setup for an appropriate working environment. Please read Final Preparations carefully as it explains several important issues the developer should be aware of before beginning to work through Constructing Cross-Compile Tools and beyond.

Constructing Cross-Compile Tools explains the installation of cross-compile tools which will be built on the host but be able to compile programs that run on the target machine. These cross-compile tools will be used to create a temporary, minimal system that will be the basis for building the final CLFS system. Some of these packages are needed to resolve circular dependencies—for example, to compile a compiler, you need a compiler.

The process of building cross-compile tools first involves building and installing all the necessary tools to create a build system for the target machine. With these cross-compiled tools, we eliminate any dependencies on the toolchain from our host distro.

After we build our “Cross-Tools”, we start building a very minimal working system in /tools. This minimal system will be built using the cross-toolchain in /cross-tools.

In Installing Basic System Software, the full CLFS system is built. Depending on the system you are cross-compiling for, you will either boot the minimal temp-system on the target machine, or chroot into it.

The chroot (change root) program is used to enter a virtual environment and start a new shell whose root directory will be set to the CLFS partition. This is very similar to rebooting and instructing the kernel to mount the CLFS partition as the root partition. The major advantage is that “chrooting” allows the builder to continue using the host while CLFS is being built. While waiting for package compilation to complete, a user can switch to a different virtual console (VC) or X desktop and continue using the computer as normal.

Some systems cannot be built by chrooting so they must be booted instead. Generally, if you building for a different arch than the host system, you must reboot because the kernel will likely not support the target machine. Booting involves installing a few additional packages that are needed for bootup, installing bootscripts, and building a miminal kernel. We also describe some alternative booting methods in Section 7.19, “What to do next”

To finish the installation, the CLFS-Bootscripts are set up in Setting Up System Bootscripts, and the kernel and boot loader are set up in Making the CLFS System Bootable. The End contains information on furthering the CLFS experience beyond this book. After the steps in this book have been implemented, the computer will be ready to reboot into the new CLFS system.

This is the process in a nutshell. Detailed information on each step is discussed in the following chapters and package descriptions. Items that may seem complicated will be clarified, and everything will fall into place as the reader embarks on the CLFS adventure.

1.3. Master Changelog

This is version 2.0.0 of the Cross-Compiled Linux From Scratch book, dated April 20, 2013. If this book is more than six months old, a newer and better version is probably already available. To find out, please check one of the mirrors via http://trac.cross-lfs.org/.

Below is a list of detailed changes made since the previous release of the book.

Changelog Entries:

  • March 02, 2013

    • [William Harrington] - Update foreword.

    • [William Harrington] - Update errata location.

  • February 16, 2013

    • [William Harrington] - Remove unneccessary config.cache entry in boot and chroot ections of util-linux.

  • February 13, 2013

    • [William Harrington] - Update dhcpcd download location.

  • February 09, 2013

    • [William Harrington] - Add test suite commands to final-system udev.

    • [William Harrington] - Update iana-etc note section for get fix patch.

  • February 08, 2013

    • [William Harrington] - Move gawk before findutils in final system for findutils test-suite coverage.

    • [William Harrington] - Move less before gzip in final system for gzip test-suite coverage.

    • [William Harrington] - Update test suite entry for final-system rsyslog.

  • February 06, 2013

    • [William Harrington] - Edit final system ncurses test suite information.

    • [William Harrington] - Edit final system util-linux test suite information.

    • [William Harrington] - Edit final system coreutils test suite information.

  • February 03, 2013

    • [William Harrington] - Change locale country to locale territory. Country is no longer valid.

  • January 27, 2013

    • [William Harrington] - Add new line to boot method and bootable section fstab.

    • [William Harrington] - Fix improper ../run -> /var/run link.

  • December 27, 2012

    • [William Harrington] - Move ProcPS before E2fsprogs as test suite requires ps.

  • December 13, 2012

    • [Chris] - Removed redundant --enable-add-ons parameter from EGLIBC installation.

  • November 18, 2012

    • [Chris] - Many updates to list of installed programs

  • November 17, 2012

    • [William Harrington] - Skip kill during installation of final-system Procps.

    • [William Harrington] - Remove sulogin, mountpoint, utmpdump, and wall from sysvinit.

  • November 12, 2012

    • [Chris] - Removed unneeded --disable-perl-regexp from temp-system grep.

  • November 05, 2012

    • [William Harrington] - Update gcc branch update patch to r193147.

    • [William Harrington] - Update binutils to 2.23.

    • [William Harrington] - Remove Binutils 2.22 branch update patch.

    • [William Harrington] - Modify coreutils temp system build.

  • November 04, 2012

    • [William Harrington] - Update bash branch update patch to level 39.

  • November 02, 2012

    • [William Harrington] - Disable login and su programs in util-linux.

    • [William Harrington] - Edit hwclock sed for util-linux.

    • [William Harrington] - Edit Coreutils testsuite section.

  • November 01, 2012

    • [William Harrington - Update Patch to 2.7.1.

    • [William Harrington - Update Perl to 5.16.2.

    • [William Harrington - Update Pkg-Config-Lite to 0.27.1-1.

    • [William Harrington - Update Psmisc to 22.20.

    • [William Harrington - Update Readline branch update patch to level 004.

    • [William Harrington - Update Util-linux to 2.22.1.

    • [William Harrington - Update Vim-7.3 to patchlevel 712.

    • [William Harrington - Linux kernel to 3.4.17.

    • [William Harrington - Remove patch test fix patch.

  • October 31, 2012

    • [William Harrington] - Update eglibc to revision 21435.

    • [William Harrington] - Update automake to 1.12.4.

    • [William Harrington] - Update bison to 2.6.4.

    • [William Harrington] - Update coreutils to 8.20.

    • [William Harrington] - Update e2fsprogs to 1.42.6.

    • [William Harrington] - Update gzip to 1.5.

    • [William Harrington] - Update kmod to 10.

    • [William Harrington] - Update less to 451.

    • [William Harrington] - Update man-pages to 3.43.

    • [William Harrington] - Update mpc to 1.0.1.

  • October 25, 2012

    • [Chris] - Updated "What now?" to reflect the name change of freshmeat.net.

  • October 23, 2012

    • [William Harrington} - Add cross-tools M4 patch.

  • October 17, 2012

    • [William Harrington} - Edit coreutils test suite command for su.

  • October 15, 2012

    • [William Harrington} - Move shadow before coreutils

  • September 17, 2012

    • [William Harrington] - Change ncftp reference in downloadclients page to link to the cblfs ncftp page.

    • [William Harrington] - Update linux kernel version from 3.4.9 to 3.4.11.

  • September 14, 2012

    • [William Harrington] - Update iproute 3.4.0 libdir hash and size.

    • [William Harrington] - Update download list link and adjust text in Introduction of packages and patches.

  • September 11, 2012

    • [William Harrington] - Install NIS and RPC related headers in cross-tools and final-system eglibc/eglibc-64bit installs.

  • September 07, 2012

    • [William Harrington] - Remove --with-rootlibdir from kmod configure in Ch 7.

    • [William Harrington] - Disable the build of static libraries when appropriate during cross-tools phase.

    • [William Harrington] - Remove creation of passwd and login links during Ch7 Boot section shadow.

    • [William Harrington] - Add passwd to the string of created symlinks in Ch7 Boot section.

  • September 06, 2012

    • [William Harrington] - Fix /var/run /run link command during createfiles part of the If you are going to boot section.

    • [William Harrington] - Add shadow to If you are going to boot section.

    • [William Harrington] - Remove enable-login-utils form util-linux in the If you are going to boot section.

  • September 04, 2012

    • [William Harrington] - Add a command to final-sytem Bison to add a variable to config.cache.

    • [William Harrington] - Correct zlib 1.2.7 md5sum.

    • [William Harrington] - Update Udev configure options in boot and final-system sections.

    • [William Harrington] - Update bootscripts to be proper with udev updates.

  • September 03, 2012

    • [William Harrington] - Add a new Download Client page to The end section.

  • August 30, 2012

    • [William Harrington] - Update host system requirements. Linux kernel version in book 2.6.32 or greater.

    • [William Harrington] - Add --with-default-terminfo-dir=/usr/share/terminfo to final-system ncurses because of branch update changes.

  • August 29, 2012

    • [William Harrington] - Edit cross-tools PPL configuration line.

    • [William Harrington] - Update linux kernel host system requirement to 2.6.32.

    • [William Harrington] - Update eglibc instructions and update eglibc text for 2.6.32 kernel support.

  • August 28, 2012

    • [William Harrington] - Edit shadow groups program and man-pages disabling section.

  • August 27, 2012

    • [William Harrington] - Create and add binutils 2.22 branch update patch.

    • [William Harrington] - Update bison version to 2.6.2.

    • [William Harrington] - Update coreutils version to 8.19.

    • [William Harrington] - Update e2fsprogs version to 1.42.5.

    • [William Harrington] - Update flex version to 2.5.37.

    • [William Harrington] - Create gcc 4.6.3 branch update patch and add to book.

    • [William Harrington] - Update grep version to 2.14.

    • [William Harrington] - Update grub version to 2.00.

    • [William Harrington] - Update iproute2 version to 3.4.0 and rediff Iproute2 patch.

    • [William Harrington] - Update kmod version to 9.

    • [William Harrington] - Update linux version to 3.4.9.

    • [William Harrington] - Update man-pages version to 3.42.

    • [William Harrington] - Update mpc version to 1.0.

    • [William Harrington] - Update mpfr version to 3.1.1.

    • [William Harrington] - Update ncurses branch update patch.

    • [William Harrington] - Update perl version to 5.16.1 and rediff libc and multilib patches.

    • [William Harrington] - Replace pkg-config with pkg-config-lite 0.27-1.

    • [William Harrington] - Remove glib package from book.

    • [William Harrington] - Update PPL version to 0.12.1.

    • [William Harrington] - Update psmisc version to 22.19.

    • [William Harrington] - Update rsyslog version to 6.2.2.

    • [William Harrington] - Update shadow version to 4.1.5.1.

    • [William Harrington] - Update util-linux version to 2.21.2.

    • [William Harrington] - Updatea xz version to 5.0.4.

    • [William Harrington] - Edit PPL configuration command line.

    • [William Harrington] - Remove flex gcc44 patch.

    • [William Harrington] - Add /run/shm to create directories sections of the book.

    • [William Harrington] - Remove GLIB CFLAGS and LIBS variables from pkg-config configuration line.

    • [William Harrington] - Remove sed for Russian man pages from shadow.

    • [William Harrington] - Replace MD5 encrypt method with SHA512 for shadow login.defs.

    • [William Harrington] - Edit shadow configuration command line.

    • [William Harrington] - Update udev configuration command line for proper installation.

    • [William Harrington] - Update cross and temp PPL to detect and use the proper gmp for sure.

    • [William Harrington] - Add note for iana-etc install.

    • [William Harrington] - Remove unneeded Bison YYENABLE_NLS edit.

  • August 26, 2012

    • [William Harrington] - Correct IPutils build so that rdisc is created and remove multiple rdisc entries for non multilib books and add rdisc to multilib books.

    • [William Harrington] - Add the note for libee in all books and clarify the issue with additional text.

  • August 22, 2012

    • [William Harrington] - Remove bash reference in hostreqs version script to use $SHELL variable.

  • 18 August 2012

    • [William Harrington] - Update automake to 1.12.3.

  • 15 August 2012

    • [William Harrington] - Update download list location.

  • 13 August 2012

    • [William Harrington] - Add xz and zlib compression to boot method kmod.

  • 11 August 2012

    • [William Harrington] - Edit configure command block in the boot method udev section so that copy and paste works properly.

    • [William Harrington] - Edit configure command boot method kmod section to install libkmod into /tools/lib rather than /lib.

  • 06 August 2012

    • [William Harrington] - Adjust XZ final system install command to properly install the lzma pkgconfig file to the proper location.

    • [William Harrington] - Update version check script to find the libc version with hosts that use paths other than /lib and /lib64, such as multiarch distros.

  • 02 August 2012

    • [William Harrington] - Add ${CLFS} to the ln -s /run /var/run command for the boot method.

  • 31 July 2012

    • [William Harrington] - Added myself to the acknowledgements page.

  • 23 July 2012

    • [William Harrington] - Add xz-utils to host system requirements.

  • 21 July 2012

    • [William Harrington] - Update vim 7.3 patch to level 608.

    • [William Harrington] - Update bash 4.2 patch to level 37.

    • [William Harrington] - Change description of chattr of e2fsprogs.

    • [William Harrington] - Remove unneeded eglibc-2.15-r17386-dl_dep_fix-1.patch from patches.

    • [William Harrington] - Remove graphite configuration options from Binutils.

    • [William Harrington] - Update automake version to 1.12.2.

  • 18 July 2012

    • [Jonathan] - Removed non-existing GCC Branch Update from patch list.

  • 10 June 2012

    • [Jonathan] - Added patch to update default Protocol and Service files for Iana-etc.

    • [Jonathan] - Added devtmpfs and firmware_install to the kernel.

    • [Jonathan] - Updated final Coreutils configuration to allow building as the root user.

  • 6 June 2012

    • [Jonathan] - Updated Coreutils from 8.15 to 8.16.

    • [Jonathan] - Updated Util-linux from 2.20 to 2.20.1.

  • 4 June 2012

    • [Jonathan] - Updated DHCPD from 5.5.4 to 5.5.6.

    • [Jonathan] - Updated Udev from 181 to 182.

    • [Jonathan] - Updated Libee from 0.3.2 to 0.4.1.

    • [Jonathan] - Updated PSMisc from 22.15 to 22.17.

    • [Jonathan] - Updated Kmod from 6 to 8.

    • [Jonathan] - Updated Automake from 1.11.3 to 1.12.1.

    • [Jonathan] - Updated Autoconf from 2.68 to 2.69.

    • [Jonathan] - Updated IPRoute2 from 3.2.0 to 3.3.0.

    • [Jonathan] - Updated E2fsprogs from 1.41 to 1.42.3.

    • [Jonathan] - Updated Glib2 from 2.28.6 to 2.28.8.

    • [Jonathan] - Updated Man-Pages from 3.35 to 3.41.

    • [Jonathan] - Updated Grep from 2.10 to 2.12.

    • [Jonathan] - Updated Gawk from 4.0.0 to 4.0.1.

    • [Jonathan] - Updated Zlib from 1.2.6 to 1.2.7.

    • [Jonathan] - Updated GCC from 4.6.2 to 4.6.3.

    • [Jonathan] - Updated GMP from 0.11.2 to 0.12.1.

    • [Jonathan] - Updated File from 5.10 to 5.11.

    • [Jonathan] - Updated Linux from 3.2.6 to 3.3.7.

    • [Jonathan] - Updated Bash Branch Update patch to -4.

    • [Jonathan] - Updated Vim Branch Update patch to -4.

  • 15 April 2012

    • [Jonathan] - Added /run to the book.

    • [Jonathan] - Upgraded Udev from 168 to 181.

  • 14 March 2012

    • [Jonathan] - Replaces Module-Init-tools with Kmod.

  • 3 March 2012

    • [Jonathan] - Updated Eglibc 2.15 from r16526 to r17386 and fixed directory name.

  • 29 February 2012

    • [Jonathan] - Added Login to the created links in the boot method - thanks Code Monkey.

    • [Jonathan] - Fixed issue with mutlilib e2fsprogs boot method.

  • 20 February 2012

    • [Jonathan] - Added --without-nscd to Shadow.

    • [Jonathan] - Added --with-ppl to cross and temp Binutils.

  • 18 February 2012

    • [Jonathan] - Enabled Patch test suite.

    • [Jonathan] - Diffutils now includes a test suite.

    • [Jonathan] - Updated Readline Branch Update to -2.

    • [Jonathan] - Fixed IPRoute2 compilation issue by removing unused libnl headers.

  • 17 February 2012

    • [Jonathan] - Added Iana-etc patch and update command.

    • [Jonathan] - Replaced ClooG-PPL with ClooG-0.16.3.

  • 16 February 2012

    • [Jonathan] - Updated Ncurses Branch Update to -3.

    • [Jonathan] - Added Eglibc patch to fix memory issue with ALSA.

    • [Jonathan] - Updated Man-pages to 3.35.

  • 15 February 2012

    • Updated Vim Branch Update patch to -3.

    • Updated Bash Branch Update patch to -3.

    • Updated Automake to 1.11.3.

    • Updated Binutils to 2.22.

    • Updated Coreutils to 8.15.

    • Updated DHCPD to 5.5.4.

    • Updated Diffutils to 3.2.

    • Updated Eglibc to 2.15.

    • Updated E2fsprogs to 1.4.2.

    • Updated File to 5.10.

    • Updated Gawk to 4.0.

    • Updated GCC to 4.6.2.

    • Updated GMP to 5.0.4.

    • Updated Grep to 2.10.

    • Updated Grep to 2.10.

    • Updated Iproute2 to 3.2.0.

    • Updated Less to 444.

    • Updated Libee to 0.3.2.

    • Updated Libtool to 2.4.2.

    • Updated Linux to 3.2.x.

    • Updated Module-init-tools to 3.15.

    • Updated MPFR to 3.1.0.

    • Updated Perl to 5.14.2.

    • Updated PSmisc to 22.15.

    • Updated Rsyslog to 6.2.0.

    • Updated Shadow to 4.1.5.

    • Updated TCL to 8.5.11.

    • Updated Util-linux to 2.20.

    • Updated XZ-Utils to 5.0.3.

    • Updated Zlib to 1.2.6.

  • 15 February 2012

    • [Jonathan] - Changelog restarted, see the 1.2.0 book for the old changelog.

1.4. Changelog for x86_64

Below is a list of changes specifics for this architecture made since the previous release of the book. For general changes see Master Changelog,

Changelog Entries:

  • 27 January 2013

    • [William Harrington] - Fix util-linux boot method instructions.

  • 11 September 2012

    • [William Harrington] - Remove rpc header fix for final-system eglibc multilib 32 bit.

  • 08 September 2012

    • [William Harrington] - Remove multiarch_wrapper.c along with the test links.

  • 07 September 2012

    • [William Harrington] - Remove note about flex not being installed when installing Grub in ch7.

    • [William Harrington] - Fix grub installation instructions in Ch 7.

  • 04 September 2012

    • [William Harrington] - Update grub instructions in the bootable section.

  • 26 August 2012

    • [William Harrington] - Remove link commands from Kmod 32-bit as they are created in the final 64-bit kmod build.

  • 07 August 2012

    • [William Harrington] - Edit configure command in final system 32 bit xz.

  • 31 July 2012

    • [William Harrington] - Remove multiarch wrapper testcase binaries and link.

  • 21 July 2012

    • [William Harrington] - Added procps HZ patch.

    • [William Harrington] - Remove 32 bit util-linux logger binary move in multilib.

    • [William Harrington] - Remove multiarch wrapper testcase test link.

    • [William Harrington] - Fix 32 bit and 64 bit udev preparation instructions.

    • [William Harrington] - Fix 32 bit kmod preparation instructions.

    • [William Harrington] - Fix rpc build issue in final system eglibc 32 bit build.

  • 15 February 2012

    • [Jonathan] - Changelog restarted, see the 1.2.0 book for the old changelog.

1.5. Resources

1.5.1. FAQ

If during the building of the CLFS system you encounter any errors, have any questions, or think there is a typo in the book, please start by consulting the Frequently Asked Questions (FAQ) that is located at http://trac.cross-lfs.org/wiki/faq.

1.5.2. Mailing Lists

The cross-lfs.org server hosts a number of mailing lists used for the development of the CLFS project. These lists include the main development and support lists, among others. If the FAQ does not contain your answer, you can search the CLFS lists via The Mail Archive http://www.mail-archive.com. You can find the mail lists with the following link:

http://www.mail-archive.com/index.php?hunt=clfs

For information on the different lists, how to subscribe, archive locations, and additional information, visit http://trac.cross-lfs.org/wiki/lists.

1.5.3. News Server

Cross-LFS does not maintain its own News Server, but we do provide access via gmane.org http://gmane.org. If you want to subscribe to the Cross-LFS lists via a newsreader you can utilize gmane.org. You can find the gmane search for CLFS with the following link:

http://dir.gmane.org/search.php?match=clfs

1.5.4. IRC

Several members of the CLFS community offer assistance on our community Internet Relay Chat (IRC) network. Before using this support, please make sure that your question is not already answered in the CLFS FAQ or the mailing list archives. You can find the IRC network at chat.freenode.net. The support channel for cross-lfs is named #cross-lfs. If you need to show people the output of your problems, please use http://pastebin.cross-lfs.org and reference the pastebin URL when asking your questions.

1.5.5. Mirror Sites

The CLFS project has a number of world-wide mirrors to make accessing the website and downloading the required packages more convenient. Please visit the CLFS website at http://trac.cross-lfs.org/wiki/mirrors for mirrors of CLFS.

1.5.6. Contact Information

Please direct all your questions and comments to the CLFS mailing lists (see above).

1.6. Help

If an issue or a question is encountered while working through this book, check the FAQ page at http://trac.cross-lfs.org/wiki/faq#generalfaq. Questions are often already answered there. If your question is not answered on this page, try to find the source of the problem. The following hint will give you some guidance for troubleshooting: http://hints.cross-lfs.org/index.php/Errors.

We also have a wonderful CLFS community that is willing to offer assistance through the mailing lists and IRC (see the Section 1.5, “Resources” section of this book). However, we get several support questions everyday and many of them can be easily answered by going to the FAQ and by searching the mailing lists first. So for us to offer the best assistance possible, you need to do some research on your own first. This allows us to focus on the more unusual support needs. If your searches do not produce a solution, please include all relevant information (mentioned below) in your request for help.

1.6.1. Things to Mention

Apart from a brief explanation of the problem being experienced, the essential things to include in any request for help are:

  • The version of the book being used (in this case 2.0.0)

  • The host distribution and version being used to create CLFS.

  • The architecture of the host and target.

  • The value of the $CLFS_HOST, $CLFS_TARGET, $BUILD32, and $BUILD64 environment variables.

  • The package or section in which the problem was encountered.

  • The exact error message or symptom received. See Section 1.6.3, “Compilation Problems” below for an example.

  • Note whether you have deviated from the book at all. A package version change or even a minor change to any command is considered deviation.

Note

Deviating from this book does not mean that we will not help you. After all, the CLFS project is about personal preference. Be upfront about any changes to the established procedure—this helps us evaluate and determine possible causes of your problem.

1.6.2. Configure Script Problems

If something goes wrong while running the configure script, review the config.log file. This file may contain the errors you encountered during configure. It often logs errors that may have not been printed to the screen. Include only the relevant lines if you need to ask for help.

1.6.3. Compilation Problems

Both the screen output and the contents of various files are useful in determining the cause of compilation problems. The screen output from the configure script and the make run can be helpful. It is not necessary to include the entire output, but do include enough of the relevant information. Below is an example of the type of information to include from the screen output from make:

gcc -DALIASPATH=\"/mnt/clfs/usr/share/locale:.\"
-DLOCALEDIR=\"/mnt/clfs/usr/share/locale\"
-DLIBDIR=\"/mnt/clfs/usr/lib\"
-DINCLUDEDIR=\"/mnt/clfs/usr/include\" -DHAVE_CONFIG_H -I. -I.
-g -O2 -c getopt1.c
gcc -g -O2 -static -o make ar.o arscan.o commands.o dir.o
expand.o file.o function.o getopt.o implicit.o job.o main.o
misc.o read.o remake.o rule.o signame.o variable.o vpath.o
default.o remote-stub.o version.o opt1.o
-lutil job.o: In function `load_too_high':
/clfs/tmp/make-3.79.1/job.c:1565: undefined reference
to `getloadavg'
collect2: ld returned 1 exit status
make[2]: *** [make] Error 1
make[2]: Leaving directory `/clfs/tmp/make-3.79.1'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/clfs/tmp/make-3.79.1'
make: *** [all-recursive-am] Error 2

In this case, many people would just include the bottom section:

make [2]: *** [make] Error 1

This is not enough information to properly diagnose the problem because it only notes that something went wrong, not what went wrong. The entire section, as in the example above, is what should be saved because it includes the command that was executed and the associated error message(s).

An excellent article about asking for help on the Internet is available online at http://catb.org/~esr/faqs/smart-questions.html. Read and follow the hints in this document to increase the likelihood of getting the help you need.

Part II. Preparing for the Build

Chapter 2. Preparing a New Partition

2.1. Introduction

In this chapter, the partition which will host the CLFS system is prepared. We will create the partition itself, create a file system on it, and mount it.

2.2. Creating a New Partition

Like most other operating systems, CLFS is usually installed on a dedicated partition. The recommended approach to building a CLFS system is to use an available empty partition or, if you have enough unpartitioned space, to create one. However, if you're building for a different architecture you can simply build everything in “/mnt/clfs” and transfer it to your target machine.

A minimal system requires around 6 gigabytes (GB). This is enough to store all the source tarballs and compile the packages. The CLFS system itself will not take up this much room. A large portion of this requirement is to provide sufficient free temporary storage. Compiling packages can require a lot of disk space which will be reclaimed after the package is installed. If the CLFS system is intended to be the primary Linux system, additional software will probably be installed which will require additional space (2-10 GB).

Because there is not always enough Random Access Memory (RAM) available for compilation processes, it is a good idea to use a small disk partition as swap space. This is used by the kernel to store seldom-used data and leave more memory available for active processes. The swap partition for an CLFS system can be the same as the one used by the host system, in which case it is not necessary to create another one.

Start a disk partitioning program such as cfdisk or fdisk with a command line option naming the hard disk on which the new partition will be created—for example /dev/hda for the primary Integrated Drive Electronics (IDE) disk. Create a Linux native partition and a swap partition, if needed. Please refer to cfdisk(8) or fdisk(8) if you do not yet know how to use the programs.

Remember the designation of the new partition (e.g., hda5). This book will refer to this as the CLFS partition. Also remember the designation of the swap partition. These names will be needed later for the /etc/fstab file.

2.3. Creating a File System on the Partition

Now that a blank partition has been set up, the file system can be created. The most widely-used system in the Linux world is the second extended file system (ext2), but with newer high-capacity hard disks, journaling file systems are becoming increasingly popular. We will create an ext2 file system. Instructions for other file systems can be found at http://cblfs.cross-lfs.org/index.php?section=6#File_System.

To create an ext2 file system on the CLFS partition, run the following:

mke2fs /dev/[xxx]

Replace [xxx] with the name of the CLFS partition (hda5 in our previous example).

Note

Some host distributions use custom features in their filesystem creation tools (E2fsprogs). This can cause problems when booting into your new CLFS system, as those features will not be supported by the CLFS-installed E2fsprogs; you will get an error similar to unsupported filesystem features, upgrade your e2fsprogs. To check if your host system uses custom enhancements, run the following command:

debugfs -R feature /dev/[xxx]

If the output contains features other than: dir_index; filetype; large_file; resize_inode or sparse_super then your host system may have custom enhancements. In that case, to avoid later problems, you should compile the stock E2fsprogs package and use the resulting binaries to re-create the filesystem on your CLFS partition:

cd /tmp
tar xjf /path/to/sources/e2fsprogs-1.42.6.tar.bz2
cd e2fsprogs-1.42.6
mkdir build
cd build
../configure
make #note that we intentionally don't 'make install' here!
./misc/mke2fs /dev/[xxx]
cd /tmp
rm -rf e2fsprogs-1.42.6

If a swap partition was created, it will need to be initialized for use by issuing the command below. If you are using an existing swap partition, there is no need to format it.

mkswap /dev/[yyy]

Replace [yyy] with the name of the swap partition.

2.4. Mounting the New Partition

Now that a file system has been created, the partition needs to be made accessible. In order to do this, the partition needs to be mounted at a chosen mount point. For the purposes of this book, it is assumed that the file system is mounted under /mnt/clfs, but the directory choice is up to you.

Choose a mount point and assign it to the CLFS environment variable by running:

export CLFS=/mnt/clfs

Next, create the mount point and mount the CLFS file system by running:

mkdir -pv ${CLFS}
mount -v /dev/[xxx] ${CLFS}

Replace [xxx] with the designation of the CLFS partition.

If using multiple partitions for CLFS (e.g., one for / and another for /usr), mount them using:

mkdir -pv ${CLFS}
mount -v /dev/[xxx] ${CLFS}
mkdir -v ${CLFS}/usr
mount -v /dev/[yyy] ${CLFS}/usr

Replace [xxx] and [yyy] with the appropriate partition names.

Ensure that this new partition is not mounted with permissions that are too restrictive (such as the nosuid, nodev, or noatime options). Run the mount command without any parameters to see what options are set for the mounted CLFS partition. If nosuid, nodev, and/or noatime are set, the partition will need to be remounted.

Now that there is an established place to work, it is time to download the packages.

Chapter 3. Packages and Patches

3.1. Introduction

This chapter includes a list of packages that need to be downloaded for building a basic Linux system. The listed version numbers correspond to versions of the software that are known to work, and this book is based on their use. We highly recommend not using newer versions because the build commands for one version may not work with a newer version. The newest package versions may also have problems that require work-arounds. These work-arounds will be developed and stabilized in the development version of the book.

Download locations may not always be accessible. If a download location has changed since this book was published, Google (http://www.google.com/) provides a useful search engine for most packages. If this search is unsuccessful, try one of the alternative means of downloading discussed at http://cross-lfs.org/files/packages/2.0.0/.

Create a directory called ${CLFS}/sources and use it to store your sources and patches. All packages should be compiled there as well. Using any other location for compiling may have unexpected results.

To create this directory, execute, as user root, the following command before starting the download session:

mkdir -v ${CLFS}/sources

Make this directory writable and sticky. When a directory is marked “sticky”, that means that even if multiple users have write permission on that directory, any file within that directory can only be deleted or modified by its owner. The following command will enable the write and sticky modes:

chmod -v a+wt ${CLFS}/sources

You can download all needed packages and patches into this directory either by using the links on the following pages in this section, or by passing the download list to wget.

3.2. All Packages

Download or otherwise obtain the following packages:

Autoconf (2.69) - 1,188 KB:

Home page: http://www.gnu.org/software/autoconf

Download: http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz

MD5 sum: 50f97f4159805e374639a73e2636f22e

Automake (1.12.4) - 1,356 KB:

Home page: http://www.gnu.org/software/automake

Download: http://ftp.gnu.org/gnu/automake/automake-1.12.4.tar.xz

MD5 sum: 7395a0420ecb5c9bc43e5fcf4824df36

Bash (4.2) - 6,848 KB:

Home page: http://www.gnu.org/software/bash

Download: http://ftp.gnu.org/gnu/bash/bash-4.2.tar.gz

MD5 sum: 3fb927c7c33022f1c327f14a81c0d4b0

Binutils (2.23) - 28,124 KB:

Home page: http://sources.redhat.com/binutils

Download: http://ftp.gnu.org/gnu/binutils/binutils-2.23.tar.gz

MD5 sum: ed58f50d8920c3f1d9cb110d5c972c27

Bison (2.6.4) - 1,708 KB:

Home page: http://www.gnu.org/software/bison

Download: http://ftp.gnu.org/gnu/bison/bison-2.6.4.tar.xz

MD5 sum: 8b2dc57eb9d2d6de4715d30de6b2ee07

Bootscripts for CLFS (2.0.0) - 44 KB:

Download: http://cross-lfs.org/files/packages/2.0.0/bootscripts-cross-lfs-2.0.0.tar.xz

MD5 sum: a396eb6898990d93f7de4bf15dad5544

Bzip2 (1.0.6) - 764 KB:

Home page: http://www.bzip.org/

Download: http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz

MD5 sum: 00b516f4704d4a7cb50a1d97e6e8e15b

ClooG (0.16.3) - 1,900 KB:

Home page: http://cloog.org

Download: http://www.bastoul.net/cloog/pages/download/cloog-0.16.3.tar.gz

MD5 sum: a0f8a241cd1c4f103f8d2c91642b3498

Coreutils (8.20) - 5,164 KB:

Home page: http://www.gnu.org/software/coreutils

Download: http://ftp.gnu.org/gnu/coreutils/coreutils-8.20.tar.xz

MD5 sum: 3d69af8f561fce512538a9fe85f147ff

DejaGNU (1.5) - 564 KB:

Home page: http://www.gnu.org/software/dejagnu

Download: http://ftp.gnu.org/gnu/dejagnu/dejagnu-1.5.tar.gz

MD5 sum: 3df1cbca885e751e22d3ebd1ac64dc3c

DHCPCD (5.5.6) - 80 KB:

Home page: http://roy.marples.name/projects/dhcpcd

Download: http://roy.marples.name/downloads/dhcpcd/dhcpcd-5.5.6.tar.bz2

MD5 sum: a5c0e43b4e836cfc003437329f6b7982

Diffutils (3.2) - 1,124 KB:

Home page: http://www.gnu.org/software/diffutils

Download: http://ftp.gnu.org/gnu/diffutils/diffutils-3.2.tar.xz

MD5 sum: 26ff64c332429c830c154be46b393382

EGLIBC (2.15) - 10,620 KB:

Home page: http://www.eglibc.org/home

Download: http://cross-lfs.org/files/eglibc-2.15-r21467.tar.xz

MD5 sum: f4087281e50843e67da86dd8da3ec9a3

E2fsprogs (1.42.6) - 4,500 KB:

Home page: http://e2fsprogs.sourceforge.net

Download: http://www.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v1.42.6/e2fsprogs-1.42.6.tar.xz

MD5 sum: a75d1ffd3980e1470014da3df309c862

Expect (5.45) - 616 KB:

Home page: http://expect.sourceforge.net

Download: http://downloads.sourceforge.net/project/expect/Expect/5.45/expect5.45.tar.gz

MD5 sum: 44e1a4f4c877e9ddc5a542dfa7ecc92b

File (5.11) - 596 KB:

Home page: http://www.darwinsys.com/file

Download: ftp://ftp.astron.com/pub/file/file-5.11.tar.gz

MD5 sum: 16a407bd66d6c7a832f3a5c0d609c27b

Note

File (5.11) may no longer be available at the listed location. The site administrators of the master download location occasionally remove older versions when new ones are released. An alternative download location that may have the correct version available is http://cross-lfs.org/files/packages/2.0.0/.

Findutils (4.4.2) - 2,100 KB:

Home page: http://www.gnu.org/software/findutils

Download: http://ftp.gnu.org/gnu/findutils/findutils-4.4.2.tar.gz

MD5 sum: 351cc4adb07d54877fa15f75fb77d39f

Flex (2.5.37) - 1,276 KB:

Home page: http://flex.sourceforge.net

Download: http://downloads.sourceforge.net/flex/flex-2.5.37.tar.bz2

MD5 sum: c75940e1fc25108f2a7b3ef42abdae06

Gawk (4.0.1) - 1,576 KB:

Home page: http://www.gnu.org/software/gawk

Download: http://ftp.gnu.org/gnu/gawk/gawk-4.0.1.tar.xz

MD5 sum: a601b032c39cd982f34272664f8afa49

GCC (4.6.3) - 70,312 KB:

Home page: http://gcc.gnu.org

Download: ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.6.3/gcc-4.6.3.tar.bz2

MD5 sum: 773092fe5194353b02bb0110052a972e

Gettext (0.18.1.1) - 14,788 KB:

Home page: http://www.gnu.org/software/gettext

Download: http://ftp.gnu.org/gnu/gettext/gettext-0.18.1.1.tar.gz

MD5 sum: 3dd55b952826d2b32f51308f2f91aa89

GMP (5.0.5) - 2,008 KB:

Home page: http://gmplib.org/

Download: http://ftp.gnu.org/gnu/gmp/gmp-5.0.5.tar.bz2

MD5 sum: 041487d25e9c230b0c42b106361055fe

Grep (2.14) - 1,168 KB:

Home page: http://www.gnu.org/software/grep

Download: http://ftp.gnu.org/gnu/grep/grep-2.14.tar.xz

MD5 sum: d4a3f03849d1e17ce56ab76aa5a24cab

Groff (1.21) - 3,776 KB:

Home page: http://www.gnu.org/software/groff

Download: http://ftp.gnu.org/gnu/groff/groff-1.21.tar.gz

MD5 sum: 8b8cd29385b97616a0f0d96d0951c5bf

Gzip (1.5) - 712 KB:

Home page: http://www.gzip.org

Download: http://ftp.gnu.org/gnu/gzip/gzip-1.5.tar.xz

MD5 sum: 2a431e169b6f62f7332ef6d47cc53bae

Iana-Etc (2.30) - 204 KB:

Home page: http://www.archlinux.org/packages/core/any/iana-etc/

Download: http://ftp.cross-lfs.org/pub/clfs/conglomeration/iana-etc/iana-etc-2.30.tar.bz2

MD5 sum: 3ba3afb1d1b261383d247f46cb135ee8

IPRoute2 (3.4.0) - 376 KB:

Home page: http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2

Download: http://www.kernel.org/pub//linux/utils/net/iproute2/iproute2-3.4.0.tar.xz

MD5 sum: 879d3fac4e90809598b2864ec4a0cbf8

IPutils (s20101006) - 96 KB:

Home page: http://www.linuxfoundation.org/en/Net:Iputils

Download: http://www.skbuff.net/iputils/iputils-s20101006.tar.bz2

MD5 sum: a36c25e9ec17e48be514dc0485e7376c

Kbd (1.15.3) - 1,624 KB:

Download: ftp://devel.altlinux.org/legion/kbd/kbd-1.15.3.tar.gz

MD5 sum: 8143e179a0f3c25646ce5085e8777200

Kmod (10) - 1,104 KB:

Home page: http://git.kernel.org/?p=utils/kernel/kmod/kmod.git;a=summary

Download: http://www.kernel.org/pub//linux/utils/kernel/kmod/kmod-10.tar.xz

MD5 sum: e2a883c4df15a50f78a7a61d5b64089f

Less (451) - 308 KB:

Home page: http://www.greenwoodsoftware.com/less

Download: http://www.greenwoodsoftware.com/less/less-451.tar.gz

MD5 sum: 765f082658002b2b46b86af4a0da1842

Libee (0.4.1) - 352 KB:

Home page: http://www.libee.org/

Download: http://www.libee.org/download/files/download/libee-0.4.1.tar.gz

MD5 sum: 7bbf4160876c12db6193c06e2badedb2

Libestr (0.1.0) - 308 KB:

Home page: http://sourceforge.net/projects/libestr/

Download: http://sourceforge.net/projects/libestr/files/libestr-0.1.0.tar.gz

MD5 sum: 1b8fe449cffc259075d327334c93bbda

Libtool (2.4.2) - 852 KB:

Home page: http://www.gnu.org/software/libtool

Download: http://ftp.gnu.org/gnu/libtool/libtool-2.4.2.tar.xz

MD5 sum: 2ec8997e0c07249eb4cbd072417d70fe

Linux (3.4.17) - 65,288 KB:

Home page: http://www.kernel.org

Download: http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.4.17.tar.xz

MD5 sum: c89817e8856ec88f84ab6a25cc2f7789

M4 (1.4.16) - 1,232 KB:

Home page: http://www.gnu.org/software/m4

Download: http://ftp.gnu.org/gnu/m4/m4-1.4.16.tar.bz2

MD5 sum: 8a7cef47fecab6272eb86a6be6363b2f

Make (3.82) - 1,216 KB:

Home page: http://www.gnu.org/software/make

Download: http://ftp.gnu.org/gnu/make/make-3.82.tar.bz2

MD5 sum: 1a11100f3c63fcf5753818e59d63088f

Man (1.6g) - 252 KB:

Home page: http://primates.ximian.com/~flucifredi/man

Download: http://primates.ximian.com/~flucifredi/man/man-1.6g.tar.gz

MD5 sum: ba154d5796928b841c9c69f0ae376660

Man-pages (3.43) - 1,076 KB:

Home page: http://www.win.tue.nl/~aeb/linux/man

Download: http://www.kernel.org/pub//linux/docs/man-pages/man-pages-3.43.tar.xz

MD5 sum: 761b823ad353975bb87eadb4a8690069

MPC (1.0.1) - 616 KB:

Home page: http://www.multiprecision.org/

Download: http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz

MD5 sum: b32a2e1a3daa392372fbd586d1ed3679

MPFR (3.1.1) - 1,048 KB:

Home page: http://www.mpfr.org/

Download: http://www.mpfr.org/mpfr-3.1.1/mpfr-3.1.1.tar.xz

MD5 sum: 91d51c41fcf2799e4ee7a7126fc95c17

Ncurses (5.9) - 2,764 KB:

Home page: http://www.gnu.org/software/ncurses

Download: ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz

MD5 sum: 8cb9c412e5f2d96bc6f459aa8c6282a1

Patch (2.7.1) - 668 KB:

Home page: http://savannah.gnu.org/projects/patch

Download: http://ftp.gnu.org/gnu/patch/patch-2.7.1.tar.xz

MD5 sum: e9ae5393426d3ad783a300a338c09b72

Perl (5.16.2) - 13,424 KB:

Home page: http://www.perl.org

Download: http://www.cpan.org/src/5.0/perl-5.16.2.tar.bz2

MD5 sum: 2818ab01672f005a4e552a713aa27b08

Pkg-config (lite-0.27.1-1) - 396 KB:

Home page: http://sourceforge.net/projects/pkgconfiglite

Download: http://sourceforge.net/projects/pkgconfiglite/files/0.27.1-1/pkg-config-lite-0.27.1-1.tar.gz

MD5 sum: 589448b99b6e073924c1bea88dfc9f38

PPL (0.12.1) - 14,592 KB:

Home page: http://bugseng.com/products/ppl/

Download: ftp://ftp.cs.unipr.it/pub/ppl/releases/0.12.1/ppl-0.12.1.tar.bz2

MD5 sum: 8da3ab9de18e669b7af8c4707817d468

Procps (3.2.8) - 280 KB:

Home page: http://procps.sourceforge.net

Download: http://procps.sourceforge.net/procps-3.2.8.tar.gz

MD5 sum: 9532714b6846013ca9898984ba4cd7e0

Psmisc (22.20) - 428 KB:

Home page: http://psmisc.sourceforge.net

Download: http://downloads.sourceforge.net/psmisc/psmisc-22.20.tar.gz

MD5 sum: a25fc99a6dc7fa7ae6e4549be80b401f

Readline (6.2) - 2,228 KB:

Home page: http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html

Download: http://ftp.gnu.org/gnu/readline/readline-6.2.tar.gz

MD5 sum: 67948acb2ca081f23359d0256e9a271c

Rsyslog (6.2.2) - 2,376 KB:

Home page: http://www.rsyslog.com/

Download: http://www.rsyslog.com/files/download/rsyslog/rsyslog-6.2.2.tar.gz

MD5 sum: b797b8222d6ea4d5dfa007efe8aafa7f

Sed (4.2.1) - 880 KB:

Home page: http://www.gnu.org/software/sed

Download: http://ftp.gnu.org/gnu/sed/sed-4.2.1.tar.bz2

MD5 sum: 7d310fbd76e01a01115075c1fd3f455a

Shadow (4.1.5.1) - 2,144 KB:

Home page: http://pkg-shadow.alioth.debian.org

Download: http://pkg-shadow.alioth.debian.org/releases/shadow-4.1.5.1.tar.bz2

MD5 sum: a00449aa439c69287b6d472191dc2247

Sysvinit (2.88dsf) - 104 KB:

Home page: http://savannah.nongnu.org/projects/sysvinit

Download: http://download.savannah.gnu.org/releases/sysvinit/sysvinit-2.88dsf.tar.bz2

MD5 sum: 6eda8a97b86e0a6f59dabbf25202aa6f

Tar (1.26) - 2,288 KB:

Home page: http://www.gnu.org/software/tar

Download: http://ftp.gnu.org/gnu/tar/tar-1.26.tar.bz2

MD5 sum: 2cee42a2ff4f1cd4f9298eeeb2264519

Tcl (8.5.12) - 4,412 KB:

Home page: http://www.tcl.tk

Download: http://downloads.sourceforge.net/tcl/tcl8.5.12-src.tar.gz

MD5 sum: 174b2b4c619ba8f96875d8a051917703

Texinfo (4.13a) - 2,688 KB:

Home page: http://www.gnu.org/software/texinfo

Download: http://ftp.gnu.org/gnu/texinfo/texinfo-4.13a.tar.gz

MD5 sum: 71ba711519209b5fb583fed2b3d86fcb

Udev (182) - 676 KB:

Home page: http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html

Download: http://www.kernel.org/pub//linux/utils/kernel/hotplug/udev-182.tar.xz

MD5 sum: 023877e6cc0d907994b8c648beab542b

Util-linux (2.22.1) - 3,124 KB:

Home page: http://userweb.kernel.org/~kzak/util-linux/

Download: http://www.kernel.org/pub//linux/utils/util-linux/v2.22/util-linux-2.22.1.tar.xz

MD5 sum: 730cf9932531ed09b53a04ca30fcb4c9

Vim (7.3) - 8,868 KB:

Home page: http://www.vim.org

Download: ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2

MD5 sum: 5b9510a17074e2b37d8bb38ae09edbf2

XZ Utils (5.0.4) - 896 KB:

Home page: http://tukaani.org/xz/

Download: http://tukaani.org/xz/xz-5.0.4.tar.xz

MD5 sum: 161015c4a65b1f293d31810e1df93090

Zlib (1.2.7) - 496 KB:

Home page: http://www.zlib.net

Download: http://zlib.net/zlib-1.2.7.tar.bz2

MD5 sum: 2ab442d169156f34c379c968f3f482dd

Total size of these packages: about 296 MB

3.3. Additional Packages for x86_64 Multilib

GRUB (2.00) - 5,020 KB:

Home page: http://www.gnu.org/software/grub

Download: http://ftp.gnu.org/gnu/grub/grub-2.00.tar.xz

MD5 sum: a1043102fbc7bcedbf53e7ee3d17ab91

Total size of these packages: about 5 MB

3.4. Needed Patches

In addition to the packages, several patches are also required. These patches correct any mistakes in the packages that should be fixed by the maintainer. The patches also make small modifications to make the packages easier to work with. The following patches will be needed to build a CLFS system:

Bash Branch Update Patch - 54,711 KB:

Download: http://patches.cross-lfs.org/2.0.0/bash-4.2-branch_update-6.patch

MD5 sum: 23c68ff88198537401d49ab6424b005d

Coreutils Uname Patch - 16 KB:

Download: http://patches.cross-lfs.org/2.0.0/coreutils-8.20-uname-1.patch

MD5 sum: d47d2d5dec9b4c0b25329511b6b11edf

EGLIBC Fixes Patch - 4 KB:

Download: http://patches.cross-lfs.org/2.0.0/eglibc-2.15-fixes-1.patch

MD5 sum: 872128f0f087f2036798680c3b118c65

GCC Branch Update Patch - 601 KB:

Download: http://patches.cross-lfs.org/2.0.0/gcc-4.6.3-branch_update-2.patch

MD5 sum: e7af1c4a02408aeb25c94ed86c7921d6

Iana-Etc Get Fix Patch - 4 KB:

Download: http://patches.cross-lfs.org/2.0.0/iana-etc-2.30-get_fix-1.patch

MD5 sum: 73aee2dc34cf4d990cc22fe323d89f27

Iana-Etc Protocol and Port Numbers Update - 3,760 KB:

Download: http://patches.cross-lfs.org/2.0.0/iana-etc-2.30-numbers_update-20120610-2.patch

MD5 sum: 826fb780d13caafb7cb99b9c346f2102

IPUtils Fixes Patch - 8 KB:

Download: http://patches.cross-lfs.org/2.0.0/iputils-s20101006-fixes-1.patch

MD5 sum: 1add4b8cbee814310f95e61997019162

IPUtils Pregenerated Documentation Patch - 136 KB:

Download: http://patches.cross-lfs.org/2.0.0/iputils-s20101006-doc-1.patch

MD5 sum: 2eee5e095005bf4be426797a4aefa27b

Kbd es.po Fix Patch - 4 KB:

Download: http://patches.cross-lfs.org/2.0.0/kbd-1.15.3-es.po_fix-1.patch

MD5 sum: 476c4066c5c663b44b67acaa4cdef62e

M4 gets Patch - 4 KB:

Download: http://patches.cross-lfs.org/2.0.0/m4-1.4.16-no-gets-1.patch

MD5 sum: 6c5013f9ae5afc78f123e96356ceec3e

Man i18n Patch - 12 KB:

Download: http://patches.cross-lfs.org/2.0.0/man-1.6g-i18n-1.patch

MD5 sum: a5aba0cb5a95a7945db8c882334b7dab

Ncurses Bash Patch - 4 KB:

Download: http://patches.cross-lfs.org/2.0.0/ncurses-5.9-bash_fix-1.patch

MD5 sum: c6f7f2ab0ebaf7721ebeb266641352db

Ncurses Branch Update Patch - 2,492 KB:

Download: http://patches.cross-lfs.org/2.0.0/ncurses-5.9-branch_update-4.patch

MD5 sum: c2b2dc2d31b02c218359e6218f12a72c

Perl Libc Patch - 20 KB:

Download: http://patches.cross-lfs.org/2.0.0/perl-5.16.2-libc-1.patch

MD5 sum: 665f85a83b6141776499f792514235c7

Procps Fix HZ Errors Patch - 4 KB:

Download: http://patches.cross-lfs.org/2.0.0/procps-3.2.8-fix_HZ_errors-1.patch

MD5 sum: 2ea4c8e9a2c2a5a291ec63c92d7c6e3b

Procps ps cgroup Patch - 4 KB:

Download: http://patches.cross-lfs.org/2.0.0/procps-3.2.8-ps_cgroup-1.patch

MD5 sum: 3c478ef88fad23353e332b1b850ec630

Readline Branch Update - 4 KB:

Download: http://patches.cross-lfs.org/2.0.0/readline-6.2-branch_update-3.patch

MD5 sum: af788f5b1cfc5db9efc9e0fa0268a574

Tar Man Page Patch - 76 KB:

Download: http://patches.cross-lfs.org/2.0.0/tar-1.26-man-1.patch

MD5 sum: 074783d41f18c5c62a7cfc77e2678693

Texinfo New Compressors Patch - 4 KB:

Download: http://patches.cross-lfs.org/2.0.0/texinfo-4.13a-new_compressors-1.patch

MD5 sum: 4ae2d3c132e21cb83b825bc691056d07

Vim Branch Update Patch - 2,980 KB:

Download: http://patches.cross-lfs.org/2.0.0/vim-7.3-branch_update-6.patch

MD5 sum: 21cfe3150e5316ef272012630950b7ad

Total size of these patches: about 63 MB

In addition to the above required patches, there exist a number of optional patches created by the CLFS community. These optional patches solve minor problems or enable functionality that is not enabled by default. Feel free to peruse the patches database located at http://patches.cross-lfs.org/2.0.0/ and acquire any additional patches to suit the system needs.

3.5. Additional Patches for x86_64 Multilib

GCC Specs Patch - 20 KB:

Download: http://patches.cross-lfs.org/2.0.0/gcc-4.6.3-specs-1.patch

MD5 sum: 61d583984f9f12b6f37141e132fc7d57

IPRoute2 Lib64 Patch - 2.0 KB:

Download: http://patches.cross-lfs.org/2.0.0/iproute2-3.4.0-libdir-1.patch

MD5 sum: cf8948c05f3a641912e6bd1b38a8a382

Perl Configure Multilib Patch - 560 KB:

Download: http://patches.cross-lfs.org/2.0.0/perl-5.16.2-Configure_multilib-1.patch

MD5 sum: f3e57e768d985b03e93848eb401e8ab4

Total size of these patches: about 582 KB

Chapter 4. Final Preparations

4.1. About ${CLFS}

Throughout this book, the environment variable CLFS will be used several times. It is paramount that this variable is always defined. It should be set to the mount point chosen for the CLFS partition. Check that the CLFS variable is set up properly with:

echo ${CLFS}

Make sure the output shows the path to the CLFS partition's mount point, which is /mnt/clfs if the provided example was followed. If the output is incorrect, the variable can be set with:

export CLFS=/mnt/clfs

Having this variable set is beneficial in that commands such as install -dv ${CLFS}/tools can be typed literally. The shell will automatically replace “${CLFS}” with “/mnt/clfs” (or whatever the variable was set to) when it processes the command line.

If you haven't created the ${CLFS} directory, do so at this time by issuing the following commands:

install -dv ${CLFS}

Do not forget to check that ${CLFS} is set whenever you leave and reenter the current working environment (as when doing a “su” to root or another user).

4.2. Creating the ${CLFS}/tools Directory

All programs compiled in Constructing a Temporary System will be installed under ${CLFS}/tools to keep them separate from the programs compiled in Installing Basic System Software. The programs compiled here are temporary tools and will not be a part of the final CLFS system. By keeping these programs in a separate directory, they can easily be discarded later after their use. This also prevents these programs from ending up in the host production directories (easy to do by accident in Constructing a Temporary System).

Create the required directory by running the following as root:

install -dv ${CLFS}/tools

The next step is to create a /tools symlink on the host system. This will point to the newly-created directory on the CLFS partition. Run this command as root as well:

ln -sv ${CLFS}/tools /

Note

The above command is correct. The ln command has a few syntactic variations, so be sure to check info coreutils ln and ln(1) before reporting what you may think is an error.

The created symlink enables the toolchain to be compiled so that it always refers to /tools, meaning that the compiler, assembler, and linker will work. This will provide a common place for our temporary tools system.

4.3. Creating the ${CLFS}/cross-tools Directory

The cross-binutils and cross-compiler built in Constructing Cross-Compile Tools will be installed under ${CLFS}/cross-tools to keep them separate from the host programs. The programs compiled here are cross-tools and will not be a part of the final CLFS system or the temp-system. By keeping these programs in a separate directory, they can easily be discarded later after their use.

Create the required directory by running the following as root:

install -dv ${CLFS}/cross-tools

The next step is to create a /cross-tools symlink on the host system. This will point to the newly-created directory on the CLFS partition. Run this command as root as well:

ln -sv ${CLFS}/cross-tools /

The symlink isn't technically necessary (though the book's instructions do assume its existence), but is there mainly for consistency (because /tools is also symlinked to ${CLFS}/tools) and to simplify the installation of the cross-compile tools.

4.4. Adding the CLFS User

When logged in as user root, making a single mistake can damage or destroy a system. Therefore, we recommend building the packages as an unprivileged user. You could use your own user name, but to make it easier to set up a clean work environment, create a new user called clfs as a member of a new group (also named clfs) and use this user during the installation process. As root, issue the following commands to add the new user:

groupadd clfs
useradd -s /bin/bash -g clfs -d /home/clfs clfs
mkdir -pv /home/clfs
chown -v clfs:clfs /home/clfs

The meaning of the command line options:

-s /bin/bash

This makes bash the default shell for user clfs.

Important

The build instructions assume that the bash shell is in use.

-g clfs

This option adds user clfs to group clfs.

clfs

This is the actual name for the created group and user.

To log in as clfs (as opposed to switching to user clfs when logged in as root, which does not require the clfs user to have a password), give clfs a password:

passwd clfs

Grant clfs full access to ${CLFS}/cross-tools and ${CLFS}/tools by making clfs the directorys' owner:

chown -v clfs ${CLFS}/tools
chown -v clfs ${CLFS}/cross-tools

If a separate working directory was created as suggested, give user clfs ownership of this directory:

chown -v clfs ${CLFS}/sources

Next, login as user clfs. This can be done via a virtual console, through a display manager, or with the following substitute user command:

su - clfs

The “-” instructs su to start a login shell as opposed to a non-login shell. The difference between these two types of shells can be found in detail in bash(1) and info bash.

Note

Until specified otherwise, all commands from this point on should be done as the clfs user.

4.5. Setting Up the Environment

Set up a good working environment by creating two new startup files for the bash shell. While logged in as user clfs, issue the following command to create a new .bash_profile:

cat > ~/.bash_profile << "EOF"
exec env -i HOME=${HOME} TERM=${TERM} PS1='\u:\w\$ ' /bin/bash
EOF

When logged on as user clfs, the initial shell is usually a login shell which reads the /etc/profile of the host (probably containing some settings and environment variables) and then .bash_profile. The exec env -i.../bin/bash command in the .bash_profile file replaces the running shell with a new one with a completely empty environment, except for the HOME, TERM, and PS1 variables. This ensures that no unwanted and potentially hazardous environment variables from the host system leak into the build environment. The technique used here achieves the goal of ensuring a clean environment.

The new instance of the shell is a non-login shell, which does not read the /etc/profile or .bash_profile files, but rather reads the .bashrc file instead. Create the .bashrc file now:

cat > ~/.bashrc << "EOF"
set +h
umask 022
CLFS=/mnt/clfs
LC_ALL=POSIX
PATH=/cross-tools/bin:/bin:/usr/bin
export CLFS LC_ALL PATH
EOF

The set +h command turns off bash's hash function. Hashing is ordinarily a useful feature—bash uses a hash table to remember the full path of executable files to avoid searching the PATH time and again to find the same executable. However, the new tools should be used as soon as they are installed. By switching off the hash function, the shell will always search the PATH when a program is to be run. As such, the shell will find the newly compiled tools in /cross-tools as soon as they are available without remembering a previous version of the same program in a different location.

Setting the user file-creation mask (umask) to 022 ensures that newly created files and directories are only writable by their owner, but are readable and executable by anyone (assuming default modes are used by the open(2) system call, new files will end up with permission mode 644 and directories with mode 755).

The CLFS variable should be set to the chosen mount point.

The LC_ALL variable controls the localization of certain programs, making their messages follow the conventions of a specified country. If the host system uses a version of Glibc older than 2.2.4, having LC_ALL set to something other than “POSIX” or “C” (during this chapter) may cause issues if you exit the chroot environment and wish to return later. Setting LC_ALL to “POSIX” or “C” (the two are equivalent) ensures that everything will work as expected in the chroot environment.

By putting /cross-tools/bin at the beginning of the PATH, the cross-compiler built in Constructing Cross-Compile Tools will be picked up by the build process for the temp-system packages before anything that may be installed on the host. This, combined with turning off hashing, helps to ensure that you will be using the cross-compile tools to build the temp-system in /tools.

Finally, to have the environment fully prepared for building the temporary tools, source the just-created user profile:

source ~/.bash_profile

4.6. About the Test Suites

Most packages provide a test suite. Running the test suite for a newly built package is a good idea because it can provide a “sanity check” indicating that everything compiled correctly. A test suite that passes its set of checks usually proves that the package is functioning as the developer intended. It does not, however, guarantee that the package is totally bug free.

It is not possible to run testsuites when cross-compiling, so package installation instructions do not explain how to run testsuites until Installing Basic System Software.

Part III. Make the Cross-Compile Tools

Chapter 5. Constructing Cross-Compile Tools

5.1. Introduction

This chapter shows you how to create cross platform tools.

If for some reason you have to stop and come back later, remember to use the su - clfs command, and it will setup the build environment that you left.

5.1.1. Common Notes

Important

Before issuing the build instructions for a package, the package should be unpacked, and a cd into the created directory should be performed.

Several of the packages are patched before compilation, but only when the patch is needed to circumvent a problem. A patch is often needed in both this and the next chapters, but sometimes in only one or the other. Therefore, do not be concerned if instructions for a downloaded patch seem to be missing. Warning messages about offset or fuzz may also be encountered when applying a patch. Do not worry about these warnings, as the patch was still successfully applied.

During the compilation of most packages, there will be several warnings that scroll by on the screen. These are normal and can safely be ignored. These warnings are as they appear—warnings about deprecated, but not invalid, use of the C or C++ syntax. C standards change fairly often, and some packages still use the older standard. This is not a problem, but does prompt the warning.

Important

After installing each package, both in this and the next chapters, delete its source and build directories, unless specifically instructed otherwise. Deleting the sources prevents mis-configuration when the same package is reinstalled later.

5.2. Build CFLAGS

CFLAGS and CXXFLAGS must not be set during the building of cross-tools.

To disable CFLAGS and CXXFLAGS use the following commands:

unset CFLAGS
unset CXXFLAGS

Now add these to ~/.bashrc, just in case you have to exit and restart building later:

echo unset CFLAGS >> ~/.bashrc
echo unset CXXFLAGS >> ~/.bashrc

5.3. Build Variables

Setting Host and Target

During the building of the cross-compile tools you will need to set a few variables that will be dependent on your particular needs. The first variable will be the triplet of the host machine, which will be put into the CLFS_HOST variable. To account for the possibility that the host and target are the same arch, as cross-compiling won't work when host and target are the same, part of the triplet needs to be changed slightly to add "cross". Set CLFS_HOST using the following command:

export CLFS_HOST=$(echo ${MACHTYPE} | sed -e 's/-[^-]*/-cross/')

Now you will need to set the triplet for the target architecture. Set the target variable using the following command:

export CLFS_TARGET="x86_64-unknown-linux-gnu"

Now we will set our Target Triplet for 32 Bits:

export CLFS_TARGET32="i686-pc-linux-gnu"
Copy settings to Environment

Now add these to ~/.bashrc, just in case you have to exit and restart building later:

cat >> ~/.bashrc << EOF
export CLFS_HOST="${CLFS_HOST}"
export CLFS_TARGET="${CLFS_TARGET}"
export CLFS_TARGET32="${CLFS_TARGET32}"
EOF

5.4. Build Flags

We will need to setup target specific flags for the compiler and linker:

export BUILD32="-m32"
export BUILD64="-m64"

Let's add the build flags to ~/.bashrc to prevent issues if we stop and come back later:

cat >> ~/.bashrc << EOF
export BUILD32="${BUILD32}"
export BUILD64="${BUILD64}"
EOF

5.5. Linux-Headers-3.4.17

The Linux Kernel contains a make target that installs “sanitized” kernel headers.

5.5.1. Installation of Linux-Headers

For this step you will need the kernel tarball.

Install the kernel header files:

install -dv /tools/include
make mrproper
make ARCH=x86_64 headers_check
make ARCH=x86_64 INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include

The meaning of the make commands:

make mrproper

Ensures that the kernel source dir is clean.

make ARCH=x86_64 headers_check

Sanitizes the raw kernel headers so that they can be used by userspace programs.

make ARCH=x86_64 INSTALL_HDR_PATH=dest headers_install

Normally the headers_install target removes the entire destination directory (default /usr/include) before installing the headers. To prevent this, we tell the kernel to install the headers to a directory inside the source dir.

Details on this package are located in Section 10.5.2, “Contents of Linux-Headers.”

5.6. File-5.11

The File package contains a utility for determining the type of a given file or files.

5.6.1. Installation of File

Prepare File for compilation:

./configure --prefix=/cross-tools --disable-static

The meaning of the configure options:

--prefix=/cross-tools

This tells the configure script to prepare to install the package in the /cross-tools directory.

--disable-static

This tells the File package not to compile or install static libraries, which are not needed for the Cross-Tools

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.57.2, “Contents of File.”

5.7. M4-1.4.16

The M4 package contains a macro processor.

5.7.1. Installation of M4

The following patch contains a fix when building with a host having Glibc or EGLIBC 2.16 or later.

patch -Np1 -i ../m4-1.4.16-no-gets-1.patch

Prepare M4 for compilation:

./configure --prefix=/cross-tools

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.38.2, “Contents of M4.”

5.8. Ncurses-5.9

The Ncurses package contains libraries for terminal-independent handling of character screens.

5.8.1. Installation of Ncurses

The following patch fixes an issue with some Bash versions:

patch -Np1 -i ../ncurses-5.9-bash_fix-1.patch

Prepare Ncurses for compilation:

./configure --prefix=/cross-tools \
    --without-debug --without-shared

The meaning of the new configure options:

--without-debug

Tells Ncurses to build without debugging information.

--without-shared

This prevents Ncurses from building its shared libraries, which are not needed at this time.

Only one binary is needed for the Cross-Tools. Build the headers and then build tic:

make -C include
make -C progs tic

Install tic with the following command:

install -v -m755 progs/tic /cross-tools/bin

Details on this package are located in Section 10.27.2, “Contents of Ncurses.”

5.9. GMP-5.0.5

GMP is a library for arithmetic on arbitrary precision integers, rational numbers, and floating-point numbers.

5.9.1. Installation of GMP

Prepare GMP for compilation:

CPPFLAGS=-fexceptions ./configure \
    --prefix=/cross-tools --enable-cxx --disable-static

The meaning of the new configure options:

CPPFLAGS=-fexceptions

Allows GMP to handle C++ exceptions thrown by PPL.

--enable-cxx

This tells GMP to enable C++ support.

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.11.2, “Contents of GMP.”

5.10. MPFR-3.1.1

The MPFR library is a C library for multiple-precision floating-point computations with correct rounding.

5.10.1. Installation of MPFR

Prepare MPFR for compilation:

LDFLAGS="-Wl,-rpath,/cross-tools/lib" \
./configure --prefix=/cross-tools \
    --enable-shared --disable-static --with-gmp=/cross-tools

The meaning of the new configure options:

LDFLAGS="-Wl,-rpath,/cross-tools/lib"

This tells configure to search in /cross-tools for libraries.

--enable-shared

This tells configure to build MPFR's shared libraries.

--with-gmp=/cross-tools

This tells configure where to find GMP.

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.13.2, “Contents of MPFR.”

5.11. MPC-1.0.1

MPC is a C library for the arithmetic of complex numbers with arbitrarily high precision and correct rounding of the result.

5.11.1. Installation of MPC

Prepare MPC for compilation:

LDFLAGS="-Wl,-rpath,/cross-tools/lib" \
./configure --prefix=/cross-tools --disable-static \
    --with-gmp=/cross-tools --with-mpfr=/cross-tools

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.15.2, “Contents of MPC.”

5.12. PPL-0.12.1

The Parma Polyhedra Library (PPL) provides numerical abstractions especially targeted at applications in the field of analysis and verification of complex systems. CLooG-PPL requires this library.

5.12.1. Installation of PPL

Prepare PPL for compilation:

CPPFLAGS="-I/cross-tools/include" \
    LDFLAGS="-Wl,-rpath,/cross-tools/lib" \
    ./configure --prefix=/cross-tools --enable-shared --disable-static \
    --enable-interfaces="c,cxx" --disable-optimization \
    --with-gmp=/cross-tools

The meaning of the new configure option:

--enable-interfaces="c,cxx"

Tells configure to enable support for both C and C++.

--disable-optimization

Tells configure to build PPL without compiler optimizations, which are not needed for the Cross-Tools.

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.17.2, “Contents of PPL.”

5.13. CLooG-0.16.3

CLooG is a library to generate code for scanning Z-polyhedra. In other words, it finds code that reaches each integral point of one or more parameterized polyhedra. GCC links with this library in order to enable the new loop generation code known as Graphite.

5.13.1. Installation of CLooG

The following prevents the configure script from setting LD_LIBRARY_PATH when it finds PPL. This will prevent any conflicts with libraries from the host system:

cp -v configure{,.orig}
sed -e "/LD_LIBRARY_PATH=/d" \
    configure.orig > configure

Prepare CLooG for compilation:

LDFLAGS="-Wl,-rpath,/cross-tools/lib" \
    ./configure --prefix=/cross-tools --enable-shared --disable-static \
    --with-gmp-prefix=/cross-tools

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.19.2, “Contents of CLooG.”

5.14. Cross Binutils-2.23

The Binutils package contains a linker, an assembler, and other tools for handling object files.

5.14.1. Installation of Cross Binutils

It is important that Binutils be compiled before Glibc and GCC because both Glibc and GCC perform various tests on the available linker and assembler to determine which of their own features to enable.

The Binutils documentation recommends building Binutils outside of the source directory in a dedicated build directory:

mkdir -v ../binutils-build
cd ../binutils-build

Prepare Binutils for compilation:

AR=ar AS=as ../binutils-2.23/configure \
  --prefix=/cross-tools --host=${CLFS_HOST} --target=${CLFS_TARGET} \
  --with-sysroot=${CLFS} --with-lib-path=/tools/lib --disable-nls \
  --enable-shared --disable-static --enable-64-bit-bfd

The meaning of the configure options:

AR=ar AS=as

This prevents Binutils from compiling with ${CLFS_HOST}-ar and ${CLFS_HOST}-as as they are provided by this package and therefore not installed yet.

--host=${CLFS_HOST}

When used with --target, this creates a cross-architecture executable that creates files for ${CLFS_TARGET} but runs on ${CLFS_HOST}.

--target=${CLFS_TARGET}

When used with --host, this creates a cross-architecture executable that creates files for ${CLFS_TARGET} but runs on ${CLFS_HOST}.

--with-lib-path=/tools/lib

This tells the configure script to specify the library search path during the compilation of Binutils, resulting in /tools/lib being passed to the linker. This prevents the linker from searching through library directories on the host.

--disable-nls

This disables internationalization as i18n is not needed for the cross-compile tools.

--disable-multilib

This option disables the building of a multilib capable Binutils.

--enable-64-bit-bfd

This adds 64 bit support to Binutils.

Compile the package:

make configure-host
make

The meaning of the make options:

configure-host

This checks the host environment and makes sure all the necessary tools are available to compile Binutils.

Install the package:

make install

Copy libiberty.h to /tools/include directory:

cp -v ../binutils-2.23/include/libiberty.h /tools/include

Details on this package are located in Section 10.22.2, “Contents of Binutils.”

5.15. Cross GCC-4.6.3 - Static

The GCC package contains the GNU compiler collection, which includes the C and C++ compilers.

5.15.1. Installation of Cross GCC Compiler with Static libgcc and no Threads

The following patch contains a number of updates to the 4.6.3 branch by the GCC developers:

patch -Np1 -i ../gcc-4.6.3-branch_update-2.patch

Make a couple of essential adjustments to the specs file to ensure GCC uses our build environment:

patch -Np1 -i ../gcc-4.6.3-specs-1.patch

Change the StartFile Spec and Standard Include Dir so that GCC looks in /tools:

echo -en '#undef STANDARD_INCLUDE_DIR\n#define STANDARD_INCLUDE_DIR "/tools/include/"\n\n' >> gcc/config/linux.h
echo -en '\n#undef STANDARD_STARTFILE_PREFIX_1\n#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\n' >> gcc/config/linux.h
echo -en '\n#undef STANDARD_STARTFILE_PREFIX_2\n#define STANDARD_STARTFILE_PREFIX_2 ""\n' >> gcc/config/linux.h

Now alter gcc's c preprocessor's default include search path to use /tools only:

cp -v gcc/Makefile.in{,.orig}
sed -e "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g" \
    gcc/Makefile.in.orig > gcc/Makefile.in

We will create a dummy limits.h so the build will not use the one provided by the host distro:

touch /tools/include/limits.h

The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:

mkdir -v ../gcc-build
cd ../gcc-build

Prepare GCC for compilation:

AR=ar LDFLAGS="-Wl,-rpath,/cross-tools/lib" \
  ../gcc-4.6.3/configure --prefix=/cross-tools \
  --build=${CLFS_HOST} --host=${CLFS_HOST} --target=${CLFS_TARGET} \
  --with-sysroot=${CLFS} --with-local-prefix=/tools --disable-nls \
  --disable-shared --with-mpfr=/cross-tools \
  --with-gmp=/cross-tools --with-ppl=/cross-tools --with-cloog=/cross-tools \
  --without-headers --with-newlib --disable-decimal-float \
  --disable-libgomp --disable-libmudflap --disable-libssp \
  --disable-threads --enable-languages=c --enable-cloog-backend=isl

The meaning of the new configure options:

--with-sysroot=${CLFS}

Tells GCC to consider ${CLFS} as the root file system.

--with-local-prefix=/tools

The purpose of this switch is to remove /usr/local/include from gcc's include search path. This is not absolutely essential, however, it helps to minimize the influence of the host system.

--disable-nls

This disables internationalization as i18n is not needed for the cross-compile tools.

--without-headers

Disables GCC from using the target's Libc when cross compiling.

--with-newlib

Tells GCC that the target libc will use 'newlib'.

--disable-decimal-float

Disables support for the C decimal floating point extension.

--disable-libgomp

Disables the creation of runtime libraries used by GOMP.

--disable-libmudflap

Disables the creation of runtime libaries used by libmudflap.

--disable-libssp

Disables the use of Stack Smashing Protection for runtime libraries.

--disable-threads

This will prevent GCC from looking for the multi-thread include files, since they haven't been created for this architecture yet. GCC will be able to find the multi-thread information after the Glibc headers are created.

--enable-languages=c

This option ensures that only the C compiler is built.

Continue with compiling the package:

make all-gcc all-target-libgcc

The meaning of the new make options:

all-gcc all-target-libgcc

Compiles only the parts of GCC that are needed at this time, rather than the full package.

Install the package:

make install-gcc install-target-libgcc

Details on this package are located in Section 10.23.2, “Contents of GCC.”

5.16. EGLIBC-2.15 32 Bit

The EGLIBC 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.

5.16.1. Installation of EGLIBC

It should be noted that compiling EGLIBC in any way other than the method suggested in this book puts the stability of the system at risk.

Disable linking to libgcc_eh:

cp -v Makeconfig{,.orig}
sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig

The EGLIBC documentation recommends building EGLIBC outside of the source directory in a dedicated build directory:

mkdir -v ../eglibc-build
cd ../eglibc-build

The following lines need to be added to config.cache for EGLIBC to support NPTL:

cat > config.cache << "EOF"
libc_cv_forced_unwind=yes
libc_cv_c_cleanup=yes
libc_cv_gnu89_inline=yes
libc_cv_ssp=no
EOF

Prepare EGLIBC for compilation:

BUILD_CC="gcc" CC="${CLFS_TARGET}-gcc ${BUILD32}" \
    AR="${CLFS_TARGET}-ar" RANLIB="${CLFS_TARGET}-ranlib" \
    CFLAGS="-march=$(cut -d- -f1 <<< $CLFS_TARGET32) -mtune=generic -g -O2" \
    ../eglibc-2.15/configure --prefix=/tools \
    --host=${CLFS_TARGET32} --build=${CLFS_HOST} \
    --disable-profile --with-tls --enable-kernel=2.6.32 --with-__thread \
    --with-binutils=/cross-tools/bin --with-headers=/tools/include \
    --cache-file=config.cache

The meaning of the new configure options:

BUILD_CC="gcc"

This sets EGLIBC to use the current compiler on our system. This is used to create the tools EGLIBC uses during its build.

CC="${CLFS_TARGET}-gcc ${BUILD32}"

Forces EGLIBC to utilize our target architecture GCC utilizing the 32 Bit flags.

AR="${CLFS_TARGET}-ar"

This forces EGLIBC to use the ar utility we made for our target architecture.

RANLIB="${CLFS_TARGET}-ranlib"

This forces EGLIBC to use the ranlib utility we made for our target architecture.

CFLAGS="-march=$(cut -d- -f1 <<< $CLFS_TARGET32) -mtune=generic -g -O2"

Forces EGLIBC to optimize for our target system.

--disable-profile

This builds the libraries without profiling information. Omit this option if profiling on the temporary tools is necessary.

--with-tls

This tells EGLIBC to use Thread Local Storage.

--enable-kernel=2.6.32

This tells EGLIBC to compile the library with support for 2.6.32 and later Linux kernels.

--with-__thread

This tells EGLIBC to use use the __thread for libc and libpthread builds.

--with-binutils=/cross-tools/bin

This tells EGLIBC to use the Binutils that are specific to our target architecture.

--with-headers=/tools/include

This tells EGLIBC to compile itself against the headers recently installed to the /tools directory, so that it knows exactly what features the kernel has and can optimize itself accordingly.

--cache-file=config.cache

This tells EGLIBC to utilize a premade cache file.

During this stage the following warning might appear:

configure: WARNING:
*** These auxiliary programs are missing or
*** incompatible versions: msgfmt
*** some features will be disabled.
*** Check the INSTALL file for required versions.

The missing or incompatible msgfmt program is generally harmless. This msgfmt program is part of the Gettext package which the host distribution should provide.

Compile the package:

make

Install the package:

make install inst_vardbdir=/tools/var/db

Details on this package are located in Section 10.8.5, “Contents of EGLIBC.”

5.17. EGLIBC-2.15 64-Bit

The EGLIBC 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.

5.17.1. Installation of EGLIBC

It should be noted that compiling EGLIBC in any way other than the method suggested in this book puts the stability of the system at risk.

Disable linking to libgcc_eh:

cp -v Makeconfig{,.orig}
sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig

The EGLIBC documentation recommends building EGLIBC outside of the source directory in a dedicated build directory:

mkdir -v ../eglibc-build
cd ../eglibc-build

The following lines need to be added to config.cache for EGLIBC to support NPTL:

cat > config.cache << "EOF"
libc_cv_forced_unwind=yes
libc_cv_c_cleanup=yes
libc_cv_gnu89_inline=yes
libc_cv_ssp=no
EOF

Tell EGLIBC to install its 64-bit libraries into /tools/lib64:

echo "slibdir=/tools/lib64" >> configparms

Prepare EGLIBC for compilation:

BUILD_CC="gcc" CC="${CLFS_TARGET}-gcc ${BUILD64}" \
    AR="${CLFS_TARGET}-ar" RANLIB="${CLFS_TARGET}-ranlib" \
    ../eglibc-2.15/configure --prefix=/tools \
    --host=${CLFS_TARGET} --build=${CLFS_HOST} --libdir=/tools/lib64 \
    --disable-profile --with-tls --enable-kernel=2.6.32 --with-__thread \
    --with-binutils=/cross-tools/bin --with-headers=/tools/include \
    --cache-file=config.cache

The meaning of the new configure options:

CC="${CLFS_TARGET}-gcc ${BUILD64}"

Forces EGLIBC to build using our target architecture GCC utilizing the 64 Bit flags.

--libdir=/tools/lib64

Puts EGLIBC into /tools/lib64 instead of /tools/lib.

During this stage the following warning might appear:

configure: WARNING:
*** These auxiliary programs are missing or
*** incompatible versions: msgfmt
*** some features will be disabled.
*** Check the INSTALL file for required versions.

The missing or incompatible msgfmt program is generally harmless. This msgfmt program is part of the Gettext package which the host distribution should provide.

Compile the package:

make

Install the package:

make install inst_vardbdir=/tools/var/db

Install NIS and RPC related headers that are not installed by default.

cp -v ../eglibc-2.15/sunrpc/rpc/*.h /tools/include/rpc
cp -v ../eglibc-2.15/sunrpc/rpcsvc/*.h /tools/include/rpcsvc
cp -v ../eglibc-2.15/nis/rpcsvc/*.h /tools/include/rpcsvc

Details on this package are located in Section 10.8.5, “Contents of EGLIBC.”

5.18. Cross GCC-4.6.3 - Final

The GCC package contains the GNU compiler collection, which includes the C and C++ compilers.

5.18.1. Installation of GCC Cross Compiler

The following patch contains a number of updates to the 4.6.3 branch by the GCC developers:

patch -Np1 -i ../gcc-4.6.3-branch_update-2.patch

Make a couple of essential adjustments to the specs file to ensure GCC uses our build environment:

patch -Np1 -i ../gcc-4.6.3-specs-1.patch

Change the StartFile Spec and Standard Include Dir so that GCC looks in /tools:

echo -en '#undef STANDARD_INCLUDE_DIR\n#define STANDARD_INCLUDE_DIR "/tools/include/"\n\n' >> gcc/config/linux.h
echo -en '\n#undef STANDARD_STARTFILE_PREFIX_1\n#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\n' >> gcc/config/linux.h
echo -en '\n#undef STANDARD_STARTFILE_PREFIX_2\n#define STANDARD_STARTFILE_PREFIX_2 ""\n' >> gcc/config/linux.h

Now alter gcc's c preprocessor's default include search path to use /tools only:

cp -v gcc/Makefile.in{,.orig}
sed -e "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g" \
    gcc/Makefile.in.orig > gcc/Makefile.in

The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:

mkdir -v ../gcc-build
cd ../gcc-build

Prepare GCC for compilation:

AR=ar LDFLAGS="-Wl,-rpath,/cross-tools/lib" \
  ../gcc-4.6.3/configure --prefix=/cross-tools \
  --build=${CLFS_HOST} --target=${CLFS_TARGET} --host=${CLFS_HOST} \
  --with-sysroot=${CLFS} --with-local-prefix=/tools --disable-nls \
  --enable-shared --disable-static --enable-languages=c,c++ \
  --enable-__cxa_atexit --with-mpfr=/cross-tools --with-gmp=/cross-tools \
  --enable-c99 --with-ppl=/cross-tools --with-cloog=/cross-tools \
  --enable-long-long --enable-threads=posix --enable-cloog-backend=isl

The meaning of the new configure options:

--enable-languages=c,c++

This option ensures that only the C and C++ compilers are built.

--enable-__cxa_atexit

This option allows use of __cxa_atexit, rather than atexit, to register C++ destructors for local statics and global objects and is essential for fully standards-compliant handling of destructors. It also affects the C++ ABI and therefore results in C++ shared libraries and C++ programs that are interoperable with other Linux distributions.

--enable-c99

Enable C99 support for C programs.

--enable-long-long

Enables long long support in the compiler.

--enable-threads=posix

This enables C++ exception handling for multi-threaded code.

Continue with compiling the package:

make AS_FOR_TARGET="${CLFS_TARGET}-as" \
    LD_FOR_TARGET="${CLFS_TARGET}-ld"

Install the package:

make install

Details on this package are located in Section 10.23.2, “Contents of GCC.”

Part IV. Building the Basic Tools

Chapter 6. Constructing a Temporary System

6.1. Introduction

This chapter shows how to compile and install a minimal Linux system. This system will contain just enough tools to start constructing the final CLFS system in Installing Basic System Software and allow a working environment with more user convenience than a minimum environment would.

The tools in this chapter are cross-compiled using the toolchain in /cross-tools and will be installed under the ${CLFS}/tools directory to keep them separate from the files installed in Installing Basic System Software and the host production directories. Since the packages compiled here are temporary, we do not want them to pollute the soon-to-be CLFS system.

Check one last time that the CLFS environment variable is set up properly:

echo ${CLFS}

Make sure the output shows the path to the CLFS partition's mount point, which is /mnt/clfs, using our example.

During this section of the build you will see several WARNING messages like the one below. It is safe to ignore these messages.

configure: WARNING: If you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used.

6.2. Build Variables

Setup target-specific variables for the compiler and linkers:

export CC="${CLFS_TARGET}-gcc"
export CXX="${CLFS_TARGET}-g++"
export AR="${CLFS_TARGET}-ar"
export AS="${CLFS_TARGET}-as"
export RANLIB="${CLFS_TARGET}-ranlib"
export LD="${CLFS_TARGET}-ld"
export STRIP="${CLFS_TARGET}-strip"

Then add the build variables to ~/.bashrc to prevent issues if you stop and come back later:

echo export CC=\""${CC}\"" >> ~/.bashrc
echo export CXX=\""${CXX}\"" >> ~/.bashrc
echo export AR=\""${AR}\"" >> ~/.bashrc
echo export AS=\""${AS}\"" >> ~/.bashrc
echo export RANLIB=\""${RANLIB}\"" >> ~/.bashrc
echo export LD=\""${LD}\"" >> ~/.bashrc
echo export STRIP=\""${STRIP}\"" >> ~/.bashrc

6.3. GMP-5.0.5

GMP is a library for arithmetic on arbitrary precision integers, rational numbers, and floating-point numbers.

6.3.1. Installation of GMP

Prepare GMP for compilation:

HOST_CC=gcc CPPFLAGS=-fexceptions CC="${CC} \
    ${BUILD64}" CXX="${CXX} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --libdir=/tools/lib64 --enable-cxx

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.11.2, “Contents of GMP.”

6.4. MPFR-3.1.1

The MPFR library is a C library for multiple-precision floating-point computations with correct rounding.

6.4.1. Installation of MPFR

Prepare MPFR for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --libdir=/tools/lib64 --enable-shared

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.13.2, “Contents of MPFR.”

6.5. MPC-1.0.1

MPC is a C library for the arithmetic of complex numbers with arbitrarily high precision and correct rounding of the result.

6.5.1. Installation of MPC

Prepare MPC for compilation:

CC="${CC} ${BUILD64}" \
  ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --libdir=/tools/lib64

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.15.2, “Contents of MPC.”

6.6. PPL-0.12.1

The Parma Polyhedra Library (PPL) provides numerical abstractions especially targeted at applications in the field of analysis and verification of complex systems. CLooG-PPL requires this library.

6.6.1. Installation of PPL

Prepare PPL for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --enable-interfaces="c,cxx" --libdir=/tools/lib64 \
    --enable-shared --disable-optimization  \
    --with-gmp-include=/tools/include --with-gmp-lib=/tools/lib

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.17.2, “Contents of PPL.”

6.7. CLooG-0.16.3

CLooG is a library to generate code for scanning Z-polyhedra. In other words, it finds code that reaches each integral point of one or more parameterized polyhedra. GCC links with this library in order to enable the new loop generation code known as Graphite.

6.7.1. Installation of CLooG

The following prevents the configure script from setting LD_LIBRARY_PATH when it finds PPL. This will prevent any conflicts with libraries from the host system:

cp -v configure{,.orig}
sed -e "/LD_LIBRARY_PATH=/d" \
    configure.orig > configure

Prepare CLooG for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET}  --libdir=/tools/lib64 \
     --enable-shared --with-gmp-prefix=/tools 

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.19.2, “Contents of CLooG.”

6.8. Zlib-1.2.7

The Zlib package contains compression and decompression routines used by some programs.

6.8.1. Installation of Zlib

Prepare Zlib for compilation:

CC="${CC} ${BUILD64}" \
   ./configure --prefix=/tools --libdir=/tools/lib64

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.21.2, “Contents of Zlib.”

6.9. Binutils-2.23

The Binutils package contains a linker, an assembler, and other tools for handling object files.

6.9.1. Installation of Binutils

The Binutils documentation recommends building Binutils outside of the source directory in a dedicated build directory:

mkdir -v ../binutils-build
cd ../binutils-build

Prepare Binutils for compilation:

CC="${CC} ${BUILD64}" ../binutils-2.23/configure \
    --prefix=/tools --libdir=/tools/lib64 --with-lib-path=/tools/lib64:/tools/lib \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} --target=${CLFS_TARGET} \
    --disable-nls --enable-shared --enable-64-bit-bfd

The meaning of the new configure options:

CC="${CC} ${BUILD64}"

Tells the compiler to use our 64-bit build flags.

Compile the package:

make configure-host
make

Install the package:

make install

Details on this package are located in Section 10.22.2, “Contents of Binutils.”

6.10. GCC-4.6.3

The GCC package contains the GNU compiler collection, which includes the C and C++ compilers.

6.10.1. Installation of GCC

The following patch contains a number of updates to the 4.6.3 branch by the GCC developers:

patch -Np1 -i ../gcc-4.6.3-branch_update-2.patch

Make a couple of essential adjustments to the specs file to ensure GCC uses our build environment:

patch -Np1 -i ../gcc-4.6.3-specs-1.patch

Change the StartFile Spec and Standard Include Dir so that GCC looks in /tools:

echo -en '#undef STANDARD_INCLUDE_DIR\n#define STANDARD_INCLUDE_DIR "/tools/include/"\n\n' >> gcc/config/linux.h
echo -en '\n#undef STANDARD_STARTFILE_PREFIX_1\n#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\n' >> gcc/config/linux.h
echo -en '\n#undef STANDARD_STARTFILE_PREFIX_2\n#define STANDARD_STARTFILE_PREFIX_2 ""\n' >> gcc/config/linux.h

Also, we need to set the directory searched by the fixincludes process for system headers, so it won't look at the host's headers:

cp -v gcc/Makefile.in{,.orig}
sed -e 's@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g' \
    gcc/Makefile.in.orig > gcc/Makefile.in

The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:

mkdir -v ../gcc-build
cd ../gcc-build

Before starting to build GCC, remember to unset any environment variables that override the default optimization flags.

Prepare GCC for compilation:

CC="${CC} ${BUILD64}" CXX="${CXX} ${BUILD64}" \
  ../gcc-4.6.3/configure --prefix=/tools \
  --libdir=/tools/lib64 --build=${CLFS_HOST} --host=${CLFS_TARGET} \
  --target=${CLFS_TARGET} --with-local-prefix=/tools  --enable-long-long \
  --enable-c99 --enable-shared --enable-threads=posix \
  --enable-__cxa_atexit --disable-nls --enable-languages=c,c++ \
  --disable-libstdcxx-pch --enable-cloog-backend=isl

The meaning of the new configure options:

CXX="${CXX} ${BUILD64}"

This forces the C++ compiler to use our 64 Bit flags.

--disable-libstdcxx-pch

Do not build the pre-compiled header (PCH) for libstdc++. It takes up a lot of space, and we have no use for it.

The following will prevent GCC from looking in the wrong directories for headers and libraries:

cp -v Makefile{,.orig}
sed "/^HOST_\(GMP\|PPL\|CLOOG\)\(LIBS\|INC\)/s:-[IL]/\(lib\|include\)::" \
    Makefile.orig > Makefile

Compile the package:

make AS_FOR_TARGET="${AS}" \
    LD_FOR_TARGET="${LD}"

Install the package:

make install

Details on this package are located in Section 10.23.2, “Contents of GCC.”

6.11. Ncurses-5.9

The Ncurses package contains libraries for terminal-independent handling of character screens.

6.11.1. Installation of Ncurses

The following patch fixes an issue with some Bash versions:

patch -Np1 -i ../ncurses-5.9-bash_fix-1.patch

Prepare Ncurses for compilation:

CC="${CC} ${BUILD64}" CXX="${CXX} ${BUILD64}" \
   ./configure --prefix=/tools --with-shared \
   --build=${CLFS_HOST} --host=${CLFS_TARGET} \
   --without-debug --without-ada \
   --enable-overwrite --with-build-cc=gcc \
   --libdir=/tools/lib64

The meaning of the new configure options:

--with-shared

This tells Ncurses to create a shared library.

--without-debug

This tells Ncurses not to build with debug information.

--without-ada

This ensures that Ncurses does not build support for the Ada compiler which may be present on the host but will not be available when building the final system.

--enable-overwrite

This tells Ncurses to install its header files into /tools/include, instead of /tools/include/ncurses, to ensure that other packages can find the Ncurses headers successfully.

--with-build-cc=gcc

This tells Ncurses what type of compiler we are using.

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.27.2, “Contents of Ncurses.”

6.12. Bash-4.2

The Bash package contains the Bourne-Again SHell.

6.12.1. Installation of Bash

The following patch contains updates from the maintainer. The maintainer of Bash only releases these patches to fix serious issues:

patch -Np1 -i ../bash-4.2-branch_update-6.patch

When Bash is cross-compiled, it cannot test for the presence of named pipes, among other things. If you used su to become an unprivileged user, this combination will cause Bash to build without process substitution, which will break one of the C++ test scripts in eglibc. The following prevents future problems by skipping the check for named pipes, as well as other tests that can not run while cross-compiling or that do not run properly:

cat > config.cache << "EOF"
ac_cv_func_mmap_fixed_mapped=yes
ac_cv_func_strcoll_works=yes
ac_cv_func_working_mktime=yes
bash_cv_func_sigsetjmp=present
bash_cv_getcwd_malloc=yes
bash_cv_job_control_missing=present
bash_cv_printf_a_format=yes
bash_cv_sys_named_pipes=present
bash_cv_ulimit_maxfds=yes
bash_cv_under_sys_siglist=yes
bash_cv_unusable_rtsigs=no
gt_cv_int_divbyzero_sigfpe=yes
EOF

Prepare Bash for compilation:

CC="${CC} ${BUILD64}" CXX="${CXX} ${BUILD64}" \
   ./configure --prefix=/tools \
   --build=${CLFS_HOST} --host=${CLFS_TARGET} \
   --without-bash-malloc --cache-file=config.cache

The meaning of the configure option:

--without-bash-malloc

This option turns off the use of Bash's memory allocation (malloc) function which is known to cause segmentation faults. By turning this option off, Bash will use the malloc functions from Glibc which are more stable.

Compile the package:

make

Install the package:

make install

Make a link for programs that use sh for a shell:

ln -sv bash /tools/bin/sh

Details on this package are located in Section 10.52.2, “Contents of Bash.”

6.13. Bison-2.6.4

The Bison package contains a parser generator.

6.13.1. Installation of Bison

Prepare Bison for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET}

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.40.2, “Contents of Bison.”

6.14. Bzip2-1.0.6

The Bzip2 package contains programs for compressing and decompressing files. Compressing text files with bzip2 yields a much better compression percentage than with the traditional gzip.

6.14.1. Installation of Bzip2

Bzip2's default Makefile target automatically runs the testsuite as well. We need to remove the tests since they won't work on a multi-architecture build, and change the default lib path to lib64:

cp -v Makefile{,.orig}
sed -e 's@^\(all:.*\) test@\1@g' \
    -e 's@/lib\(/\| \|$\)@/lib64\1@g' Makefile.orig > Makefile

The Bzip2 package does not contain a configure script. Compile it with:

make CC="${CC} ${BUILD64}" AR="${AR}" RANLIB="${RANLIB}"

Install the package:

make PREFIX=/tools install

Details on this package are located in Section 10.54.2, “Contents of Bzip2.”

6.15. Coreutils-8.20

The Coreutils package contains utilities for showing and setting the basic system characteristics.

6.15.1. Installation of Coreutils

The following command updates the timestamps on the uname and hostname man pages so that the Makefile does not attempt to regenerate them:

touch man/uname.1 man/hostname.1

Configure can not properly determine how to get free space when cross-compiling - as a result, the df program will not be built. Add the following entries to config.cache to correct this, and fix various cross-compiling issues:

cat > config.cache << EOF
fu_cv_sys_stat_statfs2_bsize=yes
gl_cv_func_working_mkstemp=yes
EOF

Prepare Coreutils for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --enable-install-program=hostname --cache-file=config.cache

The meaning of the new configure option:

--enable-install-program=hostname

Tells Coreutils to install hostname, which is needed for the Perl testsuite.

Coreutils does not build make-prime-list properly and the build host may not be able to execute the target binary. Build it using the host compiler so it can be ran for the generation of data required for the build.

cp -v Makefile{,.orig}
sed '/src_make_prime_list/d' Makefile.orig > Makefile
depbase=`echo src/make-prime-list.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
    gcc -std=gnu99  -I. -I./lib  -Ilib -I./lib -Isrc -I./src  \
    -fdiagnostics-show-option -funit-at-a-time -g -O2 -MT \
    src/make-prime-list.o -MD -MP -MF $depbase.Tpo -c -o src/make-prime-list.o \
    src/make-prime-list.c &&
mv -f $depbase.Tpo $depbase.Po
gcc -std=gnu99 -fdiagnostics-show-option -funit-at-a-time -g -O2 \
    -Wl,--as-needed  -o src/make-prime-list src/make-prime-list.o

Remove the building of the hostname man page as it is affected by the previous commands.

cp -v Makefile{,.bak}
sed -e '/hostname.1/d' Makefile.bak > Makefile

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.36.2, “Contents of Coreutils.”

6.16. Diffutils-3.2

The Diffutils package contains programs that show the differences between files or directories.

6.16.1. Installation of Diffutils

Prepare Diffutils for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
  --build=${CLFS_HOST} --host=${CLFS_TARGET}

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.55.2, “Contents of Diffutils.”

6.17. Findutils-4.4.2

The Findutils package contains programs to find files. These programs are provided to recursively search through a directory tree and to create, maintain, and search a database (often faster than the recursive find, but unreliable if the database has not been recently updated).

6.17.1. Installation of Findutils

The following cache entries set the values for tests that do not run while cross-compiling:

echo "gl_cv_func_wcwidth_works=yes" > config.cache
echo "ac_cv_func_fnmatch_gnu=yes" >> config.cache

Prepare Findutils for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --cache-file=config.cache

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.59.2, “Contents of Findutils.”

6.18. File-5.11

The File package contains a utility for determining the type of a given file or files.

6.18.1. Installation of File

Prepare File for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
   --libdir=/tools/lib64 --build=${CLFS_HOST} --host=${CLFS_TARGET}

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.57.2, “Contents of File.”

6.19. Flex-2.5.37

The Flex package contains a utility for generating programs that recognize patterns in text.

6.19.1. Installation of Flex

When cross compiling, the configure script does not determine the correct values for the following. Set the values manually:

cat > config.cache << EOF
ac_cv_func_malloc_0_nonnull=yes
ac_cv_func_realloc_0_nonnull=yes
EOF

Prepare Flex for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --cache-file=config.cache

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.44.2, “Contents of Flex.”

6.20. Gawk-4.0.1

The Gawk package contains programs for manipulating text files.

6.20.1. Installation of Gawk

Prepare Gawk for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
   --build=${CLFS_HOST} --host=${CLFS_TARGET}

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.58.2, “Contents of Gawk.”

6.21. Gettext-0.18.1.1

The Gettext package contains utilities for internationalization and localization. These allow programs to be compiled with NLS (Native Language Support), enabling them to output messages in the user's native language.

6.21.1. Installation of Gettext

Only the programs in the gettext-tools directory need to be installed for the temp-system:

cd gettext-tools

When cross-compiling the Gettext configure script assumes we don't have a working wcwidth when we do. The following will fix possible compilation errors because of this assumption:

echo "gl_cv_func_wcwidth_works=yes" > config.cache

Prepare Gettext for compilation:

CC="${CC} ${BUILD64}" CXX="${CXX} ${BUILD64}" \
    ./configure --prefix=/tools --disable-shared \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --cache-file=config.cache

The meaning of the configure options:

--disable-shared

This tells Gettext not to create a shared library.

Compile the package:

make -C gnulib-lib
make -C src msgfmt

Install the msgfmt binary:

cp -v src/msgfmt /tools/bin

Details on this package are located in Section 10.61.2, “Contents of Gettext.”

6.22. Grep-2.14

The Grep package contains programs for searching through files.

6.22.1. Installation of Grep

When cross compiling, the configure script does not determine the correct values for the following. Set the values manually:

cat > config.cache << EOF
ac_cv_func_malloc_0_nonnull=yes
ac_cv_func_realloc_0_nonnull=yes
EOF

Prepare Grep for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --without-included-regex --cache-file=config.cache

The meaning of the new configure option:

--without-included-regex

When cross-compiling, Grep's configure assumes there is no usable regex.h installed and instead uses the one included with Grep. This switch forces the use of the regex functions from EGLIBC.

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.62.2, “Contents of Grep.”

6.23. Gzip-1.5

The Gzip package contains programs for compressing and decompressing files.

6.23.1. Installation of Gzip

Prepare Gzip for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
  --build=${CLFS_HOST} --host=${CLFS_TARGET}

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.65.2, “Contents of Gzip.”

6.24. M4-1.4.16

The M4 package contains a macro processor.

6.24.1. Installation of M4

Configure can not properly determine the results of the following tests:

cat > config.cache << EOF
gl_cv_func_btowc_eof=yes
gl_cv_func_mbrtowc_incomplete_state=yes
gl_cv_func_mbrtowc_sanitycheck=yes
gl_cv_func_mbrtowc_null_arg=yes
gl_cv_func_mbrtowc_retval=yes
gl_cv_func_mbrtowc_nul_retval=yes
gl_cv_func_wcrtomb_retval=yes
gl_cv_func_wctob_works=yes
EOF

Prepare M4 for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --cache-file=config.cache

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.38.2, “Contents of M4.”

6.25. Make-3.82

The Make package contains a program for compiling packages.

6.25.1. Installation of Make

Prepare Make for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
   --build=${CLFS_HOST} --host=${CLFS_TARGET}

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.68.2, “Contents of Make.”

6.26. Patch-2.7.1

The Patch package contains a program for modifying or creating files by applying a “patch” file typically created by the diff program.

6.26.1. Installation of Patch

When cross-compiling configure cannot properly detect the existance of certain features. Override this behaviour:

echo "ac_cv_func_strnlen_working=yes" > config.cache

Prepare Patch for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --cache-file=config.cache

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.74.2, “Contents of Patch.”

6.27. Sed-4.2.1

The Sed package contains a stream editor.

6.27.1. Installation of Sed

Prepare Sed for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
   --build=${CLFS_HOST} --host=${CLFS_TARGET}

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.25.2, “Contents of Sed.”

6.28. Tar-1.26

The Tar package contains an archiving program.

6.28.1. Installation of Tar

Configure can not properly determine the results of a few tests. Set them manually:

cat > config.cache << EOF
gl_cv_func_wcwidth_works=yes
gl_cv_func_btowc_eof=yes
ac_cv_func_malloc_0_nonnull=yes
ac_cv_func_realloc_0_nonnull=yes
gl_cv_func_mbrtowc_incomplete_state=yes
gl_cv_func_mbrtowc_nul_retval=yes
gl_cv_func_mbrtowc_null_arg=yes
gl_cv_func_mbrtowc_retval=yes
gl_cv_func_wcrtomb_retval=yes
EOF

Prepare Tar for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
   --build=${CLFS_HOST} --host=${CLFS_TARGET} \
   --cache-file=config.cache

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.82.2, “Contents of Tar.”

6.29. Texinfo-4.13a

The Texinfo package contains programs for reading, writing, and converting info pages.

6.29.1. Installation of Texinfo

Prepare Texinfo for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
   --build=${CLFS_HOST} --host=${CLFS_TARGET}

Compile the package:

make -C tools/gnulib/lib
make -C tools
make

Install the package:

make install

Details on this package are located in Section 10.83.2, “Contents of Texinfo.”

6.30. Vim-7.3

The Vim package contains a powerful text editor.

6.30.1. Installation of VIM

The following patch merges all updates from the 7.3 Branch from the Vim developers:

patch -Np1 -i ../vim-7.3-branch_update-6.patch

The configure script has a single hard coded test that cannot be bypassed with a cache entry. Disable this test with the following command:

cp -v src/auto/configure{,.orig}
sed "/using uint32_t/s/as_fn_error/#&/" src/auto/configure.orig > src/auto/configure

The configure script is full of logic that aborts at the first sign of cross compiling. Work around this by setting the cached values of several tests with the following command:

cat > src/auto/config.cache << "EOF"
vim_cv_getcwd_broken=no
vim_cv_memmove_handles_overlap=yes
vim_cv_stat_ignores_slash=no
vim_cv_terminfo=yes
vim_cv_tgent=zero
vim_cv_toupper_broken=no
vim_cv_tty_group=world
ac_cv_sizeof_int=4
ac_cv_sizeof_long=4
ac_cv_sizeof_time_t=4
ac_cv_sizeof_off_t=4
EOF

Change the default location of the vimrc configuration file to /tools/etc:

echo '#define SYS_VIMRC_FILE "/tools/etc/vimrc"' >> src/feature.h

Prepare Vim for compilation:

CC="${CC} ${BUILD64}" CXX="${CXX} ${BUILD64}" \
  ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \
  --prefix=/tools --enable-multibyte --enable-gui=no \
  --disable-gtktest --disable-xim --with-features=normal \
  --disable-gpm --without-x --disable-netbeans \
  --with-tlib=ncurses

Compile the package:

make

Install the package:

make install

Many users are accustomed to using vi instead of vim. Some programs, such as vigr and vipw, also use vi. Create a symlink to permit execution of vim when users habitually enter vi and allow programs that use vi to work:

ln -sv vim /tools/bin/vi

Create a temporary vimrc to make it function more the way you may expect it to. This is explained more in the final system:

cat > /tools/etc/vimrc << "EOF"
" Begin /etc/vimrc

set nocompatible
set backspace=2
set ruler
syntax on

" End /etc/vimrc
EOF

Details on this package are located in Section 10.86.3, “Contents of Vim.”

6.31. XZ Utils-5.0.4

The XZ-Utils package contains programs for compressing and decompressing files. Compressing text files with XZ-Utils yields a much better compression percentage than with the traditional gzip.

6.31.1. Installation of XZ-Utils

Prepare XZ-Utils for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
     --build=${CLFS_HOST} --host=${CLFS_TARGET}\
     --libdir=/tools/lib64

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.70.2, “Contents of XZ-Utils.”

6.32. To Boot or to Chroot?

There are two different ways you can proceed from this point to build the final system. You can build a kernel, a bootloader, and a few other utilities, boot into the temporary system, and build the rest there. Alternatively, you can chroot into the temporary system.

The boot method is needed when you are building on a different architecture. For example, if you are building a PowerPC system from an x86, you can't chroot. The chroot method is for when you are building on the same architecture. If you are building on, and for, an x86 system, you can simply chroot. The rule of thumb here is if the architectures match and you are running the same series kernel you can just chroot. If you aren't running the same series kernel, or are wanting to run a different ABI, you will need to use the boot option.

If you are in any doubt about this, you can try the following commands to see if you can chroot:

/tools/lib/libc.so.6
/tools/lib64/libc.so.6
/tools/bin/gcc -v

If any of these commands fail, you will have to follow the boot method.

To chroot, you will also need a Linux Kernel-2.6.32 or greater (having been compiled with GCC-4.1.2 or greater). The reason for the kernel version requirement is that eglibc is built to generate the library for the smallest version of the Linux kernel expected to be supported.

To check your kernel version, run cat /proc/version - if it does not say that you are running a 2.6.32 or later Linux kernel, compiled with GCC 4.1.2 or later, you cannot chroot.

For the boot method, follow If You Are Going to Boot.

For the chroot method, follow If You Are Going to Chroot.

Chapter 7. If You Are Going to Boot

7.1. Introduction

This chapter shows how to complete the build of temporary tools to create a minimal system that will be used to boot the target machine and to build the final system packages.

There are a few additional packages that will need to be installed to allow you to boot the minimal system. Some of these packages will be installed onto root or in /usr on the CLFS partition (${CLFS}/bin, ${CLFS}/usr/bin, etc...), rather than /tools, using the "DESTDIR" option with make. This will require the clfs user to have write access to the rest of the CLFS partition, so you will need to temporarily change the ownership of ${CLFS} to the clfs user. Run the following command as root:

chown -v clfs ${CLFS}

7.2. Creating Directories

It is time to create some structure in the CLFS file system. Create a standard directory tree by issuing the following commands:

mkdir -pv ${CLFS}/{bin,boot,dev,{etc/,}opt,home,lib{,64},mnt}
mkdir -pv ${CLFS}/{proc,media/{floppy,cdrom},run/{,shm},sbin,srv,sys}
mkdir -pv ${CLFS}/var/{lock,log,mail,spool}
mkdir -pv ${CLFS}/var/{opt,cache,lib{,64}/{misc,locate},local}
install -dv ${CLFS}/root -m 0750
install -dv ${CLFS}{/var,}/tmp -m 1777
mkdir -pv ${CLFS}/usr/{,local/}{bin,include,lib{,64},sbin,src}
mkdir -pv ${CLFS}/usr/{,local/}share/{doc,info,locale,man}
mkdir -pv ${CLFS}/usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -pv ${CLFS}/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
for dir in ${CLFS}/usr{,/local}; do
  ln -sv share/{man,doc,info} $dir
done
install -dv ${CLFS}/usr/lib/locale
ln -sv ../lib/locale ${CLFS}/usr/lib64

Directories are, by default, created with permission mode 755, but this is not desirable for all directories. In the commands above, two changes are made—one to the home directory of user root, and another to the directories for temporary files.

The first mode change ensures that not just anybody can enter the /root directory—the same as a normal user would do with his or her home directory. The second mode change makes sure that any user can write to the /tmp and /var/tmp directories, but cannot remove another user's files from them. The latter is prohibited by the so-called “sticky bit,” the highest bit (1) in the 1777 bit mask.

7.2.1. FHS Compliance Note

The directory tree is based on the Filesystem Hierarchy Standard (FHS) (available at http://www.pathname.com/fhs/). In addition to the tree created above, this standard stipulates the existence of /usr/local/games and /usr/share/games. The FHS is not precise as to the structure of the /usr/local/share subdirectory, so we create only the directories that are needed. However, feel free to create these directories if you prefer to conform more strictly to the FHS.

7.3. Creating Essential Symlinks

Some programs use hard-wired paths to programs which do not exist yet. In order to satisfy these programs, create a number of symbolic links which will be replaced by real files throughout the course of the next chapter after the software has been installed.

ln -sv /tools/bin/{bash,cat,echo,grep,login,passwd,pwd,sleep,stty} ${CLFS}/bin
ln -sv /tools/bin/file ${CLFS}/usr/bin
ln -sv /tools/sbin/{agetty,blkid} ${CLFS}/sbin
ln -sv /tools/lib/libgcc_s.so{,.1} ${CLFS}/usr/lib
ln -sv /tools/lib64/libgcc_s.so{,.1} ${CLFS}/usr/lib64
ln -sv /tools/lib/libstd*so* ${CLFS}/usr/lib
ln -sv /tools/lib64/libstd*so* ${CLFS}/usr/lib64
ln -sv bash ${CLFS}/bin/sh
ln -sv ../run ${CLFS}/var/run

7.4. Util-linux-2.22.1

The Util-linux package contains miscellaneous utility programs. Among them are utilities for handling file systems, consoles, partitions, and messages.

7.4.1. Installation of Util-linux

Prepare Util-linux for compilation:

CC="${CC} ${BUILD64}" PKG_CONFIG=true ./configure \
    --prefix=/tools --exec-prefix="" --build=${CLFS_HOST} \
    --host=${CLFS_TARGET} --libdir=/tools/lib64 --bindir=/tools/bin \
    --sbindir=/tools/sbin --disable-makeinstall-chown --disable-login \
    --disable-su --config-cache

Compile the package:

make

Install the package:

make usrsbin_execdir=/tools/sbin usrbin_execdir=/tools/bin install

Details on this package are located in Section 10.30.3, “Contents of Util-linux.”

7.5. Shadow-4.1.5.1

The Shadow package contains programs for handling passwords in a secure way.

7.5.1. Installation of Shadow

Disable the installation of the groups program, as Coreutils provides a better version:

cp -v src/Makefile.in{,.orig}
sed -e 's/groups$(EXEEXT) //' src/Makefile.in.orig > src/Makefile.in

The following cache entries set the values for tests that do not run while cross-compiling:

echo "ac_cv_func_setpgrp_void=yes" > config.cache

Prepare Shadow for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} --sysconfdir=/etc \
    --cache-file=config.cache

The meaning of the configure options:

--sysconfdir=/etc

Tells Shadow to install its configuration files into /etc, rather than /tools/etc.

Compile the package:

make

This package does not come with a test suite.

Install the package:

make DESTDIR=${CLFS} install

Details on this package are located in Section 10.35.4, “Contents of Shadow.”

7.6. E2fsprogs-1.42.6

The E2fsprogs package contains the utilities for handling the ext2 file system. It also supports the ext3 and ext4 journaling file systems.

7.6.1. Installation of E2fsprogs

Make sure the libraries get installed to /tools/lib64:

cp -v configure{,.orig}
sed -e "/libdir=.*\/lib/s@/lib@/lib64@g" configure.orig > configure

The E2fsprogs documentation recommends that the package be built in a subdirectory of the source tree:

mkdir -v build
cd build

Prepare E2fsprogs for compilation:

CC="${CC} ${BUILD64}" PKG_CONFIG=true \
  ../configure --prefix=/tools --enable-elf-shlibs \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --disable-libblkid --disable-libuuid --disable-fsck \
    --disable-uuidd

The meaning of the configure options:

--enable-elf-shlibs

This creates the shared libraries which some programs in this package use.

Compile the package:

make LIBUUID="-luuid" STATIC_LIBUUID="-luuid" \
    LIBBLKID="-lblkid" STATIC_LIBBLKID="-lblkid" \
    LDFLAGS="-Wl,-rpath,/tools/lib64"

Install the binaries, documentation and shared libraries:

make install

Install the static libraries and headers:

make install-libs

Create needed symlinks for a bootable system:

ln -sv /tools/sbin/{fsck.ext2,fsck.ext3,fsck.ext4,e2fsck} ${CLFS}/sbin

Details on this package are located in Section 10.34.2, “Contents of E2fsprogs.”

7.7. Sysvinit-2.88dsf

The Sysvinit package contains programs for controlling the startup, running, and shutdown of the system.

7.7.1. Installation of Sysvinit

The following modifications help locate files specific to this particular build:

cp -v src/Makefile{,.orig}
sed -e 's,/usr/lib,/tools/lib,g' \
    src/Makefile.orig > src/Makefile

Compile the package:

make -C src clobber
make -C src CC="${CC} ${BUILD64}"

Install the package:

make -C src ROOT=${CLFS} install

7.7.2. Configuring Sysvinit

Create a new file ${CLFS}/etc/inittab by running the following:

cat > ${CLFS}/etc/inittab << "EOF"
# Begin /etc/inittab

id:3:initdefault:

si::sysinit:/etc/rc.d/init.d/rc sysinit

l0:0:wait:/etc/rc.d/init.d/rc 0
l1:S1:wait:/etc/rc.d/init.d/rc 1
l2:2:wait:/etc/rc.d/init.d/rc 2
l3:3:wait:/etc/rc.d/init.d/rc 3
l4:4:wait:/etc/rc.d/init.d/rc 4
l5:5:wait:/etc/rc.d/init.d/rc 5
l6:6:wait:/etc/rc.d/init.d/rc 6

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

su:S016:once:/sbin/sulogin

EOF

The following command adds the standard virtual terminals to ${CLFS}/etc/inittab. If your system only has a serial console skip the following command:

cat >> ${CLFS}/etc/inittab << "EOF"
1:2345:respawn:/sbin/agetty -I '\033(K' tty1 9600
2:2345:respawn:/sbin/agetty -I '\033(K' tty2 9600
3:2345:respawn:/sbin/agetty -I '\033(K' tty3 9600
4:2345:respawn:/sbin/agetty -I '\033(K' tty4 9600
5:2345:respawn:/sbin/agetty -I '\033(K' tty5 9600
6:2345:respawn:/sbin/agetty -I '\033(K' tty6 9600

EOF

If your system has a serial console, run the following command to add the entry to ${CLFS}/etc/inittab.

cat >> ${CLFS}/etc/inittab << "EOF"
c0:12345:respawn:/sbin/agetty 115200 ttyS0 vt100

EOF

Finally, add the end line to ${CLFS}/etc/inittab.

cat >> ${CLFS}/etc/inittab << "EOF"
# End /etc/inittab
EOF

Details on this package are located in Section 10.81.3, “Contents of Sysvinit.”

7.8. Kmod-10

The Kmod package contains programs for loading, inserting and removing kernel modules for Linux. Kmod replaces the Module-Init-tools package.

7.8.1. Installation of Kmod

Prepare Kmod for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --bindir=/bin --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --libdir=/tools/lib64

Compile the package:

make

Install the package:

make DESTDIR=${CLFS} install

Create symbolic links for programs that expect Module-Init-Tools.

ln -sv kmod ${CLFS}/bin/lsmod
ln -sv ../bin/kmod ${CLFS}/sbin/depmod
ln -sv ../bin/kmod ${CLFS}/sbin/insmod
ln -sv ../bin/kmod ${CLFS}/sbin/modprobe
ln -sv ../bin/kmod ${CLFS}/sbin/modinfo
ln -sv ../bin/kmod ${CLFS}/sbin/rmmod

Details on this package are located in Section 10.73.2, “Contents of Kmod.”

7.9. Udev-182

The Udev package contains programs for dynamic creation of device nodes.

7.9.1. Installation of Udev

Prepare Udev for compilation:

CC="${CC} ${BUILD64}" LIBS="-lpthread" \
    BLKID_CFLAGS="-I/tools/include/blkid" BLKID_LIBS="-L/tools/lib64 -lblkid" \
    KMOD_CFLAGS="-I/tools/include" KMOD_LIBS="-L${CLFS}/lib64 -lkmod" \
    ./configure --prefix=/usr --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --with-rootprefix='' --bindir=/sbin --sysconfdir=/etc --libexecdir=/lib \
    --libdir=/usr/lib64 --disable-introspection \
    --with-usb-ids-path=no --with-pci-ids-path=no \
    --disable-gtk-doc-html --disable-gudev --disable-keymap --disable-logging \
    --with-firmware-path=/lib/firmware

Compile the package:

make

Install the package:

make DESTDIR=${CLFS} install

Details on this package are located in Section 10.85.2, “Contents of Udev.”

7.10. Creating the passwd, group, and log Files

In order for user root to be able to login and for the name “root” to be recognized, there must be relevant entries in the /etc/passwd and /etc/group files.

Create the ${CLFS}/etc/passwd file by running the following command:

cat > ${CLFS}/etc/passwd << "EOF"
root::0:0:root:/root:/bin/bash
EOF

The actual password for root (the “::” used here is just a placeholder and allows you to login with no password) will be set later.

Additional users you may want to add:

bin:x:1:1:bin:/bin:/bin/false

Can be useful for compatibility with legacy applications.

daemon:x:2:6:daemon:/sbin:/bin/false

It is often recommended to use an unprivileged User ID/Group ID for daemons to run as, in order to limit their access to the system.

adm:x:3:16:adm:/var/adm:/bin/false

Was used for programs that performed administrative tasks.

lp:x:10:9:lp:/var/spool/lp:/bin/false

Used by programs for printing

mail:x:30:30:mail:/var/mail:/bin/false

Often used by email programs

news:x:31:31:news:/var/spool/news:/bin/false

Often used for network news servers

operator:x:50:0:operator:/root:/bin/bash

Often used to allow system operators to access the system

postmaster:x:51:30:postmaster:/var/spool/mail:/bin/false

Generally used as an account that receives all the information of troubles with the mail server

nobody:x:65534:65534:nobody:/:/bin/false

Used by NFS

Create the ${CLFS}/etc/group file by running the following command:

cat > ${CLFS}/etc/group << "EOF"
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tty:x:4:
tape:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
dialout:x:10:
audio:x:11:
video:x:12:
utmp:x:13:
usb:x:14:
cdrom:x:15:
EOF

Additional groups you may want to add

adm:x:16:root,adm,daemon

All users in this group are allowed to do administrative tasks

console:x:17:

This group has direct access to the console

cdrw:x:18:

This group is allowed to use the CDRW drive

mail:x:30:mail

Used by MTAs (Mail Transport Agents)

news:x:31:news

Used by Network News Servers

users:x:1000:

The default GID used by shadow for new users

nogroup:x:65533:

This is a default group used by some programs that do not require a group

nobody:x:65534:

This is used by NFS

The created groups are not part of any standard—they are groups decided on in part by the requirements of the Udev configuration in the final system, and in part by common convention employed by a number of existing Linux distributions. The Linux Standard Base (LSB, available at http://www.linuxbase.org) recommends only that, besides the group “root” with a Group ID (GID) of 0, a group “bin” with a GID of 1 be present. All other group names and GIDs can be chosen freely by the system administrator since well-written programs do not depend on GID numbers, but rather use the group's name.

The login, agetty, and init programs (and others) use a number of log files to record information such as who was logged into the system and when. However, these programs will not write to the log files if they do not already exist. Initialize the log files and give them proper permissions:

touch ${CLFS}/var/run/utmp ${CLFS}/var/log/{btmp,lastlog,wtmp}
chmod -v 664 ${CLFS}/var/run/utmp ${CLFS}/var/log/lastlog
chmod -v 600 ${CLFS}/var/log/btmp

The /var/run/utmp file records the users that are currently logged in. The /var/log/wtmp file records all logins and logouts. The /var/log/lastlog file records when each user last logged in. The /var/log/btmp file records the bad login attempts.

7.11. Linux-3.4.17

The Linux package contains the Linux kernel.

7.11.1. Installation of the kernel

Warning

Here a temporary cross-compiled kernel will be built. When configuring it, select the minimal amount of options required to boot the target machine and build the final system. I.e., no support for sound, printers, etc. will be needed.

Also, try to avoid the use of modules if possible, and don't use the resulting kernel image for production systems.

Building the kernel involves a few steps—configuration, compilation, and installation. Read the README file in the kernel source tree for alternative methods to the way this book configures the kernel.

To ensure that your system boots and you can properly run both 32 bit and 64 bit binaries, please make sure that you enable support for ELF and emulations for 32bit ELF into the kernel.

Prepare for compilation by running the following command:

make mrproper

This ensures that the kernel tree is absolutely clean. The kernel team recommends that this command be issued prior to each kernel compilation. Do not rely on the source tree being clean after un-tarring.

Configure the kernel via a menu-driven interface:

make ARCH=x86_64 CROSS_COMPILE=${CLFS_TARGET}- menuconfig

Compile the kernel image and modules:

make ARCH=x86_64 CROSS_COMPILE=${CLFS_TARGET}-

If the use of kernel modules can't be avoided, an /etc/modprobe.conf file may be needed. Information pertaining to modules and kernel configuration is located in the kernel documentation in the Documentation directory of the kernel sources tree. The modprobe.conf man page may also be of interest.

Be very careful when reading other documentation relating to kernel modules because it usually applies to 2.4.x kernels only. As far as we know, kernel configuration issues specific to Hotplug and Udev are not documented. The problem is that Udev will create a device node only if Hotplug or a user-written script inserts the corresponding module into the kernel, and not all modules are detectable by Hotplug. Note that statements like the one below in the /etc/modprobe.conf file do not work with Udev:

alias char-major-XXX some-module

Install the modules, if the kernel configuration uses them:

make ARCH=x86_64 CROSS_COMPILE=${CLFS_TARGET}- \
   INSTALL_MOD_PATH=${CLFS} modules_install

After kernel compilation is complete, additional steps are required to complete the installation. Some files need to be copied to the ${CLFS}/boot directory.

Issue the following command to install the kernel:

cp -v arch/x86_64/boot/bzImage ${CLFS}/boot/vmlinuz-clfs-3.4.17

System.map is a symbol file for the kernel. It maps the function entry points of every function in the kernel API, as well as the addresses of the kernel data structures for the running kernel. Issue the following command to install the map file:

cp -v System.map ${CLFS}/boot/System.map-3.4.17

The kernel configuration file .config produced by the make menuconfig step above contains all the configuration selections for the kernel that was just compiled. It is a good idea to keep this file for future reference:

cp -v .config ${CLFS}/boot/config-3.4.17

Details on this package are located in Section 13.3.2, “Contents of Linux.”

7.12. GRUB-2.00

The GRUB package contains the GRand Unified Bootloader.

7.12.1. Installation of GRUB

Note

If you would like use a different bootloader than this one you can go to the following link for alterative bootloaders and the instructions to use them. http://trac.cross-lfs.org/wiki/bootloaders

Prepare GRUB for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --sysconfdir=/etc --libdir=/tools/lib64 --disable-werror

Compile the package:

make

Install the package:

make DESTDIR=${CLFS} install

Details on this package are located in Section 10.87.3, “Contents of GRUB.”

7.13. Setting Up the Environment

The new instance of the shell that will start when the system is booted is a login shell, which will read .bash_profile file. Create the .bash_profile file now:

cat > ${CLFS}/root/.bash_profile << "EOF"
set +h
PS1='\u:\w\$ '
LC_ALL=POSIX
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/tools/sbin
export LC_ALL PATH PS1
EOF

The LC_ALL variable controls the localization of certain programs, making their messages follow the conventions of a specified country. Setting LC_ALL to “POSIX” or “C” (the two are equivalent) ensures that everything will work as expected on your temporary system.

By putting /tools/bin and /tools/sbin at the end of the standard PATH, all the programs installed in Constructing a Temporary System are only picked up by the shell if they have not yet been built on the target system. This configuration forces use of the final system binaries as they are built over the temp-system, minimising the chance of final system programs being built against the temp-system.

7.14. Build Flags

We will need to copy our build variables into our new system:

cat >> ${CLFS}/root/.bash_profile << EOF
export BUILD32="${BUILD32}"
export BUILD64="${BUILD64}"
export CLFS_TARGET32="${CLFS_TARGET32}"
EOF

7.15. Creating the /etc/fstab File

The /etc/fstab file is used by some programs to determine where file systems are to be mounted by default, which must be checked, and in which order. Create a new file systems table like this:

cat > ${CLFS}/etc/fstab << "EOF"
# Begin /etc/fstab

# file system  mount-point  type   options          dump  fsck
#                                                         order

/dev/[xxx]     /            [fff]  defaults         1     1
/dev/[yyy]     swap         swap   pri=1            0     0
proc           /proc        proc   defaults         0     0
sysfs          /sys         sysfs  defaults         0     0
devpts         /dev/pts     devpts gid=4,mode=620   0     0
shm            /dev/shm     tmpfs  defaults         0     0
tmpfs          /run            tmpfs       defaults         0     0
devtmpfs       /dev            devtmpfs    mode=0755,nosuid 0     0

# End /etc/fstab
EOF

Replace [xxx], [yyy], and [fff] with the values appropriate for the system, for example, hda2, hda5, and ext2. For details on the six fields in this file, see man 5 fstab.

The /dev/shm mount point for tmpfs is included to allow enabling POSIX-shared memory. The kernel must have the required support built into it for this to work (more about this is in the next section). Please note that very little software currently uses POSIX-shared memory. Therefore, consider the /dev/shm mount point optional. For more information, see Documentation/filesystems/tmpfs.txt in the kernel source tree.

7.16. Bootscripts for CLFS 2.0.0

The Bootscripts package contains a set of scripts to start/stop the CLFS system at bootup/shutdown.

7.16.1. Installation of Bootscripts

Install the package:

make DESTDIR=${CLFS} install-minimal

The setclock script reads the time from the hardware clock, also known as the BIOS or the Complementary Metal Oxide Semiconductor (CMOS) clock. If the hardware clock is set to UTC, this script will convert the hardware clock's time to the local time using the /etc/localtime file (which tells the hwclock program which timezone the user is in). There is no way to detect whether or not the hardware clock is set to UTC, so this needs to be configured manually.

If you do not know whether or not the hardware clock is set to UTC, you can find out after you have booted the new machine by running the hwclock --localtime --show command, and if necessary editing the /etc/sysconfig/clock script. The worst that will happen if you make a wrong guess here is that the time displayed will be wrong.

Change the value of the UTC variable below to a value of 0 (zero) if the hardware clock is not set to UTC time.

cat > ${CLFS}/etc/sysconfig/clock << "EOF"
# Begin /etc/sysconfig/clock

UTC=1

# End /etc/sysconfig/clock
EOF

Details on this package are located in Section 11.2.2, “Contents of Bootscripts.”

7.17. Populating /dev

7.17.1. Creating Initial Device Nodes

Note

The commands in the remainder of the book should be run as the root user. Check that ${CLFS} is set in the root user’s environment before proceeding.

When the kernel boots the system, it requires the presence of a few device nodes, in particular the console and null devices. The device nodes will be created on the hard disk so that they are available before udev has been started, and additionally when Linux is started in single user mode (hence the restrictive permissions on console). Create these by running the following commands:

mknod -m 600 ${CLFS}/dev/console c 5 1
mknod -m 666 ${CLFS}/dev/null c 1 3

Before udev starts, a tmpfs filesystem is mounted over /dev and the previous entries are no longer available. The following command creates files that are copied over by the udev bootscript:

mknod -m 600 ${CLFS}/lib/udev/devices/console c 5 1
mknod -m 666 ${CLFS}/lib/udev/devices/null c 1 3

7.18. Changing Ownership

Currently, the ${CLFS} directory and all of its subdirectories are owned by the user clfs, a user that exists only on the host system. For security reasons, the ${CLFS} root directory and all of its subdirectories should be owned by root. Change the ownership for ${CLFS} and its subdirectories by running this command:

chown -Rv 0:0 ${CLFS}

The following files are to be owned by the group utmp not by root.

chgrp -v 13 ${CLFS}/var/run/utmp ${CLFS}/var/log/lastlog

7.19. What to do next

Now you're at the point to get your ${CLFS} directory copied over to your target machine. The easiest method would be to tar it up and copy the file.

tar -jcvf ${CLFS}.tar.bz2 ${CLFS}

Chapter 8. If You Are Going to Chroot

8.1. Introduction

This chapter shows how to prepare a chroot jail to build the final system packages into.

8.2. Util-linux-2.22.1

The Util-linux package contains miscellaneous utility programs. Among them are utilities for handling file systems, consoles, partitions, and messages.

8.2.1. Installation of Util-linux

Prepare Util-linux for compilation:

CC="${CC} ${BUILD64}" ./configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --disable-makeinstall-chown --disable-login --disable-su \
    --config-cache

Compile the package:

make

Install the package:

make install

Details on this package are located in Section 10.30.3, “Contents of Util-linux.”

8.3. Mounting Virtual Kernel File Systems

Note

The commands in the remainder of the book should be run as the root user. Check that ${CLFS} is set in the root user’s environment before proceeding.

Various file systems exported by the kernel are used to communicate to and from the kernel itself. These file systems are virtual in that no disk space is used for them. The content of the file systems resides in memory.

Begin by creating directories onto which the file systems will be mounted:

mkdir -pv ${CLFS}/{dev,proc,sys}

Now mount the file systems:

mount -vt proc proc ${CLFS}/proc
mount -vt sysfs sysfs ${CLFS}/sys

Remember that if for any reason you stop working on the CLFS system and start again later, it is important to check that these file systems are mounted again before entering the chroot environment.

Two device nodes, /dev/console and /dev/null, are required to be present on the filesystem. These are needed by the kernel even before starting Udev early in the boot process, so we create them here:

mknod -m 600 ${CLFS}/dev/console c 5 1
mknod -m 666 ${CLFS}/dev/null c 1 3

Once the system is complete and booting, the rest of our device nodes are created by the Udev package. Since this package is not available to us right now, we must take other steps to provide device nodes under on the CLFS filesystem. We will use the “bind” option in the mount command to make our host system's /dev structure appear in the new CLFS filesystem:

mount -v -o bind /dev ${CLFS}/dev

Additional file systems will soon be mounted from within the chroot environment. To keep the host up to date, perform a “fake mount” for each of these now:

mount -f -vt tmpfs tmpfs ${CLFS}/dev/shm
mount -f -vt devpts -o gid=4,mode=620 devpts ${CLFS}/dev/pts

8.4. Entering the Chroot Environment

It is time to enter the chroot environment to begin building and installing the final CLFS system. As user root, run the following command to enter the realm that is, at the moment, populated with only the temporary tools:

chroot "${CLFS}" /tools/bin/env -i \
    HOME=/root TERM="${TERM}" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    /tools/bin/bash --login +h

The -i option given to the env command will clear all variables of the chroot environment. After that, only the HOME, TERM, PS1, and PATH variables are set again. The TERM=${TERM} construct will set the TERM variable inside chroot to the same value as outside chroot. This variable is needed for programs like vim and less to operate properly. If other variables are needed, such as CFLAGS or CXXFLAGS, this is a good place to set them again.

From this point on, there is no need to use the CLFS variable anymore, because all work will be restricted to the CLFS file system. This is because the Bash shell is told that ${CLFS} is now the root (/) directory.

Notice that /tools/bin comes last in the PATH. This means that a temporary tool will no longer be used once its final version is installed. This occurs when the shell does not “remember” the locations of executed binaries—for this reason, hashing is switched off by passing the +h option to bash.

It is important that all the commands throughout the remainder of this chapter and the following chapters are run from within the chroot environment. If you leave this environment for any reason (rebooting for example), remember to first mount the proc and devpts file systems (discussed in the previous section) and enter chroot again before continuing with the installations.

Note that the bash prompt will say I have no name! This is normal because the /etc/passwd file has not been created yet.

8.5. Changing Ownership

Note

This step is not optional as some of the binaries in /tools are set u+s. leaving the permissions as is could cause some commands, mount in particular, to fail later.

Currently, the /tools and /cross-tools directories are owned by the user clfs, a user that exists only on the host system. Although the /tools and /cross-tools directories can be deleted once the CLFS system has been finished, they can be retained to build additional CLFS systems. If the /tools and /cross-tools directories are kept as is, the files are owned by a user ID without a corresponding account. This is dangerous because a user account created later could get this same user ID and would own the /tools directory and all the files therein, thus exposing these files to possible malicious manipulation.

To avoid this issue, add the clfs user to the new CLFS system later when creating the /etc/passwd file, taking care to assign it the same user and group IDs as on the host system. Alternatively, assign the contents of the /tools and /cross-tools directories to user root by running the following commands:

chown -Rv 0:0 /tools
chown -Rv 0:0 /cross-tools

The commands use 0:0 instead of root:root, because chown is unable to resolve the name “root” until the passwd file has been created.

8.6. Creating Directories

It is time to create some structure in the CLFS file system. Create a standard directory tree by issuing the following commands:

mkdir -pv /{bin,boot,dev,{etc/,}opt,home,lib{,64},mnt}
mkdir -pv /{proc,media/{floppy,cdrom},run/{,shm},sbin,srv,sys}
mkdir -pv /var/{lock,log,mail,spool}
mkdir -pv /var/{opt,cache,lib{,64}/{misc,locate},local}
install -dv /root -m 0750
install -dv {/var,}/tmp -m 1777
mkdir -pv /usr/{,local/}{bin,include,lib{,64},sbin,src}
mkdir -pv /usr/{,local/}share/{doc,info,locale,man}
mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -pv /usr/{,local/}share/man/man{1..8}
for dir in /usr{,/local}; do
  ln -sv share/{man,doc,info} $dir
done
install -dv /usr/lib/locale
ln -sv ../lib/locale /usr/lib64

Directories are, by default, created with permission mode 755, but this is not desirable for all directories. In the commands above, two changes are made—one to the home directory of user root, and another to the directories for temporary files.

The first mode change ensures that not just anybody can enter the /root directory—the same as a normal user would do with his or her home directory. The second mode change makes sure that any user can write to the /tmp and /var/tmp directories, but cannot remove another user's files from them. The latter is prohibited by the so-called “sticky bit,” the highest bit (1) in the 1777 bit mask.

8.6.1. FHS Compliance Note

The directory tree is based on the Filesystem Hierarchy Standard (FHS) (available at http://www.pathname.com/fhs/). In addition to the tree created above, this standard stipulates the existence of /usr/local/games and /usr/share/games. The FHS is not precise as to the structure of the /usr/local/share subdirectory, so we create only the directories that are needed. However, feel free to create these directories if you prefer to conform more strictly to the FHS.

8.7. Creating Essential Symlinks

Some programs use hard-wired paths to programs which do not exist yet. In order to satisfy these programs, create a number of symbolic links which will be replaced by real files throughout the course of the next chapter after the software has been installed.

ln -sv /tools/bin/{bash,cat,echo,grep,pwd,stty} /bin
ln -sv /tools/bin/file /usr/bin
ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
ln -sv /tools/lib64/libgcc_s.so{,.1} /usr/lib64
ln -sv /tools/lib/libstd* /usr/lib
ln -sv /tools/lib64/libstd* /usr/lib64
ln -sv bash /bin/sh
ln -sv /run /var/run

8.8. Build Flags

We will need to setup target specific flags for the compiler and linkers:

export BUILD32="-m32"
export BUILD64="-m64"

You will need to set your host target triplet for 32 bit:

export CLFS_TARGET32="i686-pc-linux-gnu"

To prevent errors when you come back to your build, we will export these variables to prevent any build issues in the future:

cat >> ${CLFS}/root/.bash_profile << EOF
export BUILD32="${BUILD32}"
export BUILD64="${BUILD64}"
export CLFS_TARGET32="${CLFS_TARGET32}"
EOF

8.9. Creating the passwd, group, and log Files

In order for user root to be able to login and for the name “root” to be recognized, there must be relevant entries in the /etc/passwd and /etc/group files.

Create the /etc/passwd file by running the following command:

cat > /etc/passwd << "EOF"
root:x:0:0:root:/root:/bin/bash
EOF

The actual password for root (the “x” used here is just a placeholder) will be set later.

Additional users you may want to add:

bin:x:1:1:bin:/bin:/bin/false

Can be useful for compatibility with legacy applications.

daemon:x:2:6:daemon:/sbin:/bin/false

It is often recommended to use an unprivileged User ID/Group ID for daemons to run as, in order to limit their access to the system.

adm:x:3:16:adm:/var/adm:/bin/false

Was used for programs that performed administrative tasks.

lp:x:10:9:lp:/var/spool/lp:/bin/false

Used by programs for printing

mail:x:30:30:mail:/var/mail:/bin/false

Often used by email programs

news:x:31:31:news:/var/spool/news:/bin/false

Often used for network news servers

operator:x:50:0:operator:/root:/bin/bash

Often used to allow system operators to access the system

postmaster:x:51:30:postmaster:/var/spool/mail:/bin/false

Generally used as an account that receives all the information of troubles with the mail server

nobody:x:65534:65534:nobody:/:/bin/false

Used by NFS

Create the /etc/group file by running the following command:

cat > /etc/group << "EOF"
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tty:x:4:
tape:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
dialout:x:10:
audio:x:11:
video:x:12:
utmp:x:13:
usb:x:14:
cdrom:x:15:
EOF

Additional groups you may want to add

adm:x:16:root,adm,daemon

All users in this group are allowed to do administrative tasks

console:x:17:

This group has direct access to the console

cdrw:x:18:

This group is allowed to use the CDRW drive

mail:x:30:mail

Used by MTAs (Mail Transport Agents)

news:x:31:news

Used by Network News Servers

users:x:1000:

The default GID used by shadow for new users

nogroup:x:65533:

This is a default group used by some programs that do not require a group

nobody:x:65534:

This is used by NFS

The created groups are not part of any standard—they are groups decided on in part by the requirements of the Udev configuration in the final system, and in part by common convention employed by a number of existing Linux distributions. The Linux Standard Base (LSB, available at http://www.linuxbase.org) recommends only that, besides the group “root” with a Group ID (GID) of 0, a group “bin” with a GID of 1 be present. All other group names and GIDs can be chosen freely by the system administrator since well-written programs do not depend on GID numbers, but rather use the group's name.

To remove the “I have no name!” prompt, start a new shell. Since a full Glibc was installed in Constructing Cross-Compile Tools and the /etc/passwd and /etc/group files have been created, user name and group name resolution will now work.

exec /tools/bin/bash --login +h

Note the use of the +h directive. This tells bash not to use its internal path hashing. Without this directive, bash would remember the paths to binaries it has executed. To ensure the use of the newly compiled binaries as soon as they are installed, the +h directive will be used for the duration of the next chapters.

The login, agetty, and init programs (and others) use a number of log files to record information such as who was logged into the system and when. However, these programs will not write to the log files if they do not already exist. Initialize the log files and give them proper permissions:

touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
chgrp -v utmp /var/run/utmp /var/log/lastlog
chmod -v 664 /var/run/utmp /var/log/lastlog
chmod -v 600 /var/log/btmp

The /var/run/utmp file records the users that are currently logged in. The /var/log/wtmp file records all logins and logouts. The /var/log/lastlog file records when each user last logged in. The /var/log/btmp file records the bad login attempts.

8.10. Mounting Kernel Filesystems

8.10.1. Mounting Additional Kernel Filesystems

Mount the proper virtual (kernel) file systems on the newly-created directories:

mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm

The mount commands executed above may result in the following warning message:

can't open /etc/fstab: No such file or directory.

This file—/etc/fstab—has not been created yet but is also not required for the file systems to be properly mounted. As such, the warning can be safely ignored.

Part V. Building the CLFS System

Chapter 9. Constructing Testsuite Tools

9.1. Introduction

This chapter builds the tools needed by some packages to run the tests that they have. I.e., make check. Tcl, Expect, and DejaGNU are needed for the GCC and Binutils testsuites. Installing three packages for testing purposes may seem excessive, but it is very reassuring, if not essential, to know that the most important tools are working properly.

9.2. Tcl-8.5.12

The Tcl package contains the Tool Command Language.

9.2.1. Installation of Tcl

Prepare Tcl for compilation:

cd unix
CC="gcc ${BUILD64}" ./configure --prefix=/tools --libdir=/tools/lib64

Build the package:

make

Install the package:

make install

Tcl's private header files are needed for the next package, Expect. Install them into /tools:

make install-private-headers

Now make a necessary symbolic link:

ln -sv tclsh8.5 /tools/bin/tclsh

9.2.2. Contents of Tcl

Installed programs: tclsh (link to tclsh8.5) and tclsh8.5
Installed libraries: libtcl8.5.so, libtclstub8.5.a

Short Descriptions

tclsh8.5

The Tcl command shell

tclsh

A link to tclsh8.5

libtcl8.5.so

The Tcl library

libtclstub8.5.a

The Tcl Stub library

9.3. Expect-5.45

The Expect package contains a program for carrying out scripted dialogues with other interactive programs.

9.3.1. Installation of Expect

Now prepare Expect for compilation:

CC="gcc ${BUILD64}" ./configure --prefix=/tools \
   --with-tcl=/tools/lib64 --with-tclinclude=/tools/include  \
   --libdir=/tools/lib64

The meaning of the configure options:

--with-tcl=/tools/lib64

This ensures that the configure script finds the Tcl installation in the temporary tools location.

--with-tclinclude=/tools/include

This explicitly tells Expect where to find Tcl's internal headers. Using this option avoids conditions where configure fails because it cannot automatically discover the location of the Tcl source directory.

Build the package:

make

Install the package:

make SCRIPTS="" install

The meaning of the make parameter:

SCRIPTS=""

This prevents installation of the supplementary expect scripts, which are not needed.

9.3.2. Contents of Expect

Installed program: expect
Installed library: libexpect-5.43.a

Short Descriptions

expect

Communicates with other interactive programs according to a script

libexpect-5.43.a

Contains functions that allow Expect to be used as a Tcl extension or to be used directly from C or C++ (without Tcl)

9.4. DejaGNU-1.5

The DejaGNU package contains a framework for testing other programs.

9.4.1. Installation of DejaGNU

Prepare DejaGNU for compilation:

./configure --prefix=/tools

Build and install the package:

make install

9.4.2. Contents of DejaGNU

Installed program: runtest

Short Descriptions

runtest

A wrapper script that locates the proper expect shell and then runs DejaGNU

Chapter 10. Installing Basic System Software

10.1. Introduction

In this chapter, we enter the building site and start constructing the CLFS system in earnest. The installation of this software is straightforward. Although in many cases the installation instructions could be made shorter and more generic, we have opted to provide the full instructions for every package to minimize the possibilities for mistakes. The key to learning what makes a Linux system work is to know what each package is used for and why the user (or the system) needs it. For every installed package, a summary of its contents is given, followed by concise descriptions of each program and library the package installed.

If using compiler optimizations, please review the optimization hint at http://hints.cross-lfs.org/index.php/Optimization. Compiler optimizations can make a program run slightly faster, but they may also cause compilation difficulties and problems when running the program. If a package refuses to compile when using optimization, try to compile it without optimization and see if that fixes the problem. Even if the package does compile when using optimization, there is the risk it may have been compiled incorrectly because of the complex interactions between the code and build tools. Also note that the -march and -mtune options may cause problems with the toolchain packages (Binutils, GCC and Glibc). The small potential gains achieved in using compiler optimizations are often outweighed by the risks. First-time builders of CLFS are encouraged to build without custom optimizations. The subsequent system will still run very fast and be stable at the same time.

The order that packages are installed in this chapter needs to be strictly followed to ensure that no program accidentally acquires a path referring to /tools hard-wired into it. For the same reason, do not compile packages in parallel. Compiling in parallel may save time (especially on dual-CPU machines), but it could result in a program containing a hard-wired path to /tools, which will cause the program to stop working when that directory is removed.

To keep track of which package installs particular files, a package manager can be used. For a general overview of different styles of package managers, please take a look at the next page.

10.2. Package Management

Package Management is an often-requested addition to the CLFS Book. A Package Manager allows tracking the installation of files making it easy to remove and upgrade packages. Before you begin to wonder, NO—this section will not talk about nor recommend any particular package manager. What it provides is a roundup of the more popular techniques and how they work. The perfect package manager for you may be among these techniques or may be a combination of two or more of these techniques. This section briefly mentions issues that may arise when upgrading packages.

Some reasons why no specific package manager is recommended in CLFS or CBLFS include:

  • Dealing with package management takes the focus away from the goals of these books—teaching how a Linux system is built.

  • There are multiple solutions for package management, each having its strengths and drawbacks. Including one that satisfies all audiences is difficult.

There are some hints written on the topic of package management. Visit the Hints subproject and see if one of them fits your need.

10.2.1. Upgrade Issues

A Package Manager makes it easy to upgrade to newer versions when they are released. Generally the instructions in CLFS and CBLFS can be used to upgrade to the newer versions. Here are some points that you should be aware of when upgrading packages, especially on a running system.

  • If one of the toolchain packages (Glibc, GCC or Binutils) needs to be upgraded to a newer minor version, it is safer to rebuild CLFS. Though you may be able to get by rebuilding all the packages in their dependency order, we do not recommend it. For example, if glibc-2.2.x needs to be updated to glibc-2.3.x, it is safer to rebuild. For micro version updates, a simple reinstallation usually works, but is not guaranteed. For example, upgrading from glibc-2.3.4 to glibc-2.3.5 will not usually cause any problems.

  • If a package containing a shared library is updated, and if the name of the library changes, then all the packages dynamically linked to the library need to be recompiled to link against the newer library. (Note that there is no correlation between the package version and the name of the library.) For example, consider a package foo-1.2.3 that installs a shared library with name libfoo.so.1. Say you upgrade the package to a newer version foo-1.2.4 that installs a shared library with name libfoo.so.2. In this case, all packages that are dynamically linked to libfoo.so.1 need to be recompiled to link against libfoo.so.2. Note that you should not remove the previous libraries until the dependent packages are recompiled.

  • If you are upgrading a running system, be on the lookout for packages that use cp instead of install to install files. The latter command is usually safer if the executable or library is already loaded in memory.

10.2.2. Package Management Techniques

The following are some common package management techniques. Before making a decision on a package manager, do some research on the various techniques, particularly the drawbacks of the particular scheme.

10.2.2.1. It is All in My Head!

Yes, this is a package management technique. Some folks do not find the need for a package manager because they know the packages intimately and know what files are installed by each package. Some users also do not need any package management because they plan on rebuilding the entire system when a package is changed.

10.2.2.2. Install in Separate Directories

This is a simplistic package management that does not need any extra package to manage the installations. Each package is installed in a separate directory. For example, package foo-1.1 is installed in /usr/pkg/foo-1.1 and a symlink is made from /usr/pkg/foo to /usr/pkg/foo-1.1. When installing a new version foo-1.2, it is installed in /usr/pkg/foo-1.2 and the previous symlink is replaced by a symlink to the new version.

Environment variables such as PATH, LD_LIBRARY_PATH, MANPATH, INFOPATH and CPPFLAGS need to be expanded to include /usr/pkg/foo. For more than a few packages, this scheme becomes unmanageable.

10.2.2.3. Symlink Style Package Management

This is a variation of the previous package management technique. Each package is installed similar to the previous scheme. But instead of making the symlink, each file is symlinked into the /usr hierarchy. This removes the need to expand the environment variables. Though the symlinks can be created by the user to automate the creation, many package managers have been written using this approach. A few of the popular ones include Stow, Epkg, Graft, and Depot.

The installation needs to be faked, so that the package thinks that it is installed in /usr though in reality it is installed in the /usr/pkg hierarchy. Installing in this manner is not usually a trivial task. For example, consider that you are installing a package libfoo-1.1. The following instructions may not install the package properly:

./configure --prefix=/usr/pkg/libfoo/1.1
make
make install

The installation will work, but the dependent packages may not link to libfoo as you would expect. If you compile a package that links against libfoo, you may notice that it is linked to /usr/pkg/libfoo/1.1/lib/libfoo.so.1 instead of /usr/lib/libfoo.so.1 as you would expect. The correct approach is to use the DESTDIR strategy to fake installation of the package. This approach works as follows:

./configure --prefix=/usr
make
make DESTDIR=/usr/pkg/libfoo/1.1 install

Most packages support this approach, but there are some which do not. For the non-compliant packages, you may either need to manually install the package, or you may find that it is easier to install some problematic packages into /opt.

10.2.2.4. Timestamp Based

In this technique, a file is timestamped before the installation of the package. After the installation, a simple use of the find command with the appropriate options can generate a log of all the files installed after the timestamp file was created. A package manager written with this approach is install-log.

Though this scheme has the advantage of being simple, it has two drawbacks. If, during installation, the files are installed with any timestamp other than the current time, those files will not be tracked by the package manager. Also, this scheme can only be used when one package is installed at a time. The logs are not reliable if two packages are being installed on two different consoles.

10.2.2.5. LD_PRELOAD Based

In this approach, a library is preloaded before installation. During installation, this library tracks the packages that are being installed by attaching itself to various executables such as cp, install, mv and tracking the system calls that modify the filesystem. For this approach to work, all the executables need to be dynamically linked without the suid or sgid bit. Preloading the library may cause some unwanted side-effects during installation. Therefore, it is advised that one performs some tests to ensure that the package manager does not break anything and logs all the appropriate files.

10.2.2.6. Creating Package Archives

In this scheme, the package installation is faked into a separate tree as described in the Symlink style package management. After the installation, a package archive is created using the installed files. This archive is then used to install the package either on the local machine or can even be used to install the package on other machines.

This approach is used by most of the package managers found in the commercial distributions. Examples of package managers that follow this approach are RPM (which, incidentally, is required by the Linux Standard Base Specification), pkg-utils, Debian's apt, and Gentoo's Portage system. A hint describing how to adopt this style of package management for CLFS systems is located at http://hints.cross-lfs.org/index.php/Fakeroot.

10.3. About Test Suites, Again

In the final-system build, you are no longer cross-compiling so it is possible to run package testsuites. Some test suites are more important than others. For example, the test suites for the core toolchain packages—GCC, Binutils, and Glibc—are of the utmost importance due to their central role in a properly functioning system. The test suites for GCC and Glibc can take a very long time to complete, especially on slower hardware, but are strongly recommended.

A common issue with running the test suites for Binutils and GCC is running out of pseudo terminals (PTYs). This can result in a high number of failing tests. This may happen for several reasons, but the most likely cause (if you chrooted) is that the host system does not have the devpts file system set up correctly. This issue is discussed in greater detail at http://trac.cross-lfs.org/wiki/faq#no-ptys.

Sometimes package test suites will fail, but for reasons which the developers are aware of and have deemed non-critical. Consult the logs located at http://cross-lfs.org/testsuite-logs/2.0.0/ to verify whether or not these failures are expected. This site is valid for all tests throughout this book.

10.4. Temporary Perl-5.16.2

The Perl package contains the Practical Extraction and Report Language.

10.4.1. Installation of Perl

First adapt some hard-wired paths to the C library by applying the following patch:

patch -Np1 -i ../perl-5.16.2-libc-1.patch

Change a hardcoded path from /usr/include to /tools/include:

sed -i 's@/usr/include@/tools/include@g' ext/Errno/Errno_pm.PL

Prepare Temporary Perl for compilation:

./configure.gnu --prefix=/tools  -Dcc="gcc ${BUILD32}"

The meaning of the configure option:

-Dcc="gcc"

Tells Perl to use gcc instead of the default cc.

Compile the package:

make

Although Perl comes with a test suite, it is not recommended to run it at this point, as this Perl installation is only temporary. The test suite can be run later in this chapter if desired.

Install the package:

make install

Finally, create a necessary symlink:

ln -sfv /tools/bin/perl /usr/bin

Details on this package are located in Section 10.47.2, “Contents of Perl.”

10.5. Linux-Headers-3.4.17

The Linux Kernel contains a make target that installs “sanitized” kernel headers.

10.5.1. Installation of Linux-Headers

For this step you will need the kernel tarball.

Install the kernel header files:

make mrproper
make headers_check
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /usr/include
find /usr/include -name .install -or -name ..install.cmd | xargs rm -fv

The meaning of the make commands:

make mrproper

Ensures that the kernel source dir is clean.

make headers_check

Sanitizes the raw kernel headers so that they can be used by userspace programs.

make INSTALL_HDR_PATH=dest headers_install

Normally the headers_install target removes the entire destination directory (default /usr/include) before installing the headers. To prevent this, we tell the kernel to install the headers to a directory inside the source dir.

find /usr/include -name .install -or -name ..install.cmd | xargs rm -fv

Removes a number of unneeded debugging files that were installed.

10.5.2. Contents of Linux-Headers

Installed headers: /usr/include/{asm,asm-generic,drm,linux,mtd,rdma,scsi,sound,video,xen}/*.h
Installed directories: /usr/include/asm, /usr/include/asm-generic, /usr/include/drm, /usr/include/linux, /usr/include/mtd, /usr/include/rdma, /usr/include/scsi, /usr/include/sound, /usr/include/video, /usr/include/xen

Short Descriptions

/usr/include/{asm,asm-generic,drm,linux,mtd,rdma,sound,video}/*.h

The Linux API headers

10.6. Man-pages-3.43

The Man-pages package contains over 1,200 man pages.

10.6.1. Installation of Man-pages

Install Man-pages by running:

make install

10.6.2. Contents of Man-pages

Installed files: various man pages

Short Descriptions

man pages

This package contains man pages that describe the following: POSIX headers (section 0p), POSIX utilities (section 1p), POSIX functions (section 3p), user commands (section 1), system calls (section 2), libc calls (section 3), device information (section 4), file formats (section 5), games (section 6), conventions and macro packages (section 7), system administration (section 8), and kernel (section 9).

10.7. EGLIBC-2.15 32 Bit Libraries

The EGLIBC 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.

10.7.1. Installation of EGLIBC

Note

Some packages outside of CLFS suggest installing GNU libiconv in order to translate data from one encoding to another. The project's home page (http://www.gnu.org/software/libiconv/) says “This library provides an iconv() implementation, for use on systems which don't have one, or whose implementation cannot convert from/to Unicode.” EGLIBC provides an iconv() implementation and can convert from/to Unicode, therefore libiconv is not required on a CLFS system.

At the end of the installation, the build system will run a sanity test to make sure everything installed properly. This script will attempt to test for a library that is only used in the test suite and is never installed. Prevent the script from testing for this library with the following command:

sed -i 's/\(&& $name ne\) "db1"/ & \1 "nss_test1"/' scripts/test-installation.pl

This same script performs its tests by attempting to compile test programs against certain libraries. However it does not specify the ld.so, and our toolchain is still configured to use the one in /tools. The following set of commands will force the script to use the complete path of the new ld.so that was just installed:

LINKER=$(readelf -l /tools/bin/bash | sed -n 's@.*interpret.*/tools\(.*\)]$@\1@p')
sed -i "s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=${LINKER} -o|" \
  scripts/test-installation.pl
unset LINKER

The following patch fixes an issue that can cause ALSA to crash:

patch -Np1 -i ../eglibc-2.15-fixes-1.patch

The EGLIBC build system is self-contained and will install perfectly, even though the compiler specs file and linker are still pointing at /tools. The specs and linker cannot be adjusted before the EGLIBC install because the EGLIBC Autoconf tests would give false results and defeat the goal of achieving a clean build.

The EGLIBC documentation recommends building EGLIBC outside of the source directory in a dedicated build directory:

mkdir -v ../eglibc-build
cd ../eglibc-build

Prepare EGLIBC for compilation:

CC="gcc ${BUILD32}" CXX="g++ ${BUILD32}" \
    CFLAGS="-march=$(cut -d- -f1 <<< ${CLFS_TARGET32}) \
    -mtune=generic -g -O2" ../eglibc-2.15/configure --prefix=/usr \
    --disable-profile --enable-kernel=2.6.32 \
    --libexecdir=/usr/lib/eglibc --host=${CLFS_TARGET32}

The meaning of the new configure option:

--libexecdir=/usr/lib/eglibc

This changes the location of the pt_chown program from its default of /usr/libexec to /usr/lib/eglibc.

Compile the package:

make

Important

The test suite for EGLIBC is considered critical. Do not skip it under any circumstance.

In multilib, we tend to think that compiling for ${CLFS_TARGET32} is not cross-compiling. EGLIBC takes the traditional view that if you are building for a different host then you are cross-compiling, so you won't be running the tests and therefore you don't need the locale files. When we run the tests, many will fail if the locale files are missing. The following sed allows these tests to succeed:

sed -i '/cross-compiling/s@ifeq@ifneq@g' ../eglibc-2.15/localedata/Makefile

Before running the tests, copy a file from the source tree into our build tree to prevent a couple of test failures, then run the tests:

cp -v ../eglibc-2.15/iconvdata/gconv-modules iconvdata
make -k check 2>&1 | tee eglibc-check-log; grep Error eglibc-check-log

The EGLIBC test suite is highly dependent on certain functions of the host system, in particular the kernel. The posix/annexc test normally fails and you should see Error 1 (ignored) in the output. Apart from this, the EGLIBC test suite is always expected to pass. However, in certain circumstances, some failures are unavoidable. If a test fails because of a missing program (or missing symbolic link), or a segfault, you will see an error code greater than 127 and the details will be in the log. More commonly, tests will fail with Error 2 - for these, the contents of the corresponding .out file, e.g. posix/annexc.out may be informative. Here is a list of the most common issues:

  • The math tests sometimes fail. Certain optimization settings are known to be a factor here.

  • If you have mounted the CLFS partition with the noatime option, the atime test will fail. As mentioned in Section 2.4, “Mounting the New Partition”, do not use the noatime option while building CLFS.

  • When running on older and slower hardware, some tests can fail because of test timeouts being exceeded.

Though it is a harmless message, the install stage of EGLIBC will complain about the absence of /etc/ld.so.conf. Prevent this warning with:

touch /etc/ld.so.conf

Install the package:

make install

Details on this package are located in Section 10.8.5, “Contents of EGLIBC.”

10.8. EGLIBC-2.15 64-Bit

The EGLIBC 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.

10.8.1. Installation of Glibc

At the end of the installation, the build system will run a sanity test to make sure everything installed properly. This script will attempt to test for a library that is only used in the test suite and is never installed. Prevent the script from testing for this library with the following command:

sed -i 's/\(&& $name ne\) "db1"/ & \1 "nss_test1"/' scripts/test-installation.pl

This same script performs its tests by attempting to compile test programs against certain libraries. However it does not specify the ld.so, and our toolchain is still configured to use the one in /tools. The following set of commands will force the script to use the complete path of the new ld.so that was just installed:

LINKER=$(readelf -l /tools/bin/bash | sed -n 's@.*interpret.*/tools\(.*\)]$@\1@p')
sed -i "s|libs -o|libs -L/usr/lib64 -Wl,-dynamic-linker=${LINKER} -o|" \
  scripts/test-installation.pl
unset LINKER

The following patch fixes an issue that can cause ALSA to crash:

patch -Np1 -i ../eglibc-2.15-fixes-1.patch

The EGLIBC build system is self-contained and will install perfectly, even though the compiler specs file and linker are still pointing at /tools. The specs and linker cannot be adjusted before the EGLIBC install because the EGLIBC Autoconf tests would give false results and defeat the goal of achieving a clean build.

The EGLIBC documentation recommends building EGLIBC outside of the source directory in a dedicated build directory:

mkdir -v ../eglibc-build
cd ../eglibc-build

Tell EGLIBC to install its 64-bit libraries into /lib64:

echo "slibdir=/lib64" >> configparms

Prepare EGLIBC for compilation:

CC="gcc ${BUILD64}" CXX="g++ ${BUILD64}" \
    CFLAGS="-mtune=generic -g -O2" \
    ../eglibc-2.15/configure --prefix=/usr \
    --disable-profile --enable-kernel=2.6.32 \
    --libexecdir=/usr/lib64/eglibc --libdir=/usr/lib64

The meaning of the new configure option:

--libexecdir=/usr/lib64/glibc

This changes the location of the pt_chown program from its default of /usr/libexec to /usr/lib64/glibc.

Compile the package:

make

Important

The test suite for EGLIBC is considered critical. Do not skip it under any circumstance.

Before running the tests, copy a file from the source tree into our build tree to prevent a couple of test failures, then run the tests:

cp -v ../eglibc-2.15/iconvdata/gconv-modules iconvdata
make -k check 2>&1 | tee eglibc-check-log; grep Error eglibc-check-log

The EGLIBC test suite is highly dependent on certain functions of the host system, in particular the kernel. The posix/annexc test normally fails and you should see Error 1 (ignored) in the output. Apart from this, the EGLIBC test suite is always expected to pass. However, in certain circumstances, some failures are unavoidable. If a test fails because of a missing program (or missing symbolic link), or a segfault, you will see an error code greater than 127 and the details will be in the log. More commonly, tests will fail with Error 2 - for these, the contents of the corresponding .out file, e.g. posix/annexc.out may be informative. Here is a list of the most common issues:

  • The math tests sometimes fail. Certain optimization settings are known to be a factor here.

  • If you have mounted the CLFS partition with the noatime option, the atime test will fail. As mentioned in Section 2.4, “Mounting the New Partition”, do not use the noatime option while building CLFS.

  • When running on older and slower hardware, some tests can fail because of test timeouts being exceeded.

Install the package:

make install

Install NIS and RPC related headers that are not installed by default.

cp -v ../eglibc-2.15/sunrpc/rpc/*.h /usr/include/rpc
cp -v ../eglibc-2.15/sunrpc/rpcsvc/*.h /usr/include/rpcsvc
cp -v ../eglibc-2.15/nis/rpcsvc/*.h /usr/include/rpcsvc

10.8.2. Internationalization

The locales that can make the system respond in a different language were not installed by the above command. Install them with:

make localedata/install-locales

To save time, an alternative to running the previous command (which generates and installs every locale listed in the eglibc-2.15/localedata/SUPPORTED file) is to install only those locales that are wanted and needed. This can be achieved by using the localedef command. Information on this command is located in the INSTALL file in the EGLIBC source. However, there are a number of locales that are essential in order for the tests of future packages to pass, in particular, the libstdc++ tests from GCC. The following instructions, instead of the install-locales target used above, will install the minimum set of locales necessary for the tests to run successfully:

mkdir -pv /usr/lib/locale
localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
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 fa_IR -f UTF-8 fa_IR
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

Some locales installed by the make localedata/install-locales command above are not properly supported by some applications that are in CLFS and CBLFS. Because of the various problems that arise due to application programmers making assumptions that break in such locales, CLFS should not be used in locales that utilize multibyte character sets (including UTF-8) or right-to-left writing order. Numerous unofficial and unstable patches are required to fix these problems, and it has been decided by the CLFS developers not to support such complex locales at this time. This applies to the ja_JP and fa_IR locales as well—they have been installed only for GCC and Gettext tests to pass, and the watch program (part of the Procps package) does not work properly in them. Various attempts to circumvent these restrictions are documented in internationalization-related hints.

10.8.3. Configuring EGLIBC

The /etc/nsswitch.conf file needs to be created because, although EGLIBC provides defaults when this file is missing or corrupt, the EGLIBC defaults do not work well in a networked environment. The time zone also needs to be configured.

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

hosts: files dns
networks: files

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

# End /etc/nsswitch.conf
EOF

To determine the local time zone, run the following script:

tzselect

After answering a few questions about the location, the script will output the name of the time zone (e.g., EST5EDT or Canada/Eastern). Then create the /etc/localtime file by running:

cp -v --remove-destination /usr/share/zoneinfo/[xxx] \
    /etc/localtime

Replace [xxx] with the name of the time zone that tzselect provided (e.g., Canada/Eastern).

The meaning of the cp option:

--remove-destination

This is needed to force removal of the already existing symbolic link. The reason for copying the file instead of using a symlink is to cover the situation where /usr is on a separate partition. This could be important when booted into single user mode.

10.8.4. Configuring The Dynamic Loader

By default, the dynamic loader (/lib/ld-linux.so.2 for 32bit executables and /lib64/ld-linux-x86-64.so.2 for 64bit executables) searches through /lib, /lib64, /usr/lib, and /usr/lib64 for dynamic libraries that are needed by programs as they are run. However, if there are libraries in directories other than these, they need to be added to the /etc/ld.so.conf file in order for the dynamic loader to find them. Some directories that are commonly known to contain additional libraries are /usr/local/lib, /usr/local/lib64, /opt/lib, and /opt/lib64, so 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
/usr/local/lib64
/opt/lib
/opt/lib64

# End /etc/ld.so.conf
EOF

10.8.5. Contents of EGLIBC

Installed programs: catchsegv, gencat, getconf, getent, iconv, iconvconfig, ldconfig, ldd, lddlibc4, locale, localedef, makedb, mtrace, nscd, pcprofiledump, pldd, pt_chown, rpcgen, sln, sprof, tzselect, xtrace,zdump, and zic
Installed libraries: ld.so, libBrokenLocale.[a,so], libSegFault.so, libanl.[a,so], libbsd-compat.a, libc.[a,so], libc_nonshared.a, libcidn.[a,so], 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], libpthread_nonshared.a, libresolv.[a,so], librpcsvc.a, librt.[a,so], libthread_db.so, and libutil.[a,so]
Installed directories: /usr/include/arpa, /usr/include/bits, /usr/include/gnu, /usr/include/net, /usr/include/netash, /usr/include/netatalk, /usr/include/netax25, /usr/include/neteconet, /usr/include/netinet, /usr/include/netipx, /usr/include/netiucv, /usr/include/netpacket, /usr/include/netrom, /usr/include/netrose, /usr/include/nfs, /usr/include/protocols, /usr/include/rpc, /usr/include/rpcsvc, /usr/include/sys, /usr/lib/gconv, /usr/lib/eglibc, /usr/lib/locale, /usr/share/i18n, /usr/share/zoneinfo, /var/cache/ldconfig

Short Descriptions

catchsegv

Can be used to create a stack trace when a program terminates with a segmentation fault

gencat

Generates message catalogues

getconf

Displays the system configuration values for file system specific variables

getent

Gets entries from an administrative database

iconv

Performs character set conversion

iconvconfig

Creates fastloading iconv module configuration files

ldconfig

Configures the dynamic linker runtime bindings

ldd

Reports which shared libraries are required by each given program or shared library

lddlibc4

Assists ldd with object files

locale

Tells the compiler to enable or disable the use of POSIX locales for built-in operations

localedef

Compiles locale specifications

makedb

Creates a simple database from textual input

mtrace

Reads and interprets a memory trace file and displays a summary in human-readable format

nscd

A daemon that provides a cache for the most common name service requests

pcprofiledump

Dumps information generated by PC profiling

pldd

Lists dynamic shared objects used by running processes

pt_chown

A helper program for grantpt to set the owner, group and access permissions of a slave pseudo terminal

rpcgen

Generates C code to implement the Remote Procecure Call (RPC) protocol

sln

A statically linked program that creates symbolic links

sotruss

Traces shared library procedure calls of a specified command

sprof

Reads and displays shared object profiling data

tzselect

Asks the user about the location of the system and reports the corresponding time zone description

xtrace

Traces the execution of a program by printing the currently executed function

zdump

The time zone dumper

zic

The time zone compiler

ld.so

The helper program for shared library executables

libBrokenLocale

Used by programs, such as Mozilla, to solve broken locales

libSegFault

The segmentation fault signal handler

libanl

An asynchronous name lookup library

libbsd-compat

Provides the portability needed in order to run certain Berkey Software Distribution (BSD) programs under Linux

libc

The main C library

libcidn

Used internally by EGLIBC for handling internationalized domain names in the getaddrinfo() function

libcrypt

The cryptography library

libdl

The dynamic linking interface library

libg

A runtime library for g++

libieee

The Institute of Electrical and Electronic Engineers (IEEE) floating point library

libm

The mathematical library

libmcheck

Contains code run at boot

libmemusage

Used by memusage (included in EGLIBC, but not built in a base CLFS system as it has additional dependencies) to help collect information about the memory usage of a program

libnsl

The network services library

libnss

The Name Service Switch libraries, containing functions for resolving host names, user names, group names, aliases, services, protocols, etc.

libpcprofile

Contains profiling functions used to track the amount of CPU time spent in specific source code lines

libpthread

The POSIX threads library

libresolv

Contains functions for creating, sending, and interpreting packets to the Internet domain name servers

librpcsvc

Contains functions providing miscellaneous RPC services

librt

Contains functions providing most of the interfaces specified by the POSIX.1b Realtime Extension

libthread_db

Contains functions useful for building debuggers for multi-threaded programs

libutil

Contains code for “standard” functions used in many different Unix utilities

10.9. Adjusting the Toolchain

Now we amend the GCC specs file so that it points to the new dynamic linker. A perl command accomplishes this:

gcc -dumpspecs | \
perl -p -e 's@/tools/lib/ld@/lib/ld@g;' \
     -e 's@/tools/lib64/ld@/lib64/ld@g;' \
     -e 's@\*startfile_prefix_spec:\n@$_/usr/lib/ @g;' > \
     $(dirname $(gcc --print-libgcc-file-name))/specs

It is a good idea to visually inspect the specs file to verify the intended change was actually made.

Note that /lib or /lib64 is now the prefix of our dynamic linker.

Caution

It is imperative at this point to stop and ensure that the basic functions (compiling and linking) of the adjusted toolchain are working as expected. To do this, perform a sanity check:

For 32 bit ABI:

echo 'main(){}' > dummy.c
gcc ${BUILD32} dummy.c
readelf -l a.out | grep ': /lib'

If everything is working correctly, there should be no errors, and the output of the last command will be:

[Requesting program interpreter: /lib/ld-linux.so.2]

For 64 bit ABI:

echo 'main(){}' > dummy.c
gcc ${BUILD64} dummy.c
readelf -l a.out | grep ': /lib'

If everything is working correctly, there should be no errors, and the output of the last command will be:

[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

Note that /lib or /lib64 is now the prefix of our dynamic linker.

If the output does not appear as shown above or is not received at all, then something is seriously wrong. Investigate and retrace the steps to find out where the problem is and correct it. The most likely reason is that something went wrong with the specs file amendment above. Any issues will need to be resolved before continuing on with the process.

Once everything is working correctly, clean up the test files:

rm -v dummy.c a.out

10.10. GMP-5.0.5 32 Bit Libraries

GMP is a library for arithmetic on arbitrary precision integers, rational numbers, and floating-point numbers.

10.10.1. Installation of GMP

Note

If you are compiling this package on a different CPU than you plan to run the CLFS system on, you must replace GMP's config.guess and config.sub wrappers with the originals. This will prevent GMP from optimizing for the wrong CPU. You can make this change with the following command:

mv -v config{fsf,}.guess
mv -v config{fsf,}.sub

Prepare GMP for compilation:

CPPFLAGS=-fexceptions CC="gcc -isystem /usr/include ${BUILD32}" \
CXX="g++ -isystem /usr/include ${BUILD32}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib:/lib ${BUILD32}" \
  ABI=32 ./configure --prefix=/usr \
    --enable-cxx --enable-mpbsd

Compile the package:

make

Important

The test suite for GMP is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make install

The header installed by GMP is architecture specific. Programs compiled as 32bit will require the header provided by the 32bit installation of GMP. The same applies for 64bit programs. Move the header so a wrapper can be put in its place later:

mv -v /usr/include/gmp{,-32}.h

Details on this package are located in Section 10.11.2, “Contents of GMP.”

10.11. GMP-5.0.5 64 Bit

GMP is a library for arithmetic on arbitrary precision integers, rational numbers, and floating-point numbers.

10.11.1. Installation of GMP

Note

If you are compiling this package on a different CPU than you plan to run the CLFS system on, you must replace GMP's config.guess and config.sub wrappers with the originals. This will prevent GMP from optimizing for the wrong CPU. You can make this change with the following command:

mv -v config{fsf,}.guess
mv -v config{fsf,}.sub

Prepare GMP for compilation:

CPPFLAGS=-fexceptions CC="gcc -isystem /usr/include ${BUILD64}" \
CXX="g++ -isystem /usr/include ${BUILD64}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib64:/lib64 ${BUILD64}" \
  ./configure --prefix=/usr \
    --libdir=/usr/lib64 --enable-cxx --enable-mpbsd

Compile the package:

make

Important

The test suite for GMP is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make install

Create the 64bit header file:

mv -v /usr/include/gmp{,-64}.h

Finally, create a stub header in the place of the originals:

cat > /usr/include/gmp.h << "EOF"
/* gmp.h - Stub Header  */
#ifndef __STUB__GMP_H__
#define __STUB__GMP_H__

#if defined(__x86_64__) || \
    defined(__sparc64__) || \
    defined(__arch64__) || \
    defined(__powerpc64__) || \
    defined (__s390x__)
# include "gmp-64.h"
#else
# include "gmp-32.h"
#endif

#endif /* __STUB__GMP_H__ */
EOF

10.11.2. Contents of GMP

Installed libraries: libgmp.[a,so], libgmpxx.[a,so], libmp.[a,so]

Short Descriptions

libgmp

Contains the definitions for GNU multiple precision functions.

libgmpxx

Contains a C++ class wrapper for GMP types.

libmp

Contains the Berkeley MP compatibility library.

10.12. MPFR-3.1.1 32 Bit Libraries

The MPFR library is a C library for multiple-precision floating-point computations with correct rounding.

10.12.1. Installation of MPFR

Prepare MPFR for compilation:

CC="gcc -isystem /usr/include ${BUILD32}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib:/lib ${BUILD32}" \
  ./configure --prefix=/usr --host=${CLFS_TARGET32} --enable-shared

Compile the package:

make

Important

The test suite for MPFR is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make install

Details on this package are located in Section 10.13.2, “Contents of MPFR.”

10.13. MPFR-3.1.1 64 Bit

The MPFR library is a C library for multiple-precision floating-point computations with correct rounding.

10.13.1. Installation of MPFR

Prepare MPFR for compilation:

CC="gcc -isystem /usr/include ${BUILD64}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib64:/lib64 ${BUILD64}" \
  ./configure --prefix=/usr --libdir=/usr/lib64 --enable-shared

Compile the package:

make

Important

The test suite for MPFR is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make install

10.13.2. Contents of MPFR

Installed libraries: libmpfr.[a,so]
Installed directory: /usr/share/doc/mpfr

Short Descriptions

libmpfr

The Multiple Precision Floating-Point Reliable Library.

10.14. MPC-1.0.1 32 Bit Libraries

MPC is a C library for the arithmetic of complex numbers with arbitrarily high precision and correct rounding of the result.

10.14.1. Installation of MPC

Prepare MPC for compilation:

CC="gcc -isystem /usr/include ${BUILD32}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib:/lib ${BUILD32}" \
  ./configure --prefix=/usr --host=${CLFS_TARGET32}

Compile the package:

make

Important

The test suite for MPC is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make install

Details on this package are located in Section 10.15.2, “Contents of MPC.”

10.15. MPC-1.0.1 64 Bit

MPC is a C library for the arithmetic of complex numbers with arbitrarily high precision and correct rounding of the result.

10.15.1. Installation of MPC

Prepare MPC for compilation:

CC="gcc -isystem /usr/include ${BUILD64}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib64:/lib64 ${BUILD64}" \
  ./configure --prefix=/usr --libdir=/usr/lib64

Compile the package:

make

Important

The test suite for MPC is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make install

10.15.2. Contents of MPC

Installed libraries: libmpc.[a,so]

Short Descriptions

libmpc

The Multiple Precision Complex Library.

10.16. PPL-0.12.1 32 Bit Libraries

The Parma Polyhedra Library (PPL) provides numerical abstractions especially targeted at applications in the field of analysis and verification of complex systems. CLooG-PPL requires this library.

10.16.1. Installation of PPL

Prepare PPL for compilation:

CPPFLAGS=-fexceptions CC="gcc -isystem /usr/include ${BUILD32}" \
CXX="g++ -isystem /usr/include ${BUILD32}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib:/lib ${BUILD32}" \
  ./configure --prefix=/usr --host=${CLFS_TARGET32} \
    --enable-shared --disable-optimization

Compile the package:

make

Important

The test suite for PPL is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make install

Prepare ppl-config to be wrapped by the multiarch wrapper:

mv -v /usr/bin/ppl-config{,-32}

One of the headers installed by PPL is architecture specific. Programs compiled as 32bit will require the header provided by the 32bit installation of PPL. The same applies for 64bit programs. Move the header so a wrapper can be put in its place later:

mv -v /usr/include/ppl{,-32}.hh

Details on this package are located in Section 10.17.2, “Contents of PPL.”

10.17. PPL-0.12.1 64 Bit

The Parma Polyhedra Library (PPL) provides numerical abstractions especially targeted at applications in the field of analysis and verification of complex systems. CLooG-PPL requires this library.

10.17.1. Installation of PPL

Prepare PPL for compilation:

CPPFLAGS=-fexceptions CC="gcc -isystem /usr/include ${BUILD64}" \
CXX="g++ -isystem /usr/include ${BUILD64}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib64:/lib64 ${BUILD64}" \
  ./configure --prefix=/usr --libdir=/usr/lib64 \
    --enable-shared --disable-optimization

Compile the package:

make

Important

The test suite for PPL is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make install

Prepare ppl-config to be wrapped by the multiarch wrapper and then wrap it:

mv -v /usr/bin/ppl-config{,-64}
ln -svf multiarch_wrapper /usr/bin/ppl-config

Create the 64bit header file:

mv -v /usr/include/ppl{,-64}.hh

Finally, create a stub header in the place of the originals:

cat > /usr/include/ppl.hh << "EOF"
/* ppl.hh - Stub Header  */
#ifndef __STUB__PPL_HH__
#define __STUB__PPL_HH__

#if defined(__x86_64__) || \
    defined(__sparc64__) || \
    defined(__arch64__) || \
    defined(__powerpc64__) || \
    defined (__s390x__)
# include "ppl-64.h"
#else
# include "ppl-32.h"
#endif

#endif /* __STUB__PPL_HH__ */
EOF

10.17.2. Contents of PPL

Installed programs: ppl-config, ppl_lcdd, ppl_pips
Installed libraries: libppl.[a,so], libppl_c.[a,so]
Installed directories: /usr/share/doc/ppl

Short Descriptions

ppl-config

Outputs information about the PPL installation

ppl_lcdd

Reads an H-representation of a polyhedron and generates a V-representation of the same polyhedron

ppl_pips

A PPL-based parametric integer programming problem solver

libppl

The Parma Polyhedra Library (PPL).

libppl_c

The Parma Polyhedra Library bindings for C.

libpwl

The Parma Watchdog Library

10.18. CLooG-0.16.3 32 Bit Libraries

CLooG is a library to generate code for scanning Z-polyhedra. In other words, it finds code that reaches each integral point of one or more parameterized polyhedra. GCC links with this library in order to enable the new loop generation code known as Graphite.

10.18.1. Installation of CLooG

Prepare CLooG for compilation:

CC="gcc -isystem /usr/include ${BUILD32}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib:/lib ${BUILD32}" \
  ./configure --prefix=/usr \
    --host=${CLFS_TARGET32} --enable-shared

Compile the package:

make

Important

The test suite for CLooG is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make install

Details on this package are located in Section 10.19.2, “Contents of CLooG.”

10.19. CLooG-0.16.3 64 Bit

CLooG is a library to generate code for scanning Z-polyhedra. In other words, it finds code that reaches each integral point of one or more parameterized polyhedra. GCC links with this library in order to enable the new loop generation code known as Graphite.

10.19.1. Installation of CLooG

Prepare CLooG for compilation:

CC="gcc -isystem /usr/include ${BUILD64}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib64:/lib64 ${BUILD64}" \
  ./configure --prefix=/usr \
    --libdir=/usr/lib64 --enable-shared

Compile the package:

make

Important

The test suite for CLooG is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make install

10.19.2. Contents of CLooG

Installed program: cloog
Installed libraries: libcloog-isl.[a,so], libisl.[a,so]
Installed directories: /usr/include/cloog, /usr/include/isl

Short Descriptions

cloog

Loop generator for scanning Z-polyhedra

libcloog-isl

Isl backend for CLooG.

libisl

The Integer Set Library.

10.20. Zlib-1.2.7 32 Bit Libraries

The Zlib package contains compression and decompression routines used by some programs.

10.20.1. Installation of Zlib

Prepare Zlib for compilation:

CC="gcc -isystem /usr/include ${BUILD32}" \
CXX="g++ -isystem /usr/include ${BUILD32}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib:/lib ${BUILD32}" \
  ./configure --prefix=/usr

Compile the package:

make

To test the results, issue: make check.

Install the package:

make install

The previous command installed two .so files into /usr/lib. We will move it into /lib and then relink it to /usr/lib:

mv -v /usr/lib/libz.so.* /lib
ln -svf ../../lib/libz.so.1 /usr/lib/libz.so

Details on this package are located in Section 10.21.2, “Contents of Zlib.”

10.21. Zlib-1.2.7 64 Bit

The Zlib package contains compression and decompression routines used by some programs.

10.21.1. Installation of Zlib

Prepare Zlib for compilation:

CC="gcc -isystem /usr/include ${BUILD64}" \
CXX="g++ -isystem /usr/include ${BUILD64}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib64:/lib64 ${BUILD64}" \
  ./configure --prefix=/usr --libdir=/usr/lib64

Compile the package:

make

To test the results, issue: make check.

Install the package:

make install

The previous command installed two .so files into /usr/lib64. We will move it into /lib64 and then relink it to /usr/lib64:

mv -v /usr/lib64/libz.so.* /lib64
ln -svf ../../lib64/libz.so.1 /usr/lib64/libz.so

10.21.2. Contents of Zlib

Installed libraries: libz.[a,so]

Short Descriptions

libz

Contains compression and decompression functions used by some programs

10.22. Binutils-2.23

The Binutils package contains a linker, an assembler, and other tools for handling object files.

10.22.1. Installation of Binutils

Verify that the PTYs are working properly inside the build environment. Check that everything is set up correctly by performing a simple test:

expect -c "spawn ls"

This command should give the following output:

spawn ls

If, instead, it gives a message saying to create more ptys, then the environment is not set up for proper PTY operation. This issue needs to be resolved before running the test suites for Binutils and GCC.

The Binutils documentation recommends building Binutils outside of the source directory in a dedicated build directory:

mkdir -v ../binutils-build
cd ../binutils-build

Prepare Binutils for compilation:

CC="gcc -isystem /usr/include ${BUILD64}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib64:/lib64:/usr/lib:/lib ${BUILD64}" \
  ../binutils-2.23/configure --prefix=/usr \
    --enable-shared --enable-64-bit-bfd --libdir=/usr/lib64

Compile the package:

make configure-host

Important

During make configure-host you may receive the following error message. It is safe to ignore.

WARNING: `flex' is missing on your system. You should only
need it if you modified a `.l' file. You may need the `Flex'
package in order for those modifications to take effect. You
can get `Flex' from any GNU archive site.
make tooldir=/usr

The meaning of the make parameter:

tooldir=/usr

Normally, the tooldir (the directory where the executables will ultimately be located) is set to $(exec_prefix)/$(target_alias). Because this is a custom system, this target-specific directory in /usr is not required.

Important

The test suite for Binutils is considered critical. Do not skip it under any circumstance.

Test the results:

make check

Install the package:

make tooldir=/usr install

Install the libiberty header file that is needed by some packages:

cp -v ../binutils-2.23/include/libiberty.h /usr/include

10.22.2. Contents of Binutils

Installed programs: addr2line, ar, as, c++filt, elfedit, gprof, ld, ld.bfd, nm, objcopy, objdump, ranlib, readelf, size, strings, and strip
Installed libraries: libiberty.a, libbfd.[a,so], and libopcodes.[a,so]
Installed directory: /usr/lib/ldscripts

Short Descriptions

addr2line

Translates program addresses to file names and line numbers; given an address and the name of an executable, it uses the debugging information in the executable to determine which source file and line number are associated with the address

ar

Creates, modifies, and extracts from archives

as

An assembler that assembles the output of gcc into object files

c++filt

Used by the linker to de-mangle C++ and Java symbols and to keep overloaded functions from clashing

elfedit

Updates the ELF header of ELF files

gprof

Displays call graph profile data

ld

A linker that combines a number of object and archive files into a single file, relocating their data and tying up symbol references

ld.bfd

Hard link to ld

nm

Lists the symbols occurring in a given object file

objcopy

Translates one type of object file into another

objdump

Displays information about the given object file, with options controlling the particular information to display; the information shown is useful to programmers who are working on the compilation tools

ranlib

Generates an index of the contents of an archive and stores it in the archive; the index lists all of the symbols defined by archive members that are relocatable object files

readelf

Displays information about ELF type binaries

size

Lists the section sizes and the total size for the given object files

strings

Outputs, for each given file, the sequences of printable characters that are of at least the specified length (defaulting to four); for object files, it prints, by default, only the strings from the initializing and loading sections while for other types of files, it scans the entire file

strip

Discards symbols from object files

libiberty

Contains routines used by various GNU programs, including getopt, obstack, strerror, strtol, and strtoul

libbfd

The Binary File Descriptor library

libopcodes

A library for dealing with opcodes—the “readable text” versions of instructions for the processor; it is used for building utilities like objdump.

10.23. GCC-4.6.3

The GCC package contains the GNU compiler collection, which includes the C and C++ compilers.

10.23.1. Installation of GCC

The following patch contains a number of updates to the 4.6.3 branch by the GCC developers:

patch -Np1 -i ../gcc-4.6.3-branch_update-2.patch

Apply a sed substitution that will suppress the installation of libiberty.a. The version of libiberty.a provided by Binutils will be used instead:

sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in

The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:

mkdir -v ../gcc-build
cd ../gcc-build

Prepare GCC for compilation:

CC="gcc -isystem /usr/include ${BUILD64}" \
CXX="g++ -isystem /usr/include ${BUILD64}" \
LDFLAGS="-Wl,-rpath-link,/usr/lib64:/lib64:/usr/lib:/lib" \
  ../gcc-4.6.3/configure --prefix=/usr --libdir=/usr/lib64 \
    --libexecdir=/usr/lib64 --enable-shared --enable-threads=posix \
    --enable-__cxa_atexit --enable-c99 --enable-long-long \
    --enable-clocale=gnu --enable-languages=c,c++ --disable-libstdcxx-pch \
    --enable-cloog-backend=isl

Compile the package:

make

Important

The test suite for GCC is considered critical. Do not skip it under any circumstance.

Test the results, but do not stop at errors:

make -k check

The -k flag is used to make the test suite run through to completion and not stop at the first failure. The GCC test suite is very comprehensive and is almost guaranteed to generate a few failures. To receive a summary of the test suite results, run:

../gcc-4.6.3/contrib/test_summary

For only the summaries, pipe the output through grep -A7 Summ.

A few unexpected failures cannot always be avoided. The GCC developers are usually aware of these issues, but have not resolved them yet.

Install the package:

make install

Some packages expect the C preprocessor to be installed in the /lib directory. To support those packages, create this symlink:

ln -sv ../usr/bin/cpp /lib

Many packages use the name cc to call the C compiler. To satisfy those packages, create a symlink:

ln -sv gcc /usr/bin/cc

10.23.2. Contents of GCC

Installed programs: c++, cc (link to gcc), cpp, g++, gcc, and gcov
Installed libraries: libgcc.a, libgcc_eh.a, libgcc_s.so, libgcov.a, libgomp.[a,so], libmudflap.[a,so], libmudflapth.[a,so], libssp.[a,so], libssp_nonshared.a, libstdc++.[a,so], and libsupc++.a
Installed directories: /usr/include/c++, /usr/lib/gcc, /usr/share/gcc-4.6.3

Short Descriptions

cc

The C compiler

cpp

The C preprocessor; it is used by the compiler to expand the #include, #define, and similar statements in the source files

c++

The C++ compiler

g++

The C++ compiler

gcc

The C compiler

gcov

A coverage testing tool; it is used to analyze programs to determine where optimizations will have the most effect

libgcc

Contains run-time support for gcc

libgcov

Library that is linked into a program when gcc is instructed to enable profiling

libgomp

GNU implementation of the OpenMP API for multi-platform shared-memory parallel programming in C/C++ and Fortran

libmudflap

The libmudflap libraries are used by GCC for instrumenting pointer and array dereferencing operations.

libssp

Contains routines supporting GCC's stack-smashing protection functionality

libstdc++

The standard C++ library

libsupc++

Provides supporting routines for the C++ programming language

10.24. Creating a Multiarch Wrapper

The Multiarch Wrapper is used to wrap certain binaries that have hardcoded paths to libraries or are architecture specific.

10.24.1. Installation of The Multiarch Wrapper

Create the source file:

cat > multiarch_wrapper.c << "EOF"
#define _GNU_SOURCE

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

#ifndef DEF_SUFFIX
#  define DEF_SUFFIX "64"
#endif

int main(int argc, char **argv)
{
  char *filename;
  char *suffix;

  if(!(suffix = getenv("USE_ARCH")))
    if(!(suffix = getenv("BUILDENV")))
      suffix = DEF_SUFFIX;

  if (asprintf(&filename, "%s-%s", argv[0], suffix) < 0) {
    perror(argv[0]);
    return -1;
  }

  int status = EXIT_FAILURE;
  pid_t pid = fork();

  if (pid == 0) {
    execvp(filename, argv);
    perror(filename);
  } else if (pid < 0) {
    perror(argv[0]);
  } else {
    if (waitpid(pid, &status, 0) != pid) {
      status = EXIT_FAILURE;
      perror(argv[0]);
    } else {
      status = WEXITSTATUS(status);
    }
  }

  free(filename);

  return status;
}

EOF

Compile and Install the Multiarch Wrapper:

gcc ${BUILD64} multiarch_wrapper.c -o /usr/bin/multiarch_wrapper

This multiarch wrapper is going to be used later on in the book with Perl. It will also be very useful outside of the base CLFS system.

Create a testcase:

echo 'echo "32bit Version"' > test-32
echo 'echo "64bit Version"' > test-64
chmod -v 755 test-32 test-64
ln -sv /usr/bin/multiarch_wrapper test

Test the wrapper:

USE_ARCH=32 ./test
USE_ARCH=64 ./test

The output of the above command should be:

32bit Version
64bit Version

Remove the testcase source, binaries, and link:

rm -v multiarch_wrapper.c test{,-32,-64}

10.24.2. Contents of The Multiarch Wrapper

Installed programs: multiarch_wrapper

Short Descriptions

multiarch_wrapper

Will execute a different program based on the USE_ARCH variable. The USE_ARCH variable will be the suffix of the executed program.

10.25. Sed-4.2.1

The Sed package contains a stream editor.

10.25.1. Installation of Sed

Prepare Sed for compilation:

CC="gcc ${BUILD64}" ./configure --prefix=/usr \
   --bindir=/bin

Compile the package:

make

Build the HTML documentation:

make html

To test the results, issue: make check.

Install the package:

make install

Install the HTML documentation:

make -C doc install-html

10.25.2. Contents of Sed

Installed program: sed
Installed directory: /usr/share/doc/sed

Short Descriptions

sed

Filters and transforms text files in a single pass

10.26. Ncurses-5.9 32 Bit Libraries

The Ncurses package contains libraries for terminal-independent handling of character screens.

10.26.1. Installation of Ncurses

The following patch contains updates from the 5.9 branch by the Ncurses developers:

patch -Np1 -i ../ncurses-5.9-branch_update-4.patch

Prepare Ncurses for compilation:

CC="gcc ${BUILD32}" CXX="g++ ${BUILD32}" \
   ./configure --prefix=/usr --libdir=/lib \
   --with-shared --without-debug --enable-widec \
   --with-manpage-format=normal \
   --with-default-terminfo-dir=/usr/share/terminfo

Compile the package:

make

This package has a test suite, and can be ran after the package is installed. The tests are in the test/ directory. See the README file in that directory for details.

Install the package:

make install

Prepare ncursesw5-config to be wrapped by the multiarch wrapper:

mv -v /usr/bin/ncursesw5-config{,-32}

Move the Ncurses static libraries to the proper location:

mv -v /lib/lib{panelw,menuw,formw,ncursesw,ncurses++w}.a /usr/lib

Create symlinks in /usr/lib:

rm -v /lib/lib{ncursesw,menuw,panelw,formw}.so
ln -svf ../../lib/libncursesw.so.5 /usr/lib/libncursesw.so
ln -svf ../../lib/libmenuw.so.5 /usr/lib/libmenuw.so
ln -svf ../../lib/libpanelw.so.5 /usr/lib/libpanelw.so
ln -svf ../../lib/libformw.so.5 /usr/lib/libformw.so

Now we will make our Ncurses compatible for older and non-widec compatible programs can build properly:

for lib in curses ncurses form panel menu ; do
        echo "INPUT(-l${lib}w)" > /usr/lib/lib${lib}.so
        ln -sfv lib${lib}w.a /usr/lib/lib${lib}.a
done
ln -sfv libcurses.so /usr/lib/libcursesw.so
ln -sfv libncurses.so /usr/lib/libcurses.so
ln -sfv libncursesw.a /usr/lib/libcursesw.a
ln -sfv libncurses.a /usr/lib/libcurses.a
ln -sfv libncurses++w.a /usr/lib/libncurses++.a
ln -sfv ncursesw5-config-32 /usr/bin/ncurses5-config-32

Now we will create a symlink for /usr/share/terminfo in /usr/lib for compatibility:

ln -sfv ../share/terminfo /usr/lib/terminfo

Details on this package are located in Section 10.27.2, “Contents of Ncurses.”

10.27. Ncurses-5.9 64 Bit

The Ncurses package contains libraries for terminal-independent handling of character screens.

10.27.1. Installation of Ncurses

The following patch contains updates from the 5.9 branch by the Ncurses developers:

patch -Np1 -i ../ncurses-5.9-branch_update-4.patch

Prepare Ncurses for compilation:

CC="gcc ${BUILD64}" CXX="g++ ${BUILD64}" \
   ./configure --prefix=/usr --libdir=/lib64 \
   --with-shared --without-debug --enable-widec \
   --with-manpage-format=normal \
   --with-default-terminfo-dir=/usr/share/terminfo

Compile the package:

make

This package has a test suite, and can be ran after the package is installed. The tests are in the test/ directory. See the README file in that directory for details.

Install the package:

make install

Prepare ncursesw5-config to be wrapped by the multiarch wrapper and then wrap it:

mv -v /usr/bin/ncursesw5-config{,-64}
ln -svf multiarch_wrapper /usr/bin/ncursesw5-config

Move the Ncurses static libraries to the proper location:

mv -v /lib64/lib{panelw,menuw,formw,ncursesw,ncurses++w}.a /usr/lib64

Create symlinks in /usr/lib64:

rm -v /lib64/lib{ncursesw,menuw,panelw,formw}.so
ln -svf ../../lib64/libncursesw.so.5 /usr/lib64/libncursesw.so
ln -svf ../../lib64/libmenuw.so.5 /usr/lib64/libmenuw.so
ln -svf ../../lib64/libpanelw.so.5 /usr/lib64/libpanelw.so
ln -svf ../../lib64/libformw.so.5 /usr/lib64/libformw.so

Now we will make our Ncurses compatible for older and non-widec compatible programs can build properly:

for lib in curses ncurses form panel menu ; do
        echo "INPUT(-l${lib}w)" > /usr/lib64/lib${lib}.so
        ln -sfv lib${lib}w.a /usr/lib64/lib${lib}.a
done
ln -sfv libcurses.so /usr/lib64/libcursesw.so
ln -sfv libncurses.so /usr/lib64/libcurses.so
ln -sfv libncursesw.a /usr/lib64/libcursesw.a
ln -sfv libncurses.a /usr/lib64/libcurses.a
ln -sfv libncurses++w.a /usr/lib64/libncurses++.a
ln -sfv ncursesw5-config-64 /usr/bin/ncurses5-config-64
ln -sfv ncursesw5-config /usr/bin/ncurses5-config

Now we will create a symlink for /usr/share/terminfo in /usr/lib64 for compatibility:

ln -sfv ../share/terminfo /usr/lib64/terminfo

10.27.2. Contents of Ncurses

Installed programs: captoinfo (link to tic), clear, infocmp, infotocap (link to tic), ncursesw5-config, reset (link to tset), tabs, tic, toe, tput, and tset
Installed libraries: libcursesw.so (link to libncursesw.so), libformw.[a,so], libmenuw.[a,so], libncurses++w.a, libncursesw.[a,so], and libpanelw.[a,so]
Installed directories: /usr/share/tabset, /usr/share/terminfo

Short Descriptions

captoinfo

Converts a termcap description into a terminfo description

clear

Clears the screen, if possible

infocmp

Compares or prints out terminfo descriptions

infotocap

Converts a terminfo description into a termcap description

ncursesw5-config

Provides configuration information for ncurses

reset

Reinitializes a terminal to its default values

tabs

Sets and clears tab stops on a terminal

tic

The terminfo entry-description compiler that translates a terminfo file from source format into the binary format needed for the ncurses library routines. A terminfo file contains information on the capabilities of a certain terminal

toe

Lists all available terminal types, giving the primary name and description for each

tput

Makes the values of terminal-dependent capabilities available to the shell; it can also be used to reset or initialize a terminal or report its long name

tset

Can be used to initialize terminals

libcursesw

A link to libncursesw

libncursesw

Contains functions to display text in many complex ways on a terminal screen; a good example of the use of these functions is the menu displayed during the kernel's make menuconfig

libformw

Contains functions to implement forms

libmenuw

Contains functions to implement menus

libpanelw

Contains functions to implement panels

10.28. Pkg-config-lite-0.27.1-1

Pkg-config is a tool to help you insert the correct compiler options on the command line when compiling applications and libraries.

10.28.1. Installation of Pkg-config

Prepare Pkg-config for compilation:

CC="gcc ${BUILD64}" ./configure --prefix=/usr \
    --with-pc-path=/usr/share/pkgconfig

Compile the package:

make

To test the results, issue: make check.

Install the package:

make install

On multilib builds the library direcory has been removed from the default search path of pkg-config. Set some environment variables to help set the path correctly in the future:

export PKG_CONFIG_PATH32="/usr/lib/pkgconfig"
export PKG_CONFIG_PATH64="/usr/lib64/pkgconfig"

Export these variables to prevent any issues in the future.

cat >> /root/.bash_profile << EOF
export PKG_CONFIG_PATH32="${PKG_CONFIG_PATH32}"
export PKG_CONFIG_PATH64="${PKG_CONFIG_PATH64}"
EOF

10.28.2. Contents of Pkg-config

Installed programs: pkg-config
Installed directory: /usr/share/doc/pkg-config

Short Descriptions

pkg-config

The pkg-config program is used to retrieve information about installed libraries in the system. It is typically used to compile and link against one or more libraries.

10.29. Util-linux-2.22.1 32 Bit

The Util-linux package contains miscellaneous utility programs. Among them are utilities for handling file systems, consoles, partitions, and messages.

10.29.1. Installation of Util-linux

Prepare Util-linux for compilation:

CC="gcc ${BUILD32}" ./configure --libdir=/lib \
    --enable-arch --enable-write --disable-login --disable-su

The meaning of the configure options:

--enable-arch

This option allows the arch program to be installed.

--enable-write

This option allows the write program to be installed.

--disable-login --disable-su

Disables building the login and su programs, as the Shadow package installs its own versions.

Compile the package:

make

To test the results, issue: make check.

Install the package:

make install

Details on this package are located in Section 10.30.3, “Contents of Util-linux.”

10.30. Util-linux-2.22.1 64 Bit

The Util-linux package contains miscellaneous utility programs. Among them are utilities for handling file systems, consoles, partitions, and messages.

10.30.1. FHS compliance notes

The FHS recommends using the /var/lib/hwclock directory instead of the usual /etc directory as the location for the adjtime file. To make the hwclock program FHS-compliant, run the following:

sed -i -e 's@etc/adjtime@var/lib/hwclock/adjtime@g' \
    $(grep -rl '/etc/adjtime' .)
mkdir -pv /var/lib/hwclock

10.30.2. Installation of Util-linux

Prepare Util-linux for compilation:

CC="gcc ${BUILD64}" ./configure --libdir=/lib64 \
    --enable-arch --enable-write --disable-login --disable-su

The meaning of the configure options:

--enable-arch

This option allows the arch program to be installed.

--enable-write

This option allows the write program to be installed.

--disable-login --disable-su

Disables building the login and su programs, as the Shadow package installs its own versions.

Compile the package:

make

To test the results, issue: make check.

Install the package:

make install

Move the logger binary to /bin as it is needed by the CLFS-Bootscripts package:

mv -v /usr/bin/logger /bin

10.30.3. Contents of Util-linux

Installed programs: addpart, agetty, arch, blkid, blockdev, cal, cfdisk, chcpu, chrt, col, colcrt, colrm, column, ctrlaltdel, cytune, delpart, dmesg, eject, fallocate, fdformat, fdisk, findfs, findmnt, flock, fsck, fsck.cramfs, fsck.minix, fsfreeze, fstrim, getopt, hexdump, hwclock, ionice, ipcmk, ipcrm, ipcs, isosize, kill, ldattach, logger, look, losetup, lsblk, lscpu, lslocks, mcookie, mkfs, mkfs.bfs, mkfs.cramfs, mkfs.minix, mkswap, more, mount, mountpoint, namei, partx, pg, pivot_root, prlimit, raw, readprofile, rename, renice, resizepart, rev, rtcwake, script, scriptreplay, setarch, setsid, setterm, sfdisk, sulogin, swaplabel, swapoff (link to swapon), swapon, switch_root, tailf, taskset, tunelp, ul, umount, unshare, utmpdump, uuidd, uuidgen, wall, wdctl, whereis, wipefs, and write
Installed libraries: libblkid.[a,so], libmount.[a,so], and libuuid.[a,so]
Installed directories: /usr/include/blkid, /usr/include/libmount, /usr/include/uuid, /usr/share/getopt, /var/lib/hwclock

Short Descriptions

addpart

Informs the kernel of a new partition

agetty

Opens a tty port, prompts for a login name, and then invokes the login program

arch

Reports the machine's architecture

blkid

A command line utility to locate and print block device attributes

blockdev

Allows users to call block device ioctls from the command line

cal

Displays a simple calendar

cfdisk

Manipulates the partition table of the given device

chcpu

Utility to configure CPUs

chrt

Manipulates real-time attributes of a process

col

Filters out reverse line feeds

colcrt

Filters nroff output for terminals that lack some capabilities, such as overstriking and half-lines

colrm

Filters out the given columns

column

Formats a given file into multiple columns

ctrlaltdel

Sets the function of the Ctrl+Alt+Del key combination to a hard or a soft reset

cytune

Tunes the parameters of the serial line drivers for Cyclades cards

ddate

Gives the Discordian date or converts the given Gregorian date to a Discordian one

delpart

Asks the kernel to remove a partition

dmesg

Dumps the kernel boot messages

eject

Eject removable media

fallocate

Preallocates space to a file

fdformat

Low-level formats a floppy disk

fdisk

Manipulates the partition table of the given device

findfs

Finds a file system by label or Universally Unique Identifier (UUID)

findmnt

Lists mounted filesystems or searches for a filesystem

flock

Acquires a file lock and then executes a command with the lock held

fsck

Is used to check, and optionally repair, file systems

fsck.cramfs

Performs a consistency check on the Cramfs file system on the given device

fsck.minix

Performs a consistency check on the Minix file system on the given device

fsfreeze

Suspends and resumes access to a filesystem

fstrim

Discards unused blocks on a mounted filesystem

getopt

Parses options in the given command line

hexdump

Dumps the given file in hexadecimal or in another given format

hwclock

Reads or sets the system's hardware clock, also called the Real-Time Clock (RTC) or Basic Input-Output System (BIOS) clock

ionice

Gives and sets program I/O scheduling class and priority

ipcmk

Creates various IPC resources

ipcrm

Removes the given Inter-Process Communication (IPC) resource

ipcs

Provides IPC status information

isosize

Reports the size of an iso9660 file system

kill

Send a signal to a process

ldattach

Attaches a line discipline to a serial line

logger

Enters the given message into the system log

look

Displays lines that begin with the given string

losetup

Sets up and controls loop devices

lsblk

Prints information about block devices

lscpu

Prints CPU architechture information

lslocks

Lists local system locks

mcookie

Generates magic cookies (128-bit random hexadecimal numbers) for xauth

mkfs

Builds a file system on a device (usually a hard disk partition)

mkfs.bfs

Creates a Santa Cruz Operations (SCO) bfs file system

mkfs.cramfs

Creates a cramfs file system

mkfs.minix

Creates a Minix file system

mkswap

Initializes the given device or file to be used as a swap area

more

A filter for paging through text one screen at a time

mount

Attaches the file system on the given device to a specified directory in the file-system tree

mountpoint

Tells you whether or not a directory is a mount point.

namei

Shows the symbolic links in the given pathnames

partx

Tells the kernel about the presence and numbering of on-disk partitions

pg

Displays a text file one screen full at a time

pivot_root

Makes the given file system the new root file system of the current process

prlimit

Gets and sets a process' resource limits

raw

Binds a Linux raw character device to a block device

readprofile

Reads kernel profiling information

rename

Renames the given files, replacing a given string with another

renice

Alters the priority of running processes

resizepart

Asks the Linux kernel to resize a partition

rev

Reverses the lines of a given file

rtcwake

Enters a system sleep state until a specified wakeup time

script

Makes a typescript of a terminal session

scriptreplay

Plays back typescripts created by script

setarch

Changes reported architecture in new program environment and sets personality flags

setsid

Runs the given program in a new session

setterm

Sets terminal attributes

sfdisk

A disk partition table manipulator

sulogin

Allows root to log in; it is normally invoked by init when the system goes into single user mode

swaplabel

Prints or changes the label or UUID of a swap area

swapoff

Disables devices and files for paging and swapping

swapon

Enables devices and files for paging and swapping and lists the devices and files currently in use

switch_root

Switches to another filesystem as the root of the mount tree

tailf

Tracks the growth of a log file. Displays the last 10 lines of a log file, then continues displaying any new entries in the log file as they are created

taskset

Retrieves or sets a process's CPU affinity

tunelp

Tunes the parameters of the line printer

ul

A filter for translating underscores into escape sequences indicating underlining for the terminal in use

umount

Disconnects a file system from the system's file tree

unshare

Runs a program with some namespaces unshared from parent

utmpdump

Displays the content of the given login file in a more user-friendly format

uuidd

A daemon used by the UUID library to generate time-based UUIDs in a secure and guranteed-unique fashion.

uuidgen

Creates new UUIDs. Each new UUID can reasonably be considered unique among all UUIDs created, on the local system and on other systems, in the past and in the future

wall

Writes a message to all logged-in users

wdctl

Show hardware watchdog status

whereis

Reports the location of the binary, source, and man page for the given command

wipefs

Wipes a filesystem signature from a device

write

Sends a message to the given user if that user has not disabled receipt of such messages

libblkid

Contains routines for device identification and token extraction

libmount

Contains routines for parsing the /etc/fstab, /etc/mtab, and /proc/self/mountinfo files, managing /etc/mtab, and configuring various mount options

libuuid

Contains routines for generating unique identifiers for objects that may be accessible beyond the local system

10.31. Procps-3.2.8 32 Bit Libraries

The Procps package contains programs for monitoring processes.

10.31.1. Installation of Procps

The following patch adds process control group support to ps:

patch -Np1 -i ../procps-3.2.8-ps_cgroup-1.patch

The following patch fixes an issue where some procps utils print an error on the screen if the monitor isn't running at 60Hz:

patch -Np1 -i ../procps-3.2.8-fix_HZ_errors-1.patch

The following fixes an issue with Make 3.82:

sed -i -r '/^-include/s/\*(.*)/proc\1 ps\1/' Makefile

Compile the package:

make CC="gcc ${BUILD32}" m64=""

This package does not come with a test suite.

Install the package:

make SKIP='/bin/kill /usr/share/man/man1/kill.1' install lib64=lib

The meaning of the make and install options:

CC="gcc ${BUILD32}"

This allows us to compile using our gcc with our options lists in ${BUILD32} variable.

m64=""

The Makefile for this package goes to some lengths to build as 64-bit if at all possible. In CLFS we build each library for each available ABI. Overriding the m64 option enables us ignore this completely.

lib64=lib

The Makefile also attempts to install into lib64 on multilib, so again we choose to override it.

Details on this package are located in Section 10.32.2, “Contents of Procps.”

10.32. Procps-3.2.8 64 Bit

The Procps package contains programs for monitoring processes.

10.32.1. Installation of Procps

The following patch adds process control group support to ps:

patch -Np1 -i ../procps-3.2.8-ps_cgroup-1.patch

The following patch fixes an issue where some procps utils print an error on the screen if the monitor isn't running at 60Hz:

patch -Np1 -i ../procps-3.2.8-fix_HZ_errors-1.patch

The following fixes an issue with Make 3.82:

sed -i -r '/^-include/s/\*(.*)/proc\1 ps\1/' Makefile

Compile the package:

make CC="gcc ${BUILD64}" m64=""

This package does not come with a test suite.

Install the package:

make SKIP='/bin/kill /usr/share/man/man1/kill.1' install lib64=lib64

The meaning of the make and install options:

CC="gcc ${BUILD64}"

This allows us to compile using our gcc with our options lists in ${BUILD64} variable.

m64=""

The Makefile for this package goes to some lengths to build as 64-bit if at all possible. In CLFS we build each library for each available ABI. Overriding the m64 option enables us ignore this completely.

lib64=lib64

The Makefile also attempts to install into lib64 on multilib, so again we choose to override it.

10.32.2. Contents of Procps

Installed programs: free, pgrep, pkill, pmap, ps, pwdx, skill, slabtop, snice, sysctl, tload, top, uptime, vmstat, w, and watch
Installed library: libproc.so

Short Descriptions

free

Reports the amount of free and used memory (both physical and swap memory) in the system

pgrep

Looks up processes based on their name and other attributes

pkill

Signals processes based on their name and other attributes

pmap

Reports the memory map of the given process

ps

Lists the current running processes

pwdx

Reports the current working directory of a process

skill

Sends signals to processes matching the given criteria

slabtop

Displays detailed kernel slab cache information in real time

snice

Changes the scheduling priority of processes matching the given criteria

sysctl

Modifies kernel parameters at run time

tload

Prints a graph of the current system load average

top

Displays a list of the most CPU intensive processes; it provides an ongoing look at processor activity in real time

uptime

Reports how long the system has been running, how many users are logged on, and the system load averages

vmstat

Reports virtual memory statistics, giving information about processes, memory, paging, block Input/Output (IO), traps, and CPU activity

w

Shows which users are currently logged on, where, and since when

watch

Runs a given command repeatedly, displaying the first screen-full of its output; this allows a user to watch the output change over time

libproc

Contains the functions used by most programs in this package

10.33. E2fsprogs-1.42.6 32 Bit Libraries

The E2fsprogs package contains the utilities for handling the ext2 file system. It also supports the ext3 and ext4 journaling file systems.

10.33.1. Installation of E2fsprogs

The E2fsprogs documentation recommends that the package be built in a subdirectory of the source tree:

mkdir -v build
cd build

Prepare E2fsprogs for compilation:

CC="gcc ${BUILD32}" PKG_CONFIG_PATH="${PKG_CONFIG_PATH32}" \
  ../configure --prefix=/usr --with-root-prefix="" \
    --enable-elf-shlibs --disable-libblkid \
    --disable-libuuid --disable-fsck \
    --disable-uuidd

The meaning of the configure options:

--with-root-prefix=""

Certain programs (such as the e2fsck program) are considered essential programs. When, for example, /usr is not mounted, these programs still need to be available. They belong in directories like /lib and /sbin. If this option is not passed to E2fsprogs' configure, the programs are installed into the /usr directory.

--enable-elf-shlibs

This creates the shared libraries which some programs in this package use.

Compile the libraries:

make libs

Install the static libraries and headers:

make install-libs

Details on this package are located in Section 10.34.2, “Contents of E2fsprogs.”

10.34. E2fsprogs-1.42.6 64 Bit

The E2fsprogs package contains the utilities for handling the ext2 file system. It also supports the ext3 and ext4 journaling file systems.

10.34.1. Installation of E2fsprogs

Change the library directory to lib64:

sed -i '/libdir.*=.*\/lib/s@/lib@/lib64@g' configure

The E2fsprogs documentation recommends that the package be built in a subdirectory of the source tree:

mkdir -v build
cd build

Prepare E2fsprogs for compilation:

CC="gcc ${BUILD64}" PKG_CONFIG_PATH="${PKG_CONFIG_PATH64}" \
  ../configure --prefix=/usr --with-root-prefix="" \
    --enable-elf-shlibs --disable-libblkid \
    --disable-libuuid --disable-fsck \
    --disable-uuidd

The meaning of the configure options:

--with-root-prefix=""

Certain programs (such as the e2fsck program) are considered essential programs. When, for example, /usr is not mounted, these programs still need to be available. They belong in directories like /lib and /sbin. If this option is not passed to E2fsprogs' configure, the programs are installed into the /usr directory.

--enable-elf-shlibs

This creates the shared libraries which some programs in this package use.

Compile the package:

make

To test the results, issue: make check.

Install the binaries, documentation and shared libraries:

make install

Install the static libraries and headers:

make install-libs

10.34.2. Contents of E2fsprogs

Installed programs: badblocks, chattr, compile_et, debugfs, dumpe2fs, e2freefrag, e2fsck, e2image, e2initrd_helper, e2label, e2undo, e4defrag, filefrag, fsck.ext2, fsck.ext3, fsck.ext4, fsck.ext4dev, logsave, lsattr, mk_cmds, mke2fs, mkfs.ext2, mkfs.ext3, mkfs.ext4, mkfs.ext4dev, mklost+found, resize2fs, and tune2fs
Installed libraries: libcom_err.[a,so], libe2p.[a,so], libext2fs.[a,so], libss.[a,so], and libquota.a
Installed directories: /usr/include/e2p, /usr/include/et, /usr/include/ext2fs, /usr/include/quota, /usr/include/ss, /usr/share/et, /usr/share/ss

Short Descriptions

badblocks

Searches a device (usually a disk partition) for bad blocks

chattr

Changes the attributes on a Linux file system

compile_et

An error table compiler; it converts a table of error-code names and messages into a C source file suitable for use with the com_err library

debugfs

A file system debugger; it can be used to examine and change the state of an ext2 file system

dumpe2fs

Prints the super block and blocks group information for the file system present on a given device

e2freefrag

Reports free space fragmentation information

e2fsck

Is used to check, and optionally repair ext2, ext3 and ext4file systems

e2image

Is used to save critical ext2 file system data to a file

e2initrd_helper

Prints the FS type of a given filesystem, given either a device name or label

e2label

Displays or changes the file system label on the ext2 file system present on a given device

e2undo

Replays an undo log for an ext2/ext3/ext4 filesystem

e4defrag

Online defragmenter for ext4 filesystems

filefrag

Reports on how badly fragmented a particular file might be

fsck.ext2

By default checks ext2 file systems

fsck.ext3

By default checks ext3 file systems

fsck.ext4

By default checks ext4 file systems

fsck.ext4dev

By default checks ext4dev file systems

logsave

Saves the output of a command in a log file

lsattr

Lists the attributes of files on a second extended file system

mk_cmds

Converts a table of command names and help messages into a C source file suitable for use with the libss subsystem library

mke2fs

Creates an ext2, ext3 or ext4 file system on the given device

mkfs.ext2

By default creates ext2 file systems

mkfs.ext3

By default creates ext3 file systems

mkfs.ext4

By default creates ext4 file systems

mkfs.ext4dev

By default creates ext4dev file systems

mklost+found

Used to create a lost+found directory on an ext2 file system; it pre-allocates disk blocks to this directory to lighten the task of e2fsck

resize2fs

Can be used to enlarge or shrink an ext2 file system

tune2fs

Adjusts tunable file system parameters on an ext2 file system

libcom_err

The common error display routine

libe2p

Used by dumpe2fs, chattr, and lsattr

libext2fs

Contains routines to enable user-level programs to manipulate an ext2 file system

libquota

Provides an interface for creating and updating quota files and ext4 superblock fields

libss

Used by debugfs

10.35. Shadow-4.1.5.1

The Shadow package contains programs for handling passwords in a secure way.

10.35.1. Installation of Shadow

Note

If you would like to enforce the use of strong passwords, refer to http://cblfs.cross-lfs.org/index.php/Cracklib for installing Cracklib prior to building Shadow. Then add --with-libcrack to the configure command below.

Disable the installation of the groups program and its man pages, as Coreutils provides a better version:

sed -i 's/groups$(EXEEXT) //' src/Makefile.in
find man -name Makefile.in -exec sed -i '/groups\.1\.xml/d' '{}' \;
find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \;

Prepare Shadow for compilation:

CC="gcc ${BUILD64}" ./configure --sysconfdir=/etc

The meaning of the configure options:

--sysconfdir=/etc

Tells Shadow to install its configuration files into /etc, rather than /usr/etc.

Compile the package:

make

This package does not come with a test suite.

Install the package:

make install

Instead of using the default crypt method, use the more secure SHA512 method of password encryption, which also allows passwords longer than 8 characters. It is also necessary to change the obsolete /var/spool/mail location for user mailboxes that Shadow uses by default to the /var/mail location used currently. Use the following sed command to make these changes to the appropriate configuration file:

sed -i /etc/login.defs \
    -e 's@#\(ENCRYPT_METHOD \).*@\1SHA512@' \
    -e 's@/var/spool/mail@/var/mail@'

Note

If you built Shadow with Cracklib support, execute this sed to correct the path to the Cracklib dictionary:

sed -i 's@DICTPATH.*@DICTPATH\t/lib/cracklib/pw_dict@' /etc/login.defs

Move a misplaced program to its proper location:

mv -v /usr/bin/passwd /bin

10.35.2. Configuring Shadow

This package contains utilities to add, modify, and delete users and groups; set and change their passwords; and perform other administrative tasks. For a full explanation of what password shadowing means, see the doc/HOWTO file within the unpacked source tree. If using Shadow support, keep in mind that programs which need to verify passwords (display managers, FTP programs, pop3 daemons, etc.) must be Shadow-compliant. That is, they need to be able to work with shadowed passwords.

To enable shadowed passwords, run the following command:

pwconv

To enable shadowed group passwords, run:

grpconv

To view or change the default settings for new user accounts that you create, you can edit /etc/default/useradd. See man useradd or http://cblfs.cross-lfs.org/index.php/Configuring_for_Adding_Users for more information.

10.35.3. Setting the root password

Choose a password for user root and set it by running:

passwd root

10.35.4. Contents of Shadow

Installed programs: chage, chfn, chpasswd, chgpasswd, chsh, expiry, faillog, gpasswd, groupadd, groupdel, groupmems, groupmod, grpck, grpconv, grpunconv, lastlog, login, logoutd, newgrp, newusers, nologin, passwd, pwck, pwconv, pwunconv, sg (link to newgrp), su, useradd, userdel, usermod, vigr (link to vipw), and vipw
Installed directory: /etc/default

Short Descriptions

chage

Used to change the maximum number of days between obligatory password changes

chfn

Used to change a user's full name and other information

chgpasswd

Used to update group passwords in batch mode

chpasswd

Used to update the passwords of an entire series of user accounts

chsh

Used to change a user's default login shell

expiry

Checks and enforces the current password expiration policy

faillog

Is used to examine the log of login failures, to set a maximum number of failures before an account is blocked, or to reset the failure count

gpasswd

Is used to add and delete members and administrators to groups

groupadd

Creates a group with the given name

groupdel

Deletes the group with the given name

groupmems

Allows a user to administer his/her own group membership list without the requirement of superuser privileges

groupmod

Is used to modify the given group's name or GID

grpck

Verifies the integrity of the group files /etc/group and /etc/gshadow

grpconv

Creates or updates the shadow group file from the normal group file

grpunconv

Updates /etc/group from /etc/gshadow and then deletes the latter

lastlog

Reports the most recent login of all users or of a given user

login

Is used by the system to let users sign on

logoutd

Is a daemon used to enforce restrictions on log-on time and ports

newgrp

Is used to change the current GID during a login session

newusers

Is used to create or update an entire series of user accounts

nologin

Displays a message that an account is not available. Designed to be used as the default shell for accounts that have been disabled

passwd

Is used to change the password for a user or group account

pwck

Verifies the integrity of the password files /etc/passwd and /etc/shadow

pwconv

Creates or updates the shadow password file from the normal password file

pwunconv

Updates /etc/passwd from /etc/shadow and then deletes the latter

sg

Executes a given command while the user's GID is set to that of the given group

su

Runs a shell with substitute user and group IDs

useradd

Creates a new user with the given name, or updates the default new-user information

userdel

Deletes the given user account

usermod

Is used to modify the given user's login name, User Identification (UID), shell, initial group, home directory, etc.

vigr

Edits the /etc/group or /etc/gshadow files

vipw

Edits the /etc/passwd or /etc/shadow files

10.36. Coreutils-8.20

The Coreutils package contains utilities for showing and setting the basic system characteristics.

10.36.1. Installation of Coreutils

A known issue with the uname program from this package is that the -p switch always returns unknown. The following patch fixes this behavior for all architectures:

patch -Np1 -i ../coreutils-8.20-uname-1.patch

Now prepare Coreutils for compilation:

FORCE_UNSAFE_CONFIGURE=1 CC="gcc ${BUILD64}" \
   ./configure --prefix=/usr \
    --enable-no-install-program=kill,uptime \
    --enable-install-program=hostname

The meaning of the configure options:

FORCE_UNSAFE_CONFIGURE=1

Forces Coreutils to compile when using the root user.

Compile the package:

make

The test suite of Coreutils makes several assumptions about the presence of system users and groups that are not valid within the minimal environment that exists at the moment. Therefore, additional items need to be set up before running the tests. Skip down to “Install the package” if not running the test suite.

Create two dummy groups and a dummy user:

echo "dummy1:x:1000:" >> /etc/group
echo "dummy2:x:1001:dummy" >> /etc/group
echo "dummy:x:1000:1000::/root:/bin/bash" >> /etc/passwd

Now the test suite is ready to be run. First, run the tests that are meant to be run as user root:

make NON_ROOT_USERNAME=dummy SUBDIRS= check-root

The testsuite will now be run as the dummy user. Fix the permissions for a few files to allow this:

chown -Rv dummy .

Then run the remainder of the tests as the dummy user:

su dummy -s /bin/bash \
    -c "PATH=$PATH make RUN_EXPENSIVE_TESTS=yes -k check || true"

When testing is complete, remove the dummy user and groups:

sed -i '/dummy/d' /etc/passwd /etc/group

Install the package:

make install

Move programs to the locations specified by the FHS:

mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date} /bin
mv -v /usr/bin/{dd,df,echo,false,hostname,ln,ls,mkdir,mknod} /bin
mv -v /usr/bin/{mv,pwd,rm,rmdir,stty,true,uname} /bin
mv -v /usr/bin/chroot /usr/sbin

Other Coreutils programs are used by some of the scripts in the CLFS-Bootscripts package. As /usr may not be available during the early stages of booting, those binaries need to be on the root partition:

mv -v /usr/bin/{[,basename,head,install,nice} /bin
mv -v /usr/bin/{readlink,sleep,sync,test,touch} /bin
ln -svf ../../bin/install /usr/bin

10.36.2. Contents of Coreutils

Installed programs: [, base64, basename, cat, chcon, chgrp, chmod, chown, chroot, cksum, comm, cp, csplit, cut, date, dd, df, dir, dircolors, dirname, du, echo, env, expand, expr, factor, false, fmt, fold, groups, head, hostid, hostname, id, install, join, link, ln, logname, ls, md5sum, mkdir, mkfifo, mknod, mktemp, mv, nice, nl, nohup, nproc, od, paste, pathchk, pinky, pr, printenv, printf, ptx, pwd, readlink, realpath, rm, rmdir, runcon, seq, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, shred, shuf, sleep, sort, split, stat, stdbuf, stty, sum, sync, tac, tail, tee, test, timeout, touch, tr, true, truncate, tsort, tty, uname, unexpand, uniq, unlink, users, vdir, wc, who, whoami, and yes
Installed library: libstdbuf.so
Installed directory: /usr/lib/coreutils

Short Descriptions

base64

Base64 encode/decode data and print to standard output

basename

Strips any path and a given suffix from a file name

cat

Concatenates files to standard output

chcon

Changes security context for files and directories

chgrp

Changes the group ownership of files and directories

chmod

Changes the permissions of each file to the given mode; the mode can be either a symbolic representation of the changes to make or an octal number representing the new permissions

chown

Changes the user and/or group ownership of files and directories

chroot

Runs a command with the specified directory as the / directory

cksum

Prints the Cyclic Redundancy Check (CRC) checksum and the byte counts of each specified file

comm

Compares two sorted files, outputting in three columns the lines that are unique and the lines that are common

cp

Copies files

csplit

Splits a given file into several new files, separating them according to given patterns or line numbers and outputting the byte count of each new file

cut

Prints sections of lines, selecting the parts according to given fields or positions

date

Displays the current time in the given format, or sets the system date

dd

Copies a file using the given block size and count, while optionally performing conversions on it

df

Reports the amount of disk space available (and used) on all mounted file systems, or only on the file systems holding the selected files

dir

Lists the contents of each given directory (the same as the ls command)

dircolors

Outputs commands to set the LS_COLOR environment variable to change the color scheme used by ls

dirname

Strips the non-directory suffix from a file name

du

Reports the amount of disk space used by the current directory, by each of the given directories (including all subdirectories) or by each of the given files

echo

Displays the given strings

env

Runs a command in a modified environment

expand

Converts tabs to spaces

expr

Evaluates expressions

factor

Prints the prime factors of all specified integer numbers

false

Does nothing, unsuccessfully; it always exits with a status code indicating failure

fmt

Reformats the paragraphs in the given files

fold

Wraps the lines in the given files

groups

Reports a user's group memberships

head

Prints the first ten lines (or the given number of lines) of each given file

hostid

Reports the numeric identifier (in hexadecimal) of the host

hostname

Reports or sets the name of the host

id

Reports the effective user ID, group ID, and group memberships of the current user or specified user

install

Copies files while setting their permission modes and, if possible, their owner and group

join

Joins the lines that have identical join fields from two separate files

link

Creates a hard link with the given name to a file

ln

Makes hard links or soft (symbolic) links between files

logname

Reports the current user's login name

ls

Lists the contents of each given directory

md5sum

Reports or checks Message Digest 5 (MD5) checksums

mkdir

Creates directories with the given names

mkfifo

Creates First-In, First-Outs (FIFOs), a “named pipe” in UNIX parlance, with the given names

mknod

Creates device nodes with the given names; a device node is a character special file, a block special file, or a FIFO

mktemp

Creates temporary files in a secure manner; it is used in scripts

mv

Moves or renames files or directories

nice

Runs a program with modified scheduling priority

nl

Numbers the lines from the given files

nohup

Runs a command immune to hangups, with its output redirected to a log file

nproc

Prints the number of processing units available to the current process

od

Dumps files in octal and other formats

paste

Merges the given files, joining sequentially corresponding lines side by side, separated by tab characters

pathchk

Checks if file names are valid or portable

pinky

Is a lightweight finger client; it reports some information about the given users

pr

Paginates and columnates files for printing

printenv

Prints the environment

printf

Prints the given arguments according to the given format, much like the C printf function

ptx

Produces a permuted index from the contents of the given files, with each keyword in its context

pwd

Reports the name of the current working directory

readlink

Reports the value of the given symbolic link

realpath

Prints the resolved path

rm

Removes files or directories

rmdir

Removes directories if they are empty

runcon

Runs a command with specified security context

seq

Prints a sequence of numbers within a given range and with a given increment

sha1sum

Prints or checks 160-bit Secure Hash Algorithm 1 (SHA1) checksums

sha224sum

Prints or checks SHA224 checksums

sha256sum

Prints or checks SHA256 checksums

sha384sum

Prints or checks SHA384 checksums

sha512sum

Prints or checks SHA512 checksums

shred

Overwrites the given files repeatedly with complex patterns, making it difficult to recover the data

shuf

Write a random permutation of the input lines to standard output or a file

sleep

Pauses for the given amount of time

sort

Sorts the lines from the given files

split

Splits the given file into pieces, by size or by number of lines

stat

Displays file or filesystem status

stdbuf

Runs a command with modified buffering operations for its standard streams

stty

Sets or reports terminal line settings

sum

Prints checksum and block counts for each given file

sync

Flushes file system buffers; it forces changed blocks to disk and updates the super block

tac

Concatenates the given files in reverse

tail

Prints the last ten lines (or the given number of lines) of each given file

tee

Reads from standard input while writing both to standard output and to the given files

test or [

Compares values and checks file types

timeout

Runs a command with a time limit

touch

Changes file timestamps, setting the access and modification times of the given files to the current time; files that do not exist are created with zero length

tr

Translates, squeezes, and deletes the given characters from standard input

true

Does nothing, successfully; it always exits with a status code indicating success

truncate

Shrinks or expands a file to the specified size

tsort

Performs a topological sort; it writes a completely ordered list according to the partial ordering in a given file

tty

Reports the file name of the terminal connected to standard input

uname

Reports system information

unexpand

Converts spaces to tabs

uniq

Discards all but one of successive identical lines

unlink

Removes the given file

users

Reports the names of the users currently logged on

vdir

Is the same as ls -l

wc

Reports the number of lines, words, and bytes for each given file, as well as a total line when more than one file is given

who

Reports who is logged on

whoami

Reports the user name associated with the current effective user ID

yes

Repeatedly outputs “y” or a given string until killed

libstdbuf

Library used by stdbuf

10.37. Iana-Etc-2.30

The Iana-Etc package provides data for network services and protocols.

10.37.1. Installation of Iana-Etc

Note

This package has the option of downloading updated data when internet access is available. If /etc/resolv.conf has a nameserver entry and internet access is available at this step, then apply the IANA get patch and get the updated data:

patch -Np1 -i ../iana-etc-2.30-get_fix-1.patch
make get

Do not apply the following patch.

The following patch updates the services and protocol files:

patch -Np1 -i ../iana-etc-2.30-numbers_update-20120610-2.patch

The following command converts the raw data provided by IANA into the correct formats for the /etc/protocols and /etc/services data files:

make

This package does not come with a test suite.

Install the package:

make install

10.37.2. Contents of Iana-Etc

Installed files: /etc/protocols and /etc/services

Short Descriptions

/etc/protocols

Describes the various DARPA Internet protocols that are available from the TCP/IP subsystem

/etc/services

Provides a mapping between friendly textual names for internet services, and their underlying assigned port numbers and protocol types

10.38. M4-1.4.16

The M4 package contains a macro processor.

10.38.1. Installation of M4

Prepare M4 for compilation:

CC="gcc ${BUILD64}" ./configure --prefix=/usr

Compile the package:

make

To test the results, issue: make check.

Install the package:

make install

10.38.2. Contents of M4

Installed program: m4

Short Descriptions

m4

copies the given files while expanding the macros that they contain. These macros are either built-in or user-defined and can take any number of arguments. Besides performing macro expansion, m4 has built-in functions for including named files, running Unix commands, performing integer arithmetic, manipulating text, recursion, etc. The m4 program can be used either as a front-end to a compiler or as a macro processor in its own right.

10.39. Bison-2.6.4 32 Bit Libraries

The Bison package contains a parser generator.

10.39.1. Installation of Bison

The configure script does not determine the correct value for the following. Set the value manually:

echo "ac_cv_prog_lex_is_flex=yes" > config.cache

Prepare Bison for compilation:

CC="gcc ${BUILD32}" ./configure --prefix=/usr  --cache-file=config.cache

Compile the package:

make

To test the results, issue: make check.

Install the package:

make install

Details on this package are located in Section 10.40.2, “Contents of Bison.”

10.40. Bison-2.6.4 64Bit

The Bison package contains a parser generator.

10.40.1. Installation of Bison

The configure script does not determine the correct value for the following. Set the value manually:

echo "ac_cv_prog_lex_is_flex=yes" > config.cache

Prepare Bison for compilation:

CC="gcc ${BUILD64}" ./configure --prefix=/usr --libdir=/usr/lib64  --cache-file=config.cache

Compile the package:

make

To test the results, issue: make check.

Install the package:

make install

10.40.2. Contents of Bison

Installed programs: bison and yacc
Installed library: liby.a
Installed directory: /usr/share/bison

Short Descriptions

bison

Generates, from a series of rules, a program for analyzing the structure of text files; Bison is a replacement for Yacc (Yet Another Compiler Compiler)

yacc

A wrapper for bison, meant for programs that still call yacc instead of bison; it calls bison with the -y option

liby.a

The Yacc library containing implementations of Yacc-compatible yyerror and main functions; this library is normally not very useful, but POSIX requires it

10.41. Libtool-2.4.2 32 Bit Libraries

The Libtool package contains the GNU generic library support script. It wraps the complexity of using shared libraries in a consistent, portable interface.

10.41.1. Installation of Libtool

The following config.cache entry overrides the default search path, which does not take multilib into account:

echo "lt_cv_sys_dlsearch_path='/lib /usr/lib /usr/local/lib /opt/lib'" > config.cache

Prepare Libtool for compilation:

CC="gcc ${BUILD32}" ./configure --prefix=/usr \
    --cache-file=config.cache

Compile the package:

make

To test the results, issue: make LDEMULATION=elf_i386 check.

The meaning of the override on make check:

LDEMULATION=elf_i386

Libtool tends to do the wrong thing when building for multilib, at least on the non-default size(s) of architecture. The causes of these errors are not well understood and they can appear, or disappear, as a result of apparently innocuous other changes in the build. In this version of the book, one of the tests (pdemo-make) fails to link because it tries to link the 32-bit objects against 64-bit system libraries. This option enables the test to succeed without impacting the other tests (compare the common alternative fixes of LD="gcc ${BUILD32}" which causes far fewer tests to be executed, and configuring with LDFLAGS='-L/lib -L/usr/lib' which in this case causes other tests to fail.)

Install the package:

make install

Prepare libtool to be wrapped by the multiarch wrapper. Libtool by itself is not multilib aware:

mv -v /usr/bin/libtool{,-32}

Details on this package are located in Section 10.42.2, “Contents of Libtool.”

10.42. Libtool-2.4.2 64 Bit

The Libtool package contains the GNU generic library support script. It wraps the complexity of using shared libraries in a consistent, portable interface.

10.42.1. Installation of Libtool

The following config.cache entry overrides the default search path, which does not take multilib into account:

echo "lt_cv_sys_dlsearch_path='/lib64 /usr/lib64 /usr/local/lib64 /opt/lib64'" > config.cache

Prepare Libtool for compilation:

CC="gcc ${BUILD64}" ./configure --prefix=/usr \
   --libdir=/usr/lib64 --cache-file=config.cache

Compile the package:

make

To test the results, issue: make check.

Install the package:

make install

Prepare libtool to be wrapped by the multiarch wrapper. Libtool by itself is not multilib aware:

mv -v /usr/bin/libtool{,-64}
ln -sv multiarch_wrapper /usr/bin/libtool

10.42.2. Contents of Libtool

Installed programs: libtool and libtoolize
Installed libraries: libltdl.[a,so]
Installed directories: /usr/include/libltdl, /usr/share/libtool

Short Descriptions

libtool

Provides generalized library-building support services

libtoolize

Provides a standard way to add libtool support to a package

libltdl

Hides the various difficulties of dlopening libraries

10.43. Flex-2.5.37 32 Bit Libraries

The Flex package contains a utility for generating programs that recognize patterns in text.

10.43.1. Installation of Flex

Prepare Flex for compilation:

CC="gcc ${BUILD32}" ./configure --prefix=/usr

Compile the package:

make libfl.a libfl_pic.a

Install the package:

make install-libLIBRARIES

There are some packages that expect to find the lex library in /usr/lib. Create a symlink to account for this:

ln -sv libfl.a /usr/lib/libl.a

Details on this package are located in Section 10.44.2, “Contents of Flex.”

10.44. Flex-2.5.37 64 Bit

The Flex package contains a utility for generating programs that recognize patterns in text.

10.44.1. Installation of Flex

Prepare Flex for compilation:

CC="gcc ${BUILD64}" ./configure --prefix=/usr \
    --libdir=/usr/lib64

Compile the package:

make

To test the results, issue: make check.

Install the package:

make install

There are some packages that expect to find the lex library in /usr/lib64. Create a symlink to account for this:

ln -sv libfl.a /usr/lib64/libl.a

A few programs do not know about flex yet and try to run its predecessor, lex. To support those programs, create a wrapper script named lex that calls flex in lex emulation mode:

cat > /usr/bin/lex << "EOF"
#!/bin/sh
# Begin /usr/bin/lex

exec /usr/bin/flex -l "$@"

# End /usr/bin/lex
EOF
chmod -v 755 /usr/bin/lex

10.44.2. Contents of Flex

Installed programs: flex and lex
Installed libraries: libfl.a and libfl_pic.a

Short Descriptions

flex

A tool for generating programs that recognize patterns in text; it allows for the versatility to specify the rules for pattern-finding, eradicating the need to develop a specialized program

flex++

Link to flex which makes it generate C++ scanner classes

lex

A script that runs flex in lex emulation mode

libfl.a

The flex library

libfl_pic.a

The flex library

10.45. IPRoute2-3.4.0

The IPRoute2 package contains programs for basic and advanced IPV4-based networking.

10.45.1. Installation of IPRoute2

By default, this package builds the arpd program, which is dependent on Berkeley DB. Because arpd is not a very common requirement on a base Linux system, remove the dependency on Berkeley DB by using the commands below. If the arpd binary is needed, instructions for compiling Berkeley DB can be found in CBLFS at http://cblfs.cross-lfs.org/index.php/Berkeley_DB.

sed -i '/^TARGETS/s@arpd@@g' misc/Makefile
sed -i '/ARPD/d' Makefile
rm -v man/man8/arpd.8

Remove unused libnl headers:

sed -i '/netlink\//d' ip/ipl2tp.c

This patch adds the ability to update the LIBDIR path:

patch -Np1 -i ../iproute2-3.4.0-libdir-1.patch

Compile the package:

make CC="gcc ${BUILD64}" DESTDIR= LIBDIR=/usr/lib64 \
    DOCDIR=/usr/share/doc/iproute2 MANDIR=/usr/share/man

The meaning of the make option:

DESTDIR=

This option overrides the default DESTDIR of /usr, so that that the IPRoute2 binaries will be installed into /sbin. This is the correct location according to the FHS, because some of the IPRoute2 binaries are used by the CLFS-Bootscripts package.

DOCDIR=/usr/share/doc/iproute2 MANDIR=/usr/share/man

The DESTDIR=/ parameter would cause documentation to be installed into /share/doc and /share/man. These options ensure the docs are installed to the correct locations.

This package does not come with a test suite.

Install the package:

make DESTDIR= LIBDIR=/usr/lib64 \
    DOCDIR=/usr/share/doc/iproute2 \
    MANDIR=/usr/share/man install

10.45.2. Contents of IPRoute2

Installed programs: ctstat (link to lnstat), genl, ifcfg, ifstat, ip, lnstat, nstat, routef, routel, rtacct, rtmon, rtpr, rtstat (link to lnstat), ss, and tc
Installed directories: /etc/iproute2, /lib/tc, /usr/lib/tc, /usr/share/doc/iproute2

Short Descriptions

ctstat

Connection status utility

genl

Needs description

ifcfg

A shell script wrapper for the ip command

ifstat

Shows the interface statistics, including the amount of transmitted and received packets by interface

ip

The main executable. It has several different functions:

ip link [device] allows users to look at the state of devices and to make changes

ip addr allows users to look at addresses and their properties, add new addresses, and delete old ones

ip neighbor allows users to look at neighbor bindings and their properties, add new neighbor entries, and delete old ones

ip rule allows users to look at the routing policies and change them

ip route allows users to look at the routing table and change routing table rules

ip tunnel allows users to look at the IP tunnels and their properties, and change them

ip maddr allows users to look at the multicast addresses and their properties, and change them

ip mroute allows users to set, change, or delete the multicast routing

ip monitor allows users to continously monitor the state of devices, addresses and routes

lnstat

Provides Linux network statistics. It is a generalized and more feature-complete replacement for the old rtstat program

nstat

Shows network statistics

routef

A component of ip route. This is for flushing the routing tables

routel

A component of ip route. This is for listing the routing tables

rtacct

Displays the contents of /proc/net/rt_acct

rtmon

Route monitoring utility

rtpr

Converts the output of ip -o back into a readable form

rtstat

Route status utility

ss

Similar to the netstat command; shows active connections

tc

Traffic Controlling Executable; this is for Quality Of Service (QOS) and Class Of Service (COS) implementations

tc qdisc allows users to setup the queueing discipline

tc class allows users to setup classes based on the queuing discipline scheduling

tc estimator allows users to estimate the network flow into a network

tc filter allows users to setup the QOS/COS packet filtering

tc policy allows users to setup the QOS/COS policies

10.46. Perl-5.16.2 32 Bit Libraries

The Perl package contains the Practical Extraction and Report Language.

10.46.1. Installation of Perl

By default, Perl's Compress::Raw::Zlib module builds and links against its own internal copy of Zlib. The following command will tell it to use the system-installed Zlib:

sed -i -e '/^BUILD_ZLIB/s/True/False/' \
       -e '/^INCLUDE/s,\./zlib-src,/usr/include,' \
       -e '/^LIB/s,\./zlib-src,/usr/lib,' \
       cpan/Compress-Raw-Zlib/config.in

Note

If you are following the boot method you will need to enable the loopback device as well as set a hostname for some of the tests:

ip link set lo up
hostname clfs

Before starting to configure, create a basic /etc/hosts file which will be referenced by one of Perl's configuration files as well as used by the testsuite:

echo "127.0.0.1 localhost $(hostname)" > /etc/hosts

To have full control over the way Perl is set up, you can run the interactive Configure script and hand-pick the way this package is built. If you prefer instead to use the defaults that Perl auto-detects, prepare Perl for compilation with:

./configure.gnu --prefix=/usr \
   -Dvendorprefix=/usr \
   -Dman1dir=/usr/share/man/man1 \
   -Dman3dir=/usr/share/man/man3 \
   -Dpager="/bin/less -isR" \
   -Dcc="gcc ${BUILD32}" \
   -Dusethreads -Duseshrplib

The meaning of the configure option:

-Dpager="/bin/less -isR"

This corrects an error in the way that perldoc invokes the less program.

-Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3

Since Groff is not installed yet, configure.gnu thinks that we do not want man pages for Perl. Issuing these parameters overrides this decision.

-Dusethreads

This tells Perl to use threads.

-Duseshrplib

This tells Perl to build a shared libperl.

Compile the package:

make

To test the results, issue: make test.

Install the package:

make install

Add a suffix to the perl binary which will be used by the multiarch wrapper:

mv -v /usr/bin/perl{,-32}
mv -v /usr/bin/perl5.16.2{,-32}

Details on this package are located in Section 10.47.2, “Contents of Perl.”

10.47. Perl-5.16.2 64 Bit

The Perl package contains the Practical Extraction and Report Language.

10.47.1. Installation of Perl

By default, Perl's Compress::Raw::Zlib module builds and links against its own internal copy of Zlib. The following command will tell it to use the system-installed Zlib:

sed -i -e '/^BUILD_ZLIB/s/True/False/' \
       -e '/^INCLUDE/s,\./zlib-src,/usr/include,' \
       -e '/^LIB/s,\./zlib-src,/usr/lib64,' \
       cpan/Compress-Raw-Zlib/config.in

Perl does not, by default, know about library directories with names other than lib, The following patch will allow it to install to other directories:

patch -Np1 -i ../perl-5.16.2-Configure_multilib-1.patch

There is a further (possibly cosmetic) anomaly - if we install perl and then run perl -V it will claim that libc is in /lib. The following sed fixes this, but only takes effect when make install is run:

sed -i "/libc/s@/lib@/lib64@" hints/linux.sh

We still need to tell perl to actually use lib64:

echo 'installstyle="lib64/perl5"' >>hints/linux.sh

To have full control over the way Perl is set up, you can run the interactive Configure script and hand-pick the way this package is built. If you prefer instead to use the defaults that Perl auto-detects, prepare Perl for compilation with:

./configure.gnu --prefix=/usr \
   -Dvendorprefix=/usr \
   -Dman1dir=/usr/share/man/man1 \
   -Dman3dir=/usr/share/man/man3 \
   -Dpager="/bin/less -isR" \
   -Dlibpth="/usr/local/lib64 /lib64 /usr/lib64" \
   -Dcc="gcc ${BUILD64}" \
   -Dusethreads -Duseshrplib

The meaning of the new configure option:

-Dlibpth="/usr/local/lib64 /lib64 /usr/lib64"

This tells Perl to link against the 64-bit libraries.

-Dpager="/bin/less -isR"

This corrects an error in the way that perldoc invokes the less program.

-Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3

Since Groff is not installed yet, configure.gnu thinks that we do not want man pages for Perl. Issuing these parameters overrides this decision.

-Dusethreads

This tells Perl to use threads.

-Duseshrplib

This tells Perl to build a shared libperl.

Compile the package:

make

To test the results, issue: make test.

Install the package:

make install

Add a suffix to the perl binary which will be used by the multiarch wrapper:

mv -v /usr/bin/perl{,-64}
mv -v /usr/bin/perl5.16.2{,-64}

Now we need to create a link to the multiarch wrapper that lets us choose which perl installation to use:

ln -sv multiarch_wrapper /usr/bin/perl
ln -sv multiarch_wrapper /usr/bin/perl5.16.2

The value of the USE_ARCH environment variable will decide which perl binary to execute. USE_ARCH=32 perl -V:cc will give the value of CC used to build the 32bit perl. The multiarch_wrapper will help later with building perl extensions and bindings. Without the multiarch_wrapper it is very hard to setup a 32bit extension or binding.

10.47.2. Contents of Perl

Installed programs: a2p, c2ph, config_data, corelist, cpan, cpan2dist, cpanp, cpanp-run-perl, enc2xs, find2perl, h2ph, h2xs, instmodsh, json_pp, libnetcfg, perl, perl5.16.2 (link to perl), perlbug, perldoc, perlivp, perlthanks (link to perlbug), piconv, pl2pm, pod2html, pod2latex, pod2man, pod2text, pod2usage, podchecker, podselect, prove, psed (link to s2p), pstruct (link to c2ph), ptar, ptardiff, ptargrep, s2p, shasum, splain, xsubpp, and zipdetails
Installed libraries: Several hundred which cannot all be listed here
Installed directory: /usr/lib/perl5

Short Descriptions

a2p

Translates awk to Perl

c2ph

Dumps C structures as generated from cc -g -S

config_data

Queries or changes configuration of Perl modules

corelist

A commandline frontend to Module::CoreList

cpan

Shell script that provides a command interface to CPAN.pm

cpan2dist

The CPANPLUS distribution creator

cpanp

The CPANPLUS launcher

cpanp-run-perl

Perl script that (description needed)

enc2xs

Builds a Perl extension for the Encode module from either Unicode Character Mappings or Tcl Encoding Files

find2perl

Translates find commands to Perl

h2ph

Converts .h C header files to .ph Perl header files

h2xs

Converts .h C header files to Perl extensions

instmodsh

A shell script for examining installed Perl modules, and can even create a tarball from an installed module

json_pp

Converts data between certain input and output formats

libnetcfg

Can be used to configure the libnet

perl

Combines some of the best features of C, sed, awk and sh into a single swiss-army-knife language

perl5.16.2

A hard link to perl

perlbug

Used to generate bug reports about Perl, or the modules that come with it, and mail them

perldoc

Displays a piece of documentation in pod format that is embedded in the Perl installation tree or in a Perl script

perlivp

The Perl Installation Verification Procedure; it can be used to verify that Perl and its libraries have been installed correctly