Autotools#

Autotools is the name for the set of tools that make up the GNU Build System. When you download a piece of software, and you can see configure, configure.in or configure.ac you’re looking at something setup to use Autotools. The workflow for building this sort of software tends to be quite consistent:

  • Download a copy of the software

  • Generate a configure script if missing

  • Check out the configure script to see what options there are

  • Run the configure script with your chosen options

  • Build

  • Install

Let’s run through an example piece of software showing each of these steps. I’m picking on something from GitHub that includes all these steps.

Download your software#

This could be downloading and extracting a tarball:

$ wget https://github.com/barricklab/breseq/releases/download/v0.37.1/breseq-0.37.1-Source.tar.gz
$ tar xf breseq-0.37.1-Source.tar.gz
$ cd breseq-0.37.1
$ ls configure
configure

Here we can see that there’s already a configure script present. But what if we do that same again but rather than use a released version, get the latest version from git?

$ git clone https://github.com/barricklab/breseq
$ cd breseq
$ ls configure
ls: cannot access 'configure': No such file or directory

Generate a configure script if missing#

With this git example, we see there is no configure script present, so we need to generate it. Sometimes you’re provided with a bootstrap.sh or autogen.sh, as is the case here. So we run it:

$ ./bootstrap.sh

This sorts everything out ready for us to configure it. If neither of these scripts are present, you can instead do:

$ autoreconf -fi

Note

This often results in exactly the same outcome, but the authors may have added other things into the bootstrap script, so if present it’s wise to use it.

Configure the software#

Running the configure script first lets you find out what options you have (trimmed down output show below):

$ ./configure --help
Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]

This may show you features you can turn on and off, or explain which variables are used by the build script. In this example, we’re going to tell it where we’d like it installed to, and nothing else. Typically I’d advise installing software for a given project in one location, rather than each program being installed separately, but it’s up to you.

$ ./configure --prefix=/nobackup/example/project1

You’ll then got a lot of output showing it testing your system and ensuring it can find all the bits it needs.

If it doesn’t find what it needs, you need to look at the options provided by --help or look into setting standard environment variables like CPATH/LIBRARY_PATH, as covered in the Theory section.

Building#

Assuming everything’s gone well so far with configure, it will have now written out a top level Makefile, which contains the necessary steps to build and install your software. Building the software is now a case of:

$ make

If you’re running on a multicore machine, you can ask it to run several build jobs in parallel. For example, to build using 8 cores:

$ make -j 8

Note

Poorly written makefiles will sometimes build incorrectly when built in parallel, but you’d normally be fine running make again afterwards which would complete the build.

Install#

Once built, to install it at the location you requested:

$ make install

There you have it. Your software is installed at the location you asked. It’s still up to you at this point to either run the software directly from this location, or update you environment variables to make this software generally available to you. Details on this is covered in the Theory section.

Summary#

Important

  • Introduces Autotools for configuring build systems

  • Showcased an example of deploying breseq using Autotools

    • Showed how to find what options are available when configuring

    • Highlighted using --prefix for appropriate installation of software locally

    • Showed steps to build and install using GNU Make after configuring with Autotools

References#

Autotools GNU Make