Modernize your autotools build system

Update: I converted this post in a new GnomeGoal, see here

Update 2: Added some more tips

Autotools is the most common system to build programs in GTK+/GNOME projects.

Remove deprecated macros for our file and use the new syntax will do our build system more legible and portable

The Autotools comes with a program to make the work for us, simply run


in you source tree and you have a new updated (Checks the result for possibles errors)

Some more tips:

  • Respect the standard layout
  • Try to avoid the use of AM_MAINTAINER_MODEAM_MAINTAINER_MODE (called like that) disables dependency-checking for autotools-generated stuff. AM_MAINTAINER_MODE([enabled]) retains the default behavior, but lets users pass a configure option to disable the dependency checking. So, if you really need this macro, use AM_MAINTAINER_MODE([enabled]). See the automake manual for a extended explanation
  • Use all the parameters of AC_INIT() (for the fifth parameter you need autoconf >= 2.64):
  • Use updated versions of the programs (all of these versions (and newer) are present in Debian stable):
    • automake >= 1.11.1 (AM_INIT_AUTOMAKE([1.11.1])) (or 1.10.3, Automake < 1.10.3 and 1.11 are known to be suffering from critical security issues)
    • autoconf >= 2.64 (AC_PREREQ(2.64))
    • libtool >= 2.2.6 (LT_PREREQ([2.2.6]))
    • intltool >= 0.40.0 (IT_PROG_INTLTOOL([0.40.0]))
  • Take a look to all AM_INIT_AUTOMAKE() posible parameters. For example, to use 1.11.1 automake version and generate bzip2 distribution tarballs in addition to the gzip’ed:
AM_INIT_AUTOMAKE([1.11.1 dist-bzip2])
  • Use LT_INIT() syntax for libtool (needs libtool >= 2.2.0). More info about LT_INIT(). For example, change this:

For this:

LT_INIT([dlopen win32-dll disable-static])
  • Don’t use GNOME_COMMON_INIT, as it does not work with autoreconf. Simply add this to your (You have to define the macros dir in your, in this case: AC_CONFIG_MACRO_DIR([m4]))
  • Use gnome-common macros for compile warnings macros instead custom ones. Also use GNOME_MAINTAINER_MODE_DEFINES to get warnings when using deprecated symbols:

Other tips

Feel free to suggest more tips in the comments!

Some documentation:

Flattr this

11 thoughts on “Modernize your autotools build system”

  1. Some more hints:

    Use dist_foo_BAR to avoid pulling everything via EXTRA_DIST:

    scriptsdir = $(bindir)
    dist_scripts_SCRIPTS = script1 script2

    Pass dist-bzip2 to AM_INIT_AUTOMAKE to generate bzip2 distribution tarballs in addition to the gzip’ed:

    AM_INIT_AUTOMAKE([… dist-bzip2])

    Use silent rules and AM_V_GEN for custom compilation:

    autoconf: AM_SILENT_RULES([yes])
    automake: $(AM_V_GEN) custom-compil-tool …

  2. @Andrés, If you are interested, maybe It’s a good idea talk with some project maintainer and make a patch to use CMake instead autotools, so everybody can see the benefits and/or drawbacks of the change.

    Some time ago I did some search about this topis [1]. I only found 2 GTK+ projects that use CMake: gtkpod and inkscape (If you know any other, please tell me)


  3. @Andrés, why would Gnome want to switch to CMake? From my experience with it, it’s a pretty rubbish system… I had a lot of trouble with it. For example, it couldn’t even do pkg-config without a 3rd party script.

    I find Autotools to be nicer, as long as you do it properly (that is, non-recursively)

  4. Please don’t move to cmake. It is very clunky to use with pkg-config. Autotools may be inconvenient but it works well in *nix environments.

Comments are closed.

Leave a Reply

Your email address will not be published. Required fields are marked *