Newer
Older
#***************************************************************************
# $Id$
#
# Copyright (C) 2008 - 2009 by Daniel Stenberg et al
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
#***************************************************************************
# File version for 'aclocal' use. Keep it a single number.
dnl CARES_INCLUDES_ARPA_INET
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when arpa/inet.h is to be included.
AC_DEFUN([CARES_INCLUDES_ARPA_INET], [
cares_includes_arpa_inet="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h sys/socket.h netinet/in.h arpa/inet.h,
[], [], [$cares_includes_arpa_inet])
])
dnl CARES_INCLUDES_FCNTL
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when fcntl.h is to be included.
AC_DEFUN([CARES_INCLUDES_FCNTL], [
cares_includes_fcntl="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
# include <fcntl.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h unistd.h fcntl.h,
[], [], [$cares_includes_fcntl])
])
dnl CARES_INCLUDES_NETDB
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when netdb.h is to be included.
AC_DEFUN([CARES_INCLUDES_NETDB], [
cares_includes_netdb="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h netdb.h,
[], [], [$cares_includes_netdb])
])
dnl CARES_INCLUDES_SOCKET
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when socket.h is to be included.
AC_DEFUN([CARES_INCLUDES_SOCKET], [
cares_includes_socket="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SOCKET_H
# include <socket.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h socket.h,
[], [], [$cares_includes_socket])
])
dnl CARES_INCLUDES_STDLIB
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when stdlib.h is to be included.
AC_DEFUN([CARES_INCLUDES_STDLIB], [
cares_includes_stdlib="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h stdlib.h,
[], [], [$cares_includes_stdlib])
])
dnl CARES_INCLUDES_STRING
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
AC_DEFUN([CARES_INCLUDES_STRING], [
cares_includes_string="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
[], [], [$cares_includes_string])
])
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
dnl CARES_INCLUDES_STROPTS
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when stropts.h is to be included.
AC_DEFUN([CARES_INCLUDES_STROPTS], [
cares_includes_stropts="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_STROPTS_H
# include <stropts.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h,
[], [], [$cares_includes_stropts])
])
dnl CARES_INCLUDES_SYS_SOCKET
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when sys/socket.h is to be included.
AC_DEFUN([CARES_INCLUDES_SYS_SOCKET], [
cares_includes_sys_socket="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h sys/socket.h,
[], [], [$cares_includes_sys_socket])
])
dnl CARES_INCLUDES_SYS_TYPES
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when sys/types.h is to be included.
AC_DEFUN([CARES_INCLUDES_SYS_TYPES], [
cares_includes_sys_types="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h,
[], [], [$cares_includes_sys_types])
])
dnl CARES_INCLUDES_SYS_UIO
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when sys/uio.h is to be included.
AC_DEFUN([CARES_INCLUDES_SYS_UIO], [
cares_includes_sys_uio="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h sys/uio.h,
[], [], [$cares_includes_sys_uio])
])
dnl CARES_INCLUDES_UNISTD
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when unistd.h is to be included.
AC_DEFUN([CARES_INCLUDES_UNISTD], [
cares_includes_unistd="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h unistd.h,
[], [], [$cares_includes_unistd])
])
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
dnl CARES_INCLUDES_WINSOCK2
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when winsock(2).h is to be included.
AC_DEFUN([CARES_INCLUDES_WINSOCK2], [
cares_includes_winsock2="\
/* includes start */
#ifdef HAVE_WINDOWS_H
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
# else
# ifdef HAVE_WINSOCK_H
# include <winsock.h>
# endif
# endif
#endif
/* includes end */"
CURL_CHECK_HEADER_WINDOWS
CURL_CHECK_HEADER_WINSOCK
CURL_CHECK_HEADER_WINSOCK2
])
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
dnl CARES_INCLUDES_WS2TCPIP
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when ws2tcpip.h is to be included.
AC_DEFUN([CARES_INCLUDES_WS2TCPIP], [
cares_includes_ws2tcpip="\
/* includes start */
#ifdef HAVE_WINDOWS_H
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
# ifdef HAVE_WS2TCPIP_H
# include <ws2tcpip.h>
# endif
# endif
#endif
/* includes end */"
CURL_CHECK_HEADER_WINDOWS
CURL_CHECK_HEADER_WINSOCK2
CURL_CHECK_HEADER_WS2TCPIP
])
dnl CARES_PREPROCESS_CALLCONV
dnl -------------------------------------------------
dnl Set up variable with a preprocessor block which
dnl defines function calling convention.
AC_DEFUN([CARES_PREPROCESS_CALLCONV], [
cares_preprocess_callconv="\
/* preprocess start */
#ifdef HAVE_WINDOWS_H
# define FUNCALLCONV __stdcall
#else
# define FUNCALLCONV
#endif
/* preprocess end */"
])
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
dnl CARES_CHECK_FUNC_CLOSESOCKET
dnl -------------------------------------------------
dnl Verify if closesocket is available, prototyped, and
dnl can be compiled. If all of these are true, and
dnl usage has not been previously disallowed with
dnl shell variable cares_disallow_closesocket, then
dnl HAVE_CLOSESOCKET will be defined.
AC_DEFUN([CARES_CHECK_FUNC_CLOSESOCKET], [
AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
AC_REQUIRE([CARES_INCLUDES_SOCKET])dnl
#
tst_links_closesocket="unknown"
tst_proto_closesocket="unknown"
tst_compi_closesocket="unknown"
tst_allow_closesocket="unknown"
#
AC_MSG_CHECKING([if closesocket can be linked])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_winsock2
$cares_includes_socket
]],[[
if(0 != closesocket(0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_links_closesocket="yes"
],[
AC_MSG_RESULT([no])
tst_links_closesocket="no"
])
#
if test "$tst_links_closesocket" = "yes"; then
AC_MSG_CHECKING([if closesocket is prototyped])
AC_EGREP_CPP([closesocket],[
$cares_includes_winsock2
$cares_includes_socket
],[
AC_MSG_RESULT([yes])
tst_proto_closesocket="yes"
],[
AC_MSG_RESULT([no])
tst_proto_closesocket="no"
])
fi
#
if test "$tst_proto_closesocket" = "yes"; then
AC_MSG_CHECKING([if closesocket is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_winsock2
$cares_includes_socket
]],[[
if(0 != closesocket(0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_closesocket="yes"
],[
AC_MSG_RESULT([no])
tst_compi_closesocket="no"
])
fi
#
if test "$tst_compi_closesocket" = "yes"; then
AC_MSG_CHECKING([if closesocket usage allowed])
if test "x$cares_disallow_closesocket" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_closesocket="yes"
else
AC_MSG_RESULT([no])
tst_allow_closesocket="no"
fi
fi
#
AC_MSG_CHECKING([if closesocket might be used])
if test "$tst_links_closesocket" = "yes" &&
test "$tst_proto_closesocket" = "yes" &&
test "$tst_compi_closesocket" = "yes" &&
test "$tst_allow_closesocket" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET, 1,
[Define to 1 if you have the closesocket function.])
ac_cv_func_closesocket="yes"
else
AC_MSG_RESULT([no])
ac_cv_func_closesocket="no"
fi
])
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
dnl CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
dnl -------------------------------------------------
dnl Verify if CloseSocket is available, prototyped, and
dnl can be compiled. If all of these are true, and
dnl usage has not been previously disallowed with
dnl shell variable cares_disallow_closesocket_camel,
dnl then HAVE_CLOSESOCKET_CAMEL will be defined.
AC_DEFUN([CARES_CHECK_FUNC_CLOSESOCKET_CAMEL], [
AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
#
tst_links_closesocket_camel="unknown"
tst_proto_closesocket_camel="unknown"
tst_compi_closesocket_camel="unknown"
tst_allow_closesocket_camel="unknown"
#
AC_MSG_CHECKING([if CloseSocket can be linked])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_sys_socket
]],[[
if(0 != CloseSocket(0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_links_closesocket_camel="yes"
],[
AC_MSG_RESULT([no])
tst_links_closesocket_camel="no"
])
#
if test "$tst_links_closesocket_camel" = "yes"; then
AC_MSG_CHECKING([if CloseSocket is prototyped])
AC_EGREP_CPP([CloseSocket],[
$cares_includes_sys_socket
],[
AC_MSG_RESULT([yes])
tst_proto_closesocket_camel="yes"
],[
AC_MSG_RESULT([no])
tst_proto_closesocket_camel="no"
])
fi
#
if test "$tst_proto_closesocket_camel" = "yes"; then
AC_MSG_CHECKING([if CloseSocket is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_sys_socket
]],[[
if(0 != CloseSocket(0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_closesocket_camel="yes"
],[
AC_MSG_RESULT([no])
tst_compi_closesocket_camel="no"
])
fi
#
if test "$tst_compi_closesocket_camel" = "yes"; then
AC_MSG_CHECKING([if CloseSocket usage allowed])
if test "x$cares_disallow_closesocket_camel" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_closesocket_camel="yes"
else
AC_MSG_RESULT([no])
tst_allow_closesocket_camel="no"
fi
fi
#
AC_MSG_CHECKING([if CloseSocket might be used])
if test "$tst_links_closesocket_camel" = "yes" &&
test "$tst_proto_closesocket_camel" = "yes" &&
test "$tst_compi_closesocket_camel" = "yes" &&
test "$tst_allow_closesocket_camel" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET_CAMEL, 1,
[Define to 1 if you have the CloseSocket camel case function.])
ac_cv_func_closesocket_camel="yes"
else
AC_MSG_RESULT([no])
ac_cv_func_closesocket_camel="no"
fi
])
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
dnl CARES_CHECK_FUNC_CONNECT
dnl -------------------------------------------------
dnl Verify if connect is available, prototyped, and
dnl can be compiled. If all of these are true, and
dnl usage has not been previously disallowed with
dnl shell variable cares_disallow_connect, then
dnl HAVE_CONNECT will be defined.
AC_DEFUN([CARES_CHECK_FUNC_CONNECT], [
AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
AC_REQUIRE([CARES_INCLUDES_SOCKET])dnl
#
tst_links_connect="unknown"
tst_proto_connect="unknown"
tst_compi_connect="unknown"
tst_allow_connect="unknown"
#
AC_MSG_CHECKING([if connect can be linked])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_winsock2
$cares_includes_sys_socket
$cares_includes_socket
]],[[
if(0 != connect(0, 0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_links_connect="yes"
],[
AC_MSG_RESULT([no])
tst_links_connect="no"
])
#
if test "$tst_links_connect" = "yes"; then
AC_MSG_CHECKING([if connect is prototyped])
AC_EGREP_CPP([connect],[
$cares_includes_winsock2
$cares_includes_sys_socket
$cares_includes_socket
],[
AC_MSG_RESULT([yes])
tst_proto_connect="yes"
],[
AC_MSG_RESULT([no])
tst_proto_connect="no"
])
fi
#
if test "$tst_proto_connect" = "yes"; then
AC_MSG_CHECKING([if connect is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_winsock2
$cares_includes_sys_socket
$cares_includes_socket
]],[[
if(0 != connect(0, 0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_connect="yes"
],[
AC_MSG_RESULT([no])
tst_compi_connect="no"
])
fi
#
if test "$tst_compi_connect" = "yes"; then
AC_MSG_CHECKING([if connect usage allowed])
if test "x$cares_disallow_connect" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_connect="yes"
else
AC_MSG_RESULT([no])
tst_allow_connect="no"
fi
fi
#
AC_MSG_CHECKING([if connect might be used])
if test "$tst_links_connect" = "yes" &&
test "$tst_proto_connect" = "yes" &&
test "$tst_compi_connect" = "yes" &&
test "$tst_allow_connect" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_CONNECT, 1,
[Define to 1 if you have the connect function.])
ac_cv_func_connect="yes"
else
AC_MSG_RESULT([no])
ac_cv_func_connect="no"
fi
])
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
dnl CARES_CHECK_FUNC_FCNTL
dnl -------------------------------------------------
dnl Verify if fcntl is available, prototyped, and
dnl can be compiled. If all of these are true, and
dnl usage has not been previously disallowed with
dnl shell variable cares_disallow_fcntl, then
dnl HAVE_FCNTL will be defined.
AC_DEFUN([CARES_CHECK_FUNC_FCNTL], [
AC_REQUIRE([CARES_INCLUDES_FCNTL])dnl
#
tst_links_fcntl="unknown"
tst_proto_fcntl="unknown"
tst_compi_fcntl="unknown"
tst_allow_fcntl="unknown"
#
AC_MSG_CHECKING([if fcntl can be linked])
AC_LINK_IFELSE([
AC_LANG_FUNC_LINK_TRY([fcntl])
],[
AC_MSG_RESULT([yes])
tst_links_fcntl="yes"
],[
AC_MSG_RESULT([no])
tst_links_fcntl="no"
])
#
if test "$tst_links_fcntl" = "yes"; then
AC_MSG_CHECKING([if fcntl is prototyped])
AC_EGREP_CPP([fcntl],[
$cares_includes_fcntl
],[
AC_MSG_RESULT([yes])
tst_proto_fcntl="yes"
],[
AC_MSG_RESULT([no])
tst_proto_fcntl="no"
])
fi
#
if test "$tst_proto_fcntl" = "yes"; then
AC_MSG_CHECKING([if fcntl is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_fcntl
]],[[
if(0 != fcntl(0, 0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_fcntl="yes"
],[
AC_MSG_RESULT([no])
tst_compi_fcntl="no"
])
fi
#
if test "$tst_compi_fcntl" = "yes"; then
AC_MSG_CHECKING([if fcntl usage allowed])
if test "x$cares_disallow_fcntl" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_fcntl="yes"
else
AC_MSG_RESULT([no])
tst_allow_fcntl="no"
fi
fi
#
AC_MSG_CHECKING([if fcntl might be used])
if test "$tst_links_fcntl" = "yes" &&
test "$tst_proto_fcntl" = "yes" &&
test "$tst_compi_fcntl" = "yes" &&
test "$tst_allow_fcntl" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1,
[Define to 1 if you have the fcntl function.])
ac_cv_func_fcntl="yes"
CARES_CHECK_FUNC_FCNTL_O_NONBLOCK
else
AC_MSG_RESULT([no])
ac_cv_func_fcntl="no"
fi
])
dnl CARES_CHECK_FUNC_FCNTL_O_NONBLOCK
dnl -------------------------------------------------
dnl Verify if fcntl with status flag O_NONBLOCK is
dnl available, can be compiled, and seems to work. If
dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK
dnl will be defined.
AC_DEFUN([CARES_CHECK_FUNC_FCNTL_O_NONBLOCK], [
#
tst_compi_fcntl_o_nonblock="unknown"
tst_allow_fcntl_o_nonblock="unknown"
#
case $host_os in
sunos4* | aix3* | beos*)
dnl O_NONBLOCK does not work on these platforms
cares_disallow_fcntl_o_nonblock="yes"
;;
esac
#
if test "$ac_cv_func_fcntl" = "yes"; then
AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_fcntl
]],[[
int flags = 0;
if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_fcntl_o_nonblock="yes"
],[
AC_MSG_RESULT([no])
tst_compi_fcntl_o_nonblock="no"
])
fi
#
if test "$tst_compi_fcntl_o_nonblock" = "yes"; then
AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed])
if test "x$cares_disallow_fcntl_o_nonblock" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_fcntl_o_nonblock="yes"
else
AC_MSG_RESULT([no])
tst_allow_fcntl_o_nonblock="no"
fi
fi
#
AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used])
if test "$tst_compi_fcntl_o_nonblock" = "yes" &&
test "$tst_allow_fcntl_o_nonblock" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1,
[Define to 1 if you have a working fcntl O_NONBLOCK function.])
ac_cv_func_fcntl_o_nonblock="yes"
else
AC_MSG_RESULT([no])
ac_cv_func_fcntl_o_nonblock="no"
fi
])
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
dnl CARES_CHECK_FUNC_FREEADDRINFO
dnl -------------------------------------------------
dnl Verify if freeaddrinfo is available, prototyped,
dnl and can be compiled. If all of these are true,
dnl and usage has not been previously disallowed with
dnl shell variable cares_disallow_freeaddrinfo, then
dnl HAVE_FREEADDRINFO will be defined.
AC_DEFUN([CARES_CHECK_FUNC_FREEADDRINFO], [
AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
#
tst_links_freeaddrinfo="unknown"
tst_proto_freeaddrinfo="unknown"
tst_compi_freeaddrinfo="unknown"
tst_allow_freeaddrinfo="unknown"
#
AC_MSG_CHECKING([if freeaddrinfo can be linked])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_ws2tcpip
$cares_includes_sys_socket
$cares_includes_netdb
]],[[
freeaddrinfo(0);
]])
],[
AC_MSG_RESULT([yes])
tst_links_freeaddrinfo="yes"
],[
AC_MSG_RESULT([no])
tst_links_freeaddrinfo="no"
])
#
if test "$tst_links_freeaddrinfo" = "yes"; then
AC_MSG_CHECKING([if freeaddrinfo is prototyped])
AC_EGREP_CPP([freeaddrinfo],[
$cares_includes_ws2tcpip
$cares_includes_sys_socket
$cares_includes_netdb
],[
AC_MSG_RESULT([yes])
tst_proto_freeaddrinfo="yes"
],[
AC_MSG_RESULT([no])
tst_proto_freeaddrinfo="no"
])
fi
#
if test "$tst_proto_freeaddrinfo" = "yes"; then
AC_MSG_CHECKING([if freeaddrinfo is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_ws2tcpip
$cares_includes_sys_socket
$cares_includes_netdb
]],[[
freeaddrinfo(0);
]])
],[
AC_MSG_RESULT([yes])
tst_compi_freeaddrinfo="yes"
],[
AC_MSG_RESULT([no])
tst_compi_freeaddrinfo="no"
])
fi
#
if test "$tst_compi_freeaddrinfo" = "yes"; then
AC_MSG_CHECKING([if freeaddrinfo usage allowed])
if test "x$cares_disallow_freeaddrinfo" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_freeaddrinfo="yes"
else
AC_MSG_RESULT([no])
tst_allow_freeaddrinfo="no"
fi
fi
#
AC_MSG_CHECKING([if freeaddrinfo might be used])
if test "$tst_links_freeaddrinfo" = "yes" &&
test "$tst_proto_freeaddrinfo" = "yes" &&
test "$tst_compi_freeaddrinfo" = "yes" &&
test "$tst_allow_freeaddrinfo" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_FREEADDRINFO, 1,
[Define to 1 if you have the freeaddrinfo function.])
ac_cv_func_freeaddrinfo="yes"
else
AC_MSG_RESULT([no])
ac_cv_func_freeaddrinfo="no"
fi
])
dnl CARES_CHECK_FUNC_GETADDRINFO
dnl -------------------------------------------------
dnl Verify if getaddrinfo is available, prototyped, can
dnl be compiled and seems to work. If all of these are
dnl true, and usage has not been previously disallowed
dnl with shell variable cares_disallow_getaddrinfo, then
dnl HAVE_GETADDRINFO will be defined. Additionally when
dnl HAVE_GETADDRINFO gets defined this will also attempt
dnl to find out if getaddrinfo happens to be threadsafe,
dnl defining HAVE_GETADDRINFO_THREADSAFE when true.
AC_DEFUN([CARES_CHECK_FUNC_GETADDRINFO], [
AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
Yang Tse
committed
AC_REQUIRE([CARES_INCLUDES_STRING])dnl
AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
#
tst_links_getaddrinfo="unknown"
tst_proto_getaddrinfo="unknown"
tst_compi_getaddrinfo="unknown"
tst_works_getaddrinfo="unknown"
tst_allow_getaddrinfo="unknown"
tst_tsafe_getaddrinfo="unknown"
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
#
AC_MSG_CHECKING([if getaddrinfo can be linked])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_ws2tcpip
$cares_includes_sys_socket
$cares_includes_netdb
]],[[
if(0 != getaddrinfo(0, 0, 0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_links_getaddrinfo="yes"
],[
AC_MSG_RESULT([no])
tst_links_getaddrinfo="no"
])
#
if test "$tst_links_getaddrinfo" = "yes"; then
AC_MSG_CHECKING([if getaddrinfo is prototyped])
AC_EGREP_CPP([getaddrinfo],[
$cares_includes_ws2tcpip
$cares_includes_sys_socket
$cares_includes_netdb
],[
AC_MSG_RESULT([yes])
tst_proto_getaddrinfo="yes"
],[
AC_MSG_RESULT([no])
tst_proto_getaddrinfo="no"
])
fi
#
if test "$tst_proto_getaddrinfo" = "yes"; then
AC_MSG_CHECKING([if getaddrinfo is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_ws2tcpip
$cares_includes_sys_socket
$cares_includes_netdb
]],[[
if(0 != getaddrinfo(0, 0, 0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_getaddrinfo="yes"
],[
AC_MSG_RESULT([no])
tst_compi_getaddrinfo="no"
])
fi
#
dnl only do runtime verification when not cross-compiling
if test "x$cross_compiling" != "xyes" &&
test "$tst_compi_getaddrinfo" = "yes"; then
AC_MSG_CHECKING([if getaddrinfo seems to work])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_ws2tcpip
$cares_includes_stdlib
Yang Tse
committed
$cares_includes_string
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
$cares_includes_sys_socket
$cares_includes_netdb
]],[[
struct addrinfo hints;
struct addrinfo *ai = 0;
int error;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_NUMERICHOST;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo("127.0.0.1", 0, &hints, &ai);
if(error || !ai)
exit(1); /* fail */
else
exit(0);
]])
],[
AC_MSG_RESULT([yes])
tst_works_getaddrinfo="yes"
],[
AC_MSG_RESULT([no])
tst_works_getaddrinfo="no"
])
fi
#
if test "$tst_compi_getaddrinfo" = "yes" &&
test "$tst_works_getaddrinfo" != "no"; then
AC_MSG_CHECKING([if getaddrinfo usage allowed])
if test "x$cares_disallow_getaddrinfo" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_getaddrinfo="yes"
else
AC_MSG_RESULT([no])
tst_allow_getaddrinfo="no"
fi
fi
#
AC_MSG_CHECKING([if getaddrinfo might be used])
if test "$tst_links_getaddrinfo" = "yes" &&
test "$tst_proto_getaddrinfo" = "yes" &&
test "$tst_compi_getaddrinfo" = "yes" &&
test "$tst_allow_getaddrinfo" = "yes" &&
test "$tst_works_getaddrinfo" != "no"; then