r670 - trunk/BOOK/chapter05

robert at linuxfromscratch.org robert at linuxfromscratch.org
Wed Jul 26 17:53:50 PDT 2006


Author: robert
Date: 2006-07-26 18:53:48 -0600 (Wed, 26 Jul 2006)
New Revision: 670

Added:
   trunk/BOOK/chapter05/cocoon-toolchain.xml
   trunk/BOOK/chapter05/embryo-toolchain.xml
   trunk/BOOK/chapter05/linux-headers.xml
Removed:
   trunk/BOOK/chapter05/binutils-cross.xml
   trunk/BOOK/chapter05/binutils.xml
   trunk/BOOK/chapter05/gcc-cross.xml
   trunk/BOOK/chapter05/gcc.xml
   trunk/BOOK/chapter05/glibc-headers.xml
   trunk/BOOK/chapter05/linux-libc-headers.xml
   trunk/BOOK/chapter05/uclibc-headers.xml
Modified:
   trunk/BOOK/chapter05/adjusting.xml
   trunk/BOOK/chapter05/bash.xml
   trunk/BOOK/chapter05/bison.xml
   trunk/BOOK/chapter05/bzip2.xml
   trunk/BOOK/chapter05/chapter05.xml
   trunk/BOOK/chapter05/coreutils.xml
   trunk/BOOK/chapter05/dejagnu.xml
   trunk/BOOK/chapter05/diffutils.xml
   trunk/BOOK/chapter05/expect.xml
   trunk/BOOK/chapter05/findutils.xml
   trunk/BOOK/chapter05/flex.xml
   trunk/BOOK/chapter05/gawk.xml
   trunk/BOOK/chapter05/gettext.xml
   trunk/BOOK/chapter05/glibc.xml
   trunk/BOOK/chapter05/grep.xml
   trunk/BOOK/chapter05/gzip.xml
   trunk/BOOK/chapter05/introduction.xml
   trunk/BOOK/chapter05/m4.xml
   trunk/BOOK/chapter05/make.xml
   trunk/BOOK/chapter05/ncurses.xml
   trunk/BOOK/chapter05/patch.xml
   trunk/BOOK/chapter05/perl.xml
   trunk/BOOK/chapter05/sed.xml
   trunk/BOOK/chapter05/tar.xml
   trunk/BOOK/chapter05/tcl.xml
   trunk/BOOK/chapter05/texinfo.xml
   trunk/BOOK/chapter05/uclibc.xml
   trunk/BOOK/chapter05/util-linux.xml
Log:
glibc-2.4, gcc-4.1.1 (aka NEO) merger part 2 of 3

Modified: trunk/BOOK/chapter05/adjusting.xml
===================================================================
--- trunk/BOOK/chapter05/adjusting.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/adjusting.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -1,28 +1,123 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+  "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
   <!ENTITY % general-entities SYSTEM "../general.ent">
   %general-entities;
 ]>
+
 <sect1 id="ch-tools-adjusting">
-<title>Adjusting the Toolchain</title>
-<?dbhtml filename="adjusting.html"?>
+  <?dbhtml filename="adjusting.html"?>
 
-<para>Install the new linker we compiled earlier:</para>
+  <title>Adjusting the Toolchain</title>
 
-<screen><userinput>mv -v /tools/bin/${target}-{ld-new,ld}
-ln -vf /tools/bin/${target}-ld /tools/${target}/bin/ld</userinput></screen>
+  <para>Now that the temporary C libraries have been installed, all
+  tools compiled in the rest of this chapter should be linked against
+  these libraries. In order to accomplish this, the linker and the
+  compiler's specs file need to be adjusted.</para>
 
-<para>Test that we are linking to <filename class="directory">/tools</filename>.</para>
+  <para>The linker, adjusted at the end of the Embryo toolchain, needs
+  to be renamed so that it can be properly found and used. First, backup the
+  original linker, then replace it with the adjusted linker. We'll also
+  create a link to its counterpart in <filename class="directory">
+  /tools/$(gcc -dumpmachine)/bin</filename></para>
 
-<screen><userinput>echo 'int main(){return 0;}' | ${target}-gcc -x c -
+<screen><userinput>mv -v /tools/bin/{ld,ld-old}
+mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
+mv -v /tools/bin/{ld-new,ld}
+ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld</userinput></screen>
+
+  <para>From this point onwards, everything will link only against the
+  libraries in <filename class="directory">/tools/lib</filename>.</para>
+
+  <para>The next task is to point GCC to the new dynamic linker. This is done by
+  dumping GCC's <quote>specs</quote> file to a location where GCC will look for it
+  by default. A simple <command>sed</command> substitution then alters the
+  dynamic linker that GCC will use:</para>
+
+<screen condition="uclibc"><userinput>gcc -dumpspecs | sed 's@^/lib/ld-linux.so.2@/tools/lib/ld-uClibc.so.0 at g' \
+    > `dirname $(gcc -print-libgcc-file-name)`/specs</userinput></screen>
+
+<screen condition="glibc"><userinput>gcc -dumpspecs | sed 's@^/lib/ld-linux.so.2@/tools&@g' \
+    > `dirname $(gcc -print-libgcc-file-name)`/specs</userinput></screen>
+
+  <para condition="uclibc">It is recommended that the above command be copy-and-pasted in order to
+  ensure accuracy. Alternatively, the specs file can be edited by hand. This is
+  done by replacing every occurrence of <quote>/lib/ld-linux.so.2</quote> with
+  <quote>/tools/lib/ld-uClibc.so.0</quote></para>
+
+  <para condition="glibc">It is recommended that the above command be copy-and-pasted in order to
+  ensure accuracy. Alternatively, the specs file can be edited by hand. This is
+  done by replacing every occurrence of <quote>/lib/ld-linux.so.2</quote> with
+  <quote>/tools/lib/ld-linux.so.2</quote></para>
+
+  <para>Be sure to visually inspect the specs file in order to verify the
+  intended changes have been made.</para>
+
+  <para>During the build process, GCC runs a script
+  (<command>fixincludes</command>) that scans the system for header files
+  that may need to be fixed (they might contain syntax errors, for example),
+  and installs the fixed versions in a private include directory. There is a
+  possibility that, as a result of this process, some header files from the
+  host system have found their way into GCC's private include directory. As
+  the rest of this chapter only requires the headers from GCC and Glibc,
+  which have both been installed at this point, any <quote>fixed</quote>
+  headers can safely be removed. This helps to avoid any host headers
+  polluting the build environment. Run the following commands to remove the
+  header files in GCC's private include directory (you may find it easier to
+  copy and paste these commands, rather than typing them by hand, due to
+  their length):</para>
+
+<screen><userinput>GCC_INCLUDEDIR=`dirname $(gcc -print-libgcc-file-name)`/include &&
+find ${GCC_INCLUDEDIR}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; &&
+rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_INCLUDEDIR}/*` &&
+unset GCC_INCLUDEDIR</userinput></screen>
+
+  <caution>
+    <para>At this point, it is imperative to stop and ensure that the basic
+    functions (compiling and linking) of the new toolchain are working as
+    expected. To perform a sanity check, run the following commands:</para>
+
+<screen><userinput>echo 'int main(){return 0;}' > dummy.c
+cc dummy.c
 readelf -l a.out | grep ': /tools'</userinput></screen>
 
-<para>Should return: </para>
+    <para>If everything is working correctly, there should be no errors,
+    and the output of the last command will be of the form:</para>
 
-<screen><computeroutput>[Requesting program interpreter: /tools/lib/something.so.]</computeroutput></screen>
+<screen condition="uclibc"><computeroutput>[Requesting program interpreter:
+    /tools/lib/ld-uClibc.so.0]</computeroutput></screen>
 
-<para>Now that the adjusted linker is installed, the Binutils build and source
-directories should be removed.</para>
+<screen condition="glibc">><computeroutput>[Requesting program interpreter:
+    /tools/lib/ld-linux.so.2]</computeroutput></screen>
 
+    <para>Note that <filename class="directory">/tools/lib</filename>
+    appears as the prefix of the dynamic linker.</para>
+
+    <para>If the output is not shown as above or there was no output at all,
+    then something is wrong. Investigate and retrace the steps to find out
+    where the problem is and correct it. This issue must be resolved before
+    continuing on. First, perform the sanity check again, using
+    <command>gcc</command> instead of <command>cc</command>. If this works,
+    then the <filename class="symlink">/tools/bin/cc</filename> symlink is
+    missing. Revisit <xref linkend="ch-tools-embryo-toolchain" role=","/> and install
+    the symlink. Next, ensure that the <envar>PATH</envar> is correct. This
+    can be checked by running <command>echo $PATH</command> and verifying that
+    <filename class="directory">/tools/bin</filename> is at the head of the
+    list. If the <envar>PATH</envar> is wrong it could mean that you are not
+    logged in as user <systemitem class="username">lfs</systemitem> or that
+    something went wrong back in <xref linkend="prepare-settingenviron"
+    role="."/> Another option is that something may have gone wrong with the
+    specs file amendment above. In this case, redo the specs file amendment,
+    being careful to copy-and-paste the commands.</para>
+
+    <para>Once all is well, clean up the test files:</para>
+
+<screen><userinput>rm -v dummy.c a.out</userinput></screen>
+
+    <para>Building TCL in the next section will serve as an additional check that
+    the toolchain has been built properly.  If TCL fails to build, it is an
+    indication that something has gone wrong with the Binutils, GCC, or Glibc
+    installation, but not with TCL itself.</para>
+  </caution>
+
 </sect1>
-

Modified: trunk/BOOK/chapter05/bash.xml
===================================================================
--- trunk/BOOK/chapter05/bash.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/bash.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,10 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Bash</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i {.,builtins}/Makefile.in</userinput></screen>
-
 <para>Prepare Bash for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools --without-bash-malloc</userinput></screen>
@@ -51,8 +47,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make tests</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>
@@ -60,7 +54,7 @@
 <para>Make a link for the programs that use <command>sh</command> for
 a shell:</para>
 
-<screen><userinput>ln -s bash /tools/bin/sh</userinput></screen>
+<screen><userinput>ln -vs bash /tools/bin/sh</userinput></screen>
 
 </sect2>
 

Deleted: trunk/BOOK/chapter05/binutils-cross.xml
===================================================================
--- trunk/BOOK/chapter05/binutils-cross.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/binutils-cross.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
-  <!ENTITY % general-entities SYSTEM "../general.ent">
-  %general-entities;
-]>
-<sect1 id="ch-tools-binutils-cross" role="wrap">
-<title>Binutils-&binutils-version; Cross Linker</title>
-<?dbhtml filename="binutils-cross.html"?>
-
-<indexterm zone="ch-tools-binutils-cross">
-<primary sortas="a-Binutils">Binutils</primary>
-<secondary>tools, cross linker</secondary></indexterm>
-
-<sect2 role="package"><title/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/binutils.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
-
-<segmentedlist>
-<segtitle>&buildtime;</segtitle>
-<segtitle>&diskspace;</segtitle>
-<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
-</segmentedlist>
-
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/binutils.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
-
-</sect2>
-
-<sect2 role="installation">
-<title>Installation of Binutils</title>
-
-<para>This package is known to have issues when its default
-optimization flags (including the <parameter>-march</parameter> and
-<parameter>-mcpu</parameter> options) are changed. If any environment
-variables that override default optimizations have been defined, such
-as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
-unset them when building Binutils.</para>
-
-<para condition="uclibc">Apply the next patch to add uClibc support to Binutils.</para>
-
-<screen condition="uclibc"><userinput>patch -Np1 -i ../&binutils-uClibc_conf-patch;</userinput></screen>
-
-<para>Apply this patch to make a few utilities use proper syntax during compile and
-testing.</para>
-
-<screen><userinput>patch -Np1 -i ../&binutils-posix-patch;</userinput></screen>
-
-<para>The Binutils documentation recommends building Binutils outside of the
-source directory in a dedicated build directory:</para>
-
-<screen><userinput>mkdir -v ../binutils-build
-cd ../binutils-build</userinput></screen>
-
-<para>Prepare Binutils for compilation:</para>
-
-<screen><userinput>../binutils-&binutils-version;/configure --prefix=/tools \
-    --disable-shared  --disable-nls --target=${target}</userinput></screen>
-
-<para>Compile the package:</para>
-
-<screen><userinput>make</userinput></screen>
-
-<para>Install the package:</para>
-
-<screen><userinput>make install</userinput></screen>
-
-<para>Next, prepare the linker for the <quote>Adjusting</quote> phase
-later on:</para>
-
-<screen><userinput>make -C ld clean
-make -C ld LIB_PATH=/tools/lib
-install -v ld/ld-new /tools/bin/${target}-ld-new</userinput></screen>
-
-</sect2>
-
-<sect2 role="content"><title/>
-<para>Details on this package are located in <xref
-linkend="contents-binutils" role="."/></para>
-</sect2>
-
-</sect1>
-

Deleted: trunk/BOOK/chapter05/binutils.xml
===================================================================
--- trunk/BOOK/chapter05/binutils.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/binutils.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
-  <!ENTITY % general-entities SYSTEM "../general.ent">
-  %general-entities;
-]>
-<sect1 id="ch-tools-binutils" role="wrap">
-<title>Binutils-&binutils-version;</title>
-<?dbhtml filename="binutils.html"?>
-
-<indexterm zone="ch-tools-binutils">
-<primary sortas="a-Binutils">Binutils</primary>
-<secondary>tools</secondary></indexterm>
-
-<sect2 role="package"><title/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/binutils.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
-
-<segmentedlist>
-<segtitle>&buildtime;</segtitle>
-<segtitle>&diskspace;</segtitle>
-<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
-</segmentedlist>
-
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/binutils.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
-
-</sect2>
-
-<sect2 role="installation">
-<title>Installation of Binutils</title>
-
-<para>This package is known to have issues when its default
-optimization flags (including the <parameter>-march</parameter> and
-<parameter>-mcpu</parameter> options) are changed. If any environment
-variables that override default optimizations have been defined, such
-as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
-unset them when building Binutils.</para>
-
-<para condition="uclibc">Apply the next patch to add uClibc support to Binutils.</para>
-
-<screen condition="uclibc"><userinput>patch -Np1 -i ../&binutils-uClibc_conf-patch;</userinput></screen>
-
-<para>Apply a patch to add PAX_FLAGS elf header markings used by PaX kernels.</para>
-
-<screen><userinput>patch -Np1 -i ../&binutils-pt_pax-patch;</userinput></screen>
-
-<para>Apply this patch to make a few utilities use proper syntax during compile and
-testing.</para>
-
-<screen><userinput>patch -Np1 -i ../&binutils-posix-patch;</userinput></screen>
-
-<para>The Binutils documentation recommends building Binutils outside of the
-source directory in a dedicated build directory:</para>
-
-<screen><userinput>mkdir -v ../binutils-build
-cd ../binutils-build</userinput></screen>
-
-<para>Prepare Binutils for compilation:</para>
-
-<screen><userinput>env CC=${target}-gcc \
-../binutils-&binutils-version;/configure --prefix=/tools \
-    --host=${target} --build=${target} --target=${target} \
-    --enable-shared --with-lib-path=/tools/lib</userinput></screen>
-
-<para>Compile the package:</para>
-
-<screen><userinput>make</userinput></screen>
-
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
-<para>Install the package:</para>
-
-<screen><userinput>make install</userinput></screen>
-
-<para>Now prepare the linker for the <quote>Re-adjusting</quote> phase in the next
-chapter:</para>
-
-<screen><userinput>make -C ld clean
-make -C ld LIB_PATH=/usr/lib:/lib
-install -v ld/ld-new /tools/bin/ld-new</userinput></screen>
-
-</sect2>
-
-<sect2 role="content"><title/>
-<para>Details on this package are located in <xref
-linkend="contents-binutils" role="."/></para>
-</sect2>
-
-</sect1>
-

Modified: trunk/BOOK/chapter05/bison.xml
===================================================================
--- trunk/BOOK/chapter05/bison.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/bison.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,10 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Bison</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i Makefile.in</userinput></screen>
-
 <para>Prepare Bison for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>
@@ -39,8 +35,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Modified: trunk/BOOK/chapter05/bzip2.xml
===================================================================
--- trunk/BOOK/chapter05/bzip2.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/bzip2.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -30,10 +30,6 @@
 <para>This is installed late to work around the uClibc bug in Tar-1.14* which may
 exist on the host system.</para>
 
-<para>Apply a patch to ... EDIT ME</para>
-
-<screen><userinput>patch -Np1 -i ../&bzip2-hardened_cflags-patch;</userinput></screen>
-
 <para>The Bzip2 package does not contain a <command>configure</command>
 script. Compile it with:</para>
 

Modified: trunk/BOOK/chapter05/chapter05.xml
===================================================================
--- trunk/BOOK/chapter05/chapter05.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/chapter05.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -9,19 +9,15 @@
 <?dbhtml filename="chapter05.html"?>
 
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="introduction.xml"/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="linux-libc-headers.xml"/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="glibc-headers.xml"/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="uclibc-headers.xml"/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="binutils-cross.xml"/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gcc-cross.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="embryo-toolchain.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="linux-headers.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="glibc.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="uclibc.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="adjusting.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="tcl.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="expect.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="dejagnu.xml"/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="binutils.xml"/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gcc.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="cocoon-toolchain.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="ncurses.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="bash.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="bzip2.xml"/>

Added: trunk/BOOK/chapter05/cocoon-toolchain.xml
===================================================================
--- trunk/BOOK/chapter05/cocoon-toolchain.xml	                        (rev 0)
+++ trunk/BOOK/chapter05/cocoon-toolchain.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -0,0 +1,379 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+  "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+  <!ENTITY % general-entities SYSTEM "../general.ent">
+  %general-entities;
+]>
+
+<sect1 id="ch-tools-cocoon-toolchain" role="wrap">
+<?dbhtml filename="cocoon-toolchain.html"?>
+<title>Cocoon Toolchain</title>
+
+<indexterm zone="ch-tools-cocoon-toolchain">
+<primary sortas="a-Cocoon-Toolchain">Cocoon-Toolchain</primary>
+<secondary>tools, cocoon toolchain</secondary></indexterm>
+
+<sect2 role="package"><title/>
+<para>The Cocoon toolchain contains the GNU Compiler Collection (GCC), which
+includes the C and C++ compilers, and Binutils, which includes an assembler
+and linker.</para>
+
+<segmentedlist>
+<segtitle>&buildtime;</segtitle>
+<segtitle>&diskspace;</segtitle>
+<seglistitem><seg>About 4 SBU</seg><seg>?? MB</seg></seglistitem>
+</segmentedlist>
+
+<segmentedlist>
+<segtitle>&dependencies;</segtitle>
+<seglistitem><seg>Bash, Bison, Binutils, Coreutils, Diffutils, Findutils, Flex,
+Gawk, GCC, Gawk, Gettext, Glibc, Grep, Make, M4, Perl, Sed, and Texinfo</seg></seglistitem>
+</segmentedlist>
+
+</sect2>
+
+<sect2 role="installation">
+<title>Installation of the Cocoon Toolchain</title>
+
+<para>Unlike the previous toolchain installation, this toolchain does
+not need to be bootstrapped. Each component will only be built once.</para>
+
+<para>This package is known to have issues when its default
+optimization flags (including the <option>-march</option> and
+<option>-mtune</option> options) are changed. If any environment
+variables that override default optimizations have been defined, such
+as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
+unset them when building GCC.</para>
+
+<para>Unpack the binutils-&binutils-version;, gcc-core-&gcc-version;, and
+gcc-g++-&gcc-version; source packages but do not change directory. Then
+combine the two packages to the same directory with the following commands:</para>
+
+<screen><userinput>mkdir -v cocoon-toolchain/
+cp -va binutils-&binutils-version;/{bfd,binutils,gas,gprof,include,ld,opcodes} \
+    cocoon-toolchain/
+cp -va gcc-&gcc-version;/* cocoon-toolchain/
+cd cocoon-toolchain/</userinput></screen>
+
+<para>The binutils-&binutils-version;/ and gcc-&gcc-version;/ directories
+can be removed.</para>
+
+<para>Binutils-&binutils-version; and GCC-&gcc-version; do not use Posix
+complaint command syntax with the <command>head</command> and
+<command>tail</command> commands. Although this is not critical it should
+be fixed. Do so with the following commands:</para>
+
+<screen><userinput>cp -vi libstdc++-v3/configure{,.orig}
+sed 's/head -1/head -n 1/g' libstdc++-v3/configure.orig > libstdc++-v3/configure
+cp -vi ltcf-c.sh{,.orig}
+sed 's/head -1/head -n 1/g' ltcf-c.sh.orig > ltcf-c.sh
+cp -vi ltcf-gcj.sh{,.orig}
+sed 's/head -1/head -n 1/g' ltcf-gcj.sh.orig > ltcf-gcj.sh
+cp -vi configure{,.orig}
+sed 's/tail +16c/tail -c +16/g' configure.orig > configure
+cp -vi gas/Makefile.in{,.orig}
+sed 's/tail +16c/tail -c +16/g' gas/Makefile.in.orig > gas/Makefile.in
+cp -vi gcc/Makefile.in{,.orig}
+sed 's/tail +16c/tail -c +16/g' gcc/Makefile.in.orig > gcc/Makefile.in
+cp -vi gcc/configure{,.orig}
+sed 's/tail -3/tail -n 3/g' gcc/configure.orig > gcc/configure
+cp -vi ld/testsuite/ld-bootstrap/bootstrap.exp{,.orig}
+sed 's/tail +140/tail -n +140/g' ld/testsuite/ld-bootstrap/bootstrap.exp.orig \
+    > ld/testsuite/ld-bootstrap/bootstrap.exp</userinput></screen>
+
+<para>This version of GCC has a small bug/typo with RPATH_ENVVAR value for
+bfd and opcode. Use the following commands to fix this bug, so that
+<quote>--enable-shared</quote> will work:</para>
+
+<screen><userinput>cp -vi Makefile.in{,.orig}
+sed -e 's@/.:$$r@/.libs:$$r@' -e 's@/.:@/.libs:@' \
+    Makefile.in.orig > Makefile.in</userinput></screen>
+
+<para>We can change the default behavior of GCC to add various flags by
+creating a hardened specs header file which redefines GCC spec strings. A
+detailed summary of the GCC specs is available here:
+<ulink url="http://developer.apple.com/documentation/developertools/gcc-4.0.1/gcc/Spec-Files.html"/>.</para>
+
+<para>I'll add a description here after these specs are perfected. For now
+these specs disable SSP when <option>-DIS_IN_rtld</option> or
+<option>-D_LIBC*</option> are used. I don't think much can be done about
+using SSP on <filename class="libraryfile">ld.so</filename>, but parts of
+LIBC might be buildable with <option>-fstack-protector</option>. Paste
+this:</para>
+
+<screen><userinput><literal>echo '#ifndef HARDENED_SPECS_H
+#define HARDENED_SPECS_H
+
+#if defined(__i386__) && defined(__linux__) && defined(__ELF__) \
+	&& defined(HAVE_LD_PIE) && defined(TARGET_LIBC_PROVIDES_SSP)
+
+#undef CPP_SPEC
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT} \
+	%{DFORTIFY_SOURCE*|no-fortify:;:-DFORTIFY_SOURCE=2}"
+
+#undef CC1_SPEC
+#define CC1_SPEC "%(cc1_cpu) %{profile:-p} %{no-fortify:} \
+	%{static|D__KERNEL__|fpic|fPIC|fpie|fPIE|no-fpic|fno-pic|fno-PIC| \
+	no-pic:;shared|nostdlib|nostartfiles:-fPIC} \
+	%{static|D__KERNEL__|fpic|fPIC|fpie|fPIE|no-fpie|fno-pie| \
+	shared|nostdlib|nostartfiles:;:-fPIE} \
+	%{D__KERNEL__|DIS_IN_rtld*|D_LIBC*|fno-stack-protector| \
+	fstack-protector:;:-fstack-protector-all}"
+
+#undef CC1PLUS_SPEC
+#define CC1PLUS_SPEC CC1_SPEC
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC "%{ffast-math|funsafe-math-optimizations: \
+	crtfastmath.o%s} \
+	%{static|no-pie|nopie:crtend.o%s;:crtendS.o%s} crtn.o%s"
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "%{static:crtbeginT.o%s; \
+	no-pie|nopie:crtbegin.o%s;:crtbeginS.o%s} \
+	%{shared:;pg|p|profile:gcrt1.o%s;static|no-pie|nopie:crt1.o%s; \
+	:Scrt1.o%s} crti.o%s"
+
+#undef LINK_PIE_SPEC
+#define LINK_PIE_SPEC "%{pie:-pie} %{now:-z now} %{relro:-z relro} \
+	%{!static:%{!Bstatic: %{nonow|now:;:-z now} \
+	%{norelro|relro:;:-z relro} \
+	%{shared|Bshareable|i|r| \
+	pie|no-pie|nopie:;:-pie}}}"
+
+#else /* __i386__ && __linux__ && __ELF__ && HAVE_LD_PIE */
+#error "You are using an unsupported system. This header can not be used."
+#endif /* __i386__ && __linux__ && __ELF__ && HAVE_LD_PIE */
+#endif /* HARDENED_SPECS_H */' > gcc/hardened-specs.h</literal></userinput></screen>
+
+<para>This command includes the hardened-specs header in the right place:</para>
+
+<screen><userinput>cp -vi gcc/gcc.c gcc/gcc.c.orig
+sed -e '0,/.*config.h can define.*/s//#include "hardened-specs.h"\n&/' \
+    gcc/gcc.c.orig > gcc/gcc.c</userinput></screen>
+
+<para>Make a copy this file so we can use it again in chapter 6:</para>
+
+<screen><userinput>cp -v gcc/hardened-specs.h /tools</userinput></screen>
+
+<para condition="uclibc">Apply this patch to add uClibc to the configure script:</para>
+
+<screen condition="uclibc"><userinput>patch -Np1 -i ../&gcc-uClibc_conf-patch;</userinput></screen>
+
+<para>Under normal circumstances the GCC fixincludes script is run in order
+to fix potentially broken header files. As GCC-&gcc-version; and libc have
+already been installed at this point, and their respective header files
+are known to not require fixing, the fixincludes script is not required.
+The script may in fact pollute the build environment by installing fixed
+headers from the host system into GCC's private include directory. The
+running of the fixincludes script can be suppressed by issuing the following
+commands:</para>
+
+<screen><userinput>cp -vi gcc/Makefile.in{,.orig2}
+sed 's@\./fixinc\.sh at -c true@' gcc/Makefile.in.orig2 > gcc/Makefile.in</userinput></screen>
+
+<para>Although we don't use fixincludes we still build it. This is the only
+place where using <parameter>--enable-werror-always</parameter> will cause
+the build to fail due to a warning that <filename>fixincl.x</filename>
+uses string constants longer than what the C standard requires compilers to
+handle. This is somewhat fixed in GCC-4.2 with the addition of the
+<option>-Wno-overlength-strings</option> compiler flag. We can supress the
+<option>-Werror</option> flag for fixincludes with the following
+<command>sed</command> command:</para>
+
+<screen><userinput>cp -vi fixincludes/Makefile.in{,.orig}
+sed 's/@WERROR@/-Wno-error/' fixincludes/Makefile.in.orig \
+    > fixincludes/Makefile.in</userinput></screen>
+
+<para>Don't build <filename class="libraryfile">libssp.[a,so]</filename> with
+<option>-fstack-protector[-all]</option>. This library won't be used but
+will be built and installed:</para>
+
+<screen><userinput>cp -vi libssp/Makefile.in{,.orig}
+sed 's/^AM_CFLAGS =/& -fno-stack-protector/' \
+    libssp/Makefile.in.orig > libssp/Makefile.in</userinput></screen>
+
+<para>Don't build <filename class="libraryfile">libgcc.[a,so]</filename> with
+<option>-fstack-protector[-all]</option>.
+<filename class="libraryfile">libgcc.a</filename> is often linked into
+other static libraries and they will fail to resolve __stack_chk symbols:</para>
+
+<screen><userinput>cp -vi gcc/Makefile.in{,.orig3}
+sed 's/^LIBGCC2_CFLAGS =/& -fno-stack-protector/' \
+    gcc/Makefile.in.orig3 > gcc/Makefile.in</userinput></screen>
+
+<para>Don't build <filename class="libraryfile">crtbegin[,S,T].o</filename> or
+<filename class="libraryfile">crtend[,S].o</filename> files with
+<option>-fstack-protector[-all]</option>. These libraries should be devoid
+of dependencies (including the depenency to libc for SSP functions):</para>
+
+<screen><userinput>cp -vi gcc/Makefile.in{,.orig4}
+sed 's/^CRTSTUFF_CFLAGS =/& -fno-stack-protector/' \
+    gcc/Makefile.in.orig4 > gcc/Makefile.in</userinput></screen>
+
+<para>Apply the following patch to allow us to change the location of GCC's
+default dynamiclinker. This patch also adds the
+<parameter>--with-nostdinc</parameter> option, and points the SSP checking
+routines in <command>configure</command> to our new libc:</para>
+
+<screen><userinput>patch -Np1 -i ../&gcc-specs_x86-patch;</userinput></screen>
+
+<para>The GCC documentation recommends building outside of the source
+directory in a dedicated build/object directory:</para>
+
+<screen><userinput>mkdir -v ../cocoon-build/
+cd ../cocoon-build/</userinput></screen>
+
+<para>Prepare the toolchain for compilation:</para>
+
+<screen><userinput>../cocoon-toolchain/configure --prefix=/tools \
+    --with-local-prefix=/tools --enable-shared \
+    --enable-clocale=gnu --enable-threads=posix \
+    --enable-__cxa_atexit --enable-languages=c,c++ \
+    --with-dynamic-linker=/tools/lib/<literal condition="glibc">ld-linux.so.2</literal><literal condition="uclibc">ld-uClibc.so.0</literal> --with-nostdinc \
+    --with-lib-path=/tools/lib --disable-libstdcxx-pch \
+    --enable-checking --enable-werror-always</userinput></screen>
+
+<variablelist>
+    <title>The meaning of the configure options:</title>
+
+      <varlistentry>
+        <term><parameter>--enable-shared</parameter></term>
+        <listitem>
+          <para>This switch allows the building of <filename
+          class="libraryfile">libbfd-&binutils-version;.so</filename> and
+          <filename class="libraryfile">libopcodes-&binutils-version;.so</filename>
+          from the Binutils package. This switch is the default in the GCC
+          package and allows the building of <filename
+          class="libraryfile">libgcc_s.so.1</filename> and <filename
+          class="libraryfile">libgcc_eh.a</filename>.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-clocale=gnu</parameter></term>
+        <listitem>
+          <para>This option ensures the correct locale model is selected
+          for the C++ libraries under all circumstances. If the configure
+          script finds the <emphasis>de_DE</emphasis> locale installed,
+          it will select the correct gnu locale model. However, if the
+          <emphasis>de_DE</emphasis> locale is not installed, there is the
+          risk of building Application Binary Interface (ABI)-incompatible
+          C++ libraries because the incorrect generic locale model may be
+          selected.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-threads=posix</parameter></term>
+        <listitem>
+          <para>This enables C++ exception handling for multi-threaded code.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-__cxa_atexit</parameter></term>
+        <listitem>
+          <para>This option allows use of <function>__cxa_atexit</function>,
+          rather than <function>atexit</function>, to register C++ destructors
+          for local statics and global objects. This option 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.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-languages=c,c++</parameter></term>
+        <listitem>
+          <para>This option ensures that both the C and C++ compilers are
+          built. This option is provided by the specs patch.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--with-dynamic-linker</parameter></term>
+        <listitem>
+          <para>This option configures GCC to use our dynamic linker
+          located in /tools/lib, rather than the dynamic linker in the
+          host system.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--with-nostdinc</parameter></term>
+        <listitem>
+          <para>This option configures GCC not to look in /usr/include
+          or /usr/local/include for header files. This option is provided
+          by the specs patch.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--with-lib-path=/tools/lib</parameter></term>
+        <listitem>
+          <para>This tells the configure script to specify the library
+          search path during the compilation of Binutils, resulting in
+          <filename class="directory">/tools/lib</filename> being passed
+          to the linker. This prevents the linker from searching through
+          library directories on the host.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--disable-libstdcxx-pch</parameter></term>
+        <listitem>
+          <para>Do not build the pre-compiled header (PCH) for
+          <filename class="libraryfile">libstdc++</filename>. It takes up a
+          lot of space, and we have no use for it.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-werror-always</parameter></term>
+        <listitem>
+         <para>This switch enables the use of <option>-Werror</option> in
+          every stage of the build.</para>
+        </listitem>
+      </varlistentry>
+
+</variablelist>
+
+<para>Compile the toolchain:</para>
+
+<screen><userinput>make</userinput></screen>
+
+<para>Install the toolchain:</para>
+
+<screen><userinput>make install</userinput></screen>
+
+<important><para>Confirm the new compiler is defining PIC, SSP, and FORTIFY_SOURCE:</para>
+
+<screen><userinput>echo | cc -dM -E - | grep -E 'PIC|SSP|FORTIFY'</userinput></screen>
+
+<para>This should return:</para>
+
+<screen><computeroutput>#define FORTIFY_SOURCE 2
+#define __SSP_ALL__ 2
+#define __PIC__ 1</computeroutput></screen>
+
+<para>Otherwise something went wrong and you should verify libc was installed
+to <filename class="directory">/tools/lib</filename>, and reinstall it and this
+toolchain.</para></important>
+
+<para>Next, prepare the linker for the <quote>Re-adjusting</quote> phase
+in the next chapter:</para>
+
+<screen><userinput>make -C ld clean
+make -C ld LIB_PATH=/usr/lib:/lib
+install -v ld/.libs/ld-new /tools/bin</userinput></screen>
+
+</sect2>
+
+<sect2 role="content"><title/>
+<para>Details on this package are located in <xref
+linkend="contents-butterfly-toolchain" role="."/></para>
+</sect2>
+
+</sect1>
+

Modified: trunk/BOOK/chapter05/coreutils.xml
===================================================================
--- trunk/BOOK/chapter05/coreutils.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/coreutils.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,10 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Coreutils</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i src/Makefile.in</userinput></screen>
-
 <para>Prepare Coreutils for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>
@@ -39,12 +35,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make check</userinput>.  The
-<parameter>RUN_EXPENSIVE_TESTS=yes</parameter> parameter tells the
-test suite to run several additional tests that are considered
-relatively expensive (in terms of CPU power and memory usage) on some
-platforms, but generally are not a problem on Linux.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Modified: trunk/BOOK/chapter05/dejagnu.xml
===================================================================
--- trunk/BOOK/chapter05/dejagnu.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/dejagnu.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -30,8 +30,7 @@
 
 <para>Prepare DejaGNU for compilation:</para>
 
-<screen><userinput>env CC=${target}-gcc \
-    ./configure --prefix=/tools</userinput></screen>
+<screen><userinput>./configure --prefix=/tools</userinput></screen>
 
 <para>Build and install the package:</para>
 

Modified: trunk/BOOK/chapter05/diffutils.xml
===================================================================
--- trunk/BOOK/chapter05/diffutils.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/diffutils.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,10 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Diffutils</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i src/Makefile.in</userinput></screen>
-
 <para>Prepare Diffutils for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>

Added: trunk/BOOK/chapter05/embryo-toolchain.xml
===================================================================
--- trunk/BOOK/chapter05/embryo-toolchain.xml	                        (rev 0)
+++ trunk/BOOK/chapter05/embryo-toolchain.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+  "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+  <!ENTITY % general-entities SYSTEM "../general.ent">
+  %general-entities;
+]>
+
+<sect1 id="ch-tools-embryo-toolchain" role="wrap">
+<?dbhtml filename="embryo-toolchain.html"?>
+<title>Embryo Toolchain</title>
+
+<indexterm zone="ch-tools-embryo-toolchain">
+<primary sortas="a-Embryo-Toolchain">Embryo-Toolchain</primary>
+<secondary>tools, embryo toolchain</secondary></indexterm>
+
+<sect2 role="package"><title/>
+<para>The Embryo toolchain contains the GNU Compiler Collection (GCC), which
+includes the C and C++ compilers, and Binutils, which includes an assembler
+and linker.</para>
+
+<segmentedlist>
+<segtitle>&buildtime;</segtitle>
+<segtitle>&diskspace;</segtitle>
+<seglistitem><seg>About 18 SBU</seg><seg>?? MB</seg></seglistitem>
+</segmentedlist>
+
+<segmentedlist>
+<segtitle>&dependencies;</segtitle>
+<seglistitem><seg>Bash, Bison, Binutils, Coreutils, Diffutils, Findutils, Flex,
+Gawk, GCC, Gawk, Gettext, Glibc, Grep, Make, M4, Perl, Sed, and Texinfo</seg></seglistitem>
+</segmentedlist>
+
+</sect2>
+
+<sect2 role="installation">
+<title>Installation of the Embryo Toolchain</title>
+
+<para>We will be building Binutils and GCC from a combined source
+tree using the GCC Top Level Makefile. For more information about
+the Top Level Makefile build system see:
+<ulink url="http://gcc.gnu.org/install/"/> and
+<ulink url="http://gcc.gnu.org/wiki/Top-Level Bootstrap/"/>.</para>
+
+<para>This system will allow us to perform a 3 stage bootstrap, which
+will compile Binutils, then GCC with that Binutils, then Binutils with
+that GCC, then Binutils again with the new GCC, then GCC again with the
+second Binutils, then Binutils again with the second GCC, then GCC again
+with the third Binutils, then Binutils again with the third GCC. This
+process also recompiles the libraries. This is the ideal method to make
+sure we have a solid toolchain.</para>
+
+<para>This package is known to have issues when its default
+optimization flags (including the <parameter>-march</parameter> and
+<parameter>-mtune</parameter> options) are changed. If any environment
+variables that override default optimizations have been defined, such
+as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
+unset them when building GCC.</para>
+
+<para>Unpack both the binutils-&binutils-version; and gcc-core-&gcc-version;
+source tarballs but do not change directory. Then combine them in the same
+directory with the following commands:</para>
+
+<screen><userinput>mkdir -v embryo-toolchain/
+cp -va binutils-&binutils-version;/{bfd,binutils,gas,gprof,include,ld,opcodes} \
+    embryo-toolchain/
+cp -va gcc-&gcc-version;/* embryo-toolchain/
+cd embryo-toolchain/</userinput></screen>
+
+<para>The binutils-&binutils-version;/ and gcc-&gcc-version;/ directories
+can be removed.</para>
+
+<para>Binutils-&binutils-version; and GCC-&gcc-version; do not use Posix
+complaint command syntax with the <command>head</command> and
+<command>tail</command> commands. Although this is not critical it should
+be fixed. Do so with the following commands:</para>
+
+<screen><userinput>cp -vi libstdc++-v3/configure{,.orig}
+sed 's/head -1/head -n 1/g' libstdc++-v3/configure.orig > libstdc++-v3/configure
+cp -vi ltcf-c.sh{,.orig}
+sed 's/head -1/head -n 1/g' ltcf-c.sh.orig > ltcf-c.sh
+cp -vi ltcf-gcj.sh{,.orig}
+sed 's/head -1/head -n 1/g' ltcf-gcj.sh.orig > ltcf-gcj.sh
+cp -vi configure{,.orig}
+sed 's/tail +16c/tail -c +16/g' configure.orig > configure
+cp -vi gas/Makefile.in{,.orig}
+sed 's/tail +16c/tail -c +16/g' gas/Makefile.in.orig > gas/Makefile.in
+cp -vi gcc/Makefile.in{,.orig}
+sed 's/tail +16c/tail -c +16/g' gcc/Makefile.in.orig > gcc/Makefile.in
+cp -vi gcc/configure{,.orig}
+sed 's/tail -3/tail -n 3/g' gcc/configure.orig > gcc/configure
+cp -vi ld/testsuite/ld-bootstrap/bootstrap.exp{,.orig}
+sed 's/tail +140/tail -n +140/g' ld/testsuite/ld-bootstrap/bootstrap.exp.orig \
+    > ld/testsuite/ld-bootstrap/bootstrap.exp</userinput></screen>
+
+<para condition="uclibc">Apply this patch to add uClibc to the configure script.</para>
+
+<screen condition="uclibc"><userinput>patch -Np1 -i ../&gcc-uClibc_conf-patch;</userinput></screen>
+
+<para>We want to make this a PIC compiler so that everything we compile with
+this GCC will be built the same way in the next chapter. For example Glibc's
+utilities will use different assembly code if the compiler defines PIC.
+Packages like Glibc and Libibery do not use the <quote>--with-pic</quote>
+<command>configure</command> switch to add -fPIC to compiler flags. This
+<command>sed</command> command will hardcode -fPIC into GCC's specs:</para>
+
+<screen><userinput><literal>cp -vi gcc/config/i386/linux.h{,.orig}
+sed 's/^\(#define CC1_SPEC.*\)\("\)$/\1 %{static|fno-pic|fpic|fPIC:;:-fPIC}\2/' \
+    gcc/config/i386/linux.h.orig > gcc/config/i386/linux.h</literal></userinput></screen>
+
+<para>The GCC documentation recommends building outside of the source
+directory in a dedicated build/object directory:</para>
+
+<screen><userinput>mkdir -v ../embryo-build/
+cd ../embryo-build/</userinput></screen>
+
+<para>Prepare the toolchain for compilation:</para>
+
+<screen><userinput>../embryo-toolchain/configure --prefix=/tools \
+    --with-local-prefix=/tools --with-pic --disable-nls \
+    --disable-libmudflap --disable-libssp \
+    --enable-languages=c --enable-checking \
+    --enable-werror --enable-bootstrap</userinput></screen>
+
+<variablelist>
+    <title>The meaning of the configure options:</title>
+
+      <varlistentry>
+	<term><parameter>--with-local-prefix=/tools</parameter></term>
+	<listitem>
+         <para>The purpose of this switch is to remove <filename
+          class="directory">/usr/local/include</filename> from
+          <command>gcc</command>'s include search path. This is not
+          absolutely essential, however, it helps to minimize the
+          influence of the host system.</para>
+	</listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--with-pic</parameter></term>
+        <listitem>
+         <para>This switch compiles static and shared libraries from PIC
+          objects, while normally only shared libraries are PIC. This is
+          added so that <option>-fPIC</option> is added in stage 1 before
+          the new PIC compiler is built.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--disable-libmudflap --disable-libssp</parameter></term>
+        <listitem>
+         <para>These switches disable the building of
+          <filename class="libraryfile">libmudflap[a,so]</filename> and
+          <filename class="libraryfile">libssp[a,so]</filename>. At this
+          point there is no reason to build these libraries, and in
+          the case of libssp we do not want GCC to configure itself
+          to use this library because we will be using the version
+          from libc instead.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-languages=c</parameter></term>
+        <listitem>
+          <para>This option ensures that only the C compiler is built.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-werror</parameter></term>
+        <listitem>
+         <para>This switch enables the -Werror compiler flag during
+          stage2 and later. The -Werror flag treats warnings as
+          errors and will halt the build process if warnings are
+          generated. This switch helps ensure our toolchain is built
+          with compliant code.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-checking</parameter></term>
+        <listitem>
+         <para>With this switch the compiler is built to perform
+          internal consistency checks and adds error checking
+          within the compiler.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-bootstrap</parameter></term>
+        <listitem>
+          <para>This option enables a 3 stage bootstrap.</para>
+        </listitem>
+      </varlistentry>
+
+</variablelist>
+
+<para>Compile the toolchain with a 3 stage bootstrap:</para>
+
+<screen><userinput>make</userinput></screen>
+
+<para>Install the toolchain:</para>
+
+<screen><userinput>make install</userinput></screen>
+
+<para>Create a symlink from <command>gcc</command> to <command>cc</command>.
+Some packages will need this:</para>
+
+<screen><userinput>ln -vs gcc /tools/bin/cc</userinput></screen>
+
+<important><para>Confirm the new compiler is defining PIC:</para>
+
+<screen><userinput>echo | cc -dM -E - | grep 'PIC'</userinput></screen>
+
+<para>This should return:</para>
+
+<screen><computeroutput>#define __PIC__ 1</computeroutput></screen>
+
+<para>Otherwise something went wrong and you might have to start over.
+Check that <filename class="directory">/tools</filename> is in your
+<envar>PATH</envar>. Check the <command>make install</command> output
+for errors.</para></important>
+
+<para>Then, prepare the linker for the <quote>Adjusting</quote> phase
+later on:</para>
+
+<screen><userinput>ln -vs stage3-bfd/ bfd
+ln -vs stage3-libiberty/ libiberty
+cp -va stage3-ld/ tools-ld
+make -C tools-ld/ clean
+make -C tools-ld/ LIB_PATH=/tools/lib CC=/tools/bin/gcc
+install -v tools-ld/ld-new /tools/bin/ld-new</userinput></screen>
+
+</sect2>
+
+<sect2 role="content"><title/>
+<para>Details on this package are located in <xref
+linkend="contents-butterfly-toolchain" role="."/> and
+<xref linkend="contents-butterfly-toolchain" role="."/></para>
+</sect2>
+
+</sect1>
+

Modified: trunk/BOOK/chapter05/expect.xml
===================================================================
--- trunk/BOOK/chapter05/expect.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/expect.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -1,123 +1,158 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+  "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
   <!ENTITY % general-entities SYSTEM "../general.ent">
   %general-entities;
 ]>
+
 <sect1 id="ch-tools-expect" role="wrap">
-<title>Expect-&expect-version;</title>
-<?dbhtml filename="expect.html"?>
+  <?dbhtml filename="expect.html"?>
 
-<indexterm zone="ch-tools-expect"><primary sortas="a-Expect">Expect</primary></indexterm>
+  <title>Expect-&expect-version;</title>
 
-<sect2 role="package"><title/>
-<para>The Expect package contains a program for carrying out scripted dialogues
-with other interactive programs.</para>
+  <indexterm zone="ch-tools-expect">
+    <primary sortas="a-Expect">Expect</primary>
+  </indexterm>
 
-<segmentedlist>
-<segtitle>&buildtime;</segtitle>
-<segtitle>&diskspace;</segtitle>
-<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
-</segmentedlist>
+  <sect2 role="package">
+    <title/>
 
-<segmentedlist>
-<segtitle>&dependencies;</segtitle>
-<seglistitem><seg>Bash, Binutils, Coreutils, Diffutils,
-GCC, Glibc, Grep, Make, Sed, and Tcl</seg></seglistitem>
-</segmentedlist>
-</sect2>
+    <para>The Expect package contains a program for carrying out scripted
+    dialogues with other interactive programs.</para>
 
-<sect2 role="installation">
-<title>Installation of Expect</title>
+    <segmentedlist>
+      <segtitle>&buildtime;</segtitle>
+      <segtitle>&diskspace;</segtitle>
+      <seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
+    </segmentedlist>
 
-<para>First, fix a bug that can result in false failures during the GCC test
-suite run:</para>
+    <segmentedlist>
+      <segtitle>&dependencies;</segtitle>
+      <seglistitem><seg>Bash, Binutils, Coreutils, Diffutils,
+      GCC, Glibc, Grep, Make, Sed, and Tcl</seg></seglistitem>
+    </segmentedlist>
 
+  </sect2>
+
+  <sect2 role="installation">
+    <title>Installation of Expect</title>
+
+    <para>First, fix a bug that can result in false failures during the GCC test
+    suite run:</para>
+
 <screen><userinput>patch -Np1 -i ../&expect-spawn-patch;</userinput></screen>
 
-<para>Now prepare Expect for compilation:</para>
+<para>Add <option>-pie</option>, and reset the timestamp on the
+<filename>configure</filename> script:</para>
 
-<screen><userinput>env CC=${target}-gcc \
-    ./configure --prefix=/tools --with-tcl=/tools/lib \
-        --with-tclinclude=/tools/include --with-x=no</userinput></screen>
+<screen><userinput>cp -v Makefile.in{,.orig}
+sed 's/^LDFLAGS =/& -pie/' Makefile.in.orig > Makefile.in
+touch configure</userinput></screen>
 
-<para>The meaning of the configure options:</para>
+    <para>Now prepare Expect for compilation:</para>
 
-<variablelist>
-<varlistentry>
-<term><parameter>--with-tcl=/tools/lib</parameter></term>
-<listitem><para>This ensures that the configure script finds the Tcl installation in
-the temporary tools location instead of possibly locating an existing
-one on the host system.</para></listitem>
-</varlistentry>
+<screen><userinput>./configure --prefix=/tools --with-tcl=/tools/lib \
+    --with-tclinclude=/tools/include --with-x=no</userinput></screen>
 
-<varlistentry>
-<term><parameter>--with-tclinclude=/tools/include</parameter></term>
-<listitem><para>This tells Expect where to find TCL's private headers.</para></listitem>
-</varlistentry>
+    <variablelist>
+      <title>The meaning of the configure options:</title>
 
-<varlistentry>
-<term><parameter>--with-x=no</parameter></term>
-<listitem><para>This tells the configure script not to search for Tk
-(the Tcl GUI component) or the X Window System libraries, both of
-which may reside on the host system.</para></listitem>
-</varlistentry>
-</variablelist>
+      <varlistentry>
+        <term><parameter>--with-tcl=/tools/lib</parameter></term>
+        <listitem>
+          <para>This ensures that the configure script finds the Tcl
+          installation in the temporary tools location instead of possibly
+          locating an existing one on the host system.</para>
+        </listitem>
+      </varlistentry>
 
-<para>Build the package:</para>
+      <varlistentry>
+        <term><parameter>--with-tclinclude=/tools/include</parameter></term>
+        <listitem>
+          <para>This explicitly tells Expect where to find Tcl's internal
+          headers. Using this option avoids conditions where
+          <command>configure</command> fails because it cannot automatically
+          discover the location of Tcl's headers.</para>
+        </listitem>
+      </varlistentry>
 
+      <varlistentry>
+        <term><parameter>--with-x=no</parameter></term>
+        <listitem>
+          <para>This tells the configure script not to search for Tk (the
+          Tcl GUI component) or the X Window System libraries, both of which
+          may reside on the host system but will not exist in the temporary
+          environment.</para>
+        </listitem>
+      </varlistentry>
+
+    </variablelist>
+
+    <para>Build the package:</para>
+
 <screen><userinput>make</userinput></screen>
 
-<para>Install the package:</para>
+    <para>Install the package:</para>
 
 <screen><userinput>make SCRIPTS="" install</userinput></screen>
 
-<para>The meaning of the make parameter:</para>
+    <variablelist>
+      <title>The meaning of the make parameter:</title>
 
-<variablelist>
-<varlistentry>
-<term><parameter>SCRIPTS=""</parameter></term>
-<listitem><para>This prevents installation of the supplementary expect
-scripts, which are not needed.</para></listitem>
-</varlistentry>
-</variablelist>
+      <varlistentry>
+        <term><parameter>SCRIPTS=""</parameter></term>
+        <listitem>
+          <para>This prevents installation of the supplementary Expect
+          scripts, which are not needed.</para>
+        </listitem>
+      </varlistentry>
 
-<para>The source directories of both Tcl and Expect can now be removed.</para>
+    </variablelist>
 
-</sect2>
+  </sect2>
 
-<sect2 id="contents-expect" role="content"><title>Contents of Expect</title>
+  <sect2 id="contents-expect" role="content">
+    <title>Contents of Expect</title>
 
-<segmentedlist>
-<segtitle>Installed program</segtitle>
-<segtitle>Installed library</segtitle>
-<seglistitem><seg>expect</seg><seg>libexpect-5.42.a</seg></seglistitem>
-</segmentedlist>
+    <segmentedlist>
+      <segtitle>Installed program</segtitle>
+      <segtitle>Installed library</segtitle>
 
-<variablelist><bridgehead renderas="sect3">Short Descriptions</bridgehead>
-<?dbfo list-presentation="list"?>
-<?dbhtml list-presentation="table"?>
+      <seglistitem>
+        <seg>expect</seg>
+        <seg>libexpect-&expect-lib-version;.a</seg>
+      </seglistitem>
+    </segmentedlist>
 
-<varlistentry id="expect">
-<term><command>expect</command></term>
-<listitem>
-<para>Communicates with other interactive
-programs according to a script</para>
-<indexterm zone="ch-tools-expect expect"><primary sortas="b-expect">expect</primary></indexterm>
-</listitem>
-</varlistentry>
+    <variablelist>
+      <bridgehead renderas="sect3">Short Descriptions</bridgehead>
+      <?dbfo list-presentation="list"?>
+      <?dbhtml list-presentation="table"?>
 
-<varlistentry id="libexpect">
-<term><filename class="libraryfile">libexpect-5.42.a</filename></term>
-<listitem>
-<para>Contains functions that allow Expect to be used as a Tcl extension or to
-be used directly from C or C++ (without Tcl)</para>
-<indexterm zone="ch-tools-expect libexpect"><primary
-sortas="c-libexpect-5.42">libexpect-5.42</primary></indexterm>
-</listitem>
-</varlistentry>
-</variablelist>
+      <varlistentry id="expect">
+        <term><command>expect</command></term>
+        <listitem>
+          <para>Communicates with other interactive programs according
+          to a script</para>
+          <indexterm zone="ch-tools-expect expect">
+            <primary sortas="b-expect">expect</primary>
+          </indexterm>
+        </listitem>
+      </varlistentry>
 
-</sect2>
+      <varlistentry id="libexpect">
+        <term><filename class="libraryfile">libexpect&expect-lib-version;.a</filename></term>
+        <listitem>
+          <para>Contains functions that allow Expect to be used as a Tcl
+          extension or to be used directly from C or C++ (without Tcl)</para>
+          <indexterm zone="ch-tools-expect libexpect">
+            <primary sortas="c-libexpect-&expect-lib-version;">libexpect-&expect-lib-version;</primary>
+          </indexterm>
+        </listitem>
+      </varlistentry>
 
+    </variablelist>
+
+  </sect2>
+
 </sect1>
-

Modified: trunk/BOOK/chapter05/findutils.xml
===================================================================
--- trunk/BOOK/chapter05/findutils.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/findutils.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,11 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Findutils</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' \
-    -i {find,locate,xargs}/Makefile.in</userinput></screen>
-
 <para>Prepare Findutils for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>
@@ -40,8 +35,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Modified: trunk/BOOK/chapter05/flex.xml
===================================================================
--- trunk/BOOK/chapter05/flex.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/flex.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,33 +27,14 @@
 <sect2 role="installation">
 <title>Installation of Flex</title>
 
-<para>Apply a pqatch to ... EDIT ME</para>
+<para>Prepare Flex for compilation:</para>
 
-<screen><userinput>patch -Np1 -i ../&flex-hardened_cflags-patch;</userinput></screen>
-
-<para>Flex contains several known bugs. These can be fixed with the
-following patch:</para>
-
-<screen><userinput>patch -Np1 -i ../&flex-debian_fixes-patch;</userinput></screen>
-
-<para>The GNU autotools will detect that the Flex source code has been
-modified by the previous patch and tries to update the manual page
-accordingly.  This does not work on many systems, and the default page is
-fine, so make sure it does not get regenerated:</para>
-
-<screen><userinput>touch doc/flex.1</userinput></screen>
-
-<para>Now prepare Flex for compilation:</para>
-
 <screen><userinput>./configure --prefix=/tools</userinput></screen>
 
 <para>Compile the package:</para>
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue:
-<userinput>make check</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Modified: trunk/BOOK/chapter05/gawk.xml
===================================================================
--- trunk/BOOK/chapter05/gawk.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/gawk.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,10 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Gawk</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i Makefile.in</userinput></screen>
-
 <para>Prepare Gawk for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>
@@ -44,8 +40,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Deleted: trunk/BOOK/chapter05/gcc-cross.xml
===================================================================
--- trunk/BOOK/chapter05/gcc-cross.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/gcc-cross.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
-  <!ENTITY % general-entities SYSTEM "../general.ent">
-  %general-entities;
-]>
-<sect1 id="ch-tools-gcc-cross" role="wrap">
-<title>GCC-&gcc-version; Cross C Compiler</title>
-<?dbhtml filename="gcc-cross.html"?>
-
-<indexterm zone="ch-tools-gcc-cross">
-<primary sortas="a-GCC">GCC</primary>
-<secondary>tools, cross compiler</secondary></indexterm>
-
-<sect2 role="package"><title/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
-
-<segmentedlist>
-<segtitle>&buildtime;</segtitle>
-<segtitle>&diskspace;</segtitle>
-<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
-</segmentedlist>
-
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
-
-</sect2>
-
-<sect2 role="installation">
-<title>Installation of GCC</title>
-
-<para>Unpack only the gcc-core tarball because neither the C++
-compiler nor the test suite will be needed here.</para>
-
-<para>This package is known to have issues when its default
-optimization flags (including the <parameter>-march</parameter> and
-<parameter>-mcpu</parameter> options) are changed. If any environment
-variables that override default optimizations have been defined, such
-as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
-unset them when building GCC.</para>
-
-<para condition="uclibc">Apply this patch to add uClibc to the configure script.</para>
-
-<screen condition="uclibc"><userinput>patch -Np1 -i ../&gcc-uClibc_conf-patch;</userinput></screen>
-
-<para>GCC will try to use <filename class="directory">/tools/${target}/include</filename>
-because it is a cross compiler. The following command directs GCC to use
-<filename class="directory">/tools/include</filename> instead:</para>
-
-<screen><userinput>sed -e 's@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 /tools/include at g' \
-    -i gcc/Makefile.in</userinput></screen>
-
-<para>This patch adds two configure options, <parameter>--with-dynamic-linker</parameter>
-and <parameter> --with-nostdinc</parameter>. It must be applied before the next command
-or else the patch will fail to apply:</para>
-
-<screen><userinput>patch -Np1 -i ../&gcc-specs_x86-patch;</userinput></screen>
-
-<para>Set the start file prefix. This will default to <filename
-class="directory">/tools/${target}/lib</filename>, but there's no need to install the
-start files there:</para>
-
-<screen><userinput>echo "
-#undef STARTFILE_PREFIX_SPEC
-#define STARTFILE_PREFIX_SPEC \"/tools/lib/\"" >> gcc/config/linux.h</userinput></screen>
-
-<para>The GCC specs patch will check if the <parameter>--with-dynamic-linker</parameter>
-file exists, so make it exist:</para>
-
-<screen><userinput>touch ${ldso}</userinput></screen>
-
-<para>The GCC documentation recommends building GCC outside of the
-source directory in a dedicated build directory:</para>
-
-<screen><userinput>mkdir ../gcc-build
-cd ../gcc-build</userinput></screen>
-
-<para>Prepare Gcc for compilation:</para>
-
-<screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools --target=${target} \
-    --with-local-prefix=/tools --disable-nls \
-    --disable-shared --enable-languages=c \
-    --with-dynamic-linker=${ldso} --with-nostdinc</userinput></screen>
-
-<para>Compile the package:</para>
-
-<screen><userinput>make</userinput></screen>
-
-<para>Install the package:</para>
-
-<screen><userinput>make install</userinput></screen>
-
-</sect2>
-
-<sect2 role="content"><title/>
-<para>Details on this package are located in <xref
-linkend="contents-gcc" role="."/></para>
-</sect2>
-
-</sect1>
-

Deleted: trunk/BOOK/chapter05/gcc.xml
===================================================================
--- trunk/BOOK/chapter05/gcc.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/gcc.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -1,273 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
-  <!ENTITY % general-entities SYSTEM "../general.ent">
-  %general-entities;
-]>
-<sect1 id="ch-tools-gcc" role="wrap">
-<title>GCC-&gcc-version;</title>
-<?dbhtml filename="gcc.html"?>
-
-<indexterm zone="ch-tools-gcc">
-<primary sortas="a-GCC">GCC</primary>
-<secondary>tools</secondary></indexterm>
-
-<sect2 role="package"><title/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
-
-<segmentedlist>
-<segtitle>&buildtime;</segtitle>
-<segtitle>&diskspace;</segtitle>
-<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
-</segmentedlist>
-
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
-
-</sect2>
-
-<sect2 role="installation">
-<title>Installation of GCC</title>
-
-<para>This package is known to have issues when its default
-optimization flags (including the <parameter>-march</parameter> and
-<parameter>-mcpu</parameter> options) are changed. If any environment
-variables that override default optimizations have been defined, such
-as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
-unset them when building GCC.</para>
-
-<para>Because the C and the C++ compilers will be built, unpack both
-the core and the g++ tarballs (as well as test suite, if you want to
-run the tests). By unpacking them in the working directory, they will
-all unfold into a single <filename
-class="directory">gcc-&gcc-version;/</filename> subdirectory.</para>
-
-<para condition="uclibc">Apply these patches to ... EDIT ME:</para>
-
-<screen condition="uclibc"><userinput>patch -Np1 -i ../&gcc-uClibc_conf-patch;
-patch -Np1 -i ../&gcc-uClibc_libstdc-patch;
-patch -Np1 -i ../&gcc-uClibc_locale-patch;</userinput></screen>
-
-<para condition="uclibc">Use this command to hardcode
-<parameter>LIBS="-lintl"</parameter>:</para>
-
-<screen condition="uclibc"><userinput>sed -e 's/%{shared:-lc}/%{!nointl: -lintl} &/' \
-     -i gcc/config/linux.h</userinput></screen>
-
-<para>This patch adds the stack protector code for GCC:</para>
-
-<screen><userinput>patch -Np1 -i ../&gcc-ssp-patch;</userinput></screen>
-
-<para>The bugs URL and version strings are modified as the comments in
-<filename>version.c</filename> recommends:</para>
-
-<screen><userinput>sed -e 's at gcc.gnu.org/bugs.html at bugs.linuxfromscratch.org/@' \
-        -e 's/&gcc-version;/&gcc-version; (ssp)/' -i gcc/version.c</userinput></screen>
-
-<para>Now correct a known problem and make an essential adjustment:</para>
-
-<screen><userinput>patch -Np1 -i ../&gcc-specs_x86-patch;
-patch -Np1 -i ../&gcc-no_fixincludes-patch;</userinput></screen>
-
-<para>The first patch changes GCC's default location of the dynamic linker
-(typically <filename class="libraryfile">ld-linux.so.2</filename>). It also
-removes <filename class="directory">/usr/include</filename> from GCC's include
-search path. Patching now rather than adjusting the specs file after
-installation ensures that the new dynamic linker is used during the actual build
-of GCC. That is, all of the final (and temporary) binaries created during the
-build will link against the new Glibc.</para>
-
-<para>The second patch disables the GCC <command>fixincludes</command> script.
-This was briefly mentioned earlier, but a more in-depth explanation of the
-fixincludes process is warranted here. Under normal circumstances, the GCC
-<command>fixincludes</command> script scans the system for header files that
-need to be fixed. It might find that some Glibc header files on the host system
-need to be fixed, and will fix them and put them in the GCC private include
-directory. In <xref linkend="chapter-building-system"/>, after the newer Glibc
-has been installed, this private include directory will be searched before the
-system include directory. This may result in GCC finding the fixed headers from
-the host system, which most likely will not match the Glibc version used for the
-HLFS system.</para>
-
-<important><para>The above patches are critical in ensuring a successful overall
-build. Do not forget to apply them.</para></important>
-
-<para>Create a separate build directory again:</para>
-
-<screen><userinput>mkdir ../gcc-build
-cd ../gcc-build</userinput></screen>
-
-<para>Prepare GCC for compilation:</para>
-
-<screen><userinput>env CC=${target}-gcc \
-../gcc-&gcc-version;/configure --prefix=/tools \
-    --host=${target} --build=${target} --target=${target} \
-    --libexecdir=/tools/lib --with-local-prefix=/tools \
-    --enable-shared --enable-threads=posix \
-    --enable-__cxa_atexit --enable-languages=c,c++ \
-    --disable-libstdcxx-pch --enable-clocale \
-    --with-dynamic-linker=${ldso} --with-nostdinc \
-    --enable-multilib=no</userinput></screen>
-
-<para>Compile the package:</para>
-
-<screen><userinput>make</userinput></screen>
-
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
-<para>Install the package:</para>
-
-<screen><userinput>make install
-ln -s gcc /tools/bin/cc</userinput></screen>
-
-</sect2>
-
-<sect2  role="installation">
-<title>Adding Hardened Specs</title>
-
-<para>This depend on Perl. If you do not have Perl installed on your host system
-then you can skip this, and testing, and return here after Perl is installed
-later in this chapter.</para>
-
-<para>We are going to need to repeat these commands later for Binutils tests in
-chapter 6, and when GCC is reinstalled. Since these commands are ugly to
-repeat it's best to dump them into a script, as it is done below.</para>
-
-<para>This will add <parameter>-fstack-protector-all</parameter> to the default
-for <command>gcc</command> and <command>g++</command>. The only
-filter is for <parameter>-fno-stack-protector*</parameter>:</para>
-
-<screen><userinput>cat > hardened-specs.sh << "EOF"
-<literal>#!/bin/sh
-perl -pi -e 's@\*cc1:\n@$_%(cc1_ssp) @;' \
-    $(gcc --print-file specs) &&
-perl -pi -e 's@\*cc1plus:\n@$_%(cc1_ssp) @;' \
-    $(gcc --print-file specs) &&
-echo '*cc1_ssp:
-%{!fno-stack-protector*: -fstack-protector-all}
-'    >> $(gcc --print-file specs)</literal>
-EOF</userinput></screen>
-
-<para>These commands will make <command>gcc -fPIC</command>,
-<command>ld -pie</command>, and <command>cpp -D__PIC__ -DPIC</command>
-the default. The exact default behavior for <command>gcc -pie</command> will be
-preserved. If <parameter>-pie</parameter>, <parameter>-no-pie</parameter>, or
-<parameter>-static</parameter> are used then the vanilla behavior will be
-used instead. Additional filters are added to the link_command spec to prevent
-libraries from receiving the <parameter>-pie</parameter> option.
-Read <xref linkend="technotes-pie"/> for more information on this.</para>
-
-<para>We will append to the file created above:</para>
-
-<screen><userinput>cat >> hardened-specs.sh << "EOF"
-<literal>perl -pi -e 's@\*cc1:\n@$_%(cc1_pie) @;' \
-    $(gcc --print-file specs) &&
-perl -pi -e 's@\*cc1plus:\n@$_%(cc1_pie) @;' \
-    $(gcc --print-file specs) &&
-perl -pi -e 's@%{pie:-pie}@%(link_pie)@;' \
-    $(gcc --print-file specs) &&
-perl -pi -e 's at pie:@!no-pie|pie:@g;' $(gcc --print-file specs) &&
-perl -pi -e 's@\*cpp:\n@$_%(cpp_pie) @;' $(gcc --print-file specs) &&
-echo '*cpp_pie:
-%{!static:%{!no-pie:%{!pie: -D__PIC__ -DPIC}}}
-' >> $(gcc --print-file specs) &&
-echo '*cc1_pie:
-%{!static:%{!no-pie:%{!pie: -fPIC}}}
-' >> $(gcc --print-file specs) &&
-echo '*link_pie:
-%{pie:-pie}%{!no-pie:%{!static:%{!Bstatic:%{!i:%{!r: %{!nonow: -z now} %{!norelro: -z relro} %{!shared:%{!Bshareable:%{!pie: -pie}}}}}}}}
-' >> $(gcc --print-file specs)</literal>
-EOF</userinput></screen>
-
-<para>Now, install and run this script:</para>
-
-<screen><userinput>install hardened-specs.sh /tools/bin
-/tools/bin/hardened-specs.sh</userinput></screen>
-
-<para>You can restore the vanilla gcc specs at any time with
-<command>gcc -dumpspecs > $(gcc --print-file specs)</command>.</para>
-
-</sect2>
-
-<sect2 id="testing-gcc"  role="installation">
-<title>Testing GCC</title>
-
-<para>Now we can run tests to check that the new GCC is working as expected.</para>
-
-<para>This program will create a buffer overflow with an array length 7. This
-will test that <parameter>-fstack-protector-all</parameter> is working. It will also print the
-<function> __guard[]</function> value. The <function>__guard</function> value
-should change with each run.</para>
-
-<screen><userinput>cat > test.c << "EOF"
-<literal>#include <stdio.h>
-#include <unistd.h>
-extern long __guard[];
-int overflow(char *test) {
-  char buffer[7];
-  sprintf(buffer, "12345678901234567890123456789012345678901234567890");
-  return(1234);
-}
-int main(int argc, char **argv) {
-  printf("__guard\t=\t0x%08x;\n", __guard[0]);
-  overflow("test");
-  printf("This line should never get printed.\n");
-}</literal>
-EOF</userinput></screen>
-
-<para>Now compile and run it with <command>gcc</command>:</para>
-
-<screen><userinput>gcc -o test test.c
-./test</userinput></screen>
-
-<para>This should return something like this</para>
-
-<screen><computeroutput> __guard =       0xbd06f7b2;
-./test: stack smashing attack in function overflow()
-Aborted</computeroutput></screen>
-
-<para>Then test <command>g++</command>. The <parameter>-pie -fPIE</parameter>
-are added to check they work too:</para>
-
-<screen><userinput>g++ -pie -fPIE -o test2 test.c
-./test2</userinput></screen>
-
-<para>The <command>g++</command> test should return something very similar.
-The <function>__guard</function> value should change, and both tests should
-receive an abort signal. Your host system Syslog daemon should also log these events.</para>
-
-<para>Then make sure <command>gcc</command> is linking to <filename
-class="directory">tools</filename> and is creating position independent executables.
-Also make sure the GNU_RELRO, and PAX_FLAGS program headers exist:</para>
-
-<screen><userinput>readelf -l test{,2} | grep -e ': /tools' -e 'Shared' \
-    -e 'GNU_RELRO' -e 'PAX_FLAGS'</userinput></screen>
-
-<para>This should return (twice):</para>
-
-<screen><computeroutput>Elf file type is DYN (Shared object file)
-     [Requesting program interpreter: /tools/lib/ld-something.so]
- GNU_RELRO      0x000ef4 0x00001ef4 0x00001ef4 0x0010c 0x0010c R   0x1
- PAX_FLAGS      0x000000 0x00000000 0x00000000 0x00000 0x00000     0x4</computeroutput></screen>
-
- <para>There are two more things to check for. The BIND_NOW section should exist.
-The TEXTREL section should not exist:</para>
-
-<screen><userinput>readelf -d test{,2} | grep -e 'BIND_NOW' -e 'TEXTREL'</userinput></screen>
-
-<para>This should return (twice):</para>
-
-<screen><computeroutput>0x00000018 (BIND_NOW)</computeroutput></screen>
-
-<para>The two readelf tests should produce the same results on all shared executables
-and libraries you build.</para>
-
-</sect2>
-
-<sect2 role="content"><title/>
-<para>Details on this package are located in <xref
-linkend="contents-gcc" role="."/></para>
-</sect2>
-
-</sect1>
-

Modified: trunk/BOOK/chapter05/gettext.xml
===================================================================
--- trunk/BOOK/chapter05/gettext.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/gettext.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,14 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Gettext</title>
 
-<para>Amend <filename>Makefile.in</filename>. We're lucky Gettext already has 
-specific  <envar>CFLAGS</envar> for the programs in <filename 
-class="directory">gettext-tools/</filename>. This saves us a patch because there 
-are also libraries in that directory, but the sed might not work forever:</para>
-
-<screen><userinput>sed -e 's/.*_CFLAGS = .*$/& -pie -fpie/' -i \
-    gettext-tools/src/Makefile.in</userinput></screen>
-
 <para>Prepare Gettext for compilation:</para>
 
 <screen><userinput>cd gettext-tools/

Deleted: trunk/BOOK/chapter05/glibc-headers.xml
===================================================================
--- trunk/BOOK/chapter05/glibc-headers.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/glibc-headers.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
-  <!ENTITY % general-entities SYSTEM "../general.ent">
-  %general-entities;
-]>
-<sect1 id="ch-tools-glibc-headers" role="wrap" condition="glibc">
-<title>Glibc-&glibc-version; Headers</title>
-<?dbhtml filename="glibc-headers.html"?>
-
-<indexterm zone="ch-tools-glibc-headers">
-<primary sortas="a-Glibc">Glibc</primary>
-<secondary>tools, headers</secondary></indexterm>
-
-<sect2 role="package"><title/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/glibc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
-
-<segmentedlist>
-<segtitle>&buildtime;</segtitle>
-<segtitle>&diskspace;</segtitle>
-<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
-</segmentedlist>
-
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/glibc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
-
-</sect2>
-
-<sect2 role="installation">
-<title>Installation of Glibc Headers</title>
-
-<para>This package is known to have issues when its default
-optimization flags (including the <parameter>-march</parameter> and
-<parameter>-mcpu</parameter> options) are changed. If any environment
-variables that override default optimizations have been defined, such
-as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
-unset them when building Glibc.</para>
-
-<para>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.</para>
-
-<para>The Glibc documentation recommends building Glibc outside of the source
-directory in a dedicated build directory:</para>
-
-<screen><userinput>mkdir ../glibc-build
-cd ../glibc-build</userinput></screen>
-
-<para>Next, prepare Glibc for compilation:</para>
-
-<screen><userinput>../glibc-&glibc-version;/configure --prefix=/tools \
-    --host=${target} --without-cvs \
-    --disable-sanity-checks --with-headers=/tools/include</userinput></screen>
-
-<para>Build and install only the Glibc headers files:</para>
-
-<screen><userinput>make install-headers</userinput></screen>
-
-<para>Copy some headers that aren't installed by default</para>
-
-<screen><userinput>cp bits/stdio_lim.h /tools/include/bits
-touch /tools/include/gnu/stubs.h
-cp ../glibc-&glibc-version;/nptl/sysdeps/pthread/pthread.h /tools/include
-cp ../glibc-&glibc-version;/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h \
-    /tools/include/bits</userinput></screen>
-
-</sect2>
-
-<sect2 role="content"><title/>
-<para>Details on this package are located in <xref
-linkend="contents-glibc" role="."/></para>
-</sect2>
-
-</sect1>
-

Modified: trunk/BOOK/chapter05/glibc.xml
===================================================================
--- trunk/BOOK/chapter05/glibc.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/glibc.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -31,7 +31,7 @@
 
 <para>This package is known to have issues when its default
 optimization flags (including the <parameter>-march</parameter> and
-<parameter>-mcpu</parameter> options) are changed. If any environment
+<parameter>-mtune</parameter> options) are changed. If any environment
 variables that override default optimizations have been defined, such
 as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
 unset them when building Glibc.</para>
@@ -40,73 +40,139 @@
 the method suggested in this book puts the stability of the system at
 risk.</para>
 
-<important><para>Be sure to unpack both Glibc and Glibc-Libidn packages before
-starting the build. Then, apply the patches:</para></important>
+<para>If you want to have LibIDN installed on the finished system then you will
+need to install it here first. Read more about LibIDN here:
+<ulink url="http://www.gnu.org/software/libidn/"/>. Unpack LibIDN and rename
+the directory so Glibc will find it:</para>
 
-<screen><userinput>patch -Np1 -i ../&glibc-arc4random-patch;
-patch -Np1 -i ../&glibc-ssp-patch;
-patch -Np1 -i ../&glibc-pt_pax-patch;
-patch -Np1 -i ../&glibc-dl_execstack_PaX-patch;</userinput></screen>
+<screen><userinput>tar vjxf ../glibc-libidn-&glibc-version;.tar.bz2
+mv -v glibc-libidn-&glibc-version; libidn</userinput></screen>
 
-<para>The first patch adds SSP functions to <filename class="libraryfile">libc.a</filename>
-and <filename class="libraryfile">libc.so</filename>. The pt_pax patch
-adds definitions for elf header markings related to the Binutils-pt_pax
-patch. The dl_execstack_PaX patch fixes a problem with the dynamic loader,
-which is needed for system running PaX kernels.</para>
+<para>This patch fixes a problem with the dynamic loader for kernels with PaX:</para>
 
+<screen><userinput>patch -Np1 -i ../&glibc-dl_execstack_PaX-patch;</userinput></screen>
+
+<para>This patch is from glibc-cvs. See: <ulink url="https://bugzilla.samba.org/show_bug.cgi?id=3678"/></para>
+
+<screen><userinput>patch -Np1 -i ../&glibc-iconv_fix-patch;</userinput></screen>
+
+<para>This patch moves nested function to a static one to avoid generating a
+trampoline:</para>
+
+<screen><userinput>patch -Np1 -i ../&glibc-iconv_unnest-patch;</userinput></screen>
+
+<para>This patch keeps <command>localedef</command> from crashing while running
+a kernel with PaX:</para>
+
+<screen><userinput>patch -Np1 -i ../&glibc-localedef_segfault-patch;</userinput></screen>
+
+<para>This patch adds PT_PAX_FLAGS program header support, related to the
+Binutils PT_PAX_FLAGS patch, to Glibc:</para>
+
+<screen><userinput>patch -Np1 -i ../&glibc-pt_pax-patch;</userinput></screen>
+
+<para>This <command>sed</command> command configures Glibc to use PIC assembly
+code in the utility programs:</para>
+
+<screen><userinput>cp -vi sysdeps/unix/sysv/linux/i386/sysdep.h{,.orig}
+sed 's/^# if defined I386_USE_SYSENTER$/& \&\& defined SHARED/' \
+    sysdeps/unix/sysv/linux/i386/sysdep.h.orig \
+        > sysdeps/unix/sysv/linux/i386/sysdep.h</userinput></screen>
+
 <para>The Glibc documentation recommends building Glibc outside of the source
 directory in a dedicated build directory:</para>
 
-<screen><userinput>mkdir ../glibc-build
+<screen><userinput>mkdir -v ../glibc-build
 cd ../glibc-build</userinput></screen>
 
-<para>Create a default <filename>config.cache</filename> file to ... EDIT ME:</para>
-
-<screen><userinput>echo "libc_cv_forced_unwind=yes" > config.cache
-echo "libc_cv_c_cleanup=yes" >> config.cache</userinput></screen>
-
 <para>Prepare Glibc for compilation:</para>
 
 <screen><userinput>../glibc-&glibc-version;/configure --prefix=/tools \
-    --host=${target} --build=$(uname -m)-linux \
-    --disable-profile --enable-add-ons --with-binutils=/tools/bin \
-    --enable-kernel=2.6.0 --without-gd --without-cvs \
-    --with-headers=/tools/include --cache-file=config.cache \
-    --enable-bind-now</userinput></screen>
+    --with-binutils=/tools/bin --with-headers=/tools/include \
+    --enable-kernel=2.6.0 --enable-stackguard-randomization \
+    --enable-bind-now --enable-add-ons --without-gd \
+    --disable-profile</userinput></screen>
 
-<para>Compile the package:</para>
+<variablelist>
+    <title>The meaning of the configure options:</title>
 
-<screen><userinput>make libgcc_eh="" gnulib="-lgcc" static-gnulib="-lgcc"</userinput></screen>
+      <varlistentry>
+        <term><parameter>--with-binutils=/tools/bin</parameter></term>
+        <listitem>
+          <para>While not required, this switch ensures that there are no
+           errors pertaining to which Binutils programs get used during the
+           Glibc build.</para>
+        </listitem>
+      </varlistentry>
 
-<para>We need to use <parameter>libgcc_eh="" gnulib="-lgcc" static-gnulib="-lgcc"</parameter>
-because <filename class="libraryfile">libgcc_eh.a</filename> does not exist yet. Glibc does not
-actually need <filename class="libraryfile">libgcc_eh</filename>, everything builds fine without it.</para>
+      <varlistentry>
+        <term><parameter>--with-headers=/tools/include</parameter></term>
+        <listitem>
+          <para>This tells Glibc to compile itself against the headers
+           recently installed to the tools directory, so that it knows
+           exactly what features the kernel has and can optimize itself
+           accordingly.</para>
+        </listitem>
+      </varlistentry>
 
-<para>To test the results, issue: <userinput>make check</userinput>. All test should pass.</para>
+      <varlistentry>
+        <term><parameter>--enable-kernel=2.6.0</parameter></term>
+        <listitem>
+          <para>This tells Glibc to compile the library with support for
+           2.6.x Linux kernels.</para>
+        </listitem>
+      </varlistentry>
 
+      <varlistentry>
+        <term><parameter>--enable-stackguard-randomization</parameter></term>
+        <listitem>
+          <para>This tells Glibc to initialize __stack_chk_guard canary with
+           a random number at program start, instead of a static number.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-bind-now</parameter></term>
+        <listitem>
+          <para>This tells Glibc to enable non-lazy runtime bindings.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--without-gd</parameter></term>
+        <listitem>
+          <para>This prevents the build of the memusagestat program, which
+           insists on linking against the host's libraries (libgd, libpng,
+           libz, etc.).</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><parameter>--enable-add-ons</parameter></term>
+        <listitem>
+          <para>This tells Glibc to use the NPTL threading library, and
+           LibIDN, add-ons.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><parameter>--disable-profile</parameter></term>
+        <listitem>
+          <para>This builds the libraries without profiling information.</para>
+        </listitem>
+      </varlistentry>
+
+</variablelist>
+
+<para>Compile the package:</para>
+
+<screen><userinput>make</userinput></screen>
+
 <para>Install the package:</para>
 
-<screen><userinput>install -d /tools/etc
+<screen><userinput>install -vd /tools/etc
 touch /tools/etc/ld.so.conf
-make libgcc_eh="" gnulib="-lgcc" static-gnulib="-lgcc" install</userinput></screen>
+make install</userinput></screen>
 
-<para>If you want to install locales, then the following commands are suggested.
-If you want to install them all then replace the following commands with
-<userinput>make localedata/install-locales</userinput>.</para>
-
-<screen><userinput>install -d /tools/lib/locale
-localedef -i de_DE -f ISO-8859-1 de_DE
-localedef -i de_DE at euro -f ISO-8859-15 de_DE at euro
-localedef -i en_HK -f ISO-8859-1 en_HK
-localedef -i en_PH -f ISO-8859-1 en_PH
-localedef -i en_US -f ISO-8859-1 en_US
-localedef -i es_MX -f ISO-8859-1 es_MX
-localedef -i fa_IR -f UTF-8 fa_IR
-localedef -i fr_FR -f ISO-8859-1 fr_FR
-localedef -i fr_FR at euro -f ISO-8859-15 fr_FR at euro
-localedef -i it_IT -f ISO-8859-1 it_IT
-localedef -i ja_JP -f EUC-JP ja_JP</userinput></screen>
-
 </sect2>
 
 <sect2 role="content"><title/>

Modified: trunk/BOOK/chapter05/grep.xml
===================================================================
--- trunk/BOOK/chapter05/grep.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/grep.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,10 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Grep</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i src/Makefile.in</userinput></screen>
-
 <para>Prepare Grep for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools --disable-perl-regexp</userinput></screen>
@@ -52,8 +48,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Modified: trunk/BOOK/chapter05/gzip.xml
===================================================================
--- trunk/BOOK/chapter05/gzip.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/gzip.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,20 +27,16 @@
 <sect2 role="installation">
 <title>Installation of Gzip</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
+<para>By default Gzip uses assembly code. While this may preform better, it
+is not position independent. The assembly code causes text relocation which
+is disallowed by options in PaX/Grsec kernels. The <envar>DEFS</envar>
+environment variable is set to use only C code.</para>
 
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i Makefile.in</userinput></screen>
-
 <para>Prepare Gzip for compilation:</para>
 
 <screen><userinput>env DEFS=NO_ASM \
     ./configure --prefix=/tools</userinput></screen>
     
-<para>By default Gzip uses assembly code. While this may preform better, it
-is not position independent. The assembly code causes text relocation which
-is disallowed by options in PaX/Grsec kernels. The above <envar>DEFS</envar>
-environment variable is set to use only C code.</para>
-
 <para>Compile the package:</para>
 
 <screen><userinput>make</userinput></screen>

Modified: trunk/BOOK/chapter05/introduction.xml
===================================================================
--- trunk/BOOK/chapter05/introduction.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/introduction.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -4,64 +4,86 @@
   %general-entities;
 ]>
 <sect1 id="ch-tools-introduction">
-<title>Introduction</title>
 <?dbhtml filename="introduction.html"?>
 
-<para>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 <xref
-linkend="chapter-building-system"/> and allow a working environment
-with more user convenience than a minimum environment would.</para>
+  <title>Introduction</title>
 
-<para>There are two steps in building this minimal system. The first
-step is to build a new and host-independent toolchain (compiler,
-assembler, linker, libraries, and a few useful utilities).  The second
-step uses this toolchain to build the other essential tools.</para>
+<!-- This is repeditive of chapter01/how.xml -->
 
-<para>The files compiled in this chapter will be installed under the
-<filename class="directory">$HLFS/tools</filename> 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.</para>
+  <para>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 <xref
+  linkend="chapter-building-system"/> 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 <xref linkend="chapter-building-system"/>, whereever
+  possible, to preserve the <quote>bootstrap</quote> concept (where
+  the final system is built with the same tools and options as the
+  temporary system).</para>
 
-<para>Before issuing the build instructions for a package, the package
-should be unpacked as user <emphasis>hlfs</emphasis>, and a
-<command>cd</command> into the created directory should be performed. The build
-instructions assume that the <command>bash</command> shell is in use.</para>
+  <para>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 <quote>Embryo toolchain</quote> 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
+  <quote>Cocoon toolchain</quote>.</para>
 
-<para>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
-<emphasis>offset</emphasis> or <emphasis>fuzz</emphasis> may
-also be encountered when applying a patch. Do not worry about these
-warnings, as the patch was still successfully applied.</para>
+  <para>The files compiled in this chapter will be installed under the
+  <filename class="directory">$HLFS/tools</filename> 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.</para>
 
-<para>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.</para>
+  <important>
+  <para>Before issuing the build instructions for a package, the package
+  should be unpacked as user <emphasis>hlfs</emphasis>, and a
+  <command>cd</command> 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-&binutils-version;.tar.bz2 will unpack to
+  $HLFS/usr/src/binutils-&binutils-version; and
+  gcc-core-&gcc-version;.tar.bz2 will unpack to
+  $HLFS/usr/src/gcc-core-&gcc-version;. Intructions are provided on the
+  toolchain pages to create the combined source tree. The build that the
+  <command>bash</command> shell is in use.</para>
+  </important>
 
-<para>After installing each package, delete its source and build
-directories, unless specifically instructed otherwise. Deleting the
-sources saves space and prevents mis-configuration when the same
-package is reinstalled later. Only three of the packages need to
-retain the source and build directories in order for their contents to
-be used by later commands. Pay special attention to these
-reminders.</para>
+  <para>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
+  <emphasis>offset</emphasis> or <emphasis>fuzz</emphasis> may
+  also be encountered when applying a patch. Do not worry about these
+  warnings, as the patch was still successfully applied.</para>
 
-<para>Check one last time that the <envar>HLFS</envar> environment 
-variable is set up properly:</para>
+  <para>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.</para>
 
-<screen><userinput>echo $HLFS</userinput></screen>
+  <important>
+  <para>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.</para>
+  </important>
 
-<para>Make sure the output shows the path to the HLFS partition's mount
-point, which is <filename class="directory">/mnt/hlfs</filename>, using
-our example.</para>
+  <para>Check one last time that the <envar>HLFS</envar> environment 
+  variable is set up properly:</para>
 
+  <screen><userinput>echo $HLFS</userinput></screen>
+
+  <para>Make sure the output shows the path to the HLFS partition's mount
+  point, which is <filename class="directory">/mnt/hlfs</filename>, using
+  our example.</para>
+
 </sect1>
 

Copied: trunk/BOOK/chapter05/linux-headers.xml (from rev 668, trunk/BOOK/chapter05/linux-libc-headers.xml)
===================================================================
--- trunk/BOOK/chapter05/linux-headers.xml	                        (rev 0)
+++ trunk/BOOK/chapter05/linux-headers.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+  <!ENTITY % general-entities SYSTEM "../general.ent">
+  %general-entities;
+]>
+<sect1 id="ch-tools-linux-headers" role="wrap">
+<title>Linux-Headers-&linux-headers-version;</title>
+<?dbhtml filename="linux-headers.html"?>
+
+<indexterm zone="ch-tools-linux-headers">
+<primary sortas="a-Linux-Headers">Linux-Headers</primary>
+<secondary>tools</secondary></indexterm>
+
+<sect2 role="package"><title/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
+href="../chapter06/linux-headers.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
+
+<segmentedlist>
+<segtitle>&buildtime;</segtitle>
+<segtitle>&diskspace;</segtitle>
+<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
+</segmentedlist>
+
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
+href="../chapter06/linux-headers.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
+
+</sect2>
+
+<sect2 role="installation">
+<title>Installation of Linux-Headers</title>
+
+<para>This patch adds PIC assembly code to asm-i386/unistd.h:</para>
+
+<screen><userinput>patch --no-backup-if-mismatch -Np1 -i \
+	../&linux-headers-unistd_x86_PIC-patch;</userinput></screen>
+
+<para>The meaning of the patch option:</para>
+
+<variablelist>
+
+      <varlistentry>
+        <term><parameter>--no-backup-if-mismatch</parameter></term>
+        <listitem>
+          <para>Prevents <command>patch</command> from creating
+          <filename class="extension">.orig</filename> files, so they don't
+          get installed to <filename
+          class="directory">/tools/include</filename>. <filename
+          class="extension">.orig</filename> files might be named something
+          else depending on your version of <command>patch</command>.</para>
+        </listitem>
+      </varlistentry>
+
+</variablelist>
+
+<para>Install the header files:</para>
+
+<screen><userinput>install -vd /tools/include
+cp -vR include/asm-i386 /tools/include/asm
+cp -vR include/asm-generic /tools/include/asm-generic
+cp -vR include/linux /tools/include</userinput></screen>
+
+</sect2>
+
+<sect2 role="content"><title/>
+<para>Details on this package are located in <xref
+linkend="contents-linux-headers" role="."/></para>
+</sect2>
+
+</sect1>
+

Deleted: trunk/BOOK/chapter05/linux-libc-headers.xml
===================================================================
--- trunk/BOOK/chapter05/linux-libc-headers.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/linux-libc-headers.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
-  <!ENTITY % general-entities SYSTEM "../general.ent">
-  %general-entities;
-]>
-<sect1 id="ch-tools-linux-libc-headers" role="wrap">
-<title>Linux-Libc-Headers-&linux-libc-headers-version;</title>
-<?dbhtml filename="linux-libc-headers.html"?>
-
-<indexterm zone="ch-tools-linux-libc-headers">
-<primary sortas="a-Linux-Libc-Headers">Linux-Libc-Headers</primary>
-<secondary>tools</secondary></indexterm>
-
-<sect2 role="package"><title/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/linux-libc-headers.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
-
-<segmentedlist>
-<segtitle>&buildtime;</segtitle>
-<segtitle>&diskspace;</segtitle>
-<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
-</segmentedlist>
-
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/linux-libc-headers.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
-
-</sect2>
-
-<sect2 role="installation">
-<title>Installation of Linux-Libc-Headers</title>
-
-<para>This patch adds sysctl definitions for <envar>KERN_ERANDOM</envar> and
-<envar>KERN_URANDOM</envar>:</para>
-
-<screen><userinput>patch --no-backup-if-mismatch -Np1 -i \
-    ../&linux-libc-headers-pseudo_random-patch;</userinput></screen>
-
-<para>The meaning of the patch option:</para>
-
-<variablelist>
-<varlistentry>
-<term><parameter>--no-backup-if-mismatch</parameter></term>
-<listitem><para>Prevents <command>patch</command> from creating
-<filename class="extension">.orig</filename> files, so they don't get installed to
-<filename class="directory">/tools/include</filename>. <filename
-class="extension">.orig</filename> files might be named something else
-depending on the version of <command>patch</command>.</para></listitem>
-</varlistentry>
-</variablelist>
-
-<para>Install the headers files:</para>
-
-<screen><userinput>install -d /tools/include
-cp -R include/asm-i386 /tools/include/asm
-cp -R include/linux /tools/include</userinput></screen>
-
-</sect2>
-
-<sect2 role="content"><title/>
-<para>Details on this package are located in <xref
-linkend="contents-linux-libc-headers" role="."/></para>
-</sect2>
-
-</sect1>
-

Modified: trunk/BOOK/chapter05/m4.xml
===================================================================
--- trunk/BOOK/chapter05/m4.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/m4.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,15 +27,6 @@
 <sect2 role="installation">
 <title>Installation of M4</title>
 
-<para> M4 wants to pass <envar>CFLAGS</envar> down from the top makefile 
-with the <envar>MDEFINESS</envar> variable. This first sed command will prevent 
-that, so sub-directory makefile's can use their own cflags. The second sed command 
-adds <parameter>-fpie</parameter> to the cflags in the <filename 
-class="directory">src/</filename> directory.:</para>
-
-<screen><userinput>sed -e "s/^\(MDEFINES.*\)CFLAGS='\$(CFLAGS)' /\1/" -i Makefile.in
-sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i src/Makefile.in</userinput></screen>
-
 <para>Prepare M4 for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>
@@ -44,8 +35,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Modified: trunk/BOOK/chapter05/make.xml
===================================================================
--- trunk/BOOK/chapter05/make.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/make.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,10 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Make</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i Makefile.in</userinput></screen>
-
 <para>Prepare Make for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>
@@ -39,8 +35,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Modified: trunk/BOOK/chapter05/ncurses.xml
===================================================================
--- trunk/BOOK/chapter05/ncurses.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/ncurses.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,11 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Ncurses</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS\t.*$/& -pie -fpie/' \
-    -i {progs,tack}/Makefile.in</userinput></screen>
-
 <para>Prepare Ncurses for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools --with-shared \

Modified: trunk/BOOK/chapter05/patch.xml
===================================================================
--- trunk/BOOK/chapter05/patch.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/patch.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,10 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Patch</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i Makefile.in</userinput></screen>
-
 <para>Prepare Patch for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>

Modified: trunk/BOOK/chapter05/perl.xml
===================================================================
--- trunk/BOOK/chapter05/perl.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/perl.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -58,12 +58,6 @@
 
 <screen><userinput>make perl utilities</userinput></screen>
 
-<para>Although Perl comes with a test suite, it is not recommended to
-run it at this point. Only part of Perl was built and running
-<userinput>make test</userinput> now will cause the rest of Perl to be
-built as well, which is unnecessary at this point. The test suite can
-be run in the next chapter if desired.</para>
-
 <para>Copy these tools and their libraries:</para>
 
 <screen><userinput>install perl pod/pod2man /tools/bin

Modified: trunk/BOOK/chapter05/sed.xml
===================================================================
--- trunk/BOOK/chapter05/sed.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/sed.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -32,10 +32,6 @@
 
 <screen condition="uclibc"><userinput>patch -Np1 -i ../&sed-uClibc-patch;</userinput></screen>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i sed/Makefile.in</userinput></screen>
-
 <para>Prepare Sed for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>
@@ -44,8 +40,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Modified: trunk/BOOK/chapter05/tar.xml
===================================================================
--- trunk/BOOK/chapter05/tar.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/tar.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,11 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Tar</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' \
-    -i {rmt,src}/Makefile.in</userinput></screen>
-
 <para>Prepare Tar for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>
@@ -40,8 +35,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Modified: trunk/BOOK/chapter05/tcl.xml
===================================================================
--- trunk/BOOK/chapter05/tcl.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/tcl.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -1,110 +1,126 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+  "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
   <!ENTITY % general-entities SYSTEM "../general.ent">
   %general-entities;
 ]>
+
 <sect1 id="ch-tools-tcl" role="wrap">
-<title>Tcl-&tcl-version;</title>
-<?dbhtml filename="tcl.html"?>
+  <?dbhtml filename="tcl.html"?>
 
-<indexterm zone="ch-tools-tcl"><primary sortas="a-Tcl">Tcl</primary></indexterm>
+  <title>Tcl-&tcl-version;</title>
 
-<sect2 role="package"><title/>
-<para>The Tcl package contains the Tool Command Language.</para>
+  <indexterm zone="ch-tools-tcl">
+    <primary sortas="a-Tcl">Tcl</primary>
+  </indexterm>
 
-<segmentedlist>
-<segtitle>&buildtime;</segtitle>
-<segtitle>&diskspace;</segtitle>
-<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
-</segmentedlist>
+  <sect2 role="package">
+    <title/>
 
-<segmentedlist>
-<segtitle>&dependencies;</segtitle>
-<seglistitem><seg>Bash, Binutils, Coreutils, Diffutils,
-GCC, Glibc, Grep, Make, and Sed</seg></seglistitem>
-</segmentedlist>
+    <segmentedlist>
+      <segtitle>&buildtime;</segtitle>
+      <segtitle>&diskspace;</segtitle>
+      <seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
+    </segmentedlist>
 
-</sect2>
+    <segmentedlist>
+      <segtitle>&dependencies;</segtitle>
+      <seglistitem><seg>Bash, Binutils, Coreutils, Diffutils,
+      GCC, Glibc, Grep, Make, and Sed</seg></seglistitem>
+    </segmentedlist>
 
-<sect2 role="installation">
-<title>Installation of Tcl</title>
+  </sect2>
 
-<para>This package and the next two (Expect and DejaGNU) are
-installed to support running the test suites for GCC and Binutils.
-Installing three packages for testing purposes may seem excessive, but
-it is very reassuring, if not essential, to know that the most
-important tools are working properly. Even if the test suites are not
-run in this chapter (they are not mandatory), these packages
-are required to run the test suites in <xref
-linkend="chapter-building-system"/>.</para>
+  <sect2 role="installation">
+    <title>Installation of Tcl</title>
 
-<para>Fix a syntax error in TCL's configure script:</para>
+    <para>This package and the next two (Expect and DejaGNU) are installed
+    to support running the test suites for GCC and Binutils. Installing
+    three packages for testing purposes may seem excessive, but it is very
+    reassuring, if not essential, to know that the most important tools are
+    working properly. Even though the test suites are not run in this chapter,
+    these packages are required to run the test suites in
+    <xref linkend="chapter-building-system"/>.</para>
 
-<screen><userinput>cd unix
-cp configure{,.orig}
-sed "s/relid'/relid/" configure.orig > configure</userinput></screen>
+    <para>Now that libc is installed the <option>-pie</option> will work:</para>
 
-<para>Prepare Tcl for compilation:</para>
+<screen><userinput>cp -v unix/Makefile.in{,.orig}
+sed 's/^LDFLAGS\t.*=/& -pie/' unix/Makefile.in.orig > unix/Makefile.in</userinput></screen>
 
-<screen><userinput>env CC=${target}-gcc \
+    <para>Prepare Tcl for compilation:</para>
+
+<screen><userinput>cd unix
 ./configure --prefix=/tools</userinput></screen>
 
-<para>Build the package:</para>
+    <para>Build the package:</para>
 
 <screen><userinput>make</userinput></screen>
 
-<para>Install the package:</para>
+    <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>
 
-<para>Install TCL's private headers:</para>
+    <para>Install Tcl's headers. The next package, Expect, requires them
+    to build.</para>
 
 <screen><userinput>make install-private-headers</userinput></screen>
 
-<para>Make a necessary symbolic link:</para>
+    <para>Now make a necessary symbolic link:</para>
 
-<screen><userinput>ln -s tclsh8.4 /tools/bin/tclsh</userinput></screen>
+<screen><userinput>ln -sv tclsh8.4 /tools/bin/tclsh</userinput></screen>
 
-</sect2>
+  </sect2>
 
-<sect2 id="contents-tcl" role="content"><title>Contents of Tcl</title>
+  <sect2 id="contents-tcl" role="content">
+    <title>Contents of Tcl</title>
 
-<segmentedlist>
-<segtitle>Installed programs</segtitle>
-<segtitle>Installed library</segtitle>
-<seglistitem><seg>tclsh (link to tclsh8.4) and tclsh8.4</seg><seg>libtcl8.4.so</seg></seglistitem>
-</segmentedlist>
+    <segmentedlist>
+      <segtitle>Installed programs</segtitle>
+      <segtitle>Installed library</segtitle>
 
-<variablelist><bridgehead renderas="sect3">Short Descriptions</bridgehead>
-<?dbfo list-presentation="list"?>
-<?dbhtml list-presentation="table"?>
+      <seglistitem>
+        <seg>tclsh (link to tclsh8.4) and tclsh8.4</seg>
+        <seg>libtcl8.4.so</seg>
+      </seglistitem>
+    </segmentedlist>
 
-<varlistentry id="tclsh8.4">
-<term><command>tclsh8.4</command></term>
-<listitem>
-<para>The Tcl command shell</para>
-<indexterm zone="ch-tools-tcl tclsh8.4"><primary sortas="b-tclsh8.4">tclsh8.4</primary></indexterm>
-</listitem>
-</varlistentry>
+    <variablelist>
+      <bridgehead renderas="sect3">Short Descriptions</bridgehead>
+      <?dbfo list-presentation="list"?>
+      <?dbhtml list-presentation="table"?>
 
-<varlistentry id="tclsh">
-<term><command>tclsh</command></term>
-<listitem>
-<para>A link to tclsh8.4</para>
-<indexterm zone="ch-tools-tcl tclsh"><primary sortas="b-tclsh">tclsh</primary></indexterm>
-</listitem>
-</varlistentry>
+      <varlistentry id="tclsh8.4">
+        <term><command>tclsh8.4</command></term>
+        <listitem>
+          <para>The Tcl command shell</para>
+          <indexterm zone="ch-tools-tcl tclsh8.4">
+            <primary sortas="b-tclsh8.4">tclsh8.4</primary>
+          </indexterm>
+        </listitem>
+      </varlistentry>
 
-<varlistentry id="libtcl8.4.so">
-<term><filename class="libraryfile">libtcl8.4.so</filename></term>
-<listitem>
-<para>The Tcl library</para>
-<indexterm zone="ch-tools-tcl libtcl8.4.so"><primary sortas="c-libtcl8.4.so">libtcl8.4.so</primary></indexterm>
-</listitem>
-</varlistentry>
-</variablelist>
+      <varlistentry id="tclsh">
+        <term><command>tclsh</command></term>
+        <listitem>
+          <para>A link to tclsh8.4</para>
+          <indexterm zone="ch-tools-tcl tclsh">
+            <primary sortas="b-tclsh">tclsh</primary>
+          </indexterm>
+        </listitem>
+      </varlistentry>
 
-</sect2>
+      <varlistentry id="libtcl8.4.so">
+        <term><filename class="libraryfile">libtcl8.4.so</filename></term>
+        <listitem>
+          <para>The Tcl library</para>
+          <indexterm zone="ch-tools-tcl libtcl8.4.so">
+            <primary sortas="c-libtcl8.4.so">libtcl8.4.so</primary>
+          </indexterm>
+        </listitem>
+      </varlistentry>
 
+    </variablelist>
+
+  </sect2>
+
 </sect1>
-

Modified: trunk/BOOK/chapter05/texinfo.xml
===================================================================
--- trunk/BOOK/chapter05/texinfo.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/texinfo.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,11 +27,6 @@
 <sect2 role="installation">
 <title>Installation of Texinfo</title>
 
-<para>Amend <filename>Makefile.in</filename>:</para>
-
-<screen><userinput>sed -e 's/^CFLAGS .*$/& -pie -fpie/' \
-    -i {info,makeinfo,util}/Makefile.in</userinput></screen>
-
 <para>Prepare Texinfo for compilation:</para>
 
 <screen><userinput>./configure --prefix=/tools</userinput></screen>
@@ -40,8 +35,6 @@
 
 <screen><userinput>make</userinput></screen>
 
-<para>To test the results, issue: <userinput>make check</userinput>.</para>
-
 <para>Install the package:</para>
 
 <screen><userinput>make install</userinput></screen>

Deleted: trunk/BOOK/chapter05/uclibc-headers.xml
===================================================================
--- trunk/BOOK/chapter05/uclibc-headers.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/uclibc-headers.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
-  <!ENTITY % general-entities SYSTEM "../general.ent">
-  %general-entities;
-]>
-<sect1 id="ch-tools-uclibc-headers" role="wrap" condition="uclibc">
-<title>uClibc-&uclibc-version; Headers</title>
-<?dbhtml filename="uclibc-headers.html"?>
-
-<indexterm zone="ch-tools-uclibc-headers">
-<primary sortas="a-uClibc">uClibc</primary>
-<secondary>tools, headers</secondary></indexterm>
-
-<sect2 role="package"><title/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/uclibc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
-
-<segmentedlist>
-<segtitle>&buildtime;</segtitle>
-<segtitle>&diskspace;</segtitle>
-<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
-</segmentedlist>
-
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-href="../chapter06/uclibc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
-
-</sect2>
-
-<sect2 role="installation">
-<title>Installation of uClibc Headers</title>
-
-<para>Apply a patch that adds a generic configuration:</para>
-
-<screen><userinput>patch -Np1 -i ../&uClibc-config-patch;</userinput></screen>
-
-<para>Prepare the uClibc headers:</para>
-
-<screen><userinput>make KERNEL_SOURCE=/tools headers</userinput></screen>
-
-<para>Before installing the libc headers, remove some symlinks pointing to
-kernel headers. This will prevent many warning messages and keep uClibc
-from clobbering the already installed kernel headers.</para>
-
-<screen><userinput>rm include/{asm,asm-generic,linux}</userinput></screen>
-
-<para>Install the headers:</para>
-
-<screen><userinput>make DEVEL_PREFIX=/tools/ install_dev</userinput></screen>
-
-</sect2>
-
-<sect2 role="content"><title/>
-<para>Details on this package are located in <xref
-linkend="contents-uclibc" role="."/></para>
-</sect2>
-
-</sect1>
-

Modified: trunk/BOOK/chapter05/uclibc.xml
===================================================================
--- trunk/BOOK/chapter05/uclibc.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/uclibc.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -29,11 +29,6 @@
 <sect2 role="installation">
 <title>Installation of uClibc</title>
 
-<para>Apply a patch to add the <function>arc4random()</function> to uClibc, and
-hooks for <command>mktemp</command>(3) and SSP to use it:</para>
-
-<screen><userinput>patch -Np1 -i ../&uClibc-arc4random-patch;</userinput></screen>
-
 <para>The next patch adds a generic config file. The key features to switch on are PIC,
 arc4random, locales and SSP. This will build with standard features. In chapter 6 you
 will be able to configure uClibc to your more specific needs:</para>
@@ -49,30 +44,22 @@
 
 <screen><userinput>install -m444 ../uClibc-locale-&uclibc-locale-version;.tgz extra/locale/</userinput></screen>
 
-<para>Use these commands to remove size reducing optimizations, which also tend
-to reduce performance:</para>
-
-<screen><userinput>sed -e '/mpreferred-stack-boundary/d' \
-    -e '/falign-jumps/d' -i Rules.mak
-sed -e 's/-Os,//' -i Rules.mak</userinput></screen>
-
 <para>Reset the installation paths:</para>
 
 <screen><userinput>sed -e \
     's at .*SHARED_LIB_LOADER_P.*@SHARED_LIB_LOADER_PREFIX="/tools/lib"@g' \
-    -i .config
-sed -e 's at .*RUNTIME_PREFIX.*@RUNTIME_PREFIX="/tools"@g' -i .config
-sed -e 's at .*DEVEL_PREFIX.*@DEVEL_PREFIX="/tools/"@g' -i .config
-sed -e 's at .*KERNEL_SOURCE.*@KERNEL_SOURCE="/tools"@g' -i .config</userinput></screen>
+    -e 's at .*RUNTIME_PREFIX.*@RUNTIME_PREFIX="/tools"@g' \
+    -e 's at .*DEVEL_PREFIX.*@DEVEL_PREFIX="/tools/"@g' \
+    -e 's at .*KERNEL_SOURCE.*@KERNEL_SOURCE="/tools"@g' -i.orig .config</userinput></screen>
 
 <para>Then build and install uClibc:</para>
 
-<screen><userinput>make CROSS=${target}- all</userinput></screen>
+<screen><userinput>make all</userinput></screen>
 
-<para>UClibc will clobber the previously installed libc headers. There is no
+<para>uClibc will clobber the previously installed libc headers. There is no
 practical way to prevent this, but no harm is done:</para>
 
-<screen><userinput>rm include/{asm,asm-generic,linux}</userinput></screen>
+<screen><userinput>rm -v include/{asm,asm-generic,linux}</userinput></screen>
 
 <para>Install the package:</para>
 
@@ -92,8 +79,7 @@
 
 <para>Build and install <filename class="libraryfile">libintl</filename>:</para>
 
-<screen><userinput>env CC=${target}-gcc \
-    ./configure --prefix=/tools \
+<screen><userinput>./configure --prefix=/tools \
     --with-included-gettext --without-csharp \
     --disable-libasprintf
 make -C intl/

Modified: trunk/BOOK/chapter05/util-linux.xml
===================================================================
--- trunk/BOOK/chapter05/util-linux.xml	2006-07-27 00:52:24 UTC (rev 669)
+++ trunk/BOOK/chapter05/util-linux.xml	2006-07-27 00:53:48 UTC (rev 670)
@@ -27,16 +27,11 @@
 <sect2 role="installation">
 <title>Installation of Util-linux</title>
 
-<para>Util-linux needs this patch to compile with
-<parameter>-fpic</parameter>/<parameter>-fpie</parameter>:</para>
-
-<screen><userinput>patch -Np1 -i ../&util-linux-hardened_cflags-patch;</userinput></screen>
-
 <para>Util-linux does not use the freshly installed headers and
 libraries from the <filename class="directory">/tools</filename>
 directory. This is fixed by altering the configure script:</para>
 
-<screen><userinput>sed -i 's@/usr/include@/tools/include at g' configure</userinput></screen>
+<screen><userinput>sed 's@/usr/include@/tools/include at g' -i.orig configure</userinput></screen>
 
 <para>Prepare Util-linux for compilation:</para>
 




More information about the hlfs-book mailing list