manpagez: man pages & more
info autoconf
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.4.3 One-Shot Macros

Some macros should be called only once, either because calling them multiple time is unsafe, or because it is bad style. For instance Autoconf ensures that AC_CANONICAL_BUILD and cousins (see section Getting the Canonical System Type) are evaluated only once, because it makes no sense to run these expensive checks more than once. Such one-shot macros can be defined using AC_DEFUN_ONCE.

Macro: AC_DEFUN_ONCE (macro-name, macro-body)

Declare macro macro-name like AC_DEFUN would (see section Macro Definitions), but add additional logic that guarantees that only the first use of the macro (whether by direct expansion or AC_REQUIRE) causes an expansion of macro-body; the expansion will occur before the start of any enclosing macro defined by AC_DEFUN. Subsequent expansions are silently ignored. Generally, it does not make sense for macro-body to use parameters such as $1.

Prior to Autoconf 2.64, a macro defined by AC_DEFUN_ONCE would emit a warning if it was directly expanded a second time, so for portability, it is better to use AC_REQUIRE than direct invocation of macro-name inside a macro defined by AC_DEFUN (see section Prerequisite Macros).


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 26, 2012 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.