1 | dnl @synopsis AC_CHECK_PACKAGE(PACKAGE, FUNCTION, LIBRARY , HEADERFILE [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
---|
2 | dnl
|
---|
3 | dnl Provides --with-PACKAGE, --with-PACKAGE-include and --with-PACKAGE-libdir
|
---|
4 | dnl options to configure. Supports the now standard --with-PACKAGE=DIR
|
---|
5 | dnl approach where the package's include dir and lib dir are underneath DIR,
|
---|
6 | dnl but also allows the include and lib directories to be specified seperately
|
---|
7 | dnl
|
---|
8 | dnl adds the extra -Ipath to CFLAGS if needed
|
---|
9 | dnl adds extra -Lpath to LD_FLAGS if needed
|
---|
10 | dnl searches for the FUNCTION in the LIBRARY with
|
---|
11 | dnl AC_CHECK_LIBRARY and thus adds the lib to LIBS
|
---|
12 | dnl
|
---|
13 | dnl defines HAVE_PKG_PACKAGE if it is found, (where PACKAGE in the
|
---|
14 | dnl HAVE_PKG_PACKAGE is replaced with the actual first parameter passed)
|
---|
15 | dnl note that autoheader will complain of not having the HAVE_PKG_PACKAGE and you
|
---|
16 | dnl will have to add it to acconfig.h manually
|
---|
17 | dnl
|
---|
18 | dnl @version $Id$
|
---|
19 | dnl @author Caolan McNamara <caolan@skynet.ie>
|
---|
20 | dnl
|
---|
21 | dnl with fixes from...
|
---|
22 | dnl Alexandre Duret-Lutz <duret_g@lrde.epita.fr>
|
---|
23 |
|
---|
24 | AC_DEFUN([AC_CHECK_CLASS],
|
---|
25 | [
|
---|
26 |
|
---|
27 | AC_ARG_WITH($1,
|
---|
28 | [ --with-$1[=DIR] root directory of $1 installation],
|
---|
29 | with_$1=$withval
|
---|
30 | if test "${with_$1}" != yes; then
|
---|
31 | $1_include="$withval/include"
|
---|
32 | $1_libdir="$withval/lib"
|
---|
33 | fi
|
---|
34 | )
|
---|
35 |
|
---|
36 | AC_ARG_WITH($1-include,
|
---|
37 | [ --with-$1-include=DIR specify exact include dir for $1 headers (e.g. $4)],
|
---|
38 | $1_include="$withval")
|
---|
39 |
|
---|
40 | AC_ARG_WITH($1-libdir,
|
---|
41 | [ --with-$1-libdir=DIR specify exact library dir for $1 library (e.g. lib$3)
|
---|
42 | --without-$1 disables $1 usage completely],
|
---|
43 | $1_libdir="$withval")
|
---|
44 |
|
---|
45 | if test "${with_$1}" != no ; then
|
---|
46 | OLD_LIBS=$LIBS
|
---|
47 | OLD_LDFLAGS=$LDFLAGS
|
---|
48 | OLD_CFLAGS=$CFLAGS
|
---|
49 | OLD_CPPFLAGS=$CPPFLAGS
|
---|
50 |
|
---|
51 | if test "${$1_libdir}" ; then
|
---|
52 | LDFLAGS="$LDFLAGS -L${$1_libdir}"
|
---|
53 | fi
|
---|
54 | if test "${$1_include}" ; then
|
---|
55 | CPPFLAGS="$CPPFLAGS -I${$1_include}"
|
---|
56 | CFLAGS="$CFLAGS -I${$1_include}"
|
---|
57 | fi
|
---|
58 |
|
---|
59 | no_good=no
|
---|
60 |
|
---|
61 | AC_CHECK_HEADER($4,,no_good=yes)
|
---|
62 |
|
---|
63 | AC_LANG_PUSH([C++])
|
---|
64 | AC_CHECK_CPP($3, [#include <$4>] , [$2],,no_good=yes, $7)
|
---|
65 | AC_LANG_POP([C++])
|
---|
66 |
|
---|
67 | if test "$no_good" = yes; then
|
---|
68 | dnl broken
|
---|
69 | ifelse([$6], , , [$6])
|
---|
70 |
|
---|
71 | LIBS=$OLD_LIBS
|
---|
72 | LDFLAGS=$OLD_LDFLAGS
|
---|
73 | CPPFLAGS=$OLD_CPPFLAGS
|
---|
74 | CFLAGS=$OLD_CFLAGS
|
---|
75 | else
|
---|
76 | dnl fixed
|
---|
77 | ifelse([$5], , , [$5])
|
---|
78 |
|
---|
79 | AC_DEFINE(HAVE_PKG_$1)
|
---|
80 | fi
|
---|
81 |
|
---|
82 | fi
|
---|
83 |
|
---|
84 | ])
|
---|