]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Clean up a bit the handling of the LANG stack. More is needed.
authorAkim Demaille <akim@epita.fr>
Fri, 4 Feb 2000 08:41:39 +0000 (08:41 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 4 Feb 2000 08:41:39 +0000 (08:41 +0000)
* acgeneral.m4 (AC_LANG_CASE): New macro.
(AC_LANG_RESTORE): Use m4_case.
(AC_LINKER_OPTION): Use AC_LANG_CASE.

ChangeLog
acgeneral.m4
acspecific.m4
lib/autoconf/general.m4
lib/autoconf/specific.m4

index cf65ea428c1eb1722a268810c1a60397f55bb1ff..9a60d8a3c0e35c6a1e30c1a423360f5814b331a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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
index 15ccced003e6070d7db3d77fb25afddfa6558d22..1874bd5088ae0d7e024e72764e4da11fc33b2812 100644 (file)
@@ -314,6 +314,30 @@ dnl Returns EXP1 if non empty, otherwise EXP2.
 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
 
@@ -2064,6 +2088,17 @@ define(AC_MSG_ERROR_UNQUOTED,
 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,
@@ -2108,9 +2143,11 @@ dnl AC_LANG_RESTORE
 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
@@ -4214,21 +4251,20 @@ dnl doesn't currently support.
 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
index 7e233c80ad630437e173c8f0a170bd2d5addde34..a93bdc09211141ea1ce7782552c090759317f83f 100644 (file)
@@ -733,9 +733,8 @@ AC_SUBST(CXXCPP)dnl
 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
@@ -2941,10 +2940,10 @@ EOF
       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
 ])])
 
 
index 15ccced003e6070d7db3d77fb25afddfa6558d22..1874bd5088ae0d7e024e72764e4da11fc33b2812 100644 (file)
@@ -314,6 +314,30 @@ dnl Returns EXP1 if non empty, otherwise EXP2.
 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
 
@@ -2064,6 +2088,17 @@ define(AC_MSG_ERROR_UNQUOTED,
 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,
@@ -2108,9 +2143,11 @@ dnl AC_LANG_RESTORE
 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
@@ -4214,21 +4251,20 @@ dnl doesn't currently support.
 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
index 7e233c80ad630437e173c8f0a170bd2d5addde34..a93bdc09211141ea1ce7782552c090759317f83f 100644 (file)
@@ -733,9 +733,8 @@ AC_SUBST(CXXCPP)dnl
 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
@@ -2941,10 +2940,10 @@ EOF
       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
 ])])