+2000-03-25 Akim Demaille <akim@epita.fr>
+
+ * acgeneral.m4 (AC_TRY_COMPILER): Use AC_LINK_IFELSE.
+ (AC_TRY_LINK_FUNC, AC_CHECK_LIB, AC_CHECK_FUNC): Don't check that
+ the current language is C++ to output `extern "C"': the CPP
+ condition is enough.
+
2000-03-25 Akim Demaille <akim@epita.fr>
* acgeneral.m4 (AC_LINK_IFELSE, AC_COMPILE_IFELSE): New macros.
# `AC_TRY_COMPILER()', call `AC_LANG_*' to set-up for the right
# language.
AC_DEFUN(AC_TRY_COMPILER,
-[cat >conftest.$ac_ext <<EOF
-AC_LANG_SOURCE([[$1]])
-EOF
-if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
- [$2]=yes
+[AC_LINK_IFELSE([AC_LANG_SOURCE([[$1]])],
+[[$2]=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
[$3]=no
else
[$3]=yes
- fi
-else
- echo "configure: failed program was:" >&AC_FD_CC
- cat conftest.$ac_ext >&AC_FD_CC
- [$2]=no
-fi
-rm -fr conftest*])
+ fi],
+[[$2]=no])[]dnl
+])# AC_TRY_COMPILER
AC_DEFUN(AC_TRY_LINK_FUNC,
[AC_TRY_LINK(
AC_LANG_CASE([FORTRAN77], ,
-ifelse([$1], [main], , dnl Avoid conflicting decl of main.
+[ifelse([$1], [main], , dnl Avoid conflicting decl of main.
[/* Override any gcc2 internal prototype to avoid an error. */
-]AC_LANG_CASE(C++, [#ifdef __cplusplus
+#ifdef __cplusplus
extern "C"
#endif
-])dnl
-[/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
char $1();
-])),
+])]),
[$1()],
[$2],
[$3])])
LIBS="-l$1 $5 $LIBS"
AC_TRY_LINK(dnl
AC_LANG_CASE([FORTRAN77], ,
-ifelse([$2], [main], , dnl Avoid conflicting decl of main.
+[ifelse([$2], [main], , dnl Avoid conflicting decl of main.
[/* Override any gcc2 internal prototype to avoid an error. */
-]AC_LANG_CASE(C++, [#ifdef __cplusplus
+#ifdef __cplusplus
extern "C"
#endif
-])dnl
-[/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
char $2();
-])),
+])]),
[$2()],
AC_VAR_SET(ac_Lib, yes), AC_VAR_SET(ac_Lib, no))
LIBS="$ac_save_LIBS"])
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# -----------------------------------------------------
# Should the INCLUDES be defaulted here?
-# Contrarily to AC_LINK_IF, this macro double quote its first two args.
+# Contrarily to AC_LINK_IFELSE, this macro double quote its first two args.
# FIXME: WARNING: The code to compile was different in the case of
# Fortran between AC_TRY_COMPILE and AC_TRY_LINK, though they should
# equivalent as far as I can tell from the semantics and the docs. In
which can conflict with char $1(); below. */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */
-]AC_LANG_CASE(C++, [#ifdef __cplusplus
+#ifdef __cplusplus
extern "C"
#endif
-])dnl
-[/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
char $1();
char (*f)();
], [
# `AC_TRY_COMPILER()', call `AC_LANG_*' to set-up for the right
# language.
AC_DEFUN(AC_TRY_COMPILER,
-[cat >conftest.$ac_ext <<EOF
-AC_LANG_SOURCE([[$1]])
-EOF
-if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
- [$2]=yes
+[AC_LINK_IFELSE([AC_LANG_SOURCE([[$1]])],
+[[$2]=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
[$3]=no
else
[$3]=yes
- fi
-else
- echo "configure: failed program was:" >&AC_FD_CC
- cat conftest.$ac_ext >&AC_FD_CC
- [$2]=no
-fi
-rm -fr conftest*])
+ fi],
+[[$2]=no])[]dnl
+])# AC_TRY_COMPILER
AC_DEFUN(AC_TRY_LINK_FUNC,
[AC_TRY_LINK(
AC_LANG_CASE([FORTRAN77], ,
-ifelse([$1], [main], , dnl Avoid conflicting decl of main.
+[ifelse([$1], [main], , dnl Avoid conflicting decl of main.
[/* Override any gcc2 internal prototype to avoid an error. */
-]AC_LANG_CASE(C++, [#ifdef __cplusplus
+#ifdef __cplusplus
extern "C"
#endif
-])dnl
-[/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
char $1();
-])),
+])]),
[$1()],
[$2],
[$3])])
LIBS="-l$1 $5 $LIBS"
AC_TRY_LINK(dnl
AC_LANG_CASE([FORTRAN77], ,
-ifelse([$2], [main], , dnl Avoid conflicting decl of main.
+[ifelse([$2], [main], , dnl Avoid conflicting decl of main.
[/* Override any gcc2 internal prototype to avoid an error. */
-]AC_LANG_CASE(C++, [#ifdef __cplusplus
+#ifdef __cplusplus
extern "C"
#endif
-])dnl
-[/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
char $2();
-])),
+])]),
[$2()],
AC_VAR_SET(ac_Lib, yes), AC_VAR_SET(ac_Lib, no))
LIBS="$ac_save_LIBS"])
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# -----------------------------------------------------
# Should the INCLUDES be defaulted here?
-# Contrarily to AC_LINK_IF, this macro double quote its first two args.
+# Contrarily to AC_LINK_IFELSE, this macro double quote its first two args.
# FIXME: WARNING: The code to compile was different in the case of
# Fortran between AC_TRY_COMPILE and AC_TRY_LINK, though they should
# equivalent as far as I can tell from the semantics and the docs. In
which can conflict with char $1(); below. */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */
-]AC_LANG_CASE(C++, [#ifdef __cplusplus
+#ifdef __cplusplus
extern "C"
#endif
-])dnl
-[/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
char $1();
char (*f)();
], [