Home | History | Annotate | Line # | Download | only in cf
find-func-no-libs2.m4 revision 1.1
      1  1.1  elric dnl $Id: find-func-no-libs2.m4,v 1.1 2011/04/13 18:14:32 elric Exp $
      2  1.1  elric dnl
      3  1.1  elric dnl
      4  1.1  elric dnl Look for function in any of the specified libraries
      5  1.1  elric dnl
      6  1.1  elric 
      7  1.1  elric dnl AC_FIND_FUNC_NO_LIBS2(func, libraries, includes, arguments, extra libs, extra args)
      8  1.1  elric AC_DEFUN([AC_FIND_FUNC_NO_LIBS2], [
      9  1.1  elric 
     10  1.1  elric AC_MSG_CHECKING([for $1])
     11  1.1  elric AC_CACHE_VAL(ac_cv_funclib_$1,
     12  1.1  elric [
     13  1.1  elric if eval "test \"\$ac_cv_func_$1\" != yes" ; then
     14  1.1  elric 	ac_save_LIBS="$LIBS"
     15  1.1  elric 	for ac_lib in $2; do
     16  1.1  elric 		case "$ac_lib" in
     17  1.1  elric 		"") ;;
     18  1.1  elric 		yes) ac_lib="" ;;
     19  1.1  elric 		no) continue ;;
     20  1.1  elric 		-l*) ;;
     21  1.1  elric 		*) ac_lib="-l$ac_lib" ;;
     22  1.1  elric 		esac
     23  1.1  elric 		LIBS="$6 $ac_lib $5 $ac_save_LIBS"
     24  1.1  elric 		AC_LINK_IFELSE([AC_LANG_PROGRAM([[$3]],[[$1($4)]])],[eval "if test -n \"$ac_lib\";then ac_cv_funclib_$1=$ac_lib; else ac_cv_funclib_$1=yes; fi";break])
     25  1.1  elric 	done
     26  1.1  elric 	eval "ac_cv_funclib_$1=\${ac_cv_funclib_$1-no}"
     27  1.1  elric 	LIBS="$ac_save_LIBS"
     28  1.1  elric fi
     29  1.1  elric ])
     30  1.1  elric 
     31  1.1  elric eval "ac_res=\$ac_cv_funclib_$1"
     32  1.1  elric 
     33  1.1  elric if false; then
     34  1.1  elric 	AC_CHECK_FUNCS($1)
     35  1.1  elric dnl	AC_CHECK_LIBS($2, foo)
     36  1.1  elric fi
     37  1.1  elric # $1
     38  1.1  elric eval "ac_tr_func=HAVE_[]upcase($1)"
     39  1.1  elric eval "ac_tr_lib=HAVE_LIB[]upcase($ac_res | sed -e 's/-l//')"
     40  1.1  elric eval "LIB_$1=$ac_res"
     41  1.1  elric 
     42  1.1  elric case "$ac_res" in
     43  1.1  elric 	yes)
     44  1.1  elric 	eval "ac_cv_func_$1=yes"
     45  1.1  elric 	eval "LIB_$1="
     46  1.1  elric 	AC_DEFINE_UNQUOTED($ac_tr_func)
     47  1.1  elric 	AC_MSG_RESULT([yes])
     48  1.1  elric 	;;
     49  1.1  elric 	no)
     50  1.1  elric 	eval "ac_cv_func_$1=no"
     51  1.1  elric 	eval "LIB_$1="
     52  1.1  elric 	AC_MSG_RESULT([no])
     53  1.1  elric 	;;
     54  1.1  elric 	*)
     55  1.1  elric 	eval "ac_cv_func_$1=yes"
     56  1.1  elric 	eval "ac_cv_lib_`echo "$ac_res" | sed 's/-l//'`=yes"
     57  1.1  elric 	AC_DEFINE_UNQUOTED($ac_tr_func)
     58  1.1  elric 	AC_DEFINE_UNQUOTED($ac_tr_lib)
     59  1.1  elric 	AC_MSG_RESULT([yes, in $ac_res])
     60  1.1  elric 	;;
     61  1.1  elric esac
     62  1.1  elric AC_SUBST(LIB_$1)
     63  1.1  elric ])
     64