diff --git a/acinclude.m4 b/acinclude.m4 index c2984b863..1ebe22aa2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -10,6 +10,7 @@ dnl dnl Look for function in any of the specified libraries dnl +dnl AC_FIND_FUNC_NO_LIBS(func, libraries, includes, arguments) AC_DEFUN(AC_FIND_FUNC_NO_LIBS, [ AC_MSG_CHECKING([for $1]) @@ -22,7 +23,7 @@ if eval "test \"\$ac_cv_func_$1\" != yes" ; then ac_lib="-l$ac_lib" LIBS="$ac_lib $ac_save_LIBS" fi - AC_TRY_LINK([],[$1()],eval "if test -n \"$ac_lib\";then ac_cv_funclib_$1=$ac_lib; else ac_cv_funclib_$1=yes; fi";break) + AC_TRY_LINK([$3],[$1($4)],eval "if test -n \"$ac_lib\";then ac_cv_funclib_$1=$ac_lib; else ac_cv_funclib_$1=yes; fi";break) done eval "ac_cv_funclib_$1=\${ac_cv_funclib_$1-no}" LIBS="$ac_save_LIBS" @@ -66,10 +67,11 @@ esac AC_SUBST(LIB_$1) ]) +dnl AC_FIND_FUNC(func, libraries, includes, arguments) AC_DEFUN(AC_FIND_FUNC, [ -AC_FIND_FUNC_NO_LIBS($1, $2) +AC_FIND_FUNC_NO_LIBS([$1], [$2], [$3], [$4]) if test -n "$LIB_$1"; then - LIBS="$LIBS $LIB_$1" + LIBS="$LIB_$1 $LIBS" fi ]) @@ -98,7 +100,7 @@ dnl Mix between AC_FIND_FUNC and AC_BROKEN dnl AC_DEFUN(AC_FIND_IF_NOT_BROKEN, -[AC_FIND_FUNC($1, $2) +[AC_FIND_FUNC([$1], [$2], [$3], [$4]) if eval "test \"$ac_cv_func_$1\" != yes"; then LIBOBJS="$LIBOBJS $1.o" fi @@ -106,20 +108,111 @@ AC_SUBST(LIBOBJS)dnl ]) dnl -dnl Build S/Key support into the login program. dnl -AC_DEFUN(AC_TEST_SKEY, -[AC_ARG_WITH(skeylib, -[ --with-skeylib=dir use the skeylib.a in dir], +dnl + +dnl AC_TEST_PACKAGE(package,header,lib,linkline) +AC_DEFUN(AC_TEST_PACKAGE, +[ +AC_MSG_CHECKING(for $1) +AC_ARG_WITH($1, +[ --with-$1=dir use $1 in dir], +[if test "$with_$1" = "no"; then + with_$1= +fi] ) -test -n "$with_skeylib" && -SKEYLIB="-L$with_skeylib -lskey" && -SKEYINCLUDE="-I$with_skeylib" && -AC_MSG_RESULT(Using skeylib in $with_skeylib) -AC_SUBST(SKEYLIB) -AC_SUBST(SKEYINCLUDE) -test -n "$with_skeylib" && -AC_DEFINE(SKEY)]) +AC_ARG_WITH($1-lib, +[ --with-$1-lib=dir use $1-lib in dir], +[if test "$withval" = "yes" -o "$withval" = "no"; then + AC_MSG_ERROR([No argument for --with-$1-lib]) +elif test "X$with_$1" = "X"; then + with_$1=yes +fi] +) +AC_ARG_WITH($1-include, +[ --with-$1-include=dir use $1-include in dir], +[if test "$withval" = "yes" -o "$withval" = "no"; then + AC_MSG_ERROR([No argument for --with-$1-include]) +elif test "X$with_$1" = "X"; then + with_$1=yes +fi] +) + +define([foo], translit($1, [a-z], [A-Z])) +: << END +@@@syms="$syms foo"@@@ +END + +if test -n "$with_$1"; then + AC_DEFINE([foo]) + if test "$with_$1" != "yes"; then + $1_dir=$with_$1 + fi +dnl Try to find include + if test -n "$with_$1_include"; then + trydir=$with_$1_include + elif test "$with_$1" != "yes"; then + trydir="$with_$1 $with_$1/include" + else + trydir= + fi + found= + for i in $trydir ""; do + if test -n "$i"; then + if test -f $i/$2; then + found=yes; res=$i; break + fi + else + AC_TRY_CPP([#include <$2>], [found=yes; res=$i; break]) + fi + done + if test -n "$found"; then + $1_include=$res + else + AC_MSG_ERROR(Cannot find $2) + fi +dnl Try to find lib + if test -n "$with_$1_lib"; then + trydir=$with_$1_lib + elif test "$with_$1" != "yes"; then + trydir="$with_$1 $with_$1/lib" + else + trydir= + fi + found= + for i in $trydir ""; do + if test -n "$i"; then + if test -f $i/$3; then + found=yes; res=$i; break + fi + else + old_LIBS=$LIBS + LIBS="$4 $LIBS" + AC_TRY_LINK([], [], [found=yes; res=$i; LIBS=$old_LIBS; break]) + LIBS=$old_LIBS + fi + done + if test -n "$found"; then + $1_lib=$res + else + AC_MSG_ERROR(Cannot find $3) + fi + AC_MSG_RESULT([headers $$1_include, libraries $$1_lib]) + AC_DEFINE_UNQUOTED(foo) + if test -n "$$1_include"; then + foo[INCLUDE]="-I$$1_include" + fi + AC_SUBST(foo[INCLUDE]) + if test -n "$$1_lib"; then + foo[LIB]="-L$$1_lib" + fi + foo[LIB]="$foo[LIB] $4" + AC_SUBST(foo[LIB]) +else + AC_MSG_RESULT(no) +fi +undefine([foo]) +]) dnl dnl Check if we need the declaration of a variable @@ -150,10 +243,39 @@ if eval "test \"\$ac_cv_var_$3_declaration\" = yes"; then fi ]) +dnl +dnl +dnl + +dnl AC_CHECK_VAR(includes, variable) +AC_DEFUN(AC_CHECK_VAR, [ +AC_MSG_CHECKING(for $2) +AC_CACHE_VAL(ac_cv_var_$2, [ +AC_TRY_LINK([extern int $2; +int foo() { return $2; }], + [foo()], + ac_cv_var_$2=yes, ac_cv_var_$2=no) +]) +eval "ac_tr_var=[HAVE_]translit($2,[a-z],[A-Z])" + +define([foo], [HAVE_]translit($2, [a-z], [A-Z])) +: << END +@@@syms="$syms foo"@@@ +END +undefine([foo]) + +AC_MSG_RESULT(`eval echo \\$ac_cv_var_$2`) +if test `eval echo \\$ac_cv_var_$2` = yes; then + AC_DEFINE_UNQUOTED($ac_tr_var) + AC_CHECK_DECLARATION([$1],[$2]) +fi +]) + dnl dnl Check if we need the prototype for a function dnl +dnl AC_NEED_PROTO(includes, code, function) AC_DEFUN(AC_NEED_PROTO, [ AC_MSG_CHECKING([if $3 needs a proto]) AC_CACHE_VAL(ac_cv_func_$3_proto, [ @@ -355,18 +477,3 @@ for i in $1; do AC_MSG_RESULT($ac_res) done ]) - -dnl -dnl Check for the variable `timezone' -dnl - -AC_DEFUN(AC_KRB_VAR_TIMEZONE, [ -AC_MSG_CHECKING(for variable timezone) -AC_CACHE_VAL(ac_krb_var_timezone, -AC_TRY_LINK([#include ], [int foo = timezone;], -ac_krb_var_timezone=yes,ac_krb_var_timezone=no)) -AC_MSG_RESULT($ac_krb_var_timezone) -if test "$ac_krb_var_timezone" = yes; then - AC_DEFINE_UNQUOTED(HAVE_TIMEZONE) -fi -])