test-package.m4 revision 55682
1dnl $Id: test-package.m4,v 1.7 1999/04/19 13:33:05 assar Exp $ 2dnl 3dnl AC_TEST_PACKAGE_NEW(package,headers,libraries,extra libs,default locations) 4 5AC_DEFUN(AC_TEST_PACKAGE,[AC_TEST_PACKAGE_NEW($1,[#include <$2>],$4,,$5)]) 6 7AC_DEFUN(AC_TEST_PACKAGE_NEW,[ 8AC_ARG_WITH($1, 9[ --with-$1=dir use $1 in dir]) 10AC_ARG_WITH($1-lib, 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]) 14elif test "X$with_$1" = "X"; then 15 with_$1=yes 16fi]) 17AC_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]) 21elif test "X$with_$1" = "X"; then 22 with_$1=yes 23fi]) 24 25AC_MSG_CHECKING(for $1) 26 27case "$with_$1" in 28yes) ;; 29no) ;; 30"") ;; 31*) if test "$with_$1_include" = ""; then 32 with_$1_include="$with_$1/include" 33 fi 34 if test "$with_$1_lib" = ""; then 35 with_$1_lib="$with_$1/lib$abilibdirext" 36 fi 37 ;; 38esac 39header_dirs= 40lib_dirs= 41d='$5' 42for i in $d; do 43 header_dirs="$header_dirs $i/include" 44 lib_dirs="$lib_dirs $i/lib$abilibdirext" 45done 46 47case "$with_$1_include" in 48yes) ;; 49no) ;; 50*) header_dirs="$with_$1_include $header_dirs";; 51esac 52case "$with_$1_lib" in 53yes) ;; 54no) ;; 55*) lib_dirs="$with_$1_lib $lib_dirs";; 56esac 57 58save_CFLAGS="$CFLAGS" 59save_LIBS="$LIBS" 60ires= lres= 61for i in $header_dirs; do 62 CFLAGS="-I$i $save_CFLAGS" 63 AC_TRY_COMPILE([$2],,ires=$i;break) 64done 65for i in $lib_dirs; do 66 LIBS="-L$i $3 $4 $save_LIBS" 67 AC_TRY_LINK([$2],,lres=$i;break) 68done 69CFLAGS="$save_CFLAGS" 70LIBS="$save_LIBS" 71 72if test "$ires" -a "$lres" -a "$with_$1" != "no"; then 73 $1_includedir="$ires" 74 $1_libdir="$lres" 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.]) 78 with_$1=yes 79 AC_MSG_RESULT([headers $ires, libraries $lres]) 80else 81 INCLUDE_$1= 82 LIB_$1= 83 with_$1=no 84 AC_MSG_RESULT($with_$1) 85fi 86AC_SUBST(INCLUDE_$1) 87AC_SUBST(LIB_$1) 88]) 89