autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about AC_TRY_LINK_FUNC


From: Sergio Belkin
Subject: Re: Question about AC_TRY_LINK_FUNC
Date: Tue, 21 Dec 2010 16:27:10 -0300

2010/12/21 Eric Blake <address@hidden>:
> On 12/21/2010 08:02 AM, Sergio Belkin wrote:
>> Hi,
>>
>> The question is simple, altough the answer it's no so, what does
>> AC_TRY_LINK_FUNC macro do?
>
> It's a deprecated wrapper around the modern AC_LINK_IFELSE macro.  It
> basically tests whether a symbol (global variable or function) exists in
> the set of libraries passed in $LIBS, even if that symbol is not
> declared in any system header files.  Based on the compiler results, it
> then runs shell code snippets that you can use to affect subsequent
> AC_SUBST or AC_DEFINE patterns to propagate that information on to the
> rest of your package.  Did you have any more specific details about what
> you were trying to figure out about the macro?
>
> --
> Eric Blake   address@hidden    +1-801-349-2682
> Libvirt virtualization library http://libvirt.org
>
>

Thanks Eric for your answer and interest. I am using the macro
AX_EXT_HAVE_LIB I am trying to understand how it works. Because has a
problem: only can be used once, otherwise LIBS is overwritten by last
library found. I've made a quick and diry workaround: changed, but
it's not perfect, I'd be glad if you can help, this the macro as I am
using now (I commented out the lines modified):

AC_DEFUN([AX_EXT_HAVE_LIB],
[
new_ldflags=${LDFLAGS}
new_libs=$LIBS
AC_CHECK_LIB([$2], $3, new_libs="-l$2"; ext_lib_found="yes",
ext_lib_found="no")
for dir in $1
do
if test $ext_lib_found = no
then
ext_haslib_cvdir=`echo $dir | $as_tr_sh`
AC_CACHE_CHECK([for $2 library with -L$dir],
[ext_cv${ext_haslib_cvdir}_haslib_$2],
[ext_func_search_save_LIBS=$LIBS
ext_func_save_ldflags=${LDFLAGS}
LIBS="-l$2 $4 ${ext_func_search_save_LIBS}"
LDFLAGS="-L$dir ${ext_func_save_ldflags}"
AC_TRY_LINK_FUNC([$3], [eval "ext_cv${ext_haslib_cvdir}_haslib_$2"="yes"],
[eval "ext_cv${ext_haslib_cvdir}_haslib_$2"="no"])
LIBS=$ext_func_search_save_LIBS
LDFLAGS=$ext_func_save_ldflags
])
if eval `echo 'test x${'ext_cv${ext_haslib_cvdir}_haslib_$2'}' = "xyes"`; then
#new_libs="-l$2 ${new_libs}"
#That prevents sometimes that librarie are repeated in LIBS library:
new_libs="-l$2"
new_ldflags="-L${dir} ${new_ldflags}"
ext_lib_found="yes"
fi
fi
done
#LIBS=$new_libs
# The line below is the key for macro it works.
LIBS="$new_libs $LIBS}"
LDFLAGS=$new_ldflags
])

EOF

Thanks in advance!
-- 
--
Sergio Belkin http://www.sergiobelkin.com
Watch More TV http://sebelk.blogspot.com
Sergio Belkin -



reply via email to

[Prev in Thread] Current Thread [Next in Thread]