Unix comes in many variants and it is a nontrivial problem to write software that will compile on many different variants. Even the configuration files for the build process (the Makefiles) require all kinds of highly nontrivial intelligence on the part of the author before they will work on many different Unix variants.

One solution is to have a program that incorporates as much of this knowledge as humanly possible, and use it to automatically generate a suitable Makefile for the Unix platform at hand. Today, in the large majority of cases, software packages come with a program called ./configure to perform this task. And this program (a /bin/sh script) is usually generated by a tool written specifically for that purpose: GNU autoconf.

autoconf was written to combat the #ifdef UNIX_VARIANT proliferation disease. This disease stems from a naive approach to making software portable: that approach makes code conditional on the Unix variant it is compiled on, whenever variants differ in the primitives they offer to solve a particular task. The problem this leads to is that there are typically many more Unix variants than variants of that particular primitive, which leads to an excessive and totally unreadable mess of nested #if statements in the code. The alternative is to make #if statements depend not on Unix variant names, but on the variants that exist of each individual feature. For instance, there are only a few different variants of file locking; the #if statements would test whether a particular variant of file locking is supported, and supply code for each variant the program supports.

What this requires is a program that knows about all of these different Unix features, and tests which variants of them are supported by the Unix variant the user is compiling the software on. This is what the ./configure program does, and the knowledge used to generate the test is provided by GNU autoconf, which generates ./configure. The programmer provides a configuration file, configure.am, to tell autoconf which of the tests it knows about are relevant to the program at hand; and to supply additional tests that autoconf has no built-in knowledge of.

./configure doesn't generate its Makefiles from scratch, but from prototypes, Makefile.in. There is yet another tool to generate these: GNU automake.

(This writeup is too long. Remind me to shorten it when I have more time.)

Log in or registerto write something here or to contact authors.