forked from c-ares/c-ares
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
854 lines (767 loc) · 32.7 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
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
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
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
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
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
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
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
dnl Copyright (C) The c-ares project and its contributors
dnl SPDX-License-Identifier: MIT
AC_PREREQ([2.69])
AC_INIT([c-ares], [1.33.0],
[c-ares mailing list: http://lists.haxx.se/listinfo/c-ares])
CARES_VERSION_INFO="20:0:18"
dnl This flag accepts an argument of the form current[:revision[:age]]. So,
dnl passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
dnl 1.
dnl
dnl If either revision or age are omitted, they default to 0. Also note that age
dnl must be less than or equal to the current interface number.
dnl
dnl Here are a set of rules to help you update your library version information:
dnl
dnl 1.Start with version information of 0:0:0 for each libtool library.
dnl
dnl 2.Update the version information only immediately before a public release of
dnl your software. More frequent updates are unnecessary, and only guarantee
dnl that the current interface number gets larger faster.
dnl
dnl 3.If the library source code has changed at all since the last update, then
dnl increment revision (c:r+1:a)
dnl
dnl 4.If any interfaces have been added, removed, or changed since the last
dnl update, increment current, and set revision to 0. (c+1:r=0:a)
dnl
dnl 5.If any interfaces have been added since the last public release, then
dnl increment age. (c:r:a+1)
dnl
dnl 6.If any interfaces have been removed since the last public release, then
dnl set age to 0. (c:r:a=0)
dnl
AC_SUBST([CARES_VERSION_INFO])
AC_CONFIG_SRCDIR([src/lib/ares_ipv6.h])
AC_CONFIG_HEADERS([src/lib/ares_config.h include/ares_build.h])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR([m4])
AC_USE_SYSTEM_EXTENSIONS
AX_CXX_COMPILE_STDCXX_14([noext],[optional])
AM_INIT_AUTOMAKE([foreign subdir-objects 1.9.6])
LT_INIT([win32-dll,pic,disable-fast-install,aix-soname=svr4])
AC_LANG([C])
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_EGREP
AC_PROG_INSTALL
AC_CANONICAL_HOST
AX_COMPILER_VENDOR
AC_MSG_CHECKING([whether this is native windows])
ac_cv_native_windows=no
ac_cv_windows=no
case $host_os in
mingw*)
ac_cv_native_windows=yes
ac_cv_windows=yes
;;
cygwin*)
ac_cv_windows=yes
;;
esac
if test "$ax_cv_c_compiler_vendor" = "microsoft" ; then
ac_cv_native_windows=yes
ac_cv_windows=yes
fi
AC_MSG_RESULT($ac_cv_native_windows)
AC_ENABLE_SHARED
dnl Disable static builds by default on Windows unless overwritten since Windows
dnl can't simultaneously build shared and static with autotools.
AS_IF([test "x$ac_cv_windows" = "xyes"], [AC_DISABLE_STATIC], [AC_ENABLE_STATIC])
AC_ARG_ENABLE(warnings,
AS_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]),
[ enable_warnings=${enableval} ],
[ enable_warnings=yes ])
AC_ARG_ENABLE(symbol-hiding,
AS_HELP_STRING([--disable-symbol-hiding], [Disable symbol hiding. Enabled by default if the compiler supports it.]),
[
symbol_hiding="$enableval"
if test "$symbol_hiding" = "no" -a "x$enable_shared" = "xyes" ; then
case $host_os in
cygwin* | mingw* | pw32* | cegcc*)
AC_MSG_ERROR([Cannot disable symbol hiding on windows])
;;
esac
fi
],
[
if test "x$enable_shared" = "xyes" ; then
symbol_hiding="maybe"
else
symbol_hiding="no"
fi
]
)
AC_ARG_ENABLE(tests,
AS_HELP_STRING([--disable-tests], [disable building of test suite. Built by default if GoogleTest is found.]),
[ build_tests="$enableval" ],
[ if test "x$HAVE_CXX14" = "x1" && test "x$cross_compiling" = "xno" ; then
build_tests="maybe"
else
build_tests="no"
fi
]
)
AC_ARG_ENABLE(cares-threads,
AS_HELP_STRING([--disable-cares-threads], [Disable building of thread safety support]),
[ CARES_THREADS=${enableval} ],
[ CARES_THREADS=yes ])
AC_ARG_WITH(random,
AS_HELP_STRING([--with-random=FILE],
[read randomness from FILE (default=/dev/urandom)]),
[ CARES_RANDOM_FILE="$withval" ],
[ CARES_RANDOM_FILE="/dev/urandom" ]
)
if test -n "$CARES_RANDOM_FILE" && test X"$CARES_RANDOM_FILE" != Xno ; then
AC_SUBST(CARES_RANDOM_FILE)
AC_DEFINE_UNQUOTED(CARES_RANDOM_FILE, "$CARES_RANDOM_FILE", [a suitable file/device to read random data from])
fi
AM_MAINTAINER_MODE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
dnl CARES_DEFINE_UNQUOTED (VARIABLE, [VALUE])
dnl -------------------------------------------------
dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
dnl symbol that can be further used in custom template configuration
dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
dnl argument for the description. Symbol definitions done with this
dnl macro are intended to be exclusively used in handcrafted *.h.in
dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
dnl prevents autoheader generation and insertion of symbol template
dnl stub and definition into the first configuration header file. Do
dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
dnl one serves different functional needs.
AC_DEFUN([CARES_DEFINE_UNQUOTED], [
cat >>confdefs.h <<_EOF
[@%:@define] $1 ifelse($#, 2, [$2], 1)
_EOF
])
AX_CODE_COVERAGE
AX_CHECK_USER_NAMESPACE
AX_CHECK_UTS_NAMESPACE
AC_SYS_LARGEFILE
case $host_os in
solaris*)
AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
;;
esac
dnl solaris needed flag
case $host_os in
solaris2*)
if test "x$GCC" = 'xyes'; then
AX_APPEND_LINK_FLAGS([-mimpure-text])
fi
;;
*)
;;
esac
dnl -no-undefined libtool (not linker) flag for windows
cares_use_no_undefined=no
case $host_os in
cygwin* | mingw* | pw32* | cegcc* | os2* | aix*)
cares_use_no_undefined=yes
;;
*)
;;
esac
AM_CONDITIONAL([CARES_USE_NO_UNDEFINED], [test "$cares_use_no_undefined" = 'yes'])
if test "$ac_cv_native_windows" = "yes" ; then
AM_CPPFLAGS="$AM_CPPFLAGS -D_WIN32_WINNT=0x0602 -DWIN32_LEAN_AND_MEAN"
fi
dnl Windows can only build shared or static, not both at the same time
if test "$ac_cv_native_windows" = "yes" -a "x$enable_shared" = "xyes" -a "x$enable_static" = "xyes" ; then
AC_MSG_ERROR([Windows cannot build both static and shared simultaneously, specify --disable-shared or --disable-static])
fi
dnl Only windows requires CARES_STATICLIB definition
if test "x$enable_shared" = "xno" -a "x$enable_static" = "xyes" ; then
AC_MSG_CHECKING([whether we need CARES_STATICLIB definition])
if test "$ac_cv_native_windows" = "yes" ; then
AX_APPEND_FLAG([-DCARES_STATICLIB], [AM_CPPFLAGS])
PKGCONFIG_CFLAGS="-DCARES_STATICLIB"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
dnl Test for symbol hiding
CARES_SYMBOL_HIDING_CFLAG=""
if test "$symbol_hiding" != "no" ; then
compiler_supports_symbol_hiding="no"
if test "$ac_cv_windows" = "yes" ; then
compiler_supports_symbol_hiding="yes"
else
case "$ax_cv_c_compiler_vendor" in
clang|gnu|intel)
AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden], [CARES_SYMBOL_HIDING_CFLAG])
if test "x$CARES_SYMBOL_HIDING_CFLAG" != "x" ; then
compiler_supports_symbol_hiding="yes"
fi
;;
sun)
AX_APPEND_COMPILE_FLAGS([-xldscope=hidden], [CARES_SYMBOL_HIDING_CFLAG])
if test "x$CARES_SYMBOL_HIDING_CFLAG" != "x" ; then
compiler_supports_symbol_hiding="yes"
fi
;;
esac
fi
if test "$compiler_supports_symbol_hiding" = "no" ; then
if test "$symbol_hiding" = "yes" ; then
AC_MSG_ERROR([Compiler does not support symbol hiding])
else
symbol_hiding="no"
fi
else
AC_DEFINE([CARES_SYMBOL_HIDING], [ 1 ], [Set to 1 if non-pubilc shared library symbols are hidden])
symbol_hiding="yes"
fi
fi
AM_CONDITIONAL(CARES_SYMBOL_HIDING, test "x$symbol_hiding" = "xyes")
AC_SUBST(CARES_SYMBOL_HIDING_CFLAG)
if test "$enable_warnings" = "yes"; then
AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion -Wfloat-equal -Wformat-security -Winit-self -Wjump-misses-init -Wlogical-op -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wno-coverage-mismatch -Wold-style-definition -Wpacked -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow -Wstrict-prototypes -Wtrampolines -Wundef -Wunreachable-code -Wunused -Wvariadic-macros -Wvla -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=partial-availability -Wno-long-long ],
[AM_CFLAGS], [-Werror])
dnl Android requires c99, all others should use c90
case $host_os in
*android*)
AX_APPEND_COMPILE_FLAGS([-std=c99], [AM_CFLAGS], [-Werror])
;;
*)
AX_APPEND_COMPILE_FLAGS([-std=c90], [AM_CFLAGS], [-Werror])
;;
esac
fi
if test "$ax_cv_c_compiler_vendor" = "intel"; then
AX_APPEND_COMPILE_FLAGS([-shared-intel], [AM_CFLAGS])
fi
if test "$ac_cv_native_windows" = "yes" ; then
dnl we use [ - ] in the 4th argument to tell AC_CHECK_HEADERS to simply
dnl check for existence of the headers, not usability. This is because
dnl on windows, header order matters, and you need to include headers *after*
dnl other headers, AC_CHECK_HEADERS only allows you to specify headers that
dnl must be included *before* the header being checked.
AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h iphlpapi.h netioapi.h ws2ipdef.h winternl.h ntdef.h ntstatus.h mswsock.h ],
[], [], [-])
dnl Windows builds require linking to iphlpapi
if test "$ac_cv_header_winsock2_h" = "yes"; then
LIBS="$LIBS -lws2_32 -liphlpapi"
fi
fi
dnl **********************************************************************
dnl Checks for libraries.
dnl **********************************************************************
dnl see if libnsl or libsocket are required
AC_SEARCH_LIBS([getservbyport], [nsl socket resolv])
AC_MSG_CHECKING([if libxnet is required])
need_xnet=no
case $host_os in
hpux*)
XNET_LIBS=""
AX_APPEND_LINK_FLAGS([-lxnet], [XNET_LIBS])
if test "x$XNET_LIBS" != "x" ; then
LIBS="$LIBS $XNET_LIBS"
need_xnet=yes
fi
;;
esac
AC_MSG_RESULT($need_xnet)
dnl resolv lib for z/OS
AS_IF([test "x$host_vendor" = "xibm" -a "x$host_os" = "xopenedition" ], [
AC_SEARCH_LIBS([res_init], [resolv], [
AC_DEFINE([CARES_USE_LIBRESOLV], [1], [Use resolver library to configure cares])
], [
AC_MSG_ERROR([Unable to find libresolv which is required for z/OS])
])
])
dnl iOS 10?
AS_IF([test "x$host_vendor" = "xapple"], [
AC_MSG_CHECKING([for iOS minimum version 10 or later])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#include <stdio.h>
#include <AvailabilityMacros.h>
#include <TargetConditionals.h>
]], [[
#if TARGET_OS_IPHONE == 0 || __IPHONE_OS_VERSION_MIN_REQUIRED < 100000
#error Not iOS 10 or later
#endif
return 0;
]])
],[
AC_MSG_RESULT([yes])
ac_cv_ios_10="yes"
],[
AC_MSG_RESULT([no])
])
])
dnl macOS 10.12?
AS_IF([test "x$host_vendor" = "xapple"], [
AC_MSG_CHECKING([for macOS minimum version 10.12 or later])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#include <stdio.h>
#include <AvailabilityMacros.h>
#include <TargetConditionals.h>
]], [[
#ifndef MAC_OS_X_VERSION_10_12
# define MAC_OS_X_VERSION_10_12 101200
#endif
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
#error Not macOS 10.12 or later
#endif
return 0;
]])
],[
AC_MSG_RESULT([yes])
ac_cv_macos_10_12="yes"
],[
AC_MSG_RESULT([no])
])
])
AC_MSG_CHECKING([whether to use libgcc])
AC_ARG_ENABLE(libgcc,
AS_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
[ case "$enableval" in
yes)
LIBS="$LIBS -lgcc"
AC_MSG_RESULT(yes)
;;
*)
AC_MSG_RESULT(no)
;;
esac ],
AC_MSG_RESULT(no)
)
dnl check for a few basic system headers we need. It would be nice if we could
dnl split these on separate lines, but for some reason autotools on Windows doesn't
dnl allow this, even tried ending lines with a backslash.
AC_CHECK_HEADERS([malloc.h memory.h AvailabilityMacros.h sys/types.h sys/time.h sys/select.h sys/socket.h sys/filio.h sys/ioctl.h sys/param.h sys/uio.h sys/random.h sys/event.h sys/epoll.h assert.h iphlpapi.h netioapi.h netdb.h netinet/in.h netinet6/in6.h netinet/tcp.h net/if.h ifaddrs.h fcntl.h errno.h socket.h strings.h stdbool.h time.h poll.h limits.h arpa/nameser.h arpa/nameser_compat.h arpa/inet.h ],
dnl to do if not found
[],
dnl to do if found
[],
dnl default includes
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
dnl We do this default-include simply to make sure that the nameser_compat.h
dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
dnl (and others?) is not designed to allow this.
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
dnl *Sigh* these are needed in order for net/if.h to get properly detected.
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
]
)
cares_all_includes="
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_AVAILABILITYMACROS_H
# include <AvailabilityMacros.h>
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_TCP_H
# include <tcp.h>
#endif
#ifdef HAVE_SYS_FILIO_H
# include <sys/filio.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_TIME_H
# include <time.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_SYS_RANDOM_H
# include <sys/random.h>
#endif
#ifdef HAVE_SYS_EVENT_H
# include <sys/event.h>
#endif
#ifdef HAVE_SYS_EPOLL_H
# include <sys/epoll.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_POLL_H
# include <poll.h>
#endif
#ifdef HAVE_NET_IF_H
# include <net/if.h>
#endif
#ifdef HAVE_IFADDRS_H
# include <ifaddrs.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_RESOLV_H
# include <resolv.h>
#endif
#ifdef HAVE_IPHLPAPI_H
# include <iphlpapi.h>
#endif
#ifdef HAVE_NETIOAPI_H
# include <netioapi.h>
#endif
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
#endif
#ifdef HAVE_WS2IPDEF_H
# include <ws2ipdef.h>
#endif
#ifdef HAVE_WS2TCPIP_H
# include <ws2tcpip.h>
#endif
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
"
AC_CHECK_DECL([HAVE_ARPA_NAMESER_H],[CARES_DEFINE_UNQUOTED([CARES_HAVE_ARPA_NAMESER_H])], [])
AC_CHECK_DECL([HAVE_ARPA_NAMESER_COMPAT_H],[CARES_DEFINE_UNQUOTED([CARES_HAVE_ARPA_NAMESER_COMPAT_H])],[])
AC_CHECK_TYPE(long long, [AC_DEFINE(HAVE_LONGLONG, 1, [Define to 1 if the compiler supports the 'long long' data type.])])
AC_CHECK_TYPE(ssize_t, [ CARES_TYPEOF_ARES_SSIZE_T=ssize_t ], [ CARES_TYPEOF_ARES_SSIZE_T=int ])
AC_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SSIZE_T], ${CARES_TYPEOF_ARES_SSIZE_T}, [the signed version of size_t])
AC_CHECK_TYPE(socklen_t,
[
AC_DEFINE(HAVE_SOCKLEN_T, [], [socklen_t])
CARES_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SOCKLEN_T], [socklen_t])
],
[ CARES_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SOCKLEN_T], [int]) ],
$cares_all_includes
)
AC_CHECK_TYPE(SOCKET, [], [], $cares_all_includes)
dnl ###############################################################################
dnl clock_gettime might require an external library
AC_SEARCH_LIBS([clock_gettime], [rt posix4])
dnl Use AC_CHECK_DECL not AC_CHECK_FUNCS, while this doesn't do a linkage test,
dnl it just makes sure the headers define it, this is the only thing without
dnl a complex workaround on Windows that will do what we need. See:
dnl https://github.com/msys2/msys2/wiki/Porting/f87a222118b1008ebc166ad237f04edb759c8f4c#calling-conventions-stdcall-and-autotools
dnl https://lists.gnu.org/archive/html/autoconf/2013-05/msg00085.html
dnl and for a more complex workaround, we'd need to use AC_LINK_IFELSE like:
dnl https://mailman.videolan.org/pipermail/vlc-devel/2015-March/101802.html
dnl which would require we check each individually and provide function arguments
dnl for the test.
AC_CHECK_DECL(recv, [AC_DEFINE([HAVE_RECV], 1, [Define to 1 if you have `recv`] )], [], $cares_all_includes)
AC_CHECK_DECL(recvfrom, [AC_DEFINE([HAVE_RECVFROM], 1, [Define to 1 if you have `recvfrom`] )], [], $cares_all_includes)
AC_CHECK_DECL(send, [AC_DEFINE([HAVE_SEND], 1, [Define to 1 if you have `send`] )], [], $cares_all_includes)
AC_CHECK_DECL(getnameinfo, [AC_DEFINE([HAVE_GETNAMEINFO], 1, [Define to 1 if you have `getnameinfo`] )], [], $cares_all_includes)
AC_CHECK_DECL(gethostname, [AC_DEFINE([HAVE_GETHOSTNAME], 1, [Define to 1 if you have `gethostname`] )], [], $cares_all_includes)
AC_CHECK_DECL(connect, [AC_DEFINE([HAVE_CONNECT], 1, [Define to 1 if you have `connect`] )], [], $cares_all_includes)
AC_CHECK_DECL(connectx, [AC_DEFINE([HAVE_CONNECTX], 1, [Define to 1 if you have `connectx`] )], [], $cares_all_includes)
AC_CHECK_DECL(closesocket, [AC_DEFINE([HAVE_CLOSESOCKET], 1, [Define to 1 if you have `closesocket`] )], [], $cares_all_includes)
AC_CHECK_DECL(CloseSocket, [AC_DEFINE([HAVE_CLOSESOCKET_CAMEL], 1, [Define to 1 if you have `CloseSocket`] )], [], $cares_all_includes)
AC_CHECK_DECL(fcntl, [AC_DEFINE([HAVE_FCNTL], 1, [Define to 1 if you have `fcntl`] )], [], $cares_all_includes)
AC_CHECK_DECL(getenv, [AC_DEFINE([HAVE_GETENV], 1, [Define to 1 if you have `getenv`] )], [], $cares_all_includes)
AC_CHECK_DECL(gethostname, [AC_DEFINE([HAVE_GETHOSTNAME], 1, [Define to 1 if you have `gethostname`] )], [], $cares_all_includes)
AC_CHECK_DECL(getrandom, [AC_DEFINE([HAVE_GETRANDOM], 1, [Define to 1 if you have `getrandom`] )], [], $cares_all_includes)
AC_CHECK_DECL(getservbyport_r, [AC_DEFINE([HAVE_GETSERVBYPORT_R], 1, [Define to 1 if you have `getservbyport_r`])], [], $cares_all_includes)
AC_CHECK_DECL(inet_net_pton, [AC_DEFINE([HAVE_INET_NET_PTON], 1, [Define to 1 if you have `inet_net_pton`] )], [], $cares_all_includes)
AC_CHECK_DECL(inet_ntop, [AC_DEFINE([HAVE_INET_NTOP], 1, [Define to 1 if you have `inet_ntop`] )], [], $cares_all_includes)
AC_CHECK_DECL(inet_pton, [AC_DEFINE([HAVE_INET_PTON], 1, [Define to 1 if you have `inet_pton`] )], [], $cares_all_includes)
AC_CHECK_DECL(ioctl, [AC_DEFINE([HAVE_IOCTL], 1, [Define to 1 if you have `ioctl`] )], [], $cares_all_includes)
AC_CHECK_DECL(ioctlsocket, [AC_DEFINE([HAVE_IOCTLSOCKET], 1, [Define to 1 if you have `ioctlsocket`] )], [], $cares_all_includes)
AC_CHECK_DECL(IoctlSocket, [AC_DEFINE([HAVE_IOCTLSOCKET_CAMEL], 1, [Define to 1 if you have `IoctlSocket`] )], [], $cares_all_includes)
AC_CHECK_DECL(setsockopt, [AC_DEFINE([HAVE_SETSOCKOPT], 1, [Define to 1 if you have `setsockopt`] )], [], $cares_all_includes)
AC_CHECK_DECL(socket, [AC_DEFINE([HAVE_SOCKET], 1, [Define to 1 if you have `socket`] )], [], $cares_all_includes)
AC_CHECK_DECL(strcasecmp, [AC_DEFINE([HAVE_STRCASECMP], 1, [Define to 1 if you have `strcasecmp`] )], [], $cares_all_includes)
AC_CHECK_DECL(strdup, [AC_DEFINE([HAVE_STRDUP], 1, [Define to 1 if you have `strdup`] )], [], $cares_all_includes)
AC_CHECK_DECL(stricmp, [AC_DEFINE([HAVE_STRICMP], 1, [Define to 1 if you have `stricmp`] )], [], $cares_all_includes)
AC_CHECK_DECL(strncasecmp, [AC_DEFINE([HAVE_STRNCASECMP], 1, [Define to 1 if you have `strncasecmp`] )], [], $cares_all_includes)
AC_CHECK_DECL(strncmpi, [AC_DEFINE([HAVE_STRNCMPI], 1, [Define to 1 if you have `strncmpi`] )], [], $cares_all_includes)
AC_CHECK_DECL(strnicmp, [AC_DEFINE([HAVE_STRNICMP], 1, [Define to 1 if you have `strnicmp`] )], [], $cares_all_includes)
AC_CHECK_DECL(writev, [AC_DEFINE([HAVE_WRITEV], 1, [Define to 1 if you have `writev`] )], [], $cares_all_includes)
AC_CHECK_DECL(arc4random_buf, [AC_DEFINE([HAVE_ARC4RANDOM_BUF], 1, [Define to 1 if you have `arc4random_buf`] )], [], $cares_all_includes)
AC_CHECK_DECL(stat, [AC_DEFINE([HAVE_STAT], 1, [Define to 1 if you have `stat`] )], [], $cares_all_includes)
AC_CHECK_DECL(gettimeofday, [AC_DEFINE([HAVE_GETTIMEOFDAY], 1, [Define to 1 if you have `gettimeofday`] )], [], $cares_all_includes)
AC_CHECK_DECL(clock_gettime, [AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [Define to 1 if you have `clock_gettime`] )], [], $cares_all_includes)
AC_CHECK_DECL(if_indextoname, [AC_DEFINE([HAVE_IF_INDEXTONAME], 1, [Define to 1 if you have `if_indextoname`] )], [], $cares_all_includes)
AC_CHECK_DECL(if_nametoindex, [AC_DEFINE([HAVE_IF_NAMETOINDEX], 1, [Define to 1 if you have `if_nametoindex`] )], [], $cares_all_includes)
AC_CHECK_DECL(getifaddrs, [AC_DEFINE([HAVE_GETIFADDRS], 1, [Define to 1 if you have `getifaddrs`] )], [], $cares_all_includes)
AC_CHECK_DECL(poll, [AC_DEFINE([HAVE_POLL], 1, [Define to 1 if you have `poll`] )], [], $cares_all_includes)
AC_CHECK_DECL(pipe, [AC_DEFINE([HAVE_PIPE], 1, [Define to 1 if you have `pipe`] )], [], $cares_all_includes)
AC_CHECK_DECL(pipe2, [AC_DEFINE([HAVE_PIPE2], 1, [Define to 1 if you have `pipe2`] )], [], $cares_all_includes)
AC_CHECK_DECL(kqueue, [AC_DEFINE([HAVE_KQUEUE], 1, [Define to 1 if you have `kqueue`] )], [], $cares_all_includes)
AC_CHECK_DECL(epoll_create1, [AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if you have `epoll_{create1,ctl,wait}`])], [], $cares_all_includes)
AC_CHECK_DECL(ConvertInterfaceIndexToLuid, [AC_DEFINE([HAVE_CONVERTINTERFACEINDEXTOLUID], 1, [Define to 1 if you have `ConvertInterfaceIndexToLuid`])], [], $cares_all_includes)
AC_CHECK_DECL(ConvertInterfaceLuidToNameA, [AC_DEFINE([HAVE_CONVERTINTERFACELUIDTONAMEA], 1, [Define to 1 if you have `ConvertInterfaceLuidToNameA`])], [], $cares_all_includes)
AC_CHECK_DECL(NotifyIpInterfaceChange, [AC_DEFINE([HAVE_NOTIFYIPINTERFACECHANGE], 1, [Define to 1 if you have `NotifyIpInterfaceChange`] )], [], $cares_all_includes)
AC_CHECK_DECL(RegisterWaitForSingleObject, [AC_DEFINE([HAVE_REGISTERWAITFORSINGLEOBJECT], 1, [Define to 1 if you have `RegisterWaitForSingleObject`])], [], $cares_all_includes)
AC_CHECK_DECL(__system_property_get, [AC_DEFINE([HAVE___SYSTEM_PROPERTY_GET], 1, [Define to 1 if you have `__system_property_get`] )], [], $cares_all_includes)
dnl ###############################################################################
dnl recv, recvfrom, send, getnameinfo, gethostname
dnl ARGUMENTS AND RETURN VALUES
if test "x$ac_cv_type_ssize_t" = "xyes" -a "x$ac_cv_type_socklen_t" = "xyes" -a "x$ac_cv_native_windows" != "xyes" ; then
recvfrom_type_retv="ssize_t"
recvfrom_type_arg3="size_t"
else
recvfrom_type_retv="int"
recvfrom_type_arg3="int"
fi
if test "x$ac_cv_type_SOCKET" = "xyes" ; then
dnl If the SOCKET type is defined, it uses socket ... should be windows only
recvfrom_type_arg1="SOCKET"
else
recvfrom_type_arg1="int"
fi
if test "x$ac_cv_type_socklen_t" = "xyes" ; then
recvfrom_type_arg6="socklen_t *"
getnameinfo_type_arg2="socklen_t"
getnameinfo_type_arg46="socklen_t"
else
recvfrom_type_arg6="int *"
getnameinfo_type_arg2="int"
getnameinfo_type_arg46="int"
fi
if test "x$ac_cv_native_windows" = "xyes" ; then
recv_type_arg2="char *"
else
recv_type_arg2="void *"
fi
dnl Functions are typically consistent so the equivalent fields map ... equivalently
recv_type_retv=${recvfrom_type_retv}
send_type_retv=${recvfrom_type_retv}
recv_type_arg1=${recvfrom_type_arg1}
recvfrom_type_arg2=${recv_type_arg2}
send_type_arg1=${recvfrom_type_arg1}
recv_type_arg3=${recvfrom_type_arg3}
send_type_arg3=${recvfrom_type_arg3}
gethostname_type_arg2=${recvfrom_type_arg3}
dnl These should always be "sane" values to use always
recvfrom_qual_arg5=
recvfrom_type_arg4=int
recvfrom_type_arg5="struct sockaddr *"
recv_type_arg4=int
getnameinfo_type_arg1="struct sockaddr *"
getnameinfo_type_arg7=int
send_type_arg2="const void *"
send_type_arg4=int
AC_DEFINE_UNQUOTED([RECVFROM_TYPE_RETV], [ ${recvfrom_type_retv} ], [ recvfrom() return value ])
AC_DEFINE_UNQUOTED([RECVFROM_TYPE_ARG1], [ ${recvfrom_type_arg1} ], [ recvfrom() arg1 type ])
AC_DEFINE_UNQUOTED([RECVFROM_TYPE_ARG2], [ ${recvfrom_type_arg2} ], [ recvfrom() arg2 type ])
AC_DEFINE_UNQUOTED([RECVFROM_TYPE_ARG3], [ ${recvfrom_type_arg3} ], [ recvfrom() arg3 type ])
AC_DEFINE_UNQUOTED([RECVFROM_TYPE_ARG4], [ ${recvfrom_type_arg4} ], [ recvfrom() arg4 type ])
AC_DEFINE_UNQUOTED([RECVFROM_TYPE_ARG5], [ ${recvfrom_type_arg5} ], [ recvfrom() arg5 type ])
AC_DEFINE_UNQUOTED([RECVFROM_QUAL_ARG5], [ ${recvfrom_qual_arg5}], [ recvfrom() arg5 qualifier])
AC_DEFINE_UNQUOTED([RECV_TYPE_RETV], [ ${recv_type_retv} ], [ recv() return value ])
AC_DEFINE_UNQUOTED([RECV_TYPE_ARG1], [ ${recv_type_arg1} ], [ recv() arg1 type ])
AC_DEFINE_UNQUOTED([RECV_TYPE_ARG2], [ ${recv_type_arg2} ], [ recv() arg2 type ])
AC_DEFINE_UNQUOTED([RECV_TYPE_ARG3], [ ${recv_type_arg3} ], [ recv() arg3 type ])
AC_DEFINE_UNQUOTED([RECV_TYPE_ARG4], [ ${recv_type_arg4} ], [ recv() arg4 type ])
AC_DEFINE_UNQUOTED([SEND_TYPE_RETV], [ ${send_type_retv} ], [ send() return value ])
AC_DEFINE_UNQUOTED([SEND_TYPE_ARG1], [ ${send_type_arg1} ], [ send() arg1 type ])
AC_DEFINE_UNQUOTED([SEND_TYPE_ARG2], [ ${send_type_arg2} ], [ send() arg2 type ])
AC_DEFINE_UNQUOTED([SEND_TYPE_ARG3], [ ${send_type_arg3} ], [ send() arg3 type ])
AC_DEFINE_UNQUOTED([SEND_TYPE_ARG4], [ ${send_type_arg4} ], [ send() arg4 type ])
AC_DEFINE_UNQUOTED([GETNAMEINFO_TYPE_ARG1], [ ${getnameinfo_type_arg1} ], [ getnameinfo() arg1 type ])
AC_DEFINE_UNQUOTED([GETNAMEINFO_TYPE_ARG2], [ ${getnameinfo_type_arg2} ], [ getnameinfo() arg2 type ])
AC_DEFINE_UNQUOTED([GETNAMEINFO_TYPE_ARG7], [ ${getnameinfo_type_arg7} ], [ getnameinfo() arg7 type ])
AC_DEFINE_UNQUOTED([GETNAMEINFO_TYPE_ARG46], [ ${getnameinfo_type_arg46} ], [ getnameinfo() arg4 and 6 type ])
AC_DEFINE_UNQUOTED([GETHOSTNAME_TYPE_ARG2], [ ${gethostname_type_arg2} ], [ gethostname() arg2 type ])
dnl ###############################################################################
if test "$ac_cv_have_decl_getservbyport_r" = "yes" ; then
AC_MSG_CHECKING([number of arguments for getservbyport_r()])
getservbyport_r_args=6
case $host_os in
solaris*)
getservbyport_r_args=5
;;
aix*|openbsd*)
getservbyport_r_args=4
;;
esac
AC_MSG_RESULT([$getservbyport_r_args])
AC_DEFINE_UNQUOTED([GETSERVBYPORT_R_ARGS], [ $getservbyport_r_args ], [ number of arguments for getservbyport_r() ])
fi
if test "$ac_cv_have_decl_getservbyname_r" = "yes" ; then
AC_MSG_CHECKING([number of arguments for getservbyname_r()])
getservbyname_r_args=6
case $host_os in
solaris*)
getservbyname_r_args=5
;;
aix*|openbsd*)
getservbyname_r_args=4
;;
esac
AC_DEFINE_UNQUOTED([GETSERVBYNAME_R_ARGS], [ $getservbyname_r_args ], [ number of arguments for getservbyname_r() ])
AC_MSG_RESULT([$getservbyname_r_args])
fi
AC_TYPE_SIZE_T
AC_CHECK_DECL(AF_INET6, [AC_DEFINE([HAVE_AF_INET6],1,[Define to 1 if you have AF_INET6])], [], $cares_all_includes)
AC_CHECK_DECL(PF_INET6, [AC_DEFINE([HAVE_PF_INET6],1,[Define to 1 if you have PF_INET6])], [], $cares_all_includes)
AC_CHECK_TYPES(struct in6_addr, [], [], $cares_all_includes)
AC_CHECK_TYPES(struct sockaddr_in6, [], [], $cares_all_includes)
AC_CHECK_TYPES(struct sockaddr_storage, [], [], $cares_all_includes)
AC_CHECK_TYPES(struct addrinfo, [], [], $cares_all_includes)
AC_CHECK_TYPES(struct timeval, [], [], $cares_all_includes)
AC_CHECK_MEMBERS(struct sockaddr_in6.sin6_scope_id, [], [], $cares_all_includes)
AC_CHECK_MEMBERS(struct addrinfo.ai_flags, [], [], $cares_all_includes)
AC_CHECK_DECL(FIONBIO, [], [], $cares_all_includes)
AC_CHECK_DECL(O_NONBLOCK, [], [], $cares_all_includes)
AC_CHECK_DECL(SO_NONBLOCK, [], [], $cares_all_includes)
AC_CHECK_DECL(MSG_NOSIGNAL, [], [], $cares_all_includes)
AC_CHECK_DECL(CLOCK_MONOTONIC, [], [], $cares_all_includes)
if test "$ac_cv_have_decl_CLOCK_MONOTONIC" = "yes" -a "$ac_cv_have_decl_clock_gettime" = "yes" ; then
AC_DEFINE([HAVE_CLOCK_GETTIME_MONOTONIC], [ 1 ], [ clock_gettime() with CLOCK_MONOTONIC support ])
fi
if test "$ac_cv_have_decl_FIONBIO" = "yes" -a "$ac_cv_have_decl_ioctl" = "yes" ; then
AC_DEFINE([HAVE_IOCTL_FIONBIO], [ 1 ], [ ioctl() with FIONBIO support ])
fi
if test "$ac_cv_have_decl_FIONBIO" = "yes" -a "$ac_cv_have_decl_ioctlsocket" = "yes" ; then
AC_DEFINE([HAVE_IOCTLSOCKET_FIONBIO], [ 1 ], [ ioctlsocket() with FIONBIO support ])
fi
if test "$ac_cv_have_decl_SO_NONBLOCK" = "yes" -a "$ac_cv_have_decl_setsockopt" = "yes" ; then
AC_DEFINE([HAVE_SETSOCKOPT_SO_NONBLOCK], [ 1 ], [ setsockopt() with SO_NONBLOCK support ])
fi
if test "$ac_cv_have_decl_O_NONBLOCK" = "yes" -a "$ac_cv_have_decl_fcntl" = "yes" ; then
AC_DEFINE([HAVE_FCNTL_O_NONBLOCK], [ 1 ], [ fcntl() with O_NONBLOCK support ])
fi
dnl ares_build.h.in specific defines
if test "x$ac_cv_header_sys_types_h" = "xyes" ; then
CARES_DEFINE_UNQUOTED([CARES_HAVE_SYS_TYPES_H],[1])
fi
if test "x$ac_cv_header_sys_socket_h" = "xyes" ; then
CARES_DEFINE_UNQUOTED([CARES_HAVE_SYS_SOCKET_H],[1])
fi
if test "x$ac_cv_header_sys_select_h" = "xyes" ; then
CARES_DEFINE_UNQUOTED([CARES_HAVE_SYS_SELECT_H],[1])
fi
if test "x$ac_cv_header_ws2tcpip_h" = "xyes" ; then
CARES_DEFINE_UNQUOTED([CARES_HAVE_WS2TCPIP_H],[1])
fi
if test "x$ac_cv_header_winsock2_h" = "xyes" ; then
CARES_DEFINE_UNQUOTED([CARES_HAVE_WINSOCK2_H],[1])
fi
if test "x$ac_cv_header_windows_h" = "xyes" ; then
CARES_DEFINE_UNQUOTED([CARES_HAVE_WINDOWS_H],[1])
fi
if test "x$ac_cv_header_arpa_nameser_h" = "xyes" ; then
CARES_DEFINE_UNQUOTED([CARES_HAVE_ARPA_NAMESER_H],[1])
fi
if test "x$ac_cv_header_arpa_nameser_compa_h" = "xyes" ; then
CARES_DEFINE_UNQUOTED([CARES_HAVE_ARPA_NAMESER_COMPA_H],[1])
fi
dnl ------------ THREADING --------------
dnl windows always supports threads, only check non-windows systems.
if test "${CARES_THREADS}" = "yes" -a "x${ac_cv_native_windows}" != "xyes" ; then
AX_PTHREAD([ ], [
AC_MSG_WARN([threads requested but not supported])
CARES_THREADS=no
])
if test "${CARES_THREADS}" = "yes" ; then
AC_CHECK_HEADERS([pthread.h pthread_np.h])
LIBS="$PTHREAD_LIBS $LIBS"
AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
CXX="$PTHREAD_CXX"
fi
fi
if test "${CARES_THREADS}" = "yes" ; then
AC_DEFINE([CARES_THREADS], [ 1 ], [Threading enabled])
fi
CARES_PRIVATE_LIBS="$LIBS"
AC_SUBST(CARES_PRIVATE_LIBS)
BUILD_SUBDIRS="include src docs"
dnl ******** TESTS *******
if test "x$build_tests" != "xno" -a "x$HAVE_CXX14" = "0" ; then
if test "x$build_tests" = "xmaybe" ; then
AC_MSG_WARN([cannot build tests without a CXX14 compiler])
build_tests=no
else
AC_MSG_ERROR([*** Building tests requires a CXX14 compiler])
fi
fi
if test "x$build_tests" != "xno" -a "x$cross_compiling" = "xyes" ; then
if test "x$build_tests" = "xmaybe" ; then
AC_MSG_WARN([cannot build tests when cross compiling])
build_tests=no
else
AC_MSG_ERROR([*** Tests not supported when cross compiling])
fi
fi
if test "x$build_tests" != "xno" ; then
PKG_CHECK_MODULES([GMOCK], [gmock], [ have_gmock=yes ], [ have_gmock=no ])
if test "x$have_gmock" = "xno" ; then
if test "x$build_tests" = "xmaybe" ; then
AC_MSG_WARN([gmock could not be found, not building tests])
build_tests=no
else
AC_MSG_ERROR([tests require gmock])
fi
fi
fi
if test "x$build_tests" != "xno" ; then
build_tests=yes
AX_CXX_COMPILE_STDCXX_14([noext],[mandatory])
if test "$ac_cv_native_windows" != "yes" ; then
AX_PTHREAD([ CARES_TEST_PTHREADS="yes" ], [ AC_MSG_ERROR([threading required for tests]) ])
fi
BUILD_SUBDIRS="${BUILD_SUBDIRS} test"
fi
AC_MSG_CHECKING([whether to build tests])
AC_MSG_RESULT([$build_tests])
AM_CONDITIONAL(BUILD_TESTS, test "x$build_tests" = "xyes")
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_CPPFLAGS)
AC_SUBST(PKGCONFIG_CFLAGS)
AC_SUBST(BUILD_SUBDIRS)
AC_CONFIG_FILES([Makefile
include/Makefile
src/Makefile
src/lib/Makefile
src/tools/Makefile
docs/Makefile
libcares.pc ])
AM_COND_IF([BUILD_TESTS],
[AC_CONFIG_FILES([test/Makefile])])
AC_OUTPUT