Changeset efcb393


Ignore:
Timestamp:
05/03/2020 09:02:51 PM (3 years ago)
Author:
Pierre Labastie <pieere@…>
Branches:
10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, arm, cross-chap5, ml-11.0, multilib, s6-init, trunk, xry111/arm64, xry111/clfs-ng, xry111/git-transition, xry111/glibc-2.34, xry111/glibc-2.37, xry111/kcfg-revise, xry111/lfs-next, xry111/pip3, xry111/queue-11.3, xry111/rust-wip-20221008, xry111/tester-nohack, xry111/usr-move
Children:
a715dec
Parents:
9d719e2
Message:

Make the new book

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/cross-chap5@11831 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

Files:
2 added
1 deleted
68 edited
4 moved

Legend:

Unmodified
Added
Removed
  • chapter01/how.xml

    r9d719e2 refcb393  
    4747  work your way through <xref linkend="chapter-temporary-tools"/> and beyond.</para>
    4848
    49   <para><xref linkend="chapter-temporary-tools"/> explains the
    50   installation of a number of packages that will form the basic
    51   development suite (or toolchain) which is used to build the actual
    52   system in <xref linkend="chapter-building-system"/>. Some of these
    53   packages are needed to resolve circular dependencies&mdash;for example,
    54   to compile a compiler, you need a compiler.</para>
     49  <para><xref linkend="chapter-temporary-tools"/> explains the installation of
     50  a number of packages that are needed to resolve circular
     51  dependencies&mdash;for example, to compile a compiler, you need a compiler.
     52  or to unpack the tar package, you need tar.</para>
    5553
    5654  <para><xref linkend="chapter-temporary-tools"/> also shows you how to
     
    6765
    6866  <para>This effort to isolate the new system from the host distribution may
    69   seem excessive. A full technical explanation as to why this is done is provided in
    70   <xref linkend="ch-tools-toolchaintechnotes"/>.</para>
     67  seem excessive. A full technical explanation as to why this is done is
     68  provided in <xref linkend="ch-tools-toolchaintechnotes"/>.</para>
    7169
    72   <para>In <xref linkend="chapter-building-system"/>, the full LFS system is
    73   built. The <command>chroot</command> (change root) program is used to enter
    74   a virtual environment and start a new shell whose root directory will be
    75   set to the LFS partition. This is very similar to rebooting and instructing
    76   the kernel to mount the LFS partition as the root partition. The system
    77   does not actually reboot, but instead uses <command>chroot</command> because
    78   creating a bootable system requires additional work which is not necessary
    79   just yet. The major advantage is that <quote>chrooting</quote> allows you
    80   to continue using the host system while LFS is being built. While waiting
    81   for package compilations to complete, you can continue using your computer as
    82   normal.</para>
     70  <para><xref linkend="chapter-building-system"/> begins with installing the
     71  remaining packages needed to build and test the final toolchain. Then, the
     72  full LFS system is built. But first, the <command>chroot</command> (change
     73  root) program is used to enter a virtual environment and start a new shell
     74  whose root directory will be set to the LFS partition. This is very similar
     75  to rebooting and instructing the kernel to mount the LFS partition as the
     76  root partition. The system does not actually reboot, but instead uses
     77  <command>chroot</command> because creating a bootable system requires
     78  additional work which is not necessary just yet. The major advantage is
     79  that <quote>chrooting</quote> allows you to continue using the host system
     80  while LFS is being built. While waiting for package compilations to
     81  complete, you can continue using your computer as normal.</para>
    8382
    8483  <para>To finish the installation, the basic system configuration is set up in
  • chapter02/stages.xml

    r9d719e2 refcb393  
    2626    <itemizedlist>
    2727      <listitem>
    28          <para>Procedures done as the root user after Section 2.4 need to
    29          have the LFS environment variable set <emphasis>FOR THE ROOT
    30          USER</emphasis>.</para>
     28        <para>Procedures done as the root user after Section 2.4 need to
     29        have the LFS environment variable set <emphasis>FOR THE ROOT
     30        USER</emphasis>.</para>
    3131      </listitem>
    3232    </itemizedlist>
     
    3838    <itemizedlist>
    3939      <listitem>
    40          <para>The /mnt/lfs partition must be mounted.</para>
     40        <para>The /mnt/lfs partition must be mounted.</para>
    4141      </listitem>
    4242
    4343      <listitem>
    44          <para><emphasis>ALL</emphasis> instructions in Chapter&nbsp;5
    45          must be done by user <emphasis>lfs</emphasis>. 
    46          A  <command>su - lfs</command> needs to be done before any
    47          task in Chapter&nbsp;5.</para>
     44        <para>This chapter includes three parts. The first one, from
     45        <quote>Binutils Pass1</quote> to <quote>Stripping</quote>
     46        must be done by user <emphasis>lfs</emphasis>. A
     47        <command>su - lfs</command> needs to be done before any task in this
     48        part. The second part, from <quote>Changing Ownership</quote> to
     49        <quote>Entering the Chroot Environment</quote> must be done as the
     50        root user, with LFS set for the root user. The third part, from
     51        <quote>Creating Directories</quote> to the end of the chapter, is done
     52        in the chroot environment. The same procedures as for chapter 6
     53        apply.</para>
    4854      </listitem>
    4955
  • chapter04/abouttestsuites.xml

    r9d719e2 refcb393  
    2626
    2727  <note>
    28     <para>Experience has shown that there is little to be gained from running
    29     the test suites in <xref linkend="chapter-temporary-tools"/>. There can be
    30     no escaping the fact that the host system always exerts some influence on
    31     the tests in that chapter, often causing inexplicable failures. Because
    32     the tools built in <xref linkend="chapter-temporary-tools"/> are temporary
    33     and eventually discarded, we do not recommend running the test suites in
    34     <xref linkend="chapter-temporary-tools"/> for the average reader. The
    35     instructions for running those test suites are provided for the benefit of
    36     testers and developers, but they are strictly optional.</para>
     28    <para>Running the test suites in <xref linkend="chapter-temporary-tools"/>
     29    is impossible, since the programs are compiled with a cross-compiler,
     30    so are not supposed to be able to run on the build host.</para>
    3731  </note>
    3832
  • chapter04/addinguser.xml

    r9d719e2 refcb393  
    7878
    7979  <para>Grant <systemitem class="username">lfs</systemitem> full access to
    80   <filename class="directory">$LFS/tools</filename> by making
     80  all directories under <filename class="directory">$LFS</filename> by making
    8181  <systemitem class="username">lfs</systemitem> the directory owner:</para>
    8282
    83 <screen><userinput>chown -v lfs $LFS/tools</userinput></screen>
     83<screen><userinput>chown -v lfs $LFS/{usr,lib,var,etc,bin,sbin,lib64,tools}</userinput></screen>
    8484
    8585  <para>If a separate working directory was created as suggested, give
  • chapter04/chapter04.xml

    r9d719e2 refcb393  
    1414  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="introduction.xml"/>
    1515  <!--<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="aboutlfs.xml"/>-->
    16   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="creatingtoolsdir.xml"/>
     16  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="creatingminlayout.xml"/>
    1717  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="addinguser.xml"/>
    1818  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="settingenviron.xml"/>
  • chapter04/introduction.xml

    r9d719e2 refcb393  
    1212
    1313  <para>In this chapter, we will perform a few additional tasks to prepare
    14   for building the temporary system. We will create a directory in
     14  for building the temporary system. We will create a set of directories in
    1515  <filename class="directory">$LFS</filename> for the installation of the
    1616  temporary tools, add an unprivileged user to reduce risk,
  • chapter04/settingenviron.xml

    r9d719e2 refcb393  
    4444LC_ALL=POSIX
    4545LFS_TGT=$(uname -m)-lfs-linux-gnu
    46 PATH=/tools/bin:/bin:/usr/bin
     46PATH=$LFS/tools/bin:/bin:/usr/bin
    4747export LFS LC_ALL LFS_TGT PATH</literal>
    4848EOF</userinput></screen>
     
    6262  the shell will always search the <envar>PATH</envar> when a program is to
    6363  be run. As such, the shell will find the newly compiled tools in
    64   <filename class="directory">$LFS/tools</filename> as soon as they are
     64  <filename class="directory">~/tools</filename> as soon as they are
    6565  available without remembering a previous version of the same program in a
    6666  different location.</para>
     
    109109
    110110    <varlistentry>
    111       <term><parameter>PATH=/tools/bin:/bin:/usr/bin</parameter></term>
     111      <term><parameter>PATH=$LFS/tools/bin:/bin:/usr/bin</parameter></term>
    112112      <listitem>
    113   <para>By putting <filename class="directory">/tools/bin</filename> ahead of the
     113  <para>By putting <filename class="directory">$LFS/tools/bin</filename> ahead of the
    114114  standard <envar>PATH</envar>, all the programs installed in <xref
    115115  linkend="chapter-temporary-tools"/> are picked up by the shell immediately after
  • chapter05/bash.xml

    r9d719e2 refcb393  
    4343  <sect2 role="installation">
    4444    <title>Installation of Bash</title>
    45 <!--
    46     <para>First, apply the following patch to fix various bugs that have been
    47     addressed upstream:</para>
    4845
    49 <screen><userinput remap="pre">patch -Np1 -i ../&bash-fixes-patch;</userinput></screen>
    50 -->
    5146    <para>Prepare Bash for compilation:</para>
    5247
    53 <screen><userinput remap="configure">./configure --prefix=/tools --without-bash-malloc</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr                   \
     49            --build=$(support/config.guess) \
     50            --host=$LFS_TGT                 \
     51            --without-bash-malloc</userinput></screen>
    5452
    5553    <variablelist>
     
    7371<screen><userinput remap="make">make</userinput></screen>
    7472
    75     <para>Compilation is now complete. As discussed earlier, running the test
    76     suite is not mandatory for the temporary tools here in this chapter. To run
    77     the Bash test suite anyway, issue the following command:</para>
    78 
    79 
    80 <screen><userinput remap="test">make tests</userinput></screen>
    81 
    8273    <para>Install the package:</para>
    8374
    84 <screen><userinput remap="install">make install</userinput></screen>
     75<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
     76
     77    <para>Move the excutable to where it is expected to be:</para>
     78
     79<screen><userinput remap="install">mv $LFS/usr/bin/bash $LFS/bin/bash</userinput></screen>
    8580
    8681    <para>Make a link for the programs that use <command>sh</command> for
    8782    a shell:</para>
    8883
    89 <screen><userinput remap="install">ln -sv bash /tools/bin/sh</userinput></screen>
     84<screen><userinput remap="install">ln -sv bash $LFS/bin/sh</userinput></screen>
    9085
    9186  </sect2>
  • chapter05/binutils-pass1.xml

    r9d719e2 refcb393  
    6767      &amp;&amp; make install; }</userinput>.</para>
    6868    </note>
    69 
     69<!--
    7070    <note><para>The approximate build SBU values and required disk space
    7171    in Chapter&nbsp;5 does not include test suite data.</para></note>
    72 
     72-->
    7373    <para>Now prepare Binutils for compilation:</para>
    7474
    75 <screen><userinput remap="configure">../configure --prefix=/tools            \
     75<screen><userinput remap="configure">../configure --prefix=$LFS/tools       \
    7676             --with-sysroot=$LFS        \
    77              --with-lib-path=/tools/lib \
    7877             --target=$LFS_TGT          \
    7978             --disable-nls              \
     
    8483
    8584      <varlistentry>
    86         <term><parameter>--prefix=/tools</parameter></term>
     85        <term><parameter>--prefix=$LFS/tools</parameter></term>
    8786        <listitem>
    8887          <para>This tells the configure script to prepare to install the
    89           Binutils programs in the <filename class="directory">/tools</filename>
    90           directory.</para>
     88          Binutils programs in the <filename
     89          class="directory">$LFS/tools</filename> directory.</para>
    9190        </listitem>
    9291      </varlistentry>
     
    9998        </listitem>
    10099      </varlistentry>
    101 
     100 <!--
    102101      <varlistentry>
    103         <term><parameter>--with-lib-path=/tools/lib</parameter></term>
     102        <term><parameter>- -with-lib-path=/tools/lib</parameter></term>
    104103        <listitem>
    105104          <para>This specifies which library path the linker should be
     
    107106        </listitem>
    108107      </varlistentry>
    109 
     108  -->
    110109      <varlistentry>
    111110        <term><envar>--target=$LFS_TGT</envar></term>
     
    141140<screen><userinput remap="make">make</userinput></screen>
    142141
    143     <para>Compilation is now complete. Ordinarily we would now run the
    144     test suite, but at this early stage the test suite framework (Tcl,
    145     Expect, and DejaGNU) is not yet in place. The benefits of running the
    146     tests at this point are minimal since the programs from this
    147     first pass will soon be replaced by those from the second.</para>
    148 
    149     <para>If building on x86_64, create a symlink to ensure the sanity of
    150     the toolchain:</para>
    151 
    152 <screen><userinput remap="install">case $(uname -m) in
    153   x86_64) mkdir -v /tools/lib &amp;&amp; ln -sv lib /tools/lib64 ;;
    154 esac</userinput></screen>
    155 
    156142    <para>Install the package:</para>
    157143
  • chapter05/binutils-pass2.xml

    r9d719e2 refcb393  
    5151    <para>Prepare Binutils for compilation:</para>
    5252
    53 <screen><userinput remap="configure">CC=$LFS_TGT-gcc                \
    54 AR=$LFS_TGT-ar                 \
    55 RANLIB=$LFS_TGT-ranlib         \
    56 ../configure                   \
    57     --prefix=/tools            \
     53<screen><userinput remap="configure">../configure                   \
     54    --prefix=/usr              \
     55    --build=$(../config.guess) \
     56    --host=$LFS_TGT            \
    5857    --disable-nls              \
    59     --disable-werror           \
    60     --with-lib-path=/tools/lib \
    61     --with-sysroot</userinput></screen>
     58    --enable-shared            \
     59    --disable-werror</userinput></screen>
    6260
    6361    <variablelist>
     
    6563
    6664      <varlistentry>
    67         <term><parameter>CC=$LFS_TGT-gcc AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib</parameter></term>
     65        <term><parameter>--host=$LFS_TGT</parameter></term>
    6866        <listitem>
    69           <para>Because this is really a native build of Binutils, setting these
    70           variables ensures that the build system uses the cross-compiler and
    71           associated tools instead of the ones on the host system.</para>
    72         </listitem>
    73       </varlistentry>
    74 
    75       <varlistentry>
    76         <term><parameter>--with-lib-path=/tools/lib</parameter></term>
    77         <listitem>
    78           <para>This tells the configure script to specify the library
    79           search path during the compilation of Binutils, resulting in
    80           <filename class="directory">/tools/lib</filename> being passed
    81           to the linker. This prevents the linker from searching through
    82           library directories on the host.</para>
    83         </listitem>
    84       </varlistentry>
    85 
    86       <varlistentry>
    87         <term><parameter>--with-sysroot</parameter></term>
    88         <listitem>
    89           <para>This defines a default (non-existent) sysroot directory
    90           <filename class="directory">/tools/$LFS_TGT/sys-root</filename>.
    91           It is useful when looking for shared objects which are required by
    92           other shared objects explicitly included on the linker's command
    93           line. Those objects are searched into the directories listed in
    94           <filename>&lt;sysroot&gt;/etc/ld.so.conf</filename>, and failing
    95           that, into the linker search path, which is right. If this switch
    96           is not given, <filename>/etc/ld.so.conf</filename> on the host
    97           is used, that is, programs may be linked to libraries on
    98           the host, which we want to avoid.</para>
     67          <para>This tells the configure script that we want to build
     68          this pass of binutils for the $LFS_TGT machine, using our just
     69          built cross-compiler.  This prevents the linker from searching
     70          through library directories on the host.</para>
    9971        </listitem>
    10072      </varlistentry>
     
    10880    <para>Install the package:</para>
    10981
    110 <screen><userinput remap="install">make install</userinput></screen>
    111 
    112     <para>Now prepare the linker for the <quote>Re-adjusting</quote> phase in
    113     the next chapter:</para>
    114 
    115 <screen><userinput remap="adjust">make -C ld clean
    116 make -C ld LIB_PATH=/usr/lib:/lib
    117 cp -v ld/ld-new /tools/bin</userinput></screen>
    118 
    119     <variablelist>
    120       <title>The meaning of the make parameters:</title>
    121 
    122       <varlistentry>
    123         <term><parameter>-C ld clean</parameter></term>
    124         <listitem>
    125           <para>This tells the make program to remove all compiled
    126           files in the <filename class="directory">ld</filename>
    127           subdirectory.</para>
    128         </listitem>
    129       </varlistentry>
    130 
    131       <varlistentry>
    132         <term><parameter>-C ld LIB_PATH=/usr/lib:/lib</parameter></term>
    133         <listitem>
    134           <para>This option rebuilds everything in the <filename
    135           class="directory">ld</filename> subdirectory. Specifying the
    136           <envar>LIB_PATH</envar> Makefile variable on the command line
    137           allows us to override the default value of the temporary tools
    138           and point it to the proper final path. The value of this variable
    139           specifies the linker's default library search path. This
    140           preparation is used in the next chapter.</para>
    141         </listitem>
    142       </varlistentry>
    143 
    144     </variablelist>
     82<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    14583
    14684  </sect2>
  • chapter05/bison.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Bison for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr                     \
     49            --build=$(build-aux/config.guess) \
     50            --host=$LFS_TGT                   \
     51            --docdir=/usr/share/doc/bison-&bison-version;</userinput></screen>
     52
     53    <variablelist>
     54      <title>The meaning of the new configure option:</title>
     55
     56      <varlistentry>
     57        <term><parameter>--docdir=/usr/share/doc/bison-&bison-version;</parameter></term>
     58        <listitem>
     59          <para>This tells the build system to install bison documentation
     60          into a versioned directory.</para>
     61        </listitem>
     62      </varlistentry>
     63
     64    </variablelist>
    4965
    5066    <para>Compile the package:</para>
     
    5268<screen><userinput remap="make">make</userinput></screen>
    5369
    54     <para>To test the results, issue:</para>
    55 
    56 <screen><userinput remap="test">make check</userinput></screen>
    57 
    5870    <para>Install the package:</para>
    5971
    60 <screen><userinput remap="install">make install</userinput></screen>
     72<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    6173
    6274  </sect2>
  • chapter05/bzip2.xml

    r9d719e2 refcb393  
    4444    <title>Installation of Bzip2</title>
    4545
     46    <para>Apply a patch that will install the documentation for this
     47    package:</para>
     48
     49<screen><userinput remap="pre">patch -Np1 -i ../&bzip2-docs-patch;</userinput></screen>
     50
     51    <para>The following command ensures installation of symbolic links are
     52    relative:</para>
     53
     54<screen><userinput remap="pre">sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile</userinput></screen>
     55
     56    <para>Ensure the man pages are installed into the correct location:</para>
     57
     58<screen><userinput remap="pre">sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile</userinput></screen>
     59
    4660    <para>The Bzip2 package does not contain a <command>configure</command>
    4761    script. There are two <filename>Makefile</filename>, one for the shared
     
    4963    do the compilation in two stages. First the shared library:</para>
    5064
    51 <screen><userinput remap="make">make -f Makefile-libbz2_so
     65<screen><userinput remap="make">make CC=$LFS_TGT-gcc -f Makefile-libbz2_so
    5266make clean</userinput></screen>
    5367
     
    7084    <para>Compile and test the package with:</para>
    7185
    72 <screen><userinput remap="make">make</userinput></screen>
     86<screen><userinput remap="make">make CC=$LFS_TGT-gcc AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib</userinput></screen>
    7387
    7488    <para>Install the package:</para>
    7589
    76 <screen><userinput remap="install">make PREFIX=/tools install
    77 cp -v bzip2-shared /tools/bin/bzip2
    78 cp -av libbz2.so* /tools/lib
    79 ln -sv libbz2.so.1.0 /tools/lib/libbz2.so</userinput></screen>
     90<screen><userinput remap="install">make PREFIX=$LFS/usr install</userinput></screen>
     91
     92    <para>Install the shared <command>bzip2</command> binary into the
     93    <filename class="directory">/bin</filename> directory, make some necessary
     94    symbolic links, and clean up:</para>
     95
     96<screen><userinput remap="install">cp -v bzip2-shared $LFS/bin/bzip2
     97cp -av libbz2.so* $LFS/lib
     98ln -sv ../../lib/libbz2.so.1.0 $LFS/usr/lib/libbz2.so
     99rm -v $LFS/usr/bin/{bunzip2,bzcat,bzip2}
     100ln -sv bzip2 $LFS/bin/bunzip2
     101ln -sv bzip2 $LFS/bin/bzcat</userinput></screen>
    80102
    81103  </sect2>
     
    83105  <sect2 role="content">
    84106    <title/>
    85 
    86107    <para>Details on this package are located in
    87108    <xref linkend="contents-bzip2" role="."/></para>
  • chapter05/changingowner.xml

    r9d719e2 refcb393  
    1919  </note>
    2020
    21   <para>Currently, the <filename class="directory">$LFS/tools</filename> directory
     21  <para>Currently, the whole directory hierarchy in <filename
     22  class="directory">$LFS</filename>
    2223  is owned by the user <systemitem class="username">lfs</systemitem>, a user
    23   that exists only on the host system. If the <filename
    24   class="directory">$LFS/tools</filename> directory is kept as is, the files are
     24  that exists only on the host system. If the directories under <filename
     25  class="directory">$LFS</filename> are kept as they are, the files are
    2526  owned by a user ID without a corresponding account. This is dangerous because
    26   a user account created later could get this same user ID and would own the
    27   <filename class="directory">$LFS/tools</filename> directory and all the files
    28   therein, thus exposing these files to possible malicious manipulation.</para>
     27  a user account created later could get this same user ID and would own all
     28  the files under <filename class="directory">$LFS</filename>, thus exposing
     29  these files to possible malicious manipulation.</para>
    2930
    3031  <para>To avoid this issue, you could add the <systemitem
     
    3233  creating the <filename>/etc/passwd</filename> file, taking care to assign it
    3334  the same user and group IDs as on the host system. Better yet, change the
    34   ownership of the <filename class="directory">$LFS/tools</filename> directory to
     35  ownership of the <filename class="directory">$LFS/*</filename> directories to
    3536  user <systemitem class="username">root</systemitem> by running the following
    3637  command:</para>
    3738
    38 <screen><userinput>chown -R root:root $LFS/tools</userinput></screen>
    39 
    40   <para>Although the <filename class="directory">$LFS/tools</filename> directory
    41   can be deleted once the LFS system has been finished, it can be retained to build
    42   additional LFS systems <emphasis>of the same book version</emphasis>. How best
    43   to backup <filename class="directory">$LFS/tools</filename> is a matter of
    44   personal preference.</para>
    45 
    46   <caution>
    47     <para>If you intend to keep the temporary tools for use in building future LFS
    48     systems, <emphasis>now</emphasis> is the time to back them up. Subsequent
    49     commands in chapter 6 will alter the tools currently in place, rendering them
    50     useless for future builds.</para>
    51   </caution>
     39<screen><userinput>chown -R root:root $LFS/{usr,lib,var,etc,bin,sbin,lib64,tools}</userinput></screen>
    5240
    5341</sect1>
  • chapter05/chapter05.xml

    r9d719e2 refcb393  
    2020  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glibc.xml"/>
    2121  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="libstdc++.xml"/>
    22   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils-pass2.xml"/>
    23   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass2.xml"/>
    24   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tcl.xml"/>
    25   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="expect.xml"/>
    26   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dejagnu.xml"/>
    2722  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="m4.xml"/>
    2823  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ncurses.xml"/>
     
    3631  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="findutils.xml"/>
    3732  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gawk.xml"/>
    38   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gettext.xml"/>
    3933  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="grep.xml"/>
    4034  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gzip.xml"/>
    4135  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="make.xml"/>
    4236  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="patch.xml"/>
     37  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sed.xml"/>
     38  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tar.xml"/>
     39  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="xz.xml"/>
     40  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils-pass2.xml"/>
     41  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass2.xml"/>
     42  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="stripping.xml"/>
     43  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="changingowner.xml"/>
     44  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="kernfs.xml"/>
     45  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="chroot.xml"/>
     46  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="creatingdirs.xml"/>
     47  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="createfiles.xml"/>
     48  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="libstdc++-pass2.xml"/>
     49  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gettext.xml"/>
    4350  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="perl.xml"/>
    4451  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="python.xml"/>
    45   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sed.xml"/>
    46   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tar.xml"/>
    4752  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="texinfo.xml"/>
    4853  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="util-linux.xml"/>
    49   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="xz.xml"/>
    50   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="stripping.xml"/>
    51   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="changingowner.xml"/>
     54  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tcl.xml"/>
     55  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="expect.xml"/>
     56  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dejagnu.xml"/>
    5257
    5358</chapter>
  • chapter05/chroot.xml

    r9d719e2 refcb393  
    66]>
    77
    8 <sect1 id="ch-system-chroot">
     8<sect1 id="ch-tools-chroot">
    99  <?dbhtml filename="chroot.html"?>
    1010
    1111  <title>Entering the Chroot Environment</title>
    1212
    13   <para>It is time to enter the chroot environment to begin building and
    14   installing the final LFS system. As user <systemitem
     13  <para>Now that all the packages which depend on themselves for being built
     14  are on the system, it is time to enter the chroot environment to finish
     15  installing the remaining temporary tools. This environment will be in use
     16  also for installing the final system. As user <systemitem
    1517  class="username">root</systemitem>, run the following command to enter the
    1618  realm that is, at the moment, populated with only the temporary tools:</para>
    1719
    18 <screen role="nodump"><userinput>chroot "$LFS" /tools/bin/env -i \
     20<screen role="nodump"><userinput>chroot "$LFS" /usr/bin/env -i \
    1921    HOME=/root                  \
    2022    TERM="$TERM"                \
    2123    PS1='(lfs chroot) \u:\w\$ ' \
    22     PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    23     /tools/bin/bash --login +h</userinput></screen>
     24    PATH=/bin:/usr/bin:/sbin:/usr/sbin \
     25    /bin/bash --login +h</userinput></screen>
    2426
    2527  <para>The <parameter>-i</parameter> option given to the <command>env</command>
     
    4042  (<filename class="directory">/</filename>) directory.</para>
    4143
    42   <para>Notice that <filename class="directory">/tools/bin</filename> comes last
    43   in the <envar>PATH</envar>. This means that a temporary tool will no longer be
     44  <para>Notice that <filename class="directory">/tools/bin</filename> is not
     45  anymore in the <envar>PATH</envar>. This means that a temporary tool will no longer be
    4446  used once its final version is installed. This occurs when the shell does not
    4547  <quote>remember</quote> the locations of executed binaries&mdash;for this
  • chapter05/coreutils.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Coreutils for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools --enable-install-program=hostname</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr                     \
     49            --host=$LFS_TGT                   \
     50            --build=$(build-aux/config.guess) \
     51            --enable-install-program=hostname \
     52            --enable-no-install-program=kill,uptime</userinput></screen>
    4953
    5054    <variablelist>
     
    6569<screen><userinput remap="make">make</userinput></screen>
    6670
    67     <para>Compilation is now complete. As discussed earlier, running the test
    68     suite is not mandatory for the temporary tools here in this chapter. To run
    69     the Coreutils test suite anyway, issue the following command:</para>
    70 
    71 <screen><userinput remap="test">make RUN_EXPENSIVE_TESTS=yes check</userinput></screen>
    72 
    73     <para>The <parameter>RUN_EXPENSIVE_TESTS=yes</parameter> parameter tells the
    74     test suite to run several additional tests that are considered
    75     relatively expensive (in terms of CPU power and memory usage) on some
    76     platforms, but generally are not a problem on Linux.</para>
    77 
    7871    <para>Install the package:</para>
    7972
    80 <screen><userinput remap="install">make install</userinput></screen>
     73<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    8174<!--
    8275    <para>The above command refuses to install <filename>su</filename>
     
    8780<screen><userinput remap="install">cp -v src/su /tools/bin</userinput></screen>
    8881-->
     82    <para>Move programs to their final expected locations. Although this is
     83    not necessary in this temporary environment, we must do so because some
     84    programs harcode executable locations:</para>
     85
     86<screen><userinput remap="install">mv -v $LFS/usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} $LFS/bin
     87mv -v $LFS/usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} $LFS/bin
     88mv -v $LFS/usr/bin/{rmdir,stty,sync,true,uname} $LFS/bin
     89mv -v $LFS/usr/bin/chroot $LFS/usr/sbin
     90mkdir -pv $LFS/usr/share/man/man8
     91mv -v $LFS/usr/share/man/man1/chroot.1 $LFS/usr/share/man/man8/chroot.8
     92sed -i s/\"1\"/\"8\"/1 $LFS/usr/share/man/man8/chroot.8
     93mv -v $LFS/usr/bin/{head,nice,sleep,touch} $LFS/bin</userinput></screen>
     94
    8995  </sect2>
    9096
  • chapter05/createfiles.xml

    r9d719e2 refcb393  
    66]>
    77
    8 <sect1 id="ch-system-createfiles">
     8<sect1 id="ch-tools-createfiles">
    99  <?dbhtml filename="createfiles.html"?>
    1010
    1111  <title>Creating Essential Files and Symlinks</title>
    1212
    13   <indexterm zone="ch-system-createfiles">
     13  <indexterm zone="ch-tools-createfiles">
    1414    <primary sortas="e-/etc/passwd">/etc/passwd</primary>
    1515  </indexterm>
    1616
    17   <indexterm zone="ch-system-createfiles">
     17  <indexterm zone="ch-tools-createfiles">
    1818    <primary sortas="e-/etc/group">/etc/group</primary>
    1919  </indexterm>
    2020
    21   <indexterm zone="ch-system-createfiles">
     21  <indexterm zone="ch-tools-createfiles">
    2222    <primary sortas="e-/var/run/utmp">/var/run/utmp</primary>
    2323  </indexterm>
    2424
    25   <indexterm zone="ch-system-createfiles">
     25  <indexterm zone="ch-tools-createfiles">
    2626    <primary sortas="e-/var/log/btmp">/var/log/btmp</primary>
    2727  </indexterm>
    2828
    29   <indexterm zone="ch-system-createfiles">
     29  <indexterm zone="ch-tools-createfiles">
    3030    <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
    3131  </indexterm>
    3232
    33   <indexterm zone="ch-system-createfiles">
     33  <indexterm zone="ch-tools-createfiles">
    3434    <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
    3535  </indexterm>
    36 
    37   <para>Some programs use hard-wired paths to programs which do not exist yet.
    38   In order to satisfy these programs, create a number of symbolic links which
    39   will be replaced by real files throughout the course of this chapter after the
    40   software has been installed:</para>
    41 
    42 <screen><userinput>ln -sv /tools/bin/{bash,cat,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin
    43 ln -sv /tools/bin/{env,install,perl,printf}         /usr/bin
    44 ln -sv /tools/lib/libgcc_s.so{,.1}                  /usr/lib
    45 ln -sv /tools/lib/libstdc++.{a,so{,.6}}             /usr/lib
    46 ln -sv /tools/lib/libfl.so*                         /usr/lib
    47 
    48 ln -sv bash /bin/sh
    49 
    50 for lib in blkid mount uuid fdisk
    51 do
    52     ln -sv /tools/lib/lib$lib.so* /usr/lib
    53     sed 's|/tools|/usr|' /tools/lib/pkgconfig/${lib}.pc \
    54         &gt; /usr/lib/pkgconfig/${lib}.pc
    55 done
    56 for incdir in blkid libmount uuid libfdisk
    57 do
    58     ln -svf /tools/include/$incdir    /usr/include
    59 done</userinput></screen>
    60 
    61   <variablelist>
    62     <title>The purpose of each link:</title>
    63 
    64     <varlistentry>
    65       <term><parameter><filename>/bin/bash</filename></parameter></term>
    66       <listitem>
    67         <para>Many <command>bash</command> scripts specify
    68         <filename>/bin/bash</filename>.</para>
    69       </listitem>
    70     </varlistentry>
    71 
    72     <varlistentry>
    73       <term><parameter><filename>/bin/cat</filename></parameter></term>
    74       <listitem>
    75         <para>This pathname is hard-coded into Glibc's configure script.</para>
    76       </listitem>
    77     </varlistentry>
    78 
    79     <varlistentry>
    80       <term><parameter><filename>/bin/dd</filename></parameter></term>
    81       <listitem>
    82         <para>The path to <filename>dd</filename> will be hard-coded into the
    83         <filename>/usr/bin/libtool</filename> utility.</para>
    84       </listitem>
    85     </varlistentry>
    86 
    87     <varlistentry>
    88       <term><parameter><filename>/bin/echo</filename></parameter></term>
    89       <listitem>
    90         <para>This is to satisfy one of the tests in Glibc's test suite, which
    91         expects <filename>/bin/echo</filename>.</para>
    92       </listitem>
    93     </varlistentry>
    94 
    95     <varlistentry>
    96       <term><parameter><filename>/usr/bin/env</filename></parameter></term>
    97       <listitem>
    98         <para>This pathname is hard-coded into some packages build procedures.
    99         <!-- systemd  This may not be needed if we move sysd to the end--></para>
    100       </listitem>
    101     </varlistentry>
    102 
    103     <varlistentry>
    104       <term><parameter><filename>/usr/bin/install</filename></parameter></term>
    105       <listitem>
    106         <para>The path to <filename>install</filename> will be hard-coded into
    107         the <filename>/usr/lib/bash/Makefile.inc</filename> file.</para>
    108       </listitem>
    109     </varlistentry>
    110 
    111     <varlistentry>
    112       <term><parameter><filename>/bin/ln</filename></parameter></term>
    113       <listitem>
    114         <para>The path to <filename>ln</filename> will be hard-coded into the
    115         <filename>/usr/lib/perl5/&perl-version;/&lt;target-triplet&gt;/Config_heavy.pl</filename>
    116          file.</para>
    117       </listitem>
    118     </varlistentry>
    119 
    120     <varlistentry>
    121       <term><parameter><filename>/bin/pwd</filename></parameter></term>
    122       <listitem>
    123         <para>Some <command>configure</command> scripts, particularly Glibc's,
    124         have this pathname hard-coded.</para>
    125       </listitem>
    126     </varlistentry>
    127 
    128     <varlistentry>
    129       <term><parameter><filename>/bin/rm</filename></parameter></term>
    130       <listitem>
    131         <para>The path to <filename>rm</filename> will be hard-coded into the
    132         <filename>/usr/lib/perl5/&perl-version;/&lt;target-triplet&gt;/Config_heavy.pl</filename>
    133          file.</para>
    134       </listitem>
    135     </varlistentry>
    136 
    137     <varlistentry>
    138       <term><parameter><filename>/bin/stty</filename></parameter></term>
    139       <listitem>
    140         <para>This pathname is hard-coded into Expect, therefore it is needed
    141         for Binutils and GCC test suites to pass.</para>
    142       </listitem>
    143     </varlistentry>
    144 
    145     <varlistentry>
    146       <term><parameter><filename>/usr/bin/perl</filename></parameter></term>
    147       <listitem>
    148         <para>Many Perl scripts hard-code this path to the
    149         <command>perl</command> program.</para>
    150       </listitem>
    151     </varlistentry>
    152 
    153     <varlistentry>
    154       <term><parameter><filename>/usr/lib/libgcc_s.so{,.1}</filename></parameter></term>
    155       <listitem>
    156         <para>Glibc needs this for the pthreads library to work.</para>
    157       </listitem>
    158     </varlistentry>
    159 
    160     <varlistentry>
    161       <term><parameter><filename>/usr/lib/libstdc++{,.6}</filename></parameter></term>
    162       <listitem>
    163         <para>This is needed by several tests in Glibc's test suite, as well as
    164         for C++ support in GMP.</para>
    165       </listitem>
    166     </varlistentry>
    167 
    168     <varlistentry>
    169       <term><parameter><filename>/bin/sh</filename></parameter></term>
    170       <listitem>
    171         <para>Many shell scripts hard-code <filename>/bin/sh</filename>.</para>
    172       </listitem>
    173     </varlistentry>
    174 
    175     <varlistentry>
    176       <term>
    177         <parameter><filename>/usr/lib/libfl.so*</filename></parameter>
    178       </term>
    179       <listitem>
    180         <para>This link allows binutils to find the flex library, and to
    181         build enhanced versions of ar and ranlib.</para>
    182       </listitem>
    183     </varlistentry>
    184 
    185     <varlistentry>
    186       <term>
    187         <parameter>
    188           <filename>/usr/lib/lib{blkid,fdisk,mount,uuid}.so*</filename>,
    189           <filename>/usr/include/{blkid,libfdisk,libmount,uuid}</filename>,
    190           <filename>/usr/lib/pkgconfig/{blkid,fdisk,mount,uuid}.pc</filename>
    191         </parameter>
    192       </term>
    193       <listitem>
    194         <para>These links and files allow
    195         <phrase revision="sysv">eudev</phrase>
    196         <phrase revision="systemd">systemd</phrase> to find the
    197         util-linux libraries installed in chapter 5, without creating
    198         wrong references to /tools. The uuid library is also needed for
    199         building a python module.</para>
    200       </listitem>
    201     </varlistentry>
    202 
    203   </variablelist>
    20436
    20537  <para>Historically, Linux maintains a list of the mounted file systems in the
     
    314146
    315147  <para>The created groups are not part of any standard&mdash;they are groups
    316   decided on in part by the requirements of the Udev configuration in this
     148  decided on in part by the requirements of the Udev configuration in the next
    317149  chapter, and in part by common convention employed by a number of existing
    318150  Linux distributions. In addition, some test suites rely on specific users
     
    326158
    327159  <para>To remove the <quote>I have no name!</quote> prompt, start a new
    328   shell. Since a full Glibc was installed in <xref
    329   linkend="chapter-temporary-tools"/> and the
     160  shell. Since the
    330161  <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
    331162  files have been created, user name and group name resolution will now
    332163  work:</para>
    333164
    334 <screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
     165<screen role="nodump"><userinput>exec /bin/bash --login +h</userinput></screen>
    335166
    336167  <para>Note the use of the <parameter>+h</parameter> directive. This tells
  • chapter05/creatingdirs.xml

    r9d719e2 refcb393  
    66]>
    77
    8 <sect1 id="ch-system-creatingdirs">
     8<sect1 id="ch-tools-creatingdirs">
    99  <?dbhtml filename="creatingdirs.html"?>
    1010
    1111  <title>Creating Directories</title>
    1212
    13   <para>It is time to create some structure in the LFS file system. Create a
    14   standard directory tree by issuing the following commands:</para>
     13  <para>It is time to create the full structure in the LFS file system. Create
     14  a standard directory tree by issuing the following commands:</para>
    1515
    1616<screen><userinput>mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,mnt,opt}
    17 mkdir -pv /{media/{floppy,cdrom},sbin,srv,var}
     17mkdir -pv /{media/{floppy,cdrom},srv,var}
    1818install -dv -m 0750 /root
    1919install -dv -m 1777 /tmp /var/tmp
    2020mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
    2121mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
    22 mkdir -v  /usr/{,local/}share/{misc,terminfo,zoneinfo}
    23 mkdir -v  /usr/libexec
     22mkdir -pv  /usr/{,local/}share/{misc,terminfo,zoneinfo}
    2423mkdir -pv /usr/{,local/}share/man/man{1..8}
    25 mkdir -v  /usr/lib/pkgconfig
    26 
    27 case $(uname -m) in
    28  x86_64) mkdir -v /lib64 ;;
    29 esac
    3024
    3125mkdir -v /var/{log,mail,spool}
  • chapter05/dejagnu.xml

    r9d719e2 refcb393  
    4545    <para>Prepare DejaGNU for compilation:</para>
    4646
    47 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     47<screen><userinput remap="configure">./configure --prefix=/usr
     48makeinfo --html --no-split -o doc/dejagnu.html doc/dejagnu.texi
     49makeinfo --plaintext       -o doc/dejagnu.txt  doc/dejagnu.texi</userinput></screen>
    4850
    4951    <para>Build and install the package:</para>
    5052
    51 <screen><userinput remap="install">make install</userinput></screen>
     53<screen><userinput remap="install">make install
     54install -v -dm755  /usr/share/doc/dejagnu-&dejagnu-version;
     55install -v -m644   doc/dejagnu.{html,txt} \
     56                   /usr/share/doc/dejagnu-&dejagnu-version;</userinput></screen>
    5257
    5358    <para>To test the results, issue:</para>
  • chapter05/diffutils.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Diffutils for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr --host=$LFS_TGT</userinput></screen>
    4949
    5050    <para>Compile the package:</para>
     
    5252<screen><userinput remap="make">make</userinput></screen>
    5353
    54     <para>Compilation is now complete. As discussed earlier, running the test
    55     suite is not mandatory for the temporary tools here in this chapter. To run
    56     the Diffutils test suite anyway, issue the following command:</para>
    57 
    58 <screen><userinput remap="test">make check</userinput></screen>
    59 
    6054    <para>Install the package:</para>
    6155
    62 <screen><userinput remap="install">make install</userinput></screen>
     56<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    6357
    6458  </sect2>
  • chapter05/expect.xml

    r9d719e2 refcb393  
    4949    <title>Installation of Expect</title>
    5050
    51     <para>First, force Expect's configure script to use <filename>/bin/stty</filename>
    52     instead of a <filename>/usr/local/bin/stty</filename> it may find on the host system.
    53     This will ensure that our test suite tools remain sane for the final builds of our
    54     toolchain:</para>
     51    <para>Prepare Expect for compilation:</para>
    5552
    56 <screen><userinput remap="pre">cp -v configure{,.orig}
    57 sed 's:/usr/local/bin:/bin:' configure.orig &gt; configure</userinput></screen>
    58 
    59     <para>Now prepare Expect for compilation:</para>
    60 
    61 <screen><userinput remap="configure">./configure --prefix=/tools       \
    62             --with-tcl=/tools/lib \
    63             --with-tclinclude=/tools/include</userinput></screen>
     53<screen><userinput remap="configure">
     54./configure --prefix=/usr           \
     55            --with-tcl=/usr/lib     \
     56            --enable-shared         \
     57            --mandir=/usr/share/man \
     58            --with-tclinclude=/usr/include</userinput></screen>
    6459
    6560    <variablelist>
     
    6762
    6863      <varlistentry>
    69         <term><parameter>--with-tcl=/tools/lib</parameter></term>
     64        <term><parameter>--with-tcl=/usr/lib</parameter></term>
    7065        <listitem>
    71           <para>This ensures that the configure script finds the Tcl
    72           installation in the temporary tools location instead of possibly
    73           locating an existing one on the host system.</para>
     66          <para>This parameter is needed to tell the
     67          <command>configure</command> where the
     68          <command>tclConfig.sh</command> is located.</para>
    7469        </listitem>
    7570      </varlistentry>
    7671
    7772      <varlistentry>
    78         <term><parameter>--with-tclinclude=/tools/include</parameter></term>
     73        <term><parameter>--with-tclinclude=/usr/include</parameter></term>
    7974        <listitem>
    8075          <para>This explicitly tells Expect where to find Tcl's internal
     
    9186<screen><userinput remap="make">make</userinput></screen>
    9287
    93     <para>Compilation is now complete. As discussed earlier, running the test
    94     suite is not mandatory for the temporary tools here in this chapter. To run
    95     the Expect test suite anyway, issue the following command:</para>
    96 
    97 <screen><userinput remap="test">make test</userinput></screen>
    98 
    99     <para>Note that the Expect test suite is known to experience failures under
    100     certain host conditions that are not within our control. Therefore,
    101     test suite failures here are not surprising and are not considered
    102     critical.</para>
    103 
    10488    <para>Install the package:</para>
    10589
    106 <screen><userinput remap="install">make SCRIPTS="" install</userinput></screen>
    107 
    108     <variablelist>
    109       <title>The meaning of the make parameter:</title>
    110 
    111       <varlistentry>
    112         <term><parameter>SCRIPTS=""</parameter></term>
    113         <listitem>
    114           <para>This prevents installation of the supplementary Expect
    115           scripts, which are not needed.</para>
    116         </listitem>
    117       </varlistentry>
    118 
    119     </variablelist>
     90<screen><userinput remap="install">make install
     91ln -svf expect&expect-version;/libexpect&expect-version;.so /usr/lib</userinput></screen>
    12092
    12193  </sect2>
  • chapter05/file.xml

    r9d719e2 refcb393  
    4646    <para>Prepare File for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr   \
     49            --host=$LFS_TGT</userinput></screen>
    4950
     51<!-- devs: if using - -build here, the build system wants to compile
     52     the signature file with "file" on the build system, but stops if it is not
     53     the same version. One possibility would be to build "file" on the build
     54     system first, but it is simpler to have the system think it is not
     55     cross-compiling, and use the just built "file". -->
    5056    <para>Compile the package:</para>
    5157
    5258<screen><userinput remap="make">make</userinput></screen>
    5359
    54     <para>Compilation is now complete. As discussed earlier, running the test
    55     suite is not mandatory for the temporary tools here in this chapter. To run
    56     the File test suite anyway, issue the following command:</para>
    57 
    58 <screen><userinput remap="test">make check</userinput></screen>
    59 
    6060    <para>Install the package:</para>
    6161
    62 <screen><userinput remap="install">make install</userinput></screen>
     62<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    6363
    6464  </sect2>
     
    6666  <sect2 role="content">
    6767    <title/>
    68 
    69     <para>Details on this package are located in
    70     <xref linkend="contents-file" role="."/></para>
     68    <para>Details on this package are located in<!-- TODO
     69    <xref linkend="contents-file" role="."/>      --></para>
    7170
    7271  </sect2>
  • chapter05/findutils.xml

    r9d719e2 refcb393  
    4343  <sect2 role="installation">
    4444    <title>Installation of Findutils</title>
    45 <!--
    46     <para>First, make some fixes required by glibc-2.28:</para>
    4745
    48 <screen><userinput remap="pre">sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' gl/lib/*.c
    49 sed -i '/unistd/a #include &lt;sys/sysmacros.h&gt;' gl/lib/mountlist.c
    50 echo "#define _IO_IN_BACKUP 0x100" >> gl/lib/stdio-impl.h</userinput></screen>
    51 -->
    5246    <para>Prepare Findutils for compilation:</para>
    5347
    54 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr   \
     49            --host=$LFS_TGT \
     50            --build=$(build-aux/config.guess)</userinput></screen>
    5551
    5652    <para>Compile the package:</para>
     
    5854<screen><userinput remap="make">make</userinput></screen>
    5955
    60     <para>Compilation is now complete. As discussed earlier, running the test
    61     suite is not mandatory for the temporary tools here in this chapter. To run
    62     the Findutils test suite anyway, issue the following command:</para>
    63 
    64 <screen><userinput remap="test">make check</userinput></screen>
    65 
    6656    <para>Install the package:</para>
    6757
    68 <screen><userinput remap="install">make install</userinput></screen>
     58<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
     59
     60    <para>Move the excutable to its final expected location:</para>
     61
     62<screen><userinput remap="install">mv -v $LFS/usr/bin/find $LFS/bin
     63sed -i 's|find:=${BINDIR}|find:=/bin|' $LFS/usr/bin/updatedb</userinput></screen>
    6964
    7065  </sect2>
  • chapter05/flex.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Flex for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr                     \
     49            --host=$LFS_TGT                   \
     50            --build=$(build-aux/config.guess) \
     51            --disable-bootstrap               \
     52            --docdir=/usr/share/doc/flex-&flex-version;</userinput></screen>
     53
     54    <variablelist>
     55      <title>The meaning of the new configure option:</title>
     56
     57      <varlistentry>
     58        <term><parameter>--disable-bootstrap</parameter></term>
     59        <listitem>
     60          <para>Normally, building flex is done in two stages. A first
     61          programs, which is used to generate the source of a second one,
     62          which is then compiled. When using cross-compilation, the first
     63          program is generated on the build systemd. However, due to a bug
     64          in configure, the presence of some funciton is tested only on the
     65          host system. If this function is not found on the build system, the
     66          build fails. This can be prevented by disabling the two stage
     67          build.</para>
     68        </listitem>
     69      </varlistentry>
     70    </variablelist>
    4971
    5072    <para>Compile the package:</para>
     
    5274<screen><userinput remap="make">make</userinput></screen>
    5375
    54     <para>To test the results, issue:</para>
    55 
    56 <screen><userinput remap="test">make check</userinput></screen>
    57 
    5876    <para>Install the package:</para>
    5977
    60 <screen><userinput remap="install">make install</userinput></screen>
     78<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    6179
    6280  </sect2>
  • chapter05/gawk.xml

    r9d719e2 refcb393  
    4444    <title>Installation of Gawk</title>
    4545
     46    <para>First, ensure some unneeded files are not installed:</para>
     47
     48<screen><userinput remap="pre">sed -i 's/extras//' Makefile.in</userinput></screen>
     49
    4650    <para>Prepare Gawk for compilation:</para>
    4751
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     52<screen><userinput remap="configure">./configure --prefix=/usr   \
     53            --host=$LFS_TGT \
     54            --build=$(./config.guess)</userinput></screen>
    4955
    5056    <para>Compile the package:</para>
     
    5258<screen><userinput remap="make">make</userinput></screen>
    5359
    54     <para>Compilation is now complete. As discussed earlier, running the test
    55     suite is not mandatory for the temporary tools here in this chapter. To run
    56     the Gawk test suite anyway, issue the following command:</para>
    57 
    58 <screen><userinput remap="test">make check</userinput></screen>
    59 
    6060    <para>Install the package:</para>
    6161
    62 <screen><userinput remap="install">make install</userinput></screen>
     62<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    6363
    6464  </sect2>
  • chapter05/gcc-pass1.xml

    r9d719e2 refcb393  
    4444    <title>Installation of Cross GCC</title>
    4545
    46     <para>GCC now requires the GMP, MPFR and MPC packages. As these packages may
     46    <para>GCC requires the GMP, MPFR and MPC packages. As these packages may
    4747    not be included in your host distribution, they will be built with
    4848    GCC.  Unpack each package into the GCC source directory and rename the
     
    6363mv -v mpc-&mpc-version; mpc</userinput></screen>
    6464
    65     <para>The following command will change the location of GCC's default
    66     dynamic linker to use the one installed in <filename
    67     class="directory">/tools</filename>. It also removes <filename
    68     class="directory">/usr/include</filename> from GCC's include search path.
    69     Issue:</para>
    70 
    71 <screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h
    72 do
    73   cp -uv $file{,.orig}
    74   sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&amp;@g' \
    75       -e 's@/usr@/tools@g' $file.orig &gt; $file
    76   echo '
    77 #undef STANDARD_STARTFILE_PREFIX_1
    78 #undef STANDARD_STARTFILE_PREFIX_2
    79 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
    80 #define STANDARD_STARTFILE_PREFIX_2 ""' &gt;&gt; $file
    81   touch $file.orig
    82 done</userinput></screen>
    83 
    84     <para>In case the above seems hard to follow, let's break it down a bit.
    85     First we copy the files <filename>gcc/config/linux.h</filename>,
    86     <filename>gcc/config/i386/linux.h</filename>, and
    87     <filename>gcc/config/i386/linux64.h</filename> to a file of
    88     the same name but with an added suffix of <quote>.orig</quote>. Then the
    89     first sed expression prepends <quote>/tools</quote> to every instance of
    90     <quote>/lib/ld</quote>, <quote>/lib64/ld</quote> or
    91     <quote>/lib32/ld</quote>, while the second one replaces hard-coded
    92     instances of <quote>/usr</quote>. Next, we add our define statements which
    93     alter the default startfile prefix to the end of the file. Note that the
    94     trailing <quote>/</quote> in <quote>/tools/lib/</quote> is required.
    95     Finally, we use <command>touch</command> to update the timestamp on the
    96     copied files.  When used in conjunction with <command>cp -u</command>, this
    97     prevents unexpected changes to the original files in case the commands are
    98     inadvertently run twice.</para>
    99 
    100     <para>Finally, on x86_64 hosts, set the default directory name for
     65    <para>On x86_64 hosts, set the default directory name for
    10166    64-bit libraries to <quote>lib</quote>:</para>
    10267
     
    10873esac</userinput></screen>
    10974
    110 <!--
    111     <para>GCC doesn't detect stack protection correctly, which causes problems
    112     for the build of Glibc-&glibc-version;, so fix that by issuing the following
    113     command:</para>
    114 
    115 <screen><userinput remap="pre">sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure</userinput></screen>
    116 -->
    117 
    118 <!--
    119     <para>Also fix a problem identified upstream:</para>
    120 
    121 <screen><userinput remap="pre">sed -i 's/if \((code.*))\)/if (\1 \&amp;\&amp; \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen>
    122 -->
    12375    <para>The GCC documentation recommends building GCC
    12476    in a dedicated build directory:</para>
     
    13183<screen><userinput remap="configure">../configure                                       \
    13284    --target=$LFS_TGT                              \
    133     --prefix=/tools                                \
     85    --prefix=$LFS/tools                            \
    13486    --with-glibc-version=2.11                      \
    13587    --with-sysroot=$LFS                            \
    13688    --with-newlib                                  \
    13789    --without-headers                              \
    138     --with-local-prefix=/tools                     \
    139     --with-native-system-header-dir=/tools/include \
     90    --enable-initfini-array                        \
    14091    --disable-nls                                  \
    14192    --disable-shared                               \
     
    182133
    183134      <varlistentry>
    184         <term><parameter>--with-local-prefix=/tools</parameter></term>
    185         <listitem>
    186           <para>The local prefix is the location in the system that GCC will search
    187           for locally installed include files. The default is <filename>/usr/local</filename>.
    188           Setting this to <filename>/tools</filename> helps keep the host location of
    189           <filename>/usr/local</filename> out of this GCC's search path.</para>
    190         </listitem>
    191       </varlistentry>
    192 
    193       <varlistentry>
    194         <term><parameter>--with-native-system-header-dir=/tools/include</parameter></term>
    195         <listitem>
    196           <para>By default, GCC searches <filename>/usr/include</filename> for
    197           system headers. In conjunction with the sysroot switch, this would
    198           normally translate to <filename>$LFS/usr/include</filename>. However
    199           the headers that will be installed in the next two sections will go
    200           to <filename>$LFS/tools/include</filename>. This switch ensures that
    201           gcc will find them correctly. In the second pass of GCC, this same
    202           switch will ensure that no headers from the host system are
    203           found.</para>
    204         </listitem>
    205       </varlistentry>
    206 
    207       <varlistentry>
    208135        <term><parameter>--disable-shared</parameter></term>
    209136        <listitem>
    210137          <para>This switch forces GCC to link its internal libraries
    211           statically. We do this to avoid possible issues with the host
    212           system.</para>
     138          statically. We need this because the shared libraries require glibc,
     139          which is not yet installed on the target system.</para>
    213140        </listitem>
    214141      </varlistentry>
     
    250177<screen><userinput remap="make">make</userinput></screen>
    251178
    252     <para>Compilation is now complete. At this point, the test suite would
    253     normally be run, but, as mentioned before, the test suite framework is
    254     not in place yet. The benefits of running the tests at this point
    255     are minimal since the programs from this first pass will soon be
    256     replaced.</para>
    257 
    258179    <para>Install the package:</para>
    259180
    260 <screen><userinput remap="install">make install</userinput></screen>
    261 <!--
    262     <para>Using <parameter>- -disable-shared</parameter> means that the
    263     <filename>libgcc_eh.a</filename> file isn't created and installed. The
    264     Glibc package depends on this library as it uses
    265     <parameter>-lgcc_eh</parameter> within its build system. This dependency
    266     can be satisfied by creating a symlink to <filename>libgcc.a</filename>,
    267     since that file will end up containing the objects normally contained in
    268     <filename>libgcc_eh.a</filename>:</para>
    269 
    270 <screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&amp;_eh/'`</userinput></screen>
    271 -->
     181    <screen><userinput remap="install">make install</userinput></screen>
     182
     183    <para>This build of GCC has installed a couple of internal system
     184    headers.  Normally one of them, <filename>limits.h</filename>, would in turn
     185    include the corresponding system <filename>limits.h</filename> header, in
     186    this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
     187    time of this build of gcc <filename>$LFS/usr/include/limits.h</filename>
     188    does not exist, so the internal header that has just been installed is a
     189    partial, self-contained file and does not include the extended features of
     190    the system header. This is adequate for building glibc, but the full
     191    internal header will be needed later.  Create a full version of the internal
     192    header using a command that is identical to what the GCC build system does
     193    in normal circumstances:</para>
     194
     195<screen><userinput remap="install">cd ..
     196cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
     197  `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen>
    272198  </sect2>
    273199
  • chapter05/gcc-pass2.xml

    r9d719e2 refcb393  
    5555mv -v mpc-&mpc-version; mpc</userinput></screen>
    5656
    57     <para>Once again, change the location of GCC's default dynamic linker to
    58     use the one installed in <filename
    59     class="directory">/tools</filename>.</para>
    60 
    61 <screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h
    62 do
    63   cp -uv $file{,.orig}
    64   sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&amp;@g' \
    65       -e 's@/usr@/tools@g' $file.orig &gt; $file
    66   echo '
    67 #undef STANDARD_STARTFILE_PREFIX_1
    68 #undef STANDARD_STARTFILE_PREFIX_2
    69 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
    70 #define STANDARD_STARTFILE_PREFIX_2 ""' &gt;&gt; $file
    71   touch $file.orig
    72 done</userinput></screen>
    73 
    7457    <para>If building on x86_64, change the default directory name for 64-bit
    7558    libraries to <quote>lib</quote>:</para>
     
    8265esac</userinput></screen>
    8366
    84     <para>Our first build of GCC has installed a couple of internal system
    85     headers.  Normally one of them, <filename>limits.h</filename>, will in turn
    86     include the corresponding system <filename>limits.h</filename> header, in
    87     this case, <filename>/tools/include/limits.h</filename>. However, at the
    88     time of the first build of gcc <filename>/tools/include/limits.h</filename>
    89     did not exist, so the internal header that GCC installed is a partial,
    90     self-contained file and does not include the extended features of the
    91     system header. This was adequate for building the temporary libc, but this
    92     build of GCC now requires the full internal header.  Create a full version
    93     of the internal header using a command that is identical to what the GCC
    94     build system does in normal circumstances:</para>
    95 
    96 <screen><userinput remap="pre">cat gcc/limitx.h gcc/glimits.h gcc/limity.h &gt; \
    97   `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h</userinput></screen>
    98 <!--
    99     <para>For x86 machines, the limited number of registers is a bottleneck
    100     for the system.  Free one up by not using a frame pointer that is not
    101     needed:</para>
    102 
    103 <screen><userinput remap="pre">case `uname -m` in
    104   i?86) sed -i 's/^T_CFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in ;;
    105 esac</userinput></screen>
    106 -->
    10767    <para>Create a separate build directory again:</para>
    10868
    10969<screen><userinput remap="pre">mkdir -v build
    11070cd       build</userinput></screen>
     71
     72    <para>Create a symlink that allos libgcc to be built with posix threads
     73    support:</para>
     74
     75<screen><userinput remap="pre">mkdir -pv $LFS_TGT/libgcc
     76ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h</userinput></screen>
    11177
    11278    <para>Before starting to build GCC, remember to unset any environment
     
    11581    <para>Now prepare GCC for compilation:</para>
    11682
    117 <screen><userinput remap="configure">CC=$LFS_TGT-gcc                                    \
    118 CXX=$LFS_TGT-g++                                   \
    119 AR=$LFS_TGT-ar                                     \
    120 RANLIB=$LFS_TGT-ranlib                             \
    121 ../configure                                       \
    122     --prefix=/tools                                \
    123     --with-local-prefix=/tools                     \
    124     --with-native-system-header-dir=/tools/include \
    125     --enable-languages=c,c++                       \
    126     --disable-libstdcxx-pch                        \
     83<screen><userinput remap="configure">../configure                                       \
     84    --build=$(../config.guess)                     \
     85    --host=$LFS_TGT                                \
     86    --prefix=/usr                                  \
     87    CC_FOR_TARGET=$LFS_TGT-gcc                     \
     88    --with-build-sysroot=$LFS                      \
     89    --enable-initfini-array                        \
     90    --disable-nls                                  \
    12791    --disable-multilib                             \
    128     --disable-bootstrap                            \
    129     --disable-libgomp</userinput></screen>
     92    --disable-decimal-float                        \
     93    --disable-libatomic                            \
     94    --disable-libgomp                              \
     95    --disable-libquadmath                          \
     96    --disable-libssp                               \
     97    --disable-libvtv                               \
     98    --disable-libstdcxx                            \
     99    --enable-languages=c,c++</userinput></screen>
    130100
    131101    <variablelist>
    132       <title>The meaning of the new configure options:</title>
     102      <title>The meaning of the new configure options:</title><!-- WIP -->
    133103
    134104      <varlistentry>
    135         <term><parameter>--enable-languages=c,c++</parameter></term>
     105        <term><parameter>-with-build-sysroot=$LFS</parameter></term>
    136106        <listitem>
    137           <para>This option ensures that both the C and C++ compilers are
    138           built.</para>
     107          <para>Normally, using <parameter>--host=</parameter> ensures that
     108          a cross-compiler is used for building gcc, and that compiler knows
     109          that it has to look for headers and libraries in <filename
     110          class="directory">$LFS</filename>. But the build system of GCC uses
     111          other tools, which are not aware of this location. This switch is
     112          needed to have them find the needed files in <filename
     113          class="directory">$LFS</filename>, and not on the host.</para>
    139114        </listitem>
    140115      </varlistentry>
    141116
    142117      <varlistentry>
    143         <term><parameter>--disable-libstdcxx-pch</parameter></term>
     118        <term><parameter>--enable-initfini-array</parameter></term>
    144119        <listitem>
    145           <para>Do not build the pre-compiled header (PCH) for
    146           <filename class="libraryfile">libstdc++</filename>. It takes up a
    147           lot of space, and we have no use for it.</para>
    148         </listitem>
    149       </varlistentry>
    150 
    151       <varlistentry>
    152         <term><parameter>--disable-bootstrap</parameter></term>
    153         <listitem>
    154           <para>For native builds of GCC, the default is to do a "bootstrap"
    155           build. This does not just compile GCC, but compiles it several times.
    156           It uses the programs compiled in a first round to compile itself a
    157           second time, and then again a third time.  The second and third
    158           iterations are compared to make sure it can reproduce itself
    159           flawlessly. This also implies that it was compiled correctly.
    160           However, the LFS build method should provide a solid compiler
    161           without the need to bootstrap each time.</para>
     120          <para>This option is automatically enabled when building a native
     121          compiler with a native compiler on x86. But here, we build with
     122          a cross compiler, so we need to explicitely set this option.</para>
    162123        </listitem>
    163124      </varlistentry>
     
    171132    <para>Install the package:</para>
    172133
    173 <screen><userinput remap="install">make install</userinput></screen>
     134<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    174135
    175136    <para>As a finishing touch, create a symlink. Many programs and scripts
     
    180141    which C compiler to install:</para>
    181142
    182 <screen><userinput remap="install">ln -sv gcc /tools/bin/cc</userinput></screen>
    183 
    184   <caution>
    185     <para>At this point, it is imperative to stop and ensure that the basic
    186     functions (compiling and linking) of the new toolchain are working as
    187     expected. To perform a sanity check, run the following commands:</para>
    188 
    189 <screen><userinput>echo 'int main(){}' &gt; dummy.c
    190 cc dummy.c
    191 readelf -l a.out | grep ': /tools'</userinput></screen>
    192 
    193     <para>If everything is working correctly, there should be no errors,
    194     and the output of the last command will be of the form:</para>
    195 
    196 <screen><computeroutput>[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
    197 
    198     <para>Note that the dynamic linker will be /tools/lib/ld-linux.so.2
    199     for 32-bit machines.</para>
    200 
    201     <para>If the output is not shown as above or there was no output at all,
    202     then something is wrong. Investigate and retrace the steps to find out
    203     where the problem is and correct it. This issue must be resolved before
    204     continuing on. First, perform the sanity check again, using
    205     <command>gcc</command> instead of <command>cc</command>. If this works,
    206     then the <filename class="symlink">/tools/bin/cc</filename> symlink is
    207     missing. Install the symlink as per above.
    208     Next, ensure that the <envar>PATH</envar> is correct. This
    209     can be checked by running <command>echo $PATH</command> and verifying that
    210     <filename class="directory">/tools/bin</filename> is at the head of the
    211     list. If the <envar>PATH</envar> is wrong it could mean that you are not
    212     logged in as user <systemitem class="username">lfs</systemitem> or that
    213     something went wrong back in <xref linkend="ch-preps-settingenviron"
    214     role="."/></para>
    215 
    216     <para>Once all is well, clean up the test files:</para>
    217 
    218 <screen><userinput>rm -v dummy.c a.out</userinput></screen>
    219 
    220   </caution>
     143<screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen>
    221144
    222145  </sect2>
  • chapter05/generalinstructions.xml

    r9d719e2 refcb393  
    8282          <para>Place all the sources and patches in a directory that will be
    8383          accessible from the chroot environment such as
    84           <filename class="directory">/mnt/lfs/sources/</filename>. Do
     84          <filename class="directory">/mnt/lfs/sources/</filename>.<!-- Do
    8585          <emphasis>not</emphasis> put sources in
    86           <filename class="directory">/mnt/lfs/tools/</filename>.</para>
     86          <filename class="directory">/mnt/lfs/tools/</filename>. --></para>
    8787        </listitem>
    8888        <listitem>
  • chapter05/gettext.xml

    r9d719e2 refcb393  
    5353    <variablelist>
    5454      <title>The meaning of the configure option:</title>
    55 <!--
    56       <varlistentry>
    57         <term><parameter>EMACS="no"</parameter></term>
    58         <listitem>
    59           <para>This prevents the configure script from determining where to
    60           install Emacs Lisp files as the test is known to hang on some hosts.
    61           </para>
    62         </listitem>
    63       </varlistentry>
    64 -->
     55
    6556      <varlistentry>
    6657        <term><parameter>--disable-shared</parameter></term>
     
    7768<screen><userinput remap="make">make</userinput></screen>
    7869
    79     <para>
    80     Due to the limited environment, running the test suite at this stage
    81     is not recommended.</para>
    82 
    8370    <para>Install the <command>msgfmt</command>, <command>msgmerge</command> and
    8471    <command>xgettext</command> programs:</para>
    8572
    86 <screen><userinput remap="install">cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /tools/bin</userinput></screen>
     73<screen><userinput remap="install">cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin</userinput></screen>
    8774
    8875  </sect2>
  • chapter05/glibc.xml

    r9d719e2 refcb393  
    4444    <title>Installation of Glibc</title>
    4545
     46    <para>First, create two symbolic links, which are needed for proper
     47    operation of the dynamic library loader:</para>
     48
     49<screen><userinput remap="pre">ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
     50ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3</userinput></screen>
     51
     52    <para>Some of the Glibc programs use the non-FHS compliant
     53    <filename class="directory">/var/db</filename> directory to store their
     54    runtime data. Apply the following patch to make such programs store their
     55    runtime data in the FHS-compliant locations:</para>
     56
     57<screen><userinput remap="pre">patch -Np1 -i ../glibc-&glibc-version;-fhs-1.patch</userinput></screen>
     58
    4659    <para>The Glibc documentation recommends building Glibc
    4760    in a dedicated build directory:</para>
     
    5366
    5467<screen><userinput remap="configure">../configure                             \
    55       --prefix=/tools                    \
     68      --prefix=/usr                      \
    5669      --host=$LFS_TGT                    \
    5770      --build=$(../scripts/config.guess) \
    5871      --enable-kernel=&min-kernel;                \
    59       --with-headers=/tools/include</userinput></screen>
     72      --with-headers=$LFS/usr/include    \
     73      libc_cv_slibdir=/lib</userinput></screen>
    6074<!--
    6175      libc_cv_forced_unwind=yes          \
     
    6983        <listitem>
    7084          <para>The combined effect of these switches is that Glibc's build system
    71           configures itself to cross-compile, using the cross-linker and
     85          configures itself to be cross-compiled, using the cross-linker and
    7286          cross-compiler in <filename class="directory">/tools</filename>.</para>
    7387        </listitem>
     
    8498
    8599      <varlistentry>
    86         <term><parameter>--with-headers=/tools/include</parameter></term>
     100        <term><parameter>--with-headers=$LFS/usr/include</parameter></term>
    87101        <listitem>
    88102          <para>This tells Glibc to compile itself against the headers recently
    89           installed to the tools directory, so that it knows exactly what
     103          installed to the usr/include directory, so that it knows exactly what
    90104          features the kernel has and can optimize itself accordingly.</para>
    91105        </listitem>
    92106      </varlistentry>
     107
     108      <varlistentry>
     109        <term><parameter>libc_cv_slibdir=/lib</parameter></term>
     110        <listitem>
     111          <para>This ensures that the library is installed in /lib instead
     112          of the default /lib64 on 64 bit machines.</para>
     113        </listitem>
     114      </varlistentry>
    93115<!--
    94       <varlistentry>
    95         <term><parameter>libc_cv_forced_unwind=yes</parameter></term>
    96         <listitem>
    97           <para>The linker installed during
    98           <xref linkend="ch-tools-binutils-pass1"/> was cross-compiled and as
    99           such cannot be used until Glibc has been installed.  This means that
    100           the configure test for force-unwind support will fail, as it relies on
    101           a working linker.  The libc_cv_forced_unwind=yes variable is passed in
    102           order to inform <command>configure</command> that force-unwind
    103           support is available without it having to run the test.</para>
    104         </listitem>
    105       </varlistentry>
    106116      <varlistentry>
    107117        <term><parameter>libc_cv_c_cleanup=yes</parameter></term>
     
    112122        </listitem>
    113123      </varlistentry>
    114 -->
    115 <!--  <varlistentry>
     124
     125      <varlistentry>
    116126        <term><parameter>libc_cv_ctors_header=yes</parameter></term>
    117127        <listitem>
     
    148158    <para>Install the package:</para>
    149159
    150 <screen><userinput remap="install">make install</userinput></screen>
    151 
    152   <caution>
    153     <para>At this point, it is imperative to stop and ensure that the basic
    154     functions (compiling and linking) of the new toolchain are working as
    155     expected. To perform a sanity check, run the following commands:</para>
     160<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
     161
     162    <variablelist>
     163      <title>The meaning of the <command>make install</command> option:</title>
     164
     165      <varlistentry>
     166        <term><parameter>DESTDIR=$LFS</parameter></term>
     167        <listitem>
     168          <para>The <envar>DESTDIR</envar> make variable is used by almost all
     169          packages to define the location where the package should be
     170          installed. If it is not set, it defaults to the root (<filename
     171          class="directory">/</filename>) directory. Here we specify that
     172          the package be installed in <filename class="directory">$LFS
     173          </filename>, which will become the root after <xref linkend=
     174          "ch-tools-chroot"/>.</para>
     175        </listitem>
     176      </varlistentry>
     177
     178    </variablelist>
     179
     180    <caution>
     181      <para>At this point, it is imperative to stop and ensure that the basic
     182      functions (compiling and linking) of the new toolchain are working as
     183      expected. To perform a sanity check, run the following commands:</para>
    156184
    157185<screen><userinput>echo 'int main(){}' &gt; dummy.c
    158186$LFS_TGT-gcc dummy.c
    159 readelf -l a.out | grep ': /tools'</userinput></screen>
    160 
    161     <para>If everything is working correctly, there should be no errors,
    162     and the output of the last command will be of the form:</para>
    163 
    164 <screen><computeroutput>[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
    165 
    166     <para>Note that for 32-bit machines, the interpreter name will be
    167     <filename>/tools/lib/ld-linux.so.2</filename>.</para>
    168 
    169     <para>If the output is not shown as above or there was no output at all,
    170     then something is wrong. Investigate and retrace the steps to find out
    171     where the problem is and correct it. This issue must be resolved before
    172     continuing on.</para>
    173 
    174     <para>Once all is well, clean up the test files:</para>
     187readelf -l a.out | grep '/ld-linux'</userinput></screen>
     188
     189      <para>If everything is working correctly, there should be no errors,
     190      and the output of the last command will be of the form:</para>
     191
     192<screen><computeroutput>[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
     193
     194      <para>Note that for 32-bit machines, the interpreter name will be
     195      <filename>/lib/ld-linux.so.2</filename>.</para>
     196
     197      <para>If the output is not shown as above or there was no output at all,
     198      then something is wrong. Investigate and retrace the steps to find out
     199      where the problem is and correct it. This issue must be resolved before
     200      continuing on.</para>
     201
     202      <para>Once all is well, clean up the test files:</para>
    175203
    176204<screen><userinput>rm -v dummy.c a.out</userinput></screen>
    177205
    178   </caution>
    179 
    180   <note><para>Building Binutils in the section after next will serve as an
    181   additional check that the toolchain has been built properly. If Binutils
    182   fails to build, it is an indication that something has gone wrong with the
    183   previous Binutils, GCC, or Glibc installations.</para></note>
     206    </caution>
     207
     208    <note><para>Building packages in the next sections will serve as an
     209    additional check that the toolchain has been built properly. If some
     210    package, especially binutils-pass2 or gcc-pass2, fails to build, it is
     211    an indication that something has gone wrong with the
     212    previous Binutils, GCC, or Glibc installations.</para></note>
     213
     214    <para>Now that our cross-toolchain is complete, finalize the installation
     215    of the limits.h header. For doing so, run an utility provided by the GCC
     216    developers:</para>
     217
     218<screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen>
    184219
    185220  </sect2>
  • chapter05/grep.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Grep for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr   \
     49            --host=$LFS_TGT \
     50            --bindir=/bin</userinput></screen>
    4951
    5052    <para>Compile the package:</para>
     
    5254<screen><userinput remap="make">make</userinput></screen>
    5355
    54     <para>Compilation is now complete. As discussed earlier, running the test
    55     suite is not mandatory for the temporary tools here in this chapter. To run
    56     the Grep test suite anyway, issue the following command:</para>
    57 
    58 <screen><userinput remap="test">make check</userinput></screen>
    59 
    6056    <para>Install the package:</para>
    6157
    62 <screen><userinput remap="install">make install</userinput></screen>
     58<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    6359
    6460  </sect2>
  • chapter05/gzip.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Gzip for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr --host=$LFS_TGT</userinput></screen>
    4949
    5050    <para>Compile the package:</para>
     
    5252<screen><userinput remap="make">make</userinput></screen>
    5353
    54     <para>Compilation is now complete. As discussed earlier, running the test
    55     suite is not mandatory for the temporary tools here in this chapter. To run
    56     the Gzip test suite anyway, issue the following command:</para>
    57 
    58 <screen><userinput remap="test">make check</userinput></screen>
    59 
    6054    <para>Install the package:</para>
    6155
    62 <screen><userinput remap="install">make install</userinput></screen>
     56<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
     57
     58    <para>Move the excutable to its final expected location:</para>
     59
     60<screen><userinput remap="install">mv -v $LFS/usr/bin/gzip $LFS/bin</userinput></screen>
    6361
    6462  </sect2>
  • chapter05/introduction.xml

    r9d719e2 refcb393  
    2020  linker, libraries, and a few useful utilities).  The second step uses this
    2121  toolchain to build the other essential tools.</para>
    22 
     22<!--
    2323  <para>The files compiled in this chapter will be installed under the
    24   <filename class="directory">$LFS/tools</filename> directory to keep them
     24  <filename class="directory">$LFS</filename> directory to keep them
    2525  separate from the files installed in the next chapter and the host
    2626  production directories. Since the packages compiled here are temporary,
    2727  we do not want them to pollute the soon-to-be LFS system.</para>
    28 
     28-->
    2929</sect1>
  • chapter05/kernfs.xml

    r9d719e2 refcb393  
    66]>
    77
    8 <sect1 id="ch-system-kernfs">
     8<sect1 id="ch-tools-kernfs">
    99  <?dbhtml filename="kernfs.html"?>
    1010
    1111  <title>Preparing Virtual Kernel File Systems</title>
    1212
    13   <indexterm zone="ch-system-kernfs">
     13  <indexterm zone="ch-tools-kernfs">
    1414    <primary sortas="e-/dev/">/dev/*</primary>
    1515  </indexterm>
  • chapter05/libstdc++.xml

    r9d719e2 refcb393  
    66]>
    77
    8 <sect1 id="ch-tools-libstdcpp" role="wrap">
    9   <?dbhtml filename="gcc-libstdc++.html"?>
     8<sect1 id="ch-tools-libstdcpp-pass1" role="wrap">
     9  <?dbhtml filename="gcc-libstdc++-pass1.html"?>
    1010
    1111  <sect1info condition="script">
     
    1515  </sect1info>
    1616
    17   <title>Libstdc++ from GCC-&gcc-version;</title>
     17  <title>Libstdc++ from GCC-&gcc-version;, Pass 1</title>
    1818
    19   <indexterm zone="ch-tools-libstdcpp">
     19  <indexterm zone="ch-tools-libstdcpp-pass1">
    2020    <primary sortas="a-GCC">GCC</primary>
    21     <secondary>tools, libstdc++</secondary>
     21    <secondary>tools, libstdc++ pass 1</secondary>
    2222  </indexterm>
    2323
     
    2929    (part of GCC is written in C++), but we had to defer its installation
    3030    when we built <xref linkend="ch-tools-gcc-pass1"/>
    31     because it depends on glibc, which was not yet available in /tools.
     31    because it depends on glibc, which was not yet available in the target
     32    directory.
    3233    </para>
    3334
     
    6263<screen><userinput remap="configure">../libstdc++-v3/configure           \
    6364    --host=$LFS_TGT                 \
    64     --prefix=/tools                 \
     65    --build=$(../config.guess)      \
     66    --prefix=/usr                   \
    6567    --disable-multilib              \
    66     --disable-nls                   \<!--
    67     - -disable-libstdcxx-threads     \-->
     68    --disable-nls                   \
    6869    --disable-libstdcxx-pch         \
    6970    --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/&gcc-version;</userinput></screen>
     
    7980        </listitem>
    8081      </varlistentry>
    81         <!--
    82       <varlistentry>
    83         <term><parameter>- -disable-libstdcxx-threads</parameter></term>
    84         <listitem>
    85           <para>Since gcc-pass1 is built without thread support, the C++
    86           thread library cannot be built either.</para>
    87         </listitem>
    88       </varlistentry>
    89         -->
     82
    9083      <varlistentry>
    9184        <term><parameter>--disable-libstdcxx-pch</parameter></term>
     
    115108    <para>Install the library:</para>
    116109
    117 <screen><userinput remap="install">make install</userinput></screen>
     110<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    118111
    119112  </sect2>
  • chapter05/linux-headers.xml

    r9d719e2 refcb393  
    2525    <title/>
    2626
    27     <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
    28     href="../chapter06/linux-headers.xml"
    29     xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
     27    <para>The Linux API Headers (in linux-&linux-version;.tar.xz) expose the
     28    kernel's API for use by Glibc.</para>
    3029
    3130    <segmentedlist>
     
    6160
    6261<screen><userinput remap="make">make headers
    63 </userinput><userinput remap="install">cp -rv usr/include/* /tools/include</userinput></screen>
     62find usr/include -name '.*' -delete
     63rm usr/include/Makefile
     64</userinput><userinput remap="install">cp -rv usr/include $LFS/usr</userinput></screen>
    6465
    6566  </sect2>
    6667
    67   <sect2 role="content">
    68     <title/>
    69 
    70     <para>Details on this package are located in
    71     <xref linkend="contents-linux-headers" role="."/></para>
     68  <sect2 id="contents-linux-headers" role="content">
     69    <title>Contents of Linux API Headers</title>
     70
     71    <segmentedlist>
     72      <segtitle>Installed headers</segtitle>
     73      <segtitle>Installed directories</segtitle>
     74
     75      <seglistitem>
     76        <seg>/usr/include/asm/*.h, /usr/include/asm-generic/*.h,
     77        /usr/include/drm/*.h, /usr/include/linux/*.h, /usr/include/misc/*.h,
     78        /usr/include/mtd/*.h, /usr/include/rdma/*.h, /usr/include/scsi/*.h,
     79        /usr/include/sound/*.h, /usr/include/video/*.h,
     80        and /usr/include/xen/*.h</seg>
     81        <seg>/usr/include/asm, /usr/include/asm-generic, /usr/include/drm,
     82        /usr/include/linux, /usr/include/misc, /usr/include/mtd,
     83        /usr/include/rdma, /usr/include/scsi, /usr/include/sound,
     84        /usr/include/video, and /usr/include/xen</seg>
     85      </seglistitem>
     86    </segmentedlist>
     87
     88    <variablelist>
     89      <bridgehead renderas="sect3">Short Descriptions</bridgehead>
     90      <?dbfo list-presentation="list"?>
     91      <?dbhtml list-presentation="table"?>
     92
     93      <varlistentry id="asm">
     94        <term><filename class="headerfile">/usr/include/asm/*.h</filename></term>
     95        <listitem>
     96          <para>The Linux API ASM Headers</para>
     97          <indexterm zone="ch-tools-linux-headers asm">
     98            <primary sortas="e-/usr/include/asm/*.h">/usr/include/asm/*.h</primary>
     99          </indexterm>
     100        </listitem>
     101      </varlistentry>
     102
     103     <varlistentry id="asm-generic">
     104        <term><filename class="headerfile">/usr/include/asm-generic/*.h</filename></term>
     105        <listitem>
     106          <para>The Linux API ASM Generic Headers</para>
     107          <indexterm zone="ch-tools-linux-headers asm-generic">
     108            <primary sortas="e-/usr/include/asm-generic/*.h">/usr/include/asm-generic/*.h</primary>
     109          </indexterm>
     110        </listitem>
     111      </varlistentry>
     112
     113      <varlistentry id="drm">
     114        <term><filename class="headerfile">/usr/include/drm/*.h</filename></term>
     115        <listitem>
     116          <para>The Linux API DRM Headers</para>
     117          <indexterm zone="ch-tools-linux-headers drm">
     118            <primary sortas="e-/usr/include/drm/*.h">/usr/include/drm/*.h</primary>
     119          </indexterm>
     120        </listitem>
     121      </varlistentry>
     122
     123      <varlistentry id="linux">
     124        <term><filename class="headerfile">/usr/include/linux/*.h</filename></term>
     125        <listitem>
     126          <para>The Linux API Linux Headers</para>
     127          <indexterm zone="ch-tools-linux-headers linux">
     128            <primary sortas="e-/usr/include/linux/*.h">/usr/include/linux/*.h</primary>
     129          </indexterm>
     130        </listitem>
     131      </varlistentry>
     132
     133      <varlistentry id="misc">
     134        <term><filename class="headerfile">/usr/include/misc/*.h</filename></term>
     135        <listitem>
     136          <para>The Linux API Miscellaneous Headers</para>
     137          <indexterm zone="ch-tools-linux-headers misc">
     138            <primary sortas="e-/usr/include/misc/*.h">/usr/include/misc/*.h</primary>
     139          </indexterm>
     140        </listitem>
     141      </varlistentry>
     142
     143      <varlistentry id="mtd">
     144        <term><filename class="headerfile">/usr/include/mtd/*.h</filename></term>
     145        <listitem>
     146          <para>The Linux API MTD Headers</para>
     147          <indexterm zone="ch-tools-linux-headers mtd">
     148            <primary sortas="e-/usr/include/mtd/*.h">/usr/include/mtd/*.h</primary>
     149          </indexterm>
     150        </listitem>
     151      </varlistentry>
     152
     153      <varlistentry id="rdma">
     154        <term><filename class="headerfile">/usr/include/rdma/*.h</filename></term>
     155        <listitem>
     156          <para>The Linux API RDMA Headers</para>
     157          <indexterm zone="ch-tools-linux-headers rdma">
     158            <primary sortas="e-/usr/include/rdma/*.h">/usr/include/rdma/*.h</primary>
     159         </indexterm>
     160        </listitem>
     161      </varlistentry>
     162
     163      <varlistentry id="scsi">
     164        <term><filename class="headerfile">/usr/include/scsi/*.h</filename></term>
     165        <listitem>
     166          <para>The Linux API SCSI Headers</para>
     167          <indexterm zone="ch-tools-linux-headers scsi">
     168            <primary sortas="e-/usr/include/scsi/*.h">/usr/include/scsi/*.h</primary>
     169          </indexterm>
     170        </listitem>
     171      </varlistentry>
     172
     173      <varlistentry id="sound">
     174        <term><filename class="headerfile">/usr/include/sound/*.h</filename></term>
     175        <listitem>
     176          <para>The Linux API Sound Headers</para>
     177          <indexterm zone="ch-tools-linux-headers sound">
     178           <primary sortas="e-/usr/include/sound/*.h">/usr/include/sound/*.h</primary>
     179          </indexterm>
     180        </listitem>
     181      </varlistentry>
     182
     183      <varlistentry id="video">
     184        <term><filename class="headerfile">/usr/include/video/*.h</filename></term>
     185        <listitem>
     186          <para>The Linux API Video Headers</para>
     187          <indexterm zone="ch-tools-linux-headers video">
     188            <primary sortas="e-/usr/include/video/*.h">/usr/include/video/*.h</primary>
     189          </indexterm>
     190        </listitem>
     191      </varlistentry>
     192
     193      <varlistentry id="xen">
     194        <term><filename class="headerfile">/usr/include/xen/*.h</filename></term>
     195        <listitem>
     196          <para>The Linux API Xen Headers</para>
     197          <indexterm zone="ch-tools-linux-headers xen">
     198            <primary sortas="e-/usr/include/xen/*.h">/usr/include/xen/*.h</primary>
     199          </indexterm>
     200        </listitem>
     201      </varlistentry>
     202
     203    </variablelist>
    72204
    73205  </sect2>
  • chapter05/m4.xml

    r9d719e2 refcb393  
    5151    <para>Prepare M4 for compilation:</para>
    5252
    53 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     53<screen><userinput remap="configure">./configure --prefix=/usr   \
     54            --host=$LFS_TGT \
     55            --build=$(build-aux/config.guess)</userinput></screen>
    5456
    5557    <para>Compile the package:</para>
     
    5759<screen><userinput remap="make">make</userinput></screen>
    5860
    59     <para>Compilation is now complete. As discussed earlier, running the test
    60     suite is not mandatory for the temporary tools here in this chapter. To run
    61     the M4 test suite anyway, issue the following command:</para>
    62 
    63 <screen><userinput remap="test">make check</userinput></screen>
    64 
    6561    <para>Install the package:</para>
    6662
    67 <screen><userinput remap="install">make install</userinput></screen>
     63<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    6864
    6965  </sect2>
     
    7167  <sect2 role="content">
    7268    <title/>
    73 
    7469    <para>Details on this package are located in
    7570    <xref linkend="contents-m4" role="."/></para>
  • chapter05/make.xml

    r9d719e2 refcb393  
    4242  <sect2 role="installation">
    4343    <title>Installation of Make</title>
    44 <!--
    45     <para>First, work around an error caused by glibc-2.27 and later:</para>
    4644
    47 <screen><userinput remap="pre">sed -i '211,217 d; 219,229 d; 232 d' glob/glob.c</userinput></screen>
    48 -->
    4945    <para>Prepare Make for compilation:</para>
    5046
    51 <screen><userinput remap="configure">./configure --prefix=/tools --without-guile</userinput></screen>
    52 
    53     <variablelist>
    54       <title>The meaning of the configure option:</title>
    55 
    56       <varlistentry>
    57         <term><parameter>--without-guile</parameter></term>
    58         <listitem>
    59           <para>This ensures that Make-&make-version; won't link against Guile libraries, which
    60           may be present on the host system, but won't be available within the
    61           <command>chroot</command> environment in the next chapter.</para>
    62         </listitem>
    63       </varlistentry>
    64     </variablelist>
     47<screen><userinput remap="configure">./configure --prefix=/usr   \
     48            --host=$LFS_TGT \
     49            --build=$(build-aux/config.guess)</userinput></screen>
    6550
    6651    <para>Compile the package:</para>
     
    6853<screen><userinput remap="make">make</userinput></screen>
    6954
    70     <para>Compilation is now complete. As discussed earlier, running the test
    71     suite is not mandatory for the temporary tools here in this chapter. To run
    72     the Make test suite anyway, issue the following command:</para>
    73 
    74 <screen><userinput remap="test">make check</userinput></screen>
    75 
    7655    <para>Install the package:</para>
    7756
    78 <screen><userinput remap="install">make install</userinput></screen>
     57<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    7958
    8059  </sect2>
  • chapter05/ncurses.xml

    r9d719e2 refcb393  
    5050    <para>Prepare Ncurses for compilation:</para>
    5151
    52 <screen><userinput remap="configure">./configure --prefix=/tools \
    53             --with-shared   \
    54             --without-debug \
    55             --without-ada   \
    56             --enable-widec  \
    57             --enable-overwrite</userinput></screen>
     52<screen><userinput remap="configure">./configure --prefix=/usr             \
     53            --host=$LFS_TGT           \
     54            --build=$(./config.guess) \
     55            --mandir=/usr/share/man   \
     56            --with-shared             \
     57            --without-debug           \
     58            --without-ada             \
     59            --without-normal          \
     60            --disable-db-install      \
     61            --enable-widec            \
     62            --enable-pc-files</userinput></screen>
    5863
    5964    <variablelist>
    60       <title>The meaning of the configure options:</title>
     65      <title>The meaning of the new configure options:</title>
    6166
    6267      <varlistentry>
     
    6671          compiler which may be present on the host but will not be available
    6772          once we enter the <command>chroot</command> environment.</para>
    68         </listitem>
    69       </varlistentry>
    70 
    71       <varlistentry>
    72         <term><parameter>--enable-overwrite</parameter></term>
    73         <listitem>
    74           <para>This tells Ncurses to install its header files into
    75           <filename class="directory">/tools/include</filename>, instead of
    76           <filename class="directory">/tools/include/ncurses</filename>, to
    77           ensure that other packages can find the Ncurses headers
    78           successfully.</para>
    7973        </listitem>
    8074      </varlistentry>
     
    9488      </varlistentry>
    9589
     90      <varlistentry>
     91        <term><parameter>--enable-pc-files</parameter></term>
     92        <listitem>
     93          <para>This switch generates and installs .pc files for pkg-config.
     94          </para>
     95        </listitem>
     96      </varlistentry>
     97
     98      <varlistentry>
     99        <term><parameter>--without-normal</parameter></term>
     100        <listitem>
     101          <para>This switch disables building and installing most static libraries.
     102          </para>
     103        </listitem>
     104      </varlistentry>
     105
     106      <varlistentry>
     107        <term><parameter>--disable-db-install</parameter></term>
     108        <listitem>
     109          <para>This switch disables building the terminfo database: it is not
     110          needed at this stage, and if <command>tic</command> is too old,
     111          it cannot compile recent databases.</para>
     112        </listitem>
     113      </varlistentry>
     114
    96115    </variablelist>
    97116
     
    100119<screen><userinput remap="make">make</userinput></screen>
    101120
    102     <para>This package has a test suite, but it can only be run after the
    103     package has been installed.  The tests reside in the
    104     <filename class="directory">test/</filename> directory.  See the
    105     <filename>README</filename> file in that directory for further details.
    106     </para>
     121    <para>Install the package:</para>
     122<!-- TODO: check and document -->
     123<screen><userinput remap="install">make DESTDIR=$LFS install
     124  ln -s libncursesw.so $LFS/usr/lib/libncurses.so</userinput></screen>
    107125
    108     <para>Install the package:</para>
     126    <para>Move the shared libraries to the
     127    <filename class="directory">/lib</filename> directory, where they are
     128    expected to reside:</para>
    109129
    110 <screen><userinput remap="install">make install
    111 ln -s libncursesw.so /tools/lib/libncurses.so</userinput></screen>
     130<screen><userinput remap="install">mv -v $LFS/usr/lib/libncursesw.so.6* $LFS/lib</userinput></screen>
     131
     132    <para>Because the libraries have been moved, one symlink points to
     133    a non-existent file. Recreate it:</para>
     134
     135<screen><userinput remap="install">ln -sfv ../../lib/$(readlink $LFS/usr/lib/libncursesw.so) $LFS/usr/lib/libncursesw.so</userinput></screen>
     136
    112137
    113138  </sect2>
  • chapter05/patch.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Patch for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr   \
     49            --host=$LFS_TGT \
     50            --build=$(build-aux/config.guess)</userinput></screen>
    4951
    5052    <para>Compile the package:</para>
     
    5254<screen><userinput remap="make">make</userinput></screen>
    5355
    54     <para>Compilation is now complete. As discussed earlier, running the test
    55     suite is not mandatory for the temporary tools here in this chapter. To run
    56     the Patch test suite anyway, issue the following command:</para>
    57 
    58 <screen><userinput remap="test">make check</userinput></screen>
    59 
    6056    <para>Install the package:</para>
    6157
    62 <screen><userinput remap="install">make install</userinput></screen>
     58<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    6359
    6460  </sect2>
  • chapter05/perl.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Perl for compilation:</para>
    4747
    48 <screen><userinput remap="configure">sh Configure -des -Dprefix=/tools -Dlibs=-lm -Uloclibpth -Ulocincpth</userinput></screen>
     48<screen><userinput remap="configure">sh Configure -des -Dprefix=/usr</userinput></screen>
    4949
    5050    <variablelist>
    51       <title>The meaning of the Configure options:</title>
    52 
     51      <title>The meaning of the new Configure options:</title>
    5352      <varlistentry>
    5453        <term><parameter>-des</parameter></term>
     
    6059      </varlistentry>
    6160
    62       <varlistentry>
    63         <term>
    64           <parameter>-Uloclibpth</parameter> and
    65           <parameter>-Ulocincpth</parameter>
    66         </term>
    67         <listitem>
    68           <para>These entries undefine variables that cause the configuration
    69           to search for locally installed components that may exist on the
    70           host system.</para>
    71         </listitem>
    72       </varlistentry>
    73 
    7461    </variablelist>
    75 
    76 
    77 
    7862
    7963    <para>Build the package:</para>
     
    8165<screen><userinput remap="make">make</userinput></screen>
    8266
    83     <para>Although Perl comes with a test suite, it would be better to wait
    84     until it is installed in the next chapter.</para>
    85 
    86     <para>Only a few of the utilities and libraries need to be installed at this
    87     time:</para>
    88 
    89 <screen><userinput remap="install">cp -v perl cpan/podlators/scripts/pod2man /tools/bin
    90 mkdir -pv /tools/lib/perl5/&perl-version;
    91 cp -Rv lib/* /tools/lib/perl5/&perl-version;</userinput></screen>
     67<screen><userinput remap="install">make install</userinput></screen>
    9268
    9369  </sect2>
  • chapter05/python.xml

    r9d719e2 refcb393  
    66]>
    77
    8 <sect1 id="ch-tools-Python" role="wrap">
    9   <?dbhtml filename="Python.html"?>
     8<sect1 id="ch-system-Python-temp" role="wrap">
     9  <?dbhtml filename="Python-temp.html"?>
    1010
    1111  <sect1info condition="script">
     
    1717  <title>Python-&python-version;</title>
    1818
    19   <indexterm zone="ch-tools-Python">
     19  <indexterm zone="ch-system-Python-temp">
    2020    <primary sortas="a-Python">Python</primary>
    21     <secondary>tools</secondary>
     21    <secondary>temporary</secondary>
    2222  </indexterm>
    2323
     
    5151    </note>
    5252
    53     <para>This package first builds the Python interpreter, then some
    54     standard Python modules. The main script for building modules is
    55     written in Python, and uses hard-coded paths to the host <filename
    56     class="directory">/usr/include</filename> and <filename
    57     class="directory">/usr/lib</filename> directories. To prevent them
    58     from being used, issue:</para>
    59 
    60 <screen><userinput remap="pre">sed -i '/def add_multiarch_paths/a \        return' setup.py</userinput></screen>
    61 
    6253    <para>Prepare Python for compilation:</para>
    6354
    64 <screen><userinput remap="configure">./configure --prefix=/tools --without-ensurepip</userinput></screen>
     55<screen><userinput remap="configure">./configure --prefix=/usr --without-ensurepip</userinput></screen>
    6556
    6657    <variablelist>
     
    8172<screen><userinput remap="make">make</userinput></screen>
    8273
    83     <para>Compilation is now complete. The test suite requires TK and
    84     and X Windows and cannot be run at this time.
    85     </para>
    86 
    8774    <para>Install the package:</para>
    8875
  • chapter05/sed.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Sed for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr   \
     49            --host=$LFS_TGT \
     50            --bindir=/bin</userinput></screen>
    4951
    5052    <para>Compile the package:</para>
     
    5254<screen><userinput remap="make">make</userinput></screen>
    5355
    54     <para>Compilation is now complete. As discussed earlier, running the test
    55     suite is not mandatory for the temporary tools here in this chapter. To run
    56     the Sed test suite anyway, issue the following command:</para>
    57 
    58 <screen><userinput remap="test">make check</userinput></screen>
    59 
    6056    <para>Install the package:</para>
    6157
    62 <screen><userinput remap="install">make install</userinput></screen>
     58<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    6359
    6460  </sect2>
  • chapter05/stripping.xml

    r9d719e2 refcb393  
    1616  debugging symbols. Remove those symbols with:</para>
    1717
    18 <screen><userinput>strip --strip-debug /tools/lib/*
    19 /usr/bin/strip --strip-unneeded /tools/{,s}bin/*</userinput></screen>
     18<screen><userinput>$LFS_TGT-strip --strip-debug $LFS/usr/lib/*
     19$LFS_TGT-strip --strip-unneeded $LFS/usr/{,s}bin/*</userinput></screen>
    2020
    2121  <para>These commands will skip a number of files, reporting that it does not
    2222  recognize their file format. Most of these are scripts instead of binaries.
    23   Also use the system strip command to include the strip binary in /tools.</para>
     23  Note that we use the <command>strip</command> program built in
     24  <quote>Binutils pass 1</quote>, since it is the one that knows how to strip
     25  our cross-compiled programs.</para>
     26<!-- Normally, the host "strip" could be used too, since it is actually the
     27same computer. But Some old versions of binutils may generate buggy crt1.o
     28and the like, because they do not know about recently introduced symbol
     29types. For more details,
     30see https://sourceware.org/bugzilla/show_bug.cgi?id=22875-->
    2431
    2532  <para>Take care <emphasis>not</emphasis> to use
     
    3037  <para>To save more, remove the documentation:</para>
    3138
    32 <screen><userinput>rm -rf /tools/{,share}/{info,man,doc}</userinput></screen>
     39<screen><userinput>rm -rf $LFS/usr/{,share}/{info,man,doc}</userinput></screen>
    3340
    3441  <para>The libtool .la files are only useful when linking with static
     
    3744  Remove those files now:</para>
    3845
    39 <screen><userinput>find /tools/{lib,libexec} -name \*.la -delete</userinput></screen>
     46<screen><userinput>find $LFS/usr/{lib,libexec} -name \*.la -delete</userinput></screen>
    4047
    4148  <para>At this point, you should have at least 3 GB of free space in
  • chapter05/tar.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Tar for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr                     \
     49            --host=$LFS_TGT                   \
     50            --build=$(build-aux/config.guess) \
     51            --bindir=/bin</userinput></screen>
    4952
    5053    <para>Compile the package:</para>
     
    5255<screen><userinput remap="make">make</userinput></screen>
    5356
    54     <para>Compilation is now complete. As discussed earlier, running the test
    55     suite is not mandatory for the temporary tools here in this chapter. To run
    56     the Tar test suite anyway, issue the following command:</para>
    57 
    58 <screen><userinput remap="test">make check</userinput></screen>
    59 
    6057    <para>Install the package:</para>
    6158
    62 <screen><userinput remap="install">make install</userinput></screen>
     59<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    6360
    6461  </sect2>
  • chapter05/tcl.xml

    r9d719e2 refcb393  
    44  <!ENTITY % general-entities SYSTEM "../general.ent">
    55  %general-entities;
     6  <!ENTITY tdbc-ver          "1.1.1">
     7  <!ENTITY itcl-ver          "4.2.0">
    68]>
    79
     
    4749    packages.  Installing three packages for testing purposes may seem
    4850    excessive, but it is very reassuring, if not essential, to know that the
    49     most important tools are working properly. Even if the test suites are not
    50     run in this chapter (they are not mandatory), these packages are required
     51    most important tools are working properly. These packages are required
    5152    to run the test suites in <xref linkend="chapter-building-system"/>.</para>
    5253
     
    5758    <para>Prepare Tcl for compilation:</para>
    5859
    59 <screen><userinput remap="configure">cd unix
    60 ./configure --prefix=/tools</userinput></screen>
     60<screen><userinput remap="configure">SRCDIR=$(pwd)
     61cd unix
     62./configure --prefix=/usr           \
     63            --mandir=/usr/share/man \
     64            $([ "$(uname -m)" = x86_64 ] &amp;&amp; echo --enable-64bit)</userinput></screen>
     65
     66    <variablelist>
     67      <title>The meaning of the configure options:</title>
     68
     69      <varlistentry>
     70        <term><parameter>$([ "$(uname -m)" = x86_64 ] &amp;&amp; echo --enable-64bit)</parameter></term>
     71        <listitem>
     72          <para>The construct <parameter>$(&lt;shell command&gt;)</parameter>
     73          is replaced by the output of the chell command.  Here this output is
     74          empty if running on a 32 bit machine, and is
     75          <parameter>--enable-64bit</parameter> if running on a 64 bit machine.
     76          </para>
     77        </listitem>
     78      </varlistentry>
     79
     80    </variablelist>
    6181
    6282    <para>Build the package:</para>
    6383
    64 <screen><userinput remap="make">make</userinput></screen>
     84<screen><userinput remap="make">make
    6585
    66     <para>Compilation is now complete. As discussed earlier, running the test
    67     suite is not mandatory for the temporary tools here in this chapter. To run
    68     the Tcl test suite anyway, issue the following command:</para>
     86sed -e "s|$SRCDIR/unix|/usr/lib|" \
     87    -e "s|$SRCDIR|/usr/include|"  \
     88    -i tclConfig.sh
    6989
    70 <screen><userinput remap="test">TZ=UTC make test</userinput></screen>
     90sed -e "s|$SRCDIR/unix/pkgs/tdbc&tdbc-ver;|/usr/lib/tdbc&tdbc-ver;|" \
     91    -e "s|$SRCDIR/pkgs/tdbc&tdbc-ver;/generic|/usr/include|"    \
     92    -e "s|$SRCDIR/pkgs/tdbc&tdbc-ver;/library|/usr/lib/tcl8.6|" \
     93    -e "s|$SRCDIR/pkgs/tdbc&tdbc-ver;|/usr/include|"            \
     94    -i pkgs/tdbc&tdbc-ver;/tdbcConfig.sh
    7195
    72     <para>The Tcl test suite may experience failures under certain host
    73     conditions that are not fully understood. Therefore, test suite failures
    74     here are not surprising, and are not considered critical. The
    75     <parameter>TZ=UTC</parameter> parameter sets the time zone to Coordinated
    76     Universal Time (UTC), but only
    77     for the duration of the test suite run. This ensures that the clock tests
    78     are exercised correctly. Details on the <envar>TZ</envar> environment
    79     variable are provided in <xref linkend="chapter-config"/>.</para>
     96sed -e "s|$SRCDIR/unix/pkgs/itcl&itcl-ver;|/usr/lib/itcl&itcl-ver;|" \
     97    -e "s|$SRCDIR/pkgs/itcl&itcl-ver;/generic|/usr/include|"    \
     98    -e "s|$SRCDIR/pkgs/itcl&itcl-ver;|/usr/include|"            \
     99    -i pkgs/itcl&itcl-ver;/itclConfig.sh
     100
     101unset SRCDIR</userinput></screen>
     102
     103    <para>The various <quote>sed</quote> after the <quote>make</quote> command
     104    remove references to the build directory from various configuration files,
     105    and replaces them with the install directory. This is not mandatory
     106    for the remaining of LFS, but may be needed in case a package built later
     107    uses Tcl.</para>
    80108
    81109    <para>Install the package:</para>
     
    86114    be removed later:</para>
    87115
    88 <screen><userinput remap="install">chmod -v u+w /tools/lib/libtcl&tcl-major-version;.so</userinput></screen>
     116<screen><userinput remap="install">chmod -v u+w /usr/lib/libtcl&tcl-major-version;.so</userinput></screen>
    89117
    90118    <para>Install Tcl's headers. The next package, Expect, requires them
     
    95123    <para>Now make a necessary symbolic link:</para>
    96124
    97 <screen><userinput remap="install">ln -sv tclsh&tcl-major-version; /tools/bin/tclsh</userinput></screen>
     125<screen><userinput remap="install">ln -sfv tclsh&tcl-major-version; /usr/bin/tclsh</userinput></screen>
    98126
    99127  </sect2>
  • chapter05/texinfo.xml

    r9d719e2 refcb393  
    66]>
    77
    8 <sect1 id="ch-tools-texinfo" role="wrap">
    9   <?dbhtml filename="texinfo.html"?>
     8<sect1 id="ch-system-texinfo-temp" role="wrap">
     9  <?dbhtml filename="texinfo-temp.html"?>
    1010
    1111  <sect1info condition="script">
     
    1717  <title>Texinfo-&texinfo-version;</title>
    1818
    19   <indexterm zone="ch-tools-texinfo">
     19  <indexterm zone="ch-system-texinfo-temp">
    2020    <primary sortas="a-Texinfo">Texinfo</primary>
    21     <secondary>tools</secondary>
     21    <secondary>temporary</secondary>
    2222  </indexterm>
    2323
     
    4646    <para>Prepare Texinfo for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
    4949
    5050    <note>
     
    5757
    5858<screen><userinput remap="make">make</userinput></screen>
    59 
    60     <para>Compilation is now complete. As discussed earlier, running the test
    61     suite is not mandatory for the temporary tools here in this chapter. To run
    62     the Texinfo test suite anyway, issue the following command:</para>
    63 
    64 <screen><userinput remap="test">make check</userinput></screen>
    6559
    6660    <para>Install the package:</para>
  • chapter05/toolchaintechnotes.xml

    r9d719e2 refcb393  
    2525  the most educational value at the same time.</para>
    2626
    27   <note>
    28     <para>Before continuing, be aware of the name of the working platform,
    29     often referred to as the target triplet. A simple way to determine the
    30     name of the target triplet is to run the <command>config.guess</command>
    31     script that comes with the source for many packages. Unpack the Binutils
    32     sources and run the script: <userinput>./config.guess</userinput> and note
    33     the output. For example, for a 32-bit Intel processor the
    34     output will be <emphasis>i686-pc-linux-gnu</emphasis>. On a 64-bit
    35     system it will be <emphasis>x86_64-pc-linux-gnu</emphasis>.</para>
    36 
    37     <para>Also be aware of the name of the platform's dynamic linker, often
    38     referred to as the dynamic loader (not to be confused with the standard
    39     linker <command>ld</command> that is part of Binutils). The dynamic linker
    40     provided by Glibc finds and loads the shared libraries needed by a program,
    41     prepares the program to run, and then runs it. The name of the dynamic
    42     linker for a 32-bit Intel machine will be <filename
    43     class="libraryfile">ld-linux.so.2</filename> (<filename
    44     class="libraryfile">ld-linux-x86-64.so.2</filename> for 64-bit systems).  A
    45     sure-fire way to determine the name of the dynamic linker is to inspect a
    46     random binary from the host system by running: <userinput>readelf -l
    47     &lt;name of binary&gt; | grep interpreter</userinput> and noting the
    48     output. The authoritative reference covering all platforms is in the
    49     <filename>shlib-versions</filename> file in the root of the Glibc source
    50     tree.</para>
    51   </note>
    52 
    53   <para>Some key technical points of how the <xref
    54   linkend="chapter-temporary-tools"/> build method works:</para>
    55 
    56   <itemizedlist>
    57     <listitem>
    58       <para>Slightly adjusting the name of the working platform, by changing the
    59       &quot;vendor&quot; field target triplet by way of the
    60       <envar>LFS_TGT</envar> variable, ensures that the first build of Binutils
    61       and GCC produces a compatible cross-linker and cross-compiler. Instead of
    62       producing binaries for another architecture, the cross-linker and
    63       cross-compiler will produce binaries compatible with the current
    64       hardware.</para>
    65     </listitem>
    66     <listitem>
    67       <para> The temporary libraries are cross-compiled.  Because a
    68       cross-compiler by its nature cannot rely on anything from its host
    69       system, this method removes potential contamination of the target
    70       system by lessening the chance of headers or libraries from the host
    71       being incorporated into the new tools.  Cross-compilation also allows for
    72       the possibility of building both 32-bit and 64-bit libraries on 64-bit
    73       capable hardware.</para>
    74     </listitem>
    75     <listitem>
    76     <para>Careful manipulation of the GCC source tells the compiler which target
    77     dynamic linker will be used.</para>
    78     </listitem>
    79   </itemizedlist>
    80 
    81   <para>Binutils is installed first because the <command>configure</command>
    82   runs of both GCC and Glibc perform various feature tests on the assembler
    83   and linker to determine which software features to enable or disable. This
    84   is more important than one might first realize. An incorrectly configured
    85   GCC or Glibc can result in a subtly broken toolchain, where the impact of
    86   such breakage might not show up until near the end of the build of an
    87   entire distribution. A test suite failure will usually highlight this error
    88   before too much additional work is performed.</para>
    89 
    90   <para>Binutils installs its assembler and linker in two locations,
    91   <filename class="directory">/tools/bin</filename> and <filename
    92   class="directory">/tools/$LFS_TGT/bin</filename>. The tools in one
    93   location are hard linked to the other. An important facet of the linker is
    94   its library search order. Detailed information can be obtained from
    95   <command>ld</command> by passing it the <parameter>--verbose</parameter>
    96   flag. For example, an <userinput>ld --verbose | grep SEARCH</userinput>
    97   will illustrate the current search paths and their order. It shows which
    98   files are linked by <command>ld</command> by compiling a dummy program and
    99   passing the <parameter>--verbose</parameter> switch to the linker. For example,
    100   <userinput>gcc dummy.c -Wl,--verbose 2&gt;&amp;1 | grep succeeded</userinput>
    101   will show all the files successfully opened during the linking.</para>
    102 
    103   <para>The next package installed is GCC. An example of what can be
    104   seen during its run of <command>configure</command> is:</para>
    105 
    106 <screen><computeroutput>checking what assembler to use... /tools/i686-lfs-linux-gnu/bin/as
    107 checking what linker to use... /tools/i686-lfs-linux-gnu/bin/ld</computeroutput></screen>
    108 
    109   <para>This is important for the reasons mentioned above. It also demonstrates
    110   that GCC's configure script does not search the PATH directories to find which
    111   tools to use. However, during the actual operation of <command>gcc</command>
    112   itself, the same search paths are not necessarily used. To find out which
    113   standard linker <command>gcc</command> will use, run:
    114   <userinput>gcc -print-prog-name=ld</userinput>.</para>
    115 
    116   <para>Detailed information can be obtained from <command>gcc</command> by
    117   passing it the <parameter>-v</parameter> command line option while compiling
    118   a dummy program. For example, <userinput>gcc -v dummy.c</userinput> will show
    119   detailed information about the preprocessor, compilation, and assembly stages,
    120   including <command>gcc</command>'s included search paths and their order.</para>
    121 
    122   <para>Next installed are sanitized Linux API headers. These allow the standard
    123   C library (Glibc) to interface with features that the Linux kernel will
    124   provide.</para>
    125 
    126   <para>The next package installed is Glibc. The most important considerations
    127   for building Glibc are the compiler, binary tools, and kernel headers. The
    128   compiler is generally not an issue since Glibc will always use the compiler
    129   relating to the <parameter>--host</parameter> parameter passed to its
    130   configure script; e.g. in our case, the compiler will be
    131   <command>i686-lfs-linux-gnu-gcc</command>. The binary tools and kernel
    132   headers can be a bit more complicated. Therefore, take no risks and use the
    133   available configure switches to enforce the correct selections. After the run
    134   of <command>configure</command>, check the contents of the
    135   <filename>config.make</filename> file in the <filename
    136   class="directory">glibc-build</filename> directory for all important details.
    137   Note the use of <parameter>CC="i686-lfs-gnu-gcc"</parameter> to control which
    138   binary tools are used and the use of the <parameter>-nostdinc</parameter> and
    139   <parameter>-isystem</parameter> flags to control the compiler's include
    140   search path. These items highlight an important aspect of the Glibc
    141   package&mdash;it is very self-sufficient in terms of its build machinery and
    142   generally does not rely on toolchain defaults.</para>
    143 
    144   <para>During the second pass of Binutils, we are able to utilize the
    145   <parameter>--with-lib-path</parameter> configure switch to control
    146   <command>ld</command>'s library search path.</para>
    147 
    148   <para>For the second pass of GCC, its sources also need to be modified to
    149   tell GCC to use the new dynamic linker. Failure to do so will result in the
    150   GCC programs themselves having the name of the dynamic linker from the host
    151   system's <filename class="directory">/lib</filename> directory embedded into
    152   them, which would defeat the goal of getting away from the host. From this
    153   point onwards, the core toolchain is self-contained and self-hosted. The
    154   remainder of the <xref linkend="chapter-temporary-tools"/> packages all build
    155   against the new Glibc in <filename
    156   class="directory">/tools</filename>.</para>
    157 
    158   <para>Upon entering the chroot environment in <xref
    159   linkend="chapter-building-system"/>, the first major package to be
    160   installed is Glibc, due to its self-sufficient nature mentioned above.
    161   Once this Glibc is installed into <filename
    162   class="directory">/usr</filename>, we will perform a quick changeover of the
    163   toolchain defaults, and then proceed in building the rest of the target
    164   LFS system.</para>
     27  <para>The build process is based on the process of
     28  <emphasis>cross-compilation</emphasis>. Cross-compilation is normally used
     29  for building a compiler and its toolchain for a machine different from
     30  the one that is used for the build. This is not strictly needed for LFS,
     31  since the machine where the new system will run is the same as the one
     32  used for the build. But cross-compilation has the great advantage that
     33  anything that is cross-compiled cannot depend on the host environment.</para>
     34
     35  <sect2 id="cross-compile" xreflabel="About Cross-Compilation">
     36
     37    <title>About Cross-Compilation</title>
     38
     39    <para>Cross-compilation involves some concepts that deserve a section on
     40    their own. Although this section may be omitted in a first reading, it
     41    is strongly suggested to come back to it later in order to get a full
     42    grasp of the build process.</para>
     43
     44    <para>Let us first define some terms used in this context:</para>
     45
     46    <variablelist>
     47      <varlistentry><term>build</term><listitem>
     48        <para>is the machine where we build programs. Note that this machine
     49        is referred to as the <quote>host</quote> in other
     50        sections.</para></listitem>
     51      </varlistentry>
     52
     53      <varlistentry><term>host</term><listitem>
     54        <para>is the machine/system where the built programs will run. Note
     55        that this use of <quote>host</quote> is not the same as in other
     56        sections.</para></listitem>
     57      </varlistentry>
     58
     59      <varlistentry><term>target</term><listitem>
     60        <para>is only used for compilers. It is the machine the compiler
     61        produces code for. It may be different from both build and
     62        host.</para></listitem>
     63      </varlistentry>
     64
     65    </variablelist>
     66
     67    <para>As an example, let us imagine the following scenario: we may have a
     68    compiler on a slow machine only, let's call the machine A, and the compiler
     69    ccA. We may have also a fast machine (B), but with no compiler, and we may
     70    want to produce code for a another slow machine (C). Then, to build a
     71    compiler for machine C, we would have three stages:</para>
     72
     73    <informaltable align="center">
     74      <tgroup cols="5">
     75        <colspec colnum="1" align="center"/>
     76        <colspec colnum="2" align="center"/>
     77        <colspec colnum="3" align="center"/>
     78        <colspec colnum="4" align="center"/>
     79        <colspec colnum="5" align="left"/>
     80        <thead>
     81          <row><entry>Stage</entry><entry>Build</entry><entry>Host</entry>
     82               <entry>Target</entry><entry>Action</entry></row>
     83        </thead>
     84        <tbody>
     85          <row>
     86            <entry>1</entry><entry>A</entry><entry>A</entry><entry>B</entry>
     87            <entry>build cross-compiler cc1 using ccA on machine A</entry>
     88          </row>
     89          <row>
     90            <entry>2</entry><entry>A</entry><entry>B</entry><entry>B</entry>
     91            <entry>build cross-compiler cc2 using cc1 on machine A</entry>
     92          </row>
     93          <row>
     94            <entry>3</entry><entry>B</entry><entry>C</entry><entry>C</entry>
     95            <entry>build compiler ccC using cc2 on machine B</entry>
     96          </row>
     97        </tbody>
     98      </tgroup>
     99    </informaltable>
     100
     101    <para>Then, all the other programs needed by machine C can be compiled
     102    using cc2 on the fast machine B. Note that unless B can run programs
     103    produced for C, there is no way to test the built programs until machine
     104    C itself is running. For example, for testing ccC, we may want to add a
     105    fourth stage:</para>
     106
     107    <informaltable align="center">
     108      <tgroup cols="5">
     109        <colspec colnum="1" align="center"/>
     110        <colspec colnum="2" align="center"/>
     111        <colspec colnum="3" align="center"/>
     112        <colspec colnum="4" align="center"/>
     113        <colspec colnum="5" align="left"/>
     114        <thead>
     115          <row><entry>Stage</entry><entry>Build</entry><entry>Host</entry>
     116               <entry>Target</entry><entry>Action</entry></row>
     117        </thead>
     118        <tbody>
     119          <row>
     120            <entry>4</entry><entry>C</entry><entry>C</entry><entry>C</entry>
     121            <entry>rebuild  and test ccC using itself on machine C</entry>
     122          </row>
     123        </tbody>
     124      </tgroup>
     125    </informaltable>
     126
     127    <para>In the example above, only cc1 and cc2 are cross-compilers, that is,
     128    they produce code for a machine different from the one they are run on.
     129    The other compilers ccA and ccC produce code for the machine they are run
     130    on. Such compilers are called <emphasis>native</emphasis> compilers.</para>
     131
     132  </sect2>
     133
     134  <sect2 id="lfs-cross">
     135    <title>Implementation of Cross-Compilation for LFS</title>
     136
     137    <note>
     138      <para>Almost all the build systems use names of the form
     139      cpu-vendor-kernel-os referred to as the machine triplet. An astute
     140      reader may wonder why a <quote>triplet</quote> refers to a four component
     141      name. The reason is history: initially, three component names were enough
     142      to designate unambiguously a machine, but with new machines and systems
     143      appearing, that proved insufficient. The word <quote>triplet</quote>
     144      remained. A simple way to determine your machine triplet is to run
     145      the <command>config.guess</command>
     146      script that comes with the source for many packages. Unpack the Binutils
     147      sources and run the script: <userinput>./config.guess</userinput> and note
     148      the output. For example, for a 32-bit Intel processor the
     149      output will be <emphasis>i686-pc-linux-gnu</emphasis>. On a 64-bit
     150      system it will be <emphasis>x86_64-pc-linux-gnu</emphasis>.</para>
     151
     152      <para>Also be aware of the name of the platform's dynamic linker, often
     153      referred to as the dynamic loader (not to be confused with the standard
     154      linker <command>ld</command> that is part of Binutils). The dynamic linker
     155      provided by Glibc finds and loads the shared libraries needed by a
     156      program, prepares the program to run, and then runs it. The name of the
     157      dynamic linker for a 32-bit Intel machine will be <filename
     158      class="libraryfile">ld-linux.so.2</filename> (<filename
     159      class="libraryfile">ld-linux-x86-64.so.2</filename> for 64-bit systems). A
     160      sure-fire way to determine the name of the dynamic linker is to inspect a
     161      random binary from the host system by running: <userinput>readelf -l
     162      &lt;name of binary&gt; | grep interpreter</userinput> and noting the
     163      output. The authoritative reference covering all platforms is in the
     164      <filename>shlib-versions</filename> file in the root of the Glibc source
     165      tree.</para>
     166    </note>
     167
     168    <para>In order to fake a cross compilation, the name of the host triplet
     169    is slightly adjusted by changing the &quot;vendor&quot; field in the
     170    <envar>LFS_TGT</envar> variable. We also use the
     171    <parameter>--with-sysroot</parameter> when building the cross linker and
     172    cross compiler, to tell them where to find the needed host files. This
     173    ensures none of the other programs built in <xref
     174    linkend="chapter-temporary-tools"/> can link to libraries on the build
     175    machine. Only two stages are mandatory, and one more for tests:</para>
     176
     177    <informaltable align="center">
     178      <tgroup cols="5">
     179        <colspec colnum="1" align="center"/>
     180        <colspec colnum="2" align="center"/>
     181        <colspec colnum="3" align="center"/>
     182        <colspec colnum="4" align="center"/>
     183        <colspec colnum="5" align="left"/>
     184        <thead>
     185          <row><entry>Stage</entry><entry>Build</entry><entry>Host</entry>
     186               <entry>Target</entry><entry>Action</entry></row>
     187        </thead>
     188        <tbody>
     189          <row>
     190            <entry>1</entry><entry>pc</entry><entry>pc</entry><entry>lfs</entry>
     191            <entry>build cross-compiler cc1 using cc-pc on pc</entry>
     192          </row>
     193          <row>
     194            <entry>2</entry><entry>pc</entry><entry>lfs</entry><entry>lfs</entry>
     195            <entry>build compiler cc-lfs using cc1 on pc</entry>
     196          </row>
     197          <row>
     198            <entry>3</entry><entry>lfs</entry><entry>lfs</entry><entry>lfs</entry>
     199            <entry>rebuild and test cc-lfs using itself on lfs</entry>
     200          </row>
     201        </tbody>
     202      </tgroup>
     203    </informaltable>
     204
     205    <para>In the above table, <quote>on pc</quote> means the commands are run
     206    on a machine using the already installed distribution. <quote>On
     207    lfs</quote> means the commands are run in a chrooted environment.</para>
     208
     209    <para>Now, there is more about cross-compiling: the C language is not
     210    just a compiler, but also defines a standard library. In this book, the
     211    GNU C library, named glibc, is used. This library must
     212    be compiled for the lfs machine, that is, using the cross compiler cc1.
     213    But the compiler itself uses an internal library implementing complex
     214    instructions not available in the assembler instruction set. This
     215    internal library is named libgcc, and must be linked to the glibc
     216    library to be fully functional! Furthermore, the standard library for
     217    C++ (libstdc++) also needs being linked to glibc. The solution
     218    to this chicken and egg problem is to first build a degraded cc1+libgcc,
     219    lacking some fuctionalities such as threads and exception handling, then
     220    build glibc using this degraded compiler (glibc itself is not
     221    degraded), then build libstdc++. But this last library will lack the
     222    same functionalities as libgcc.</para>
     223
     224    <para>This is not the end of the story: the conclusion of the preceding
     225    paragraph is that cc1 is unable to build a fully functional libstdc++, but
     226    this is the only compiler available for building the C/C++ libraries
     227    during stage 2! Of course, the compiler built during stage 2, cc-lfs,
     228    would be able to build those libraries, but (i) the build system of
     229    gcc does not know that it is usable on pc, and (ii) using it on pc
     230    would be at risk of linking to the pc libraries, since cc-lfs is a native
     231    compiler. So we have to build libstdc++ later, in chroot.</para>
     232
     233  </sect2>
     234
     235  <sect2 id="other-details">
     236
     237    <title>Other procedural details</title>
     238
     239    <para>The cross-compiler will be installed in a separate <filename
     240    class="directory">$LFS/tools</filename> directory, since it will not
     241    be part of the final system.</para>
     242
     243    <para>Binutils is installed first because the <command>configure</command>
     244    runs of both GCC and Glibc perform various feature tests on the assembler
     245    and linker to determine which software features to enable or disable. This
     246    is more important than one might first realize. An incorrectly configured
     247    GCC or Glibc can result in a subtly broken toolchain, where the impact of
     248    such breakage might not show up until near the end of the build of an
     249    entire distribution. A test suite failure will usually highlight this error
     250    before too much additional work is performed.</para>
     251
     252    <para>Binutils installs its assembler and linker in two locations,
     253    <filename class="directory">$LFS/tools/bin</filename> and <filename
     254    class="directory">$LFS/tools/$LFS_TGT/bin</filename>. The tools in one
     255    location are hard linked to the other. An important facet of the linker is
     256    its library search order. Detailed information can be obtained from
     257    <command>ld</command> by passing it the <parameter>--verbose</parameter>
     258    flag. For example, <command>$LFS_TGT-ld --verbose | grep SEARCH</command>
     259    will illustrate the current search paths and their order. It shows which
     260    files are linked by <command>ld</command> by compiling a dummy program and
     261    passing the <parameter>--verbose</parameter> switch to the linker. For
     262    example,
     263    <command>$LFS_TGT-gcc dummy.c -Wl,--verbose 2&gt;&amp;1 | grep succeeded</command>
     264    will show all the files successfully opened during the linking.</para>
     265
     266    <para>The next package installed is GCC. An example of what can be
     267    seen during its run of <command>configure</command> is:</para>
     268
     269<screen><computeroutput>checking what assembler to use... /mnt/lfs/tools/i686-lfs-linux-gnu/bin/as
     270checking what linker to use... /mnt/lfs/tools/i686-lfs-linux-gnu/bin/ld</computeroutput></screen>
     271
     272    <para>This is important for the reasons mentioned above. It also
     273    demonstrates that GCC's configure script does not search the PATH
     274    directories to find which tools to use. However, during the actual
     275    operation of <command>gcc</command> itself, the same search paths are not
     276    necessarily used. To find out which standard linker <command>gcc</command>
     277    will use, run: <command>$LFS_TGT-gcc -print-prog-name=ld</command>.</para>
     278
     279    <para>Detailed information can be obtained from <command>gcc</command> by
     280    passing it the <parameter>-v</parameter> command line option while compiling
     281    a dummy program. For example, <command>gcc -v dummy.c</command> will show
     282    detailed information about the preprocessor, compilation, and assembly
     283    stages, including <command>gcc</command>'s included search paths and their
     284    order.</para>
     285
     286    <para>Next installed are sanitized Linux API headers. These allow the
     287    standard C library (Glibc) to interface with features that the Linux
     288    kernel will provide.</para>
     289
     290    <para>The next package installed is Glibc. The most important
     291    considerations for building Glibc are the compiler, binary tools, and
     292    kernel headers. The compiler is generally not an issue since Glibc will
     293    always use the compiler relating to the <parameter>--host</parameter>
     294    parameter passed to its configure script; e.g. in our case, the compiler
     295    will be <command>$LFS_TGT-gcc</command>. The binary tools and kernel
     296    headers can be a bit more complicated. Therefore, take no risks and use
     297    the available configure switches to enforce the correct selections. After
     298    the run of <command>configure</command>, check the contents of the
     299    <filename>config.make</filename> file in the <filename
     300    class="directory">build</filename> directory for all important details.
     301    Note the use of <parameter>CC="$LFS_TGT-gcc"</parameter> (with
     302    <envar>$LFS_TGT</envar> expanded) to control which binary tools are used
     303    and the use of the <parameter>-nostdinc</parameter> and
     304    <parameter>-isystem</parameter> flags to control the compiler's include
     305    search path. These items highlight an important aspect of the Glibc
     306    package&mdash;it is very self-sufficient in terms of its build machinery
     307    and generally does not rely on toolchain defaults.</para>
     308
     309    <para>As said above, the standard C++ library is compiled next, followed
     310    by all the programs that need themselves to be built. The install step
     311    uses the <envar>DESTDIR</envar> variable to have the programs land into
     312    the LFS filesystem.</para>
     313
     314    <para>Then the native lfs compiler is built. First Binutils Pass 2, with
     315    the same <envar>DESTDIR</envar> install as the other programs, then the
     316    second pass of GCC, omitting libstdc++ and other non-important libraries.
     317    Due to some weird logic in GCC's configure script,
     318    <envar>CC_FOR_TARGET</envar> ends up as <command>cc</command> when host
     319    is the same as target, but is different from build. This is why
     320    <parameter>CC_FOR_TARGET=$LFS_TGT-gcc</parameter> is put explicitely into
     321    the configure options.</para>
     322
     323    <para>Upon entering the chroot environment in <xref
     324    linkend="chapter-building-system"/>, the first task is to install
     325    libstdc++. Then temporary installations of programs needed for the proper
     326    operation of the toolchain are performed. Programs needed for testing
     327    other programs are also built. From this point onwards, the
     328    core toolchain is self-contained and self-hosted.  In the remainder of
     329    the <xref linkend="chapter-building-system"/>, final versions of all the
     330    packages needed for a fully functional system are built, tested and
     331    installed.</para>
     332
     333  </sect2>
    165334
    166335</sect1>
  • chapter05/util-linux.xml

    r9d719e2 refcb393  
    4242    <title>Installation of Util-linux</title>
    4343
     44    <para>First create a directory
     45    to enable storage for the <command>hwclock</command> program:</para>
     46
     47<screen><userinput remap="pre">mkdir -pv /var/lib/hwclock</userinput></screen>
     48
    4449    <para>Prepare Util-linux for compilation:</para>
    4550
    46 <screen><userinput remap="configure">./configure --prefix=/tools                \
    47             --without-python               \
    48             --disable-makeinstall-chown    \
    49             --without-systemdsystemunitdir \
    50             --without-ncurses              \
    51             PKG_CONFIG=""</userinput></screen>
     51<screen><userinput remap="configure">./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \
     52            --docdir=/usr/share/doc/util-linux-&util-linux-version; \
     53            --disable-chfn-chsh  \
     54            --disable-login      \
     55            --disable-nologin    \
     56            --disable-su         \
     57            --disable-setpriv    \
     58            --disable-runuser    \
     59            --disable-pylibmount \
     60            --disable-static     \
     61            --without-python</userinput></screen>
    5262
    5363    <variablelist>
    54       <title>The meaning of the configure option:</title>
     64      <title>The meaning of the configure options:</title>
     65<!-- TODO -->
     66      <varlistentry>
     67        <term><parameter>ADJTIME_PATH=/var/lib/hwclock/adjtime</parameter></term>
     68        <listitem>
     69          <para>This sets the location of the file recording information about
     70          the hardware clock, in accordance to the FHS. This is not stricly
     71          needed fot his temporary tool, but it prevent creating a file
     72          at another location, which would not be overwritten or removed
     73          when building the final util-linux.</para>
     74        </listitem>
     75      </varlistentry>
     76
     77      <varlistentry>
     78        <term><parameter>--disable-*</parameter></term>
     79        <listitem>
     80          <para>Those switches prevent warnings about building components
     81          that require packages not in LFS or not installed yet.</para>
     82        </listitem>
     83      </varlistentry>
    5584
    5685      <varlistentry>
    5786        <term><parameter>--without-python</parameter></term>
    5887        <listitem>
    59           <para>This switch disables using <application>Python</application>
    60           if it is installed on the host system.  It avoids trying to build
    61           unneeded bindings.</para>
     88          <para>This switch disables using <application>Python</application>.
     89          It avoids trying to build unneeded bindings.</para>
    6290        </listitem>
    6391      </varlistentry>
    6492
    65       <varlistentry>
    66         <term><parameter>--disable-makeinstall-chown</parameter></term>
    67         <listitem>
    68           <para>This switch disables using the <command>chown</command> command
    69           during installation.  This is not needed when installing into the
    70           /tools directory and avoids the necessity of installing as
    71           root.</para>
    72         </listitem>
    73       </varlistentry>
    74 
    75       <varlistentry>
    76         <term><parameter>--without-ncurses</parameter></term>
    77         <listitem>
    78           <para>This switch disables using the ncurses library for
    79           the build process. This is not needed when installing into the
    80           /tools directory and avoids problems on some host distros.</para>
    81         </listitem>
    82       </varlistentry>
    83 
    84       <varlistentry>
    85         <term><parameter>--without-systemdsystemunitdir</parameter></term>
    86         <listitem>
    87           <para>On systems that use systemd, the package tries to install
    88           a systemd specific file to a non-existent directory in /tools.
    89           This switch disables the unnecessary action.</para>
    90         </listitem>
    91       </varlistentry>
    92 
    93       <varlistentry>
    94         <term><envar>PKG_CONFIG=""</envar></term>
    95         <listitem>
    96           <para>Setting this environment variable prevents adding unneeded
    97           features that may be available on the host. Note that the location
    98           shown for setting this environment variable is different from other
    99           LFS sections where variables are set preceding the command.  This
    100           location is shown to demonstrate an alternative way of setting an
    101           environment variable when using configure.</para>
    102         </listitem>
    103       </varlistentry>
    10493     </variablelist>
    10594
  • chapter05/xz.xml

    r9d719e2 refcb393  
    4646    <para>Prepare Xz for compilation:</para>
    4747
    48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
     48<screen><userinput remap="configure">./configure --prefix=/usr                     \
     49            --host=$LFS_TGT                   \
     50            --build=$(build-aux/config.guess) \
     51            --disable-static                  \
     52            --docdir=/usr/share/doc/xz-&xz-version;</userinput></screen>
    4953
    5054   <para>Compile the package:</para>
     
    5256<screen><userinput remap="make">make</userinput></screen>
    5357
    54     <para>Compilation is now complete. As discussed earlier, running the test
    55     suite is not mandatory for the temporary tools here in this chapter. To run
    56     the Xz test suite anyway, issue the following command:</para>
    57 
    58 <screen><userinput remap="test">make check</userinput></screen>
    59 
    6058    <para>Install the package:</para>
    6159
    62 <screen><userinput remap="install">make install</userinput></screen>
     60<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
     61
     62    <para>Make sure that all essential files are in the correct directory:</para>
     63
     64<screen><userinput remap="install">mv -v   $LFS/usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat} $LFS/bin
     65mv -v $LFS/usr/lib/liblzma.so.* $LFS/lib
     66ln -svf ../../lib/$(readlink $LFS/usr/lib/liblzma.so) $LFS/usr/lib/liblzma.so</userinput></screen>
    6367
    6468  </sect2>
     
    6670  <sect2 role="content">
    6771    <title/>
    68 
    69     <para>Details on this package are located in
    70     <xref linkend="contents-xz" role="."/></para>
     72    <para>Details on this package are located in<!-- TODO
     73    <xref linkend="contents-xz" role="."/>      --></para>
    7174
    7275  </sect2>
  • chapter06/acl.xml

    r9d719e2 refcb393  
    5151            --docdir=/usr/share/doc/acl-&acl-version;</userinput></screen>
    5252
    53 <screen revision="systemd"><userinput remap="configure">./configure --prefix=/usr         \
     53<screen revision="systemd"><userinput remap="configure">
     54./configure --prefix=/usr         \
    5455            --disable-static      \
    5556            --libexecdir=/usr/lib \
  • chapter06/attr.xml

    r9d719e2 refcb393  
    4444    <para>Prepare Attr for compilation:</para>
    4545
    46 <screen revision="sysv"><userinput remap="configure">./configure --prefix=/usr     \
     46<screen revision="sysv"><userinput remap="configure">
     47./configure --prefix=/usr     \
    4748            --bindir=/bin     \
    4849            --disable-static  \
     
    5051            --docdir=/usr/share/doc/attr-&attr-version;</userinput></screen>
    5152
    52 <screen revision="systemd"><userinput remap="configure">./configure --prefix=/usr     \
     53<screen revision="systemd"><userinput remap="configure">
     54./configure --prefix=/usr     \
    5355            --disable-static  \
    5456            --sysconfdir=/etc \
  • chapter06/bc.xml

    r9d719e2 refcb393  
    4141  <sect2 role="installation">
    4242    <title>Installation of Bc</title>
    43 <!--
    44     <para>First, change an internal script to use <command>sed</command> instead
    45     of <command>ed</command>:</para>
    4643
    47 <screen><userinput remap="pre">cat &gt; bc/fix-libmath_h &lt;&lt; "EOF"
    48 #! /bin/bash
    49 sed -e '1   s/^/{"/' \
    50     -e     's/$/",/' \
    51     -e '2,$ s/^/"/'  \
    52     -e   '$ d'       \
    53     -i libmath.h
     44    <para>Prepare Bc for compilation:</para>
    5445
    55 sed -e '$ s/$/0}/' \
    56     -i libmath.h
    57 EOF</userinput></screen>
    58 
    59     <para>Create temporary symbolic links so the package can find
    60     the readline library and confirm that its required libncurses
    61     library is available. Even though the libraries are in /tools/lib
    62     at this point, the system will use /usr/lib at the end of
    63     this chapter.</para>
    64 
    65 <screen><userinput remap="pre">ln -sv /tools/lib/libncursesw.so.6 /usr/lib/libncursesw.so.6
    66 ln -sfv libncursesw.so.6 /usr/lib/libncurses.so</userinput></screen>
    67 
    68     <para>Fix an issue in <command>configure</command> due to missing
    69     files in the early stages of LFS:</para>
    70 
    71 <screen><userinput remap="pre">sed -i -e '/flex/s/as_fn_error/: ;; # &amp;/' configure</userinput></screen>
    72 -->
    73     <para>Prepare Bc for compilation:</para>
    74 <!--
    75 <screen><userinput remap="configure">./configure - -prefix=/usr           \
    76             - -with-readline         \
    77             - -mandir=/usr/share/man \
    78             - -infodir=/usr/share/info</userinput></screen>
    79 -->
    8046<screen><userinput remap="configure">PREFIX=/usr CC=gcc CFLAGS="-std=c99" ./configure.sh -G -O3</userinput></screen>
    8147
    8248    <variablelist>
    8349      <title>The meaning of the configure options:</title>
    84 <!--
    85       <varlistentry>
    86         <term><parameter>- -with-readline</parameter></term>
    87         <listitem>
    88           <para>This option tells Bc to use the <filename
    89           class="libraryfile">readline</filename> library that is already
    90           installed on the system rather than using its own readline
    91           version.</para>
    92         </listitem>
    93       </varlistentry>
    94 -->
     50
    9551      <varlistentry>
    9652        <term><parameter>CC=gcc CFLAGS="-std=c99"</parameter></term>
    9753        <listitem>
    98           <para>These parameters specify the compiler and C standard to use.</para>
     54          <para>These parameters specify the compiler and the C standard to use.</para>
    9955        </listitem>
    10056      </varlistentry>
     
    11975
    12076<screen><userinput remap="make">make</userinput></screen>
    121 <!--
    122     <para>To test bc, run the commands below. There is quite a bit of output,
    123     so you may want to redirect it to a file. There are a very small percentage
    124     of tests (10 of 12,144) that will indicate a round off error at the last
    125     digit.</para>
    126 
    127 <screen><userinput remap="test">echo "quit" | ./bc/bc -l Test/checklib.b</userinput></screen>
    128 -->
    12977
    13078    <para>To test bc, run:</para>
  • chapter06/bzip2.xml

    r9d719e2 refcb393  
    9191<screen><userinput remap="install">cp -v bzip2-shared /bin/bzip2
    9292cp -av libbz2.so* /lib
    93 ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so
    94 rm -v /usr/bin/{bunzip2,bzcat,bzip2}
    95 ln -sv bzip2 /bin/bunzip2
    96 ln -sv bzip2 /bin/bzcat</userinput></screen>
     93rm -v /usr/bin/{bunzip2,bzcat,bzip2}</userinput></screen>
    9794
    9895  </sect2>
  • chapter06/chapter06.xml

    r9d719e2 refcb393  
    1313
    1414  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="introduction.xml"/>
    15   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="kernfs.xml"/>
    1615  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="pkgmgt.xml"/>
    17   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="chroot.xml"/>
    18   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="creatingdirs.xml"/>
    19   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="createfiles.xml"/>
    20   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="linux-headers.xml"/>
     16<!--  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="linux-headers.xml"/>-->
    2117  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="man-pages.xml"/>
     18<!--  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="adjusting.xml"/>-->
    2219  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glibc.xml"/>
    23   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="adjusting.xml"/>
    2420  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zlib.xml"/>
    2521  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="bzip2.xml"/>
  • chapter06/check.xml

    r9d719e2 refcb393  
    5757    (up to 4 SBU) time.</para>
    5858
    59     <para>Install the package and fix a script:</para>
     59    <para>Install the package:</para>
    6060
    61     <screen><userinput remap="install">make docdir=/usr/share/doc/check-&check-version; install &amp;&amp;
    62 sed -i '1 s/tools/usr/' /usr/bin/checkmk</userinput></screen>
    63 <!-- Removes a hardcoded call to /tools/bin/gawk at line 1 of checkmk. -->
     61    <screen><userinput remap="install">make docdir=/usr/share/doc/check-&check-version; install</userinput></screen>
    6462
    6563  </sect2>
  • chapter06/coreutils.xml

    r9d719e2 refcb393  
    124124<screen><userinput remap="test">chown -Rv nobody . </userinput></screen>
    125125
    126     <para>Now run the tests. Make sure the PATH in the <userinput>su</userinput>
    127     environment includes /tools/bin.</para>
     126    <para>Now run the tests:</para>
    128127
    129128<screen><userinput remap="test">su nobody -s /bin/bash \
  • chapter06/e2fsprogs.xml

    r9d719e2 refcb393  
    5353    <para>Prepare E2fsprogs for compilation:</para>
    5454
    55 <!--<screen><userinput remap="configure">LIBS=-L/tools/lib                    \
    56 CFLAGS=-I/tools/include              \
    57 CFLAGS=-I/tools/include              \
    58 PKG_CONFIG_PATH=/tools/lib/pkgconfig \
    59 ../configure - -prefix=/usr           \-->
    6055<screen><userinput remap="configure">../configure --prefix=/usr           \
    6156             --bindir=/bin           \
     
    6964    <variablelist>
    7065      <title>The meaning of the environment variable and configure options:</title>
    71 <!--
    72       <varlistentry>
    73         <term><parameter>PKG_CONFIG_PATH, LIBS, CFLAGS</parameter></term>
    74         <listitem>
    75           <para>These variables enable e2fsprogs to be built using the
    76           <xref linkend="ch-tools-util-linux"/> package built earlier.</para>
    77         </listitem>
    78       </varlistentry>
    79 -->
     66
    8067      <varlistentry>
    8168        <term><parameter>--with-root-prefix=""</parameter> and
     
    118105
    119106<screen><userinput remap="make">make</userinput></screen>
    120 <!--
    121     <para>To set up and run the test suite we need to first link some
    122     libraries from /tools/lib to a location where the test programs look.
    123     To run the tests, issue:</para>
    124 -->
    125107
    126108    <para>To run the tests, issue:</para>
    127109
    128110<screen><userinput remap="test">make check</userinput></screen>
    129 <!--ln -sfv /tools/lib/lib{blk,uu}id.so.1 lib -->
    130 <!--make LD_LIBRARY_PATH=/tools/lib check</userinput></screen>-->
    131111
    132112    <para>One of the E2fsprogs tests will attempt to allocate 256 MB of memory.
  • chapter06/flex.xml

    r9d719e2 refcb393  
    5151    Now, prepare Flex for compilation:</para>
    5252
    53 <screen><userinput remap="configure">HELP2MAN=/tools/bin/true \
     53<screen><userinput remap="configure">HELP2MAN=/bin/true \
    5454./configure --prefix=/usr --docdir=/usr/share/doc/flex-&flex-version;</userinput></screen>
    5555
  • chapter06/gcc.xml

    r9d719e2 refcb393  
    5959    <para>Prepare GCC for compilation:</para>
    6060
    61 <screen><userinput remap="configure">SED=sed                               \
    62 ../configure --prefix=/usr            \
     61<screen><userinput remap="configure">../configure --prefix=/usr            \
     62             LD=ld                    \
    6363             --enable-languages=c,c++ \
    6464             --disable-multilib       \
     
    7272
    7373    <variablelist>
    74       <title>The meaning of the new configure parameters:</title>
    75 
    76       <varlistentry>
    77         <term><envar>SED=sed</envar></term>
    78         <listitem>
    79           <para>Setting this environment variable prevents a hard-coded
    80           path to /tools/bin/sed.</para>
    81         </listitem>
    82       </varlistentry>
    83       <!--
    84       <varlistentry>
    85         <term><parameter>- -disable-libmpx</parameter></term>
    86         <listitem>
    87           <para>This switch tells GCC to not build mpx (Memory Protection
    88           Extensions) that can cause problems on some processors. It has
    89           been removed from the next version of gcc.</para>
    90         </listitem>
    91       </varlistentry>
    92       -->
     74      <title>The meaning of the new configure parameter:</title>
     75
    9376      <varlistentry>
    9477        <term><parameter>--with-system-zlib</parameter></term>
     
    171154
    172155<screen><userinput remap="install">ln -sv ../usr/bin/cpp /lib</userinput></screen>
    173 
     156  <!-- already done earlier
    174157    <para>Many packages use the name <command>cc</command> to call the C
    175158    compiler. To satisfy those packages, create a symlink:</para>
    176159
    177160<screen><userinput remap="install">ln -sv gcc /usr/bin/cc</userinput></screen>
    178 
     161  -->
    179162    <para>Add a compatibility symlink to enable building programs with
    180163    Link Time Optimization (LTO):</para>
  • chapter06/glibc.xml

    r9d719e2 refcb393  
    4444    <title>Installation of Glibc</title>
    4545
    46     <note><para>The Glibc build system is self-contained and will install
    47     perfectly, even though the compiler specs file and linker are still
    48     pointing to <filename class="directory">/tools</filename>. The specs
    49     and linker cannot be adjusted before the Glibc install because the
    50     Glibc autoconf tests would give false results and defeat the goal
    51     of achieving a clean build.</para></note>
    52 
    5346    <para>Some of the Glibc programs use the non-FHS compliant
    5447    <filename class="directory">/var/db</filename> directory to store
     
    6760<screen><userinput remap="pre">sed -i '/asm.socket.h/a# include &lt;linux/sockios.h&gt;' \
    6861   sysdeps/unix/sysv/linux/bits/socket.h</userinput></screen>
    69 -->
     62=== already done ===
    7063    <para>Create a symlink for LSB
    7164    compliance. Additionally, for x86_64, create a compatibility symlink
     
    7972    ;;
    8073esac</userinput></screen>
    81 <!--
     74
    8275    <para>Remove a file that may be left over from a previous build attempt:
    8376    </para>
     
    9386    <para>Prepare Glibc for compilation:</para>
    9487
    95 <screen><userinput remap="configure">CC="gcc -ffile-prefix-map=/tools=/usr" \
    96 ../configure --prefix=/usr                          \
    97              --disable-werror                       \
    98              --enable-kernel=&min-kernel;                    \
    99              --enable-stack-protector=strong        \
    100              --with-headers=/usr/include            \
     88<screen><userinput remap="configure">../configure --prefix=/usr                            \
     89             --disable-werror                         \
     90             --enable-kernel=&min-kernel;                      \
     91             --enable-stack-protector=strong          \
     92             --with-headers=/usr/include              \
    10193             libc_cv_slibdir=/lib</userinput></screen>
    102 
    103    <variablelist>
     94  <!-- WIP -->
     95    <variablelist>
    10496      <title>The meaning of the options and new configure parameters:</title>
    10597
    10698      <varlistentry>
    107         <term><parameter>CC="gcc -ffile-prefix-map=/tools=/usr"</parameter></term>
    108         <listitem>
    109           <para>Make GCC record any references to files in /tools in result
    110           of the compilation as if the files resided in /usr.  This avoids
    111           introduction of invalid paths in debugging symbols.</para>
     99        <term><parameter>CC="gcc -ffile-prefix-map=$LFS_DIR=$DIR"</parameter></term>
     100        <listitem>
     101          <para>Make GCC record any references to files in <filename
     102          class="directory">/usr/lib/gcc/x86_64-lfs-linux-gnu</filename>
     103          in result of the compilation as if the files resided in <filename
     104          class="directory">/usr/lib/gcc/x86_64-pc-linux-gnu</filename>.
     105          This avoids introduction of invalid paths in debugging
     106          symbols.</para>
    112107        </listitem>
    113108      </varlistentry>
     
    129124        </listitem>
    130125      </varlistentry>
    131 
     126<!-- do we need this one? -->
    132127      <varlistentry>
    133128        <term><parameter>--with-headers=/usr/include</parameter></term>
    134129        <listitem>
    135130          <para>This option tells the build system where to find the
    136           kernel API headers. By default, those headers are sought in
    137           <filename class="directory">/tools/include</filename>.</para>
     131          kernel API headers.</para>
    138132        </listitem>
    139133      </varlistentry>
  • chapter06/introduction.xml

    r9d719e2 refcb393  
    3737  at the same time.</para>
    3838
    39   <para>The order that packages are installed in this chapter needs to be
    40   strictly followed to ensure that no program accidentally acquires a path
    41   referring to <filename class="directory">/tools</filename> hard-wired into
    42   it.  For the same reason, do not compile separate packages in parallel.
    43   Compiling in parallel may save time (especially on dual-CPU machines), but it
    44   could result in a program containing a hard-wired path to <filename
    45   class="directory">/tools</filename>, which will cause the program to stop
    46   working when that directory is removed.</para>
    47 
    4839  <para>Before the installation instructions, each installation page provides
    4940  information about the package, including a concise description of what it
  • chapter06/kbd.xml

    r9d719e2 refcb393  
    6161    <para>Prepare Kbd for compilation:</para>
    6262
    63 <screen><userinput remap="configure">PKG_CONFIG_PATH=/tools/lib/pkgconfig ./configure --prefix=/usr --disable-vlock</userinput></screen>
     63<screen><userinput remap="configure">./configure --prefix=/usr --disable-vlock</userinput></screen>
    6464
    6565    <variablelist>
    6666      <title>The meaning of the configure options:</title>
    67 <!--
    68       <varlistentry>
    69         <term><parameter>- -datadir=/lib/kbd</parameter></term>
    70         <listitem>
    71           <para>This option puts keyboard layout data in a directory that will
    72           always be on the root partition instead of the default <filename
    73           class="directory">/usr/share/kbd</filename>.</para>
    74        </listitem>
    75       </varlistentry>
    76 -->
     67
    7768      <varlistentry>
    7869        <term><parameter>--disable-vlock</parameter></term>
     
    10596    </note>
    10697
    107 <!--
    108     <para>Some of the scripts in the LFS-Bootscripts package depend on
    109     <command>kbd_mode</command>, <command>loadkeys</command>,
    110     <command>openvt</command>, and
    111     <command>setfont</command>.  As <filename class="directory">/usr</filename>
    112     may not be available during the early stages of booting, those binaries
    113     need to be on the root partition:</para>
    114 
    115 <screen><userinput remap="install">mv -v /usr/bin/{kbd_mode,loadkeys,openvt,setfont} /bin</userinput></screen>
    116 -->
    11798    <para>If desired, install the documentation:</para>
    11899
  • chapter06/libpipeline.xml

    r9d719e2 refcb393  
    4646<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
    4747
    48 <!--
    49 <screen><userinput remap="configure">PKG_CONFIG_PATH=/tools/lib/pkgconfig ./configure - -prefix=/usr</userinput></screen>
    50 
    51     <variablelist>
    52       <title>The meaning of the configure options:</title>
    53 
    54       <varlistentry>
    55         <term><parameter>PKG_CONFIG_PATH</parameter></term>
    56         <listitem>
    57           <para>Use pkg-config to obtain the location of the test
    58           library metadata built in <xref linkend="ch-system-check"/>.</para>
    59         </listitem>
    60       </varlistentry>
    61 
    62     </variablelist>
    63 -->
    6448    <para>Compile the package:</para>
    6549
  • chapter06/readline.xml

    r9d719e2 refcb393  
    7474    <para>Compile the package:</para>
    7575
    76 <screen><userinput remap="make">make SHLIB_LIBS="-L/tools/lib -lncursesw"</userinput></screen>
     76<screen><userinput remap="make">make SHLIB_LIBS="-lncursesw"</userinput></screen>
    7777
    7878    <variablelist>
     
    8080
    8181      <varlistentry>
    82         <term><parameter>SHLIB_LIBS="-L/tools/lib -lncursesw"</parameter></term>
     82        <term><parameter>SHLIB_LIBS="-lncursesw"</parameter></term>
    8383        <listitem>
    8484          <para>This option forces Readline to link against the
     
    9393    <para>Install the package:</para>
    9494
    95 <screen><userinput remap="install">make SHLIB_LIBS="-L/tools/lib -lncursesw" install</userinput></screen>
     95<screen><userinput remap="install">make SHLIB_LIBS="-lncursesw" install</userinput></screen>
    9696
    9797    <para>Now move the dynamic libraries to a more appropriate location
  • chapter06/revisedchroot.xml

    r9d719e2 refcb393  
    2727    /bin/bash --login</userinput></screen>
    2828
    29   <para>The reason for this is that the programs in <filename
    30   class="directory">/tools</filename> are no longer needed.  For this reason
    31   you can delete the <filename class="directory">/tools</filename>
    32   directory if so desired.</para>
    33 
    34   <note>
    35     <para>Removing <filename class="directory">/tools</filename> will also
    36     remove the temporary copies of Tcl, Expect, and DejaGNU which were used
    37     for running the toolchain tests. If you need these programs later on,
    38     they will need to be recompiled and re-installed. The BLFS book has
    39     instructions for this (see <ulink url="&blfs-root;"/>).</para>
    40   </note>
     29  <para>Here the <parameter>+h</parameter> option is not used anymore, since
     30  all the previous programs have been replaced: hashing is therefore
     31  possible.</para>
    4132
    4233  <para>If the virtual kernel file systems have been unmounted, either manually
  • chapter06/sed.xml

    r9d719e2 refcb393  
    4343    <para>First fix an issue in the LFS environment and remove a failing test:</para>
    4444
    45 <screen><userinput remap="pre">sed -i 's/usr/tools/'                 build-aux/help2man
    46 sed -i 's/testsuite.panic-tests.sh//' Makefile.in</userinput></screen>
     45<screen><userinput remap="pre">sed -i 's/testsuite.panic-tests.sh//' Makefile.in</userinput></screen>
    4746
    4847    <para>Prepare Sed for compilation:</para>
    4948
    5049<screen><userinput remap="configure">./configure --prefix=/usr --bindir=/bin</userinput></screen>
    51 <!--
    52     <variablelist>
    53       <title>The meaning of the new configure option:</title>
    5450
    55       <varlistentry>
    56         <term><parameter>-i -htmldir</parameter></term>
    57         <listitem>
    58           <para>This sets the installation directory for the HTML documentation.</para>
    59         </listitem>
    60       </varlistentry>
    61     </variablelist>
    62 -->
    6351    <para>Compile the package and generate the HTML documentation:</para>
    6452
  • chapter06/shadow.xml

    r9d719e2 refcb393  
    8585
    8686<screen><userinput remap="configure">touch /usr/bin/passwd
    87 ./configure --sysconfdir=/etc --with-group-name-max-length=32</userinput></screen>
     87./configure --sysconfdir=/etc               \
     88            --with-group-name-max-length=32</userinput></screen>
    8889
    8990    <variablelist>
  • chapter06/strippingagain.xml

    r9d719e2 refcb393  
    5757unset LIB save_lib save_usrlib</userinput></screen>
    5858
    59   <para>Before performing the stripping, take special care to ensure that
     59<!--  <para>Before performing the stripping, take special care to ensure that
    6060  none of the binaries that are about to be stripped are running:</para>
    6161
    6262<screen role="nodump"><userinput>exec /tools/bin/bash</userinput></screen>
    6363 
    64   <!--
    65   If
    66   unsure whether the user entered chroot with the command given in
    67   <xref linkend="ch-system-chroot" role=","/> first use the version
    68   of bash we created in
    69   chroot:</para>
     64  <para>Now the binaries and libraries can be safely stripped:</para>
     65-->
     66  <para>Now the binaries and libraries can be stripped:</para>
     67<screen><userinput>find /usr/lib -type f -name \*.a \
     68   -exec strip --strip-debug {} ';'
    7069
    71 <screen role="nodump"><userinput>logout</userinput></screen>
     70find /lib /usr/lib -type f -name \*.so* ! -name \*dbg \
     71   -exec strip --strip-unneeded {} ';'
    7272
    73   <para>Then reenter it with:</para>
    74 
    75 <screen role="nodump"><userinput>chroot $LFS /tools/bin/env -i          \
    76     HOME=/root TERM=$TERM              \
    77     PS1='(lfs chroot) \u:\w\$ '        \
    78     PATH=/bin:/usr/bin:/sbin:/usr/sbin \
    79     /tools/bin/bash - -login</userinput></screen>-->
    80 
    81   <para>Now the binaries and libraries can be safely stripped:</para>
    82 
    83 <screen><userinput>/tools/bin/find /usr/lib -type f -name \*.a \
    84    -exec /tools/bin/strip --strip-debug {} ';'
    85 
    86 /tools/bin/find /lib /usr/lib -type f \( -name \*.so* -a ! -name \*dbg \) \
    87    -exec /tools/bin/strip --strip-unneeded {} ';'
    88 
    89 /tools/bin/find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \
    90     -exec /tools/bin/strip --strip-all {} ';'</userinput></screen>
     73find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \
     74    -exec strip --strip-all {} ';'</userinput></screen>
    9175
    9276  <para>A large number of files will be reported as having their file
  • chapter06/systemd.xml

    r9d719e2 refcb393  
    4949    <para>Create a symlink to work around missing xsltproc:</para>
    5050
    51 <screen><userinput remap="pre">ln -sf /tools/bin/true /usr/bin/xsltproc</userinput></screen>
     51<screen><userinput remap="pre">ln -sf /bin/true /usr/bin/xsltproc</userinput></screen>
    5252
    5353    <para>Set up the man pages:</para>
     
    102102        <listitem>
    103103          <para>These switches provide location of binaries needed by
    104           systemd at runtime that have not yet been installed, or who's
    105           pkgconfig files are currently only in
    106           <filename>/tools/lib/pkgconfig</filename>.</para>
     104          systemd at runtime that have not yet been installed.</para>
    107105        </listitem>
    108106      </varlistentry>
  • chapter06/util-linux.xml

    r9d719e2 refcb393  
    5555  <sect2 role="installation">
    5656    <title>Installation of Util-linux</title>
    57 <!--
    58     <para>First, fix one of the regression tests:</para>
    59 
    60 <screen><userinput remap="pre">sed -e 's/2^64/(2^64/' -e 's/E &lt;/E) &lt;=/' -e 's/ne /eq /' \
    61     -i tests/ts/ipcs/limits2</userinput></screen>
    62 -->
    63 
    64     <para>Remove the earlier created symlinks and files:</para>
    65 
    66 <screen><userinput remap="pre">rm -vf /usr/include/{blkid,libfdisk,libmount,uuid}
    67 rm -vf /usr/lib/lib{blkid,fdisk,mount,uuid}.so*
    68 rm -vf /usr/lib/pkgconfig/{blkid,fdisk,mount,uuid}.pc</userinput></screen>
    6957
    7058    <para>Prepare Util-linux for compilation:</para>
  • chapter08/kernel.xml

    r9d719e2 refcb393  
    300300      <emphasis>always</emphasis> be the ones against which Glibc was compiled,
    301301      that is, the sanitised headers installed in <xref
    302       linkend="ch-system-linux-headers"/>.  Therefore, they should
     302      linkend="ch-tools-linux-headers"/>.  Therefore, they should
    303303      <emphasis>never</emphasis> be replaced by either the raw kernel headers
    304304      or any other kernel sanitized headers.</para>
Note: See TracChangeset for help on using the changeset viewer.