I wanted to mention a few words the Autoconf. Autoconf generates that wonderful configure script which tells you whether you have all the things required the application you’re trying to compile (or not). Configure scripts also build Makefiles out of either Makefile.in or Makefile.am files. This is great because it lets you compile projects differently for different systems (Oh, Lord how I dream of a world with real, transparent, and consistent platform independence but I digress).
When the uninitiated (that’s me) start wanting to fool around with they notice two things:
- Configure.ac is weird… really weird.
- Makefile.in has these weird @things@ which seem to magically get replaced with stuff by (presumably configure) and boy wouldn’t it be great if I could do that.
I faced three options on how to learn about autoconf: a) check if someone wrote info on how to do what I need to do online b) read the book (I’ll probably do that later) c) see if someone will tell me the little parts that I Need To Know and I’ll figure out the rest later.
A stab at option a) taught me that the configure.ac file is made of up macros, which is a part of why it’s so weird. However I couldn’t find a place that would tell me only what I needed to know to modify an existing configure.ac. So I switched paths.
Following option c) I chatted with Luser of the wonderful mozilla irc community who told me how to make more of those magical @things@. After learning that I figured out two more useful things. making a total of Three Things You Need To Know To Modify configure.ac Files:
- Use the AC_SUBST(var) macro to make more of those magical @things@ in a Makefile.in. What happens is that the name of the variable you put in to the macro (e.g. foo) is will create a magical @thing@ (e.g. @foo@). The vaule of foo during the running of ./configure will determine the value with which @foo@ will be replaces. Note: is like a preprocessor replacing #define’s so no changing the value of @foo@ when your Makefile runs. That’s why most Makefiles assign @constant@ values to variables at the beginning of the scripts.
- You may want to inform the user of what you’re checking for, to do this use the AC_MSG_CHECKING([what I’m checking for]) macro. The message, in square brackets not quotes, is what’ll appear to the user (you know that load of “Checking for foo…” lines? That’s how they show up. For an explanation of why square brackets not quotes please check The Goat/Autoconf Book as I no intention of investigating right now
- To report results of something you’ve checked for use the AC_MSG_RESULT($var) macro. Where the $var is the var is the variable holding the result which you wish to let the user know about and $var is the result itself.
Finally, remember to run autoconf (no arguments) to generate a configure script from the configure.ac script. Good luck!
No comment yet