<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../../general.ent">
  %general-entities;
]>

<sect1 id="ch-cross-tools-glibc" role="wrap">
  <?dbhtml filename="glibc.html"?>

  <title>Glibc-&glibc-version;</title>

  <indexterm zone="ch-cross-tools-glibc">
    <primary sortas="a-Glibc">Glibc</primary>
    <secondary>cross tools</secondary>
  </indexterm>

  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  href="../../final-system/common/glibc.xml"
  xpointer="xpointer(//*[@role='package'])"/>

  <sect2 role="installation">
    <title>Installation of Glibc</title>

    <para os="da">It should be noted that compiling Glibc in any way other than
    the method suggested in this book puts the stability of the system at
    risk.</para>

    <para os="db">Disable linking to <filename>libgcc_eh</filename>:</para>

<screen os="dc"><userinput>patch -Np1 -i ../&glibc-libgcc_eh-patch;</userinput></screen>

    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
    href="../../final-system/common/glibc.xml"
    xpointer="xpointer(//*[@os='c'])"/>

    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
    href="../../final-system/common/glibc.xml"
    xpointer="xpointer(//*[@os='d'])"/>

    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
    href="../../final-system/common/glibc.xml"
    xpointer="xpointer(//*[@os='s1'])"/>

    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
    href="../../final-system/common/glibc.xml"
    xpointer="xpointer(//*[@os='s2'])"/>

    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
    href="../../final-system/common/glibc.xml"
    xpointer="xpointer(//*[@os='e'])"/>

    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
    href="../../final-system/common/glibc.xml"
    xpointer="xpointer(//*[@os='f'])"/>

    <para os="dd">The following lines need to be added to
    <filename>config.cache</filename> for Glibc to support NPTL:</para>

<screen os="de"><userinput>echo "libc_cv_forced_unwind=yes" &gt; config.cache
echo "libc_cv_c_cleanup=yes" &gt;&gt; config.cache</userinput></screen>

    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
    href="../../final-system/common/glibc.xml"
    xpointer="xpointer(//*[@os='g'])"/>

<screen os="df"><userinput>BUILD_CC="gcc" CC="${CLFS_TARGET}-gcc" \
    AR="${CLFS_TARGET}-ar" RANLIB="${CLFS_TARGET}-ranlib" \
    ../glibc-&glibc-version;/configure --prefix=/tools \
    --host=${CLFS_TARGET} --build=${CLFS_HOST} \
    --disable-profile --enable-add-ons \
    --with-tls --enable-kernel=2.6.0 --with-__thread \
    --with-binutils=/cross-tools/bin --with-headers=/tools/include \
    --cache-file=config.cache</userinput></screen>

    <variablelist os="dg">
      <title>The meaning of the new configure options:</title>

      <varlistentry os="dg1">
        <term><parameter>BUILD_CC="gcc"</parameter></term>
        <listitem>
          <para>This sets Glibc to use the current compiler on our system. This is
          used to create the tools Glibc uses during its build.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="dg2">
        <term><parameter>CC="${CLFS_TARGET}-gcc"</parameter></term>
        <listitem>
          <para>This forces Glibc to use the GCC compiler that we made for our target
          architecture.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="dg3">
        <term><parameter>AR="${CLFS_TARGET}-ar"</parameter></term>
        <listitem>
          <para>This forces Glibc to use the <command>ar</command> utility
          we made for our target architecture.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="dg4">
        <term><parameter>RANLIB="${CLFS_TARGET}-ranlib"</parameter></term>
        <listitem>
          <para>This forces Glibc to use the <command>ranlib</command> utility
          we made for our target architecture.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="dg5">
        <term><parameter>--disable-profile</parameter></term>
        <listitem>
          <para>This builds the libraries without profiling information. 
	  Omit this option if profiling on the temporary tools is necessary.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="dg6">
        <term><parameter>--enable-add-ons</parameter></term>
        <listitem>
          <para>This tells Glibc to utilize all add-ons that are
          available.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="dg7">
        <term><parameter>--with-tls</parameter></term>
        <listitem>
          <para>This tells Glibc to use Thread Local Storage.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="dg8">
        <term><parameter>--with-__thread</parameter></term>
        <listitem>
          <para>This tells Glibc to use use the __thread for libc and
          libpthread builds.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="dg9">
        <term><parameter>--with-binutils=/cross-tools/bin</parameter></term>
        <listitem>
          <para>This tells Glibc to use the Binutils that are specific to
          our target architecture.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="dg10">
        <term><parameter>--cache-file=config.cache</parameter></term>
        <listitem>
          <para>This tells Glibc to utilize a premade cache file.</para>
        </listitem>
      </varlistentry>

    </variablelist>

    <para os="dh">During this stage the following warning might appear:</para>

<blockquote os="di"><screen><computeroutput>configure: WARNING:
*** These auxiliary programs are missing or
*** incompatible versions: msgfmt
*** some features will be disabled.
*** Check the INSTALL file for required versions.</computeroutput></screen></blockquote>

    <para os="dj">The missing or incompatible <command>msgfmt</command> program is
    generally harmless. This <command>msgfmt</command> program is part of the
    Gettext package which the host distribution should provide.</para>

    <para os="dk">Compile the package:</para>

<screen os="dl"><userinput>make</userinput></screen>

    <para os="dm">Install the package:</para>

<screen os="dn"><userinput>make install</userinput></screen>

  </sect2>

  <sect2 role="content">
    <title/>

    <para>Details on this package are located in <xref
    linkend="contents-glibc" role="."/></para>

  </sect2>

</sect1>
