+2000-05-11 Akim Demaille <akim@epita.fr>
+
+ 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 <akim@epita.fr>
* aclang.m4 (AC_F77_LIBRARY_LDFLAGS): Less adventurous use of
## ----------------------- ##
-# 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. #
# 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)
# 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)
# 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)
# 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, $@)])
# ----------------
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)
[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 <stdlib.h>], , CXXCPP=/lib/cpp)
ac_cv_prog_CXXCPP=$CXXCPP
-AC_LANG_RESTORE()dnl
+AC_LANG_POP()dnl
])dnl
CXXCPP=$ac_cv_prog_CXXCPP
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)
# 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)
# 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 <<EOF
rm -f conftest.*
-AC_LANG_RESTORE()dnl
+AC_LANG_POP()dnl
# This will ultimately be our output variable.
FLIBS=
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)
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
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"
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.*$//'`
@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
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
## ----------------------- ##
-# 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. #
# 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)
# 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)
# 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)
# 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, $@)])
# ----------------
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)
[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 <stdlib.h>], , CXXCPP=/lib/cpp)
ac_cv_prog_CXXCPP=$CXXCPP
-AC_LANG_RESTORE()dnl
+AC_LANG_POP()dnl
])dnl
CXXCPP=$ac_cv_prog_CXXCPP
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)
# 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)
# 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 <<EOF
rm -f conftest.*
-AC_LANG_RESTORE()dnl
+AC_LANG_POP()dnl
# This will ultimately be our output variable.
FLIBS=
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)
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
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"
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.*$//'`
## ----------------------- ##
-# 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. #
# 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)
# 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)
# 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)
# 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, $@)])
# ----------------
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)
[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 <stdlib.h>], , CXXCPP=/lib/cpp)
ac_cv_prog_CXXCPP=$CXXCPP
-AC_LANG_RESTORE()dnl
+AC_LANG_POP()dnl
])dnl
CXXCPP=$ac_cv_prog_CXXCPP
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)
# 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)
# 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 <<EOF
rm -f conftest.*
-AC_LANG_RESTORE()dnl
+AC_LANG_POP()dnl
# This will ultimately be our output variable.
FLIBS=
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)
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
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"
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.*$//'`
## ----------------------- ##
-# 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. #
# 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)
# 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)
# 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)
# 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, $@)])
# ----------------
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)
[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 <stdlib.h>], , CXXCPP=/lib/cpp)
ac_cv_prog_CXXCPP=$CXXCPP
-AC_LANG_RESTORE()dnl
+AC_LANG_POP()dnl
])dnl
CXXCPP=$ac_cv_prog_CXXCPP
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)
# 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)
# 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 <<EOF
rm -f conftest.*
-AC_LANG_RESTORE()dnl
+AC_LANG_POP()dnl
# This will ultimately be our output variable.
FLIBS=
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)
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
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"
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.*$//'`