From: Eric Blake Date: Wed, 9 Sep 2009 14:32:46 +0000 (-0600) Subject: Optimize AC_REPLACE_FUNCS. X-Git-Tag: v2.66~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4d3a51a96f83c2f5f6eefc34ec87a2eddfb5f45;p=thirdparty%2Fautoconf.git 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. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index bb248867..98e0b314 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-02-26 Eric Blake + 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) : Document a way to change the default CFLAGS. diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4 index 24dcf869..aae7220a 100644 --- a/lib/autoconf/functions.m4 +++ b/lib/autoconf/functions.m4 @@ -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)