GROMACS: Fast, Free and Flexible MD
 
 
 
Development Tools
Tuesday, 13 September 2005
To maintain and configure the Makefiles and static/shared libraries in GROMACS we use the GNU Autotools triplet, i.e. automake, autoconf and libtool.

These programs might seem complicated the first time you try to understand them, but they are a powerful solution for a very complex task: Using these tools we can support essentially all vendor compilers and make programs to produce both shared and static libraries on the platform of your choice.

You can find a very good introduction to these programs in the autotools book. It's available free online at sources.redhat.com/autobook/.

GNU Autoconf

The autoconf program reads the input file configure.ac (formerly configure.in) to create the configure script. The input file is a mix of shell scripts and M4 macros (yuck...) that are either defined in autoconf or the acinclude.m4 file.

When a user runs the configure script it performs a lot of small tests, usually by trying to compile various code snippets or checking whether certain system files are present.

Autoconf then reads all the Makefile.in's, and depending on the outcome of the tests it replaces variables like @VARIABLE@ with real values and creates the final Makefiles. This way we can select the compilers, flags, library names, etc, depending on the system where you are performing the build. It is not very hard to write new autoconf tests, but it might take some trial and error to get the M4 syntax right. GROMACS needs autoconf version 2.50 or later. Once you have the configure script you probably want to generate config.h.in by typing 'autoheader'.


Check the manual at http://www.gnu.org/software/autoconf/manual/index.html for details.

 

GNU Automake

Autoconf does the host configuration for you, but it still requires a Makefile.in, which is essentially a normal Makefile with variables. For a large package the Makefile.in's will be very complex with a lot of different rules, dependencies, etc.

Of course we are too lazy to write those ourselves - let's use the Automake tool to do it for us!

When we use Automake, we create automake templates in the Makefile.am files which are used to create each Makefile.in. The whole idea is that the automake files only contain the logical description of the program, i.e. which source files are used to build a certain library or program. Automake will take care of everything else; it will create the appropriate Makefile rules, the commands necessary to build your files, and it defines dependencies for you. It will even include code to extract dependencies at build time for almost all compilers and make programs!

If we need to do something special in a Makefile we can just enter normal commands, for instance as we've done in gmxlib. These will be copied into the final Makefile, with @VARIABLE@ replaced when the configure script is run.

NOTE: The automake command depends on the contents of the aclocal.m4 file (generated from acinclude.m4) and the configure script, so if you've just checked out from CVS or changed acinclude.m4 you need to run both 'aclocal' and 'autoconf' first.

GROMACS is quite a complicated package since we use both C, assembly, Fortran, and libraries with dynamic names. This means we rely on features that are only present in Automake version 1.5 or later. Sorry, but previous versions won't work:


The full automake manual is available at sources.redhat.com/automake/automake.html


Automake enables a lot of other cool things that I haven't mentioned. For example, if you type 'make tags' in the top level directory you will get source code tags that you can use in emacs when you develop.

GNU Libtool

In principle, automake and autoconf provide everything you need to build any application, if you just write tests for all system features you need.

One very common step in the build process is the creation of libraries. Static libraries are easy to build, but most modern systems can also use shared libraries to decrease the installed size of your application. Unfortunately there isn't any standardized way to create shared libraries; you might need special flags to compile the objects, a flag to tell the compiler to make a shared library, and probably a third flag to include a default search path in your library. This is definitely the most complicated part of the build process, and thus there is a special program to help you do it - GNU Libtool.

Libtool works as an interface script, and takes the normal compiler command line as an argument. Libtool will then create all the files necessary for shared and/or static libraries. You can find all the information you need in the Libtool manual, but for GROMACS development the makefiles will actually take care of it for you!

It might be useful to know that Libtool works with libtool objects (.lo) and libtool libraries (.la) instead of the normal ones, to keep track of files both for static and shared libs.

Note that you will never have to install libtool or work directly with any libtool binary. A GROMACS- and host-specific libtool script will be created in the top source directory when you run configure, and this version of libtool is called from your makefiles during the build process.

You can find more information on the Libtool homepage at www.gnu.org/software/libtool/libtool.html, but note that the Fortran support and some other things we include are not yet parts of the official Libtool

(I'm working on getting it accepted, hopefully it should be included in the next Libtool release).

 
< Prev   Next >
 
Top! Top!
This page took 0.030637 seconds to load.