From c691fa6cc261f87e84829ddc923cfd91abde3046 Mon Sep 17 00:00:00 2001 From: Romain Lenglet Date: Sat, 8 Aug 2009 10:48:17 +0900 Subject: [PATCH] Make AC_COMPILE_IFELSE work for Erlang tests. * lib/autoconf/erlang.m4 (AC_LANG(Erlang)): Make AC_COMPILE_IFELSE work for Erlang tests. * lib/autoconf/general.m4 (_AC_COMPILE_IFELSE_BODY, _AC_COMPILE_IFELSE, _AC_LINK_IFELSE_BODY, _AC_LINK_IFELSE): Cleanup conftest.beam generated by Erlang compiler. * tests/erlang.at (Erlang): Add tests for AC_COMPILE_IFELSE and AC_LINK_IFELSE. Improve wording. * doc/autoconf.texi (Running the Linker): Remove mention that AC_LINK_IFELSE doesn't work for Erlang tests. * NEWS: Mention that AC_COMPILE_IFELSE now works for Erlang. --- ChangeLog | 13 +++++++++++++ NEWS | 2 ++ doc/autoconf.texi | 3 --- lib/autoconf/erlang.m4 | 2 +- lib/autoconf/general.m4 | 9 +++++---- tests/erlang.at | 23 +++++++++++++++++++---- 6 files changed, 40 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85c68ee..ceb788e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-08-08 Romain Lenglet + + * lib/autoconf/erlang.m4 (AC_LANG(Erlang)): Make AC_COMPILE_IFELSE + work for Erlang tests. + * lib/autoconf/general.m4 (_AC_COMPILE_IFELSE_BODY, + _AC_COMPILE_IFELSE, _AC_LINK_IFELSE_BODY, _AC_LINK_IFELSE): + Cleanup conftest.beam generated by Erlang compiler. + * tests/erlang.at (Erlang): Add tests for AC_COMPILE_IFELSE and + AC_LINK_IFELSE. Improve wording. + * doc/autoconf.texi (Running the Linker): Remove mention that + AC_LINK_IFELSE doesn't work for Erlang tests. + * NEWS: Mention that AC_COMPILE_IFELSE now works for Erlang. + 2009-08-07 Romain Lenglet * lib/autoconf/erlang.m4 (AC_LANG(Erlang)): Make AC_RUN_IFELSE diff --git a/NEWS b/NEWS index 50f4e0e..c4a75bb 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ GNU Autoconf NEWS - User visible changes. ** The following documented autotest macros are new: AT_CHECK_EUNIT +** The AC_COMPILE_IFELSE macro now works for Erlang tests. + * Major changes in Autoconf 2.64 (2009-07-26) [stable] Released by Eric Blake, based on git versions 2.63b.*. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index b1b38da..d868711 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -8522,9 +8522,6 @@ It is customary to report unexpected failures with use @code{AC_RUN_IFELSE} if you need to do that (@pxref{Runtime}). @end defmac -The @code{AC_LINK_IFELSE} macro cannot be used for Erlang tests, since Erlang -programs are interpreted and do not require linking. - @node Runtime diff --git a/lib/autoconf/erlang.m4 b/lib/autoconf/erlang.m4 index 59b02e4..e54fb1f 100644 --- a/lib/autoconf/erlang.m4 +++ b/lib/autoconf/erlang.m4 @@ -123,7 +123,7 @@ fi # --------------- AC_LANG_DEFINE([Erlang], [erl], [ERL], [], [ac_ext=erl -ac_compile='$ERLC $ERLCFLAGS -b beam conftest.$ac_ext >&AS_MESSAGE_LOG_FD' +ac_compile='$ERLC $ERLCFLAGS -b beam conftest.$ac_ext >&AS_MESSAGE_LOG_FD && echo "DUMMY" > conftest.$ac_objext' ac_link='$ERLC $ERLCFLAGS -b beam conftest.$ac_ext >&AS_MESSAGE_LOG_FD && echo "[#]!/bin/sh" > conftest$ac_exeext && AS_ECHO(["\"$ERL\" -run conftest start -run init stop -noshell"]) >> conftest$ac_exeext && chmod +x conftest$ac_exeext' ]) diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index f030c26..0d5225f 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -2557,7 +2557,7 @@ AC_DEFUN([AC_EGREP_HEADER], # Shell function body for _AC_COMPILE_IFELSE. m4_define([_AC_COMPILE_IFELSE_BODY], [ AS_LINENO_PUSH([$[]1]) - rm -f conftest.$ac_objext + rm -f conftest.$ac_objext conftest.beam AS_IF([_AC_DO_STDERR($ac_compile) && { test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test ! -s conftest.err @@ -2581,7 +2581,8 @@ AC_DEFUN([_AC_COMPILE_IFELSE], [$0_BODY])]dnl [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])]dnl [AS_IF([ac_fn_[]_AC_LANG_ABBREV[]_try_compile "$LINENO"], [$2], [$3]) -rm -f core conftest.err conftest.$ac_objext[]m4_ifval([$1], [ conftest.$ac_ext])[]dnl +rm -f core conftest.err conftest.$ac_objext \ + conftest.beam[]m4_ifval([$1], [ conftest.$ac_ext])[]dnl ])# _AC_COMPILE_IFELSE @@ -2613,7 +2614,7 @@ AU_DEFUN([AC_TRY_COMPILE], # Shell function body for _AC_LINK_IFELSE. m4_define([_AC_LINK_IFELSE_BODY], [ AS_LINENO_PUSH([$[]1]) - rm -f conftest.$ac_objext conftest$ac_exeext + rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext AS_IF([_AC_DO_STDERR($ac_link) && { test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test ! -s conftest.err @@ -2652,7 +2653,7 @@ AC_DEFUN([_AC_LINK_IFELSE], [$0_BODY])]dnl [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])]dnl [AS_IF([ac_fn_[]_AC_LANG_ABBREV[]_try_link "$LINENO"], [$2], [$3]) -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext[]m4_ifval([$1], [ conftest.$ac_ext])[]dnl ])# _AC_LINK_IFELSE diff --git a/tests/erlang.at b/tests/erlang.at index e8a5de7..655bbee 100644 --- a/tests/erlang.at +++ b/tests/erlang.at @@ -34,15 +34,30 @@ AT_CHECK_MACRO([Erlang], AC_ERLANG_PATH_ERLC([not found]) if test "$ERL" = "not found" || test "$ERLC" = "not found"; then exit 77; fi AC_LANG([Erlang]) -## Can't compile, but can run an Erlang module: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [halt(0)])], + [AC_MSG_RESULT([ok])], + [AC_MSG_RESULT([failed]) + AC_MSG_ERROR([could not compile valid test program])]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [some invalid code])], [AC_MSG_RESULT([ok]) - AC_MSG_ERROR([compiling Erlang program should fail])], - [AC_MSG_RESULT([failed])]) + AC_MSG_ERROR([should not be able to compile test program])], + [AC_MSG_RESULT([failed])]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([], [halt(0)])], + [AC_MSG_RESULT([ok])], + [AC_MSG_RESULT([failed]) + AC_MSG_ERROR([could not link valid test program])]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([], [some invalid code])], + [AC_MSG_RESULT([ok]) + AC_MSG_ERROR([should not be able to link test program])], + [AC_MSG_RESULT([failed])]) AC_RUN_IFELSE([AC_LANG_PROGRAM([], [halt(0)])], [AC_MSG_RESULT([ok])], [AC_MSG_RESULT([failed]) - AC_MSG_ERROR([could not run test program])]) + AC_MSG_ERROR([could not run valid test program])]) +AC_RUN_IFELSE([AC_LANG_PROGRAM([], [some invalid code])], + [AC_MSG_RESULT([ok]) + AC_MSG_ERROR([should not be able to run test program])], + [AC_MSG_RESULT([failed])]) ]], [AT_KEYWORDS([Erlang])]) -- 1.6.3.1