7.5 Frequently Asked Questions
Experience has shown that there are several common questions that arise as people begin to use automake for their own projects. It seemed prudent to mention these issues here.
Users often want to make a library (or program, but for some reason it comes up more frequently with libraries) whose sources live in subdirectories:
If you try this with Automake 1.4, you'll get an error:
For libraries, this problem is mostly simply solve by using libtool convenience libraries. For programs, there is no simple solution. Many people elect to restructure their package in this case.
The next major release of Automake addresses this problem.
Another general problem that comes up is that of setting compilation flags. Most rules have flags--for instance, compilation of C code automatically uses `CFLAGS'. However, these variables are considered user variables. Setting them in `Makefile.am' is unsafe, because the user will expect to be able to override them at will.
To handle this, for each flag variable, Automake introduce an `AM_' version which can be set in `Makefile.am'. For instance, we could set some flags for C and C++ compilation like so:
Finally, people often ask how to compile a single source file in two
different ways. For instance, the `etags.c' file which comes with
Emacs can be compiled with different `-D' options to produce the
With Automake 1.4 this can only be done by writing your own compilation rules, like this:
This is tedious and hard to maintain for larger programs. Automake 1.5 will support a much more natural approach: