(AC_PROG_CC, AC_PROG_CXX): Use it.
(AC_PROG_CC_STDC): Be sure to remove tmp files.
* tests/compile.at (AC_TRY_LINK_FUNC): Don't use exit to test it,
since it produces a prototype which conflicts with the one
computed by _AC_PROG_CXX_EXIT_DECLARATION.
* tests/semantics.at (AC_CHECK_FUNCS, AC_HAVE_FUNCS): Likewise.
(AC_HAVE_FUNCS): Test AC_HAVE_FUNCS!
+2001-01-11 Akim Demaille <akim@epita.fr>
+
+ * aclang.m4 (_AC_PROG_CXX_EXIT_DECLARATION): New.
+ (AC_PROG_CC, AC_PROG_CXX): Use it.
+ (AC_PROG_CC_STDC): Be sure to remove tmp files.
+ * tests/compile.at (AC_TRY_LINK_FUNC): Don't use exit to test it,
+ since it produces a prototype which conflicts with the one
+ computed by _AC_PROG_CXX_EXIT_DECLARATION.
+ * tests/semantics.at (AC_CHECK_FUNCS, AC_HAVE_FUNCS): Likewise.
+ (AC_HAVE_FUNCS): Test AC_HAVE_FUNCS!
+
2001-01-11 Kevin Ryde <user42@zip.com.au>
* autoconf.texi (Shellology): Fix an @end itemize, and a typo.
Chose a means to declare patterns to catch, means to escape the
control, and document it.
+** AC_CHECK_FUNCS and AC_TRY_LINK_FUNC
+I have still not understood what's the difference between the two
+which requires to have two different sources: AC_LANG_CALL and
+AC_LANG_FUNC_LINK_TRY (which names seem to be inappropriate).
+Wouldn't one be enough?
+
* Autoconf 2.51 or so
** AC_FUNC_GETLOADAVG
# We need `stdio.h' to open a `FILE', so the prologue defaults to the
# inclusion of `stdio.h'.
m4_define([AC_LANG_INT_SAVE(C)],
-[AC_LANG_PROGRAM([m4_default([$1], [@%:@include "stdio.h"])],
+[AC_LANG_PROGRAM([m4_default([$1], [@%:@include <stdio.h>])],
[FILE *f = fopen ("conftestval", "w");
if (!f)
exit (1);
# AC_LANG_SOURCE(C++)(BODY)
# -------------------------
-m4_define([AC_LANG_SOURCE(C++)],
-[#line __oline__ "configure"
-#include "confdefs.h"
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-$1])
+m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
# AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
# ----------------------------------------
-# Same as C.
m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
# AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
# -------------------------------------
-# Same as C.
m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
# ------------------------------------
-# Same as C.
m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
# AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
# ---------------------------------------------------
-# Same as C.
m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
# AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
# -------------------------------------------
-# Same as C.
m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CC_G
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+_AC_COMPILE_IFELSE([@%:@ifndef __cplusplus
+ choke me
+@%:@endif],
+ [_AC_PROG_CXX_EXIT_DECLARATION])
AC_LANG_POP
])# AC_PROG_CC
])# AC_PROG_CC_C_O
-
# ---------------------- #
# 3c. The C++ compiler. #
# ---------------------- #
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CXX_G
+_AC_PROG_CXX_EXIT_DECLARATION
AC_LANG_POP
])# AC_PROG_CXX
])# _AC_PROG_CXX_G
+# _AC_PROG_CXX_EXIT_DECLARATION
+# -----------------------------
+# Find a valid prototype for exit and declare it in confdefs.h.
+m4_define([_AC_PROG_CXX_EXIT_DECLARATION],
+[for ac_declaration in \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);' \
+ ''
+do
+ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <stdlib.h>
+$ac_declaration],
+ [exit (42);])],
+ [],
+ [continue])
+ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration],
+ [exit (42);])],
+ [break])
+done
+echo '#ifdef __cplusplus' >>confdefs.h
+echo $ac_declaration >>confdefs.h
+echo '#endif' >>confdefs.h
+])# _AC_PROG_CXX_EXIT_DECLARATION
+
# ----------------------------- #
# 3d. The Fortran 77 compiler. #
CC="$ac_save_CC $ac_arg"
AC_COMPILE_IFELSE([],
[ac_cv_prog_cc_stdc=$ac_arg
-rm -f conftest.$ac_ext conftest.$ac_objext
break])
done
+rm -f conftest.$ac_ext conftest.$ac_objext
CC=$ac_save_CC
])
case "x$ac_cv_prog_cc_stdc" in
# We need `stdio.h' to open a `FILE', so the prologue defaults to the
# inclusion of `stdio.h'.
m4_define([AC_LANG_INT_SAVE(C)],
-[AC_LANG_PROGRAM([m4_default([$1], [@%:@include "stdio.h"])],
+[AC_LANG_PROGRAM([m4_default([$1], [@%:@include <stdio.h>])],
[FILE *f = fopen ("conftestval", "w");
if (!f)
exit (1);
# AC_LANG_SOURCE(C++)(BODY)
# -------------------------
-m4_define([AC_LANG_SOURCE(C++)],
-[#line __oline__ "configure"
-#include "confdefs.h"
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-$1])
+m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
# AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
# ----------------------------------------
-# Same as C.
m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
# AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
# -------------------------------------
-# Same as C.
m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
# ------------------------------------
-# Same as C.
m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
# AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
# ---------------------------------------------------
-# Same as C.
m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
# AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
# -------------------------------------------
-# Same as C.
m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CC_G
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+_AC_COMPILE_IFELSE([@%:@ifndef __cplusplus
+ choke me
+@%:@endif],
+ [_AC_PROG_CXX_EXIT_DECLARATION])
AC_LANG_POP
])# AC_PROG_CC
])# AC_PROG_CC_C_O
-
# ---------------------- #
# 3c. The C++ compiler. #
# ---------------------- #
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CXX_G
+_AC_PROG_CXX_EXIT_DECLARATION
AC_LANG_POP
])# AC_PROG_CXX
])# _AC_PROG_CXX_G
+# _AC_PROG_CXX_EXIT_DECLARATION
+# -----------------------------
+# Find a valid prototype for exit and declare it in confdefs.h.
+m4_define([_AC_PROG_CXX_EXIT_DECLARATION],
+[for ac_declaration in \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);' \
+ ''
+do
+ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <stdlib.h>
+$ac_declaration],
+ [exit (42);])],
+ [],
+ [continue])
+ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration],
+ [exit (42);])],
+ [break])
+done
+echo '#ifdef __cplusplus' >>confdefs.h
+echo $ac_declaration >>confdefs.h
+echo '#endif' >>confdefs.h
+])# _AC_PROG_CXX_EXIT_DECLARATION
+
# ----------------------------- #
# 3d. The Fortran 77 compiler. #
CC="$ac_save_CC $ac_arg"
AC_COMPILE_IFELSE([],
[ac_cv_prog_cc_stdc=$ac_arg
-rm -f conftest.$ac_ext conftest.$ac_objext
break])
done
+rm -f conftest.$ac_ext conftest.$ac_objext
CC=$ac_save_CC
])
case "x$ac_cv_prog_cc_stdc" in
# We need `stdio.h' to open a `FILE', so the prologue defaults to the
# inclusion of `stdio.h'.
m4_define([AC_LANG_INT_SAVE(C)],
-[AC_LANG_PROGRAM([m4_default([$1], [@%:@include "stdio.h"])],
+[AC_LANG_PROGRAM([m4_default([$1], [@%:@include <stdio.h>])],
[FILE *f = fopen ("conftestval", "w");
if (!f)
exit (1);
# AC_LANG_SOURCE(C++)(BODY)
# -------------------------
-m4_define([AC_LANG_SOURCE(C++)],
-[#line __oline__ "configure"
-#include "confdefs.h"
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-$1])
+m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
# AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
# ----------------------------------------
-# Same as C.
m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
# AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
# -------------------------------------
-# Same as C.
m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
# ------------------------------------
-# Same as C.
m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
# AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
# ---------------------------------------------------
-# Same as C.
m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
# AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
# -------------------------------------------
-# Same as C.
m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CC_G
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+_AC_COMPILE_IFELSE([@%:@ifndef __cplusplus
+ choke me
+@%:@endif],
+ [_AC_PROG_CXX_EXIT_DECLARATION])
AC_LANG_POP
])# AC_PROG_CC
])# AC_PROG_CC_C_O
-
# ---------------------- #
# 3c. The C++ compiler. #
# ---------------------- #
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CXX_G
+_AC_PROG_CXX_EXIT_DECLARATION
AC_LANG_POP
])# AC_PROG_CXX
])# _AC_PROG_CXX_G
+# _AC_PROG_CXX_EXIT_DECLARATION
+# -----------------------------
+# Find a valid prototype for exit and declare it in confdefs.h.
+m4_define([_AC_PROG_CXX_EXIT_DECLARATION],
+[for ac_declaration in \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);' \
+ ''
+do
+ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <stdlib.h>
+$ac_declaration],
+ [exit (42);])],
+ [],
+ [continue])
+ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration],
+ [exit (42);])],
+ [break])
+done
+echo '#ifdef __cplusplus' >>confdefs.h
+echo $ac_declaration >>confdefs.h
+echo '#endif' >>confdefs.h
+])# _AC_PROG_CXX_EXIT_DECLARATION
+
# ----------------------------- #
# 3d. The Fortran 77 compiler. #
CC="$ac_save_CC $ac_arg"
AC_COMPILE_IFELSE([],
[ac_cv_prog_cc_stdc=$ac_arg
-rm -f conftest.$ac_ext conftest.$ac_objext
break])
done
+rm -f conftest.$ac_ext conftest.$ac_objext
CC=$ac_save_CC
])
case "x$ac_cv_prog_cc_stdc" in
# We need `stdio.h' to open a `FILE', so the prologue defaults to the
# inclusion of `stdio.h'.
m4_define([AC_LANG_INT_SAVE(C)],
-[AC_LANG_PROGRAM([m4_default([$1], [@%:@include "stdio.h"])],
+[AC_LANG_PROGRAM([m4_default([$1], [@%:@include <stdio.h>])],
[FILE *f = fopen ("conftestval", "w");
if (!f)
exit (1);
# AC_LANG_SOURCE(C++)(BODY)
# -------------------------
-m4_define([AC_LANG_SOURCE(C++)],
-[#line __oline__ "configure"
-#include "confdefs.h"
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-$1])
+m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
# AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
# ----------------------------------------
-# Same as C.
m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
# AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
# -------------------------------------
-# Same as C.
m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
# ------------------------------------
-# Same as C.
m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
# AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
# ---------------------------------------------------
-# Same as C.
m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
# AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
# -------------------------------------------
-# Same as C.
m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CC_G
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+_AC_COMPILE_IFELSE([@%:@ifndef __cplusplus
+ choke me
+@%:@endif],
+ [_AC_PROG_CXX_EXIT_DECLARATION])
AC_LANG_POP
])# AC_PROG_CC
])# AC_PROG_CC_C_O
-
# ---------------------- #
# 3c. The C++ compiler. #
# ---------------------- #
AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
_AC_PROG_CXX_G
+_AC_PROG_CXX_EXIT_DECLARATION
AC_LANG_POP
])# AC_PROG_CXX
])# _AC_PROG_CXX_G
+# _AC_PROG_CXX_EXIT_DECLARATION
+# -----------------------------
+# Find a valid prototype for exit and declare it in confdefs.h.
+m4_define([_AC_PROG_CXX_EXIT_DECLARATION],
+[for ac_declaration in \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);' \
+ ''
+do
+ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <stdlib.h>
+$ac_declaration],
+ [exit (42);])],
+ [],
+ [continue])
+ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration],
+ [exit (42);])],
+ [break])
+done
+echo '#ifdef __cplusplus' >>confdefs.h
+echo $ac_declaration >>confdefs.h
+echo '#endif' >>confdefs.h
+])# _AC_PROG_CXX_EXIT_DECLARATION
+
# ----------------------------- #
# 3d. The Fortran 77 compiler. #
CC="$ac_save_CC $ac_arg"
AC_COMPILE_IFELSE([],
[ac_cv_prog_cc_stdc=$ac_arg
-rm -f conftest.$ac_ext conftest.$ac_objext
break])
done
+rm -f conftest.$ac_ext conftest.$ac_objext
CC=$ac_save_CC
])
case "x$ac_cv_prog_cc_stdc" in
## ------------------ ##
AT_CHECK_MACRO([AC_TRY_LINK_FUNC],
-[AC_TRY_LINK_FUNC(exit,,
- [AC_MSG_ERROR([cannot find `exit'])])
+[AC_TRY_LINK_FUNC(printf,,
+ [AC_MSG_ERROR([cannot find `printf'])])
AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
[AC_MSG_ERROR([found a nonexistent function])])])
# AC_CHECK_FUNCS
# --------------
# Check that it performs the correct actions:
-# Must define HAVE_EXIT, but not HAVE_AUTOCONF_TIXE
+# Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
AT_CHECK_MACRO([AC_CHECK_FUNCS],
-[AC_CHECK_FUNCS(exit autoconf_tixe)],
+[AC_CHECK_FUNCS(printf autoconf_ftnirp)],
[AT_CHECK_DEFINES(
-[/* #undef HAVE_AUTOCONF_TIXE */
-#define HAVE_EXIT 1
+[/* #undef HAVE_AUTOCONF_FTNIRP */
+#define HAVE_PRINTF 1
])])
# This macro is an obsolete version of AC_CHECK_FUNCS. Running this
# test allows to check that AU_ALIAS'ed macros work properly.
AT_CHECK_MACRO([AC_HAVE_FUNCS],
-[AC_CHECK_FUNCS(exit autoconf_tixe)],
+[AC_HAVE_FUNCS(printf autoconf_ftnirp)],
[AT_CHECK_DEFINES(
-[/* #undef HAVE_AUTOCONF_TIXE */
-#define HAVE_EXIT 1
+[/* #undef HAVE_AUTOCONF_FTNIRP */
+#define HAVE_PRINTF 1
])])