2
dnl Copyright (C) 2008 Sun Microsystems
4
dnl This program is free software; you can redistribute it and/or modify
5
dnl it under the terms of the GNU General Public License as published by
6
dnl the Free Software Foundation; version 2 of the License.
8
dnl This program is distributed in the hope that it will be useful,
9
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
dnl GNU General Public License for more details.
13
dnl You should have received a copy of the GNU General Public License
14
dnl along with this program; if not, write to the Free Software
15
dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
dnl SEARCH_FOR_LIB(LIB, FUNCTIONS, FUNCTION,
18
dnl [ACTION-IF-NOT-FOUND],
21
AC_DEFUN([SEARCH_FOR_LIB],
23
AS_VAR_PUSHDEF([with_lib], [with_$1])
24
AS_VAR_PUSHDEF([ac_header], [ac_cv_header_$3])
25
AS_VAR_PUSHDEF([have_lib], [ac_cv_have_$1])
26
AS_VAR_PUSHDEF([libs_var], AS_TR_CPP([$1_LIBS]))
27
AS_VAR_PUSHDEF([cflags_var], AS_TR_CPP([$1_CFLAGS]))
28
AS_VAR_PUSHDEF([path_var], AS_TR_CPP([$1_PATH]))
30
[AS_VAR_PUSHDEF([ac_lib], [ac_cv_lib_$1_$2])],
31
[AS_VAR_PUSHDEF([ac_lib], [ac_cv_lib_$1''_$2])])
33
AS_IF([test "x$prefix" = "xNONE"],
34
[AS_VAR_SET([path_var],["$ac_default_prefix"])],
35
[AS_VAR_SET([path_var],["$prefix"])])
39
[AS_HELP_STRING([--with-$1@<:@=DIR@:>@],
41
[ AS_VAR_SET([with_lib], [$withval]) ],
42
[ AS_VAR_SET([with_lib], [yes]) ])
44
AS_IF([test AS_VAR_GET([with_lib]) = yes],[
45
AC_CHECK_HEADERS([$3])
50
AS_VAR_SET([libs_var],[${LIBS}])
51
LIBS="${my_save_LIBS}"
52
AS_VAR_SET([cflags_var],[""])
53
AS_IF([test AS_VAR_GET([ac_header]) = "$3" -a AS_VAR_GET([ac_lib]) = yes],
54
[AS_VAR_SET([have_lib],[yes])
55
AS_VAR_SET([path_var],[$PATH])
57
[AS_VAR_SET([have_lib],[no])
58
AS_VAR_SET([with_lib],["AS_VAR_GET([path_var]) /usr/local /opt/csw /opt/local"])
61
AS_IF([test "AS_VAR_GET([with_lib])" != yes],[
62
for libloc in AS_VAR_GET([with_lib])
64
AC_MSG_CHECKING(for $1 in $libloc)
65
if test -f $libloc/$3 -a -f $libloc/lib$1.a
68
if cd $libloc; then libloc=`pwd`; cd $owd; fi
69
AS_VAR_SET([cflags_var],[-I$libloc])
70
AS_VAR_SET([libs_var],["-L$libloc -l$1"])
71
AS_VAR_SET([path_var],["$libloc:$PATH"])
72
AS_VAR_SET([have_lib],[yes])
75
elif test -f $libloc/include/$3 -a -f $libloc/lib/lib$1.a; then
77
if cd $libloc; then libloc=`pwd`; cd $owd; fi
78
AS_VAR_SET([cflags_var],[-I$libloc/include])
79
AS_VAR_SET([libs_var],["-L$libloc/lib -l$1"])
80
AS_VAR_SET([path_var],["$libloc/bin:$PATH"])
81
AS_VAR_SET([have_lib],[yes])
86
AS_VAR_SET([have_lib],[no])
90
AS_IF([test AS_VAR_GET([have_lib]) = no],[
91
AC_MSG_WARN([$3 or lib$1.a not found. Try installing $1 developement packages])
97
AS_VAR_POPDEF([with_lib])
98
AS_VAR_POPDEF([ac_header])
99
AS_VAR_POPDEF([libs_var])
100
AS_VAR_POPDEF([cflags_var])
101
AS_VAR_POPDEF([path_var])
102
AS_VAR_POPDEF([have_lib])
103
AS_VAR_POPDEF([ac_lib])