<sect1 id="compiling">
 <title>Compilation issues</title>

 <para>
   You really shouldn't need this section, because ideally you should
   be able to get everything in tidy packages for your system. There are
   always some who want to do it themselves, though. This is a representative
   list of the questions that come up the most commonly.
 </para>

 <qandaset defaultlabel="qanda">

  <qandaentry id="compile-order"> 
   <question>
    <para>
      In what order do I compile the packages?
    </para>
   </question>
   <answer>
    <para>
      This order has been reported to work well:
    </para>
    <procedure>
     <title>Compilation order for GNOME</title>
     <step>
      <para>
        Compile <application>glib</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>gtk+</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>imlib</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>ORBit</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>audiofile</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>esound</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>libxml</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>gnome-libs</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>gdk-pixbuf</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>libghttp</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>libglade</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>libgtop</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>gnome-print</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>control-center</application>.
      </para>
     </step>
     <step>
      <para>
        Compile <application>gnome-core</application>.
      </para>
     </step>
    </procedure>
    <para>
      After this, the order is less important. You should be able to 
      compile the remaining GNOME applications in any order.
     <note>
      <title>Extras for Nautilus and Evolution</title>
      <para>
        If you want to experiment with <application>Evolution</application> 
        and/or <application>Nautilus</application>, two applications which 
        are not yet part of the standard GNOME distribution, you will need
        to download and compile
        <application>gconf</application>, <application>oaf</application>,
        <application>popt</application> and <application>bonobo</application>
        as well. All of these will eventually be part of GNOME, but they are
        not part of it yet.
      </para>
     </note>
    </para>
   </answer>
  </qandaentry>

  <qandaentry id="compile-howto">
   <question>
    <para>
      That's all very well but how do I compile a tarball?
    </para>
   </question>
   <answer>
    <para>
      If you have an rpm-based system, skip this question and go to
      the section about generating rpms from tarballs. It saves a lot
      of trouble to do with putting files into the right places for your
      system. If not, the standard way to compile gnome tarballs 
      is to issue the following commands as a normal user:
    </para>
    <procedure>
     <title>Compiling tarballs</title>
     <step>
      <para>
        Unpack the tarball and <command>cd</command> into the top of the
        tarball directory.
      </para>
     </step>
     <step>
      <para>
        <command>./configure</command>
      </para>
     </step>
     <step>
      <para>
        <command>make</command>
      </para>
     </step>
     <step>
      <para>
        This is a good time to test the program to check it's working before
        doing the next stage. 
      </para>
     </step>
     <step>
      <para>
        <command>su</command> 
      </para>
     </step>
     <step>
      <para>
        <command>make install</command>      
       </para>
     </step>
     <step performance="optional">
      <para>
        If you want to be able to remove the program neatly later, do
        not delete all the files in that directory. This will allow you
        to do <command>make uninstall</command> at a later date. See
        <link linkend="uninstalling">the question about uninstalling</link>
        for details.
      </para>
     </step>
    </procedure>

    <para>    
      That will put your tarball into 
      <filename class="directory">/usr/local/</filename>, which is
      where programs you compile locally should go. If you want it
      somewhere different, then you should either get the 
      package in the same format that the rest of your package
      management system uses, so that it can go with the rest; or 
      you need to pass the <command>./configure</command> some extra 
      arguments telling it where it should go. These arguments are 
      generally
      <option>--prefix</option> and <option>--sysconfdir</option>.
      Some people also advocate 
      <option>--localstatedir</option> and <option>--datadir</option>.
      
     <note>
      <title>Just so you know in advance</title>
      <para>
        Please re-read the first sentence of the previous paragraph.
        Programs you compile locally <emphasis>should</emphasis> go
        in <filename class="directory">/usr/local/</filename>. Mixing
        binaries provided by a package management system (rpm, dpkg)
        with binaries from locally-compiled source into the same
        directory such as <filename class="directory">/usr/</filename>
        is not universally recommended.
      </para>
     </note>
    </para>
   </answer>
  </qandaentry>

  <qandaentry id="compile-prefixes">
   <question> 
    <para>                        
      My system has GNOME in one part of the filesystem. How do I make
      sure my newly-compiled packages end up in the same place?
    </para>   
   </question>
   <answer>   
    <para>      
      By default, tarballs you build and compile yourself will be placed
      in <filename class="directory">/usr/local</filename>. This is not
      always where you want them, because then if you use package management
      then later RPMs or debs may not see the programs in 
      <filename class="directory">/usr/local/</filename>. 
    </para> 
    <para>
      There is a very strong school of thought which says that you
      should not be muddling up packages installed from different
      methods into the same directories because it will confuse things
      badly. If you use rpms you can create rpms from tarballs of
      most GNOME packages as 
      <link linkend="tarball-to-rpm">described below</link>.
    </para>
    <para>
      That said, different distributions use different combinations of
      prefixes. The way to find out what <application>GNOME</application>
      is expecting on your machine is to type
      <command>gnome-config --prefix</command> and 
      <command>gnome-config --sysconfdir</command>. You can then use
      the results when you do <command>./configure</command> by giving
      it arguments: for example,
      <command>./configure --prefix=/usr --sysconfdir=/etc</command>. You
      can even show off by making use of backticks and doing
      <command>./configure --prefix=`gnome-config --prefix` --sysconfdir `gnome-config --sysconfdir`</command>
      all in one line. You can get a complete list of all the arguments
      you can give to configure by typing <command>./configure --help</command>.
    </para>
    <para>
      If you must do this, these are the combinations you are
      probably looking for:
    </para>
    <table>
     <title>Prefixes for different platforms</title>

     <tgroup cols=4 align=left>
      <thead>
       <row>
        <entry>OS</entry>
        <entry>--prefix</entry>
        <entry>--sysconfdir</entry>
        <entry>Notes</entry>
       </row>
      </thead>

      <tbody>
       <row>
        <entry>Red Hat Linux</entry>
        <entry>/usr</entry>
        <entry>/etc</entry>
        <entry></entry>
       </row>

       <row>
        <entry>Debian GNU/Linux</entry>
        <entry>/usr</entry>
        <entry>/etc</entry>
        <entry></entry>
       </row>

       <row>
        <entry>Caldera OpenLinux</entry>
        <entry>/opt/gnome</entry>
        <entry>/etc/opt/gnome</entry>
        <entry>Helix GNOME uses /opt/gnome/etc for sysconfdir</entry>
       </row>

       <row>
        <entry>SuSE Linux</entry>
        <entry>/opt/gnome</entry>
        <entry>/etc/opt/gnome</entry>
        <entry></entry>
       </row>

       <row>
        <entry>Linux Mandrake</entry>
        <entry>/usr</entry>
        <entry>/etc</entry>
        <entry></entry>
       </row>

       <row>
        <entry>Solaris</entry>
        <entry>/opt/gnome</entry>
        <entry></entry>
        <entry>Helix GNOME uses /opt/gnome/etc for sysconfdir</entry>
       </row>
      </tbody>
     </tgroup>
    </table>
   </answer>  
  </qandaentry>

  <qandaentry id="double-gnome">
   <question>
    <para>
      I have a perfectly fine GNOME installation, but I want to try some of
      the newer packages without blowing away my working set-up. Can I
      compile a newer set of GNOME packages into a particular area? How do I
      do this?
    </para>
   </question>
   <answer>
    <para>
      Yes, you can. The most sensible approach is to compile it yourself
      into an area in your own home directory. Doing this as your normal
      user rather than root means that you're not going to overwrite
      working system binaries. 
      <!-- Thanks to Eric Baudais for the instructions -->
    </para>
    <procedure>
     <title>Installing GNOME into your home directory</title>
     <step>
      <para>
        <command>cd</command> (go to home directory)
      </para>
     </step>
     <step>
      <para>
        <command>tar xvfz gnome-package.tar.gz</command> (unpack a package)
      </para>
     </step>
     <step>
      <para>
        <command>cd gnome-package</command> (into that directory)
      </para>
     </step>
     <step>
      <para>
        <command>./configure --prefix=~/gnome --sysconfdir=~/gnome/etc</command>
        (note the <keycap>~</keycap> sign in each prefix. Don't miss this out!)
      </para>
     </step>
     <step>
      <para>
        <command>make</command> (compile it. This is the longest stage)
      </para>
     </step>
     <step>
      <para>
        <command>make install</command> (put it where the next programs will
        see it)
      </para>
     </step>
     <step>
      <para>
        <command>cd ~/gnome/bin</command> (this is where it should have ended
        up)
      </para>
     </step>
     <step>
      <para>
        <command>./gnome-app</command> (try it out)
      </para>
     </step>
    </procedure>
    <para>
       The above will work for most things but you may have problems 
       with applets, which expect to see a file called
       <filename>/etc/CORBA/servers</filename>. You can probably create a
       symlink from your home directory to this, but your writer 
       hasn't tried.
    </para>
   </answer>
  </qandaentry>

  <qandaentry id="tarball-to-rpm">
   <question>
    <para>
      My system is RPM-based. What do I do with tarballs?
    </para>
   </question>
   <answer>
    <para>
      You can create an RPM from a tarball if the tarball contains a
      valid specfile. Many GNOME packages do. As root, run
      <command>rpm -tb &lt;tarballname&gt;</command> to create a 
      binary rpm, or <command>rpm -ta &lt;tarballname&gt;</command>
      to create both a binary and a source rpm.
    </para>
    <para>
      If there is no specfile in the tarball, it is not unknown for people 
      to post their homemade specfiles to the
      <ulink type="http" url="http://mail.gnome.org/mailman/listinfo/gnome-list/">
      gnome-list mailing list</ulink> or to
      <ulink type="http" url="http://news.gnome.org/gnome-news/">Gnotices</ulink>.
      You can take a separate specfile and do one of two things with it:
    </para>
    <para>
      Option one: as root, place the tarball of package foo in the SOURCES 
      directory and the specfile in the SPECS directory of
      <filename class="directory">/usr/src/redhat/</filename>,
      change to the SPECS directory, and run
      <command>rpm -ba foo.spec</command>. You may need to replace
      <filename class="directory">redhat</filename> with the appropriate
      directory name for your distribution. This will be whatever sub-directory
      there is <emphasis>besides</emphasis> the one called 
      <filename class="directory">linux</filename>.
    </para>
    <para>
      Option two: untar your tarball with <command>tar xvfz foo.tar.gz</command>,
      place the specfile into the resulting directory, and retar it up with
      <command>tar cvfz foo.tar.gz foo/*</command>. Then become root, and
      run <command>rpm -ta</command> on the resulting new tarball.
    </para>
   </answer>
  </qandaentry>

  <qandaentry id="rh-locale-fix">
   <question>
    <para>
      I have problems building RPMs from tarballs because it can't
      find locales correctly.
    </para>
   </question>
   <answer>
    <para>
      Run this command before building the rpm: 
      <command>unset LINGUAS</command>. It should work now. You may
      want to add this to the %build section of the specfile instead.
      Some people have suggested that you may wish to unset
      <envar>LANGUAGE</envar>, <envar>LANG</envar> and <envar>LC_ALL</envar>
      as well.
      <!-- FIXME: Are unset LANGUAGE, LC_ALL and LANG actually necessary? -->
    </para>
   </answer>
  </qandaentry>

  <qandaentry id="db2html">
   <question>
    <para>
      I need <quote>db2html</quote> to build some of the help files.
      What is it and where can I get it?
    </para>
   </question>
   <answer>
    <para>
      <application>db2html</application> is a script which invokes 
      <application>jade</application> or <application>openjade</application>.
      The packaging of the DocBook tools varies with OS and distribution.
      On Red Hat and some other distributions, it is found in the
      <application>stylesheets</application> package. On other systems,
      it may be part of a different DocBook-related package. The current
      collection of packages is sgml-common, docbook, jade (or openjade)
      and stylesheets (or cygnus-stylesheets). If you want to produce
      PostScript documentation you will also want the jadetex package.
      A new set of tools called docbook-utils is also in creation. The
      canonical source for DocBook tools is the Cygnus 
      <ulink type="http"
      url="http://sources.redhat.com/docbook-tools/">docbook tools
      website</ulink> and associated
      <ulink type="ftp"
      url="ftp://sourceware.cygnus.com/pub/docbook-tools/">ftp archive</ulink>,
      both of which are now hosted by Red Hat; but the tools are increasingly 
      being provided by the major Linux and BSD distributions. Check your 
      vendor's FTP site. GNOME uses  DocBook a lot for documentation and 
      you can find lots of information about it on the 
      <ulink type="http" url="http://developer.gnome.org/projects/gdp/">Gnome
      Documentation Project</ulink> pages. 
    </para>
   </answer>
  </qandaentry>

  <qandaentry id="gnome-stylesheets">
   <question>
    <para>
      I have DocBook correctly installed but when I build a package I
      get errors as the documentation sections get built. 
    </para>
   </question>

   <answer>
    <para>
      GNOME has an extra stylesheet and a DTD which it uses for documents 
      which use graphics. These enable us to use PNG graphics instead of
      GIFs. In big package releases, the maintainers will make sure the
      docs are already built. In some tarballs, though, this doesn't always
      happen. These are generally the tarballs which aren't meant for
      stable <quote>production</quote> release where it's expected the
      people playing with them will know what is going on with this
      message. If you meet it, you have a couple of choices:
    </para>
    <itemizedlist>
     <listitem>
      <para>
        After <command>./configure</command> and before <command>make</command>,
        edit the file <filename>Makefile.am</filename> and remove 
        "docs" from the line beginning "SUBDIRS". This will mean the docs
        just won't get built.
      </para>
     </listitem>
     <listitem>
      <para>
        Change the DTD (the line in angle-brackets). Alter
        <replaceable>"-//GNOME//DTD DocBook PNG Variant V1.1//EN"</replaceable>
        to read <replaceable>"-//OASIS//DTD DocBook V3.1//EN"</replaceable>
        in all files that have the suffix <quote>.sgml</quote>.
        If you want to, remove all the sections which appear to look like
        graphics (easily identified by being surrounded by the
        <sgmltag>&lt;figure&gt;</sgmltag> and
        <sgmltag>&lt;/figure&gt;</sgmltag> tags. This will build the docs
        without the graphics (or with broken links if you leave them in).
      </para>
     </listitem>
     <listitem>
      <para>
        Get the GNOME DTD and stylesheets and install them. They are
        available as a tarball, a deb or an rpm, or the individual components
        from
        <ulink type="http" url="http://people.redhat.com/dcm/software.html">Dave
        Mason's page</ulink>. Then it should build.
      </para>
     </listitem>
    </itemizedlist>
   </answer>
  </qandaentry>

  <qandaentry id="package-devel">
   <question>
    <para>
      I have installed all the base packages from the ftp site, but when 
      I start to compile something else, I am told I am missing a headerfile 
      with a message like this: <quote>Cannot find gnome-libs</quote> or 
      <quote>somefile.h: not found</quote>. 
    </para>
   </question>
   <answer>
    <para>
      This affects people who install binary rpms or debs. It does not
      affect people using tarballs, source rpms or debs with the source.
    </para>
    <para>
      Binary packages come in two sorts. There are the ones which come
      with names of the form &lt;package&gt;.suffix, and there are the
      ones with the form &lt;package-dev&gt;.suffix or 
      &lt;package-devel&gt;.suffix. (SuSE, using eight-letter package
      names, often abbreviates them further to such forms as 
      &lt;pkgdev&gt;.suffix or even &lt;pkgd&gt;.suffix.) The first sort 
      are what you need to run the programs in the package and are generally 
      called the <quote>base</quote> packages on ftp sites. The second sort 
      are what you need in addition if you want to compile and install new 
      programs that rely on other programs' code. They contain header files 
      which the new programs you want to compile will look for. If you expect 
      to be compiling the occasional tarball (or generating rpms from 
      tarballs), collect gnome-core-devel, gnome-libs-devel and so on 
      binaries and install them in addition to the base packages.
    </para>
   </answer>
  </qandaentry>

  <qandaentry id="berkeley-db-compat">
   <question>
   <!-- This Q and parts of A courtesy of Sven Wallman -->
    <para>
      gnome-libs won't compile on <systemitem class="osname">Solaris 
      2.6</systemitem>. It fails with a complaint about 
      <errorname>Berkeley DB lacking DB 1.85 compatibility</errorname>.
    </para>
   </question>
   <answer>
    <para>
      <application>Berkeley DB</application> versions later than 2.7.7
      (3 and up, basically) apparently break compatability with v1.85.
      Either get 2.7.7 or have a look at the patch to 
      <filename class="headerfile">db_185.h</filename> which is found on 
      <ulink type="http" 
      url="http://www.stahl.bau.tu-bs.de/~hildeb/postfix/docs/faq.html#db">
      the postfix FAQ</ulink>. You will still need to tinker with
      configuration scripts after applying this patch, though. 
    </para>
    <para>
      Also check out Paul Barnfeather's <ulink type="http"
      url="http://www.clanger9.demon.co.uk/computer/gnome/">Building GNOME
      on Solaris</ulink> page for more Solaris hints.
    </para>
   </answer>
  </qandaentry> 

  <qandaentry id="uninstalling">
   <question> 
    <para>                        
      How do I uninstall something I installed?
    </para>   
   </question>
   <answer>   
    <para>      
      With rpm: <command>rpm --erase package</command>.
    </para> 
    <para>
      With dpkg: either
    </para>
    <itemizedlist>
     <listitem>
      <para>
        <command>dpkg --remove package</command>
      </para>
     </listitem>
     <listitem>
      <para>
        <command>apt-get remove package</command>
      </para>
     </listitem>
    </itemizedlist>
    <para>
      Or
    </para>
    <itemizedlist>
     <listitem>
      <para>
        <command>dpkg --purge package</command>
      </para>
     </listitem>
     <listitem>
      <para>
        <command>apt-get remove --purge package</command>
      </para>
     </listitem>
    </itemizedlist>
    <para>
      You should probably use <command>apt-get</command> because it will
      automatically figure out dependencies. The <option>--purge</option>
      for each command will remove configuration files as well.
    </para>
    <para>
      With tarballs: you must previously have kept the source tree.
      Change to the directory containing it, run 
      <command>make uninstall</command> and hope someone wrote the
      rule which will do this for you.
    </para>
   </answer>  
  </qandaentry>
 </qandaset>
</sect1>
