From Mandriva Community Wiki

Revision as of 22:47, 17 December 2010 by Christiaan Welvaart (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search


The autotools is a suite of different tools created by the GNU project to ease software distribution, compilation, installation. They are currently composed of:

Why worry about them

Many programs use GNU autotools as part of their build system. Normally this is of no concern to packagers because the configure script and files were already generated by the developers. In some cases, however, these files must be (re)generated:

  • One or more patches need to change something in configure or Makefile(.in)s. This is the most common reason and follows the general rule not to modify generated files.
  • The software is a pre-release snapshot ("CVS version") and does not include the generated files.
  • The autotool versions used to generate the files included in the source package have bugs or missing features (new architecture support, e.g. for x86-64).

What they do

  • libtoolize - installs libtool files in the build dir, for use from makefiles
  • aclocal - this tool collects m4 macros from various places and puts them in aclocal.m4, it is part of the automake package
  • automake - creates from, configure will then generate Makefile based on this
  • autoconf - creates a configure script from or
  • autoheader - creates a C header template, afterwards the configure script will "fill in the blanks" and indicate what kind of features are available in the building machine

What to add to the specfile

Sources often include an script that can be used to find out what tools to run and how. It is better not to run this script directly because it likely does not select an older automake-1.x if that is necessary, and it will also run configure while this should be done using the %configure or %configure2_5x macros. Some software authors/maintainers may be kind enough to implement autotools version checking and/or allow configure not to run, but one has to poke into the script oneself in order to decide.

Below is an example of what can be added to the %build section before %configure or %configure2_5x.

libtoolize -c -f --install
automake -a -c

Note: autoheader is optional. If (or .ac) does not include AC_CONFIG_HEADERS macros, then (ac)config.h won't be generated, so don't run it.

Alternatively, merge all autotools lines into one autoreconf call:

libtoolize --copy --force --install
autoreconf --force --install

You may already have noticed that %configure* macros already execute libtoolize, so why run it beforehand? libtool also installs some m4 macros, so if libtoolize is not executed before aclocal, aclocal may pick up other versions of libtool m4 macros already bundled into the software. The result of mixing different versions of macros with libtool files can vary from nothing to catastrophic.

Some packages ship with a directory of m4 macro files, which has to be passed to aclocal with the -I flag. So when the dir is called "m4", write:

aclocal -I m4

Mandriva contains several automake versions. If the sources of the package cannot be built with the latest version from the automake1.8 package, a version number must be appended to he automake and aclocal commands: -1.7, or -1.4.

The automake "-a -c" parameters are not always needed but won't cause problems either. Note however that in the default (GNU) mode, automake -a adds a COPYING file containing the GPL text if no such file is found. If necessary this can be fixed by changing the strictness setting (e.g. with --foreign). An appropriate setting can be taken from the input files or

Autoconf automatically detects what version should be used (2.1 or 2.5). If this does not work, set FORCE_AUTOCONF_2_5=1 or WANT_AUTOCONF_2_1=1 . To select the correct version of automake/aclocal to use, check "" in the source tarball, it will display which version was used by program author to create tarballs. It is the safest way to use the same version (or the same major version) as what software authors use.

When an automake other than automake1.8, say automake1.7, is used, add the appropriate requirement:

BuildRequires: automake1.7

When running autotools, some additional build dependencies may be needed, e.g. intltool, gnome-common, gtk-doc.

Available documentation

Official manuals:


Personal tools