1
#***************************************************************************
3
# Project ___| | | | _ \| |
5
# | (__| |_| | _ <| |___
6
# \___|\___/|_| \_\_____|
8
# Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
10
# This software is licensed as described in the file COPYING, which
11
# you should have received as part of this distribution. The terms
12
# are also available at http://curl.haxx.se/docs/copyright.html.
14
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15
# copies of the Software, and permit persons to whom the Software is
16
# furnished to do so, under the terms of the COPYING file.
18
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
# KIND, either express or implied.
21
# $Id: acinclude.m4,v 1.86 2006-04-19 11:11:10 bagder Exp $
22
###########################################################################
24
dnl CURL_CHECK_HEADER_WINDOWS
25
dnl -------------------------------------------------
26
dnl Check for compilable and valid windows.h header
28
AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
29
AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
33
#ifndef WIN32_LEAN_AND_MEAN
34
#define WIN32_LEAN_AND_MEAN
41
ac_cv_header_windows_h="yes"
43
ac_cv_header_windows_h="no"
46
if test "x$ac_cv_header_windows_h" = "xyes"; then
47
AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
48
[Define to 1 if you have the windows.h header file.])
49
AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
50
[Define to avoid automatic inclusion of winsock.h])
55
dnl CURL_CHECK_HEADER_WINSOCK
56
dnl -------------------------------------------------
57
dnl Check for compilable and valid winsock.h header
59
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
60
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
61
AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
65
#ifndef WIN32_LEAN_AND_MEAN
66
#define WIN32_LEAN_AND_MEAN
71
int dummy=WSACleanup();
74
ac_cv_header_winsock_h="yes"
76
ac_cv_header_winsock_h="no"
79
if test "x$ac_cv_header_winsock_h" = "xyes"; then
80
AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
81
[Define to 1 if you have the winsock.h header file.])
86
dnl CURL_CHECK_HEADER_WINSOCK2
87
dnl -------------------------------------------------
88
dnl Check for compilable and valid winsock2.h header
90
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
91
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
92
AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
96
#ifndef WIN32_LEAN_AND_MEAN
97
#define WIN32_LEAN_AND_MEAN
100
#include <winsock2.h>
102
int dummy=2*IPPROTO_ESP;
105
ac_cv_header_winsock2_h="yes"
107
ac_cv_header_winsock2_h="no"
110
if test "x$ac_cv_header_winsock2_h" = "xyes"; then
111
AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
112
[Define to 1 if you have the winsock2.h header file.])
117
dnl CURL_CHECK_HEADER_WS2TCPIP
118
dnl -------------------------------------------------
119
dnl Check for compilable and valid ws2tcpip.h header
121
AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
122
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
123
AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
127
#ifndef WIN32_LEAN_AND_MEAN
128
#define WIN32_LEAN_AND_MEAN
131
#include <winsock2.h>
132
#include <ws2tcpip.h>
134
int dummy=2*IP_PKTINFO;
137
ac_cv_header_ws2tcpip_h="yes"
139
ac_cv_header_ws2tcpip_h="no"
142
if test "x$ac_cv_header_ws2tcpip_h" = "xyes"; then
143
AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
144
[Define to 1 if you have the ws2tcpip.h header file.])
149
dnl CURL_CHECK_TYPE_SOCKLEN_T
150
dnl -------------------------------------------------
151
dnl Check for existing socklen_t type, and provide
152
dnl an equivalent type if socklen_t not available
154
AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
155
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
156
AC_CHECK_TYPE([socklen_t], ,[
157
AC_CACHE_CHECK([for socklen_t equivalent],
158
[curl_cv_socklen_t_equiv], [
159
curl_cv_socklen_t_equiv="unknown"
160
for arg2 in "struct sockaddr" void; do
161
for t in int size_t unsigned long "unsigned long"; do
165
#ifdef HAVE_WINDOWS_H
166
#ifndef WIN32_LEAN_AND_MEAN
167
#define WIN32_LEAN_AND_MEAN
170
#ifdef HAVE_WINSOCK2_H
171
#include <winsock2.h>
173
#ifdef HAVE_WINSOCK_H
178
#ifdef HAVE_SYS_TYPES_H
179
#include <sys/types.h>
181
#ifdef HAVE_SYS_SOCKET_H
182
#include <sys/socket.h>
185
int getpeername (int, $arg2 *, $t *);
188
getpeername(0,0,&len);
191
curl_cv_socklen_t_equiv="$t"
197
if test "$curl_cv_socklen_t_equiv" = "unknown"; then
198
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
200
AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
201
[type to use in place of socklen_t if not defined])
205
#ifdef HAVE_WINDOWS_H
206
#ifndef WIN32_LEAN_AND_MEAN
207
#define WIN32_LEAN_AND_MEAN
210
#ifdef HAVE_WINSOCK2_H
211
#include <winsock2.h>
212
#ifdef HAVE_WS2TCPIP_H
213
#include <ws2tcpip.h>
217
#ifdef HAVE_SYS_TYPES_H
218
#include <sys/types.h>
220
#ifdef HAVE_SYS_SOCKET_H
221
#include <sys/socket.h>
228
dnl CURL_CHECK_FUNC_GETNAMEINFO
229
dnl -------------------------------------------------
230
dnl Test if the getnameinfo function is available,
231
dnl and check the types of five of its arguments.
232
dnl If the function succeeds HAVE_GETNAMEINFO will be
233
dnl defined, defining the types of the arguments in
234
dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
235
dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7.
236
dnl This function is experimental and its results shall
237
dnl not be trusted while this notice is in place ------
239
AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
240
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
241
AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
242
AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
244
AC_MSG_CHECKING([for getnameinfo])
246
AC_LANG_FUNC_LINK_TRY([getnameinfo])
249
curl_cv_getnameinfo="yes"
252
curl_cv_getnameinfo="no"
255
if test "$curl_cv_getnameinfo" != "yes"; then
256
AC_MSG_CHECKING([deeper for getnameinfo])
262
curl_cv_getnameinfo="yes"
264
AC_MSG_RESULT([but still no])
265
curl_cv_getnameinfo="no"
269
if test "$curl_cv_getnameinfo" != "yes"; then
270
AC_MSG_CHECKING([deeper and deeper for getnameinfo])
273
#ifdef HAVE_WINDOWS_H
274
#ifndef WIN32_LEAN_AND_MEAN
275
#define WIN32_LEAN_AND_MEAN
278
#ifdef HAVE_WINSOCK2_H
279
#include <winsock2.h>
280
#ifdef HAVE_WS2TCPIP_H
281
#include <ws2tcpip.h>
285
#ifdef HAVE_SYS_TYPES_H
286
#include <sys/types.h>
288
#ifdef HAVE_SYS_SOCKET_H
289
#include <sys/socket.h>
296
getnameinfo(0, 0, 0, 0, 0, 0, 0);
299
curl_cv_getnameinfo="yes"
301
AC_MSG_RESULT([but still no])
302
curl_cv_getnameinfo="no"
306
if test "$curl_cv_getnameinfo" = "yes"; then
307
AC_CACHE_CHECK([types of arguments for getnameinfo],
308
[curl_cv_func_getnameinfo_args], [
309
curl_cv_func_getnameinfo_args="unknown"
310
for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
311
for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
312
for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
313
for gni_arg7 in 'int' 'unsigned int'; do
317
#ifdef HAVE_WINDOWS_H
318
#ifndef WIN32_LEAN_AND_MEAN
319
#define WIN32_LEAN_AND_MEAN
321
#if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
323
#define _WIN32_WINNT 0x0501
326
#ifdef HAVE_WINSOCK2_H
327
#include <winsock2.h>
328
#ifdef HAVE_WS2TCPIP_H
329
#include <ws2tcpip.h>
332
#define GNICALLCONV WSAAPI
334
#ifdef HAVE_SYS_TYPES_H
335
#include <sys/types.h>
337
#ifdef HAVE_SYS_SOCKET_H
338
#include <sys/socket.h>
345
extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
351
$gni_arg46 hostlen=0;
352
$gni_arg46 servlen=0;
354
int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
357
curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
365
if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
366
AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
367
AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
369
gni_prev_IFS=$IFS; IFS=','
370
set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
373
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $[1],
374
[Define to the type of arg 1 for getnameinfo.])
375
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
376
[Define to the type of arg 2 for getnameinfo.])
377
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
378
[Define to the type of args 4 and 6 for getnameinfo.])
379
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
380
[Define to the type of arg 7 for getnameinfo.])
381
AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
382
[Define to 1 if you have the getnameinfo function.])
383
ac_cv_func_getnameinfo="yes"
389
dnl CURL_CHECK_NONBLOCKING_SOCKET
390
dnl -------------------------------------------------
1
391
dnl Check for how to set a socket to non-blocking state. There seems to exist
2
392
dnl four known different ways, with the one used almost everywhere being POSIX
3
393
dnl and XPG3, while the other different ways for different systems (old BSD,