autoconf: One-Shot Macros

1 
1 10.4.3 One-Shot Macros
1 ----------------------
1 
1 Some macros should be called only once, either because calling them
1 multiple time is unsafe, or because it is bad style.  For instance
11 Autoconf ensures that `AC_CANONICAL_BUILD' and cousins (⇒
 Canonicalizing) are evaluated only once, because it makes no sense to
1 run these expensive checks more than once.  Such one-shot macros can be
1 defined using `AC_DEFUN_ONCE'.
1 
1  -- Macro: AC_DEFUN_ONCE (MACRO-NAME, MACRO-BODY)
11      Declare macro MACRO-NAME like `AC_DEFUN' would (⇒Macro
      Definitions), but add additional logic that guarantees that only
1      the first use of the macro (whether by direct expansion or
1      `AC_REQUIRE') causes an expansion of MACRO-BODY; the expansion
1      will occur before the start of any enclosing macro defined by
1      `AC_DEFUN'.  Subsequent expansions are silently ignored.
1      Generally, it does not make sense for MACRO-BODY to use parameters
1      such as `$1'.
1 
1    Prior to Autoconf 2.64, a macro defined by `AC_DEFUN_ONCE' would
1 emit a warning if it was directly expanded a second time, so for
1 portability, it is better to use `AC_REQUIRE' than direct invocation of
11 MACRO-NAME inside a macro defined by `AC_DEFUN' (⇒Prerequisite
 Macros).
1