From: Akim Demaille Date: Thu, 11 May 2000 12:41:33 +0000 (+0000) Subject: Replace AC_LANG_SAVE/AC_LANG_RESTORE with AC_LANG_PUSH/AC_LANG_POP. X-Git-Tag: autoconf-2.50~928 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=347ad8e7339ae07a91189ff93f4597a795f66e92;p=thirdparty%2Fautoconf.git Replace AC_LANG_SAVE/AC_LANG_RESTORE with AC_LANG_PUSH/AC_LANG_POP. * aclang.m4 (_AC_LANG_CURRENT, AC_LANG_STACK): You two are the same thing, which now we shall name `_AC_LANG'. All users adjusted. (AC_LANG_PUSH, AC_LANG_POP): New macros. (AC_LANG_SAVE, AC_LANG_RESTORE): AU defined. (AC_PROG_CC_WORKS, AC_PROG_CXXCPP, AC_PROG_CXX_WORKS, AC_PROG_F77_WORKS, AC_F77_LIBRARY_LDFLAGS, AC_F77_NAME_MANGLING): Use them. (AC_F77_LIBRARY_LDFLAGS): Move the requirements at its top. * doc/autoconf.texi (Language Choice): Document them. (Old Macros): Welcome AC_LANG_SAVE and AC_LANG_RESTORE. --- diff --git a/ChangeLog b/ChangeLog index ed8632c51..af7162713 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2000-05-11 Akim Demaille + + Replace AC_LANG_SAVE/AC_LANG_RESTORE with AC_LANG_PUSH/AC_LANG_POP. + + * aclang.m4 (_AC_LANG_CURRENT, AC_LANG_STACK): You two are the same + thing, which now we shall name `_AC_LANG'. + All users adjusted. + (AC_LANG_PUSH, AC_LANG_POP): New macros. + (AC_LANG_SAVE, AC_LANG_RESTORE): AU defined. + (AC_PROG_CC_WORKS, AC_PROG_CXXCPP, AC_PROG_CXX_WORKS, + AC_PROG_F77_WORKS, AC_F77_LIBRARY_LDFLAGS, AC_F77_NAME_MANGLING): + Use them. + (AC_F77_LIBRARY_LDFLAGS): Move the requirements at its top. + * doc/autoconf.texi (Language Choice): Document them. + (Old Macros): Welcome AC_LANG_SAVE and AC_LANG_RESTORE. + 2000-05-11 Akim Demaille * aclang.m4 (AC_F77_LIBRARY_LDFLAGS): Less adventurous use of diff --git a/aclang.m4 b/aclang.m4 index ae4c90af7..6250fd69c 100644 --- a/aclang.m4 +++ b/aclang.m4 @@ -73,9 +73,6 @@ ## ----------------------- ## -# The current scheme is really not beautiful. It'd be better to have -# AC_LANG_PUSH(C), AC_LANG_POP. In addition, that's easy to do. -# FIXME: do it yet for 2.16? # ---------------------------- # # Generic language selection. # @@ -86,24 +83,7 @@ # Expand into IF-LANG1 if the current language is LANG1 etc. else # into default. define(AC_LANG_CASE, -[m4_case(_AC_LANG_CURRENT, $@)]) - - -# AC_LANG_SAVE -# ------------ -# Push the current language on a stack. -define(AC_LANG_SAVE, -[pushdef([AC_LANG_STACK], _AC_LANG_CURRENT)]) - - -# AC_LANG_RESTORE -# --------------- -# Restore the current language from the stack. -pushdef([AC_LANG_RESTORE], -[ifelse(AC_LANG_STACK, [AC_LANG_STACK], - [AC_FATAL([too many AC_LANG_RESTORE])])dnl -AC_LANG(AC_LANG_STACK)dnl -popdef([AC_LANG_STACK])]) +[m4_case(_AC_LANG, $@)]) # _AC_LANG_DISPATCH(MACRO, LANG, ARGS) @@ -125,8 +105,42 @@ define([_AC_LANG_DISPATCH], # 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_define([_AC_LANG_CURRENT], [$1])dnl -_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[m4_define([_AC_LANG], [$1])dnl +_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) + + +# AC_LANG_PUSH(LANG) +# ------------------ +# Save the current language, and use LANG. +define([AC_LANG_PUSH], +[pushdef([_AC_LANG])dnl +AC_LANG([$1])]) + + +# AC_LANG_POP +# ----------- +# Restore the previous language. +define([AC_LANG_POP], +[popdef([_AC_LANG])dnl +ifelse(_AC_LANG, [_AC_LANG], + [AC_FATAL([too many $0])])dnl +AC_LANG(_AC_LANG)]) + + +# AC_LANG_SAVE +# ------------ +# Save the current language, but don't change language. +AU_DEFUN([AC_LANG_SAVE], +[AC_DIAGNOSE([obsolete], + [instead of using `AC_LANG', `AC_LANG_SAVE', +and `AC_LANG_RESTORE', you should use `AC_LANG_PUSH' and `AC_LANG_POP'.]) +pushdef([_AC_LANG], _AC_LANG)]) + + +# AC_LANG_RESTORE +# --------------- +# Restore the current language from the stack. +AU_DEFUN([AC_LANG_RESTORE], [AC_LANG_POP($@)]) # AC_LANG_SOURCE(BODY) @@ -134,7 +148,7 @@ _AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) # Produce a valid source for the current language, which includes the # BODY. Include the `#line' sync lines. AC_DEFUN([AC_LANG_SOURCE], -[_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # AC_LANG_PROGRAM(PROLOGUE, BODY) @@ -144,14 +158,14 @@ AC_DEFUN([AC_LANG_SOURCE], # execution the BODY (typically glued inside the `main' function, or # equivalent). AC_DEFUN([AC_LANG_PROGRAM], -[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)])]) +[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])]) # AC_LANG_CALL(PROLOGUE, FUNCTION) # -------------------------------- # Call the FUNCTION. AC_DEFUN([AC_LANG_CALL], -[_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) @@ -423,11 +437,10 @@ fi # ---------------- AC_DEFUN(AC_PROG_CC_WORKS, [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(C) +AC_LANG_PUSH(C) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_cc_works) if test $ac_cv_prog_cc_works = no; then AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.], 77) @@ -557,12 +570,11 @@ AC_DEFUN(AC_PROG_CXXCPP, [AC_MSG_CHECKING(how to run the C++ preprocessor) if test -z "$CXXCPP"; then AC_CACHE_VAL(ac_cv_prog_CXXCPP, -[AC_LANG_SAVE()dnl -AC_LANG(C++)dnl +[AC_LANG_PUSH(C++) CXXCPP="${CXX-g++} -E" AC_TRY_CPP([#include ], , CXXCPP=/lib/cpp) ac_cv_prog_CXXCPP=$CXXCPP -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl ])dnl CXXCPP=$ac_cv_prog_CXXCPP fi @@ -620,11 +632,10 @@ fi # ----------------- AC_DEFUN(AC_PROG_CXX_WORKS, [AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $CPPFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(C++) +AC_LANG_PUSH(C++) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_cxx_works) if test $ac_cv_prog_cxx_works = no; then AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.], 77) @@ -716,13 +727,12 @@ fi # compiler is `g77'). AC_DEFUN(AC_PROG_F77_WORKS, [AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +AC_LANG_PUSH(Fortran 77) AC_TRY_COMPILER( [ program conftest end ], ac_cv_prog_f77_works, ac_cv_prog_f77_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_f77_works) if test $ac_cv_prog_f77_works = no; then AC_MSG_ERROR([installation or configuration problem: Fortran 77 compiler cannot create executables.], 77) @@ -1200,14 +1210,12 @@ fi # However, nearly all of this macro came from the "OCTAVE_FLIBS" macro # in "octave-2.0.13/aclocal.m4", and full credit should go to John # W. Eaton for writing this extremely useful macro. Thank you John. -AC_DEFUN(AC_F77_LIBRARY_LDFLAGS, -[AC_CACHE_CHECK([for Fortran 77 libraries], - ac_cv_flibs, +AC_DEFUN([AC_F77_LIBRARY_LDFLAGS], [AC_REQUIRE([AC_PROG_F77])dnl AC_REQUIRE([AC_CYGWIN])dnl - -AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +AC_CACHE_CHECK([for Fortran 77 libraries], + ac_cv_flibs, +[AC_LANG_PUSH(Fortran 77) # This is the simplest of all Fortran 77 programs. cat >conftest.$ac_ext <&8 rm -f conftest.* -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl # This will ultimately be our output variable. FLIBS= @@ -1333,7 +1341,6 @@ done ac_ld_run_path=`echo $ac_link_output | sed -n -e 's%^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$%\1%p'` test "x$ac_ld_run_path" != x && FLIBS="$ac_ld_run_path $FLIBS" - ac_cv_flibs=$FLIBS ]) AC_SUBST(FLIBS) @@ -1370,8 +1377,7 @@ AC_REQUIRE([AC_PROG_F77])dnl AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl AC_CACHE_CHECK([for Fortran 77 name-mangling scheme], ac_cv_f77_mangling, -[AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +[AC_LANG_PUSH(Fortran 77) AC_COMPILE_IFELSE( [ subroutine foobar() return @@ -1381,8 +1387,7 @@ AC_COMPILE_IFELSE( end], [mv conftest.${ac_objext} cf77_test.${ac_objext} - AC_LANG_SAVE()dnl - AC_LANG(C) + AC_LANG_PUSH(C) ac_save_LIBS=$LIBS LIBS="cf77_test.${ac_objext} $FLIBS $LIBS" @@ -1416,9 +1421,9 @@ AC_COMPILE_IFELSE( fi LIBS=$ac_save_LIBS - AC_LANG_RESTORE()dnl + AC_LANG_POP()dnl rm -f cf77_test*]) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl ]) dnl Get case/underscore from cache variable, in case above tests were skipped: f77_case=`echo "$ac_cv_f77_mangling" | sed 's/ case.*$//'` diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 7bd2a1d52..44e0b2a1b 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -4671,24 +4671,17 @@ otherwise. @end table @end defmac -@defmac AC_LANG_SAVE -@maindex LANG_SAVE -Remember the current language (as set by @code{AC_LANG_C}, -@code{AC_LANG_CPLUSPLUS} or @code{AC_LANG_FORTRAN77}) on a stack. Does -not change which language is current. Use this macro and -@code{AC_LANG_RESTORE} in macros that need to temporarily switch to a -particular language. +@defmac AC_LANG_PUSH (@var{language}) +@maindex LANG_PUSH +Remember the current language (as set by @code{AC_LANG}) on a stack, and +then select the @var{language}. Use this macro and @code{AC_LANG_POP} +in macros that need to temporarily switch to a particular language. @end defmac -@defmac AC_LANG_RESTORE -@maindex LANG_RESTORE +@defmac AC_LANG_POP +@maindex LANG_POP Select the language that is saved on the top of the stack, as set by -@code{AC_LANG_SAVE}, and remove it from the stack. This macro is -equivalent to either @code{AC_LANG_C}, @code{AC_LANG_CPLUSPLUS} or -@code{AC_LANG_FORTRAN77}, whichever had been run most recently when -@code{AC_LANG_SAVE} was last called. - -Do not call this macro more times than @code{AC_LANG_SAVE}. +@code{AC_LANG_PUSH}, and remove it from the stack. @end defmac @defmac AC_REQUIRE_CPP @@ -7517,6 +7510,20 @@ Same as @samp{AC_LANG(C++)}. Same as @samp{AC_LANG(Fortran 77)}. @end defmac +@defmac AC_LANG_RESTORE +@maindex LANG_RESTORE +Select the @var{language} that is saved on the top of the stack, as set +by @code{AC_LANG_SAVE}, remove it from the stack, and call +@code{AC_LANG(@var{language})}. +@end defmac + +@defmac AC_LANG_SAVE +@maindex LANG_SAVE +Remember the current language (as set by @code{AC_LANG}) on a stack. +Doe not change which language is current. @code{AC_LANG_PUSH} is +preferred. +@end defmac + @defmac AC_LINK_FILES (@var{source}@dots{}, @var{dest}@dots{}) @maindex LINK_FILES This is an obsolete version of @code{AC_CONFIG_LINKS}. An updated diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index ae4c90af7..6250fd69c 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -73,9 +73,6 @@ ## ----------------------- ## -# The current scheme is really not beautiful. It'd be better to have -# AC_LANG_PUSH(C), AC_LANG_POP. In addition, that's easy to do. -# FIXME: do it yet for 2.16? # ---------------------------- # # Generic language selection. # @@ -86,24 +83,7 @@ # Expand into IF-LANG1 if the current language is LANG1 etc. else # into default. define(AC_LANG_CASE, -[m4_case(_AC_LANG_CURRENT, $@)]) - - -# AC_LANG_SAVE -# ------------ -# Push the current language on a stack. -define(AC_LANG_SAVE, -[pushdef([AC_LANG_STACK], _AC_LANG_CURRENT)]) - - -# AC_LANG_RESTORE -# --------------- -# Restore the current language from the stack. -pushdef([AC_LANG_RESTORE], -[ifelse(AC_LANG_STACK, [AC_LANG_STACK], - [AC_FATAL([too many AC_LANG_RESTORE])])dnl -AC_LANG(AC_LANG_STACK)dnl -popdef([AC_LANG_STACK])]) +[m4_case(_AC_LANG, $@)]) # _AC_LANG_DISPATCH(MACRO, LANG, ARGS) @@ -125,8 +105,42 @@ define([_AC_LANG_DISPATCH], # 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_define([_AC_LANG_CURRENT], [$1])dnl -_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[m4_define([_AC_LANG], [$1])dnl +_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) + + +# AC_LANG_PUSH(LANG) +# ------------------ +# Save the current language, and use LANG. +define([AC_LANG_PUSH], +[pushdef([_AC_LANG])dnl +AC_LANG([$1])]) + + +# AC_LANG_POP +# ----------- +# Restore the previous language. +define([AC_LANG_POP], +[popdef([_AC_LANG])dnl +ifelse(_AC_LANG, [_AC_LANG], + [AC_FATAL([too many $0])])dnl +AC_LANG(_AC_LANG)]) + + +# AC_LANG_SAVE +# ------------ +# Save the current language, but don't change language. +AU_DEFUN([AC_LANG_SAVE], +[AC_DIAGNOSE([obsolete], + [instead of using `AC_LANG', `AC_LANG_SAVE', +and `AC_LANG_RESTORE', you should use `AC_LANG_PUSH' and `AC_LANG_POP'.]) +pushdef([_AC_LANG], _AC_LANG)]) + + +# AC_LANG_RESTORE +# --------------- +# Restore the current language from the stack. +AU_DEFUN([AC_LANG_RESTORE], [AC_LANG_POP($@)]) # AC_LANG_SOURCE(BODY) @@ -134,7 +148,7 @@ _AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) # Produce a valid source for the current language, which includes the # BODY. Include the `#line' sync lines. AC_DEFUN([AC_LANG_SOURCE], -[_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # AC_LANG_PROGRAM(PROLOGUE, BODY) @@ -144,14 +158,14 @@ AC_DEFUN([AC_LANG_SOURCE], # execution the BODY (typically glued inside the `main' function, or # equivalent). AC_DEFUN([AC_LANG_PROGRAM], -[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)])]) +[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])]) # AC_LANG_CALL(PROLOGUE, FUNCTION) # -------------------------------- # Call the FUNCTION. AC_DEFUN([AC_LANG_CALL], -[_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) @@ -423,11 +437,10 @@ fi # ---------------- AC_DEFUN(AC_PROG_CC_WORKS, [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(C) +AC_LANG_PUSH(C) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_cc_works) if test $ac_cv_prog_cc_works = no; then AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.], 77) @@ -557,12 +570,11 @@ AC_DEFUN(AC_PROG_CXXCPP, [AC_MSG_CHECKING(how to run the C++ preprocessor) if test -z "$CXXCPP"; then AC_CACHE_VAL(ac_cv_prog_CXXCPP, -[AC_LANG_SAVE()dnl -AC_LANG(C++)dnl +[AC_LANG_PUSH(C++) CXXCPP="${CXX-g++} -E" AC_TRY_CPP([#include ], , CXXCPP=/lib/cpp) ac_cv_prog_CXXCPP=$CXXCPP -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl ])dnl CXXCPP=$ac_cv_prog_CXXCPP fi @@ -620,11 +632,10 @@ fi # ----------------- AC_DEFUN(AC_PROG_CXX_WORKS, [AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $CPPFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(C++) +AC_LANG_PUSH(C++) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_cxx_works) if test $ac_cv_prog_cxx_works = no; then AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.], 77) @@ -716,13 +727,12 @@ fi # compiler is `g77'). AC_DEFUN(AC_PROG_F77_WORKS, [AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +AC_LANG_PUSH(Fortran 77) AC_TRY_COMPILER( [ program conftest end ], ac_cv_prog_f77_works, ac_cv_prog_f77_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_f77_works) if test $ac_cv_prog_f77_works = no; then AC_MSG_ERROR([installation or configuration problem: Fortran 77 compiler cannot create executables.], 77) @@ -1200,14 +1210,12 @@ fi # However, nearly all of this macro came from the "OCTAVE_FLIBS" macro # in "octave-2.0.13/aclocal.m4", and full credit should go to John # W. Eaton for writing this extremely useful macro. Thank you John. -AC_DEFUN(AC_F77_LIBRARY_LDFLAGS, -[AC_CACHE_CHECK([for Fortran 77 libraries], - ac_cv_flibs, +AC_DEFUN([AC_F77_LIBRARY_LDFLAGS], [AC_REQUIRE([AC_PROG_F77])dnl AC_REQUIRE([AC_CYGWIN])dnl - -AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +AC_CACHE_CHECK([for Fortran 77 libraries], + ac_cv_flibs, +[AC_LANG_PUSH(Fortran 77) # This is the simplest of all Fortran 77 programs. cat >conftest.$ac_ext <&8 rm -f conftest.* -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl # This will ultimately be our output variable. FLIBS= @@ -1333,7 +1341,6 @@ done ac_ld_run_path=`echo $ac_link_output | sed -n -e 's%^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$%\1%p'` test "x$ac_ld_run_path" != x && FLIBS="$ac_ld_run_path $FLIBS" - ac_cv_flibs=$FLIBS ]) AC_SUBST(FLIBS) @@ -1370,8 +1377,7 @@ AC_REQUIRE([AC_PROG_F77])dnl AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl AC_CACHE_CHECK([for Fortran 77 name-mangling scheme], ac_cv_f77_mangling, -[AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +[AC_LANG_PUSH(Fortran 77) AC_COMPILE_IFELSE( [ subroutine foobar() return @@ -1381,8 +1387,7 @@ AC_COMPILE_IFELSE( end], [mv conftest.${ac_objext} cf77_test.${ac_objext} - AC_LANG_SAVE()dnl - AC_LANG(C) + AC_LANG_PUSH(C) ac_save_LIBS=$LIBS LIBS="cf77_test.${ac_objext} $FLIBS $LIBS" @@ -1416,9 +1421,9 @@ AC_COMPILE_IFELSE( fi LIBS=$ac_save_LIBS - AC_LANG_RESTORE()dnl + AC_LANG_POP()dnl rm -f cf77_test*]) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl ]) dnl Get case/underscore from cache variable, in case above tests were skipped: f77_case=`echo "$ac_cv_f77_mangling" | sed 's/ case.*$//'` diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4 index ae4c90af7..6250fd69c 100644 --- a/lib/autoconf/fortran.m4 +++ b/lib/autoconf/fortran.m4 @@ -73,9 +73,6 @@ ## ----------------------- ## -# The current scheme is really not beautiful. It'd be better to have -# AC_LANG_PUSH(C), AC_LANG_POP. In addition, that's easy to do. -# FIXME: do it yet for 2.16? # ---------------------------- # # Generic language selection. # @@ -86,24 +83,7 @@ # Expand into IF-LANG1 if the current language is LANG1 etc. else # into default. define(AC_LANG_CASE, -[m4_case(_AC_LANG_CURRENT, $@)]) - - -# AC_LANG_SAVE -# ------------ -# Push the current language on a stack. -define(AC_LANG_SAVE, -[pushdef([AC_LANG_STACK], _AC_LANG_CURRENT)]) - - -# AC_LANG_RESTORE -# --------------- -# Restore the current language from the stack. -pushdef([AC_LANG_RESTORE], -[ifelse(AC_LANG_STACK, [AC_LANG_STACK], - [AC_FATAL([too many AC_LANG_RESTORE])])dnl -AC_LANG(AC_LANG_STACK)dnl -popdef([AC_LANG_STACK])]) +[m4_case(_AC_LANG, $@)]) # _AC_LANG_DISPATCH(MACRO, LANG, ARGS) @@ -125,8 +105,42 @@ define([_AC_LANG_DISPATCH], # 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_define([_AC_LANG_CURRENT], [$1])dnl -_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[m4_define([_AC_LANG], [$1])dnl +_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) + + +# AC_LANG_PUSH(LANG) +# ------------------ +# Save the current language, and use LANG. +define([AC_LANG_PUSH], +[pushdef([_AC_LANG])dnl +AC_LANG([$1])]) + + +# AC_LANG_POP +# ----------- +# Restore the previous language. +define([AC_LANG_POP], +[popdef([_AC_LANG])dnl +ifelse(_AC_LANG, [_AC_LANG], + [AC_FATAL([too many $0])])dnl +AC_LANG(_AC_LANG)]) + + +# AC_LANG_SAVE +# ------------ +# Save the current language, but don't change language. +AU_DEFUN([AC_LANG_SAVE], +[AC_DIAGNOSE([obsolete], + [instead of using `AC_LANG', `AC_LANG_SAVE', +and `AC_LANG_RESTORE', you should use `AC_LANG_PUSH' and `AC_LANG_POP'.]) +pushdef([_AC_LANG], _AC_LANG)]) + + +# AC_LANG_RESTORE +# --------------- +# Restore the current language from the stack. +AU_DEFUN([AC_LANG_RESTORE], [AC_LANG_POP($@)]) # AC_LANG_SOURCE(BODY) @@ -134,7 +148,7 @@ _AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) # Produce a valid source for the current language, which includes the # BODY. Include the `#line' sync lines. AC_DEFUN([AC_LANG_SOURCE], -[_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # AC_LANG_PROGRAM(PROLOGUE, BODY) @@ -144,14 +158,14 @@ AC_DEFUN([AC_LANG_SOURCE], # execution the BODY (typically glued inside the `main' function, or # equivalent). AC_DEFUN([AC_LANG_PROGRAM], -[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)])]) +[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])]) # AC_LANG_CALL(PROLOGUE, FUNCTION) # -------------------------------- # Call the FUNCTION. AC_DEFUN([AC_LANG_CALL], -[_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) @@ -423,11 +437,10 @@ fi # ---------------- AC_DEFUN(AC_PROG_CC_WORKS, [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(C) +AC_LANG_PUSH(C) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_cc_works) if test $ac_cv_prog_cc_works = no; then AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.], 77) @@ -557,12 +570,11 @@ AC_DEFUN(AC_PROG_CXXCPP, [AC_MSG_CHECKING(how to run the C++ preprocessor) if test -z "$CXXCPP"; then AC_CACHE_VAL(ac_cv_prog_CXXCPP, -[AC_LANG_SAVE()dnl -AC_LANG(C++)dnl +[AC_LANG_PUSH(C++) CXXCPP="${CXX-g++} -E" AC_TRY_CPP([#include ], , CXXCPP=/lib/cpp) ac_cv_prog_CXXCPP=$CXXCPP -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl ])dnl CXXCPP=$ac_cv_prog_CXXCPP fi @@ -620,11 +632,10 @@ fi # ----------------- AC_DEFUN(AC_PROG_CXX_WORKS, [AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $CPPFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(C++) +AC_LANG_PUSH(C++) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_cxx_works) if test $ac_cv_prog_cxx_works = no; then AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.], 77) @@ -716,13 +727,12 @@ fi # compiler is `g77'). AC_DEFUN(AC_PROG_F77_WORKS, [AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +AC_LANG_PUSH(Fortran 77) AC_TRY_COMPILER( [ program conftest end ], ac_cv_prog_f77_works, ac_cv_prog_f77_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_f77_works) if test $ac_cv_prog_f77_works = no; then AC_MSG_ERROR([installation or configuration problem: Fortran 77 compiler cannot create executables.], 77) @@ -1200,14 +1210,12 @@ fi # However, nearly all of this macro came from the "OCTAVE_FLIBS" macro # in "octave-2.0.13/aclocal.m4", and full credit should go to John # W. Eaton for writing this extremely useful macro. Thank you John. -AC_DEFUN(AC_F77_LIBRARY_LDFLAGS, -[AC_CACHE_CHECK([for Fortran 77 libraries], - ac_cv_flibs, +AC_DEFUN([AC_F77_LIBRARY_LDFLAGS], [AC_REQUIRE([AC_PROG_F77])dnl AC_REQUIRE([AC_CYGWIN])dnl - -AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +AC_CACHE_CHECK([for Fortran 77 libraries], + ac_cv_flibs, +[AC_LANG_PUSH(Fortran 77) # This is the simplest of all Fortran 77 programs. cat >conftest.$ac_ext <&8 rm -f conftest.* -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl # This will ultimately be our output variable. FLIBS= @@ -1333,7 +1341,6 @@ done ac_ld_run_path=`echo $ac_link_output | sed -n -e 's%^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$%\1%p'` test "x$ac_ld_run_path" != x && FLIBS="$ac_ld_run_path $FLIBS" - ac_cv_flibs=$FLIBS ]) AC_SUBST(FLIBS) @@ -1370,8 +1377,7 @@ AC_REQUIRE([AC_PROG_F77])dnl AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl AC_CACHE_CHECK([for Fortran 77 name-mangling scheme], ac_cv_f77_mangling, -[AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +[AC_LANG_PUSH(Fortran 77) AC_COMPILE_IFELSE( [ subroutine foobar() return @@ -1381,8 +1387,7 @@ AC_COMPILE_IFELSE( end], [mv conftest.${ac_objext} cf77_test.${ac_objext} - AC_LANG_SAVE()dnl - AC_LANG(C) + AC_LANG_PUSH(C) ac_save_LIBS=$LIBS LIBS="cf77_test.${ac_objext} $FLIBS $LIBS" @@ -1416,9 +1421,9 @@ AC_COMPILE_IFELSE( fi LIBS=$ac_save_LIBS - AC_LANG_RESTORE()dnl + AC_LANG_POP()dnl rm -f cf77_test*]) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl ]) dnl Get case/underscore from cache variable, in case above tests were skipped: f77_case=`echo "$ac_cv_f77_mangling" | sed 's/ case.*$//'` diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4 index ae4c90af7..6250fd69c 100644 --- a/lib/autoconf/lang.m4 +++ b/lib/autoconf/lang.m4 @@ -73,9 +73,6 @@ ## ----------------------- ## -# The current scheme is really not beautiful. It'd be better to have -# AC_LANG_PUSH(C), AC_LANG_POP. In addition, that's easy to do. -# FIXME: do it yet for 2.16? # ---------------------------- # # Generic language selection. # @@ -86,24 +83,7 @@ # Expand into IF-LANG1 if the current language is LANG1 etc. else # into default. define(AC_LANG_CASE, -[m4_case(_AC_LANG_CURRENT, $@)]) - - -# AC_LANG_SAVE -# ------------ -# Push the current language on a stack. -define(AC_LANG_SAVE, -[pushdef([AC_LANG_STACK], _AC_LANG_CURRENT)]) - - -# AC_LANG_RESTORE -# --------------- -# Restore the current language from the stack. -pushdef([AC_LANG_RESTORE], -[ifelse(AC_LANG_STACK, [AC_LANG_STACK], - [AC_FATAL([too many AC_LANG_RESTORE])])dnl -AC_LANG(AC_LANG_STACK)dnl -popdef([AC_LANG_STACK])]) +[m4_case(_AC_LANG, $@)]) # _AC_LANG_DISPATCH(MACRO, LANG, ARGS) @@ -125,8 +105,42 @@ define([_AC_LANG_DISPATCH], # 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_define([_AC_LANG_CURRENT], [$1])dnl -_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[m4_define([_AC_LANG], [$1])dnl +_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) + + +# AC_LANG_PUSH(LANG) +# ------------------ +# Save the current language, and use LANG. +define([AC_LANG_PUSH], +[pushdef([_AC_LANG])dnl +AC_LANG([$1])]) + + +# AC_LANG_POP +# ----------- +# Restore the previous language. +define([AC_LANG_POP], +[popdef([_AC_LANG])dnl +ifelse(_AC_LANG, [_AC_LANG], + [AC_FATAL([too many $0])])dnl +AC_LANG(_AC_LANG)]) + + +# AC_LANG_SAVE +# ------------ +# Save the current language, but don't change language. +AU_DEFUN([AC_LANG_SAVE], +[AC_DIAGNOSE([obsolete], + [instead of using `AC_LANG', `AC_LANG_SAVE', +and `AC_LANG_RESTORE', you should use `AC_LANG_PUSH' and `AC_LANG_POP'.]) +pushdef([_AC_LANG], _AC_LANG)]) + + +# AC_LANG_RESTORE +# --------------- +# Restore the current language from the stack. +AU_DEFUN([AC_LANG_RESTORE], [AC_LANG_POP($@)]) # AC_LANG_SOURCE(BODY) @@ -134,7 +148,7 @@ _AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) # Produce a valid source for the current language, which includes the # BODY. Include the `#line' sync lines. AC_DEFUN([AC_LANG_SOURCE], -[_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # AC_LANG_PROGRAM(PROLOGUE, BODY) @@ -144,14 +158,14 @@ AC_DEFUN([AC_LANG_SOURCE], # execution the BODY (typically glued inside the `main' function, or # equivalent). AC_DEFUN([AC_LANG_PROGRAM], -[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)])]) +[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])]) # AC_LANG_CALL(PROLOGUE, FUNCTION) # -------------------------------- # Call the FUNCTION. AC_DEFUN([AC_LANG_CALL], -[_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) @@ -423,11 +437,10 @@ fi # ---------------- AC_DEFUN(AC_PROG_CC_WORKS, [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(C) +AC_LANG_PUSH(C) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_cc_works) if test $ac_cv_prog_cc_works = no; then AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.], 77) @@ -557,12 +570,11 @@ AC_DEFUN(AC_PROG_CXXCPP, [AC_MSG_CHECKING(how to run the C++ preprocessor) if test -z "$CXXCPP"; then AC_CACHE_VAL(ac_cv_prog_CXXCPP, -[AC_LANG_SAVE()dnl -AC_LANG(C++)dnl +[AC_LANG_PUSH(C++) CXXCPP="${CXX-g++} -E" AC_TRY_CPP([#include ], , CXXCPP=/lib/cpp) ac_cv_prog_CXXCPP=$CXXCPP -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl ])dnl CXXCPP=$ac_cv_prog_CXXCPP fi @@ -620,11 +632,10 @@ fi # ----------------- AC_DEFUN(AC_PROG_CXX_WORKS, [AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $CPPFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(C++) +AC_LANG_PUSH(C++) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_cxx_works) if test $ac_cv_prog_cxx_works = no; then AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.], 77) @@ -716,13 +727,12 @@ fi # compiler is `g77'). AC_DEFUN(AC_PROG_F77_WORKS, [AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works]) -AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +AC_LANG_PUSH(Fortran 77) AC_TRY_COMPILER( [ program conftest end ], ac_cv_prog_f77_works, ac_cv_prog_f77_cross) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl AC_MSG_RESULT($ac_cv_prog_f77_works) if test $ac_cv_prog_f77_works = no; then AC_MSG_ERROR([installation or configuration problem: Fortran 77 compiler cannot create executables.], 77) @@ -1200,14 +1210,12 @@ fi # However, nearly all of this macro came from the "OCTAVE_FLIBS" macro # in "octave-2.0.13/aclocal.m4", and full credit should go to John # W. Eaton for writing this extremely useful macro. Thank you John. -AC_DEFUN(AC_F77_LIBRARY_LDFLAGS, -[AC_CACHE_CHECK([for Fortran 77 libraries], - ac_cv_flibs, +AC_DEFUN([AC_F77_LIBRARY_LDFLAGS], [AC_REQUIRE([AC_PROG_F77])dnl AC_REQUIRE([AC_CYGWIN])dnl - -AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +AC_CACHE_CHECK([for Fortran 77 libraries], + ac_cv_flibs, +[AC_LANG_PUSH(Fortran 77) # This is the simplest of all Fortran 77 programs. cat >conftest.$ac_ext <&8 rm -f conftest.* -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl # This will ultimately be our output variable. FLIBS= @@ -1333,7 +1341,6 @@ done ac_ld_run_path=`echo $ac_link_output | sed -n -e 's%^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$%\1%p'` test "x$ac_ld_run_path" != x && FLIBS="$ac_ld_run_path $FLIBS" - ac_cv_flibs=$FLIBS ]) AC_SUBST(FLIBS) @@ -1370,8 +1377,7 @@ AC_REQUIRE([AC_PROG_F77])dnl AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl AC_CACHE_CHECK([for Fortran 77 name-mangling scheme], ac_cv_f77_mangling, -[AC_LANG_SAVE()dnl -AC_LANG(Fortran 77) +[AC_LANG_PUSH(Fortran 77) AC_COMPILE_IFELSE( [ subroutine foobar() return @@ -1381,8 +1387,7 @@ AC_COMPILE_IFELSE( end], [mv conftest.${ac_objext} cf77_test.${ac_objext} - AC_LANG_SAVE()dnl - AC_LANG(C) + AC_LANG_PUSH(C) ac_save_LIBS=$LIBS LIBS="cf77_test.${ac_objext} $FLIBS $LIBS" @@ -1416,9 +1421,9 @@ AC_COMPILE_IFELSE( fi LIBS=$ac_save_LIBS - AC_LANG_RESTORE()dnl + AC_LANG_POP()dnl rm -f cf77_test*]) -AC_LANG_RESTORE()dnl +AC_LANG_POP()dnl ]) dnl Get case/underscore from cache variable, in case above tests were skipped: f77_case=`echo "$ac_cv_f77_mangling" | sed 's/ case.*$//'`