I was interested in finding out inside a macro (at the shell level) if the
macro was invoked for the last time (to do some extra stuff), and came up
with this SIM_AC_ITERATOR macro.  Can anyone tell me if this approach is
"kosher" autoconf or if it should be done in some alternate way?

  Lars J

dnl ************************************************************************
dnl Usage:
dnl   SIM_AC_ITERATOR( ITERATION, ITERATIONS )
dnl
dnl Description:
dnl   This macro sets up two shell-level variables; the ITERATION and the
dnl   ITERATIONS arguments.  The variable named in the ITERATION argument
dnl   starts with the value 1 and counts upwards on each SIM_AC_ITERATOR
dnl   invocation.  The variable named in the ITERATIONS argument contains
dnl   the total number SIM_AC_ITERATOR invocations (with those arguments)
dnl   in the configure script.
dnl
dnl Credits:
dnl   Lars J. Aas <[EMAIL PROTECTED]>
dnl

AC_DEFUN([SIM_AC_ITERATOR],
[AC_DIVERT_PUSH([AC_DIVERSION_INIT])dnl
ifelse(defn([sim_ac_$1_count]), [],
  [define([sim_ac_$1_count],1)$2=sim_ac_$1_count],
  [define([sim_ac_$1_count],m4_eval(1+sim_ac_$1_count))$2=sim_ac_$1_count])
AC_DIVERT_POP()dnl
$1=sim_ac_$1_count
])

Reply via email to