Product SiteDocumentation Site

5.5. Installing Prerequisites

Every good INSTALL file tells you what the prerequisites are. If you find an INSTALL file that doesn't, offer to fix it.
Freeciv does, though. Right there in the table of contents:
0. Prerequisites:
1. Prerequisites for the clients:
     1a. Prerequisites for the Gtk+ client:
     1b. Prerequisites for the SDL client:
     1c. Prerequisites for the Xaw client:
There are two sets of requirements. One set of requirements is listed for general building with the following list:
Then another set of requirements is required for building the Freeciv clients, which can actually be compiled in different flavors, and each flavor has a different set of dependencies. You are just building the Gtk+ client, which means:
That's a lot of stuff. How do you get all that stuff?
This is where Linux distributions shine. All modern Linux distributions have package management programs that allow for easy location and installation of FOSS software. In this example case, presume the Fedora distribution, but Ubuntu uses similar commands and works in largely the same way.
First, make sure that you have a C compiler. In fact, use the compiler that Freeciv recommends in the INSTALL file: gcc.
[gregdek@ip-10-242-118-147 freeciv]$ rpm -q gcc
package gcc is not installed
Hm! You have your first problem.
RPM is a program that maintains a list of software packages installed on the system. With this command, you asked, "tell me if you have gcc installed". And RPM said "nope, sorry." Which means you turn to RPM's big brother, yum. (In the Ubuntu/Debian world, these commands would be dpkg and apt-get, respectively.)
Next you ask yum to install gcc:
[gregdek@ip-10-242-118-147 freeciv]$ yum install gcc
Loaded plugins: fastestmirror
You need to be root to perform this command.
Oh, right. If you're going to work with Linux, you need to know when you need to be regular user, and when you need to be root. When you're adding new software to the system, to be accessed by other programs and potentially other users, you need to be root. (You can also use the su -c command, which allows you to masquerade as root.)
[root@ip-10-242-118-147 ~]# yum install gcc
Loaded plugins: fastestmirror
Determining fastest mirrors
 * updates-newkey: kdeforge.unl.edu
 * fedora: kdeforge.unl.edu
 * updates: kdeforge.unl.edu
updates-newkey                                           | 2.3 kB     00:00     
fedora                                                   | 2.1 kB     00:00     
updates                                                  | 2.6 kB     00:00     
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package gcc.i386 0:4.1.2-33 set to be updated
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
--> Running transaction check
---> Package glibc-devel.i386 0:2.7-2 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch           Version            Repository        Size
================================================================================
Installing:
 gcc                   i386           4.1.2-33           fedora           5.2 M
Installing for dependencies:
 glibc-devel           i386           2.7-2              fedora           2.0 M

Transaction Summary
================================================================================
Install      2 Package(s)         
Update       0 Package(s)         
Remove       0 Package(s)         

Total download size: 7.2 M
Is this ok [y/N]:
Lots of interesting information here! And you already start to see how software fits together. The programs yum and rpm work together to make sure that when you choose to install gcc, you also get everything that gcc needs to be useful -- in this case, the header and object files necessary for developing programs that use the standard C libraries. You asked for one software package, but now you get two.
Answer yes:
Is this ok [y/N]: y
Downloading Packages:
(1/2): glibc-devel-2.7-2.i386.rpm                        | 2.0 MB     00:00     
(2/2): gcc-4.1.2-33.i386.rpm                             | 5.2 MB     00:00     
--------------------------------------------------------------------------------
Total                                           6.4 MB/s | 7.2 MB     00:01     
============================== Entering rpm code ===============================
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : glibc-devel                                              1/2 
  Installing     : gcc                                                      2/2 
=============================== Leaving rpm code ===============================

Installed:
  gcc.i386 0:4.1.2-33                                                           

Dependency Installed:
  glibc-devel.i386 0:2.7-2                                                      

Complete!
All right, that's one dependency down. Which also means that you can build anything that needs GCC in the future, so that's useful.
Now you need a make program. They recommend gmake, so see if it's installed.
[root@ip-10-242-118-147 ~]# rpm -q gmake
package gmake is not installed
All right, install it.
[root@ip-10-242-118-147 ~]# yum install gmake
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * updates-newkey: kdeforge.unl.edu
 * fedora: kdeforge.unl.edu
 * updates: kdeforge.unl.edu
Setting up Install Process
Parsing package install arguments
No package gmake available.
Nothing to do
Wait, what's this? It appears that gmake isn't installed, and isn't available? What's going on?
Well, upon reading the INSTALL instructions more closely, there is this nugget:
   You can check if you have GNU make installed on your system by
   typing:

    % make -v                   [and if this doesn't work, try "gmake -v"]

   The output should include "GNU Make" somewhere.
Get in the habit of reading instructions.
[root@ip-10-242-118-147 ~]# make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-redhat-linux-gnu
All right, you've got make. How about GNU gettext?
[root@ip-10-242-118-147 ~]# rpm -q gettext
gettext-0.16.1-12.fc8
Very good. Autoconf?
[root@ip-10-242-118-147 ~]# rpm -q autoconf
package autoconf is not installed
[root@ip-10-242-118-147 ~]# yum install -y autoconf

(snip lots of yum output)

Installed:
  autoconf.noarch 0:2.61-9.fc8

Dependency Installed:
  imake.i386 0:1.0.2-5.fc8

Complete!
All set. Automake?
[root@ip-10-242-118-147 ~]# yum install -y automake

(snip lots of yum output)

Installed:
  automake.noarch 0:1.10-6

Complete!
Note that this time you didn't even bother to see if the RPM was installed first; you just installed it, because if automake had already been installed, yum would have let us know:
[root@ip-10-242-118-147 ~]# yum install -y automake
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * updates-newkey: kdeforge.unl.edu
 * fedora: kdeforge.unl.edu
 * updates: kdeforge.unl.edu
Setting up Install Process
Parsing package install arguments
Package automake-1.10-6.noarch already installed and latest version
Nothing to do
That's half of the prerequisites. Time for the other half.
[root@ip-10-242-118-147 ~]# yum install pkg-config
(snip)
No package pkg-config available.
Nothing to do

[root@ip-10-242-118-147 ~]# yum install pkgconfig
(snip)
Package 1:pkgconfig-0.22-4.fc8.i386 already installed and latest version
Nothing to do
Okay, so you've got pkg-config installed, even though they seem to be calling it pkgconfig for some reason, which was discovered through a lucky guess -- noting that in the INSTALL file, even though they call it pkg-config, the file in question is called pkgconfig-0.14.0.tar.gz. These kinds of little inconsistencies are maddening, and you will find them everywhere in your software life, so get used to them.
Now for Glib:
[root@ip-10-242-118-147 ~]# yum install Glib
(snip)
No package Glib available.
  * Maybe you meant: glib
Nothing to do
Oh, maybe you did mean glib. Thanks!
[root@ip-10-242-118-147 ~]# yum install glib
(snip)
Installed:
  glib.i386 1:1.2.10-28.fc8  

Complete!
This is kind of slow, isn't it? Can you specify multiple packages to be installed at once? Indeed you can.
[root@ip-10-242-118-147 ~]# yum install atk pango gtk+
(snip)
Package atk-1.20.0-1.fc8.i386 already installed and latest version
(snip)
Installed:
  gtk+.i386 1:1.2.10-59.fc8              pango.i386 0:1.18.4-1.fc8             

Dependency Installed:
  cairo.i386 0:1.4.14-1.fc8                   libX11.i386 0:1.1.3-4.fc8         
  libXext.i386 0:1.0.1-4.fc8                  libXft.i386 0:2.1.12-3.fc8        
  libXi.i386 0:1.1.3-1.fc8                    libXrender.i386 0:0.9.4-1.fc8     
  xorg-x11-filesystem.noarch 0:7.1-2.fc6     

Complete!
Whew. At long last, you're done.
Or so it would appear -- but appearances can be deceiving.