From d26822c06539122ddb0f78858e31bbb8e2a4843c Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 9 Sep 2009 08:32:46 -0600 Subject: [PATCH] Optimize AC_REPLACE_FUNCS. * lib/autoconf/functions.m4 (_AC_REPLACE_FUNC): New helper macro. (AC_REPLACE_FUNCS): Use it to check for functions only once, and to pass literal rather than shell variable to AC_LIBOBJ. Signed-off-by: Eric Blake --- ChangeLog | 7 +++++++ lib/autoconf/functions.m4 | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8d4ed1..464bf85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2010-02-25 Eric Blake + Optimize AC_REPLACE_FUNCS. + * lib/autoconf/functions.m4 (_AC_REPLACE_FUNC): New helper macro. + (AC_REPLACE_FUNCS): Use it to check for functions only once, and + to pass literal rather than shell variable to AC_LIBOBJ. + +2010-02-25 Eric Blake + Properly quote AC_PREREQ during autoupdate. * lib/autoconf/general.m4 (AC_PREREQ): Follow consistent quoting style for AC_PREREQ. diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4 index 24dcf86..f2e6ad6 100644 --- a/lib/autoconf/functions.m4 +++ b/lib/autoconf/functions.m4 @@ -116,12 +116,21 @@ 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_FUNCS([$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) -- 1.6.6.1