15.3. Configuration

A purely technical interest of the fact authors create the sources is the porting of the software. Free software developed for a Unix system can be used on all of the existing Unix systems (whether they are free or proprietary), with some 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:

15.3.1. Autoconf

15.3.1.1. Principle

Autoconf is used to correctly configure software. It creates the files required by the compilation (Makefile for instance), and sometimes changes directly 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 final user runs the script, and Autoconf configures all that is needed by the compilation.

15.3.1.2. 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

15.3.1.3. What if... it does not work?

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

That 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. That will help you in solving the issue.

  • Check that said library is well 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 What if... it does not work? number 5.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, gtk+-devel instead of libgtk). The development version of the library provides the "include" files necessary for the compilation of a 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 -k to display the partitions of your system, and mind 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 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!

15.3.2. 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 (architecture-dependent). It is quite handy for applications using X Window System. But Imake is 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!

15.3.3. Various shell scripts

Read the INSTALL or README files for more information. Usually, you have to run a file of type 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 can not manage to determine the file you must run, you can type ./ (under Bash), and then press twice the TAB key (tabulation key). Bash automatically (in its default configuration) completes by a possible executable file from the directory (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

15.3.4. 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 make) and a config.h file (this name is only conventional).

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


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/