An overview
of the GNU autotools
Some practical advice about GNU autotools
April 14, 2003 – Stanford Linear Accelerator Center

Fabrizio Coccetti

The Issue
Warren did not only have PIPE Dreams at CHEP03 …
He also has Auto-configuration Dreams

The real Problem
How do we handle platform specific issues?
Providing a different Makefile for each architecture
Using Autoconf, Automake and Libtool
The installer needs only
Bourne shell
C compilers
Make program

Some advantages when using GNU autotools
The installation of a program is straightforward:
./configure; make; make install
This procedure checks for system parameters, libraries, location of programs, availability of functions and writes a Makefile
./configure supports many options to overwrite defaults settings

GNU autoconf

GNU automake

configure.ac
dnl Comment … …
AC_INIT(main.c)
AM_INIT_AUTOMAKE(project_name, 1.2.8)
AM_PROG_LIBTOOL it supports libtool and shared libraries
AC_PROG_CC  (or AC_PROG_CXX) it locates the C (C++) compiler
AC_HEADER_STDC it checks for standard headers
AC_CHECK_HEADERS(sys/time.h /header.h) it checks for headers availability
AC_CHECK_LIB(crypto SSLeay_version) it checks for libraries availability
AC_CHECK_FUNCS(ctime) it checks for functions availability
AC_PROG_INSTALL it checks for BSD compatible install utility
AC_OUTPUT([Makefile])

Makefile.am
bin_PROGRAMS = foo
/configure --prefix=… (default /usr/local)
foo_PROGRAMS=foo.c foo.h
noist_PROGRAMS=test
(make compiles, make install does nothing)
EXTRA_DIST=disclaimer.txt

Example
foo.c :
#include <stdio.h>
main()
{
 printf(“Cum grano salis\n");
}
Makefile.am :
bin_PROGRAMS = foo
foo_SOURCES = foo.c
configure.ac :
AC_INIT(foo.c)
AM_INIT_AUTOMAKE(latin_words, 0.9)
AC_PROG_CC
AC_HEADER_STDC
AC_PROG_INSTALL
AC_OUTPUT([Makefile])

Summary
Source Code, configure.ac, Makefile.am
  autoscan; aclocal; autoconf
Create NEWS README AUTHORS ChangeLog
  automake –add-missing
./configure; make; make dist
Result:  project_name-2.10.tar.gz
aclocal.m4  autom4te-2.53.cache  ChangeLog   config.status  configure.in   COPYING  install-sh  Makefile.am  missing        NEWS       README AUTHORS     autoscan.log         config.log  configure      configure.scan  INSTALL  Makefile.in  mkinstalldirs  code.c

References
GNU Autoconf, Automake, and Libtool http://sources.redhat.com/autobook/autobook/autobook_toc.html
GNU Autoconf Manual
http://www.gnu.org/manual/autoconf
GNU Automake Manual
http://www.gnu.org/manual/automake
GNU Libtool Manual
http://www.gnu.org/manual/libtool
Learning the GNU development tools
http://autotoolset.sourceforge.net/tutorial.html
The GNU configure and build system
http://www.airs.com/ian/configure/configure_toc.html
GNU macro processor (GNU m4)
http://www.gnu.org/manual/m4-1.4/m4.html