-
Notifications
You must be signed in to change notification settings - Fork 1
/
acinclude.m4
87 lines (78 loc) · 2.49 KB
/
acinclude.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
AC_DEFUN([AX_ASSERT_LIB], [
AC_CHECK_HEADER([$2], , [AC_MSG_FAILURE([$1 library headers could not be found.])], [$5])
AC_MSG_CHECKING([if $1 library is available])
LIBS="-l$1 $LIBS"
AC_TRY_LINK(
[$5
#include <$2>], [$3], [AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no]); AC_MSG_FAILURE([$4])]
)
])
AC_DEFUN([AX_SEARCH_LIB], [
_ldflags="$LDFLAGS"
_cppflags="$CPPFLAGS"
_libs="$LIBS"
AC_ARG_WITH(m4_translit([$1], [_], [-]),
[AS_HELP_STRING([--with-]m4_translit([$1], [_], [-])[=DIR],
[search for $1 files in DIR/lib and DIR/include])],
[dnl
if test -d $withval
then
LDFLAGS="-L$withval/lib $_ldflags"
CPPFLAGS="-I$withval/include $_cppflags"
AC_SUBST(m4_translit([$1], [a-z-], [A-Z_])[_LDFLAGS], [-L$withval/lib])
AC_SUBST(m4_translit([$1], [a-z-], [A-Z_])[_CPPFLAGS], [-I$withval/include])
else
AC_MSG_ERROR([$withval: No such directory])
fi
]
)
AC_ARG_WITH(m4_translit([$1], [_], [-])[-lib],
[AS_HELP_STRING([--with-]m4_translit([$1], [_], [-])[-lib=DIR],
[search for $1 library in DIR])],
[dnl
if test -d $withval
then
LDFLAGS="-L$withval $_ldflags"
AC_SUBST(m4_translit([$1], [a-z-], [A-Z_])[_LDFLAGS], [-L$withval])
else
AC_MSG_ERROR([$withval: No such directory])
fi
]
)
AC_ARG_WITH(m4_translit([$1], [_], [-])[-includes],
[AS_HELP_STRING([--with-]m4_translit([$1], [_], [-])[-includes=DIR],
[search for $1 library header files in DIR])],
[dnl
if test -d $withval
then
CPPFLAGS="-I$withval $_cppflags"
AC_SUBST(m4_translit([$1], [a-z-], [A-Z_])[_CPPFLAGS], [-I$withval])
else
AC_MSG_ERROR([$withval: No such directory])
fi
]
)
AC_CHECK_HEADER([$4], , [AC_MSG_FAILURE([$1 library headers could not be found. You may want to specify a search path using `--with-]m4_translit([$1], [_], [-])[-includes'.])])
_result=no
for lib in $1 $2; do
AC_MSG_CHECKING([if $lib library is available])
LIBS="-l$lib $3 $_libs"
AC_TRY_LINK([#include <$4>], [$5], [
AC_SUBST(m4_translit([$1], [a-z-], [A-Z_])[_LIBS], [-l$lib])
AC_MSG_RESULT([yes])
_result=yes
break
], [AC_MSG_RESULT([no])])
done
if test "$_result" = "no"; then
AC_MSG_FAILURE([$1 library could not be found. You may want to specify a search path using `--with-]m4_translit([$1], [_], [-])[[[-lib]]'.])
fi
CPPFLAGS="$_cppflags"
LDFLAGS="$_ldflags"
LIBS="$_libs"
_result=
_cppflags=
_ldflags=
_libs=
])