1 dnl $Id: test-package.m4,v 1.7 1999/04/19 13:33:05 assar Exp $
3 dnl AC_TEST_PACKAGE_NEW(package,headers,libraries,extra libs,default locations)
5 AC_DEFUN(AC_TEST_PACKAGE,[AC_TEST_PACKAGE_NEW($1,[#include <$2>],$4,,$5)])
7 AC_DEFUN(AC_TEST_PACKAGE_NEW,[
9 [ --with-$1=dir use $1 in dir])
11 [ --with-$1-lib=dir use $1 libraries in dir],
12 [if test "$withval" = "yes" -o "$withval" = "no"; then
13 AC_MSG_ERROR([No argument for --with-$1-lib])
14 elif test "X$with_$1" = "X"; then
17 AC_ARG_WITH($1-include,
18 [ --with-$1-include=dir use $1 headers in dir],
19 [if test "$withval" = "yes" -o "$withval" = "no"; then
20 AC_MSG_ERROR([No argument for --with-$1-include])
21 elif test "X$with_$1" = "X"; then
25 AC_MSG_CHECKING(for $1)
31 *) if test "$with_$1_include" = ""; then
32 with_$1_include="$with_$1/include"
34 if test "$with_$1_lib" = ""; then
35 with_$1_lib="$with_$1/lib$abilibdirext"
43 header_dirs="$header_dirs $i/include"
44 lib_dirs="$lib_dirs $i/lib$abilibdirext"
47 case "$with_$1_include" in
50 *) header_dirs="$with_$1_include $header_dirs";;
52 case "$with_$1_lib" in
55 *) lib_dirs="$with_$1_lib $lib_dirs";;
61 for i in $header_dirs; do
62 CFLAGS="-I$i $save_CFLAGS"
63 AC_TRY_COMPILE([$2],,ires=$i;break)
65 for i in $lib_dirs; do
66 LIBS="-L$i $3 $4 $save_LIBS"
67 AC_TRY_LINK([$2],,lres=$i;break)
72 if test "$ires" -a "$lres" -a "$with_$1" != "no"; then
75 INCLUDE_$1="-I$$1_includedir"
76 LIB_$1="-L$$1_libdir $3"
77 AC_DEFINE_UNQUOTED(upcase($1),1,[Define if you have the $1 package.])
79 AC_MSG_RESULT([headers $ires, libraries $lres])
84 AC_MSG_RESULT($with_$1)