acinclude.m4 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915
  1. dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
  2. dnl -------------------------------------------------
  3. dnl Use the C preprocessor to find out if the given object-style symbol
  4. dnl is defined and get its expansion. This macro will not use default
  5. dnl includes even if no INCLUDES argument is given. This macro will run
  6. dnl silently when invoked with three arguments. If the expansion would
  7. dnl result in a set of double-quoted strings the returned expansion will
  8. dnl actually be a single double-quoted string concatenating all them.
  9. AC_DEFUN([CURL_CHECK_DEF], [
  10. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  11. AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
  12. if test -z "$SED"; then
  13. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  14. fi
  15. if test -z "$GREP"; then
  16. AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
  17. fi
  18. ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
  19. tmp_exp=""
  20. AC_PREPROC_IFELSE([
  21. AC_LANG_SOURCE(
  22. ifelse($2,,,[$2])[[
  23. #ifdef $1
  24. CURL_DEF_TOKEN $1
  25. #endif
  26. ]])
  27. ],[
  28. tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
  29. "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
  30. "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
  31. "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
  32. if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
  33. tmp_exp=""
  34. fi
  35. ])
  36. if test -z "$tmp_exp"; then
  37. AS_VAR_SET(ac_HaveDef, no)
  38. ifelse($3,,[AC_MSG_RESULT([no])])
  39. else
  40. AS_VAR_SET(ac_HaveDef, yes)
  41. AS_VAR_SET(ac_Def, $tmp_exp)
  42. ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
  43. fi
  44. AS_VAR_POPDEF([ac_Def])dnl
  45. AS_VAR_POPDEF([ac_HaveDef])dnl
  46. ])
  47. dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
  48. dnl -------------------------------------------------
  49. dnl Use the C compiler to find out only if the given symbol is defined
  50. dnl or not, this can not find out its expansion. This macro will not use
  51. dnl default includes even if no INCLUDES argument is given. This macro
  52. dnl will run silently when invoked with three arguments.
  53. AC_DEFUN([CURL_CHECK_DEF_CC], [
  54. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  55. ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
  56. AC_COMPILE_IFELSE([
  57. AC_LANG_SOURCE(
  58. ifelse($2,,,[$2])[[
  59. int main (void)
  60. {
  61. #ifdef $1
  62. return 0;
  63. #else
  64. force compilation error
  65. #endif
  66. }
  67. ]])
  68. ],[
  69. tst_symbol_defined="yes"
  70. ],[
  71. tst_symbol_defined="no"
  72. ])
  73. if test "$tst_symbol_defined" = "yes"; then
  74. AS_VAR_SET(ac_HaveDef, yes)
  75. ifelse($3,,[AC_MSG_RESULT([yes])])
  76. else
  77. AS_VAR_SET(ac_HaveDef, no)
  78. ifelse($3,,[AC_MSG_RESULT([no])])
  79. fi
  80. AS_VAR_POPDEF([ac_HaveDef])dnl
  81. ])
  82. dnl CARES_CHECK_LIB_XNET
  83. dnl -------------------------------------------------
  84. dnl Verify if X/Open network library is required.
  85. AC_DEFUN([CARES_CHECK_LIB_XNET], [
  86. AC_MSG_CHECKING([if X/Open network library is required])
  87. tst_lib_xnet_required="no"
  88. AC_COMPILE_IFELSE([
  89. AC_LANG_SOURCE([[
  90. int main (void)
  91. {
  92. #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
  93. return 0;
  94. #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
  95. return 0;
  96. #else
  97. force compilation error
  98. #endif
  99. }
  100. ]])
  101. ],[
  102. tst_lib_xnet_required="yes"
  103. LIBS="$LIBS -lxnet"
  104. ])
  105. AC_MSG_RESULT([$tst_lib_xnet_required])
  106. ])
  107. dnl CARES_CHECK_AIX_ALL_SOURCE
  108. dnl -------------------------------------------------
  109. dnl Provides a replacement of traditional AC_AIX with
  110. dnl an uniform behaviour across all autoconf versions,
  111. dnl and with our own placement rules.
  112. AC_DEFUN([CARES_CHECK_AIX_ALL_SOURCE], [
  113. AH_VERBATIM([_ALL_SOURCE],
  114. [/* Define to 1 if OS is AIX. */
  115. #ifndef _ALL_SOURCE
  116. # undef _ALL_SOURCE
  117. #endif])
  118. AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
  119. AC_BEFORE([$0], [CARES_CONFIGURE_REENTRANT])dnl
  120. AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
  121. AC_EGREP_CPP([yes_this_is_aix],[
  122. #ifdef _AIX
  123. yes_this_is_aix
  124. #endif
  125. ],[
  126. AC_MSG_RESULT([yes])
  127. AC_DEFINE(_ALL_SOURCE)
  128. ],[
  129. AC_MSG_RESULT([no])
  130. ])
  131. ])
  132. dnl CURL_CHECK_HEADER_WINDOWS
  133. dnl -------------------------------------------------
  134. dnl Check for compilable and valid windows.h header
  135. AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
  136. AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
  137. AC_COMPILE_IFELSE([
  138. AC_LANG_PROGRAM([[
  139. #undef inline
  140. #ifndef WIN32_LEAN_AND_MEAN
  141. #define WIN32_LEAN_AND_MEAN
  142. #endif
  143. #include <windows.h>
  144. ]],[[
  145. #if defined(__CYGWIN__) || defined(__CEGCC__)
  146. HAVE_WINDOWS_H shall not be defined.
  147. #else
  148. int dummy=2*WINVER;
  149. #endif
  150. ]])
  151. ],[
  152. ac_cv_header_windows_h="yes"
  153. ],[
  154. ac_cv_header_windows_h="no"
  155. ])
  156. ])
  157. case "$ac_cv_header_windows_h" in
  158. yes)
  159. AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
  160. [Define to 1 if you have the windows.h header file.])
  161. AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
  162. [Define to avoid automatic inclusion of winsock.h])
  163. ;;
  164. esac
  165. ])
  166. dnl CURL_CHECK_NATIVE_WINDOWS
  167. dnl -------------------------------------------------
  168. dnl Check if building a native Windows target
  169. AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
  170. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  171. AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
  172. if test "$ac_cv_header_windows_h" = "no"; then
  173. ac_cv_native_windows="no"
  174. else
  175. AC_COMPILE_IFELSE([
  176. AC_LANG_PROGRAM([[
  177. ]],[[
  178. #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
  179. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
  180. int dummy=1;
  181. #else
  182. Not a native Windows build target.
  183. #endif
  184. ]])
  185. ],[
  186. ac_cv_native_windows="yes"
  187. ],[
  188. ac_cv_native_windows="no"
  189. ])
  190. fi
  191. ])
  192. AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$ac_cv_native_windows" = xyes)
  193. ])
  194. dnl CURL_CHECK_HEADER_WINSOCK
  195. dnl -------------------------------------------------
  196. dnl Check for compilable and valid winsock.h header
  197. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
  198. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  199. AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
  200. AC_COMPILE_IFELSE([
  201. AC_LANG_PROGRAM([[
  202. #undef inline
  203. #ifndef WIN32_LEAN_AND_MEAN
  204. #define WIN32_LEAN_AND_MEAN
  205. #endif
  206. #include <windows.h>
  207. #include <winsock.h>
  208. ]],[[
  209. #if defined(__CYGWIN__) || defined(__CEGCC__)
  210. HAVE_WINSOCK_H shall not be defined.
  211. #else
  212. int dummy=WSACleanup();
  213. #endif
  214. ]])
  215. ],[
  216. ac_cv_header_winsock_h="yes"
  217. ],[
  218. ac_cv_header_winsock_h="no"
  219. ])
  220. ])
  221. case "$ac_cv_header_winsock_h" in
  222. yes)
  223. AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
  224. [Define to 1 if you have the winsock.h header file.])
  225. ;;
  226. esac
  227. ])
  228. dnl CURL_CHECK_HEADER_WINSOCK2
  229. dnl -------------------------------------------------
  230. dnl Check for compilable and valid winsock2.h header
  231. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
  232. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  233. AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
  234. AC_COMPILE_IFELSE([
  235. AC_LANG_PROGRAM([[
  236. #undef inline
  237. #ifndef WIN32_LEAN_AND_MEAN
  238. #define WIN32_LEAN_AND_MEAN
  239. #endif
  240. #include <windows.h>
  241. #include <winsock2.h>
  242. ]],[[
  243. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  244. HAVE_WINSOCK2_H shall not be defined.
  245. #else
  246. int dummy=2*IPPROTO_ESP;
  247. #endif
  248. ]])
  249. ],[
  250. ac_cv_header_winsock2_h="yes"
  251. ],[
  252. ac_cv_header_winsock2_h="no"
  253. ])
  254. ])
  255. case "$ac_cv_header_winsock2_h" in
  256. yes)
  257. AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
  258. [Define to 1 if you have the winsock2.h header file.])
  259. ;;
  260. esac
  261. ])
  262. dnl CURL_CHECK_HEADER_WS2TCPIP
  263. dnl -------------------------------------------------
  264. dnl Check for compilable and valid ws2tcpip.h header
  265. AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
  266. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  267. AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
  268. AC_COMPILE_IFELSE([
  269. AC_LANG_PROGRAM([[
  270. #undef inline
  271. #ifndef WIN32_LEAN_AND_MEAN
  272. #define WIN32_LEAN_AND_MEAN
  273. #endif
  274. #include <windows.h>
  275. #include <winsock2.h>
  276. #include <ws2tcpip.h>
  277. ]],[[
  278. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  279. HAVE_WS2TCPIP_H shall not be defined.
  280. #else
  281. int dummy=2*IP_PKTINFO;
  282. #endif
  283. ]])
  284. ],[
  285. ac_cv_header_ws2tcpip_h="yes"
  286. ],[
  287. ac_cv_header_ws2tcpip_h="no"
  288. ])
  289. ])
  290. case "$ac_cv_header_ws2tcpip_h" in
  291. yes)
  292. AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
  293. [Define to 1 if you have the ws2tcpip.h header file.])
  294. ;;
  295. esac
  296. ])
  297. dnl CURL_CHECK_HEADER_MALLOC
  298. dnl -------------------------------------------------
  299. dnl Check for compilable and valid malloc.h header,
  300. dnl and check if it is needed even with stdlib.h
  301. AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
  302. AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
  303. AC_COMPILE_IFELSE([
  304. AC_LANG_PROGRAM([[
  305. #include <malloc.h>
  306. ]],[[
  307. void *p = malloc(10);
  308. void *q = calloc(10,10);
  309. free(p);
  310. free(q);
  311. ]])
  312. ],[
  313. ac_cv_header_malloc_h="yes"
  314. ],[
  315. ac_cv_header_malloc_h="no"
  316. ])
  317. ])
  318. if test "$ac_cv_header_malloc_h" = "yes"; then
  319. AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
  320. [Define to 1 if you have the malloc.h header file.])
  321. #
  322. AC_COMPILE_IFELSE([
  323. AC_LANG_PROGRAM([[
  324. #include <stdlib.h>
  325. ]],[[
  326. void *p = malloc(10);
  327. void *q = calloc(10,10);
  328. free(p);
  329. free(q);
  330. ]])
  331. ],[
  332. curl_cv_need_header_malloc_h="no"
  333. ],[
  334. curl_cv_need_header_malloc_h="yes"
  335. ])
  336. #
  337. case "$curl_cv_need_header_malloc_h" in
  338. yes)
  339. AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
  340. [Define to 1 if you need the malloc.h header file even with stdlib.h])
  341. ;;
  342. esac
  343. fi
  344. ])
  345. dnl CURL_CHECK_HEADER_MEMORY
  346. dnl -------------------------------------------------
  347. dnl Check for compilable and valid memory.h header,
  348. dnl and check if it is needed even with stdlib.h for
  349. dnl memory related functions.
  350. AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
  351. AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
  352. AC_COMPILE_IFELSE([
  353. AC_LANG_PROGRAM([[
  354. #include <memory.h>
  355. ]],[[
  356. void *p = malloc(10);
  357. void *q = calloc(10,10);
  358. free(p);
  359. free(q);
  360. ]])
  361. ],[
  362. ac_cv_header_memory_h="yes"
  363. ],[
  364. ac_cv_header_memory_h="no"
  365. ])
  366. ])
  367. if test "$ac_cv_header_memory_h" = "yes"; then
  368. AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
  369. [Define to 1 if you have the memory.h header file.])
  370. #
  371. AC_COMPILE_IFELSE([
  372. AC_LANG_PROGRAM([[
  373. #include <stdlib.h>
  374. ]],[[
  375. void *p = malloc(10);
  376. void *q = calloc(10,10);
  377. free(p);
  378. free(q);
  379. ]])
  380. ],[
  381. curl_cv_need_header_memory_h="no"
  382. ],[
  383. curl_cv_need_header_memory_h="yes"
  384. ])
  385. #
  386. case "$curl_cv_need_header_memory_h" in
  387. yes)
  388. AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
  389. [Define to 1 if you need the memory.h header file even with stdlib.h])
  390. ;;
  391. esac
  392. fi
  393. ])
  394. dnl CURL_CHECK_FUNC_GETNAMEINFO
  395. dnl -------------------------------------------------
  396. dnl Test if the getnameinfo function is available,
  397. dnl and check the types of five of its arguments.
  398. dnl If the function succeeds HAVE_GETNAMEINFO will be
  399. dnl defined, defining the types of the arguments in
  400. dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
  401. dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
  402. dnl and also defining the type qualifier of first
  403. dnl argument in GETNAMEINFO_QUAL_ARG1.
  404. AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
  405. AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
  406. AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
  407. #
  408. AC_MSG_CHECKING([for getnameinfo])
  409. AC_LINK_IFELSE([
  410. AC_LANG_FUNC_LINK_TRY([getnameinfo])
  411. ],[
  412. AC_MSG_RESULT([yes])
  413. curl_cv_getnameinfo="yes"
  414. ],[
  415. AC_MSG_RESULT([no])
  416. curl_cv_getnameinfo="no"
  417. ])
  418. #
  419. if test "$curl_cv_getnameinfo" != "yes"; then
  420. AC_MSG_CHECKING([deeper for getnameinfo])
  421. AC_LINK_IFELSE([
  422. AC_LANG_PROGRAM([[
  423. ]],[[
  424. getnameinfo();
  425. ]])
  426. ],[
  427. AC_MSG_RESULT([yes])
  428. curl_cv_getnameinfo="yes"
  429. ],[
  430. AC_MSG_RESULT([but still no])
  431. curl_cv_getnameinfo="no"
  432. ])
  433. fi
  434. #
  435. if test "$curl_cv_getnameinfo" != "yes"; then
  436. AC_MSG_CHECKING([deeper and deeper for getnameinfo])
  437. AC_LINK_IFELSE([
  438. AC_LANG_PROGRAM([[
  439. #undef inline
  440. #ifdef HAVE_WINDOWS_H
  441. #ifndef WIN32_LEAN_AND_MEAN
  442. #define WIN32_LEAN_AND_MEAN
  443. #endif
  444. #include <windows.h>
  445. #ifdef HAVE_WINSOCK2_H
  446. #include <winsock2.h>
  447. #ifdef HAVE_WS2TCPIP_H
  448. #include <ws2tcpip.h>
  449. #endif
  450. #endif
  451. #else
  452. #ifdef HAVE_SYS_TYPES_H
  453. #include <sys/types.h>
  454. #endif
  455. #ifdef HAVE_SYS_SOCKET_H
  456. #include <sys/socket.h>
  457. #endif
  458. #ifdef HAVE_NETDB_H
  459. #include <netdb.h>
  460. #endif
  461. #endif
  462. ]],[[
  463. getnameinfo(0, 0, 0, 0, 0, 0, 0);
  464. ]])
  465. ],[
  466. AC_MSG_RESULT([yes])
  467. curl_cv_getnameinfo="yes"
  468. ],[
  469. AC_MSG_RESULT([but still no])
  470. curl_cv_getnameinfo="no"
  471. ])
  472. fi
  473. #
  474. if test "$curl_cv_getnameinfo" = "yes"; then
  475. AC_CACHE_CHECK([types of arguments for getnameinfo],
  476. [curl_cv_func_getnameinfo_args], [
  477. curl_cv_func_getnameinfo_args="unknown"
  478. for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
  479. for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
  480. for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
  481. for gni_arg7 in 'int' 'unsigned int'; do
  482. if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
  483. AC_COMPILE_IFELSE([
  484. AC_LANG_PROGRAM([[
  485. #undef inline
  486. #ifdef HAVE_WINDOWS_H
  487. #ifndef WIN32_LEAN_AND_MEAN
  488. #define WIN32_LEAN_AND_MEAN
  489. #endif
  490. #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
  491. #undef _WIN32_WINNT
  492. #define _WIN32_WINNT 0x0501
  493. #endif
  494. #include <windows.h>
  495. #ifdef HAVE_WINSOCK2_H
  496. #include <winsock2.h>
  497. #ifdef HAVE_WS2TCPIP_H
  498. #include <ws2tcpip.h>
  499. #endif
  500. #endif
  501. #define GNICALLCONV WSAAPI
  502. #else
  503. #ifdef HAVE_SYS_TYPES_H
  504. #include <sys/types.h>
  505. #endif
  506. #ifdef HAVE_SYS_SOCKET_H
  507. #include <sys/socket.h>
  508. #endif
  509. #ifdef HAVE_NETDB_H
  510. #include <netdb.h>
  511. #endif
  512. #define GNICALLCONV
  513. #endif
  514. extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
  515. char *, $gni_arg46,
  516. char *, $gni_arg46,
  517. $gni_arg7);
  518. ]],[[
  519. $gni_arg2 salen=0;
  520. $gni_arg46 hostlen=0;
  521. $gni_arg46 servlen=0;
  522. $gni_arg7 flags=0;
  523. int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
  524. ]])
  525. ],[
  526. curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
  527. ])
  528. fi
  529. done
  530. done
  531. done
  532. done
  533. ]) # AC-CACHE-CHECK
  534. if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
  535. AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
  536. AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
  537. else
  538. gni_prev_IFS=$IFS; IFS=','
  539. set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
  540. IFS=$gni_prev_IFS
  541. shift
  542. #
  543. gni_qual_type_arg1=$[1]
  544. #
  545. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
  546. [Define to the type of arg 2 for getnameinfo.])
  547. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
  548. [Define to the type of args 4 and 6 for getnameinfo.])
  549. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
  550. [Define to the type of arg 7 for getnameinfo.])
  551. #
  552. prev_sh_opts=$-
  553. #
  554. case $prev_sh_opts in
  555. *f*)
  556. ;;
  557. *)
  558. set -f
  559. ;;
  560. esac
  561. #
  562. case "$gni_qual_type_arg1" in
  563. const*)
  564. gni_qual_arg1=const
  565. gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
  566. ;;
  567. *)
  568. gni_qual_arg1=
  569. gni_type_arg1=$gni_qual_type_arg1
  570. ;;
  571. esac
  572. #
  573. AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
  574. [Define to the type qualifier of arg 1 for getnameinfo.])
  575. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
  576. [Define to the type of arg 1 for getnameinfo.])
  577. #
  578. case $prev_sh_opts in
  579. *f*)
  580. ;;
  581. *)
  582. set +f
  583. ;;
  584. esac
  585. #
  586. AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
  587. [Define to 1 if you have the getnameinfo function.])
  588. ac_cv_func_getnameinfo="yes"
  589. fi
  590. fi
  591. ])
  592. dnl TYPE_SOCKADDR_STORAGE
  593. dnl -------------------------------------------------
  594. dnl Check for struct sockaddr_storage. Most IPv6-enabled
  595. dnl hosts have it, but AIX 4.3 is one known exception.
  596. AC_DEFUN([TYPE_SOCKADDR_STORAGE],
  597. [
  598. AC_CHECK_TYPE([struct sockaddr_storage],
  599. AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
  600. [if struct sockaddr_storage is defined]), ,
  601. [
  602. #undef inline
  603. #ifdef HAVE_WINDOWS_H
  604. #ifndef WIN32_LEAN_AND_MEAN
  605. #define WIN32_LEAN_AND_MEAN
  606. #endif
  607. #include <windows.h>
  608. #ifdef HAVE_WINSOCK2_H
  609. #include <winsock2.h>
  610. #endif
  611. #else
  612. #ifdef HAVE_SYS_TYPES_H
  613. #include <sys/types.h>
  614. #endif
  615. #ifdef HAVE_SYS_SOCKET_H
  616. #include <sys/socket.h>
  617. #endif
  618. #ifdef HAVE_NETINET_IN_H
  619. #include <netinet/in.h>
  620. #endif
  621. #ifdef HAVE_ARPA_INET_H
  622. #include <arpa/inet.h>
  623. #endif
  624. #endif
  625. ])
  626. ])
  627. dnl CURL_CHECK_NI_WITHSCOPEID
  628. dnl -------------------------------------------------
  629. dnl Check for working NI_WITHSCOPEID in getnameinfo()
  630. AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
  631. AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
  632. AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
  633. AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
  634. netdb.h netinet/in.h arpa/inet.h)
  635. #
  636. AC_CACHE_CHECK([for working NI_WITHSCOPEID],
  637. [ac_cv_working_ni_withscopeid], [
  638. AC_RUN_IFELSE([
  639. AC_LANG_PROGRAM([[
  640. #ifdef HAVE_STDLIB_H
  641. #include <stdlib.h>
  642. #endif
  643. #ifdef HAVE_STDIO_H
  644. #include <stdio.h>
  645. #endif
  646. #ifdef HAVE_SYS_TYPES_H
  647. #include <sys/types.h>
  648. #endif
  649. #ifdef HAVE_SYS_SOCKET_H
  650. #include <sys/socket.h>
  651. #endif
  652. #ifdef HAVE_NETDB_H
  653. #include <netdb.h>
  654. #endif
  655. #ifdef HAVE_NETINET_IN_H
  656. #include <netinet/in.h>
  657. #endif
  658. #ifdef HAVE_ARPA_INET_H
  659. #include <arpa/inet.h>
  660. #endif
  661. ]],[[
  662. #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
  663. #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
  664. struct sockaddr_storage sa;
  665. #else
  666. unsigned char sa[256];
  667. #endif
  668. char hostbuf[NI_MAXHOST];
  669. int rc;
  670. GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
  671. GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
  672. GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
  673. int fd = socket(AF_INET6, SOCK_STREAM, 0);
  674. if(fd < 0) {
  675. perror("socket()");
  676. return 1; /* Error creating socket */
  677. }
  678. rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
  679. if(rc) {
  680. perror("getsockname()");
  681. return 2; /* Error retrieving socket name */
  682. }
  683. rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
  684. if(rc) {
  685. printf("rc = %s\n", gai_strerror(rc));
  686. return 3; /* Error translating socket address */
  687. }
  688. return 0; /* Ok, NI_WITHSCOPEID works */
  689. #else
  690. return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
  691. #endif
  692. ]]) # AC-LANG-PROGRAM
  693. ],[
  694. # Exit code == 0. Program worked.
  695. ac_cv_working_ni_withscopeid="yes"
  696. ],[
  697. # Exit code != 0. Program failed.
  698. ac_cv_working_ni_withscopeid="no"
  699. ],[
  700. # Program is not run when cross-compiling. So we assume
  701. # NI_WITHSCOPEID will work if we are able to compile it.
  702. AC_COMPILE_IFELSE([
  703. AC_LANG_PROGRAM([[
  704. #include <sys/types.h>
  705. #include <sys/socket.h>
  706. #include <netdb.h>
  707. ]],[[
  708. unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
  709. ]])
  710. ],[
  711. ac_cv_working_ni_withscopeid="yes"
  712. ],[
  713. ac_cv_working_ni_withscopeid="no"
  714. ]) # AC-COMPILE-IFELSE
  715. ]) # AC-RUN-IFELSE
  716. ]) # AC-CACHE-CHECK
  717. case "$ac_cv_working_ni_withscopeid" in
  718. yes)
  719. AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
  720. [Define to 1 if NI_WITHSCOPEID exists and works.])
  721. ;;
  722. esac
  723. ])
  724. dnl CURL_CHECK_FUNC_RECV
  725. dnl -------------------------------------------------
  726. dnl Test if the socket recv() function is available,
  727. dnl and check its return type and the types of its
  728. dnl arguments. If the function succeeds HAVE_RECV
  729. dnl will be defined, defining the types of the arguments
  730. dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
  731. dnl and RECV_TYPE_ARG4, defining the type of the function
  732. dnl return value in RECV_TYPE_RETV.
  733. AC_DEFUN([CURL_CHECK_FUNC_RECV], [
  734. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  735. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  736. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  737. #
  738. AC_MSG_CHECKING([for recv])
  739. AC_LINK_IFELSE([
  740. AC_LANG_PROGRAM([[
  741. #undef inline
  742. #ifdef HAVE_WINDOWS_H
  743. #ifndef WIN32_LEAN_AND_MEAN
  744. #define WIN32_LEAN_AND_MEAN
  745. #endif
  746. #include <windows.h>
  747. #ifdef HAVE_WINSOCK2_H
  748. #include <winsock2.h>
  749. #else
  750. #ifdef HAVE_WINSOCK_H
  751. #include <winsock.h>
  752. #endif
  753. #endif
  754. #else
  755. #ifdef HAVE_SYS_TYPES_H
  756. #include <sys/types.h>
  757. #endif
  758. #ifdef HAVE_SYS_SOCKET_H
  759. #include <sys/socket.h>
  760. #endif
  761. #endif
  762. ]],[[
  763. recv(0, 0, 0, 0);
  764. ]])
  765. ],[
  766. AC_MSG_RESULT([yes])
  767. curl_cv_recv="yes"
  768. ],[
  769. AC_MSG_RESULT([no])
  770. curl_cv_recv="no"
  771. ])
  772. #
  773. if test "$curl_cv_recv" = "yes"; then
  774. AC_CACHE_CHECK([types of args and return type for recv],
  775. [curl_cv_func_recv_args], [
  776. curl_cv_func_recv_args="unknown"
  777. for recv_retv in 'int' 'ssize_t'; do
  778. for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  779. for recv_arg2 in 'char *' 'void *'; do
  780. for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  781. for recv_arg4 in 'int' 'unsigned int'; do
  782. if test "$curl_cv_func_recv_args" = "unknown"; then
  783. AC_COMPILE_IFELSE([
  784. AC_LANG_PROGRAM([[
  785. #undef inline
  786. #ifdef HAVE_WINDOWS_H
  787. #ifndef WIN32_LEAN_AND_MEAN
  788. #define WIN32_LEAN_AND_MEAN
  789. #endif
  790. #include <windows.h>
  791. #ifdef HAVE_WINSOCK2_H
  792. #include <winsock2.h>
  793. #else
  794. #ifdef HAVE_WINSOCK_H
  795. #include <winsock.h>
  796. #endif
  797. #endif
  798. #define RECVCALLCONV PASCAL
  799. #else
  800. #ifdef HAVE_SYS_TYPES_H
  801. #include <sys/types.h>
  802. #endif
  803. #ifdef HAVE_SYS_SOCKET_H
  804. #include <sys/socket.h>
  805. #endif
  806. #define RECVCALLCONV
  807. #endif
  808. extern $recv_retv RECVCALLCONV
  809. recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
  810. ]],[[
  811. $recv_arg1 s=0;
  812. $recv_arg2 buf=0;
  813. $recv_arg3 len=0;
  814. $recv_arg4 flags=0;
  815. $recv_retv res = recv(s, buf, len, flags);
  816. ]])
  817. ],[
  818. curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
  819. ])
  820. fi
  821. done
  822. done
  823. done
  824. done
  825. done
  826. ]) # AC-CACHE-CHECK
  827. if test "$curl_cv_func_recv_args" = "unknown"; then
  828. AC_MSG_ERROR([Cannot find proper types to use for recv args])
  829. else
  830. recv_prev_IFS=$IFS; IFS=','
  831. set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
  832. IFS=$recv_prev_IFS
  833. shift
  834. #
  835. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
  836. [Define to the type of arg 1 for recv.])
  837. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
  838. [Define to the type of arg 2 for recv.])
  839. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
  840. [Define to the type of arg 3 for recv.])
  841. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
  842. [Define to the type of arg 4 for recv.])
  843. AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
  844. [Define to the function return type for recv.])
  845. #
  846. AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
  847. [Define to 1 if you have the recv function.])
  848. ac_cv_func_recv="yes"
  849. fi
  850. else
  851. AC_MSG_ERROR([Unable to link function recv])
  852. fi
  853. ])
  854. dnl CURL_CHECK_FUNC_SEND
  855. dnl -------------------------------------------------
  856. dnl Test if the socket send() function is available,
  857. dnl and check its return type and the types of its
  858. dnl arguments. If the function succeeds HAVE_SEND
  859. dnl will be defined, defining the types of the arguments
  860. dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
  861. dnl and SEND_TYPE_ARG4, defining the type of the function
  862. dnl return value in SEND_TYPE_RETV, and also defining the
  863. dnl type qualifier of second argument in SEND_QUAL_ARG2.
  864. AC_DEFUN([CURL_CHECK_FUNC_SEND], [
  865. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  866. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  867. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  868. #
  869. AC_MSG_CHECKING([for send])
  870. AC_LINK_IFELSE([
  871. AC_LANG_PROGRAM([[
  872. #undef inline
  873. #ifdef HAVE_WINDOWS_H
  874. #ifndef WIN32_LEAN_AND_MEAN
  875. #define WIN32_LEAN_AND_MEAN
  876. #endif
  877. #include <windows.h>
  878. #ifdef HAVE_WINSOCK2_H
  879. #include <winsock2.h>
  880. #else
  881. #ifdef HAVE_WINSOCK_H
  882. #include <winsock.h>
  883. #endif
  884. #endif
  885. #else
  886. #ifdef HAVE_SYS_TYPES_H
  887. #include <sys/types.h>
  888. #endif
  889. #ifdef HAVE_SYS_SOCKET_H
  890. #include <sys/socket.h>
  891. #endif
  892. #endif
  893. ]],[[
  894. send(0, 0, 0, 0);
  895. ]])
  896. ],[
  897. AC_MSG_RESULT([yes])
  898. curl_cv_send="yes"
  899. ],[
  900. AC_MSG_RESULT([no])
  901. curl_cv_send="no"
  902. ])
  903. #
  904. if test "$curl_cv_send" = "yes"; then
  905. AC_CACHE_CHECK([types of args and return type for send],
  906. [curl_cv_func_send_args], [
  907. curl_cv_func_send_args="unknown"
  908. for send_retv in 'int' 'ssize_t'; do
  909. for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  910. for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
  911. for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  912. for send_arg4 in 'int' 'unsigned int'; do
  913. if test "$curl_cv_func_send_args" = "unknown"; then
  914. AC_COMPILE_IFELSE([
  915. AC_LANG_PROGRAM([[
  916. #undef inline
  917. #ifdef HAVE_WINDOWS_H
  918. #ifndef WIN32_LEAN_AND_MEAN
  919. #define WIN32_LEAN_AND_MEAN
  920. #endif
  921. #include <windows.h>
  922. #ifdef HAVE_WINSOCK2_H
  923. #include <winsock2.h>
  924. #else
  925. #ifdef HAVE_WINSOCK_H
  926. #include <winsock.h>
  927. #endif
  928. #endif
  929. #define SENDCALLCONV PASCAL
  930. #else
  931. #ifdef HAVE_SYS_TYPES_H
  932. #include <sys/types.h>
  933. #endif
  934. #ifdef HAVE_SYS_SOCKET_H
  935. #include <sys/socket.h>
  936. #endif
  937. #define SENDCALLCONV
  938. #endif
  939. extern $send_retv SENDCALLCONV
  940. send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
  941. ]],[[
  942. $send_arg1 s=0;
  943. $send_arg3 len=0;
  944. $send_arg4 flags=0;
  945. $send_retv res = send(s, 0, len, flags);
  946. ]])
  947. ],[
  948. curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
  949. ])
  950. fi
  951. done
  952. done
  953. done
  954. done
  955. done
  956. ]) # AC-CACHE-CHECK
  957. if test "$curl_cv_func_send_args" = "unknown"; then
  958. AC_MSG_ERROR([Cannot find proper types to use for send args])
  959. else
  960. send_prev_IFS=$IFS; IFS=','
  961. set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
  962. IFS=$send_prev_IFS
  963. shift
  964. #
  965. send_qual_type_arg2=$[2]
  966. #
  967. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
  968. [Define to the type of arg 1 for send.])
  969. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
  970. [Define to the type of arg 3 for send.])
  971. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
  972. [Define to the type of arg 4 for send.])
  973. AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
  974. [Define to the function return type for send.])
  975. #
  976. prev_sh_opts=$-
  977. #
  978. case $prev_sh_opts in
  979. *f*)
  980. ;;
  981. *)
  982. set -f
  983. ;;
  984. esac
  985. #
  986. case "$send_qual_type_arg2" in
  987. const*)
  988. send_qual_arg2=const
  989. send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
  990. ;;
  991. *)
  992. send_qual_arg2=
  993. send_type_arg2=$send_qual_type_arg2
  994. ;;
  995. esac
  996. #
  997. AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
  998. [Define to the type qualifier of arg 2 for send.])
  999. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
  1000. [Define to the type of arg 2 for send.])
  1001. #
  1002. case $prev_sh_opts in
  1003. *f*)
  1004. ;;
  1005. *)
  1006. set +f
  1007. ;;
  1008. esac
  1009. #
  1010. AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
  1011. [Define to 1 if you have the send function.])
  1012. ac_cv_func_send="yes"
  1013. fi
  1014. else
  1015. AC_MSG_ERROR([Unable to link function send])
  1016. fi
  1017. ])
  1018. dnl CURL_CHECK_FUNC_RECVFROM
  1019. dnl -------------------------------------------------
  1020. dnl Test if the socket recvfrom() function is available,
  1021. dnl and check its return type and the types of its
  1022. dnl arguments. If the function succeeds HAVE_RECVFROM
  1023. dnl will be defined, defining the types of the arguments
  1024. dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
  1025. dnl to RECVFROM_TYPE_ARG6, defining also the type of the
  1026. dnl function return value in RECVFROM_TYPE_RETV.
  1027. dnl Notice that the types returned for pointer arguments
  1028. dnl will actually be the type pointed by the pointer.
  1029. AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
  1030. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1031. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1032. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1033. #
  1034. AC_MSG_CHECKING([for recvfrom])
  1035. AC_LINK_IFELSE([
  1036. AC_LANG_PROGRAM([[
  1037. #undef inline
  1038. #ifdef HAVE_WINDOWS_H
  1039. #ifndef WIN32_LEAN_AND_MEAN
  1040. #define WIN32_LEAN_AND_MEAN
  1041. #endif
  1042. #include <windows.h>
  1043. #ifdef HAVE_WINSOCK2_H
  1044. #include <winsock2.h>
  1045. #else
  1046. #ifdef HAVE_WINSOCK_H
  1047. #include <winsock.h>
  1048. #endif
  1049. #endif
  1050. #else
  1051. #ifdef HAVE_SYS_TYPES_H
  1052. #include <sys/types.h>
  1053. #endif
  1054. #ifdef HAVE_SYS_SOCKET_H
  1055. #include <sys/socket.h>
  1056. #endif
  1057. #endif
  1058. ]],[[
  1059. recvfrom(0, 0, 0, 0, 0, 0);
  1060. ]])
  1061. ],[
  1062. AC_MSG_RESULT([yes])
  1063. curl_cv_recvfrom="yes"
  1064. ],[
  1065. AC_MSG_RESULT([no])
  1066. curl_cv_recvfrom="no"
  1067. ])
  1068. #
  1069. if test "$curl_cv_recvfrom" = "yes"; then
  1070. AC_CACHE_CHECK([types of args and return type for recvfrom],
  1071. [curl_cv_func_recvfrom_args], [
  1072. curl_cv_func_recvfrom_args="unknown"
  1073. for recvfrom_retv in 'int' 'ssize_t'; do
  1074. for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1075. for recvfrom_arg2 in 'char *' 'void *'; do
  1076. for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1077. for recvfrom_arg4 in 'int' 'unsigned int'; do
  1078. for recvfrom_arg5 in 'struct sockaddr *' 'void *' 'const struct sockaddr *'; do
  1079. for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
  1080. if test "$curl_cv_func_recvfrom_args" = "unknown"; then
  1081. AC_COMPILE_IFELSE([
  1082. AC_LANG_PROGRAM([[
  1083. #undef inline
  1084. #ifdef HAVE_WINDOWS_H
  1085. #ifndef WIN32_LEAN_AND_MEAN
  1086. #define WIN32_LEAN_AND_MEAN
  1087. #endif
  1088. #include <windows.h>
  1089. #ifdef HAVE_WINSOCK2_H
  1090. #include <winsock2.h>
  1091. #else
  1092. #ifdef HAVE_WINSOCK_H
  1093. #include <winsock.h>
  1094. #endif
  1095. #endif
  1096. #define RECVFROMCALLCONV PASCAL
  1097. #else
  1098. #ifdef HAVE_SYS_TYPES_H
  1099. #include <sys/types.h>
  1100. #endif
  1101. #ifdef HAVE_SYS_SOCKET_H
  1102. #include <sys/socket.h>
  1103. #endif
  1104. #define RECVFROMCALLCONV
  1105. #endif
  1106. extern $recvfrom_retv RECVFROMCALLCONV
  1107. recvfrom($recvfrom_arg1, $recvfrom_arg2,
  1108. $recvfrom_arg3, $recvfrom_arg4,
  1109. $recvfrom_arg5, $recvfrom_arg6);
  1110. ]],[[
  1111. $recvfrom_arg1 s=0;
  1112. $recvfrom_arg2 buf=0;
  1113. $recvfrom_arg3 len=0;
  1114. $recvfrom_arg4 flags=0;
  1115. $recvfrom_arg5 addr=0;
  1116. $recvfrom_arg6 addrlen=0;
  1117. $recvfrom_retv res=0;
  1118. res = recvfrom(s, buf, len, flags, addr, addrlen);
  1119. ]])
  1120. ],[
  1121. curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
  1122. ])
  1123. fi
  1124. done
  1125. done
  1126. done
  1127. done
  1128. done
  1129. done
  1130. done
  1131. ]) # AC-CACHE-CHECK
  1132. # Nearly last minute change for this release starts here
  1133. AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
  1134. [Define to 1 if you have the recvfrom function.])
  1135. ac_cv_func_recvfrom="yes"
  1136. # Nearly last minute change for this release ends here
  1137. if test "$curl_cv_func_recvfrom_args" = "unknown"; then
  1138. AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
  1139. else
  1140. recvfrom_prev_IFS=$IFS; IFS=','
  1141. set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
  1142. IFS=$recvfrom_prev_IFS
  1143. shift
  1144. #
  1145. recvfrom_ptrt_arg2=$[2]
  1146. recvfrom_qual_ptrt_arg5=$[5]
  1147. recvfrom_ptrt_arg6=$[6]
  1148. #
  1149. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
  1150. [Define to the type of arg 1 for recvfrom.])
  1151. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
  1152. [Define to the type of arg 3 for recvfrom.])
  1153. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
  1154. [Define to the type of arg 4 for recvfrom.])
  1155. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
  1156. [Define to the function return type for recvfrom.])
  1157. #
  1158. prev_sh_opts=$-
  1159. #
  1160. case $prev_sh_opts in
  1161. *f*)
  1162. ;;
  1163. *)
  1164. set -f
  1165. ;;
  1166. esac
  1167. #
  1168. case "$recvfrom_qual_ptrt_arg5" in
  1169. const*)
  1170. recvfrom_qual_arg5=const
  1171. recvfrom_ptrt_arg5=`echo $recvfrom_qual_ptrt_arg5 | sed 's/^const //'`
  1172. ;;
  1173. *)
  1174. recvfrom_qual_arg5=
  1175. recvfrom_ptrt_arg5=$recvfrom_qual_ptrt_arg5
  1176. ;;
  1177. esac
  1178. #
  1179. recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
  1180. recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
  1181. recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
  1182. #
  1183. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
  1184. [Define to the type pointed by arg 2 for recvfrom.])
  1185. AC_DEFINE_UNQUOTED(RECVFROM_QUAL_ARG5, $recvfrom_qual_arg5,
  1186. [Define to the type qualifier pointed by arg 5 for recvfrom.])
  1187. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
  1188. [Define to the type pointed by arg 5 for recvfrom.])
  1189. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
  1190. [Define to the type pointed by arg 6 for recvfrom.])
  1191. #
  1192. if test "$recvfrom_type_arg2" = "void"; then
  1193. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
  1194. [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
  1195. fi
  1196. if test "$recvfrom_type_arg5" = "void"; then
  1197. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
  1198. [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
  1199. fi
  1200. if test "$recvfrom_type_arg6" = "void"; then
  1201. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
  1202. [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
  1203. fi
  1204. #
  1205. case $prev_sh_opts in
  1206. *f*)
  1207. ;;
  1208. *)
  1209. set +f
  1210. ;;
  1211. esac
  1212. #
  1213. AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
  1214. [Define to 1 if you have the recvfrom function.])
  1215. ac_cv_func_recvfrom="yes"
  1216. fi
  1217. else
  1218. AC_MSG_WARN([Unable to link function recvfrom])
  1219. AC_MSG_WARN([Your system will be vulnerable to some forms of DNS cache poisoning])
  1220. fi
  1221. ])
  1222. dnl CURL_CHECK_MSG_NOSIGNAL
  1223. dnl -------------------------------------------------
  1224. dnl Check for MSG_NOSIGNAL
  1225. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  1226. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1227. AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
  1228. AC_COMPILE_IFELSE([
  1229. AC_LANG_PROGRAM([[
  1230. #undef inline
  1231. #ifdef HAVE_WINDOWS_H
  1232. #ifndef WIN32_LEAN_AND_MEAN
  1233. #define WIN32_LEAN_AND_MEAN
  1234. #endif
  1235. #include <windows.h>
  1236. #ifdef HAVE_WINSOCK2_H
  1237. #include <winsock2.h>
  1238. #else
  1239. #ifdef HAVE_WINSOCK_H
  1240. #include <winsock.h>
  1241. #endif
  1242. #endif
  1243. #else
  1244. #ifdef HAVE_SYS_TYPES_H
  1245. #include <sys/types.h>
  1246. #endif
  1247. #ifdef HAVE_SYS_SOCKET_H
  1248. #include <sys/socket.h>
  1249. #endif
  1250. #endif
  1251. ]],[[
  1252. int flag=MSG_NOSIGNAL;
  1253. ]])
  1254. ],[
  1255. ac_cv_msg_nosignal="yes"
  1256. ],[
  1257. ac_cv_msg_nosignal="no"
  1258. ])
  1259. ])
  1260. case "$ac_cv_msg_nosignal" in
  1261. yes)
  1262. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  1263. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  1264. ;;
  1265. esac
  1266. ])
  1267. dnl CURL_CHECK_STRUCT_TIMEVAL
  1268. dnl -------------------------------------------------
  1269. dnl Check for timeval struct
  1270. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  1271. AC_REQUIRE([AC_HEADER_TIME])dnl
  1272. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1273. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1274. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
  1275. AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
  1276. AC_COMPILE_IFELSE([
  1277. AC_LANG_PROGRAM([[
  1278. #undef inline
  1279. #ifdef HAVE_WINDOWS_H
  1280. #ifndef WIN32_LEAN_AND_MEAN
  1281. #define WIN32_LEAN_AND_MEAN
  1282. #endif
  1283. #include <windows.h>
  1284. #ifdef HAVE_WINSOCK2_H
  1285. #include <winsock2.h>
  1286. #else
  1287. #ifdef HAVE_WINSOCK_H
  1288. #include <winsock.h>
  1289. #endif
  1290. #endif
  1291. #endif
  1292. #ifdef HAVE_SYS_TYPES_H
  1293. #include <sys/types.h>
  1294. #endif
  1295. #ifdef HAVE_SYS_TIME_H
  1296. #include <sys/time.h>
  1297. #ifdef TIME_WITH_SYS_TIME
  1298. #include <time.h>
  1299. #endif
  1300. #else
  1301. #ifdef HAVE_TIME_H
  1302. #include <time.h>
  1303. #endif
  1304. #endif
  1305. #ifdef HAVE_SYS_SOCKET_H
  1306. #include <sys/socket.h>
  1307. #endif
  1308. ]],[[
  1309. struct timeval ts;
  1310. ts.tv_sec = 0;
  1311. ts.tv_usec = 0;
  1312. ]])
  1313. ],[
  1314. ac_cv_struct_timeval="yes"
  1315. ],[
  1316. ac_cv_struct_timeval="no"
  1317. ])
  1318. ])
  1319. case "$ac_cv_struct_timeval" in
  1320. yes)
  1321. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  1322. [Define to 1 if you have the timeval struct.])
  1323. ;;
  1324. esac
  1325. ])
  1326. dnl TYPE_SIG_ATOMIC_T
  1327. dnl -------------------------------------------------
  1328. dnl Check if the sig_atomic_t type is available, and
  1329. dnl verify if it is already defined as volatile.
  1330. AC_DEFUN([TYPE_SIG_ATOMIC_T], [
  1331. AC_CHECK_HEADERS(signal.h)
  1332. AC_CHECK_TYPE([sig_atomic_t],[
  1333. AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
  1334. [Define to 1 if sig_atomic_t is an available typedef.])
  1335. ], ,[
  1336. #ifdef HAVE_SIGNAL_H
  1337. #include <signal.h>
  1338. #endif
  1339. ])
  1340. case "$ac_cv_type_sig_atomic_t" in
  1341. yes)
  1342. #
  1343. AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
  1344. AC_LINK_IFELSE([
  1345. AC_LANG_PROGRAM([[
  1346. #ifdef HAVE_SIGNAL_H
  1347. #include <signal.h>
  1348. #endif
  1349. ]],[[
  1350. static volatile sig_atomic_t dummy = 0;
  1351. ]])
  1352. ],[
  1353. AC_MSG_RESULT([no])
  1354. ac_cv_sig_atomic_t_volatile="no"
  1355. ],[
  1356. AC_MSG_RESULT([yes])
  1357. ac_cv_sig_atomic_t_volatile="yes"
  1358. ])
  1359. #
  1360. if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
  1361. AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
  1362. [Define to 1 if sig_atomic_t is already defined as volatile.])
  1363. fi
  1364. ;;
  1365. esac
  1366. ])
  1367. dnl TYPE_IN_ADDR_T
  1368. dnl -------------------------------------------------
  1369. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  1370. dnl and a few other things.
  1371. AC_DEFUN([TYPE_IN_ADDR_T], [
  1372. AC_CHECK_TYPE([in_addr_t], ,[
  1373. dnl in_addr_t not available
  1374. AC_CACHE_CHECK([for in_addr_t equivalent],
  1375. [curl_cv_in_addr_t_equiv], [
  1376. curl_cv_in_addr_t_equiv="unknown"
  1377. for t in "unsigned long" int size_t unsigned long; do
  1378. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  1379. AC_LINK_IFELSE([
  1380. AC_LANG_PROGRAM([[
  1381. #undef inline
  1382. #ifdef HAVE_WINDOWS_H
  1383. #ifndef WIN32_LEAN_AND_MEAN
  1384. #define WIN32_LEAN_AND_MEAN
  1385. #endif
  1386. #include <windows.h>
  1387. #ifdef HAVE_WINSOCK2_H
  1388. #include <winsock2.h>
  1389. #else
  1390. #ifdef HAVE_WINSOCK_H
  1391. #include <winsock.h>
  1392. #endif
  1393. #endif
  1394. #else
  1395. #ifdef HAVE_SYS_TYPES_H
  1396. #include <sys/types.h>
  1397. #endif
  1398. #ifdef HAVE_SYS_SOCKET_H
  1399. #include <sys/socket.h>
  1400. #endif
  1401. #ifdef HAVE_NETINET_IN_H
  1402. #include <netinet/in.h>
  1403. #endif
  1404. #ifdef HAVE_ARPA_INET_H
  1405. #include <arpa/inet.h>
  1406. #endif
  1407. #endif
  1408. ]],[[
  1409. $t data = inet_addr ("1.2.3.4");
  1410. ]])
  1411. ],[
  1412. curl_cv_in_addr_t_equiv="$t"
  1413. ])
  1414. fi
  1415. done
  1416. ])
  1417. case "$curl_cv_in_addr_t_equiv" in
  1418. unknown)
  1419. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  1420. ;;
  1421. *)
  1422. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  1423. [Type to use in place of in_addr_t when system does not provide it.])
  1424. ;;
  1425. esac
  1426. ],[
  1427. #undef inline
  1428. #ifdef HAVE_WINDOWS_H
  1429. #ifndef WIN32_LEAN_AND_MEAN
  1430. #define WIN32_LEAN_AND_MEAN
  1431. #endif
  1432. #include <windows.h>
  1433. #ifdef HAVE_WINSOCK2_H
  1434. #include <winsock2.h>
  1435. #else
  1436. #ifdef HAVE_WINSOCK_H
  1437. #include <winsock.h>
  1438. #endif
  1439. #endif
  1440. #else
  1441. #ifdef HAVE_SYS_TYPES_H
  1442. #include <sys/types.h>
  1443. #endif
  1444. #ifdef HAVE_SYS_SOCKET_H
  1445. #include <sys/socket.h>
  1446. #endif
  1447. #ifdef HAVE_NETINET_IN_H
  1448. #include <netinet/in.h>
  1449. #endif
  1450. #ifdef HAVE_ARPA_INET_H
  1451. #include <arpa/inet.h>
  1452. #endif
  1453. #endif
  1454. ])
  1455. ])
  1456. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  1457. dnl -------------------------------------------------
  1458. dnl Check if monotonic clock_gettime is available.
  1459. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  1460. AC_REQUIRE([AC_HEADER_TIME])dnl
  1461. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
  1462. AC_MSG_CHECKING([for monotonic clock_gettime])
  1463. AC_COMPILE_IFELSE([
  1464. AC_LANG_PROGRAM([[
  1465. #ifdef HAVE_SYS_TYPES_H
  1466. #include <sys/types.h>
  1467. #endif
  1468. #ifdef HAVE_SYS_TIME_H
  1469. #include <sys/time.h>
  1470. #ifdef TIME_WITH_SYS_TIME
  1471. #include <time.h>
  1472. #endif
  1473. #else
  1474. #ifdef HAVE_TIME_H
  1475. #include <time.h>
  1476. #endif
  1477. #endif
  1478. ]],[[
  1479. struct timespec ts;
  1480. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1481. ]])
  1482. ],[
  1483. AC_MSG_RESULT([yes])
  1484. ac_cv_func_clock_gettime="yes"
  1485. ],[
  1486. AC_MSG_RESULT([no])
  1487. ac_cv_func_clock_gettime="no"
  1488. ])
  1489. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  1490. dnl until library linking and run-time checks for clock_gettime succeed.
  1491. ])
  1492. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  1493. dnl -------------------------------------------------
  1494. dnl If monotonic clock_gettime is available then,
  1495. dnl check and prepended to LIBS any needed libraries.
  1496. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  1497. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  1498. #
  1499. if test "$ac_cv_func_clock_gettime" = "yes"; then
  1500. #
  1501. AC_MSG_CHECKING([for clock_gettime in libraries])
  1502. #
  1503. curl_cv_save_LIBS="$LIBS"
  1504. curl_cv_gclk_LIBS="unknown"
  1505. #
  1506. for x_xlibs in '' '-lrt' '-lposix4' ; do
  1507. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  1508. if test -z "$x_xlibs"; then
  1509. LIBS="$curl_cv_save_LIBS"
  1510. else
  1511. LIBS="$x_xlibs $curl_cv_save_LIBS"
  1512. fi
  1513. AC_LINK_IFELSE([
  1514. AC_LANG_PROGRAM([[
  1515. #ifdef HAVE_SYS_TYPES_H
  1516. #include <sys/types.h>
  1517. #endif
  1518. #ifdef HAVE_SYS_TIME_H
  1519. #include <sys/time.h>
  1520. #ifdef TIME_WITH_SYS_TIME
  1521. #include <time.h>
  1522. #endif
  1523. #else
  1524. #ifdef HAVE_TIME_H
  1525. #include <time.h>
  1526. #endif
  1527. #endif
  1528. ]],[[
  1529. struct timespec ts;
  1530. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1531. ]])
  1532. ],[
  1533. curl_cv_gclk_LIBS="$x_xlibs"
  1534. ])
  1535. fi
  1536. done
  1537. #
  1538. LIBS="$curl_cv_save_LIBS"
  1539. #
  1540. case X-"$curl_cv_gclk_LIBS" in
  1541. X-unknown)
  1542. AC_MSG_RESULT([cannot find clock_gettime])
  1543. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1544. ac_cv_func_clock_gettime="no"
  1545. ;;
  1546. X-)
  1547. AC_MSG_RESULT([no additional lib required])
  1548. ac_cv_func_clock_gettime="yes"
  1549. ;;
  1550. *)
  1551. if test -z "$curl_cv_save_LIBS"; then
  1552. LIBS="$curl_cv_gclk_LIBS"
  1553. else
  1554. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  1555. fi
  1556. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  1557. ac_cv_func_clock_gettime="yes"
  1558. ;;
  1559. esac
  1560. #
  1561. dnl only do runtime verification when not cross-compiling
  1562. if test "x$cross_compiling" != "xyes" &&
  1563. test "$ac_cv_func_clock_gettime" = "yes"; then
  1564. AC_MSG_CHECKING([if monotonic clock_gettime works])
  1565. AC_RUN_IFELSE([
  1566. AC_LANG_PROGRAM([[
  1567. #ifdef HAVE_STDLIB_H
  1568. #include <stdlib.h>
  1569. #endif
  1570. #ifdef HAVE_SYS_TYPES_H
  1571. #include <sys/types.h>
  1572. #endif
  1573. #ifdef HAVE_SYS_TIME_H
  1574. #include <sys/time.h>
  1575. #ifdef TIME_WITH_SYS_TIME
  1576. #include <time.h>
  1577. #endif
  1578. #else
  1579. #ifdef HAVE_TIME_H
  1580. #include <time.h>
  1581. #endif
  1582. #endif
  1583. ]],[[
  1584. struct timespec ts;
  1585. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  1586. exit(0);
  1587. else
  1588. exit(1);
  1589. ]])
  1590. ],[
  1591. AC_MSG_RESULT([yes])
  1592. ],[
  1593. AC_MSG_RESULT([no])
  1594. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1595. ac_cv_func_clock_gettime="no"
  1596. LIBS="$curl_cv_save_LIBS"
  1597. ])
  1598. fi
  1599. #
  1600. case "$ac_cv_func_clock_gettime" in
  1601. yes)
  1602. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  1603. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  1604. ;;
  1605. esac
  1606. #
  1607. fi
  1608. #
  1609. ])
  1610. dnl CARES_CHECK_LIBS_CONNECT
  1611. dnl -------------------------------------------------
  1612. dnl Verify if network connect function is already available
  1613. dnl using current libraries or if another one is required.
  1614. AC_DEFUN([CARES_CHECK_LIBS_CONNECT], [
  1615. AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
  1616. AC_MSG_CHECKING([for connect in libraries])
  1617. tst_connect_save_LIBS="$LIBS"
  1618. tst_connect_need_LIBS="unknown"
  1619. for tst_lib in '' '-lsocket' ; do
  1620. if test "$tst_connect_need_LIBS" = "unknown"; then
  1621. LIBS="$tst_lib $tst_connect_save_LIBS"
  1622. AC_LINK_IFELSE([
  1623. AC_LANG_PROGRAM([[
  1624. $cares_includes_winsock2
  1625. #ifndef HAVE_WINDOWS_H
  1626. int connect(int, void*, int);
  1627. #endif
  1628. ]],[[
  1629. if(0 != connect(0, 0, 0))
  1630. return 1;
  1631. ]])
  1632. ],[
  1633. tst_connect_need_LIBS="$tst_lib"
  1634. ])
  1635. fi
  1636. done
  1637. LIBS="$tst_connect_save_LIBS"
  1638. #
  1639. case X-"$tst_connect_need_LIBS" in
  1640. X-unknown)
  1641. AC_MSG_RESULT([cannot find connect])
  1642. AC_MSG_ERROR([cannot find connect function in libraries.])
  1643. ;;
  1644. X-)
  1645. AC_MSG_RESULT([yes])
  1646. ;;
  1647. *)
  1648. AC_MSG_RESULT([$tst_connect_need_LIBS])
  1649. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  1650. ;;
  1651. esac
  1652. ])
  1653. dnl CARES_DEFINE_UNQUOTED (VARIABLE, [VALUE])
  1654. dnl -------------------------------------------------
  1655. dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
  1656. dnl symbol that can be further used in custom template configuration
  1657. dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
  1658. dnl argument for the description. Symbol definitions done with this
  1659. dnl macro are intended to be exclusively used in handcrafted *.h.in
  1660. dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
  1661. dnl prevents autoheader generation and insertion of symbol template
  1662. dnl stub and definition into the first configuration header file. Do
  1663. dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
  1664. dnl one serves different functional needs.
  1665. AC_DEFUN([CARES_DEFINE_UNQUOTED], [
  1666. cat >>confdefs.h <<_EOF
  1667. [@%:@define] $1 ifelse($#, 2, [$2], 1)
  1668. _EOF
  1669. ])
  1670. dnl CARES_CONFIGURE_ARES_SOCKLEN_T
  1671. dnl -------------------------------------------------
  1672. dnl Find out suitable ares_socklen_t data type definition and size, making
  1673. dnl appropriate definitions for template file ares_build.h.in
  1674. dnl to properly configure and use the library.
  1675. dnl
  1676. dnl The need for the ares_socklen_t definition arises mainly to properly
  1677. dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
  1678. dnl data type which is 32 or 64-Bit wide depending on the data model being
  1679. dnl used, and that on the other hand is only actually used when interfacing
  1680. dnl the X/Open sockets provided in the xnet library.
  1681. AC_DEFUN([CARES_CONFIGURE_ARES_SOCKLEN_T], [
  1682. AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
  1683. AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
  1684. AC_REQUIRE([CARES_PREPROCESS_CALLCONV])dnl
  1685. #
  1686. AC_MSG_CHECKING([for ares_socklen_t data type])
  1687. cares_typeof_ares_socklen_t="unknown"
  1688. for arg1 in int SOCKET; do
  1689. for arg2 in 'struct sockaddr' void; do
  1690. for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
  1691. if test "$cares_typeof_ares_socklen_t" = "unknown"; then
  1692. AC_COMPILE_IFELSE([
  1693. AC_LANG_PROGRAM([[
  1694. $cares_includes_ws2tcpip
  1695. $cares_includes_sys_socket
  1696. $cares_preprocess_callconv
  1697. extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
  1698. ]],[[
  1699. $t *lenptr = 0;
  1700. if(0 != getpeername(0, 0, lenptr))
  1701. return 1;
  1702. ]])
  1703. ],[
  1704. cares_typeof_ares_socklen_t="$t"
  1705. ])
  1706. fi
  1707. done
  1708. done
  1709. done
  1710. for t in socklen_t int; do
  1711. if test "$cares_typeof_ares_socklen_t" = "void"; then
  1712. AC_COMPILE_IFELSE([
  1713. AC_LANG_PROGRAM([[
  1714. $cares_includes_sys_socket
  1715. typedef $t ares_socklen_t;
  1716. ]],[[
  1717. ares_socklen_t dummy;
  1718. ]])
  1719. ],[
  1720. cares_typeof_ares_socklen_t="$t"
  1721. ])
  1722. fi
  1723. done
  1724. AC_MSG_RESULT([$cares_typeof_ares_socklen_t])
  1725. if test "$cares_typeof_ares_socklen_t" = "void" ||
  1726. test "$cares_typeof_ares_socklen_t" = "unknown"; then
  1727. AC_MSG_ERROR([cannot find data type for ares_socklen_t.])
  1728. fi
  1729. #
  1730. AC_MSG_CHECKING([size of ares_socklen_t])
  1731. cares_sizeof_ares_socklen_t="unknown"
  1732. cares_pull_headers_socklen_t="unknown"
  1733. if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
  1734. tst_pull_header_checks='none ws2tcpip'
  1735. tst_size_checks='4'
  1736. else
  1737. tst_pull_header_checks='none systypes syssocket'
  1738. tst_size_checks='4 8 2'
  1739. fi
  1740. for tst_size in $tst_size_checks; do
  1741. for tst_pull_headers in $tst_pull_header_checks; do
  1742. if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
  1743. case $tst_pull_headers in
  1744. ws2tcpip)
  1745. tmp_includes="$cares_includes_ws2tcpip"
  1746. ;;
  1747. systypes)
  1748. tmp_includes="$cares_includes_sys_types"
  1749. ;;
  1750. syssocket)
  1751. tmp_includes="$cares_includes_sys_socket"
  1752. ;;
  1753. *)
  1754. tmp_includes=""
  1755. ;;
  1756. esac
  1757. AC_COMPILE_IFELSE([
  1758. AC_LANG_PROGRAM([[
  1759. $tmp_includes
  1760. typedef $cares_typeof_ares_socklen_t ares_socklen_t;
  1761. typedef char dummy_arr[sizeof(ares_socklen_t) == $tst_size ? 1 : -1];
  1762. ]],[[
  1763. ares_socklen_t dummy;
  1764. ]])
  1765. ],[
  1766. cares_sizeof_ares_socklen_t="$tst_size"
  1767. cares_pull_headers_socklen_t="$tst_pull_headers"
  1768. ])
  1769. fi
  1770. done
  1771. done
  1772. AC_MSG_RESULT([$cares_sizeof_ares_socklen_t])
  1773. if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
  1774. AC_MSG_ERROR([cannot find out size of ares_socklen_t.])
  1775. fi
  1776. #
  1777. case $cares_pull_headers_socklen_t in
  1778. ws2tcpip)
  1779. CARES_DEFINE_UNQUOTED([CARES_PULL_WS2TCPIP_H])
  1780. ;;
  1781. systypes)
  1782. CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
  1783. ;;
  1784. syssocket)
  1785. CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
  1786. CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_SOCKET_H])
  1787. ;;
  1788. esac
  1789. CARES_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SOCKLEN_T], [$cares_typeof_ares_socklen_t])
  1790. CARES_DEFINE_UNQUOTED([CARES_SIZEOF_ARES_SOCKLEN_T], [$cares_sizeof_ares_socklen_t])
  1791. ])
  1792. dnl This macro determines if the specified struct exists in the specified file
  1793. dnl Syntax:
  1794. dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
  1795. AC_DEFUN([CARES_CHECK_STRUCT], [
  1796. AC_MSG_CHECKING([for struct $2])
  1797. AC_TRY_COMPILE([$1],
  1798. [
  1799. struct $2 struct_instance;
  1800. ], ac_struct="yes", ac_found="no")
  1801. if test "$ac_struct" = "yes" ; then
  1802. AC_MSG_RESULT(yes)
  1803. $3
  1804. else
  1805. AC_MSG_RESULT(no)
  1806. $4
  1807. fi
  1808. ])
  1809. dnl This macro determines if the specified constant exists in the specified file
  1810. dnl Syntax:
  1811. dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
  1812. AC_DEFUN([CARES_CHECK_CONSTANT], [
  1813. AC_MSG_CHECKING([for $2])
  1814. AC_EGREP_CPP(VARIABLEWASDEFINED,
  1815. [
  1816. $1
  1817. #ifdef $2
  1818. VARIABLEWASDEFINED
  1819. #else
  1820. NJET
  1821. #endif
  1822. ], ac_constant="yes", ac_constant="no"
  1823. )
  1824. if test "$ac_constant" = "yes" ; then
  1825. AC_MSG_RESULT(yes)
  1826. $3
  1827. else
  1828. AC_MSG_RESULT(no)
  1829. $4
  1830. fi
  1831. ])