See Alexandre Duret Lutz s Autotools tutorial, a must read.
It contains diagrams explaining how the different files of an autotools project interact with each other and by which tool they are used: configure
, config.h
, config.status
, aclocal.m4
etc
EDIT:
John Calcote also explains the purpose of aclocal and aclocal.m4 in the first chapter of his book about Autotools: Chapter 1: A brief introduction to the GNU Autotools:
The aclocal utility is actually documented by the GNU manuals as a temporary work-around for a certain lack of flexibility in Autoconf. Autoconf was designed and written first, and then a few years later, the idea for Automake was conceived as an add-on for Autoconf. But Autoconf was really not designed to be extensible on the scale required by Automake.
...
Essentially, aclocal’s job is to create an aclocal.m4 file by consolidating various macro files from installed Autotool packages and user-specified locations, such that Autoconf can find them all in one place.
...
However, the latest documentation from both sets of tools suggests that the entire aclocal/acinclude paradigm is now obsolete, in favor of a newer method of specifying a directory containing m4 macro files. The current recommendation is that you create a directory in your project directory called simply m4 (acinclude seems more appropriate to this author), and add macros in the form of individual .m4 files to this directory. All files in this directory will be gathered into aclocal.m4 before Autoconf processes your configure.ac file. Ultimately, aclocal will be replaced by functionality in Autoconf itself.