* m4sugar.m4: Formatting changes.
* acgeneral.m4 (AC_DIVERT_PUSH, AC_DIVERT_POP, AC_REQUIRE)
(AC_DIAGNOSE, AC_FATAL, AC_MSG_WARN, AC_MSG_NOTICE, AC_MSG_ERROR):
Use m4_copy to define them, in order to keep a good $0.
(AC_INIT): AC_LANG_PUSH C, not AC_LANG, to initialize the stack.
* aclang.m4 (AC_LANG_PUSH): Dont't use m4_defn on undefined macros.
(AC_LANG_POP): Admit an argument specifying the language we quit
when popping.
Adjust Autoconf's AC_LANG_POPs.
* tests/tools.at (AWK portability): Don't depend on AC_INIT.
(autoconf --trace: user macros): Obviously I
meant TRACE1, not AC_TRACE1.
+2001-01-18 Akim Demaille <akim@epita.fr>
+
+ Various cleanups and consistency checks.
+
+ * m4sugar.m4: Formatting changes.
+ * acgeneral.m4 (AC_DIVERT_PUSH, AC_DIVERT_POP, AC_REQUIRE)
+ (AC_DIAGNOSE, AC_FATAL, AC_MSG_WARN, AC_MSG_NOTICE, AC_MSG_ERROR):
+ Use m4_copy to define them, in order to keep a good $0.
+ (AC_INIT): AC_LANG_PUSH C, not AC_LANG, to initialize the stack.
+ * aclang.m4 (AC_LANG_PUSH): Dont't use m4_defn on undefined macros.
+ (AC_LANG_POP): Admit an argument specifying the language we quit
+ when popping.
+ Adjust Autoconf's AC_LANG_POPs.
+ * tests/tools.at (AWK portability): Don't depend on AC_INIT.
+ (autoconf --trace: user macros): Obviously I
+ meant TRACE1, not AC_TRACE1.
+
2001-01-17 Akim Demaille <akim@epita.fr>
* m4sugar.m4 (m4_undefine, m4_popdef): Don't tolerate undefined
# AC_DIVERT_PUSH(DIVERSION-NAME)
-# ------------------------------
-m4_define([AC_DIVERT_PUSH],
-[m4_divert_push($@)])
-
-
# AC_DIVERT_POP
-# -------------
-m4_define([AC_DIVERT_POP],
-[m4_divert_pop($@)])
+# ------------------------------
+m4_copy([m4_divert_push],[AC_DIVERT_PUSH])
+m4_copy([m4_divert_pop], [AC_DIVERT_POP])
# Throw away output until AC_INIT is called.
# ------------------
# If STRING has never been AC_PROVIDE'd, then expand it. A macro must
# be AC_DEFUN'd if either it is AC_REQUIRE'd, or it AC_REQUIRE's.
-m4_define([AC_REQUIRE],
-[m4_require([$1])])
+m4_copy([m4_require], [AC_REQUIRE])
# AC_EXPAND_ONCE(TEXT)
_AC_ARG_VAR_PRECIOUS(build_alias)dnl
_AC_ARG_VAR_PRECIOUS(host_alias)dnl
_AC_ARG_VAR_PRECIOUS(target_alias)dnl
-AC_LANG(C)
+AC_LANG_PUSH(C)
_AC_PROG_ECHO()dnl
dnl Substitute for predefined variables.
# AC_DIAGNOSE(CATEGORY, MESSAGE)
-# ------------------------------
-# Report a MESSAGE to the user of autoconf if `-W' or `-W all' was
-# specified.
-m4_define([AC_DIAGNOSE],
-[m4_warn($@)])
+# AC_FATAL(MESSAGE, [EXIT-STATUS])
+# --------------------------------
+m4_copy([m4_warn], [AC_DIAGNOSE])
+m4_copy([m4_fatal], [AC_FATAL])
# AC_WARNING(MESSAGE)
[AC_DIAGNOSE([syntax], [$1])])
-# AC_FATAL(MESSAGE, [EXIT-STATUS])
-# --------------------------------
-m4_define([AC_FATAL],
-[m4_fatal($@)])
-
-
## ---------------------------------------- ##
# AC_MSG_NOTICE(STRING)
# AC_MSG_ERROR(ERROR, [EXIT-STATUS = 1])
# --------------------------------------
-m4_define([AC_MSG_WARN], [AS_WARN($@)])
-m4_define([AC_MSG_NOTICE], [AS_MESSAGE($@)])
-m4_define([AC_MSG_ERROR], [AS_ERROR($@)])
+m4_copy([AS_WARN], [AC_MSG_WARN])
+m4_copy([AS_MESSAGE], [AC_MSG_NOTICE])
+m4_copy([AS_ERROR], [AC_MSG_ERROR])
# AU::AC_CHECKING(FEATURE)
# AC_LANG(LANG)
# -------------
# Set the current language to LANG.
-#
-# Do *not* write AC_LANG([$1]), because this pair of parens does not
-# correspond to an evaluation, rather, they are just part of the name.
-# If you add quotes here, they will be part of the name too, yielding
-# `AC_LANG([C])' for instance, which does not exist.
AC_DEFUN([AC_LANG],
-[m4_if(m4_defn([_AC_LANG]), [$1], [],
- [m4_define([_AC_LANG], [$1])dnl
+[m4_ifdef([_AC_LANG],
+ [m4_if(m4_defn([_AC_LANG]), [$1], [],
+ [m4_define([_AC_LANG], [$1])])dnl
_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
# ------------------
# Save the current language, and use LANG.
m4_define([AC_LANG_PUSH],
-[m4_pushdef([_AC_LANG], m4_defn([_AC_LANG]))dnl
+[m4_pushdef([_AC_LANG],
+ m4_ifdef([_AC_LANG],
+ [m4_defn([_AC_LANG])]))dnl
AC_LANG([$1])])
-# AC_LANG_POP
-# -----------
-# Restore the previous language.
+# AC_LANG_POP([LANG])
+# -------------------
+# If given, check that the current language is LANG, and restore the
+# previous language.
m4_define([AC_LANG_POP],
-[m4_popdef([_AC_LANG])dnl
+[m4_ifval([$1],
+ [m4_if([$1], m4_defn([_AC_LANG]), [],
+ [m4_fatal([$0($1): unexpected current language: ]_AC_LANG)])])dnl
+m4_popdef([_AC_LANG])dnl
m4_if(_AC_LANG, [_AC_LANG], [AC_FATAL([too many $0])])dnl
AC_LANG(_AC_LANG)])
AC_MSG_ERROR([C preprocessor "$CPP" fails sanity check])
fi
AC_SUBST(CPP)dnl
-AC_LANG_POP()dnl
+AC_LANG_POP(C)dnl
])# AC_PROG_CPP
# This just gives the user an opportunity to specify an alternative
# search list for the C compiler.
AC_DEFUN([AC_PROG_CC],
-[AC_LANG_PUSH(C)
+[AC_LANG_PUSH(C)dnl
AC_ARG_VAR([CC], [C compiler command])
AC_ARG_VAR([CFLAGS], [C compiler flags])
m4_ifval([$1],
choke me
@%:@endif],
[_AC_PROG_CXX_EXIT_DECLARATION])
-AC_LANG_POP
+AC_LANG_POP(C)dnl
])# AC_PROG_CC
AC_MSG_ERROR([C++ preprocessor "$CXXCPP" fails sanity check])
fi
AC_SUBST(CXXCPP)dnl
-AC_LANG_POP()dnl
+AC_LANG_POP(C++)dnl
])# AC_PROG_CXXCPP
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CXX_G
_AC_PROG_CXX_EXIT_DECLARATION
-AC_LANG_POP
+AC_LANG_POP(C++)dnl
])# AC_PROG_CXX
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_F77_G
-AC_LANG_POP
+AC_LANG_POP(Fortran 77)dnl
])# AC_PROG_F77
FFLAGS=$ac_save_FFLAGS
rm -f conftest.*
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
# If we are using xlf then replace all the commas with spaces.
if echo $ac_f77_v_output | grep xlfentry >/dev/null 2>&1; then
])
FLIBS="$ac_cv_flibs"
AC_SUBST(FLIBS)
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
])# AC_F77_LIBRARY_LDFLAGS
fi
LIBS=$ac_save_LIBS
- AC_LANG_POP()dnl
+ AC_LANG_POP(C)dnl
rm -f cf77_test* conftest*])
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
])
])# _AC_F77_NAME_MANGLING
in macros that need to temporarily switch to a particular language.
@end defmac
-@defmac AC_LANG_POP
+@defmac AC_LANG_POP (@ovar{language})
@maindex LANG_POP
Select the language that is saved on the top of the stack, as set by
@code{AC_LANG_PUSH}, and remove it from the stack.
+
+If given, @var{language} specifies the language we just @emph{quit}. It
+is a good idea to specify it when it's known (which should be the
+case...), since Autoconf will track inconsistencies.
+
+@example
+AC_LANG_PUSH(Fortran 77)
+# Perform some tests on Fortran 77.
+# ...
+AC_LANG_POP(Fortran 77)
+@end example
@end defmac
@defmac AC_REQUIRE_CPP
# AC_LANG(LANG)
# -------------
# Set the current language to LANG.
-#
-# Do *not* write AC_LANG([$1]), because this pair of parens does not
-# correspond to an evaluation, rather, they are just part of the name.
-# If you add quotes here, they will be part of the name too, yielding
-# `AC_LANG([C])' for instance, which does not exist.
AC_DEFUN([AC_LANG],
-[m4_if(m4_defn([_AC_LANG]), [$1], [],
- [m4_define([_AC_LANG], [$1])dnl
+[m4_ifdef([_AC_LANG],
+ [m4_if(m4_defn([_AC_LANG]), [$1], [],
+ [m4_define([_AC_LANG], [$1])])dnl
_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
# ------------------
# Save the current language, and use LANG.
m4_define([AC_LANG_PUSH],
-[m4_pushdef([_AC_LANG], m4_defn([_AC_LANG]))dnl
+[m4_pushdef([_AC_LANG],
+ m4_ifdef([_AC_LANG],
+ [m4_defn([_AC_LANG])]))dnl
AC_LANG([$1])])
-# AC_LANG_POP
-# -----------
-# Restore the previous language.
+# AC_LANG_POP([LANG])
+# -------------------
+# If given, check that the current language is LANG, and restore the
+# previous language.
m4_define([AC_LANG_POP],
-[m4_popdef([_AC_LANG])dnl
+[m4_ifval([$1],
+ [m4_if([$1], m4_defn([_AC_LANG]), [],
+ [m4_fatal([$0($1): unexpected current language: ]_AC_LANG)])])dnl
+m4_popdef([_AC_LANG])dnl
m4_if(_AC_LANG, [_AC_LANG], [AC_FATAL([too many $0])])dnl
AC_LANG(_AC_LANG)])
AC_MSG_ERROR([C preprocessor "$CPP" fails sanity check])
fi
AC_SUBST(CPP)dnl
-AC_LANG_POP()dnl
+AC_LANG_POP(C)dnl
])# AC_PROG_CPP
# This just gives the user an opportunity to specify an alternative
# search list for the C compiler.
AC_DEFUN([AC_PROG_CC],
-[AC_LANG_PUSH(C)
+[AC_LANG_PUSH(C)dnl
AC_ARG_VAR([CC], [C compiler command])
AC_ARG_VAR([CFLAGS], [C compiler flags])
m4_ifval([$1],
choke me
@%:@endif],
[_AC_PROG_CXX_EXIT_DECLARATION])
-AC_LANG_POP
+AC_LANG_POP(C)dnl
])# AC_PROG_CC
AC_MSG_ERROR([C++ preprocessor "$CXXCPP" fails sanity check])
fi
AC_SUBST(CXXCPP)dnl
-AC_LANG_POP()dnl
+AC_LANG_POP(C++)dnl
])# AC_PROG_CXXCPP
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CXX_G
_AC_PROG_CXX_EXIT_DECLARATION
-AC_LANG_POP
+AC_LANG_POP(C++)dnl
])# AC_PROG_CXX
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_F77_G
-AC_LANG_POP
+AC_LANG_POP(Fortran 77)dnl
])# AC_PROG_F77
FFLAGS=$ac_save_FFLAGS
rm -f conftest.*
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
# If we are using xlf then replace all the commas with spaces.
if echo $ac_f77_v_output | grep xlfentry >/dev/null 2>&1; then
])
FLIBS="$ac_cv_flibs"
AC_SUBST(FLIBS)
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
])# AC_F77_LIBRARY_LDFLAGS
fi
LIBS=$ac_save_LIBS
- AC_LANG_POP()dnl
+ AC_LANG_POP(C)dnl
rm -f cf77_test* conftest*])
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
])
])# _AC_F77_NAME_MANGLING
# AC_LANG(LANG)
# -------------
# Set the current language to LANG.
-#
-# Do *not* write AC_LANG([$1]), because this pair of parens does not
-# correspond to an evaluation, rather, they are just part of the name.
-# If you add quotes here, they will be part of the name too, yielding
-# `AC_LANG([C])' for instance, which does not exist.
AC_DEFUN([AC_LANG],
-[m4_if(m4_defn([_AC_LANG]), [$1], [],
- [m4_define([_AC_LANG], [$1])dnl
+[m4_ifdef([_AC_LANG],
+ [m4_if(m4_defn([_AC_LANG]), [$1], [],
+ [m4_define([_AC_LANG], [$1])])dnl
_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
# ------------------
# Save the current language, and use LANG.
m4_define([AC_LANG_PUSH],
-[m4_pushdef([_AC_LANG], m4_defn([_AC_LANG]))dnl
+[m4_pushdef([_AC_LANG],
+ m4_ifdef([_AC_LANG],
+ [m4_defn([_AC_LANG])]))dnl
AC_LANG([$1])])
-# AC_LANG_POP
-# -----------
-# Restore the previous language.
+# AC_LANG_POP([LANG])
+# -------------------
+# If given, check that the current language is LANG, and restore the
+# previous language.
m4_define([AC_LANG_POP],
-[m4_popdef([_AC_LANG])dnl
+[m4_ifval([$1],
+ [m4_if([$1], m4_defn([_AC_LANG]), [],
+ [m4_fatal([$0($1): unexpected current language: ]_AC_LANG)])])dnl
+m4_popdef([_AC_LANG])dnl
m4_if(_AC_LANG, [_AC_LANG], [AC_FATAL([too many $0])])dnl
AC_LANG(_AC_LANG)])
AC_MSG_ERROR([C preprocessor "$CPP" fails sanity check])
fi
AC_SUBST(CPP)dnl
-AC_LANG_POP()dnl
+AC_LANG_POP(C)dnl
])# AC_PROG_CPP
# This just gives the user an opportunity to specify an alternative
# search list for the C compiler.
AC_DEFUN([AC_PROG_CC],
-[AC_LANG_PUSH(C)
+[AC_LANG_PUSH(C)dnl
AC_ARG_VAR([CC], [C compiler command])
AC_ARG_VAR([CFLAGS], [C compiler flags])
m4_ifval([$1],
choke me
@%:@endif],
[_AC_PROG_CXX_EXIT_DECLARATION])
-AC_LANG_POP
+AC_LANG_POP(C)dnl
])# AC_PROG_CC
AC_MSG_ERROR([C++ preprocessor "$CXXCPP" fails sanity check])
fi
AC_SUBST(CXXCPP)dnl
-AC_LANG_POP()dnl
+AC_LANG_POP(C++)dnl
])# AC_PROG_CXXCPP
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CXX_G
_AC_PROG_CXX_EXIT_DECLARATION
-AC_LANG_POP
+AC_LANG_POP(C++)dnl
])# AC_PROG_CXX
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_F77_G
-AC_LANG_POP
+AC_LANG_POP(Fortran 77)dnl
])# AC_PROG_F77
FFLAGS=$ac_save_FFLAGS
rm -f conftest.*
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
# If we are using xlf then replace all the commas with spaces.
if echo $ac_f77_v_output | grep xlfentry >/dev/null 2>&1; then
])
FLIBS="$ac_cv_flibs"
AC_SUBST(FLIBS)
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
])# AC_F77_LIBRARY_LDFLAGS
fi
LIBS=$ac_save_LIBS
- AC_LANG_POP()dnl
+ AC_LANG_POP(C)dnl
rm -f cf77_test* conftest*])
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
])
])# _AC_F77_NAME_MANGLING
# AC_DIVERT_PUSH(DIVERSION-NAME)
-# ------------------------------
-m4_define([AC_DIVERT_PUSH],
-[m4_divert_push($@)])
-
-
# AC_DIVERT_POP
-# -------------
-m4_define([AC_DIVERT_POP],
-[m4_divert_pop($@)])
+# ------------------------------
+m4_copy([m4_divert_push],[AC_DIVERT_PUSH])
+m4_copy([m4_divert_pop], [AC_DIVERT_POP])
# Throw away output until AC_INIT is called.
# ------------------
# If STRING has never been AC_PROVIDE'd, then expand it. A macro must
# be AC_DEFUN'd if either it is AC_REQUIRE'd, or it AC_REQUIRE's.
-m4_define([AC_REQUIRE],
-[m4_require([$1])])
+m4_copy([m4_require], [AC_REQUIRE])
# AC_EXPAND_ONCE(TEXT)
_AC_ARG_VAR_PRECIOUS(build_alias)dnl
_AC_ARG_VAR_PRECIOUS(host_alias)dnl
_AC_ARG_VAR_PRECIOUS(target_alias)dnl
-AC_LANG(C)
+AC_LANG_PUSH(C)
_AC_PROG_ECHO()dnl
dnl Substitute for predefined variables.
# AC_DIAGNOSE(CATEGORY, MESSAGE)
-# ------------------------------
-# Report a MESSAGE to the user of autoconf if `-W' or `-W all' was
-# specified.
-m4_define([AC_DIAGNOSE],
-[m4_warn($@)])
+# AC_FATAL(MESSAGE, [EXIT-STATUS])
+# --------------------------------
+m4_copy([m4_warn], [AC_DIAGNOSE])
+m4_copy([m4_fatal], [AC_FATAL])
# AC_WARNING(MESSAGE)
[AC_DIAGNOSE([syntax], [$1])])
-# AC_FATAL(MESSAGE, [EXIT-STATUS])
-# --------------------------------
-m4_define([AC_FATAL],
-[m4_fatal($@)])
-
-
## ---------------------------------------- ##
# AC_MSG_NOTICE(STRING)
# AC_MSG_ERROR(ERROR, [EXIT-STATUS = 1])
# --------------------------------------
-m4_define([AC_MSG_WARN], [AS_WARN($@)])
-m4_define([AC_MSG_NOTICE], [AS_MESSAGE($@)])
-m4_define([AC_MSG_ERROR], [AS_ERROR($@)])
+m4_copy([AS_WARN], [AC_MSG_WARN])
+m4_copy([AS_MESSAGE], [AC_MSG_NOTICE])
+m4_copy([AS_ERROR], [AC_MSG_ERROR])
# AU::AC_CHECKING(FEATURE)
# AC_LANG(LANG)
# -------------
# Set the current language to LANG.
-#
-# Do *not* write AC_LANG([$1]), because this pair of parens does not
-# correspond to an evaluation, rather, they are just part of the name.
-# If you add quotes here, they will be part of the name too, yielding
-# `AC_LANG([C])' for instance, which does not exist.
AC_DEFUN([AC_LANG],
-[m4_if(m4_defn([_AC_LANG]), [$1], [],
- [m4_define([_AC_LANG], [$1])dnl
+[m4_ifdef([_AC_LANG],
+ [m4_if(m4_defn([_AC_LANG]), [$1], [],
+ [m4_define([_AC_LANG], [$1])])dnl
_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
# ------------------
# Save the current language, and use LANG.
m4_define([AC_LANG_PUSH],
-[m4_pushdef([_AC_LANG], m4_defn([_AC_LANG]))dnl
+[m4_pushdef([_AC_LANG],
+ m4_ifdef([_AC_LANG],
+ [m4_defn([_AC_LANG])]))dnl
AC_LANG([$1])])
-# AC_LANG_POP
-# -----------
-# Restore the previous language.
+# AC_LANG_POP([LANG])
+# -------------------
+# If given, check that the current language is LANG, and restore the
+# previous language.
m4_define([AC_LANG_POP],
-[m4_popdef([_AC_LANG])dnl
+[m4_ifval([$1],
+ [m4_if([$1], m4_defn([_AC_LANG]), [],
+ [m4_fatal([$0($1): unexpected current language: ]_AC_LANG)])])dnl
+m4_popdef([_AC_LANG])dnl
m4_if(_AC_LANG, [_AC_LANG], [AC_FATAL([too many $0])])dnl
AC_LANG(_AC_LANG)])
AC_MSG_ERROR([C preprocessor "$CPP" fails sanity check])
fi
AC_SUBST(CPP)dnl
-AC_LANG_POP()dnl
+AC_LANG_POP(C)dnl
])# AC_PROG_CPP
# This just gives the user an opportunity to specify an alternative
# search list for the C compiler.
AC_DEFUN([AC_PROG_CC],
-[AC_LANG_PUSH(C)
+[AC_LANG_PUSH(C)dnl
AC_ARG_VAR([CC], [C compiler command])
AC_ARG_VAR([CFLAGS], [C compiler flags])
m4_ifval([$1],
choke me
@%:@endif],
[_AC_PROG_CXX_EXIT_DECLARATION])
-AC_LANG_POP
+AC_LANG_POP(C)dnl
])# AC_PROG_CC
AC_MSG_ERROR([C++ preprocessor "$CXXCPP" fails sanity check])
fi
AC_SUBST(CXXCPP)dnl
-AC_LANG_POP()dnl
+AC_LANG_POP(C++)dnl
])# AC_PROG_CXXCPP
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CXX_G
_AC_PROG_CXX_EXIT_DECLARATION
-AC_LANG_POP
+AC_LANG_POP(C++)dnl
])# AC_PROG_CXX
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_F77_G
-AC_LANG_POP
+AC_LANG_POP(Fortran 77)dnl
])# AC_PROG_F77
FFLAGS=$ac_save_FFLAGS
rm -f conftest.*
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
# If we are using xlf then replace all the commas with spaces.
if echo $ac_f77_v_output | grep xlfentry >/dev/null 2>&1; then
])
FLIBS="$ac_cv_flibs"
AC_SUBST(FLIBS)
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
])# AC_F77_LIBRARY_LDFLAGS
fi
LIBS=$ac_save_LIBS
- AC_LANG_POP()dnl
+ AC_LANG_POP(C)dnl
rm -f cf77_test* conftest*])
-AC_LANG_POP()dnl
+AC_LANG_POP(Fortran 77)dnl
])
])# _AC_F77_NAME_MANGLING
# m4_copy(SRC, DST)
# -----------------
# Define DST as the definition of SRC.
+# What's the difference between:
+# 1. m4_copy([from], [to])
+# 2. m4_define([from], [to($@)])
+# Well, obviously 1 is more expansive in space. Maybe 2 is more expansive
+# in time, but because of the space cost of 1, it's not that obvious.
+# Nevertheless, one huge difference is the handling of `$0'. If `from'
+# uses `$0', then with 1, `to''s `$0' is `to', while it is `from' in 2.
+# The user will certainly prefer see `from'.
m4_define([m4_copy],
[m4_define([$2], m4_defn([$1]))])
# m4_for(VARIABLE, FIRST, LAST, [STEP = +/-1], EXPRESSION)
# --------------------------------------------------------
# Expand EXPRESSION defining VARIABLE to FROM, FROM + 1, ..., TO.
-# Both limits are included.
-
+# Both limits are included, and bounds are checked for consistency.
m4_define([m4_for],
[m4_case(m4_sign(m4_eval($3 - $2)),
1, [m4_assert(m4_sign(m4_default($4, 1)) == 1)],
[_m4_for([$1], [$3], m4_default([$4], -1), [$5])])dnl
m4_popdef([$1])])
+
+# _m4_for(VARIABLE, FIRST, LAST, STEP, EXPRESSION)
+# ------------------------------------------------
+# Core of the loop, no consistency checks.
m4_define([_m4_for],
[$4[]dnl
m4_if($1, [$2], [],
## --------------------------- ##
-# _m4_divert(DIBERSION-NAME or NUMBER)
+# _m4_divert(DIVERSION-NAME or NUMBER)
# ------------------------------------
-# If DIVERSION-NAME is the name of a diversion, return its number, otherwise
-# return makeNUMBER.
+# If DIVERSION-NAME is the name of a diversion, return its number,
+# otherwise if is a NUMBER return it.
m4_define([_m4_divert],
[m4_ifdef([_m4_divert($1)],
[m4_indir([_m4_divert($1)])],
# -----------------------------
m4_define([m4_expansion_stack_push],
[m4_pushdef([m4_expansion_stack],
- [$1]
-m4_defn([m4_expansion_stack]))])
+ [$1]m4_ifdef([m4_expansion_stack], [
+m4_defn([m4_expansion_stack])]))])
# m4_expansion_stack_pop
# -----------------------
# Dump the expansion stack.
m4_define([m4_expansion_stack_dump],
-[m4_errprint(m4_defn([m4_expansion_stack]))dnl
+[m4_ifdef([m4_expansion_stack],
+ [m4_errprintn(m4_defn([m4_expansion_stack]))])dnl
m4_errprintn(m4_location[: the top level])])
# m4_copy(SRC, DST)
# -----------------
# Define DST as the definition of SRC.
+# What's the difference between:
+# 1. m4_copy([from], [to])
+# 2. m4_define([from], [to($@)])
+# Well, obviously 1 is more expansive in space. Maybe 2 is more expansive
+# in time, but because of the space cost of 1, it's not that obvious.
+# Nevertheless, one huge difference is the handling of `$0'. If `from'
+# uses `$0', then with 1, `to''s `$0' is `to', while it is `from' in 2.
+# The user will certainly prefer see `from'.
m4_define([m4_copy],
[m4_define([$2], m4_defn([$1]))])
# m4_for(VARIABLE, FIRST, LAST, [STEP = +/-1], EXPRESSION)
# --------------------------------------------------------
# Expand EXPRESSION defining VARIABLE to FROM, FROM + 1, ..., TO.
-# Both limits are included.
-
+# Both limits are included, and bounds are checked for consistency.
m4_define([m4_for],
[m4_case(m4_sign(m4_eval($3 - $2)),
1, [m4_assert(m4_sign(m4_default($4, 1)) == 1)],
[_m4_for([$1], [$3], m4_default([$4], -1), [$5])])dnl
m4_popdef([$1])])
+
+# _m4_for(VARIABLE, FIRST, LAST, STEP, EXPRESSION)
+# ------------------------------------------------
+# Core of the loop, no consistency checks.
m4_define([_m4_for],
[$4[]dnl
m4_if($1, [$2], [],
## --------------------------- ##
-# _m4_divert(DIBERSION-NAME or NUMBER)
+# _m4_divert(DIVERSION-NAME or NUMBER)
# ------------------------------------
-# If DIVERSION-NAME is the name of a diversion, return its number, otherwise
-# return makeNUMBER.
+# If DIVERSION-NAME is the name of a diversion, return its number,
+# otherwise if is a NUMBER return it.
m4_define([_m4_divert],
[m4_ifdef([_m4_divert($1)],
[m4_indir([_m4_divert($1)])],
# -----------------------------
m4_define([m4_expansion_stack_push],
[m4_pushdef([m4_expansion_stack],
- [$1]
-m4_defn([m4_expansion_stack]))])
+ [$1]m4_ifdef([m4_expansion_stack], [
+m4_defn([m4_expansion_stack])]))])
# m4_expansion_stack_pop
# -----------------------
# Dump the expansion stack.
m4_define([m4_expansion_stack_dump],
-[m4_errprint(m4_defn([m4_expansion_stack]))dnl
+[m4_ifdef([m4_expansion_stack],
+ [m4_errprintn(m4_defn([m4_expansion_stack]))])dnl
m4_errprintn(m4_location[: the top level])])
AT_SETUP([AWK portability])
AT_DATA([configure.ac],
-[[AC_INIT
-]])
+[])
if (gawk --version) >/dev/null 2>&1; then
# Generation of the script.
AC_DEFUN([TRACE1], [TRACE2(m4_shift($@))])
AC_DEFUN([TRACE2], [[$2], $1])
TRACE1(foo, bar, baz)
-TRACE1(foo, AC_TRACE1(bar, baz))
+TRACE1(foo, TRACE1(bar, baz))
TRACE1(foo, active, baz)
TRACE1(foo, [active], TRACE1(active, [active]))
]])
AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir -t TRACE1 -t TRACE2], 0,
[[configure.ac:4:TRACE1:foo:bar:baz
configure.ac:4:TRACE2:bar:baz
-configure.ac:5:TRACE1:foo:AC_TRACE1(bar, baz)
-configure.ac:5:TRACE2:AC_TRACE1(bar, baz)
+configure.ac:5:TRACE1:bar:baz
+configure.ac:5:TRACE2:baz
+configure.ac:5:TRACE1:foo::baz
+configure.ac:5:TRACE2::baz
configure.ac:6:TRACE1:foo:ACTIVE:baz
configure.ac:6:TRACE2:ACTIVE:baz
configure.ac:7:TRACE1:ACTIVE:active
[[
[foo], [bar], [baz].
-[foo], [AC_TRACE1(bar, baz)], [].
+[bar], [baz], [].
+
+[foo], [], [baz].
[foo], [ACTIVE], [baz].
# ${sep}@.
AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir -t TRACE2:'${)===(}@'], 0,
[[[bar])===([baz]
-[AC_TRACE1(bar, baz)]
+[baz]
+[])===([baz]
[ACTIVE])===([baz]
[active]
[active])===([])===([ACTIVE]