Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the point of aclocal?

Tags:

autotools

What's the point of the aclocal script and aclocal.m4 file, in context of using autotools to configure source files? From what I read, aclocal scans macro files for macros that are later used by automake. I don't understand this process in depth, but it seems that the scanning functionality could have just been embedded into automake.

like image 672
theactiveactor Avatar asked Dec 28 '09 18:12

theactiveactor


2 Answers

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.

like image 100
Gregory Pakosz Avatar answered Sep 19 '22 18:09

Gregory Pakosz


In my software, aclocal.m4 collects the various non-standard Autoconf macros that I use during the builds of my software. One such set of macros deals with sub-second timing - choosing the best of the available options (according to some pre-determined criterion for what is 'best'); another such set of macros deals with the intricacies of the IBM Informix ESQL/C compilation system as it has evolved over the last two decades (it handles ESQL/C 5.20, where version 5.00 was released in 1990, and it also handles the latest versions of IBM Informix ClientSDK 3.50 - which, much to my chagrin, contains ESQL/C 3.50 even though it was released in 2008).

So, aclocal.m4 is for local macros that are not necessarily part of regular Autoconf but which are used by your specific software.

like image 45
Jonathan Leffler Avatar answered Sep 19 '22 18:09

Jonathan Leffler