From 587da45d65fdeddd9cc2927af2a29a3d5fd06411 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 25 Mar 2000 09:05:22 +0000 Subject: [PATCH] * acgeneral.m4 (AC_LANG_CALL, AC_LANG_CALL(C), AC_LANG_CALL(C++), AC_LANG_CALL(FORTRAN77)): New macros. (AC_TRY_LINK_FUNC): Use it. (AC_TRY_CPP): Argument was output twice. (AC_COMPILE_IFELSE, AC_LINK_IFELSE): Output $3 only if needed. --- ChangeLog | 8 +++++ acgeneral.m4 | 74 +++++++++++++++++++++++++---------------- lib/autoconf/general.m4 | 74 +++++++++++++++++++++++++---------------- 3 files changed, 100 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64dcb218..b2cd8765 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2000-03-25 Akim Demaille + + * acgeneral.m4 (AC_LANG_CALL, AC_LANG_CALL(C), AC_LANG_CALL(C++), + AC_LANG_CALL(FORTRAN77)): New macros. + (AC_TRY_LINK_FUNC): Use it. + (AC_TRY_CPP): Argument was output twice. + (AC_COMPILE_IFELSE, AC_LINK_IFELSE): Output $3 only if needed. + 2000-03-25 Akim Demaille * acgeneral.m4 (AC_TRY_COMPILER): Use AC_LINK_IFELSE. diff --git a/acgeneral.m4 b/acgeneral.m4 index 4e54c92a..e67928d3 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -2184,6 +2184,13 @@ AC_DEFUN([AC_LANG_PROGRAM], [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)])]) +# AC_LANG_CALL(PROLOGUE, FUNCTION) +# -------------------------------- +# Call the FUNCTION. +AC_DEFUN([AC_LANG_CALL], +[_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) + + # ---------------- # # The C language. # @@ -2232,6 +2239,22 @@ $2 }]) +# AC_LANG_CALL(C)(PROLOGUE, FUNCTION) +# ----------------------------------- +# Avoid conflicting decl of main. +define([AC_LANG_CALL(C)], +[AC_LANG_PROGRAM([$1 +ifelse([$2], [main], , +[/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* 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 ();])]) + + + # ------------------ # # The C++ language. # # ------------------ # @@ -2267,17 +2290,14 @@ $1]) # AC_LANG_PROGRAM(C++)(PROLOGUE, BODY) # ------------------------------------ -define([AC_LANG_PROGRAM(C++)], -[$1 -int -main () -{ -dnl Do *not* indent the following line: there may be CPP directives. -dnl Don't move the `;' right after for the same reason. -$2 - ; - return 0; -}]) +# Same as C. +define([AC_LANG_PROGRAM(C++)], defn([AC_LANG_PROGRAM(C)])) + + +# AC_LANG_CALL(C++)(PROLOGUE, FUNCTION) +# ------------------------------------- +# Same as C. +define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)])) @@ -2319,6 +2339,14 @@ $2 end]) +# AC_LANG_CALL(FORTRAN77)(PROLOGUE, FUNCTION) +# ------------------------------------------- +# FIXME: This is a guess, help! +define([AC_LANG_CALL(FORTRAN77)], +[AC_LANG_PROGRAM([$1], +[ call $2])]) + + ## ---------------------------- ## @@ -2722,20 +2750,7 @@ AC_DEFUN(AC_TRY_COMPILER, # the link succeeds, execute ACTION-IF-FOUND; otherwise, execute # ACTION-IF-NOT-FOUND. AC_DEFUN(AC_TRY_LINK_FUNC, -[AC_TRY_LINK( -AC_LANG_CASE([FORTRAN77], , -[ifelse([$1], [main], , dnl Avoid conflicting decl of main. -[/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* 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])]) +[AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], [$2], [$3])]) # AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS, @@ -2839,7 +2854,6 @@ AC_DEFUN(AC_TRY_CPP, [AC_REQUIRE_CPP()dnl cat >conftest.$ac_ext <&AC_FD_CC cat conftest.$ac_ext >&AC_FD_CC - $3 +ifval([$3], +[ $3 +])dnl fi rm -f conftest*[]dnl ])# AC_COMPILE_IFELSE @@ -2944,7 +2960,9 @@ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then else echo "configure: failed program was:" >&AC_FD_CC cat conftest.$ac_ext >&AC_FD_CC - $3 +ifval([$3], +[ $3 +])dnl fi rm -f conftest*[]dnl ])# AC_LINK_IFELSE diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 4e54c92a..e67928d3 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -2184,6 +2184,13 @@ AC_DEFUN([AC_LANG_PROGRAM], [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)])]) +# AC_LANG_CALL(PROLOGUE, FUNCTION) +# -------------------------------- +# Call the FUNCTION. +AC_DEFUN([AC_LANG_CALL], +[_AC_LANG_DISPATCH([$0], _AC_LANG_CURRENT, $@)]) + + # ---------------- # # The C language. # @@ -2232,6 +2239,22 @@ $2 }]) +# AC_LANG_CALL(C)(PROLOGUE, FUNCTION) +# ----------------------------------- +# Avoid conflicting decl of main. +define([AC_LANG_CALL(C)], +[AC_LANG_PROGRAM([$1 +ifelse([$2], [main], , +[/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* 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 ();])]) + + + # ------------------ # # The C++ language. # # ------------------ # @@ -2267,17 +2290,14 @@ $1]) # AC_LANG_PROGRAM(C++)(PROLOGUE, BODY) # ------------------------------------ -define([AC_LANG_PROGRAM(C++)], -[$1 -int -main () -{ -dnl Do *not* indent the following line: there may be CPP directives. -dnl Don't move the `;' right after for the same reason. -$2 - ; - return 0; -}]) +# Same as C. +define([AC_LANG_PROGRAM(C++)], defn([AC_LANG_PROGRAM(C)])) + + +# AC_LANG_CALL(C++)(PROLOGUE, FUNCTION) +# ------------------------------------- +# Same as C. +define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)])) @@ -2319,6 +2339,14 @@ $2 end]) +# AC_LANG_CALL(FORTRAN77)(PROLOGUE, FUNCTION) +# ------------------------------------------- +# FIXME: This is a guess, help! +define([AC_LANG_CALL(FORTRAN77)], +[AC_LANG_PROGRAM([$1], +[ call $2])]) + + ## ---------------------------- ## @@ -2722,20 +2750,7 @@ AC_DEFUN(AC_TRY_COMPILER, # the link succeeds, execute ACTION-IF-FOUND; otherwise, execute # ACTION-IF-NOT-FOUND. AC_DEFUN(AC_TRY_LINK_FUNC, -[AC_TRY_LINK( -AC_LANG_CASE([FORTRAN77], , -[ifelse([$1], [main], , dnl Avoid conflicting decl of main. -[/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* 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])]) +[AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], [$2], [$3])]) # AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS, @@ -2839,7 +2854,6 @@ AC_DEFUN(AC_TRY_CPP, [AC_REQUIRE_CPP()dnl cat >conftest.$ac_ext <&AC_FD_CC cat conftest.$ac_ext >&AC_FD_CC - $3 +ifval([$3], +[ $3 +])dnl fi rm -f conftest*[]dnl ])# AC_COMPILE_IFELSE @@ -2944,7 +2960,9 @@ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then else echo "configure: failed program was:" >&AC_FD_CC cat conftest.$ac_ext >&AC_FD_CC - $3 +ifval([$3], +[ $3 +])dnl fi rm -f conftest*[]dnl ])# AC_LINK_IFELSE