Autotools recommendations

From Rosalab Wiki
Jump to: navigation, search

Many programs use GNU autotools as part of their build system. Usually tarballs with source code from upstream already contain configure script and Makefile.in file generated by autotools. However, different versions of autotools are not always compatible with each other, so these generated files may not work in the ROSA build system. So it can be a good idea to regenerate all the files when building a package for ROSA Linux.

Below is an example of what can be added to the %build section before running %configure:

libtoolize -c -f --install
aclocal
autoheader
automake -a -c
autoconf

Note : autoheader is optional. If configure.in (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

Note that sources often include an autogen.sh script that can be used to find out what tools to run and how. But it is not recommended to invoke this script in spec files, since it can pick up wrong autotools version in case when several versions are installed in parallel. Moreover, this script will automatically run 'configure' while this should be done using the %configure macro.

For compatibility reasons, ROSA contains several automake versions. If the sources of the package cannot be built with the latest version, an appropriate version number must be appended to he automake and aclocal commands, e.g., automake-1.9.

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 autogen.sh.

Autoconf automatically detects what version should be used. 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 "Makefile.in" 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 the default one is used, add the appropriate build requirement:

BuildRequires: automake1.9

See Also

Note:
This page is based on the Mandriva Autotools page.