configure.ac 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983
  1. AC_PREREQ([2.60])
  2. AC_INIT([c-ares], [1.18.1],
  3. [c-ares mailing list: http://lists.haxx.se/listinfo/c-ares])
  4. CARES_VERSION_INFO="7:1:5"
  5. dnl This flag accepts an argument of the form current[:revision[:age]]. So,
  6. dnl passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
  7. dnl 1.
  8. dnl
  9. dnl If either revision or age are omitted, they default to 0. Also note that age
  10. dnl must be less than or equal to the current interface number.
  11. dnl
  12. dnl Here are a set of rules to help you update your library version information:
  13. dnl
  14. dnl 1.Start with version information of 0:0:0 for each libtool library.
  15. dnl
  16. dnl 2.Update the version information only immediately before a public release of
  17. dnl your software. More frequent updates are unnecessary, and only guarantee
  18. dnl that the current interface number gets larger faster.
  19. dnl
  20. dnl 3.If the library source code has changed at all since the last update, then
  21. dnl increment revision (c:r+1:a)
  22. dnl
  23. dnl 4.If any interfaces have been added, removed, or changed since the last
  24. dnl update, increment current, and set revision to 0. (c+1:r=0:a)
  25. dnl
  26. dnl 5.If any interfaces have been added since the last public release, then
  27. dnl increment age. (c:r:a+1)
  28. dnl
  29. dnl 6.If any interfaces have been removed since the last public release, then
  30. dnl set age to 0. (c:r:a=0)
  31. dnl
  32. AC_SUBST([CARES_VERSION_INFO])
  33. AC_CONFIG_SRCDIR([src/lib/ares_ipv6.h])
  34. AC_CONFIG_HEADERS([src/lib/ares_config.h include/ares_build.h])
  35. AC_CONFIG_MACRO_DIR([m4])
  36. AM_MAINTAINER_MODE
  37. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  38. AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX_11])
  39. CARES_CHECK_OPTION_DEBUG
  40. CARES_CHECK_OPTION_OPTIMIZE
  41. CARES_CHECK_OPTION_WARNINGS
  42. CARES_CHECK_OPTION_WERROR
  43. CARES_CHECK_OPTION_SYMBOL_HIDING
  44. CARES_CHECK_OPTION_EXPOSE_STATICS
  45. XC_CHECK_PATH_SEPARATOR
  46. dnl SED is mandatory for configure process and libtool.
  47. dnl Set it now, allowing it to be changed later.
  48. AC_PATH_PROG([SED], [sed], [not_found],
  49. [$PATH:/usr/bin:/usr/local/bin])
  50. if test -z "$SED" || test "$SED" = "not_found"; then
  51. AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
  52. fi
  53. AC_SUBST([SED])
  54. dnl GREP is mandatory for configure process and libtool.
  55. dnl Set it now, allowing it to be changed later.
  56. AC_PATH_PROG([GREP], [grep], [not_found],
  57. [$PATH:/usr/bin:/usr/local/bin])
  58. if test -z "$GREP" || test "$GREP" = "not_found"; then
  59. AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
  60. fi
  61. AC_SUBST([GREP])
  62. dnl EGREP is mandatory for configure process and libtool.
  63. dnl Set it now, allowing it to be changed later.
  64. if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
  65. AC_MSG_CHECKING([for egrep])
  66. EGREP="$GREP -E"
  67. AC_MSG_RESULT([$EGREP])
  68. else
  69. AC_PATH_PROG([EGREP], [egrep], [not_found],
  70. [$PATH:/usr/bin:/usr/local/bin])
  71. fi
  72. if test -z "$EGREP" || test "$EGREP" = "not_found"; then
  73. AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
  74. fi
  75. AC_SUBST([EGREP])
  76. dnl AR is mandatory for configure process and libtool.
  77. dnl This is target dependent, so check it as a tool.
  78. if test -z "$AR"; then
  79. dnl allow it to be overridden
  80. AC_PATH_TOOL([AR], [ar], [not_found],
  81. [$PATH:/usr/bin:/usr/local/bin])
  82. if test -z "$AR" || test "$AR" = "not_found"; then
  83. AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
  84. fi
  85. fi
  86. AC_SUBST([AR])
  87. AX_CODE_COVERAGE
  88. dnl
  89. dnl Detect the canonical host and target build environment
  90. dnl
  91. AC_CANONICAL_HOST
  92. dnl Get system canonical name
  93. AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
  94. XC_CHECK_PROG_CC
  95. AX_CXX_COMPILE_STDCXX_11([noext],[optional])
  96. XC_AUTOMAKE
  97. dnl This defines _ALL_SOURCE for AIX
  98. CARES_CHECK_AIX_ALL_SOURCE
  99. dnl Our configure and build reentrant settings
  100. CARES_CONFIGURE_THREAD_SAFE
  101. CARES_CONFIGURE_REENTRANT
  102. dnl check for how to do large files
  103. AC_SYS_LARGEFILE
  104. case $host_os in
  105. solaris*)
  106. AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
  107. ;;
  108. esac
  109. XC_LIBTOOL
  110. #
  111. # Automake conditionals based on libtool related checks
  112. #
  113. AM_CONDITIONAL([CARES_LT_SHLIB_USE_VERSION_INFO],
  114. [test "x$xc_lt_shlib_use_version_info" = 'xyes'])
  115. AM_CONDITIONAL([CARES_LT_SHLIB_USE_NO_UNDEFINED],
  116. [test "x$xc_lt_shlib_use_no_undefined" = 'xyes'])
  117. AM_CONDITIONAL([CARES_LT_SHLIB_USE_MIMPURE_TEXT],
  118. [test "x$xc_lt_shlib_use_mimpure_text" = 'xyes'])
  119. #
  120. # Due to libtool and automake machinery limitations of not allowing
  121. # specifying separate CPPFLAGS or CFLAGS when compiling objects for
  122. # inclusion of these in shared or static libraries, we are forced to
  123. # build using separate configure runs for shared and static libraries
  124. # on systems where different CPPFLAGS or CFLAGS are mandatory in order
  125. # to compile objects for each kind of library. Notice that relying on
  126. # the '-DPIC' CFLAG that libtool provides is not valid given that the
  127. # user might for example choose to build static libraries with PIC.
  128. #
  129. #
  130. # Make our Makefile.am files use the staticlib CPPFLAG only when strictly
  131. # targeting a static library and not building its shared counterpart.
  132. #
  133. AM_CONDITIONAL([USE_CPPFLAG_CARES_STATICLIB],
  134. [test "x$xc_lt_build_static_only" = 'xyes'])
  135. #
  136. # Make staticlib CPPFLAG variable and its definition visible in output
  137. # files unconditionally, providing an empty definition unless strictly
  138. # targeting a static library and not building its shared counterpart.
  139. #
  140. CPPFLAG_CARES_STATICLIB=
  141. if test "x$xc_lt_build_static_only" = 'xyes'; then
  142. CPPFLAG_CARES_STATICLIB='-DCARES_STATICLIB'
  143. fi
  144. AC_SUBST([CPPFLAG_CARES_STATICLIB])
  145. dnl **********************************************************************
  146. dnl platform/compiler/architecture specific checks/flags
  147. dnl **********************************************************************
  148. CARES_CHECK_COMPILER
  149. CARES_SET_COMPILER_BASIC_OPTS
  150. CARES_SET_COMPILER_DEBUG_OPTS
  151. CARES_SET_COMPILER_OPTIMIZE_OPTS
  152. CARES_SET_COMPILER_WARNING_OPTS
  153. if test "$compiler_id" = "INTEL_UNIX_C"; then
  154. #
  155. if test "$compiler_num" -ge "1000"; then
  156. dnl icc 10.X or later
  157. CFLAGS="$CFLAGS -shared-intel"
  158. elif test "$compiler_num" -ge "900"; then
  159. dnl icc 9.X specific
  160. CFLAGS="$CFLAGS -i-dynamic"
  161. fi
  162. #
  163. fi
  164. CARES_CHECK_COMPILER_HALT_ON_ERROR
  165. CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
  166. CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH
  167. CARES_CHECK_COMPILER_SYMBOL_HIDING
  168. dnl **********************************************************************
  169. dnl Compilation based checks should not be done before this point.
  170. dnl **********************************************************************
  171. dnl **********************************************************************
  172. dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
  173. dnl and ws2tcpip.h take precedence over any other further checks which
  174. dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
  175. dnl this specific header files. And do them before its results are used.
  176. dnl **********************************************************************
  177. CURL_CHECK_HEADER_WINDOWS
  178. CURL_CHECK_NATIVE_WINDOWS
  179. case X-"$ac_cv_native_windows" in
  180. X-yes)
  181. CURL_CHECK_HEADER_WINSOCK
  182. CURL_CHECK_HEADER_WINSOCK2
  183. CURL_CHECK_HEADER_WS2TCPIP
  184. CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600"
  185. ;;
  186. *)
  187. ac_cv_header_winsock_h="no"
  188. ac_cv_header_winsock2_h="no"
  189. ac_cv_header_ws2tcpip_h="no"
  190. ;;
  191. esac
  192. dnl **********************************************************************
  193. dnl Checks for libraries.
  194. dnl **********************************************************************
  195. CARES_CHECK_LIB_XNET
  196. dnl gethostbyname without lib or in the nsl lib?
  197. AC_CHECK_FUNC(gethostbyname,
  198. [HAVE_GETHOSTBYNAME="1"
  199. ],
  200. [ AC_CHECK_LIB(nsl, gethostbyname,
  201. [HAVE_GETHOSTBYNAME="1"
  202. LIBS="$LIBS -lnsl"
  203. ])
  204. ])
  205. if test "$HAVE_GETHOSTBYNAME" != "1"
  206. then
  207. dnl gethostbyname in the socket lib?
  208. AC_CHECK_LIB(socket, gethostbyname,
  209. [HAVE_GETHOSTBYNAME="1"
  210. LIBS="$LIBS -lsocket"
  211. ])
  212. fi
  213. dnl At least one system has been identified to require BOTH nsl and socket
  214. dnl libs at the same time to link properly.
  215. if test "$HAVE_GETHOSTBYNAME" != "1"
  216. then
  217. AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
  218. my_ac_save_LIBS=$LIBS
  219. LIBS="-lnsl -lsocket $LIBS"
  220. AC_LINK_IFELSE([
  221. AC_LANG_PROGRAM([[
  222. ]],[[
  223. gethostbyname();
  224. ]])
  225. ],[
  226. AC_MSG_RESULT([yes])
  227. HAVE_GETHOSTBYNAME="1"
  228. ],[
  229. AC_MSG_RESULT([no])
  230. LIBS=$my_ac_save_LIBS
  231. ])
  232. fi
  233. if test "$HAVE_GETHOSTBYNAME" != "1"
  234. then
  235. dnl This is for winsock systems
  236. if test "$ac_cv_header_windows_h" = "yes"; then
  237. if test "$ac_cv_header_winsock_h" = "yes"; then
  238. case $host in
  239. *-*-mingw32ce*)
  240. winsock_LIB="-lwinsock"
  241. ;;
  242. *)
  243. winsock_LIB="-lwsock32"
  244. ;;
  245. esac
  246. fi
  247. if test "$ac_cv_header_winsock2_h" = "yes"; then
  248. winsock_LIB="-lws2_32"
  249. fi
  250. if test ! -z "$winsock_LIB"; then
  251. my_ac_save_LIBS=$LIBS
  252. LIBS="$winsock_LIB $LIBS"
  253. AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
  254. AC_LINK_IFELSE([
  255. AC_LANG_PROGRAM([[
  256. #ifdef HAVE_WINDOWS_H
  257. #ifndef WIN32_LEAN_AND_MEAN
  258. #define WIN32_LEAN_AND_MEAN
  259. #endif
  260. #include <windows.h>
  261. #ifdef HAVE_WINSOCK2_H
  262. #include <winsock2.h>
  263. #else
  264. #ifdef HAVE_WINSOCK_H
  265. #include <winsock.h>
  266. #endif
  267. #endif
  268. #endif
  269. ]],[[
  270. gethostbyname("www.dummysite.com");
  271. ]])
  272. ],[
  273. AC_MSG_RESULT([yes])
  274. HAVE_GETHOSTBYNAME="1"
  275. ],[
  276. AC_MSG_RESULT([no])
  277. winsock_LIB=""
  278. LIBS=$my_ac_save_LIBS
  279. ])
  280. fi
  281. fi
  282. fi
  283. if test "$HAVE_GETHOSTBYNAME" != "1"
  284. then
  285. dnl This is for Minix 3.1
  286. AC_MSG_CHECKING([for gethostbyname for Minix 3])
  287. AC_LINK_IFELSE([
  288. AC_LANG_PROGRAM([[
  289. /* Older Minix versions may need <net/gen/netdb.h> here instead */
  290. #include <netdb.h>
  291. ]],[[
  292. gethostbyname("www.dummysite.com");
  293. ]])
  294. ],[
  295. AC_MSG_RESULT([yes])
  296. HAVE_GETHOSTBYNAME="1"
  297. ],[
  298. AC_MSG_RESULT([no])
  299. ])
  300. fi
  301. if test "$HAVE_GETHOSTBYNAME" != "1"
  302. then
  303. dnl This is for eCos with a stubbed DNS implementation
  304. AC_MSG_CHECKING([for gethostbyname for eCos])
  305. AC_LINK_IFELSE([
  306. AC_LANG_PROGRAM([[
  307. #include <stdio.h>
  308. #include <netdb.h>
  309. ]],[[
  310. gethostbyname("www.dummysite.com");
  311. ]])
  312. ],[
  313. AC_MSG_RESULT([yes])
  314. HAVE_GETHOSTBYNAME="1"
  315. ],[
  316. AC_MSG_RESULT([no])
  317. ])
  318. fi
  319. if test "$HAVE_GETHOSTBYNAME" != "1"
  320. then
  321. dnl gethostbyname in the net lib - for BeOS
  322. AC_CHECK_LIB(net, gethostbyname,
  323. [HAVE_GETHOSTBYNAME="1"
  324. LIBS="$LIBS -lnet"
  325. ])
  326. fi
  327. if test "$HAVE_GETHOSTBYNAME" != "1"; then
  328. AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
  329. fi
  330. dnl resolv lib for Apple (MacOS and iOS)
  331. AS_IF([test "x$host_vendor" = "xapple"], [
  332. AC_SEARCH_LIBS([res_servicename], [resolv], [
  333. AC_DEFINE([CARES_USE_LIBRESOLV], [1], [Use resolver library to configure cares])
  334. ], [
  335. AC_MSG_ERROR([Unable to find libresolv which is required for iPhone targets])
  336. ])
  337. ])
  338. dnl resolv lib for z/OS
  339. AS_IF([test "x$host_vendor" = "xibm" -a "x$host_os" = "xopenedition" ], [
  340. AC_SEARCH_LIBS([res_init], [resolv], [
  341. AC_DEFINE([CARES_USE_LIBRESOLV], [1], [Use resolver library to configure cares])
  342. ], [
  343. AC_MSG_ERROR([Unable to find libresolv which is required for z/OS])
  344. ])
  345. ])
  346. dnl resolve lib?
  347. AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
  348. if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
  349. AC_CHECK_LIB(resolve, strcasecmp,
  350. [LIBS="-lresolve $LIBS"],
  351. ,
  352. -lnsl)
  353. fi
  354. ac_cv_func_strcasecmp="no"
  355. dnl Windows builds require linking to iphlpapi
  356. if test "$ac_cv_header_winsock2_h" = "yes"; then
  357. LIBS="$LIBS -liphlpapi"
  358. fi
  359. CARES_CHECK_LIBS_CONNECT
  360. dnl iOS 10?
  361. AS_IF([test "x$host_vendor" = "xapple"], [
  362. AC_MSG_CHECKING([for iOS minimum version 10 or later])
  363. AC_COMPILE_IFELSE([
  364. AC_LANG_PROGRAM([[
  365. #include <stdio.h>
  366. #include <TargetConditionals.h>
  367. ]], [[
  368. #if TARGET_OS_IPHONE == 0 || __IPHONE_OS_VERSION_MIN_REQUIRED < 100000
  369. #error Not iOS 10 or later
  370. #endif
  371. return 0;
  372. ]])
  373. ],[
  374. AC_MSG_RESULT([yes])
  375. ac_cv_ios_10="yes"
  376. ],[
  377. AC_MSG_RESULT([no])
  378. ])
  379. ])
  380. dnl macOS 10.12?
  381. AS_IF([test "x$host_vendor" = "xapple"], [
  382. AC_MSG_CHECKING([for macOS minimum version 10.12 or later])
  383. AC_COMPILE_IFELSE([
  384. AC_LANG_PROGRAM([[
  385. #include <stdio.h>
  386. #include <TargetConditionals.h>
  387. ]], [[
  388. #ifndef MAC_OS_X_VERSION_10_12
  389. # define MAC_OS_X_VERSION_10_12 101200
  390. #endif
  391. #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
  392. #error Not macOS 10.12 or later
  393. #endif
  394. return 0;
  395. ]])
  396. ],[
  397. AC_MSG_RESULT([yes])
  398. ac_cv_macos_10_12="yes"
  399. ],[
  400. AC_MSG_RESULT([no])
  401. ])
  402. ])
  403. dnl **********************************************************************
  404. dnl In case that function clock_gettime with monotonic timer is available,
  405. dnl check for additional required libraries.
  406. dnl **********************************************************************
  407. dnl Xcode 8 bug: iOS when targeting less than 10, or macOS when targeting less than 10.12 will
  408. dnl say clock_gettime exists, it is a weak symbol that only exists in iOS 10 or macOS 10.12 and will
  409. dnl cause a crash at runtime when running on older versions. Skip finding CLOCK_MONOTONIC on older
  410. dnl Apple OS's.
  411. if test "x$host_vendor" != "xapple" || test "x$ac_cv_ios_10" = "xyes" || test "x$ac_cv_macos_10_12" = "xyes"; then
  412. CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  413. fi
  414. AC_MSG_CHECKING([whether to use libgcc])
  415. AC_ARG_ENABLE(libgcc,
  416. AS_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
  417. [ case "$enableval" in
  418. yes)
  419. LIBS="$LIBS -lgcc"
  420. AC_MSG_RESULT(yes)
  421. ;;
  422. *) AC_MSG_RESULT(no)
  423. ;;
  424. esac ],
  425. AC_MSG_RESULT(no)
  426. )
  427. dnl Let's hope this split URL remains working:
  428. dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
  429. dnl genprogc/thread_quick_ref.htm
  430. dnl **********************************************************************
  431. dnl Back to "normal" configuring
  432. dnl **********************************************************************
  433. dnl Checks for header files.
  434. STDC_HEADERS
  435. AC_PROG_EGREP
  436. CURL_CHECK_HEADER_MALLOC
  437. CURL_CHECK_HEADER_MEMORY
  438. dnl check for a few basic system headers we need
  439. AC_CHECK_HEADERS(
  440. sys/types.h \
  441. sys/time.h \
  442. sys/select.h \
  443. sys/socket.h \
  444. sys/ioctl.h \
  445. sys/param.h \
  446. sys/uio.h \
  447. assert.h \
  448. netdb.h \
  449. netinet/in.h \
  450. netinet/tcp.h \
  451. net/if.h \
  452. errno.h \
  453. socket.h \
  454. strings.h \
  455. stdbool.h \
  456. time.h \
  457. limits.h \
  458. arpa/nameser.h \
  459. arpa/nameser_compat.h \
  460. arpa/inet.h,
  461. dnl to do if not found
  462. [],
  463. dnl to do if found
  464. [],
  465. dnl default includes
  466. [
  467. #ifdef HAVE_SYS_TYPES_H
  468. #include <sys/types.h>
  469. #endif
  470. #ifdef HAVE_SYS_TIME_H
  471. #include <sys/time.h>
  472. #endif
  473. dnl We do this default-include simply to make sure that the nameser_compat.h
  474. dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
  475. dnl (and others?) is not designed to allow this.
  476. #ifdef HAVE_ARPA_NAMESER_H
  477. #include <arpa/nameser.h>
  478. #endif
  479. dnl *Sigh* these are needed in order for net/if.h to get properly detected.
  480. #ifdef HAVE_SYS_SOCKET_H
  481. #include <sys/socket.h>
  482. #endif
  483. #ifdef HAVE_NETINET_IN_H
  484. #include <netinet/in.h>
  485. #endif
  486. ]
  487. )
  488. dnl Test and set CARES_HAVE_ARPA_NAMESER_H / CARES_HAVE_ARPA_NAMESER_COMPAT_H
  489. AC_CHECK_DECL([HAVE_ARPA_NAMESER_H],
  490. [
  491. CARES_DEFINE_UNQUOTED([CARES_HAVE_ARPA_NAMESER_H])
  492. ],
  493. []
  494. )
  495. AC_CHECK_DECL([HAVE_ARPA_NAMESER_COMPAT_H],
  496. [
  497. CARES_DEFINE_UNQUOTED([CARES_HAVE_ARPA_NAMESER_COMPAT_H])
  498. ],
  499. []
  500. )
  501. dnl Checks for typedefs, structures, and compiler characteristics.
  502. AC_C_CONST
  503. AC_TYPE_SIZE_T
  504. m4_warn([obsolete],
  505. [Update your code to rely only on HAVE_SYS_TIME_H,
  506. then remove this warning and the obsolete code below it.
  507. All current systems provide time.h; it need not be checked for.
  508. Not all systems provide sys/time.h, but those that do, all allow
  509. you to include it and time.h simultaneously.])dnl
  510. AC_CHECK_HEADERS_ONCE([sys/time.h])
  511. # Obsolete code to be removed.
  512. if test $ac_cv_header_sys_time_h = yes; then
  513. AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both <sys/time.h>
  514. and <time.h>. This macro is obsolete.])
  515. fi
  516. # End of obsolete code.
  517. CURL_CHECK_STRUCT_TIMEVAL
  518. AC_CHECK_TYPE(long long,
  519. [AC_DEFINE(HAVE_LONGLONG, 1,
  520. [Define to 1 if the compiler supports the 'long long' data type.])]
  521. longlong="yes"
  522. )
  523. if test "xyes" = "x$longlong"; then
  524. AC_MSG_CHECKING([if numberLL works])
  525. AC_COMPILE_IFELSE([
  526. AC_LANG_PROGRAM([[
  527. ]],[[
  528. long long val = 1000LL;
  529. ]])
  530. ],[
  531. AC_MSG_RESULT([yes])
  532. AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
  533. ],[
  534. AC_MSG_RESULT([no])
  535. ])
  536. fi
  537. # check for ssize_t
  538. AC_CHECK_TYPE(ssize_t, [ CARES_TYPEOF_ARES_SSIZE_T=ssize_t ],
  539. [ CARES_TYPEOF_ARES_SSIZE_T=int ])
  540. AC_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SSIZE_T], ${CARES_TYPEOF_ARES_SSIZE_T},
  541. [the signed version of size_t])
  542. # check for bool type
  543. AC_CHECK_TYPE([bool],[
  544. AC_DEFINE(HAVE_BOOL_T, 1,
  545. [Define to 1 if bool is an available type.])
  546. ], ,[
  547. #ifdef HAVE_SYS_TYPES_H
  548. #include <sys/types.h>
  549. #endif
  550. #ifdef HAVE_STDBOOL_H
  551. #include <stdbool.h>
  552. #endif
  553. ])
  554. CARES_CONFIGURE_ARES_SOCKLEN_T
  555. TYPE_IN_ADDR_T
  556. TYPE_SOCKADDR_STORAGE
  557. TYPE_SIG_ATOMIC_T
  558. m4_warn([obsolete],
  559. [your code may safely assume C89 semantics that RETSIGTYPE is void.
  560. Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl
  561. AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE(
  562. [AC_LANG_PROGRAM([#include <sys/types.h>
  563. #include <signal.h>
  564. ],
  565. [return *(signal (0, 0)) (0) == 1;])],
  566. [ac_cv_type_signal=int],
  567. [ac_cv_type_signal=void])])
  568. AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers
  569. (`int' or `void').])
  570. CURL_CHECK_FUNC_RECV
  571. CURL_CHECK_FUNC_RECVFROM
  572. CURL_CHECK_FUNC_SEND
  573. CURL_CHECK_MSG_NOSIGNAL
  574. CARES_CHECK_FUNC_CLOSESOCKET
  575. CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
  576. CARES_CHECK_FUNC_CONNECT
  577. CARES_CHECK_FUNC_FCNTL
  578. CARES_CHECK_FUNC_FREEADDRINFO
  579. CARES_CHECK_FUNC_GETADDRINFO
  580. CARES_CHECK_FUNC_GETENV
  581. CARES_CHECK_FUNC_GETHOSTBYADDR
  582. CARES_CHECK_FUNC_GETHOSTBYNAME
  583. CARES_CHECK_FUNC_GETHOSTNAME
  584. CARES_CHECK_FUNC_GETSERVBYPORT_R
  585. CARES_CHECK_FUNC_INET_NET_PTON
  586. CARES_CHECK_FUNC_INET_NTOP
  587. CARES_CHECK_FUNC_INET_PTON
  588. CARES_CHECK_FUNC_IOCTL
  589. CARES_CHECK_FUNC_IOCTLSOCKET
  590. CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
  591. CARES_CHECK_FUNC_SETSOCKOPT
  592. CARES_CHECK_FUNC_SOCKET
  593. CARES_CHECK_FUNC_STRCASECMP
  594. CARES_CHECK_FUNC_STRCMPI
  595. CARES_CHECK_FUNC_STRDUP
  596. CARES_CHECK_FUNC_STRICMP
  597. CARES_CHECK_FUNC_STRNCASECMP
  598. CARES_CHECK_FUNC_STRNCMPI
  599. CARES_CHECK_FUNC_STRNICMP
  600. CARES_CHECK_FUNC_WRITEV
  601. dnl check for AF_INET6
  602. CARES_CHECK_CONSTANT(
  603. [
  604. #undef inline
  605. #ifdef HAVE_WINDOWS_H
  606. #ifndef WIN32_LEAN_AND_MEAN
  607. #define WIN32_LEAN_AND_MEAN
  608. #endif
  609. #include <windows.h>
  610. #ifdef HAVE_WINSOCK2_H
  611. #include <winsock2.h>
  612. #endif
  613. #else
  614. #ifdef HAVE_SYS_TYPES_H
  615. #include <sys/types.h>
  616. #endif
  617. #ifdef HAVE_SYS_SOCKET_H
  618. #include <sys/socket.h>
  619. #endif
  620. #endif
  621. ], [PF_INET6],
  622. AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
  623. )
  624. dnl check for PF_INET6
  625. CARES_CHECK_CONSTANT(
  626. [
  627. #undef inline
  628. #ifdef HAVE_WINDOWS_H
  629. #ifndef WIN32_LEAN_AND_MEAN
  630. #define WIN32_LEAN_AND_MEAN
  631. #endif
  632. #include <windows.h>
  633. #ifdef HAVE_WINSOCK2_H
  634. #include <winsock2.h>
  635. #endif
  636. #else
  637. #ifdef HAVE_SYS_TYPES_H
  638. #include <sys/types.h>
  639. #endif
  640. #ifdef HAVE_SYS_SOCKET_H
  641. #include <sys/socket.h>
  642. #endif
  643. #endif
  644. ], [AF_INET6],
  645. AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
  646. )
  647. dnl check for the in6_addr structure
  648. CARES_CHECK_STRUCT(
  649. [
  650. #undef inline
  651. #ifdef HAVE_WINDOWS_H
  652. #ifndef WIN32_LEAN_AND_MEAN
  653. #define WIN32_LEAN_AND_MEAN
  654. #endif
  655. #include <windows.h>
  656. #ifdef HAVE_WINSOCK2_H
  657. #include <winsock2.h>
  658. #ifdef HAVE_WS2TCPIP_H
  659. #include <ws2tcpip.h>
  660. #endif
  661. #endif
  662. #else
  663. #ifdef HAVE_SYS_TYPES_H
  664. #include <sys/types.h>
  665. #endif
  666. #ifdef HAVE_NETINET_IN_H
  667. #include <netinet/in.h>
  668. #endif
  669. #endif
  670. ], [in6_addr],
  671. AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
  672. )
  673. dnl check for the sockaddr_in6 structure
  674. CARES_CHECK_STRUCT(
  675. [
  676. #undef inline
  677. #ifdef HAVE_WINDOWS_H
  678. #ifndef WIN32_LEAN_AND_MEAN
  679. #define WIN32_LEAN_AND_MEAN
  680. #endif
  681. #include <windows.h>
  682. #ifdef HAVE_WINSOCK2_H
  683. #include <winsock2.h>
  684. #ifdef HAVE_WS2TCPIP_H
  685. #include <ws2tcpip.h>
  686. #endif
  687. #endif
  688. #else
  689. #ifdef HAVE_SYS_TYPES_H
  690. #include <sys/types.h>
  691. #endif
  692. #ifdef HAVE_NETINET_IN_H
  693. #include <netinet/in.h>
  694. #endif
  695. #endif
  696. ], [sockaddr_in6],
  697. AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
  698. [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
  699. )
  700. AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
  701. AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
  702. [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
  703. , ,
  704. [
  705. #undef inline
  706. #ifdef HAVE_WINDOWS_H
  707. #ifndef WIN32_LEAN_AND_MEAN
  708. #define WIN32_LEAN_AND_MEAN
  709. #endif
  710. #include <windows.h>
  711. #ifdef HAVE_WINSOCK2_H
  712. #include <winsock2.h>
  713. #ifdef HAVE_WS2TCPIP_H
  714. #include <ws2tcpip.h>
  715. #endif
  716. #endif
  717. #else
  718. #ifdef HAVE_SYS_TYPES_H
  719. #include <sys/types.h>
  720. #endif
  721. #ifdef HAVE_NETINET_IN_H
  722. #include <netinet/in.h>
  723. #endif
  724. #endif
  725. ])
  726. dnl check for the addrinfo structure
  727. AC_CHECK_MEMBER(struct addrinfo.ai_flags,
  728. AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
  729. [Define to 1 if you have struct addrinfo.]),,
  730. [
  731. #undef inline
  732. #ifdef HAVE_WINDOWS_H
  733. #ifndef WIN32_LEAN_AND_MEAN
  734. #define WIN32_LEAN_AND_MEAN
  735. #endif
  736. #include <windows.h>
  737. #ifdef HAVE_WINSOCK2_H
  738. #include <winsock2.h>
  739. #ifdef HAVE_WS2TCPIP_H
  740. #include <ws2tcpip.h>
  741. #endif
  742. #endif
  743. #else
  744. #ifdef HAVE_SYS_TYPES_H
  745. #include <sys/types.h>
  746. #endif
  747. #ifdef HAVE_NETINET_IN_H
  748. #include <netinet/in.h>
  749. #endif
  750. #ifdef HAVE_SYS_SOCKET_H
  751. #include <sys/socket.h>
  752. #endif
  753. #ifdef HAVE_NETDB_H
  754. #include <netdb.h>
  755. #endif
  756. #endif
  757. ]
  758. )
  759. AC_CHECK_FUNCS([bitncmp \
  760. gettimeofday \
  761. if_indextoname
  762. ],[
  763. ],[
  764. func="$ac_func"
  765. AC_MSG_CHECKING([deeper for $func])
  766. AC_LINK_IFELSE([
  767. AC_LANG_PROGRAM([[
  768. ]],[[
  769. $func ();
  770. ]])
  771. ],[
  772. AC_MSG_RESULT([yes])
  773. eval "ac_cv_func_$func=yes"
  774. AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
  775. [Define to 1 if you have the $func function.])
  776. ],[
  777. AC_MSG_RESULT([but still no])
  778. ])
  779. ])
  780. dnl Android. Some variants like arm64 may no longer have __system_property_get
  781. dnl in libc, but they are defined in the headers. Perform a link check.
  782. AC_CHECK_FUNC([__system_property_get], [
  783. AC_DEFINE([HAVE___SYSTEM_PROPERTY_GET], [1], [Define if __system_property_get exists.])
  784. ])
  785. dnl Check if the getnameinfo function is available
  786. dnl and get the types of five of its arguments.
  787. CURL_CHECK_FUNC_GETNAMEINFO
  788. AC_C_BIGENDIAN(
  789. [AC_DEFINE(ARES_BIG_ENDIAN, 1,
  790. [define this if ares is built for a big endian system])],
  791. ,
  792. [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
  793. )
  794. dnl Check for user-specified random device
  795. AC_ARG_WITH(random,
  796. AS_HELP_STRING([--with-random=FILE],
  797. [read randomness from FILE (default=/dev/urandom)]),
  798. [ CARES_RANDOM_FILE="$withval" ],
  799. [
  800. dnl Check for random device. If we're cross compiling, we can't
  801. dnl check, and it's better to assume it doesn't exist than it is
  802. dnl to fail on AC_CHECK_FILE or later.
  803. if test "$cross_compiling" = "no"; then
  804. AC_CHECK_FILE("/dev/urandom", [ CARES_RANDOM_FILE="/dev/urandom"] )
  805. else
  806. AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
  807. fi
  808. ]
  809. )
  810. if test -n "$CARES_RANDOM_FILE" && test X"$CARES_RANDOM_FILE" != Xno ; then
  811. AC_SUBST(CARES_RANDOM_FILE)
  812. AC_DEFINE_UNQUOTED(CARES_RANDOM_FILE, "$CARES_RANDOM_FILE",
  813. [a suitable file/device to read random data from])
  814. fi
  815. CARES_CHECK_OPTION_NONBLOCKING
  816. CARES_CHECK_NONBLOCKING_SOCKET
  817. CARES_CONFIGURE_SYMBOL_HIDING
  818. CARES_PRIVATE_LIBS="$LIBS"
  819. AC_SUBST(CARES_PRIVATE_LIBS)
  820. CARES_CFLAG_EXTRAS=""
  821. if test X"$want_werror" = Xyes; then
  822. CARES_CFLAG_EXTRAS="-Werror"
  823. fi
  824. AC_SUBST(CARES_CFLAG_EXTRAS)
  825. dnl squeeze whitespace out of some variables
  826. squeeze CFLAGS
  827. squeeze CPPFLAGS
  828. squeeze DEFS
  829. squeeze LDFLAGS
  830. squeeze LIBS
  831. squeeze CARES_PRIVATE_LIBS
  832. XC_CHECK_BUILD_FLAGS
  833. AC_MSG_CHECKING([whether to build tests])
  834. AC_ARG_ENABLE(tests,
  835. AS_HELP_STRING([--enable-tests], [build test suite]),
  836. [ build_tests="$enableval" ],
  837. [ if test "x$HAVE_CXX11" = "x1" && test "x$cross_compiling" = "xno" ; then
  838. build_tests="yes"
  839. else
  840. build_tests="no"
  841. fi
  842. ]
  843. )
  844. if test "x$build_tests" = "xyes" ; then
  845. if test "x$HAVE_CXX11" = "0" ; then
  846. AC_MSG_ERROR([*** Building tests requires a CXX11 compiler])
  847. fi
  848. if test "x$cross_compiling" = "xyes" ; then
  849. AC_MSG_ERROR([*** Tests not supported when cross compiling])
  850. fi
  851. fi
  852. AC_MSG_RESULT([$build_tests])
  853. BUILD_SUBDIRS="include src docs"
  854. if test "x$build_tests" = "xyes" ; then
  855. AC_CONFIG_SUBDIRS([test])
  856. BUILD_SUBDIRS="${BUILD_SUBDIRS} test"
  857. fi
  858. AC_SUBST(BUILD_SUBDIRS)
  859. AC_CONFIG_FILES([Makefile \
  860. include/Makefile \
  861. src/Makefile \
  862. src/lib/Makefile \
  863. src/tools/Makefile \
  864. docs/Makefile \
  865. libcares.pc ])
  866. AC_OUTPUT
  867. XC_AMEND_DISTCLEAN(['.'])