From: Akim Demaille Date: Fri, 4 Feb 2000 08:41:39 +0000 (+0000) Subject: Clean up a bit the handling of the LANG stack. More is needed. X-Git-Tag: autoconf-2.50~1256 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f8a47f153be86a043ba25d23648ee6470d937db;p=thirdparty%2Fautoconf.git 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. --- diff --git a/ChangeLog b/ChangeLog index cf65ea428..9a60d8a3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +1999-11-13 Akim Demaille + + 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 * autoconf.texi (Generic Declarations): Fixed a typo which diff --git a/acgeneral.m4 b/acgeneral.m4 index 15ccced00..1874bd508 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -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 diff --git a/acspecific.m4 b/acspecific.m4 index 7e233c80a..a93bdc092 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -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 ])]) diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 15ccced00..1874bd508 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -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 diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 7e233c80a..a93bdc092 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -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 ])])