Configuration

For purely technical interest, the fact that authors create the sources is for the porting of the software. Free software developed for a UNIX system may be used on all of the existing UNIX systems (whether they are free or proprietary), with some or no changes. That requires configuration of the software just before compiling it.

Several configuration systems exist. You have to use the one the author of the software wants (sometimes, several are needed). Usually, you can:

Autoconf

Principle

AutoConf is used to correctly configure software. It creates the files required by the compilation (Makefile for instance), and sometimes directly changes the sources (for instance by using a config.h.in file).

The principle of AutoConf is simple:

  • The programmer of the software knows which tests are required to configure his software (eg: “which version of this library do you use?”). He writes them in a file named configure.in, following a precise syntax.

  • He executes AutoConf, which generates a configuration script named configure from the configure.in file. This script makes the tests required when the program is configured.

  • The end-user runs the script, and AutoConf configures everything that is needed by the compilation.

Example

An example of the use of AutoConf:

     $ ./configure
     loading cache ./config.cache
     checking for gcc... gcc
     checking whether the C compiler (gcc  ) works... yes
     checking whether the C compiler (gcc  ) is a cross-compiler... no
     checking whether we are using GNU C... yes
     checking whether gcc accepts -g... yes
     checking for main in -lX11... yes
     checking for main in -lXpm... yes
     checking for main in -lguile... yes
     checking for main in -lm... yes
     checking for main in -lncurses... yes
     checking how to run the C preprocessor... gcc -E
     checking for X... libraries /usr/X11R6/lib, headers /usr/X11R6/include
     checking for ANSI C header files... yes
     checking for unistd.h... yes
     checking for working const... yes
     updating cache ./config.cache
     creating ./config.status
     creating lib/Makefile
     creating src/Makefile
     creating Makefile
    

To have better control of what configure generates, some options may be added by the way of the command line or environment variables. Example:

     $ ./configure --with-gcc --prefix=/opt/GNU
    

or (with bash):

     $ export CC=`which gcc`
     $ export CFLAGS=-O2
     $ ./configure --with-gcc
    

or:

     $ CC=gcc CFLAGS=-O2 ./configure
    

What if... it does not work?

Typically, it is an error that looks like configure: error: Cannot find library guile (most of the errors of the configure script look like this).

This means that the configure script was not able to find a library (the guile library in the example). The principle is that the configure script compiles a short test program, which uses this library. If it does not succeed in compiling this program, it will not be able to compile the software. Then an error occurs.

  • Look for the reason of the error by looking at the end of the config.log file, which contains a track of all the steps of the configuration. The C compiler is clear enough with its error messages. This will usually help you in solving the problem.

  • Check that the said library is properly installed. If not, install it (from the sources or a compiled binary file) and run configure again. An efficient way to check it is to search for the file that contains the symbols of the library; which is always lib<name>.so. For instance,

    	$ find / -name 'libguile*'
           

    or else:

    	$ locate libguile
           

  • Check that the library is accessible by the compiler. That means it is in a directory among: /usr/lib, /lib, /usr/X11R6/lib (or among those specified by the environment variable LD_LIBRARY_PATH, explained the section called “What if... it does not work?” number b. Check that this file is a library by typing file libguile.so.

  • Check that the headers corresponding to the library are installed in the right place (usually /usr/include or /usr/local/include or /usr/X11R6/include). If you do not know which headers you need, check that you have installed the development version of the required library (for instance, libgtk+2.0-devel instead of libgtk+2.0). The development version of the library provides the “include” files necessary for the compilation of software using this library.

  • Check that you have enough space on your disk (the configure script needs some space for temporary files). Use the command df -h to display the partitions of your system, and note the full or nearly full partitions.

If you do not understand the error message stored in the config.log file, do not hesitate to ask for help from the free software community (see section the section called “Technical support”).

Furthermore, check whether configure answers by 100% of No or whether it answers No while you are sure that a library exists. For instance, it would be very strange that there is no curses library on your system). In that case, the LD_LIBRARY_PATH variable is probably wrong!

Imake

imake allows you to configure free software by creating a Makefile file from simple rules. These rules determine which files need to be compiled to build the binary file, and imake generates the corresponding Makefile. These rules are specified in a file named Imakefile.

The interesting thing about imake is that it uses information that is site-dependent (architecture-dependent). It is quite handy for applications using X Window System. But imake is also used for many other applications.

The easiest use of imake is to go into the main directory of the decompressed archive, and then to run the xmkmf script, which calls the imake program:

    $ xmkmf -a
    $ imake -DUseInstalled -I/usr/X11R6/lib/X11/config
    $ make Makefiles
   

If the site is not correctly installed, recompile and install X11R6!

Various shell scripts

Read the INSTALL or README files for more information. Usually, you have to run a file called install.sh or configure.sh. Then, either the installation script is non-interactive (and determines itself what it needs) or it asks you information on your system (paths, for instance).

If you cannot manage to determine the file you must run, you can type ./ (under bash), and then press the TAB key (tabulation key) twice. bash automatically (in its default configuration) completes by a possible executable file from the directory (and therefore, a possible configuration script). If several files may be executed, it gives you a list. You just have to choose the right file.

A particular case is the installation of perl modules (but not only). The installation of such modules is made by the execution of a configuration script, which is written in perl. The command to execute is usually:

    $ perl Makefile.PL
   

Alternatives

Some free software distributions are badly organized, especially during the first stages of development (but the user is warned!). They sometimes require you to change “by hand” some configuration files. Usually, these files are a Makefile file (see section the section called “Make”) and a config.h file (this name is only conventional).

We advise against these manipulations except for users who really do know what they are doing. This requires real knowledge and some motivation to succeed, but practice makes perfect.