Newer
Older
#***************************************************************************
# $Id$
#
# Copyright (C) 2008 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_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])
])
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
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_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])
])
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
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
])
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
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
])
287
288
289
290
291
292
293
294
295
296
297
298
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
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
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
])
436
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
527
528
529
530
531
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
])
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
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
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.
AC_DEFUN([CARES_CHECK_FUNC_GETADDRINFO], [
AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
AC_REQUIRE([CARES_INCLUDES_STDLIB])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"
#
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
$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
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO, 1,
[Define to 1 if you have a working getaddrinfo function.])
ac_cv_func_getaddrinfo="yes"
else
AC_MSG_RESULT([no])
ac_cv_func_getaddrinfo="no"
fi
])
dnl CARES_CHECK_FUNC_GETHOSTNAME
dnl -------------------------------------------------
dnl Verify if gethostname 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_gethostname, then
dnl HAVE_GETHOSTNAME will be defined.
AC_DEFUN([CARES_CHECK_FUNC_GETHOSTNAME], [
AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
AC_REQUIRE([CARES_INCLUDES_UNISTD])dnl
#
tst_links_gethostname="unknown"
tst_proto_gethostname="unknown"
tst_compi_gethostname="unknown"
tst_allow_gethostname="unknown"
#
AC_MSG_CHECKING([if gethostname can be linked])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_winsock2
$cares_includes_unistd
]],[[
if(0 != gethostname(0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_links_gethostname="yes"
],[
AC_MSG_RESULT([no])
tst_links_gethostname="no"
])
#
if test "$tst_links_gethostname" = "yes"; then
AC_MSG_CHECKING([if gethostname is prototyped])
AC_EGREP_CPP([gethostname],[
$cares_includes_unistd
],[
AC_MSG_RESULT([yes])
tst_proto_gethostname="yes"
],[
AC_MSG_RESULT([no])
tst_proto_gethostname="no"
])
fi
#
if test "$tst_proto_gethostname" = "yes"; then
AC_MSG_CHECKING([if gethostname is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
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
$cares_includes_unistd
]],[[
if(0 != gethostname(0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_gethostname="yes"
],[
AC_MSG_RESULT([no])
tst_compi_gethostname="no"
])
fi
#
if test "$tst_compi_gethostname" = "yes"; then
AC_MSG_CHECKING([if gethostname usage allowed])
if test "x$cares_disallow_gethostname" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_gethostname="yes"
else
AC_MSG_RESULT([no])
tst_allow_gethostname="no"
fi
fi
#
AC_MSG_CHECKING([if gethostname might be used])
if test "$tst_links_gethostname" = "yes" &&
test "$tst_proto_gethostname" = "yes" &&
test "$tst_compi_gethostname" = "yes" &&
test "$tst_allow_gethostname" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_GETHOSTNAME, 1,
[Define to 1 if you have the gethostname function.])
ac_cv_func_gethostname="yes"
else
AC_MSG_RESULT([no])
ac_cv_func_gethostname="no"
fi
])
dnl CARES_CHECK_FUNC_GETSERVBYPORT_R
dnl -------------------------------------------------
dnl Verify if getservbyport_r is available, prototyped,
dnl and can be compiled. If all of these are true, and
dnl usage has not been previously disallowed with
dnl shell variable cares_disallow_getservbyport_r, then
dnl HAVE_GETSERVBYPORT_R will be defined.
AC_DEFUN([CARES_CHECK_FUNC_GETSERVBYPORT_R], [
772
773
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
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
#
tst_links_getservbyport_r="unknown"
tst_proto_getservbyport_r="unknown"
tst_compi_getservbyport_r="unknown"
tst_allow_getservbyport_r="unknown"
tst_nargs_getservbyport_r="unknown"
#
AC_MSG_CHECKING([if getservbyport_r can be linked])
AC_LINK_IFELSE([
AC_LANG_FUNC_LINK_TRY([getservbyport_r])
],[
AC_MSG_RESULT([yes])
tst_links_getservbyport_r="yes"
],[
AC_MSG_RESULT([no])
tst_links_getservbyport_r="no"
])
#
if test "$tst_links_getservbyport_r" = "yes"; then
AC_MSG_CHECKING([if getservbyport_r is prototyped])
AC_EGREP_CPP([getservbyport_r],[
$cares_includes_netdb
],[
AC_MSG_RESULT([yes])
tst_proto_getservbyport_r="yes"
],[
AC_MSG_RESULT([no])
tst_proto_getservbyport_r="no"
])
fi
#
if test "$tst_proto_getservbyport_r" = "yes"; then
if test "$tst_nargs_getservbyport_r" = "unknown"; then
AC_MSG_CHECKING([if getservbyport_r takes 4 args.])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_netdb
]],[[
if(0 != getservbyport_r(0, 0, 0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_getservbyport_r="yes"
tst_nargs_getservbyport_r="4"
],[
AC_MSG_RESULT([no])
tst_compi_getservbyport_r="no"
])
fi
if test "$tst_nargs_getservbyport_r" = "unknown"; then
AC_MSG_CHECKING([if getservbyport_r takes 5 args.])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_netdb
]],[[
if(0 != getservbyport_r(0, 0, 0, 0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_getservbyport_r="yes"
tst_nargs_getservbyport_r="5"
],[
AC_MSG_RESULT([no])
tst_compi_getservbyport_r="no"
])
fi
if test "$tst_nargs_getservbyport_r" = "unknown"; then
AC_MSG_CHECKING([if getservbyport_r takes 6 args.])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_netdb
]],[[
if(0 != getservbyport_r(0, 0, 0, 0, 0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_getservbyport_r="yes"
tst_nargs_getservbyport_r="6"
],[
AC_MSG_RESULT([no])
tst_compi_getservbyport_r="no"
])
fi
AC_MSG_CHECKING([if getservbyport_r is compilable])
if test "$tst_compi_getservbyport_r" = "yes"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
#
if test "$tst_compi_getservbyport_r" = "yes"; then
AC_MSG_CHECKING([if getservbyport_r usage allowed])
if test "x$cares_disallow_getservbyport_r" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_getservbyport_r="yes"
else
AC_MSG_RESULT([no])
tst_allow_getservbyport_r="no"
fi
fi
#
AC_MSG_CHECKING([if getservbyport_r might be used])
if test "$tst_links_getservbyport_r" = "yes" &&
test "$tst_proto_getservbyport_r" = "yes" &&
test "$tst_compi_getservbyport_r" = "yes" &&
test "$tst_allow_getservbyport_r" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_GETSERVBYPORT_R, 1,
[Define to 1 if you have the getservbyport_r function.])
AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $tst_nargs_getservbyport_r,
[Specifies the number of arguments to getservbyport_r])
if test "$tst_nargs_getservbyport_r" -eq "4"; then
AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
[Specifies the size of the buffer to pass to getservbyport_r])
else
AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
[Specifies the size of the buffer to pass to getservbyport_r])
fi
ac_cv_func_getservbyport_r="yes"
else
AC_MSG_RESULT([no])
ac_cv_func_getservbyport_r="no"
fi
])
dnl CARES_CHECK_FUNC_INET_NTOP
dnl -------------------------------------------------
dnl Verify if inet_ntop 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_inet_ntop, then
dnl HAVE_INET_NTOP will be defined.
AC_DEFUN([CARES_CHECK_FUNC_INET_NTOP], [
AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
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
956
957
958
959
960
961
962
963
964
965
966
967
968
AC_REQUIRE([CARES_INCLUDES_ARPA_INET])dnl
AC_REQUIRE([CARES_INCLUDES_STRING])dnl
#
tst_links_inet_ntop="unknown"
tst_proto_inet_ntop="unknown"
tst_compi_inet_ntop="unknown"
tst_works_inet_ntop="unknown"
tst_allow_inet_ntop="unknown"
#
AC_MSG_CHECKING([if inet_ntop can be linked])
AC_LINK_IFELSE([
AC_LANG_FUNC_LINK_TRY([inet_ntop])
],[
AC_MSG_RESULT([yes])
tst_links_inet_ntop="yes"
],[
AC_MSG_RESULT([no])
tst_links_inet_ntop="no"
])
#
if test "$tst_links_inet_ntop" = "yes"; then
AC_MSG_CHECKING([if inet_ntop is prototyped])
AC_EGREP_CPP([inet_ntop],[
$cares_includes_arpa_inet
],[
AC_MSG_RESULT([yes])
tst_proto_inet_ntop="yes"
],[
AC_MSG_RESULT([no])
tst_proto_inet_ntop="no"
])
fi
#
if test "$tst_proto_inet_ntop" = "yes"; then
AC_MSG_CHECKING([if inet_ntop is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_arpa_inet
]],[[
if(0 != inet_ntop(0, 0, 0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_inet_ntop="yes"
],[
AC_MSG_RESULT([no])
tst_compi_inet_ntop="no"
])
fi
#
dnl only do runtime verification when not cross-compiling
if test "x$cross_compiling" != "xyes" &&
test "$tst_compi_inet_ntop" = "yes"; then
AC_MSG_CHECKING([if inet_ntop seems to work])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([[
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_arpa_inet
$cares_includes_string
]],[[
char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
char ipv4res[sizeof "255.255.255.255"];
unsigned char ipv6a[26];
unsigned char ipv4a[5];
char *ipv6ptr = 0;
char *ipv4ptr = 0;
/* - */
ipv4res[0] = '\0';
ipv4a[0] = 0xc0;
ipv4a[1] = 0xa8;
ipv4a[2] = 0x64;
ipv4a[3] = 0x01;
ipv4a[4] = 0x01;
/* - */
ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
if(!ipv4ptr)
exit(1); /* fail */
if(ipv4ptr != ipv4res)
exit(1); /* fail */
if(!ipv4ptr[0])
exit(1); /* fail */
if(memcmp(ipv4res, "192.168.100.1", 13) != 0)
exit(1); /* fail */
/* - */
ipv6res[0] = '\0';
memset(ipv6a, 0, sizeof(ipv6a));
ipv6a[0] = 0xfe;
ipv6a[1] = 0x80;