Chapter 15. Building and installing free software

Table of Contents
15.1. Introduction
15.1.1. Requirements
15.1.2. Compilation
15.1.3. Structure of a distribution
15.2. Decompression
15.2.1. tar.gz archive
15.2.2. The use of GNU Tar
15.2.3. bzip2
15.2.4. Just do it!
15.3. Configuration
15.3.1. Autoconf
15.3.2. Imake
15.3.3. Various shell scripts
15.3.4. Alternatives
15.4. Compilation
15.4.1. make
15.4.2. Rules
15.4.3. Go, go, go!
15.4.4. Explanations
15.4.5. What if... it does not work?
15.5. Installation
15.5.1. With make
15.5.2. Problems
15.6. Support
15.6.1. Documentation
15.6.2. Technical support
15.6.3. How to find free software
15.7. Acknowledgments

I am often asked how to install free software from sources. Compiling software yourself is really easy because most of the steps to follow are the same no matter what the software to install is. The aim of this document is to guide the beginner step by step and explain to him the meaning of each move. I assume that the reader has a minimal knowledge of Unix (ls or mkdir for instance).

This guide is only a guide, not a reference manual. That is why several links are given at the end to answer the remaining questions. This guide can probably be improved, so I appreciate receiving any remarks or corrections on its contents.

15.1. Introduction

What makes the difference between free software and proprietary software is the access to the sources of the software[1]. That means free software is distributed as archives of source files. It may be unfamiliar to beginners because users of free software must compile sources by themselves before they can use the software.

There are compiled versions of most of the existing free software. The user in a hurry just has to install these pre-compiled binaries. Some free software is not distributed under this form, or the earlier versions are not yet distributed under binary form. Furthermore, if you use an exotic operating system or an exotic architecture, a lot of software will not be compiled for you. More importantly, compiling software by yourself allows you to enable only the interesting options or to extend the functionality of the software by adding extensions in order to obtain a software that exactly fits your needs.

15.1.1. Requirements

To build software, you need:

  • a computer with a working operating system,

  • general knowledge of the operating system you use,

  • some space on your disk,

  • a compiler (usually for the C language)and an archiver (tar),

  • some food (in difficult cases, it may last a long time). A real hacker eats pizzas - not quiches.

  • something to drink (for the same reason). A real hacker drinks soda - for caffeine.

  • the phone number of your techie friend who recompiles his kernel each week,

  • especially patience and a lot of it!

Compiling from sources does not generally present a lot of problems, but if you are not used to it the smallest snag can throw you. The aim of this document is to show you how to escape from such a situation.

15.1.2. Compilation

15.1.2.1. Principle

In order to translate a source code into a binary file, a compilation must be done (usually from C or C++ sources, which are the most widespread languages among the (Unix) free software community). Some free software is written in languages which do not require compilation (for instance Perl or the shell, but they still require some configuration.

C compilation is logically done by a C compiler that is usually gcc, the free compiler written by the GNU project). Compiling a whole software package is a complex task, which goes through the successive compilation of different source files (it is easier for various reasons for the programmer to put the different parts of his work in separate files). In order to make it easier on you, these repetitive operations are handled by a utility named make.

15.1.2.2. The four steps of compilation

To understand how compilation works (in order to be able to solve possible problems), you have to know the four steps. The object is to little by little convert a text written in a language that is comprehensible by a trained human being (i.e. C language), into a language that is comprehensible by a machine (or a very trained human being and even so, in few cases). gcc executes four programs one after the other, each of which takes on one step:

  1. cpp: The first step consists in replacing directives (preprocessors) by pure C instructions. Typically, that means inserting a header (#include) or defining a macro (#define). At the end of this stage, a pure C code is generated.

  2. cc1: This step consists in converting C into assembly language. The generated code depends on the target architecture.

  3. as: This step consists in generating object code (or binary code) from the assembly language. At the end of this stage, a .o file is generated.

  4. ld: The last step (linkage) links all the object files (.o) and the associated libraries, and produces an executable file.

15.1.3. Structure of a distribution

A correctly structured free software distribution always has the same organization:

  • An INSTALL file, which describes the installation procedure.

  • A README file, which contains general information related to the program (short description, author, URL where to fetch it, related documentation, useful links, etc). If the INSTALL file is missing, the README file usually contains a brief installation procedure.

  • A COPYING file, which contains the license or describes the distribution conditions of the software. Sometimes a LICENSE file replaces it.

  • A CONTRIB or CREDITS file, which contains a list of people related to the software (active participation, pertinent comments, third-party programs, etc).

  • A CHANGES file (or less frequently, a NEWS file), which contains recent improvements and bugfixes.

  • A Makefile file (see the section make), which allows compilation of the software (it is a necessary file for make). This file often does not exist at the beginning and is generated during configuration process.

  • Quite often, a configure or Imakefile file, which allows one to generate a new file Makefile,

  • A directory that contains the sources, and where the binary file is usually stored at the end of the compilation. Its name is often src.

  • A directory that contains the documentation related to the program (usually in man or Texinfo format), whose name is often doc.

  • Sometimes, a directory that contains data specific to the software (typically configuration files, example of produced data, or resources files).

Notes

[1]

This is not completely true since some proprietary software also provides their source code. But unlike what happens with free software, the final user is not allowed to use them as he wants.


Tux on Star from MandrakeSoft Linux is a registered trademark of Linus Torvalds. All other trademarks and copyrights are the property of their respective owners.
Unless otherwise stated, all the content of these pages and all images are Copyright MandrakeSoft S.A. and MandrakeSoft Inc. 2000.
http://www.linux-mandrake.com/