1021d409fSDag-Erling Smørgravdnl $Id: aclocal.m4,v 1.6 2005/09/19 16:33:39 tim Exp $ 283d2307dSDag-Erling Smørgravdnl 383d2307dSDag-Erling Smørgravdnl OpenSSH-specific autoconf macros 483d2307dSDag-Erling Smørgravdnl 583d2307dSDag-Erling Smørgrav 683d2307dSDag-Erling Smørgrav 783d2307dSDag-Erling Smørgravdnl OSSH_CHECK_HEADER_FOR_FIELD(field, header, symbol) 883d2307dSDag-Erling Smørgravdnl Does AC_EGREP_HEADER on 'header' for the string 'field' 983d2307dSDag-Erling Smørgravdnl If found, set 'symbol' to be defined. Cache the result. 1083d2307dSDag-Erling Smørgravdnl TODO: This is not foolproof, better to compile and read from there 1183d2307dSDag-Erling SmørgravAC_DEFUN(OSSH_CHECK_HEADER_FOR_FIELD, [ 1283d2307dSDag-Erling Smørgrav# look for field '$1' in header '$2' 1383d2307dSDag-Erling Smørgrav dnl This strips characters illegal to m4 from the header filename 1483d2307dSDag-Erling Smørgrav ossh_safe=`echo "$2" | sed 'y%./+-%__p_%'` 1583d2307dSDag-Erling Smørgrav dnl 1683d2307dSDag-Erling Smørgrav ossh_varname="ossh_cv_$ossh_safe""_has_"$1 1783d2307dSDag-Erling Smørgrav AC_MSG_CHECKING(for $1 field in $2) 1883d2307dSDag-Erling Smørgrav AC_CACHE_VAL($ossh_varname, [ 1983d2307dSDag-Erling Smørgrav AC_EGREP_HEADER($1, $2, [ dnl 2083d2307dSDag-Erling Smørgrav eval "$ossh_varname=yes" dnl 2183d2307dSDag-Erling Smørgrav ], [ dnl 2283d2307dSDag-Erling Smørgrav eval "$ossh_varname=no" dnl 2383d2307dSDag-Erling Smørgrav ]) dnl 2483d2307dSDag-Erling Smørgrav ]) 2583d2307dSDag-Erling Smørgrav ossh_result=`eval 'echo $'"$ossh_varname"` 2683d2307dSDag-Erling Smørgrav if test -n "`echo $ossh_varname`"; then 2783d2307dSDag-Erling Smørgrav AC_MSG_RESULT($ossh_result) 2883d2307dSDag-Erling Smørgrav if test "x$ossh_result" = "xyes"; then 29021d409fSDag-Erling Smørgrav AC_DEFINE($3, 1, [Define if you have $1 in $2]) 3083d2307dSDag-Erling Smørgrav fi 3183d2307dSDag-Erling Smørgrav else 3283d2307dSDag-Erling Smørgrav AC_MSG_RESULT(no) 3383d2307dSDag-Erling Smørgrav fi 3483d2307dSDag-Erling Smørgrav]) 3583d2307dSDag-Erling Smørgrav 3683d2307dSDag-Erling Smørgravdnl OSSH_PATH_ENTROPY_PROG(variablename, command): 3783d2307dSDag-Erling Smørgravdnl Tidiness function, sets 'undef' if not found, and does the AC_SUBST 3883d2307dSDag-Erling SmørgravAC_DEFUN(OSSH_PATH_ENTROPY_PROG, [ 3983d2307dSDag-Erling Smørgrav AC_PATH_PROG($1, $2) 4083d2307dSDag-Erling Smørgrav if test -z "[$]$1" ; then 4183d2307dSDag-Erling Smørgrav $1="undef" 4283d2307dSDag-Erling Smørgrav fi 4383d2307dSDag-Erling Smørgrav AC_SUBST($1) 4483d2307dSDag-Erling Smørgrav]) 4583d2307dSDag-Erling Smørgrav 4683d2307dSDag-Erling Smørgravdnl Check for socklen_t: historically on BSD it is an int, and in 4783d2307dSDag-Erling Smørgravdnl POSIX 1g it is a type of its own, but some platforms use different 4883d2307dSDag-Erling Smørgravdnl types for the argument to getsockopt, getpeername, etc. So we 4983d2307dSDag-Erling Smørgravdnl have to test to find something that will work. 5083d2307dSDag-Erling SmørgravAC_DEFUN([TYPE_SOCKLEN_T], 5183d2307dSDag-Erling Smørgrav[ 5283d2307dSDag-Erling Smørgrav AC_CHECK_TYPE([socklen_t], ,[ 5383d2307dSDag-Erling Smørgrav AC_MSG_CHECKING([for socklen_t equivalent]) 5483d2307dSDag-Erling Smørgrav AC_CACHE_VAL([curl_cv_socklen_t_equiv], 5583d2307dSDag-Erling Smørgrav [ 5683d2307dSDag-Erling Smørgrav # Systems have either "struct sockaddr *" or 5783d2307dSDag-Erling Smørgrav # "void *" as the second argument to getpeername 5883d2307dSDag-Erling Smørgrav curl_cv_socklen_t_equiv= 5983d2307dSDag-Erling Smørgrav for arg2 in "struct sockaddr" void; do 6083d2307dSDag-Erling Smørgrav for t in int size_t unsigned long "unsigned long"; do 6183d2307dSDag-Erling Smørgrav AC_TRY_COMPILE([ 6283d2307dSDag-Erling Smørgrav #include <sys/types.h> 6383d2307dSDag-Erling Smørgrav #include <sys/socket.h> 6483d2307dSDag-Erling Smørgrav 6583d2307dSDag-Erling Smørgrav int getpeername (int, $arg2 *, $t *); 6683d2307dSDag-Erling Smørgrav ],[ 6783d2307dSDag-Erling Smørgrav $t len; 6883d2307dSDag-Erling Smørgrav getpeername(0,0,&len); 6983d2307dSDag-Erling Smørgrav ],[ 7083d2307dSDag-Erling Smørgrav curl_cv_socklen_t_equiv="$t" 7183d2307dSDag-Erling Smørgrav break 7283d2307dSDag-Erling Smørgrav ]) 7383d2307dSDag-Erling Smørgrav done 7483d2307dSDag-Erling Smørgrav done 7583d2307dSDag-Erling Smørgrav 7683d2307dSDag-Erling Smørgrav if test "x$curl_cv_socklen_t_equiv" = x; then 7783d2307dSDag-Erling Smørgrav AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) 7883d2307dSDag-Erling Smørgrav fi 7983d2307dSDag-Erling Smørgrav ]) 8083d2307dSDag-Erling Smørgrav AC_MSG_RESULT($curl_cv_socklen_t_equiv) 8183d2307dSDag-Erling Smørgrav AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv, 8283d2307dSDag-Erling Smørgrav [type to use in place of socklen_t if not defined])], 8383d2307dSDag-Erling Smørgrav [#include <sys/types.h> 8483d2307dSDag-Erling Smørgrav#include <sys/socket.h>]) 8583d2307dSDag-Erling Smørgrav]) 8683d2307dSDag-Erling Smørgrav 87