<?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-headers" role="wrap">
  <?dbhtml filename="glibc-headers.html"?>

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

  <indexterm zone="ch-cross-tools-glibc-headers">
    <primary sortas="a-Glibc">Glibc</primary>
    <secondary>cross tools, headers</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 Headers</title>

    <para os="s1">The following sed removes a dependency of gcc 3.4.x from
    the glibc used in cross-lfs. The reason it is changed is
    because only the headers are being installed now; no compiling takes place.
    In the next glibc build, the gcc that's built right after this section will be used.</para>

<screen os="s2"><userinput>cp -v configure{,.orig}
sed -e 's/3.4/3.[0-9]/g' configure.orig > configure</userinput></screen>

    <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'])"/>

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

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

    <para os="df">Glibc has an issue cross-compiling the headers, where it can
    misdetect the capabilities of Binutils and decide they are inadequate.  The
    following line fixes this:</para>

<screen os="dg"><userinput>echo "libc_cv_initfini_array=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="s3"><userinput>CC=gcc ../glibc-&glibc-version;/configure --prefix=/tools \
    --host=${LFS_TARGET} --build=${LFS_HOST} \
    --disable-sanity-checks --enable-kernel=2.6.0 \
    --with-headers=/tools/include --cache-file=config.cache \
    --with-binutils=/cross-tools/${LFS_TARGET}/bin</userinput></screen>

   <note os="e1">
      <para><emphasis>Any</emphasis> error message you see about nptl at this
      point can safely be ignored.</para>
   </note>

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

      <varlistentry os="ca1">
        <term><parameter>CC=gcc</parameter></term>
        <listitem>
          <para>Tells Glibc to use the host's GCC compiler.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="ca2">
        <term><parameter>--build=${LFS_HOST}</parameter></term>
        <listitem>
          <para>When used with --host, this creates a cross-architecture
          executable that creates files for ${LFS_TARGET} but runs on ${LFS_HOST).</para>
        </listitem>
      </varlistentry>

      <varlistentry os="ca3">
        <term><parameter>--host=${LFS_TARGET}</parameter></term>
        <listitem>
          <para>When used with --build, this creates a cross-architecture
          executable that creates files for ${LFS_TARGET} but runs on ${LFS_HOST).</para>
        </listitem>
      </varlistentry>

      <varlistentry os="ca4">
        <term><parameter>--disable-sanity-checks</parameter></term>
        <listitem>
          <para>This switch disables any checks that are in place.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="ca5">
        <term><parameter>--enable-kernel=2.6.0</parameter></term>
        <listitem>
          <para>This tells Glibc to compile the library with support
          for 2.6.x Linux kernels.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="ca6">
        <term><parameter>--with-headers=/tools/include</parameter></term>
        <listitem>
          <para>This tells Glibc to compile itself against the headers
          recently installed to the <filename class="directory">/tools</filename>
          directory, so that it knows exactly what features the kernel has
          and can optimize itself accordingly.</para>
        </listitem>
      </varlistentry>

      <varlistentry os="ca7">
        <term><parameter>--with-binutils=/cross-tools/${LFS_TARGET}/bin</parameter></term>
        <listitem>
          <para>This tells Glibc to use the binutils for the specific target architecture.</para>
        </listitem>
      </varlistentry>

    </variablelist>

    <para os="cb">Now, install the headers:</para>

<screen os="cd"><userinput>make install-headers</userinput></screen>

    <para os="ce">Some files aren't installed by the above command, so copy the additional header files that are needed:</para>

    <para os="cf">First copy a common file over to <filename
    class="directory">/tools/include</filename>:</para>

<screen os="cg"><userinput>cp -v bits/stdio_lim.h /tools/include/bits</userinput></screen>

    <para os="ch">Now create a blank stub file:</para>

<screen os="ci"><userinput>touch /tools/include/gnu/stubs.h</userinput></screen>

    <para os="cj">For NPTL use the following command:</para>

<screen os="ck"><userinput>cp -v \
../glibc-&glibc-version;/nptl/sysdeps/pthread/pthread.h \
/tools/include</userinput></screen>

    <para os="cl">Now copy the architecture specific header over:</para>

<screen os="cm"><userinput>cp -v \
../glibc-&glibc-version;/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h \
/tools/include/bits</userinput></screen>

  </sect2>

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

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

  </sect2>

</sect1>
