+2000-09-12 Akim Demaille <akim@epita.fr>
+
+ The test suite fails on some hosts because for instance
+ AC_INIT
+ AC_CHECK_FUNC(exit)
+ will not look for a compiler, it will just use `cc'.
+ Macros that need a compiler should require one.
+
+ * acgeneral.m4 (_AC_REQUIRE): New macro, which is actually the
+ previous version of AC_REQUIRE plus the possibility to distinguish
+ the name of the symbol being AC_PROVIDE'd, and the text to expand.
+ (AC_REQUIRE): Reimplement in terms of _AC_REQUIRE.
+ * aclang.m4 (AC_LANG_COMPILER, AC_LANG_COMPILER_REQUIRE)
+ (AC_LANG_COMPILER(C), AC_LANG_COMPILER(C++))
+ (AC_LANG_COMPILER(Fortran 77)):
+ New macros.
+ * acgeneral.m4 (AC_COMPILE_IFELSE, AC_LINK_IFELSE, AC_RUN_IFELSE):
+ Require a compiler.
+ (AC_TRY_RUN): Formatting changes.
+ * acfunctions.m4 (AC_FUNC_SETPGRP): Quote properly. The previous
+ changes revealed the weaknesses of this macro.
+
2000-09-12 Pavel Roskin <proski@gnu.org>
* acgeneral.m4 (_AC_TRY_CPP): New macro. It runs the preprocessor
# ---------------
AC_DEFUN([AC_FUNC_SETPGRP],
[AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
-AC_TRY_RUN(
+[AC_TRY_RUN(
[#if HAVE_UNISTD_H
# include <unistd.h>
#endif
exit (0);
else
exit (1);
-}], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes,
- AC_MSG_ERROR(cannot check setpgrp if cross compiling))
-)
+}],
+ [ac_cv_func_setpgrp_void=no],
+ [ac_cv_func_setpgrp_void=yes],
+ [AC_MSG_ERROR([cannot check setpgrp if cross compiling])])])
if test $ac_cv_func_setpgrp_void = yes; then
AC_DEFINE(SETPGRP_VOID, 1,
[Define if the `setpgrp' function takes no argument.])
[AC_PROVIDE_IFELSE([$2], [AC_DIAGNOSE([syntax], [$2 was called before $1])])])
-# AC_REQUIRE(MACRO-NAME)
-# ----------------------
-# If MACRO-NAME has never been expanded, expand it *before* the current
-# macro expansion. Once expanded, emit it in _AC_DIVERT_DUMP.
-define([AC_REQUIRE],
+# _AC_REQUIRE(NAME-TO-CHECK, BODY-TO-EXPAND)
+# ------------------------------------------
+# If NAME-TO-CHECK has never been expanded (actually, if it is not
+# AC_PROVIDE'd), expand BODY-TO-EXPAND *before* the current macro
+# expansion. Once expanded, emit it in _AC_DIVERT_DUMP.
+#
+# The normal cases are:
+#
+# - NAME-TO-CHECK == BODY-TO-EXPAND
+# Which you can use for regular macros with or without arguments, e.g.,
+# _AC_REQUIRE([AC_PROG_CC], [AC_PROG_CC])
+# _AC_REQUIRE([AC_CHECK_HEADERS(limits.h)], [AC_CHECK_HEADERS(limits.h)])
+#
+# - BODY-TO-EXPAND == m4_indir([NAME-TO-CHECK])
+# In the case of macros with irregular names. For instance:
+# _AC_REQUIRE([AC_LANG_COMPILER(C)], [indir([AC_LANG_COMPILER(C)])])
+# which means `if the macro named `AC_LANG_COMPILER(C)' (the parens are
+# part of the name, it is not an argument) has not been run, then
+# call it.'
+# Had you used
+# _AC_REQUIRE([AC_LANG_COMPILER(C)], [AC_LANG_COMPILER(C)])
+# then _AC_REQUIRE would have tried to expand `AC_LANG_COMPILER(C)', i.e.,
+# call the macro `AC_LANG_COMPILER' with `C' as argument.
+#
+# You could argue that `AC_LANG_COMPILER', when it receives an argument
+# such as `C' should dispatch the call to `AC_LANG_COMPILER(C)'. But this
+# `extension' prevents `AC_LANG_COMPILER' from having actual arguments that
+# it passes to `AC_LANG_COMPILER(C)'.
+define([_AC_REQUIRE],
[ifndef([_AC_DIVERT_DUMP],
[AC_FATAL([$0: cannot be used outside of an AC_DEFUN'd macro])])dnl
AC_PROVIDE_IFELSE([$1],
[],
[AC_DIVERT_PUSH(m4_eval(_AC_DIVERT_DIVERSION - 1))dnl
-$1
+$2
divert(_AC_DIVERT_DUMP)undivert(_AC_DIVERT_DIVERSION)dnl
AC_DIVERT_POP()])dnl
AC_PROVIDE_IFELSE([$1],
])
+# AC_REQUIRE(STRING)
+# ------------------
+# If STRING has never been AC_PROVIDE'd, then expand it.
+define([AC_REQUIRE],
+[_AC_REQUIRE([$1], [$1])])
+
+
# AC_EXPAND_ONCE(TEXT)
# --------------------
# If TEXT has never been expanded, expand it *here*.
# --------------------------------------------------------------------
# Try to compile PROGRAM.
AC_DEFUN([AC_COMPILE_IFELSE],
-[m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
+[AC_LANG_COMPILER_REQUIRE()dnl
+m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
if AC_TRY_EVAL(ac_compile) && test -s conftest.$ac_objext; then
m4_default([$2], :)
else
# -----------------------------------------------------------------
# Try to link PROGRAM.
AC_DEFUN([AC_LINK_IFELSE],
-[m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
+[AC_LANG_COMPILER_REQUIRE()dnl
+m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then
m4_default([$2], :)
else
# -----------------------------------------------------------
# Compile, link, and run.
AC_DEFUN([AC_RUN_IFELSE],
-[m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
+[AC_LANG_COMPILER_REQUIRE()dnl
+m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
if AC_TRY_EVAL(ac_link) &&
test -s conftest$ac_exeext && (./conftest; exit) 2>/dev/null; then
m4_default([$2], :)
# [ACTION-IF-CROSS-COMPILING])
# --------------------------------------------------------
AC_DEFUN([AC_TRY_RUN],
-[if test "$cross_compiling" = yes; then
+[ifval([$4], [],
+ [AC_DIAGNOSE([cross],
+ [$0 called without default to allow cross compiling])])dnl
+if test "$cross_compiling" = yes; then
m4_default([$4],
- [AC_DIAGNOSE([cross],
- [AC_TRY_RUN called without default to allow cross compiling])dnl
-AC_MSG_ERROR(cannot run test program while cross compiling)])
+ [AC_MSG_ERROR(cannot run test program while cross compiling)])
else
AC_RUN_IFELSE([AC_LANG_SOURCE([[$1]])], [$2], [$3])
fi
# 3a. Generic routines in compilers and preprocessors. #
# ----------------------------------------------------- #
+# AC_LANG_COMPILER
+# ----------------
+# Find a compiler for the current LANG. Note that because we might
+# AC_REQUIRE `AC_LANG_COMPILER(C)' for instance, the latter must be
+# AC_DEFUN'd, not just define'd.
+define([AC_LANG_COMPILER],
+[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+
+
+# AC_LANG_COMPILER_REQUIRE
+# ------------------------
+# Ensure we have a compiler for the current LANG.
+AC_DEFUN([AC_LANG_COMPILER_REQUIRE],
+[_AC_REQUIRE([AC_LANG_COMPILER(]_AC_LANG[)],
+ [indir([AC_LANG_COMPILER(]_AC_LANG[)])])])
+
+
# AC_REQUIRE_CPP
# --------------
# Require finding the C or C++ preprocessor, whichever is the
])# AC_PROG_CPP
+# AC_LANG_COMPILER(C)
+# -------------------
+# Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(C)],
+[AC_PROG_CC])
+
+
# AC_PROG_CC([COMPILER ...])
# --------------------------
# COMPILER ... is a space separated list of C compilers to search for.
])# AC_PROG_CXXCPP
+# AC_LANG_COMPILER(C++)
+# ---------------------
+# Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(C++)],
+[AC_PROG_CXX])
+
+
# AC_PROG_CXX([LIST-OF-COMPILERS])
# --------------------------------
# LIST-OF-COMPILERS is a space separated list of C++ compilers to search
# ----------------------------- #
+# AC_LANG_COMPILER(Fortran 77)
+# ----------------------------
+# Find the Fortran 77 compiler. Must be AC_DEFUN'd to be
+# AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(Fortran 77)],
+[AC_PROG_F77])
+
+
# AC_PROG_F77([COMPILERS...])
# ---------------------------
# COMPILERS is a space separated list of Fortran 77 compilers to search
# 3a. Generic routines in compilers and preprocessors. #
# ----------------------------------------------------- #
+# AC_LANG_COMPILER
+# ----------------
+# Find a compiler for the current LANG. Note that because we might
+# AC_REQUIRE `AC_LANG_COMPILER(C)' for instance, the latter must be
+# AC_DEFUN'd, not just define'd.
+define([AC_LANG_COMPILER],
+[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+
+
+# AC_LANG_COMPILER_REQUIRE
+# ------------------------
+# Ensure we have a compiler for the current LANG.
+AC_DEFUN([AC_LANG_COMPILER_REQUIRE],
+[_AC_REQUIRE([AC_LANG_COMPILER(]_AC_LANG[)],
+ [indir([AC_LANG_COMPILER(]_AC_LANG[)])])])
+
+
# AC_REQUIRE_CPP
# --------------
# Require finding the C or C++ preprocessor, whichever is the
])# AC_PROG_CPP
+# AC_LANG_COMPILER(C)
+# -------------------
+# Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(C)],
+[AC_PROG_CC])
+
+
# AC_PROG_CC([COMPILER ...])
# --------------------------
# COMPILER ... is a space separated list of C compilers to search for.
])# AC_PROG_CXXCPP
+# AC_LANG_COMPILER(C++)
+# ---------------------
+# Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(C++)],
+[AC_PROG_CXX])
+
+
# AC_PROG_CXX([LIST-OF-COMPILERS])
# --------------------------------
# LIST-OF-COMPILERS is a space separated list of C++ compilers to search
# ----------------------------- #
+# AC_LANG_COMPILER(Fortran 77)
+# ----------------------------
+# Find the Fortran 77 compiler. Must be AC_DEFUN'd to be
+# AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(Fortran 77)],
+[AC_PROG_F77])
+
+
# AC_PROG_F77([COMPILERS...])
# ---------------------------
# COMPILERS is a space separated list of Fortran 77 compilers to search
# 3a. Generic routines in compilers and preprocessors. #
# ----------------------------------------------------- #
+# AC_LANG_COMPILER
+# ----------------
+# Find a compiler for the current LANG. Note that because we might
+# AC_REQUIRE `AC_LANG_COMPILER(C)' for instance, the latter must be
+# AC_DEFUN'd, not just define'd.
+define([AC_LANG_COMPILER],
+[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+
+
+# AC_LANG_COMPILER_REQUIRE
+# ------------------------
+# Ensure we have a compiler for the current LANG.
+AC_DEFUN([AC_LANG_COMPILER_REQUIRE],
+[_AC_REQUIRE([AC_LANG_COMPILER(]_AC_LANG[)],
+ [indir([AC_LANG_COMPILER(]_AC_LANG[)])])])
+
+
# AC_REQUIRE_CPP
# --------------
# Require finding the C or C++ preprocessor, whichever is the
])# AC_PROG_CPP
+# AC_LANG_COMPILER(C)
+# -------------------
+# Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(C)],
+[AC_PROG_CC])
+
+
# AC_PROG_CC([COMPILER ...])
# --------------------------
# COMPILER ... is a space separated list of C compilers to search for.
])# AC_PROG_CXXCPP
+# AC_LANG_COMPILER(C++)
+# ---------------------
+# Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(C++)],
+[AC_PROG_CXX])
+
+
# AC_PROG_CXX([LIST-OF-COMPILERS])
# --------------------------------
# LIST-OF-COMPILERS is a space separated list of C++ compilers to search
# ----------------------------- #
+# AC_LANG_COMPILER(Fortran 77)
+# ----------------------------
+# Find the Fortran 77 compiler. Must be AC_DEFUN'd to be
+# AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(Fortran 77)],
+[AC_PROG_F77])
+
+
# AC_PROG_F77([COMPILERS...])
# ---------------------------
# COMPILERS is a space separated list of Fortran 77 compilers to search
# ---------------
AC_DEFUN([AC_FUNC_SETPGRP],
[AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
-AC_TRY_RUN(
+[AC_TRY_RUN(
[#if HAVE_UNISTD_H
# include <unistd.h>
#endif
exit (0);
else
exit (1);
-}], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes,
- AC_MSG_ERROR(cannot check setpgrp if cross compiling))
-)
+}],
+ [ac_cv_func_setpgrp_void=no],
+ [ac_cv_func_setpgrp_void=yes],
+ [AC_MSG_ERROR([cannot check setpgrp if cross compiling])])])
if test $ac_cv_func_setpgrp_void = yes; then
AC_DEFINE(SETPGRP_VOID, 1,
[Define if the `setpgrp' function takes no argument.])
[AC_PROVIDE_IFELSE([$2], [AC_DIAGNOSE([syntax], [$2 was called before $1])])])
-# AC_REQUIRE(MACRO-NAME)
-# ----------------------
-# If MACRO-NAME has never been expanded, expand it *before* the current
-# macro expansion. Once expanded, emit it in _AC_DIVERT_DUMP.
-define([AC_REQUIRE],
+# _AC_REQUIRE(NAME-TO-CHECK, BODY-TO-EXPAND)
+# ------------------------------------------
+# If NAME-TO-CHECK has never been expanded (actually, if it is not
+# AC_PROVIDE'd), expand BODY-TO-EXPAND *before* the current macro
+# expansion. Once expanded, emit it in _AC_DIVERT_DUMP.
+#
+# The normal cases are:
+#
+# - NAME-TO-CHECK == BODY-TO-EXPAND
+# Which you can use for regular macros with or without arguments, e.g.,
+# _AC_REQUIRE([AC_PROG_CC], [AC_PROG_CC])
+# _AC_REQUIRE([AC_CHECK_HEADERS(limits.h)], [AC_CHECK_HEADERS(limits.h)])
+#
+# - BODY-TO-EXPAND == m4_indir([NAME-TO-CHECK])
+# In the case of macros with irregular names. For instance:
+# _AC_REQUIRE([AC_LANG_COMPILER(C)], [indir([AC_LANG_COMPILER(C)])])
+# which means `if the macro named `AC_LANG_COMPILER(C)' (the parens are
+# part of the name, it is not an argument) has not been run, then
+# call it.'
+# Had you used
+# _AC_REQUIRE([AC_LANG_COMPILER(C)], [AC_LANG_COMPILER(C)])
+# then _AC_REQUIRE would have tried to expand `AC_LANG_COMPILER(C)', i.e.,
+# call the macro `AC_LANG_COMPILER' with `C' as argument.
+#
+# You could argue that `AC_LANG_COMPILER', when it receives an argument
+# such as `C' should dispatch the call to `AC_LANG_COMPILER(C)'. But this
+# `extension' prevents `AC_LANG_COMPILER' from having actual arguments that
+# it passes to `AC_LANG_COMPILER(C)'.
+define([_AC_REQUIRE],
[ifndef([_AC_DIVERT_DUMP],
[AC_FATAL([$0: cannot be used outside of an AC_DEFUN'd macro])])dnl
AC_PROVIDE_IFELSE([$1],
[],
[AC_DIVERT_PUSH(m4_eval(_AC_DIVERT_DIVERSION - 1))dnl
-$1
+$2
divert(_AC_DIVERT_DUMP)undivert(_AC_DIVERT_DIVERSION)dnl
AC_DIVERT_POP()])dnl
AC_PROVIDE_IFELSE([$1],
])
+# AC_REQUIRE(STRING)
+# ------------------
+# If STRING has never been AC_PROVIDE'd, then expand it.
+define([AC_REQUIRE],
+[_AC_REQUIRE([$1], [$1])])
+
+
# AC_EXPAND_ONCE(TEXT)
# --------------------
# If TEXT has never been expanded, expand it *here*.
# --------------------------------------------------------------------
# Try to compile PROGRAM.
AC_DEFUN([AC_COMPILE_IFELSE],
-[m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
+[AC_LANG_COMPILER_REQUIRE()dnl
+m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
if AC_TRY_EVAL(ac_compile) && test -s conftest.$ac_objext; then
m4_default([$2], :)
else
# -----------------------------------------------------------------
# Try to link PROGRAM.
AC_DEFUN([AC_LINK_IFELSE],
-[m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
+[AC_LANG_COMPILER_REQUIRE()dnl
+m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then
m4_default([$2], :)
else
# -----------------------------------------------------------
# Compile, link, and run.
AC_DEFUN([AC_RUN_IFELSE],
-[m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
+[AC_LANG_COMPILER_REQUIRE()dnl
+m4_ifvanl([$1], [AC_LANG_CONFTEST([$1])])dnl
if AC_TRY_EVAL(ac_link) &&
test -s conftest$ac_exeext && (./conftest; exit) 2>/dev/null; then
m4_default([$2], :)
# [ACTION-IF-CROSS-COMPILING])
# --------------------------------------------------------
AC_DEFUN([AC_TRY_RUN],
-[if test "$cross_compiling" = yes; then
+[ifval([$4], [],
+ [AC_DIAGNOSE([cross],
+ [$0 called without default to allow cross compiling])])dnl
+if test "$cross_compiling" = yes; then
m4_default([$4],
- [AC_DIAGNOSE([cross],
- [AC_TRY_RUN called without default to allow cross compiling])dnl
-AC_MSG_ERROR(cannot run test program while cross compiling)])
+ [AC_MSG_ERROR(cannot run test program while cross compiling)])
else
AC_RUN_IFELSE([AC_LANG_SOURCE([[$1]])], [$2], [$3])
fi
# 3a. Generic routines in compilers and preprocessors. #
# ----------------------------------------------------- #
+# AC_LANG_COMPILER
+# ----------------
+# Find a compiler for the current LANG. Note that because we might
+# AC_REQUIRE `AC_LANG_COMPILER(C)' for instance, the latter must be
+# AC_DEFUN'd, not just define'd.
+define([AC_LANG_COMPILER],
+[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+
+
+# AC_LANG_COMPILER_REQUIRE
+# ------------------------
+# Ensure we have a compiler for the current LANG.
+AC_DEFUN([AC_LANG_COMPILER_REQUIRE],
+[_AC_REQUIRE([AC_LANG_COMPILER(]_AC_LANG[)],
+ [indir([AC_LANG_COMPILER(]_AC_LANG[)])])])
+
+
# AC_REQUIRE_CPP
# --------------
# Require finding the C or C++ preprocessor, whichever is the
])# AC_PROG_CPP
+# AC_LANG_COMPILER(C)
+# -------------------
+# Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(C)],
+[AC_PROG_CC])
+
+
# AC_PROG_CC([COMPILER ...])
# --------------------------
# COMPILER ... is a space separated list of C compilers to search for.
])# AC_PROG_CXXCPP
+# AC_LANG_COMPILER(C++)
+# ---------------------
+# Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(C++)],
+[AC_PROG_CXX])
+
+
# AC_PROG_CXX([LIST-OF-COMPILERS])
# --------------------------------
# LIST-OF-COMPILERS is a space separated list of C++ compilers to search
# ----------------------------- #
+# AC_LANG_COMPILER(Fortran 77)
+# ----------------------------
+# Find the Fortran 77 compiler. Must be AC_DEFUN'd to be
+# AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(Fortran 77)],
+[AC_PROG_F77])
+
+
# AC_PROG_F77([COMPILERS...])
# ---------------------------
# COMPILERS is a space separated list of Fortran 77 compilers to search