1dnl $Id: aclocal.m4,v 1.9 2013/06/02 21:31:27 tim Exp $ 2dnl 3dnl OpenSSH-specific autoconf macros 4dnl 5 6dnl OSSH_CHECK_CFLAG_COMPILE(check_flag[, define_flag]) 7dnl Check that $CC accepts a flag 'check_flag'. If it is supported append 8dnl 'define_flag' to $CFLAGS. If 'define_flag' is not specified, then append 9dnl 'check_flag'. 10AC_DEFUN([OSSH_CHECK_CFLAG_COMPILE], [{ 11 AC_MSG_CHECKING([if $CC supports $1]) 12 saved_CFLAGS="$CFLAGS" 13 CFLAGS="$CFLAGS $1" 14 _define_flag="$2" 15 test "x$_define_flag" = "x" && _define_flag="$1" 16 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])], 17 [ 18if `grep -i "unrecognized option" conftest.err >/dev/null` 19then 20 AC_MSG_RESULT([no]) 21 CFLAGS="$saved_CFLAGS" 22else 23 AC_MSG_RESULT([yes]) 24 CFLAGS="$saved_CFLAGS $_define_flag" 25fi], 26 [ AC_MSG_RESULT([no]) 27 CFLAGS="$saved_CFLAGS" ] 28 ) 29}]) 30 31 32dnl OSSH_CHECK_HEADER_FOR_FIELD(field, header, symbol) 33dnl Does AC_EGREP_HEADER on 'header' for the string 'field' 34dnl If found, set 'symbol' to be defined. Cache the result. 35dnl TODO: This is not foolproof, better to compile and read from there 36AC_DEFUN(OSSH_CHECK_HEADER_FOR_FIELD, [ 37# look for field '$1' in header '$2' 38 dnl This strips characters illegal to m4 from the header filename 39 ossh_safe=`echo "$2" | sed 'y%./+-%__p_%'` 40 dnl 41 ossh_varname="ossh_cv_$ossh_safe""_has_"$1 42 AC_MSG_CHECKING(for $1 field in $2) 43 AC_CACHE_VAL($ossh_varname, [ 44 AC_EGREP_HEADER($1, $2, [ dnl 45 eval "$ossh_varname=yes" dnl 46 ], [ dnl 47 eval "$ossh_varname=no" dnl 48 ]) dnl 49 ]) 50 ossh_result=`eval 'echo $'"$ossh_varname"` 51 if test -n "`echo $ossh_varname`"; then 52 AC_MSG_RESULT($ossh_result) 53 if test "x$ossh_result" = "xyes"; then 54 AC_DEFINE($3, 1, [Define if you have $1 in $2]) 55 fi 56 else 57 AC_MSG_RESULT(no) 58 fi 59]) 60 61dnl Check for socklen_t: historically on BSD it is an int, and in 62dnl POSIX 1g it is a type of its own, but some platforms use different 63dnl types for the argument to getsockopt, getpeername, etc. So we 64dnl have to test to find something that will work. 65AC_DEFUN([TYPE_SOCKLEN_T], 66[ 67 AC_CHECK_TYPE([socklen_t], ,[ 68 AC_MSG_CHECKING([for socklen_t equivalent]) 69 AC_CACHE_VAL([curl_cv_socklen_t_equiv], 70 [ 71 # Systems have either "struct sockaddr *" or 72 # "void *" as the second argument to getpeername 73 curl_cv_socklen_t_equiv= 74 for arg2 in "struct sockaddr" void; do 75 for t in int size_t unsigned long "unsigned long"; do 76 AC_TRY_COMPILE([ 77 #include <sys/types.h> 78 #include <sys/socket.h> 79 80 int getpeername (int, $arg2 *, $t *); 81 ],[ 82 $t len; 83 getpeername(0,0,&len); 84 ],[ 85 curl_cv_socklen_t_equiv="$t" 86 break 87 ]) 88 done 89 done 90 91 if test "x$curl_cv_socklen_t_equiv" = x; then 92 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) 93 fi 94 ]) 95 AC_MSG_RESULT($curl_cv_socklen_t_equiv) 96 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv, 97 [type to use in place of socklen_t if not defined])], 98 [#include <sys/types.h> 99#include <sys/socket.h>]) 100]) 101 102