| 1 | dnl $Id$
|
|---|
| 2 | dnl
|
|---|
| 3 | dnl rk_TEST_PACKAGE(package,headers,libraries,extra libs,
|
|---|
| 4 | dnl default locations, conditional, config-program, headers)
|
|---|
| 5 |
|
|---|
| 6 | AC_DEFUN([rk_TEST_PACKAGE],[
|
|---|
| 7 | AC_ARG_WITH($1,
|
|---|
| 8 | AS_HELP_STRING([--with-$1=dir],[use $1 in dir]))
|
|---|
| 9 | AC_ARG_WITH($1-lib,
|
|---|
| 10 | AS_HELP_STRING([--with-$1-lib=dir],[use $1 libraries in dir]),
|
|---|
| 11 | [if test "$withval" = "yes" -o "$withval" = "no"; then
|
|---|
| 12 | AC_MSG_ERROR([No argument for --with-$1-lib])
|
|---|
| 13 | elif test "X$with_$1" = "X"; then
|
|---|
| 14 | with_$1=yes
|
|---|
| 15 | fi])
|
|---|
| 16 | AC_ARG_WITH($1-include,
|
|---|
| 17 | AS_HELP_STRING([--with-$1-include=dir],[use $1 headers in dir]),
|
|---|
| 18 | [if test "$withval" = "yes" -o "$withval" = "no"; then
|
|---|
| 19 | AC_MSG_ERROR([No argument for --with-$1-include])
|
|---|
| 20 | elif test "X$with_$1" = "X"; then
|
|---|
| 21 | with_$1=yes
|
|---|
| 22 | fi])
|
|---|
| 23 | AC_ARG_WITH($1-config,
|
|---|
| 24 | AS_HELP_STRING([--with-$1-config=path],[config program for $1]))
|
|---|
| 25 |
|
|---|
| 26 | m4_ifval([$6],
|
|---|
| 27 | m4_define([rk_pkgname], $6),
|
|---|
| 28 | m4_define([rk_pkgname], AS_TR_CPP($1)))
|
|---|
| 29 |
|
|---|
| 30 | AC_MSG_CHECKING(for $1)
|
|---|
| 31 |
|
|---|
| 32 | case "$with_$1" in
|
|---|
| 33 | yes|"") d='$5' ;;
|
|---|
| 34 | no) d= ;;
|
|---|
| 35 | *) d="$with_$1" ;;
|
|---|
| 36 | esac
|
|---|
| 37 |
|
|---|
| 38 | header_dirs=
|
|---|
| 39 | lib_dirs=
|
|---|
| 40 | for i in $d; do
|
|---|
| 41 | if test "$with_$1_include" = ""; then
|
|---|
| 42 | if test -d "$i/include/$1"; then
|
|---|
| 43 | header_dirs="$header_dirs $i/include/$1"
|
|---|
| 44 | fi
|
|---|
| 45 | if test -d "$i/include"; then
|
|---|
| 46 | header_dirs="$header_dirs $i/include"
|
|---|
| 47 | fi
|
|---|
| 48 | fi
|
|---|
| 49 | if test "$with_$1_lib" = ""; then
|
|---|
| 50 | if test -d "$i/lib$abilibdirext"; then
|
|---|
| 51 | lib_dirs="$lib_dirs $i/lib$abilibdirext"
|
|---|
| 52 | fi
|
|---|
| 53 | fi
|
|---|
| 54 | done
|
|---|
| 55 |
|
|---|
| 56 | if test "$with_$1_include"; then
|
|---|
| 57 | header_dirs="$with_$1_include $header_dirs"
|
|---|
| 58 | fi
|
|---|
| 59 | if test "$with_$1_lib"; then
|
|---|
| 60 | lib_dirs="$with_$1_lib $lib_dirs"
|
|---|
| 61 | fi
|
|---|
| 62 |
|
|---|
| 63 | if test "$with_$1_config" = ""; then
|
|---|
| 64 | with_$1_config='$7'
|
|---|
| 65 | fi
|
|---|
| 66 |
|
|---|
| 67 | $1_cflags=
|
|---|
| 68 | $1_libs=
|
|---|
| 69 |
|
|---|
| 70 | case "$with_$1_config" in
|
|---|
| 71 | yes|no|""|"$7")
|
|---|
| 72 | if test -f $with_$1/bin/$7 ; then
|
|---|
| 73 | with_$1_config=$with_$1/bin/$7
|
|---|
| 74 | fi
|
|---|
| 75 | ;;
|
|---|
| 76 | esac
|
|---|
| 77 |
|
|---|
| 78 | case "$with_$1_config" in
|
|---|
| 79 | yes|no|"")
|
|---|
| 80 | ;;
|
|---|
| 81 | *)
|
|---|
| 82 | $1_cflags="`$with_$1_config --cflags 2>&1`"
|
|---|
| 83 | $1_libs="`$with_$1_config --libs 2>&1`"
|
|---|
| 84 | ;;
|
|---|
| 85 | esac
|
|---|
| 86 |
|
|---|
| 87 | found=no
|
|---|
| 88 | if test "$with_$1" != no; then
|
|---|
| 89 | save_CFLAGS="$CFLAGS"
|
|---|
| 90 | save_LIBS="$LIBS"
|
|---|
| 91 | if test "$[]$1_cflags" -a "$[]$1_libs"; then
|
|---|
| 92 | CFLAGS="$[]$1_cflags $save_CFLAGS"
|
|---|
| 93 | LIBS="$[]$1_libs $save_LIBS"
|
|---|
| 94 | m4_ifval([$8],[AC_CHECK_HEADERS([[$8]])])
|
|---|
| 95 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[]])],[
|
|---|
| 96 | INCLUDE_$1="$[]$1_cflags"
|
|---|
| 97 | LIB_$1="$[]$1_libs"
|
|---|
| 98 | AC_MSG_RESULT([from $with_$1_config])
|
|---|
| 99 | found=yes])
|
|---|
| 100 | fi
|
|---|
| 101 | if test "$found" = no; then
|
|---|
| 102 | ires= lres=
|
|---|
| 103 | for i in $header_dirs; do
|
|---|
| 104 | CFLAGS="-I$i $save_CFLAGS"
|
|---|
| 105 | m4_ifval([$8],[AC_CHECK_HEADERS([[$8]])])
|
|---|
| 106 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$2]],[[]])],[ires=$i;break])
|
|---|
| 107 | done
|
|---|
| 108 | for i in $lib_dirs; do
|
|---|
| 109 | LIBS="-L$i $3 $4 $save_LIBS"
|
|---|
| 110 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[]])],[lres=$i;break])
|
|---|
| 111 | done
|
|---|
| 112 | if test "$ires" -a "$lres" -a "$with_$1" != "no"; then
|
|---|
| 113 | INCLUDE_$1="-I$ires"
|
|---|
| 114 | LIB_$1="-L$lres $3 $4"
|
|---|
| 115 | found=yes
|
|---|
| 116 | AC_MSG_RESULT([headers $ires, libraries $lres])
|
|---|
| 117 | fi
|
|---|
| 118 | fi
|
|---|
| 119 | CFLAGS="$save_CFLAGS"
|
|---|
| 120 | LIBS="$save_LIBS"
|
|---|
| 121 | fi
|
|---|
| 122 |
|
|---|
| 123 | if test "$found" = yes; then
|
|---|
| 124 | AC_DEFINE_UNQUOTED(rk_pkgname, 1, [Define if you have the $1 package.])
|
|---|
| 125 | with_$1=yes
|
|---|
| 126 | else
|
|---|
| 127 | with_$1=no
|
|---|
| 128 | INCLUDE_$1=
|
|---|
| 129 | LIB_$1=
|
|---|
| 130 | AC_MSG_RESULT(no)
|
|---|
| 131 | fi
|
|---|
| 132 |
|
|---|
| 133 | AC_SUBST(INCLUDE_$1)
|
|---|
| 134 | AC_SUBST(LIB_$1)
|
|---|
| 135 | ])
|
|---|