From 2200cf61c96b13426c6a8498b11a5b5e48386b62 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 21 Mar 2000 12:15:54 +0000 Subject: [PATCH] Start the language support overhaul: Introduce AC_LANG(). * acgeneral.m4 (AC_LANG): Renamed as _AC_LANG_CURRENT. (AC_LANG, AC_LANG(C), AC_LANG(C++), AC_LANG(FORTRAN77)): New macros. (AC_LANG_C, AC_LANG_CPLUSPLUS, AC_LANG_FORTRAN): AU_DEFUN'ed. Adjust all callers. * acspecific.m4 (AC_F77_NAME_MANGLING): Remove the exceeding AC_LANG_RESTORE. * tests/Makefile.am (FILTER_MACROS): Add AC_LANG. --- ChangeLog | 13 ++++++ acgeneral.m4 | 99 +++++++++++++++++++++++++--------------- acspecific.m4 | 19 ++++---- lib/autoconf/general.m4 | 99 +++++++++++++++++++++++++--------------- lib/autoconf/specific.m4 | 19 ++++---- tests/Makefile.am | 3 ++ tests/Makefile.in | 4 +- 7 files changed, 161 insertions(+), 95 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e679432..fa859ee7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2000-03-21 Akim Demaille + + Start the language support overhaul: Introduce AC_LANG(). + + * acgeneral.m4 (AC_LANG): Renamed as _AC_LANG_CURRENT. + (AC_LANG, AC_LANG(C), AC_LANG(C++), AC_LANG(FORTRAN77)): New + macros. + (AC_LANG_C, AC_LANG_CPLUSPLUS, AC_LANG_FORTRAN): AU_DEFUN'ed. + Adjust all callers. + * acspecific.m4 (AC_F77_NAME_MANGLING): Remove the exceeding + AC_LANG_RESTORE. + * tests/Makefile.am (FILTER_MACROS): Add AC_LANG. + 2000-03-21 Akim Demaille Speed ups. diff --git a/acgeneral.m4 b/acgeneral.m4 index 11d9b72e..26a0ee00 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -1379,7 +1379,7 @@ echo >confdefs.h dnl Let the site file select an alternate cache file if it wants to. AC_SITE_LOAD AC_CACHE_LOAD -AC_LANG_C +AC_LANG(C) _AC_PROG_ECHO()dnl dnl Substitute for predefined variables. @@ -2065,14 +2065,45 @@ define(AC_MSG_ERROR_UNQUOTED, # Expand into IF-LANG1 if the current language is LANG1 etc. else # into default. define(AC_LANG_CASE, -[m4_case(AC_LANG, $@)]) +[m4_case(_AC_LANG_CURRENT, $@)]) -# AC_LANG_C -# --------- -AC_DEFUN(AC_LANG_C, -[define([AC_LANG], [C])dnl -ac_ext=c +# 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])]) + + +# AC_LANG(LANG) +# ------------- +# Set the current language to LANG. +# +# Do *not* write AC_LANG([$1]), because this pair of parens do not +# correspond to an evaluation, rather, they are just part of the name. +# 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], +[ifdef([AC_LANG($1)], + [define([_AC_LANG_CURRENT], [$1])dnl +indir([AC_LANG($1)])], + [AC_FATAL([$0: unknown language: $1])])]) + + +# AC_LANG(C) +# ---------- +define([AC_LANG(C)], +[ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&AC_FD_CC' @@ -2081,11 +2112,15 @@ cross_compiling=$ac_cv_prog_cc_cross ]) -# AC_LANG_CPLUSPLUS -# ----------------- -AC_DEFUN(AC_LANG_CPLUSPLUS, -[define([AC_LANG], [CPLUSPLUS])dnl -ac_ext=C +# AC_LANG_C +# --------- +AU_DEFUN([AC_LANG_C], [AC_LANG(C)]) + + +# AC_LANG(C++) +# ------------ +define([AC_LANG(C++)], +[ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&AC_FD_CC' @@ -2094,34 +2129,26 @@ cross_compiling=$ac_cv_prog_cxx_cross ]) -# AC_LANG_FORTRAN77 +# AC_LANG_CPLUSPLUS # ----------------- -AC_DEFUN(AC_LANG_FORTRAN77, -[define([AC_LANG], [FORTRAN77])dnl -ac_ext=f +AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)]) + + +# AC_LANG(FORTRAN77) +# ------------------ +define([AC_LANG(FORTRAN77)], +[ac_ext=f ac_compile='${F77-f77} -c $FFLAGS conftest.$ac_ext 1>&AC_FD_CC' ac_link='${F77-f77} -o conftest${ac_exeext} $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&AC_FD_CC' cross_compiling=$ac_cv_prog_f77_cross ]) -# AC_LANG_SAVE -# ------------ -# Push the current language on a stack. -define(AC_LANG_SAVE, -[pushdef([AC_LANG_STACK], AC_LANG)]) +# AC_LANG_FORTRAN77 +# ----------------- +AU_DEFUN([AC_LANG_FORTRAN77], [AC_LANG(FORTRAN77)]) -# AC_LANG_RESTORE -# --------------- -# Restore the current language from the stack. -pushdef([AC_LANG_RESTORE], -[m4_case(AC_LANG_STACK, - [C], [AC_LANG_C()], - [CPLUSPLUS], [AC_LANG_CPLUSPLUS()], - [FORTRAN77], [AC_LANG_FORTRAN77()])dnl -popdef([AC_LANG_STACK])]) - @@ -2542,7 +2569,7 @@ AC_DEFUN(AC_TRY_LINK_FUNC, AC_LANG_CASE([FORTRAN77], , ifelse([$1], [main], , dnl Avoid conflicting decl of main. [/* Override any gcc2 internal prototype to avoid an error. */ -]AC_LANG_CASE(CPLUSPLUS, [#ifdef __cplusplus +]AC_LANG_CASE(C++, [#ifdef __cplusplus extern "C" #endif ])dnl @@ -2603,7 +2630,7 @@ AC_TRY_LINK(dnl AC_LANG_CASE([FORTRAN77], , ifelse([$2], [main], , dnl Avoid conflicting decl of main. [/* Override any gcc2 internal prototype to avoid an error. */ -]AC_LANG_CASE(CPLUSPLUS, [#ifdef __cplusplus +]AC_LANG_CASE(C++, [#ifdef __cplusplus extern "C" #endif ])dnl @@ -2839,7 +2866,7 @@ AC_DEFUN(AC_TRY_RUN_NATIVE, [cat >conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ -]AC_LANG_CASE(CPLUSPLUS, [#ifdef __cplusplus +]AC_LANG_CASE(C++, [#ifdef __cplusplus extern "C" #endif ])dnl @@ -4527,7 +4554,7 @@ fi # FIXME: Get rid of this macro. AC_DEFUN(AC_LINKER_OPTION, [AC_LANG_CASE([C], [test x"$GCC" = xyes && using_gnu_compiler=yes], - [CPLUSPLUS], [test x"$GXX" = xyes && using_gnu_compiler=yes], + [C++], [test x"$GXX" = xyes && using_gnu_compiler=yes], [FORTRAN77], [test x"$G77" = xyes && using_gnu_compiler=yes], [using_gnu_compiler=]) diff --git a/acspecific.m4 b/acspecific.m4 index 028f3310..86ed9208 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -221,7 +221,7 @@ fi AC_DEFUN(AC_PROG_CC_WORKS, [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works]) AC_LANG_SAVE -AC_LANG_C +AC_LANG(C) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross) AC_LANG_RESTORE @@ -240,7 +240,7 @@ cross_compiling=$ac_cv_prog_cc_cross AC_DEFUN(AC_PROG_CXX_WORKS, [AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $CPPFLAGS $LDFLAGS) works]) AC_LANG_SAVE -AC_LANG_CPLUSPLUS +AC_LANG(C++) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross) AC_LANG_RESTORE @@ -263,7 +263,7 @@ cross_compiling=$ac_cv_prog_cxx_cross AC_DEFUN(AC_PROG_F77_WORKS, [AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works]) AC_LANG_SAVE -AC_LANG_FORTRAN77 +AC_LANG(FORTRAN77) AC_TRY_COMPILER( [ program conftest end @@ -671,7 +671,7 @@ AC_DEFUN(AC_PROG_CXXCPP, if test -z "$CXXCPP"; then AC_CACHE_VAL(ac_cv_prog_CXXCPP, [AC_LANG_SAVE()dnl -AC_LANG_CPLUSPLUS()dnl +AC_LANG(C++)dnl CXXCPP="${CXX-g++} -E" AC_TRY_CPP([#include ], , CXXCPP=/lib/cpp) ac_cv_prog_CXXCPP="$CXXCPP" @@ -2681,7 +2681,7 @@ AC_DEFUN(AC_F77_LIBRARY_LDFLAGS, AC_REQUIRE([AC_CYGWIN])dnl AC_LANG_SAVE - AC_LANG_FORTRAN77 + AC_LANG(FORTRAN77) # This is the simplest of all Fortran 77 programs. cat >conftest.$ac_ext <conftest.$ac_ext <&AC_FD_CC cat conftest.$ac_ext >&AC_FD_CC fi -dnl Matthew: We need to pop the language stack twice. -dnl Akim: FIXME: Why? You've done it above, AFAICT. AC_LANG_RESTORE()dnl -AC_LANG_RESTORE()dnl -])]) +])])# AC_F77_NAME_MANGLING # AC_F77_WRAPPERS diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 11d9b72e..26a0ee00 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -1379,7 +1379,7 @@ echo >confdefs.h dnl Let the site file select an alternate cache file if it wants to. AC_SITE_LOAD AC_CACHE_LOAD -AC_LANG_C +AC_LANG(C) _AC_PROG_ECHO()dnl dnl Substitute for predefined variables. @@ -2065,14 +2065,45 @@ define(AC_MSG_ERROR_UNQUOTED, # Expand into IF-LANG1 if the current language is LANG1 etc. else # into default. define(AC_LANG_CASE, -[m4_case(AC_LANG, $@)]) +[m4_case(_AC_LANG_CURRENT, $@)]) -# AC_LANG_C -# --------- -AC_DEFUN(AC_LANG_C, -[define([AC_LANG], [C])dnl -ac_ext=c +# 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])]) + + +# AC_LANG(LANG) +# ------------- +# Set the current language to LANG. +# +# Do *not* write AC_LANG([$1]), because this pair of parens do not +# correspond to an evaluation, rather, they are just part of the name. +# 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], +[ifdef([AC_LANG($1)], + [define([_AC_LANG_CURRENT], [$1])dnl +indir([AC_LANG($1)])], + [AC_FATAL([$0: unknown language: $1])])]) + + +# AC_LANG(C) +# ---------- +define([AC_LANG(C)], +[ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&AC_FD_CC' @@ -2081,11 +2112,15 @@ cross_compiling=$ac_cv_prog_cc_cross ]) -# AC_LANG_CPLUSPLUS -# ----------------- -AC_DEFUN(AC_LANG_CPLUSPLUS, -[define([AC_LANG], [CPLUSPLUS])dnl -ac_ext=C +# AC_LANG_C +# --------- +AU_DEFUN([AC_LANG_C], [AC_LANG(C)]) + + +# AC_LANG(C++) +# ------------ +define([AC_LANG(C++)], +[ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&AC_FD_CC' @@ -2094,34 +2129,26 @@ cross_compiling=$ac_cv_prog_cxx_cross ]) -# AC_LANG_FORTRAN77 +# AC_LANG_CPLUSPLUS # ----------------- -AC_DEFUN(AC_LANG_FORTRAN77, -[define([AC_LANG], [FORTRAN77])dnl -ac_ext=f +AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)]) + + +# AC_LANG(FORTRAN77) +# ------------------ +define([AC_LANG(FORTRAN77)], +[ac_ext=f ac_compile='${F77-f77} -c $FFLAGS conftest.$ac_ext 1>&AC_FD_CC' ac_link='${F77-f77} -o conftest${ac_exeext} $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&AC_FD_CC' cross_compiling=$ac_cv_prog_f77_cross ]) -# AC_LANG_SAVE -# ------------ -# Push the current language on a stack. -define(AC_LANG_SAVE, -[pushdef([AC_LANG_STACK], AC_LANG)]) +# AC_LANG_FORTRAN77 +# ----------------- +AU_DEFUN([AC_LANG_FORTRAN77], [AC_LANG(FORTRAN77)]) -# AC_LANG_RESTORE -# --------------- -# Restore the current language from the stack. -pushdef([AC_LANG_RESTORE], -[m4_case(AC_LANG_STACK, - [C], [AC_LANG_C()], - [CPLUSPLUS], [AC_LANG_CPLUSPLUS()], - [FORTRAN77], [AC_LANG_FORTRAN77()])dnl -popdef([AC_LANG_STACK])]) - @@ -2542,7 +2569,7 @@ AC_DEFUN(AC_TRY_LINK_FUNC, AC_LANG_CASE([FORTRAN77], , ifelse([$1], [main], , dnl Avoid conflicting decl of main. [/* Override any gcc2 internal prototype to avoid an error. */ -]AC_LANG_CASE(CPLUSPLUS, [#ifdef __cplusplus +]AC_LANG_CASE(C++, [#ifdef __cplusplus extern "C" #endif ])dnl @@ -2603,7 +2630,7 @@ AC_TRY_LINK(dnl AC_LANG_CASE([FORTRAN77], , ifelse([$2], [main], , dnl Avoid conflicting decl of main. [/* Override any gcc2 internal prototype to avoid an error. */ -]AC_LANG_CASE(CPLUSPLUS, [#ifdef __cplusplus +]AC_LANG_CASE(C++, [#ifdef __cplusplus extern "C" #endif ])dnl @@ -2839,7 +2866,7 @@ AC_DEFUN(AC_TRY_RUN_NATIVE, [cat >conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ -]AC_LANG_CASE(CPLUSPLUS, [#ifdef __cplusplus +]AC_LANG_CASE(C++, [#ifdef __cplusplus extern "C" #endif ])dnl @@ -4527,7 +4554,7 @@ fi # FIXME: Get rid of this macro. AC_DEFUN(AC_LINKER_OPTION, [AC_LANG_CASE([C], [test x"$GCC" = xyes && using_gnu_compiler=yes], - [CPLUSPLUS], [test x"$GXX" = xyes && using_gnu_compiler=yes], + [C++], [test x"$GXX" = xyes && using_gnu_compiler=yes], [FORTRAN77], [test x"$G77" = xyes && using_gnu_compiler=yes], [using_gnu_compiler=]) diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 028f3310..86ed9208 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -221,7 +221,7 @@ fi AC_DEFUN(AC_PROG_CC_WORKS, [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works]) AC_LANG_SAVE -AC_LANG_C +AC_LANG(C) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross) AC_LANG_RESTORE @@ -240,7 +240,7 @@ cross_compiling=$ac_cv_prog_cc_cross AC_DEFUN(AC_PROG_CXX_WORKS, [AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $CPPFLAGS $LDFLAGS) works]) AC_LANG_SAVE -AC_LANG_CPLUSPLUS +AC_LANG(C++) AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross) AC_LANG_RESTORE @@ -263,7 +263,7 @@ cross_compiling=$ac_cv_prog_cxx_cross AC_DEFUN(AC_PROG_F77_WORKS, [AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works]) AC_LANG_SAVE -AC_LANG_FORTRAN77 +AC_LANG(FORTRAN77) AC_TRY_COMPILER( [ program conftest end @@ -671,7 +671,7 @@ AC_DEFUN(AC_PROG_CXXCPP, if test -z "$CXXCPP"; then AC_CACHE_VAL(ac_cv_prog_CXXCPP, [AC_LANG_SAVE()dnl -AC_LANG_CPLUSPLUS()dnl +AC_LANG(C++)dnl CXXCPP="${CXX-g++} -E" AC_TRY_CPP([#include ], , CXXCPP=/lib/cpp) ac_cv_prog_CXXCPP="$CXXCPP" @@ -2681,7 +2681,7 @@ AC_DEFUN(AC_F77_LIBRARY_LDFLAGS, AC_REQUIRE([AC_CYGWIN])dnl AC_LANG_SAVE - AC_LANG_FORTRAN77 + AC_LANG(FORTRAN77) # This is the simplest of all Fortran 77 programs. cat >conftest.$ac_ext <conftest.$ac_ext <&AC_FD_CC cat conftest.$ac_ext >&AC_FD_CC fi -dnl Matthew: We need to pop the language stack twice. -dnl Akim: FIXME: Why? You've done it above, AFAICT. AC_LANG_RESTORE()dnl -AC_LANG_RESTORE()dnl -])]) +])])# AC_F77_NAME_MANGLING # AC_F77_WRAPPERS diff --git a/tests/Makefile.am b/tests/Makefile.am index 7646950e..b397b35a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -54,6 +54,8 @@ testsuite: atgeneral.m4 atspecific.m4 suite.m4 macros.m4 $(SUITE) # - AC_INIT # AC_INIT includes all the AC_INIT macros. Note that there is an # infinite m4 recursion if AC_INIT it used twice. +# - AC_LANG +# Requires an argument. # - AC_PROG_(CC|CXX|F77)_(GNU|WORKS) # are used in AC_PROG_CC etc. # - AC_PATH_PROGS? @@ -71,6 +73,7 @@ FILTER_MACROS = egrep -v -e \ ^AC_CHECK_(DECL|FILE|FUNC|HEADER|MEMBER|PROG|SIZEOF|TYPE)S?$$\ ^AC_CONFIG\ ^AC_INIT\ +^AC_LANG\ ^AC_LINKER_OPTION$$\ ^AC_LINK_FILES$$\ ^AC_LIST_MEMBER_OF$$\ diff --git a/tests/Makefile.in b/tests/Makefile.in index 502f0015..76876f22 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -87,6 +87,8 @@ PERL = perl # - AC_INIT # AC_INIT includes all the AC_INIT macros. Note that there is an # infinite m4 recursion if AC_INIT it used twice. +# - AC_LANG +# Requires an argument. # - AC_PROG_(CC|CXX|F77)_(GNU|WORKS) # are used in AC_PROG_CC etc. # - AC_PATH_PROGS? @@ -99,7 +101,7 @@ PERL = perl # # Multiple `-e' to egrep are not portable, so join all the patterns together. # We use the fact that automake will replace all the `\\\n' with ` '. -FILTER_MACROS = egrep -v -e `echo '^AC_ARG_VAR$$ ^AC_CHECK_(DECL|FILE|FUNC|HEADER|MEMBER|PROG|SIZEOF|TYPE)S?$$ ^AC_CONFIG ^AC_INIT ^AC_LINKER_OPTION$$ ^AC_LINK_FILES$$ ^AC_LIST_MEMBER_OF$$ ^AC_PATH_(TOOL|PROG)S?$$ ^AC_PROG_(CC|CXX|F77)_(GNU|WORKS)$$ ^AC_REPLACE_FUNCS$$ ^AC_SEARCH_LIBS$$ ^AC_TRY _AC_' | tr ' ' '|'` +FILTER_MACROS = egrep -v -e `echo '^AC_ARG_VAR$$ ^AC_CHECK_(DECL|FILE|FUNC|HEADER|MEMBER|PROG|SIZEOF|TYPE)S?$$ ^AC_CONFIG ^AC_INIT ^AC_LANG ^AC_LINKER_OPTION$$ ^AC_LINK_FILES$$ ^AC_LIST_MEMBER_OF$$ ^AC_PATH_(TOOL|PROG)S?$$ ^AC_PROG_(CC|CXX|F77)_(GNU|WORKS)$$ ^AC_REPLACE_FUNCS$$ ^AC_SEARCH_LIBS$$ ^AC_TRY _AC_' | tr ' ' '|'` CLEANFILES = debug-*.sh macro configure configure.in config.status config.cache config.log config.h.in config.h