<?xml version="1.0" encoding="UTF-8"?>
<appendix id="HDRWQ163">
  <title>Appendix A. Building OpenAFS from Source Code</title>

  <para>This chapter describes how to build OpenAFS from source code. <indexterm>
      <primary>storing</primary>

      <secondary>OpenAFS source in volume</secondary>
    </indexterm> <indexterm>
      <primary>creating</primary>

      <secondary>volume</secondary>

      <tertiary>for OpenAFS source</tertiary>
    </indexterm> <indexterm>
      <primary>volume</primary>

      <secondary>for OpenAFS source</secondary>
    </indexterm> <indexterm>
      <primary>source (AFS)</primary>

      <secondary>storing in AFS volume</secondary>
    </indexterm> <indexterm>
      <primary>files</primary>

      <secondary>OpenAFS source</secondary>
    </indexterm></para>

  <sect1 id="HDRWQ164">
    <title>Loading the Source Files</title>

    <para>Working on an AFS client machine, login to AFS as a
    administrative user, then perform these steps to load the OpenAFS
    source tree from the OpenAFS Source Distribution.
    <orderedlist>
        <indexterm>
          <primary>commands</primary>

          <secondary>vos create</secondary>

          <tertiary>src.afs volume</tertiary>
        </indexterm>

        <indexterm>
          <primary>vos commands</primary>

          <secondary>create</secondary>

          <tertiary>src.afs volume</tertiary>
        </indexterm>

        <indexterm>
          <primary>src.afs volume</primary>
        </indexterm>

        <indexterm>
          <primary>volume</primary>

          <secondary>creating</secondary>

          <tertiary>src.afs</tertiary>
        </indexterm>

        <indexterm>
          <primary>creating</primary>

          <secondary>src.afs volume</secondary>
        </indexterm>

        <listitem>
          <para>Create and mount a volume for housing the OpenAFS source tree. These instructions name the volume <emphasis
          role="bold">src.afs</emphasis> and mount it at the <emphasis
          role="bold">/afs/</emphasis><replaceable>cellname</replaceable><emphasis role="bold">/afs/src</emphasis> directory.</para>

          <para>Setting the <emphasis role="bold">-maxquota</emphasis> argument to <emphasis role="bold">0</emphasis> (zero) sets an
          unlimited quota on the volume, which enables you to copy all of the files into the volume without exceeding its quota. If
          you wish, you can set the volume's quota to a finite value after you complete the copying operation. At that point, use
          the <emphasis role="bold">vos examine</emphasis> command to determine how much space the volume is occupying. Then issue
          the <emphasis role="bold">fs setquota</emphasis> command to set a quota that is slightly larger.</para>

          <programlisting>
   # <emphasis role="bold">vos create</emphasis> &lt;<replaceable>machine name</replaceable>&gt; &lt;<replaceable>partition name</replaceable>&gt; <emphasis
              role="bold">src.afs -maxquota 0</emphasis> 
   # <emphasis role="bold">cd /afs/.</emphasis><replaceable>cellname</replaceable>
   # <emphasis role="bold">mkdir afs</emphasis>
   # <emphasis role="bold">fs mkmount afs/src src.afs</emphasis>
   # <emphasis role="bold">vos release root.cell</emphasis>
   # <emphasis role="bold">fs checkvolumes</emphasis>
</programlisting>
        </listitem>

        <listitem>
          <para>Download the latest stable OpenAFS source distribution
          (openafs-src.<replaceable>X.Y.Z</replaceable>.tar.gz)
          from <ulink url="http://www.openafs.org/release/latest.html">openafs.org</ulink>
          to the local <emphasis role="bold">/tmp</emphasis> directory.
          <indexterm>
              <primary>downloading</primary>

              <secondary>source files from openafs.org</secondary>
            </indexterm>
            </para>
        </listitem>

        <listitem>
          <para>In the local <emphasis role="bold">/tmp</emphasis> directory, unpack the source archive. <programlisting>
   # <emphasis role="bold">cd /tmp</emphasis>
   # <emphasis role="bold">gzip -dc openafs-src-<replaceable>X.Y.Z</replaceable>.tar.gz | tar xvf -</emphasis>
</programlisting>
          <indexterm>
              <primary>unpacking</primary>

              <secondary>source files from the archive</secondary>
            </indexterm>
            </para>
        </listitem>

        <listitem>
          <para>Copy the source files from the unpacked archive into the newly created volume. <programlisting>
   # <emphasis role="bold">cd /tmp/openafs-<replaceable>X.Y.Z</replaceable></emphasis>
   # <emphasis role="bold">cp -rp  *  /afs/.</emphasis><replaceable>cellname</replaceable>/<emphasis role="bold">afs/src</emphasis>
</programlisting></para>
        </listitem>
      </orderedlist></para>

    <indexterm>
      <primary>source (AFS)</primary>

      <secondary>compiling</secondary>
    </indexterm>

    <indexterm>
      <primary>compiling AFS from source</primary>
    </indexterm>

    <indexterm>
      <primary>building</primary>

      <secondary>AFS from source</secondary>
    </indexterm>
  </sect1>

  <sect1 id="HDRWQ165">
    <title>Compiling OpenAFS Binaries Using Configure and Make</title>

    <para>The OpenAFS distribution uses the <emphasis role="bold">autoconf</emphasis> program and Makefiles for compiling the OpenAFS software.<orderedlist>
        <listitem>
          <para>Create a subdirectory under the <emphasis role="bold">/afs/.</emphasis><replaceable>cellname</replaceable><emphasis
          role="bold">/afs</emphasis> directory for each system type for which you will build AFS binaries. Creating and mounting a
          volume for each system type is recommended, but you can also simply use the <emphasis role="bold">mkdir</emphasis>
          command. If you create a new volume, grant it an unlimited quota to avoid running out of space during the build process.
          <programlisting>
   # <emphasis role="bold">cd /afs/.</emphasis><replaceable>cellname</replaceable><emphasis role="bold">/afs</emphasis>    
</programlisting></para>

          <para>If creating a new volume:</para>

          <programlisting>
   # <emphasis role="bold">vos create</emphasis> &lt;<replaceable>machine name</replaceable>&gt; &lt;<replaceable>partition name</replaceable>&gt; <replaceable>sysname</replaceable> <emphasis
              role="bold">-maxquota 0</emphasis>
   # <emphasis role="bold">fs mkmount</emphasis> <replaceable>sysname</replaceable> <replaceable>sysname</replaceable>    
</programlisting>

          <para>If not creating a new volume:</para>

          <programlisting>
   # <emphasis role="bold">mkdir</emphasis> <replaceable>sysname</replaceable>
</programlisting>
        </listitem>

        <listitem>
          <para>In the directory for each system type, create subdirectories called <emphasis role="bold">dest</emphasis>, <emphasis
          role="bold">dest/bin</emphasis>, and <emphasis role="bold">obj</emphasis>. If you plan to use the
          <emphasis>@sys</emphasis> variable in pathnames that refer to these directories, then you must use the conventional system
          names listed in the <emphasis>OpenAFS Release Notes</emphasis>. <programlisting>
   # <emphasis role="bold">cd</emphasis> <replaceable>sysname</replaceable>
   # <emphasis role="bold">mkdir dest</emphasis> 
   # <emphasis role="bold">mkdir dest/bin</emphasis> 
   # <emphasis role="bold">mkdir obj</emphasis>
</programlisting></para>
        </listitem>

        <listitem>
          <para>Create the indicated directories and symbolic links in the <emphasis
          role="bold">/afs/.</emphasis><replaceable>cellname</replaceable><emphasis role="bold">/afs</emphasis> directory.
          <programlisting>
   # <emphasis role="bold">cd /afs/.</emphasis><replaceable>cellname</replaceable><emphasis role="bold">/afs</emphasis>
   # <emphasis role="bold">ln -s  @sys/dest  dest</emphasis>
   # <emphasis role="bold">ln -s  @sys/obj  obj</emphasis>
   # <emphasis role="bold">ln -s  .  PARENT</emphasis>
   # <emphasis role="bold">ln -s  src/Makefile  Makefile</emphasis>   
</programlisting></para>

          <para>The following is an example directory listing for the <emphasis
          role="bold">/afs/.</emphasis><replaceable>cellname</replaceable><emphasis role="bold">/afs</emphasis> directory after
          completing the preceding steps. It includes two example system types.</para>

          <programlisting>
   lrwxr-xr-x admin   12 Jun 18 11:26 Makefile-&gt;src/Makefile
   lrwxr-xr-x admin    1 Jun 18 11:26 PARENT -&gt; .
   lrwxr-xr-x admin    9 Jun 18 11:25 dest -&gt; @sys/dest
   lrwxr-xr-x admin    8 Jun 18 11:25 obj -&gt; @sys/obj
   drwxrwxrwx admin 4096 Jun 18 11:24 rcs
   drwxrwxrwx admin 2048 Jun 18 11:27 rs_aix42
   drwxrwxrwx admin 2048 Jun 18 11:10 src
   drwxrwxrwx admin 2048 Jun 18 11:27 sun4x_56
</programlisting>
        </listitem>

        <listitem>
          <para><emphasis role="bold">(Optional)</emphasis> By default, the build procedure writes its results into a destination
          directory for each system type called <emphasis role="bold">/afs/.</emphasis><replaceable>cellname</replaceable><emphasis
          role="bold">/afs/</emphasis><replaceable>sysname</replaceable><emphasis role="bold">/dest</emphasis>. To write the results
          to a different destination directory, create a link from the <emphasis role="bold">dest</emphasis> directory to it.
          <programlisting>
   # <emphasis role="bold">cd /afs/.</emphasis><replaceable>cellname</replaceable><emphasis role="bold">/afs/</emphasis><replaceable>sysname</replaceable>
   # <emphasis role="bold">ln -s</emphasis> <replaceable>full_path_of_alternate_directory</replaceable> <emphasis role="bold">dest</emphasis>
</programlisting> <indexterm>
              <primary>commands</primary>

              <secondary></secondary>
            </indexterm></para>
        </listitem>
<!--
    % cd /afs/.rampaginggeek.com/src/afs/@sys
    % ../src/configure
    make
    make dest
    -->
        
        <listitem>
          <para>For each system type you plan to build, run the following commands on a machine of that system type:</para>
          <programlisting>
   # <emphasis role="bold">cd  /afs/</emphasis><replaceable>cellname</replaceable><emphasis role="bold">/</emphasis><replaceable>sysname</replaceable>
   # <emphasis role="bold">../src/configure</emphasis>
   # <emphasis role="bold">make</emphasis>
   # <emphasis role="bold">make dest</emphasis>
</programlisting>

          <indexterm>
            <primary>commands</primary>

            <secondary>make</secondary>
          </indexterm>

          <indexterm>
            <primary>configure command</primary>
          </indexterm>

          <indexterm>
            <primary>make command</primary>
          </indexterm>

          <indexterm>
            <primary>commands</primary>

            <secondary>configure</secondary>
          </indexterm>

        </listitem>

        <listitem>
          <para><anchor id="LIWQ166" />Working in the <emphasis
          role="bold">/afs/.</emphasis><replaceable>cellname</replaceable><emphasis role="bold">/afs</emphasis> directory on a
          machine of the system type for which you are building AFS, issue the <emphasis role="bold">make install</emphasis>
          command.</para>
        </listitem>
      </orderedlist></para>
  </sect1>
</appendix>
