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