René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

./configure, automake, autoconf and the like

Source code (especially C/C++) must be compiled differently on different platforms. Aggravating is the fact that some (library-) functions are not present on all platform (for example gettimeofday). This poses problems if the same source code is to be compiled on different platforms.
In order to tackle this problem, GNU proposes a two step build mechanism involving configure, autoconf, automake and the like.
Essentially, it boils down to a standard build process for a program like so:
./configure
make
make install
Invoking configure creates a config.status file, which is a shell script. config.status is used to convert Makefile.in into the Makefile. config.status also turnes config.in into config.h
./configure also creates a config.cache file. config.cache should be removed if configure.in is significantely changed.
Lastly, ./configure creates a stamp-h.in file.
On the installer machine, nothing more than a bourne shell, a c compiler and a make programm are needed.
The programmer additionally needs the autoconf package, the automake package and m4.
configure's behaviour can be changed through its options.

configure.in

configure.scan

autoscan can be used to create a configure.scan file which can be used as a starting point for a configure.in file.

Makefile.am

Makefile.am is a simple specification of a project's build requirements that will be turned into a fully fledged Makefile.
A typical Makefile.am has the form
variable=value
Most Makefile.am assigns values to the following variables:
  • INCLUDES
  • LDFLAGS
  • LDADD
  • EXTRA_DIST
  • SUBDIRS
  • bin_PROGRAMMS ??? see below
    This variable defines a list of programs to be installed in the $(prefix)/bin directory.
  • lib_LIBRARIES
  • check_PROGRAMS
    Lists the programs that are needed to run make check
  • TESTS
    Lists the programs that are run make check Because those programs sometimes need to be built themselves, usually one wants to write
    TESTS = $(check_PROGRAMS)
    
Additionally, for each program, the following variables must be assigned to:
  • prog_SOURCES
  • prog_LDADD
  • prog_LDFLAGS
  • prog_DEPENDENCIES
For each library, the following variables must be assigned to:
  • lib{library_name}_SOURCES
  • lib{library_name}_LDFLAGS
  • lib{library_name}_DEPENDENCIES

Super targets

  • bin_PROGRAMMS
    ??? see above
  • bin_SCRIPTS
  • man_MANS
  • lib_LTLIBRARIES
  • noinst_PROGRAMMS

Makefile.in

Makefile

Usually, the Makefile is generated by ./configure from Makefile.in

Targets

acconfig.h

acconfig.h is the file out of which config.h.in is generated.

config.h.in

config.h.in (or config.in, see AM_CONFIG_HEADER) is the file out of which config.h is generated.
autoheader can be used to create an initial config.h.in.

config.h

config.guess

config.log

Use this file when something went wrong with ./configure.

config.status

config.status is a shell script that may be used to recreate the current configuration. That is, all generated files will be regenerated.
Can also be used with recheck

How they interact

On this page is a dot generated graphic that illustrates (or at least: tries to) how the tools interact and which files they produce.

Examples

Small example