acinclude.m4 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at https://curl.haxx.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. #***************************************************************************
  22. dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
  23. dnl -------------------------------------------------
  24. dnl Use the C preprocessor to find out if the given object-style symbol
  25. dnl is defined and get its expansion. This macro will not use default
  26. dnl includes even if no INCLUDES argument is given. This macro will run
  27. dnl silently when invoked with three arguments. If the expansion would
  28. dnl result in a set of double-quoted strings the returned expansion will
  29. dnl actually be a single double-quoted string concatenating all them.
  30. AC_DEFUN([CURL_CHECK_DEF], [
  31. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  32. AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
  33. if test -z "$SED"; then
  34. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  35. fi
  36. if test -z "$GREP"; then
  37. AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
  38. fi
  39. ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
  40. tmp_exp=""
  41. AC_PREPROC_IFELSE([
  42. AC_LANG_SOURCE(
  43. ifelse($2,,,[$2])[[
  44. #ifdef $1
  45. CURL_DEF_TOKEN $1
  46. #endif
  47. ]])
  48. ],[
  49. tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
  50. "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
  51. "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
  52. "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
  53. if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
  54. tmp_exp=""
  55. fi
  56. ])
  57. if test -z "$tmp_exp"; then
  58. AS_VAR_SET(ac_HaveDef, no)
  59. ifelse($3,,[AC_MSG_RESULT([no])])
  60. else
  61. AS_VAR_SET(ac_HaveDef, yes)
  62. AS_VAR_SET(ac_Def, $tmp_exp)
  63. ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
  64. fi
  65. AS_VAR_POPDEF([ac_Def])dnl
  66. AS_VAR_POPDEF([ac_HaveDef])dnl
  67. ])
  68. dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
  69. dnl -------------------------------------------------
  70. dnl Use the C compiler to find out only if the given symbol is defined
  71. dnl or not, this can not find out its expansion. This macro will not use
  72. dnl default includes even if no INCLUDES argument is given. This macro
  73. dnl will run silently when invoked with three arguments.
  74. AC_DEFUN([CURL_CHECK_DEF_CC], [
  75. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  76. ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
  77. AC_COMPILE_IFELSE([
  78. AC_LANG_SOURCE(
  79. ifelse($2,,,[$2])[[
  80. int main (void)
  81. {
  82. #ifdef $1
  83. return 0;
  84. #else
  85. force compilation error
  86. #endif
  87. }
  88. ]])
  89. ],[
  90. tst_symbol_defined="yes"
  91. ],[
  92. tst_symbol_defined="no"
  93. ])
  94. if test "$tst_symbol_defined" = "yes"; then
  95. AS_VAR_SET(ac_HaveDef, yes)
  96. ifelse($3,,[AC_MSG_RESULT([yes])])
  97. else
  98. AS_VAR_SET(ac_HaveDef, no)
  99. ifelse($3,,[AC_MSG_RESULT([no])])
  100. fi
  101. AS_VAR_POPDEF([ac_HaveDef])dnl
  102. ])
  103. dnl CURL_CHECK_LIB_XNET
  104. dnl -------------------------------------------------
  105. dnl Verify if X/Open network library is required.
  106. AC_DEFUN([CURL_CHECK_LIB_XNET], [
  107. AC_MSG_CHECKING([if X/Open network library is required])
  108. tst_lib_xnet_required="no"
  109. AC_COMPILE_IFELSE([
  110. AC_LANG_SOURCE([[
  111. int main (void)
  112. {
  113. #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
  114. return 0;
  115. #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
  116. return 0;
  117. #else
  118. force compilation error
  119. #endif
  120. }
  121. ]])
  122. ],[
  123. tst_lib_xnet_required="yes"
  124. LIBS="-lxnet $LIBS"
  125. ])
  126. AC_MSG_RESULT([$tst_lib_xnet_required])
  127. ])
  128. dnl CURL_CHECK_AIX_ALL_SOURCE
  129. dnl -------------------------------------------------
  130. dnl Provides a replacement of traditional AC_AIX with
  131. dnl an uniform behaviour across all autoconf versions,
  132. dnl and with our own placement rules.
  133. AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
  134. AH_VERBATIM([_ALL_SOURCE],
  135. [/* Define to 1 if OS is AIX. */
  136. #ifndef _ALL_SOURCE
  137. # undef _ALL_SOURCE
  138. #endif])
  139. AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
  140. AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
  141. AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
  142. AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
  143. AC_EGREP_CPP([yes_this_is_aix],[
  144. #ifdef _AIX
  145. yes_this_is_aix
  146. #endif
  147. ],[
  148. AC_MSG_RESULT([yes])
  149. AC_DEFINE(_ALL_SOURCE)
  150. ],[
  151. AC_MSG_RESULT([no])
  152. ])
  153. ])
  154. dnl CURL_CHECK_HEADER_WINDOWS
  155. dnl -------------------------------------------------
  156. dnl Check for compilable and valid windows.h header
  157. AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
  158. AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
  159. AC_COMPILE_IFELSE([
  160. AC_LANG_PROGRAM([[
  161. #undef inline
  162. #ifndef WIN32_LEAN_AND_MEAN
  163. #define WIN32_LEAN_AND_MEAN
  164. #endif
  165. #include <windows.h>
  166. ]],[[
  167. #if defined(__CYGWIN__) || defined(__CEGCC__)
  168. HAVE_WINDOWS_H shall not be defined.
  169. #else
  170. int dummy=2*WINVER;
  171. #endif
  172. ]])
  173. ],[
  174. ac_cv_header_windows_h="yes"
  175. ],[
  176. ac_cv_header_windows_h="no"
  177. ])
  178. ])
  179. case "$ac_cv_header_windows_h" in
  180. yes)
  181. AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
  182. [Define to 1 if you have the windows.h header file.])
  183. AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
  184. [Define to avoid automatic inclusion of winsock.h])
  185. ;;
  186. esac
  187. ])
  188. dnl CURL_CHECK_NATIVE_WINDOWS
  189. dnl -------------------------------------------------
  190. dnl Check if building a native Windows target
  191. AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
  192. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  193. AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
  194. if test "$ac_cv_header_windows_h" = "no"; then
  195. ac_cv_native_windows="no"
  196. else
  197. AC_COMPILE_IFELSE([
  198. AC_LANG_PROGRAM([[
  199. ]],[[
  200. #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
  201. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
  202. int dummy=1;
  203. #else
  204. Not a native Windows build target.
  205. #endif
  206. ]])
  207. ],[
  208. ac_cv_native_windows="yes"
  209. ],[
  210. ac_cv_native_windows="no"
  211. ])
  212. fi
  213. ])
  214. AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$ac_cv_native_windows" = xyes)
  215. ])
  216. dnl CURL_CHECK_HEADER_WINSOCK
  217. dnl -------------------------------------------------
  218. dnl Check for compilable and valid winsock.h header
  219. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
  220. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  221. AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
  222. AC_COMPILE_IFELSE([
  223. AC_LANG_PROGRAM([[
  224. #undef inline
  225. #ifndef WIN32_LEAN_AND_MEAN
  226. #define WIN32_LEAN_AND_MEAN
  227. #endif
  228. #include <windows.h>
  229. #include <winsock.h>
  230. ]],[[
  231. #if defined(__CYGWIN__) || defined(__CEGCC__)
  232. HAVE_WINSOCK_H shall not be defined.
  233. #else
  234. int dummy=WSACleanup();
  235. #endif
  236. ]])
  237. ],[
  238. ac_cv_header_winsock_h="yes"
  239. ],[
  240. ac_cv_header_winsock_h="no"
  241. ])
  242. ])
  243. case "$ac_cv_header_winsock_h" in
  244. yes)
  245. AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
  246. [Define to 1 if you have the winsock.h header file.])
  247. ;;
  248. esac
  249. ])
  250. dnl CURL_CHECK_HEADER_WINSOCK2
  251. dnl -------------------------------------------------
  252. dnl Check for compilable and valid winsock2.h header
  253. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
  254. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  255. AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
  256. AC_COMPILE_IFELSE([
  257. AC_LANG_PROGRAM([[
  258. #undef inline
  259. #ifndef WIN32_LEAN_AND_MEAN
  260. #define WIN32_LEAN_AND_MEAN
  261. #endif
  262. #include <windows.h>
  263. #include <winsock2.h>
  264. ]],[[
  265. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  266. HAVE_WINSOCK2_H shall not be defined.
  267. #else
  268. int dummy=2*IPPROTO_ESP;
  269. #endif
  270. ]])
  271. ],[
  272. ac_cv_header_winsock2_h="yes"
  273. ],[
  274. ac_cv_header_winsock2_h="no"
  275. ])
  276. ])
  277. case "$ac_cv_header_winsock2_h" in
  278. yes)
  279. AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
  280. [Define to 1 if you have the winsock2.h header file.])
  281. ;;
  282. esac
  283. ])
  284. dnl CURL_CHECK_HEADER_WS2TCPIP
  285. dnl -------------------------------------------------
  286. dnl Check for compilable and valid ws2tcpip.h header
  287. AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
  288. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  289. AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
  290. AC_COMPILE_IFELSE([
  291. AC_LANG_PROGRAM([[
  292. #undef inline
  293. #ifndef WIN32_LEAN_AND_MEAN
  294. #define WIN32_LEAN_AND_MEAN
  295. #endif
  296. #include <windows.h>
  297. #include <winsock2.h>
  298. #include <ws2tcpip.h>
  299. ]],[[
  300. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  301. HAVE_WS2TCPIP_H shall not be defined.
  302. #else
  303. int dummy=2*IP_PKTINFO;
  304. #endif
  305. ]])
  306. ],[
  307. ac_cv_header_ws2tcpip_h="yes"
  308. ],[
  309. ac_cv_header_ws2tcpip_h="no"
  310. ])
  311. ])
  312. case "$ac_cv_header_ws2tcpip_h" in
  313. yes)
  314. AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
  315. [Define to 1 if you have the ws2tcpip.h header file.])
  316. ;;
  317. esac
  318. ])
  319. dnl CURL_CHECK_HEADER_WINLDAP
  320. dnl -------------------------------------------------
  321. dnl Check for compilable and valid winldap.h header
  322. AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
  323. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  324. AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
  325. AC_COMPILE_IFELSE([
  326. AC_LANG_PROGRAM([[
  327. #undef inline
  328. #ifdef HAVE_WINDOWS_H
  329. #ifndef WIN32_LEAN_AND_MEAN
  330. #define WIN32_LEAN_AND_MEAN
  331. #endif
  332. #include <windows.h>
  333. #endif
  334. #include <winldap.h>
  335. ]],[[
  336. #if defined(__CYGWIN__) || defined(__CEGCC__)
  337. HAVE_WINLDAP_H shall not be defined.
  338. #else
  339. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  340. ULONG res = ldap_unbind(ldp);
  341. #endif
  342. ]])
  343. ],[
  344. ac_cv_header_winldap_h="yes"
  345. ],[
  346. ac_cv_header_winldap_h="no"
  347. ])
  348. ])
  349. case "$ac_cv_header_winldap_h" in
  350. yes)
  351. AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
  352. [Define to 1 if you have the winldap.h header file.])
  353. ;;
  354. esac
  355. ])
  356. dnl CURL_CHECK_HEADER_WINBER
  357. dnl -------------------------------------------------
  358. dnl Check for compilable and valid winber.h header
  359. AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
  360. AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
  361. AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
  362. AC_COMPILE_IFELSE([
  363. AC_LANG_PROGRAM([[
  364. #undef inline
  365. #ifdef HAVE_WINDOWS_H
  366. #ifndef WIN32_LEAN_AND_MEAN
  367. #define WIN32_LEAN_AND_MEAN
  368. #endif
  369. #include <windows.h>
  370. #endif
  371. #include <winldap.h>
  372. #include <winber.h>
  373. ]],[[
  374. #if defined(__CYGWIN__) || defined(__CEGCC__)
  375. HAVE_WINBER_H shall not be defined.
  376. #else
  377. BERVAL *bvp = NULL;
  378. BerElement *bep = ber_init(bvp);
  379. ber_free(bep, 1);
  380. #endif
  381. ]])
  382. ],[
  383. ac_cv_header_winber_h="yes"
  384. ],[
  385. ac_cv_header_winber_h="no"
  386. ])
  387. ])
  388. case "$ac_cv_header_winber_h" in
  389. yes)
  390. AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
  391. [Define to 1 if you have the winber.h header file.])
  392. ;;
  393. esac
  394. ])
  395. dnl CURL_CHECK_HEADER_LBER
  396. dnl -------------------------------------------------
  397. dnl Check for compilable and valid lber.h header,
  398. dnl and check if it is needed even with ldap.h
  399. AC_DEFUN([CURL_CHECK_HEADER_LBER], [
  400. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  401. AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
  402. AC_COMPILE_IFELSE([
  403. AC_LANG_PROGRAM([[
  404. #undef inline
  405. #ifdef HAVE_WINDOWS_H
  406. #ifndef WIN32_LEAN_AND_MEAN
  407. #define WIN32_LEAN_AND_MEAN
  408. #endif
  409. #include <windows.h>
  410. #else
  411. #ifdef HAVE_SYS_TYPES_H
  412. #include <sys/types.h>
  413. #endif
  414. #endif
  415. #ifndef NULL
  416. #define NULL (void *)0
  417. #endif
  418. #include <lber.h>
  419. ]],[[
  420. BerValue *bvp = NULL;
  421. BerElement *bep = ber_init(bvp);
  422. ber_free(bep, 1);
  423. ]])
  424. ],[
  425. ac_cv_header_lber_h="yes"
  426. ],[
  427. ac_cv_header_lber_h="no"
  428. ])
  429. ])
  430. if test "$ac_cv_header_lber_h" = "yes"; then
  431. AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
  432. [Define to 1 if you have the lber.h header file.])
  433. #
  434. AC_COMPILE_IFELSE([
  435. AC_LANG_PROGRAM([[
  436. #undef inline
  437. #ifdef HAVE_WINDOWS_H
  438. #ifndef WIN32_LEAN_AND_MEAN
  439. #define WIN32_LEAN_AND_MEAN
  440. #endif
  441. #include <windows.h>
  442. #else
  443. #ifdef HAVE_SYS_TYPES_H
  444. #include <sys/types.h>
  445. #endif
  446. #endif
  447. #ifndef NULL
  448. #define NULL (void *)0
  449. #endif
  450. #ifndef LDAP_DEPRECATED
  451. #define LDAP_DEPRECATED 1
  452. #endif
  453. #include <ldap.h>
  454. ]],[[
  455. BerValue *bvp = NULL;
  456. BerElement *bep = ber_init(bvp);
  457. ber_free(bep, 1);
  458. ]])
  459. ],[
  460. curl_cv_need_header_lber_h="no"
  461. ],[
  462. curl_cv_need_header_lber_h="yes"
  463. ])
  464. #
  465. case "$curl_cv_need_header_lber_h" in
  466. yes)
  467. AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
  468. [Define to 1 if you need the lber.h header file even with ldap.h])
  469. ;;
  470. esac
  471. fi
  472. ])
  473. dnl CURL_CHECK_HEADER_LDAP
  474. dnl -------------------------------------------------
  475. dnl Check for compilable and valid ldap.h header
  476. AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
  477. AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
  478. AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
  479. AC_COMPILE_IFELSE([
  480. AC_LANG_PROGRAM([[
  481. #undef inline
  482. #ifdef HAVE_WINDOWS_H
  483. #ifndef WIN32_LEAN_AND_MEAN
  484. #define WIN32_LEAN_AND_MEAN
  485. #endif
  486. #include <windows.h>
  487. #else
  488. #ifdef HAVE_SYS_TYPES_H
  489. #include <sys/types.h>
  490. #endif
  491. #endif
  492. #ifndef LDAP_DEPRECATED
  493. #define LDAP_DEPRECATED 1
  494. #endif
  495. #ifdef NEED_LBER_H
  496. #include <lber.h>
  497. #endif
  498. #include <ldap.h>
  499. ]],[[
  500. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  501. int res = ldap_unbind(ldp);
  502. ]])
  503. ],[
  504. ac_cv_header_ldap_h="yes"
  505. ],[
  506. ac_cv_header_ldap_h="no"
  507. ])
  508. ])
  509. case "$ac_cv_header_ldap_h" in
  510. yes)
  511. AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
  512. [Define to 1 if you have the ldap.h header file.])
  513. ;;
  514. esac
  515. ])
  516. dnl CURL_CHECK_HEADER_LDAP_SSL
  517. dnl -------------------------------------------------
  518. dnl Check for compilable and valid ldap_ssl.h header
  519. AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
  520. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  521. AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
  522. AC_COMPILE_IFELSE([
  523. AC_LANG_PROGRAM([[
  524. #undef inline
  525. #ifdef HAVE_WINDOWS_H
  526. #ifndef WIN32_LEAN_AND_MEAN
  527. #define WIN32_LEAN_AND_MEAN
  528. #endif
  529. #include <windows.h>
  530. #else
  531. #ifdef HAVE_SYS_TYPES_H
  532. #include <sys/types.h>
  533. #endif
  534. #endif
  535. #ifndef LDAP_DEPRECATED
  536. #define LDAP_DEPRECATED 1
  537. #endif
  538. #ifdef NEED_LBER_H
  539. #include <lber.h>
  540. #endif
  541. #ifdef HAVE_LDAP_H
  542. #include <ldap.h>
  543. #endif
  544. #include <ldap_ssl.h>
  545. ]],[[
  546. LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
  547. ]])
  548. ],[
  549. ac_cv_header_ldap_ssl_h="yes"
  550. ],[
  551. ac_cv_header_ldap_ssl_h="no"
  552. ])
  553. ])
  554. case "$ac_cv_header_ldap_ssl_h" in
  555. yes)
  556. AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
  557. [Define to 1 if you have the ldap_ssl.h header file.])
  558. ;;
  559. esac
  560. ])
  561. dnl CURL_CHECK_HEADER_LDAPSSL
  562. dnl -------------------------------------------------
  563. dnl Check for compilable and valid ldapssl.h header
  564. AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
  565. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  566. AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
  567. AC_COMPILE_IFELSE([
  568. AC_LANG_PROGRAM([[
  569. #undef inline
  570. #ifdef HAVE_WINDOWS_H
  571. #ifndef WIN32_LEAN_AND_MEAN
  572. #define WIN32_LEAN_AND_MEAN
  573. #endif
  574. #include <windows.h>
  575. #else
  576. #ifdef HAVE_SYS_TYPES_H
  577. #include <sys/types.h>
  578. #endif
  579. #endif
  580. #ifndef NULL
  581. #define NULL (void *)0
  582. #endif
  583. #ifndef LDAP_DEPRECATED
  584. #define LDAP_DEPRECATED 1
  585. #endif
  586. #ifdef NEED_LBER_H
  587. #include <lber.h>
  588. #endif
  589. #ifdef HAVE_LDAP_H
  590. #include <ldap.h>
  591. #endif
  592. #include <ldapssl.h>
  593. ]],[[
  594. char *cert_label = NULL;
  595. LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
  596. ]])
  597. ],[
  598. ac_cv_header_ldapssl_h="yes"
  599. ],[
  600. ac_cv_header_ldapssl_h="no"
  601. ])
  602. ])
  603. case "$ac_cv_header_ldapssl_h" in
  604. yes)
  605. AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
  606. [Define to 1 if you have the ldapssl.h header file.])
  607. ;;
  608. esac
  609. ])
  610. dnl CURL_CHECK_LIBS_WINLDAP
  611. dnl -------------------------------------------------
  612. dnl Check for libraries needed for WINLDAP support,
  613. dnl and prepended to LIBS any needed libraries.
  614. dnl This macro can take an optional parameter with a
  615. dnl white space separated list of libraries to check
  616. dnl before the WINLDAP default ones.
  617. AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
  618. AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
  619. #
  620. AC_MSG_CHECKING([for WINLDAP libraries])
  621. #
  622. u_libs=""
  623. #
  624. ifelse($1,,,[
  625. for x_lib in $1; do
  626. case "$x_lib" in
  627. -l*)
  628. l_lib="$x_lib"
  629. ;;
  630. *)
  631. l_lib="-l$x_lib"
  632. ;;
  633. esac
  634. if test -z "$u_libs"; then
  635. u_libs="$l_lib"
  636. else
  637. u_libs="$u_libs $l_lib"
  638. fi
  639. done
  640. ])
  641. #
  642. curl_cv_save_LIBS="$LIBS"
  643. curl_cv_ldap_LIBS="unknown"
  644. #
  645. for x_nlibs in '' "$u_libs" \
  646. '-lwldap32' ; do
  647. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  648. if test -z "$x_nlibs"; then
  649. LIBS="$curl_cv_save_LIBS"
  650. else
  651. LIBS="$x_nlibs $curl_cv_save_LIBS"
  652. fi
  653. AC_LINK_IFELSE([
  654. AC_LANG_PROGRAM([[
  655. #undef inline
  656. #ifdef HAVE_WINDOWS_H
  657. #ifndef WIN32_LEAN_AND_MEAN
  658. #define WIN32_LEAN_AND_MEAN
  659. #endif
  660. #include <windows.h>
  661. #ifdef HAVE_WINLDAP_H
  662. #include <winldap.h>
  663. #endif
  664. #ifdef HAVE_WINBER_H
  665. #include <winber.h>
  666. #endif
  667. #endif
  668. ]],[[
  669. BERVAL *bvp = NULL;
  670. BerElement *bep = ber_init(bvp);
  671. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  672. ULONG res = ldap_unbind(ldp);
  673. ber_free(bep, 1);
  674. ]])
  675. ],[
  676. curl_cv_ldap_LIBS="$x_nlibs"
  677. ])
  678. fi
  679. done
  680. #
  681. LIBS="$curl_cv_save_LIBS"
  682. #
  683. case X-"$curl_cv_ldap_LIBS" in
  684. X-unknown)
  685. AC_MSG_RESULT([cannot find WINLDAP libraries])
  686. ;;
  687. X-)
  688. AC_MSG_RESULT([no additional lib required])
  689. ;;
  690. *)
  691. if test -z "$curl_cv_save_LIBS"; then
  692. LIBS="$curl_cv_ldap_LIBS"
  693. else
  694. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  695. fi
  696. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  697. ;;
  698. esac
  699. #
  700. ])
  701. dnl CURL_CHECK_LIBS_LDAP
  702. dnl -------------------------------------------------
  703. dnl Check for libraries needed for LDAP support,
  704. dnl and prepended to LIBS any needed libraries.
  705. dnl This macro can take an optional parameter with a
  706. dnl white space separated list of libraries to check
  707. dnl before the default ones.
  708. AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
  709. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  710. #
  711. AC_MSG_CHECKING([for LDAP libraries])
  712. #
  713. u_libs=""
  714. #
  715. ifelse($1,,,[
  716. for x_lib in $1; do
  717. case "$x_lib" in
  718. -l*)
  719. l_lib="$x_lib"
  720. ;;
  721. *)
  722. l_lib="-l$x_lib"
  723. ;;
  724. esac
  725. if test -z "$u_libs"; then
  726. u_libs="$l_lib"
  727. else
  728. u_libs="$u_libs $l_lib"
  729. fi
  730. done
  731. ])
  732. #
  733. curl_cv_save_LIBS="$LIBS"
  734. curl_cv_ldap_LIBS="unknown"
  735. #
  736. for x_nlibs in '' "$u_libs" \
  737. '-lldap' \
  738. '-llber -lldap' \
  739. '-lldap -llber' \
  740. '-lldapssl -lldapx -lldapsdk' \
  741. '-lldapsdk -lldapx -lldapssl' ; do
  742. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  743. if test -z "$x_nlibs"; then
  744. LIBS="$curl_cv_save_LIBS"
  745. else
  746. LIBS="$x_nlibs $curl_cv_save_LIBS"
  747. fi
  748. AC_LINK_IFELSE([
  749. AC_LANG_PROGRAM([[
  750. #undef inline
  751. #ifdef HAVE_WINDOWS_H
  752. #ifndef WIN32_LEAN_AND_MEAN
  753. #define WIN32_LEAN_AND_MEAN
  754. #endif
  755. #include <windows.h>
  756. #else
  757. #ifdef HAVE_SYS_TYPES_H
  758. #include <sys/types.h>
  759. #endif
  760. #endif
  761. #ifndef NULL
  762. #define NULL (void *)0
  763. #endif
  764. #ifndef LDAP_DEPRECATED
  765. #define LDAP_DEPRECATED 1
  766. #endif
  767. #ifdef NEED_LBER_H
  768. #include <lber.h>
  769. #endif
  770. #ifdef HAVE_LDAP_H
  771. #include <ldap.h>
  772. #endif
  773. ]],[[
  774. BerValue *bvp = NULL;
  775. BerElement *bep = ber_init(bvp);
  776. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  777. int res = ldap_unbind(ldp);
  778. ber_free(bep, 1);
  779. ]])
  780. ],[
  781. curl_cv_ldap_LIBS="$x_nlibs"
  782. ])
  783. fi
  784. done
  785. #
  786. LIBS="$curl_cv_save_LIBS"
  787. #
  788. case X-"$curl_cv_ldap_LIBS" in
  789. X-unknown)
  790. AC_MSG_RESULT([cannot find LDAP libraries])
  791. ;;
  792. X-)
  793. AC_MSG_RESULT([no additional lib required])
  794. ;;
  795. *)
  796. if test -z "$curl_cv_save_LIBS"; then
  797. LIBS="$curl_cv_ldap_LIBS"
  798. else
  799. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  800. fi
  801. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  802. ;;
  803. esac
  804. #
  805. ])
  806. dnl CURL_CHECK_HEADER_MALLOC
  807. dnl -------------------------------------------------
  808. dnl Check for compilable and valid malloc.h header,
  809. dnl and check if it is needed even with stdlib.h
  810. AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
  811. AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
  812. AC_COMPILE_IFELSE([
  813. AC_LANG_PROGRAM([[
  814. #include <malloc.h>
  815. ]],[[
  816. void *p = malloc(10);
  817. void *q = calloc(10,10);
  818. free(p);
  819. free(q);
  820. ]])
  821. ],[
  822. ac_cv_header_malloc_h="yes"
  823. ],[
  824. ac_cv_header_malloc_h="no"
  825. ])
  826. ])
  827. if test "$ac_cv_header_malloc_h" = "yes"; then
  828. AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
  829. [Define to 1 if you have the malloc.h header file.])
  830. #
  831. AC_COMPILE_IFELSE([
  832. AC_LANG_PROGRAM([[
  833. #include <stdlib.h>
  834. ]],[[
  835. void *p = malloc(10);
  836. void *q = calloc(10,10);
  837. free(p);
  838. free(q);
  839. ]])
  840. ],[
  841. curl_cv_need_header_malloc_h="no"
  842. ],[
  843. curl_cv_need_header_malloc_h="yes"
  844. ])
  845. #
  846. case "$curl_cv_need_header_malloc_h" in
  847. yes)
  848. AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
  849. [Define to 1 if you need the malloc.h header file even with stdlib.h])
  850. ;;
  851. esac
  852. fi
  853. ])
  854. dnl CURL_CHECK_HEADER_MEMORY
  855. dnl -------------------------------------------------
  856. dnl Check for compilable and valid memory.h header,
  857. dnl and check if it is needed even with stdlib.h for
  858. dnl memory related functions.
  859. AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
  860. AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
  861. AC_COMPILE_IFELSE([
  862. AC_LANG_PROGRAM([[
  863. #include <memory.h>
  864. ]],[[
  865. void *p = malloc(10);
  866. void *q = calloc(10,10);
  867. free(p);
  868. free(q);
  869. ]])
  870. ],[
  871. ac_cv_header_memory_h="yes"
  872. ],[
  873. ac_cv_header_memory_h="no"
  874. ])
  875. ])
  876. if test "$ac_cv_header_memory_h" = "yes"; then
  877. AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
  878. [Define to 1 if you have the memory.h header file.])
  879. #
  880. AC_COMPILE_IFELSE([
  881. AC_LANG_PROGRAM([[
  882. #include <stdlib.h>
  883. ]],[[
  884. void *p = malloc(10);
  885. void *q = calloc(10,10);
  886. free(p);
  887. free(q);
  888. ]])
  889. ],[
  890. curl_cv_need_header_memory_h="no"
  891. ],[
  892. curl_cv_need_header_memory_h="yes"
  893. ])
  894. #
  895. case "$curl_cv_need_header_memory_h" in
  896. yes)
  897. AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
  898. [Define to 1 if you need the memory.h header file even with stdlib.h])
  899. ;;
  900. esac
  901. fi
  902. ])
  903. dnl CURL_CHECK_FUNC_GETNAMEINFO
  904. dnl -------------------------------------------------
  905. dnl Test if the getnameinfo function is available,
  906. dnl and check the types of five of its arguments.
  907. dnl If the function succeeds HAVE_GETNAMEINFO will be
  908. dnl defined, defining the types of the arguments in
  909. dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
  910. dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
  911. dnl and also defining the type qualifier of first
  912. dnl argument in GETNAMEINFO_QUAL_ARG1.
  913. AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
  914. AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
  915. AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
  916. #
  917. AC_MSG_CHECKING([for getnameinfo])
  918. AC_LINK_IFELSE([
  919. AC_LANG_FUNC_LINK_TRY([getnameinfo])
  920. ],[
  921. AC_MSG_RESULT([yes])
  922. curl_cv_getnameinfo="yes"
  923. ],[
  924. AC_MSG_RESULT([no])
  925. curl_cv_getnameinfo="no"
  926. ])
  927. #
  928. if test "$curl_cv_getnameinfo" != "yes"; then
  929. AC_MSG_CHECKING([deeper for getnameinfo])
  930. AC_LINK_IFELSE([
  931. AC_LANG_PROGRAM([[
  932. ]],[[
  933. getnameinfo();
  934. ]])
  935. ],[
  936. AC_MSG_RESULT([yes])
  937. curl_cv_getnameinfo="yes"
  938. ],[
  939. AC_MSG_RESULT([but still no])
  940. curl_cv_getnameinfo="no"
  941. ])
  942. fi
  943. #
  944. if test "$curl_cv_getnameinfo" != "yes"; then
  945. AC_MSG_CHECKING([deeper and deeper for getnameinfo])
  946. AC_LINK_IFELSE([
  947. AC_LANG_PROGRAM([[
  948. #undef inline
  949. #ifdef HAVE_WINDOWS_H
  950. #ifndef WIN32_LEAN_AND_MEAN
  951. #define WIN32_LEAN_AND_MEAN
  952. #endif
  953. #include <windows.h>
  954. #ifdef HAVE_WINSOCK2_H
  955. #include <winsock2.h>
  956. #ifdef HAVE_WS2TCPIP_H
  957. #include <ws2tcpip.h>
  958. #endif
  959. #endif
  960. #else
  961. #ifdef HAVE_SYS_TYPES_H
  962. #include <sys/types.h>
  963. #endif
  964. #ifdef HAVE_SYS_SOCKET_H
  965. #include <sys/socket.h>
  966. #endif
  967. #ifdef HAVE_NETDB_H
  968. #include <netdb.h>
  969. #endif
  970. #endif
  971. ]],[[
  972. getnameinfo(0, 0, 0, 0, 0, 0, 0);
  973. ]])
  974. ],[
  975. AC_MSG_RESULT([yes])
  976. curl_cv_getnameinfo="yes"
  977. ],[
  978. AC_MSG_RESULT([but still no])
  979. curl_cv_getnameinfo="no"
  980. ])
  981. fi
  982. #
  983. if test "$curl_cv_getnameinfo" = "yes"; then
  984. AC_CACHE_CHECK([types of arguments for getnameinfo],
  985. [curl_cv_func_getnameinfo_args], [
  986. curl_cv_func_getnameinfo_args="unknown"
  987. for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
  988. for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
  989. for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
  990. for gni_arg7 in 'int' 'unsigned int'; do
  991. if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
  992. AC_COMPILE_IFELSE([
  993. AC_LANG_PROGRAM([[
  994. #undef inline
  995. #ifdef HAVE_WINDOWS_H
  996. #ifndef WIN32_LEAN_AND_MEAN
  997. #define WIN32_LEAN_AND_MEAN
  998. #endif
  999. #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
  1000. #undef _WIN32_WINNT
  1001. #define _WIN32_WINNT 0x0501
  1002. #endif
  1003. #include <windows.h>
  1004. #ifdef HAVE_WINSOCK2_H
  1005. #include <winsock2.h>
  1006. #ifdef HAVE_WS2TCPIP_H
  1007. #include <ws2tcpip.h>
  1008. #endif
  1009. #endif
  1010. #define GNICALLCONV WSAAPI
  1011. #else
  1012. #ifdef HAVE_SYS_TYPES_H
  1013. #include <sys/types.h>
  1014. #endif
  1015. #ifdef HAVE_SYS_SOCKET_H
  1016. #include <sys/socket.h>
  1017. #endif
  1018. #ifdef HAVE_NETDB_H
  1019. #include <netdb.h>
  1020. #endif
  1021. #define GNICALLCONV
  1022. #endif
  1023. extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
  1024. char *, $gni_arg46,
  1025. char *, $gni_arg46,
  1026. $gni_arg7);
  1027. ]],[[
  1028. $gni_arg2 salen=0;
  1029. $gni_arg46 hostlen=0;
  1030. $gni_arg46 servlen=0;
  1031. $gni_arg7 flags=0;
  1032. int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
  1033. ]])
  1034. ],[
  1035. curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
  1036. ])
  1037. fi
  1038. done
  1039. done
  1040. done
  1041. done
  1042. ]) # AC-CACHE-CHECK
  1043. if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
  1044. AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
  1045. AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
  1046. else
  1047. gni_prev_IFS=$IFS; IFS=','
  1048. set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
  1049. IFS=$gni_prev_IFS
  1050. shift
  1051. #
  1052. gni_qual_type_arg1=$[1]
  1053. #
  1054. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
  1055. [Define to the type of arg 2 for getnameinfo.])
  1056. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
  1057. [Define to the type of args 4 and 6 for getnameinfo.])
  1058. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
  1059. [Define to the type of arg 7 for getnameinfo.])
  1060. #
  1061. prev_sh_opts=$-
  1062. #
  1063. case $prev_sh_opts in
  1064. *f*)
  1065. ;;
  1066. *)
  1067. set -f
  1068. ;;
  1069. esac
  1070. #
  1071. case "$gni_qual_type_arg1" in
  1072. const*)
  1073. gni_qual_arg1=const
  1074. gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
  1075. ;;
  1076. *)
  1077. gni_qual_arg1=
  1078. gni_type_arg1=$gni_qual_type_arg1
  1079. ;;
  1080. esac
  1081. #
  1082. AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
  1083. [Define to the type qualifier of arg 1 for getnameinfo.])
  1084. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
  1085. [Define to the type of arg 1 for getnameinfo.])
  1086. #
  1087. case $prev_sh_opts in
  1088. *f*)
  1089. ;;
  1090. *)
  1091. set +f
  1092. ;;
  1093. esac
  1094. #
  1095. AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
  1096. [Define to 1 if you have the getnameinfo function.])
  1097. ac_cv_func_getnameinfo="yes"
  1098. fi
  1099. fi
  1100. ])
  1101. dnl TYPE_SOCKADDR_STORAGE
  1102. dnl -------------------------------------------------
  1103. dnl Check for struct sockaddr_storage. Most IPv6-enabled
  1104. dnl hosts have it, but AIX 4.3 is one known exception.
  1105. AC_DEFUN([TYPE_SOCKADDR_STORAGE],
  1106. [
  1107. AC_CHECK_TYPE([struct sockaddr_storage],
  1108. AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
  1109. [if struct sockaddr_storage is defined]), ,
  1110. [
  1111. #undef inline
  1112. #ifdef HAVE_WINDOWS_H
  1113. #ifndef WIN32_LEAN_AND_MEAN
  1114. #define WIN32_LEAN_AND_MEAN
  1115. #endif
  1116. #include <windows.h>
  1117. #ifdef HAVE_WINSOCK2_H
  1118. #include <winsock2.h>
  1119. #endif
  1120. #else
  1121. #ifdef HAVE_SYS_TYPES_H
  1122. #include <sys/types.h>
  1123. #endif
  1124. #ifdef HAVE_SYS_SOCKET_H
  1125. #include <sys/socket.h>
  1126. #endif
  1127. #ifdef HAVE_NETINET_IN_H
  1128. #include <netinet/in.h>
  1129. #endif
  1130. #ifdef HAVE_ARPA_INET_H
  1131. #include <arpa/inet.h>
  1132. #endif
  1133. #endif
  1134. ])
  1135. ])
  1136. dnl CURL_CHECK_NI_WITHSCOPEID
  1137. dnl -------------------------------------------------
  1138. dnl Check for working NI_WITHSCOPEID in getnameinfo()
  1139. AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
  1140. AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
  1141. AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
  1142. AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
  1143. netdb.h netinet/in.h arpa/inet.h)
  1144. #
  1145. AC_CACHE_CHECK([for working NI_WITHSCOPEID],
  1146. [ac_cv_working_ni_withscopeid], [
  1147. AC_RUN_IFELSE([
  1148. AC_LANG_PROGRAM([[
  1149. #ifdef HAVE_STDLIB_H
  1150. #include <stdlib.h>
  1151. #endif
  1152. #ifdef HAVE_STDIO_H
  1153. #include <stdio.h>
  1154. #endif
  1155. #ifdef HAVE_SYS_TYPES_H
  1156. #include <sys/types.h>
  1157. #endif
  1158. #ifdef HAVE_SYS_SOCKET_H
  1159. #include <sys/socket.h>
  1160. #endif
  1161. #ifdef HAVE_NETDB_H
  1162. #include <netdb.h>
  1163. #endif
  1164. #ifdef HAVE_NETINET_IN_H
  1165. #include <netinet/in.h>
  1166. #endif
  1167. #ifdef HAVE_ARPA_INET_H
  1168. #include <arpa/inet.h>
  1169. #endif
  1170. ]],[[
  1171. #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
  1172. #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
  1173. struct sockaddr_storage sa;
  1174. #else
  1175. unsigned char sa[256];
  1176. #endif
  1177. char hostbuf[NI_MAXHOST];
  1178. int rc;
  1179. GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
  1180. GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
  1181. GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
  1182. int fd = socket(AF_INET6, SOCK_STREAM, 0);
  1183. if(fd < 0) {
  1184. perror("socket()");
  1185. return 1; /* Error creating socket */
  1186. }
  1187. rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
  1188. if(rc) {
  1189. perror("getsockname()");
  1190. return 2; /* Error retrieving socket name */
  1191. }
  1192. rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
  1193. if(rc) {
  1194. printf("rc = %s\n", gai_strerror(rc));
  1195. return 3; /* Error translating socket address */
  1196. }
  1197. return 0; /* Ok, NI_WITHSCOPEID works */
  1198. #else
  1199. return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
  1200. #endif
  1201. ]]) # AC-LANG-PROGRAM
  1202. ],[
  1203. # Exit code == 0. Program worked.
  1204. ac_cv_working_ni_withscopeid="yes"
  1205. ],[
  1206. # Exit code != 0. Program failed.
  1207. ac_cv_working_ni_withscopeid="no"
  1208. ],[
  1209. # Program is not run when cross-compiling. So we assume
  1210. # NI_WITHSCOPEID will work if we are able to compile it.
  1211. AC_COMPILE_IFELSE([
  1212. AC_LANG_PROGRAM([[
  1213. #include <sys/types.h>
  1214. #include <sys/socket.h>
  1215. #include <netdb.h>
  1216. ]],[[
  1217. unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
  1218. ]])
  1219. ],[
  1220. ac_cv_working_ni_withscopeid="yes"
  1221. ],[
  1222. ac_cv_working_ni_withscopeid="no"
  1223. ]) # AC-COMPILE-IFELSE
  1224. ]) # AC-RUN-IFELSE
  1225. ]) # AC-CACHE-CHECK
  1226. case "$ac_cv_working_ni_withscopeid" in
  1227. yes)
  1228. AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
  1229. [Define to 1 if NI_WITHSCOPEID exists and works.])
  1230. ;;
  1231. esac
  1232. ])
  1233. dnl CURL_CHECK_FUNC_RECV
  1234. dnl -------------------------------------------------
  1235. dnl Test if the socket recv() function is available,
  1236. dnl and check its return type and the types of its
  1237. dnl arguments. If the function succeeds HAVE_RECV
  1238. dnl will be defined, defining the types of the arguments
  1239. dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
  1240. dnl and RECV_TYPE_ARG4, defining the type of the function
  1241. dnl return value in RECV_TYPE_RETV.
  1242. AC_DEFUN([CURL_CHECK_FUNC_RECV], [
  1243. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1244. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1245. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1246. #
  1247. AC_MSG_CHECKING([for recv])
  1248. AC_LINK_IFELSE([
  1249. AC_LANG_PROGRAM([[
  1250. #undef inline
  1251. #ifdef HAVE_WINDOWS_H
  1252. #ifndef WIN32_LEAN_AND_MEAN
  1253. #define WIN32_LEAN_AND_MEAN
  1254. #endif
  1255. #include <windows.h>
  1256. #ifdef HAVE_WINSOCK2_H
  1257. #include <winsock2.h>
  1258. #else
  1259. #ifdef HAVE_WINSOCK_H
  1260. #include <winsock.h>
  1261. #endif
  1262. #endif
  1263. #else
  1264. #ifdef HAVE_SYS_TYPES_H
  1265. #include <sys/types.h>
  1266. #endif
  1267. #ifdef HAVE_SYS_SOCKET_H
  1268. #include <sys/socket.h>
  1269. #endif
  1270. #endif
  1271. ]],[[
  1272. recv(0, 0, 0, 0);
  1273. ]])
  1274. ],[
  1275. AC_MSG_RESULT([yes])
  1276. curl_cv_recv="yes"
  1277. ],[
  1278. AC_MSG_RESULT([no])
  1279. curl_cv_recv="no"
  1280. ])
  1281. #
  1282. if test "$curl_cv_recv" = "yes"; then
  1283. AC_CACHE_CHECK([types of args and return type for recv],
  1284. [curl_cv_func_recv_args], [
  1285. curl_cv_func_recv_args="unknown"
  1286. for recv_retv in 'int' 'ssize_t'; do
  1287. for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1288. for recv_arg2 in 'char *' 'void *'; do
  1289. for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1290. for recv_arg4 in 'int' 'unsigned int'; do
  1291. if test "$curl_cv_func_recv_args" = "unknown"; then
  1292. AC_COMPILE_IFELSE([
  1293. AC_LANG_PROGRAM([[
  1294. #undef inline
  1295. #ifdef HAVE_WINDOWS_H
  1296. #ifndef WIN32_LEAN_AND_MEAN
  1297. #define WIN32_LEAN_AND_MEAN
  1298. #endif
  1299. #include <windows.h>
  1300. #ifdef HAVE_WINSOCK2_H
  1301. #include <winsock2.h>
  1302. #else
  1303. #ifdef HAVE_WINSOCK_H
  1304. #include <winsock.h>
  1305. #endif
  1306. #endif
  1307. #define RECVCALLCONV PASCAL
  1308. #else
  1309. #ifdef HAVE_SYS_TYPES_H
  1310. #include <sys/types.h>
  1311. #endif
  1312. #ifdef HAVE_SYS_SOCKET_H
  1313. #include <sys/socket.h>
  1314. #endif
  1315. #define RECVCALLCONV
  1316. #endif
  1317. extern $recv_retv RECVCALLCONV
  1318. recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
  1319. ]],[[
  1320. $recv_arg1 s=0;
  1321. $recv_arg2 buf=0;
  1322. $recv_arg3 len=0;
  1323. $recv_arg4 flags=0;
  1324. $recv_retv res = recv(s, buf, len, flags);
  1325. ]])
  1326. ],[
  1327. curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
  1328. ])
  1329. fi
  1330. done
  1331. done
  1332. done
  1333. done
  1334. done
  1335. ]) # AC-CACHE-CHECK
  1336. if test "$curl_cv_func_recv_args" = "unknown"; then
  1337. AC_MSG_ERROR([Cannot find proper types to use for recv args])
  1338. else
  1339. recv_prev_IFS=$IFS; IFS=','
  1340. set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
  1341. IFS=$recv_prev_IFS
  1342. shift
  1343. #
  1344. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
  1345. [Define to the type of arg 1 for recv.])
  1346. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
  1347. [Define to the type of arg 2 for recv.])
  1348. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
  1349. [Define to the type of arg 3 for recv.])
  1350. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
  1351. [Define to the type of arg 4 for recv.])
  1352. AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
  1353. [Define to the function return type for recv.])
  1354. #
  1355. AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
  1356. [Define to 1 if you have the recv function.])
  1357. ac_cv_func_recv="yes"
  1358. fi
  1359. else
  1360. AC_MSG_ERROR([Unable to link function recv])
  1361. fi
  1362. ])
  1363. dnl CURL_CHECK_FUNC_SEND
  1364. dnl -------------------------------------------------
  1365. dnl Test if the socket send() function is available,
  1366. dnl and check its return type and the types of its
  1367. dnl arguments. If the function succeeds HAVE_SEND
  1368. dnl will be defined, defining the types of the arguments
  1369. dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
  1370. dnl and SEND_TYPE_ARG4, defining the type of the function
  1371. dnl return value in SEND_TYPE_RETV, and also defining the
  1372. dnl type qualifier of second argument in SEND_QUAL_ARG2.
  1373. AC_DEFUN([CURL_CHECK_FUNC_SEND], [
  1374. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1375. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1376. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1377. #
  1378. AC_MSG_CHECKING([for send])
  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. #endif
  1402. ]],[[
  1403. send(0, 0, 0, 0);
  1404. ]])
  1405. ],[
  1406. AC_MSG_RESULT([yes])
  1407. curl_cv_send="yes"
  1408. ],[
  1409. AC_MSG_RESULT([no])
  1410. curl_cv_send="no"
  1411. ])
  1412. #
  1413. if test "$curl_cv_send" = "yes"; then
  1414. AC_CACHE_CHECK([types of args and return type for send],
  1415. [curl_cv_func_send_args], [
  1416. curl_cv_func_send_args="unknown"
  1417. for send_retv in 'int' 'ssize_t'; do
  1418. for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1419. for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
  1420. for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1421. for send_arg4 in 'int' 'unsigned int'; do
  1422. if test "$curl_cv_func_send_args" = "unknown"; then
  1423. AC_COMPILE_IFELSE([
  1424. AC_LANG_PROGRAM([[
  1425. #undef inline
  1426. #ifdef HAVE_WINDOWS_H
  1427. #ifndef WIN32_LEAN_AND_MEAN
  1428. #define WIN32_LEAN_AND_MEAN
  1429. #endif
  1430. #include <windows.h>
  1431. #ifdef HAVE_WINSOCK2_H
  1432. #include <winsock2.h>
  1433. #else
  1434. #ifdef HAVE_WINSOCK_H
  1435. #include <winsock.h>
  1436. #endif
  1437. #endif
  1438. #define SENDCALLCONV PASCAL
  1439. #else
  1440. #ifdef HAVE_SYS_TYPES_H
  1441. #include <sys/types.h>
  1442. #endif
  1443. #ifdef HAVE_SYS_SOCKET_H
  1444. #include <sys/socket.h>
  1445. #endif
  1446. #define SENDCALLCONV
  1447. #endif
  1448. extern $send_retv SENDCALLCONV
  1449. send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
  1450. ]],[[
  1451. $send_arg1 s=0;
  1452. $send_arg3 len=0;
  1453. $send_arg4 flags=0;
  1454. $send_retv res = send(s, 0, len, flags);
  1455. ]])
  1456. ],[
  1457. curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
  1458. ])
  1459. fi
  1460. done
  1461. done
  1462. done
  1463. done
  1464. done
  1465. ]) # AC-CACHE-CHECK
  1466. if test "$curl_cv_func_send_args" = "unknown"; then
  1467. AC_MSG_ERROR([Cannot find proper types to use for send args])
  1468. else
  1469. send_prev_IFS=$IFS; IFS=','
  1470. set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
  1471. IFS=$send_prev_IFS
  1472. shift
  1473. #
  1474. send_qual_type_arg2=$[2]
  1475. #
  1476. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
  1477. [Define to the type of arg 1 for send.])
  1478. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
  1479. [Define to the type of arg 3 for send.])
  1480. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
  1481. [Define to the type of arg 4 for send.])
  1482. AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
  1483. [Define to the function return type for send.])
  1484. #
  1485. prev_sh_opts=$-
  1486. #
  1487. case $prev_sh_opts in
  1488. *f*)
  1489. ;;
  1490. *)
  1491. set -f
  1492. ;;
  1493. esac
  1494. #
  1495. case "$send_qual_type_arg2" in
  1496. const*)
  1497. send_qual_arg2=const
  1498. send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
  1499. ;;
  1500. *)
  1501. send_qual_arg2=
  1502. send_type_arg2=$send_qual_type_arg2
  1503. ;;
  1504. esac
  1505. #
  1506. AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
  1507. [Define to the type qualifier of arg 2 for send.])
  1508. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
  1509. [Define to the type of arg 2 for send.])
  1510. #
  1511. case $prev_sh_opts in
  1512. *f*)
  1513. ;;
  1514. *)
  1515. set +f
  1516. ;;
  1517. esac
  1518. #
  1519. AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
  1520. [Define to 1 if you have the send function.])
  1521. ac_cv_func_send="yes"
  1522. fi
  1523. else
  1524. AC_MSG_ERROR([Unable to link function send])
  1525. fi
  1526. ])
  1527. dnl CURL_CHECK_MSG_NOSIGNAL
  1528. dnl -------------------------------------------------
  1529. dnl Check for MSG_NOSIGNAL
  1530. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  1531. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1532. AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
  1533. AC_COMPILE_IFELSE([
  1534. AC_LANG_PROGRAM([[
  1535. #undef inline
  1536. #ifdef HAVE_WINDOWS_H
  1537. #ifndef WIN32_LEAN_AND_MEAN
  1538. #define WIN32_LEAN_AND_MEAN
  1539. #endif
  1540. #include <windows.h>
  1541. #ifdef HAVE_WINSOCK2_H
  1542. #include <winsock2.h>
  1543. #else
  1544. #ifdef HAVE_WINSOCK_H
  1545. #include <winsock.h>
  1546. #endif
  1547. #endif
  1548. #else
  1549. #ifdef HAVE_SYS_TYPES_H
  1550. #include <sys/types.h>
  1551. #endif
  1552. #ifdef HAVE_SYS_SOCKET_H
  1553. #include <sys/socket.h>
  1554. #endif
  1555. #endif
  1556. ]],[[
  1557. int flag=MSG_NOSIGNAL;
  1558. ]])
  1559. ],[
  1560. ac_cv_msg_nosignal="yes"
  1561. ],[
  1562. ac_cv_msg_nosignal="no"
  1563. ])
  1564. ])
  1565. case "$ac_cv_msg_nosignal" in
  1566. yes)
  1567. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  1568. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  1569. ;;
  1570. esac
  1571. ])
  1572. dnl CURL_CHECK_STRUCT_TIMEVAL
  1573. dnl -------------------------------------------------
  1574. dnl Check for timeval struct
  1575. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  1576. AC_REQUIRE([AC_HEADER_TIME])dnl
  1577. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1578. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1579. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
  1580. AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
  1581. AC_COMPILE_IFELSE([
  1582. AC_LANG_PROGRAM([[
  1583. #undef inline
  1584. #ifdef HAVE_WINDOWS_H
  1585. #ifndef WIN32_LEAN_AND_MEAN
  1586. #define WIN32_LEAN_AND_MEAN
  1587. #endif
  1588. #include <windows.h>
  1589. #ifdef HAVE_WINSOCK2_H
  1590. #include <winsock2.h>
  1591. #else
  1592. #ifdef HAVE_WINSOCK_H
  1593. #include <winsock.h>
  1594. #endif
  1595. #endif
  1596. #endif
  1597. #ifdef HAVE_SYS_TYPES_H
  1598. #include <sys/types.h>
  1599. #endif
  1600. #ifdef HAVE_SYS_TIME_H
  1601. #include <sys/time.h>
  1602. #ifdef TIME_WITH_SYS_TIME
  1603. #include <time.h>
  1604. #endif
  1605. #else
  1606. #ifdef HAVE_TIME_H
  1607. #include <time.h>
  1608. #endif
  1609. #endif
  1610. #ifdef HAVE_SYS_SOCKET_H
  1611. #include <sys/socket.h>
  1612. #endif
  1613. ]],[[
  1614. struct timeval ts;
  1615. ts.tv_sec = 0;
  1616. ts.tv_usec = 0;
  1617. ]])
  1618. ],[
  1619. ac_cv_struct_timeval="yes"
  1620. ],[
  1621. ac_cv_struct_timeval="no"
  1622. ])
  1623. ])
  1624. case "$ac_cv_struct_timeval" in
  1625. yes)
  1626. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  1627. [Define to 1 if you have the timeval struct.])
  1628. ;;
  1629. esac
  1630. ])
  1631. dnl TYPE_SIG_ATOMIC_T
  1632. dnl -------------------------------------------------
  1633. dnl Check if the sig_atomic_t type is available, and
  1634. dnl verify if it is already defined as volatile.
  1635. AC_DEFUN([TYPE_SIG_ATOMIC_T], [
  1636. AC_CHECK_HEADERS(signal.h)
  1637. AC_CHECK_TYPE([sig_atomic_t],[
  1638. AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
  1639. [Define to 1 if sig_atomic_t is an available typedef.])
  1640. ], ,[
  1641. #ifdef HAVE_SIGNAL_H
  1642. #include <signal.h>
  1643. #endif
  1644. ])
  1645. case "$ac_cv_type_sig_atomic_t" in
  1646. yes)
  1647. #
  1648. AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
  1649. AC_LINK_IFELSE([
  1650. AC_LANG_PROGRAM([[
  1651. #ifdef HAVE_SIGNAL_H
  1652. #include <signal.h>
  1653. #endif
  1654. ]],[[
  1655. static volatile sig_atomic_t dummy = 0;
  1656. ]])
  1657. ],[
  1658. AC_MSG_RESULT([no])
  1659. ac_cv_sig_atomic_t_volatile="no"
  1660. ],[
  1661. AC_MSG_RESULT([yes])
  1662. ac_cv_sig_atomic_t_volatile="yes"
  1663. ])
  1664. #
  1665. if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
  1666. AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
  1667. [Define to 1 if sig_atomic_t is already defined as volatile.])
  1668. fi
  1669. ;;
  1670. esac
  1671. ])
  1672. dnl TYPE_IN_ADDR_T
  1673. dnl -------------------------------------------------
  1674. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  1675. dnl and a few other things.
  1676. AC_DEFUN([TYPE_IN_ADDR_T], [
  1677. AC_CHECK_TYPE([in_addr_t], ,[
  1678. dnl in_addr_t not available
  1679. AC_CACHE_CHECK([for in_addr_t equivalent],
  1680. [curl_cv_in_addr_t_equiv], [
  1681. curl_cv_in_addr_t_equiv="unknown"
  1682. for t in "unsigned long" int size_t unsigned long; do
  1683. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  1684. AC_LINK_IFELSE([
  1685. AC_LANG_PROGRAM([[
  1686. #undef inline
  1687. #ifdef HAVE_WINDOWS_H
  1688. #ifndef WIN32_LEAN_AND_MEAN
  1689. #define WIN32_LEAN_AND_MEAN
  1690. #endif
  1691. #include <windows.h>
  1692. #ifdef HAVE_WINSOCK2_H
  1693. #include <winsock2.h>
  1694. #else
  1695. #ifdef HAVE_WINSOCK_H
  1696. #include <winsock.h>
  1697. #endif
  1698. #endif
  1699. #else
  1700. #ifdef HAVE_SYS_TYPES_H
  1701. #include <sys/types.h>
  1702. #endif
  1703. #ifdef HAVE_SYS_SOCKET_H
  1704. #include <sys/socket.h>
  1705. #endif
  1706. #ifdef HAVE_NETINET_IN_H
  1707. #include <netinet/in.h>
  1708. #endif
  1709. #ifdef HAVE_ARPA_INET_H
  1710. #include <arpa/inet.h>
  1711. #endif
  1712. #endif
  1713. ]],[[
  1714. $t data = inet_addr ("1.2.3.4");
  1715. ]])
  1716. ],[
  1717. curl_cv_in_addr_t_equiv="$t"
  1718. ])
  1719. fi
  1720. done
  1721. ])
  1722. case "$curl_cv_in_addr_t_equiv" in
  1723. unknown)
  1724. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  1725. ;;
  1726. *)
  1727. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  1728. [Type to use in place of in_addr_t when system does not provide it.])
  1729. ;;
  1730. esac
  1731. ],[
  1732. #undef inline
  1733. #ifdef HAVE_WINDOWS_H
  1734. #ifndef WIN32_LEAN_AND_MEAN
  1735. #define WIN32_LEAN_AND_MEAN
  1736. #endif
  1737. #include <windows.h>
  1738. #ifdef HAVE_WINSOCK2_H
  1739. #include <winsock2.h>
  1740. #else
  1741. #ifdef HAVE_WINSOCK_H
  1742. #include <winsock.h>
  1743. #endif
  1744. #endif
  1745. #else
  1746. #ifdef HAVE_SYS_TYPES_H
  1747. #include <sys/types.h>
  1748. #endif
  1749. #ifdef HAVE_SYS_SOCKET_H
  1750. #include <sys/socket.h>
  1751. #endif
  1752. #ifdef HAVE_NETINET_IN_H
  1753. #include <netinet/in.h>
  1754. #endif
  1755. #ifdef HAVE_ARPA_INET_H
  1756. #include <arpa/inet.h>
  1757. #endif
  1758. #endif
  1759. ])
  1760. ])
  1761. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  1762. dnl -------------------------------------------------
  1763. dnl Check if monotonic clock_gettime is available.
  1764. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  1765. AC_REQUIRE([AC_HEADER_TIME])dnl
  1766. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
  1767. AC_MSG_CHECKING([for monotonic clock_gettime])
  1768. #
  1769. if test "x$dontwant_rt" == "xno" ; then
  1770. AC_COMPILE_IFELSE([
  1771. AC_LANG_PROGRAM([[
  1772. #ifdef HAVE_SYS_TYPES_H
  1773. #include <sys/types.h>
  1774. #endif
  1775. #ifdef HAVE_SYS_TIME_H
  1776. #include <sys/time.h>
  1777. #ifdef TIME_WITH_SYS_TIME
  1778. #include <time.h>
  1779. #endif
  1780. #else
  1781. #ifdef HAVE_TIME_H
  1782. #include <time.h>
  1783. #endif
  1784. #endif
  1785. ]],[[
  1786. struct timespec ts;
  1787. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1788. ]])
  1789. ],[
  1790. AC_MSG_RESULT([yes])
  1791. ac_cv_func_clock_gettime="yes"
  1792. ],[
  1793. AC_MSG_RESULT([no])
  1794. ac_cv_func_clock_gettime="no"
  1795. ])
  1796. fi
  1797. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  1798. dnl until library linking and run-time checks for clock_gettime succeed.
  1799. ])
  1800. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  1801. dnl -------------------------------------------------
  1802. dnl If monotonic clock_gettime is available then,
  1803. dnl check and prepended to LIBS any needed libraries.
  1804. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  1805. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  1806. #
  1807. if test "$ac_cv_func_clock_gettime" = "yes"; then
  1808. #
  1809. AC_MSG_CHECKING([for clock_gettime in libraries])
  1810. #
  1811. curl_cv_save_LIBS="$LIBS"
  1812. curl_cv_gclk_LIBS="unknown"
  1813. #
  1814. for x_xlibs in '' '-lrt' '-lposix4' ; do
  1815. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  1816. if test -z "$x_xlibs"; then
  1817. LIBS="$curl_cv_save_LIBS"
  1818. else
  1819. LIBS="$x_xlibs $curl_cv_save_LIBS"
  1820. fi
  1821. AC_LINK_IFELSE([
  1822. AC_LANG_PROGRAM([[
  1823. #ifdef HAVE_SYS_TYPES_H
  1824. #include <sys/types.h>
  1825. #endif
  1826. #ifdef HAVE_SYS_TIME_H
  1827. #include <sys/time.h>
  1828. #ifdef TIME_WITH_SYS_TIME
  1829. #include <time.h>
  1830. #endif
  1831. #else
  1832. #ifdef HAVE_TIME_H
  1833. #include <time.h>
  1834. #endif
  1835. #endif
  1836. ]],[[
  1837. struct timespec ts;
  1838. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1839. ]])
  1840. ],[
  1841. curl_cv_gclk_LIBS="$x_xlibs"
  1842. ])
  1843. fi
  1844. done
  1845. #
  1846. LIBS="$curl_cv_save_LIBS"
  1847. #
  1848. case X-"$curl_cv_gclk_LIBS" in
  1849. X-unknown)
  1850. AC_MSG_RESULT([cannot find clock_gettime])
  1851. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1852. ac_cv_func_clock_gettime="no"
  1853. ;;
  1854. X-)
  1855. AC_MSG_RESULT([no additional lib required])
  1856. ac_cv_func_clock_gettime="yes"
  1857. ;;
  1858. *)
  1859. if test -z "$curl_cv_save_LIBS"; then
  1860. LIBS="$curl_cv_gclk_LIBS"
  1861. else
  1862. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  1863. fi
  1864. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  1865. ac_cv_func_clock_gettime="yes"
  1866. ;;
  1867. esac
  1868. #
  1869. dnl only do runtime verification when not cross-compiling
  1870. if test "x$cross_compiling" != "xyes" &&
  1871. test "$ac_cv_func_clock_gettime" = "yes"; then
  1872. AC_MSG_CHECKING([if monotonic clock_gettime works])
  1873. AC_RUN_IFELSE([
  1874. AC_LANG_PROGRAM([[
  1875. #ifdef HAVE_STDLIB_H
  1876. #include <stdlib.h>
  1877. #endif
  1878. #ifdef HAVE_SYS_TYPES_H
  1879. #include <sys/types.h>
  1880. #endif
  1881. #ifdef HAVE_SYS_TIME_H
  1882. #include <sys/time.h>
  1883. #ifdef TIME_WITH_SYS_TIME
  1884. #include <time.h>
  1885. #endif
  1886. #else
  1887. #ifdef HAVE_TIME_H
  1888. #include <time.h>
  1889. #endif
  1890. #endif
  1891. ]],[[
  1892. struct timespec ts;
  1893. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  1894. exit(0);
  1895. else
  1896. exit(1);
  1897. ]])
  1898. ],[
  1899. AC_MSG_RESULT([yes])
  1900. ],[
  1901. AC_MSG_RESULT([no])
  1902. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1903. ac_cv_func_clock_gettime="no"
  1904. LIBS="$curl_cv_save_LIBS"
  1905. ])
  1906. fi
  1907. #
  1908. case "$ac_cv_func_clock_gettime" in
  1909. yes)
  1910. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  1911. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  1912. ;;
  1913. esac
  1914. #
  1915. fi
  1916. #
  1917. ])
  1918. dnl CURL_CHECK_LIBS_CONNECT
  1919. dnl -------------------------------------------------
  1920. dnl Verify if network connect function is already available
  1921. dnl using current libraries or if another one is required.
  1922. AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
  1923. AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
  1924. AC_MSG_CHECKING([for connect in libraries])
  1925. tst_connect_save_LIBS="$LIBS"
  1926. tst_connect_need_LIBS="unknown"
  1927. for tst_lib in '' '-lsocket' ; do
  1928. if test "$tst_connect_need_LIBS" = "unknown"; then
  1929. LIBS="$tst_lib $tst_connect_save_LIBS"
  1930. AC_LINK_IFELSE([
  1931. AC_LANG_PROGRAM([[
  1932. $curl_includes_winsock2
  1933. #ifndef HAVE_WINDOWS_H
  1934. int connect(int, void*, int);
  1935. #endif
  1936. ]],[[
  1937. if(0 != connect(0, 0, 0))
  1938. return 1;
  1939. ]])
  1940. ],[
  1941. tst_connect_need_LIBS="$tst_lib"
  1942. ])
  1943. fi
  1944. done
  1945. LIBS="$tst_connect_save_LIBS"
  1946. #
  1947. case X-"$tst_connect_need_LIBS" in
  1948. X-unknown)
  1949. AC_MSG_RESULT([cannot find connect])
  1950. AC_MSG_ERROR([cannot find connect function in libraries.])
  1951. ;;
  1952. X-)
  1953. AC_MSG_RESULT([yes])
  1954. ;;
  1955. *)
  1956. AC_MSG_RESULT([$tst_connect_need_LIBS])
  1957. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  1958. ;;
  1959. esac
  1960. ])
  1961. dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
  1962. dnl -------------------------------------------------
  1963. dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
  1964. dnl symbol that can be further used in custom template configuration
  1965. dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
  1966. dnl argument for the description. Symbol definitions done with this
  1967. dnl macro are intended to be exclusively used in handcrafted *.h.in
  1968. dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
  1969. dnl prevents autoheader generation and insertion of symbol template
  1970. dnl stub and definition into the first configuration header file. Do
  1971. dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
  1972. dnl one serves different functional needs.
  1973. AC_DEFUN([CURL_DEFINE_UNQUOTED], [
  1974. cat >>confdefs.h <<_EOF
  1975. [@%:@define] $1 ifelse($#, 2, [$2], 1)
  1976. _EOF
  1977. ])
  1978. dnl CURL_CONFIGURE_LONG
  1979. dnl -------------------------------------------------
  1980. dnl Find out the size of long as reported by sizeof() and define
  1981. dnl CURL_SIZEOF_LONG as appropriate to be used in template file
  1982. dnl include/curl/curlbuild.h.in to properly configure the library.
  1983. dnl The size of long is a build time characteristic and as such
  1984. dnl must be recorded in curlbuild.h
  1985. AC_DEFUN([CURL_CONFIGURE_LONG], [
  1986. if test -z "$ac_cv_sizeof_long" ||
  1987. test "$ac_cv_sizeof_long" -eq "0"; then
  1988. AC_MSG_ERROR([cannot find out size of long.])
  1989. fi
  1990. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
  1991. ])
  1992. dnl CURL_CONFIGURE_CURL_SOCKLEN_T
  1993. dnl -------------------------------------------------
  1994. dnl Find out suitable curl_socklen_t data type definition and size, making
  1995. dnl appropriate definitions for template file include/curl/curlbuild.h.in
  1996. dnl to properly configure and use the library.
  1997. dnl
  1998. dnl The need for the curl_socklen_t definition arises mainly to properly
  1999. dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
  2000. dnl data type which is 32 or 64-Bit wide depending on the data model being
  2001. dnl used, and that on the other hand is only actually used when interfacing
  2002. dnl the X/Open sockets provided in the xnet library.
  2003. AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
  2004. AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
  2005. AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
  2006. AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
  2007. #
  2008. AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
  2009. #
  2010. AC_MSG_CHECKING([for curl_socklen_t data type])
  2011. curl_typeof_curl_socklen_t="unknown"
  2012. for arg1 in int SOCKET; do
  2013. for arg2 in 'struct sockaddr' void; do
  2014. for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
  2015. if test "$curl_typeof_curl_socklen_t" = "unknown"; then
  2016. AC_COMPILE_IFELSE([
  2017. AC_LANG_PROGRAM([[
  2018. $curl_includes_ws2tcpip
  2019. $curl_includes_sys_socket
  2020. $curl_preprocess_callconv
  2021. extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
  2022. ]],[[
  2023. $t *lenptr = 0;
  2024. if(0 != getpeername(0, 0, lenptr))
  2025. return 1;
  2026. ]])
  2027. ],[
  2028. curl_typeof_curl_socklen_t="$t"
  2029. ])
  2030. fi
  2031. done
  2032. done
  2033. done
  2034. for t in socklen_t int; do
  2035. if test "$curl_typeof_curl_socklen_t" = "void"; then
  2036. AC_COMPILE_IFELSE([
  2037. AC_LANG_PROGRAM([[
  2038. $curl_includes_sys_socket
  2039. typedef $t curl_socklen_t;
  2040. ]],[[
  2041. curl_socklen_t dummy;
  2042. ]])
  2043. ],[
  2044. curl_typeof_curl_socklen_t="$t"
  2045. ])
  2046. fi
  2047. done
  2048. AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
  2049. if test "$curl_typeof_curl_socklen_t" = "void" ||
  2050. test "$curl_typeof_curl_socklen_t" = "unknown"; then
  2051. AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
  2052. fi
  2053. #
  2054. AC_MSG_CHECKING([size of curl_socklen_t])
  2055. curl_sizeof_curl_socklen_t="unknown"
  2056. curl_pull_headers_socklen_t="unknown"
  2057. if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
  2058. tst_pull_header_checks='none ws2tcpip'
  2059. tst_size_checks='4'
  2060. else
  2061. tst_pull_header_checks='none systypes syssocket'
  2062. tst_size_checks='4 8 2'
  2063. fi
  2064. for tst_size in $tst_size_checks; do
  2065. for tst_pull_headers in $tst_pull_header_checks; do
  2066. if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
  2067. case $tst_pull_headers in
  2068. ws2tcpip)
  2069. tmp_includes="$curl_includes_ws2tcpip"
  2070. ;;
  2071. systypes)
  2072. tmp_includes="$curl_includes_sys_types"
  2073. ;;
  2074. syssocket)
  2075. tmp_includes="$curl_includes_sys_socket"
  2076. ;;
  2077. *)
  2078. tmp_includes=""
  2079. ;;
  2080. esac
  2081. AC_COMPILE_IFELSE([
  2082. AC_LANG_PROGRAM([[
  2083. $tmp_includes
  2084. typedef $curl_typeof_curl_socklen_t curl_socklen_t;
  2085. typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
  2086. ]],[[
  2087. curl_socklen_t dummy;
  2088. ]])
  2089. ],[
  2090. curl_sizeof_curl_socklen_t="$tst_size"
  2091. curl_pull_headers_socklen_t="$tst_pull_headers"
  2092. ])
  2093. fi
  2094. done
  2095. done
  2096. AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
  2097. if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
  2098. AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
  2099. fi
  2100. #
  2101. case $curl_pull_headers_socklen_t in
  2102. ws2tcpip)
  2103. CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
  2104. ;;
  2105. systypes)
  2106. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
  2107. ;;
  2108. syssocket)
  2109. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
  2110. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
  2111. ;;
  2112. esac
  2113. CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
  2114. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
  2115. ])
  2116. dnl CURL_CONFIGURE_PULL_SYS_POLL
  2117. dnl -------------------------------------------------
  2118. dnl Find out if system header file sys/poll.h must be included by the
  2119. dnl external interface, making appropriate definitions for template file
  2120. dnl include/curl/curlbuild.h.in to properly configure and use the library.
  2121. dnl
  2122. dnl The need for the sys/poll.h inclusion arises mainly to properly
  2123. dnl interface AIX systems which define macros 'events' and 'revents'.
  2124. AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
  2125. AC_REQUIRE([CURL_INCLUDES_POLL])dnl
  2126. #
  2127. tst_poll_events_macro_defined="unknown"
  2128. #
  2129. AC_COMPILE_IFELSE([
  2130. AC_LANG_PROGRAM([[
  2131. $curl_includes_poll
  2132. ]],[[
  2133. #if defined(events) || defined(revents)
  2134. return 0;
  2135. #else
  2136. force compilation error
  2137. #endif
  2138. ]])
  2139. ],[
  2140. tst_poll_events_macro_defined="yes"
  2141. ],[
  2142. tst_poll_events_macro_defined="no"
  2143. ])
  2144. #
  2145. if test "$tst_poll_events_macro_defined" = "yes"; then
  2146. if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
  2147. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
  2148. fi
  2149. fi
  2150. #
  2151. ])
  2152. dnl CURL_CHECK_FUNC_SELECT
  2153. dnl -------------------------------------------------
  2154. dnl Test if the socket select() function is available,
  2155. dnl and check its return type and the types of its
  2156. dnl arguments. If the function succeeds HAVE_SELECT
  2157. dnl will be defined, defining the types of the
  2158. dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
  2159. dnl and SELECT_TYPE_ARG5, defining the type of the
  2160. dnl function return value in SELECT_TYPE_RETV, and
  2161. dnl also defining the type qualifier of fifth argument
  2162. dnl in SELECT_QUAL_ARG5.
  2163. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  2164. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  2165. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  2166. #
  2167. AC_MSG_CHECKING([for select])
  2168. AC_LINK_IFELSE([
  2169. AC_LANG_PROGRAM([[
  2170. #undef inline
  2171. #ifdef HAVE_WINDOWS_H
  2172. #ifndef WIN32_LEAN_AND_MEAN
  2173. #define WIN32_LEAN_AND_MEAN
  2174. #endif
  2175. #include <windows.h>
  2176. #ifdef HAVE_WINSOCK2_H
  2177. #include <winsock2.h>
  2178. #else
  2179. #ifdef HAVE_WINSOCK_H
  2180. #include <winsock.h>
  2181. #endif
  2182. #endif
  2183. #endif
  2184. #ifdef HAVE_SYS_TYPES_H
  2185. #include <sys/types.h>
  2186. #endif
  2187. #ifdef HAVE_SYS_TIME_H
  2188. #include <sys/time.h>
  2189. #ifdef TIME_WITH_SYS_TIME
  2190. #include <time.h>
  2191. #endif
  2192. #else
  2193. #ifdef HAVE_TIME_H
  2194. #include <time.h>
  2195. #endif
  2196. #endif
  2197. #ifndef HAVE_WINDOWS_H
  2198. #ifdef HAVE_SYS_SELECT_H
  2199. #include <sys/select.h>
  2200. #endif
  2201. #ifdef HAVE_SYS_SOCKET_H
  2202. #include <sys/socket.h>
  2203. #endif
  2204. #endif
  2205. ]],[[
  2206. select(0, 0, 0, 0, 0);
  2207. ]])
  2208. ],[
  2209. AC_MSG_RESULT([yes])
  2210. curl_cv_select="yes"
  2211. ],[
  2212. AC_MSG_RESULT([no])
  2213. curl_cv_select="no"
  2214. ])
  2215. #
  2216. if test "$curl_cv_select" = "yes"; then
  2217. AC_CACHE_CHECK([types of args and return type for select],
  2218. [curl_cv_func_select_args], [
  2219. curl_cv_func_select_args="unknown"
  2220. for sel_retv in 'int' 'ssize_t'; do
  2221. for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
  2222. for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
  2223. for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
  2224. if test "$curl_cv_func_select_args" = "unknown"; then
  2225. AC_COMPILE_IFELSE([
  2226. AC_LANG_PROGRAM([[
  2227. #undef inline
  2228. #ifdef HAVE_WINDOWS_H
  2229. #ifndef WIN32_LEAN_AND_MEAN
  2230. #define WIN32_LEAN_AND_MEAN
  2231. #endif
  2232. #include <windows.h>
  2233. #ifdef HAVE_WINSOCK2_H
  2234. #include <winsock2.h>
  2235. #else
  2236. #ifdef HAVE_WINSOCK_H
  2237. #include <winsock.h>
  2238. #endif
  2239. #endif
  2240. #define SELECTCALLCONV PASCAL
  2241. #endif
  2242. #ifdef HAVE_SYS_TYPES_H
  2243. #include <sys/types.h>
  2244. #endif
  2245. #ifdef HAVE_SYS_TIME_H
  2246. #include <sys/time.h>
  2247. #ifdef TIME_WITH_SYS_TIME
  2248. #include <time.h>
  2249. #endif
  2250. #else
  2251. #ifdef HAVE_TIME_H
  2252. #include <time.h>
  2253. #endif
  2254. #endif
  2255. #ifndef HAVE_WINDOWS_H
  2256. #ifdef HAVE_SYS_SELECT_H
  2257. #include <sys/select.h>
  2258. #endif
  2259. #ifdef HAVE_SYS_SOCKET_H
  2260. #include <sys/socket.h>
  2261. #endif
  2262. #define SELECTCALLCONV
  2263. #endif
  2264. #ifndef HAVE_STRUCT_TIMEVAL
  2265. struct timeval {
  2266. long tv_sec;
  2267. long tv_usec;
  2268. };
  2269. #endif
  2270. extern $sel_retv SELECTCALLCONV select($sel_arg1,
  2271. $sel_arg234,
  2272. $sel_arg234,
  2273. $sel_arg234,
  2274. $sel_arg5);
  2275. ]],[[
  2276. $sel_arg1 nfds=0;
  2277. $sel_arg234 rfds=0;
  2278. $sel_arg234 wfds=0;
  2279. $sel_arg234 efds=0;
  2280. $sel_retv res = select(nfds, rfds, wfds, efds, 0);
  2281. ]])
  2282. ],[
  2283. curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
  2284. ])
  2285. fi
  2286. done
  2287. done
  2288. done
  2289. done
  2290. ]) # AC-CACHE-CHECK
  2291. if test "$curl_cv_func_select_args" = "unknown"; then
  2292. AC_MSG_WARN([Cannot find proper types to use for select args])
  2293. AC_MSG_WARN([HAVE_SELECT will not be defined])
  2294. else
  2295. select_prev_IFS=$IFS; IFS=','
  2296. set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
  2297. IFS=$select_prev_IFS
  2298. shift
  2299. #
  2300. sel_qual_type_arg5=$[3]
  2301. #
  2302. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
  2303. [Define to the type of arg 1 for select.])
  2304. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
  2305. [Define to the type of args 2, 3 and 4 for select.])
  2306. AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
  2307. [Define to the function return type for select.])
  2308. #
  2309. prev_sh_opts=$-
  2310. #
  2311. case $prev_sh_opts in
  2312. *f*)
  2313. ;;
  2314. *)
  2315. set -f
  2316. ;;
  2317. esac
  2318. #
  2319. case "$sel_qual_type_arg5" in
  2320. const*)
  2321. sel_qual_arg5=const
  2322. sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
  2323. ;;
  2324. *)
  2325. sel_qual_arg5=
  2326. sel_type_arg5=$sel_qual_type_arg5
  2327. ;;
  2328. esac
  2329. #
  2330. AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
  2331. [Define to the type qualifier of arg 5 for select.])
  2332. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
  2333. [Define to the type of arg 5 for select.])
  2334. #
  2335. case $prev_sh_opts in
  2336. *f*)
  2337. ;;
  2338. *)
  2339. set +f
  2340. ;;
  2341. esac
  2342. #
  2343. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  2344. [Define to 1 if you have the select function.])
  2345. ac_cv_func_select="yes"
  2346. fi
  2347. fi
  2348. ])
  2349. dnl CURL_VERIFY_RUNTIMELIBS
  2350. dnl -------------------------------------------------
  2351. dnl Verify that the shared libs found so far can be used when running
  2352. dnl programs, since otherwise the situation will create odd configure errors
  2353. dnl that are misleading people.
  2354. dnl
  2355. dnl Make sure this test is run BEFORE the first test in the script that
  2356. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  2357. dnl macro. It must also run AFTER all lib-checking macros are complete.
  2358. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  2359. dnl this test is of course not sensible if we are cross-compiling!
  2360. if test "x$cross_compiling" != xyes; then
  2361. dnl just run a program to verify that the libs checked for previous to this
  2362. dnl point also is available run-time!
  2363. AC_MSG_CHECKING([run-time libs availability])
  2364. AC_TRY_RUN([
  2365. main()
  2366. {
  2367. return 0;
  2368. }
  2369. ],
  2370. AC_MSG_RESULT([fine]),
  2371. AC_MSG_RESULT([failed])
  2372. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  2373. )
  2374. dnl if this test fails, configure has already stopped
  2375. fi
  2376. ])
  2377. dnl CURL_CHECK_VARIADIC_MACROS
  2378. dnl -------------------------------------------------
  2379. dnl Check compiler support of variadic macros
  2380. AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
  2381. AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
  2382. [curl_cv_variadic_macros_c99], [
  2383. AC_COMPILE_IFELSE([
  2384. AC_LANG_PROGRAM([[
  2385. #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
  2386. #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
  2387. int fun3(int arg1, int arg2, int arg3);
  2388. int fun2(int arg1, int arg2);
  2389. int fun3(int arg1, int arg2, int arg3)
  2390. { return arg1 + arg2 + arg3; }
  2391. int fun2(int arg1, int arg2)
  2392. { return arg1 + arg2; }
  2393. ]],[[
  2394. int res3 = c99_vmacro3(1, 2, 3);
  2395. int res2 = c99_vmacro2(1, 2);
  2396. ]])
  2397. ],[
  2398. curl_cv_variadic_macros_c99="yes"
  2399. ],[
  2400. curl_cv_variadic_macros_c99="no"
  2401. ])
  2402. ])
  2403. case "$curl_cv_variadic_macros_c99" in
  2404. yes)
  2405. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
  2406. [Define to 1 if compiler supports C99 variadic macro style.])
  2407. ;;
  2408. esac
  2409. AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
  2410. [curl_cv_variadic_macros_gcc], [
  2411. AC_COMPILE_IFELSE([
  2412. AC_LANG_PROGRAM([[
  2413. #define gcc_vmacro3(first, args...) fun3(first, args)
  2414. #define gcc_vmacro2(first, args...) fun2(first, args)
  2415. int fun3(int arg1, int arg2, int arg3);
  2416. int fun2(int arg1, int arg2);
  2417. int fun3(int arg1, int arg2, int arg3)
  2418. { return arg1 + arg2 + arg3; }
  2419. int fun2(int arg1, int arg2)
  2420. { return arg1 + arg2; }
  2421. ]],[[
  2422. int res3 = gcc_vmacro3(1, 2, 3);
  2423. int res2 = gcc_vmacro2(1, 2);
  2424. ]])
  2425. ],[
  2426. curl_cv_variadic_macros_gcc="yes"
  2427. ],[
  2428. curl_cv_variadic_macros_gcc="no"
  2429. ])
  2430. ])
  2431. case "$curl_cv_variadic_macros_gcc" in
  2432. yes)
  2433. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
  2434. [Define to 1 if compiler supports old gcc variadic macro style.])
  2435. ;;
  2436. esac
  2437. ])
  2438. dnl CURL_CHECK_CA_BUNDLE
  2439. dnl -------------------------------------------------
  2440. dnl Check if a default ca-bundle should be used
  2441. dnl
  2442. dnl regarding the paths this will scan:
  2443. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  2444. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  2445. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  2446. dnl /usr/local/share/certs/ca-root.crt FreeBSD
  2447. dnl /etc/ssl/cert.pem OpenBSD
  2448. dnl /etc/ssl/certs/ (ca path) SUSE
  2449. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  2450. AC_MSG_CHECKING([default CA cert bundle/path])
  2451. AC_ARG_WITH(ca-bundle,
  2452. AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
  2453. AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  2454. [
  2455. want_ca="$withval"
  2456. if test "x$want_ca" = "xyes"; then
  2457. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  2458. fi
  2459. ],
  2460. [ want_ca="unset" ])
  2461. AC_ARG_WITH(ca-path,
  2462. AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
  2463. AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  2464. [
  2465. want_capath="$withval"
  2466. if test "x$want_capath" = "xyes"; then
  2467. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  2468. fi
  2469. ],
  2470. [ want_capath="unset"])
  2471. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  2472. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2473. dnl both given
  2474. ca="$want_ca"
  2475. capath="$want_capath"
  2476. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  2477. dnl --with-ca-bundle given
  2478. ca="$want_ca"
  2479. capath="no"
  2480. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2481. dnl --with-ca-path given
  2482. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$POLARSSL_ENABLED" != "x1"; then
  2483. AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or PolarSSL])
  2484. fi
  2485. capath="$want_capath"
  2486. ca="no"
  2487. else
  2488. dnl first try autodetecting a CA bundle , then a CA path
  2489. dnl both autodetections can be skipped by --without-ca-*
  2490. ca="no"
  2491. capath="no"
  2492. if test "x$cross_compiling" != "xyes"; then
  2493. dnl NOT cross-compiling and...
  2494. dnl neither of the --with-ca-* options are provided
  2495. if test "x$want_ca" = "xunset"; then
  2496. dnl the path we previously would have installed the curl ca bundle
  2497. dnl to, and thus we now check for an already existing cert in that
  2498. dnl place in case we find no other
  2499. if test "x$prefix" != xNONE; then
  2500. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  2501. else
  2502. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  2503. fi
  2504. for a in /etc/ssl/certs/ca-certificates.crt \
  2505. /etc/pki/tls/certs/ca-bundle.crt \
  2506. /usr/share/ssl/certs/ca-bundle.crt \
  2507. /usr/local/share/certs/ca-root.crt \
  2508. /etc/ssl/cert.pem \
  2509. "$cac"; do
  2510. if test -f "$a"; then
  2511. ca="$a"
  2512. break
  2513. fi
  2514. done
  2515. fi
  2516. if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
  2517. "x$OPENSSL_ENABLED" = "x1"; then
  2518. for a in /etc/ssl/certs/; do
  2519. if test -d "$a" && ls "$a"/[[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]].0 >/dev/null 2>/dev/null; then
  2520. capath="$a"
  2521. break
  2522. fi
  2523. done
  2524. fi
  2525. else
  2526. dnl no option given and cross-compiling
  2527. AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
  2528. fi
  2529. fi
  2530. if test "x$ca" != "xno"; then
  2531. CURL_CA_BUNDLE='"'$ca'"'
  2532. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  2533. AC_SUBST(CURL_CA_BUNDLE)
  2534. AC_MSG_RESULT([$ca])
  2535. fi
  2536. if test "x$capath" != "xno"; then
  2537. CURL_CA_PATH="\"$capath\""
  2538. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  2539. AC_MSG_RESULT([$capath (capath)])
  2540. fi
  2541. if test "x$ca" = "xno" && test "x$capath" = "xno"; then
  2542. AC_MSG_RESULT([no])
  2543. fi
  2544. AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
  2545. AC_ARG_WITH(ca-fallback,
  2546. AC_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
  2547. AC_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
  2548. [
  2549. if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
  2550. AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
  2551. fi
  2552. ],
  2553. [ with_ca_fallback="no"])
  2554. AC_MSG_RESULT([$with_ca_fallback])
  2555. if test "x$with_ca_fallback" = "xyes"; then
  2556. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
  2557. AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
  2558. fi
  2559. AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
  2560. fi
  2561. ])
  2562. dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
  2563. dnl -------------------------------------------------
  2564. dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
  2565. AC_DEFUN([DO_CURL_OFF_T_CHECK], [
  2566. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  2567. if test "$curl_typeof_curl_off_t" = "unknown" && test ! -z "$1"; then
  2568. tmp_includes=""
  2569. tmp_source=""
  2570. tmp_fmt=""
  2571. case XC_SH_TR_SH([$1]) in
  2572. int64_t)
  2573. tmp_includes="$curl_includes_inttypes"
  2574. tmp_source="char f@<:@@:>@ = PRId64;"
  2575. tmp_fmt="PRId64"
  2576. ;;
  2577. int32_t)
  2578. tmp_includes="$curl_includes_inttypes"
  2579. tmp_source="char f@<:@@:>@ = PRId32;"
  2580. tmp_fmt="PRId32"
  2581. ;;
  2582. int16_t)
  2583. tmp_includes="$curl_includes_inttypes"
  2584. tmp_source="char f@<:@@:>@ = PRId16;"
  2585. tmp_fmt="PRId16"
  2586. ;;
  2587. esac
  2588. AC_COMPILE_IFELSE([
  2589. AC_LANG_PROGRAM([[
  2590. $tmp_includes
  2591. typedef $1 curl_off_t;
  2592. typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
  2593. ]],[[
  2594. $tmp_source
  2595. curl_off_t dummy;
  2596. ]])
  2597. ],[
  2598. if test -z "$tmp_fmt"; then
  2599. curl_typeof_curl_off_t="$1"
  2600. curl_sizeof_curl_off_t="$2"
  2601. else
  2602. CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
  2603. AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
  2604. AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
  2605. if test AS_VAR_GET(tmp_HaveFmtDef) = "yes"; then
  2606. curl_format_curl_off_t=AS_VAR_GET(tmp_FmtDef)
  2607. curl_typeof_curl_off_t="$1"
  2608. curl_sizeof_curl_off_t="$2"
  2609. fi
  2610. AS_VAR_POPDEF([tmp_FmtDef])dnl
  2611. AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
  2612. fi
  2613. ])
  2614. fi
  2615. ])
  2616. dnl DO_CURL_OFF_T_SUFFIX_CHECK (TYPE)
  2617. dnl -------------------------------------------------
  2618. dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
  2619. AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [
  2620. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  2621. AC_MSG_CHECKING([constant suffix string for curl_off_t])
  2622. #
  2623. curl_suffix_curl_off_t="unknown"
  2624. curl_suffix_curl_off_tu="unknown"
  2625. #
  2626. case XC_SH_TR_SH([$1]) in
  2627. long_long | __longlong | __longlong_t)
  2628. tst_suffixes="LL::"
  2629. ;;
  2630. long)
  2631. tst_suffixes="L::"
  2632. ;;
  2633. int)
  2634. tst_suffixes="::"
  2635. ;;
  2636. __int64 | int64_t)
  2637. tst_suffixes="LL:i64::"
  2638. ;;
  2639. __int32 | int32_t)
  2640. tst_suffixes="L:i32::"
  2641. ;;
  2642. __int16 | int16_t)
  2643. tst_suffixes="L:i16::"
  2644. ;;
  2645. *)
  2646. AC_MSG_ERROR([unexpected data type $1])
  2647. ;;
  2648. esac
  2649. #
  2650. old_IFS=$IFS; IFS=':'
  2651. for tmp_ssuf in $tst_suffixes ; do
  2652. IFS=$old_IFS
  2653. if test "x$curl_suffix_curl_off_t" = "xunknown"; then
  2654. case $tmp_ssuf in
  2655. i64 | i32 | i16)
  2656. tmp_usuf="u$tmp_ssuf"
  2657. ;;
  2658. LL | L)
  2659. tmp_usuf="U$tmp_ssuf"
  2660. ;;
  2661. *)
  2662. tmp_usuf=""
  2663. ;;
  2664. esac
  2665. AC_COMPILE_IFELSE([
  2666. AC_LANG_PROGRAM([[
  2667. $curl_includes_inttypes
  2668. typedef $1 new_t;
  2669. ]],[[
  2670. new_t s1;
  2671. new_t s2;
  2672. s1 = -10$tmp_ssuf ;
  2673. s2 = 20$tmp_ssuf ;
  2674. if(s1 > s2)
  2675. return 1;
  2676. ]])
  2677. ],[
  2678. curl_suffix_curl_off_t="$tmp_ssuf"
  2679. curl_suffix_curl_off_tu="$tmp_usuf"
  2680. ])
  2681. fi
  2682. done
  2683. IFS=$old_IFS
  2684. #
  2685. if test "x$curl_suffix_curl_off_t" = "xunknown"; then
  2686. AC_MSG_ERROR([cannot find constant suffix string for curl_off_t.])
  2687. else
  2688. AC_MSG_RESULT([$curl_suffix_curl_off_t])
  2689. AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
  2690. AC_MSG_RESULT([$curl_suffix_curl_off_tu])
  2691. fi
  2692. #
  2693. ])
  2694. dnl CURL_CONFIGURE_CURL_OFF_T
  2695. dnl -------------------------------------------------
  2696. dnl Find out suitable curl_off_t data type definition and associated
  2697. dnl items, and make the appropriate definitions used in template file
  2698. dnl include/curl/curlbuild.h.in to properly configure the library.
  2699. AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
  2700. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  2701. #
  2702. AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
  2703. AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
  2704. AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
  2705. #
  2706. if test -z "$SED"; then
  2707. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  2708. fi
  2709. #
  2710. AC_CHECK_SIZEOF(long)
  2711. AC_CHECK_SIZEOF(void*)
  2712. #
  2713. if test -z "$ac_cv_sizeof_long" ||
  2714. test "$ac_cv_sizeof_long" -eq "0"; then
  2715. AC_MSG_ERROR([cannot find out size of long.])
  2716. fi
  2717. if test -z "$ac_cv_sizeof_voidp" ||
  2718. test "$ac_cv_sizeof_voidp" -eq "0"; then
  2719. AC_MSG_ERROR([cannot find out size of void*.])
  2720. fi
  2721. #
  2722. x_LP64_long=""
  2723. x_LP32_long=""
  2724. #
  2725. if test "$ac_cv_sizeof_long" -eq "8" &&
  2726. test "$ac_cv_sizeof_voidp" -ge "8"; then
  2727. x_LP64_long="long"
  2728. elif test "$ac_cv_sizeof_long" -eq "4" &&
  2729. test "$ac_cv_sizeof_voidp" -ge "4"; then
  2730. x_LP32_long="long"
  2731. fi
  2732. #
  2733. dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
  2734. #
  2735. curl_typeof_curl_off_t="unknown"
  2736. curl_sizeof_curl_off_t="unknown"
  2737. curl_format_curl_off_t="unknown"
  2738. curl_format_curl_off_tu="unknown"
  2739. #
  2740. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2741. AC_MSG_CHECKING([for 64-bit curl_off_t data type])
  2742. for t8 in \
  2743. "$x_LP64_long" \
  2744. 'int64_t' \
  2745. '__int64' \
  2746. 'long long' \
  2747. '__longlong' \
  2748. '__longlong_t' ; do
  2749. DO_CURL_OFF_T_CHECK([$t8], [8])
  2750. done
  2751. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  2752. fi
  2753. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2754. AC_MSG_CHECKING([for 32-bit curl_off_t data type])
  2755. for t4 in \
  2756. "$x_LP32_long" \
  2757. 'int32_t' \
  2758. '__int32' \
  2759. 'int' ; do
  2760. DO_CURL_OFF_T_CHECK([$t4], [4])
  2761. done
  2762. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  2763. fi
  2764. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2765. AC_MSG_ERROR([cannot find data type for curl_off_t.])
  2766. fi
  2767. #
  2768. AC_MSG_CHECKING([size of curl_off_t])
  2769. AC_MSG_RESULT([$curl_sizeof_curl_off_t])
  2770. #
  2771. AC_MSG_CHECKING([formatting string directive for curl_off_t])
  2772. if test "$curl_format_curl_off_t" != "unknown"; then
  2773. x_pull_headers="yes"
  2774. curl_format_curl_off_t=`echo "$curl_format_curl_off_t" | "$SED" 's/[["]]//g'`
  2775. curl_format_curl_off_tu=`echo "$curl_format_curl_off_t" | "$SED" 's/i$/u/'`
  2776. curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/d$/u/'`
  2777. curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'`
  2778. else
  2779. x_pull_headers="no"
  2780. case XC_SH_TR_SH([$curl_typeof_curl_off_t]) in
  2781. long_long | __longlong | __longlong_t)
  2782. curl_format_curl_off_t="lld"
  2783. curl_format_curl_off_tu="llu"
  2784. ;;
  2785. long)
  2786. curl_format_curl_off_t="ld"
  2787. curl_format_curl_off_tu="lu"
  2788. ;;
  2789. int)
  2790. curl_format_curl_off_t="d"
  2791. curl_format_curl_off_tu="u"
  2792. ;;
  2793. __int64)
  2794. curl_format_curl_off_t="I64d"
  2795. curl_format_curl_off_tu="I64u"
  2796. ;;
  2797. __int32)
  2798. curl_format_curl_off_t="I32d"
  2799. curl_format_curl_off_tu="I32u"
  2800. ;;
  2801. __int16)
  2802. curl_format_curl_off_t="I16d"
  2803. curl_format_curl_off_tu="I16u"
  2804. ;;
  2805. *)
  2806. AC_MSG_ERROR([cannot find print format string for curl_off_t.])
  2807. ;;
  2808. esac
  2809. fi
  2810. AC_MSG_RESULT(["$curl_format_curl_off_t"])
  2811. #
  2812. AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
  2813. AC_MSG_RESULT(["$curl_format_curl_off_tu"])
  2814. #
  2815. DO_CURL_OFF_T_SUFFIX_CHECK([$curl_typeof_curl_off_t])
  2816. #
  2817. if test "$x_pull_headers" = "yes"; then
  2818. if test "x$ac_cv_header_sys_types_h" = "xyes"; then
  2819. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
  2820. fi
  2821. if test "x$ac_cv_header_stdint_h" = "xyes"; then
  2822. CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
  2823. fi
  2824. if test "x$ac_cv_header_inttypes_h" = "xyes"; then
  2825. CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
  2826. fi
  2827. fi
  2828. #
  2829. CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_OFF_T], [$curl_typeof_curl_off_t])
  2830. CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_T], ["$curl_format_curl_off_t"])
  2831. CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_TU], ["$curl_format_curl_off_tu"])
  2832. CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$curl_format_curl_off_t"])
  2833. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$curl_sizeof_curl_off_t])
  2834. CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$curl_suffix_curl_off_t])
  2835. CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$curl_suffix_curl_off_tu])
  2836. #
  2837. ])
  2838. dnl CURL_CHECK_WIN32_LARGEFILE
  2839. dnl -------------------------------------------------
  2840. dnl Check if curl's WIN32 large file will be used
  2841. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  2842. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  2843. AC_MSG_CHECKING([whether build target supports WIN32 file API])
  2844. curl_win32_file_api="no"
  2845. if test "$ac_cv_header_windows_h" = "yes"; then
  2846. if test x"$enable_largefile" != "xno"; then
  2847. AC_COMPILE_IFELSE([
  2848. AC_LANG_PROGRAM([[
  2849. ]],[[
  2850. #if !defined(_WIN32_WCE) && \
  2851. (defined(__MINGW32__) || \
  2852. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
  2853. int dummy=1;
  2854. #else
  2855. WIN32 large file API not supported.
  2856. #endif
  2857. ]])
  2858. ],[
  2859. curl_win32_file_api="win32_large_files"
  2860. ])
  2861. fi
  2862. if test "$curl_win32_file_api" = "no"; then
  2863. AC_COMPILE_IFELSE([
  2864. AC_LANG_PROGRAM([[
  2865. ]],[[
  2866. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  2867. int dummy=1;
  2868. #else
  2869. WIN32 small file API not supported.
  2870. #endif
  2871. ]])
  2872. ],[
  2873. curl_win32_file_api="win32_small_files"
  2874. ])
  2875. fi
  2876. fi
  2877. case "$curl_win32_file_api" in
  2878. win32_large_files)
  2879. AC_MSG_RESULT([yes (large file enabled)])
  2880. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  2881. [Define to 1 if you are building a Windows target with large file support.])
  2882. ;;
  2883. win32_small_files)
  2884. AC_MSG_RESULT([yes (large file disabled)])
  2885. AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
  2886. [Define to 1 if you are building a Windows target without large file support.])
  2887. ;;
  2888. *)
  2889. AC_MSG_RESULT([no])
  2890. ;;
  2891. esac
  2892. ])
  2893. dnl CURL_EXPORT_PCDIR ($pcdir)
  2894. dnl ------------------------
  2895. dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
  2896. dnl
  2897. dnl we need this macro since pkg-config distinguishes among empty and unset
  2898. dnl variable while checking PKG_CONFIG_LIBDIR
  2899. dnl
  2900. AC_DEFUN([CURL_EXPORT_PCDIR], [
  2901. if test -n "$1"; then
  2902. PKG_CONFIG_LIBDIR="$1"
  2903. export PKG_CONFIG_LIBDIR
  2904. fi
  2905. ])
  2906. dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
  2907. dnl ------------------------
  2908. dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
  2909. dnl path to it, or 'no' if not found/present.
  2910. dnl
  2911. dnl If pkg-config is present, check that it has info about the $module or
  2912. dnl return "no" anyway!
  2913. dnl
  2914. dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
  2915. dnl
  2916. AC_DEFUN([CURL_CHECK_PKGCONFIG], [
  2917. if test -n "$PKG_CONFIG"; then
  2918. PKGCONFIG="$PKG_CONFIG"
  2919. else
  2920. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
  2921. [$PATH:/usr/bin:/usr/local/bin])
  2922. fi
  2923. if test "x$PKGCONFIG" != "xno"; then
  2924. AC_MSG_CHECKING([for $1 options with pkg-config])
  2925. dnl ask pkg-config about $1
  2926. itexists=`CURL_EXPORT_PCDIR([$2]) dnl
  2927. $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
  2928. if test -z "$itexists"; then
  2929. dnl pkg-config does not have info about the given module! set the
  2930. dnl variable to 'no'
  2931. PKGCONFIG="no"
  2932. AC_MSG_RESULT([no])
  2933. else
  2934. AC_MSG_RESULT([found])
  2935. fi
  2936. fi
  2937. ])
  2938. dnl CURL_GENERATE_CONFIGUREHELP_PM
  2939. dnl -------------------------------------------------
  2940. dnl Generate test harness configurehelp.pm module, defining and
  2941. dnl initializing some perl variables with values which are known
  2942. dnl when the configure script runs. For portability reasons, test
  2943. dnl harness needs information on how to run the C preprocessor.
  2944. AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
  2945. AC_REQUIRE([AC_PROG_CPP])dnl
  2946. tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
  2947. if test -z "$tmp_cpp"; then
  2948. tmp_cpp='cpp'
  2949. fi
  2950. cat >./tests/configurehelp.pm <<_EOF
  2951. [@%:@] This is a generated file. Do not edit.
  2952. package configurehelp;
  2953. use strict;
  2954. use warnings;
  2955. use Exporter;
  2956. use vars qw(
  2957. @ISA
  2958. @EXPORT_OK
  2959. \$Cpreprocessor
  2960. );
  2961. @ISA = qw(Exporter);
  2962. @EXPORT_OK = qw(
  2963. \$Cpreprocessor
  2964. );
  2965. \$Cpreprocessor = '$tmp_cpp';
  2966. 1;
  2967. _EOF
  2968. ])