2008-05-07 13:39:42 +00:00
|
|
|
dnl $Id: test-package.m4 14166 2004-08-26 12:35:42Z joda $
|
2000-01-09 20:58:00 +00:00
|
|
|
dnl
|
2002-08-30 21:23:27 +00:00
|
|
|
dnl rk_TEST_PACKAGE(package,headers,libraries,extra libs,
|
|
|
|
dnl default locations, conditional, config-program)
|
2000-01-09 20:58:00 +00:00
|
|
|
|
2004-04-03 21:22:55 +00:00
|
|
|
AC_DEFUN([rk_TEST_PACKAGE],[
|
2000-01-09 20:58:00 +00:00
|
|
|
AC_ARG_WITH($1,
|
2008-05-07 13:39:42 +00:00
|
|
|
AS_HELP_STRING([--with-$1=dir],[use $1 in dir]))
|
2000-01-09 20:58:00 +00:00
|
|
|
AC_ARG_WITH($1-lib,
|
2008-05-07 13:39:42 +00:00
|
|
|
AS_HELP_STRING([--with-$1-lib=dir],[use $1 libraries in dir]),
|
2000-01-09 20:58:00 +00:00
|
|
|
[if test "$withval" = "yes" -o "$withval" = "no"; then
|
|
|
|
AC_MSG_ERROR([No argument for --with-$1-lib])
|
|
|
|
elif test "X$with_$1" = "X"; then
|
|
|
|
with_$1=yes
|
|
|
|
fi])
|
|
|
|
AC_ARG_WITH($1-include,
|
2008-05-07 13:39:42 +00:00
|
|
|
AS_HELP_STRING([--with-$1-include=dir],[use $1 headers in dir]),
|
2000-01-09 20:58:00 +00:00
|
|
|
[if test "$withval" = "yes" -o "$withval" = "no"; then
|
|
|
|
AC_MSG_ERROR([No argument for --with-$1-include])
|
|
|
|
elif test "X$with_$1" = "X"; then
|
|
|
|
with_$1=yes
|
|
|
|
fi])
|
2002-08-30 21:23:27 +00:00
|
|
|
AC_ARG_WITH($1-config,
|
2008-05-07 13:39:42 +00:00
|
|
|
AS_HELP_STRING([--with-$1-config=path],[config program for $1]))
|
2002-08-30 21:23:27 +00:00
|
|
|
|
|
|
|
m4_ifval([$6],
|
|
|
|
m4_define([rk_pkgname], $6),
|
|
|
|
m4_define([rk_pkgname], AS_TR_CPP($1)))
|
2000-01-09 20:58:00 +00:00
|
|
|
|
|
|
|
AC_MSG_CHECKING(for $1)
|
|
|
|
|
|
|
|
case "$with_$1" in
|
2002-08-30 21:23:27 +00:00
|
|
|
yes|"") d='$5' ;;
|
|
|
|
no) d= ;;
|
|
|
|
*) d="$with_$1" ;;
|
2000-01-09 20:58:00 +00:00
|
|
|
esac
|
2002-08-30 21:23:27 +00:00
|
|
|
|
2000-01-09 20:58:00 +00:00
|
|
|
header_dirs=
|
|
|
|
lib_dirs=
|
|
|
|
for i in $d; do
|
2002-08-30 21:23:27 +00:00
|
|
|
if test "$with_$1_include" = ""; then
|
|
|
|
if test -d "$i/include/$1"; then
|
|
|
|
header_dirs="$header_dirs $i/include/$1"
|
|
|
|
fi
|
|
|
|
if test -d "$i/include"; then
|
|
|
|
header_dirs="$header_dirs $i/include"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if test "$with_$1_lib" = ""; then
|
|
|
|
if test -d "$i/lib$abilibdirext"; then
|
|
|
|
lib_dirs="$lib_dirs $i/lib$abilibdirext"
|
|
|
|
fi
|
|
|
|
fi
|
2000-01-09 20:58:00 +00:00
|
|
|
done
|
|
|
|
|
2002-08-30 21:23:27 +00:00
|
|
|
if test "$with_$1_include"; then
|
|
|
|
header_dirs="$with_$1_include $header_dirs"
|
|
|
|
fi
|
|
|
|
if test "$with_$1_lib"; then
|
|
|
|
lib_dirs="$with_$1_lib $lib_dirs"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$with_$1_config" = ""; then
|
|
|
|
with_$1_config='$7'
|
|
|
|
fi
|
|
|
|
|
|
|
|
$1_cflags=
|
|
|
|
$1_libs=
|
|
|
|
|
2008-05-07 13:39:42 +00:00
|
|
|
case "$with_$1_config" in
|
|
|
|
yes|no|""|"$7")
|
|
|
|
if test -f $with_$1/bin/$7 ; then
|
|
|
|
with_$1_config=$with_$1/bin/$7
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2002-08-30 21:23:27 +00:00
|
|
|
case "$with_$1_config" in
|
|
|
|
yes|no|"")
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
$1_cflags="`$with_$1_config --cflags 2>&1`"
|
|
|
|
$1_libs="`$with_$1_config --libs 2>&1`"
|
|
|
|
;;
|
2000-01-09 20:58:00 +00:00
|
|
|
esac
|
|
|
|
|
2002-08-30 21:23:27 +00:00
|
|
|
found=no
|
|
|
|
if test "$with_$1" != no; then
|
|
|
|
save_CFLAGS="$CFLAGS"
|
|
|
|
save_LIBS="$LIBS"
|
|
|
|
if test "$[]$1_cflags" -a "$[]$1_libs"; then
|
|
|
|
CFLAGS="$[]$1_cflags $save_CFLAGS"
|
|
|
|
LIBS="$[]$1_libs $save_LIBS"
|
2008-05-07 13:39:42 +00:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[]])],[
|
2002-08-30 21:23:27 +00:00
|
|
|
INCLUDE_$1="$[]$1_cflags"
|
|
|
|
LIB_$1="$[]$1_libs"
|
|
|
|
AC_MSG_RESULT([from $with_$1_config])
|
|
|
|
found=yes])
|
|
|
|
fi
|
|
|
|
if test "$found" = no; then
|
|
|
|
ires= lres=
|
|
|
|
for i in $header_dirs; do
|
|
|
|
CFLAGS="-I$i $save_CFLAGS"
|
2008-05-07 13:39:42 +00:00
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$2]],[[]])],[ires=$i;break])
|
2002-08-30 21:23:27 +00:00
|
|
|
done
|
|
|
|
for i in $lib_dirs; do
|
|
|
|
LIBS="-L$i $3 $4 $save_LIBS"
|
2008-05-07 13:39:42 +00:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[]])],[lres=$i;break])
|
2002-08-30 21:23:27 +00:00
|
|
|
done
|
|
|
|
if test "$ires" -a "$lres" -a "$with_$1" != "no"; then
|
|
|
|
INCLUDE_$1="-I$ires"
|
2002-09-16 21:04:40 +00:00
|
|
|
LIB_$1="-L$lres $3 $4"
|
2002-08-30 21:23:27 +00:00
|
|
|
found=yes
|
|
|
|
AC_MSG_RESULT([headers $ires, libraries $lres])
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
CFLAGS="$save_CFLAGS"
|
|
|
|
LIBS="$save_LIBS"
|
|
|
|
fi
|
2000-01-09 20:58:00 +00:00
|
|
|
|
2002-08-30 21:23:27 +00:00
|
|
|
if test "$found" = yes; then
|
|
|
|
AC_DEFINE_UNQUOTED(rk_pkgname, 1, [Define if you have the $1 package.])
|
2000-01-09 20:58:00 +00:00
|
|
|
with_$1=yes
|
|
|
|
else
|
2002-08-30 21:23:27 +00:00
|
|
|
with_$1=no
|
2000-01-09 20:58:00 +00:00
|
|
|
INCLUDE_$1=
|
|
|
|
LIB_$1=
|
2002-08-30 21:23:27 +00:00
|
|
|
AC_MSG_RESULT(no)
|
2000-01-09 20:58:00 +00:00
|
|
|
fi
|
2002-08-30 21:23:27 +00:00
|
|
|
|
2000-01-09 20:58:00 +00:00
|
|
|
AC_SUBST(INCLUDE_$1)
|
|
|
|
AC_SUBST(LIB_$1)
|
|
|
|
])
|