configure.ac 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  1. AC_PREREQ(2.57)
  2. dnl Version not hardcoded here. Fetched later from ares_version.h
  3. AC_INIT([c-ares], [-],
  4. [c-ares mailing list => http://cool.haxx.se/mailman/listinfo/c-ares])
  5. CARES_OVERRIDE_AUTOCONF
  6. AC_CONFIG_SRCDIR([ares_ipv6.h])
  7. AM_CONFIG_HEADER([config.h ares_build.h])
  8. AM_MAINTAINER_MODE
  9. CARES_CHECK_OPTION_DEBUG
  10. CARES_CHECK_OPTION_OPTIMIZE
  11. CARES_CHECK_OPTION_WARNINGS
  12. CARES_CHECK_PATH_SEPARATOR
  13. dnl SED is mandatory for configure process and libtool.
  14. dnl Set it now, allowing it to be changed later.
  15. AC_PATH_PROG([SED], [sed], [not_found],
  16. [$PATH:/usr/bin:/usr/local/bin])
  17. if test -z "$SED" || test "$SED" = "not_found"; then
  18. AC_MSG_ERROR([sed not found in PATH. Cannot continue without sed.])
  19. fi
  20. AC_SUBST([SED])
  21. dnl GREP is mandatory for configure process and libtool.
  22. dnl Set it now, allowing it to be changed later.
  23. AC_PATH_PROG([GREP], [grep], [not_found],
  24. [$PATH:/usr/bin:/usr/local/bin])
  25. if test -z "$GREP" || test "$GREP" = "not_found"; then
  26. AC_MSG_ERROR([grep not found in PATH. Cannot continue without grep.])
  27. fi
  28. AC_SUBST([GREP])
  29. dnl EGREP is mandatory for configure process and libtool.
  30. dnl Set it now, allowing it to be changed later.
  31. if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1; then
  32. AC_MSG_CHECKING([for egrep])
  33. EGREP="$GREP -E"
  34. AC_MSG_RESULT([$EGREP])
  35. else
  36. AC_PATH_PROG([EGREP], [egrep], [not_found],
  37. [$PATH:/usr/bin:/usr/local/bin])
  38. fi
  39. if test -z "$EGREP" || test "$EGREP" = "not_found"; then
  40. AC_MSG_ERROR([egrep not found in PATH. Cannot continue without egrep.])
  41. fi
  42. AC_SUBST([EGREP])
  43. dnl AR is mandatory for configure process and libtool.
  44. dnl This is target dependant, so check it as a tool.
  45. AC_PATH_TOOL([AR], [ar], [not_found],
  46. [$PATH:/usr/bin:/usr/local/bin])
  47. if test -z "$AR" || test "$AR" = "not_found"; then
  48. AC_MSG_ERROR([ar not found in PATH. Cannot continue without ar.])
  49. fi
  50. AC_SUBST([AR])
  51. dnl Fetch c-ares version from ares_version.h
  52. VERSION=`$SED -ne 's/^#define ARES_VERSION_STR "\(.*\)"/\1/p' ${srcdir}/ares_version.h`
  53. AM_INIT_AUTOMAKE([c-ares], [$VERSION])
  54. AC_MSG_CHECKING([c-ares version])
  55. AC_MSG_RESULT([$VERSION])
  56. dnl
  57. dnl Detect the canonical host and target build environment
  58. dnl
  59. AC_CANONICAL_HOST
  60. dnl Get system canonical name
  61. AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
  62. CARES_CHECK_PROG_CC
  63. AM_PROG_CC_C_O
  64. AC_PROG_INSTALL
  65. dnl This defines _ALL_SOURCE for AIX
  66. CARES_CHECK_AIX_ALL_SOURCE
  67. dnl Our configure and build reentrant settings
  68. CARES_CONFIGURE_REENTRANT
  69. dnl check for how to do large files
  70. AC_SYS_LARGEFILE
  71. case $host_os in
  72. solaris*)
  73. AC_DEFINE(ETC_INET, 1, [if a /etc/inet dir is being used])
  74. ;;
  75. esac
  76. dnl support building of Windows DLLs
  77. AC_LIBTOOL_WIN32_DLL
  78. CARES_PROCESS_DEBUG_BUILD_OPTS
  79. AM_CONDITIONAL(DEBUGBUILD, test x$want_debug = xyes)
  80. AM_CONDITIONAL(CURLDEBUG, test x$want_debug = xyes)
  81. dnl force libtool to build static libraries with PIC on AMD64-Linux & FreeBSD
  82. AC_MSG_CHECKING([if arch-OS host is AMD64-Linux/FreeBSD (to build static libraries with PIC)])
  83. case $host in
  84. x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
  85. AC_MSG_RESULT([yes])
  86. with_pic=yes
  87. ;;
  88. *)
  89. AC_MSG_RESULT([no])
  90. ;;
  91. esac
  92. dnl libtool setup
  93. AC_PROG_LIBTOOL
  94. AC_MSG_CHECKING([if we need -no-undefined])
  95. case $host in
  96. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
  97. need_no_undefined=yes
  98. ;;
  99. *)
  100. need_no_undefined=no
  101. ;;
  102. esac
  103. AC_MSG_RESULT($need_no_undefined)
  104. AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
  105. dnl **********************************************************************
  106. dnl platform/compiler/architecture specific checks/flags
  107. dnl **********************************************************************
  108. CARES_CHECK_COMPILER
  109. CARES_SET_COMPILER_BASIC_OPTS
  110. CARES_SET_COMPILER_DEBUG_OPTS
  111. CARES_SET_COMPILER_OPTIMIZE_OPTS
  112. CARES_SET_COMPILER_WARNING_OPTS
  113. case $host in
  114. #
  115. x86_64*linux*|amd64*freebsd*|ia64*freebsd*)
  116. #
  117. if test "$compiler_id" = "INTEL_UNIX_C"; then
  118. #
  119. if test "$compiler_num" -ge "900" &&
  120. test "$compiler_num" -lt "1000"; then
  121. dnl icc 9.X specific
  122. CFLAGS="$CFLAGS -i-dynamic"
  123. fi
  124. #
  125. if test "$compiler_num" -ge "1000"; then
  126. dnl icc 10.X or later
  127. CFLAGS="$CFLAGS -shared-intel"
  128. fi
  129. #
  130. fi
  131. ;;
  132. #
  133. esac
  134. CURL_CHECK_COMPILER_HALT_ON_ERROR
  135. CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
  136. dnl **********************************************************************
  137. dnl Compilation based checks should not be done before this point.
  138. dnl **********************************************************************
  139. dnl **********************************************************************
  140. dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
  141. dnl and ws2tcpip.h take precedence over any other further checks which
  142. dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
  143. dnl this specific header files. And do them before its results are used.
  144. dnl **********************************************************************
  145. CURL_CHECK_HEADER_WINDOWS
  146. CURL_CHECK_NATIVE_WINDOWS
  147. case X-"$ac_cv_native_windows" in
  148. X-yes)
  149. CURL_CHECK_HEADER_WINSOCK
  150. CURL_CHECK_HEADER_WINSOCK2
  151. CURL_CHECK_HEADER_WS2TCPIP
  152. ;;
  153. *)
  154. ac_cv_header_winsock_h="no"
  155. ac_cv_header_winsock2_h="no"
  156. ac_cv_header_ws2tcpip_h="no"
  157. ;;
  158. esac
  159. dnl **********************************************************************
  160. dnl Checks for libraries.
  161. dnl **********************************************************************
  162. tst_lib_xnet_required="no"
  163. AC_MSG_CHECKING([if X/Open network library is required])
  164. CURL_CHECK_DEF([__hpux], [], [silent])
  165. CURL_CHECK_DEF_CC([_XOPEN_SOURCE_EXTENDED], [], [silent])
  166. if test "$curl_cv_have_def__XOPEN_SOURCE_EXTENDED" = "yes" &&
  167. test "$curl_cv_have_def___hpux" = "yes"; then
  168. my_ac_save_LIBS=$LIBS
  169. LIBS="-lxnet $LIBS"
  170. AC_LINK_IFELSE([
  171. AC_LANG_PROGRAM([[
  172. ]],[[
  173. if(0 != getpeername(0, 0, 0))
  174. return 1;
  175. ]])
  176. ],[
  177. tst_lib_xnet_required="yes"
  178. ],[
  179. LIBS=$my_ac_save_LIBS
  180. ])
  181. fi
  182. AC_MSG_RESULT([$tst_lib_xnet_required])
  183. dnl gethostbyname without lib or in the nsl lib?
  184. AC_CHECK_FUNC(gethostbyname,
  185. [HAVE_GETHOSTBYNAME="1"
  186. ],
  187. [ AC_CHECK_LIB(nsl, gethostbyname,
  188. [HAVE_GETHOSTBYNAME="1"
  189. LIBS="$LIBS -lnsl"
  190. ])
  191. ])
  192. if test "$HAVE_GETHOSTBYNAME" != "1"
  193. then
  194. dnl gethostbyname in the socket lib?
  195. AC_CHECK_LIB(socket, gethostbyname,
  196. [HAVE_GETHOSTBYNAME="1"
  197. LIBS="$LIBS -lsocket"
  198. ])
  199. fi
  200. dnl At least one system has been identified to require BOTH nsl and socket
  201. dnl libs at the same time to link properly.
  202. if test "$HAVE_GETHOSTBYNAME" != "1"
  203. then
  204. AC_MSG_CHECKING([for gethostbyname with both nsl and socket libs])
  205. my_ac_save_LIBS=$LIBS
  206. LIBS="-lnsl -lsocket $LIBS"
  207. AC_LINK_IFELSE([
  208. AC_LANG_PROGRAM([[
  209. ]],[[
  210. gethostbyname();
  211. ]])
  212. ],[
  213. AC_MSG_RESULT([yes])
  214. HAVE_GETHOSTBYNAME="1"
  215. ],[
  216. AC_MSG_RESULT([no])
  217. LIBS=$my_ac_save_LIBS
  218. ])
  219. fi
  220. if test "$HAVE_GETHOSTBYNAME" != "1"
  221. then
  222. dnl This is for winsock systems
  223. if test "$ac_cv_header_windows_h" = "yes"; then
  224. if test "$ac_cv_header_winsock_h" = "yes"; then
  225. case $host in
  226. *-*-mingw32ce*)
  227. winsock_LIB="-lwinsock"
  228. ;;
  229. *)
  230. winsock_LIB="-lwsock32"
  231. ;;
  232. esac
  233. fi
  234. if test "$ac_cv_header_winsock2_h" = "yes"; then
  235. winsock_LIB="-lws2_32"
  236. fi
  237. if test ! -z "$winsock_LIB"; then
  238. my_ac_save_LIBS=$LIBS
  239. LIBS="$winsock_LIB $LIBS"
  240. AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
  241. AC_LINK_IFELSE([
  242. AC_LANG_PROGRAM([[
  243. #ifdef HAVE_WINDOWS_H
  244. #ifndef WIN32_LEAN_AND_MEAN
  245. #define WIN32_LEAN_AND_MEAN
  246. #endif
  247. #include <windows.h>
  248. #ifdef HAVE_WINSOCK2_H
  249. #include <winsock2.h>
  250. #else
  251. #ifdef HAVE_WINSOCK_H
  252. #include <winsock.h>
  253. #endif
  254. #endif
  255. #endif
  256. ]],[[
  257. gethostbyname("www.dummysite.com");
  258. ]])
  259. ],[
  260. AC_MSG_RESULT([yes])
  261. HAVE_GETHOSTBYNAME="1"
  262. ],[
  263. AC_MSG_RESULT([no])
  264. winsock_LIB=""
  265. LIBS=$my_ac_save_LIBS
  266. ])
  267. fi
  268. fi
  269. fi
  270. if test "$HAVE_GETHOSTBYNAME" != "1"
  271. then
  272. dnl This is for Minix 3.1
  273. AC_MSG_CHECKING([for gethostbyname for Minix 3])
  274. AC_LINK_IFELSE([
  275. AC_LANG_PROGRAM([[
  276. /* Older Minix versions may need <net/gen/netdb.h> here instead */
  277. #include <netdb.h>
  278. ]],[[
  279. gethostbyname("www.dummysite.com");
  280. ]])
  281. ],[
  282. AC_MSG_RESULT([yes])
  283. HAVE_GETHOSTBYNAME="1"
  284. ],[
  285. AC_MSG_RESULT([no])
  286. ])
  287. fi
  288. if test "$HAVE_GETHOSTBYNAME" != "1"
  289. then
  290. dnl This is for eCos with a stubbed DNS implementation
  291. AC_MSG_CHECKING([for gethostbyname for eCos])
  292. AC_LINK_IFELSE([
  293. AC_LANG_PROGRAM([[
  294. #include <stdio.h>
  295. #include <netdb.h>
  296. ]],[[
  297. gethostbyname("www.dummysite.com");
  298. ]])
  299. ],[
  300. AC_MSG_RESULT([yes])
  301. HAVE_GETHOSTBYNAME="1"
  302. ],[
  303. AC_MSG_RESULT([no])
  304. ])
  305. fi
  306. if test "$HAVE_GETHOSTBYNAME" != "1"
  307. then
  308. dnl gethostbyname in the net lib - for BeOS
  309. AC_CHECK_LIB(net, gethostbyname,
  310. [HAVE_GETHOSTBYNAME="1"
  311. LIBS="$LIBS -lnet"
  312. ])
  313. fi
  314. if test "$HAVE_GETHOSTBYNAME" != "1"; then
  315. AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
  316. fi
  317. dnl resolve lib?
  318. AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
  319. if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
  320. AC_CHECK_LIB(resolve, strcasecmp,
  321. [LIBS="-lresolve $LIBS"],
  322. ,
  323. -lnsl)
  324. fi
  325. ac_cv_func_strcasecmp="no"
  326. dnl socket lib?
  327. AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
  328. dnl **********************************************************************
  329. dnl In case that function clock_gettime with monotonic timer is available,
  330. dnl check for additional required libraries.
  331. dnl **********************************************************************
  332. CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  333. AC_MSG_CHECKING([whether to use libgcc])
  334. AC_ARG_ENABLE(libgcc,
  335. AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
  336. [ case "$enableval" in
  337. yes)
  338. LIBS="$LIBS -lgcc"
  339. AC_MSG_RESULT(yes)
  340. ;;
  341. *) AC_MSG_RESULT(no)
  342. ;;
  343. esac ],
  344. AC_MSG_RESULT(no)
  345. )
  346. dnl Default is to try the thread-safe versions of a few functions
  347. OPT_THREAD=on
  348. dnl detect AIX 4.3 or later
  349. AC_MSG_CHECKING([AIX 4.3 or later])
  350. AC_PREPROC_IFELSE([
  351. #if defined(_AIX) && defined(_AIX43)
  352. printf("just fine");
  353. #else
  354. #error "this is not AIX 4.3 or later"
  355. #endif
  356. ],
  357. [ AC_MSG_RESULT([yes])
  358. RECENTAIX=yes
  359. OPT_THREAD=off ],
  360. [ AC_MSG_RESULT([no]) ]
  361. )
  362. AC_ARG_ENABLE(thread,dnl
  363. AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
  364. AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
  365. [ case "$enableval" in
  366. no)
  367. OPT_THREAD=off
  368. AC_MSG_WARN(c-ares will not get built using thread-safe functions)
  369. ;;
  370. *)
  371. ;;
  372. esac
  373. ]
  374. )
  375. if test X"$OPT_THREAD" = Xoff
  376. then
  377. AC_DEFINE(DISABLED_THREADSAFE, 1,
  378. [Set to explicitly specify we don't want to use thread-safe functions])
  379. fi
  380. dnl for recent AIX versions, we skip all the thread-safe checks above since
  381. dnl they claim a thread-safe libc using the standard API. But there are
  382. dnl some functions still not thread-safe. Check for these!
  383. dnl Let's hope this split URL remains working:
  384. dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
  385. dnl genprogc/thread_quick_ref.htm
  386. if test "x$RECENTAIX" = "xyes"; then
  387. AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
  388. fi
  389. dnl **********************************************************************
  390. dnl Back to "normal" configuring
  391. dnl **********************************************************************
  392. dnl Checks for header files.
  393. AC_HEADER_STDC
  394. CURL_CHECK_HEADER_MALLOC
  395. CURL_CHECK_HEADER_MEMORY
  396. dnl check for a few basic system headers we need
  397. AC_CHECK_HEADERS(
  398. sys/types.h \
  399. sys/time.h \
  400. sys/select.h \
  401. sys/socket.h \
  402. sys/ioctl.h \
  403. sys/param.h \
  404. sys/uio.h \
  405. netdb.h \
  406. netinet/in.h \
  407. netinet/tcp.h \
  408. net/if.h \
  409. errno.h \
  410. strings.h \
  411. stdbool.h \
  412. time.h \
  413. limits.h \
  414. arpa/nameser.h \
  415. arpa/nameser_compat.h \
  416. arpa/inet.h,
  417. dnl to do if not found
  418. [],
  419. dnl to do if found
  420. [],
  421. dnl default includes
  422. [
  423. #ifdef HAVE_SYS_TYPES_H
  424. #include <sys/types.h>
  425. #endif
  426. #ifdef HAVE_SYS_TIME_H
  427. #include <sys/time.h>
  428. #endif
  429. dnl We do this default-include simply to make sure that the nameser_compat.h
  430. dnl header *REALLY* can be include after the new nameser.h. It seems AIX 5.1
  431. dnl (and others?) is not designed to allow this.
  432. #ifdef HAVE_ARPA_NAMESER_H
  433. #include <arpa/nameser.h>
  434. #endif
  435. dnl *Sigh* these are needed in order for net/if.h to get properly detected.
  436. #ifdef HAVE_SYS_SOCKET_H
  437. #include <sys/socket.h>
  438. #endif
  439. #ifdef HAVE_NETINET_IN_H
  440. #include <netinet/in.h>
  441. #endif
  442. ]
  443. )
  444. dnl Checks for typedefs, structures, and compiler characteristics.
  445. AC_C_CONST
  446. AC_TYPE_SIZE_T
  447. AC_HEADER_TIME
  448. CURL_CHECK_STRUCT_TIMEVAL
  449. AC_CHECK_SIZEOF(size_t)
  450. AC_CHECK_SIZEOF(int)
  451. AC_CHECK_SIZEOF(long)
  452. CARES_CONFIGURE_LONG
  453. AC_CHECK_SIZEOF(time_t)
  454. AC_CHECK_TYPE(long long,
  455. [AC_DEFINE(HAVE_LONGLONG, 1,
  456. [Define to 1 if the compiler supports the 'long long' data type.])]
  457. longlong="yes"
  458. )
  459. if test "xyes" = "x$longlong"; then
  460. AC_MSG_CHECKING([if numberLL works])
  461. AC_COMPILE_IFELSE([long long val = 1000LL;],
  462. [AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])]
  463. AC_MSG_RESULT(yes),
  464. AC_MSG_RESULT(no)
  465. )
  466. fi
  467. # check for ssize_t
  468. AC_CHECK_TYPE(ssize_t, ,
  469. AC_DEFINE(ssize_t, int, [the signed version of size_t]))
  470. # check for bool type
  471. AC_CHECK_TYPE([bool],[
  472. AC_DEFINE(HAVE_BOOL_T, 1,
  473. [Define to 1 if bool is an available type.])
  474. ], ,[
  475. #ifdef HAVE_SYS_TYPES_H
  476. #include <sys/types.h>
  477. #endif
  478. #ifdef HAVE_STDBOOL_H
  479. #include <stdbool.h>
  480. #endif
  481. ])
  482. CARES_CONFIGURE_ARES_SOCKLEN_T
  483. TYPE_IN_ADDR_T
  484. TYPE_SOCKADDR_STORAGE
  485. TYPE_SIG_ATOMIC_T
  486. AC_TYPE_SIGNAL
  487. CURL_CHECK_FUNC_RECV
  488. CURL_CHECK_FUNC_RECVFROM
  489. CURL_CHECK_FUNC_SEND
  490. CURL_CHECK_MSG_NOSIGNAL
  491. CARES_CHECK_FUNC_FCNTL
  492. CARES_CHECK_FUNC_FREEADDRINFO
  493. CARES_CHECK_FUNC_GETADDRINFO
  494. CARES_CHECK_FUNC_GETHOSTBYADDR
  495. CARES_CHECK_FUNC_GETHOSTBYNAME
  496. CARES_CHECK_FUNC_GETHOSTNAME
  497. CARES_CHECK_FUNC_GETSERVBYPORT_R
  498. CARES_CHECK_FUNC_INET_NTOP
  499. CARES_CHECK_FUNC_INET_PTON
  500. CARES_CHECK_FUNC_IOCTL
  501. CARES_CHECK_FUNC_IOCTLSOCKET
  502. CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
  503. CARES_CHECK_FUNC_SETSOCKOPT
  504. CARES_CHECK_FUNC_STRCASECMP
  505. CARES_CHECK_FUNC_STRCMPI
  506. CARES_CHECK_FUNC_STRDUP
  507. CARES_CHECK_FUNC_STRICMP
  508. CARES_CHECK_FUNC_STRNCASECMP
  509. CARES_CHECK_FUNC_STRNCMPI
  510. CARES_CHECK_FUNC_STRNICMP
  511. CARES_CHECK_FUNC_WRITEV
  512. dnl check for AF_INET6
  513. CARES_CHECK_CONSTANT(
  514. [
  515. #undef inline
  516. #ifdef HAVE_WINDOWS_H
  517. #ifndef WIN32_LEAN_AND_MEAN
  518. #define WIN32_LEAN_AND_MEAN
  519. #endif
  520. #include <windows.h>
  521. #ifdef HAVE_WINSOCK2_H
  522. #include <winsock2.h>
  523. #endif
  524. #else
  525. #ifdef HAVE_SYS_TYPES_H
  526. #include <sys/types.h>
  527. #endif
  528. #ifdef HAVE_SYS_SOCKET_H
  529. #include <sys/socket.h>
  530. #endif
  531. #endif
  532. ], [PF_INET6],
  533. AC_DEFINE_UNQUOTED(HAVE_PF_INET6,1,[Define to 1 if you have PF_INET6.])
  534. )
  535. dnl check for PF_INET6
  536. CARES_CHECK_CONSTANT(
  537. [
  538. #undef inline
  539. #ifdef HAVE_WINDOWS_H
  540. #ifndef WIN32_LEAN_AND_MEAN
  541. #define WIN32_LEAN_AND_MEAN
  542. #endif
  543. #include <windows.h>
  544. #ifdef HAVE_WINSOCK2_H
  545. #include <winsock2.h>
  546. #endif
  547. #else
  548. #ifdef HAVE_SYS_TYPES_H
  549. #include <sys/types.h>
  550. #endif
  551. #ifdef HAVE_SYS_SOCKET_H
  552. #include <sys/socket.h>
  553. #endif
  554. #endif
  555. ], [AF_INET6],
  556. AC_DEFINE_UNQUOTED(HAVE_AF_INET6,1,[Define to 1 if you have AF_INET6.])
  557. )
  558. dnl check for the in6_addr structure
  559. CARES_CHECK_STRUCT(
  560. [
  561. #undef inline
  562. #ifdef HAVE_WINDOWS_H
  563. #ifndef WIN32_LEAN_AND_MEAN
  564. #define WIN32_LEAN_AND_MEAN
  565. #endif
  566. #include <windows.h>
  567. #ifdef HAVE_WINSOCK2_H
  568. #include <winsock2.h>
  569. #ifdef HAVE_WS2TCPIP_H
  570. #include <ws2tcpip.h>
  571. #endif
  572. #endif
  573. #else
  574. #ifdef HAVE_SYS_TYPES_H
  575. #include <sys/types.h>
  576. #endif
  577. #ifdef HAVE_NETINET_IN_H
  578. #include <netinet/in.h>
  579. #endif
  580. #endif
  581. ], [in6_addr],
  582. AC_DEFINE_UNQUOTED(HAVE_STRUCT_IN6_ADDR,1,[Define to 1 if you have struct in6_addr.])
  583. )
  584. dnl check for the sockaddr_in6 structure
  585. CARES_CHECK_STRUCT(
  586. [
  587. #undef inline
  588. #ifdef HAVE_WINDOWS_H
  589. #ifndef WIN32_LEAN_AND_MEAN
  590. #define WIN32_LEAN_AND_MEAN
  591. #endif
  592. #include <windows.h>
  593. #ifdef HAVE_WINSOCK2_H
  594. #include <winsock2.h>
  595. #ifdef HAVE_WS2TCPIP_H
  596. #include <ws2tcpip.h>
  597. #endif
  598. #endif
  599. #else
  600. #ifdef HAVE_SYS_TYPES_H
  601. #include <sys/types.h>
  602. #endif
  603. #ifdef HAVE_NETINET_IN_H
  604. #include <netinet/in.h>
  605. #endif
  606. #endif
  607. ], [sockaddr_in6],
  608. AC_DEFINE_UNQUOTED(HAVE_STRUCT_SOCKADDR_IN6,1,
  609. [Define to 1 if you have struct sockaddr_in6.]) ac_have_sockaddr_in6=yes
  610. )
  611. AC_CHECK_MEMBER(struct sockaddr_in6.sin6_scope_id,
  612. AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,1,
  613. [Define to 1 if your struct sockaddr_in6 has sin6_scope_id.])
  614. , ,
  615. [
  616. #undef inline
  617. #ifdef HAVE_WINDOWS_H
  618. #ifndef WIN32_LEAN_AND_MEAN
  619. #define WIN32_LEAN_AND_MEAN
  620. #endif
  621. #include <windows.h>
  622. #ifdef HAVE_WINSOCK2_H
  623. #include <winsock2.h>
  624. #ifdef HAVE_WS2TCPIP_H
  625. #include <ws2tcpip.h>
  626. #endif
  627. #endif
  628. #else
  629. #ifdef HAVE_SYS_TYPES_H
  630. #include <sys/types.h>
  631. #endif
  632. #ifdef HAVE_NETINET_IN_H
  633. #include <netinet/in.h>
  634. #endif
  635. #endif
  636. ])
  637. dnl check for the addrinfo structure
  638. AC_CHECK_MEMBER(struct addrinfo.ai_flags,
  639. AC_DEFINE_UNQUOTED(HAVE_STRUCT_ADDRINFO,1,
  640. [Define to 1 if you have struct addrinfo.]),,
  641. [
  642. #undef inline
  643. #ifdef HAVE_WINDOWS_H
  644. #ifndef WIN32_LEAN_AND_MEAN
  645. #define WIN32_LEAN_AND_MEAN
  646. #endif
  647. #include <windows.h>
  648. #ifdef HAVE_WINSOCK2_H
  649. #include <winsock2.h>
  650. #ifdef HAVE_WS2TCPIP_H
  651. #include <ws2tcpip.h>
  652. #endif
  653. #endif
  654. #else
  655. #ifdef HAVE_SYS_TYPES_H
  656. #include <sys/types.h>
  657. #endif
  658. #ifdef HAVE_NETINET_IN_H
  659. #include <netinet/in.h>
  660. #endif
  661. #ifdef HAVE_SYS_SOCKET_H
  662. #include <sys/socket.h>
  663. #endif
  664. #ifdef HAVE_NETDB_H
  665. #include <netdb.h>
  666. #endif
  667. #endif
  668. ]
  669. )
  670. AC_CHECK_FUNCS([bitncmp \
  671. gettimeofday \
  672. if_indextoname
  673. ],[
  674. ],[
  675. func="$ac_func"
  676. AC_MSG_CHECKING([deeper for $func])
  677. AC_LINK_IFELSE([
  678. AC_LANG_PROGRAM([[
  679. ]],[[
  680. $func ();
  681. ]])
  682. ],[
  683. AC_MSG_RESULT([yes])
  684. eval "ac_cv_func_$func=yes"
  685. AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$func])], [1],
  686. [Define to 1 if you have the $func function.])
  687. ],[
  688. AC_MSG_RESULT([but still no])
  689. ])
  690. ])
  691. dnl Check for inet_net_pton
  692. AC_CHECK_FUNCS(inet_net_pton)
  693. dnl Again, some systems have it, but not IPv6
  694. if test "$ac_cv_func_inet_net_pton" = "yes" ; then
  695. AC_MSG_CHECKING(if inet_net_pton supports IPv6)
  696. AC_TRY_RUN(
  697. [
  698. #ifdef HAVE_SYS_TYPES_H
  699. #include <sys/types.h>
  700. #endif
  701. #ifdef HAVE_SYS_SOCKET_H
  702. #include <sys/socket.h>
  703. #endif
  704. #ifdef HAVE_NETINET_IN_H
  705. #include <netinet/in.h>
  706. #endif
  707. int main()
  708. {
  709. struct in6_addr addr6;
  710. if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
  711. exit(1);
  712. else
  713. exit(0);
  714. }
  715. ], [
  716. AC_MSG_RESULT(yes)
  717. AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
  718. ], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
  719. fi
  720. AC_CHECK_SIZEOF(struct in6_addr, ,
  721. [
  722. #undef inline
  723. #ifdef HAVE_WINDOWS_H
  724. #ifndef WIN32_LEAN_AND_MEAN
  725. #define WIN32_LEAN_AND_MEAN
  726. #endif
  727. #include <windows.h>
  728. #ifdef HAVE_WINSOCK2_H
  729. #include <winsock2.h>
  730. #ifdef HAVE_WS2TCPIP_H
  731. #include <ws2tcpip.h>
  732. #endif
  733. #endif
  734. #else
  735. #ifdef HAVE_SYS_TYPES_H
  736. #include <sys/types.h>
  737. #endif
  738. #ifdef HAVE_SYS_SOCKET_H
  739. #include <sys/socket.h>
  740. #endif
  741. #ifdef HAVE_NETINET_IN_H
  742. #include <netinet/in.h>
  743. #endif
  744. #endif
  745. ]
  746. )
  747. AC_CHECK_SIZEOF(struct in_addr, ,
  748. [
  749. #undef inline
  750. #ifdef HAVE_WINDOWS_H
  751. #ifndef WIN32_LEAN_AND_MEAN
  752. #define WIN32_LEAN_AND_MEAN
  753. #endif
  754. #include <windows.h>
  755. #ifdef HAVE_WINSOCK2_H
  756. #include <winsock2.h>
  757. #ifdef HAVE_WS2TCPIP_H
  758. #include <ws2tcpip.h>
  759. #endif
  760. #endif
  761. #else
  762. #ifdef HAVE_SYS_TYPES_H
  763. #include <sys/types.h>
  764. #endif
  765. #ifdef HAVE_SYS_SOCKET_H
  766. #include <sys/socket.h>
  767. #endif
  768. #ifdef HAVE_NETINET_IN_H
  769. #include <netinet/in.h>
  770. #endif
  771. #endif
  772. ]
  773. )
  774. dnl Check if the getnameinfo function is available
  775. dnl and get the types of five of its arguments.
  776. CURL_CHECK_FUNC_GETNAMEINFO
  777. AC_C_BIGENDIAN(
  778. [AC_DEFINE(ARES_BIG_ENDIAN, 1,
  779. [define this if ares is built for a big endian system])],
  780. ,
  781. [AC_MSG_WARN([couldn't figure out endianess, assuming little endian!])]
  782. )
  783. dnl Check for user-specified random device
  784. AC_ARG_WITH(random,
  785. AC_HELP_STRING([--with-random=FILE],
  786. [read randomness from FILE (default=/dev/urandom)]),
  787. [ RANDOM_FILE="$withval" ],
  788. [
  789. dnl Check for random device. If we're cross compiling, we can't
  790. dnl check, and it's better to assume it doesn't exist than it is
  791. dnl to fail on AC_CHECK_FILE or later.
  792. if test "$cross_compiling" = "no"; then
  793. AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
  794. else
  795. AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
  796. fi
  797. ]
  798. )
  799. if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
  800. AC_SUBST(RANDOM_FILE)
  801. AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
  802. [a suitable file/device to read random data from])
  803. fi
  804. CARES_CHECK_OPTION_NONBLOCKING
  805. CARES_CHECK_NONBLOCKING_SOCKET
  806. CARES_PRIVATE_LIBS="$LIBS"
  807. AC_SUBST(CARES_PRIVATE_LIBS)
  808. dnl squeeze whitespace out of some variables
  809. squeeze CFLAGS
  810. squeeze CPPFLAGS
  811. squeeze DEFS
  812. squeeze LDFLAGS
  813. squeeze LIBS
  814. squeeze CARES_PRIVATE_LIBS
  815. AC_CONFIG_FILES([Makefile libcares.pc])
  816. AC_OUTPUT