aclocal.m4 revision 226046
191094Sdesdnl $Id: aclocal.m4,v 1.8 2011/05/20 01:45:25 djm Exp $ 292289Sdesdnl 391094Sdesdnl OpenSSH-specific autoconf macros 491094Sdesdnl 591094Sdes 699158Sdesdnl OSSH_CHECK_CFLAG_COMPILE(check_flag[, define_flag]) 799158Sdesdnl Check that $CC accepts a flag 'check_flag'. If it is supported append 899158Sdesdnl 'define_flag' to $CFLAGS. If 'define_flag' is not specified, then append 991094Sdesdnl 'check_flag'. 1091094SdesAC_DEFUN([OSSH_CHECK_CFLAG_COMPILE], [{ 1191094Sdes AC_MSG_CHECKING([if $CC supports $1]) 1291094Sdes saved_CFLAGS="$CFLAGS" 1391094Sdes CFLAGS="$CFLAGS $1" 1491094Sdes _define_flag="$2" 1591094Sdes test "x$_define_flag" = "x" && _define_flag="$1" 1691094Sdes AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])], 1791094Sdes [ AC_MSG_RESULT([yes]) 1891094Sdes CFLAGS="$saved_CFLAGS $_define_flag"], 1991094Sdes [ AC_MSG_RESULT([no]) 2091094Sdes CFLAGS="$saved_CFLAGS" ] 2191094Sdes ) 2291094Sdes}]) 2391094Sdes 2491094Sdes 2591094Sdesdnl OSSH_CHECK_HEADER_FOR_FIELD(field, header, symbol) 2691094Sdesdnl Does AC_EGREP_HEADER on 'header' for the string 'field' 2791094Sdesdnl If found, set 'symbol' to be defined. Cache the result. 2891094Sdesdnl TODO: This is not foolproof, better to compile and read from there 2991094SdesAC_DEFUN(OSSH_CHECK_HEADER_FOR_FIELD, [ 3091094Sdes# look for field '$1' in header '$2' 3191094Sdes dnl This strips characters illegal to m4 from the header filename 3291094Sdes ossh_safe=`echo "$2" | sed 'y%./+-%__p_%'` 3391094Sdes dnl 3499158Sdes ossh_varname="ossh_cv_$ossh_safe""_has_"$1 3591094Sdes AC_MSG_CHECKING(for $1 field in $2) 3691094Sdes AC_CACHE_VAL($ossh_varname, [ 3791094Sdes AC_EGREP_HEADER($1, $2, [ dnl 3891094Sdes eval "$ossh_varname=yes" dnl 3991094Sdes ], [ dnl 4091094Sdes eval "$ossh_varname=no" dnl 4191094Sdes ]) dnl 4291094Sdes ]) 4391094Sdes ossh_result=`eval 'echo $'"$ossh_varname"` 4491094Sdes if test -n "`echo $ossh_varname`"; then 4591094Sdes AC_MSG_RESULT($ossh_result) 4691094Sdes if test "x$ossh_result" = "xyes"; then 4791094Sdes AC_DEFINE($3, 1, [Define if you have $1 in $2]) 4891094Sdes fi 4991094Sdes else 5091094Sdes AC_MSG_RESULT(no) 5191094Sdes fi 5291094Sdes]) 5391094Sdes 5491094Sdesdnl Check for socklen_t: historically on BSD it is an int, and in 5591094Sdesdnl POSIX 1g it is a type of its own, but some platforms use different 5691094Sdesdnl types for the argument to getsockopt, getpeername, etc. So we 5791094Sdesdnl have to test to find something that will work. 5891094SdesAC_DEFUN([TYPE_SOCKLEN_T], 5991094Sdes[ 6091094Sdes AC_CHECK_TYPE([socklen_t], ,[ 6191094Sdes AC_MSG_CHECKING([for socklen_t equivalent]) 6291094Sdes AC_CACHE_VAL([curl_cv_socklen_t_equiv], 6391094Sdes [ 6491094Sdes # Systems have either "struct sockaddr *" or 6591094Sdes # "void *" as the second argument to getpeername 6691094Sdes curl_cv_socklen_t_equiv= 6791094Sdes for arg2 in "struct sockaddr" void; do 6891094Sdes for t in int size_t unsigned long "unsigned long"; do 6993982Sdes AC_TRY_COMPILE([ 7099158Sdes #include <sys/types.h> 7191094Sdes #include <sys/socket.h> 7291094Sdes 7391094Sdes int getpeername (int, $arg2 *, $t *); 7491100Sdes ],[ 7591094Sdes $t len; 7691094Sdes getpeername(0,0,&len); 7791100Sdes ],[ 7891100Sdes curl_cv_socklen_t_equiv="$t" 7991100Sdes break 8091100Sdes ]) 8191100Sdes done 8291100Sdes done 8391100Sdes 8491100Sdes if test "x$curl_cv_socklen_t_equiv" = x; then 8591100Sdes AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) 8691100Sdes fi 8791100Sdes ]) 8891100Sdes AC_MSG_RESULT($curl_cv_socklen_t_equiv) 8991100Sdes AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv, 9091100Sdes [type to use in place of socklen_t if not defined])], 9191100Sdes [#include <sys/types.h> 9291100Sdes#include <sys/socket.h>]) 9391100Sdes]) 9491100Sdes 9591100Sdes