10.4 Obsoleting Macros

Configuration and portability technology has evolved over the years. Often better ways of solving a particular problem are developed, or ad-hoc approaches are systematized. This process has occurred in many parts of Autoconf. One result is that some of the macros are now considered obsolete; they still work, but are no longer considered the best thing to do, hence they should be replaced with more modern macros. Ideally, autoupdate should replace the old macro calls with their modern implementation.

Autoconf provides a simple means to obsolete a macro.

Macro: AU_DEFUN (old-macro, implementation, [message], [silent])

Define old-macro as implementation, just like AC_DEFUN, but also declare old-macro to be obsolete. When autoupdate is run, occurrences of old-macro will be replaced by the text of implementation in the updated configure.ac file.

If a simple textual replacement is not enough to finish the job of updating a configure.ac to modern style, provide instructions for whatever additional manual work is required as message. These instructions will be printed by autoupdate, and embedded in the updated configure.ac file, next to the text of implementation.

Normally, autoconf will also issue a warning (in the “obsolete” category) when it expands old-macro. This warning does not include message; it only advises the maintainer to run autoupdate. If it is inappropriate to issue this warning, set the silent argument to the word silent. One might want to use a silent AU_DEFUN when old-macro is used in a widely-distributed third-party macro. If that macro’s maintainers are aware of the need to update their code, it’s unnecessary to nag all of the transitive users of old-macro as well. This capability was added to AU_DEFUN in Autoconf 2.70; older versions of autoconf will ignore the silent argument and issue the warning anyway.

Caution: If implementation contains M4 or M4sugar macros, they will be evaluated when autoupdate is run, not emitted verbatim like the rest of implementation. This cannot be avoided with extra quotation, because then old-macro will not work when it is called normally. See the definition of AC_FOREACH in general.m4 for a workaround.

Macro: AU_ALIAS (old-name, new-name, [silent])

A shorthand version of AU_DEFUN, to be used when a macro has simply been renamed. autoupdate will replace calls to old-name with calls to new-name, keeping any arguments intact. No instructions for additional manual work will be printed.

The silent argument works the same as the silent argument to AU_DEFUN. It was added to AU_ALIAS in Autoconf 2.70.

Caution: AU_ALIAS cannot be used when new-name is an M4 or M4sugar macro. See above.