1 dnl @synopsis AC_ma_SEARCH_PACKAGE(PACKAGE, FUNCTION, PREFIX LIST, LIBRARY LIST, HEADERFILE [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
2 dnl based on AC_caolan_SEARCH_PACKAGE
4 dnl Provides --with-PACKAGE, --with-PACKAGE-include and --with-PACKAGE-libdir
5 dnl options to configure. Supports the now standard --with-PACKAGE=DIR
6 dnl approach where the package's include dir and lib dir are underneath DIR,
7 dnl but also allows the include and lib directories to be specified seperately
9 dnl PREFIX LIST can be a list of directories to search for the package
10 dnl if set to "no", the package must be enabled with --with-PACKAGE
11 dnl otherwise it is enabled unless overridden with --without-PACKAGE
13 dnl adds the extra -Ipath to CFLAGS if needed
14 dnl adds extra -Lpath to LD_FLAGS if needed
15 dnl searches for the FUNCTION in each of the LIBRARY LIST with
16 dnl AC_SEARCH_LIBRARY and thus adds the lib to LIBS
18 dnl defines HAVE_PKG_PACKAGE if it is found, (where PACKAGE in the
19 dnl HAVE_PKG_PACKAGE is replaced with the actual first parameter passed)
20 dnl note that autoheader will complain of not having the HAVE_PKG_PACKAGE and you
21 dnl will have to add it to acconfig.h manually
23 dnl @version $Id: ac_caolan_search_package.m4,v 1.3 2003/10/29 02:13:06 guidod Exp $
24 dnl @author Caolan McNamara <caolan@skynet.ie>
26 dnl with fixes from...
27 dnl Alexandre Duret-Lutz <duret_g@lrde.epita.fr>
28 dnl Matthew Mueller <donut@azstarnet.com>
29 dnl Matthias Andree <matthias.andree@gmx.de>
31 AC_PREREQ(2.59)dnl oldest tested version
33 AC_DEFUN([AC_ma_SEARCH_PACKAGE],
38 AS_HELP_STRING([--without-$1],[disables $1 usage completely])
39 AS_HELP_STRING([--with-$1[=DIR]],[root directory of $1 installation]),
40 if test "${with_$1}" != yes; then
42 $1_winclude="$withval/include"
43 $1_wlibdir="$withval/lib"
47 AC_ARG_WITH($1-include,
48 AS_HELP_STRING([--with-$1-include=DIR],[specify exact include dir for $1 headers]),
49 $1_winclude="$withval")
51 AC_ARG_WITH($1-libdir,
52 AS_HELP_STRING([--with-$1-libdir=DIR],[specify exact library dir for $1 library]),
53 $1_wlibdir="$withval")
55 if test "${with_$1}" != no ; then
57 if test "$search" = "${with_$1}" ; then
58 $1_include="${$1_winclude}"
59 $1_libdir="${$1_wlibdir}"
65 if test ! -f "${$1_include}/$5" -o ! -d "${$1_libdir}" ; then
72 OLD_CPPFLAGS=$CPPFLAGS
74 if test -n "${$1_libdir}" -a "${$1_libdir}" != /usr/lib ; then
75 LDFLAGS="$LDFLAGS -L${$1_libdir}"
77 if test -n "${$1_include}" -a "${$1_include}" != /usr/include ; then
78 CPPFLAGS="$CPPFLAGS -I${$1_include}"
82 AC_SEARCH_LIBS($2,$4,success=yes)
83 AC_CHECK_HEADERS($5,,success=no)
84 if test "$success" = yes; then
86 ifelse([$6], , , [$6])
87 AC_DEFINE(HAVE_PKG_$1,1,[Define to 1 if you have the '$1' package.])
92 CPPFLAGS=$OLD_CPPFLAGS
96 if test "$success" = no ; then
98 ifelse([$7], , , [$7])
101 CPPFLAGS=$OLD_CPPFLAGS