blob: b68a47080ffc0503504eb0278ea2b19a15e5b176 [file] [log] [blame]
Tim Rice7df8d392005-09-19 09:33:39 -07001dnl $Id: aclocal.m4,v 1.6 2005/09/19 16:33:39 tim Exp $
Damien Miller0437b332000-05-02 09:56:41 +10002dnl
3dnl OpenSSH-specific autoconf macros
4dnl
5
Damien Miller61e50f12000-05-08 20:49:37 +10006
7dnl OSSH_CHECK_HEADER_FOR_FIELD(field, header, symbol)
8dnl Does AC_EGREP_HEADER on 'header' for the string 'field'
9dnl If found, set 'symbol' to be defined. Cache the result.
10dnl TODO: This is not foolproof, better to compile and read from there
11AC_DEFUN(OSSH_CHECK_HEADER_FOR_FIELD, [
12# look for field '$1' in header '$2'
13 dnl This strips characters illegal to m4 from the header filename
14 ossh_safe=`echo "$2" | sed 'y%./+-%__p_%'`
15 dnl
16 ossh_varname="ossh_cv_$ossh_safe""_has_"$1
17 AC_MSG_CHECKING(for $1 field in $2)
18 AC_CACHE_VAL($ossh_varname, [
19 AC_EGREP_HEADER($1, $2, [ dnl
20 eval "$ossh_varname=yes" dnl
21 ], [ dnl
22 eval "$ossh_varname=no" dnl
23 ]) dnl
24 ])
Damien Miller8dd33fd2000-06-26 10:20:19 +100025 ossh_result=`eval 'echo $'"$ossh_varname"`
Damien Miller61e50f12000-05-08 20:49:37 +100026 if test -n "`echo $ossh_varname`"; then
27 AC_MSG_RESULT($ossh_result)
28 if test "x$ossh_result" = "xyes"; then
Tim Rice7df8d392005-09-19 09:33:39 -070029 AC_DEFINE($3, 1, [Define if you have $1 in $2])
Damien Miller61e50f12000-05-08 20:49:37 +100030 fi
31 else
32 AC_MSG_RESULT(no)
33 fi
34])
35
36dnl OSSH_PATH_ENTROPY_PROG(variablename, command):
Damien Miller0437b332000-05-02 09:56:41 +100037dnl Tidiness function, sets 'undef' if not found, and does the AC_SUBST
Damien Miller61e50f12000-05-08 20:49:37 +100038AC_DEFUN(OSSH_PATH_ENTROPY_PROG, [
39 AC_PATH_PROG($1, $2)
Damien Miller0437b332000-05-02 09:56:41 +100040 if test -z "[$]$1" ; then
41 $1="undef"
42 fi
Damien Miller61e50f12000-05-08 20:49:37 +100043 AC_SUBST($1)
Damien Miller0437b332000-05-02 09:56:41 +100044])
45
Tim Rice13aae5e2001-10-21 17:53:58 -070046dnl Check for socklen_t: historically on BSD it is an int, and in
47dnl POSIX 1g it is a type of its own, but some platforms use different
48dnl types for the argument to getsockopt, getpeername, etc. So we
49dnl have to test to find something that will work.
50AC_DEFUN([TYPE_SOCKLEN_T],
51[
52 AC_CHECK_TYPE([socklen_t], ,[
53 AC_MSG_CHECKING([for socklen_t equivalent])
54 AC_CACHE_VAL([curl_cv_socklen_t_equiv],
55 [
56 # Systems have either "struct sockaddr *" or
57 # "void *" as the second argument to getpeername
58 curl_cv_socklen_t_equiv=
59 for arg2 in "struct sockaddr" void; do
60 for t in int size_t unsigned long "unsigned long"; do
61 AC_TRY_COMPILE([
62 #include <sys/types.h>
63 #include <sys/socket.h>
64
65 int getpeername (int, $arg2 *, $t *);
66 ],[
67 $t len;
68 getpeername(0,0,&len);
69 ],[
70 curl_cv_socklen_t_equiv="$t"
71 break
72 ])
73 done
74 done
75
76 if test "x$curl_cv_socklen_t_equiv" = x; then
77 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
78 fi
79 ])
80 AC_MSG_RESULT($curl_cv_socklen_t_equiv)
81 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
82 [type to use in place of socklen_t if not defined])],
83 [#include <sys/types.h>
84#include <sys/socket.h>])
85])
86