23.2 Reusing Existing Macros
It goes without saying that it makes sense to reuse macros where possible--indeed, a search of the Autoconf macro archive might turn up a macro which does exactly what you want, alleviating the need to write a macro at all (see section 23.5.1 Autoconf macro archive).
It's more likely, though, that there will be generic, parameterized
tests available that you can use to help you get your job done.
Autoconf"s `generic' tests provide one such collection of macros. A
macro that wants to test for support of a new language keyword, for
example, should rely on the
In any case, it is good practice when reusing macros to adhere to their publicized interface--do not rely on implementation details such as shell variables used to record the test's result unless this is explicitly mentioned as part of the macro's behavior. Macros in the Autoconf core can, and do, change their implementation from time to time.
Reusing a macro does not imply that the macro is necessarily invoked
from within the definition of your macro. Sometimes you might just want
to rely on some action performed by a macro earlier in the configuration
run--this is still a form of reuse. In these cases, it is necessary to
ensure that this macro has indeed run at least once before your macro is
invoked. It is possible to state such a dependency by invoking the
Should you need to write a macro from scratch, the following sections will provide guidelines for writing better macros.