* acgeneral.m4 (AC_LANG_CASE): New macro.
(AC_LANG_RESTORE): Use m4_case.
(AC_LINKER_OPTION): Use AC_LANG_CASE.
+1999-11-13 Akim Demaille <akim@epita.fr>
+
+ Clean up a bit the handling of the LANG stack. More is needed.
+
+ * acgeneral.m4 (AC_LANG_CASE): New macro.
+ (AC_LANG_RESTORE): Use m4_case.
+ (AC_LINKER_OPTION): Use AC_LANG_CASE.
+
1999-11-11 Akim Demaille <akim@epita.fr>
* autoconf.texi (Generic Declarations): Fixed a typo which
define([m4_default], [ifval([$1], [$1], [$2])])
+dnl m4_case(SWITCH, VAL1, IF-VAL1, VAL2, IF-VAL2, ..., DEFAULT)
+dnl -----------------------------------------------------------
+dnl m4 equivalent of
+dnl switch (SWITCH)
+dnl {
+dnl case VAL1:
+dnl IF-VAL1;
+dnl break;
+dnl case VAL2:
+dnl IF-VAL2;
+dnl break;
+dnl ...
+dnl default:
+dnl DEFAULT;
+dnl break;
+dnl }.
+dnl All the values are optional, and the macro is robust to active
+dnl symbols properly quoted.
+define(m4_case,
+[ifelse([$1], 1,,
+ [$#], 2, [$2],
+ [$1], [$2], [$3],
+ [m4_case([$1], m4_shift(m4_shift($@)))])])
+
dnl ### Implementing m4 loops
dnl ### Selecting which language to use for testing
+dnl The current scheme is really not beautiful. It'd be better to have
+dnl AC_LANG_PUSH(C), AC_LANG_POP. In addition, that's easy to do. FIXME:
+dnl do it yet for 2.16?
+
+dnl AC_LANG_CASE(LANG1, IF-LANG1, LANG2, IF-LANG2, ..., DEFAULT)
+dnl ------------------------------------------------------------
+dnl Expand into IF-LANG1 if the current language is LANG1 etc. else
+dnl into default.
+define(AC_LANG_CASE,
+[m4_case(AC_LANG, $@)])
+
dnl AC_LANG_C
dnl ---------
AC_DEFUN(AC_LANG_C,
dnl ---------------
dnl Restore the current language from the stack.
pushdef([AC_LANG_RESTORE],
-[ifelse(AC_LANG_STACK, [C], [AC_LANG_C],dnl
-AC_LANG_STACK, [CPLUSPLUS], [AC_LANG_CPLUSPLUS],dnl
-AC_LANG_STACK, [FORTRAN77], [AC_LANG_FORTRAN77])[]popdef([AC_LANG_STACK])])
+[m4_case(AC_LANG_STACK,
+ [C], [AC_LANG_C()],
+ [CPLUSPLUS], [AC_LANG_CPLUSPLUS()],
+ [FORTRAN77], [AC_LANG_FORTRAN77()])dnl
+popdef([AC_LANG_STACK])])
dnl ### Compiler-running mechanics
dnl
dnl pushdef([AC_LINKER_OPTION],
AC_DEFUN(AC_LINKER_OPTION,
-[
- using_gnu_compiler=
-
- ifelse(AC_LANG, [C], test x"$GCC" = xyes && using_gnu_compiler=yes,
- [ifelse(AC_LANG, [CPLUSPLUS], test x"$GXX" = xyes && using_gnu_compiler=yes,
- [ifelse(AC_LANG, [FORTRAN77], test x"$G77" = xyes && using_gnu_compiler=yes)])])
-
- for i in $1; do
- if test x"$using_gnu_compiler" = xyes; then
- $2="[$]$2 -Xlinker $i"
- else
- $2="[$]$2 $i"
- fi
- done
-])
+[AC_LANG_CASE([C], [test x"$GCC" = xyes && using_gnu_compiler=yes],
+ [CPLUSPLUS], [test x"$GXX" = xyes && using_gnu_compiler=yes],
+ [FORTRAN77], [test x"$G77" = xyes && using_gnu_compiler=yes],
+ [using_gnu_compiler=])
+
+dnl I don't understand the point of having the test inside of the
+dnl loop.
+for ac_link_opt in $1; do
+ if test x"$using_gnu_compiler" = xyes; then
+ $2="[$]$2 -Xlinker $ac_link_opt"
+ else
+ $2="[$]$2 $ac_link_opt"
+ fi
+done])
dnl AC_LIST_MEMBER_OF
dnl Require finding the C or C++ preprocessor, whichever is the
dnl current language.
AC_DEFUN(AC_REQUIRE_CPP,
-[ifelse(AC_LANG,
- C, [AC_REQUIRE([AC_PROG_CPP])],
- [AC_REQUIRE([AC_PROG_CXXCPP])])])
+[AC_LANG_CASE(C, [AC_REQUIRE([AC_PROG_CPP])],
+ [AC_REQUIRE([AC_PROG_CXXCPP])])])
dnl AC_PROG_LEX
echo "configure: failed program was:" >&AC_FD_CC
cat conftest.$ac_ext >&AC_FD_CC
fi
-
dnl We need to pop the language stack twice.
- AC_LANG_RESTORE
- AC_LANG_RESTORE
+dnl FIXME: Why? You've done it above, AFAICT.
+AC_LANG_RESTORE()dnl
+AC_LANG_RESTORE()dnl
])])
define([m4_default], [ifval([$1], [$1], [$2])])
+dnl m4_case(SWITCH, VAL1, IF-VAL1, VAL2, IF-VAL2, ..., DEFAULT)
+dnl -----------------------------------------------------------
+dnl m4 equivalent of
+dnl switch (SWITCH)
+dnl {
+dnl case VAL1:
+dnl IF-VAL1;
+dnl break;
+dnl case VAL2:
+dnl IF-VAL2;
+dnl break;
+dnl ...
+dnl default:
+dnl DEFAULT;
+dnl break;
+dnl }.
+dnl All the values are optional, and the macro is robust to active
+dnl symbols properly quoted.
+define(m4_case,
+[ifelse([$1], 1,,
+ [$#], 2, [$2],
+ [$1], [$2], [$3],
+ [m4_case([$1], m4_shift(m4_shift($@)))])])
+
dnl ### Implementing m4 loops
dnl ### Selecting which language to use for testing
+dnl The current scheme is really not beautiful. It'd be better to have
+dnl AC_LANG_PUSH(C), AC_LANG_POP. In addition, that's easy to do. FIXME:
+dnl do it yet for 2.16?
+
+dnl AC_LANG_CASE(LANG1, IF-LANG1, LANG2, IF-LANG2, ..., DEFAULT)
+dnl ------------------------------------------------------------
+dnl Expand into IF-LANG1 if the current language is LANG1 etc. else
+dnl into default.
+define(AC_LANG_CASE,
+[m4_case(AC_LANG, $@)])
+
dnl AC_LANG_C
dnl ---------
AC_DEFUN(AC_LANG_C,
dnl ---------------
dnl Restore the current language from the stack.
pushdef([AC_LANG_RESTORE],
-[ifelse(AC_LANG_STACK, [C], [AC_LANG_C],dnl
-AC_LANG_STACK, [CPLUSPLUS], [AC_LANG_CPLUSPLUS],dnl
-AC_LANG_STACK, [FORTRAN77], [AC_LANG_FORTRAN77])[]popdef([AC_LANG_STACK])])
+[m4_case(AC_LANG_STACK,
+ [C], [AC_LANG_C()],
+ [CPLUSPLUS], [AC_LANG_CPLUSPLUS()],
+ [FORTRAN77], [AC_LANG_FORTRAN77()])dnl
+popdef([AC_LANG_STACK])])
dnl ### Compiler-running mechanics
dnl
dnl pushdef([AC_LINKER_OPTION],
AC_DEFUN(AC_LINKER_OPTION,
-[
- using_gnu_compiler=
-
- ifelse(AC_LANG, [C], test x"$GCC" = xyes && using_gnu_compiler=yes,
- [ifelse(AC_LANG, [CPLUSPLUS], test x"$GXX" = xyes && using_gnu_compiler=yes,
- [ifelse(AC_LANG, [FORTRAN77], test x"$G77" = xyes && using_gnu_compiler=yes)])])
-
- for i in $1; do
- if test x"$using_gnu_compiler" = xyes; then
- $2="[$]$2 -Xlinker $i"
- else
- $2="[$]$2 $i"
- fi
- done
-])
+[AC_LANG_CASE([C], [test x"$GCC" = xyes && using_gnu_compiler=yes],
+ [CPLUSPLUS], [test x"$GXX" = xyes && using_gnu_compiler=yes],
+ [FORTRAN77], [test x"$G77" = xyes && using_gnu_compiler=yes],
+ [using_gnu_compiler=])
+
+dnl I don't understand the point of having the test inside of the
+dnl loop.
+for ac_link_opt in $1; do
+ if test x"$using_gnu_compiler" = xyes; then
+ $2="[$]$2 -Xlinker $ac_link_opt"
+ else
+ $2="[$]$2 $ac_link_opt"
+ fi
+done])
dnl AC_LIST_MEMBER_OF
dnl Require finding the C or C++ preprocessor, whichever is the
dnl current language.
AC_DEFUN(AC_REQUIRE_CPP,
-[ifelse(AC_LANG,
- C, [AC_REQUIRE([AC_PROG_CPP])],
- [AC_REQUIRE([AC_PROG_CXXCPP])])])
+[AC_LANG_CASE(C, [AC_REQUIRE([AC_PROG_CPP])],
+ [AC_REQUIRE([AC_PROG_CXXCPP])])])
dnl AC_PROG_LEX
echo "configure: failed program was:" >&AC_FD_CC
cat conftest.$ac_ext >&AC_FD_CC
fi
-
dnl We need to pop the language stack twice.
- AC_LANG_RESTORE
- AC_LANG_RESTORE
+dnl FIXME: Why? You've done it above, AFAICT.
+AC_LANG_RESTORE()dnl
+AC_LANG_RESTORE()dnl
])])