5. Constructing a Temporary System

5.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 HLFS system in Chapter 6 and allow a working environment with more user convenience than a minimum environment would. This chapter will also build with the same toolchain hardeneding features used in Chapter 6, whereever possible, to preserve the “bootstrap” concept (where the final system is built with the same tools and options as the temporary system).

There are two steps in building this minimal system. The first step is to build a new and host-independent toolchain (compiler, assembler, and linker), called “Embryo toolchain” in this book. The second step uses this toolchain to build another toolchain, C libraries, and a few useful utilities, linked to the new C libraries. This second toolchain is called the “Cocoon toolchain”.

The files compiled in this chapter will be installed under the $HLFS/tools directory to keep them separate from the files installed in the next chapter and the host production directories. Since the packages compiled here are temporary, we do not want them to pollute the soon-to-be HLFS system. The final toolchain which will be installed to the production directories is called the Butterfly toolchain, and will be independent of the previous toolchains.

[Important]

Important

Before issuing the build instructions for a package, the package should be unpacked as user hlfs, and a cd into the created directory should be performed. The exception to this is when building the toolchain because the toolchain compiles two, or more, packages from the same source tree. The instructions assume you will unpack the toolchain packages under the same directory. For example, if source packages are located in $HLFS/usr/src, binutils-2.17.tar.bz2 will unpack to $HLFS/usr/src/binutils-2.17 and gcc-core-4.1.2.tar.bz2 will unpack to $HLFS/usr/src/gcc-4.1.2. Intructions are provided on the toolchain pages to create the combined source tree.

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 chapter, 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]

Important

After installing each package, delete its source and build directories. Deleting the sources saves space and prevents mis-configuration when the same package is reinstalled later.

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

echo $HLFS

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