-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathx_ac_check_cond_lib.m4
44 lines (43 loc) · 1.58 KB
/
x_ac_check_cond_lib.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
##*****************************************************************************
## $Id: x_ac_check_cond_lib.m4 391 2005-02-10 02:31:11Z dun $
##*****************************************************************************
# AUTHOR:
# Chris Dunlap <[email protected]>
#
# SYNOPSIS:
# X_AC_CHECK_COND_LIB(library, function)
#
# DESCRIPTION:
# Check whether a program can be linked with <library> to get <function>.
# Like AC_CHECK_LIB(), except that if the check succeeds, HAVE_LIB<library>
# will be defined and a shell variable LIB<library> containing "-l<library>"
# will be substituted via AC_SUBST().
#
# In other words, this is just like the default action of AC_CHECK_LIB(),
# except that instead of modifying LIBS (which will affect the linking of
# all executables), the shell variable LIB<library> is defined so it can be
# added to the linking of just those executables needing this library.
# Also note that this checks to see if the library is even needed at all.
##*****************************************************************************
AC_DEFUN([X_AC_CHECK_COND_LIB], [
AC_CACHE_CHECK(
[for $2 in default libs],
[x_ac_cv_lib_none_$2], [
AC_LINK_IFELSE(
[AC_LANG_CALL([], [$2])],
AS_VAR_SET(x_ac_cv_lib_none_$2, yes),
AS_VAR_SET(x_ac_cv_lib_none_$2, no)
)]
)
AS_IF([test AS_VAR_GET(x_ac_cv_lib_none_$2) = no],
AC_CHECK_LIB(
[$1],
[$2], [
AH_CHECK_LIB([$1])
AS_TR_CPP([LIB$1])="-l$1";
AC_SUBST(AS_TR_CPP([LIB$1]))
AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_LIB$1]))
]
)
)]
)