• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.haxx.se/docs/copyright.html.
13#
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
23# File version for 'aclocal' use. Keep it a single number.
24# serial 73
25
26
27dnl CURL_INCLUDES_ARPA_INET
28dnl -------------------------------------------------
29dnl Set up variable with list of headers that must be
30dnl included when arpa/inet.h is to be included.
31
32AC_DEFUN([CURL_INCLUDES_ARPA_INET], [
33curl_includes_arpa_inet="\
34/* includes start */
35#ifdef HAVE_SYS_TYPES_H
36#  include <sys/types.h>
37#endif
38#ifdef HAVE_SYS_SOCKET_H
39#  include <sys/socket.h>
40#endif
41#ifdef HAVE_NETINET_IN_H
42#  include <netinet/in.h>
43#endif
44#ifdef HAVE_ARPA_INET_H
45#  include <arpa/inet.h>
46#endif
47#ifdef HAVE_WINSOCK2_H
48#include <winsock2.h>
49#include <ws2tcpip.h>
50#endif
51/* includes end */"
52  AC_CHECK_HEADERS(
53    sys/types.h sys/socket.h netinet/in.h arpa/inet.h,
54    [], [], [$curl_includes_arpa_inet])
55])
56
57
58dnl CURL_INCLUDES_FCNTL
59dnl -------------------------------------------------
60dnl Set up variable with list of headers that must be
61dnl included when fcntl.h is to be included.
62
63AC_DEFUN([CURL_INCLUDES_FCNTL], [
64curl_includes_fcntl="\
65/* includes start */
66#ifdef HAVE_SYS_TYPES_H
67#  include <sys/types.h>
68#endif
69#ifdef HAVE_UNISTD_H
70#  include <unistd.h>
71#endif
72#ifdef HAVE_FCNTL_H
73#  include <fcntl.h>
74#endif
75/* includes end */"
76  AC_CHECK_HEADERS(
77    sys/types.h unistd.h fcntl.h,
78    [], [], [$curl_includes_fcntl])
79])
80
81
82dnl CURL_INCLUDES_IFADDRS
83dnl -------------------------------------------------
84dnl Set up variable with list of headers that must be
85dnl included when ifaddrs.h is to be included.
86
87AC_DEFUN([CURL_INCLUDES_IFADDRS], [
88curl_includes_ifaddrs="\
89/* includes start */
90#ifdef HAVE_SYS_TYPES_H
91#  include <sys/types.h>
92#endif
93#ifdef HAVE_SYS_SOCKET_H
94#  include <sys/socket.h>
95#endif
96#ifdef HAVE_NETINET_IN_H
97#  include <netinet/in.h>
98#endif
99#ifdef HAVE_IFADDRS_H
100#  include <ifaddrs.h>
101#endif
102/* includes end */"
103  AC_CHECK_HEADERS(
104    sys/types.h sys/socket.h netinet/in.h ifaddrs.h,
105    [], [], [$curl_includes_ifaddrs])
106])
107
108
109dnl CURL_INCLUDES_INTTYPES
110dnl -------------------------------------------------
111dnl Set up variable with list of headers that must be
112dnl included when inttypes.h is to be included.
113
114AC_DEFUN([CURL_INCLUDES_INTTYPES], [
115curl_includes_inttypes="\
116/* includes start */
117#ifdef HAVE_SYS_TYPES_H
118# include <sys/types.h>
119#endif
120#ifdef HAVE_STDINT_H
121# include <stdint.h>
122#endif
123#ifdef HAVE_INTTYPES_H
124# include <inttypes.h>
125#endif
126/* includes end */"
127  case $host_os in
128    irix*)
129      ac_cv_header_stdint_h="no"
130      ;;
131  esac
132  AC_CHECK_HEADERS(
133    sys/types.h stdint.h inttypes.h,
134    [], [], [$curl_includes_inttypes])
135])
136
137
138dnl CURL_INCLUDES_LIBGEN
139dnl -------------------------------------------------
140dnl Set up variable with list of headers that must be
141dnl included when libgen.h is to be included.
142
143AC_DEFUN([CURL_INCLUDES_LIBGEN], [
144curl_includes_libgen="\
145/* includes start */
146#ifdef HAVE_SYS_TYPES_H
147#  include <sys/types.h>
148#endif
149#ifdef HAVE_LIBGEN_H
150#  include <libgen.h>
151#endif
152/* includes end */"
153  AC_CHECK_HEADERS(
154    sys/types.h libgen.h,
155    [], [], [$curl_includes_libgen])
156])
157
158
159dnl CURL_INCLUDES_NETDB
160dnl -------------------------------------------------
161dnl Set up variable with list of headers that must be
162dnl included when netdb.h is to be included.
163
164AC_DEFUN([CURL_INCLUDES_NETDB], [
165curl_includes_netdb="\
166/* includes start */
167#ifdef HAVE_SYS_TYPES_H
168#  include <sys/types.h>
169#endif
170#ifdef HAVE_NETDB_H
171#  include <netdb.h>
172#endif
173/* includes end */"
174  AC_CHECK_HEADERS(
175    sys/types.h netdb.h,
176    [], [], [$curl_includes_netdb])
177])
178
179
180dnl CURL_INCLUDES_POLL
181dnl -------------------------------------------------
182dnl Set up variable with list of headers that must be
183dnl included when poll.h is to be included.
184
185AC_DEFUN([CURL_INCLUDES_POLL], [
186curl_includes_poll="\
187/* includes start */
188#ifdef HAVE_SYS_TYPES_H
189#  include <sys/types.h>
190#endif
191#ifdef HAVE_POLL_H
192#  include <poll.h>
193#endif
194#ifdef HAVE_SYS_POLL_H
195#  include <sys/poll.h>
196#endif
197/* includes end */"
198  AC_CHECK_HEADERS(
199    sys/types.h poll.h sys/poll.h,
200    [], [], [$curl_includes_poll])
201])
202
203
204dnl CURL_INCLUDES_SETJMP
205dnl -------------------------------------------------
206dnl Set up variable with list of headers that must be
207dnl included when setjmp.h is to be included.
208
209AC_DEFUN([CURL_INCLUDES_SETJMP], [
210curl_includes_setjmp="\
211/* includes start */
212#ifdef HAVE_SYS_TYPES_H
213#  include <sys/types.h>
214#endif
215#ifdef HAVE_SETJMP_H
216#  include <setjmp.h>
217#endif
218/* includes end */"
219  AC_CHECK_HEADERS(
220    sys/types.h setjmp.h,
221    [], [], [$curl_includes_setjmp])
222])
223
224
225dnl CURL_INCLUDES_SIGNAL
226dnl -------------------------------------------------
227dnl Set up variable with list of headers that must be
228dnl included when signal.h is to be included.
229
230AC_DEFUN([CURL_INCLUDES_SIGNAL], [
231curl_includes_signal="\
232/* includes start */
233#ifdef HAVE_SYS_TYPES_H
234#  include <sys/types.h>
235#endif
236#ifdef HAVE_SIGNAL_H
237#  include <signal.h>
238#endif
239/* includes end */"
240  AC_CHECK_HEADERS(
241    sys/types.h signal.h,
242    [], [], [$curl_includes_signal])
243])
244
245
246dnl CURL_INCLUDES_SOCKET
247dnl -------------------------------------------------
248dnl Set up variable with list of headers that must be
249dnl included when socket.h is to be included.
250
251AC_DEFUN([CURL_INCLUDES_SOCKET], [
252curl_includes_socket="\
253/* includes start */
254#ifdef HAVE_SYS_TYPES_H
255#  include <sys/types.h>
256#endif
257#ifdef HAVE_SOCKET_H
258#  include <socket.h>
259#endif
260/* includes end */"
261  AC_CHECK_HEADERS(
262    sys/types.h socket.h,
263    [], [], [$curl_includes_socket])
264])
265
266
267dnl CURL_INCLUDES_STDIO
268dnl -------------------------------------------------
269dnl Set up variable with list of headers that must be
270dnl included when stdio.h is to be included.
271
272AC_DEFUN([CURL_INCLUDES_STDIO], [
273curl_includes_stdio="\
274/* includes start */
275#ifdef HAVE_SYS_TYPES_H
276#  include <sys/types.h>
277#endif
278#ifdef HAVE_STDIO_H
279#  include <stdio.h>
280#endif
281/* includes end */"
282  AC_CHECK_HEADERS(
283    sys/types.h stdio.h,
284    [], [], [$curl_includes_stdio])
285])
286
287
288dnl CURL_INCLUDES_STDLIB
289dnl -------------------------------------------------
290dnl Set up variable with list of headers that must be
291dnl included when stdlib.h is to be included.
292
293AC_DEFUN([CURL_INCLUDES_STDLIB], [
294curl_includes_stdlib="\
295/* includes start */
296#ifdef HAVE_SYS_TYPES_H
297#  include <sys/types.h>
298#endif
299#ifdef HAVE_STDLIB_H
300#  include <stdlib.h>
301#endif
302/* includes end */"
303  AC_CHECK_HEADERS(
304    sys/types.h stdlib.h,
305    [], [], [$curl_includes_stdlib])
306])
307
308
309dnl CURL_INCLUDES_STRING
310dnl -------------------------------------------------
311dnl Set up variable with list of headers that must be
312dnl included when string(s).h is to be included.
313
314AC_DEFUN([CURL_INCLUDES_STRING], [
315curl_includes_string="\
316/* includes start */
317#ifdef HAVE_SYS_TYPES_H
318#  include <sys/types.h>
319#endif
320#ifdef HAVE_STRING_H
321#  include <string.h>
322#endif
323#ifdef HAVE_STRINGS_H
324#  include <strings.h>
325#endif
326/* includes end */"
327  AC_CHECK_HEADERS(
328    sys/types.h string.h strings.h,
329    [], [], [$curl_includes_string])
330])
331
332
333dnl CURL_INCLUDES_STROPTS
334dnl -------------------------------------------------
335dnl Set up variable with list of headers that must be
336dnl included when stropts.h is to be included.
337
338AC_DEFUN([CURL_INCLUDES_STROPTS], [
339curl_includes_stropts="\
340/* includes start */
341#ifdef HAVE_SYS_TYPES_H
342#  include <sys/types.h>
343#endif
344#ifdef HAVE_UNISTD_H
345#  include <unistd.h>
346#endif
347#ifdef HAVE_SYS_SOCKET_H
348#  include <sys/socket.h>
349#endif
350#ifdef HAVE_SYS_IOCTL_H
351#  include <sys/ioctl.h>
352#endif
353#ifdef HAVE_STROPTS_H
354#  include <stropts.h>
355#endif
356/* includes end */"
357  AC_CHECK_HEADERS(
358    sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h,
359    [], [], [$curl_includes_stropts])
360])
361
362
363dnl CURL_INCLUDES_SYS_SOCKET
364dnl -------------------------------------------------
365dnl Set up variable with list of headers that must be
366dnl included when sys/socket.h is to be included.
367
368AC_DEFUN([CURL_INCLUDES_SYS_SOCKET], [
369curl_includes_sys_socket="\
370/* includes start */
371#ifdef HAVE_SYS_TYPES_H
372#  include <sys/types.h>
373#endif
374#ifdef HAVE_SYS_SOCKET_H
375#  include <sys/socket.h>
376#endif
377/* includes end */"
378  AC_CHECK_HEADERS(
379    sys/types.h sys/socket.h,
380    [], [], [$curl_includes_sys_socket])
381])
382
383
384dnl CURL_INCLUDES_SYS_TYPES
385dnl -------------------------------------------------
386dnl Set up variable with list of headers that must be
387dnl included when sys/types.h is to be included.
388
389AC_DEFUN([CURL_INCLUDES_SYS_TYPES], [
390curl_includes_sys_types="\
391/* includes start */
392#ifdef HAVE_SYS_TYPES_H
393#  include <sys/types.h>
394#endif
395/* includes end */"
396  AC_CHECK_HEADERS(
397    sys/types.h,
398    [], [], [$curl_includes_sys_types])
399])
400
401
402dnl CURL_INCLUDES_SYS_UIO
403dnl -------------------------------------------------
404dnl Set up variable with list of headers that must be
405dnl included when sys/uio.h is to be included.
406
407AC_DEFUN([CURL_INCLUDES_SYS_UIO], [
408curl_includes_sys_uio="\
409/* includes start */
410#ifdef HAVE_SYS_TYPES_H
411#  include <sys/types.h>
412#endif
413#ifdef HAVE_SYS_UIO_H
414#  include <sys/uio.h>
415#endif
416/* includes end */"
417  AC_CHECK_HEADERS(
418    sys/types.h sys/uio.h,
419    [], [], [$curl_includes_sys_uio])
420])
421
422
423dnl CURL_INCLUDES_SYS_XATTR
424dnl -------------------------------------------------
425dnl Set up variable with list of headers that must be
426dnl included when sys/xattr.h is to be included.
427
428AC_DEFUN([CURL_INCLUDES_SYS_XATTR], [
429curl_includes_sys_xattr="\
430/* includes start */
431#ifdef HAVE_SYS_TYPES_H
432#  include <sys/types.h>
433#endif
434#ifdef HAVE_SYS_XATTR_H
435#  include <sys/xattr.h>
436#endif
437/* includes end */"
438  AC_CHECK_HEADERS(
439    sys/types.h sys/xattr.h,
440    [], [], [$curl_includes_sys_xattr])
441])
442
443dnl CURL_INCLUDES_TIME
444dnl -------------------------------------------------
445dnl Set up variable with list of headers that must be
446dnl included when time.h is to be included.
447
448AC_DEFUN([CURL_INCLUDES_TIME], [
449AC_REQUIRE([AC_HEADER_TIME])dnl
450curl_includes_time="\
451/* includes start */
452#ifdef HAVE_SYS_TYPES_H
453#  include <sys/types.h>
454#endif
455#ifdef HAVE_SYS_TIME_H
456#  include <sys/time.h>
457#  ifdef TIME_WITH_SYS_TIME
458#    include <time.h>
459#  endif
460#else
461#  ifdef HAVE_TIME_H
462#    include <time.h>
463#  endif
464#endif
465/* includes end */"
466  AC_CHECK_HEADERS(
467    sys/types.h sys/time.h time.h,
468    [], [], [$curl_includes_time])
469])
470
471
472dnl CURL_INCLUDES_UNISTD
473dnl -------------------------------------------------
474dnl Set up variable with list of headers that must be
475dnl included when unistd.h is to be included.
476
477AC_DEFUN([CURL_INCLUDES_UNISTD], [
478curl_includes_unistd="\
479/* includes start */
480#ifdef HAVE_SYS_TYPES_H
481#  include <sys/types.h>
482#endif
483#ifdef HAVE_UNISTD_H
484#  include <unistd.h>
485#endif
486/* includes end */"
487  AC_CHECK_HEADERS(
488    sys/types.h unistd.h,
489    [], [], [$curl_includes_unistd])
490])
491
492
493dnl CURL_INCLUDES_WINSOCK2
494dnl -------------------------------------------------
495dnl Set up variable with list of headers that must be
496dnl included when winsock(2).h is to be included.
497
498AC_DEFUN([CURL_INCLUDES_WINSOCK2], [
499curl_includes_winsock2="\
500/* includes start */
501#ifdef HAVE_WINDOWS_H
502#  ifndef WIN32_LEAN_AND_MEAN
503#    define WIN32_LEAN_AND_MEAN
504#  endif
505#  include <windows.h>
506#  ifdef HAVE_WINSOCK2_H
507#    include <winsock2.h>
508#  else
509#    ifdef HAVE_WINSOCK_H
510#      include <winsock.h>
511#    endif
512#  endif
513#endif
514/* includes end */"
515  CURL_CHECK_HEADER_WINDOWS
516  CURL_CHECK_HEADER_WINSOCK
517  CURL_CHECK_HEADER_WINSOCK2
518])
519
520
521dnl CURL_INCLUDES_WS2TCPIP
522dnl -------------------------------------------------
523dnl Set up variable with list of headers that must be
524dnl included when ws2tcpip.h is to be included.
525
526AC_DEFUN([CURL_INCLUDES_WS2TCPIP], [
527curl_includes_ws2tcpip="\
528/* includes start */
529#ifdef HAVE_WINDOWS_H
530#  ifndef WIN32_LEAN_AND_MEAN
531#    define WIN32_LEAN_AND_MEAN
532#  endif
533#  include <windows.h>
534#  ifdef HAVE_WINSOCK2_H
535#    include <winsock2.h>
536#    ifdef HAVE_WS2TCPIP_H
537#       include <ws2tcpip.h>
538#    endif
539#  endif
540#endif
541/* includes end */"
542  CURL_CHECK_HEADER_WINDOWS
543  CURL_CHECK_HEADER_WINSOCK2
544  CURL_CHECK_HEADER_WS2TCPIP
545])
546
547
548dnl CURL_INCLUDES_BSDSOCKET
549dnl -------------------------------------------------
550dnl Set up variable with list of headers that must be
551dnl included when bsdsocket.h is to be included.
552
553AC_DEFUN([CURL_INCLUDES_BSDSOCKET], [
554curl_includes_bsdsocket="\
555/* includes start */
556#ifdef HAVE_PROTO_BSDSOCKET_H
557#  include <proto/bsdsocket.h>
558  struct Library *SocketBase = NULL;
559#endif
560/* includes end */"
561  AC_CHECK_HEADERS(
562    proto/bsdsocket.h,
563    [], [], [      $curl_includes_bsdsocket])
564])
565
566dnl CURL_INCLUDES_NETIF
567dnl -------------------------------------------------
568dnl Set up variable with list of headers that must be
569dnl included when net/if.h is to be included.
570
571AC_DEFUN([CURL_INCLUDES_NETIF], [
572curl_includes_netif="\
573/* includes start */
574#ifdef HAVE_NET_IF_H
575#  include <net/if.h>
576#endif
577/* includes end */"
578  AC_CHECK_HEADERS(
579    net/if.h,
580    [], [], [$curl_includes_netif])
581])
582
583
584dnl CURL_PREPROCESS_CALLCONV
585dnl -------------------------------------------------
586dnl Set up variable with a preprocessor block which
587dnl defines function calling convention.
588
589AC_DEFUN([CURL_PREPROCESS_CALLCONV], [
590curl_preprocess_callconv="\
591/* preprocess start */
592#ifdef HAVE_WINDOWS_H
593#  define FUNCALLCONV __stdcall
594#else
595#  define FUNCALLCONV
596#endif
597/* preprocess end */"
598])
599
600
601dnl CURL_CHECK_FUNC_ALARM
602dnl -------------------------------------------------
603dnl Verify if alarm is available, prototyped, and
604dnl can be compiled. If all of these are true, and
605dnl usage has not been previously disallowed with
606dnl shell variable curl_disallow_alarm, then
607dnl HAVE_ALARM will be defined.
608
609AC_DEFUN([CURL_CHECK_FUNC_ALARM], [
610  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
611  #
612  tst_links_alarm="unknown"
613  tst_proto_alarm="unknown"
614  tst_compi_alarm="unknown"
615  tst_allow_alarm="unknown"
616  #
617  AC_MSG_CHECKING([if alarm can be linked])
618  AC_LINK_IFELSE([
619    AC_LANG_FUNC_LINK_TRY([alarm])
620  ],[
621    AC_MSG_RESULT([yes])
622    tst_links_alarm="yes"
623  ],[
624    AC_MSG_RESULT([no])
625    tst_links_alarm="no"
626  ])
627  #
628  if test "$tst_links_alarm" = "yes"; then
629    AC_MSG_CHECKING([if alarm is prototyped])
630    AC_EGREP_CPP([alarm],[
631      $curl_includes_unistd
632    ],[
633      AC_MSG_RESULT([yes])
634      tst_proto_alarm="yes"
635    ],[
636      AC_MSG_RESULT([no])
637      tst_proto_alarm="no"
638    ])
639  fi
640  #
641  if test "$tst_proto_alarm" = "yes"; then
642    AC_MSG_CHECKING([if alarm is compilable])
643    AC_COMPILE_IFELSE([
644      AC_LANG_PROGRAM([[
645        $curl_includes_unistd
646      ]],[[
647        if(0 != alarm(0))
648          return 1;
649      ]])
650    ],[
651      AC_MSG_RESULT([yes])
652      tst_compi_alarm="yes"
653    ],[
654      AC_MSG_RESULT([no])
655      tst_compi_alarm="no"
656    ])
657  fi
658  #
659  if test "$tst_compi_alarm" = "yes"; then
660    AC_MSG_CHECKING([if alarm usage allowed])
661    if test "x$curl_disallow_alarm" != "xyes"; then
662      AC_MSG_RESULT([yes])
663      tst_allow_alarm="yes"
664    else
665      AC_MSG_RESULT([no])
666      tst_allow_alarm="no"
667    fi
668  fi
669  #
670  AC_MSG_CHECKING([if alarm might be used])
671  if test "$tst_links_alarm" = "yes" &&
672     test "$tst_proto_alarm" = "yes" &&
673     test "$tst_compi_alarm" = "yes" &&
674     test "$tst_allow_alarm" = "yes"; then
675    AC_MSG_RESULT([yes])
676    AC_DEFINE_UNQUOTED(HAVE_ALARM, 1,
677      [Define to 1 if you have the alarm function.])
678    curl_cv_func_alarm="yes"
679  else
680    AC_MSG_RESULT([no])
681    curl_cv_func_alarm="no"
682  fi
683])
684
685
686dnl CURL_CHECK_FUNC_BASENAME
687dnl -------------------------------------------------
688dnl Verify if basename is available, prototyped, and
689dnl can be compiled. If all of these are true, and
690dnl usage has not been previously disallowed with
691dnl shell variable curl_disallow_basename, then
692dnl HAVE_BASENAME will be defined.
693
694AC_DEFUN([CURL_CHECK_FUNC_BASENAME], [
695  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
696  AC_REQUIRE([CURL_INCLUDES_LIBGEN])dnl
697  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
698  #
699  tst_links_basename="unknown"
700  tst_proto_basename="unknown"
701  tst_compi_basename="unknown"
702  tst_allow_basename="unknown"
703  #
704  AC_MSG_CHECKING([if basename can be linked])
705  AC_LINK_IFELSE([
706    AC_LANG_FUNC_LINK_TRY([basename])
707  ],[
708    AC_MSG_RESULT([yes])
709    tst_links_basename="yes"
710  ],[
711    AC_MSG_RESULT([no])
712    tst_links_basename="no"
713  ])
714  #
715  if test "$tst_links_basename" = "yes"; then
716    AC_MSG_CHECKING([if basename is prototyped])
717    AC_EGREP_CPP([basename],[
718      $curl_includes_string
719      $curl_includes_libgen
720      $curl_includes_unistd
721    ],[
722      AC_MSG_RESULT([yes])
723      tst_proto_basename="yes"
724    ],[
725      AC_MSG_RESULT([no])
726      tst_proto_basename="no"
727    ])
728  fi
729  #
730  if test "$tst_proto_basename" = "yes"; then
731    AC_MSG_CHECKING([if basename is compilable])
732    AC_COMPILE_IFELSE([
733      AC_LANG_PROGRAM([[
734        $curl_includes_string
735        $curl_includes_libgen
736        $curl_includes_unistd
737      ]],[[
738        if(0 != basename(0))
739          return 1;
740      ]])
741    ],[
742      AC_MSG_RESULT([yes])
743      tst_compi_basename="yes"
744    ],[
745      AC_MSG_RESULT([no])
746      tst_compi_basename="no"
747    ])
748  fi
749  #
750  if test "$tst_compi_basename" = "yes"; then
751    AC_MSG_CHECKING([if basename usage allowed])
752    if test "x$curl_disallow_basename" != "xyes"; then
753      AC_MSG_RESULT([yes])
754      tst_allow_basename="yes"
755    else
756      AC_MSG_RESULT([no])
757      tst_allow_basename="no"
758    fi
759  fi
760  #
761  AC_MSG_CHECKING([if basename might be used])
762  if test "$tst_links_basename" = "yes" &&
763     test "$tst_proto_basename" = "yes" &&
764     test "$tst_compi_basename" = "yes" &&
765     test "$tst_allow_basename" = "yes"; then
766    AC_MSG_RESULT([yes])
767    AC_DEFINE_UNQUOTED(HAVE_BASENAME, 1,
768      [Define to 1 if you have the basename function.])
769    curl_cv_func_basename="yes"
770  else
771    AC_MSG_RESULT([no])
772    curl_cv_func_basename="no"
773  fi
774])
775
776
777dnl CURL_CHECK_FUNC_CLOSESOCKET
778dnl -------------------------------------------------
779dnl Verify if closesocket is available, prototyped, and
780dnl can be compiled. If all of these are true, and
781dnl usage has not been previously disallowed with
782dnl shell variable curl_disallow_closesocket, then
783dnl HAVE_CLOSESOCKET will be defined.
784
785AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET], [
786  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
787  AC_REQUIRE([CURL_INCLUDES_SOCKET])dnl
788  #
789  tst_links_closesocket="unknown"
790  tst_proto_closesocket="unknown"
791  tst_compi_closesocket="unknown"
792  tst_allow_closesocket="unknown"
793  #
794  AC_MSG_CHECKING([if closesocket can be linked])
795  AC_LINK_IFELSE([
796    AC_LANG_PROGRAM([[
797      $curl_includes_winsock2
798      $curl_includes_bsdsocket
799      $curl_includes_socket
800    ]],[[
801      if(0 != closesocket(0))
802        return 1;
803    ]])
804  ],[
805    AC_MSG_RESULT([yes])
806    tst_links_closesocket="yes"
807  ],[
808    AC_MSG_RESULT([no])
809    tst_links_closesocket="no"
810  ])
811  #
812  if test "$tst_links_closesocket" = "yes"; then
813    AC_MSG_CHECKING([if closesocket is prototyped])
814    AC_EGREP_CPP([closesocket],[
815      $curl_includes_winsock2
816      $curl_includes_bsdsocket
817      $curl_includes_socket
818    ],[
819      AC_MSG_RESULT([yes])
820      tst_proto_closesocket="yes"
821    ],[
822      AC_MSG_RESULT([no])
823      tst_proto_closesocket="no"
824    ])
825  fi
826  #
827  if test "$tst_proto_closesocket" = "yes"; then
828    AC_MSG_CHECKING([if closesocket is compilable])
829    AC_COMPILE_IFELSE([
830      AC_LANG_PROGRAM([[
831        $curl_includes_winsock2
832      $curl_includes_bsdsocket
833        $curl_includes_socket
834      ]],[[
835        if(0 != closesocket(0))
836          return 1;
837      ]])
838    ],[
839      AC_MSG_RESULT([yes])
840      tst_compi_closesocket="yes"
841    ],[
842      AC_MSG_RESULT([no])
843      tst_compi_closesocket="no"
844    ])
845  fi
846  #
847  if test "$tst_compi_closesocket" = "yes"; then
848    AC_MSG_CHECKING([if closesocket usage allowed])
849    if test "x$curl_disallow_closesocket" != "xyes"; then
850      AC_MSG_RESULT([yes])
851      tst_allow_closesocket="yes"
852    else
853      AC_MSG_RESULT([no])
854      tst_allow_closesocket="no"
855    fi
856  fi
857  #
858  AC_MSG_CHECKING([if closesocket might be used])
859  if test "$tst_links_closesocket" = "yes" &&
860     test "$tst_proto_closesocket" = "yes" &&
861     test "$tst_compi_closesocket" = "yes" &&
862     test "$tst_allow_closesocket" = "yes"; then
863    AC_MSG_RESULT([yes])
864    AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET, 1,
865      [Define to 1 if you have the closesocket function.])
866    curl_cv_func_closesocket="yes"
867  else
868    AC_MSG_RESULT([no])
869    curl_cv_func_closesocket="no"
870  fi
871])
872
873
874dnl CURL_CHECK_FUNC_CLOSESOCKET_CAMEL
875dnl -------------------------------------------------
876dnl Verify if CloseSocket is available, prototyped, and
877dnl can be compiled. If all of these are true, and
878dnl usage has not been previously disallowed with
879dnl shell variable curl_disallow_closesocket_camel,
880dnl then HAVE_CLOSESOCKET_CAMEL will be defined.
881
882AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET_CAMEL], [
883  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
884  #
885  tst_links_closesocket_camel="unknown"
886  tst_proto_closesocket_camel="unknown"
887  tst_compi_closesocket_camel="unknown"
888  tst_allow_closesocket_camel="unknown"
889  #
890  AC_MSG_CHECKING([if CloseSocket can be linked])
891  AC_LINK_IFELSE([
892    AC_LANG_PROGRAM([[
893      $curl_includes_sys_socket
894    ]],[[
895      if(0 != CloseSocket(0))
896        return 1;
897    ]])
898  ],[
899    AC_MSG_RESULT([yes])
900    tst_links_closesocket_camel="yes"
901  ],[
902    AC_MSG_RESULT([no])
903    tst_links_closesocket_camel="no"
904  ])
905  #
906  if test "$tst_links_closesocket_camel" = "yes"; then
907    AC_MSG_CHECKING([if CloseSocket is prototyped])
908    AC_EGREP_CPP([CloseSocket],[
909      $curl_includes_sys_socket
910    ],[
911      AC_MSG_RESULT([yes])
912      tst_proto_closesocket_camel="yes"
913    ],[
914      AC_MSG_RESULT([no])
915      tst_proto_closesocket_camel="no"
916    ])
917  fi
918  #
919  if test "$tst_proto_closesocket_camel" = "yes"; then
920    AC_MSG_CHECKING([if CloseSocket is compilable])
921    AC_COMPILE_IFELSE([
922      AC_LANG_PROGRAM([[
923        $curl_includes_sys_socket
924      ]],[[
925        if(0 != CloseSocket(0))
926          return 1;
927      ]])
928    ],[
929      AC_MSG_RESULT([yes])
930      tst_compi_closesocket_camel="yes"
931    ],[
932      AC_MSG_RESULT([no])
933      tst_compi_closesocket_camel="no"
934    ])
935  fi
936  #
937  if test "$tst_compi_closesocket_camel" = "yes"; then
938    AC_MSG_CHECKING([if CloseSocket usage allowed])
939    if test "x$curl_disallow_closesocket_camel" != "xyes"; then
940      AC_MSG_RESULT([yes])
941      tst_allow_closesocket_camel="yes"
942    else
943      AC_MSG_RESULT([no])
944      tst_allow_closesocket_camel="no"
945    fi
946  fi
947  #
948  AC_MSG_CHECKING([if CloseSocket might be used])
949  if test "$tst_links_closesocket_camel" = "yes" &&
950     test "$tst_proto_closesocket_camel" = "yes" &&
951     test "$tst_compi_closesocket_camel" = "yes" &&
952     test "$tst_allow_closesocket_camel" = "yes"; then
953    AC_MSG_RESULT([yes])
954    AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET_CAMEL, 1,
955      [Define to 1 if you have the CloseSocket camel case function.])
956    curl_cv_func_closesocket_camel="yes"
957  else
958    AC_MSG_RESULT([no])
959    curl_cv_func_closesocket_camel="no"
960  fi
961])
962
963
964dnl CURL_CHECK_FUNC_CONNECT
965dnl -------------------------------------------------
966dnl Verify if connect is available, prototyped, and
967dnl can be compiled. If all of these are true, and
968dnl usage has not been previously disallowed with
969dnl shell variable curl_disallow_connect, then
970dnl HAVE_CONNECT will be defined.
971
972AC_DEFUN([CURL_CHECK_FUNC_CONNECT], [
973  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
974  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
975  AC_REQUIRE([CURL_INCLUDES_SOCKET])dnl
976  #
977  tst_links_connect="unknown"
978  tst_proto_connect="unknown"
979  tst_compi_connect="unknown"
980  tst_allow_connect="unknown"
981  #
982  AC_MSG_CHECKING([if connect can be linked])
983  AC_LINK_IFELSE([
984    AC_LANG_PROGRAM([[
985      $curl_includes_winsock2
986      $curl_includes_bsdsocket
987      $curl_includes_sys_socket
988      $curl_includes_socket
989    ]],[[
990      if(0 != connect(0, 0, 0))
991        return 1;
992    ]])
993  ],[
994    AC_MSG_RESULT([yes])
995    tst_links_connect="yes"
996  ],[
997    AC_MSG_RESULT([no])
998    tst_links_connect="no"
999  ])
1000  #
1001  if test "$tst_links_connect" = "yes"; then
1002    AC_MSG_CHECKING([if connect is prototyped])
1003    AC_EGREP_CPP([connect],[
1004      $curl_includes_winsock2
1005      $curl_includes_bsdsocket
1006      $curl_includes_sys_socket
1007      $curl_includes_socket
1008    ],[
1009      AC_MSG_RESULT([yes])
1010      tst_proto_connect="yes"
1011    ],[
1012      AC_MSG_RESULT([no])
1013      tst_proto_connect="no"
1014    ])
1015  fi
1016  #
1017  if test "$tst_proto_connect" = "yes"; then
1018    AC_MSG_CHECKING([if connect is compilable])
1019    AC_COMPILE_IFELSE([
1020      AC_LANG_PROGRAM([[
1021        $curl_includes_winsock2
1022      $curl_includes_bsdsocket
1023        $curl_includes_sys_socket
1024        $curl_includes_socket
1025      ]],[[
1026        if(0 != connect(0, 0, 0))
1027          return 1;
1028      ]])
1029    ],[
1030      AC_MSG_RESULT([yes])
1031      tst_compi_connect="yes"
1032    ],[
1033      AC_MSG_RESULT([no])
1034      tst_compi_connect="no"
1035    ])
1036  fi
1037  #
1038  if test "$tst_compi_connect" = "yes"; then
1039    AC_MSG_CHECKING([if connect usage allowed])
1040    if test "x$curl_disallow_connect" != "xyes"; then
1041      AC_MSG_RESULT([yes])
1042      tst_allow_connect="yes"
1043    else
1044      AC_MSG_RESULT([no])
1045      tst_allow_connect="no"
1046    fi
1047  fi
1048  #
1049  AC_MSG_CHECKING([if connect might be used])
1050  if test "$tst_links_connect" = "yes" &&
1051     test "$tst_proto_connect" = "yes" &&
1052     test "$tst_compi_connect" = "yes" &&
1053     test "$tst_allow_connect" = "yes"; then
1054    AC_MSG_RESULT([yes])
1055    AC_DEFINE_UNQUOTED(HAVE_CONNECT, 1,
1056      [Define to 1 if you have the connect function.])
1057    curl_cv_func_connect="yes"
1058  else
1059    AC_MSG_RESULT([no])
1060    curl_cv_func_connect="no"
1061  fi
1062])
1063
1064
1065dnl CURL_CHECK_FUNC_FCNTL
1066dnl -------------------------------------------------
1067dnl Verify if fcntl is available, prototyped, and
1068dnl can be compiled. If all of these are true, and
1069dnl usage has not been previously disallowed with
1070dnl shell variable curl_disallow_fcntl, then
1071dnl HAVE_FCNTL will be defined.
1072
1073AC_DEFUN([CURL_CHECK_FUNC_FCNTL], [
1074  AC_REQUIRE([CURL_INCLUDES_FCNTL])dnl
1075  #
1076  tst_links_fcntl="unknown"
1077  tst_proto_fcntl="unknown"
1078  tst_compi_fcntl="unknown"
1079  tst_allow_fcntl="unknown"
1080  #
1081  AC_MSG_CHECKING([if fcntl can be linked])
1082  AC_LINK_IFELSE([
1083    AC_LANG_FUNC_LINK_TRY([fcntl])
1084  ],[
1085    AC_MSG_RESULT([yes])
1086    tst_links_fcntl="yes"
1087  ],[
1088    AC_MSG_RESULT([no])
1089    tst_links_fcntl="no"
1090  ])
1091  #
1092  if test "$tst_links_fcntl" = "yes"; then
1093    AC_MSG_CHECKING([if fcntl is prototyped])
1094    AC_EGREP_CPP([fcntl],[
1095      $curl_includes_fcntl
1096    ],[
1097      AC_MSG_RESULT([yes])
1098      tst_proto_fcntl="yes"
1099    ],[
1100      AC_MSG_RESULT([no])
1101      tst_proto_fcntl="no"
1102    ])
1103  fi
1104  #
1105  if test "$tst_proto_fcntl" = "yes"; then
1106    AC_MSG_CHECKING([if fcntl is compilable])
1107    AC_COMPILE_IFELSE([
1108      AC_LANG_PROGRAM([[
1109        $curl_includes_fcntl
1110      ]],[[
1111        if(0 != fcntl(0, 0, 0))
1112          return 1;
1113      ]])
1114    ],[
1115      AC_MSG_RESULT([yes])
1116      tst_compi_fcntl="yes"
1117    ],[
1118      AC_MSG_RESULT([no])
1119      tst_compi_fcntl="no"
1120    ])
1121  fi
1122  #
1123  if test "$tst_compi_fcntl" = "yes"; then
1124    AC_MSG_CHECKING([if fcntl usage allowed])
1125    if test "x$curl_disallow_fcntl" != "xyes"; then
1126      AC_MSG_RESULT([yes])
1127      tst_allow_fcntl="yes"
1128    else
1129      AC_MSG_RESULT([no])
1130      tst_allow_fcntl="no"
1131    fi
1132  fi
1133  #
1134  AC_MSG_CHECKING([if fcntl might be used])
1135  if test "$tst_links_fcntl" = "yes" &&
1136     test "$tst_proto_fcntl" = "yes" &&
1137     test "$tst_compi_fcntl" = "yes" &&
1138     test "$tst_allow_fcntl" = "yes"; then
1139    AC_MSG_RESULT([yes])
1140    AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1,
1141      [Define to 1 if you have the fcntl function.])
1142    curl_cv_func_fcntl="yes"
1143    CURL_CHECK_FUNC_FCNTL_O_NONBLOCK
1144  else
1145    AC_MSG_RESULT([no])
1146    curl_cv_func_fcntl="no"
1147  fi
1148])
1149
1150
1151dnl CURL_CHECK_FUNC_FCNTL_O_NONBLOCK
1152dnl -------------------------------------------------
1153dnl Verify if fcntl with status flag O_NONBLOCK is
1154dnl available, can be compiled, and seems to work. If
1155dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK
1156dnl will be defined.
1157
1158AC_DEFUN([CURL_CHECK_FUNC_FCNTL_O_NONBLOCK], [
1159  #
1160  tst_compi_fcntl_o_nonblock="unknown"
1161  tst_allow_fcntl_o_nonblock="unknown"
1162  #
1163  case $host_os in
1164    sunos4* | aix3* | beos*)
1165      dnl O_NONBLOCK does not work on these platforms
1166      curl_disallow_fcntl_o_nonblock="yes"
1167      ;;
1168  esac
1169  #
1170  if test "$curl_cv_func_fcntl" = "yes"; then
1171    AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable])
1172    AC_COMPILE_IFELSE([
1173      AC_LANG_PROGRAM([[
1174        $curl_includes_fcntl
1175      ]],[[
1176        int flags = 0;
1177        if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
1178          return 1;
1179      ]])
1180    ],[
1181      AC_MSG_RESULT([yes])
1182      tst_compi_fcntl_o_nonblock="yes"
1183    ],[
1184      AC_MSG_RESULT([no])
1185      tst_compi_fcntl_o_nonblock="no"
1186    ])
1187  fi
1188  #
1189  if test "$tst_compi_fcntl_o_nonblock" = "yes"; then
1190    AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed])
1191    if test "x$curl_disallow_fcntl_o_nonblock" != "xyes"; then
1192      AC_MSG_RESULT([yes])
1193      tst_allow_fcntl_o_nonblock="yes"
1194    else
1195      AC_MSG_RESULT([no])
1196      tst_allow_fcntl_o_nonblock="no"
1197    fi
1198  fi
1199  #
1200  AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used])
1201  if test "$tst_compi_fcntl_o_nonblock" = "yes" &&
1202     test "$tst_allow_fcntl_o_nonblock" = "yes"; then
1203    AC_MSG_RESULT([yes])
1204    AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1,
1205      [Define to 1 if you have a working fcntl O_NONBLOCK function.])
1206    curl_cv_func_fcntl_o_nonblock="yes"
1207  else
1208    AC_MSG_RESULT([no])
1209    curl_cv_func_fcntl_o_nonblock="no"
1210  fi
1211])
1212
1213dnl CURL_CHECK_FUNC_FGETXATTR
1214dnl -------------------------------------------------
1215dnl Verify if fgetxattr is available, prototyped, and
1216dnl can be compiled. If all of these are true, and
1217dnl usage has not been previously disallowed with
1218dnl shell variable curl_disallow_fgetxattr, then
1219dnl HAVE_FGETXATTR will be defined.
1220
1221AC_DEFUN([CURL_CHECK_FUNC_FGETXATTR], [
1222  AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
1223  #
1224  tst_links_fgetxattr="unknown"
1225  tst_proto_fgetxattr="unknown"
1226  tst_compi_fgetxattr="unknown"
1227  tst_allow_fgetxattr="unknown"
1228  tst_nargs_fgetxattr="unknown"
1229  #
1230  AC_MSG_CHECKING([if fgetxattr can be linked])
1231  AC_LINK_IFELSE([
1232    AC_LANG_FUNC_LINK_TRY([fgetxattr])
1233  ],[
1234    AC_MSG_RESULT([yes])
1235    tst_links_fgetxattr="yes"
1236  ],[
1237    AC_MSG_RESULT([no])
1238    tst_links_fgetxattr="no"
1239  ])
1240  #
1241  if test "$tst_links_fgetxattr" = "yes"; then
1242    AC_MSG_CHECKING([if fgetxattr is prototyped])
1243    AC_EGREP_CPP([fgetxattr],[
1244      $curl_includes_sys_xattr
1245    ],[
1246      AC_MSG_RESULT([yes])
1247      tst_proto_fgetxattr="yes"
1248    ],[
1249      AC_MSG_RESULT([no])
1250      tst_proto_fgetxattr="no"
1251    ])
1252  fi
1253  #
1254  if test "$tst_proto_fgetxattr" = "yes"; then
1255    if test "$tst_nargs_fgetxattr" = "unknown"; then
1256      AC_MSG_CHECKING([if fgetxattr takes 4 args.])
1257      AC_COMPILE_IFELSE([
1258        AC_LANG_PROGRAM([[
1259          $curl_includes_sys_xattr
1260        ]],[[
1261          if(0 != fgetxattr(0, 0, 0, 0))
1262            return 1;
1263        ]])
1264      ],[
1265        AC_MSG_RESULT([yes])
1266        tst_compi_fgetxattr="yes"
1267        tst_nargs_fgetxattr="4"
1268      ],[
1269        AC_MSG_RESULT([no])
1270        tst_compi_fgetxattr="no"
1271      ])
1272    fi
1273    if test "$tst_nargs_fgetxattr" = "unknown"; then
1274      AC_MSG_CHECKING([if fgetxattr takes 6 args.])
1275      AC_COMPILE_IFELSE([
1276        AC_LANG_PROGRAM([[
1277          $curl_includes_sys_xattr
1278        ]],[[
1279          if(0 != fgetxattr(0, 0, 0, 0, 0, 0))
1280            return 1;
1281        ]])
1282      ],[
1283        AC_MSG_RESULT([yes])
1284        tst_compi_fgetxattr="yes"
1285        tst_nargs_fgetxattr="6"
1286      ],[
1287        AC_MSG_RESULT([no])
1288        tst_compi_fgetxattr="no"
1289      ])
1290    fi
1291    AC_MSG_CHECKING([if fgetxattr is compilable])
1292    if test "$tst_compi_fgetxattr" = "yes"; then
1293      AC_MSG_RESULT([yes])
1294    else
1295      AC_MSG_RESULT([no])
1296    fi
1297  fi
1298  #
1299  if test "$tst_compi_fgetxattr" = "yes"; then
1300    AC_MSG_CHECKING([if fgetxattr usage allowed])
1301    if test "x$curl_disallow_fgetxattr" != "xyes"; then
1302      AC_MSG_RESULT([yes])
1303      tst_allow_fgetxattr="yes"
1304    else
1305      AC_MSG_RESULT([no])
1306      tst_allow_fgetxattr="no"
1307    fi
1308  fi
1309  #
1310  AC_MSG_CHECKING([if fgetxattr might be used])
1311  if test "$tst_links_fgetxattr" = "yes" &&
1312     test "$tst_proto_fgetxattr" = "yes" &&
1313     test "$tst_compi_fgetxattr" = "yes" &&
1314     test "$tst_allow_fgetxattr" = "yes"; then
1315    AC_MSG_RESULT([yes])
1316    AC_DEFINE_UNQUOTED(HAVE_FGETXATTR, 1,
1317      [Define to 1 if you have the fgetxattr function.])
1318    dnl AC_DEFINE_UNQUOTED(FGETXATTR_ARGS, $tst_nargs_fgetxattr,
1319    dnl   [Specifies the number of arguments to fgetxattr])
1320    #
1321    if test "$tst_nargs_fgetxattr" -eq "4"; then
1322      AC_DEFINE(HAVE_FGETXATTR_4, 1, [fgetxattr() takes 4 args])
1323    elif test "$tst_nargs_fgetxattr" -eq "6"; then
1324      AC_DEFINE(HAVE_FGETXATTR_6, 1, [fgetxattr() takes 6 args])
1325    fi
1326    #
1327    curl_cv_func_fgetxattr="yes"
1328  else
1329    AC_MSG_RESULT([no])
1330    curl_cv_func_fgetxattr="no"
1331  fi
1332])
1333
1334
1335dnl CURL_CHECK_FUNC_FLISTXATTR
1336dnl -------------------------------------------------
1337dnl Verify if flistxattr is available, prototyped, and
1338dnl can be compiled. If all of these are true, and
1339dnl usage has not been previously disallowed with
1340dnl shell variable curl_disallow_flistxattr, then
1341dnl HAVE_FLISTXATTR will be defined.
1342
1343AC_DEFUN([CURL_CHECK_FUNC_FLISTXATTR], [
1344  AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
1345  #
1346  tst_links_flistxattr="unknown"
1347  tst_proto_flistxattr="unknown"
1348  tst_compi_flistxattr="unknown"
1349  tst_allow_flistxattr="unknown"
1350  tst_nargs_flistxattr="unknown"
1351  #
1352  AC_MSG_CHECKING([if flistxattr can be linked])
1353  AC_LINK_IFELSE([
1354    AC_LANG_FUNC_LINK_TRY([flistxattr])
1355  ],[
1356    AC_MSG_RESULT([yes])
1357    tst_links_flistxattr="yes"
1358  ],[
1359    AC_MSG_RESULT([no])
1360    tst_links_flistxattr="no"
1361  ])
1362  #
1363  if test "$tst_links_flistxattr" = "yes"; then
1364    AC_MSG_CHECKING([if flistxattr is prototyped])
1365    AC_EGREP_CPP([flistxattr],[
1366      $curl_includes_sys_xattr
1367    ],[
1368      AC_MSG_RESULT([yes])
1369      tst_proto_flistxattr="yes"
1370    ],[
1371      AC_MSG_RESULT([no])
1372      tst_proto_flistxattr="no"
1373    ])
1374  fi
1375  #
1376  if test "$tst_proto_flistxattr" = "yes"; then
1377    if test "$tst_nargs_flistxattr" = "unknown"; then
1378      AC_MSG_CHECKING([if flistxattr takes 3 args.])
1379      AC_COMPILE_IFELSE([
1380        AC_LANG_PROGRAM([[
1381          $curl_includes_sys_xattr
1382        ]],[[
1383          if(0 != flistxattr(0, 0, 0))
1384            return 1;
1385        ]])
1386      ],[
1387        AC_MSG_RESULT([yes])
1388        tst_compi_flistxattr="yes"
1389        tst_nargs_flistxattr="3"
1390      ],[
1391        AC_MSG_RESULT([no])
1392        tst_compi_flistxattr="no"
1393      ])
1394    fi
1395    if test "$tst_nargs_flistxattr" = "unknown"; then
1396      AC_MSG_CHECKING([if flistxattr takes 4 args.])
1397      AC_COMPILE_IFELSE([
1398        AC_LANG_PROGRAM([[
1399          $curl_includes_sys_xattr
1400        ]],[[
1401          if(0 != flistxattr(0, 0, 0, 0))
1402            return 1;
1403        ]])
1404      ],[
1405        AC_MSG_RESULT([yes])
1406        tst_compi_flistxattr="yes"
1407        tst_nargs_flistxattr="4"
1408      ],[
1409        AC_MSG_RESULT([no])
1410        tst_compi_flistxattr="no"
1411      ])
1412    fi
1413    AC_MSG_CHECKING([if flistxattr is compilable])
1414    if test "$tst_compi_flistxattr" = "yes"; then
1415      AC_MSG_RESULT([yes])
1416    else
1417      AC_MSG_RESULT([no])
1418    fi
1419  fi
1420  #
1421  if test "$tst_compi_flistxattr" = "yes"; then
1422    AC_MSG_CHECKING([if flistxattr usage allowed])
1423    if test "x$curl_disallow_flistxattr" != "xyes"; then
1424      AC_MSG_RESULT([yes])
1425      tst_allow_flistxattr="yes"
1426    else
1427      AC_MSG_RESULT([no])
1428      tst_allow_flistxattr="no"
1429    fi
1430  fi
1431  #
1432  AC_MSG_CHECKING([if flistxattr might be used])
1433  if test "$tst_links_flistxattr" = "yes" &&
1434     test "$tst_proto_flistxattr" = "yes" &&
1435     test "$tst_compi_flistxattr" = "yes" &&
1436     test "$tst_allow_flistxattr" = "yes"; then
1437    AC_MSG_RESULT([yes])
1438    AC_DEFINE_UNQUOTED(HAVE_FLISTXATTR, 1,
1439      [Define to 1 if you have the flistxattr function.])
1440    dnl AC_DEFINE_UNQUOTED(FLISTXATTR_ARGS, $tst_nargs_flistxattr,
1441    dnl   [Specifies the number of arguments to flistxattr])
1442    #
1443    if test "$tst_nargs_flistxattr" -eq "3"; then
1444      AC_DEFINE(HAVE_FLISTXATTR_3, 1, [flistxattr() takes 3 args])
1445    elif test "$tst_nargs_flistxattr" -eq "4"; then
1446      AC_DEFINE(HAVE_FLISTXATTR_4, 1, [flistxattr() takes 4 args])
1447    fi
1448    #
1449    curl_cv_func_flistxattr="yes"
1450  else
1451    AC_MSG_RESULT([no])
1452    curl_cv_func_flistxattr="no"
1453  fi
1454])
1455
1456
1457dnl CURL_CHECK_FUNC_FREEADDRINFO
1458dnl -------------------------------------------------
1459dnl Verify if freeaddrinfo is available, prototyped,
1460dnl and can be compiled. If all of these are true,
1461dnl and usage has not been previously disallowed with
1462dnl shell variable curl_disallow_freeaddrinfo, then
1463dnl HAVE_FREEADDRINFO will be defined.
1464
1465AC_DEFUN([CURL_CHECK_FUNC_FREEADDRINFO], [
1466  AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
1467  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
1468  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1469  #
1470  tst_links_freeaddrinfo="unknown"
1471  tst_proto_freeaddrinfo="unknown"
1472  tst_compi_freeaddrinfo="unknown"
1473  tst_allow_freeaddrinfo="unknown"
1474  #
1475  AC_MSG_CHECKING([if freeaddrinfo can be linked])
1476  AC_LINK_IFELSE([
1477    AC_LANG_PROGRAM([[
1478      $curl_includes_ws2tcpip
1479      $curl_includes_sys_socket
1480      $curl_includes_netdb
1481    ]],[[
1482      freeaddrinfo(0);
1483    ]])
1484  ],[
1485    AC_MSG_RESULT([yes])
1486    tst_links_freeaddrinfo="yes"
1487  ],[
1488    AC_MSG_RESULT([no])
1489    tst_links_freeaddrinfo="no"
1490  ])
1491  #
1492  if test "$tst_links_freeaddrinfo" = "yes"; then
1493    AC_MSG_CHECKING([if freeaddrinfo is prototyped])
1494    AC_EGREP_CPP([freeaddrinfo],[
1495      $curl_includes_ws2tcpip
1496      $curl_includes_sys_socket
1497      $curl_includes_netdb
1498    ],[
1499      AC_MSG_RESULT([yes])
1500      tst_proto_freeaddrinfo="yes"
1501    ],[
1502      AC_MSG_RESULT([no])
1503      tst_proto_freeaddrinfo="no"
1504    ])
1505  fi
1506  #
1507  if test "$tst_proto_freeaddrinfo" = "yes"; then
1508    AC_MSG_CHECKING([if freeaddrinfo is compilable])
1509    AC_COMPILE_IFELSE([
1510      AC_LANG_PROGRAM([[
1511        $curl_includes_ws2tcpip
1512        $curl_includes_sys_socket
1513        $curl_includes_netdb
1514      ]],[[
1515        freeaddrinfo(0);
1516      ]])
1517    ],[
1518      AC_MSG_RESULT([yes])
1519      tst_compi_freeaddrinfo="yes"
1520    ],[
1521      AC_MSG_RESULT([no])
1522      tst_compi_freeaddrinfo="no"
1523    ])
1524  fi
1525  #
1526  if test "$tst_compi_freeaddrinfo" = "yes"; then
1527    AC_MSG_CHECKING([if freeaddrinfo usage allowed])
1528    if test "x$curl_disallow_freeaddrinfo" != "xyes"; then
1529      AC_MSG_RESULT([yes])
1530      tst_allow_freeaddrinfo="yes"
1531    else
1532      AC_MSG_RESULT([no])
1533      tst_allow_freeaddrinfo="no"
1534    fi
1535  fi
1536  #
1537  AC_MSG_CHECKING([if freeaddrinfo might be used])
1538  if test "$tst_links_freeaddrinfo" = "yes" &&
1539     test "$tst_proto_freeaddrinfo" = "yes" &&
1540     test "$tst_compi_freeaddrinfo" = "yes" &&
1541     test "$tst_allow_freeaddrinfo" = "yes"; then
1542    AC_MSG_RESULT([yes])
1543    AC_DEFINE_UNQUOTED(HAVE_FREEADDRINFO, 1,
1544      [Define to 1 if you have the freeaddrinfo function.])
1545    curl_cv_func_freeaddrinfo="yes"
1546  else
1547    AC_MSG_RESULT([no])
1548    curl_cv_func_freeaddrinfo="no"
1549  fi
1550])
1551
1552
1553dnl CURL_CHECK_FUNC_FREEIFADDRS
1554dnl -------------------------------------------------
1555dnl Verify if freeifaddrs is available, prototyped, and
1556dnl can be compiled. If all of these are true, and
1557dnl usage has not been previously disallowed with
1558dnl shell variable curl_disallow_freeifaddrs, then
1559dnl HAVE_FREEIFADDRS will be defined.
1560
1561AC_DEFUN([CURL_CHECK_FUNC_FREEIFADDRS], [
1562  AC_REQUIRE([CURL_INCLUDES_IFADDRS])dnl
1563  #
1564  tst_links_freeifaddrs="unknown"
1565  tst_proto_freeifaddrs="unknown"
1566  tst_compi_freeifaddrs="unknown"
1567  tst_allow_freeifaddrs="unknown"
1568  #
1569  AC_MSG_CHECKING([if freeifaddrs can be linked])
1570  AC_LINK_IFELSE([
1571    AC_LANG_FUNC_LINK_TRY([freeifaddrs])
1572  ],[
1573    AC_MSG_RESULT([yes])
1574    tst_links_freeifaddrs="yes"
1575  ],[
1576    AC_MSG_RESULT([no])
1577    tst_links_freeifaddrs="no"
1578  ])
1579  #
1580  if test "$tst_links_freeifaddrs" = "yes"; then
1581    AC_MSG_CHECKING([if freeifaddrs is prototyped])
1582    AC_EGREP_CPP([freeifaddrs],[
1583      $curl_includes_ifaddrs
1584    ],[
1585      AC_MSG_RESULT([yes])
1586      tst_proto_freeifaddrs="yes"
1587    ],[
1588      AC_MSG_RESULT([no])
1589      tst_proto_freeifaddrs="no"
1590    ])
1591  fi
1592  #
1593  if test "$tst_proto_freeifaddrs" = "yes"; then
1594    AC_MSG_CHECKING([if freeifaddrs is compilable])
1595    AC_COMPILE_IFELSE([
1596      AC_LANG_PROGRAM([[
1597        $curl_includes_ifaddrs
1598      ]],[[
1599        freeifaddrs(0);
1600      ]])
1601    ],[
1602      AC_MSG_RESULT([yes])
1603      tst_compi_freeifaddrs="yes"
1604    ],[
1605      AC_MSG_RESULT([no])
1606      tst_compi_freeifaddrs="no"
1607    ])
1608  fi
1609  #
1610  if test "$tst_compi_freeifaddrs" = "yes"; then
1611    AC_MSG_CHECKING([if freeifaddrs usage allowed])
1612    if test "x$curl_disallow_freeifaddrs" != "xyes"; then
1613      AC_MSG_RESULT([yes])
1614      tst_allow_freeifaddrs="yes"
1615    else
1616      AC_MSG_RESULT([no])
1617      tst_allow_freeifaddrs="no"
1618    fi
1619  fi
1620  #
1621  AC_MSG_CHECKING([if freeifaddrs might be used])
1622  if test "$tst_links_freeifaddrs" = "yes" &&
1623     test "$tst_proto_freeifaddrs" = "yes" &&
1624     test "$tst_compi_freeifaddrs" = "yes" &&
1625     test "$tst_allow_freeifaddrs" = "yes"; then
1626    AC_MSG_RESULT([yes])
1627    AC_DEFINE_UNQUOTED(HAVE_FREEIFADDRS, 1,
1628      [Define to 1 if you have the freeifaddrs function.])
1629    curl_cv_func_freeifaddrs="yes"
1630  else
1631    AC_MSG_RESULT([no])
1632    curl_cv_func_freeifaddrs="no"
1633  fi
1634])
1635
1636
1637dnl CURL_CHECK_FUNC_FREMOVEXATTR
1638dnl -------------------------------------------------
1639dnl Verify if fremovexattr is available, prototyped, and
1640dnl can be compiled. If all of these are true, and
1641dnl usage has not been previously disallowed with
1642dnl shell variable curl_disallow_fremovexattr, then
1643dnl HAVE_FREMOVEXATTR will be defined.
1644
1645AC_DEFUN([CURL_CHECK_FUNC_FREMOVEXATTR], [
1646  AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
1647  #
1648  tst_links_fremovexattr="unknown"
1649  tst_proto_fremovexattr="unknown"
1650  tst_compi_fremovexattr="unknown"
1651  tst_allow_fremovexattr="unknown"
1652  tst_nargs_fremovexattr="unknown"
1653  #
1654  AC_MSG_CHECKING([if fremovexattr can be linked])
1655  AC_LINK_IFELSE([
1656    AC_LANG_FUNC_LINK_TRY([fremovexattr])
1657  ],[
1658    AC_MSG_RESULT([yes])
1659    tst_links_fremovexattr="yes"
1660  ],[
1661    AC_MSG_RESULT([no])
1662    tst_links_fremovexattr="no"
1663  ])
1664  #
1665  if test "$tst_links_fremovexattr" = "yes"; then
1666    AC_MSG_CHECKING([if fremovexattr is prototyped])
1667    AC_EGREP_CPP([fremovexattr],[
1668      $curl_includes_sys_xattr
1669    ],[
1670      AC_MSG_RESULT([yes])
1671      tst_proto_fremovexattr="yes"
1672    ],[
1673      AC_MSG_RESULT([no])
1674      tst_proto_fremovexattr="no"
1675    ])
1676  fi
1677  #
1678  if test "$tst_proto_fremovexattr" = "yes"; then
1679    if test "$tst_nargs_fremovexattr" = "unknown"; then
1680      AC_MSG_CHECKING([if fremovexattr takes 2 args.])
1681      AC_COMPILE_IFELSE([
1682        AC_LANG_PROGRAM([[
1683          $curl_includes_sys_xattr
1684        ]],[[
1685          if(0 != fremovexattr(0, 0))
1686            return 1;
1687        ]])
1688      ],[
1689        AC_MSG_RESULT([yes])
1690        tst_compi_fremovexattr="yes"
1691        tst_nargs_fremovexattr="2"
1692      ],[
1693        AC_MSG_RESULT([no])
1694        tst_compi_fremovexattr="no"
1695      ])
1696    fi
1697    if test "$tst_nargs_fremovexattr" = "unknown"; then
1698      AC_MSG_CHECKING([if fremovexattr takes 3 args.])
1699      AC_COMPILE_IFELSE([
1700        AC_LANG_PROGRAM([[
1701          $curl_includes_sys_xattr
1702        ]],[[
1703          if(0 != fremovexattr(0, 0, 0))
1704            return 1;
1705        ]])
1706      ],[
1707        AC_MSG_RESULT([yes])
1708        tst_compi_fremovexattr="yes"
1709        tst_nargs_fremovexattr="3"
1710      ],[
1711        AC_MSG_RESULT([no])
1712        tst_compi_fremovexattr="no"
1713      ])
1714    fi
1715    AC_MSG_CHECKING([if fremovexattr is compilable])
1716    if test "$tst_compi_fremovexattr" = "yes"; then
1717      AC_MSG_RESULT([yes])
1718    else
1719      AC_MSG_RESULT([no])
1720    fi
1721  fi
1722  #
1723  if test "$tst_compi_fremovexattr" = "yes"; then
1724    AC_MSG_CHECKING([if fremovexattr usage allowed])
1725    if test "x$curl_disallow_fremovexattr" != "xyes"; then
1726      AC_MSG_RESULT([yes])
1727      tst_allow_fremovexattr="yes"
1728    else
1729      AC_MSG_RESULT([no])
1730      tst_allow_fremovexattr="no"
1731    fi
1732  fi
1733  #
1734  AC_MSG_CHECKING([if fremovexattr might be used])
1735  if test "$tst_links_fremovexattr" = "yes" &&
1736     test "$tst_proto_fremovexattr" = "yes" &&
1737     test "$tst_compi_fremovexattr" = "yes" &&
1738     test "$tst_allow_fremovexattr" = "yes"; then
1739    AC_MSG_RESULT([yes])
1740    AC_DEFINE_UNQUOTED(HAVE_FREMOVEXATTR, 1,
1741      [Define to 1 if you have the fremovexattr function.])
1742    dnl AC_DEFINE_UNQUOTED(FREMOVEXATTR_ARGS, $tst_nargs_fremovexattr,
1743    dnl   [Specifies the number of arguments to fremovexattr])
1744    #
1745    if test "$tst_nargs_fremovexattr" -eq "2"; then
1746      AC_DEFINE(HAVE_FREMOVEXATTR_2, 1, [fremovexattr() takes 2 args])
1747    elif test "$tst_nargs_fremovexattr" -eq "3"; then
1748      AC_DEFINE(HAVE_FREMOVEXATTR_3, 1, [fremovexattr() takes 3 args])
1749    fi
1750    #
1751    curl_cv_func_fremovexattr="yes"
1752  else
1753    AC_MSG_RESULT([no])
1754    curl_cv_func_fremovexattr="no"
1755  fi
1756])
1757
1758
1759dnl CURL_CHECK_FUNC_FSETXATTR
1760dnl -------------------------------------------------
1761dnl Verify if fsetxattr is available, prototyped, and
1762dnl can be compiled. If all of these are true, and
1763dnl usage has not been previously disallowed with
1764dnl shell variable curl_disallow_fsetxattr, then
1765dnl HAVE_FSETXATTR will be defined.
1766
1767AC_DEFUN([CURL_CHECK_FUNC_FSETXATTR], [
1768  AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
1769  #
1770  tst_links_fsetxattr="unknown"
1771  tst_proto_fsetxattr="unknown"
1772  tst_compi_fsetxattr="unknown"
1773  tst_allow_fsetxattr="unknown"
1774  tst_nargs_fsetxattr="unknown"
1775  #
1776  AC_MSG_CHECKING([if fsetxattr can be linked])
1777  AC_LINK_IFELSE([
1778    AC_LANG_FUNC_LINK_TRY([fsetxattr])
1779  ],[
1780    AC_MSG_RESULT([yes])
1781    tst_links_fsetxattr="yes"
1782  ],[
1783    AC_MSG_RESULT([no])
1784    tst_links_fsetxattr="no"
1785  ])
1786  #
1787  if test "$tst_links_fsetxattr" = "yes"; then
1788    AC_MSG_CHECKING([if fsetxattr is prototyped])
1789    AC_EGREP_CPP([fsetxattr],[
1790      $curl_includes_sys_xattr
1791    ],[
1792      AC_MSG_RESULT([yes])
1793      tst_proto_fsetxattr="yes"
1794    ],[
1795      AC_MSG_RESULT([no])
1796      tst_proto_fsetxattr="no"
1797    ])
1798  fi
1799  #
1800  if test "$tst_proto_fsetxattr" = "yes"; then
1801    if test "$tst_nargs_fsetxattr" = "unknown"; then
1802      AC_MSG_CHECKING([if fsetxattr takes 5 args.])
1803      AC_COMPILE_IFELSE([
1804        AC_LANG_PROGRAM([[
1805          $curl_includes_sys_xattr
1806        ]],[[
1807          if(0 != fsetxattr(0, 0, 0, 0, 0))
1808            return 1;
1809        ]])
1810      ],[
1811        AC_MSG_RESULT([yes])
1812        tst_compi_fsetxattr="yes"
1813        tst_nargs_fsetxattr="5"
1814      ],[
1815        AC_MSG_RESULT([no])
1816        tst_compi_fsetxattr="no"
1817      ])
1818    fi
1819    if test "$tst_nargs_fsetxattr" = "unknown"; then
1820      AC_MSG_CHECKING([if fsetxattr takes 6 args.])
1821      AC_COMPILE_IFELSE([
1822        AC_LANG_PROGRAM([[
1823          $curl_includes_sys_xattr
1824        ]],[[
1825          if(0 != fsetxattr(0, 0, 0, 0, 0, 0))
1826            return 1;
1827        ]])
1828      ],[
1829        AC_MSG_RESULT([yes])
1830        tst_compi_fsetxattr="yes"
1831        tst_nargs_fsetxattr="6"
1832      ],[
1833        AC_MSG_RESULT([no])
1834        tst_compi_fsetxattr="no"
1835      ])
1836    fi
1837    AC_MSG_CHECKING([if fsetxattr is compilable])
1838    if test "$tst_compi_fsetxattr" = "yes"; then
1839      AC_MSG_RESULT([yes])
1840    else
1841      AC_MSG_RESULT([no])
1842    fi
1843  fi
1844  #
1845  if test "$tst_compi_fsetxattr" = "yes"; then
1846    AC_MSG_CHECKING([if fsetxattr usage allowed])
1847    if test "x$curl_disallow_fsetxattr" != "xyes"; then
1848      AC_MSG_RESULT([yes])
1849      tst_allow_fsetxattr="yes"
1850    else
1851      AC_MSG_RESULT([no])
1852      tst_allow_fsetxattr="no"
1853    fi
1854  fi
1855  #
1856  AC_MSG_CHECKING([if fsetxattr might be used])
1857  if test "$tst_links_fsetxattr" = "yes" &&
1858     test "$tst_proto_fsetxattr" = "yes" &&
1859     test "$tst_compi_fsetxattr" = "yes" &&
1860     test "$tst_allow_fsetxattr" = "yes"; then
1861    AC_MSG_RESULT([yes])
1862    AC_DEFINE_UNQUOTED(HAVE_FSETXATTR, 1,
1863      [Define to 1 if you have the fsetxattr function.])
1864    dnl AC_DEFINE_UNQUOTED(FSETXATTR_ARGS, $tst_nargs_fsetxattr,
1865    dnl   [Specifies the number of arguments to fsetxattr])
1866    #
1867    if test "$tst_nargs_fsetxattr" -eq "5"; then
1868      AC_DEFINE(HAVE_FSETXATTR_5, 1, [fsetxattr() takes 5 args])
1869    elif test "$tst_nargs_fsetxattr" -eq "6"; then
1870      AC_DEFINE(HAVE_FSETXATTR_6, 1, [fsetxattr() takes 6 args])
1871    fi
1872    #
1873    curl_cv_func_fsetxattr="yes"
1874  else
1875    AC_MSG_RESULT([no])
1876    curl_cv_func_fsetxattr="no"
1877  fi
1878])
1879
1880
1881dnl CURL_CHECK_FUNC_FTRUNCATE
1882dnl -------------------------------------------------
1883dnl Verify if ftruncate is available, prototyped, and
1884dnl can be compiled. If all of these are true, and
1885dnl usage has not been previously disallowed with
1886dnl shell variable curl_disallow_ftruncate, then
1887dnl HAVE_FTRUNCATE will be defined.
1888
1889AC_DEFUN([CURL_CHECK_FUNC_FTRUNCATE], [
1890  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
1891  #
1892  tst_links_ftruncate="unknown"
1893  tst_proto_ftruncate="unknown"
1894  tst_compi_ftruncate="unknown"
1895  tst_allow_ftruncate="unknown"
1896  #
1897  AC_MSG_CHECKING([if ftruncate can be linked])
1898  AC_LINK_IFELSE([
1899    AC_LANG_FUNC_LINK_TRY([ftruncate])
1900  ],[
1901    AC_MSG_RESULT([yes])
1902    tst_links_ftruncate="yes"
1903  ],[
1904    AC_MSG_RESULT([no])
1905    tst_links_ftruncate="no"
1906  ])
1907  #
1908  if test "$tst_links_ftruncate" = "yes"; then
1909    AC_MSG_CHECKING([if ftruncate is prototyped])
1910    AC_EGREP_CPP([ftruncate],[
1911      $curl_includes_unistd
1912    ],[
1913      AC_MSG_RESULT([yes])
1914      tst_proto_ftruncate="yes"
1915    ],[
1916      AC_MSG_RESULT([no])
1917      tst_proto_ftruncate="no"
1918    ])
1919  fi
1920  #
1921  if test "$tst_proto_ftruncate" = "yes"; then
1922    AC_MSG_CHECKING([if ftruncate is compilable])
1923    AC_COMPILE_IFELSE([
1924      AC_LANG_PROGRAM([[
1925        $curl_includes_unistd
1926      ]],[[
1927        if(0 != ftruncate(0, 0))
1928          return 1;
1929      ]])
1930    ],[
1931      AC_MSG_RESULT([yes])
1932      tst_compi_ftruncate="yes"
1933    ],[
1934      AC_MSG_RESULT([no])
1935      tst_compi_ftruncate="no"
1936    ])
1937  fi
1938  #
1939  if test "$tst_compi_ftruncate" = "yes"; then
1940    AC_MSG_CHECKING([if ftruncate usage allowed])
1941    if test "x$curl_disallow_ftruncate" != "xyes"; then
1942      AC_MSG_RESULT([yes])
1943      tst_allow_ftruncate="yes"
1944    else
1945      AC_MSG_RESULT([no])
1946      tst_allow_ftruncate="no"
1947    fi
1948  fi
1949  #
1950  AC_MSG_CHECKING([if ftruncate might be used])
1951  if test "$tst_links_ftruncate" = "yes" &&
1952     test "$tst_proto_ftruncate" = "yes" &&
1953     test "$tst_compi_ftruncate" = "yes" &&
1954     test "$tst_allow_ftruncate" = "yes"; then
1955    AC_MSG_RESULT([yes])
1956    AC_DEFINE_UNQUOTED(HAVE_FTRUNCATE, 1,
1957      [Define to 1 if you have the ftruncate function.])
1958    curl_cv_func_ftruncate="yes"
1959  else
1960    AC_MSG_RESULT([no])
1961    curl_cv_func_ftruncate="no"
1962  fi
1963])
1964
1965
1966dnl CURL_CHECK_FUNC_GETADDRINFO
1967dnl -------------------------------------------------
1968dnl Verify if getaddrinfo is available, prototyped, can
1969dnl be compiled and seems to work. If all of these are
1970dnl true, and usage has not been previously disallowed
1971dnl with shell variable curl_disallow_getaddrinfo, then
1972dnl HAVE_GETADDRINFO will be defined. Additionally when
1973dnl HAVE_GETADDRINFO gets defined this will also attempt
1974dnl to find out if getaddrinfo happens to be threadsafe,
1975dnl defining HAVE_GETADDRINFO_THREADSAFE when true.
1976
1977AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
1978  AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
1979  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
1980  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1981  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
1982  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1983  AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
1984  #
1985  tst_links_getaddrinfo="unknown"
1986  tst_proto_getaddrinfo="unknown"
1987  tst_compi_getaddrinfo="unknown"
1988  tst_works_getaddrinfo="unknown"
1989  tst_allow_getaddrinfo="unknown"
1990  tst_tsafe_getaddrinfo="unknown"
1991  #
1992  AC_MSG_CHECKING([if getaddrinfo can be linked])
1993  AC_LINK_IFELSE([
1994    AC_LANG_PROGRAM([[
1995      $curl_includes_ws2tcpip
1996      $curl_includes_sys_socket
1997      $curl_includes_netdb
1998    ]],[[
1999      if(0 != getaddrinfo(0, 0, 0, 0))
2000        return 1;
2001    ]])
2002  ],[
2003    AC_MSG_RESULT([yes])
2004    tst_links_getaddrinfo="yes"
2005  ],[
2006    AC_MSG_RESULT([no])
2007    tst_links_getaddrinfo="no"
2008  ])
2009  #
2010  if test "$tst_links_getaddrinfo" = "yes"; then
2011    AC_MSG_CHECKING([if getaddrinfo is prototyped])
2012    AC_EGREP_CPP([getaddrinfo],[
2013      $curl_includes_ws2tcpip
2014      $curl_includes_sys_socket
2015      $curl_includes_netdb
2016    ],[
2017      AC_MSG_RESULT([yes])
2018      tst_proto_getaddrinfo="yes"
2019    ],[
2020      AC_MSG_RESULT([no])
2021      tst_proto_getaddrinfo="no"
2022    ])
2023  fi
2024  #
2025  if test "$tst_proto_getaddrinfo" = "yes"; then
2026    AC_MSG_CHECKING([if getaddrinfo is compilable])
2027    AC_COMPILE_IFELSE([
2028      AC_LANG_PROGRAM([[
2029        $curl_includes_ws2tcpip
2030        $curl_includes_sys_socket
2031        $curl_includes_netdb
2032      ]],[[
2033        if(0 != getaddrinfo(0, 0, 0, 0))
2034          return 1;
2035      ]])
2036    ],[
2037      AC_MSG_RESULT([yes])
2038      tst_compi_getaddrinfo="yes"
2039    ],[
2040      AC_MSG_RESULT([no])
2041      tst_compi_getaddrinfo="no"
2042    ])
2043  fi
2044  #
2045  dnl only do runtime verification when not cross-compiling
2046  if test "x$cross_compiling" != "xyes" &&
2047    test "$tst_compi_getaddrinfo" = "yes"; then
2048    AC_MSG_CHECKING([if getaddrinfo seems to work])
2049    CURL_RUN_IFELSE([
2050      AC_LANG_PROGRAM([[
2051        $curl_includes_ws2tcpip
2052        $curl_includes_stdlib
2053        $curl_includes_string
2054        $curl_includes_sys_socket
2055        $curl_includes_netdb
2056      ]],[[
2057        struct addrinfo hints;
2058        struct addrinfo *ai = 0;
2059        int error;
2060
2061        #ifdef HAVE_WINSOCK2_H
2062        WSADATA wsa;
2063        if (WSAStartup(MAKEWORD(2,2), &wsa))
2064                exit(2);
2065        #endif
2066
2067        memset(&hints, 0, sizeof(hints));
2068        hints.ai_flags = AI_NUMERICHOST;
2069        hints.ai_family = AF_UNSPEC;
2070        hints.ai_socktype = SOCK_STREAM;
2071        error = getaddrinfo("127.0.0.1", 0, &hints, &ai);
2072        if(error || !ai)
2073          exit(1); /* fail */
2074        else
2075          exit(0);
2076      ]])
2077    ],[
2078      AC_MSG_RESULT([yes])
2079      tst_works_getaddrinfo="yes"
2080    ],[
2081      AC_MSG_RESULT([no])
2082      tst_works_getaddrinfo="no"
2083    ])
2084  fi
2085  #
2086  if test "$tst_compi_getaddrinfo" = "yes" &&
2087    test "$tst_works_getaddrinfo" != "no"; then
2088    AC_MSG_CHECKING([if getaddrinfo usage allowed])
2089    if test "x$curl_disallow_getaddrinfo" != "xyes"; then
2090      AC_MSG_RESULT([yes])
2091      tst_allow_getaddrinfo="yes"
2092    else
2093      AC_MSG_RESULT([no])
2094      tst_allow_getaddrinfo="no"
2095    fi
2096  fi
2097  #
2098  AC_MSG_CHECKING([if getaddrinfo might be used])
2099  if test "$tst_links_getaddrinfo" = "yes" &&
2100     test "$tst_proto_getaddrinfo" = "yes" &&
2101     test "$tst_compi_getaddrinfo" = "yes" &&
2102     test "$tst_allow_getaddrinfo" = "yes" &&
2103     test "$tst_works_getaddrinfo" != "no"; then
2104    AC_MSG_RESULT([yes])
2105    AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO, 1,
2106      [Define to 1 if you have a working getaddrinfo function.])
2107    curl_cv_func_getaddrinfo="yes"
2108  else
2109    AC_MSG_RESULT([no])
2110    curl_cv_func_getaddrinfo="no"
2111    curl_cv_func_getaddrinfo_threadsafe="no"
2112  fi
2113  #
2114  if test "$curl_cv_func_getaddrinfo" = "yes"; then
2115    AC_MSG_CHECKING([if getaddrinfo is threadsafe])
2116    case $host_os in
2117      aix[[1234]].* | aix5.[[01]].*)
2118        dnl aix 5.1 and older
2119        tst_tsafe_getaddrinfo="no"
2120        ;;
2121      aix*)
2122        dnl aix 5.2 and newer
2123        tst_tsafe_getaddrinfo="yes"
2124        ;;
2125      darwin[[12345]].*)
2126        dnl darwin 5.0 and mac os x 10.1.X and older
2127        tst_tsafe_getaddrinfo="no"
2128        ;;
2129      darwin*)
2130        dnl darwin 6.0 and mac os x 10.2.X and newer
2131        tst_tsafe_getaddrinfo="yes"
2132        ;;
2133      freebsd[[1234]].* | freebsd5.[[1234]]*)
2134        dnl freebsd 5.4 and older
2135        tst_tsafe_getaddrinfo="no"
2136        ;;
2137      freebsd*)
2138        dnl freebsd 5.5 and newer
2139        tst_tsafe_getaddrinfo="yes"
2140        ;;
2141      hpux[[123456789]].* | hpux10.* | hpux11.0* | hpux11.10*)
2142        dnl hpux 11.10 and older
2143        tst_tsafe_getaddrinfo="no"
2144        ;;
2145      hpux*)
2146        dnl hpux 11.11 and newer
2147        tst_tsafe_getaddrinfo="yes"
2148        ;;
2149      netbsd[[123]].*)
2150        dnl netbsd 3.X and older
2151        tst_tsafe_getaddrinfo="no"
2152        ;;
2153      netbsd*)
2154        dnl netbsd 4.X and newer
2155        tst_tsafe_getaddrinfo="yes"
2156        ;;
2157      *bsd*)
2158        dnl All other bsd's
2159        tst_tsafe_getaddrinfo="no"
2160        ;;
2161      solaris2*)
2162        dnl solaris which have it
2163        tst_tsafe_getaddrinfo="yes"
2164        ;;
2165    esac
2166    if test "$tst_tsafe_getaddrinfo" = "unknown" &&
2167       test "$curl_cv_native_windows" = "yes"; then
2168      tst_tsafe_getaddrinfo="yes"
2169    fi
2170    if test "$tst_tsafe_getaddrinfo" = "unknown"; then
2171      CURL_CHECK_DEF_CC([h_errno], [
2172        $curl_includes_sys_socket
2173        $curl_includes_netdb
2174        ], [silent])
2175      if test "$curl_cv_have_def_h_errno" = "yes"; then
2176        tst_h_errno_macro="yes"
2177      else
2178        tst_h_errno_macro="no"
2179      fi
2180      AC_COMPILE_IFELSE([
2181        AC_LANG_PROGRAM([[
2182          $curl_includes_sys_socket
2183          $curl_includes_netdb
2184        ]],[[
2185          h_errno = 2;
2186          if(0 != h_errno)
2187            return 1;
2188        ]])
2189      ],[
2190        tst_h_errno_modifiable_lvalue="yes"
2191      ],[
2192        tst_h_errno_modifiable_lvalue="no"
2193      ])
2194      AC_COMPILE_IFELSE([
2195        AC_LANG_PROGRAM([[
2196        ]],[[
2197#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
2198          return 0;
2199#elif defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 700)
2200          return 0;
2201#else
2202          force compilation error
2203#endif
2204        ]])
2205      ],[
2206        tst_h_errno_sbs_issue_7="yes"
2207      ],[
2208        tst_h_errno_sbs_issue_7="no"
2209      ])
2210      if test "$tst_h_errno_macro" = "no" &&
2211         test "$tst_h_errno_modifiable_lvalue" = "no" &&
2212         test "$tst_h_errno_sbs_issue_7" = "no"; then
2213        tst_tsafe_getaddrinfo="no"
2214      else
2215        tst_tsafe_getaddrinfo="yes"
2216      fi
2217    fi
2218    AC_MSG_RESULT([$tst_tsafe_getaddrinfo])
2219    if test "$tst_tsafe_getaddrinfo" = "yes"; then
2220      AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO_THREADSAFE, 1,
2221        [Define to 1 if the getaddrinfo function is threadsafe.])
2222      curl_cv_func_getaddrinfo_threadsafe="yes"
2223    else
2224      curl_cv_func_getaddrinfo_threadsafe="no"
2225    fi
2226  fi
2227])
2228
2229
2230dnl CURL_CHECK_FUNC_GETHOSTBYADDR
2231dnl -------------------------------------------------
2232dnl Verify if gethostbyaddr is available, prototyped,
2233dnl and can be compiled. If all of these are true,
2234dnl and usage has not been previously disallowed with
2235dnl shell variable curl_disallow_gethostbyaddr, then
2236dnl HAVE_GETHOSTBYADDR will be defined.
2237
2238AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYADDR], [
2239  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2240  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2241  #
2242  tst_links_gethostbyaddr="unknown"
2243  tst_proto_gethostbyaddr="unknown"
2244  tst_compi_gethostbyaddr="unknown"
2245  tst_allow_gethostbyaddr="unknown"
2246  #
2247  AC_MSG_CHECKING([if gethostbyaddr can be linked])
2248  AC_LINK_IFELSE([
2249    AC_LANG_PROGRAM([[
2250      $curl_includes_winsock2
2251      $curl_includes_bsdsocket
2252      $curl_includes_netdb
2253    ]],[[
2254      if(0 != gethostbyaddr(0, 0, 0))
2255        return 1;
2256    ]])
2257  ],[
2258    AC_MSG_RESULT([yes])
2259    tst_links_gethostbyaddr="yes"
2260  ],[
2261    AC_MSG_RESULT([no])
2262    tst_links_gethostbyaddr="no"
2263  ])
2264  #
2265  if test "$tst_links_gethostbyaddr" = "yes"; then
2266    AC_MSG_CHECKING([if gethostbyaddr is prototyped])
2267    AC_EGREP_CPP([gethostbyaddr],[
2268      $curl_includes_winsock2
2269      $curl_includes_bsdsocket
2270      $curl_includes_netdb
2271    ],[
2272      AC_MSG_RESULT([yes])
2273      tst_proto_gethostbyaddr="yes"
2274    ],[
2275      AC_MSG_RESULT([no])
2276      tst_proto_gethostbyaddr="no"
2277    ])
2278  fi
2279  #
2280  if test "$tst_proto_gethostbyaddr" = "yes"; then
2281    AC_MSG_CHECKING([if gethostbyaddr is compilable])
2282    AC_COMPILE_IFELSE([
2283      AC_LANG_PROGRAM([[
2284        $curl_includes_winsock2
2285      $curl_includes_bsdsocket
2286        $curl_includes_netdb
2287      ]],[[
2288        if(0 != gethostbyaddr(0, 0, 0))
2289          return 1;
2290      ]])
2291    ],[
2292      AC_MSG_RESULT([yes])
2293      tst_compi_gethostbyaddr="yes"
2294    ],[
2295      AC_MSG_RESULT([no])
2296      tst_compi_gethostbyaddr="no"
2297    ])
2298  fi
2299  #
2300  if test "$tst_compi_gethostbyaddr" = "yes"; then
2301    AC_MSG_CHECKING([if gethostbyaddr usage allowed])
2302    if test "x$curl_disallow_gethostbyaddr" != "xyes"; then
2303      AC_MSG_RESULT([yes])
2304      tst_allow_gethostbyaddr="yes"
2305    else
2306      AC_MSG_RESULT([no])
2307      tst_allow_gethostbyaddr="no"
2308    fi
2309  fi
2310  #
2311  AC_MSG_CHECKING([if gethostbyaddr might be used])
2312  if test "$tst_links_gethostbyaddr" = "yes" &&
2313     test "$tst_proto_gethostbyaddr" = "yes" &&
2314     test "$tst_compi_gethostbyaddr" = "yes" &&
2315     test "$tst_allow_gethostbyaddr" = "yes"; then
2316    AC_MSG_RESULT([yes])
2317    AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR, 1,
2318      [Define to 1 if you have the gethostbyaddr function.])
2319    curl_cv_func_gethostbyaddr="yes"
2320  else
2321    AC_MSG_RESULT([no])
2322    curl_cv_func_gethostbyaddr="no"
2323  fi
2324])
2325
2326dnl CURL_CHECK_FUNC_GAI_STRERROR
2327dnl -------------------------------------------------
2328dnl Verify if gai_strerror is available, prototyped,
2329dnl and can be compiled. If all of these are true,
2330dnl and usage has not been previously disallowed with
2331dnl shell variable curl_disallow_gai_strerror, then
2332dnl HAVE_GAI_STRERROR will be defined.
2333
2334AC_DEFUN([CURL_CHECK_FUNC_GAI_STRERROR], [
2335  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2336  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2337  #
2338  tst_links_gai_strerror="unknown"
2339  tst_proto_gai_strerror="unknown"
2340  tst_compi_gai_strerror="unknown"
2341  tst_allow_gai_strerror="unknown"
2342  #
2343  AC_MSG_CHECKING([if gai_strerror can be linked])
2344  AC_LINK_IFELSE([
2345    AC_LANG_PROGRAM([[
2346      $curl_includes_winsock2
2347      $curl_includes_bsdsocket
2348      $curl_includes_netdb
2349    ]],[[
2350      if(0 != gai_strerror(0))
2351        return 1;
2352    ]])
2353  ],[
2354    AC_MSG_RESULT([yes])
2355    tst_links_gai_strerror="yes"
2356  ],[
2357    AC_MSG_RESULT([no])
2358    tst_links_gai_strerror="no"
2359  ])
2360  #
2361  if test "$tst_links_gai_strerror" = "yes"; then
2362    AC_MSG_CHECKING([if gai_strerror is prototyped])
2363    AC_EGREP_CPP([gai_strerror],[
2364      $curl_includes_winsock2
2365      $curl_includes_bsdsocket
2366      $curl_includes_netdb
2367    ],[
2368      AC_MSG_RESULT([yes])
2369      tst_proto_gai_strerror="yes"
2370    ],[
2371      AC_MSG_RESULT([no])
2372      tst_proto_gai_strerror="no"
2373    ])
2374  fi
2375  #
2376  if test "$tst_proto_gai_strerror" = "yes"; then
2377    AC_MSG_CHECKING([if gai_strerror is compilable])
2378    AC_COMPILE_IFELSE([
2379      AC_LANG_PROGRAM([[
2380        $curl_includes_winsock2
2381      $curl_includes_bsdsocket
2382        $curl_includes_netdb
2383      ]],[[
2384        if(0 != gai_strerror(0))
2385          return 1;
2386      ]])
2387    ],[
2388      AC_MSG_RESULT([yes])
2389      tst_compi_gai_strerror="yes"
2390    ],[
2391      AC_MSG_RESULT([no])
2392      tst_compi_gai_strerror="no"
2393    ])
2394  fi
2395  #
2396  if test "$tst_compi_gai_strerror" = "yes"; then
2397    AC_MSG_CHECKING([if gai_strerror usage allowed])
2398    if test "x$curl_disallow_gai_strerror" != "xyes"; then
2399      AC_MSG_RESULT([yes])
2400      tst_allow_gai_strerror="yes"
2401    else
2402      AC_MSG_RESULT([no])
2403      tst_allow_gai_strerror="no"
2404    fi
2405  fi
2406  #
2407  AC_MSG_CHECKING([if gai_strerror might be used])
2408  if test "$tst_links_gai_strerror" = "yes" &&
2409     test "$tst_proto_gai_strerror" = "yes" &&
2410     test "$tst_compi_gai_strerror" = "yes" &&
2411     test "$tst_allow_gai_strerror" = "yes"; then
2412    AC_MSG_RESULT([yes])
2413    AC_DEFINE_UNQUOTED(HAVE_GAI_STRERROR, 1,
2414      [Define to 1 if you have the gai_strerror function.])
2415    curl_cv_func_gai_strerror="yes"
2416  else
2417    AC_MSG_RESULT([no])
2418    curl_cv_func_gai_strerror="no"
2419  fi
2420])
2421
2422
2423dnl CURL_CHECK_FUNC_GETHOSTBYADDR_R
2424dnl -------------------------------------------------
2425dnl Verify if gethostbyaddr_r is available, prototyped,
2426dnl and can be compiled. If all of these are true, and
2427dnl usage has not been previously disallowed with
2428dnl shell variable curl_disallow_gethostbyaddr_r, then
2429dnl HAVE_GETHOSTBYADDR_R will be defined.
2430
2431AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYADDR_R], [
2432  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2433  #
2434  tst_links_gethostbyaddr_r="unknown"
2435  tst_proto_gethostbyaddr_r="unknown"
2436  tst_compi_gethostbyaddr_r="unknown"
2437  tst_allow_gethostbyaddr_r="unknown"
2438  tst_nargs_gethostbyaddr_r="unknown"
2439  #
2440  AC_MSG_CHECKING([if gethostbyaddr_r can be linked])
2441  AC_LINK_IFELSE([
2442    AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
2443  ],[
2444    AC_MSG_RESULT([yes])
2445    tst_links_gethostbyaddr_r="yes"
2446  ],[
2447    AC_MSG_RESULT([no])
2448    tst_links_gethostbyaddr_r="no"
2449  ])
2450  #
2451  if test "$tst_links_gethostbyaddr_r" = "yes"; then
2452    AC_MSG_CHECKING([if gethostbyaddr_r is prototyped])
2453    AC_EGREP_CPP([gethostbyaddr_r],[
2454      $curl_includes_netdb
2455    ],[
2456      AC_MSG_RESULT([yes])
2457      tst_proto_gethostbyaddr_r="yes"
2458    ],[
2459      AC_MSG_RESULT([no])
2460      tst_proto_gethostbyaddr_r="no"
2461    ])
2462  fi
2463  #
2464  if test "$tst_proto_gethostbyaddr_r" = "yes"; then
2465    if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
2466      AC_MSG_CHECKING([if gethostbyaddr_r takes 5 args.])
2467      AC_COMPILE_IFELSE([
2468        AC_LANG_PROGRAM([[
2469          $curl_includes_netdb
2470        ]],[[
2471          if(0 != gethostbyaddr_r(0, 0, 0, 0, 0))
2472            return 1;
2473        ]])
2474      ],[
2475        AC_MSG_RESULT([yes])
2476        tst_compi_gethostbyaddr_r="yes"
2477        tst_nargs_gethostbyaddr_r="5"
2478      ],[
2479        AC_MSG_RESULT([no])
2480        tst_compi_gethostbyaddr_r="no"
2481      ])
2482    fi
2483    if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
2484      AC_MSG_CHECKING([if gethostbyaddr_r takes 7 args.])
2485      AC_COMPILE_IFELSE([
2486        AC_LANG_PROGRAM([[
2487          $curl_includes_netdb
2488        ]],[[
2489          if(0 != gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0))
2490            return 1;
2491        ]])
2492      ],[
2493        AC_MSG_RESULT([yes])
2494        tst_compi_gethostbyaddr_r="yes"
2495        tst_nargs_gethostbyaddr_r="7"
2496      ],[
2497        AC_MSG_RESULT([no])
2498        tst_compi_gethostbyaddr_r="no"
2499      ])
2500    fi
2501    if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
2502      AC_MSG_CHECKING([if gethostbyaddr_r takes 8 args.])
2503      AC_COMPILE_IFELSE([
2504        AC_LANG_PROGRAM([[
2505          $curl_includes_netdb
2506        ]],[[
2507          if(0 != gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0, 0))
2508            return 1;
2509        ]])
2510      ],[
2511        AC_MSG_RESULT([yes])
2512        tst_compi_gethostbyaddr_r="yes"
2513        tst_nargs_gethostbyaddr_r="8"
2514      ],[
2515        AC_MSG_RESULT([no])
2516        tst_compi_gethostbyaddr_r="no"
2517      ])
2518    fi
2519    AC_MSG_CHECKING([if gethostbyaddr_r is compilable])
2520    if test "$tst_compi_gethostbyaddr_r" = "yes"; then
2521      AC_MSG_RESULT([yes])
2522    else
2523      AC_MSG_RESULT([no])
2524    fi
2525  fi
2526  #
2527  if test "$tst_compi_gethostbyaddr_r" = "yes"; then
2528    AC_MSG_CHECKING([if gethostbyaddr_r usage allowed])
2529    if test "x$curl_disallow_gethostbyaddr_r" != "xyes"; then
2530      AC_MSG_RESULT([yes])
2531      tst_allow_gethostbyaddr_r="yes"
2532    else
2533      AC_MSG_RESULT([no])
2534      tst_allow_gethostbyaddr_r="no"
2535    fi
2536  fi
2537  #
2538  AC_MSG_CHECKING([if gethostbyaddr_r might be used])
2539  if test "$tst_links_gethostbyaddr_r" = "yes" &&
2540     test "$tst_proto_gethostbyaddr_r" = "yes" &&
2541     test "$tst_compi_gethostbyaddr_r" = "yes" &&
2542     test "$tst_allow_gethostbyaddr_r" = "yes"; then
2543    AC_MSG_RESULT([yes])
2544    AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
2545      [Define to 1 if you have the gethostbyaddr_r function.])
2546    dnl AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_ARGS, $tst_nargs_gethostbyaddr_r,
2547    dnl   [Specifies the number of arguments to gethostbyaddr_r])
2548    #
2549    if test "$tst_nargs_gethostbyaddr_r" -eq "5"; then
2550      AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2551    elif test "$tst_nargs_gethostbyaddr_r" -eq "7"; then
2552      AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2553    elif test "$tst_nargs_gethostbyaddr_r" -eq "8"; then
2554      AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2555    fi
2556    #
2557    curl_cv_func_gethostbyaddr_r="yes"
2558  else
2559    AC_MSG_RESULT([no])
2560    curl_cv_func_gethostbyaddr_r="no"
2561  fi
2562])
2563
2564
2565dnl CURL_CHECK_FUNC_GETHOSTBYNAME
2566dnl -------------------------------------------------
2567dnl Verify if gethostbyname is available, prototyped,
2568dnl and can be compiled. If all of these are true,
2569dnl and usage has not been previously disallowed with
2570dnl shell variable curl_disallow_gethostbyname, then
2571dnl HAVE_GETHOSTBYNAME will be defined.
2572
2573AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME], [
2574  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2575  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2576  #
2577  tst_links_gethostbyname="unknown"
2578  tst_proto_gethostbyname="unknown"
2579  tst_compi_gethostbyname="unknown"
2580  tst_allow_gethostbyname="unknown"
2581  #
2582  AC_MSG_CHECKING([if gethostbyname can be linked])
2583  AC_LINK_IFELSE([
2584    AC_LANG_PROGRAM([[
2585      $curl_includes_winsock2
2586      $curl_includes_bsdsocket
2587      $curl_includes_netdb
2588    ]],[[
2589      if(0 != gethostbyname(0))
2590        return 1;
2591    ]])
2592  ],[
2593    AC_MSG_RESULT([yes])
2594    tst_links_gethostbyname="yes"
2595  ],[
2596    AC_MSG_RESULT([no])
2597    tst_links_gethostbyname="no"
2598  ])
2599  #
2600  if test "$tst_links_gethostbyname" = "yes"; then
2601    AC_MSG_CHECKING([if gethostbyname is prototyped])
2602    AC_EGREP_CPP([gethostbyname],[
2603      $curl_includes_winsock2
2604      $curl_includes_bsdsocket
2605      $curl_includes_netdb
2606    ],[
2607      AC_MSG_RESULT([yes])
2608      tst_proto_gethostbyname="yes"
2609    ],[
2610      AC_MSG_RESULT([no])
2611      tst_proto_gethostbyname="no"
2612    ])
2613  fi
2614  #
2615  if test "$tst_proto_gethostbyname" = "yes"; then
2616    AC_MSG_CHECKING([if gethostbyname is compilable])
2617    AC_COMPILE_IFELSE([
2618      AC_LANG_PROGRAM([[
2619        $curl_includes_winsock2
2620      $curl_includes_bsdsocket
2621        $curl_includes_netdb
2622      ]],[[
2623        if(0 != gethostbyname(0))
2624          return 1;
2625      ]])
2626    ],[
2627      AC_MSG_RESULT([yes])
2628      tst_compi_gethostbyname="yes"
2629    ],[
2630      AC_MSG_RESULT([no])
2631      tst_compi_gethostbyname="no"
2632    ])
2633  fi
2634  #
2635  if test "$tst_compi_gethostbyname" = "yes"; then
2636    AC_MSG_CHECKING([if gethostbyname usage allowed])
2637    if test "x$curl_disallow_gethostbyname" != "xyes"; then
2638      AC_MSG_RESULT([yes])
2639      tst_allow_gethostbyname="yes"
2640    else
2641      AC_MSG_RESULT([no])
2642      tst_allow_gethostbyname="no"
2643    fi
2644  fi
2645  #
2646  AC_MSG_CHECKING([if gethostbyname might be used])
2647  if test "$tst_links_gethostbyname" = "yes" &&
2648     test "$tst_proto_gethostbyname" = "yes" &&
2649     test "$tst_compi_gethostbyname" = "yes" &&
2650     test "$tst_allow_gethostbyname" = "yes"; then
2651    AC_MSG_RESULT([yes])
2652    AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME, 1,
2653      [Define to 1 if you have the gethostbyname function.])
2654    curl_cv_func_gethostbyname="yes"
2655  else
2656    AC_MSG_RESULT([no])
2657    curl_cv_func_gethostbyname="no"
2658  fi
2659])
2660
2661
2662dnl CURL_CHECK_FUNC_GETHOSTBYNAME_R
2663dnl -------------------------------------------------
2664dnl Verify if gethostbyname_r is available, prototyped,
2665dnl and can be compiled. If all of these are true, and
2666dnl usage has not been previously disallowed with
2667dnl shell variable curl_disallow_gethostbyname_r, then
2668dnl HAVE_GETHOSTBYNAME_R will be defined.
2669
2670AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME_R], [
2671  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2672  #
2673  tst_links_gethostbyname_r="unknown"
2674  tst_proto_gethostbyname_r="unknown"
2675  tst_compi_gethostbyname_r="unknown"
2676  tst_allow_gethostbyname_r="unknown"
2677  tst_nargs_gethostbyname_r="unknown"
2678  #
2679  AC_MSG_CHECKING([if gethostbyname_r can be linked])
2680  AC_LINK_IFELSE([
2681    AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
2682  ],[
2683    AC_MSG_RESULT([yes])
2684    tst_links_gethostbyname_r="yes"
2685  ],[
2686    AC_MSG_RESULT([no])
2687    tst_links_gethostbyname_r="no"
2688  ])
2689  #
2690  if test "$tst_links_gethostbyname_r" = "yes"; then
2691    AC_MSG_CHECKING([if gethostbyname_r is prototyped])
2692    AC_EGREP_CPP([gethostbyname_r],[
2693      $curl_includes_netdb
2694    ],[
2695      AC_MSG_RESULT([yes])
2696      tst_proto_gethostbyname_r="yes"
2697    ],[
2698      AC_MSG_RESULT([no])
2699      tst_proto_gethostbyname_r="no"
2700    ])
2701  fi
2702  #
2703  if test "$tst_proto_gethostbyname_r" = "yes"; then
2704    if test "$tst_nargs_gethostbyname_r" = "unknown"; then
2705      AC_MSG_CHECKING([if gethostbyname_r takes 3 args.])
2706      AC_COMPILE_IFELSE([
2707        AC_LANG_PROGRAM([[
2708          $curl_includes_netdb
2709        ]],[[
2710          if(0 != gethostbyname_r(0, 0, 0))
2711            return 1;
2712        ]])
2713      ],[
2714        AC_MSG_RESULT([yes])
2715        tst_compi_gethostbyname_r="yes"
2716        tst_nargs_gethostbyname_r="3"
2717      ],[
2718        AC_MSG_RESULT([no])
2719        tst_compi_gethostbyname_r="no"
2720      ])
2721    fi
2722    if test "$tst_nargs_gethostbyname_r" = "unknown"; then
2723      AC_MSG_CHECKING([if gethostbyname_r takes 5 args.])
2724      AC_COMPILE_IFELSE([
2725        AC_LANG_PROGRAM([[
2726          $curl_includes_netdb
2727        ]],[[
2728          if(0 != gethostbyname_r(0, 0, 0, 0, 0))
2729            return 1;
2730        ]])
2731      ],[
2732        AC_MSG_RESULT([yes])
2733        tst_compi_gethostbyname_r="yes"
2734        tst_nargs_gethostbyname_r="5"
2735      ],[
2736        AC_MSG_RESULT([no])
2737        tst_compi_gethostbyname_r="no"
2738      ])
2739    fi
2740    if test "$tst_nargs_gethostbyname_r" = "unknown"; then
2741      AC_MSG_CHECKING([if gethostbyname_r takes 6 args.])
2742      AC_COMPILE_IFELSE([
2743        AC_LANG_PROGRAM([[
2744          $curl_includes_netdb
2745        ]],[[
2746          if(0 != gethostbyname_r(0, 0, 0, 0, 0, 0))
2747            return 1;
2748        ]])
2749      ],[
2750        AC_MSG_RESULT([yes])
2751        tst_compi_gethostbyname_r="yes"
2752        tst_nargs_gethostbyname_r="6"
2753      ],[
2754        AC_MSG_RESULT([no])
2755        tst_compi_gethostbyname_r="no"
2756      ])
2757    fi
2758    AC_MSG_CHECKING([if gethostbyname_r is compilable])
2759    if test "$tst_compi_gethostbyname_r" = "yes"; then
2760      AC_MSG_RESULT([yes])
2761    else
2762      AC_MSG_RESULT([no])
2763    fi
2764  fi
2765  #
2766  if test "$tst_compi_gethostbyname_r" = "yes"; then
2767    AC_MSG_CHECKING([if gethostbyname_r usage allowed])
2768    if test "x$curl_disallow_gethostbyname_r" != "xyes"; then
2769      AC_MSG_RESULT([yes])
2770      tst_allow_gethostbyname_r="yes"
2771    else
2772      AC_MSG_RESULT([no])
2773      tst_allow_gethostbyname_r="no"
2774    fi
2775  fi
2776  #
2777  AC_MSG_CHECKING([if gethostbyname_r might be used])
2778  if test "$tst_links_gethostbyname_r" = "yes" &&
2779     test "$tst_proto_gethostbyname_r" = "yes" &&
2780     test "$tst_compi_gethostbyname_r" = "yes" &&
2781     test "$tst_allow_gethostbyname_r" = "yes"; then
2782    AC_MSG_RESULT([yes])
2783    AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
2784      [Define to 1 if you have the gethostbyname_r function.])
2785    dnl AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_ARGS, $tst_nargs_gethostbyname_r,
2786    dnl   [Specifies the number of arguments to gethostbyname_r])
2787    #
2788    if test "$tst_nargs_gethostbyname_r" -eq "3"; then
2789      AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2790    elif test "$tst_nargs_gethostbyname_r" -eq "5"; then
2791      AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
2792    elif test "$tst_nargs_gethostbyname_r" -eq "6"; then
2793      AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
2794    fi
2795    #
2796    curl_cv_func_gethostbyname_r="yes"
2797  else
2798    AC_MSG_RESULT([no])
2799    curl_cv_func_gethostbyname_r="no"
2800  fi
2801])
2802
2803
2804dnl CURL_CHECK_FUNC_GETHOSTNAME
2805dnl -------------------------------------------------
2806dnl Verify if gethostname is available, prototyped, and
2807dnl can be compiled. If all of these are true, and
2808dnl usage has not been previously disallowed with
2809dnl shell variable curl_disallow_gethostname, then
2810dnl HAVE_GETHOSTNAME will be defined.
2811
2812AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
2813  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2814  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
2815  AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
2816  AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
2817  #
2818  tst_links_gethostname="unknown"
2819  tst_proto_gethostname="unknown"
2820  tst_compi_gethostname="unknown"
2821  tst_allow_gethostname="unknown"
2822  #
2823  AC_MSG_CHECKING([if gethostname can be linked])
2824  AC_LINK_IFELSE([
2825    AC_LANG_PROGRAM([[
2826      $curl_includes_winsock2
2827      $curl_includes_bsdsocket
2828      $curl_includes_unistd
2829    ]],[[
2830      if(0 != gethostname(0, 0))
2831        return 1;
2832    ]])
2833  ],[
2834    AC_MSG_RESULT([yes])
2835    tst_links_gethostname="yes"
2836  ],[
2837    AC_MSG_RESULT([no])
2838    tst_links_gethostname="no"
2839  ])
2840  #
2841  if test "$tst_links_gethostname" = "yes"; then
2842    AC_MSG_CHECKING([if gethostname is prototyped])
2843    AC_EGREP_CPP([gethostname],[
2844      $curl_includes_winsock2
2845      $curl_includes_bsdsocket
2846      $curl_includes_unistd
2847    ],[
2848      AC_MSG_RESULT([yes])
2849      tst_proto_gethostname="yes"
2850    ],[
2851      AC_MSG_RESULT([no])
2852      tst_proto_gethostname="no"
2853    ])
2854  fi
2855  #
2856  if test "$tst_proto_gethostname" = "yes"; then
2857    AC_MSG_CHECKING([if gethostname is compilable])
2858    AC_COMPILE_IFELSE([
2859      AC_LANG_PROGRAM([[
2860        $curl_includes_winsock2
2861      $curl_includes_bsdsocket
2862        $curl_includes_unistd
2863      ]],[[
2864        if(0 != gethostname(0, 0))
2865          return 1;
2866      ]])
2867    ],[
2868      AC_MSG_RESULT([yes])
2869      tst_compi_gethostname="yes"
2870    ],[
2871      AC_MSG_RESULT([no])
2872      tst_compi_gethostname="no"
2873    ])
2874  fi
2875  #
2876  if test "$tst_compi_gethostname" = "yes"; then
2877    AC_MSG_CHECKING([for gethostname arg 2 data type])
2878    tst_gethostname_type_arg2="unknown"
2879    for tst_arg1 in 'char *' 'unsigned char *' 'void *'; do
2880      for tst_arg2 in 'int' 'unsigned int' 'size_t'; do
2881        if test "$tst_gethostname_type_arg2" = "unknown"; then
2882          AC_COMPILE_IFELSE([
2883            AC_LANG_PROGRAM([[
2884              $curl_includes_winsock2
2885      $curl_includes_bsdsocket
2886              $curl_includes_unistd
2887              $curl_preprocess_callconv
2888              extern int FUNCALLCONV gethostname($tst_arg1, $tst_arg2);
2889            ]],[[
2890              if(0 != gethostname(0, 0))
2891                return 1;
2892            ]])
2893          ],[
2894            tst_gethostname_type_arg2="$tst_arg2"
2895          ])
2896        fi
2897      done
2898    done
2899    AC_MSG_RESULT([$tst_gethostname_type_arg2])
2900    if test "$tst_gethostname_type_arg2" != "unknown"; then
2901      AC_DEFINE_UNQUOTED(GETHOSTNAME_TYPE_ARG2, $tst_gethostname_type_arg2,
2902        [Define to the type of arg 2 for gethostname.])
2903    fi
2904  fi
2905  #
2906  if test "$tst_compi_gethostname" = "yes"; then
2907    AC_MSG_CHECKING([if gethostname usage allowed])
2908    if test "x$curl_disallow_gethostname" != "xyes"; then
2909      AC_MSG_RESULT([yes])
2910      tst_allow_gethostname="yes"
2911    else
2912      AC_MSG_RESULT([no])
2913      tst_allow_gethostname="no"
2914    fi
2915  fi
2916  #
2917  AC_MSG_CHECKING([if gethostname might be used])
2918  if test "$tst_links_gethostname" = "yes" &&
2919     test "$tst_proto_gethostname" = "yes" &&
2920     test "$tst_compi_gethostname" = "yes" &&
2921     test "$tst_allow_gethostname" = "yes"; then
2922    AC_MSG_RESULT([yes])
2923    AC_DEFINE_UNQUOTED(HAVE_GETHOSTNAME, 1,
2924      [Define to 1 if you have the gethostname function.])
2925    curl_cv_func_gethostname="yes"
2926  else
2927    AC_MSG_RESULT([no])
2928    curl_cv_func_gethostname="no"
2929  fi
2930])
2931
2932dnl CURL_CHECK_FUNC_GETPEERNAME
2933dnl -------------------------------------------------
2934dnl Verify if getpeername is available, prototyped, and
2935dnl can be compiled. If all of these are true, and
2936dnl usage has not been previously disallowed with
2937dnl shell variable curl_disallow_getpeername, then
2938dnl HAVE_GETPEERNAME will be defined.
2939
2940AC_DEFUN([CURL_CHECK_FUNC_GETPEERNAME], [
2941  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2942  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
2943  AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
2944  AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
2945  #
2946  tst_links_getpeername="unknown"
2947  tst_proto_getpeername="unknown"
2948  tst_compi_getpeername="unknown"
2949  tst_allow_getpeername="unknown"
2950  #
2951  AC_MSG_CHECKING([if getpeername can be linked])
2952  AC_LINK_IFELSE([
2953    AC_LANG_PROGRAM([[
2954      $curl_includes_winsock2
2955      $curl_includes_bsdsocket
2956      $curl_includes_sys_socket
2957    ]],[[
2958      if(0 != getpeername(0, (void *)0, (void *)0))
2959        return 1;
2960    ]])
2961  ],[
2962    AC_MSG_RESULT([yes])
2963    tst_links_getpeername="yes"
2964  ],[
2965    AC_MSG_RESULT([no])
2966    tst_links_getpeername="no"
2967  ])
2968  #
2969  if test "$tst_links_getpeername" = "yes"; then
2970    AC_MSG_CHECKING([if getpeername is prototyped])
2971    AC_EGREP_CPP([getpeername],[
2972      $curl_includes_winsock2
2973      $curl_includes_bsdsocket
2974      $curl_includes_sys_socket
2975    ],[
2976      AC_MSG_RESULT([yes])
2977      tst_proto_getpeername="yes"
2978    ],[
2979      AC_MSG_RESULT([no])
2980      tst_proto_getpeername="no"
2981    ])
2982  fi
2983  #
2984  if test "$tst_proto_getpeername" = "yes"; then
2985    AC_MSG_CHECKING([if getpeername is compilable])
2986    AC_COMPILE_IFELSE([
2987      AC_LANG_PROGRAM([[
2988        $curl_includes_winsock2
2989        $curl_includes_bsdsocket
2990        $curl_includes_sys_socket
2991      ]],[[
2992        if(0 != getpeername(0, (void *)0, (void *)0))
2993          return 1;
2994      ]])
2995    ],[
2996      AC_MSG_RESULT([yes])
2997      tst_compi_getpeername="yes"
2998    ],[
2999      AC_MSG_RESULT([no])
3000      tst_compi_getpeername="no"
3001    ])
3002  fi
3003  #
3004  if test "$tst_compi_getpeername" = "yes"; then
3005    AC_MSG_CHECKING([if getpeername usage allowed])
3006    if test "x$curl_disallow_getpeername" != "xyes"; then
3007      AC_MSG_RESULT([yes])
3008      tst_allow_getpeername="yes"
3009    else
3010      AC_MSG_RESULT([no])
3011      tst_allow_getpeername="no"
3012    fi
3013  fi
3014  #
3015  AC_MSG_CHECKING([if getpeername might be used])
3016  if test "$tst_links_getpeername" = "yes" &&
3017     test "$tst_proto_getpeername" = "yes" &&
3018     test "$tst_compi_getpeername" = "yes" &&
3019     test "$tst_allow_getpeername" = "yes"; then
3020    AC_MSG_RESULT([yes])
3021    AC_DEFINE_UNQUOTED(HAVE_GETPEERNAME, 1,
3022      [Define to 1 if you have the getpeername function.])
3023    curl_cv_func_getpeername="yes"
3024  else
3025    AC_MSG_RESULT([no])
3026    curl_cv_func_getpeername="no"
3027  fi
3028])
3029
3030dnl CURL_CHECK_FUNC_GETSOCKNAME
3031dnl -------------------------------------------------
3032dnl Verify if getsockname is available, prototyped, and
3033dnl can be compiled. If all of these are true, and
3034dnl usage has not been previously disallowed with
3035dnl shell variable curl_disallow_getsockname, then
3036dnl HAVE_GETSOCKNAME will be defined.
3037
3038AC_DEFUN([CURL_CHECK_FUNC_GETSOCKNAME], [
3039  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
3040  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
3041  AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
3042  AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
3043  #
3044  tst_links_getsockname="unknown"
3045  tst_proto_getsockname="unknown"
3046  tst_compi_getsockname="unknown"
3047  tst_allow_getsockname="unknown"
3048  #
3049  AC_MSG_CHECKING([if getsockname can be linked])
3050  AC_LINK_IFELSE([
3051    AC_LANG_PROGRAM([[
3052      $curl_includes_winsock2
3053      $curl_includes_bsdsocket
3054      $curl_includes_sys_socket
3055    ]],[[
3056      if(0 != getsockname(0, (void *)0, (void *)0))
3057        return 1;
3058    ]])
3059  ],[
3060    AC_MSG_RESULT([yes])
3061    tst_links_getsockname="yes"
3062  ],[
3063    AC_MSG_RESULT([no])
3064    tst_links_getsockname="no"
3065  ])
3066  #
3067  if test "$tst_links_getsockname" = "yes"; then
3068    AC_MSG_CHECKING([if getsockname is prototyped])
3069    AC_EGREP_CPP([getsockname],[
3070      $curl_includes_winsock2
3071      $curl_includes_bsdsocket
3072      $curl_includes_sys_socket
3073    ],[
3074      AC_MSG_RESULT([yes])
3075      tst_proto_getsockname="yes"
3076    ],[
3077      AC_MSG_RESULT([no])
3078      tst_proto_getsockname="no"
3079    ])
3080  fi
3081  #
3082  if test "$tst_proto_getsockname" = "yes"; then
3083    AC_MSG_CHECKING([if getsockname is compilable])
3084    AC_COMPILE_IFELSE([
3085      AC_LANG_PROGRAM([[
3086        $curl_includes_winsock2
3087        $curl_includes_bsdsocket
3088        $curl_includes_sys_socket
3089      ]],[[
3090        if(0 != getsockname(0, (void *)0, (void *)0))
3091          return 1;
3092      ]])
3093    ],[
3094      AC_MSG_RESULT([yes])
3095      tst_compi_getsockname="yes"
3096    ],[
3097      AC_MSG_RESULT([no])
3098      tst_compi_getsockname="no"
3099    ])
3100  fi
3101  #
3102  if test "$tst_compi_getsockname" = "yes"; then
3103    AC_MSG_CHECKING([if getsockname usage allowed])
3104    if test "x$curl_disallow_getsockname" != "xyes"; then
3105      AC_MSG_RESULT([yes])
3106      tst_allow_getsockname="yes"
3107    else
3108      AC_MSG_RESULT([no])
3109      tst_allow_getsockname="no"
3110    fi
3111  fi
3112  #
3113  AC_MSG_CHECKING([if getsockname might be used])
3114  if test "$tst_links_getsockname" = "yes" &&
3115     test "$tst_proto_getsockname" = "yes" &&
3116     test "$tst_compi_getsockname" = "yes" &&
3117     test "$tst_allow_getsockname" = "yes"; then
3118    AC_MSG_RESULT([yes])
3119    AC_DEFINE_UNQUOTED(HAVE_GETSOCKNAME, 1,
3120      [Define to 1 if you have the getsockname function.])
3121    curl_cv_func_getsockname="yes"
3122  else
3123    AC_MSG_RESULT([no])
3124    curl_cv_func_getsockname="no"
3125  fi
3126])
3127
3128dnl CURL_CHECK_FUNC_IF_NAMETOINDEX
3129dnl -------------------------------------------------
3130dnl Verify if if_nametoindex is available, prototyped, and
3131dnl can be compiled. If all of these are true, and
3132dnl usage has not been previously disallowed with
3133dnl shell variable curl_disallow_if_nametoindex, then
3134dnl HAVE_IF_NAMETOINDEX will be defined.
3135
3136AC_DEFUN([CURL_CHECK_FUNC_IF_NAMETOINDEX], [
3137  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
3138  AC_REQUIRE([CURL_INCLUDES_NETIF])dnl
3139  AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
3140  #
3141  tst_links_if_nametoindex="unknown"
3142  tst_proto_if_nametoindex="unknown"
3143  tst_compi_if_nametoindex="unknown"
3144  tst_allow_if_nametoindex="unknown"
3145  #
3146  AC_MSG_CHECKING([if if_nametoindex can be linked])
3147  AC_LINK_IFELSE([
3148    AC_LANG_PROGRAM([[
3149      $curl_includes_winsock2
3150      $curl_includes_bsdsocket
3151      #include <net/if.h>
3152    ]],[[
3153      if(0 != if_nametoindex(""))
3154        return 1;
3155    ]])
3156  ],[
3157    AC_MSG_RESULT([yes])
3158    tst_links_if_nametoindex="yes"
3159  ],[
3160    AC_MSG_RESULT([no])
3161    tst_links_if_nametoindex="no"
3162  ])
3163  #
3164  if test "$tst_links_if_nametoindex" = "yes"; then
3165    AC_MSG_CHECKING([if if_nametoindex is prototyped])
3166    AC_EGREP_CPP([if_nametoindex],[
3167      $curl_includes_winsock2
3168      $curl_includes_netif
3169    ],[
3170      AC_MSG_RESULT([yes])
3171      tst_proto_if_nametoindex="yes"
3172    ],[
3173      AC_MSG_RESULT([no])
3174      tst_proto_if_nametoindex="no"
3175    ])
3176  fi
3177  #
3178  if test "$tst_proto_if_nametoindex" = "yes"; then
3179    AC_MSG_CHECKING([if if_nametoindex is compilable])
3180    AC_COMPILE_IFELSE([
3181      AC_LANG_PROGRAM([[
3182        $curl_includes_winsock2
3183        $curl_includes_netif
3184      ]],[[
3185        if(0 != if_nametoindex(""))
3186          return 1;
3187      ]])
3188    ],[
3189      AC_MSG_RESULT([yes])
3190      tst_compi_if_nametoindex="yes"
3191    ],[
3192      AC_MSG_RESULT([no])
3193      tst_compi_if_nametoindex="no"
3194    ])
3195  fi
3196  #
3197  if test "$tst_compi_if_nametoindex" = "yes"; then
3198    AC_MSG_CHECKING([if if_nametoindex usage allowed])
3199    if test "x$curl_disallow_if_nametoindex" != "xyes"; then
3200      AC_MSG_RESULT([yes])
3201      tst_allow_if_nametoindex="yes"
3202    else
3203      AC_MSG_RESULT([no])
3204      tst_allow_if_nametoindex="no"
3205    fi
3206  fi
3207  #
3208  AC_MSG_CHECKING([if if_nametoindex might be used])
3209  if test "$tst_links_if_nametoindex" = "yes" &&
3210     test "$tst_proto_if_nametoindex" = "yes" &&
3211     test "$tst_compi_if_nametoindex" = "yes" &&
3212     test "$tst_allow_if_nametoindex" = "yes"; then
3213    AC_MSG_RESULT([yes])
3214    AC_DEFINE_UNQUOTED(HAVE_IF_NAMETOINDEX, 1,
3215      [Define to 1 if you have the if_nametoindex function.])
3216    curl_cv_func_if_nametoindex="yes"
3217  else
3218    AC_MSG_RESULT([no])
3219    curl_cv_func_if_nametoindex="no"
3220  fi
3221])
3222
3223
3224dnl CURL_CHECK_FUNC_GETIFADDRS
3225dnl -------------------------------------------------
3226dnl Verify if getifaddrs is available, prototyped, can
3227dnl be compiled and seems to work. If all of these are
3228dnl true, and usage has not been previously disallowed
3229dnl with shell variable curl_disallow_getifaddrs, then
3230dnl HAVE_GETIFADDRS will be defined.
3231
3232AC_DEFUN([CURL_CHECK_FUNC_GETIFADDRS], [
3233  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3234  AC_REQUIRE([CURL_INCLUDES_IFADDRS])dnl
3235  #
3236  tst_links_getifaddrs="unknown"
3237  tst_proto_getifaddrs="unknown"
3238  tst_compi_getifaddrs="unknown"
3239  tst_works_getifaddrs="unknown"
3240  tst_allow_getifaddrs="unknown"
3241  #
3242  AC_MSG_CHECKING([if getifaddrs can be linked])
3243  AC_LINK_IFELSE([
3244    AC_LANG_FUNC_LINK_TRY([getifaddrs])
3245  ],[
3246    AC_MSG_RESULT([yes])
3247    tst_links_getifaddrs="yes"
3248  ],[
3249    AC_MSG_RESULT([no])
3250    tst_links_getifaddrs="no"
3251  ])
3252  #
3253  if test "$tst_links_getifaddrs" = "yes"; then
3254    AC_MSG_CHECKING([if getifaddrs is prototyped])
3255    AC_EGREP_CPP([getifaddrs],[
3256      $curl_includes_ifaddrs
3257    ],[
3258      AC_MSG_RESULT([yes])
3259      tst_proto_getifaddrs="yes"
3260    ],[
3261      AC_MSG_RESULT([no])
3262      tst_proto_getifaddrs="no"
3263    ])
3264  fi
3265  #
3266  if test "$tst_proto_getifaddrs" = "yes"; then
3267    AC_MSG_CHECKING([if getifaddrs is compilable])
3268    AC_COMPILE_IFELSE([
3269      AC_LANG_PROGRAM([[
3270        $curl_includes_ifaddrs
3271      ]],[[
3272        if(0 != getifaddrs(0))
3273          return 1;
3274      ]])
3275    ],[
3276      AC_MSG_RESULT([yes])
3277      tst_compi_getifaddrs="yes"
3278    ],[
3279      AC_MSG_RESULT([no])
3280      tst_compi_getifaddrs="no"
3281    ])
3282  fi
3283  #
3284  dnl only do runtime verification when not cross-compiling
3285  if test "x$cross_compiling" != "xyes" &&
3286    test "$tst_compi_getifaddrs" = "yes"; then
3287    AC_MSG_CHECKING([if getifaddrs seems to work])
3288    CURL_RUN_IFELSE([
3289      AC_LANG_PROGRAM([[
3290        $curl_includes_stdlib
3291        $curl_includes_ifaddrs
3292      ]],[[
3293        struct ifaddrs *ifa = 0;
3294        int error;
3295
3296        error = getifaddrs(&ifa);
3297        if(error || !ifa)
3298          exit(1); /* fail */
3299        else
3300          exit(0);
3301      ]])
3302    ],[
3303      AC_MSG_RESULT([yes])
3304      tst_works_getifaddrs="yes"
3305    ],[
3306      AC_MSG_RESULT([no])
3307      tst_works_getifaddrs="no"
3308    ])
3309  fi
3310  #
3311  if test "$tst_compi_getifaddrs" = "yes" &&
3312    test "$tst_works_getifaddrs" != "no"; then
3313    AC_MSG_CHECKING([if getifaddrs usage allowed])
3314    if test "x$curl_disallow_getifaddrs" != "xyes"; then
3315      AC_MSG_RESULT([yes])
3316      tst_allow_getifaddrs="yes"
3317    else
3318      AC_MSG_RESULT([no])
3319      tst_allow_getifaddrs="no"
3320    fi
3321  fi
3322  #
3323  AC_MSG_CHECKING([if getifaddrs might be used])
3324  if test "$tst_links_getifaddrs" = "yes" &&
3325     test "$tst_proto_getifaddrs" = "yes" &&
3326     test "$tst_compi_getifaddrs" = "yes" &&
3327     test "$tst_allow_getifaddrs" = "yes" &&
3328     test "$tst_works_getifaddrs" != "no"; then
3329    AC_MSG_RESULT([yes])
3330    AC_DEFINE_UNQUOTED(HAVE_GETIFADDRS, 1,
3331      [Define to 1 if you have a working getifaddrs function.])
3332    curl_cv_func_getifaddrs="yes"
3333  else
3334    AC_MSG_RESULT([no])
3335    curl_cv_func_getifaddrs="no"
3336  fi
3337])
3338
3339
3340dnl CURL_CHECK_FUNC_GETSERVBYPORT_R
3341dnl -------------------------------------------------
3342dnl Verify if getservbyport_r is available, prototyped,
3343dnl and can be compiled. If all of these are true, and
3344dnl usage has not been previously disallowed with
3345dnl shell variable curl_disallow_getservbyport_r, then
3346dnl HAVE_GETSERVBYPORT_R will be defined.
3347
3348AC_DEFUN([CURL_CHECK_FUNC_GETSERVBYPORT_R], [
3349  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
3350  #
3351  tst_links_getservbyport_r="unknown"
3352  tst_proto_getservbyport_r="unknown"
3353  tst_compi_getservbyport_r="unknown"
3354  tst_allow_getservbyport_r="unknown"
3355  tst_nargs_getservbyport_r="unknown"
3356  #
3357  AC_MSG_CHECKING([if getservbyport_r can be linked])
3358  AC_LINK_IFELSE([
3359    AC_LANG_FUNC_LINK_TRY([getservbyport_r])
3360  ],[
3361    AC_MSG_RESULT([yes])
3362    tst_links_getservbyport_r="yes"
3363  ],[
3364    AC_MSG_RESULT([no])
3365    tst_links_getservbyport_r="no"
3366  ])
3367  #
3368  if test "$tst_links_getservbyport_r" = "yes"; then
3369    AC_MSG_CHECKING([if getservbyport_r is prototyped])
3370    AC_EGREP_CPP([getservbyport_r],[
3371      $curl_includes_netdb
3372    ],[
3373      AC_MSG_RESULT([yes])
3374      tst_proto_getservbyport_r="yes"
3375    ],[
3376      AC_MSG_RESULT([no])
3377      tst_proto_getservbyport_r="no"
3378    ])
3379  fi
3380  #
3381  if test "$tst_proto_getservbyport_r" = "yes"; then
3382    if test "$tst_nargs_getservbyport_r" = "unknown"; then
3383      AC_MSG_CHECKING([if getservbyport_r takes 4 args.])
3384      AC_COMPILE_IFELSE([
3385        AC_LANG_PROGRAM([[
3386          $curl_includes_netdb
3387        ]],[[
3388          if(0 != getservbyport_r(0, 0, 0, 0))
3389            return 1;
3390        ]])
3391      ],[
3392        AC_MSG_RESULT([yes])
3393        tst_compi_getservbyport_r="yes"
3394        tst_nargs_getservbyport_r="4"
3395      ],[
3396        AC_MSG_RESULT([no])
3397        tst_compi_getservbyport_r="no"
3398      ])
3399    fi
3400    if test "$tst_nargs_getservbyport_r" = "unknown"; then
3401      AC_MSG_CHECKING([if getservbyport_r takes 5 args.])
3402      AC_COMPILE_IFELSE([
3403        AC_LANG_PROGRAM([[
3404          $curl_includes_netdb
3405        ]],[[
3406          if(0 != getservbyport_r(0, 0, 0, 0, 0))
3407            return 1;
3408        ]])
3409      ],[
3410        AC_MSG_RESULT([yes])
3411        tst_compi_getservbyport_r="yes"
3412        tst_nargs_getservbyport_r="5"
3413      ],[
3414        AC_MSG_RESULT([no])
3415        tst_compi_getservbyport_r="no"
3416      ])
3417    fi
3418    if test "$tst_nargs_getservbyport_r" = "unknown"; then
3419      AC_MSG_CHECKING([if getservbyport_r takes 6 args.])
3420      AC_COMPILE_IFELSE([
3421        AC_LANG_PROGRAM([[
3422          $curl_includes_netdb
3423        ]],[[
3424          if(0 != getservbyport_r(0, 0, 0, 0, 0, 0))
3425            return 1;
3426        ]])
3427      ],[
3428        AC_MSG_RESULT([yes])
3429        tst_compi_getservbyport_r="yes"
3430        tst_nargs_getservbyport_r="6"
3431      ],[
3432        AC_MSG_RESULT([no])
3433        tst_compi_getservbyport_r="no"
3434      ])
3435    fi
3436    AC_MSG_CHECKING([if getservbyport_r is compilable])
3437    if test "$tst_compi_getservbyport_r" = "yes"; then
3438      AC_MSG_RESULT([yes])
3439    else
3440      AC_MSG_RESULT([no])
3441    fi
3442  fi
3443  #
3444  if test "$tst_compi_getservbyport_r" = "yes"; then
3445    AC_MSG_CHECKING([if getservbyport_r usage allowed])
3446    if test "x$curl_disallow_getservbyport_r" != "xyes"; then
3447      AC_MSG_RESULT([yes])
3448      tst_allow_getservbyport_r="yes"
3449    else
3450      AC_MSG_RESULT([no])
3451      tst_allow_getservbyport_r="no"
3452    fi
3453  fi
3454  #
3455  AC_MSG_CHECKING([if getservbyport_r might be used])
3456  if test "$tst_links_getservbyport_r" = "yes" &&
3457     test "$tst_proto_getservbyport_r" = "yes" &&
3458     test "$tst_compi_getservbyport_r" = "yes" &&
3459     test "$tst_allow_getservbyport_r" = "yes"; then
3460    AC_MSG_RESULT([yes])
3461    AC_DEFINE_UNQUOTED(HAVE_GETSERVBYPORT_R, 1,
3462      [Define to 1 if you have the getservbyport_r function.])
3463    AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $tst_nargs_getservbyport_r,
3464      [Specifies the number of arguments to getservbyport_r])
3465    if test "$tst_nargs_getservbyport_r" -eq "4"; then
3466      AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
3467        [Specifies the size of the buffer to pass to getservbyport_r])
3468    else
3469      AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
3470        [Specifies the size of the buffer to pass to getservbyport_r])
3471    fi
3472    curl_cv_func_getservbyport_r="yes"
3473  else
3474    AC_MSG_RESULT([no])
3475    curl_cv_func_getservbyport_r="no"
3476  fi
3477])
3478
3479
3480dnl CURL_CHECK_FUNC_GETXATTR
3481dnl -------------------------------------------------
3482dnl Verify if getxattr is available, prototyped, and
3483dnl can be compiled. If all of these are true, and
3484dnl usage has not been previously disallowed with
3485dnl shell variable curl_disallow_getxattr, then
3486dnl HAVE_GETXATTR will be defined.
3487
3488AC_DEFUN([CURL_CHECK_FUNC_GETXATTR], [
3489  AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
3490  #
3491  tst_links_getxattr="unknown"
3492  tst_proto_getxattr="unknown"
3493  tst_compi_getxattr="unknown"
3494  tst_allow_getxattr="unknown"
3495  tst_nargs_getxattr="unknown"
3496  #
3497  AC_MSG_CHECKING([if getxattr can be linked])
3498  AC_LINK_IFELSE([
3499    AC_LANG_FUNC_LINK_TRY([getxattr])
3500  ],[
3501    AC_MSG_RESULT([yes])
3502    tst_links_getxattr="yes"
3503  ],[
3504    AC_MSG_RESULT([no])
3505    tst_links_getxattr="no"
3506  ])
3507  #
3508  if test "$tst_links_getxattr" = "yes"; then
3509    AC_MSG_CHECKING([if getxattr is prototyped])
3510    AC_EGREP_CPP([getxattr],[
3511      $curl_includes_sys_xattr
3512    ],[
3513      AC_MSG_RESULT([yes])
3514      tst_proto_getxattr="yes"
3515    ],[
3516      AC_MSG_RESULT([no])
3517      tst_proto_getxattr="no"
3518    ])
3519  fi
3520  #
3521  if test "$tst_proto_getxattr" = "yes"; then
3522    if test "$tst_nargs_getxattr" = "unknown"; then
3523      AC_MSG_CHECKING([if getxattr takes 4 args.])
3524      AC_COMPILE_IFELSE([
3525        AC_LANG_PROGRAM([[
3526          $curl_includes_sys_xattr
3527        ]],[[
3528          if(0 != getxattr(0, 0, 0, 0))
3529            return 1;
3530        ]])
3531      ],[
3532        AC_MSG_RESULT([yes])
3533        tst_compi_getxattr="yes"
3534        tst_nargs_getxattr="4"
3535      ],[
3536        AC_MSG_RESULT([no])
3537        tst_compi_getxattr="no"
3538      ])
3539    fi
3540    if test "$tst_nargs_getxattr" = "unknown"; then
3541      AC_MSG_CHECKING([if getxattr takes 6 args.])
3542      AC_COMPILE_IFELSE([
3543        AC_LANG_PROGRAM([[
3544          $curl_includes_sys_xattr
3545        ]],[[
3546          if(0 != getxattr(0, 0, 0, 0, 0, 0))
3547            return 1;
3548        ]])
3549      ],[
3550        AC_MSG_RESULT([yes])
3551        tst_compi_getxattr="yes"
3552        tst_nargs_getxattr="6"
3553      ],[
3554        AC_MSG_RESULT([no])
3555        tst_compi_getxattr="no"
3556      ])
3557    fi
3558    AC_MSG_CHECKING([if getxattr is compilable])
3559    if test "$tst_compi_getxattr" = "yes"; then
3560      AC_MSG_RESULT([yes])
3561    else
3562      AC_MSG_RESULT([no])
3563    fi
3564  fi
3565  #
3566  if test "$tst_compi_getxattr" = "yes"; then
3567    AC_MSG_CHECKING([if getxattr usage allowed])
3568    if test "x$curl_disallow_getxattr" != "xyes"; then
3569      AC_MSG_RESULT([yes])
3570      tst_allow_getxattr="yes"
3571    else
3572      AC_MSG_RESULT([no])
3573      tst_allow_getxattr="no"
3574    fi
3575  fi
3576  #
3577  AC_MSG_CHECKING([if getxattr might be used])
3578  if test "$tst_links_getxattr" = "yes" &&
3579     test "$tst_proto_getxattr" = "yes" &&
3580     test "$tst_compi_getxattr" = "yes" &&
3581     test "$tst_allow_getxattr" = "yes"; then
3582    AC_MSG_RESULT([yes])
3583    AC_DEFINE_UNQUOTED(HAVE_GETXATTR, 1,
3584      [Define to 1 if you have the getxattr function.])
3585    dnl AC_DEFINE_UNQUOTED(GETXATTR_ARGS, $tst_nargs_getxattr,
3586    dnl   [Specifies the number of arguments to getxattr])
3587    #
3588    if test "$tst_nargs_getxattr" -eq "4"; then
3589      AC_DEFINE(HAVE_GETXATTR_4, 1, [getxattr() takes 4 args])
3590    elif test "$tst_nargs_getxattr" -eq "6"; then
3591      AC_DEFINE(HAVE_GETXATTR_6, 1, [getxattr() takes 6 args])
3592    fi
3593    #
3594    curl_cv_func_getxattr="yes"
3595  else
3596    AC_MSG_RESULT([no])
3597    curl_cv_func_getxattr="no"
3598  fi
3599])
3600
3601
3602dnl CURL_CHECK_FUNC_GMTIME_R
3603dnl -------------------------------------------------
3604dnl Verify if gmtime_r is available, prototyped, can
3605dnl be compiled and seems to work. If all of these are
3606dnl true, and usage has not been previously disallowed
3607dnl with shell variable curl_disallow_gmtime_r, then
3608dnl HAVE_GMTIME_R will be defined.
3609
3610AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [
3611  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3612  AC_REQUIRE([CURL_INCLUDES_TIME])dnl
3613  #
3614  tst_links_gmtime_r="unknown"
3615  tst_proto_gmtime_r="unknown"
3616  tst_compi_gmtime_r="unknown"
3617  tst_works_gmtime_r="unknown"
3618  tst_allow_gmtime_r="unknown"
3619  #
3620  AC_MSG_CHECKING([if gmtime_r can be linked])
3621  AC_LINK_IFELSE([
3622    AC_LANG_FUNC_LINK_TRY([gmtime_r])
3623  ],[
3624    AC_MSG_RESULT([yes])
3625    tst_links_gmtime_r="yes"
3626  ],[
3627    AC_MSG_RESULT([no])
3628    tst_links_gmtime_r="no"
3629  ])
3630  #
3631  if test "$tst_links_gmtime_r" = "yes"; then
3632    AC_MSG_CHECKING([if gmtime_r is prototyped])
3633    AC_EGREP_CPP([gmtime_r],[
3634      $curl_includes_time
3635    ],[
3636      AC_MSG_RESULT([yes])
3637      tst_proto_gmtime_r="yes"
3638    ],[
3639      AC_MSG_RESULT([no])
3640      tst_proto_gmtime_r="no"
3641    ])
3642  fi
3643  #
3644  if test "$tst_proto_gmtime_r" = "yes"; then
3645    AC_MSG_CHECKING([if gmtime_r is compilable])
3646    AC_COMPILE_IFELSE([
3647      AC_LANG_PROGRAM([[
3648        $curl_includes_time
3649      ]],[[
3650        if(0 != gmtime_r(0, 0))
3651          return 1;
3652      ]])
3653    ],[
3654      AC_MSG_RESULT([yes])
3655      tst_compi_gmtime_r="yes"
3656    ],[
3657      AC_MSG_RESULT([no])
3658      tst_compi_gmtime_r="no"
3659    ])
3660  fi
3661  #
3662  dnl only do runtime verification when not cross-compiling
3663  if test "x$cross_compiling" != "xyes" &&
3664    test "$tst_compi_gmtime_r" = "yes"; then
3665    AC_MSG_CHECKING([if gmtime_r seems to work])
3666    CURL_RUN_IFELSE([
3667      AC_LANG_PROGRAM([[
3668        $curl_includes_stdlib
3669        $curl_includes_time
3670      ]],[[
3671        time_t local = 1170352587;
3672        struct tm *gmt = 0;
3673        struct tm result;
3674        gmt = gmtime_r(&local, &result);
3675        if(gmt)
3676          exit(0);
3677        else
3678          exit(1);
3679      ]])
3680    ],[
3681      AC_MSG_RESULT([yes])
3682      tst_works_gmtime_r="yes"
3683    ],[
3684      AC_MSG_RESULT([no])
3685      tst_works_gmtime_r="no"
3686    ])
3687  fi
3688  #
3689  if test "$tst_compi_gmtime_r" = "yes" &&
3690    test "$tst_works_gmtime_r" != "no"; then
3691    AC_MSG_CHECKING([if gmtime_r usage allowed])
3692    if test "x$curl_disallow_gmtime_r" != "xyes"; then
3693      AC_MSG_RESULT([yes])
3694      tst_allow_gmtime_r="yes"
3695    else
3696      AC_MSG_RESULT([no])
3697      tst_allow_gmtime_r="no"
3698    fi
3699  fi
3700  #
3701  AC_MSG_CHECKING([if gmtime_r might be used])
3702  if test "$tst_links_gmtime_r" = "yes" &&
3703     test "$tst_proto_gmtime_r" = "yes" &&
3704     test "$tst_compi_gmtime_r" = "yes" &&
3705     test "$tst_allow_gmtime_r" = "yes" &&
3706     test "$tst_works_gmtime_r" != "no"; then
3707    AC_MSG_RESULT([yes])
3708    AC_DEFINE_UNQUOTED(HAVE_GMTIME_R, 1,
3709      [Define to 1 if you have a working gmtime_r function.])
3710    curl_cv_func_gmtime_r="yes"
3711  else
3712    AC_MSG_RESULT([no])
3713    curl_cv_func_gmtime_r="no"
3714  fi
3715])
3716
3717
3718dnl CURL_CHECK_FUNC_INET_NTOA_R
3719dnl -------------------------------------------------
3720dnl Verify if inet_ntoa_r is available, prototyped,
3721dnl and can be compiled. If all of these are true, and
3722dnl usage has not been previously disallowed with
3723dnl shell variable curl_disallow_inet_ntoa_r, then
3724dnl HAVE_INET_NTOA_R will be defined.
3725
3726AC_DEFUN([CURL_CHECK_FUNC_INET_NTOA_R], [
3727  AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
3728  #
3729  tst_links_inet_ntoa_r="unknown"
3730  tst_proto_inet_ntoa_r="unknown"
3731  tst_compi_inet_ntoa_r="unknown"
3732  tst_allow_inet_ntoa_r="unknown"
3733  tst_nargs_inet_ntoa_r="unknown"
3734  #
3735  AC_MSG_CHECKING([if inet_ntoa_r can be linked])
3736  AC_LINK_IFELSE([
3737    AC_LANG_FUNC_LINK_TRY([inet_ntoa_r])
3738  ],[
3739    AC_MSG_RESULT([yes])
3740    tst_links_inet_ntoa_r="yes"
3741  ],[
3742    AC_MSG_RESULT([no])
3743    tst_links_inet_ntoa_r="no"
3744  ])
3745  #
3746  if test "$tst_links_inet_ntoa_r" = "yes"; then
3747    AC_MSG_CHECKING([if inet_ntoa_r is prototyped])
3748    AC_EGREP_CPP([inet_ntoa_r],[
3749      $curl_includes_arpa_inet
3750    ],[
3751      AC_MSG_RESULT([yes])
3752      tst_proto_inet_ntoa_r="yes"
3753    ],[
3754      AC_MSG_RESULT([no])
3755      tst_proto_inet_ntoa_r="no"
3756    ])
3757  fi
3758  #
3759  if test "$tst_proto_inet_ntoa_r" = "yes"; then
3760    if test "$tst_nargs_inet_ntoa_r" = "unknown"; then
3761      AC_MSG_CHECKING([if inet_ntoa_r takes 2 args.])
3762      AC_COMPILE_IFELSE([
3763        AC_LANG_PROGRAM([[
3764          $curl_includes_arpa_inet
3765        ]],[[
3766          struct in_addr addr;
3767          if(0 != inet_ntoa_r(addr, 0))
3768            return 1;
3769        ]])
3770      ],[
3771        AC_MSG_RESULT([yes])
3772        tst_compi_inet_ntoa_r="yes"
3773        tst_nargs_inet_ntoa_r="2"
3774      ],[
3775        AC_MSG_RESULT([no])
3776        tst_compi_inet_ntoa_r="no"
3777      ])
3778    fi
3779    if test "$tst_nargs_inet_ntoa_r" = "unknown"; then
3780      AC_MSG_CHECKING([if inet_ntoa_r takes 3 args.])
3781      AC_COMPILE_IFELSE([
3782        AC_LANG_PROGRAM([[
3783          $curl_includes_arpa_inet
3784        ]],[[
3785          struct in_addr addr;
3786          if(0 != inet_ntoa_r(addr, 0, 0))
3787            return 1;
3788        ]])
3789      ],[
3790        AC_MSG_RESULT([yes])
3791        tst_compi_inet_ntoa_r="yes"
3792        tst_nargs_inet_ntoa_r="3"
3793      ],[
3794        AC_MSG_RESULT([no])
3795        tst_compi_inet_ntoa_r="no"
3796      ])
3797    fi
3798    AC_MSG_CHECKING([if inet_ntoa_r is compilable])
3799    if test "$tst_compi_inet_ntoa_r" = "yes"; then
3800      AC_MSG_RESULT([yes])
3801    else
3802      AC_MSG_RESULT([no])
3803    fi
3804  fi
3805  #
3806  if test "$tst_compi_inet_ntoa_r" = "yes"; then
3807    AC_MSG_CHECKING([if inet_ntoa_r usage allowed])
3808    if test "x$curl_disallow_inet_ntoa_r" != "xyes"; then
3809      AC_MSG_RESULT([yes])
3810      tst_allow_inet_ntoa_r="yes"
3811    else
3812      AC_MSG_RESULT([no])
3813      tst_allow_inet_ntoa_r="no"
3814    fi
3815  fi
3816  #
3817  AC_MSG_CHECKING([if inet_ntoa_r might be used])
3818  if test "$tst_links_inet_ntoa_r" = "yes" &&
3819     test "$tst_proto_inet_ntoa_r" = "yes" &&
3820     test "$tst_compi_inet_ntoa_r" = "yes" &&
3821     test "$tst_allow_inet_ntoa_r" = "yes"; then
3822    AC_MSG_RESULT([yes])
3823    AC_DEFINE_UNQUOTED(HAVE_INET_NTOA_R, 1,
3824      [Define to 1 if you have the inet_ntoa_r function.])
3825    dnl AC_DEFINE_UNQUOTED(INET_NTOA_R_ARGS, $tst_nargs_inet_ntoa_r,
3826    dnl   [Specifies the number of arguments to inet_ntoa_r])
3827    #
3828    if test "$tst_nargs_inet_ntoa_r" -eq "2"; then
3829      AC_DEFINE(HAVE_INET_NTOA_R_2, 1, [inet_ntoa_r() takes 2 args])
3830    elif test "$tst_nargs_inet_ntoa_r" -eq "3"; then
3831      AC_DEFINE(HAVE_INET_NTOA_R_3, 1, [inet_ntoa_r() takes 3 args])
3832    fi
3833    #
3834    curl_cv_func_inet_ntoa_r="yes"
3835  else
3836    AC_MSG_RESULT([no])
3837    curl_cv_func_inet_ntoa_r="no"
3838  fi
3839])
3840
3841
3842dnl CURL_CHECK_FUNC_INET_NTOP
3843dnl -------------------------------------------------
3844dnl Verify if inet_ntop is available, prototyped, can
3845dnl be compiled and seems to work. If all of these are
3846dnl true, and usage has not been previously disallowed
3847dnl with shell variable curl_disallow_inet_ntop, then
3848dnl HAVE_INET_NTOP will be defined.
3849
3850AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
3851  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3852  AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
3853  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3854  #
3855  tst_links_inet_ntop="unknown"
3856  tst_proto_inet_ntop="unknown"
3857  tst_compi_inet_ntop="unknown"
3858  tst_works_inet_ntop="unknown"
3859  tst_allow_inet_ntop="unknown"
3860  #
3861  AC_MSG_CHECKING([if inet_ntop can be linked])
3862  AC_LINK_IFELSE([
3863    AC_LANG_FUNC_LINK_TRY([inet_ntop])
3864  ],[
3865    AC_MSG_RESULT([yes])
3866    tst_links_inet_ntop="yes"
3867  ],[
3868    AC_MSG_RESULT([no])
3869    tst_links_inet_ntop="no"
3870  ])
3871  #
3872  if test "$tst_links_inet_ntop" = "yes"; then
3873    AC_MSG_CHECKING([if inet_ntop is prototyped])
3874    AC_EGREP_CPP([inet_ntop],[
3875      $curl_includes_arpa_inet
3876    ],[
3877      AC_MSG_RESULT([yes])
3878      tst_proto_inet_ntop="yes"
3879    ],[
3880      AC_MSG_RESULT([no])
3881      tst_proto_inet_ntop="no"
3882    ])
3883  fi
3884  #
3885  if test "$tst_proto_inet_ntop" = "yes"; then
3886    AC_MSG_CHECKING([if inet_ntop is compilable])
3887    AC_COMPILE_IFELSE([
3888      AC_LANG_PROGRAM([[
3889        $curl_includes_arpa_inet
3890      ]],[[
3891        if(0 != inet_ntop(0, 0, 0, 0))
3892          return 1;
3893      ]])
3894    ],[
3895      AC_MSG_RESULT([yes])
3896      tst_compi_inet_ntop="yes"
3897    ],[
3898      AC_MSG_RESULT([no])
3899      tst_compi_inet_ntop="no"
3900    ])
3901  fi
3902  #
3903  dnl only do runtime verification when not cross-compiling
3904  if test "x$cross_compiling" != "xyes" &&
3905    test "$tst_compi_inet_ntop" = "yes"; then
3906    AC_MSG_CHECKING([if inet_ntop seems to work])
3907    CURL_RUN_IFELSE([
3908      AC_LANG_PROGRAM([[
3909        $curl_includes_stdlib
3910        $curl_includes_arpa_inet
3911        $curl_includes_string
3912      ]],[[
3913        char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
3914        char ipv4res[sizeof "255.255.255.255"];
3915        unsigned char ipv6a[26];
3916        unsigned char ipv4a[5];
3917        char *ipv6ptr = 0;
3918        char *ipv4ptr = 0;
3919        /* - */
3920        ipv4res[0] = '\0';
3921        ipv4a[0] = 0xc0;
3922        ipv4a[1] = 0xa8;
3923        ipv4a[2] = 0x64;
3924        ipv4a[3] = 0x01;
3925        ipv4a[4] = 0x01;
3926        /* - */
3927        ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
3928        if(!ipv4ptr)
3929          exit(1); /* fail */
3930        if(ipv4ptr != ipv4res)
3931          exit(1); /* fail */
3932        if(!ipv4ptr[0])
3933          exit(1); /* fail */
3934        if(memcmp(ipv4res, "192.168.100.1", 13) != 0)
3935          exit(1); /* fail */
3936        /* - */
3937        ipv6res[0] = '\0';
3938        memset(ipv6a, 0, sizeof(ipv6a));
3939        ipv6a[0] = 0xfe;
3940        ipv6a[1] = 0x80;
3941        ipv6a[8] = 0x02;
3942        ipv6a[9] = 0x14;
3943        ipv6a[10] = 0x4f;
3944        ipv6a[11] = 0xff;
3945        ipv6a[12] = 0xfe;
3946        ipv6a[13] = 0x0b;
3947        ipv6a[14] = 0x76;
3948        ipv6a[15] = 0xc8;
3949        ipv6a[25] = 0x01;
3950        /* - */
3951        ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
3952        if(!ipv6ptr)
3953          exit(1); /* fail */
3954        if(ipv6ptr != ipv6res)
3955          exit(1); /* fail */
3956        if(!ipv6ptr[0])
3957          exit(1); /* fail */
3958        if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24) != 0)
3959          exit(1); /* fail */
3960        /* - */
3961        exit(0);
3962      ]])
3963    ],[
3964      AC_MSG_RESULT([yes])
3965      tst_works_inet_ntop="yes"
3966    ],[
3967      AC_MSG_RESULT([no])
3968      tst_works_inet_ntop="no"
3969    ])
3970  fi
3971  #
3972  if test "$tst_compi_inet_ntop" = "yes" &&
3973    test "$tst_works_inet_ntop" != "no"; then
3974    AC_MSG_CHECKING([if inet_ntop usage allowed])
3975    if test "x$curl_disallow_inet_ntop" != "xyes"; then
3976      AC_MSG_RESULT([yes])
3977      tst_allow_inet_ntop="yes"
3978    else
3979      AC_MSG_RESULT([no])
3980      tst_allow_inet_ntop="no"
3981    fi
3982  fi
3983  #
3984  AC_MSG_CHECKING([if inet_ntop might be used])
3985  if test "$tst_links_inet_ntop" = "yes" &&
3986     test "$tst_proto_inet_ntop" = "yes" &&
3987     test "$tst_compi_inet_ntop" = "yes" &&
3988     test "$tst_allow_inet_ntop" = "yes" &&
3989     test "$tst_works_inet_ntop" != "no"; then
3990    AC_MSG_RESULT([yes])
3991    AC_DEFINE_UNQUOTED(HAVE_INET_NTOP, 1,
3992      [Define to 1 if you have a IPv6 capable working inet_ntop function.])
3993    curl_cv_func_inet_ntop="yes"
3994  else
3995    AC_MSG_RESULT([no])
3996    curl_cv_func_inet_ntop="no"
3997  fi
3998])
3999
4000
4001dnl CURL_CHECK_FUNC_INET_PTON
4002dnl -------------------------------------------------
4003dnl Verify if inet_pton is available, prototyped, can
4004dnl be compiled and seems to work. If all of these are
4005dnl true, and usage has not been previously disallowed
4006dnl with shell variable curl_disallow_inet_pton, then
4007dnl HAVE_INET_PTON will be defined.
4008
4009AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [
4010  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
4011  AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
4012  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4013  #
4014  tst_links_inet_pton="unknown"
4015  tst_proto_inet_pton="unknown"
4016  tst_compi_inet_pton="unknown"
4017  tst_works_inet_pton="unknown"
4018  tst_allow_inet_pton="unknown"
4019  #
4020  AC_MSG_CHECKING([if inet_pton can be linked])
4021  AC_LINK_IFELSE([
4022    AC_LANG_FUNC_LINK_TRY([inet_pton])
4023  ],[
4024    AC_MSG_RESULT([yes])
4025    tst_links_inet_pton="yes"
4026  ],[
4027    AC_MSG_RESULT([no])
4028    tst_links_inet_pton="no"
4029  ])
4030  #
4031  if test "$tst_links_inet_pton" = "yes"; then
4032    AC_MSG_CHECKING([if inet_pton is prototyped])
4033    AC_EGREP_CPP([inet_pton],[
4034      $curl_includes_arpa_inet
4035    ],[
4036      AC_MSG_RESULT([yes])
4037      tst_proto_inet_pton="yes"
4038    ],[
4039      AC_MSG_RESULT([no])
4040      tst_proto_inet_pton="no"
4041    ])
4042  fi
4043  #
4044  if test "$tst_proto_inet_pton" = "yes"; then
4045    AC_MSG_CHECKING([if inet_pton is compilable])
4046    AC_COMPILE_IFELSE([
4047      AC_LANG_PROGRAM([[
4048        $curl_includes_arpa_inet
4049      ]],[[
4050        if(0 != inet_pton(0, 0, 0))
4051          return 1;
4052      ]])
4053    ],[
4054      AC_MSG_RESULT([yes])
4055      tst_compi_inet_pton="yes"
4056    ],[
4057      AC_MSG_RESULT([no])
4058      tst_compi_inet_pton="no"
4059    ])
4060  fi
4061  #
4062  dnl only do runtime verification when not cross-compiling
4063  if test "x$cross_compiling" != "xyes" &&
4064    test "$tst_compi_inet_pton" = "yes"; then
4065    AC_MSG_CHECKING([if inet_pton seems to work])
4066    CURL_RUN_IFELSE([
4067      AC_LANG_PROGRAM([[
4068        $curl_includes_stdlib
4069        $curl_includes_arpa_inet
4070        $curl_includes_string
4071      ]],[[
4072        unsigned char ipv6a[16+1];
4073        unsigned char ipv4a[4+1];
4074        const char *ipv6src = "fe80::214:4fff:fe0b:76c8";
4075        const char *ipv4src = "192.168.100.1";
4076        /* - */
4077        memset(ipv4a, 1, sizeof(ipv4a));
4078        if(1 != inet_pton(AF_INET, ipv4src, ipv4a))
4079          exit(1); /* fail */
4080        /* - */
4081        if( (ipv4a[0] != 0xc0) ||
4082            (ipv4a[1] != 0xa8) ||
4083            (ipv4a[2] != 0x64) ||
4084            (ipv4a[3] != 0x01) ||
4085            (ipv4a[4] != 0x01) )
4086          exit(1); /* fail */
4087        /* - */
4088        memset(ipv6a, 1, sizeof(ipv6a));
4089        if(1 != inet_pton(AF_INET6, ipv6src, ipv6a))
4090          exit(1); /* fail */
4091        /* - */
4092        if( (ipv6a[0]  != 0xfe) ||
4093            (ipv6a[1]  != 0x80) ||
4094            (ipv6a[8]  != 0x02) ||
4095            (ipv6a[9]  != 0x14) ||
4096            (ipv6a[10] != 0x4f) ||
4097            (ipv6a[11] != 0xff) ||
4098            (ipv6a[12] != 0xfe) ||
4099            (ipv6a[13] != 0x0b) ||
4100            (ipv6a[14] != 0x76) ||
4101            (ipv6a[15] != 0xc8) ||
4102            (ipv6a[16] != 0x01) )
4103          exit(1); /* fail */
4104        /* - */
4105        if( (ipv6a[2]  != 0x0) ||
4106            (ipv6a[3]  != 0x0) ||
4107            (ipv6a[4]  != 0x0) ||
4108            (ipv6a[5]  != 0x0) ||
4109            (ipv6a[6]  != 0x0) ||
4110            (ipv6a[7]  != 0x0) )
4111          exit(1); /* fail */
4112        /* - */
4113        exit(0);
4114      ]])
4115    ],[
4116      AC_MSG_RESULT([yes])
4117      tst_works_inet_pton="yes"
4118    ],[
4119      AC_MSG_RESULT([no])
4120      tst_works_inet_pton="no"
4121    ])
4122  fi
4123  #
4124  if test "$tst_compi_inet_pton" = "yes" &&
4125    test "$tst_works_inet_pton" != "no"; then
4126    AC_MSG_CHECKING([if inet_pton usage allowed])
4127    if test "x$curl_disallow_inet_pton" != "xyes"; then
4128      AC_MSG_RESULT([yes])
4129      tst_allow_inet_pton="yes"
4130    else
4131      AC_MSG_RESULT([no])
4132      tst_allow_inet_pton="no"
4133    fi
4134  fi
4135  #
4136  AC_MSG_CHECKING([if inet_pton might be used])
4137  if test "$tst_links_inet_pton" = "yes" &&
4138     test "$tst_proto_inet_pton" = "yes" &&
4139     test "$tst_compi_inet_pton" = "yes" &&
4140     test "$tst_allow_inet_pton" = "yes" &&
4141     test "$tst_works_inet_pton" != "no"; then
4142    AC_MSG_RESULT([yes])
4143    AC_DEFINE_UNQUOTED(HAVE_INET_PTON, 1,
4144      [Define to 1 if you have a IPv6 capable working inet_pton function.])
4145    curl_cv_func_inet_pton="yes"
4146  else
4147    AC_MSG_RESULT([no])
4148    curl_cv_func_inet_pton="no"
4149  fi
4150])
4151
4152
4153dnl CURL_CHECK_FUNC_IOCTL
4154dnl -------------------------------------------------
4155dnl Verify if ioctl is available, prototyped, and
4156dnl can be compiled. If all of these are true, and
4157dnl usage has not been previously disallowed with
4158dnl shell variable curl_disallow_ioctl, then
4159dnl HAVE_IOCTL will be defined.
4160
4161AC_DEFUN([CURL_CHECK_FUNC_IOCTL], [
4162  AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
4163  #
4164  tst_links_ioctl="unknown"
4165  tst_proto_ioctl="unknown"
4166  tst_compi_ioctl="unknown"
4167  tst_allow_ioctl="unknown"
4168  #
4169  AC_MSG_CHECKING([if ioctl can be linked])
4170  AC_LINK_IFELSE([
4171    AC_LANG_FUNC_LINK_TRY([ioctl])
4172  ],[
4173    AC_MSG_RESULT([yes])
4174    tst_links_ioctl="yes"
4175  ],[
4176    AC_MSG_RESULT([no])
4177    tst_links_ioctl="no"
4178  ])
4179  #
4180  if test "$tst_links_ioctl" = "yes"; then
4181    AC_MSG_CHECKING([if ioctl is prototyped])
4182    AC_EGREP_CPP([ioctl],[
4183      $curl_includes_stropts
4184    ],[
4185      AC_MSG_RESULT([yes])
4186      tst_proto_ioctl="yes"
4187    ],[
4188      AC_MSG_RESULT([no])
4189      tst_proto_ioctl="no"
4190    ])
4191  fi
4192  #
4193  if test "$tst_proto_ioctl" = "yes"; then
4194    AC_MSG_CHECKING([if ioctl is compilable])
4195    AC_COMPILE_IFELSE([
4196      AC_LANG_PROGRAM([[
4197        $curl_includes_stropts
4198      ]],[[
4199        if(0 != ioctl(0, 0, 0))
4200          return 1;
4201      ]])
4202    ],[
4203      AC_MSG_RESULT([yes])
4204      tst_compi_ioctl="yes"
4205    ],[
4206      AC_MSG_RESULT([no])
4207      tst_compi_ioctl="no"
4208    ])
4209  fi
4210  #
4211  if test "$tst_compi_ioctl" = "yes"; then
4212    AC_MSG_CHECKING([if ioctl usage allowed])
4213    if test "x$curl_disallow_ioctl" != "xyes"; then
4214      AC_MSG_RESULT([yes])
4215      tst_allow_ioctl="yes"
4216    else
4217      AC_MSG_RESULT([no])
4218      tst_allow_ioctl="no"
4219    fi
4220  fi
4221  #
4222  AC_MSG_CHECKING([if ioctl might be used])
4223  if test "$tst_links_ioctl" = "yes" &&
4224     test "$tst_proto_ioctl" = "yes" &&
4225     test "$tst_compi_ioctl" = "yes" &&
4226     test "$tst_allow_ioctl" = "yes"; then
4227    AC_MSG_RESULT([yes])
4228    AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1,
4229      [Define to 1 if you have the ioctl function.])
4230    curl_cv_func_ioctl="yes"
4231    CURL_CHECK_FUNC_IOCTL_FIONBIO
4232    CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR
4233  else
4234    AC_MSG_RESULT([no])
4235    curl_cv_func_ioctl="no"
4236  fi
4237])
4238
4239
4240dnl CURL_CHECK_FUNC_IOCTL_FIONBIO
4241dnl -------------------------------------------------
4242dnl Verify if ioctl with the FIONBIO command is
4243dnl available, can be compiled, and seems to work. If
4244dnl all of these are true, then HAVE_IOCTL_FIONBIO
4245dnl will be defined.
4246
4247AC_DEFUN([CURL_CHECK_FUNC_IOCTL_FIONBIO], [
4248  #
4249  tst_compi_ioctl_fionbio="unknown"
4250  tst_allow_ioctl_fionbio="unknown"
4251  #
4252  if test "$curl_cv_func_ioctl" = "yes"; then
4253    AC_MSG_CHECKING([if ioctl FIONBIO is compilable])
4254    AC_COMPILE_IFELSE([
4255      AC_LANG_PROGRAM([[
4256        $curl_includes_stropts
4257      ]],[[
4258        int flags = 0;
4259        if(0 != ioctl(0, FIONBIO, &flags))
4260          return 1;
4261      ]])
4262    ],[
4263      AC_MSG_RESULT([yes])
4264      tst_compi_ioctl_fionbio="yes"
4265    ],[
4266      AC_MSG_RESULT([no])
4267      tst_compi_ioctl_fionbio="no"
4268    ])
4269  fi
4270  #
4271  if test "$tst_compi_ioctl_fionbio" = "yes"; then
4272    AC_MSG_CHECKING([if ioctl FIONBIO usage allowed])
4273    if test "x$curl_disallow_ioctl_fionbio" != "xyes"; then
4274      AC_MSG_RESULT([yes])
4275      tst_allow_ioctl_fionbio="yes"
4276    else
4277      AC_MSG_RESULT([no])
4278      tst_allow_ioctl_fionbio="no"
4279    fi
4280  fi
4281  #
4282  AC_MSG_CHECKING([if ioctl FIONBIO might be used])
4283  if test "$tst_compi_ioctl_fionbio" = "yes" &&
4284     test "$tst_allow_ioctl_fionbio" = "yes"; then
4285    AC_MSG_RESULT([yes])
4286    AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1,
4287      [Define to 1 if you have a working ioctl FIONBIO function.])
4288    curl_cv_func_ioctl_fionbio="yes"
4289  else
4290    AC_MSG_RESULT([no])
4291    curl_cv_func_ioctl_fionbio="no"
4292  fi
4293])
4294
4295
4296dnl CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR
4297dnl -------------------------------------------------
4298dnl Verify if ioctl with the SIOCGIFADDR command is available,
4299dnl struct ifreq is defined, they can be compiled, and seem to
4300dnl work. If all of these are true, then HAVE_IOCTL_SIOCGIFADDR
4301dnl will be defined.
4302
4303AC_DEFUN([CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR], [
4304  #
4305  tst_compi_ioctl_siocgifaddr="unknown"
4306  tst_allow_ioctl_siocgifaddr="unknown"
4307  #
4308  if test "$curl_cv_func_ioctl" = "yes"; then
4309    AC_MSG_CHECKING([if ioctl SIOCGIFADDR is compilable])
4310    AC_COMPILE_IFELSE([
4311      AC_LANG_PROGRAM([[
4312        $curl_includes_stropts
4313        #include <net/if.h>
4314      ]],[[
4315        struct ifreq ifr;
4316        if(0 != ioctl(0, SIOCGIFADDR, &ifr))
4317          return 1;
4318      ]])
4319    ],[
4320      AC_MSG_RESULT([yes])
4321      tst_compi_ioctl_siocgifaddr="yes"
4322    ],[
4323      AC_MSG_RESULT([no])
4324      tst_compi_ioctl_siocgifaddr="no"
4325    ])
4326  fi
4327  #
4328  if test "$tst_compi_ioctl_siocgifaddr" = "yes"; then
4329    AC_MSG_CHECKING([if ioctl SIOCGIFADDR usage allowed])
4330    if test "x$curl_disallow_ioctl_siocgifaddr" != "xyes"; then
4331      AC_MSG_RESULT([yes])
4332      tst_allow_ioctl_siocgifaddr="yes"
4333    else
4334      AC_MSG_RESULT([no])
4335      tst_allow_ioctl_siocgifaddr="no"
4336    fi
4337  fi
4338  #
4339  AC_MSG_CHECKING([if ioctl SIOCGIFADDR might be used])
4340  if test "$tst_compi_ioctl_siocgifaddr" = "yes" &&
4341     test "$tst_allow_ioctl_siocgifaddr" = "yes"; then
4342    AC_MSG_RESULT([yes])
4343    AC_DEFINE_UNQUOTED(HAVE_IOCTL_SIOCGIFADDR, 1,
4344      [Define to 1 if you have a working ioctl SIOCGIFADDR function.])
4345    curl_cv_func_ioctl_siocgifaddr="yes"
4346  else
4347    AC_MSG_RESULT([no])
4348    curl_cv_func_ioctl_siocgifaddr="no"
4349  fi
4350])
4351
4352
4353dnl CURL_CHECK_FUNC_IOCTLSOCKET
4354dnl -------------------------------------------------
4355dnl Verify if ioctlsocket is available, prototyped, and
4356dnl can be compiled. If all of these are true, and
4357dnl usage has not been previously disallowed with
4358dnl shell variable curl_disallow_ioctlsocket, then
4359dnl HAVE_IOCTLSOCKET will be defined.
4360
4361AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [
4362  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
4363  #
4364  tst_links_ioctlsocket="unknown"
4365  tst_proto_ioctlsocket="unknown"
4366  tst_compi_ioctlsocket="unknown"
4367  tst_allow_ioctlsocket="unknown"
4368  #
4369  AC_MSG_CHECKING([if ioctlsocket can be linked])
4370  AC_LINK_IFELSE([
4371    AC_LANG_PROGRAM([[
4372      $curl_includes_winsock2
4373      $curl_includes_bsdsocket
4374    ]],[[
4375      if(0 != ioctlsocket(0, 0, 0))
4376        return 1;
4377    ]])
4378  ],[
4379    AC_MSG_RESULT([yes])
4380    tst_links_ioctlsocket="yes"
4381  ],[
4382    AC_MSG_RESULT([no])
4383    tst_links_ioctlsocket="no"
4384  ])
4385  #
4386  if test "$tst_links_ioctlsocket" = "yes"; then
4387    AC_MSG_CHECKING([if ioctlsocket is prototyped])
4388    AC_EGREP_CPP([ioctlsocket],[
4389      $curl_includes_winsock2
4390      $curl_includes_bsdsocket
4391    ],[
4392      AC_MSG_RESULT([yes])
4393      tst_proto_ioctlsocket="yes"
4394    ],[
4395      AC_MSG_RESULT([no])
4396      tst_proto_ioctlsocket="no"
4397    ])
4398  fi
4399  #
4400  if test "$tst_proto_ioctlsocket" = "yes"; then
4401    AC_MSG_CHECKING([if ioctlsocket is compilable])
4402    AC_COMPILE_IFELSE([
4403      AC_LANG_PROGRAM([[
4404        $curl_includes_winsock2
4405      $curl_includes_bsdsocket
4406      ]],[[
4407        if(0 != ioctlsocket(0, 0, 0))
4408          return 1;
4409      ]])
4410    ],[
4411      AC_MSG_RESULT([yes])
4412      tst_compi_ioctlsocket="yes"
4413    ],[
4414      AC_MSG_RESULT([no])
4415      tst_compi_ioctlsocket="no"
4416    ])
4417  fi
4418  #
4419  if test "$tst_compi_ioctlsocket" = "yes"; then
4420    AC_MSG_CHECKING([if ioctlsocket usage allowed])
4421    if test "x$curl_disallow_ioctlsocket" != "xyes"; then
4422      AC_MSG_RESULT([yes])
4423      tst_allow_ioctlsocket="yes"
4424    else
4425      AC_MSG_RESULT([no])
4426      tst_allow_ioctlsocket="no"
4427    fi
4428  fi
4429  #
4430  AC_MSG_CHECKING([if ioctlsocket might be used])
4431  if test "$tst_links_ioctlsocket" = "yes" &&
4432     test "$tst_proto_ioctlsocket" = "yes" &&
4433     test "$tst_compi_ioctlsocket" = "yes" &&
4434     test "$tst_allow_ioctlsocket" = "yes"; then
4435    AC_MSG_RESULT([yes])
4436    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1,
4437      [Define to 1 if you have the ioctlsocket function.])
4438    curl_cv_func_ioctlsocket="yes"
4439    CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
4440  else
4441    AC_MSG_RESULT([no])
4442    curl_cv_func_ioctlsocket="no"
4443  fi
4444])
4445
4446
4447dnl CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
4448dnl -------------------------------------------------
4449dnl Verify if ioctlsocket with the FIONBIO command is
4450dnl available, can be compiled, and seems to work. If
4451dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO
4452dnl will be defined.
4453
4454AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [
4455  #
4456  tst_compi_ioctlsocket_fionbio="unknown"
4457  tst_allow_ioctlsocket_fionbio="unknown"
4458  #
4459  if test "$curl_cv_func_ioctlsocket" = "yes"; then
4460    AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable])
4461    AC_COMPILE_IFELSE([
4462      AC_LANG_PROGRAM([[
4463        $curl_includes_winsock2
4464      $curl_includes_bsdsocket
4465      ]],[[
4466        int flags = 0;
4467        if(0 != ioctlsocket(0, FIONBIO, &flags))
4468          return 1;
4469      ]])
4470    ],[
4471      AC_MSG_RESULT([yes])
4472      tst_compi_ioctlsocket_fionbio="yes"
4473    ],[
4474      AC_MSG_RESULT([no])
4475      tst_compi_ioctlsocket_fionbio="no"
4476    ])
4477  fi
4478  #
4479  if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then
4480    AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed])
4481    if test "x$curl_disallow_ioctlsocket_fionbio" != "xyes"; then
4482      AC_MSG_RESULT([yes])
4483      tst_allow_ioctlsocket_fionbio="yes"
4484    else
4485      AC_MSG_RESULT([no])
4486      tst_allow_ioctlsocket_fionbio="no"
4487    fi
4488  fi
4489  #
4490  AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used])
4491  if test "$tst_compi_ioctlsocket_fionbio" = "yes" &&
4492     test "$tst_allow_ioctlsocket_fionbio" = "yes"; then
4493    AC_MSG_RESULT([yes])
4494    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1,
4495      [Define to 1 if you have a working ioctlsocket FIONBIO function.])
4496    curl_cv_func_ioctlsocket_fionbio="yes"
4497  else
4498    AC_MSG_RESULT([no])
4499    curl_cv_func_ioctlsocket_fionbio="no"
4500  fi
4501])
4502
4503
4504dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
4505dnl -------------------------------------------------
4506dnl Verify if IoctlSocket is available, prototyped, and
4507dnl can be compiled. If all of these are true, and
4508dnl usage has not been previously disallowed with
4509dnl shell variable curl_disallow_ioctlsocket_camel,
4510dnl then HAVE_IOCTLSOCKET_CAMEL will be defined.
4511
4512AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
4513  AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
4514  #
4515  tst_links_ioctlsocket_camel="unknown"
4516  tst_proto_ioctlsocket_camel="unknown"
4517  tst_compi_ioctlsocket_camel="unknown"
4518  tst_allow_ioctlsocket_camel="unknown"
4519  #
4520  AC_MSG_CHECKING([if IoctlSocket can be linked])
4521  AC_LINK_IFELSE([
4522    AC_LANG_FUNC_LINK_TRY([IoctlSocket])
4523  ],[
4524    AC_MSG_RESULT([yes])
4525    tst_links_ioctlsocket_camel="yes"
4526  ],[
4527    AC_MSG_RESULT([no])
4528    tst_links_ioctlsocket_camel="no"
4529  ])
4530  #
4531  if test "$tst_links_ioctlsocket_camel" = "yes"; then
4532    AC_MSG_CHECKING([if IoctlSocket is prototyped])
4533    AC_EGREP_CPP([IoctlSocket],[
4534      $curl_includes_stropts
4535    ],[
4536      AC_MSG_RESULT([yes])
4537      tst_proto_ioctlsocket_camel="yes"
4538    ],[
4539      AC_MSG_RESULT([no])
4540      tst_proto_ioctlsocket_camel="no"
4541    ])
4542  fi
4543  #
4544  if test "$tst_proto_ioctlsocket_camel" = "yes"; then
4545    AC_MSG_CHECKING([if IoctlSocket is compilable])
4546    AC_COMPILE_IFELSE([
4547      AC_LANG_PROGRAM([[
4548        $curl_includes_stropts
4549      ]],[[
4550        if(0 != IoctlSocket(0, 0, 0))
4551          return 1;
4552      ]])
4553    ],[
4554      AC_MSG_RESULT([yes])
4555      tst_compi_ioctlsocket_camel="yes"
4556    ],[
4557      AC_MSG_RESULT([no])
4558      tst_compi_ioctlsocket_camel="no"
4559    ])
4560  fi
4561  #
4562  if test "$tst_compi_ioctlsocket_camel" = "yes"; then
4563    AC_MSG_CHECKING([if IoctlSocket usage allowed])
4564    if test "x$curl_disallow_ioctlsocket_camel" != "xyes"; then
4565      AC_MSG_RESULT([yes])
4566      tst_allow_ioctlsocket_camel="yes"
4567    else
4568      AC_MSG_RESULT([no])
4569      tst_allow_ioctlsocket_camel="no"
4570    fi
4571  fi
4572  #
4573  AC_MSG_CHECKING([if IoctlSocket might be used])
4574  if test "$tst_links_ioctlsocket_camel" = "yes" &&
4575     test "$tst_proto_ioctlsocket_camel" = "yes" &&
4576     test "$tst_compi_ioctlsocket_camel" = "yes" &&
4577     test "$tst_allow_ioctlsocket_camel" = "yes"; then
4578    AC_MSG_RESULT([yes])
4579    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1,
4580      [Define to 1 if you have the IoctlSocket camel case function.])
4581    curl_cv_func_ioctlsocket_camel="yes"
4582    CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
4583  else
4584    AC_MSG_RESULT([no])
4585    curl_cv_func_ioctlsocket_camel="no"
4586  fi
4587])
4588
4589
4590dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
4591dnl -------------------------------------------------
4592dnl Verify if IoctlSocket with FIONBIO command is available,
4593dnl can be compiled, and seems to work. If all of these are
4594dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined.
4595
4596AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [
4597  #
4598  tst_compi_ioctlsocket_camel_fionbio="unknown"
4599  tst_allow_ioctlsocket_camel_fionbio="unknown"
4600  #
4601  if test "$curl_cv_func_ioctlsocket_camel" = "yes"; then
4602    AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable])
4603    AC_COMPILE_IFELSE([
4604      AC_LANG_PROGRAM([[
4605        $curl_includes_stropts
4606      ]],[[
4607        long flags = 0;
4608        if(0 != ioctlsocket(0, FIONBIO, &flags))
4609          return 1;
4610      ]])
4611    ],[
4612      AC_MSG_RESULT([yes])
4613      tst_compi_ioctlsocket_camel_fionbio="yes"
4614    ],[
4615      AC_MSG_RESULT([no])
4616      tst_compi_ioctlsocket_camel_fionbio="no"
4617    ])
4618  fi
4619  #
4620  if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then
4621    AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed])
4622    if test "x$curl_disallow_ioctlsocket_camel_fionbio" != "xyes"; then
4623      AC_MSG_RESULT([yes])
4624      tst_allow_ioctlsocket_camel_fionbio="yes"
4625    else
4626      AC_MSG_RESULT([no])
4627      tst_allow_ioctlsocket_camel_fionbio="no"
4628    fi
4629  fi
4630  #
4631  AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used])
4632  if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" &&
4633     test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then
4634    AC_MSG_RESULT([yes])
4635    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1,
4636      [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.])
4637    curl_cv_func_ioctlsocket_camel_fionbio="yes"
4638  else
4639    AC_MSG_RESULT([no])
4640    curl_cv_func_ioctlsocket_camel_fionbio="no"
4641  fi
4642])
4643
4644
4645dnl CURL_CHECK_FUNC_LISTXATTR
4646dnl -------------------------------------------------
4647dnl Verify if listxattr is available, prototyped, and
4648dnl can be compiled. If all of these are true, and
4649dnl usage has not been previously disallowed with
4650dnl shell variable curl_disallow_listxattr, then
4651dnl HAVE_LISTXATTR will be defined.
4652
4653AC_DEFUN([CURL_CHECK_FUNC_LISTXATTR], [
4654  AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
4655  #
4656  tst_links_listxattr="unknown"
4657  tst_proto_listxattr="unknown"
4658  tst_compi_listxattr="unknown"
4659  tst_allow_listxattr="unknown"
4660  tst_nargs_listxattr="unknown"
4661  #
4662  AC_MSG_CHECKING([if listxattr can be linked])
4663  AC_LINK_IFELSE([
4664    AC_LANG_FUNC_LINK_TRY([listxattr])
4665  ],[
4666    AC_MSG_RESULT([yes])
4667    tst_links_listxattr="yes"
4668  ],[
4669    AC_MSG_RESULT([no])
4670    tst_links_listxattr="no"
4671  ])
4672  #
4673  if test "$tst_links_listxattr" = "yes"; then
4674    AC_MSG_CHECKING([if listxattr is prototyped])
4675    AC_EGREP_CPP([listxattr],[
4676      $curl_includes_sys_xattr
4677    ],[
4678      AC_MSG_RESULT([yes])
4679      tst_proto_listxattr="yes"
4680    ],[
4681      AC_MSG_RESULT([no])
4682      tst_proto_listxattr="no"
4683    ])
4684  fi
4685  #
4686  if test "$tst_proto_listxattr" = "yes"; then
4687    if test "$tst_nargs_listxattr" = "unknown"; then
4688      AC_MSG_CHECKING([if listxattr takes 3 args.])
4689      AC_COMPILE_IFELSE([
4690        AC_LANG_PROGRAM([[
4691          $curl_includes_sys_xattr
4692        ]],[[
4693          if(0 != listxattr(0, 0, 0))
4694            return 1;
4695        ]])
4696      ],[
4697        AC_MSG_RESULT([yes])
4698        tst_compi_listxattr="yes"
4699        tst_nargs_listxattr="3"
4700      ],[
4701        AC_MSG_RESULT([no])
4702        tst_compi_listxattr="no"
4703      ])
4704    fi
4705    if test "$tst_nargs_listxattr" = "unknown"; then
4706      AC_MSG_CHECKING([if listxattr takes 4 args.])
4707      AC_COMPILE_IFELSE([
4708        AC_LANG_PROGRAM([[
4709          $curl_includes_sys_xattr
4710        ]],[[
4711          if(0 != listxattr(0, 0, 0, 0))
4712            return 1;
4713        ]])
4714      ],[
4715        AC_MSG_RESULT([yes])
4716        tst_compi_listxattr="yes"
4717        tst_nargs_listxattr="4"
4718      ],[
4719        AC_MSG_RESULT([no])
4720        tst_compi_listxattr="no"
4721      ])
4722    fi
4723    AC_MSG_CHECKING([if listxattr is compilable])
4724    if test "$tst_compi_listxattr" = "yes"; then
4725      AC_MSG_RESULT([yes])
4726    else
4727      AC_MSG_RESULT([no])
4728    fi
4729  fi
4730  #
4731  if test "$tst_compi_listxattr" = "yes"; then
4732    AC_MSG_CHECKING([if listxattr usage allowed])
4733    if test "x$curl_disallow_listxattr" != "xyes"; then
4734      AC_MSG_RESULT([yes])
4735      tst_allow_listxattr="yes"
4736    else
4737      AC_MSG_RESULT([no])
4738      tst_allow_listxattr="no"
4739    fi
4740  fi
4741  #
4742  AC_MSG_CHECKING([if listxattr might be used])
4743  if test "$tst_links_listxattr" = "yes" &&
4744     test "$tst_proto_listxattr" = "yes" &&
4745     test "$tst_compi_listxattr" = "yes" &&
4746     test "$tst_allow_listxattr" = "yes"; then
4747    AC_MSG_RESULT([yes])
4748    AC_DEFINE_UNQUOTED(HAVE_LISTXATTR, 1,
4749      [Define to 1 if you have the listxattr function.])
4750    dnl AC_DEFINE_UNQUOTED(LISTXATTR_ARGS, $tst_nargs_listxattr,
4751    dnl   [Specifies the number of arguments to listxattr])
4752    #
4753    if test "$tst_nargs_listxattr" -eq "3"; then
4754      AC_DEFINE(HAVE_LISTXATTR_3, 1, [listxattr() takes 3 args])
4755    elif test "$tst_nargs_listxattr" -eq "4"; then
4756      AC_DEFINE(HAVE_LISTXATTR_4, 1, [listxattr() takes 4 args])
4757    fi
4758    #
4759    curl_cv_func_listxattr="yes"
4760  else
4761    AC_MSG_RESULT([no])
4762    curl_cv_func_listxattr="no"
4763  fi
4764])
4765
4766
4767dnl CURL_CHECK_FUNC_LOCALTIME_R
4768dnl -------------------------------------------------
4769dnl Verify if localtime_r is available, prototyped, can
4770dnl be compiled and seems to work. If all of these are
4771dnl true, and usage has not been previously disallowed
4772dnl with shell variable curl_disallow_localtime_r, then
4773dnl HAVE_LOCALTIME_R will be defined.
4774
4775AC_DEFUN([CURL_CHECK_FUNC_LOCALTIME_R], [
4776  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
4777  AC_REQUIRE([CURL_INCLUDES_TIME])dnl
4778  #
4779  tst_links_localtime_r="unknown"
4780  tst_proto_localtime_r="unknown"
4781  tst_compi_localtime_r="unknown"
4782  tst_works_localtime_r="unknown"
4783  tst_allow_localtime_r="unknown"
4784  #
4785  AC_MSG_CHECKING([if localtime_r can be linked])
4786  AC_LINK_IFELSE([
4787    AC_LANG_FUNC_LINK_TRY([localtime_r])
4788  ],[
4789    AC_MSG_RESULT([yes])
4790    tst_links_localtime_r="yes"
4791  ],[
4792    AC_MSG_RESULT([no])
4793    tst_links_localtime_r="no"
4794  ])
4795  #
4796  if test "$tst_links_localtime_r" = "yes"; then
4797    AC_MSG_CHECKING([if localtime_r is prototyped])
4798    AC_EGREP_CPP([localtime_r],[
4799      $curl_includes_time
4800    ],[
4801      AC_MSG_RESULT([yes])
4802      tst_proto_localtime_r="yes"
4803    ],[
4804      AC_MSG_RESULT([no])
4805      tst_proto_localtime_r="no"
4806    ])
4807  fi
4808  #
4809  if test "$tst_proto_localtime_r" = "yes"; then
4810    AC_MSG_CHECKING([if localtime_r is compilable])
4811    AC_COMPILE_IFELSE([
4812      AC_LANG_PROGRAM([[
4813        $curl_includes_time
4814      ]],[[
4815        if(0 != localtime_r(0, 0))
4816          return 1;
4817      ]])
4818    ],[
4819      AC_MSG_RESULT([yes])
4820      tst_compi_localtime_r="yes"
4821    ],[
4822      AC_MSG_RESULT([no])
4823      tst_compi_localtime_r="no"
4824    ])
4825  fi
4826  #
4827  dnl only do runtime verification when not cross-compiling
4828  if test "x$cross_compiling" != "xyes" &&
4829    test "$tst_compi_localtime_r" = "yes"; then
4830    AC_MSG_CHECKING([if localtime_r seems to work])
4831    CURL_RUN_IFELSE([
4832      AC_LANG_PROGRAM([[
4833        $curl_includes_stdlib
4834        $curl_includes_time
4835      ]],[[
4836        time_t clock = 1170352587;
4837        struct tm *tmp = 0;
4838        struct tm result;
4839        tmp = localtime_r(&clock, &result);
4840        if(tmp)
4841          exit(0);
4842        else
4843          exit(1);
4844      ]])
4845    ],[
4846      AC_MSG_RESULT([yes])
4847      tst_works_localtime_r="yes"
4848    ],[
4849      AC_MSG_RESULT([no])
4850      tst_works_localtime_r="no"
4851    ])
4852  fi
4853  #
4854  if test "$tst_compi_localtime_r" = "yes" &&
4855    test "$tst_works_localtime_r" != "no"; then
4856    AC_MSG_CHECKING([if localtime_r usage allowed])
4857    if test "x$curl_disallow_localtime_r" != "xyes"; then
4858      AC_MSG_RESULT([yes])
4859      tst_allow_localtime_r="yes"
4860    else
4861      AC_MSG_RESULT([no])
4862      tst_allow_localtime_r="no"
4863    fi
4864  fi
4865  #
4866  AC_MSG_CHECKING([if localtime_r might be used])
4867  if test "$tst_links_localtime_r" = "yes" &&
4868     test "$tst_proto_localtime_r" = "yes" &&
4869     test "$tst_compi_localtime_r" = "yes" &&
4870     test "$tst_allow_localtime_r" = "yes" &&
4871     test "$tst_works_localtime_r" != "no"; then
4872    AC_MSG_RESULT([yes])
4873    AC_DEFINE_UNQUOTED(HAVE_LOCALTIME_R, 1,
4874      [Define to 1 if you have a working localtime_r function.])
4875    curl_cv_func_localtime_r="yes"
4876  else
4877    AC_MSG_RESULT([no])
4878    curl_cv_func_localtime_r="no"
4879  fi
4880])
4881
4882
4883dnl CURL_CHECK_FUNC_MEMRCHR
4884dnl -------------------------------------------------
4885dnl Verify if memrchr is available, prototyped, and
4886dnl can be compiled. If all of these are true, and
4887dnl usage has not been previously disallowed with
4888dnl shell variable curl_disallow_memrchr, then
4889dnl HAVE_MEMRCHR will be defined.
4890
4891AC_DEFUN([CURL_CHECK_FUNC_MEMRCHR], [
4892  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4893  #
4894  tst_links_memrchr="unknown"
4895  tst_macro_memrchr="unknown"
4896  tst_proto_memrchr="unknown"
4897  tst_compi_memrchr="unknown"
4898  tst_allow_memrchr="unknown"
4899  #
4900  AC_MSG_CHECKING([if memrchr can be linked])
4901  AC_LINK_IFELSE([
4902    AC_LANG_FUNC_LINK_TRY([memrchr])
4903  ],[
4904    AC_MSG_RESULT([yes])
4905    tst_links_memrchr="yes"
4906  ],[
4907    AC_MSG_RESULT([no])
4908    tst_links_memrchr="no"
4909  ])
4910  #
4911  if test "$tst_links_memrchr" = "no"; then
4912    AC_MSG_CHECKING([if memrchr seems a macro])
4913    AC_LINK_IFELSE([
4914      AC_LANG_PROGRAM([[
4915        $curl_includes_string
4916      ]],[[
4917        if(0 != memrchr(0, 0, 0))
4918          return 1;
4919      ]])
4920    ],[
4921      AC_MSG_RESULT([yes])
4922      tst_macro_memrchr="yes"
4923    ],[
4924      AC_MSG_RESULT([no])
4925      tst_macro_memrchr="no"
4926    ])
4927  fi
4928  #
4929  if test "$tst_links_memrchr" = "yes"; then
4930    AC_MSG_CHECKING([if memrchr is prototyped])
4931    AC_EGREP_CPP([memrchr],[
4932      $curl_includes_string
4933    ],[
4934      AC_MSG_RESULT([yes])
4935      tst_proto_memrchr="yes"
4936    ],[
4937      AC_MSG_RESULT([no])
4938      tst_proto_memrchr="no"
4939    ])
4940  fi
4941  #
4942  if test "$tst_proto_memrchr" = "yes" ||
4943     test "$tst_macro_memrchr" = "yes"; then
4944    AC_MSG_CHECKING([if memrchr is compilable])
4945    AC_COMPILE_IFELSE([
4946      AC_LANG_PROGRAM([[
4947        $curl_includes_string
4948      ]],[[
4949        if(0 != memrchr(0, 0, 0))
4950          return 1;
4951      ]])
4952    ],[
4953      AC_MSG_RESULT([yes])
4954      tst_compi_memrchr="yes"
4955    ],[
4956      AC_MSG_RESULT([no])
4957      tst_compi_memrchr="no"
4958    ])
4959  fi
4960  #
4961  if test "$tst_compi_memrchr" = "yes"; then
4962    AC_MSG_CHECKING([if memrchr usage allowed])
4963    if test "x$curl_disallow_memrchr" != "xyes"; then
4964      AC_MSG_RESULT([yes])
4965      tst_allow_memrchr="yes"
4966    else
4967      AC_MSG_RESULT([no])
4968      tst_allow_memrchr="no"
4969    fi
4970  fi
4971  #
4972  AC_MSG_CHECKING([if memrchr might be used])
4973  if (test "$tst_proto_memrchr" = "yes" ||
4974      test "$tst_macro_memrchr" = "yes") &&
4975     test "$tst_compi_memrchr" = "yes" &&
4976     test "$tst_allow_memrchr" = "yes"; then
4977    AC_MSG_RESULT([yes])
4978    AC_DEFINE_UNQUOTED(HAVE_MEMRCHR, 1,
4979      [Define to 1 if you have the memrchr function or macro.])
4980    curl_cv_func_memrchr="yes"
4981  else
4982    AC_MSG_RESULT([no])
4983    curl_cv_func_memrchr="no"
4984  fi
4985])
4986
4987
4988dnl CURL_CHECK_FUNC_POLL
4989dnl -------------------------------------------------
4990dnl Verify if poll is available, prototyped, can
4991dnl be compiled and seems to work. If all of these are
4992dnl true, and usage has not been previously disallowed
4993dnl with shell variable curl_disallow_poll, then
4994dnl HAVE_POLL will be defined.
4995
4996AC_DEFUN([CURL_CHECK_FUNC_POLL], [
4997  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
4998  AC_REQUIRE([CURL_INCLUDES_POLL])dnl
4999  #
5000  tst_links_poll="unknown"
5001  tst_proto_poll="unknown"
5002  tst_compi_poll="unknown"
5003  tst_works_poll="unknown"
5004  tst_allow_poll="unknown"
5005  #
5006  case $host_os in
5007    darwin*|interix*)
5008      dnl poll() does not work on these platforms
5009      dnl Interix: "does provide poll(), but the implementing developer must
5010      dnl have been in a bad mood, because poll() only works on the /proc
5011      dnl filesystem here"
5012      dnl macOS: poll() first didn't exist, then was broken until fixed in 10.9
5013      dnl only to break again in 10.12.
5014      curl_disallow_poll="yes"
5015      tst_compi_poll="no"
5016      ;;
5017  esac
5018  #
5019  AC_MSG_CHECKING([if poll can be linked])
5020  AC_LINK_IFELSE([
5021    AC_LANG_PROGRAM([[
5022      $curl_includes_poll
5023    ]],[[
5024      if(0 != poll(0, 0, 0))
5025        return 1;
5026    ]])
5027  ],[
5028    AC_MSG_RESULT([yes])
5029    tst_links_poll="yes"
5030  ],[
5031    AC_MSG_RESULT([no])
5032    tst_links_poll="no"
5033  ])
5034  #
5035  if test "$tst_links_poll" = "yes"; then
5036    AC_MSG_CHECKING([if poll is prototyped])
5037    AC_EGREP_CPP([poll],[
5038      $curl_includes_poll
5039    ],[
5040      AC_MSG_RESULT([yes])
5041      tst_proto_poll="yes"
5042    ],[
5043      AC_MSG_RESULT([no])
5044      tst_proto_poll="no"
5045    ])
5046  fi
5047  #
5048  if test "$tst_proto_poll" = "yes"; then
5049    AC_MSG_CHECKING([if poll is compilable])
5050    AC_COMPILE_IFELSE([
5051      AC_LANG_PROGRAM([[
5052        $curl_includes_poll
5053      ]],[[
5054        if(0 != poll(0, 0, 0))
5055          return 1;
5056      ]])
5057    ],[
5058      AC_MSG_RESULT([yes])
5059      tst_compi_poll="yes"
5060    ],[
5061      AC_MSG_RESULT([no])
5062      tst_compi_poll="no"
5063    ])
5064  fi
5065  #
5066  dnl only do runtime verification when not cross-compiling
5067  if test "x$cross_compiling" != "xyes" &&
5068    test "$tst_compi_poll" = "yes"; then
5069    AC_MSG_CHECKING([if poll seems to work])
5070    CURL_RUN_IFELSE([
5071      AC_LANG_PROGRAM([[
5072        $curl_includes_stdlib
5073        $curl_includes_poll
5074        $curl_includes_time
5075      ]],[[
5076        /* detect the original poll() breakage */
5077        if(0 != poll(0, 0, 10))
5078          exit(1); /* fail */
5079        else {
5080          /* detect the 10.12 poll() breakage */
5081          struct timeval before, after;
5082          int rc;
5083          size_t us;
5084
5085          gettimeofday(&before, NULL);
5086          rc = poll(NULL, 0, 500);
5087          gettimeofday(&after, NULL);
5088
5089          us = (after.tv_sec - before.tv_sec) * 1000000 +
5090            (after.tv_usec - before.tv_usec);
5091
5092          if(us < 400000)
5093            exit(1);
5094        }
5095      ]])
5096    ],[
5097      AC_MSG_RESULT([yes])
5098      tst_works_poll="yes"
5099    ],[
5100      AC_MSG_RESULT([no])
5101      tst_works_poll="no"
5102    ])
5103  fi
5104  #
5105  if test "$tst_compi_poll" = "yes" &&
5106    test "$tst_works_poll" != "no"; then
5107    AC_MSG_CHECKING([if poll usage allowed])
5108    if test "x$curl_disallow_poll" != "xyes"; then
5109      AC_MSG_RESULT([yes])
5110      tst_allow_poll="yes"
5111    else
5112      AC_MSG_RESULT([no])
5113      tst_allow_poll="no"
5114    fi
5115  fi
5116  #
5117  AC_MSG_CHECKING([if poll might be used])
5118  if test "$tst_links_poll" = "yes" &&
5119     test "$tst_proto_poll" = "yes" &&
5120     test "$tst_compi_poll" = "yes" &&
5121     test "$tst_allow_poll" = "yes" &&
5122     test "$tst_works_poll" != "no"; then
5123    AC_MSG_RESULT([yes])
5124    AC_DEFINE_UNQUOTED(HAVE_POLL, 1,
5125      [Define to 1 if you have a working poll function.])
5126    AC_DEFINE_UNQUOTED(HAVE_POLL_FINE, 1,
5127      [If you have a fine poll])
5128    curl_cv_func_poll="yes"
5129  else
5130    AC_MSG_RESULT([no])
5131    curl_cv_func_poll="no"
5132  fi
5133])
5134
5135
5136dnl CURL_CHECK_FUNC_REMOVEXATTR
5137dnl -------------------------------------------------
5138dnl Verify if removexattr is available, prototyped, and
5139dnl can be compiled. If all of these are true, and
5140dnl usage has not been previously disallowed with
5141dnl shell variable curl_disallow_removexattr, then
5142dnl HAVE_REMOVEXATTR will be defined.
5143
5144AC_DEFUN([CURL_CHECK_FUNC_REMOVEXATTR], [
5145  AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
5146  #
5147  tst_links_removexattr="unknown"
5148  tst_proto_removexattr="unknown"
5149  tst_compi_removexattr="unknown"
5150  tst_allow_removexattr="unknown"
5151  tst_nargs_removexattr="unknown"
5152  #
5153  AC_MSG_CHECKING([if removexattr can be linked])
5154  AC_LINK_IFELSE([
5155    AC_LANG_FUNC_LINK_TRY([removexattr])
5156  ],[
5157    AC_MSG_RESULT([yes])
5158    tst_links_removexattr="yes"
5159  ],[
5160    AC_MSG_RESULT([no])
5161    tst_links_removexattr="no"
5162  ])
5163  #
5164  if test "$tst_links_removexattr" = "yes"; then
5165    AC_MSG_CHECKING([if removexattr is prototyped])
5166    AC_EGREP_CPP([removexattr],[
5167      $curl_includes_sys_xattr
5168    ],[
5169      AC_MSG_RESULT([yes])
5170      tst_proto_removexattr="yes"
5171    ],[
5172      AC_MSG_RESULT([no])
5173      tst_proto_removexattr="no"
5174    ])
5175  fi
5176  #
5177  if test "$tst_proto_removexattr" = "yes"; then
5178    if test "$tst_nargs_removexattr" = "unknown"; then
5179      AC_MSG_CHECKING([if removexattr takes 2 args.])
5180      AC_COMPILE_IFELSE([
5181        AC_LANG_PROGRAM([[
5182          $curl_includes_sys_xattr
5183        ]],[[
5184          if(0 != removexattr(0, 0))
5185            return 1;
5186        ]])
5187      ],[
5188        AC_MSG_RESULT([yes])
5189        tst_compi_removexattr="yes"
5190        tst_nargs_removexattr="2"
5191      ],[
5192        AC_MSG_RESULT([no])
5193        tst_compi_removexattr="no"
5194      ])
5195    fi
5196    if test "$tst_nargs_removexattr" = "unknown"; then
5197      AC_MSG_CHECKING([if removexattr takes 3 args.])
5198      AC_COMPILE_IFELSE([
5199        AC_LANG_PROGRAM([[
5200          $curl_includes_sys_xattr
5201        ]],[[
5202          if(0 != removexattr(0, 0, 0))
5203            return 1;
5204        ]])
5205      ],[
5206        AC_MSG_RESULT([yes])
5207        tst_compi_removexattr="yes"
5208        tst_nargs_removexattr="3"
5209      ],[
5210        AC_MSG_RESULT([no])
5211        tst_compi_removexattr="no"
5212      ])
5213    fi
5214    AC_MSG_CHECKING([if removexattr is compilable])
5215    if test "$tst_compi_removexattr" = "yes"; then
5216      AC_MSG_RESULT([yes])
5217    else
5218      AC_MSG_RESULT([no])
5219    fi
5220  fi
5221  #
5222  if test "$tst_compi_removexattr" = "yes"; then
5223    AC_MSG_CHECKING([if removexattr usage allowed])
5224    if test "x$curl_disallow_removexattr" != "xyes"; then
5225      AC_MSG_RESULT([yes])
5226      tst_allow_removexattr="yes"
5227    else
5228      AC_MSG_RESULT([no])
5229      tst_allow_removexattr="no"
5230    fi
5231  fi
5232  #
5233  AC_MSG_CHECKING([if removexattr might be used])
5234  if test "$tst_links_removexattr" = "yes" &&
5235     test "$tst_proto_removexattr" = "yes" &&
5236     test "$tst_compi_removexattr" = "yes" &&
5237     test "$tst_allow_removexattr" = "yes"; then
5238    AC_MSG_RESULT([yes])
5239    AC_DEFINE_UNQUOTED(HAVE_REMOVEXATTR, 1,
5240      [Define to 1 if you have the removexattr function.])
5241    dnl AC_DEFINE_UNQUOTED(REMOVEXATTR_ARGS, $tst_nargs_removexattr,
5242    dnl   [Specifies the number of arguments to removexattr])
5243    #
5244    if test "$tst_nargs_removexattr" -eq "2"; then
5245      AC_DEFINE(HAVE_REMOVEXATTR_2, 1, [removexattr() takes 2 args])
5246    elif test "$tst_nargs_removexattr" -eq "3"; then
5247      AC_DEFINE(HAVE_REMOVEXATTR_3, 1, [removexattr() takes 3 args])
5248    fi
5249    #
5250    curl_cv_func_removexattr="yes"
5251  else
5252    AC_MSG_RESULT([no])
5253    curl_cv_func_removexattr="no"
5254  fi
5255])
5256
5257
5258dnl CURL_CHECK_FUNC_SETSOCKOPT
5259dnl -------------------------------------------------
5260dnl Verify if setsockopt is available, prototyped, and
5261dnl can be compiled. If all of these are true, and
5262dnl usage has not been previously disallowed with
5263dnl shell variable curl_disallow_setsockopt, then
5264dnl HAVE_SETSOCKOPT will be defined.
5265
5266AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT], [
5267  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
5268  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
5269  #
5270  tst_links_setsockopt="unknown"
5271  tst_proto_setsockopt="unknown"
5272  tst_compi_setsockopt="unknown"
5273  tst_allow_setsockopt="unknown"
5274  #
5275  AC_MSG_CHECKING([if setsockopt can be linked])
5276  AC_LINK_IFELSE([
5277    AC_LANG_PROGRAM([[
5278      $curl_includes_winsock2
5279      $curl_includes_bsdsocket
5280      $curl_includes_sys_socket
5281    ]],[[
5282      if(0 != setsockopt(0, 0, 0, 0, 0))
5283        return 1;
5284    ]])
5285  ],[
5286    AC_MSG_RESULT([yes])
5287    tst_links_setsockopt="yes"
5288  ],[
5289    AC_MSG_RESULT([no])
5290    tst_links_setsockopt="no"
5291  ])
5292  #
5293  if test "$tst_links_setsockopt" = "yes"; then
5294    AC_MSG_CHECKING([if setsockopt is prototyped])
5295    AC_EGREP_CPP([setsockopt],[
5296      $curl_includes_winsock2
5297      $curl_includes_bsdsocket
5298      $curl_includes_sys_socket
5299    ],[
5300      AC_MSG_RESULT([yes])
5301      tst_proto_setsockopt="yes"
5302    ],[
5303      AC_MSG_RESULT([no])
5304      tst_proto_setsockopt="no"
5305    ])
5306  fi
5307  #
5308  if test "$tst_proto_setsockopt" = "yes"; then
5309    AC_MSG_CHECKING([if setsockopt is compilable])
5310    AC_COMPILE_IFELSE([
5311      AC_LANG_PROGRAM([[
5312        $curl_includes_winsock2
5313      $curl_includes_bsdsocket
5314        $curl_includes_sys_socket
5315      ]],[[
5316        if(0 != setsockopt(0, 0, 0, 0, 0))
5317          return 1;
5318      ]])
5319    ],[
5320      AC_MSG_RESULT([yes])
5321      tst_compi_setsockopt="yes"
5322    ],[
5323      AC_MSG_RESULT([no])
5324      tst_compi_setsockopt="no"
5325    ])
5326  fi
5327  #
5328  if test "$tst_compi_setsockopt" = "yes"; then
5329    AC_MSG_CHECKING([if setsockopt usage allowed])
5330    if test "x$curl_disallow_setsockopt" != "xyes"; then
5331      AC_MSG_RESULT([yes])
5332      tst_allow_setsockopt="yes"
5333    else
5334      AC_MSG_RESULT([no])
5335      tst_allow_setsockopt="no"
5336    fi
5337  fi
5338  #
5339  AC_MSG_CHECKING([if setsockopt might be used])
5340  if test "$tst_links_setsockopt" = "yes" &&
5341     test "$tst_proto_setsockopt" = "yes" &&
5342     test "$tst_compi_setsockopt" = "yes" &&
5343     test "$tst_allow_setsockopt" = "yes"; then
5344    AC_MSG_RESULT([yes])
5345    AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT, 1,
5346      [Define to 1 if you have the setsockopt function.])
5347    curl_cv_func_setsockopt="yes"
5348    CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
5349  else
5350    AC_MSG_RESULT([no])
5351    curl_cv_func_setsockopt="no"
5352  fi
5353])
5354
5355
5356dnl CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
5357dnl -------------------------------------------------
5358dnl Verify if setsockopt with the SO_NONBLOCK command is
5359dnl available, can be compiled, and seems to work. If
5360dnl all of these are true, then HAVE_SETSOCKOPT_SO_NONBLOCK
5361dnl will be defined.
5362
5363AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [
5364  #
5365  tst_compi_setsockopt_so_nonblock="unknown"
5366  tst_allow_setsockopt_so_nonblock="unknown"
5367  #
5368  if test "$curl_cv_func_setsockopt" = "yes"; then
5369    AC_MSG_CHECKING([if setsockopt SO_NONBLOCK is compilable])
5370    AC_COMPILE_IFELSE([
5371      AC_LANG_PROGRAM([[
5372        $curl_includes_winsock2
5373      $curl_includes_bsdsocket
5374        $curl_includes_sys_socket
5375      ]],[[
5376        if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
5377          return 1;
5378      ]])
5379    ],[
5380      AC_MSG_RESULT([yes])
5381      tst_compi_setsockopt_so_nonblock="yes"
5382    ],[
5383      AC_MSG_RESULT([no])
5384      tst_compi_setsockopt_so_nonblock="no"
5385    ])
5386  fi
5387  #
5388  if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then
5389    AC_MSG_CHECKING([if setsockopt SO_NONBLOCK usage allowed])
5390    if test "x$curl_disallow_setsockopt_so_nonblock" != "xyes"; then
5391      AC_MSG_RESULT([yes])
5392      tst_allow_setsockopt_so_nonblock="yes"
5393    else
5394      AC_MSG_RESULT([no])
5395      tst_allow_setsockopt_so_nonblock="no"
5396    fi
5397  fi
5398  #
5399  AC_MSG_CHECKING([if setsockopt SO_NONBLOCK might be used])
5400  if test "$tst_compi_setsockopt_so_nonblock" = "yes" &&
5401     test "$tst_allow_setsockopt_so_nonblock" = "yes"; then
5402    AC_MSG_RESULT([yes])
5403    AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT_SO_NONBLOCK, 1,
5404      [Define to 1 if you have a working setsockopt SO_NONBLOCK function.])
5405    curl_cv_func_setsockopt_so_nonblock="yes"
5406  else
5407    AC_MSG_RESULT([no])
5408    curl_cv_func_setsockopt_so_nonblock="no"
5409  fi
5410])
5411
5412
5413dnl CURL_CHECK_FUNC_SETXATTR
5414dnl -------------------------------------------------
5415dnl Verify if setxattr is available, prototyped, and
5416dnl can be compiled. If all of these are true, and
5417dnl usage has not been previously disallowed with
5418dnl shell variable curl_disallow_setxattr, then
5419dnl HAVE_SETXATTR will be defined.
5420
5421AC_DEFUN([CURL_CHECK_FUNC_SETXATTR], [
5422  AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
5423  #
5424  tst_links_setxattr="unknown"
5425  tst_proto_setxattr="unknown"
5426  tst_compi_setxattr="unknown"
5427  tst_allow_setxattr="unknown"
5428  tst_nargs_setxattr="unknown"
5429  #
5430  AC_MSG_CHECKING([if setxattr can be linked])
5431  AC_LINK_IFELSE([
5432    AC_LANG_FUNC_LINK_TRY([setxattr])
5433  ],[
5434    AC_MSG_RESULT([yes])
5435    tst_links_setxattr="yes"
5436  ],[
5437    AC_MSG_RESULT([no])
5438    tst_links_setxattr="no"
5439  ])
5440  #
5441  if test "$tst_links_setxattr" = "yes"; then
5442    AC_MSG_CHECKING([if setxattr is prototyped])
5443    AC_EGREP_CPP([setxattr],[
5444      $curl_includes_sys_xattr
5445    ],[
5446      AC_MSG_RESULT([yes])
5447      tst_proto_setxattr="yes"
5448    ],[
5449      AC_MSG_RESULT([no])
5450      tst_proto_setxattr="no"
5451    ])
5452  fi
5453  #
5454  if test "$tst_proto_setxattr" = "yes"; then
5455    if test "$tst_nargs_setxattr" = "unknown"; then
5456      AC_MSG_CHECKING([if setxattr takes 5 args.])
5457      AC_COMPILE_IFELSE([
5458        AC_LANG_PROGRAM([[
5459          $curl_includes_sys_xattr
5460        ]],[[
5461          if(0 != setxattr(0, 0, 0, 0, 0))
5462            return 1;
5463        ]])
5464      ],[
5465        AC_MSG_RESULT([yes])
5466        tst_compi_setxattr="yes"
5467        tst_nargs_setxattr="5"
5468      ],[
5469        AC_MSG_RESULT([no])
5470        tst_compi_setxattr="no"
5471      ])
5472    fi
5473    if test "$tst_nargs_setxattr" = "unknown"; then
5474      AC_MSG_CHECKING([if setxattr takes 6 args.])
5475      AC_COMPILE_IFELSE([
5476        AC_LANG_PROGRAM([[
5477          $curl_includes_sys_xattr
5478        ]],[[
5479          if(0 != setxattr(0, 0, 0, 0, 0, 0))
5480            return 1;
5481        ]])
5482      ],[
5483        AC_MSG_RESULT([yes])
5484        tst_compi_setxattr="yes"
5485        tst_nargs_setxattr="6"
5486      ],[
5487        AC_MSG_RESULT([no])
5488        tst_compi_setxattr="no"
5489      ])
5490    fi
5491    AC_MSG_CHECKING([if setxattr is compilable])
5492    if test "$tst_compi_setxattr" = "yes"; then
5493      AC_MSG_RESULT([yes])
5494    else
5495      AC_MSG_RESULT([no])
5496    fi
5497  fi
5498  #
5499  if test "$tst_compi_setxattr" = "yes"; then
5500    AC_MSG_CHECKING([if setxattr usage allowed])
5501    if test "x$curl_disallow_setxattr" != "xyes"; then
5502      AC_MSG_RESULT([yes])
5503      tst_allow_setxattr="yes"
5504    else
5505      AC_MSG_RESULT([no])
5506      tst_allow_setxattr="no"
5507    fi
5508  fi
5509  #
5510  AC_MSG_CHECKING([if setxattr might be used])
5511  if test "$tst_links_setxattr" = "yes" &&
5512     test "$tst_proto_setxattr" = "yes" &&
5513     test "$tst_compi_setxattr" = "yes" &&
5514     test "$tst_allow_setxattr" = "yes"; then
5515    AC_MSG_RESULT([yes])
5516    AC_DEFINE_UNQUOTED(HAVE_SETXATTR, 1,
5517      [Define to 1 if you have the setxattr function.])
5518    dnl AC_DEFINE_UNQUOTED(SETXATTR_ARGS, $tst_nargs_setxattr,
5519    dnl   [Specifies the number of arguments to setxattr])
5520    #
5521    if test "$tst_nargs_setxattr" -eq "5"; then
5522      AC_DEFINE(HAVE_SETXATTR_5, 1, [setxattr() takes 5 args])
5523    elif test "$tst_nargs_setxattr" -eq "6"; then
5524      AC_DEFINE(HAVE_SETXATTR_6, 1, [setxattr() takes 6 args])
5525    fi
5526    #
5527    curl_cv_func_setxattr="yes"
5528  else
5529    AC_MSG_RESULT([no])
5530    curl_cv_func_setxattr="no"
5531  fi
5532])
5533
5534
5535dnl CURL_CHECK_FUNC_SIGACTION
5536dnl -------------------------------------------------
5537dnl Verify if sigaction is available, prototyped, and
5538dnl can be compiled. If all of these are true, and
5539dnl usage has not been previously disallowed with
5540dnl shell variable curl_disallow_sigaction, then
5541dnl HAVE_SIGACTION will be defined.
5542
5543AC_DEFUN([CURL_CHECK_FUNC_SIGACTION], [
5544  AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
5545  #
5546  tst_links_sigaction="unknown"
5547  tst_proto_sigaction="unknown"
5548  tst_compi_sigaction="unknown"
5549  tst_allow_sigaction="unknown"
5550  #
5551  AC_MSG_CHECKING([if sigaction can be linked])
5552  AC_LINK_IFELSE([
5553    AC_LANG_FUNC_LINK_TRY([sigaction])
5554  ],[
5555    AC_MSG_RESULT([yes])
5556    tst_links_sigaction="yes"
5557  ],[
5558    AC_MSG_RESULT([no])
5559    tst_links_sigaction="no"
5560  ])
5561  #
5562  if test "$tst_links_sigaction" = "yes"; then
5563    AC_MSG_CHECKING([if sigaction is prototyped])
5564    AC_EGREP_CPP([sigaction],[
5565      $curl_includes_signal
5566    ],[
5567      AC_MSG_RESULT([yes])
5568      tst_proto_sigaction="yes"
5569    ],[
5570      AC_MSG_RESULT([no])
5571      tst_proto_sigaction="no"
5572    ])
5573  fi
5574  #
5575  if test "$tst_proto_sigaction" = "yes"; then
5576    AC_MSG_CHECKING([if sigaction is compilable])
5577    AC_COMPILE_IFELSE([
5578      AC_LANG_PROGRAM([[
5579        $curl_includes_signal
5580      ]],[[
5581        if(0 != sigaction(0, 0, 0))
5582          return 1;
5583      ]])
5584    ],[
5585      AC_MSG_RESULT([yes])
5586      tst_compi_sigaction="yes"
5587    ],[
5588      AC_MSG_RESULT([no])
5589      tst_compi_sigaction="no"
5590    ])
5591  fi
5592  #
5593  if test "$tst_compi_sigaction" = "yes"; then
5594    AC_MSG_CHECKING([if sigaction usage allowed])
5595    if test "x$curl_disallow_sigaction" != "xyes"; then
5596      AC_MSG_RESULT([yes])
5597      tst_allow_sigaction="yes"
5598    else
5599      AC_MSG_RESULT([no])
5600      tst_allow_sigaction="no"
5601    fi
5602  fi
5603  #
5604  AC_MSG_CHECKING([if sigaction might be used])
5605  if test "$tst_links_sigaction" = "yes" &&
5606     test "$tst_proto_sigaction" = "yes" &&
5607     test "$tst_compi_sigaction" = "yes" &&
5608     test "$tst_allow_sigaction" = "yes"; then
5609    AC_MSG_RESULT([yes])
5610    AC_DEFINE_UNQUOTED(HAVE_SIGACTION, 1,
5611      [Define to 1 if you have the sigaction function.])
5612    curl_cv_func_sigaction="yes"
5613  else
5614    AC_MSG_RESULT([no])
5615    curl_cv_func_sigaction="no"
5616  fi
5617])
5618
5619
5620dnl CURL_CHECK_FUNC_SIGINTERRUPT
5621dnl -------------------------------------------------
5622dnl Verify if siginterrupt is available, prototyped, and
5623dnl can be compiled. If all of these are true, and
5624dnl usage has not been previously disallowed with
5625dnl shell variable curl_disallow_siginterrupt, then
5626dnl HAVE_SIGINTERRUPT will be defined.
5627
5628AC_DEFUN([CURL_CHECK_FUNC_SIGINTERRUPT], [
5629  AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
5630  #
5631  tst_links_siginterrupt="unknown"
5632  tst_proto_siginterrupt="unknown"
5633  tst_compi_siginterrupt="unknown"
5634  tst_allow_siginterrupt="unknown"
5635  #
5636  AC_MSG_CHECKING([if siginterrupt can be linked])
5637  AC_LINK_IFELSE([
5638    AC_LANG_FUNC_LINK_TRY([siginterrupt])
5639  ],[
5640    AC_MSG_RESULT([yes])
5641    tst_links_siginterrupt="yes"
5642  ],[
5643    AC_MSG_RESULT([no])
5644    tst_links_siginterrupt="no"
5645  ])
5646  #
5647  if test "$tst_links_siginterrupt" = "yes"; then
5648    AC_MSG_CHECKING([if siginterrupt is prototyped])
5649    AC_EGREP_CPP([siginterrupt],[
5650      $curl_includes_signal
5651    ],[
5652      AC_MSG_RESULT([yes])
5653      tst_proto_siginterrupt="yes"
5654    ],[
5655      AC_MSG_RESULT([no])
5656      tst_proto_siginterrupt="no"
5657    ])
5658  fi
5659  #
5660  if test "$tst_proto_siginterrupt" = "yes"; then
5661    AC_MSG_CHECKING([if siginterrupt is compilable])
5662    AC_COMPILE_IFELSE([
5663      AC_LANG_PROGRAM([[
5664        $curl_includes_signal
5665      ]],[[
5666        if(0 != siginterrupt(0, 0))
5667          return 1;
5668      ]])
5669    ],[
5670      AC_MSG_RESULT([yes])
5671      tst_compi_siginterrupt="yes"
5672    ],[
5673      AC_MSG_RESULT([no])
5674      tst_compi_siginterrupt="no"
5675    ])
5676  fi
5677  #
5678  if test "$tst_compi_siginterrupt" = "yes"; then
5679    AC_MSG_CHECKING([if siginterrupt usage allowed])
5680    if test "x$curl_disallow_siginterrupt" != "xyes"; then
5681      AC_MSG_RESULT([yes])
5682      tst_allow_siginterrupt="yes"
5683    else
5684      AC_MSG_RESULT([no])
5685      tst_allow_siginterrupt="no"
5686    fi
5687  fi
5688  #
5689  AC_MSG_CHECKING([if siginterrupt might be used])
5690  if test "$tst_links_siginterrupt" = "yes" &&
5691     test "$tst_proto_siginterrupt" = "yes" &&
5692     test "$tst_compi_siginterrupt" = "yes" &&
5693     test "$tst_allow_siginterrupt" = "yes"; then
5694    AC_MSG_RESULT([yes])
5695    AC_DEFINE_UNQUOTED(HAVE_SIGINTERRUPT, 1,
5696      [Define to 1 if you have the siginterrupt function.])
5697    curl_cv_func_siginterrupt="yes"
5698  else
5699    AC_MSG_RESULT([no])
5700    curl_cv_func_siginterrupt="no"
5701  fi
5702])
5703
5704
5705dnl CURL_CHECK_FUNC_SIGNAL
5706dnl -------------------------------------------------
5707dnl Verify if signal is available, prototyped, and
5708dnl can be compiled. If all of these are true, and
5709dnl usage has not been previously disallowed with
5710dnl shell variable curl_disallow_signal, then
5711dnl HAVE_SIGNAL will be defined.
5712
5713AC_DEFUN([CURL_CHECK_FUNC_SIGNAL], [
5714  AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
5715  #
5716  tst_links_signal="unknown"
5717  tst_proto_signal="unknown"
5718  tst_compi_signal="unknown"
5719  tst_allow_signal="unknown"
5720  #
5721  AC_MSG_CHECKING([if signal can be linked])
5722  AC_LINK_IFELSE([
5723    AC_LANG_FUNC_LINK_TRY([signal])
5724  ],[
5725    AC_MSG_RESULT([yes])
5726    tst_links_signal="yes"
5727  ],[
5728    AC_MSG_RESULT([no])
5729    tst_links_signal="no"
5730  ])
5731  #
5732  if test "$tst_links_signal" = "yes"; then
5733    AC_MSG_CHECKING([if signal is prototyped])
5734    AC_EGREP_CPP([signal],[
5735      $curl_includes_signal
5736    ],[
5737      AC_MSG_RESULT([yes])
5738      tst_proto_signal="yes"
5739    ],[
5740      AC_MSG_RESULT([no])
5741      tst_proto_signal="no"
5742    ])
5743  fi
5744  #
5745  if test "$tst_proto_signal" = "yes"; then
5746    AC_MSG_CHECKING([if signal is compilable])
5747    AC_COMPILE_IFELSE([
5748      AC_LANG_PROGRAM([[
5749        $curl_includes_signal
5750      ]],[[
5751        if(0 != signal(0, 0))
5752          return 1;
5753      ]])
5754    ],[
5755      AC_MSG_RESULT([yes])
5756      tst_compi_signal="yes"
5757    ],[
5758      AC_MSG_RESULT([no])
5759      tst_compi_signal="no"
5760    ])
5761  fi
5762  #
5763  if test "$tst_compi_signal" = "yes"; then
5764    AC_MSG_CHECKING([if signal usage allowed])
5765    if test "x$curl_disallow_signal" != "xyes"; then
5766      AC_MSG_RESULT([yes])
5767      tst_allow_signal="yes"
5768    else
5769      AC_MSG_RESULT([no])
5770      tst_allow_signal="no"
5771    fi
5772  fi
5773  #
5774  AC_MSG_CHECKING([if signal might be used])
5775  if test "$tst_links_signal" = "yes" &&
5776     test "$tst_proto_signal" = "yes" &&
5777     test "$tst_compi_signal" = "yes" &&
5778     test "$tst_allow_signal" = "yes"; then
5779    AC_MSG_RESULT([yes])
5780    AC_DEFINE_UNQUOTED(HAVE_SIGNAL, 1,
5781      [Define to 1 if you have the signal function.])
5782    curl_cv_func_signal="yes"
5783  else
5784    AC_MSG_RESULT([no])
5785    curl_cv_func_signal="no"
5786  fi
5787])
5788
5789
5790dnl CURL_CHECK_FUNC_SIGSETJMP
5791dnl -------------------------------------------------
5792dnl Verify if sigsetjmp is available, prototyped, and
5793dnl can be compiled. If all of these are true, and
5794dnl usage has not been previously disallowed with
5795dnl shell variable curl_disallow_sigsetjmp, then
5796dnl HAVE_SIGSETJMP will be defined.
5797
5798AC_DEFUN([CURL_CHECK_FUNC_SIGSETJMP], [
5799  AC_REQUIRE([CURL_INCLUDES_SETJMP])dnl
5800  #
5801  tst_links_sigsetjmp="unknown"
5802  tst_macro_sigsetjmp="unknown"
5803  tst_proto_sigsetjmp="unknown"
5804  tst_compi_sigsetjmp="unknown"
5805  tst_allow_sigsetjmp="unknown"
5806  #
5807  AC_MSG_CHECKING([if sigsetjmp can be linked])
5808  AC_LINK_IFELSE([
5809    AC_LANG_FUNC_LINK_TRY([sigsetjmp])
5810  ],[
5811    AC_MSG_RESULT([yes])
5812    tst_links_sigsetjmp="yes"
5813  ],[
5814    AC_MSG_RESULT([no])
5815    tst_links_sigsetjmp="no"
5816  ])
5817  #
5818  if test "$tst_links_sigsetjmp" = "no"; then
5819    AC_MSG_CHECKING([if sigsetjmp seems a macro])
5820    AC_LINK_IFELSE([
5821      AC_LANG_PROGRAM([[
5822        $curl_includes_setjmp
5823      ]],[[
5824        sigjmp_buf env;
5825        if(0 != sigsetjmp(env, 0))
5826          return 1;
5827      ]])
5828    ],[
5829      AC_MSG_RESULT([yes])
5830      tst_macro_sigsetjmp="yes"
5831    ],[
5832      AC_MSG_RESULT([no])
5833      tst_macro_sigsetjmp="no"
5834    ])
5835  fi
5836  #
5837  if test "$tst_links_sigsetjmp" = "yes"; then
5838    AC_MSG_CHECKING([if sigsetjmp is prototyped])
5839    AC_EGREP_CPP([sigsetjmp],[
5840      $curl_includes_setjmp
5841    ],[
5842      AC_MSG_RESULT([yes])
5843      tst_proto_sigsetjmp="yes"
5844    ],[
5845      AC_MSG_RESULT([no])
5846      tst_proto_sigsetjmp="no"
5847    ])
5848  fi
5849  #
5850  if test "$tst_proto_sigsetjmp" = "yes" ||
5851     test "$tst_macro_sigsetjmp" = "yes"; then
5852    AC_MSG_CHECKING([if sigsetjmp is compilable])
5853    AC_COMPILE_IFELSE([
5854      AC_LANG_PROGRAM([[
5855        $curl_includes_setjmp
5856      ]],[[
5857        sigjmp_buf env;
5858        if(0 != sigsetjmp(env, 0))
5859          return 1;
5860      ]])
5861    ],[
5862      AC_MSG_RESULT([yes])
5863      tst_compi_sigsetjmp="yes"
5864    ],[
5865      AC_MSG_RESULT([no])
5866      tst_compi_sigsetjmp="no"
5867    ])
5868  fi
5869  #
5870  if test "$tst_compi_sigsetjmp" = "yes"; then
5871    AC_MSG_CHECKING([if sigsetjmp usage allowed])
5872    if test "x$curl_disallow_sigsetjmp" != "xyes"; then
5873      AC_MSG_RESULT([yes])
5874      tst_allow_sigsetjmp="yes"
5875    else
5876      AC_MSG_RESULT([no])
5877      tst_allow_sigsetjmp="no"
5878    fi
5879  fi
5880  #
5881  AC_MSG_CHECKING([if sigsetjmp might be used])
5882  if (test "$tst_proto_sigsetjmp" = "yes" ||
5883      test "$tst_macro_sigsetjmp" = "yes") &&
5884     test "$tst_compi_sigsetjmp" = "yes" &&
5885     test "$tst_allow_sigsetjmp" = "yes"; then
5886    AC_MSG_RESULT([yes])
5887    AC_DEFINE_UNQUOTED(HAVE_SIGSETJMP, 1,
5888      [Define to 1 if you have the sigsetjmp function or macro.])
5889    curl_cv_func_sigsetjmp="yes"
5890  else
5891    AC_MSG_RESULT([no])
5892    curl_cv_func_sigsetjmp="no"
5893  fi
5894])
5895
5896
5897dnl CURL_CHECK_FUNC_SOCKET
5898dnl -------------------------------------------------
5899dnl Verify if socket is available, prototyped, and
5900dnl can be compiled. If all of these are true, and
5901dnl usage has not been previously disallowed with
5902dnl shell variable curl_disallow_socket, then
5903dnl HAVE_SOCKET will be defined.
5904
5905AC_DEFUN([CURL_CHECK_FUNC_SOCKET], [
5906  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
5907  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
5908  AC_REQUIRE([CURL_INCLUDES_SOCKET])dnl
5909  #
5910  tst_links_socket="unknown"
5911  tst_proto_socket="unknown"
5912  tst_compi_socket="unknown"
5913  tst_allow_socket="unknown"
5914  #
5915  AC_MSG_CHECKING([if socket can be linked])
5916  AC_LINK_IFELSE([
5917    AC_LANG_PROGRAM([[
5918      $curl_includes_winsock2
5919      $curl_includes_bsdsocket
5920      $curl_includes_sys_socket
5921      $curl_includes_socket
5922    ]],[[
5923      if(0 != socket(0, 0, 0))
5924        return 1;
5925    ]])
5926  ],[
5927    AC_MSG_RESULT([yes])
5928    tst_links_socket="yes"
5929  ],[
5930    AC_MSG_RESULT([no])
5931    tst_links_socket="no"
5932  ])
5933  #
5934  if test "$tst_links_socket" = "yes"; then
5935    AC_MSG_CHECKING([if socket is prototyped])
5936    AC_EGREP_CPP([socket],[
5937      $curl_includes_winsock2
5938      $curl_includes_bsdsocket
5939      $curl_includes_sys_socket
5940      $curl_includes_socket
5941    ],[
5942      AC_MSG_RESULT([yes])
5943      tst_proto_socket="yes"
5944    ],[
5945      AC_MSG_RESULT([no])
5946      tst_proto_socket="no"
5947    ])
5948  fi
5949  #
5950  if test "$tst_proto_socket" = "yes"; then
5951    AC_MSG_CHECKING([if socket is compilable])
5952    AC_COMPILE_IFELSE([
5953      AC_LANG_PROGRAM([[
5954        $curl_includes_winsock2
5955      $curl_includes_bsdsocket
5956        $curl_includes_sys_socket
5957        $curl_includes_socket
5958      ]],[[
5959        if(0 != socket(0, 0, 0))
5960          return 1;
5961      ]])
5962    ],[
5963      AC_MSG_RESULT([yes])
5964      tst_compi_socket="yes"
5965    ],[
5966      AC_MSG_RESULT([no])
5967      tst_compi_socket="no"
5968    ])
5969  fi
5970  #
5971  if test "$tst_compi_socket" = "yes"; then
5972    AC_MSG_CHECKING([if socket usage allowed])
5973    if test "x$curl_disallow_socket" != "xyes"; then
5974      AC_MSG_RESULT([yes])
5975      tst_allow_socket="yes"
5976    else
5977      AC_MSG_RESULT([no])
5978      tst_allow_socket="no"
5979    fi
5980  fi
5981  #
5982  AC_MSG_CHECKING([if socket might be used])
5983  if test "$tst_links_socket" = "yes" &&
5984     test "$tst_proto_socket" = "yes" &&
5985     test "$tst_compi_socket" = "yes" &&
5986     test "$tst_allow_socket" = "yes"; then
5987    AC_MSG_RESULT([yes])
5988    AC_DEFINE_UNQUOTED(HAVE_SOCKET, 1,
5989      [Define to 1 if you have the socket function.])
5990    curl_cv_func_socket="yes"
5991  else
5992    AC_MSG_RESULT([no])
5993    curl_cv_func_socket="no"
5994  fi
5995])
5996
5997
5998dnl CURL_CHECK_FUNC_SOCKETPAIR
5999dnl -------------------------------------------------
6000dnl Verify if socketpair is available, prototyped, and
6001dnl can be compiled. If all of these are true, and
6002dnl usage has not been previously disallowed with
6003dnl shell variable curl_disallow_socketpair, then
6004dnl HAVE_SOCKETPAIR will be defined.
6005
6006AC_DEFUN([CURL_CHECK_FUNC_SOCKETPAIR], [
6007  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
6008  AC_REQUIRE([CURL_INCLUDES_SOCKET])dnl
6009  #
6010  tst_links_socketpair="unknown"
6011  tst_proto_socketpair="unknown"
6012  tst_compi_socketpair="unknown"
6013  tst_allow_socketpair="unknown"
6014  #
6015  AC_MSG_CHECKING([if socketpair can be linked])
6016  AC_LINK_IFELSE([
6017    AC_LANG_FUNC_LINK_TRY([socketpair])
6018  ],[
6019    AC_MSG_RESULT([yes])
6020    tst_links_socketpair="yes"
6021  ],[
6022    AC_MSG_RESULT([no])
6023    tst_links_socketpair="no"
6024  ])
6025  #
6026  if test "$tst_links_socketpair" = "yes"; then
6027    AC_MSG_CHECKING([if socketpair is prototyped])
6028    AC_EGREP_CPP([socketpair],[
6029      $curl_includes_sys_socket
6030      $curl_includes_socket
6031    ],[
6032      AC_MSG_RESULT([yes])
6033      tst_proto_socketpair="yes"
6034    ],[
6035      AC_MSG_RESULT([no])
6036      tst_proto_socketpair="no"
6037    ])
6038  fi
6039  #
6040  if test "$tst_proto_socketpair" = "yes"; then
6041    AC_MSG_CHECKING([if socketpair is compilable])
6042    AC_COMPILE_IFELSE([
6043      AC_LANG_PROGRAM([[
6044        $curl_includes_sys_socket
6045        $curl_includes_socket
6046      ]],[[
6047        int sv[2];
6048        if(0 != socketpair(0, 0, 0, sv))
6049          return 1;
6050      ]])
6051    ],[
6052      AC_MSG_RESULT([yes])
6053      tst_compi_socketpair="yes"
6054    ],[
6055      AC_MSG_RESULT([no])
6056      tst_compi_socketpair="no"
6057    ])
6058  fi
6059  #
6060  if test "$tst_compi_socketpair" = "yes"; then
6061    AC_MSG_CHECKING([if socketpair usage allowed])
6062    if test "x$curl_disallow_socketpair" != "xyes"; then
6063      AC_MSG_RESULT([yes])
6064      tst_allow_socketpair="yes"
6065    else
6066      AC_MSG_RESULT([no])
6067      tst_allow_socketpair="no"
6068    fi
6069  fi
6070  #
6071  AC_MSG_CHECKING([if socketpair might be used])
6072  if test "$tst_links_socketpair" = "yes" &&
6073     test "$tst_proto_socketpair" = "yes" &&
6074     test "$tst_compi_socketpair" = "yes" &&
6075     test "$tst_allow_socketpair" = "yes"; then
6076    AC_MSG_RESULT([yes])
6077    AC_DEFINE_UNQUOTED(HAVE_SOCKETPAIR, 1,
6078      [Define to 1 if you have the socketpair function.])
6079    curl_cv_func_socketpair="yes"
6080  else
6081    AC_MSG_RESULT([no])
6082    curl_cv_func_socketpair="no"
6083  fi
6084])
6085
6086
6087dnl CURL_CHECK_FUNC_STRCASECMP
6088dnl -------------------------------------------------
6089dnl Verify if strcasecmp is available, prototyped, and
6090dnl can be compiled. If all of these are true, and
6091dnl usage has not been previously disallowed with
6092dnl shell variable curl_disallow_strcasecmp, then
6093dnl HAVE_STRCASECMP will be defined.
6094
6095AC_DEFUN([CURL_CHECK_FUNC_STRCASECMP], [
6096  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6097  #
6098  tst_links_strcasecmp="unknown"
6099  tst_proto_strcasecmp="unknown"
6100  tst_compi_strcasecmp="unknown"
6101  tst_allow_strcasecmp="unknown"
6102  #
6103  AC_MSG_CHECKING([if strcasecmp can be linked])
6104  AC_LINK_IFELSE([
6105    AC_LANG_FUNC_LINK_TRY([strcasecmp])
6106  ],[
6107    AC_MSG_RESULT([yes])
6108    tst_links_strcasecmp="yes"
6109  ],[
6110    AC_MSG_RESULT([no])
6111    tst_links_strcasecmp="no"
6112  ])
6113  #
6114  if test "$tst_links_strcasecmp" = "yes"; then
6115    AC_MSG_CHECKING([if strcasecmp is prototyped])
6116    AC_EGREP_CPP([strcasecmp],[
6117      $curl_includes_string
6118    ],[
6119      AC_MSG_RESULT([yes])
6120      tst_proto_strcasecmp="yes"
6121    ],[
6122      AC_MSG_RESULT([no])
6123      tst_proto_strcasecmp="no"
6124    ])
6125  fi
6126  #
6127  if test "$tst_proto_strcasecmp" = "yes"; then
6128    AC_MSG_CHECKING([if strcasecmp is compilable])
6129    AC_COMPILE_IFELSE([
6130      AC_LANG_PROGRAM([[
6131        $curl_includes_string
6132      ]],[[
6133        if(0 != strcasecmp(0, 0))
6134          return 1;
6135      ]])
6136    ],[
6137      AC_MSG_RESULT([yes])
6138      tst_compi_strcasecmp="yes"
6139    ],[
6140      AC_MSG_RESULT([no])
6141      tst_compi_strcasecmp="no"
6142    ])
6143  fi
6144  #
6145  if test "$tst_compi_strcasecmp" = "yes"; then
6146    AC_MSG_CHECKING([if strcasecmp usage allowed])
6147    if test "x$curl_disallow_strcasecmp" != "xyes"; then
6148      AC_MSG_RESULT([yes])
6149      tst_allow_strcasecmp="yes"
6150    else
6151      AC_MSG_RESULT([no])
6152      tst_allow_strcasecmp="no"
6153    fi
6154  fi
6155  #
6156  AC_MSG_CHECKING([if strcasecmp might be used])
6157  if test "$tst_links_strcasecmp" = "yes" &&
6158     test "$tst_proto_strcasecmp" = "yes" &&
6159     test "$tst_compi_strcasecmp" = "yes" &&
6160     test "$tst_allow_strcasecmp" = "yes"; then
6161    AC_MSG_RESULT([yes])
6162    AC_DEFINE_UNQUOTED(HAVE_STRCASECMP, 1,
6163      [Define to 1 if you have the strcasecmp function.])
6164    curl_cv_func_strcasecmp="yes"
6165  else
6166    AC_MSG_RESULT([no])
6167    curl_cv_func_strcasecmp="no"
6168  fi
6169])
6170
6171dnl CURL_CHECK_FUNC_STRCMPI
6172dnl -------------------------------------------------
6173dnl Verify if strcmpi is available, prototyped, and
6174dnl can be compiled. If all of these are true, and
6175dnl usage has not been previously disallowed with
6176dnl shell variable curl_disallow_strcmpi, then
6177dnl HAVE_STRCMPI will be defined.
6178
6179AC_DEFUN([CURL_CHECK_FUNC_STRCMPI], [
6180  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6181  #
6182  tst_links_strcmpi="unknown"
6183  tst_proto_strcmpi="unknown"
6184  tst_compi_strcmpi="unknown"
6185  tst_allow_strcmpi="unknown"
6186  #
6187  AC_MSG_CHECKING([if strcmpi can be linked])
6188  AC_LINK_IFELSE([
6189    AC_LANG_FUNC_LINK_TRY([strcmpi])
6190  ],[
6191    AC_MSG_RESULT([yes])
6192    tst_links_strcmpi="yes"
6193  ],[
6194    AC_MSG_RESULT([no])
6195    tst_links_strcmpi="no"
6196  ])
6197  #
6198  if test "$tst_links_strcmpi" = "yes"; then
6199    AC_MSG_CHECKING([if strcmpi is prototyped])
6200    AC_EGREP_CPP([strcmpi],[
6201      $curl_includes_string
6202    ],[
6203      AC_MSG_RESULT([yes])
6204      tst_proto_strcmpi="yes"
6205    ],[
6206      AC_MSG_RESULT([no])
6207      tst_proto_strcmpi="no"
6208    ])
6209  fi
6210  #
6211  if test "$tst_proto_strcmpi" = "yes"; then
6212    AC_MSG_CHECKING([if strcmpi is compilable])
6213    AC_COMPILE_IFELSE([
6214      AC_LANG_PROGRAM([[
6215        $curl_includes_string
6216      ]],[[
6217        if(0 != strcmpi(0, 0))
6218          return 1;
6219      ]])
6220    ],[
6221      AC_MSG_RESULT([yes])
6222      tst_compi_strcmpi="yes"
6223    ],[
6224      AC_MSG_RESULT([no])
6225      tst_compi_strcmpi="no"
6226    ])
6227  fi
6228  #
6229  if test "$tst_compi_strcmpi" = "yes"; then
6230    AC_MSG_CHECKING([if strcmpi usage allowed])
6231    if test "x$curl_disallow_strcmpi" != "xyes"; then
6232      AC_MSG_RESULT([yes])
6233      tst_allow_strcmpi="yes"
6234    else
6235      AC_MSG_RESULT([no])
6236      tst_allow_strcmpi="no"
6237    fi
6238  fi
6239  #
6240  AC_MSG_CHECKING([if strcmpi might be used])
6241  if test "$tst_links_strcmpi" = "yes" &&
6242     test "$tst_proto_strcmpi" = "yes" &&
6243     test "$tst_compi_strcmpi" = "yes" &&
6244     test "$tst_allow_strcmpi" = "yes"; then
6245    AC_MSG_RESULT([yes])
6246    AC_DEFINE_UNQUOTED(HAVE_STRCMPI, 1,
6247      [Define to 1 if you have the strcmpi function.])
6248    curl_cv_func_strcmpi="yes"
6249  else
6250    AC_MSG_RESULT([no])
6251    curl_cv_func_strcmpi="no"
6252  fi
6253])
6254
6255
6256dnl CURL_CHECK_FUNC_STRDUP
6257dnl -------------------------------------------------
6258dnl Verify if strdup is available, prototyped, and
6259dnl can be compiled. If all of these are true, and
6260dnl usage has not been previously disallowed with
6261dnl shell variable curl_disallow_strdup, then
6262dnl HAVE_STRDUP will be defined.
6263
6264AC_DEFUN([CURL_CHECK_FUNC_STRDUP], [
6265  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6266  #
6267  tst_links_strdup="unknown"
6268  tst_proto_strdup="unknown"
6269  tst_compi_strdup="unknown"
6270  tst_allow_strdup="unknown"
6271  #
6272  AC_MSG_CHECKING([if strdup can be linked])
6273  AC_LINK_IFELSE([
6274    AC_LANG_FUNC_LINK_TRY([strdup])
6275  ],[
6276    AC_MSG_RESULT([yes])
6277    tst_links_strdup="yes"
6278  ],[
6279    AC_MSG_RESULT([no])
6280    tst_links_strdup="no"
6281  ])
6282  #
6283  if test "$tst_links_strdup" = "yes"; then
6284    AC_MSG_CHECKING([if strdup is prototyped])
6285    AC_EGREP_CPP([strdup],[
6286      $curl_includes_string
6287    ],[
6288      AC_MSG_RESULT([yes])
6289      tst_proto_strdup="yes"
6290    ],[
6291      AC_MSG_RESULT([no])
6292      tst_proto_strdup="no"
6293    ])
6294  fi
6295  #
6296  if test "$tst_proto_strdup" = "yes"; then
6297    AC_MSG_CHECKING([if strdup is compilable])
6298    AC_COMPILE_IFELSE([
6299      AC_LANG_PROGRAM([[
6300        $curl_includes_string
6301      ]],[[
6302        if(0 != strdup(0))
6303          return 1;
6304      ]])
6305    ],[
6306      AC_MSG_RESULT([yes])
6307      tst_compi_strdup="yes"
6308    ],[
6309      AC_MSG_RESULT([no])
6310      tst_compi_strdup="no"
6311    ])
6312  fi
6313  #
6314  if test "$tst_compi_strdup" = "yes"; then
6315    AC_MSG_CHECKING([if strdup usage allowed])
6316    if test "x$curl_disallow_strdup" != "xyes"; then
6317      AC_MSG_RESULT([yes])
6318      tst_allow_strdup="yes"
6319    else
6320      AC_MSG_RESULT([no])
6321      tst_allow_strdup="no"
6322    fi
6323  fi
6324  #
6325  AC_MSG_CHECKING([if strdup might be used])
6326  if test "$tst_links_strdup" = "yes" &&
6327     test "$tst_proto_strdup" = "yes" &&
6328     test "$tst_compi_strdup" = "yes" &&
6329     test "$tst_allow_strdup" = "yes"; then
6330    AC_MSG_RESULT([yes])
6331    AC_DEFINE_UNQUOTED(HAVE_STRDUP, 1,
6332      [Define to 1 if you have the strdup function.])
6333    curl_cv_func_strdup="yes"
6334  else
6335    AC_MSG_RESULT([no])
6336    curl_cv_func_strdup="no"
6337  fi
6338])
6339
6340
6341dnl CURL_CHECK_FUNC_STRERROR_R
6342dnl -------------------------------------------------
6343dnl Verify if strerror_r is available, prototyped, can be compiled and
6344dnl seems to work. If all of these are true, and usage has not been
6345dnl previously disallowed with shell variable curl_disallow_strerror_r,
6346dnl then HAVE_STRERROR_R and STRERROR_R_TYPE_ARG3 will be defined, as
6347dnl well as one of HAVE_GLIBC_STRERROR_R or HAVE_POSIX_STRERROR_R.
6348dnl
6349dnl glibc-style strerror_r:
6350dnl
6351dnl      char *strerror_r(int errnum, char *workbuf, size_t bufsize);
6352dnl
6353dnl  glibc-style strerror_r returns a pointer to the error string,
6354dnl  and might use the provided workbuf as a scratch area if needed. A
6355dnl  quick test on a few systems shows that it's usually not used at all.
6356dnl
6357dnl POSIX-style strerror_r:
6358dnl
6359dnl      int strerror_r(int errnum, char *resultbuf, size_t bufsize);
6360dnl
6361dnl  POSIX-style strerror_r returns 0 upon successful completion and the
6362dnl  error string in the provided resultbuf.
6363dnl
6364
6365AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
6366  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
6367  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6368  #
6369  tst_links_strerror_r="unknown"
6370  tst_proto_strerror_r="unknown"
6371  tst_compi_strerror_r="unknown"
6372  tst_glibc_strerror_r="unknown"
6373  tst_posix_strerror_r="unknown"
6374  tst_allow_strerror_r="unknown"
6375  tst_works_glibc_strerror_r="unknown"
6376  tst_works_posix_strerror_r="unknown"
6377  tst_glibc_strerror_r_type_arg3="unknown"
6378  tst_posix_strerror_r_type_arg3="unknown"
6379  #
6380  AC_MSG_CHECKING([if strerror_r can be linked])
6381  AC_LINK_IFELSE([
6382    AC_LANG_FUNC_LINK_TRY([strerror_r])
6383  ],[
6384    AC_MSG_RESULT([yes])
6385    tst_links_strerror_r="yes"
6386  ],[
6387    AC_MSG_RESULT([no])
6388    tst_links_strerror_r="no"
6389  ])
6390  #
6391  if test "$tst_links_strerror_r" = "yes"; then
6392    AC_MSG_CHECKING([if strerror_r is prototyped])
6393    AC_EGREP_CPP([strerror_r],[
6394      $curl_includes_string
6395    ],[
6396      AC_MSG_RESULT([yes])
6397      tst_proto_strerror_r="yes"
6398    ],[
6399      AC_MSG_RESULT([no])
6400      tst_proto_strerror_r="no"
6401    ])
6402  fi
6403  #
6404  if test "$tst_proto_strerror_r" = "yes"; then
6405    AC_MSG_CHECKING([if strerror_r is compilable])
6406    AC_COMPILE_IFELSE([
6407      AC_LANG_PROGRAM([[
6408        $curl_includes_string
6409      ]],[[
6410        if(0 != strerror_r(0, 0, 0))
6411          return 1;
6412      ]])
6413    ],[
6414      AC_MSG_RESULT([yes])
6415      tst_compi_strerror_r="yes"
6416    ],[
6417      AC_MSG_RESULT([no])
6418      tst_compi_strerror_r="no"
6419    ])
6420  fi
6421  #
6422  if test "$tst_compi_strerror_r" = "yes"; then
6423    AC_MSG_CHECKING([if strerror_r is glibc like])
6424    tst_glibc_strerror_r_type_arg3="unknown"
6425    for arg3 in 'size_t' 'int' 'unsigned int'; do
6426      if test "$tst_glibc_strerror_r_type_arg3" = "unknown"; then
6427        AC_COMPILE_IFELSE([
6428          AC_LANG_PROGRAM([[
6429            $curl_includes_string
6430            char *strerror_r(int errnum, char *workbuf, $arg3 bufsize);
6431          ]],[[
6432            if(0 != strerror_r(0, 0, 0))
6433              return 1;
6434          ]])
6435        ],[
6436          tst_glibc_strerror_r_type_arg3="$arg3"
6437        ])
6438      fi
6439    done
6440    case "$tst_glibc_strerror_r_type_arg3" in
6441      unknown)
6442        AC_MSG_RESULT([no])
6443        tst_glibc_strerror_r="no"
6444        ;;
6445      *)
6446        AC_MSG_RESULT([yes])
6447        tst_glibc_strerror_r="yes"
6448        ;;
6449    esac
6450  fi
6451  #
6452  dnl only do runtime verification when not cross-compiling
6453  if test "x$cross_compiling" != "xyes" &&
6454    test "$tst_glibc_strerror_r" = "yes"; then
6455    AC_MSG_CHECKING([if strerror_r seems to work])
6456    CURL_RUN_IFELSE([
6457      AC_LANG_PROGRAM([[
6458        $curl_includes_stdlib
6459        $curl_includes_string
6460#       include <errno.h>
6461      ]],[[
6462        char buffer[1024];
6463        char *string = 0;
6464        buffer[0] = '\0';
6465        string = strerror_r(EACCES, buffer, sizeof(buffer));
6466        if(!string)
6467          exit(1); /* fail */
6468        if(!string[0])
6469          exit(1); /* fail */
6470        else
6471          exit(0);
6472      ]])
6473    ],[
6474      AC_MSG_RESULT([yes])
6475      tst_works_glibc_strerror_r="yes"
6476    ],[
6477      AC_MSG_RESULT([no])
6478      tst_works_glibc_strerror_r="no"
6479    ])
6480  fi
6481  #
6482  if test "$tst_compi_strerror_r" = "yes" &&
6483    test "$tst_works_glibc_strerror_r" != "yes"; then
6484    AC_MSG_CHECKING([if strerror_r is POSIX like])
6485    tst_posix_strerror_r_type_arg3="unknown"
6486    for arg3 in 'size_t' 'int' 'unsigned int'; do
6487      if test "$tst_posix_strerror_r_type_arg3" = "unknown"; then
6488        AC_COMPILE_IFELSE([
6489          AC_LANG_PROGRAM([[
6490            $curl_includes_string
6491            int strerror_r(int errnum, char *resultbuf, $arg3 bufsize);
6492          ]],[[
6493            if(0 != strerror_r(0, 0, 0))
6494              return 1;
6495          ]])
6496        ],[
6497          tst_posix_strerror_r_type_arg3="$arg3"
6498        ])
6499      fi
6500    done
6501    case "$tst_posix_strerror_r_type_arg3" in
6502      unknown)
6503        AC_MSG_RESULT([no])
6504        tst_posix_strerror_r="no"
6505        ;;
6506      *)
6507        AC_MSG_RESULT([yes])
6508        tst_posix_strerror_r="yes"
6509        ;;
6510    esac
6511  fi
6512  #
6513  dnl only do runtime verification when not cross-compiling
6514  if test "x$cross_compiling" != "xyes" &&
6515    test "$tst_posix_strerror_r" = "yes"; then
6516    AC_MSG_CHECKING([if strerror_r seems to work])
6517    CURL_RUN_IFELSE([
6518      AC_LANG_PROGRAM([[
6519        $curl_includes_stdlib
6520        $curl_includes_string
6521#       include <errno.h>
6522      ]],[[
6523        char buffer[1024];
6524        int error = 1;
6525        buffer[0] = '\0';
6526        error = strerror_r(EACCES, buffer, sizeof(buffer));
6527        if(error)
6528          exit(1); /* fail */
6529        if(buffer[0] == '\0')
6530          exit(1); /* fail */
6531        else
6532          exit(0);
6533      ]])
6534    ],[
6535      AC_MSG_RESULT([yes])
6536      tst_works_posix_strerror_r="yes"
6537    ],[
6538      AC_MSG_RESULT([no])
6539      tst_works_posix_strerror_r="no"
6540    ])
6541  fi
6542  #
6543  if test "$tst_works_glibc_strerror_r" = "yes"; then
6544    tst_posix_strerror_r="no"
6545  fi
6546  if test "$tst_works_posix_strerror_r" = "yes"; then
6547    tst_glibc_strerror_r="no"
6548  fi
6549  if test "$tst_glibc_strerror_r" = "yes" &&
6550    test "$tst_works_glibc_strerror_r" != "no" &&
6551    test "$tst_posix_strerror_r" != "yes"; then
6552    tst_allow_strerror_r="check"
6553  fi
6554  if test "$tst_posix_strerror_r" = "yes" &&
6555    test "$tst_works_posix_strerror_r" != "no" &&
6556    test "$tst_glibc_strerror_r" != "yes"; then
6557    tst_allow_strerror_r="check"
6558  fi
6559  if test "$tst_allow_strerror_r" = "check"; then
6560    AC_MSG_CHECKING([if strerror_r usage allowed])
6561    if test "x$curl_disallow_strerror_r" != "xyes"; then
6562      AC_MSG_RESULT([yes])
6563      tst_allow_strerror_r="yes"
6564    else
6565      AC_MSG_RESULT([no])
6566      tst_allow_strerror_r="no"
6567    fi
6568  fi
6569  #
6570  AC_MSG_CHECKING([if strerror_r might be used])
6571  if test "$tst_links_strerror_r" = "yes" &&
6572     test "$tst_proto_strerror_r" = "yes" &&
6573     test "$tst_compi_strerror_r" = "yes" &&
6574     test "$tst_allow_strerror_r" = "yes"; then
6575    AC_MSG_RESULT([yes])
6576    if test "$tst_glibc_strerror_r" = "yes"; then
6577      AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
6578        [Define to 1 if you have the strerror_r function.])
6579      AC_DEFINE_UNQUOTED(HAVE_GLIBC_STRERROR_R, 1,
6580        [Define to 1 if you have a working glibc-style strerror_r function.])
6581      AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_glibc_strerror_r_type_arg3,
6582        [Define to the type of arg 3 for strerror_r.])
6583    fi
6584    if test "$tst_posix_strerror_r" = "yes"; then
6585      AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
6586        [Define to 1 if you have the strerror_r function.])
6587      AC_DEFINE_UNQUOTED(HAVE_POSIX_STRERROR_R, 1,
6588        [Define to 1 if you have a working POSIX-style strerror_r function.])
6589      AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_posix_strerror_r_type_arg3,
6590        [Define to the type of arg 3 for strerror_r.])
6591    fi
6592    curl_cv_func_strerror_r="yes"
6593  else
6594    AC_MSG_RESULT([no])
6595    curl_cv_func_strerror_r="no"
6596  fi
6597  #
6598  if test "$tst_compi_strerror_r" = "yes" &&
6599     test "$tst_allow_strerror_r" = "unknown"; then
6600    AC_MSG_WARN([cannot determine strerror_r() style: edit lib/curl_config.h manually.])
6601  fi
6602  #
6603])
6604
6605
6606dnl CURL_CHECK_FUNC_STRICMP
6607dnl -------------------------------------------------
6608dnl Verify if stricmp is available, prototyped, and
6609dnl can be compiled. If all of these are true, and
6610dnl usage has not been previously disallowed with
6611dnl shell variable curl_disallow_stricmp, then
6612dnl HAVE_STRICMP will be defined.
6613
6614AC_DEFUN([CURL_CHECK_FUNC_STRICMP], [
6615  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6616  #
6617  tst_links_stricmp="unknown"
6618  tst_proto_stricmp="unknown"
6619  tst_compi_stricmp="unknown"
6620  tst_allow_stricmp="unknown"
6621  #
6622  AC_MSG_CHECKING([if stricmp can be linked])
6623  AC_LINK_IFELSE([
6624    AC_LANG_FUNC_LINK_TRY([stricmp])
6625  ],[
6626    AC_MSG_RESULT([yes])
6627    tst_links_stricmp="yes"
6628  ],[
6629    AC_MSG_RESULT([no])
6630    tst_links_stricmp="no"
6631  ])
6632  #
6633  if test "$tst_links_stricmp" = "yes"; then
6634    AC_MSG_CHECKING([if stricmp is prototyped])
6635    AC_EGREP_CPP([stricmp],[
6636      $curl_includes_string
6637    ],[
6638      AC_MSG_RESULT([yes])
6639      tst_proto_stricmp="yes"
6640    ],[
6641      AC_MSG_RESULT([no])
6642      tst_proto_stricmp="no"
6643    ])
6644  fi
6645  #
6646  if test "$tst_proto_stricmp" = "yes"; then
6647    AC_MSG_CHECKING([if stricmp is compilable])
6648    AC_COMPILE_IFELSE([
6649      AC_LANG_PROGRAM([[
6650        $curl_includes_string
6651      ]],[[
6652        if(0 != stricmp(0, 0))
6653          return 1;
6654      ]])
6655    ],[
6656      AC_MSG_RESULT([yes])
6657      tst_compi_stricmp="yes"
6658    ],[
6659      AC_MSG_RESULT([no])
6660      tst_compi_stricmp="no"
6661    ])
6662  fi
6663  #
6664  if test "$tst_compi_stricmp" = "yes"; then
6665    AC_MSG_CHECKING([if stricmp usage allowed])
6666    if test "x$curl_disallow_stricmp" != "xyes"; then
6667      AC_MSG_RESULT([yes])
6668      tst_allow_stricmp="yes"
6669    else
6670      AC_MSG_RESULT([no])
6671      tst_allow_stricmp="no"
6672    fi
6673  fi
6674  #
6675  AC_MSG_CHECKING([if stricmp might be used])
6676  if test "$tst_links_stricmp" = "yes" &&
6677     test "$tst_proto_stricmp" = "yes" &&
6678     test "$tst_compi_stricmp" = "yes" &&
6679     test "$tst_allow_stricmp" = "yes"; then
6680    AC_MSG_RESULT([yes])
6681    AC_DEFINE_UNQUOTED(HAVE_STRICMP, 1,
6682      [Define to 1 if you have the stricmp function.])
6683    curl_cv_func_stricmp="yes"
6684  else
6685    AC_MSG_RESULT([no])
6686    curl_cv_func_stricmp="no"
6687  fi
6688])
6689
6690dnl CURL_CHECK_FUNC_STRNCASECMP
6691dnl -------------------------------------------------
6692dnl Verify if strncasecmp is available, prototyped, and
6693dnl can be compiled. If all of these are true, and
6694dnl usage has not been previously disallowed with
6695dnl shell variable curl_disallow_strncasecmp, then
6696dnl HAVE_STRNCASECMP will be defined.
6697
6698AC_DEFUN([CURL_CHECK_FUNC_STRNCASECMP], [
6699  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6700  #
6701  tst_links_strncasecmp="unknown"
6702  tst_proto_strncasecmp="unknown"
6703  tst_compi_strncasecmp="unknown"
6704  tst_allow_strncasecmp="unknown"
6705  #
6706  AC_MSG_CHECKING([if strncasecmp can be linked])
6707  AC_LINK_IFELSE([
6708    AC_LANG_FUNC_LINK_TRY([strncasecmp])
6709  ],[
6710    AC_MSG_RESULT([yes])
6711    tst_links_strncasecmp="yes"
6712  ],[
6713    AC_MSG_RESULT([no])
6714    tst_links_strncasecmp="no"
6715  ])
6716  #
6717  if test "$tst_links_strncasecmp" = "yes"; then
6718    AC_MSG_CHECKING([if strncasecmp is prototyped])
6719    AC_EGREP_CPP([strncasecmp],[
6720      $curl_includes_string
6721    ],[
6722      AC_MSG_RESULT([yes])
6723      tst_proto_strncasecmp="yes"
6724    ],[
6725      AC_MSG_RESULT([no])
6726      tst_proto_strncasecmp="no"
6727    ])
6728  fi
6729  #
6730  if test "$tst_proto_strncasecmp" = "yes"; then
6731    AC_MSG_CHECKING([if strncasecmp is compilable])
6732    AC_COMPILE_IFELSE([
6733      AC_LANG_PROGRAM([[
6734        $curl_includes_string
6735      ]],[[
6736        if(0 != strncasecmp(0, 0, 0))
6737          return 1;
6738      ]])
6739    ],[
6740      AC_MSG_RESULT([yes])
6741      tst_compi_strncasecmp="yes"
6742    ],[
6743      AC_MSG_RESULT([no])
6744      tst_compi_strncasecmp="no"
6745    ])
6746  fi
6747  #
6748  if test "$tst_compi_strncasecmp" = "yes"; then
6749    AC_MSG_CHECKING([if strncasecmp usage allowed])
6750    if test "x$curl_disallow_strncasecmp" != "xyes"; then
6751      AC_MSG_RESULT([yes])
6752      tst_allow_strncasecmp="yes"
6753    else
6754      AC_MSG_RESULT([no])
6755      tst_allow_strncasecmp="no"
6756    fi
6757  fi
6758  #
6759  AC_MSG_CHECKING([if strncasecmp might be used])
6760  if test "$tst_links_strncasecmp" = "yes" &&
6761     test "$tst_proto_strncasecmp" = "yes" &&
6762     test "$tst_compi_strncasecmp" = "yes" &&
6763     test "$tst_allow_strncasecmp" = "yes"; then
6764    AC_MSG_RESULT([yes])
6765    AC_DEFINE_UNQUOTED(HAVE_STRNCASECMP, 1,
6766      [Define to 1 if you have the strncasecmp function.])
6767    curl_cv_func_strncasecmp="yes"
6768  else
6769    AC_MSG_RESULT([no])
6770    curl_cv_func_strncasecmp="no"
6771  fi
6772])
6773
6774
6775dnl CURL_CHECK_FUNC_STRNCMPI
6776dnl -------------------------------------------------
6777dnl Verify if strncmpi is available, prototyped, and
6778dnl can be compiled. If all of these are true, and
6779dnl usage has not been previously disallowed with
6780dnl shell variable curl_disallow_strncmpi, then
6781dnl HAVE_STRNCMPI will be defined.
6782
6783AC_DEFUN([CURL_CHECK_FUNC_STRNCMPI], [
6784  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6785  #
6786  tst_links_strncmpi="unknown"
6787  tst_proto_strncmpi="unknown"
6788  tst_compi_strncmpi="unknown"
6789  tst_allow_strncmpi="unknown"
6790  #
6791  AC_MSG_CHECKING([if strncmpi can be linked])
6792  AC_LINK_IFELSE([
6793    AC_LANG_FUNC_LINK_TRY([strncmpi])
6794  ],[
6795    AC_MSG_RESULT([yes])
6796    tst_links_strncmpi="yes"
6797  ],[
6798    AC_MSG_RESULT([no])
6799    tst_links_strncmpi="no"
6800  ])
6801  #
6802  if test "$tst_links_strncmpi" = "yes"; then
6803    AC_MSG_CHECKING([if strncmpi is prototyped])
6804    AC_EGREP_CPP([strncmpi],[
6805      $curl_includes_string
6806    ],[
6807      AC_MSG_RESULT([yes])
6808      tst_proto_strncmpi="yes"
6809    ],[
6810      AC_MSG_RESULT([no])
6811      tst_proto_strncmpi="no"
6812    ])
6813  fi
6814  #
6815  if test "$tst_proto_strncmpi" = "yes"; then
6816    AC_MSG_CHECKING([if strncmpi is compilable])
6817    AC_COMPILE_IFELSE([
6818      AC_LANG_PROGRAM([[
6819        $curl_includes_string
6820      ]],[[
6821        if(0 != strncmpi(0, 0))
6822          return 1;
6823      ]])
6824    ],[
6825      AC_MSG_RESULT([yes])
6826      tst_compi_strncmpi="yes"
6827    ],[
6828      AC_MSG_RESULT([no])
6829      tst_compi_strncmpi="no"
6830    ])
6831  fi
6832  #
6833  if test "$tst_compi_strncmpi" = "yes"; then
6834    AC_MSG_CHECKING([if strncmpi usage allowed])
6835    if test "x$curl_disallow_strncmpi" != "xyes"; then
6836      AC_MSG_RESULT([yes])
6837      tst_allow_strncmpi="yes"
6838    else
6839      AC_MSG_RESULT([no])
6840      tst_allow_strncmpi="no"
6841    fi
6842  fi
6843  #
6844  AC_MSG_CHECKING([if strncmpi might be used])
6845  if test "$tst_links_strncmpi" = "yes" &&
6846     test "$tst_proto_strncmpi" = "yes" &&
6847     test "$tst_compi_strncmpi" = "yes" &&
6848     test "$tst_allow_strncmpi" = "yes"; then
6849    AC_MSG_RESULT([yes])
6850    AC_DEFINE_UNQUOTED(HAVE_STRNCMPI, 1,
6851      [Define to 1 if you have the strncmpi function.])
6852    curl_cv_func_strncmpi="yes"
6853  else
6854    AC_MSG_RESULT([no])
6855    curl_cv_func_strncmpi="no"
6856  fi
6857])
6858
6859
6860dnl CURL_CHECK_FUNC_STRNICMP
6861dnl -------------------------------------------------
6862dnl Verify if strnicmp is available, prototyped, and
6863dnl can be compiled. If all of these are true, and
6864dnl usage has not been previously disallowed with
6865dnl shell variable curl_disallow_strnicmp, then
6866dnl HAVE_STRNICMP will be defined.
6867
6868AC_DEFUN([CURL_CHECK_FUNC_STRNICMP], [
6869  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6870  #
6871  tst_links_strnicmp="unknown"
6872  tst_proto_strnicmp="unknown"
6873  tst_compi_strnicmp="unknown"
6874  tst_allow_strnicmp="unknown"
6875  #
6876  AC_MSG_CHECKING([if strnicmp can be linked])
6877  AC_LINK_IFELSE([
6878    AC_LANG_FUNC_LINK_TRY([strnicmp])
6879  ],[
6880    AC_MSG_RESULT([yes])
6881    tst_links_strnicmp="yes"
6882  ],[
6883    AC_MSG_RESULT([no])
6884    tst_links_strnicmp="no"
6885  ])
6886  #
6887  if test "$tst_links_strnicmp" = "yes"; then
6888    AC_MSG_CHECKING([if strnicmp is prototyped])
6889    AC_EGREP_CPP([strnicmp],[
6890      $curl_includes_string
6891    ],[
6892      AC_MSG_RESULT([yes])
6893      tst_proto_strnicmp="yes"
6894    ],[
6895      AC_MSG_RESULT([no])
6896      tst_proto_strnicmp="no"
6897    ])
6898  fi
6899  #
6900  if test "$tst_proto_strnicmp" = "yes"; then
6901    AC_MSG_CHECKING([if strnicmp is compilable])
6902    AC_COMPILE_IFELSE([
6903      AC_LANG_PROGRAM([[
6904        $curl_includes_string
6905      ]],[[
6906        if(0 != strnicmp(0, 0))
6907          return 1;
6908      ]])
6909    ],[
6910      AC_MSG_RESULT([yes])
6911      tst_compi_strnicmp="yes"
6912    ],[
6913      AC_MSG_RESULT([no])
6914      tst_compi_strnicmp="no"
6915    ])
6916  fi
6917  #
6918  if test "$tst_compi_strnicmp" = "yes"; then
6919    AC_MSG_CHECKING([if strnicmp usage allowed])
6920    if test "x$curl_disallow_strnicmp" != "xyes"; then
6921      AC_MSG_RESULT([yes])
6922      tst_allow_strnicmp="yes"
6923    else
6924      AC_MSG_RESULT([no])
6925      tst_allow_strnicmp="no"
6926    fi
6927  fi
6928  #
6929  AC_MSG_CHECKING([if strnicmp might be used])
6930  if test "$tst_links_strnicmp" = "yes" &&
6931     test "$tst_proto_strnicmp" = "yes" &&
6932     test "$tst_compi_strnicmp" = "yes" &&
6933     test "$tst_allow_strnicmp" = "yes"; then
6934    AC_MSG_RESULT([yes])
6935    AC_DEFINE_UNQUOTED(HAVE_STRNICMP, 1,
6936      [Define to 1 if you have the strnicmp function.])
6937    curl_cv_func_strnicmp="yes"
6938  else
6939    AC_MSG_RESULT([no])
6940    curl_cv_func_strnicmp="no"
6941  fi
6942])
6943
6944
6945dnl CURL_CHECK_FUNC_STRSTR
6946dnl -------------------------------------------------
6947dnl Verify if strstr is available, prototyped, and
6948dnl can be compiled. If all of these are true, and
6949dnl usage has not been previously disallowed with
6950dnl shell variable curl_disallow_strstr, then
6951dnl HAVE_STRSTR will be defined.
6952
6953AC_DEFUN([CURL_CHECK_FUNC_STRSTR], [
6954  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6955  #
6956  tst_links_strstr="unknown"
6957  tst_proto_strstr="unknown"
6958  tst_compi_strstr="unknown"
6959  tst_allow_strstr="unknown"
6960  #
6961  AC_MSG_CHECKING([if strstr can be linked])
6962  AC_LINK_IFELSE([
6963    AC_LANG_FUNC_LINK_TRY([strstr])
6964  ],[
6965    AC_MSG_RESULT([yes])
6966    tst_links_strstr="yes"
6967  ],[
6968    AC_MSG_RESULT([no])
6969    tst_links_strstr="no"
6970  ])
6971  #
6972  if test "$tst_links_strstr" = "yes"; then
6973    AC_MSG_CHECKING([if strstr is prototyped])
6974    AC_EGREP_CPP([strstr],[
6975      $curl_includes_string
6976    ],[
6977      AC_MSG_RESULT([yes])
6978      tst_proto_strstr="yes"
6979    ],[
6980      AC_MSG_RESULT([no])
6981      tst_proto_strstr="no"
6982    ])
6983  fi
6984  #
6985  if test "$tst_proto_strstr" = "yes"; then
6986    AC_MSG_CHECKING([if strstr is compilable])
6987    AC_COMPILE_IFELSE([
6988      AC_LANG_PROGRAM([[
6989        $curl_includes_string
6990      ]],[[
6991        if(0 != strstr(0, 0))
6992          return 1;
6993      ]])
6994    ],[
6995      AC_MSG_RESULT([yes])
6996      tst_compi_strstr="yes"
6997    ],[
6998      AC_MSG_RESULT([no])
6999      tst_compi_strstr="no"
7000    ])
7001  fi
7002  #
7003  if test "$tst_compi_strstr" = "yes"; then
7004    AC_MSG_CHECKING([if strstr usage allowed])
7005    if test "x$curl_disallow_strstr" != "xyes"; then
7006      AC_MSG_RESULT([yes])
7007      tst_allow_strstr="yes"
7008    else
7009      AC_MSG_RESULT([no])
7010      tst_allow_strstr="no"
7011    fi
7012  fi
7013  #
7014  AC_MSG_CHECKING([if strstr might be used])
7015  if test "$tst_links_strstr" = "yes" &&
7016     test "$tst_proto_strstr" = "yes" &&
7017     test "$tst_compi_strstr" = "yes" &&
7018     test "$tst_allow_strstr" = "yes"; then
7019    AC_MSG_RESULT([yes])
7020    AC_DEFINE_UNQUOTED(HAVE_STRSTR, 1,
7021      [Define to 1 if you have the strstr function.])
7022    curl_cv_func_strstr="yes"
7023  else
7024    AC_MSG_RESULT([no])
7025    curl_cv_func_strstr="no"
7026  fi
7027])
7028
7029
7030dnl CURL_CHECK_FUNC_STRTOK_R
7031dnl -------------------------------------------------
7032dnl Verify if strtok_r is available, prototyped, and
7033dnl can be compiled. If all of these are true, and
7034dnl usage has not been previously disallowed with
7035dnl shell variable curl_disallow_strtok_r, then
7036dnl HAVE_STRTOK_R will be defined.
7037
7038AC_DEFUN([CURL_CHECK_FUNC_STRTOK_R], [
7039  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
7040  #
7041  tst_links_strtok_r="unknown"
7042  tst_proto_strtok_r="unknown"
7043  tst_compi_strtok_r="unknown"
7044  tst_allow_strtok_r="unknown"
7045  #
7046  AC_MSG_CHECKING([if strtok_r can be linked])
7047  AC_LINK_IFELSE([
7048    AC_LANG_FUNC_LINK_TRY([strtok_r])
7049  ],[
7050    AC_MSG_RESULT([yes])
7051    tst_links_strtok_r="yes"
7052  ],[
7053    AC_MSG_RESULT([no])
7054    tst_links_strtok_r="no"
7055  ])
7056  #
7057  if test "$tst_links_strtok_r" = "yes"; then
7058    AC_MSG_CHECKING([if strtok_r is prototyped])
7059    AC_EGREP_CPP([strtok_r],[
7060      $curl_includes_string
7061    ],[
7062      AC_MSG_RESULT([yes])
7063      tst_proto_strtok_r="yes"
7064    ],[
7065      AC_MSG_RESULT([no])
7066      tst_proto_strtok_r="no"
7067    ])
7068  fi
7069  #
7070  if test "$tst_proto_strtok_r" = "yes"; then
7071    AC_MSG_CHECKING([if strtok_r is compilable])
7072    AC_COMPILE_IFELSE([
7073      AC_LANG_PROGRAM([[
7074        $curl_includes_string
7075      ]],[[
7076        if(0 != strtok_r(0, 0, 0))
7077          return 1;
7078      ]])
7079    ],[
7080      AC_MSG_RESULT([yes])
7081      tst_compi_strtok_r="yes"
7082    ],[
7083      AC_MSG_RESULT([no])
7084      tst_compi_strtok_r="no"
7085    ])
7086  fi
7087  #
7088  if test "$tst_compi_strtok_r" = "yes"; then
7089    AC_MSG_CHECKING([if strtok_r usage allowed])
7090    if test "x$curl_disallow_strtok_r" != "xyes"; then
7091      AC_MSG_RESULT([yes])
7092      tst_allow_strtok_r="yes"
7093    else
7094      AC_MSG_RESULT([no])
7095      tst_allow_strtok_r="no"
7096    fi
7097  fi
7098  #
7099  AC_MSG_CHECKING([if strtok_r might be used])
7100  if test "$tst_links_strtok_r" = "yes" &&
7101     test "$tst_proto_strtok_r" = "yes" &&
7102     test "$tst_compi_strtok_r" = "yes" &&
7103     test "$tst_allow_strtok_r" = "yes"; then
7104    AC_MSG_RESULT([yes])
7105    AC_DEFINE_UNQUOTED(HAVE_STRTOK_R, 1,
7106      [Define to 1 if you have the strtok_r function.])
7107    curl_cv_func_strtok_r="yes"
7108  else
7109    AC_MSG_RESULT([no])
7110    curl_cv_func_strtok_r="no"
7111  fi
7112])
7113
7114
7115dnl CURL_CHECK_FUNC_STRTOLL
7116dnl -------------------------------------------------
7117dnl Verify if strtoll is available, prototyped, and
7118dnl can be compiled. If all of these are true, and
7119dnl usage has not been previously disallowed with
7120dnl shell variable curl_disallow_strtoll, then
7121dnl HAVE_STRTOLL will be defined.
7122
7123AC_DEFUN([CURL_CHECK_FUNC_STRTOLL], [
7124  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
7125  #
7126  tst_links_strtoll="unknown"
7127  tst_proto_strtoll="unknown"
7128  tst_compi_strtoll="unknown"
7129  tst_allow_strtoll="unknown"
7130  #
7131  AC_MSG_CHECKING([if strtoll can be linked])
7132  AC_LINK_IFELSE([
7133    AC_LANG_FUNC_LINK_TRY([strtoll])
7134  ],[
7135    AC_MSG_RESULT([yes])
7136    tst_links_strtoll="yes"
7137  ],[
7138    AC_MSG_RESULT([no])
7139    tst_links_strtoll="no"
7140  ])
7141  #
7142  if test "$tst_links_strtoll" = "yes"; then
7143    AC_MSG_CHECKING([if strtoll is prototyped])
7144    AC_EGREP_CPP([strtoll],[
7145      $curl_includes_stdlib
7146    ],[
7147      AC_MSG_RESULT([yes])
7148      tst_proto_strtoll="yes"
7149    ],[
7150      AC_MSG_RESULT([no])
7151      tst_proto_strtoll="no"
7152    ])
7153  fi
7154  #
7155  if test "$tst_proto_strtoll" = "yes"; then
7156    AC_MSG_CHECKING([if strtoll is compilable])
7157    AC_COMPILE_IFELSE([
7158      AC_LANG_PROGRAM([[
7159        $curl_includes_stdlib
7160      ]],[[
7161        if(0 != strtoll(0, 0, 0))
7162          return 1;
7163      ]])
7164    ],[
7165      AC_MSG_RESULT([yes])
7166      tst_compi_strtoll="yes"
7167    ],[
7168      AC_MSG_RESULT([no])
7169      tst_compi_strtoll="no"
7170    ])
7171  fi
7172  #
7173  if test "$tst_compi_strtoll" = "yes"; then
7174    AC_MSG_CHECKING([if strtoll usage allowed])
7175    if test "x$curl_disallow_strtoll" != "xyes"; then
7176      AC_MSG_RESULT([yes])
7177      tst_allow_strtoll="yes"
7178    else
7179      AC_MSG_RESULT([no])
7180      tst_allow_strtoll="no"
7181    fi
7182  fi
7183  #
7184  AC_MSG_CHECKING([if strtoll might be used])
7185  if test "$tst_links_strtoll" = "yes" &&
7186     test "$tst_proto_strtoll" = "yes" &&
7187     test "$tst_compi_strtoll" = "yes" &&
7188     test "$tst_allow_strtoll" = "yes"; then
7189    AC_MSG_RESULT([yes])
7190    AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
7191      [Define to 1 if you have the strtoll function.])
7192    curl_cv_func_strtoll="yes"
7193  else
7194    AC_MSG_RESULT([no])
7195    curl_cv_func_strtoll="no"
7196  fi
7197])
7198
7199
7200dnl CURL_CHECK_FUNC_WRITEV
7201dnl -------------------------------------------------
7202dnl Verify if writev is available, prototyped, and
7203dnl can be compiled. If all of these are true, and
7204dnl usage has not been previously disallowed with
7205dnl shell variable curl_disallow_writev, then
7206dnl HAVE_WRITEV will be defined.
7207
7208AC_DEFUN([CURL_CHECK_FUNC_WRITEV], [
7209  AC_REQUIRE([CURL_INCLUDES_SYS_UIO])dnl
7210  #
7211  tst_links_writev="unknown"
7212  tst_proto_writev="unknown"
7213  tst_compi_writev="unknown"
7214  tst_allow_writev="unknown"
7215  #
7216  AC_MSG_CHECKING([if writev can be linked])
7217  AC_LINK_IFELSE([
7218    AC_LANG_FUNC_LINK_TRY([writev])
7219  ],[
7220    AC_MSG_RESULT([yes])
7221    tst_links_writev="yes"
7222  ],[
7223    AC_MSG_RESULT([no])
7224    tst_links_writev="no"
7225  ])
7226  #
7227  if test "$tst_links_writev" = "yes"; then
7228    AC_MSG_CHECKING([if writev is prototyped])
7229    AC_EGREP_CPP([writev],[
7230      $curl_includes_sys_uio
7231    ],[
7232      AC_MSG_RESULT([yes])
7233      tst_proto_writev="yes"
7234    ],[
7235      AC_MSG_RESULT([no])
7236      tst_proto_writev="no"
7237    ])
7238  fi
7239  #
7240  if test "$tst_proto_writev" = "yes"; then
7241    AC_MSG_CHECKING([if writev is compilable])
7242    AC_COMPILE_IFELSE([
7243      AC_LANG_PROGRAM([[
7244        $curl_includes_sys_uio
7245      ]],[[
7246        if(0 != writev(0, 0, 0))
7247          return 1;
7248      ]])
7249    ],[
7250      AC_MSG_RESULT([yes])
7251      tst_compi_writev="yes"
7252    ],[
7253      AC_MSG_RESULT([no])
7254      tst_compi_writev="no"
7255    ])
7256  fi
7257  #
7258  if test "$tst_compi_writev" = "yes"; then
7259    AC_MSG_CHECKING([if writev usage allowed])
7260    if test "x$curl_disallow_writev" != "xyes"; then
7261      AC_MSG_RESULT([yes])
7262      tst_allow_writev="yes"
7263    else
7264      AC_MSG_RESULT([no])
7265      tst_allow_writev="no"
7266    fi
7267  fi
7268  #
7269  AC_MSG_CHECKING([if writev might be used])
7270  if test "$tst_links_writev" = "yes" &&
7271     test "$tst_proto_writev" = "yes" &&
7272     test "$tst_compi_writev" = "yes" &&
7273     test "$tst_allow_writev" = "yes"; then
7274    AC_MSG_RESULT([yes])
7275    AC_DEFINE_UNQUOTED(HAVE_WRITEV, 1,
7276      [Define to 1 if you have the writev function.])
7277    curl_cv_func_writev="yes"
7278  else
7279    AC_MSG_RESULT([no])
7280    curl_cv_func_writev="no"
7281  fi
7282])
7283
7284dnl CURL_RUN_IFELSE
7285dnl -------------------------------------------------
7286dnl Wrapper macro to use instead of AC_RUN_IFELSE. It
7287dnl sets LD_LIBRARY_PATH locally for this run only, from the
7288dnl CURL_LIBRARY_PATH variable. It keeps the LD_LIBRARY_PATH
7289dnl changes contained within this macro.
7290
7291AC_DEFUN([CURL_RUN_IFELSE], [
7292   old=$LD_LIBRARY_PATH
7293   LD_LIBRARY_PATH=$CURL_LIBRARY_PATH:$old
7294   export LD_LIBRARY_PATH
7295   AC_RUN_IFELSE([AC_LANG_SOURCE([$1])], $2, $3, $4)
7296   LD_LIBRARY_PATH=$old # restore
7297])
7298
7299dnl CURL_COVERAGE
7300dnl --------------------------------------------------
7301dnl Switch on options and libs to build with gcc's code coverage.
7302dnl
7303
7304AC_DEFUN([CURL_COVERAGE],[
7305  AC_REQUIRE([AC_PROG_SED])
7306  AC_REQUIRE([AC_ARG_ENABLE])
7307  AC_MSG_CHECKING([for code coverage support])
7308  coverage="no"
7309  curl_coverage_msg="disabled"
7310
7311  dnl check if enabled by argument
7312  AC_ARG_ENABLE(code-coverage,
7313     AC_HELP_STRING([--enable-code-coverage], [Provide code coverage]),
7314     coverage="$enableval")
7315
7316  dnl if not gcc switch off again
7317  AS_IF([ test "$GCC" != "yes" ], coverage="no" )
7318  AC_MSG_RESULT($coverage)
7319
7320  if test "x$coverage" = "xyes"; then
7321    curl_coverage_msg="enabled"
7322
7323    AC_CHECK_TOOL([GCOV], [gcov], [gcov])
7324    if test -z "$GCOV"; then
7325      AC_MSG_ERROR([needs gcov for code coverage])
7326    fi
7327    AC_CHECK_PROG([LCOV], [lcov], [lcov])
7328    if test -z "$LCOV"; then
7329      AC_MSG_ERROR([needs lcov for code coverage])
7330    fi
7331
7332    CPPFLAGS="$CPPFLAGS -DNDEBUG"
7333    CFLAGS="$CLAGS -O0 -g -fprofile-arcs -ftest-coverage"
7334    LIBS="$LIBS -lgcov"
7335  fi
7336])
7337