add the possibility to use a *-config program to get flags; rename to
rk_TEST_PACKAGE while here git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11274 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
		@@ -1,11 +1,9 @@
 | 
				
			|||||||
dnl $Id$
 | 
					dnl $Id$
 | 
				
			||||||
dnl
 | 
					dnl
 | 
				
			||||||
dnl AC_TEST_PACKAGE_NEW(package,headers,libraries,extra libs,
 | 
					dnl rk_TEST_PACKAGE(package,headers,libraries,extra libs,
 | 
				
			||||||
dnl			default locations, conditional, config-program)
 | 
					dnl			default locations, conditional, config-program)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AC_DEFUN(AC_TEST_PACKAGE,[AC_TEST_PACKAGE_NEW($1,[#include <$2>],$4,,$5)])
 | 
					AC_DEFUN(rk_TEST_PACKAGE,[
 | 
				
			||||||
 | 
					 | 
				
			||||||
AC_DEFUN(AC_TEST_PACKAGE_NEW,[
 | 
					 | 
				
			||||||
AC_ARG_WITH($1,
 | 
					AC_ARG_WITH($1,
 | 
				
			||||||
	AC_HELP_STRING([--with-$1=dir],[use $1 in dir]))
 | 
						AC_HELP_STRING([--with-$1=dir],[use $1 in dir]))
 | 
				
			||||||
AC_ARG_WITH($1-lib,
 | 
					AC_ARG_WITH($1-lib,
 | 
				
			||||||
@@ -22,73 +20,106 @@ AC_ARG_WITH($1-include,
 | 
				
			|||||||
elif test "X$with_$1" = "X"; then
 | 
					elif test "X$with_$1" = "X"; then
 | 
				
			||||||
  with_$1=yes
 | 
					  with_$1=yes
 | 
				
			||||||
fi])
 | 
					fi])
 | 
				
			||||||
 | 
					AC_ARG_WITH($1-config,
 | 
				
			||||||
 | 
						AC_HELP_STRING([--with-$1-config=path],[config program for $1]))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					m4_ifval([$6],
 | 
				
			||||||
 | 
						m4_define([rk_pkgname], $6),
 | 
				
			||||||
 | 
						m4_define([rk_pkgname], AS_TR_CPP($1)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AC_MSG_CHECKING(for $1)
 | 
					AC_MSG_CHECKING(for $1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
case "$with_$1" in
 | 
					case "$with_$1" in
 | 
				
			||||||
yes)	;;
 | 
					yes|"") d='$5' ;;
 | 
				
			||||||
no)	;;
 | 
					no)	d= ;;
 | 
				
			||||||
"")	;;
 | 
					*)	d="$with_$1" ;;
 | 
				
			||||||
*)	if test "$with_$1_include" = ""; then
 | 
					 | 
				
			||||||
		with_$1_include="$with_$1/include"
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
	if test "$with_$1_lib" = ""; then
 | 
					 | 
				
			||||||
		with_$1_lib="$with_$1/lib$abilibdirext"
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
	;;
 | 
					 | 
				
			||||||
esac
 | 
					esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
header_dirs=
 | 
					header_dirs=
 | 
				
			||||||
lib_dirs=
 | 
					lib_dirs=
 | 
				
			||||||
d='$5'
 | 
					 | 
				
			||||||
for i in $d; do
 | 
					for i in $d; do
 | 
				
			||||||
 | 
						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"
 | 
								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"
 | 
								lib_dirs="$lib_dirs $i/lib$abilibdirext"
 | 
				
			||||||
 | 
							fi
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
case "$with_$1_include" in
 | 
					if test "$with_$1_include"; then
 | 
				
			||||||
yes) ;;
 | 
						header_dirs="$with_$1_include $header_dirs"
 | 
				
			||||||
no)  ;;
 | 
					fi
 | 
				
			||||||
*)   header_dirs="$with_$1_include $header_dirs";;
 | 
					if test "$with_$1_lib"; then
 | 
				
			||||||
esac
 | 
						lib_dirs="$with_$1_lib $lib_dirs"
 | 
				
			||||||
case "$with_$1_lib" in
 | 
					fi
 | 
				
			||||||
yes) ;;
 | 
					
 | 
				
			||||||
no)  ;;
 | 
					if test "$with_$1_config" = ""; then
 | 
				
			||||||
*)   lib_dirs="$with_$1_lib $lib_dirs";;
 | 
						with_$1_config='$7'
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$1_cflags=
 | 
				
			||||||
 | 
					$1_libs=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					case "$with_$1_config" in
 | 
				
			||||||
 | 
					yes|no|"")
 | 
				
			||||||
 | 
						;;
 | 
				
			||||||
 | 
					*)
 | 
				
			||||||
 | 
						$1_cflags="`$with_$1_config --cflags 2>&1`"
 | 
				
			||||||
 | 
						$1_libs="`$with_$1_config --libs 2>&1`"
 | 
				
			||||||
 | 
						;;
 | 
				
			||||||
esac
 | 
					esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
save_CFLAGS="$CFLAGS"
 | 
					found=no
 | 
				
			||||||
save_LIBS="$LIBS"
 | 
					if test "$with_$1" != no; then
 | 
				
			||||||
ires= lres=
 | 
						save_CFLAGS="$CFLAGS"
 | 
				
			||||||
for i in $header_dirs; do
 | 
						save_LIBS="$LIBS"
 | 
				
			||||||
 | 
						if test "$[]$1_cflags" -a "$[]$1_libs"; then
 | 
				
			||||||
 | 
							CFLAGS="$[]$1_cflags $save_CFLAGS"
 | 
				
			||||||
 | 
							LIBS="$[]$1_libs $save_LIBS"
 | 
				
			||||||
 | 
							AC_TRY_LINK([$2],,[
 | 
				
			||||||
 | 
								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"
 | 
								CFLAGS="-I$i $save_CFLAGS"
 | 
				
			||||||
			AC_TRY_COMPILE([$2],,ires=$i;break)
 | 
								AC_TRY_COMPILE([$2],,ires=$i;break)
 | 
				
			||||||
done
 | 
							done
 | 
				
			||||||
for i in $lib_dirs; do
 | 
							for i in $lib_dirs; do
 | 
				
			||||||
			LIBS="-L$i $3 $4 $save_LIBS"
 | 
								LIBS="-L$i $3 $4 $save_LIBS"
 | 
				
			||||||
			AC_TRY_LINK([$2],,lres=$i;break)
 | 
								AC_TRY_LINK([$2],,lres=$i;break)
 | 
				
			||||||
done
 | 
							done
 | 
				
			||||||
CFLAGS="$save_CFLAGS"
 | 
							if test "$ires" -a "$lres" -a "$with_$1" != "no"; then
 | 
				
			||||||
LIBS="$save_LIBS"
 | 
								INCLUDE_$1="-I$ires"
 | 
				
			||||||
 | 
								LIB_$1="-L$lres $3"
 | 
				
			||||||
if test "$ires" -a "$lres" -a "$with_$1" != "no"; then
 | 
								found=yes
 | 
				
			||||||
	$1_includedir="$ires"
 | 
					 | 
				
			||||||
	$1_libdir="$lres"
 | 
					 | 
				
			||||||
	INCLUDE_$1="-I$$1_includedir"
 | 
					 | 
				
			||||||
	LIB_$1="-L$$1_libdir $3"
 | 
					 | 
				
			||||||
	m4_ifval([$6],
 | 
					 | 
				
			||||||
		AC_DEFINE_UNQUOTED($6,1,[Define if you have the $1 package.]),
 | 
					 | 
				
			||||||
		AC_DEFINE_UNQUOTED(upcase($1),1,[Define if you have the $1 package.]))
 | 
					 | 
				
			||||||
	with_$1=yes
 | 
					 | 
				
			||||||
			AC_MSG_RESULT([headers $ires, libraries $lres])
 | 
								AC_MSG_RESULT([headers $ires, libraries $lres])
 | 
				
			||||||
 | 
							fi
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
						CFLAGS="$save_CFLAGS"
 | 
				
			||||||
 | 
						LIBS="$save_LIBS"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if test "$found" = yes; then
 | 
				
			||||||
 | 
						AC_DEFINE_UNQUOTED(rk_pkgname, 1, [Define if you have the $1 package.])
 | 
				
			||||||
 | 
						with_$1=yes
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
 | 
						with_$1=no
 | 
				
			||||||
	INCLUDE_$1=
 | 
						INCLUDE_$1=
 | 
				
			||||||
	LIB_$1=
 | 
						LIB_$1=
 | 
				
			||||||
	with_$1=no
 | 
						AC_MSG_RESULT(no)
 | 
				
			||||||
	AC_MSG_RESULT($with_$1)
 | 
					 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
dnl m4_ifval([$6],
 | 
					
 | 
				
			||||||
dnl 	AM_CONDITIONAL($6, test "$with_$1" = yes)
 | 
					 | 
				
			||||||
dnl 	AM_CONDITIONAL(upcase($1), test "$with_$1" = yes))
 | 
					 | 
				
			||||||
AC_SUBST(INCLUDE_$1)
 | 
					AC_SUBST(INCLUDE_$1)
 | 
				
			||||||
AC_SUBST(LIB_$1)
 | 
					AC_SUBST(LIB_$1)
 | 
				
			||||||
])
 | 
					])
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user