blob: f959e3d43f6479b897031b50c9bd3d6cd4c1eb97 [file] [log] [blame]
9487f7f2011-08-03 07:05:30 -07001#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
Dirk Vogta7d7f962016-12-01 10:50:48 +01008# Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
9487f7f2011-08-03 07:05:30 -07009#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
Dirk Vogta7d7f962016-12-01 10:50:48 +010012# are also available at https://curl.haxx.se/docs/copyright.html.
9487f7f2011-08-03 07:05:30 -070013#
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.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21#***************************************************************************
22
9487f7f2011-08-03 07:05:30 -070023dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
24dnl -------------------------------------------------
25dnl Use the C preprocessor to find out if the given object-style symbol
26dnl is defined and get its expansion. This macro will not use default
27dnl includes even if no INCLUDES argument is given. This macro will run
28dnl silently when invoked with three arguments. If the expansion would
29dnl result in a set of double-quoted strings the returned expansion will
30dnl actually be a single double-quoted string concatenating all them.
31
32AC_DEFUN([CURL_CHECK_DEF], [
Dirk Vogta7d7f962016-12-01 10:50:48 +010033 AC_REQUIRE([CURL_CPP_P])dnl
34 OLDCPPFLAGS=$CPPFLAGS
35 # CPPPFLAG comes from CURL_CPP_P
36 CPPFLAGS="$CPPFLAGS $CPPPFLAG"
9487f7f2011-08-03 07:05:30 -070037 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
38 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
39 if test -z "$SED"; then
40 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
41 fi
42 if test -z "$GREP"; then
43 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
44 fi
45 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
46 tmp_exp=""
47 AC_PREPROC_IFELSE([
48 AC_LANG_SOURCE(
49ifelse($2,,,[$2])[[
50#ifdef $1
51CURL_DEF_TOKEN $1
52#endif
53 ]])
54 ],[
55 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
56 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
Dirk Vogta7d7f962016-12-01 10:50:48 +010057 "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
9487f7f2011-08-03 07:05:30 -070058 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
59 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
60 tmp_exp=""
61 fi
62 ])
63 if test -z "$tmp_exp"; then
64 AS_VAR_SET(ac_HaveDef, no)
65 ifelse($3,,[AC_MSG_RESULT([no])])
66 else
67 AS_VAR_SET(ac_HaveDef, yes)
68 AS_VAR_SET(ac_Def, $tmp_exp)
69 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
70 fi
71 AS_VAR_POPDEF([ac_Def])dnl
72 AS_VAR_POPDEF([ac_HaveDef])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +010073 CPPFLAGS=$OLDCPPFLAGS
9487f7f2011-08-03 07:05:30 -070074])
75
76
77dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
78dnl -------------------------------------------------
79dnl Use the C compiler to find out only if the given symbol is defined
80dnl or not, this can not find out its expansion. This macro will not use
81dnl default includes even if no INCLUDES argument is given. This macro
82dnl will run silently when invoked with three arguments.
83
84AC_DEFUN([CURL_CHECK_DEF_CC], [
85 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
86 ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
87 AC_COMPILE_IFELSE([
88 AC_LANG_SOURCE(
89ifelse($2,,,[$2])[[
90int main (void)
91{
92#ifdef $1
93 return 0;
94#else
95 force compilation error
96#endif
97}
98 ]])
99 ],[
100 tst_symbol_defined="yes"
101 ],[
102 tst_symbol_defined="no"
103 ])
104 if test "$tst_symbol_defined" = "yes"; then
105 AS_VAR_SET(ac_HaveDef, yes)
106 ifelse($3,,[AC_MSG_RESULT([yes])])
107 else
108 AS_VAR_SET(ac_HaveDef, no)
109 ifelse($3,,[AC_MSG_RESULT([no])])
110 fi
111 AS_VAR_POPDEF([ac_HaveDef])dnl
112])
113
114
115dnl CURL_CHECK_LIB_XNET
116dnl -------------------------------------------------
117dnl Verify if X/Open network library is required.
118
119AC_DEFUN([CURL_CHECK_LIB_XNET], [
120 AC_MSG_CHECKING([if X/Open network library is required])
121 tst_lib_xnet_required="no"
122 AC_COMPILE_IFELSE([
123 AC_LANG_SOURCE([[
124int main (void)
125{
126#if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
127 return 0;
128#elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
129 return 0;
130#else
131 force compilation error
132#endif
133}
134 ]])
135 ],[
136 tst_lib_xnet_required="yes"
Dirk Vogta7d7f962016-12-01 10:50:48 +0100137 LIBS="-lxnet $LIBS"
9487f7f2011-08-03 07:05:30 -0700138 ])
139 AC_MSG_RESULT([$tst_lib_xnet_required])
140])
141
142
143dnl CURL_CHECK_AIX_ALL_SOURCE
144dnl -------------------------------------------------
145dnl Provides a replacement of traditional AC_AIX with
146dnl an uniform behaviour across all autoconf versions,
147dnl and with our own placement rules.
148
149AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
150 AH_VERBATIM([_ALL_SOURCE],
151 [/* Define to 1 if OS is AIX. */
152#ifndef _ALL_SOURCE
153# undef _ALL_SOURCE
154#endif])
155 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
156 AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100157 AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
9487f7f2011-08-03 07:05:30 -0700158 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
159 AC_EGREP_CPP([yes_this_is_aix],[
160#ifdef _AIX
161 yes_this_is_aix
162#endif
163 ],[
164 AC_MSG_RESULT([yes])
165 AC_DEFINE(_ALL_SOURCE)
166 ],[
167 AC_MSG_RESULT([no])
168 ])
169])
170
171
172dnl CURL_CHECK_HEADER_WINDOWS
173dnl -------------------------------------------------
174dnl Check for compilable and valid windows.h header
175
176AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
Dirk Vogta7d7f962016-12-01 10:50:48 +0100177 AC_CACHE_CHECK([for windows.h], [curl_cv_header_windows_h], [
9487f7f2011-08-03 07:05:30 -0700178 AC_COMPILE_IFELSE([
179 AC_LANG_PROGRAM([[
180#undef inline
181#ifndef WIN32_LEAN_AND_MEAN
182#define WIN32_LEAN_AND_MEAN
183#endif
184#include <windows.h>
185 ]],[[
186#if defined(__CYGWIN__) || defined(__CEGCC__)
187 HAVE_WINDOWS_H shall not be defined.
188#else
189 int dummy=2*WINVER;
190#endif
191 ]])
192 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100193 curl_cv_header_windows_h="yes"
9487f7f2011-08-03 07:05:30 -0700194 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100195 curl_cv_header_windows_h="no"
9487f7f2011-08-03 07:05:30 -0700196 ])
197 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100198 case "$curl_cv_header_windows_h" in
9487f7f2011-08-03 07:05:30 -0700199 yes)
200 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
201 [Define to 1 if you have the windows.h header file.])
202 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
203 [Define to avoid automatic inclusion of winsock.h])
204 ;;
205 esac
206])
207
208
209dnl CURL_CHECK_NATIVE_WINDOWS
210dnl -------------------------------------------------
211dnl Check if building a native Windows target
212
213AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
214 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100215 AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
216 if test "$curl_cv_header_windows_h" = "no"; then
217 curl_cv_native_windows="no"
9487f7f2011-08-03 07:05:30 -0700218 else
219 AC_COMPILE_IFELSE([
220 AC_LANG_PROGRAM([[
221 ]],[[
222#if defined(__MINGW32__) || defined(__MINGW32CE__) || \
223 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
224 int dummy=1;
225#else
226 Not a native Windows build target.
227#endif
228 ]])
229 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100230 curl_cv_native_windows="yes"
9487f7f2011-08-03 07:05:30 -0700231 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100232 curl_cv_native_windows="no"
9487f7f2011-08-03 07:05:30 -0700233 ])
234 fi
235 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100236 AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
9487f7f2011-08-03 07:05:30 -0700237])
238
239
240dnl CURL_CHECK_HEADER_WINSOCK
241dnl -------------------------------------------------
242dnl Check for compilable and valid winsock.h header
243
244AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
245 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100246 AC_CACHE_CHECK([for winsock.h], [curl_cv_header_winsock_h], [
9487f7f2011-08-03 07:05:30 -0700247 AC_COMPILE_IFELSE([
248 AC_LANG_PROGRAM([[
249#undef inline
250#ifndef WIN32_LEAN_AND_MEAN
251#define WIN32_LEAN_AND_MEAN
252#endif
253#include <windows.h>
254#include <winsock.h>
255 ]],[[
256#if defined(__CYGWIN__) || defined(__CEGCC__)
257 HAVE_WINSOCK_H shall not be defined.
258#else
259 int dummy=WSACleanup();
260#endif
261 ]])
262 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100263 curl_cv_header_winsock_h="yes"
9487f7f2011-08-03 07:05:30 -0700264 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100265 curl_cv_header_winsock_h="no"
9487f7f2011-08-03 07:05:30 -0700266 ])
267 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100268 case "$curl_cv_header_winsock_h" in
9487f7f2011-08-03 07:05:30 -0700269 yes)
270 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
271 [Define to 1 if you have the winsock.h header file.])
272 ;;
273 esac
274])
275
276
277dnl CURL_CHECK_HEADER_WINSOCK2
278dnl -------------------------------------------------
279dnl Check for compilable and valid winsock2.h header
280
281AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
282 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100283 AC_CACHE_CHECK([for winsock2.h], [curl_cv_header_winsock2_h], [
9487f7f2011-08-03 07:05:30 -0700284 AC_COMPILE_IFELSE([
285 AC_LANG_PROGRAM([[
286#undef inline
287#ifndef WIN32_LEAN_AND_MEAN
288#define WIN32_LEAN_AND_MEAN
289#endif
290#include <windows.h>
291#include <winsock2.h>
292 ]],[[
293#if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
294 HAVE_WINSOCK2_H shall not be defined.
295#else
296 int dummy=2*IPPROTO_ESP;
297#endif
298 ]])
299 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100300 curl_cv_header_winsock2_h="yes"
9487f7f2011-08-03 07:05:30 -0700301 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100302 curl_cv_header_winsock2_h="no"
9487f7f2011-08-03 07:05:30 -0700303 ])
304 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100305 case "$curl_cv_header_winsock2_h" in
9487f7f2011-08-03 07:05:30 -0700306 yes)
307 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
308 [Define to 1 if you have the winsock2.h header file.])
309 ;;
310 esac
311])
312
313
314dnl CURL_CHECK_HEADER_WS2TCPIP
315dnl -------------------------------------------------
316dnl Check for compilable and valid ws2tcpip.h header
317
318AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
319 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100320 AC_CACHE_CHECK([for ws2tcpip.h], [curl_cv_header_ws2tcpip_h], [
9487f7f2011-08-03 07:05:30 -0700321 AC_COMPILE_IFELSE([
322 AC_LANG_PROGRAM([[
323#undef inline
324#ifndef WIN32_LEAN_AND_MEAN
325#define WIN32_LEAN_AND_MEAN
326#endif
327#include <windows.h>
328#include <winsock2.h>
329#include <ws2tcpip.h>
330 ]],[[
331#if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
332 HAVE_WS2TCPIP_H shall not be defined.
333#else
334 int dummy=2*IP_PKTINFO;
335#endif
336 ]])
337 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100338 curl_cv_header_ws2tcpip_h="yes"
9487f7f2011-08-03 07:05:30 -0700339 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100340 curl_cv_header_ws2tcpip_h="no"
9487f7f2011-08-03 07:05:30 -0700341 ])
342 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100343 case "$curl_cv_header_ws2tcpip_h" in
9487f7f2011-08-03 07:05:30 -0700344 yes)
345 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
346 [Define to 1 if you have the ws2tcpip.h header file.])
347 ;;
348 esac
349])
350
351
352dnl CURL_CHECK_HEADER_WINLDAP
353dnl -------------------------------------------------
354dnl Check for compilable and valid winldap.h header
355
356AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
357 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100358 AC_CACHE_CHECK([for winldap.h], [curl_cv_header_winldap_h], [
9487f7f2011-08-03 07:05:30 -0700359 AC_COMPILE_IFELSE([
360 AC_LANG_PROGRAM([[
361#undef inline
362#ifdef HAVE_WINDOWS_H
363#ifndef WIN32_LEAN_AND_MEAN
364#define WIN32_LEAN_AND_MEAN
365#endif
366#include <windows.h>
367#endif
368#include <winldap.h>
369 ]],[[
370#if defined(__CYGWIN__) || defined(__CEGCC__)
371 HAVE_WINLDAP_H shall not be defined.
372#else
373 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
374 ULONG res = ldap_unbind(ldp);
375#endif
376 ]])
377 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100378 curl_cv_header_winldap_h="yes"
9487f7f2011-08-03 07:05:30 -0700379 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100380 curl_cv_header_winldap_h="no"
9487f7f2011-08-03 07:05:30 -0700381 ])
382 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100383 case "$curl_cv_header_winldap_h" in
9487f7f2011-08-03 07:05:30 -0700384 yes)
385 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
386 [Define to 1 if you have the winldap.h header file.])
387 ;;
388 esac
389])
390
391
392dnl CURL_CHECK_HEADER_WINBER
393dnl -------------------------------------------------
394dnl Check for compilable and valid winber.h header
395
396AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
397 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100398 AC_CACHE_CHECK([for winber.h], [curl_cv_header_winber_h], [
9487f7f2011-08-03 07:05:30 -0700399 AC_COMPILE_IFELSE([
400 AC_LANG_PROGRAM([[
401#undef inline
402#ifdef HAVE_WINDOWS_H
403#ifndef WIN32_LEAN_AND_MEAN
404#define WIN32_LEAN_AND_MEAN
405#endif
406#include <windows.h>
407#endif
408#include <winldap.h>
409#include <winber.h>
410 ]],[[
411#if defined(__CYGWIN__) || defined(__CEGCC__)
412 HAVE_WINBER_H shall not be defined.
413#else
414 BERVAL *bvp = NULL;
415 BerElement *bep = ber_init(bvp);
416 ber_free(bep, 1);
417#endif
418 ]])
419 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100420 curl_cv_header_winber_h="yes"
9487f7f2011-08-03 07:05:30 -0700421 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100422 curl_cv_header_winber_h="no"
9487f7f2011-08-03 07:05:30 -0700423 ])
424 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100425 case "$curl_cv_header_winber_h" in
9487f7f2011-08-03 07:05:30 -0700426 yes)
427 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
428 [Define to 1 if you have the winber.h header file.])
429 ;;
430 esac
431])
432
433
434dnl CURL_CHECK_HEADER_LBER
435dnl -------------------------------------------------
436dnl Check for compilable and valid lber.h header,
437dnl and check if it is needed even with ldap.h
438
439AC_DEFUN([CURL_CHECK_HEADER_LBER], [
440 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100441 AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
9487f7f2011-08-03 07:05:30 -0700442 AC_COMPILE_IFELSE([
443 AC_LANG_PROGRAM([[
444#undef inline
445#ifdef HAVE_WINDOWS_H
446#ifndef WIN32_LEAN_AND_MEAN
447#define WIN32_LEAN_AND_MEAN
448#endif
449#include <windows.h>
450#else
451#ifdef HAVE_SYS_TYPES_H
452#include <sys/types.h>
453#endif
454#endif
455#ifndef NULL
456#define NULL (void *)0
457#endif
458#include <lber.h>
459 ]],[[
460 BerValue *bvp = NULL;
461 BerElement *bep = ber_init(bvp);
462 ber_free(bep, 1);
463 ]])
464 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100465 curl_cv_header_lber_h="yes"
9487f7f2011-08-03 07:05:30 -0700466 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100467 curl_cv_header_lber_h="no"
9487f7f2011-08-03 07:05:30 -0700468 ])
469 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100470 if test "$curl_cv_header_lber_h" = "yes"; then
9487f7f2011-08-03 07:05:30 -0700471 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
472 [Define to 1 if you have the lber.h header file.])
473 #
474 AC_COMPILE_IFELSE([
475 AC_LANG_PROGRAM([[
476#undef inline
477#ifdef HAVE_WINDOWS_H
478#ifndef WIN32_LEAN_AND_MEAN
479#define WIN32_LEAN_AND_MEAN
480#endif
481#include <windows.h>
482#else
483#ifdef HAVE_SYS_TYPES_H
484#include <sys/types.h>
485#endif
486#endif
487#ifndef NULL
488#define NULL (void *)0
489#endif
490#ifndef LDAP_DEPRECATED
491#define LDAP_DEPRECATED 1
492#endif
493#include <ldap.h>
494 ]],[[
495 BerValue *bvp = NULL;
496 BerElement *bep = ber_init(bvp);
497 ber_free(bep, 1);
498 ]])
499 ],[
500 curl_cv_need_header_lber_h="no"
501 ],[
502 curl_cv_need_header_lber_h="yes"
503 ])
504 #
505 case "$curl_cv_need_header_lber_h" in
506 yes)
507 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
508 [Define to 1 if you need the lber.h header file even with ldap.h])
509 ;;
510 esac
511 fi
512])
513
514
515dnl CURL_CHECK_HEADER_LDAP
516dnl -------------------------------------------------
517dnl Check for compilable and valid ldap.h header
518
519AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
520 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100521 AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
9487f7f2011-08-03 07:05:30 -0700522 AC_COMPILE_IFELSE([
523 AC_LANG_PROGRAM([[
524#undef inline
525#ifdef HAVE_WINDOWS_H
526#ifndef WIN32_LEAN_AND_MEAN
527#define WIN32_LEAN_AND_MEAN
528#endif
529#include <windows.h>
530#else
531#ifdef HAVE_SYS_TYPES_H
532#include <sys/types.h>
533#endif
534#endif
535#ifndef LDAP_DEPRECATED
536#define LDAP_DEPRECATED 1
537#endif
538#ifdef NEED_LBER_H
539#include <lber.h>
540#endif
541#include <ldap.h>
542 ]],[[
543 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
544 int res = ldap_unbind(ldp);
545 ]])
546 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100547 curl_cv_header_ldap_h="yes"
9487f7f2011-08-03 07:05:30 -0700548 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100549 curl_cv_header_ldap_h="no"
9487f7f2011-08-03 07:05:30 -0700550 ])
551 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100552 case "$curl_cv_header_ldap_h" in
9487f7f2011-08-03 07:05:30 -0700553 yes)
554 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
555 [Define to 1 if you have the ldap.h header file.])
556 ;;
557 esac
558])
559
560
561dnl CURL_CHECK_HEADER_LDAP_SSL
562dnl -------------------------------------------------
563dnl Check for compilable and valid ldap_ssl.h header
564
565AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
566 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100567 AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
9487f7f2011-08-03 07:05:30 -0700568 AC_COMPILE_IFELSE([
569 AC_LANG_PROGRAM([[
570#undef inline
571#ifdef HAVE_WINDOWS_H
572#ifndef WIN32_LEAN_AND_MEAN
573#define WIN32_LEAN_AND_MEAN
574#endif
575#include <windows.h>
576#else
577#ifdef HAVE_SYS_TYPES_H
578#include <sys/types.h>
579#endif
580#endif
581#ifndef LDAP_DEPRECATED
582#define LDAP_DEPRECATED 1
583#endif
584#ifdef NEED_LBER_H
585#include <lber.h>
586#endif
587#ifdef HAVE_LDAP_H
588#include <ldap.h>
589#endif
590#include <ldap_ssl.h>
591 ]],[[
592 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
593 ]])
594 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100595 curl_cv_header_ldap_ssl_h="yes"
9487f7f2011-08-03 07:05:30 -0700596 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100597 curl_cv_header_ldap_ssl_h="no"
9487f7f2011-08-03 07:05:30 -0700598 ])
599 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100600 case "$curl_cv_header_ldap_ssl_h" in
9487f7f2011-08-03 07:05:30 -0700601 yes)
602 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
603 [Define to 1 if you have the ldap_ssl.h header file.])
604 ;;
605 esac
606])
607
608
609dnl CURL_CHECK_HEADER_LDAPSSL
610dnl -------------------------------------------------
611dnl Check for compilable and valid ldapssl.h header
612
613AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
614 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
Dirk Vogta7d7f962016-12-01 10:50:48 +0100615 AC_CACHE_CHECK([for ldapssl.h], [curl_cv_header_ldapssl_h], [
9487f7f2011-08-03 07:05:30 -0700616 AC_COMPILE_IFELSE([
617 AC_LANG_PROGRAM([[
618#undef inline
619#ifdef HAVE_WINDOWS_H
620#ifndef WIN32_LEAN_AND_MEAN
621#define WIN32_LEAN_AND_MEAN
622#endif
623#include <windows.h>
624#else
625#ifdef HAVE_SYS_TYPES_H
626#include <sys/types.h>
627#endif
628#endif
629#ifndef NULL
630#define NULL (void *)0
631#endif
632#ifndef LDAP_DEPRECATED
633#define LDAP_DEPRECATED 1
634#endif
635#ifdef NEED_LBER_H
636#include <lber.h>
637#endif
638#ifdef HAVE_LDAP_H
639#include <ldap.h>
640#endif
641#include <ldapssl.h>
642 ]],[[
643 char *cert_label = NULL;
644 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
645 ]])
646 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100647 curl_cv_header_ldapssl_h="yes"
9487f7f2011-08-03 07:05:30 -0700648 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100649 curl_cv_header_ldapssl_h="no"
9487f7f2011-08-03 07:05:30 -0700650 ])
651 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100652 case "$curl_cv_header_ldapssl_h" in
9487f7f2011-08-03 07:05:30 -0700653 yes)
654 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
655 [Define to 1 if you have the ldapssl.h header file.])
656 ;;
657 esac
658])
659
660
661dnl CURL_CHECK_LIBS_WINLDAP
662dnl -------------------------------------------------
663dnl Check for libraries needed for WINLDAP support,
664dnl and prepended to LIBS any needed libraries.
665dnl This macro can take an optional parameter with a
666dnl white space separated list of libraries to check
667dnl before the WINLDAP default ones.
668
669AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
670 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
671 #
672 AC_MSG_CHECKING([for WINLDAP libraries])
673 #
674 u_libs=""
675 #
676 ifelse($1,,,[
677 for x_lib in $1; do
678 case "$x_lib" in
679 -l*)
680 l_lib="$x_lib"
681 ;;
682 *)
683 l_lib="-l$x_lib"
684 ;;
685 esac
686 if test -z "$u_libs"; then
687 u_libs="$l_lib"
688 else
689 u_libs="$u_libs $l_lib"
690 fi
691 done
692 ])
693 #
694 curl_cv_save_LIBS="$LIBS"
695 curl_cv_ldap_LIBS="unknown"
696 #
697 for x_nlibs in '' "$u_libs" \
698 '-lwldap32' ; do
699 if test "$curl_cv_ldap_LIBS" = "unknown"; then
700 if test -z "$x_nlibs"; then
701 LIBS="$curl_cv_save_LIBS"
702 else
703 LIBS="$x_nlibs $curl_cv_save_LIBS"
704 fi
705 AC_LINK_IFELSE([
706 AC_LANG_PROGRAM([[
707#undef inline
708#ifdef HAVE_WINDOWS_H
709#ifndef WIN32_LEAN_AND_MEAN
710#define WIN32_LEAN_AND_MEAN
711#endif
712#include <windows.h>
713#ifdef HAVE_WINLDAP_H
714#include <winldap.h>
715#endif
716#ifdef HAVE_WINBER_H
717#include <winber.h>
718#endif
719#endif
720 ]],[[
721 BERVAL *bvp = NULL;
722 BerElement *bep = ber_init(bvp);
723 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
724 ULONG res = ldap_unbind(ldp);
725 ber_free(bep, 1);
726 ]])
727 ],[
728 curl_cv_ldap_LIBS="$x_nlibs"
729 ])
730 fi
731 done
732 #
733 LIBS="$curl_cv_save_LIBS"
734 #
735 case X-"$curl_cv_ldap_LIBS" in
736 X-unknown)
737 AC_MSG_RESULT([cannot find WINLDAP libraries])
738 ;;
739 X-)
740 AC_MSG_RESULT([no additional lib required])
741 ;;
742 *)
743 if test -z "$curl_cv_save_LIBS"; then
744 LIBS="$curl_cv_ldap_LIBS"
745 else
746 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
747 fi
748 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
749 ;;
750 esac
751 #
752])
753
754
755dnl CURL_CHECK_LIBS_LDAP
756dnl -------------------------------------------------
757dnl Check for libraries needed for LDAP support,
758dnl and prepended to LIBS any needed libraries.
759dnl This macro can take an optional parameter with a
760dnl white space separated list of libraries to check
761dnl before the default ones.
762
763AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
764 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
765 #
766 AC_MSG_CHECKING([for LDAP libraries])
767 #
768 u_libs=""
769 #
770 ifelse($1,,,[
771 for x_lib in $1; do
772 case "$x_lib" in
773 -l*)
774 l_lib="$x_lib"
775 ;;
776 *)
777 l_lib="-l$x_lib"
778 ;;
779 esac
780 if test -z "$u_libs"; then
781 u_libs="$l_lib"
782 else
783 u_libs="$u_libs $l_lib"
784 fi
785 done
786 ])
787 #
788 curl_cv_save_LIBS="$LIBS"
789 curl_cv_ldap_LIBS="unknown"
790 #
791 for x_nlibs in '' "$u_libs" \
792 '-lldap' \
793 '-llber -lldap' \
794 '-lldap -llber' \
795 '-lldapssl -lldapx -lldapsdk' \
796 '-lldapsdk -lldapx -lldapssl' ; do
797 if test "$curl_cv_ldap_LIBS" = "unknown"; then
798 if test -z "$x_nlibs"; then
799 LIBS="$curl_cv_save_LIBS"
800 else
801 LIBS="$x_nlibs $curl_cv_save_LIBS"
802 fi
803 AC_LINK_IFELSE([
804 AC_LANG_PROGRAM([[
805#undef inline
806#ifdef HAVE_WINDOWS_H
807#ifndef WIN32_LEAN_AND_MEAN
808#define WIN32_LEAN_AND_MEAN
809#endif
810#include <windows.h>
811#else
812#ifdef HAVE_SYS_TYPES_H
813#include <sys/types.h>
814#endif
815#endif
816#ifndef NULL
817#define NULL (void *)0
818#endif
819#ifndef LDAP_DEPRECATED
820#define LDAP_DEPRECATED 1
821#endif
822#ifdef NEED_LBER_H
823#include <lber.h>
824#endif
825#ifdef HAVE_LDAP_H
826#include <ldap.h>
827#endif
828 ]],[[
829 BerValue *bvp = NULL;
830 BerElement *bep = ber_init(bvp);
831 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
832 int res = ldap_unbind(ldp);
833 ber_free(bep, 1);
834 ]])
835 ],[
836 curl_cv_ldap_LIBS="$x_nlibs"
837 ])
838 fi
839 done
840 #
841 LIBS="$curl_cv_save_LIBS"
842 #
843 case X-"$curl_cv_ldap_LIBS" in
844 X-unknown)
845 AC_MSG_RESULT([cannot find LDAP libraries])
846 ;;
847 X-)
848 AC_MSG_RESULT([no additional lib required])
849 ;;
850 *)
851 if test -z "$curl_cv_save_LIBS"; then
852 LIBS="$curl_cv_ldap_LIBS"
853 else
854 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
855 fi
856 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
857 ;;
858 esac
859 #
860])
861
862
863dnl CURL_CHECK_HEADER_MALLOC
864dnl -------------------------------------------------
865dnl Check for compilable and valid malloc.h header,
866dnl and check if it is needed even with stdlib.h
867
868AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
Dirk Vogta7d7f962016-12-01 10:50:48 +0100869 AC_CACHE_CHECK([for malloc.h], [curl_cv_header_malloc_h], [
9487f7f2011-08-03 07:05:30 -0700870 AC_COMPILE_IFELSE([
871 AC_LANG_PROGRAM([[
872#include <malloc.h>
873 ]],[[
874 void *p = malloc(10);
875 void *q = calloc(10,10);
876 free(p);
877 free(q);
878 ]])
879 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100880 curl_cv_header_malloc_h="yes"
9487f7f2011-08-03 07:05:30 -0700881 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100882 curl_cv_header_malloc_h="no"
9487f7f2011-08-03 07:05:30 -0700883 ])
884 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100885 if test "$curl_cv_header_malloc_h" = "yes"; then
9487f7f2011-08-03 07:05:30 -0700886 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
887 [Define to 1 if you have the malloc.h header file.])
888 #
889 AC_COMPILE_IFELSE([
890 AC_LANG_PROGRAM([[
891#include <stdlib.h>
892 ]],[[
893 void *p = malloc(10);
894 void *q = calloc(10,10);
895 free(p);
896 free(q);
897 ]])
898 ],[
899 curl_cv_need_header_malloc_h="no"
900 ],[
901 curl_cv_need_header_malloc_h="yes"
902 ])
903 #
904 case "$curl_cv_need_header_malloc_h" in
905 yes)
906 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
907 [Define to 1 if you need the malloc.h header file even with stdlib.h])
908 ;;
909 esac
910 fi
911])
912
913
914dnl CURL_CHECK_HEADER_MEMORY
915dnl -------------------------------------------------
916dnl Check for compilable and valid memory.h header,
917dnl and check if it is needed even with stdlib.h for
918dnl memory related functions.
919
920AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
Dirk Vogta7d7f962016-12-01 10:50:48 +0100921 AC_CACHE_CHECK([for memory.h], [curl_cv_header_memory_h], [
9487f7f2011-08-03 07:05:30 -0700922 AC_COMPILE_IFELSE([
923 AC_LANG_PROGRAM([[
924#include <memory.h>
925 ]],[[
926 void *p = malloc(10);
927 void *q = calloc(10,10);
928 free(p);
929 free(q);
930 ]])
931 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100932 curl_cv_header_memory_h="yes"
9487f7f2011-08-03 07:05:30 -0700933 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +0100934 curl_cv_header_memory_h="no"
9487f7f2011-08-03 07:05:30 -0700935 ])
936 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +0100937 if test "$curl_cv_header_memory_h" = "yes"; then
9487f7f2011-08-03 07:05:30 -0700938 AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
939 [Define to 1 if you have the memory.h header file.])
940 #
941 AC_COMPILE_IFELSE([
942 AC_LANG_PROGRAM([[
943#include <stdlib.h>
944 ]],[[
945 void *p = malloc(10);
946 void *q = calloc(10,10);
947 free(p);
948 free(q);
949 ]])
950 ],[
951 curl_cv_need_header_memory_h="no"
952 ],[
953 curl_cv_need_header_memory_h="yes"
954 ])
955 #
956 case "$curl_cv_need_header_memory_h" in
957 yes)
958 AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
959 [Define to 1 if you need the memory.h header file even with stdlib.h])
960 ;;
961 esac
962 fi
963])
964
965
966dnl CURL_CHECK_FUNC_GETNAMEINFO
967dnl -------------------------------------------------
968dnl Test if the getnameinfo function is available,
969dnl and check the types of five of its arguments.
970dnl If the function succeeds HAVE_GETNAMEINFO will be
971dnl defined, defining the types of the arguments in
972dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
973dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
974dnl and also defining the type qualifier of first
975dnl argument in GETNAMEINFO_QUAL_ARG1.
976
977AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
978 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
979 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
980 #
981 AC_MSG_CHECKING([for getnameinfo])
982 AC_LINK_IFELSE([
983 AC_LANG_FUNC_LINK_TRY([getnameinfo])
984 ],[
985 AC_MSG_RESULT([yes])
986 curl_cv_getnameinfo="yes"
987 ],[
988 AC_MSG_RESULT([no])
989 curl_cv_getnameinfo="no"
990 ])
991 #
992 if test "$curl_cv_getnameinfo" != "yes"; then
993 AC_MSG_CHECKING([deeper for getnameinfo])
994 AC_LINK_IFELSE([
995 AC_LANG_PROGRAM([[
996 ]],[[
997 getnameinfo();
998 ]])
999 ],[
1000 AC_MSG_RESULT([yes])
1001 curl_cv_getnameinfo="yes"
1002 ],[
1003 AC_MSG_RESULT([but still no])
1004 curl_cv_getnameinfo="no"
1005 ])
1006 fi
1007 #
1008 if test "$curl_cv_getnameinfo" != "yes"; then
1009 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
1010 AC_LINK_IFELSE([
1011 AC_LANG_PROGRAM([[
1012#undef inline
1013#ifdef HAVE_WINDOWS_H
1014#ifndef WIN32_LEAN_AND_MEAN
1015#define WIN32_LEAN_AND_MEAN
1016#endif
1017#include <windows.h>
1018#ifdef HAVE_WINSOCK2_H
1019#include <winsock2.h>
1020#ifdef HAVE_WS2TCPIP_H
1021#include <ws2tcpip.h>
1022#endif
1023#endif
1024#else
1025#ifdef HAVE_SYS_TYPES_H
1026#include <sys/types.h>
1027#endif
1028#ifdef HAVE_SYS_SOCKET_H
1029#include <sys/socket.h>
1030#endif
1031#ifdef HAVE_NETDB_H
1032#include <netdb.h>
1033#endif
1034#endif
1035 ]],[[
1036 getnameinfo(0, 0, 0, 0, 0, 0, 0);
1037 ]])
1038 ],[
1039 AC_MSG_RESULT([yes])
1040 curl_cv_getnameinfo="yes"
1041 ],[
1042 AC_MSG_RESULT([but still no])
1043 curl_cv_getnameinfo="no"
1044 ])
1045 fi
1046 #
1047 if test "$curl_cv_getnameinfo" = "yes"; then
1048 AC_CACHE_CHECK([types of arguments for getnameinfo],
1049 [curl_cv_func_getnameinfo_args], [
1050 curl_cv_func_getnameinfo_args="unknown"
1051 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1052 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
1053 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
1054 for gni_arg7 in 'int' 'unsigned int'; do
1055 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1056 AC_COMPILE_IFELSE([
1057 AC_LANG_PROGRAM([[
1058#undef inline
1059#ifdef HAVE_WINDOWS_H
1060#ifndef WIN32_LEAN_AND_MEAN
1061#define WIN32_LEAN_AND_MEAN
1062#endif
1063#if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
1064#undef _WIN32_WINNT
1065#define _WIN32_WINNT 0x0501
1066#endif
1067#include <windows.h>
1068#ifdef HAVE_WINSOCK2_H
1069#include <winsock2.h>
1070#ifdef HAVE_WS2TCPIP_H
1071#include <ws2tcpip.h>
1072#endif
1073#endif
1074#define GNICALLCONV WSAAPI
1075#else
1076#ifdef HAVE_SYS_TYPES_H
1077#include <sys/types.h>
1078#endif
1079#ifdef HAVE_SYS_SOCKET_H
1080#include <sys/socket.h>
1081#endif
1082#ifdef HAVE_NETDB_H
1083#include <netdb.h>
1084#endif
1085#define GNICALLCONV
1086#endif
1087 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
1088 char *, $gni_arg46,
1089 char *, $gni_arg46,
1090 $gni_arg7);
1091 ]],[[
1092 $gni_arg2 salen=0;
1093 $gni_arg46 hostlen=0;
1094 $gni_arg46 servlen=0;
1095 $gni_arg7 flags=0;
1096 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
1097 ]])
1098 ],[
1099 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1100 ])
1101 fi
1102 done
1103 done
1104 done
1105 done
1106 ]) # AC-CACHE-CHECK
1107 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1108 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1109 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1110 else
1111 gni_prev_IFS=$IFS; IFS=','
1112 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1113 IFS=$gni_prev_IFS
1114 shift
1115 #
1116 gni_qual_type_arg1=$[1]
1117 #
1118 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1119 [Define to the type of arg 2 for getnameinfo.])
1120 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1121 [Define to the type of args 4 and 6 for getnameinfo.])
1122 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1123 [Define to the type of arg 7 for getnameinfo.])
1124 #
1125 prev_sh_opts=$-
1126 #
1127 case $prev_sh_opts in
1128 *f*)
1129 ;;
1130 *)
1131 set -f
1132 ;;
1133 esac
1134 #
1135 case "$gni_qual_type_arg1" in
1136 const*)
1137 gni_qual_arg1=const
1138 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1139 ;;
1140 *)
1141 gni_qual_arg1=
1142 gni_type_arg1=$gni_qual_type_arg1
1143 ;;
1144 esac
1145 #
1146 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1147 [Define to the type qualifier of arg 1 for getnameinfo.])
1148 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1149 [Define to the type of arg 1 for getnameinfo.])
1150 #
1151 case $prev_sh_opts in
1152 *f*)
1153 ;;
1154 *)
1155 set +f
1156 ;;
1157 esac
1158 #
1159 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1160 [Define to 1 if you have the getnameinfo function.])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001161 curl_cv_func_getnameinfo="yes"
9487f7f2011-08-03 07:05:30 -07001162 fi
1163 fi
1164])
1165
1166
1167dnl TYPE_SOCKADDR_STORAGE
1168dnl -------------------------------------------------
1169dnl Check for struct sockaddr_storage. Most IPv6-enabled
1170dnl hosts have it, but AIX 4.3 is one known exception.
1171
1172AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1173[
1174 AC_CHECK_TYPE([struct sockaddr_storage],
1175 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1176 [if struct sockaddr_storage is defined]), ,
1177 [
1178#undef inline
1179#ifdef HAVE_WINDOWS_H
1180#ifndef WIN32_LEAN_AND_MEAN
1181#define WIN32_LEAN_AND_MEAN
1182#endif
1183#include <windows.h>
1184#ifdef HAVE_WINSOCK2_H
1185#include <winsock2.h>
1186#endif
1187#else
1188#ifdef HAVE_SYS_TYPES_H
1189#include <sys/types.h>
1190#endif
1191#ifdef HAVE_SYS_SOCKET_H
1192#include <sys/socket.h>
1193#endif
1194#ifdef HAVE_NETINET_IN_H
1195#include <netinet/in.h>
1196#endif
1197#ifdef HAVE_ARPA_INET_H
1198#include <arpa/inet.h>
1199#endif
1200#endif
1201 ])
1202])
1203
1204
1205dnl CURL_CHECK_NI_WITHSCOPEID
1206dnl -------------------------------------------------
1207dnl Check for working NI_WITHSCOPEID in getnameinfo()
1208
1209AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1210 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1211 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1212 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1213 netdb.h netinet/in.h arpa/inet.h)
1214 #
1215 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
Dirk Vogta7d7f962016-12-01 10:50:48 +01001216 [curl_cv_working_ni_withscopeid], [
9487f7f2011-08-03 07:05:30 -07001217 AC_RUN_IFELSE([
1218 AC_LANG_PROGRAM([[
1219#ifdef HAVE_STDLIB_H
1220#include <stdlib.h>
1221#endif
1222#ifdef HAVE_STDIO_H
1223#include <stdio.h>
1224#endif
1225#ifdef HAVE_SYS_TYPES_H
1226#include <sys/types.h>
1227#endif
1228#ifdef HAVE_SYS_SOCKET_H
1229#include <sys/socket.h>
1230#endif
1231#ifdef HAVE_NETDB_H
1232#include <netdb.h>
1233#endif
1234#ifdef HAVE_NETINET_IN_H
1235#include <netinet/in.h>
1236#endif
1237#ifdef HAVE_ARPA_INET_H
1238#include <arpa/inet.h>
1239#endif
1240 ]],[[
1241#if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1242#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1243 struct sockaddr_storage sa;
1244#else
1245 unsigned char sa[256];
1246#endif
1247 char hostbuf[NI_MAXHOST];
1248 int rc;
1249 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1250 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1251 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1252 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1253 if(fd < 0) {
1254 perror("socket()");
1255 return 1; /* Error creating socket */
1256 }
1257 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1258 if(rc) {
1259 perror("getsockname()");
1260 return 2; /* Error retrieving socket name */
1261 }
1262 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1263 if(rc) {
1264 printf("rc = %s\n", gai_strerror(rc));
1265 return 3; /* Error translating socket address */
1266 }
1267 return 0; /* Ok, NI_WITHSCOPEID works */
1268#else
1269 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1270#endif
1271 ]]) # AC-LANG-PROGRAM
1272 ],[
1273 # Exit code == 0. Program worked.
Dirk Vogta7d7f962016-12-01 10:50:48 +01001274 curl_cv_working_ni_withscopeid="yes"
9487f7f2011-08-03 07:05:30 -07001275 ],[
1276 # Exit code != 0. Program failed.
Dirk Vogta7d7f962016-12-01 10:50:48 +01001277 curl_cv_working_ni_withscopeid="no"
9487f7f2011-08-03 07:05:30 -07001278 ],[
1279 # Program is not run when cross-compiling. So we assume
1280 # NI_WITHSCOPEID will work if we are able to compile it.
1281 AC_COMPILE_IFELSE([
1282 AC_LANG_PROGRAM([[
1283#include <sys/types.h>
1284#include <sys/socket.h>
1285#include <netdb.h>
1286 ]],[[
1287 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1288 ]])
1289 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +01001290 curl_cv_working_ni_withscopeid="yes"
9487f7f2011-08-03 07:05:30 -07001291 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +01001292 curl_cv_working_ni_withscopeid="no"
9487f7f2011-08-03 07:05:30 -07001293 ]) # AC-COMPILE-IFELSE
1294 ]) # AC-RUN-IFELSE
1295 ]) # AC-CACHE-CHECK
Dirk Vogta7d7f962016-12-01 10:50:48 +01001296 case "$curl_cv_working_ni_withscopeid" in
9487f7f2011-08-03 07:05:30 -07001297 yes)
1298 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1299 [Define to 1 if NI_WITHSCOPEID exists and works.])
1300 ;;
1301 esac
1302])
1303
1304
1305dnl CURL_CHECK_FUNC_RECV
1306dnl -------------------------------------------------
1307dnl Test if the socket recv() function is available,
1308dnl and check its return type and the types of its
1309dnl arguments. If the function succeeds HAVE_RECV
1310dnl will be defined, defining the types of the arguments
1311dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1312dnl and RECV_TYPE_ARG4, defining the type of the function
1313dnl return value in RECV_TYPE_RETV.
1314
1315AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1316 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1317 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1318 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1319 #
1320 AC_MSG_CHECKING([for recv])
1321 AC_LINK_IFELSE([
1322 AC_LANG_PROGRAM([[
1323#undef inline
1324#ifdef HAVE_WINDOWS_H
1325#ifndef WIN32_LEAN_AND_MEAN
1326#define WIN32_LEAN_AND_MEAN
1327#endif
1328#include <windows.h>
1329#ifdef HAVE_WINSOCK2_H
1330#include <winsock2.h>
1331#else
1332#ifdef HAVE_WINSOCK_H
1333#include <winsock.h>
1334#endif
1335#endif
1336#else
1337#ifdef HAVE_SYS_TYPES_H
1338#include <sys/types.h>
1339#endif
1340#ifdef HAVE_SYS_SOCKET_H
1341#include <sys/socket.h>
1342#endif
1343#endif
1344 ]],[[
1345 recv(0, 0, 0, 0);
1346 ]])
1347 ],[
1348 AC_MSG_RESULT([yes])
1349 curl_cv_recv="yes"
1350 ],[
1351 AC_MSG_RESULT([no])
1352 curl_cv_recv="no"
1353 ])
1354 #
1355 if test "$curl_cv_recv" = "yes"; then
1356 AC_CACHE_CHECK([types of args and return type for recv],
1357 [curl_cv_func_recv_args], [
1358 curl_cv_func_recv_args="unknown"
1359 for recv_retv in 'int' 'ssize_t'; do
1360 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1361 for recv_arg2 in 'char *' 'void *'; do
1362 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1363 for recv_arg4 in 'int' 'unsigned int'; do
1364 if test "$curl_cv_func_recv_args" = "unknown"; then
1365 AC_COMPILE_IFELSE([
1366 AC_LANG_PROGRAM([[
1367#undef inline
1368#ifdef HAVE_WINDOWS_H
1369#ifndef WIN32_LEAN_AND_MEAN
1370#define WIN32_LEAN_AND_MEAN
1371#endif
1372#include <windows.h>
1373#ifdef HAVE_WINSOCK2_H
1374#include <winsock2.h>
1375#else
1376#ifdef HAVE_WINSOCK_H
1377#include <winsock.h>
1378#endif
1379#endif
1380#define RECVCALLCONV PASCAL
1381#else
1382#ifdef HAVE_SYS_TYPES_H
1383#include <sys/types.h>
1384#endif
1385#ifdef HAVE_SYS_SOCKET_H
1386#include <sys/socket.h>
1387#endif
1388#define RECVCALLCONV
1389#endif
1390 extern $recv_retv RECVCALLCONV
1391 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1392 ]],[[
1393 $recv_arg1 s=0;
1394 $recv_arg2 buf=0;
1395 $recv_arg3 len=0;
1396 $recv_arg4 flags=0;
1397 $recv_retv res = recv(s, buf, len, flags);
1398 ]])
1399 ],[
1400 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1401 ])
1402 fi
1403 done
1404 done
1405 done
1406 done
1407 done
1408 ]) # AC-CACHE-CHECK
1409 if test "$curl_cv_func_recv_args" = "unknown"; then
1410 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1411 else
1412 recv_prev_IFS=$IFS; IFS=','
1413 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1414 IFS=$recv_prev_IFS
1415 shift
1416 #
1417 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1418 [Define to the type of arg 1 for recv.])
1419 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1420 [Define to the type of arg 2 for recv.])
1421 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1422 [Define to the type of arg 3 for recv.])
1423 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1424 [Define to the type of arg 4 for recv.])
1425 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1426 [Define to the function return type for recv.])
1427 #
1428 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1429 [Define to 1 if you have the recv function.])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001430 curl_cv_func_recv="yes"
9487f7f2011-08-03 07:05:30 -07001431 fi
1432 else
1433 AC_MSG_ERROR([Unable to link function recv])
1434 fi
1435])
1436
1437
1438dnl CURL_CHECK_FUNC_SEND
1439dnl -------------------------------------------------
1440dnl Test if the socket send() function is available,
1441dnl and check its return type and the types of its
1442dnl arguments. If the function succeeds HAVE_SEND
1443dnl will be defined, defining the types of the arguments
1444dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1445dnl and SEND_TYPE_ARG4, defining the type of the function
1446dnl return value in SEND_TYPE_RETV, and also defining the
1447dnl type qualifier of second argument in SEND_QUAL_ARG2.
1448
1449AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1450 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1451 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1452 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1453 #
1454 AC_MSG_CHECKING([for send])
1455 AC_LINK_IFELSE([
1456 AC_LANG_PROGRAM([[
1457#undef inline
1458#ifdef HAVE_WINDOWS_H
1459#ifndef WIN32_LEAN_AND_MEAN
1460#define WIN32_LEAN_AND_MEAN
1461#endif
1462#include <windows.h>
1463#ifdef HAVE_WINSOCK2_H
1464#include <winsock2.h>
1465#else
1466#ifdef HAVE_WINSOCK_H
1467#include <winsock.h>
1468#endif
1469#endif
1470#else
1471#ifdef HAVE_SYS_TYPES_H
1472#include <sys/types.h>
1473#endif
1474#ifdef HAVE_SYS_SOCKET_H
1475#include <sys/socket.h>
1476#endif
1477#endif
1478 ]],[[
1479 send(0, 0, 0, 0);
1480 ]])
1481 ],[
1482 AC_MSG_RESULT([yes])
1483 curl_cv_send="yes"
1484 ],[
1485 AC_MSG_RESULT([no])
1486 curl_cv_send="no"
1487 ])
1488 #
1489 if test "$curl_cv_send" = "yes"; then
1490 AC_CACHE_CHECK([types of args and return type for send],
1491 [curl_cv_func_send_args], [
1492 curl_cv_func_send_args="unknown"
1493 for send_retv in 'int' 'ssize_t'; do
1494 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1495 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1496 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1497 for send_arg4 in 'int' 'unsigned int'; do
1498 if test "$curl_cv_func_send_args" = "unknown"; then
1499 AC_COMPILE_IFELSE([
1500 AC_LANG_PROGRAM([[
1501#undef inline
1502#ifdef HAVE_WINDOWS_H
1503#ifndef WIN32_LEAN_AND_MEAN
1504#define WIN32_LEAN_AND_MEAN
1505#endif
1506#include <windows.h>
1507#ifdef HAVE_WINSOCK2_H
1508#include <winsock2.h>
1509#else
1510#ifdef HAVE_WINSOCK_H
1511#include <winsock.h>
1512#endif
1513#endif
1514#define SENDCALLCONV PASCAL
1515#else
1516#ifdef HAVE_SYS_TYPES_H
1517#include <sys/types.h>
1518#endif
1519#ifdef HAVE_SYS_SOCKET_H
1520#include <sys/socket.h>
1521#endif
1522#define SENDCALLCONV
1523#endif
1524 extern $send_retv SENDCALLCONV
1525 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1526 ]],[[
1527 $send_arg1 s=0;
1528 $send_arg3 len=0;
1529 $send_arg4 flags=0;
1530 $send_retv res = send(s, 0, len, flags);
1531 ]])
1532 ],[
1533 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1534 ])
1535 fi
1536 done
1537 done
1538 done
1539 done
1540 done
1541 ]) # AC-CACHE-CHECK
1542 if test "$curl_cv_func_send_args" = "unknown"; then
1543 AC_MSG_ERROR([Cannot find proper types to use for send args])
1544 else
1545 send_prev_IFS=$IFS; IFS=','
1546 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1547 IFS=$send_prev_IFS
1548 shift
1549 #
1550 send_qual_type_arg2=$[2]
1551 #
1552 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1553 [Define to the type of arg 1 for send.])
1554 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1555 [Define to the type of arg 3 for send.])
1556 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1557 [Define to the type of arg 4 for send.])
1558 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1559 [Define to the function return type for send.])
1560 #
1561 prev_sh_opts=$-
1562 #
1563 case $prev_sh_opts in
1564 *f*)
1565 ;;
1566 *)
1567 set -f
1568 ;;
1569 esac
1570 #
1571 case "$send_qual_type_arg2" in
1572 const*)
1573 send_qual_arg2=const
1574 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1575 ;;
1576 *)
1577 send_qual_arg2=
1578 send_type_arg2=$send_qual_type_arg2
1579 ;;
1580 esac
1581 #
1582 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1583 [Define to the type qualifier of arg 2 for send.])
1584 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1585 [Define to the type of arg 2 for send.])
1586 #
1587 case $prev_sh_opts in
1588 *f*)
1589 ;;
1590 *)
1591 set +f
1592 ;;
1593 esac
1594 #
1595 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1596 [Define to 1 if you have the send function.])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001597 curl_cv_func_send="yes"
9487f7f2011-08-03 07:05:30 -07001598 fi
1599 else
1600 AC_MSG_ERROR([Unable to link function send])
1601 fi
1602])
1603
9487f7f2011-08-03 07:05:30 -07001604dnl CURL_CHECK_MSG_NOSIGNAL
1605dnl -------------------------------------------------
1606dnl Check for MSG_NOSIGNAL
1607
1608AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1609 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
Dirk Vogta7d7f962016-12-01 10:50:48 +01001610 AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
9487f7f2011-08-03 07:05:30 -07001611 AC_COMPILE_IFELSE([
1612 AC_LANG_PROGRAM([[
1613#undef inline
1614#ifdef HAVE_WINDOWS_H
1615#ifndef WIN32_LEAN_AND_MEAN
1616#define WIN32_LEAN_AND_MEAN
1617#endif
1618#include <windows.h>
1619#ifdef HAVE_WINSOCK2_H
1620#include <winsock2.h>
1621#else
1622#ifdef HAVE_WINSOCK_H
1623#include <winsock.h>
1624#endif
1625#endif
1626#else
1627#ifdef HAVE_SYS_TYPES_H
1628#include <sys/types.h>
1629#endif
1630#ifdef HAVE_SYS_SOCKET_H
1631#include <sys/socket.h>
1632#endif
1633#endif
1634 ]],[[
1635 int flag=MSG_NOSIGNAL;
1636 ]])
1637 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +01001638 curl_cv_msg_nosignal="yes"
9487f7f2011-08-03 07:05:30 -07001639 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +01001640 curl_cv_msg_nosignal="no"
9487f7f2011-08-03 07:05:30 -07001641 ])
1642 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001643 case "$curl_cv_msg_nosignal" in
9487f7f2011-08-03 07:05:30 -07001644 yes)
1645 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1646 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1647 ;;
1648 esac
1649])
1650
1651
1652dnl CURL_CHECK_STRUCT_TIMEVAL
1653dnl -------------------------------------------------
1654dnl Check for timeval struct
1655
1656AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1657 AC_REQUIRE([AC_HEADER_TIME])dnl
1658 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1659 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1660 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
Dirk Vogta7d7f962016-12-01 10:50:48 +01001661 AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
9487f7f2011-08-03 07:05:30 -07001662 AC_COMPILE_IFELSE([
1663 AC_LANG_PROGRAM([[
1664#undef inline
1665#ifdef HAVE_WINDOWS_H
1666#ifndef WIN32_LEAN_AND_MEAN
1667#define WIN32_LEAN_AND_MEAN
1668#endif
1669#include <windows.h>
1670#ifdef HAVE_WINSOCK2_H
1671#include <winsock2.h>
1672#else
1673#ifdef HAVE_WINSOCK_H
1674#include <winsock.h>
1675#endif
1676#endif
1677#endif
1678#ifdef HAVE_SYS_TYPES_H
1679#include <sys/types.h>
1680#endif
1681#ifdef HAVE_SYS_TIME_H
1682#include <sys/time.h>
1683#ifdef TIME_WITH_SYS_TIME
1684#include <time.h>
1685#endif
1686#else
1687#ifdef HAVE_TIME_H
1688#include <time.h>
1689#endif
1690#endif
1691#ifdef HAVE_SYS_SOCKET_H
1692#include <sys/socket.h>
1693#endif
1694 ]],[[
1695 struct timeval ts;
1696 ts.tv_sec = 0;
1697 ts.tv_usec = 0;
1698 ]])
1699 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +01001700 curl_cv_struct_timeval="yes"
9487f7f2011-08-03 07:05:30 -07001701 ],[
Dirk Vogta7d7f962016-12-01 10:50:48 +01001702 curl_cv_struct_timeval="no"
9487f7f2011-08-03 07:05:30 -07001703 ])
1704 ])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001705 case "$curl_cv_struct_timeval" in
9487f7f2011-08-03 07:05:30 -07001706 yes)
1707 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1708 [Define to 1 if you have the timeval struct.])
1709 ;;
1710 esac
1711])
1712
1713
1714dnl TYPE_SIG_ATOMIC_T
1715dnl -------------------------------------------------
1716dnl Check if the sig_atomic_t type is available, and
1717dnl verify if it is already defined as volatile.
1718
1719AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1720 AC_CHECK_HEADERS(signal.h)
1721 AC_CHECK_TYPE([sig_atomic_t],[
1722 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1723 [Define to 1 if sig_atomic_t is an available typedef.])
1724 ], ,[
1725#ifdef HAVE_SIGNAL_H
1726#include <signal.h>
1727#endif
1728 ])
1729 case "$ac_cv_type_sig_atomic_t" in
1730 yes)
1731 #
1732 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1733 AC_LINK_IFELSE([
1734 AC_LANG_PROGRAM([[
1735#ifdef HAVE_SIGNAL_H
1736#include <signal.h>
1737#endif
1738 ]],[[
1739 static volatile sig_atomic_t dummy = 0;
1740 ]])
1741 ],[
1742 AC_MSG_RESULT([no])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001743 curl_cv_sig_atomic_t_volatile="no"
9487f7f2011-08-03 07:05:30 -07001744 ],[
1745 AC_MSG_RESULT([yes])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001746 curl_cv_sig_atomic_t_volatile="yes"
9487f7f2011-08-03 07:05:30 -07001747 ])
1748 #
Dirk Vogta7d7f962016-12-01 10:50:48 +01001749 if test "$curl_cv_sig_atomic_t_volatile" = "yes"; then
9487f7f2011-08-03 07:05:30 -07001750 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1751 [Define to 1 if sig_atomic_t is already defined as volatile.])
1752 fi
1753 ;;
1754 esac
1755])
1756
1757
1758dnl TYPE_IN_ADDR_T
1759dnl -------------------------------------------------
1760dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1761dnl and a few other things.
1762
1763AC_DEFUN([TYPE_IN_ADDR_T], [
1764 AC_CHECK_TYPE([in_addr_t], ,[
1765 dnl in_addr_t not available
1766 AC_CACHE_CHECK([for in_addr_t equivalent],
1767 [curl_cv_in_addr_t_equiv], [
1768 curl_cv_in_addr_t_equiv="unknown"
1769 for t in "unsigned long" int size_t unsigned long; do
1770 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1771 AC_LINK_IFELSE([
1772 AC_LANG_PROGRAM([[
1773#undef inline
1774#ifdef HAVE_WINDOWS_H
1775#ifndef WIN32_LEAN_AND_MEAN
1776#define WIN32_LEAN_AND_MEAN
1777#endif
1778#include <windows.h>
1779#ifdef HAVE_WINSOCK2_H
1780#include <winsock2.h>
1781#else
1782#ifdef HAVE_WINSOCK_H
1783#include <winsock.h>
1784#endif
1785#endif
1786#else
1787#ifdef HAVE_SYS_TYPES_H
1788#include <sys/types.h>
1789#endif
1790#ifdef HAVE_SYS_SOCKET_H
1791#include <sys/socket.h>
1792#endif
1793#ifdef HAVE_NETINET_IN_H
1794#include <netinet/in.h>
1795#endif
1796#ifdef HAVE_ARPA_INET_H
1797#include <arpa/inet.h>
1798#endif
1799#endif
1800 ]],[[
1801 $t data = inet_addr ("1.2.3.4");
1802 ]])
1803 ],[
1804 curl_cv_in_addr_t_equiv="$t"
1805 ])
1806 fi
1807 done
1808 ])
1809 case "$curl_cv_in_addr_t_equiv" in
1810 unknown)
1811 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1812 ;;
1813 *)
1814 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1815 [Type to use in place of in_addr_t when system does not provide it.])
1816 ;;
1817 esac
1818 ],[
1819#undef inline
1820#ifdef HAVE_WINDOWS_H
1821#ifndef WIN32_LEAN_AND_MEAN
1822#define WIN32_LEAN_AND_MEAN
1823#endif
1824#include <windows.h>
1825#ifdef HAVE_WINSOCK2_H
1826#include <winsock2.h>
1827#else
1828#ifdef HAVE_WINSOCK_H
1829#include <winsock.h>
1830#endif
1831#endif
1832#else
1833#ifdef HAVE_SYS_TYPES_H
1834#include <sys/types.h>
1835#endif
1836#ifdef HAVE_SYS_SOCKET_H
1837#include <sys/socket.h>
1838#endif
1839#ifdef HAVE_NETINET_IN_H
1840#include <netinet/in.h>
1841#endif
1842#ifdef HAVE_ARPA_INET_H
1843#include <arpa/inet.h>
1844#endif
1845#endif
1846 ])
1847])
1848
1849
1850dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1851dnl -------------------------------------------------
1852dnl Check if monotonic clock_gettime is available.
1853
1854AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1855 AC_REQUIRE([AC_HEADER_TIME])dnl
1856 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1857 AC_MSG_CHECKING([for monotonic clock_gettime])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001858 #
1859 if test "x$dontwant_rt" = "xno" ; then
1860 AC_COMPILE_IFELSE([
1861 AC_LANG_PROGRAM([[
9487f7f2011-08-03 07:05:30 -07001862#ifdef HAVE_SYS_TYPES_H
1863#include <sys/types.h>
1864#endif
1865#ifdef HAVE_SYS_TIME_H
1866#include <sys/time.h>
1867#ifdef TIME_WITH_SYS_TIME
1868#include <time.h>
1869#endif
1870#else
1871#ifdef HAVE_TIME_H
1872#include <time.h>
1873#endif
1874#endif
Dirk Vogta7d7f962016-12-01 10:50:48 +01001875 ]],[[
1876 struct timespec ts;
1877 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1878 ]])
1879 ],[
1880 AC_MSG_RESULT([yes])
1881 curl_func_clock_gettime="yes"
1882 ],[
1883 AC_MSG_RESULT([no])
1884 curl_func_clock_gettime="no"
1885 ])
1886 fi
9487f7f2011-08-03 07:05:30 -07001887 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1888 dnl until library linking and run-time checks for clock_gettime succeed.
1889])
1890
1891
1892dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1893dnl -------------------------------------------------
1894dnl If monotonic clock_gettime is available then,
1895dnl check and prepended to LIBS any needed libraries.
1896
1897AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1898 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1899 #
Dirk Vogta7d7f962016-12-01 10:50:48 +01001900 if test "$curl_func_clock_gettime" = "yes"; then
9487f7f2011-08-03 07:05:30 -07001901 #
1902 AC_MSG_CHECKING([for clock_gettime in libraries])
1903 #
1904 curl_cv_save_LIBS="$LIBS"
1905 curl_cv_gclk_LIBS="unknown"
1906 #
1907 for x_xlibs in '' '-lrt' '-lposix4' ; do
1908 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1909 if test -z "$x_xlibs"; then
1910 LIBS="$curl_cv_save_LIBS"
1911 else
1912 LIBS="$x_xlibs $curl_cv_save_LIBS"
1913 fi
1914 AC_LINK_IFELSE([
1915 AC_LANG_PROGRAM([[
1916#ifdef HAVE_SYS_TYPES_H
1917#include <sys/types.h>
1918#endif
1919#ifdef HAVE_SYS_TIME_H
1920#include <sys/time.h>
1921#ifdef TIME_WITH_SYS_TIME
1922#include <time.h>
1923#endif
1924#else
1925#ifdef HAVE_TIME_H
1926#include <time.h>
1927#endif
1928#endif
1929 ]],[[
1930 struct timespec ts;
1931 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1932 ]])
1933 ],[
1934 curl_cv_gclk_LIBS="$x_xlibs"
1935 ])
1936 fi
1937 done
1938 #
1939 LIBS="$curl_cv_save_LIBS"
1940 #
1941 case X-"$curl_cv_gclk_LIBS" in
1942 X-unknown)
1943 AC_MSG_RESULT([cannot find clock_gettime])
1944 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001945 curl_func_clock_gettime="no"
9487f7f2011-08-03 07:05:30 -07001946 ;;
1947 X-)
1948 AC_MSG_RESULT([no additional lib required])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001949 curl_func_clock_gettime="yes"
9487f7f2011-08-03 07:05:30 -07001950 ;;
1951 *)
1952 if test -z "$curl_cv_save_LIBS"; then
1953 LIBS="$curl_cv_gclk_LIBS"
1954 else
1955 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1956 fi
9487f7f2011-08-03 07:05:30 -07001957 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001958 curl_func_clock_gettime="yes"
9487f7f2011-08-03 07:05:30 -07001959 ;;
1960 esac
1961 #
1962 dnl only do runtime verification when not cross-compiling
1963 if test "x$cross_compiling" != "xyes" &&
Dirk Vogta7d7f962016-12-01 10:50:48 +01001964 test "$curl_func_clock_gettime" = "yes"; then
9487f7f2011-08-03 07:05:30 -07001965 AC_MSG_CHECKING([if monotonic clock_gettime works])
1966 AC_RUN_IFELSE([
1967 AC_LANG_PROGRAM([[
1968#ifdef HAVE_STDLIB_H
1969#include <stdlib.h>
1970#endif
1971#ifdef HAVE_SYS_TYPES_H
1972#include <sys/types.h>
1973#endif
1974#ifdef HAVE_SYS_TIME_H
1975#include <sys/time.h>
1976#ifdef TIME_WITH_SYS_TIME
1977#include <time.h>
1978#endif
1979#else
1980#ifdef HAVE_TIME_H
1981#include <time.h>
1982#endif
1983#endif
1984 ]],[[
1985 struct timespec ts;
1986 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1987 exit(0);
1988 else
1989 exit(1);
1990 ]])
1991 ],[
1992 AC_MSG_RESULT([yes])
1993 ],[
1994 AC_MSG_RESULT([no])
1995 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
Dirk Vogta7d7f962016-12-01 10:50:48 +01001996 curl_func_clock_gettime="no"
9487f7f2011-08-03 07:05:30 -07001997 LIBS="$curl_cv_save_LIBS"
1998 ])
1999 fi
2000 #
Dirk Vogta7d7f962016-12-01 10:50:48 +01002001 case "$curl_func_clock_gettime" in
9487f7f2011-08-03 07:05:30 -07002002 yes)
2003 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2004 [Define to 1 if you have the clock_gettime function and monotonic timer.])
2005 ;;
2006 esac
2007 #
2008 fi
2009 #
2010])
2011
2012
2013dnl CURL_CHECK_LIBS_CONNECT
2014dnl -------------------------------------------------
2015dnl Verify if network connect function is already available
2016dnl using current libraries or if another one is required.
2017
2018AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
2019 AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2020 AC_MSG_CHECKING([for connect in libraries])
2021 tst_connect_save_LIBS="$LIBS"
2022 tst_connect_need_LIBS="unknown"
2023 for tst_lib in '' '-lsocket' ; do
2024 if test "$tst_connect_need_LIBS" = "unknown"; then
2025 LIBS="$tst_lib $tst_connect_save_LIBS"
2026 AC_LINK_IFELSE([
2027 AC_LANG_PROGRAM([[
2028 $curl_includes_winsock2
2029 #ifndef HAVE_WINDOWS_H
2030 int connect(int, void*, int);
2031 #endif
2032 ]],[[
2033 if(0 != connect(0, 0, 0))
2034 return 1;
2035 ]])
2036 ],[
2037 tst_connect_need_LIBS="$tst_lib"
2038 ])
2039 fi
2040 done
2041 LIBS="$tst_connect_save_LIBS"
2042 #
2043 case X-"$tst_connect_need_LIBS" in
2044 X-unknown)
2045 AC_MSG_RESULT([cannot find connect])
2046 AC_MSG_ERROR([cannot find connect function in libraries.])
2047 ;;
2048 X-)
2049 AC_MSG_RESULT([yes])
2050 ;;
2051 *)
2052 AC_MSG_RESULT([$tst_connect_need_LIBS])
2053 LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
2054 ;;
2055 esac
2056])
2057
2058
2059dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
2060dnl -------------------------------------------------
2061dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
2062dnl symbol that can be further used in custom template configuration
2063dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
2064dnl argument for the description. Symbol definitions done with this
2065dnl macro are intended to be exclusively used in handcrafted *.h.in
2066dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
2067dnl prevents autoheader generation and insertion of symbol template
2068dnl stub and definition into the first configuration header file. Do
2069dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
2070dnl one serves different functional needs.
2071
2072AC_DEFUN([CURL_DEFINE_UNQUOTED], [
2073cat >>confdefs.h <<_EOF
2074[@%:@define] $1 ifelse($#, 2, [$2], 1)
2075_EOF
2076])
2077
2078
2079dnl CURL_CONFIGURE_LONG
2080dnl -------------------------------------------------
2081dnl Find out the size of long as reported by sizeof() and define
2082dnl CURL_SIZEOF_LONG as appropriate to be used in template file
2083dnl include/curl/curlbuild.h.in to properly configure the library.
2084dnl The size of long is a build time characteristic and as such
2085dnl must be recorded in curlbuild.h
2086
2087AC_DEFUN([CURL_CONFIGURE_LONG], [
2088 if test -z "$ac_cv_sizeof_long" ||
2089 test "$ac_cv_sizeof_long" -eq "0"; then
2090 AC_MSG_ERROR([cannot find out size of long.])
2091 fi
2092 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
2093])
2094
2095
2096dnl CURL_CONFIGURE_CURL_SOCKLEN_T
2097dnl -------------------------------------------------
2098dnl Find out suitable curl_socklen_t data type definition and size, making
2099dnl appropriate definitions for template file include/curl/curlbuild.h.in
2100dnl to properly configure and use the library.
2101dnl
2102dnl The need for the curl_socklen_t definition arises mainly to properly
2103dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
2104dnl data type which is 32 or 64-Bit wide depending on the data model being
2105dnl used, and that on the other hand is only actually used when interfacing
2106dnl the X/Open sockets provided in the xnet library.
2107
2108AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
2109 AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
2110 AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
2111 AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
2112 #
Dirk Vogta7d7f962016-12-01 10:50:48 +01002113 AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
2114 #
9487f7f2011-08-03 07:05:30 -07002115 AC_MSG_CHECKING([for curl_socklen_t data type])
2116 curl_typeof_curl_socklen_t="unknown"
2117 for arg1 in int SOCKET; do
2118 for arg2 in 'struct sockaddr' void; do
2119 for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
2120 if test "$curl_typeof_curl_socklen_t" = "unknown"; then
2121 AC_COMPILE_IFELSE([
2122 AC_LANG_PROGRAM([[
2123 $curl_includes_ws2tcpip
2124 $curl_includes_sys_socket
2125 $curl_preprocess_callconv
2126 extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
2127 ]],[[
2128 $t *lenptr = 0;
2129 if(0 != getpeername(0, 0, lenptr))
2130 return 1;
2131 ]])
2132 ],[
2133 curl_typeof_curl_socklen_t="$t"
2134 ])
2135 fi
2136 done
2137 done
2138 done
2139 for t in socklen_t int; do
2140 if test "$curl_typeof_curl_socklen_t" = "void"; then
2141 AC_COMPILE_IFELSE([
2142 AC_LANG_PROGRAM([[
2143 $curl_includes_sys_socket
2144 typedef $t curl_socklen_t;
2145 ]],[[
2146 curl_socklen_t dummy;
2147 ]])
2148 ],[
2149 curl_typeof_curl_socklen_t="$t"
2150 ])
2151 fi
2152 done
2153 AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
2154 if test "$curl_typeof_curl_socklen_t" = "void" ||
2155 test "$curl_typeof_curl_socklen_t" = "unknown"; then
2156 AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
2157 fi
2158 #
2159 AC_MSG_CHECKING([size of curl_socklen_t])
2160 curl_sizeof_curl_socklen_t="unknown"
2161 curl_pull_headers_socklen_t="unknown"
Dirk Vogta7d7f962016-12-01 10:50:48 +01002162 if test "$curl_cv_header_ws2tcpip_h" = "yes"; then
9487f7f2011-08-03 07:05:30 -07002163 tst_pull_header_checks='none ws2tcpip'
2164 tst_size_checks='4'
2165 else
2166 tst_pull_header_checks='none systypes syssocket'
2167 tst_size_checks='4 8 2'
2168 fi
2169 for tst_size in $tst_size_checks; do
2170 for tst_pull_headers in $tst_pull_header_checks; do
2171 if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
2172 case $tst_pull_headers in
2173 ws2tcpip)
2174 tmp_includes="$curl_includes_ws2tcpip"
2175 ;;
2176 systypes)
2177 tmp_includes="$curl_includes_sys_types"
2178 ;;
2179 syssocket)
2180 tmp_includes="$curl_includes_sys_socket"
2181 ;;
2182 *)
2183 tmp_includes=""
2184 ;;
2185 esac
2186 AC_COMPILE_IFELSE([
2187 AC_LANG_PROGRAM([[
2188 $tmp_includes
2189 typedef $curl_typeof_curl_socklen_t curl_socklen_t;
2190 typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
2191 ]],[[
2192 curl_socklen_t dummy;
2193 ]])
2194 ],[
2195 curl_sizeof_curl_socklen_t="$tst_size"
2196 curl_pull_headers_socklen_t="$tst_pull_headers"
2197 ])
2198 fi
2199 done
2200 done
2201 AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
2202 if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
2203 AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
2204 fi
2205 #
2206 case $curl_pull_headers_socklen_t in
2207 ws2tcpip)
2208 CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
2209 ;;
2210 systypes)
2211 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2212 ;;
2213 syssocket)
2214 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2215 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
2216 ;;
2217 esac
2218 CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
2219 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
2220])
2221
2222
Dirk Vogta7d7f962016-12-01 10:50:48 +01002223dnl CURL_CONFIGURE_PULL_SYS_POLL
2224dnl -------------------------------------------------
2225dnl Find out if system header file sys/poll.h must be included by the
2226dnl external interface, making appropriate definitions for template file
2227dnl include/curl/curlbuild.h.in to properly configure and use the library.
2228dnl
2229dnl The need for the sys/poll.h inclusion arises mainly to properly
2230dnl interface AIX systems which define macros 'events' and 'revents'.
2231
2232AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
2233 AC_REQUIRE([CURL_INCLUDES_POLL])dnl
2234 #
2235 tst_poll_events_macro_defined="unknown"
2236 #
2237 AC_COMPILE_IFELSE([
2238 AC_LANG_PROGRAM([[
2239 $curl_includes_poll
2240 ]],[[
2241#if defined(events) || defined(revents)
2242 return 0;
2243#else
2244 force compilation error
2245#endif
2246 ]])
2247 ],[
2248 tst_poll_events_macro_defined="yes"
2249 ],[
2250 tst_poll_events_macro_defined="no"
2251 ])
2252 #
2253 if test "$tst_poll_events_macro_defined" = "yes"; then
2254 if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
2255 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
2256 fi
2257 fi
2258 #
2259])
2260
2261
9487f7f2011-08-03 07:05:30 -07002262dnl CURL_CHECK_FUNC_SELECT
2263dnl -------------------------------------------------
2264dnl Test if the socket select() function is available,
2265dnl and check its return type and the types of its
2266dnl arguments. If the function succeeds HAVE_SELECT
2267dnl will be defined, defining the types of the
2268dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2269dnl and SELECT_TYPE_ARG5, defining the type of the
2270dnl function return value in SELECT_TYPE_RETV, and
2271dnl also defining the type qualifier of fifth argument
2272dnl in SELECT_QUAL_ARG5.
2273
2274AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2275 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2276 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2277 #
2278 AC_MSG_CHECKING([for select])
2279 AC_LINK_IFELSE([
2280 AC_LANG_PROGRAM([[
2281#undef inline
2282#ifdef HAVE_WINDOWS_H
2283#ifndef WIN32_LEAN_AND_MEAN
2284#define WIN32_LEAN_AND_MEAN
2285#endif
2286#include <windows.h>
2287#ifdef HAVE_WINSOCK2_H
2288#include <winsock2.h>
2289#else
2290#ifdef HAVE_WINSOCK_H
2291#include <winsock.h>
2292#endif
2293#endif
2294#endif
2295#ifdef HAVE_SYS_TYPES_H
2296#include <sys/types.h>
2297#endif
2298#ifdef HAVE_SYS_TIME_H
2299#include <sys/time.h>
2300#ifdef TIME_WITH_SYS_TIME
2301#include <time.h>
2302#endif
2303#else
2304#ifdef HAVE_TIME_H
2305#include <time.h>
2306#endif
2307#endif
2308#ifndef HAVE_WINDOWS_H
2309#ifdef HAVE_SYS_SELECT_H
2310#include <sys/select.h>
2311#endif
2312#ifdef HAVE_SYS_SOCKET_H
2313#include <sys/socket.h>
2314#endif
2315#endif
2316 ]],[[
2317 select(0, 0, 0, 0, 0);
2318 ]])
2319 ],[
2320 AC_MSG_RESULT([yes])
2321 curl_cv_select="yes"
2322 ],[
2323 AC_MSG_RESULT([no])
2324 curl_cv_select="no"
2325 ])
2326 #
2327 if test "$curl_cv_select" = "yes"; then
2328 AC_CACHE_CHECK([types of args and return type for select],
2329 [curl_cv_func_select_args], [
2330 curl_cv_func_select_args="unknown"
2331 for sel_retv in 'int' 'ssize_t'; do
2332 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2333 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2334 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2335 if test "$curl_cv_func_select_args" = "unknown"; then
2336 AC_COMPILE_IFELSE([
2337 AC_LANG_PROGRAM([[
2338#undef inline
2339#ifdef HAVE_WINDOWS_H
2340#ifndef WIN32_LEAN_AND_MEAN
2341#define WIN32_LEAN_AND_MEAN
2342#endif
2343#include <windows.h>
2344#ifdef HAVE_WINSOCK2_H
2345#include <winsock2.h>
2346#else
2347#ifdef HAVE_WINSOCK_H
2348#include <winsock.h>
2349#endif
2350#endif
2351#define SELECTCALLCONV PASCAL
2352#endif
2353#ifdef HAVE_SYS_TYPES_H
2354#include <sys/types.h>
2355#endif
2356#ifdef HAVE_SYS_TIME_H
2357#include <sys/time.h>
2358#ifdef TIME_WITH_SYS_TIME
2359#include <time.h>
2360#endif
2361#else
2362#ifdef HAVE_TIME_H
2363#include <time.h>
2364#endif
2365#endif
2366#ifndef HAVE_WINDOWS_H
2367#ifdef HAVE_SYS_SELECT_H
2368#include <sys/select.h>
2369#endif
2370#ifdef HAVE_SYS_SOCKET_H
2371#include <sys/socket.h>
2372#endif
2373#define SELECTCALLCONV
2374#endif
2375#ifndef HAVE_STRUCT_TIMEVAL
2376 struct timeval {
2377 long tv_sec;
2378 long tv_usec;
2379 };
2380#endif
2381 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2382 $sel_arg234,
2383 $sel_arg234,
2384 $sel_arg234,
2385 $sel_arg5);
2386 ]],[[
2387 $sel_arg1 nfds=0;
2388 $sel_arg234 rfds=0;
2389 $sel_arg234 wfds=0;
2390 $sel_arg234 efds=0;
2391 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2392 ]])
2393 ],[
2394 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2395 ])
2396 fi
2397 done
2398 done
2399 done
2400 done
2401 ]) # AC-CACHE-CHECK
2402 if test "$curl_cv_func_select_args" = "unknown"; then
2403 AC_MSG_WARN([Cannot find proper types to use for select args])
2404 AC_MSG_WARN([HAVE_SELECT will not be defined])
2405 else
2406 select_prev_IFS=$IFS; IFS=','
2407 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2408 IFS=$select_prev_IFS
2409 shift
2410 #
2411 sel_qual_type_arg5=$[3]
2412 #
2413 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2414 [Define to the type of arg 1 for select.])
2415 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2416 [Define to the type of args 2, 3 and 4 for select.])
2417 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2418 [Define to the function return type for select.])
2419 #
2420 prev_sh_opts=$-
2421 #
2422 case $prev_sh_opts in
2423 *f*)
2424 ;;
2425 *)
2426 set -f
2427 ;;
2428 esac
2429 #
2430 case "$sel_qual_type_arg5" in
2431 const*)
2432 sel_qual_arg5=const
2433 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2434 ;;
2435 *)
2436 sel_qual_arg5=
2437 sel_type_arg5=$sel_qual_type_arg5
2438 ;;
2439 esac
2440 #
2441 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2442 [Define to the type qualifier of arg 5 for select.])
2443 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2444 [Define to the type of arg 5 for select.])
2445 #
2446 case $prev_sh_opts in
2447 *f*)
2448 ;;
2449 *)
2450 set +f
2451 ;;
2452 esac
2453 #
2454 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2455 [Define to 1 if you have the select function.])
Dirk Vogta7d7f962016-12-01 10:50:48 +01002456 curl_cv_func_select="yes"
9487f7f2011-08-03 07:05:30 -07002457 fi
2458 fi
2459])
2460
2461
9487f7f2011-08-03 07:05:30 -07002462dnl CURL_VERIFY_RUNTIMELIBS
2463dnl -------------------------------------------------
2464dnl Verify that the shared libs found so far can be used when running
2465dnl programs, since otherwise the situation will create odd configure errors
2466dnl that are misleading people.
2467dnl
2468dnl Make sure this test is run BEFORE the first test in the script that
2469dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2470dnl macro. It must also run AFTER all lib-checking macros are complete.
2471
2472AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2473
2474 dnl this test is of course not sensible if we are cross-compiling!
2475 if test "x$cross_compiling" != xyes; then
2476
2477 dnl just run a program to verify that the libs checked for previous to this
2478 dnl point also is available run-time!
2479 AC_MSG_CHECKING([run-time libs availability])
2480 AC_TRY_RUN([
2481main()
2482{
2483 return 0;
2484}
2485],
2486 AC_MSG_RESULT([fine]),
2487 AC_MSG_RESULT([failed])
2488 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2489 )
2490
2491 dnl if this test fails, configure has already stopped
2492 fi
2493])
2494
2495
2496dnl CURL_CHECK_VARIADIC_MACROS
2497dnl -------------------------------------------------
2498dnl Check compiler support of variadic macros
2499
2500AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2501 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2502 [curl_cv_variadic_macros_c99], [
2503 AC_COMPILE_IFELSE([
2504 AC_LANG_PROGRAM([[
2505#define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2506#define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2507 int fun3(int arg1, int arg2, int arg3);
2508 int fun2(int arg1, int arg2);
2509 int fun3(int arg1, int arg2, int arg3)
2510 { return arg1 + arg2 + arg3; }
2511 int fun2(int arg1, int arg2)
2512 { return arg1 + arg2; }
2513 ]],[[
2514 int res3 = c99_vmacro3(1, 2, 3);
2515 int res2 = c99_vmacro2(1, 2);
2516 ]])
2517 ],[
2518 curl_cv_variadic_macros_c99="yes"
2519 ],[
2520 curl_cv_variadic_macros_c99="no"
2521 ])
2522 ])
2523 case "$curl_cv_variadic_macros_c99" in
2524 yes)
2525 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2526 [Define to 1 if compiler supports C99 variadic macro style.])
2527 ;;
2528 esac
2529 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2530 [curl_cv_variadic_macros_gcc], [
2531 AC_COMPILE_IFELSE([
2532 AC_LANG_PROGRAM([[
2533#define gcc_vmacro3(first, args...) fun3(first, args)
2534#define gcc_vmacro2(first, args...) fun2(first, args)
2535 int fun3(int arg1, int arg2, int arg3);
2536 int fun2(int arg1, int arg2);
2537 int fun3(int arg1, int arg2, int arg3)
2538 { return arg1 + arg2 + arg3; }
2539 int fun2(int arg1, int arg2)
2540 { return arg1 + arg2; }
2541 ]],[[
2542 int res3 = gcc_vmacro3(1, 2, 3);
2543 int res2 = gcc_vmacro2(1, 2);
2544 ]])
2545 ],[
2546 curl_cv_variadic_macros_gcc="yes"
2547 ],[
2548 curl_cv_variadic_macros_gcc="no"
2549 ])
2550 ])
2551 case "$curl_cv_variadic_macros_gcc" in
2552 yes)
2553 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2554 [Define to 1 if compiler supports old gcc variadic macro style.])
2555 ;;
2556 esac
2557])
2558
2559
2560dnl CURL_CHECK_CA_BUNDLE
2561dnl -------------------------------------------------
2562dnl Check if a default ca-bundle should be used
2563dnl
2564dnl regarding the paths this will scan:
2565dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2566dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2567dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
Dirk Vogta7d7f962016-12-01 10:50:48 +01002568dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD
2569dnl /etc/ssl/cert.pem OpenBSD, FreeBSD (symlink)
9487f7f2011-08-03 07:05:30 -07002570dnl /etc/ssl/certs/ (ca path) SUSE
2571
2572AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2573
2574 AC_MSG_CHECKING([default CA cert bundle/path])
2575
2576 AC_ARG_WITH(ca-bundle,
Dirk Vogta7d7f962016-12-01 10:50:48 +01002577AC_HELP_STRING([--with-ca-bundle=FILE],
2578[Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
9487f7f2011-08-03 07:05:30 -07002579AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2580 [
2581 want_ca="$withval"
2582 if test "x$want_ca" = "xyes"; then
2583 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
2584 fi
2585 ],
2586 [ want_ca="unset" ])
2587 AC_ARG_WITH(ca-path,
Dirk Vogta7d7f962016-12-01 10:50:48 +01002588AC_HELP_STRING([--with-ca-path=DIRECTORY],
2589[Path to a directory containing CA certificates stored individually, with \
2590their filenames in a hash format. This option can be used with OpenSSL, \
2591GnuTLS and PolarSSL backends. Refer to OpenSSL c_rehash for details. \
2592(example: /etc/certificates)])
9487f7f2011-08-03 07:05:30 -07002593AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
2594 [
2595 want_capath="$withval"
2596 if test "x$want_capath" = "xyes"; then
2597 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
2598 fi
2599 ],
2600 [ want_capath="unset"])
2601
Dirk Vogta7d7f962016-12-01 10:50:48 +01002602 ca_warning=" (warning: certs not found)"
2603 capath_warning=" (warning: certs not found)"
2604 check_capath=""
2605
9487f7f2011-08-03 07:05:30 -07002606 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
2607 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2608 dnl both given
Dirk Vogta7d7f962016-12-01 10:50:48 +01002609 ca="$want_ca"
2610 capath="$want_capath"
9487f7f2011-08-03 07:05:30 -07002611 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
2612 dnl --with-ca-bundle given
2613 ca="$want_ca"
2614 capath="no"
2615 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2616 dnl --with-ca-path given
Dirk Vogta7d7f962016-12-01 10:50:48 +01002617 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$POLARSSL_ENABLED" != "x1"; then
2618 AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or PolarSSL])
9487f7f2011-08-03 07:05:30 -07002619 fi
2620 capath="$want_capath"
2621 ca="no"
2622 else
9487f7f2011-08-03 07:05:30 -07002623 dnl first try autodetecting a CA bundle , then a CA path
2624 dnl both autodetections can be skipped by --without-ca-*
2625 ca="no"
2626 capath="no"
Dirk Vogta7d7f962016-12-01 10:50:48 +01002627 if test "x$cross_compiling" != "xyes"; then
2628 dnl NOT cross-compiling and...
2629 dnl neither of the --with-ca-* options are provided
2630 if test "x$want_ca" = "xunset"; then
2631 dnl the path we previously would have installed the curl ca bundle
2632 dnl to, and thus we now check for an already existing cert in that
2633 dnl place in case we find no other
2634 if test "x$prefix" != xNONE; then
2635 cac="${prefix}/share/curl/curl-ca-bundle.crt"
2636 else
2637 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
2638 fi
9487f7f2011-08-03 07:05:30 -07002639
Dirk Vogta7d7f962016-12-01 10:50:48 +01002640 for a in /etc/ssl/certs/ca-certificates.crt \
2641 /etc/pki/tls/certs/ca-bundle.crt \
2642 /usr/share/ssl/certs/ca-bundle.crt \
2643 /usr/local/share/certs/ca-root-nss.crt \
2644 /etc/ssl/cert.pem \
2645 "$cac"; do
2646 if test -f "$a"; then
2647 ca="$a"
2648 break
2649 fi
2650 done
2651 fi
2652 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
2653 "x$OPENSSL_ENABLED" = "x1"; then
2654 check_capath="/etc/ssl/certs/"
2655 fi
2656 else
2657 dnl no option given and cross-compiling
2658 AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
9487f7f2011-08-03 07:05:30 -07002659 fi
2660 fi
2661
Dirk Vogta7d7f962016-12-01 10:50:48 +01002662 if test "x$ca" = "xno" || test -f "$ca"; then
2663 ca_warning=""
2664 fi
9487f7f2011-08-03 07:05:30 -07002665
Dirk Vogta7d7f962016-12-01 10:50:48 +01002666 if test "x$capath" != "xno"; then
2667 check_capath="$capath"
2668 fi
2669
2670 if test ! -z "$check_capath"; then
2671 for a in "$check_capath"; do
2672 if test -d "$a" && ls "$a"/[[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]].0 >/dev/null 2>/dev/null; then
2673 if test "x$capath" = "xno"; then
2674 capath="$a"
2675 fi
2676 capath_warning=""
2677 break
2678 fi
2679 done
2680 fi
2681
2682 if test "x$capath" = "xno"; then
2683 capath_warning=""
2684 fi
9487f7f2011-08-03 07:05:30 -07002685
2686 if test "x$ca" != "xno"; then
2687 CURL_CA_BUNDLE='"'$ca'"'
2688 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
2689 AC_SUBST(CURL_CA_BUNDLE)
2690 AC_MSG_RESULT([$ca])
Dirk Vogta7d7f962016-12-01 10:50:48 +01002691 fi
2692 if test "x$capath" != "xno"; then
9487f7f2011-08-03 07:05:30 -07002693 CURL_CA_PATH="\"$capath\""
2694 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
2695 AC_MSG_RESULT([$capath (capath)])
Dirk Vogta7d7f962016-12-01 10:50:48 +01002696 fi
2697 if test "x$ca" = "xno" && test "x$capath" = "xno"; then
9487f7f2011-08-03 07:05:30 -07002698 AC_MSG_RESULT([no])
2699 fi
Dirk Vogta7d7f962016-12-01 10:50:48 +01002700
2701 AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
2702 AC_ARG_WITH(ca-fallback,
2703AC_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
2704AC_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
2705 [
2706 if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
2707 AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
2708 fi
2709 ],
2710 [ with_ca_fallback="no"])
2711 AC_MSG_RESULT([$with_ca_fallback])
2712 if test "x$with_ca_fallback" = "xyes"; then
2713 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
2714 AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
2715 fi
2716 AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
2717 fi
9487f7f2011-08-03 07:05:30 -07002718])
2719
2720
2721dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
2722dnl -------------------------------------------------
2723dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
2724
2725AC_DEFUN([DO_CURL_OFF_T_CHECK], [
2726 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2727 if test "$curl_typeof_curl_off_t" = "unknown" && test ! -z "$1"; then
2728 tmp_includes=""
2729 tmp_source=""
2730 tmp_fmt=""
Dirk Vogta7d7f962016-12-01 10:50:48 +01002731 case XC_SH_TR_SH([$1]) in
9487f7f2011-08-03 07:05:30 -07002732 int64_t)
2733 tmp_includes="$curl_includes_inttypes"
2734 tmp_source="char f@<:@@:>@ = PRId64;"
2735 tmp_fmt="PRId64"
2736 ;;
2737 int32_t)
2738 tmp_includes="$curl_includes_inttypes"
2739 tmp_source="char f@<:@@:>@ = PRId32;"
2740 tmp_fmt="PRId32"
2741 ;;
2742 int16_t)
2743 tmp_includes="$curl_includes_inttypes"
2744 tmp_source="char f@<:@@:>@ = PRId16;"
2745 tmp_fmt="PRId16"
2746 ;;
2747 esac
2748 AC_COMPILE_IFELSE([
2749 AC_LANG_PROGRAM([[
2750 $tmp_includes
2751 typedef $1 curl_off_t;
2752 typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
2753 ]],[[
2754 $tmp_source
2755 curl_off_t dummy;
2756 ]])
2757 ],[
2758 if test -z "$tmp_fmt"; then
2759 curl_typeof_curl_off_t="$1"
2760 curl_sizeof_curl_off_t="$2"
2761 else
2762 CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
2763 AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
2764 AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
2765 if test AS_VAR_GET(tmp_HaveFmtDef) = "yes"; then
2766 curl_format_curl_off_t=AS_VAR_GET(tmp_FmtDef)
2767 curl_typeof_curl_off_t="$1"
2768 curl_sizeof_curl_off_t="$2"
2769 fi
2770 AS_VAR_POPDEF([tmp_FmtDef])dnl
2771 AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
2772 fi
2773 ])
2774 fi
2775])
2776
2777
2778dnl DO_CURL_OFF_T_SUFFIX_CHECK (TYPE)
2779dnl -------------------------------------------------
2780dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
2781
2782AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [
2783 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2784 AC_MSG_CHECKING([constant suffix string for curl_off_t])
2785 #
2786 curl_suffix_curl_off_t="unknown"
2787 curl_suffix_curl_off_tu="unknown"
2788 #
Dirk Vogta7d7f962016-12-01 10:50:48 +01002789 case XC_SH_TR_SH([$1]) in
9487f7f2011-08-03 07:05:30 -07002790 long_long | __longlong | __longlong_t)
2791 tst_suffixes="LL::"
2792 ;;
2793 long)
2794 tst_suffixes="L::"
2795 ;;
2796 int)
2797 tst_suffixes="::"
2798 ;;
2799 __int64 | int64_t)
2800 tst_suffixes="LL:i64::"
2801 ;;
2802 __int32 | int32_t)
2803 tst_suffixes="L:i32::"
2804 ;;
2805 __int16 | int16_t)
2806 tst_suffixes="L:i16::"
2807 ;;
2808 *)
2809 AC_MSG_ERROR([unexpected data type $1])
2810 ;;
2811 esac
2812 #
2813 old_IFS=$IFS; IFS=':'
2814 for tmp_ssuf in $tst_suffixes ; do
2815 IFS=$old_IFS
2816 if test "x$curl_suffix_curl_off_t" = "xunknown"; then
2817 case $tmp_ssuf in
2818 i64 | i32 | i16)
2819 tmp_usuf="u$tmp_ssuf"
2820 ;;
2821 LL | L)
2822 tmp_usuf="U$tmp_ssuf"
2823 ;;
2824 *)
2825 tmp_usuf=""
2826 ;;
2827 esac
2828 AC_COMPILE_IFELSE([
2829 AC_LANG_PROGRAM([[
2830 $curl_includes_inttypes
2831 typedef $1 new_t;
2832 ]],[[
2833 new_t s1;
2834 new_t s2;
2835 s1 = -10$tmp_ssuf ;
2836 s2 = 20$tmp_ssuf ;
2837 if(s1 > s2)
2838 return 1;
2839 ]])
2840 ],[
2841 curl_suffix_curl_off_t="$tmp_ssuf"
2842 curl_suffix_curl_off_tu="$tmp_usuf"
2843 ])
2844 fi
2845 done
2846 IFS=$old_IFS
2847 #
2848 if test "x$curl_suffix_curl_off_t" = "xunknown"; then
2849 AC_MSG_ERROR([cannot find constant suffix string for curl_off_t.])
2850 else
2851 AC_MSG_RESULT([$curl_suffix_curl_off_t])
2852 AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
2853 AC_MSG_RESULT([$curl_suffix_curl_off_tu])
2854 fi
2855 #
2856])
2857
2858
2859dnl CURL_CONFIGURE_CURL_OFF_T
2860dnl -------------------------------------------------
2861dnl Find out suitable curl_off_t data type definition and associated
2862dnl items, and make the appropriate definitions used in template file
2863dnl include/curl/curlbuild.h.in to properly configure the library.
2864
2865AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
2866 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2867 #
2868 AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
2869 AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
2870 AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
2871 #
2872 if test -z "$SED"; then
2873 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
2874 fi
2875 #
2876 AC_CHECK_SIZEOF(long)
2877 AC_CHECK_SIZEOF(void*)
2878 #
2879 if test -z "$ac_cv_sizeof_long" ||
2880 test "$ac_cv_sizeof_long" -eq "0"; then
2881 AC_MSG_ERROR([cannot find out size of long.])
2882 fi
2883 if test -z "$ac_cv_sizeof_voidp" ||
2884 test "$ac_cv_sizeof_voidp" -eq "0"; then
2885 AC_MSG_ERROR([cannot find out size of void*.])
2886 fi
2887 #
2888 x_LP64_long=""
2889 x_LP32_long=""
9487f7f2011-08-03 07:05:30 -07002890 #
2891 if test "$ac_cv_sizeof_long" -eq "8" &&
2892 test "$ac_cv_sizeof_voidp" -ge "8"; then
2893 x_LP64_long="long"
2894 elif test "$ac_cv_sizeof_long" -eq "4" &&
2895 test "$ac_cv_sizeof_voidp" -ge "4"; then
2896 x_LP32_long="long"
9487f7f2011-08-03 07:05:30 -07002897 fi
2898 #
2899 dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
2900 #
2901 curl_typeof_curl_off_t="unknown"
2902 curl_sizeof_curl_off_t="unknown"
2903 curl_format_curl_off_t="unknown"
2904 curl_format_curl_off_tu="unknown"
2905 #
2906 if test "$curl_typeof_curl_off_t" = "unknown"; then
2907 AC_MSG_CHECKING([for 64-bit curl_off_t data type])
2908 for t8 in \
2909 "$x_LP64_long" \
2910 'int64_t' \
2911 '__int64' \
2912 'long long' \
2913 '__longlong' \
2914 '__longlong_t' ; do
2915 DO_CURL_OFF_T_CHECK([$t8], [8])
2916 done
2917 AC_MSG_RESULT([$curl_typeof_curl_off_t])
2918 fi
2919 if test "$curl_typeof_curl_off_t" = "unknown"; then
2920 AC_MSG_CHECKING([for 32-bit curl_off_t data type])
2921 for t4 in \
2922 "$x_LP32_long" \
2923 'int32_t' \
2924 '__int32' \
2925 'int' ; do
2926 DO_CURL_OFF_T_CHECK([$t4], [4])
2927 done
2928 AC_MSG_RESULT([$curl_typeof_curl_off_t])
2929 fi
2930 if test "$curl_typeof_curl_off_t" = "unknown"; then
9487f7f2011-08-03 07:05:30 -07002931 AC_MSG_ERROR([cannot find data type for curl_off_t.])
2932 fi
2933 #
2934 AC_MSG_CHECKING([size of curl_off_t])
2935 AC_MSG_RESULT([$curl_sizeof_curl_off_t])
2936 #
2937 AC_MSG_CHECKING([formatting string directive for curl_off_t])
2938 if test "$curl_format_curl_off_t" != "unknown"; then
2939 x_pull_headers="yes"
2940 curl_format_curl_off_t=`echo "$curl_format_curl_off_t" | "$SED" 's/[["]]//g'`
2941 curl_format_curl_off_tu=`echo "$curl_format_curl_off_t" | "$SED" 's/i$/u/'`
2942 curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/d$/u/'`
2943 curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'`
2944 else
2945 x_pull_headers="no"
Dirk Vogta7d7f962016-12-01 10:50:48 +01002946 case XC_SH_TR_SH([$curl_typeof_curl_off_t]) in
9487f7f2011-08-03 07:05:30 -07002947 long_long | __longlong | __longlong_t)
2948 curl_format_curl_off_t="lld"
2949 curl_format_curl_off_tu="llu"
2950 ;;
2951 long)
2952 curl_format_curl_off_t="ld"
2953 curl_format_curl_off_tu="lu"
2954 ;;
2955 int)
2956 curl_format_curl_off_t="d"
2957 curl_format_curl_off_tu="u"
2958 ;;
2959 __int64)
2960 curl_format_curl_off_t="I64d"
2961 curl_format_curl_off_tu="I64u"
2962 ;;
2963 __int32)
2964 curl_format_curl_off_t="I32d"
2965 curl_format_curl_off_tu="I32u"
2966 ;;
2967 __int16)
2968 curl_format_curl_off_t="I16d"
2969 curl_format_curl_off_tu="I16u"
2970 ;;
2971 *)
2972 AC_MSG_ERROR([cannot find print format string for curl_off_t.])
2973 ;;
2974 esac
2975 fi
2976 AC_MSG_RESULT(["$curl_format_curl_off_t"])
2977 #
2978 AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
2979 AC_MSG_RESULT(["$curl_format_curl_off_tu"])
2980 #
2981 DO_CURL_OFF_T_SUFFIX_CHECK([$curl_typeof_curl_off_t])
2982 #
2983 if test "$x_pull_headers" = "yes"; then
2984 if test "x$ac_cv_header_sys_types_h" = "xyes"; then
2985 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2986 fi
2987 if test "x$ac_cv_header_stdint_h" = "xyes"; then
2988 CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
2989 fi
2990 if test "x$ac_cv_header_inttypes_h" = "xyes"; then
2991 CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
2992 fi
2993 fi
2994 #
2995 CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_OFF_T], [$curl_typeof_curl_off_t])
2996 CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_T], ["$curl_format_curl_off_t"])
2997 CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_TU], ["$curl_format_curl_off_tu"])
2998 CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$curl_format_curl_off_t"])
2999 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$curl_sizeof_curl_off_t])
3000 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$curl_suffix_curl_off_t])
3001 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$curl_suffix_curl_off_tu])
3002 #
3003])
3004
3005
3006dnl CURL_CHECK_WIN32_LARGEFILE
3007dnl -------------------------------------------------
3008dnl Check if curl's WIN32 large file will be used
3009
3010AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
3011 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
3012 AC_MSG_CHECKING([whether build target supports WIN32 file API])
3013 curl_win32_file_api="no"
Dirk Vogta7d7f962016-12-01 10:50:48 +01003014 if test "$curl_cv_header_windows_h" = "yes"; then
9487f7f2011-08-03 07:05:30 -07003015 if test x"$enable_largefile" != "xno"; then
3016 AC_COMPILE_IFELSE([
3017 AC_LANG_PROGRAM([[
3018 ]],[[
3019#if !defined(_WIN32_WCE) && \
3020 (defined(__MINGW32__) || \
3021 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
3022 int dummy=1;
3023#else
3024 WIN32 large file API not supported.
3025#endif
3026 ]])
3027 ],[
3028 curl_win32_file_api="win32_large_files"
3029 ])
3030 fi
3031 if test "$curl_win32_file_api" = "no"; then
3032 AC_COMPILE_IFELSE([
3033 AC_LANG_PROGRAM([[
3034 ]],[[
3035#if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
3036 int dummy=1;
3037#else
3038 WIN32 small file API not supported.
3039#endif
3040 ]])
3041 ],[
3042 curl_win32_file_api="win32_small_files"
3043 ])
3044 fi
3045 fi
3046 case "$curl_win32_file_api" in
3047 win32_large_files)
3048 AC_MSG_RESULT([yes (large file enabled)])
3049 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
3050 [Define to 1 if you are building a Windows target with large file support.])
3051 ;;
3052 win32_small_files)
3053 AC_MSG_RESULT([yes (large file disabled)])
Dirk Vogta7d7f962016-12-01 10:50:48 +01003054 AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
9487f7f2011-08-03 07:05:30 -07003055 [Define to 1 if you are building a Windows target without large file support.])
3056 ;;
3057 *)
3058 AC_MSG_RESULT([no])
3059 ;;
3060 esac
3061])
3062
3063dnl CURL_EXPORT_PCDIR ($pcdir)
3064dnl ------------------------
3065dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
3066dnl
3067dnl we need this macro since pkg-config distinguishes among empty and unset
3068dnl variable while checking PKG_CONFIG_LIBDIR
3069dnl
3070
3071AC_DEFUN([CURL_EXPORT_PCDIR], [
3072 if test -n "$1"; then
3073 PKG_CONFIG_LIBDIR="$1"
3074 export PKG_CONFIG_LIBDIR
3075 fi
3076])
3077
3078dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
3079dnl ------------------------
Dirk Vogta7d7f962016-12-01 10:50:48 +01003080dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
3081dnl path to it, or 'no' if not found/present.
9487f7f2011-08-03 07:05:30 -07003082dnl
3083dnl If pkg-config is present, check that it has info about the $module or
3084dnl return "no" anyway!
3085dnl
3086dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
3087dnl
3088
3089AC_DEFUN([CURL_CHECK_PKGCONFIG], [
Dirk Vogta7d7f962016-12-01 10:50:48 +01003090 if test -n "$PKG_CONFIG"; then
3091 PKGCONFIG="$PKG_CONFIG"
3092 else
3093 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
3094 [$PATH:/usr/bin:/usr/local/bin])
9487f7f2011-08-03 07:05:30 -07003095 fi
3096
Dirk Vogta7d7f962016-12-01 10:50:48 +01003097 if test "x$PKGCONFIG" != "xno"; then
9487f7f2011-08-03 07:05:30 -07003098 AC_MSG_CHECKING([for $1 options with pkg-config])
3099 dnl ask pkg-config about $1
3100 itexists=`CURL_EXPORT_PCDIR([$2]) dnl
3101 $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
3102
3103 if test -z "$itexists"; then
3104 dnl pkg-config does not have info about the given module! set the
3105 dnl variable to 'no'
3106 PKGCONFIG="no"
3107 AC_MSG_RESULT([no])
3108 else
3109 AC_MSG_RESULT([found])
3110 fi
3111 fi
3112])
3113
3114
3115dnl CURL_GENERATE_CONFIGUREHELP_PM
3116dnl -------------------------------------------------
3117dnl Generate test harness configurehelp.pm module, defining and
3118dnl initializing some perl variables with values which are known
3119dnl when the configure script runs. For portability reasons, test
3120dnl harness needs information on how to run the C preprocessor.
3121
3122AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
3123 AC_REQUIRE([AC_PROG_CPP])dnl
3124 tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
3125 if test -z "$tmp_cpp"; then
3126 tmp_cpp='cpp'
3127 fi
3128 cat >./tests/configurehelp.pm <<_EOF
3129[@%:@] This is a generated file. Do not edit.
3130
3131package configurehelp;
3132
3133use strict;
3134use warnings;
3135use Exporter;
3136
3137use vars qw(
3138 @ISA
3139 @EXPORT_OK
3140 \$Cpreprocessor
3141 );
3142
3143@ISA = qw(Exporter);
3144
3145@EXPORT_OK = qw(
3146 \$Cpreprocessor
3147 );
3148
3149\$Cpreprocessor = '$tmp_cpp';
3150
31511;
3152_EOF
3153])
Dirk Vogta7d7f962016-12-01 10:50:48 +01003154
3155dnl CURL_CPP_P
3156dnl
3157dnl Check if $cpp -P should be used for extract define values due to gcc 5
3158dnl splitting up strings and defines between line outputs. gcc by default
3159dnl (without -P) will show TEST EINVAL TEST as
3160dnl
3161dnl # 13 "conftest.c"
3162dnl TEST
3163dnl # 13 "conftest.c" 3 4
3164dnl 22
3165dnl # 13 "conftest.c"
3166dnl TEST
3167
3168AC_DEFUN([CURL_CPP_P], [
3169 AC_MSG_CHECKING([if cpp -P is needed])
3170 AC_EGREP_CPP([TEST.*TEST], [
3171 #include <errno.h>
3172TEST EINVAL TEST
3173 ], [cpp=no], [cpp=yes])
3174 AC_MSG_RESULT([$cpp])
3175
3176 dnl we need cpp -P so check if it works then
3177 if test "x$cpp" = "xyes"; then
3178 AC_MSG_CHECKING([if cpp -P works])
3179 OLDCPPFLAGS=$CPPFLAGS
3180 CPPFLAGS="$CPPFLAGS -P"
3181 AC_EGREP_CPP([TEST.*TEST], [
3182 #include <errno.h>
3183TEST EINVAL TEST
3184 ], [cpp_p=yes], [cpp_p=no])
3185 AC_MSG_RESULT([$cpp_p])
3186
3187 if test "x$cpp_p" = "xno"; then
3188 AC_MSG_WARN([failed to figure out cpp -P alternative])
3189 # without -P
3190 CPPPFLAG=""
3191 else
3192 # with -P
3193 CPPPFLAG="-P"
3194 fi
3195 dnl restore CPPFLAGS
3196 CPPFLAGS=$OLDCPPFLAGS
3197 else
3198 # without -P
3199 CPPPFLAG=""
3200 fi
3201])
3202
3203
3204dnl CURL_MAC_CFLAGS
3205dnl
3206dnl Check if -mmacosx-version-min, -miphoneos-version-min or any
3207dnl similar are set manually, otherwise do. And set
3208dnl -Werror=partial-availability.
3209dnl
3210
3211AC_DEFUN([CURL_MAC_CFLAGS], [
3212
3213 tst_cflags="no"
3214 case $host_os in
3215 darwin*)
3216 tst_cflags="yes"
3217 ;;
3218 esac
3219
3220 AC_MSG_CHECKING([for good-to-use Mac CFLAGS])
3221 AC_MSG_RESULT([$tst_cflags]);
3222
3223 if test "$tst_cflags" = "yes"; then
3224 AC_MSG_CHECKING([for *version-min in CFLAGS])
3225 min=""
3226 if test -z "$(echo $CFLAGS | grep m.*os.*-version-min)"; then
3227 min="-mmacosx-version-min=10.8"
3228 CFLAGS="$CFLAGS $min"
3229 fi
3230 if test -z "$min"; then
3231 AC_MSG_RESULT([set by user])
3232 else
3233 AC_MSG_RESULT([$min set])
3234 fi
3235 CFLAGS="$CFLAGS -Werror=partial-availability"
3236 fi
3237
3238])