1 dnl $Heimdal: test-package.m4 14166 2004-08-26 12:35:42Z joda $
4 dnl rk_TEST_PACKAGE(package,headers,libraries,extra libs,
5 dnl default locations, conditional, config-program)
7 AC_DEFUN([rk_TEST_PACKAGE],[
9 AS_HELP_STRING([--with-$1=dir],[use $1 in dir]))
11 AS_HELP_STRING([--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 AS_HELP_STRING([--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
24 AC_ARG_WITH($1-config,
25 AS_HELP_STRING([--with-$1-config=path],[config program for $1]))
28 m4_define([rk_pkgname], $6),
29 m4_define([rk_pkgname], AS_TR_CPP($1)))
31 AC_MSG_CHECKING(for $1)
42 if test "$with_$1_include" = ""; then
43 if test -d "$i/include/$1"; then
44 header_dirs="$header_dirs $i/include/$1"
46 if test -d "$i/include"; then
47 header_dirs="$header_dirs $i/include"
50 if test "$with_$1_lib" = ""; then
51 if test -d "$i/lib$abilibdirext"; then
52 lib_dirs="$lib_dirs $i/lib$abilibdirext"
57 if test "$with_$1_include"; then
58 header_dirs="$with_$1_include $header_dirs"
60 if test "$with_$1_lib"; then
61 lib_dirs="$with_$1_lib $lib_dirs"
64 if test "$with_$1_config" = ""; then
71 case "$with_$1_config" in
73 if test -f $with_$1/bin/$7 ; then
74 with_$1_config=$with_$1/bin/$7
79 case "$with_$1_config" in
83 $1_cflags="`$with_$1_config --cflags 2>&1`"
84 $1_libs="`$with_$1_config --libs 2>&1`"
89 if test "$with_$1" != no; then
92 if test "$[]$1_cflags" -a "$[]$1_libs"; then
93 CFLAGS="$[]$1_cflags $save_CFLAGS"
94 LIBS="$[]$1_libs $save_LIBS"
95 AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[]])],[
96 INCLUDE_$1="$[]$1_cflags"
98 AC_MSG_RESULT([from $with_$1_config])
101 if test "$found" = no; then
103 for i in $header_dirs; do
104 CFLAGS="-I$i $save_CFLAGS"
105 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$2]],[[]])],[ires=$i;break])
107 for i in $lib_dirs; do
108 LIBS="-L$i $3 $4 $save_LIBS"
109 AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[]])],[lres=$i;break])
111 if test "$ires" -a "$lres" -a "$with_$1" != "no"; then
113 LIB_$1="-L$lres $3 $4"
115 AC_MSG_RESULT([headers $ires, libraries $lres])
118 CFLAGS="$save_CFLAGS"
122 if test "$found" = yes; then
123 AC_DEFINE_UNQUOTED(rk_pkgname, 1, [Define if you have the $1 package.])