]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Use a shell function for _AC_RUN_IFELSE.
authorPaolo Bonzini <bonzini@gnu.org>
Mon, 20 Oct 2008 13:35:43 +0000 (15:35 +0200)
committerEric Blake <ebb9@byu.net>
Thu, 23 Oct 2008 12:35:59 +0000 (06:35 -0600)
* lib/autoconf/general.m4 (_AC_RUN_IFELSE_BODY): New macro.
(_AC_RUN_IFELSE): Use a shell function.
(_AC_RUN_LOG): Avoid subshell for logging.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/autoconf/general.m4

index 2f8cb50a4e35dd57f9e69ffed021a1bcb53ddec2..bcd5fe3bf50ac0cdcae6f9e9ef75a52bcaa9afb1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-23  Paolo Bonzini  <bonzini@gnu.org>
+       and Eric Blake  <ebb9@byu.net>
+
+       Use a shell function for _AC_RUN_IFELSE.
+       * lib/autoconf/general.m4 (_AC_RUN_IFELSE_BODY): New macro.
+       (_AC_RUN_IFELSE): Use a shell function.
+       (_AC_RUN_LOG): Avoid subshell for logging.
+
 2008-10-23  Eric Blake  <ebb9@byu.net>
 
        Formatting tweak: balance () with m4sh case statements.
index 04866c26df52dd79f8676728ec9caffcfb87201a..21959dfeac72d4bb1f6ee140e4fb06f99e8a2412 100644 (file)
@@ -2230,7 +2230,7 @@ AU_ALIAS([AC_VERBOSE], [AC_MSG_RESULT])
 # ----------------------------------
 # Eval COMMAND, save the exit status in ac_status, and log it.
 AC_DEFUN([_AC_RUN_LOG],
-[{ ($2) >&AS_MESSAGE_LOG_FD
+[{ { $2; } >&AS_MESSAGE_LOG_FD
   ($1) 2>&AS_MESSAGE_LOG_FD
   ac_status=$?
   _AS_ECHO_LOG([\$? = $ac_status])
@@ -2606,6 +2606,23 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])], [$4], [$5])])
 ## ------------------------------- ##
 
 
+# _AC_RUN_IFELSE_BODY
+# -------------------
+# Shell function body for _AC_RUN_IFELSE.
+m4_define([_AC_RUN_IFELSE_BODY],
+[  AS_LINENO_PUSH([$[]1])
+  AS_IF([_AC_DO_VAR(ac_link) && _AC_DO_TOKENS(./conftest$ac_exeext)],
+      [ac_retval=0],
+      [AS_ECHO(["$as_me: program exited with status $ac_status"]) >&AS_MESSAGE_LOG_FD
+       _AC_MSG_LOG_CONFTEST
+       ac_retval=$ac_status])
+  rm -rf conftest.dSYM
+  rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest$ac_exeext
+  AS_LINENO_POP
+  return $ac_retval
+])# _AC_RUN_IFELSE_BODY
+
+
 # _AC_RUN_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
 # ------------------------------------------------------------
 # Compile, link, and run.
@@ -2613,22 +2630,17 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])], [$4], [$5])])
 # We also remove conftest.o as if the compilation fails, some compilers
 # don't remove it.  We remove gmon.out and bb.out, which may be
 # created during the run if the program is built with profiling support.
-m4_define([_AC_RUN_IFELSE],
-[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
-rm -f conftest$ac_exeext
-AS_IF([_AC_DO_VAR(ac_link) && _AC_DO_TOKENS(./conftest$ac_exeext)],
-      [$2],
-      [AS_ECHO(["$as_me: program exited with status $ac_status"]) >&AS_MESSAGE_LOG_FD
-_AC_MSG_LOG_CONFTEST
-m4_ifvaln([$3],
-         [( exit $ac_status )
-$3])dnl])
-rm -rf conftest.dSYM
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext m4_ifval([$1],
-                                                    [conftest.$ac_ext])[]dnl
+AC_DEFUN([_AC_RUN_IFELSE],
+[AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_try_run],
+  [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_try_run], [LINENO],
+    [Try to link conftest.$ac_ext, and return whether this succeeded.
+     Assumes that executables *can* be run.])],
+  [$0_BODY])]dnl
+[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])]dnl
+[AS_IF([ac_func_[]_AC_LANG_ABBREV[]_try_run "$LINENO"], [$2], [$3])
+m4_ifvaln([$1], [rm -f conftest.$ac_ext])dnl
 ])# _AC_RUN_IFELSE
 
-
 # AC_RUN_IFELSE(PROGRAM,
 #               [ACTION-IF-TRUE], [ACTION-IF-FALSE],
 #               [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR])