Cross-Compiled Linux From Scratch

Version 1.0.0-Sparc64-Pure64

Jim Gifford

Ryan Oliver

Copyright (c) 2005, Jim Gifford & Ryan Oliver

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

i. 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 bought 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)
Jim Gifford, CLFS Project Co-leader
Ryan Oliver, CLFS Project Co-leader
Joe Ciccone, Justin Knierim, Chris Staub, Matt Darcy, Ken Moffat,
Manuel Canales Esparcia, and Nathan Coulson - CLFS Developers

ii. 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.

iii. 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:

iv. 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.17 are not recommended as they have not been tested)

  • Bzip2-1.0.2

  • Coreutils-5.0 (or Sh-Utils-2.0, Textutils-2.0, and Fileutils-4.1)

  • Diffutils-2.8

  • Findutils-4.1.20

  • Gawk-3.0

  • Gcc-2.95.3 (Versions greater than 4.1.1 are not recommended as they have not been tested)

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

  • Grep-2.5

  • Gzip-1.2.4

  • Make-3.79.1

  • Patch-2.5.4

  • Sed-3.0.2

  • Tar-1.14

To see whether your host system has all the appropriate versions, run the following:

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-4
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
/lib/libc.so.6 | head -n1 | cut -d" " -f1-7
grep --version | head -n1
gzip --version | head -n1
make --version | head -n1
patch --version | head -n1
sed --version | head -n1
tar --version | head -n1

EOF

bash version-check.sh

v. 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.

vi. Structure

This book is divided into the following parts.

vi.1. 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.

vi.2. Part II - Preparing for the Build

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

vi.3. 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.

vi.4. 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.

vi.5. 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.

vi.6. 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; Appendix B gives acknowledgments to people who have helped work on the CLFS project and website; Appendix C and D have information about package dependencies and the the build order. Some architectures may have additional appendices for arch-specific issues.

vii. 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/clfs/errata/1.0.0/ 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.

  • Jeremy Utley - Release Manager 1.x Series.

Our CLFS Team:

  • Joe Ciccone - Alpha, MIPS, Sparc builds.

  • Nathan Coulson - Bootscripts.

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

  • Manuel Canales Esparcia - Book XML.

  • Karen McGuiness - Proofreader.

  • 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.

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

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 the Linux From Scratch LiveCD. This CD works well as a host system, providing all the tools you need to successfully follow the instructions in this book. It does also contain source packages and patches for the LFS book, and a copy of the LFS book, but not the needed packages or book for CLFS. You can still use the CD for building CLFS, but you will need to download the packages, patches and book separately. You can also look at http://www.linuxfromscratch.org/hints/downloads/files/lfscd-remastering-howto.txt for infomation on building your own CD, replacing the LFS packages and book with those for CLFS. Once you have the CD, no network connection or additional downloads are necessary. For more information about the LFS LiveCD or to download a copy, visit http://www.linuxfromscratch.org/livecd/.

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.22, “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 1.0.0 of the Cross-Compiled Linux From Scratch book, dated September 21, 2006. 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:

  • September 18, 2006

    • [Chris] - Removed TeX installation commands from Texinfo instructions.

  • September 16, 2006

    • [jim] - Updated Udev-Cross-LFS rules to 1.0-3. Fixes bootup with /lib64/udev.

  • September 10, 2006

    • [jim] - Added a patch to fix Inetutils. Telnet on 64 bit systems will fail, it will attempt to connect to 255.255.255.255 instead of the ip address entered. This was due to a change in glibc's handling of inet_addr, was long now is u_int32_t. Bug found by Vladimir Vainer.

    • [jim] - Add patch to fix gzexe. Used Matts change from LFS, that utilizes Robert's fix. More details at http://wiki.linuxfromscratch.org/lfs/ticket/1876.

    • [Chris] - Added Host System Requiremets page, and added more info to the "To Boot or Chroot?" page about needing a 2.6.x Linux kernel to chroot.

  • September 9, 2006

    • [jim] - Updated Linux to 2.6.17.13 and Linux Headers to 2.6.17.13-09092006.

  • September 8, 2006

    • [jim] - Fixed Perl Testsuite Network tests.

  • September 7, 2006

    • [jim] - Updated Multilib Tree to follow build standards set in the book.

    • [jim] - Updated copy commands in Linux Headers, simpler and cleaner.

  • September 6, 2006

    • [jim] - UDEV Rules - On multilib builds, change /lib/udev to /lib64/udev, to keep consistency through the system.

    • [jim] - Removed sed from tcl, not required.

    • [jim] - Replace Perl FPIC patch with a sed, to make sure fpic is set correctly.

  • September 5, 2006

    • [jim] - UDEV - On multilib builds, change /lib/udev to /lib64/udev, to keep consistency through the system.

    • [jim] - IPRoute2 - On multilib builds, change /usr/lib/tc to /usr/lib64/tc, to keep consistency through the system.

  • August 28, 2006

    • [jim] - Renamed Cross-LFS Bootscripts 0.4 to 1.0, for the release. No changes made to the scripts.

    • [jim] - Renamed Cross-LFS Udev Rules 0.1-07062006 to 1.0, for the release. No changes made to the rules.

  • August 27, 2006

    • [jim] - Updated to Cross-LFS Bootscripts 0.4.

  • August 23, 2006

    • [jim] - Updated Linux to 2.6.17.11 and Linux Headers to 2.6.17.11-08232006.

    • [jim] - Updated Linux to 2.6.17.10 and Linux Headers to 2.6.17.10-08232006.

  • August 21, 2006

    • [jciccone] - Added a multilib perl setup that has a multilib wrapper. The multilib wrapper checks for the value of PERL_ARCH and executes the cooresponding perl binary.

    • [ken] - Remove include/net from instructions for headers.

  • August 20, 2006

    • [jciccone] - Added the Perl fPIC patch which makes perl build a shared DynaLoader.a.

    • [Chris] - Removed mention of package users hint from "Package Management" page.

    • [jim] - Updated Linux to 2.6.17.9 and Linux Headers to 2.6.17.9-08202006.

    • [jim] - Added Linux Tulip Patch to all Linux 2.6.17.9 builds. Fixes an initialization error.

  • August 8, 2006

    • [jim] - Moved man-pages to the beginning of the build. (fixes ticket #82).

    • [jim] - Updated the wording of Bzip2, changes were made to MIPS but not the other multilib architectures. Updated for all architectures now (fixes ticket #79).

  • August 7, 2006

    • [Chris] - Updated udev explanatory text in the book and added "Custom Symlinks" page, taken from LFS. Thanks to Alexander Patrakov for the updated text (fixes ticket #75).

  • August 3, 2006

    • [ken] - Fixed the temporary bash to correct a failure in the Glibc testsuite, (fixes ticket #78). Thanks to Go Moko.

  • July 27, 2006

    • [jim] - Fixed symlink issue in bootscripts. New Package CLFS-bootscripts 0.3.

  • July 25, 2006

    • [jim] - Symlinks /tools/bin/file to /usr/bin/file for the GCC testsuite.

  • July 24, 2006

    • [Chris] - Updated commands for building the keymap into the kernel - changed the bootable/kernel page to account for the new keymap files location, and changed the instructions in the "boot" section to reflect that fact that we don't know where the keymap files may be on the host (fixes ticket #56).

  • July 20, 2006

    • [jim] - Updated to linux-2.6.17.6 and linux-headers-2.6.17.6-07202006.

    • [jim] - Updated to Udev 096.

  • July 17, 2006

    • [jeremy] - Minor foreword fixups courtesy of Karen.

  • July 16, 2006

    • [Chris] - Removed unneeded chown and chmod commands from final-system linux-headers installation.

    • [Chris] - Added a sed command to fix updatedb due to the new location for the find program.

  • July 14, 2006

    • [jeremy] - Updated to new foreword

  • July 11, 2006

    • [jim] - Updated to linux-headers-2.6.17.4-07112006.

  • July 9, 2006

    • [jim] - Updated to linux-headers-2.6.17.4-07092006.

  • July 8, 2006

    • [jim] - Updated to linux-2.6.17.4 and linux-headers-2.6.17.4-07072006.

    • [Chris] - Removed many "${CLFS}" references from explanatory text in boot section.

  • July 7, 2006

    • [Chris] - Modified the "creating directories" sections - changed multilib instructions to be consistent with the new format now used for every other arch, and changed mips instructions to use xincludes.

  • July 6, 2006

    • [jim] - Updated Udev rules to 07062006, Fixed cdrom, permissions and groups.

  • July 5, 2006

    • [jim] - Fixes a possible issue with bootscripts if the the /usr partition is not mounted during startup. Moved find to /bin and moved some kbd utilities to /bin.

  • July 4, 2006

    • [jim] - Updated the Grub patch to fix various issues, see text of patch for more details.

  • July 2, 2006

    • [Chris] - Updated passwd and group file creation to only create minimal users and groups and include information on other users/groups.

    • [jim] - Added file to Testsuite tools, required for gcc tests.

  • July 1, 2006

    • [jim] - Updated the build to use CLFS in variables instead of LFS. Also change /mnt/lfs to /mnt/clfs.

  • June 29, 2006

    • [jim] - Updated Temp-System and Boot builds to be more consistant. Added --build=${LFS_HOST}, where possible.

    • [jim] - Updated to Cross-LFS Bootscripts. Added check for for /etc/sysconfig/createfiles.

  • June 27, 2006

    • [jim] - Updated to linux-headers-2.6.17.1-06272006.

  • June 25, 2006

    • [jciccone] - Updated to linux-headers-2.6.17.1-06252006.

  • June 24, 2006

    • [jeremy] - Release of 1.0.0-rc1

  • June 23, 2006

    • [jim] - Updated Binutils 2.17.

    • [jim] - Updated Cross-LFS Specific Packages and Patches links for Release.

  • June 22, 2006

    • [jim] - Added mktemp to Linux dependency list. New dependency as of 2.6.17.

    • [jim] - Updated Vim 7.0 patch.

  • June 21, 2006

    • [Chris] - Text updates to the book, including replacing "LFS" with "CLFS".

    • [jim] - Updated to linux-headers-2.6.17.1-06212006-1.

    • [jim] - Updated Vim 7.0 patch.

  • June 20, 2006

    • [jeremy] - Corrected e2fsprogs installation in the boot section, to take into account the new mke2fs.conf file.

    • [jciccone] - Updated to linux-2.6.17.1 and linux-headers-2.6.17.1-06202006.

    • [jim] - Updated to linux-headers-2.6.17.1-06202006-1.

  • June 19, 2006

    • [jciccone] - Updated to man-1.6d.

    • [jciccone] - Added an iconv_fix patch to glibc which fixes an issue that has shown up primarily in samba.

    • [jciccone] - Updated to linux-2.6.17 and linux-headers-2.6.17-06192006.

  • June 15, 2006

    • [jim] - Let Perl use thread support.

  • June 14, 2006

    • [jim] - Updated to Binutils 2.16.94.

  • June 10, 2006

    • [Chris] - Updates to lists of installed programs for several packages.

    • [Ken] - Fixed the module-init-tools install in the presence of existing files. Thanks to Manuel for pointing me to the fix in LFS, and to Dan Nicholson for the fix.

  • June 9, 2006

    • [jim] - Updates to Shadow 4.0.16 build instructions.

    • [jim] - Updated to Linux Headers 2.6.16.20 to 06092006.

  • June 7, 2006

    • [jim] - Updated to Shadow 4.0.16.

  • June 6, 2006

    • [Chris] - Added many more -v switches for verbosity.

  • June 5, 2006

    • [jim] - Updated to linux-2.6.16.20, and linux-headers-2.6.16.20.

    • [jim] - Updated to Bison 2.3.

  • June 4, 2006

    • [Chris] - Removed obsolete paragraph about "resetting" passwords when using pwconv from Shadow instructions.

    • [jim] - Updated to Linux Headers 2.6.16.19 to 06042006.

  • June 1, 2006

    • [Chris] - Updated list of installed programs for several packages.

  • May 31, 2006

    • [ken] - Removed redundant chown of /usr/share/libtool/libltdl.

    • [jim] - Updated to linux-2.6.16.19, and linux-headers-2.6.16.19.

  • May 30, 2006

    • [jim] - Added a patch to fix a missing declaration of R_OK in util-linux.

    • [Chris] - Removed the long-gone swapdev program from the list of programs installed by util-linux, and several programs not installed by default from the kbd program list.

    • [jim] - Updated to E2fsprogs 1.39.

    • [jim] - Updated to Man-Pages 2.33.

  • May 29, 2006

    • [jim] - Updated to Binutils 2.16.93.

    • [jim] - Updated to UDEV 093.

    • [jim] - Updated Udev Rules to 0.1-05292006.

    • [jim] - Updated Linux Headers 2.6.16.18 to 05292006.

  • May 28, 2006

    • [jim] - Added a patch to Grub to prevent. Error 24: Attempt to access block outside partition.

  • May 25, 2006

    • [jim] - Updated to GCC 4.1.1.

    • [jim] - Add Vim 7.0 Upstream Patches.

  • May 22, 2006

    • [jim] - Updated to Coreutils 5.96.

    • [jim] - Updated linux-2.6.16.18, and linux-headers-2.6.16.18.

  • May 21, 2006

    • [jciccone] - Updated to Bison-2.2, linux-2.6.16.17, and linux-headers-2.6.16.17.

  • May 17, 2006

    • [Chris] - Made a number of text updates and grammar fixes and added more dependency info (bootscripts, udev-rules, tree) to Appendix C.

  • May 16, 2006

    • [Chris] - Changed the temp-system and final-system package build order and a few package build instructions to account for the changed order (the rest of ticket #26).

    • [ken] - Change name of coreutils patch to match the patch.

  • May 15, 2006

    • [jim] - Updated to Man-Pages 2.32.

  • May 14, 2006

    • [jim] - Updated Udev Rules to 0.1-05142006.

    • [jim] - Updated Linux Headers 2.6.16.16 to 05142006.

  • May 13, 2006

    • [jim] - Updated to Coreutils 5.95.

  • May 12, 2006

    • [jim] - Add Vim 7.0 Upstream Patches.

  • May 11, 2006

    • [jim] - Updated Linux and Linux Headers to 2.6.16.16.

    • [jim] - Add Vim 7.0 Upstream Patches.

  • May 10,2006

    • [Chris] - Added more detailed dependency info and moved it to Appendices C and D. Fixes half of ticket #26.

  • May 9, 2006

    • [jim] - Updated to Binutils 2.16.92.

    • [jim] - Updated to Vim 7.0.

    • [jciccone] - Updated to Linux 2.6.16.15.

  • May 7, 2006

    • [jim] - Updated Linux Headers 2.6.16.14 to 05072006.

  • May 6, 2006

    • [jciccone] - Updated Linux Headers 2.6.16.14 to 05062006.

  • May 4, 2006

    • [jim] - Updated to Linux-2.6.16.14.

    • [jim] - Updated Linux Headers 2.6.16.13 to 05042006.

  • May 3, 2006

    • [Chris] - Updated to Man-Pages 2.31.

    • [jim] - Updated to Linux-2.6.16.13.

    • [jim] - Updated to Iana-Etc 2.10.

  • May 2, 2006

    • [jim] - Updated Linux Headers 2.6.16.12 to 05022006.

    • [jim] - Reverted change to bash. Needed on some architectures.

    • [jim] - Fixed a coreutils cross-compile issues on some architectures.

  • May 1, 2006

    • [Chris] - Updated to Man-Pages 2.30.

    • [jim] - Updated Linux Headers 2.6.16.11 to 05012006.

    • [Chris] - Updated to Linux-2.6.16.12.

  • April 30, 2006

    • [jim] - Updated Linux Headers 2.6.16.11 to 04302006.

  • April 29, 2006

    • [ken] - Add asm-generic to headers which are chowned in non-multilib books.

  • April 28, 2006

    • [jim] - Updated Linux Headers 2.6.16.11 to 04282006.

    • [jim] - Updated Udev Rules to 0.1-04282006.

  • April 27, 2006

    • [jim] - Updated to Linux Headers 2.6.16.11 to 04272006.

  • April 25, 2006

    • [jim] - Updated to Udev 091.

    • [jim] - Updated to Linux Headers 2.6.16.11 to 04262006.

  • April 24, 2006

    • [ken] - Updated to iproute2-2.6.16-060323.

    • [jim] - Updated to Linux and Linux Headers 2.6.16.11.

  • April 22, 2006

    • [ken] - Add example commands to test if chroot is possible, thanks to William Zhou.

  • April 21, 2006

    • [jim] - Updated Linux-Headers to fix x86_64-biarch problem.

  • April 20, 2006

    • [jim] - Added missing asm-generic copy to Linux-Headers.

    • [jim] - Updated Linux-Headers to include nvram.h.

  • April 19, 2006

    • [jim] - Updated to Bash Patch -8.

    • [jim] - Removed Linux-Libc-Headers and replace it with our Linux-Headers package.

    • [jim] - Updated to Linux 2.6.16.9.

    • [jim] - Updated to Linux 2.6.16.8.

  • April 18, 2006

    • [jim] - Renamed gcc fold_const patch to the PR #.

    • [jim] - Added GCC 4.1.0 patch PR20425. This allows searching of multilib dirs for the specs file.

  • April 17, 2006

    • [Chris] - Removed sed command from temp-system bash - no longer needed for Bash 3.1.

    • [jim] - Updated to Udev 090.

    • [jim] - Updated to udev-rules 0.1-04172006.

    • [jciccone] - Added a gcc patch that fixes an optimaztion error which can result in incorrect code.

    • [jciccone] - Removed the util-linux and kernel patch that fixes the checksum calculation for sun disklabels.

  • April 14, 2006

    • [jciccone] - Added a security patch to tar.

    • [jciccone] - Added a util-linux and kernel patch to fix a checksum calculation issue for sun disklabels.

  • April 13, 2006

    • [jim] - Updated to GCC 4.1.0.

    • [jim] - Fixed make install-minimal in udev-rules.

    • [jim] - Updated to Linux 2.6.16.5.

  • April 12, 2006

    • [jim] - Updated to Glibc 2.4.

    • [jim] - Updated to latest bash patch -7.

  • April 10, 2006

    • [jim] - Changed numbering of udev-rules to use 0.1-SVNDATE.

  • April 6, 2006

    • [jim] - Added install-minimal to udev rules.

    • [jim] - Updated to Udev 089.

  • April 1, 2006

    • [jim] - Updated to Make 3.81.

    • [jim] - Updated to Man-Pages 2.28.

  • March 28, 2006

    • [jim] - Updated to Linux 2.6.16.1.

    • [jim] - Updated to Man-Pages 2.27.

  • March 27, 2006

    • [jciccone] - Updated coreutils suppress_uptime_kill_su patch to -2.

    • [jciccone] - Updated readline fixes patch to -3.patch.

    • [jciccone] - Updated bash fixes patch to -6.

  • March 22, 2006

    • [jim] - Updated Udev to build floppy helper.

  • March 21, 2006

    • [jim] - Updated to Udev 088.

    • [jim] - Updated to Man-Pages 2.26.

    • [jim] - Updated to IPRoute2 2.6.15-060110.

  • March 20, 2006

    • [jim] - Fixed build issue with Texinfo in temp-system. Added --build.

    • [jim] - Updated to Linux 2.6.16.

    • [jim] - Updated to Shadow 4.0.15.

    • [Chris] - Removed note about GCC 2.95.3 from kernel section, as documentation has been updated in linux-2.6.16 and it now recommends GCC >= 3.2.

  • March 15, 2006

    • [jim] - Changed bootscripts to CLFS-bootscripts 0.1.

    • [jim] - Updated to Psmisc 22.2.

    • [jim] - Updated to Flex 2.5.33.

  • March 14, 2006

    • [jim] - Updated to Linux 2.6.16-rc6.

    • [jim] - Removal of Hotplug.

    • [jim] - Updated to Udev 087.

    • [jim] - Removal of old udev rules.

    • [jim] - Added Udev-Cross-LFS 0.1.

    • [jim] - Updated to GCC 4.0.3.

    • [jim] - Updated to File 4.17.

  • March 13, 2006

    • [jciccone] - Removed pure64 bootloader warning from the top page.

  • March 9, 2006

    • [Chris] - Simplified IPRoute2 instruction by removing redundant "configure" command.

  • March 2, 2006

    • [Chris] - Updated to Man-Pages 2.25.

    • [Chris] - Reverted to Expect 5.43.0. 5.44.1 depends on Tk.

  • February 27, 2006

    • [jim] - Updated Bash fixes patch to -5.

  • February 26, 2006

    • [jim] - Updated to Expect 5.44.1.

  • February 23, 2006

    • [Chris] - Simplified the "Changing Ownership" page for the boot section, and rewrote some of the text in the final "Reboot" page.

  • February 21, 2006

    • [jim] - Removed Dependency of Tempfile from Bzip2.

    • [jim] - Updated Bash fixes patch to -4.

    • [jciccone] - Updated to Man-Pages 2.24

  • February 14, 2006

    • [jim] - Updated to Coreutils 5.94.

  • February 11, 2006

    • [Chris] - Added -v switches to commands that accept it.

  • February 9, 2006

    • [jim] - Updated to Man-Pages 2.23.

  • February 8, 2006

    • [jim] - Changed x86_64 to use unknown in the target triplet.

  • February 7, 2006

    • [Chris] - Removed inetutils from boot section - it will be covered in the "netboot" hint.

    • [Chris] - Added section on Package Management - moved out of BLFS.

  • February 6, 2006

    • [Chris] - Moved the text explaining why binutils should be the first package compiled to a more appopriate location at the first installation of binutils, and changed the wording in temp-system gettext.

    • [jim] - Updated Readline and Bash patches from Upstream.

  • February 5, 2006

    • [jim] - Updated Procps 32bit build in Multilib builds to use lib64=lib. Fixed via Trac Ticket #2.

    • [jim] - Updated to Man-Pages 2.22.

  • February 3, 2006

    • [jim] - Updated to Sed 4.1.5.

  • February 2, 2006

    • [jim] - Updated to Perl 5.8.8.

    • [jhuntwork] - Minor textual fix to GCC.

  • February 1, 2006

    • [Chris] - Added a sed substitution to man instructions to fix an error in the makewhatis script.

  • January 31, 2006

    • [Chris] - Added -v to commands that accept them, for consistency with LFS.

  • January 30, 2006

    • [jim] - Change final-system GCC, to use make bootstrap. Update provided by Ryan Oliver.

  • January 29, 2006

    • [jim] - Updated Toolchain adjustment in final-system. Thank you Dan Nicholson.

  • January 24, 2006

    • [jim] - Updated to Man 1.6c.

  • January 23, 2006

    • [Chris] - Removed unnecessary --with-ncurses switches from temp-system bash and inetutils.

    • [Chris] - Moved zlib from temp-system to boot as it's not needed if you chroot.

  • January 19, 2006

    • [Chris] - Removed patch from shadow instructions.

    • [Chris] - Added perl sprintf vulnerability patch.

    • [jim] - Updated to Man-Pages 2.21.

  • January 13, 2006

    • [ken] - Moved grep ahead of libtool to avoid /tools being hardcoded into the libtool script for EGREP.

    • [ken] - Alter bison to build repeatably, from LFS.

    • [ken] - Alter gccbug to use mktemp, from LFS.

    • [ken] - Move creation of /etc/hosts within Perl instructions, for repeatability, from LFS.

    • [Chris] - Moved bootloader setup to right after "Changing Ownership" in Chapter 7, and changed several package installation instructions in that chapter.

  • January 12, 2006

    • [Chris] - Moved directory and symlink creation pages to the beginning of Chapter 7.

    • [jim] - Updated to Psmisc 22.1.

    • [jim] - Updated to Man-Pages 2.20.

    • [jim] - Updated Coreutils build instructions to copy more files to /bin. These are changes for bootscripts and the new udev rules.

    • [jim] - Updated to Linux 2.6.14.6.

    • [jim] - Numerous complaints about temp-system Perl failing to build. So I moved temp perl to first package in final-system build. The failures we noted on Pure 64 builds.

  • January 11, 2006

    • [jim] - Rewrote wrote zlib final instructions to include a patch the will allow build of static and shared libraries at the same time. Thanx for the recommendation Tushar Teredesai.

  • January 8, 2006

    • [Chris] - Rewrote much of the description of the build process and test suite information.

  • January 3, 2006

    • [jim] - Updated to Shadow 4.0.14.

  • December 30, 2005

    • [Chris] - Updated package dependencies, removed explanation of "target alias" and "cross-compiling" from final-system binutils, and removed note about GRUB's testsuite failure.

    • [ken] - Fix where tree gets installed.

  • December 29, 2005

    • [jim] - Added CC="gcc" to temp-system perl build.

  • December 28, 2005

    • [ken] - Remove --with-x=no from expect - either we booted, or we are in chroot.

    • [ken] - Fix a failure to build glibc-headers.

    • [jim] - Updated to Linux 2.6.14.5.

  • December 23, 2005

    • [jim] - Updated Shadow patch to fix linking to outside libraries.

  • December 22, 2005

    • [jim] - Bash Maintainer Released Bash-001 patch. This patch fixes the following issue: There are parsing problems with compound assignments in several contexts, including as arguments to builtins like `local', `eval', and `let', and as multiple assignments in a single command.

    • [jim] - Readline Maintainer Released Readline-001 patch. This patch fixes the following issue: A problem with the readline callback interface can result in segmentation faults when using the delete-char function via a multiple-key sequence. Two consecutive calls to delete-char will crash the application calling readline.

    • [jim] - Removed halt, sync, and shutdown users. These users work, but offer a potential security threat. Thus the reason for removal.

    • [jim] - Fixed Vim symlink. Thank you LFS and Jeremy Huntwork.

  • December 20, 2005

    • [jim] - Updated to M4 1.4.4.

  • December 19, 2005

    • [ken] - Fix for accessing vim's documentation, from LFS.

    • [jim] - Fixed the Gettext testsuite from failing, by fixing an issue in Gawk. Thank you Greg Schaefer.

  • December 18, 2005

    • [jim] - Re-arranged temp-tools. Renamed it to testsuite-tools. Moved perl and texinfo to temp-system. Moved flags from testsuite-tools to chroot and boot sections.

    • [jim] - Removed 32bit and N32 builds from temp-system, upon testing it was found that these were not needed for building the final system on a multilib capable build.

    • [jim] - Updated to Libtool 1.5.22.

    • [jim] - Updated to Man-Pages 2.18.

  • December 17, 2005

    • [jim] - Updated to psmisc 21.9.

  • December 16, 2005

    • [jim] - Moved Tree to temp-tools, since it's not needed for the final-system.

    • [jim] - Moved Procps before perl in the final-system build. Fixes test suite issue in perl.

  • December 15, 2005

    • [ken] - Minor fix for rendering in temp-tools/texinfo.

    • [jim] - Added not to temp-system about the WARNING message.

  • December 14, 2005

    • [jim] - Change the CLFS_HOST and CLFS_TARGET pages to prevent further build issues.

    • [jim] - Updated to Man-Pages 2.17.

    • [jim] - Added Tree 1.5.0. Added for the udev testsuite.

  • December 13, 2005

    • [jim] - Removed setvbuf test from Temp-System Bash compile. Thanks to David Fix.

  • December 12, 2005

    • [jim] - Removed testsuites from Temp-Tools section.

  • December 11, 2005

    • [ken] - Fix Tcl configure, thanks to Greg Schafer.

  • December 9, 2005

    • [jim] - Upgraded to Module Init Tools 3.2.2.

    • [ken] - Bzip2 - clarify what is being tested.

    • [jim] - Removed installation of sound sanitized headers. They will be removed in the next release of linux-libc-headers.

  • December 8, 2005

    • [jim] - Upgraded to Less 394.

    • [jim] - Upgraded to Bash 3.1.

    • [jim] - Upgraded to Readline 5.1.

  • December 7, 2005

    • [jim] - Upgraded to TCL 8.4.12.

    • [jim] - Upgraded to IPRoute2 2.6.14-051107.

    • [jim] - Upgraded to Readline 5.0.5.

    • [jim] - Upgraded to Bash 3.0.16.

  • December 6, 2005

    • [jim] - Upgraded to Glibc 20051107.

    • [jim] - Sparcv8 now uses the same Glibc as the other architectures.

    • [jim] - Ported Gettext update from Temp-system LFS to Cross-LFS.

    • [ken] - Tidying in Gettext to reflect our differences from LFS, and correct the date in changelog.

    • [jim] - Moved Cross-tools from $HOME to LFS. This provide a easy way for livecd builders to not loose valueable build time, if something goes wrong.

    • [jim] - Upgraded to Findutils 4.2.27.

  • December 5, 2005

    • [Matt Darcy] - Updated the resources page to include reference and base instructions on using the LFS pastebin

    • [Matt Darcy] - Updated some of the missing text poritions of the book

    • [Matt Darcy] - Updated creation of $CLFSHOME parameter to a less user error system. This change will will need to be validated by by other devs

    • [ken] - Moved Mktemp ahead of Module-init-tools so that the latter's testsuite doesn't bail out when testing generate-modprobe.conf.

  • December 3, 2005

    • [ken] - Reference a home directory for dummy user when testing coreutils, and correct sed 'man page' to 'HTML documentation', both from LFS.

  • December 2, 2005

    • [jim] - Updated to Man-Pages 2.16.

  • December 1, 2005

    • [jim] - Updated to Linux 2.6.14.3.

    • [jim] - Updated to Man-Pages 2.15.

    • [jim] - Updated to Udev 076.

    • [jim] - Added support for Sparc v8 and below.

  • November 30, 2005

    • [jim] - Text updates to final-system.

    • [jim] - Text updates to temp-tools.

  • November 29, 2005

    • [jim] - Text updates to chroot.

    • [jim] - Text updates to boot.

  • November 28, 2005

    • [jim] - Text updates to glibc in all sections.

    • [jim] - Text updates to temp-system.

    • [jim] - Fixed duplicated gcc configure line in gcc. Thank you Dennis Perkins.

  • November 27, 2005

    • [jim] - Text updates to gcc in all sections.

    • [jim] - Updates to Ncurses, added curses file and link. Thank you G. Moko.

  • November 25, 2005

    • [jim] - Text updates to binutils in all sections.

  • November 24, 2005

    • [Matt Darcy] - Text updates to resources page

    • [Matt Darcy] - Updated reference to LFS news server to reflect that it no longer exists

  • November 23, 2005

    • [jim] - For inetutils to utilize the Ncurses headers in /tools/include.

  • November 21, 2005

    • [jim] - Updated to Udev 075.

    • [jim] - Updated to Module Init Tools 3.2.1.

  • November 20, 2005

    • [jim] - Updated to Findutils 4.2.26.

  • November 18, 2005

    • [manuel] - Fixed the unpack of the module-init-tools-testsuite package.

  • November 17, 2005

    • [jim] - Update to Man-Pages 2.14.

    • [jim] - Update to Linux 2.6.14.2. This includes changes for the MIPS Architecture. New Patch added.

    • [jim] - Added change to move /usr/bin/less to /bin/less.

  • November 13, 2005

    • [manuel] - Improve the heuristic for determining a locale that is supported by both Glibc and packages outside LFS. Ported from LFS-SVN.

    • [manuel] - Omit running Bzip2's testsuite as a separate step, as make runs it automatically. Ported from LFS-SVN.

    • [jim] - Updated TCL build to install headers. Thank you Greg Schafer.

    • [jim] - Updated Expect to use the newly relocated TCL Headers. Thank you Greg Schafer.

  • November 10, 2005

    • [ken] - Added Data/Dumper to temp perl modules, for coreutils testsuite. Ported from LFS-SVN.

    • [ken] - Removed POSIX VERSION information from coreutils page Thank you G Moko.

    • [jim] - Added text for multilib kernel build requirements.

  • November 9, 2005

    • [manuel] - Stop Udev from killing udevd processes on the system and removed udevdir=/dev. Ported from LFS-SVN.

    • [manuel] - Install the binaries from Less to /usr/bin instead of /bin. Ported from LFS-SVN.

    • [manuel] - Removed SBUs and disk usage information.

    • [jim] - Added missing utmp group. Thank you William Zhou.

  • November 8, 2005

    • [jim] - Removed make headers -C bfd from Binutils. Thank you Robert Day.

  • November 7, 2005

    • [manuel] - Remove the optimization related warnings from the toolchain packages. Ported from LFS-SVN.

    • [manuel] - Install Vim's documentation to /usr/share/doc/vim-7.0 instead of /usr/share/vim/vim64/doc. Ported from LFS-SVN.

    • [manuel] - Correct the instructions for running the Module-Init-Tools' testsuite. Ported from LFS-SVN.

    • [jim] - Removed unnecessary linking libc sed in gcc-final in cross-tools. Recommendation from Erik-Jan, via cross-lfs list.

  • November 6, 2005

    • [jim] - Updated to Coreutils 5.93.

    • [jim] - Updated to Procps 3.2.6.

    • [jim] - Updated to Man-Pages 2.13.

  • November 5, 2005

    • [jim] - Updated to psmisc 21.8.

  • November 3, 2005

    • [jim] - Fixes added to coreutils. Coreutils was install locales to /locale. Added fixes for dircolors and md5sum also.

  • October 31, 2005

    • [jim] - Now an official project. Resetting all Changelogs.

Branch Synced from the Release of LFS 6.0 on February 23rd, 2005

1.4. Changelog for Sparc64-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:

  • June 25, 2006

    • [jim] - Added Generic Information to Build Variables. Reverted due to problems with GCC compile. We have to specify -mcpu=ultrasparc.

  • May 1, 2006

    • [jim] - Updated GCC to fix TLS issue with Sparc64 builds.

  • March 9, 2006

    • [jim] - Updated to Silo 1.4.11.

  • March 6, 2006

    • [jciccone] - Added a silo patch to fix 64bit build issues.

  • February 11, 2006

    • [jim] - Re-added GCCTARGET to Sparc64 builds.

  • November 8, 2005

    • [jim] - Added patch to fix Binutils Sparc aout usage.

    • [jim] - Elftoaout 64bit fixes are in place, we can now build Silo using a 64bit elftoaout. Thank you to the Linux-Sparc list, especially Dave Miller.

  • October 31, 2005

    • [jim] - Now an official project. Resetting all Changelogs.

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 it's own News Server, but we do provide access via gmane.org http://gmane.org. If you want to subscribe to the Cross-LFS via a newsreader you can utilize gmane.org. You can find the game 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://www.linuxfromscratch.org/hints/downloads/files/errors.txt.

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 1.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 your 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 1.5 gigabytes (GB). This is enough to store all the source tarballs and compile the packages. However, if the CLFS system is intended to be the primary Linux system, additional software will probably be installed which will require additional space (2-3 GB). 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.

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.

On a Sparc system we have to create an special partition first. This partition is called “Whole disk”, and must be the 3rd partition on the disk.

The other partitions are virtual slices of this “Whole disk” partition. But there are some limitations on the first partion of hda or sda on the system. This partition must be less than 2 gigabytes and this partition must be root.

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://www.linuxfromscratch.org/blfs/view/svn/postlfs/filesystems.html.

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.39.tar.bz2
cd e2fsprogs-1.39
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.39

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/1.0.0/.

Downloaded packages and patches will need to be stored somewhere that is conveniently available throughout the entire build. A working directory is also required to unpack the sources and build them. ${CLFS}/sources can be used both as the place to store the tarballs and patches and as a working directory. By using this directory, the required elements will be located on the CLFS partition and will be available during all stages of the building process.

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

3.2. All Packages

Download or otherwise obtain the following packages:

Autoconf (2.59) - 904 KB:

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

Download: http://ftp.gnu.org/gnu/autoconf/autoconf-2.59.tar.bz2

MD5 sum: 1ee40f7a676b3cfdc0e3f7cd81551b5f

Automake (1.9.6) - 748 KB:

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

Download: http://ftp.gnu.org/gnu/automake/automake-1.9.6.tar.bz2

MD5 sum: c11b8100bb311492d8220378fd8bf9e0

Bash (3.1) - 2,475 KB:

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

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

MD5 sum: ef5304c4b22aaa5088972c792ed45d72

Bash Documentation (3.1) - 2,013 KB:

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

MD5 sum: a8c517c6a7b21b8b855190399c5935ae

Binutils (2.17) - 13,496 KB:

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

Download: http://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2

MD5 sum: e26e2e06b6e4bf3acf1dc8688a94c0d1

Bison (2.3) - 1,060 KB:

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

Download: http://ftp.gnu.org/gnu/bison/bison-2.3.tar.bz2

MD5 sum: c18640c6ec31a169d351e3117ecce3ec

Bzip2 (1.0.3) - 654 KB:

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

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

MD5 sum: 8a716bebecb6e647d2e8a29ea5d8447f

CLFS-Bootscripts (1.0) - 28 KB:

Download: http://cross-lfs.org/files/packages/1.0.0/bootscripts-cross-lfs-1.0.tar.bz2

MD5 sum: 79bff3247411589d7de51fdaea9578bd

Coreutils (5.96) - 4,960 KB:

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

Download: http://ftp.gnu.org/gnu/coreutils/coreutils-5.96.tar.bz2

MD5 sum: bf55d069d82128fd754a090ce8b5acff

DejaGNU (1.4.4) - 1,056 KB:

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

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

MD5 sum: 053f18fd5d00873de365413cab17a666

Diffutils (2.8.7) - 1,034 KB:

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

Download: ftp://alpha.gnu.org/gnu/diffutils/diffutils-2.8.7.tar.gz

MD5 sum: 18d6587cb915e7aa110a5d463d6ed156

E2fsprogs (1.39) - 3,612 KB:

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

Download: http://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs-1.39.tar.gz?download

MD5 sum: 06f7806782e357797fad1d34b7ced0c6

Expect (5.43.0) - 514 KB:

Home page: http://expect.nist.gov

Download: http://expect.nist.gov/src/expect-5.43.0.tar.gz

MD5 sum: 43e1dc0e0bc9492cf2e1a6f59f276bc3

File (4.17) - 544 KB:

Download: ftp://ftp.gw.com/mirrors/pub/unix/file/file-4.17.tar.gz

MD5 sum: 50919c65e0181423d66bb25d7fe7b0fd

Note

File (4.17) 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/1.0.0/.

Findutils (4.2.27) - 1,097 KB:

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

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

MD5 sum: f1e0ddf09f28f8102ff3b90f3b5bc920

Flex (2.5.33) - 680 KB:

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

Download: http://prdownloads.sourceforge.net/flex/flex-2.5.33.tar.bz2?download

MD5 sum: 343374a00b38d9e39d1158b71af37150

Gawk (3.1.5) - 1,716 KB:

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

Download: http://ftp.gnu.org/gnu/gawk/gawk-3.1.5.tar.bz2

MD5 sum: 5703f72d0eea1d463f735aad8222655f

GCC (4.1.1) - 38,300 KB:

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

Download: http://ftp.gnu.org/gnu/gcc/gcc-4.1.1/gcc-4.1.1.tar.bz2

MD5 sum: ad9f97a4d04982ccf4fd67cb464879f3

Gettext (0.14.5) - 6,940 KB:

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

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

MD5 sum: e2f6581626a22a0de66dce1d81d00de3

Glibc (2.4) - 14,847 KB:

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

Download: http://ftp.gnu.org/gnu/glibc/glibc-2.4.tar.bz2

MD5 sum: 7e9a88dcd41fbc53801dbe5bdacaf245

Grep (2.5.1a) - 516 KB:

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

Download: http://ftp.gnu.org/gnu/grep/grep-2.5.1a.tar.bz2

MD5 sum: 52202fe462770fa6be1bb667bd6cf30c

Groff (1.19.2) - 2,836 KB:

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

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

MD5 sum: f7c9cf2e4b9967d3af167d7c9fadaae4

Gzip (1.3.5) - 324 KB:

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

Download: ftp://alpha.gnu.org/gnu/gzip/gzip-1.3.5.tar.gz

MD5 sum: 3d6c191dfd2bf307014b421c12dc8469

Iana-Etc (2.10) - 184 KB:

Home page: http://www.sethwklein.net/projects/iana-etc/

Download: http://www.sethwklein.net/projects/iana-etc/downloads/iana-etc-2.10.tar.bz2

MD5 sum: 53dea53262b281322143c744ca60ffbb

Inetutils (1.4.2) - 1019 KB:

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

Download: http://ftp.gnu.org/gnu/inetutils/inetutils-1.4.2.tar.gz

MD5 sum: df0909a586ddac2b7a0d62795eea4206

IPRoute2 (2.6.16-060323) - 378 KB:

Home page: http://linux-net.osdl.org/index.php/Iproute2

Download: http://developer.osdl.org/dev/iproute2/download/iproute2-2.6.16-060323.tar.gz

MD5 sum: f31d4516b35bbfeaa72c762f5959e97c

Kbd (1.12) - 618 KB:

Download: http://www.kernel.org/pub/linux/utils/kbd/kbd-1.12.tar.bz2

MD5 sum: 069d1175b4891343b107a8ac2b4a39f6

Less (394) - 286 KB:

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

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

MD5 sum: a9f072ccefa0d315b325f3e9cdbd4b97

Libtool (1.5.22) - 2,854 KB:

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

Download: http://ftp.gnu.org/gnu/libtool/libtool-1.5.22.tar.gz

MD5 sum: 8e0ac9797b62ba4dcc8a2fb7936412b0

Linux (2.6.17.13) - 40,320 KB:

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

Download: http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.13.tar.bz2

MD5 sum: 834885b3ad9988b966570bee92459572

Linux-Headers (2.6.17.13-09092006) - 1,576 KB:

Home page: http://headers.cross-lfs.org/

Download: http://cross-lfs.org/files/packages/1.0.0/linux-headers-2.6.17.13-09092006.tar.bz2

MD5 sum: bfda0e9440dd76e6e35fdce79c9b0bf6

M4 (1.4.4) - 300 KB:

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

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

MD5 sum: eb93bfbcb12cf00165583302bb31a822

Make (3.81) - 1,125 KB:

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

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

MD5 sum: 354853e0b2da90c527e35aabb8d6f1e6

Man (1.6d) - 268 KB:

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

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

MD5 sum: 36d3f65bcc10f0754a3234e00d92ad6d

Man-pages (2.33) - 1,752 KB:

Download: http://www.kernel.org/pub/linux/docs/manpages/man-pages-2.33.tar.bz2

MD5 sum: e9f61ec73b5390c582530da173c12b10

Mktemp (1.5) - 69 KB:

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

Download: ftp://ftp.mktemp.org/pub/mktemp/mktemp-1.5.tar.gz

MD5 sum: 9a35c59502a228c6ce2be025fc6e3ff2

Module-Init-Tools (3.2.2) - 166 KB:

Download: http://www.kerneltools.org/pub/downloads/module-init-tools/module-init-tools-3.2.2.tar.bz2

MD5 sum: a1ad0a09d3231673f70d631f3f5040e9

Ncurses (5.5) - 2,260 KB:

Home page: http://dickey.his.com/ncurses/

Download: ftp://invisible-island.net/ncurses/ncurses-5.5.tar.gz

MD5 sum: e73c1ac10b4bfc46db43b2ddfd6244ef

Patch (2.5.9) - 198 KB:

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

Download: ftp://alpha.gnu.org/gnu/diffutils/patch-2.5.9.tar.gz

MD5 sum: dacfb618082f8d3a2194601193cf8716

Perl (5.8.8) - 9,887 KB:

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

Download: http://ftp.funet.fi/pub/CPAN/src/perl-5.8.8.tar.bz2

MD5 sum: a377c0c67ab43fd96eeec29ce19e8382

Procps (3.2.6) - 273 KB:

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

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

MD5 sum: 7ce39ea27d7b3da0e8ad74dd41d06783

Psmisc (22.2) - 239 KB:

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

Download: http://prdownloads.sourceforge.net/psmisc/psmisc-22.2.tar.gz?download

MD5 sum: 77737c817a40ef2c160a7194b5b64337

Readline (5.1) - 1,983 KB:

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

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

MD5 sum: 7ee5a692db88b30ca48927a13fd60e46

Sed (4.1.5) - 781 KB:

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

Download: http://ftp.gnu.org/gnu/sed/sed-4.1.5.tar.gz

MD5 sum: 7a1cbbbb3341287308e140bd4834c3ba

Shadow (4.0.16) - 1,412 KB:

Download: ftp://ftp.pld.org.pl/software/shadow/shadow-4.0.16.tar.bz2

MD5 sum: 1d91f7479143d1d705b94180c0d4874b

Note

Shadow (4.0.16) 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/1.0.0/.

Sysklogd (1.4.1) - 80 KB:

Home page: http://www.infodrom.org/projects/sysklogd/

Download: http://www.infodrom.org/projects/sysklogd/download/sysklogd-1.4.1.tar.gz

MD5 sum: d214aa40beabf7bdb0c9b3c64432c774

Sysvinit (2.86) - 97 KB:

Download: ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/sysvinit-2.86.tar.gz

MD5 sum: 7d5d61c026122ab791ac04c8a84db967

Tar (1.15.1) - 1,574 KB:

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

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

MD5 sum: 57da3c38f8e06589699548a34d5a5d07

Tcl (8.4.12) - 3,419 KB:

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

Download: http://prdownloads.sourceforge.net/tcl/tcl8.4.12-src.tar.gz?download

MD5 sum: 7480432d8730263f267952788eb4839b

Texinfo (4.8) - 1,487 KB:

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

Download: http://ftp.gnu.org/gnu/texinfo/texinfo-4.8.tar.bz2

MD5 sum: 6ba369bbfe4afaa56122e65b3ee3a68c

Tree (1.5.0) - 26 KB:

Download: ftp://mama.indstate.edu/linux/tree/tree-1.5.0.tgz

MD5 sum: e0d090c564e7ea5afa16bac80620c7e0

Udev (096) - 192 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-096.tar.bz2

MD5 sum: f4effef7807ce1dc91ab581686ef197b

Udev Cross-LFS Rules (1.0-3) - 12 KB:

Download: http://cross-lfs.org/files/packages/1.0.0/udev-cross-lfs-1.0-3.tar.bz2

MD5 sum: 0c9b9e24a37b9501bcd4889da71cf313

Util-linux (2.12r) - 1,339 KB:

Download: http://www.kernel.org/pub/linux/utils/util-linux/util-linux-2.12r.tar.bz2

MD5 sum: af9d9e03038481fbf79ea3ac33f116f9

Vim (7.0) - 6,422 KB:

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

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

MD5 sum: 4ca69757678272f718b1041c810d82d8

Vim (7.0) language files (optional) - 1,153 KB:

Download: ftp://ftp.vim.org/pub/vim/extra/vim-7.0-lang.tar.gz

MD5 sum: 6d43efaff570b5c86e76b833ea0c6a04

Zlib (1.2.3) - 485 KB:

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

Download: http://www.zlib.net/zlib-1.2.3.tar.gz

MD5 sum: debc62758716a169df9f62e6ab2bc634

Total size of these packages: about 180 MB

3.3. Additional Packages for Sparc64

ELFtoaout (2.3) - 13 KB:

Download: http://gd.tuwien.ac.at/opsys/linux/Owl/pool/sources/elftoaout/elftoaout-2.3.tgz

MD5 sum: be3bd6f7ba8ae107cbdbaa820ba64f86

Silo (1.4.11) - 142 KB:

Home page: http://www.sparc-boot.org/

Download: http://www.sparc-boot.org/pub/silo/silo-1.4.11.tar.bz2

MD5 sum: 37eea1b33d80f6c35d53af9029e30a02

Total size of these packages: about 155 KB

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 Fixes Patch - 23 KB:

Download: http://patches.cross-lfs.org/1.0.0/bash-3.1-fixes-8.patch

MD5 sum: bc337045fa4c5839babf0306cc9df6d0

Binutils Posix Patch - 4.9 KB:

Download: http://patches.cross-lfs.org/1.0.0/binutils-2.17-posix-1.patch

MD5 sum: 7e42a8edc0c59246bbc58c428256113c

Bzip2 Documentation Patch - 1.7 KB:

Download: http://patches.cross-lfs.org/1.0.0/bzip2-1.0.3-install_docs-1.patch

MD5 sum: 9e5dfbf4814b71ef986b872c9af84488

Bzip2 Bzdiff Remove Tempfile - 1.8 KB:

Download: http://patches.cross-lfs.org/1.0.0/bzip2-1.0.3-remove_tempfile-1.patch

MD5 sum: bcadb0ce282c96af15a86a2ccdac0765

Bzip2 Bzgrep Security Fixes Patch - 1.3 KB:

Download: http://patches.cross-lfs.org/1.0.0/bzip2-1.0.3-bzgrep_security-1.patch

MD5 sum: 4eae50e4fd690498f23d3057dfad7066

Coreutils Suppress Uptime, Kill, Su Patch - 13 KB:

Download: http://patches.cross-lfs.org/1.0.0/coreutils-5.96-suppress_uptime_kill_su-1.patch

MD5 sum: 227d41a6d0f13c31375153eae91e913d

Expect Spawn Patch - 6.9 KB:

Download: http://patches.cross-lfs.org/1.0.0/expect-5.43.0-spawn-2.patch

MD5 sum: 7706e1e8238c72eed8dc905d6f3b6aa9

Gawk Segfault Patch - 1.3 KB:

Download: http://patches.cross-lfs.org/1.0.0/gawk-3.1.5-segfault_fix-1.patch

MD5 sum: 7679530d88bf3eb56c42eb6aba342ddb

GCC Cross Search Paths Patch - 2 KB:

Download: http://patches.cross-lfs.org/1.0.0/gcc-4.1.1-cross_search_paths-1.patch

MD5 sum: 541fe39d228ddaa0d8396a35ec3a0ada

GCC PR20425 Patch - 36 KB:

Download: http://patches.cross-lfs.org/1.0.0/gcc-4.1.1-PR20425-1.patch

MD5 sum: 95535bda8e4d37d30251db0b121b5374

GCC Posix Patch - 9 KB:

Download: http://patches.cross-lfs.org/1.0.0/gcc-4.1.1-posix-1.patch

MD5 sum: 0d88068740a0e00780891f2cb905b808

Glibc iconv Fix - 4 KB:

Download: http://patches.cross-lfs.org/1.0.0/glibc-2.4-iconv_fix-1.patch

MD5 sum: 9c8e681226ccf7a1f25c6467674f915e

Glibc Disable linking with libgcc_eh.a - 1 KB:

Download: http://patches.cross-lfs.org/1.0.0/glibc-2.4-libgcc_eh-1.patch

MD5 sum: e5122ea7b89a5f22615eaadf8e46b334

Glibc Localedef Segfault - 1.9 KB:

Download: http://patches.cross-lfs.org/1.0.0/glibc-2.4-localedef_segfault-1.patch

MD5 sum: 42452abc6196789e0a83afa1ca7e6e4e

Gzip Security Fix Patch - 2 KB:

Download: http://patches.cross-lfs.org/1.0.0/gzip-1.3.5-security_fixes-1.patch

MD5 sum: f107844f01fc49446654ae4a8f8a0728

Inetutils inet_addr Patch - 4 KB:

Download: http://patches.cross-lfs.org/1.0.0/inetutils-1.4.2-inet_addr_fix-1.patch

MD5 sum: a33267b7a4e0d303a6f8dfeafde7bd8e

Inetutils GCC 4.x Fixes Patch - 4.1 KB:

Download: http://patches.cross-lfs.org/1.0.0/inetutils-1.4.2-gcc4_fixes-3.patch

MD5 sum: 5204fbc503c9fb6a8e353583818db6b9

Inetutils No-Server-Man-Pages Patch - 1.3 KB:

Download: http://patches.cross-lfs.org/1.0.0/inetutils-1.4.2-no_server_man_pages-1.patch

MD5 sum: eb477f532bc6d26e7025fcfc4452511d

KBD GCC 4.x Fixes Patch - 1.5 KB:

Download: http://patches.cross-lfs.org/1.0.0/kbd-1.12-gcc4_fixes-1.patch

MD5 sum: 615bc1e381ab646f04d8045751ed1f69

Linux Tulip Update Patch - 8 KB:

Download: http://patches.cross-lfs.org/1.0.0/linux-2.6.17.13-tulip-1.patch

MD5 sum: 0dd7027a8cb8e59c74c24ff0a8f45f3b

Mktemp Tempfile Patch - 3.6 KB:

Download: http://patches.cross-lfs.org/1.0.0/mktemp-1.5-add_tempfile-3.patch

MD5 sum: 65d73faabe3f637ad79853b460d30a19

Perl Libc Patch - 4 KB:

Download: http://patches.cross-lfs.org/1.0.0/perl-5.8.8-libc-2.patch

MD5 sum: 3bf8aef1fb6eb6110405e699e4141f99

Readline Fixes Patch - 2.1 KB:

Download: http://patches.cross-lfs.org/1.0.0/readline-5.1-fixes-3.patch

MD5 sum: e30963cd5c6f6a11a23344af36cfa38c

Sysklogd Fixes Patch - 28 KB:

Download: http://patches.cross-lfs.org/1.0.0/sysklogd-1.4.1-fixes-1.patch

MD5 sum: 508104f058d1aef26b3bc8059821935f

Tar GCC-4.x Fix Patch - 1.2 KB:

Download: http://patches.cross-lfs.org/1.0.0/tar-1.15.1-gcc4_fix_tests-1.patch

MD5 sum: 8e286a1394e6bcf2907f13801770a72a

Tar Security Fix Patch - 3.9 KB:

Download: http://patches.cross-lfs.org/1.0.0/tar-1.15.1-security_fixes-1.patch

MD5 sum: 19876e726d9cec9ce1508e3af74dc22e

Tar Sparse Fix Patch - 1 KB:

Download: http://patches.cross-lfs.org/1.0.0/tar-1.15.1-sparse_fix-1.patch

MD5 sum: 9e3623f7c88d8766878ecb27c980d86a

Texinfo Tempfile Fix Patch - 2.2 KB:

Download: http://patches.cross-lfs.org/1.0.0/texinfo-4.8-tempfile_fix-2.patch

MD5 sum: 559bda136a2ac7777ecb67511227af85

Util-linux Cramfs Patch - 2.8 KB:

Download: http://patches.cross-lfs.org/1.0.0/util-linux-2.12r-cramfs-1.patch

MD5 sum: 1c3f40b30e12738eb7b66a35b7374572

Util-linux GCC 4.x Patch - 1 KB:

Download: http://patches.cross-lfs.org/1.0.0/util-linux-2.12r-gcc4_fixes-1.patch

MD5 sum: 6c030921dc9b92daf688f12a4ee6f6e0

Util-linux Missing Header Patch - 1 KB:

Download: http://patches.cross-lfs.org/1.0.0/util-linux-2.12r-missing_header-1.patch

MD5 sum: 33ccc15d2e92caa6189b044f573fdcda

Vim Fixes Patch - 32 KB:

Download: http://patches.cross-lfs.org/1.0.0/vim-7.0-fixes-5.patch

MD5 sum: 6e179cfe811d105de4fd9156a0ef6699

Zlib fPIC Patch - 3.2 KB:

Download: http://patches.cross-lfs.org/1.0.0/zlib-1.2.3-fPIC-1.patch

MD5 sum: 545d60b20bfde6f53023de44438cef59

Total size of these patches: about 214.7 KB

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/1.0.0/ and acquire any additional patches to suit the system needs.

3.5. Additional Patches for Sparc64

Elftoaout Fixes Patch - 6.7 KB:

Download: http://patches.cross-lfs.org/1.0.0/elftoaout-2.3-64bit_fixes-1.patch

MD5 sum: 485e77cf2ed082d3d0ea99c703f1f14b

GCC Sparc TLS Fix - 1 KB:

Download: http://patches.cross-lfs.org/1.0.0/gcc-4.1.1-sparc_tls-1.patch

MD5 sum: f7bae419ce2cddb1d4918eff4eb582e3

GCC Pure 64 Patch - 15 KB:

Download: http://patches.cross-lfs.org/1.0.0/gcc-4.1.1-pure64-1.patch

MD5 sum: cea9bf46663392d627de81e2456698e3

GCC Specs Patch - 6.4 KB:

Download: http://patches.cross-lfs.org/1.0.0/gcc-4.1.1-pure64_specs-1.patch

MD5 sum: 99e0ae890fce0614be210e83f0a5b975

KBD kbdrate Patch - 1 KB:

Download: http://patches.cross-lfs.org/1.0.0/kbd-1.12-sparc_kbdrate-1.patch

MD5 sum: 6cffbcd3a8cb415fd0bf851d0f2a3a0f

Silo Fixes Patch - 657 KB:

Download: http://patches.cross-lfs.org/1.0.0/silo-1.4.11-fixes-1.patch

MD5 sum: cc864b6a80d53604ea0281fb99a8cfb9

Total size of these patches: about 687.1 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 -m -k /dev/null clfs

The meaning of the command line options:

-s /bin/bash

This makes bash the default shell for user clfs.

-g clfs

This option adds user clfs to group clfs.

-m

This creates a home directory for clfs.

-k /dev/null

This parameter prevents possible copying of files from a skeleton directory (default is /etc/skel) by changing the input location to the special null device.

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.

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 as user clfs, and a cd into the created directory should be performed. The build instructions assume that the bash shell is in use.

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. You will need to set the CHOST triplet to match your particular needs. To set this information you can issue the following command:

export CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"

Now we will set our Target Triplet:

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

Copy settings to Environment

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

echo export CLFS_HOST=\""${CLFS_HOST}\"" >> ~/.bashrc
echo export CLFS_TARGET=\""${CLFS_TARGET}\"" >> ~/.bashrc

5.4. Build Flags

We will need to setup target specific flags for the compiler and linkers.

export BUILD64="[BUILD64 entries]"
export GCCTARGET="[GCCTARGET entries]"

Lets add the build flags to ~/.bashrc to prevent issues if we stop and come back later.

echo export BUILD64=\""${BUILD64}\"" >> ~/.bashrc
echo export GCCTARGET=\""${GCCTARGET}\"" >> ~/.bashrc

The following table gives the entires for different Sparc 64 capable processors. Pick the processor that matches your system. Note: GCC settings are only needed in the early sections of the book, and will not be used in the final-system builds.

Table 5.1. List of architectures, target triplets, and recommended book

Processor BUILD64 GCCTARGET
Ultrasparc and Ultrasparc2 -m64 -mcpu=ultrasparc -mtune=ultrasparc -mcpu=ultrasparc -mtune=ultrasparc
Ultrasparc3 -m64 -mcpu=ultrasparc3 -mtune=ultrasparc3 -mcpu=ultrasparc3 -mtune=ultrasparc3

5.5. Linux-Headers-2.6.17.13-09092006

The Linux Headers package contains the “sanitized” kernel headers.

5.5.1. Installation of Linux-Headers

Install the header files that are needed for the base build:

install -dv /tools/include
cp -av include/asm-sparc64 /tools/include/asm
cp -av include/{asm-generic,linux} /tools/include/

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

5.6. Cross Binutils-2.17

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

5.6.1. Installation of Cross Binutils

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

To make sure that the proper syntax is used for a couple of tools, apply the following patch:

patch -Np1 -i ../binutils-2.17-posix-1.patch

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:

../binutils-2.17/configure --prefix=/cross-tools \
   --host=${CLFS_HOST} --target=${CLFS_TARGET} --with-lib-path=/tools/lib \
   --disable-nls --enable-shared --enable-64-bit-bfd --disable-multilib

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.

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

--enable-shared

Enable the creation of the shared libraries.

--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 the libiberty.h file to /tools/include directory:

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

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

5.7. Cross GCC-4.1.1 - Static

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

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

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

patch -Np1 -i ../gcc-4.1.1-pure64_specs-1.patch

To make sure that a couple of tools use the proper syntax, apply the following patch:

patch -Np1 -i ../gcc-4.1.1-posix-1.patch

The following patch ensures that gcc does not search the /usr directory for libgcc_s.so when cross-compiling:

patch -Np1 -i ../gcc-4.1.1-cross_search_paths-1.patch

Change the StartFile Spec to point to the correct library location:

echo "
#undef STARTFILE_PREFIX_SPEC
#define STARTFILE_PREFIX_SPEC \"/tools/lib/\"" >> gcc/config/sparc/linux.h
echo "
#undef STARTFILE_PREFIX_SPEC
#define STARTFILE_PREFIX_SPEC \"/tools/lib/\"" >> gcc/config/sparc/linux64.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:

../gcc-4.1.1/configure --prefix=/cross-tools \
    --host=${CLFS_HOST} --target=${CLFS_TARGET} --disable-multilib \
    --with-local-prefix=/tools --disable-nls --disable-shared \
    --disable-threads --enable-languages=c

The meaning of the configure options:

--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-shared

Disables the creation of the shared 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 CFLAGS_FOR_TARGET="${GCCTARGET}" all-gcc

Install the package:

make install-gcc

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

5.8. Glibc-2.4

The Glibc 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.8.1. Installation of Glibc

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

Disable linking to libgcc_eh:

patch -Np1 -i ../glibc-2.4-libgcc_eh-1.patch

The following patch fixes an issue that can cause localdef to segfault:

patch -Np1 -i ../glibc-2.4-localedef_segfault-1.patch

The following sed fixes a build issue with Glibc. This will prevent nscd from trying to link to libraries that don't exist:

cp -v nscd/Makefile{,.orig}
sed -e "/nscd_stat.o: sysincludes = # nothing/d" nscd/Makefile.orig > \
    nscd/Makefile

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

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

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

echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes" >> config.cache
echo "libc_cv_sparc64_tls=yes" >> config.cache

Prepare Glibc for compilation:

BUILD_CC="gcc" CC="${CLFS_TARGET}-gcc ${BUILD64}" \
    AR="${CLFS_TARGET}-ar" RANLIB="${CLFS_TARGET}-ranlib" \
    ../glibc-2.4/configure --prefix=/tools \
    --host=${CLFS_TARGET} --build=${CLFS_HOST} \
    --disable-profile --enable-add-ons \
    --with-tls --enable-kernel=2.6.0 --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 Glibc to build using our target architecture GCC utilizing the 64 Bit flags.

--libdir=/tools/lib64

Puts Glibc 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

The stubs.h header installed by glibc looks for stubs-32.h and stubs-64.h. This configuration of glibc only generates stubs-64.h. Fix this with the following:

mv -v /tools/include/gnu/stubs{-64,}.h

Details on this package are located in Section 10.6.5, “Contents of Glibc.”

5.9. GCC-4.1.1 - Cross Compiler Final

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

5.9.1. Installation of GCC Cross Compiler

The following patch fixes the searching of multilib dirs for specs file. The patch standardizes the gcc drivers path iteration functions, ensuring multilib directories are searched in the correct order. This fixes various issues, most noticably with libtool on multilib systems:

patch -Np1 -i ../gcc-4.1.1-PR20425-1.patch

The following patch fixes a TLS build issue. For more details go to http://gcc.gnu.org/ml/gcc-patches/2006-02/msg00177.html:

patch -Np1 -i ../gcc-4.1.1-sparc_tls-1.patch

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

patch -Np1 -i ../gcc-4.1.1-pure64_specs-1.patch

To make sure that a couple of tools use the proper syntax, apply the following patch:

patch -Np1 -i ../gcc-4.1.1-posix-1.patch

The following patch ensures that gcc does not search the /usr directory for libgcc_s.so when cross-compiling:

patch -Np1 -i ../gcc-4.1.1-cross_search_paths-1.patch

Change the StartFile Spec to point to the correct library location:

echo "
#undef STARTFILE_PREFIX_SPEC
#define STARTFILE_PREFIX_SPEC \"/tools/lib/\"" >> gcc/config/sparc/linux.h
echo "
#undef STARTFILE_PREFIX_SPEC
#define STARTFILE_PREFIX_SPEC \"/tools/lib/\"" >> gcc/config/sparc/linux64.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:

../gcc-4.1.1/configure --prefix=/cross-tools \
    --target=${CLFS_TARGET} --host=${CLFS_HOST} --disable-multilib \
    --with-local-prefix=/tools --disable-nls --enable-shared \
    --enable-languages=c,c++ --enable-__cxa_atexit \
    --enable-c99 --enable-long-long --enable-threads=posix

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.9.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. Binutils-2.17

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

6.3.1. Installation of Binutils

To make sure that the proper syntax is used for a couple of tools, apply the following patch:

patch -Np1 -i ../binutils-2.17-posix-1.patch

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.17/configure --prefix=/tools \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} --target=${CLFS_TARGET} \
    --disable-nls --enable-shared --enable-64-bit-bfd \
    --disable-multilib

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.8.2, “Contents of Binutils.”

6.4. GCC-4.1.1

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

6.4.1. Installation of GCC

The following patch fixes the searching of multilib dirs for specs file. The patch standardizes the gcc drivers path iteration functions, ensuring multilib directories are searched in the correct order. This fixes various issues, most noticably with libtool on multilib systems:

patch -Np1 -i ../gcc-4.1.1-PR20425-1.patch

The following patch fixes a TLS build issue. For more details go to http://gcc.gnu.org/ml/gcc-patches/2006-02/msg00177.html:

patch -Np1 -i ../gcc-4.1.1-sparc_tls-1.patch

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

patch -Np1 -i ../gcc-4.1.1-pure64_specs-1.patch

To make sure that a couple of tools use the proper syntax, apply the following patch:

patch -Np1 -i ../gcc-4.1.1-posix-1.patch

The following patch ensures that gcc does not search the /usr directory for libgcc_s.so when cross-compiling:

patch -Np1 -i ../gcc-4.1.1-cross_search_paths-1.patch

Now we will change cpp's search path not to look in /usr/include:

cp -v gcc/cppdefault.c{,.orig}
sed -e '/#define STANDARD_INCLUDE_DIR/s@"/usr/include"@0@g' \
    gcc/cppdefault.c.orig > gcc/cppdefault.c

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

When searching for the multilibs, force the build to use the results of --print-multi-lib from our cross-compiler, not the native compiler gcc builds now:

cp -v gcc/Makefile.in{,.orig2}
sed -e "/MULTILIBS/s@\$(GCC_FOR_TARGET)@/cross-tools/bin/${CC}@g" \
   gcc/Makefile.in.orig2 > 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.1.1/configure --prefix=/tools --disable-multilib \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} --target=${CLFS_TARGET} \
    --libexecdir=/tools/lib --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

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.

Compile the package:

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

Install the package:

make install

Now we copy the files that are placed in /tools/lib64 to /tools/lib. We also delete the /tools/lib64 directory:

cp -va /tools/lib64/* /tools/lib
rm -rvf /tools/lib64

Many packages use the name cc to call the C compiler. To satisfy those packages, create a symlink:

ln -sv gcc /tools/bin/cc

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

6.5. Ncurses-5.5

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

6.5.1. Installation of Ncurses

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

The meaning of the 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.14.2, “Contents of Ncurses.”

6.6. Bash-3.1

The Bash package contains the Bourne-Again SHell.

6.6.1. Installation of Bash

Remove a test that causes the build to fail:

echo "ac_cv_func_setvbuf_reversed=no" >> config.cache

When bash is cross-compiled, it cannot test for the presence of named pipes. 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 glibc. Prevent that by forcing the following definition:

echo "bash_cv_sys_named_pipes=yes" >> config.cache

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.25.2, “Contents of Bash.”

6.7. Bzip2-1.0.3

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.7.1. Installation of Bzip2

Bzip2's default Makefile target automatically runs the testsuite as well. Disable the tests since they won't work on a multi-architecture build:

cp -v Makefile{,.orig}
sed -e 's@^\(all:.*\) test@\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.26.2, “Contents of Bzip2.”

6.8. Coreutils-5.96

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

6.8.1. Installation of Coreutils

Coreutils has some issues when cross-compiling. So we define the items cross-compiling doesn't like:

echo "ac_cv_sys_restartable_syscalls=yes" > config.cache
echo "ac_cv_func_setvbuf_reversed=yes" >> config.cache
echo "utils_cv_sys_open_max=1024" >> config.cache

Prepare Coreutils for compilation:

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

Compile the package:

make

Install the package:

make install

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

6.9. Diffutils-2.8.7

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

6.9.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.27.2, “Contents of Diffutils.”

6.10. Findutils-4.2.27

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.10.1. Installation of Findutils

Findutils has an issue with cross-compiling where it can't find getline. Fix it here:

echo "am_cv_func_working_getline=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.30.2, “Contents of Findutils.”

6.11. Gawk-3.1.5

The Gawk package contains programs for manipulating text files.

6.11.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.31.2, “Contents of Gawk.”

6.12. Gettext-0.14.5

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.12.1. Installation of Gettext

Gettext has an issue with cross-compiling where it can't find getline. Fix it here:

cd gettext-tools
echo "am_cv_func_working_getline=yes" >> config.cache

Prepare Gettext for compilation:

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

The meaning of the configure options:

--disable-shared

This tells Gettext not to create a shared library.

Only one program in the Gettext package needs to be built:

make -C lib
make -C src msgfmt

Install the msgfmt binary:

cp -v src/msgfmt /tools/bin

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

6.13. Grep-2.5.1a

The Grep package contains programs for searching through files.

6.13.1. Installation of Grep

Prepare Grep for compilation:

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

The meaning of the configure options:

--disable-perl-regexp

This ensures that the grep program does not get linked against a Perl Compatible Regular Expression (PCRE) library that may be present on the host but will not be available when building the final system.

Compile the package:

make

Install the package:

make install

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

6.14. Gzip-1.3.5

The Gzip package contains programs for compressing and decompressing files.

6.14.1. Installation of Gzip

Setup configure so it can use cross-compiled tools:

cp -v configure{,.orig}
sed -e "s@nm conftest@${CLFS_TARGET}-&@" configure.orig > configure

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.35.2, “Contents of Gzip.”

6.15. Make-3.81

The Make package contains a program for compiling packages.

6.15.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.39.2, “Contents of Make.”

6.16. Patch-2.5.9

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

6.16.1. Installation of Patch

Prepare Patch 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.44.2, “Contents of Patch.”

6.17. Sed-4.1.5

The Sed package contains a stream editor.

6.17.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.16.2, “Contents of Sed.”

6.18. Tar-1.15.1

The Tar package contains an archiving program.

6.18.1. Installation of Tar

Tar has an issue with cross-compiling where it can't find getline. Fix it here:

echo "am_cv_func_working_getline=yes" >> config.cache

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.49.2, “Contents of Tar.”

6.19. Texinfo-4.8

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

6.19.1. Installation of Texinfo

Prepare Texinfo 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.50.2, “Contents of Texinfo.”

6.20. 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/bin/gcc -v

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

To chroot, you will also need a Linux Kernel-2.6.x (having been compiled with GCC-3.0 or greater). The reason for the kernel version requirement is that, without it, thread-local storage support in Binutils will not be built and the Native POSIX Threading Library (NPTL) test suite will segfault.

To check your kernel version, run cat /proc/version - if it does not say that you are running a 2.6.2 or later Linux kernel, compiled with GCC 3.0 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,mnt}
mkdir -pv ${CLFS}/{proc,media/{floppy,cdrom},sbin,srv,sys}
mkdir -pv ${CLFS}/var/{lock,log,mail,run,spool}
mkdir -pv ${CLFS}/var/{opt,cache,lib/{misc,locate},local}
install -dv -m 0750 ${CLFS}/root
install -dv -m 1777 ${CLFS}{/var,}/tmp
mkdir -pv ${CLFS}/usr/{,local/}{bin,include,lib,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

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,grep,pwd,stty} ${CLFS}/bin
ln -sv /tools/lib/libgcc_s.so{,.1} ${CLFS}/usr/lib
ln -sv /tools/lib/libstd* ${CLFS}/usr/lib
ln -sv bash ${CLFS}/bin/sh

7.4. Zlib-1.2.3

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

7.4.1. Installation of Zlib

Prepare Zlib for compilation:

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

Compile the package:

make

Install the package:

make install

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

7.5. E2fsprogs-1.39

The E2fsprogs package contains the utilities for handling the ext2 file system. It also supports the ext3 journaling file system.

7.5.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="${CC} ${BUILD64}" ../configure --prefix=/tools \
--enable-elf-shlibs --disable-evms \
--host=${CLFS_TARGET}

The meaning of the configure options:

--enable-elf-shlibs

This creates the shared libraries which some programs in this package use.

--disable-evms

This disables the building of the Enterprise Volume Management System (EVMS) plugin. This plugin is not up-to-date with the latest EVMS internal interfaces and EVMS is not installed as part of a base CLFS system, so the plugin is not required. See the EVMS website at http://evms.sourceforge.net/ for more information regarding EVMS.

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

Install the binaries and documentation:

make DESTDIR=${CLFS} install

The meaning of the make option:

DESTDIR=${CLFS}

The Makefile for e2fsprogs hard-codes a path to the mke2fs.conf file, attempting to install it into ${DESTDIR}/etc, causing the installation to fail as it tries to write to /etc. The DESTDIR parameter prevents this.

Install the shared libraries:

make install-libs

Create needed symlinks for a bootable system:

ln -sv /tools/sbin/{fsck.ext2,fsck.ext3,e2fsck} ${CLFS}/sbin

Details on this package are located in Section 10.28.2, “Contents of E2fsprogs.”

7.6. Sysvinit-2.86

The Sysvinit package contains programs for controlling the startup, running, and shutdown of the system.

7.6.1. Installation of Sysvinit

Make some modifications to allow you to boot into the minimal temp-system:

cp -v src/Makefile src/Makefile.orig
sed -e 's@root@0@g' \
    -e "s@/dev/initctl@${CLFS}&@g" \
    -e 's@\(mknod \)-m \([0-9]* \)\(.* \)p@\1\3p; chmod \2\3@g' \
    -e "s@/usr/lib@/tools/lib@" \
    src/Makefile.orig > src/Makefile

Compile the package:

make -C src clobber
make -C src CC="${CC} ${BUILD64}"

Install the package:

make -C src install INSTALL="install" ROOT="${CLFS}"

7.6.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

# Remove this section if you System only
# has a console port
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

# Uncomment this section if your system has a console
# port
#c0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100

# End /etc/inittab
EOF

Details on this package are located in Section 10.48.3, “Contents of Sysvinit.”

7.7. Module-Init-Tools-3.2.2

The Module-Init-Tools package contains programs for handling kernel modules in Linux kernels greater than or equal to version 2.5.47.

7.7.1. Installation of Module-Init-Tools

Prepare Module-Init-Tools for compilation:

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

Compile the package:

make

Install the package:

make DESTDIR="${CLFS}" install

Details on this package are located in Section 10.43.2, “Contents of Module-Init-Tools.”

7.8. Util-linux-2.12r

The Util-linux package contains miscellaneous utility programs. Among them are utilities for handling file systems, consoles, partitions, and messages.

7.8.1. Installation of Util-linux

Util-linux fails to compile against newer versions of Linux kernel headers. The following patch properly fixes this issue:

patch -Np1 -i ../util-linux-2.12r-cramfs-1.patch

The following patch fixes build issues with GCC 4.1.1:

patch -Np1 -i ../util-linux-2.12r-gcc4_fixes-1.patch

The following patch fixes swapon.c - it tries to find the variable R_OK, but the header that has R_OK is not included:

patch -Np1 -i ../util-linux-2.12r-missing_header-1.patch

Util-linux does not use the freshly installed headers and libraries from the /tools directory by default. This is fixed by altering the configure script:

cp -v configure{,.orig}
sed -e 's@/usr/include@/tools/include@g' configure.orig > configure

The Util-linux installation uses -o root. The following sed removes that since we don't have users setup yet:

cp -v MCONFIG{,.orig}
sed -e 's|-o root||' MCONFIG.orig > MCONFIG

Prepare Util-linux for compilation:

CC="${CC} ${BUILD64}" ./configure

Compile the package:

make HAVE_KILL=yes HAVE_SLN=yes \
    HAVE_SHADOW=no CPUOPT="" ARCH="" \
    CPU=""

The meaning of the make parameters:

HAVE_KILL=yes

This prevents the kill program from being built.

HAVE_SLN=yes

This prevents the sln program (a statically linked version of ln already installed by Glibc) from being built and installed again.

HAVE_SHADOW=no

This disables linking to shadow .

CPUOPT=""

This disables any compiler optimizations by CPU type.

ARCH=""

This disables the detection of the architecture.

CPU=""

This disables the detection of the CPU.

Install the package:

make HAVE_KILL=yes HAVE_SLN=yes HAVE_SHADOW=no \
    USE_TTY_GROUP=no CPUOPT="" ARCH="" \
    CPU="" DESTDIR=${CLFS} install

Details on this package are located in Section 10.52.3, “Contents of Util-linux.”

7.9. Udev-096

The Udev package contains programs for dynamic creation of device nodes.

7.9.1. Installation of Udev

Compile the package:

make CROSS_COMPILE="${CLFS_TARGET}-" CC="${CC} ${BUILD64}" \
    LD="${CC} ${BUILD64}"

Install the package:

make DESTDIR=${CLFS} install

Details on this package are located in Section 10.51.2, “Contents of Udev.”

7.10. ELFtoaout-2.3

The ELFtoaout package contains the Sparc ELF to a.out converter.

7.10.1. Installation of ELFtoaout

The following patch fixes some 64 bit issues with elftoaout:

patch -Np1 -i ../elftoaout-2.3-64bit_fixes-1.patch

Compile the ELFtoaout package:

make

Install the package:

install -v -m 0755 -s elftoaout /cross-tools/bin

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

7.11. 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 allow 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

uucp:x:32:32:uucp:/var/spool/uucp:/bin/false

Often used for Unix-to-Unix Copy of files from one server to the next

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

uucp:x:32:uucp

Used by the Unix-to-Unix copy users

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.12. Linux-2.6.17.13

The Linux package contains the Linux kernel.

7.12.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.

The following patch fixes on intialization issue with the tulip network driver:

patch -Np1 -i ../linux-2.6.17.13-tulip-1.patch

Prepare for compilation by running the following command:

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.

make mrproper ARCH=sparc64 CROSS_COMPILE=${CLFS_TARGET}-

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.

If your keyboard isn't a US one and you have Kbd installed on your host system, you can build the proper keymap for your keyboard layout inside the kernel. If you wish to do this, run the following command (replace [path to keymap] with the keymap location on the host - a common location is in /usr/share/kbd):

loadkeys -m [path to  keymap] > \
    drivers/char/defkeymap.c

For example, if using a Dutch keyboard, use /usr/share/kbd/keymaps/i386/qwerty/nl.map.gz.

Configure the kernel via a menu-driven interface:

make ARCH=sparc64 CROSS_COMPILE=${CLFS_TARGET}- menuconfig

Compile the kernel image and modules:

make ARCH=sparc64 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 INSTALL_MOD_PATH=${CLFS} ARCH=sparc64 \
   CROSS_COMPILE=${CLFS_TARGET}- 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 vmlinux ${CLFS}/boot/clfskernel-2.6.17.13

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-2.6.17.13

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-2.6.17.13

Details on this package are located in Section 12.3.2, “Contents of Linux.”

7.13. Silo-1.4.11

The Silo package contains the Sparc Improved boot LOader.

7.13.1. Installation of Silo

The following patch fixes compile issues:

patch -Np1 -i ../silo-1.4.11-fixes-1.patch

Compile the Silo package:

make CROSS_COMPILE=${CLFS_TARGET}-

Install the package:

make DESTDIR=${CLFS} install

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

7.14. 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 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.15. Build Flags

We will need to copy our build variables into our new system:

echo export BUILD64=\""${BUILD64}\"" >> ${CLFS}/root/.bash_profile

7.16. 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
none           /proc/openprom  openpromfs  defaults         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.17. CLFS-Bootscripts-1.0

The CLFS-Bootscripts package contains a set of scripts to start/stop the CLFS system at bootup/shutdown.

7.17.1. Installation of CLFS-Bootscripts

Install the package:

make ETCDIR=${CLFS}/etc 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 CLFS-Bootscripts.”

7.18. Udev Rules-1.0-3

The Udev Cross-LFS rules package contains the necessary rules set for a basic functional system.

7.18.1. Installation of Udev-Rules

Install the package:

make DESTDIR=${CLFS} install-minimal

Details on this package are located in Section 11.3.2, “Contents of Udev Rules.”

7.19. Populating /dev

7.19.1. Creating Initial Device Nodes

Note

The commands in the remainder of the book should be run as the root user. Also, double-check that ${CLFS} is set as root.

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

7.20. 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 it subdirectories should be owned by root. Change the ownership for ${CLFS} and its subdirectories by running this command:

chown -Rv root:root ${CLFS}

7.21. Making the Temporary System Bootable

This is for the configuration of silo, similar to what is in bootscripts.

cat > ${CLFS}/etc/silo.conf << "EOF"
# Begin /etc/silo.conf
partition = 1         # Boot partition (= root partition)
root = /dev/sda1      # Root partition
timeout = 150         # Wait 15 seconds before booting the default section

image = /boot/clfskernel-2.6.17.13
  label = linux
# End /etc/silo.conf
EOF

If you already have Silo installed on your target system, you do not need to reinstall it. Silo is just a chain loader and has no bearing on the system build.

After you get the build copied to when you can boot, you will need to issue the following command:

silo -f

7.22. 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}

Some others have came up with other ideas on how to do this. Below is a table with the method and link to where the information is stored.

Table 7.1. Boot Methods

Boot Method For Architectures Hyperlink
nfsroot MIPS, PPC, Sparc, x86, and x86_64 http://documents.jg555.com/netboot

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.12r

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

The following patch fixes build issues with GCC 4.1.1:

patch -Np1 -i ../util-linux-2.12r-gcc4_fixes-1.patch

Util-linux does not use the freshly installed headers and libraries from the /tools directory by default. This is fixed by altering the configure script:

cp -v configure{,.orig}
sed -e 's@/usr/include@/tools/include@g' configure.orig > configure

Prepare Util-linux for compilation:

CC="${CC} ${BUILD64}" ./configure

Compile some support routines:

make ARCH="" CPU="" -C lib

The meaning of the make parameters:

ARCH=""

This disables the detection of the architecture.

CPU=""

This disables the detection of the CPU.

Only a few of the utilities contained in this package need to be built:

make ARCH="" CPU="" -C mount mount umount
make ARCH="" CPU="" -C text-utils more

Copy these programs to the temporary tools directory:

cp -v mount/{,u}mount text-utils/more /tools/bin

Details on this package are located in Section 10.52.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. Also, double-check that ${CLFS} is set as root.

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

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,mnt}
mkdir -pv /{proc,media/{floppy,cdrom},sbin,srv,sys}
mkdir -pv /var/{lock,log,mail,run,spool}
mkdir -pv /var/{opt,cache,lib/{misc,locate},local}
install -dv -m 0750 /root
install -dv -m 1777 {/var,}/tmp
mkdir -pv /usr/{,local/}{bin,include,lib,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

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,grep,pwd,stty} /bin
ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
ln -sv /tools/lib/libstd* /usr/lib
ln -sv bash /bin/sh

8.8. Build Flags

We will need to setup target specific flags for the compiler and linkers.

export BUILD64="[BUILD64 entries]"

To prevent errors when you come back to your build, we will export these variables to prevent any build issues in the future:

echo export BUILD64=\""${BUILD64}\"" >> ~/.bash_profile

The following table gives the entires for different Sparc 64 capable processors. Pick the processor that matches your system. Note: GCC settings are only needed in the early sections of the book, and will not be used in the final-system builds.

Table 8.1. List of architectures, target triplets, and recommended book

Processor BUILD64 GCCTARGET