Author: jpeach Date: 2006-05-05 07:42:34 +0000 (Fri, 05 May 2006) New Revision: 15451
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15451 Log: Rewrite AC_LIBTESTFUNC so that it works like the callers of it expect. Modified: branches/SAMBA_3_0/source/aclocal.m4 trunk/source/aclocal.m4 Changeset: Modified: branches/SAMBA_3_0/source/aclocal.m4 =================================================================== --- branches/SAMBA_3_0/source/aclocal.m4 2006-05-05 07:15:45 UTC (rev 15450) +++ branches/SAMBA_3_0/source/aclocal.m4 2006-05-05 07:42:34 UTC (rev 15451) @@ -104,20 +104,32 @@ ]) -dnl Check for a function in a library, but don't -dnl keep adding the same library to the LIBS variable. -dnl Check whether the function is available in the current -dnl LIBS before adding the library. This prevents us spuriously -dnl finding symbols that are in libc. -dnl AC_LIBTESTFUNC(lib,func) +dnl Check for a function in a library, but don't keep adding the same library +dnl to the LIBS variable. Check whether the function is available in the +dnl current LIBS before adding the library which prevents us spuriously +dnl adding libraries for symbols that are in libc. On success, this ensures that +dnl HAVE_FOO is defined. +AC_LIBTESTFUNC(lib,func) AC_DEFUN(AC_LIBTESTFUNC, [ - AC_CHECK_FUNCS($2, [], - [ case "$LIBS" in - *-l$1*) AC_CHECK_FUNCS($2) ;; - *) AC_CHECK_LIB($1, $2) - AC_CHECK_FUNCS($2) - ;; + AC_CHECK_FUNCS($2, + [ + # $2 was found in libc or existing $LIBS + AC_DEFINE(translit([HAVE_$2], [a-z], [A-Z]), 1, + [Whether $2 is available]) + ], + [ + # $2 was not found, try adding lib$1 + case " $LIBS " in + *\ -l$1\ *) ;; + *) AC_CHECK_LIB($1, $2, + [ + AC_DEFINE(translit([HAVE_$2], [a-z], [A-Z]), 1, + [Whether $2 is available]) + LIBS="-l$1 $LIBS" + ], + []) + ;; esac ]) ]) Modified: trunk/source/aclocal.m4 =================================================================== --- trunk/source/aclocal.m4 2006-05-05 07:15:45 UTC (rev 15450) +++ trunk/source/aclocal.m4 2006-05-05 07:42:34 UTC (rev 15451) @@ -104,20 +104,25 @@ ]) -dnl Check for a function in a library, but don't -dnl keep adding the same library to the LIBS variable. -dnl Check whether the function is available in the current -dnl LIBS before adding the library. This prevents us spuriously -dnl finding symbols that are in libc. -dnl AC_LIBTESTFUNC(lib,func) +dnl Check for a function in a library, but don't keep adding the same library +dnl to the LIBS variable. Check whether the function is available in the +dnl current LIBS before adding the library which prevents us spuriously +dnl adding libraries for symbols that are in libc. On success, this ensures that +dnl HAVE_FOO is defined. +AC_LIBTESTFUNC(lib,func) AC_DEFUN(AC_LIBTESTFUNC, [ AC_CHECK_FUNCS($2, [], [ case "$LIBS" in - *-l$1*) AC_CHECK_FUNCS($2) ;; - *) AC_CHECK_LIB($1, $2) - AC_CHECK_FUNCS($2) - ;; + *-l$1*) ;; + *) AC_CHECK_LIB($1, $2, + [ + AC_DEFINE(translit([HAVE_$2], [a-z], [A-Z]), 1, + [Whether $2 is available]) + LIBS="-l$1 $LIBS" + ], + []) + ;; esac ]) ])
