1 dnl $Id: aclocal.m4,v 1.9 2013/06/02 21:31:27 tim Exp $
3 dnl OpenSSH-specific autoconf macros
6 dnl OSSH_CHECK_CFLAG_COMPILE(check_flag[, define_flag])
7 dnl Check that $CC accepts a flag 'check_flag'. If it is supported append
8 dnl 'define_flag' to $CFLAGS. If 'define_flag' is not specified, then append
10 AC_DEFUN([OSSH_CHECK_CFLAG_COMPILE], [{
11 AC_MSG_CHECKING([if $CC supports $1])
12 saved_CFLAGS="$CFLAGS"
15 test "x$_define_flag" = "x" && _define_flag="$1"
16 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
18 if `grep -i "unrecognized option" conftest.err >/dev/null`
21 CFLAGS="$saved_CFLAGS"
24 CFLAGS="$saved_CFLAGS $_define_flag"
27 CFLAGS="$saved_CFLAGS" ]
32 dnl OSSH_CHECK_HEADER_FOR_FIELD(field, header, symbol)
33 dnl Does AC_EGREP_HEADER on 'header' for the string 'field'
34 dnl If found, set 'symbol' to be defined. Cache the result.
35 dnl TODO: This is not foolproof, better to compile and read from there
36 AC_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_%'`
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
47 eval "$ossh_varname=no" dnl
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])
61 dnl Check for socklen_t: historically on BSD it is an int, and in
62 dnl POSIX 1g it is a type of its own, but some platforms use different
63 dnl types for the argument to getsockopt, getpeername, etc. So we
64 dnl have to test to find something that will work.
65 AC_DEFUN([TYPE_SOCKLEN_T],
67 AC_CHECK_TYPE([socklen_t], ,[
68 AC_MSG_CHECKING([for socklen_t equivalent])
69 AC_CACHE_VAL([curl_cv_socklen_t_equiv],
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
77 #include <sys/types.h>
78 #include <sys/socket.h>
80 int getpeername (int, $arg2 *, $t *);
83 getpeername(0,0,&len);
85 curl_cv_socklen_t_equiv="$t"
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])
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>])