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

<sect1 id="ch-bootable-kernel" role="wrap">
  <?dbhtml filename="kernel.html"?>

  <title>Linux-&linux-version;</title>

  <indexterm zone="ch-bootable-kernel">
    <primary sortas="a-Linux">Linux</primary>
  </indexterm>

  <sect2 role="package"><title/>
    <para>The Linux package contains the Linux kernel.</para>

  </sect2>

  <sect2 role="installation">
    <title>Installation of the kernel</title>

    <para os="a">Building the kernel involves a few steps&mdash;configuration,
    compilation, and installation. Read the <filename>README</filename>
    file in the kernel source tree for alternative methods to the way this
    book configures the kernel.</para>

    <para os="b">Prepare for compilation by running the following command:</para>

<screen os="c"><userinput>make mrproper</userinput></screen>

    <para os="d">This ensures that the kernel tree is absolutely clean. The
    kernel team recommends that this command be issued prior to each
    kernel compilation. Do not rely on the source tree being clean after
    un-tarring.</para>

    <para os="e">Configure the kernel via a menu-driven interface.  Be sure to
      enable DEVTMPFS so that <filename class="directory">/dev</filename> will
      be populated automatically.</para>

    <note os="f"><para>Since you are building for an embedded system make sure
        all key components are built into the kernel and not as modules. The key
        components are console/video, disk, and network. Without these built
        in, the system will not function properly. It is recommended to
        configure the kernel without modules in order to conserve disk space
        and to reduce the complexity of booting.</para></note>

<screen os="g"><userinput>make ARCH=${CLFS_ARCH} CROSS_COMPILE=${CLFS_TARGET}- menuconfig</userinput></screen>

<para os="h">Alternatively, the <command>make oldconfig</command> or
  <command>make <replaceable>${CLFS_TARGET}</replaceable>_defconfig</command>
    may be more appropriate in some situations. See the
    <filename>README</filename> file for more information.</para>

    <para os="i">If desired, skip kernel configuration by copying the kernel
    config file, <filename>.config</filename>, from an example system
    (assuming it is available) to the root directory of the unpacked kernel
    sources.</para>

  <note><para>If you are using the u-boot bootloader, creating a
      <filename>uImage</filename> type kernel is recommended.  Install the
      u-boot tools (not documented here) and append "uImage" when compiling the
      kernel.</para></note>
 
  <para os="j">Compile the configured kernel image and modules:</para>

<screen os="k"><userinput>make ARCH=${CLFS_ARCH} CROSS_COMPILE=${CLFS_TARGET}-</userinput></screen>

    <para os="l">If using kernel modules, an
      <filename>/etc/modprobe.conf</filename> file may be needed.  Information
      pertaining to modules and kernel configuration is located in the kernel
      documentation in the <filename class="directory">Documentation</filename>
      directory of the kernel sources tree. Also,
      <filename>modprobe.conf(5)</filename> may be of interest.</para>

  <para os="p">If building modules, install the modules:</para>

<screen os="q"><userinput>make ARCH=${CLFS_ARCH} CROSS_COMPILE=${CLFS_TARGET}- \
    INSTALL_MOD_PATH=${CLFS}/targetfs modules_install</userinput></screen>

    <para os="y">The kernel configuration file <filename>.config</filename>
    produced by the <command>make menuconfig</command> step above contains
    all the configuration selections for the kernel that was just compiled.
    It is a good idea to keep this file for future reference.</para>

  <para>The resulting kernel will be located within the <filename
      class="directory">arch/${CLFS_ARCH}/boot</filename>.  There may be more
    than one version of the same kernel, simply with different compression or
    bootloader helpers added.  Follow your bootloader's instructions on how to
    copy the kernel to the final system.</para>

  </sect2>

  <sect2 id="contents-kernel" role="content">
    <title>Contents of Linux</title>

    <segmentedlist>
      <segtitle>Installed files</segtitle>

      <seglistitem>
        <seg>.config, Image files, and System.map</seg>
      </seglistitem>
    </segmentedlist>

    <variablelist>
      <bridgehead renderas="sect3">Short Descriptions</bridgehead>
      <?dbfo list-presentation="list"?>
      <?dbhtml list-presentation="table"?>

      <varlistentry id="config">
        <term><filename>.config</filename></term>
        <listitem>
          <para>Contains all the configuration selections for the kernel</para>
        </listitem>
      </varlistentry>

      <varlistentry id="kernel">
        <term><filename>zImage, uImage, bzImage, vmlinux</filename></term>
        <listitem>
          <para>The compiled Linux kernel.</para>
        </listitem>
      </varlistentry>

      <varlistentry id="System.map">
        <term><filename>System.map</filename></term>
        <listitem>
          <para>A list of addresses and symbols; it maps the entry points
          and addresses of all the functions and data structures in the
          kernel.  Useful for debugging, sometimes.</para>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect2>

</sect1>
