]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Optimize AC_REPLACE_FUNCS.
authorEric Blake <ebb9@byu.net>
Wed, 9 Sep 2009 14:32:46 +0000 (08:32 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 26 Feb 2010 23:18:52 +0000 (16:18 -0700)
* lib/autoconf/functions.m4 (_AC_REPLACE_FUNC): New helper macro.
(AC_REPLACE_FUNCS): Use it to reduce forks when checking for
replacements, by using literal rather than shell variable.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
lib/autoconf/functions.m4

index bb2488672798680d0f6e3420b350d08499d7788a..98e0b314f6bbeb91119de73fdff65f8731b0288f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-02-26  Eric Blake  <eblake@redhat.com>
 
+       Optimize AC_REPLACE_FUNCS.
+       * lib/autoconf/functions.m4 (_AC_REPLACE_FUNC): New helper macro.
+       (AC_REPLACE_FUNCS): Use it to reduce forks when checking for
+       replacements, by using literal rather than shell variable.
+
        Document how to safely override CFLAGS default.
        * doc/autoconf.texi (C Compiler) <AC_PROG_CC>: Document a way to
        change the default CFLAGS.
index 24dcf86931311435c469ce70bb0b73c1aef99b46..aae7220aa6a9e5e11074f6d13d52346e21a33b05 100644 (file)
@@ -116,12 +116,23 @@ m4_define([_AC_FUNCS_EXPANSION],
 ])
 
 
+# _AC_REPLACE_FUNC(FUNCTION)
+# --------------------------
+# If FUNCTION exists, define HAVE_FUNCTION; else add FUNCTION.c
+# to the list of library objects.  FUNCTION must be literal.
+m4_define([_AC_REPLACE_FUNC],
+[AC_CHECK_FUNC([$1],
+  [_AH_CHECK_FUNC([$1])AC_DEFINE(AS_TR_CPP([HAVE_$1]))],
+  [AC_LIBOBJ([$1])])])
+
 # AC_REPLACE_FUNCS(FUNCTION...)
 # -----------------------------
+# For each FUNCTION in the whitespace separated list, perform the
+# equivalent of AC_CHECK_FUNC, then call AC_LIBOBJ if the function
+# was not found.
 AC_DEFUN([AC_REPLACE_FUNCS],
-[m4_map_args_w([$1], [AC_LIBSOURCE(], [.c)])]dnl
-[AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
-])
+[m4_map_args_w([$1], [_AC_REPLACE_FUNC(], [)
+])])
 
 
 # AC_TRY_LINK_FUNC(FUNC, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)