2
0

acinclude.m4 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2013, 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 http://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. AC_COMPILE_IFELSE([
  1769. AC_LANG_PROGRAM([[
  1770. #ifdef HAVE_SYS_TYPES_H
  1771. #include <sys/types.h>
  1772. #endif
  1773. #ifdef HAVE_SYS_TIME_H
  1774. #include <sys/time.h>
  1775. #ifdef TIME_WITH_SYS_TIME
  1776. #include <time.h>
  1777. #endif
  1778. #else
  1779. #ifdef HAVE_TIME_H
  1780. #include <time.h>
  1781. #endif
  1782. #endif
  1783. ]],[[
  1784. struct timespec ts;
  1785. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1786. ]])
  1787. ],[
  1788. AC_MSG_RESULT([yes])
  1789. ac_cv_func_clock_gettime="yes"
  1790. ],[
  1791. AC_MSG_RESULT([no])
  1792. ac_cv_func_clock_gettime="no"
  1793. ])
  1794. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  1795. dnl until library linking and run-time checks for clock_gettime succeed.
  1796. ])
  1797. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  1798. dnl -------------------------------------------------
  1799. dnl If monotonic clock_gettime is available then,
  1800. dnl check and prepended to LIBS any needed libraries.
  1801. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  1802. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  1803. #
  1804. if test "$ac_cv_func_clock_gettime" = "yes"; then
  1805. #
  1806. AC_MSG_CHECKING([for clock_gettime in libraries])
  1807. #
  1808. curl_cv_save_LIBS="$LIBS"
  1809. curl_cv_gclk_LIBS="unknown"
  1810. #
  1811. for x_xlibs in '' '-lrt' '-lposix4' ; do
  1812. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  1813. if test -z "$x_xlibs"; then
  1814. LIBS="$curl_cv_save_LIBS"
  1815. else
  1816. LIBS="$x_xlibs $curl_cv_save_LIBS"
  1817. fi
  1818. AC_LINK_IFELSE([
  1819. AC_LANG_PROGRAM([[
  1820. #ifdef HAVE_SYS_TYPES_H
  1821. #include <sys/types.h>
  1822. #endif
  1823. #ifdef HAVE_SYS_TIME_H
  1824. #include <sys/time.h>
  1825. #ifdef TIME_WITH_SYS_TIME
  1826. #include <time.h>
  1827. #endif
  1828. #else
  1829. #ifdef HAVE_TIME_H
  1830. #include <time.h>
  1831. #endif
  1832. #endif
  1833. ]],[[
  1834. struct timespec ts;
  1835. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1836. ]])
  1837. ],[
  1838. curl_cv_gclk_LIBS="$x_xlibs"
  1839. ])
  1840. fi
  1841. done
  1842. #
  1843. LIBS="$curl_cv_save_LIBS"
  1844. #
  1845. case X-"$curl_cv_gclk_LIBS" in
  1846. X-unknown)
  1847. AC_MSG_RESULT([cannot find clock_gettime])
  1848. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1849. ac_cv_func_clock_gettime="no"
  1850. ;;
  1851. X-)
  1852. AC_MSG_RESULT([no additional lib required])
  1853. ac_cv_func_clock_gettime="yes"
  1854. ;;
  1855. *)
  1856. if test -z "$curl_cv_save_LIBS"; then
  1857. LIBS="$curl_cv_gclk_LIBS"
  1858. else
  1859. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  1860. fi
  1861. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  1862. ac_cv_func_clock_gettime="yes"
  1863. ;;
  1864. esac
  1865. #
  1866. dnl only do runtime verification when not cross-compiling
  1867. if test "x$cross_compiling" != "xyes" &&
  1868. test "$ac_cv_func_clock_gettime" = "yes"; then
  1869. AC_MSG_CHECKING([if monotonic clock_gettime works])
  1870. AC_RUN_IFELSE([
  1871. AC_LANG_PROGRAM([[
  1872. #ifdef HAVE_STDLIB_H
  1873. #include <stdlib.h>
  1874. #endif
  1875. #ifdef HAVE_SYS_TYPES_H
  1876. #include <sys/types.h>
  1877. #endif
  1878. #ifdef HAVE_SYS_TIME_H
  1879. #include <sys/time.h>
  1880. #ifdef TIME_WITH_SYS_TIME
  1881. #include <time.h>
  1882. #endif
  1883. #else
  1884. #ifdef HAVE_TIME_H
  1885. #include <time.h>
  1886. #endif
  1887. #endif
  1888. ]],[[
  1889. struct timespec ts;
  1890. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  1891. exit(0);
  1892. else
  1893. exit(1);
  1894. ]])
  1895. ],[
  1896. AC_MSG_RESULT([yes])
  1897. ],[
  1898. AC_MSG_RESULT([no])
  1899. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1900. ac_cv_func_clock_gettime="no"
  1901. LIBS="$curl_cv_save_LIBS"
  1902. ])
  1903. fi
  1904. #
  1905. case "$ac_cv_func_clock_gettime" in
  1906. yes)
  1907. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  1908. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  1909. ;;
  1910. esac
  1911. #
  1912. fi
  1913. #
  1914. ])
  1915. dnl CURL_CHECK_LIBS_CONNECT
  1916. dnl -------------------------------------------------
  1917. dnl Verify if network connect function is already available
  1918. dnl using current libraries or if another one is required.
  1919. AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
  1920. AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
  1921. AC_MSG_CHECKING([for connect in libraries])
  1922. tst_connect_save_LIBS="$LIBS"
  1923. tst_connect_need_LIBS="unknown"
  1924. for tst_lib in '' '-lsocket' ; do
  1925. if test "$tst_connect_need_LIBS" = "unknown"; then
  1926. LIBS="$tst_lib $tst_connect_save_LIBS"
  1927. AC_LINK_IFELSE([
  1928. AC_LANG_PROGRAM([[
  1929. $curl_includes_winsock2
  1930. #ifndef HAVE_WINDOWS_H
  1931. int connect(int, void*, int);
  1932. #endif
  1933. ]],[[
  1934. if(0 != connect(0, 0, 0))
  1935. return 1;
  1936. ]])
  1937. ],[
  1938. tst_connect_need_LIBS="$tst_lib"
  1939. ])
  1940. fi
  1941. done
  1942. LIBS="$tst_connect_save_LIBS"
  1943. #
  1944. case X-"$tst_connect_need_LIBS" in
  1945. X-unknown)
  1946. AC_MSG_RESULT([cannot find connect])
  1947. AC_MSG_ERROR([cannot find connect function in libraries.])
  1948. ;;
  1949. X-)
  1950. AC_MSG_RESULT([yes])
  1951. ;;
  1952. *)
  1953. AC_MSG_RESULT([$tst_connect_need_LIBS])
  1954. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  1955. ;;
  1956. esac
  1957. ])
  1958. dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
  1959. dnl -------------------------------------------------
  1960. dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
  1961. dnl symbol that can be further used in custom template configuration
  1962. dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
  1963. dnl argument for the description. Symbol definitions done with this
  1964. dnl macro are intended to be exclusively used in handcrafted *.h.in
  1965. dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
  1966. dnl prevents autoheader generation and insertion of symbol template
  1967. dnl stub and definition into the first configuration header file. Do
  1968. dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
  1969. dnl one serves different functional needs.
  1970. AC_DEFUN([CURL_DEFINE_UNQUOTED], [
  1971. cat >>confdefs.h <<_EOF
  1972. [@%:@define] $1 ifelse($#, 2, [$2], 1)
  1973. _EOF
  1974. ])
  1975. dnl CURL_CONFIGURE_LONG
  1976. dnl -------------------------------------------------
  1977. dnl Find out the size of long as reported by sizeof() and define
  1978. dnl CURL_SIZEOF_LONG as appropriate to be used in template file
  1979. dnl include/curl/curlbuild.h.in to properly configure the library.
  1980. dnl The size of long is a build time characteristic and as such
  1981. dnl must be recorded in curlbuild.h
  1982. AC_DEFUN([CURL_CONFIGURE_LONG], [
  1983. if test -z "$ac_cv_sizeof_long" ||
  1984. test "$ac_cv_sizeof_long" -eq "0"; then
  1985. AC_MSG_ERROR([cannot find out size of long.])
  1986. fi
  1987. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
  1988. ])
  1989. dnl CURL_CONFIGURE_CURL_SOCKLEN_T
  1990. dnl -------------------------------------------------
  1991. dnl Find out suitable curl_socklen_t data type definition and size, making
  1992. dnl appropriate definitions for template file include/curl/curlbuild.h.in
  1993. dnl to properly configure and use the library.
  1994. dnl
  1995. dnl The need for the curl_socklen_t definition arises mainly to properly
  1996. dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
  1997. dnl data type which is 32 or 64-Bit wide depending on the data model being
  1998. dnl used, and that on the other hand is only actually used when interfacing
  1999. dnl the X/Open sockets provided in the xnet library.
  2000. AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
  2001. AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
  2002. AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
  2003. AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
  2004. #
  2005. AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
  2006. #
  2007. AC_MSG_CHECKING([for curl_socklen_t data type])
  2008. curl_typeof_curl_socklen_t="unknown"
  2009. for arg1 in int SOCKET; do
  2010. for arg2 in 'struct sockaddr' void; do
  2011. for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
  2012. if test "$curl_typeof_curl_socklen_t" = "unknown"; then
  2013. AC_COMPILE_IFELSE([
  2014. AC_LANG_PROGRAM([[
  2015. $curl_includes_ws2tcpip
  2016. $curl_includes_sys_socket
  2017. $curl_preprocess_callconv
  2018. extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
  2019. ]],[[
  2020. $t *lenptr = 0;
  2021. if(0 != getpeername(0, 0, lenptr))
  2022. return 1;
  2023. ]])
  2024. ],[
  2025. curl_typeof_curl_socklen_t="$t"
  2026. ])
  2027. fi
  2028. done
  2029. done
  2030. done
  2031. for t in socklen_t int; do
  2032. if test "$curl_typeof_curl_socklen_t" = "void"; then
  2033. AC_COMPILE_IFELSE([
  2034. AC_LANG_PROGRAM([[
  2035. $curl_includes_sys_socket
  2036. typedef $t curl_socklen_t;
  2037. ]],[[
  2038. curl_socklen_t dummy;
  2039. ]])
  2040. ],[
  2041. curl_typeof_curl_socklen_t="$t"
  2042. ])
  2043. fi
  2044. done
  2045. AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
  2046. if test "$curl_typeof_curl_socklen_t" = "void" ||
  2047. test "$curl_typeof_curl_socklen_t" = "unknown"; then
  2048. AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
  2049. fi
  2050. #
  2051. AC_MSG_CHECKING([size of curl_socklen_t])
  2052. curl_sizeof_curl_socklen_t="unknown"
  2053. curl_pull_headers_socklen_t="unknown"
  2054. if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
  2055. tst_pull_header_checks='none ws2tcpip'
  2056. tst_size_checks='4'
  2057. else
  2058. tst_pull_header_checks='none systypes syssocket'
  2059. tst_size_checks='4 8 2'
  2060. fi
  2061. for tst_size in $tst_size_checks; do
  2062. for tst_pull_headers in $tst_pull_header_checks; do
  2063. if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
  2064. case $tst_pull_headers in
  2065. ws2tcpip)
  2066. tmp_includes="$curl_includes_ws2tcpip"
  2067. ;;
  2068. systypes)
  2069. tmp_includes="$curl_includes_sys_types"
  2070. ;;
  2071. syssocket)
  2072. tmp_includes="$curl_includes_sys_socket"
  2073. ;;
  2074. *)
  2075. tmp_includes=""
  2076. ;;
  2077. esac
  2078. AC_COMPILE_IFELSE([
  2079. AC_LANG_PROGRAM([[
  2080. $tmp_includes
  2081. typedef $curl_typeof_curl_socklen_t curl_socklen_t;
  2082. typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
  2083. ]],[[
  2084. curl_socklen_t dummy;
  2085. ]])
  2086. ],[
  2087. curl_sizeof_curl_socklen_t="$tst_size"
  2088. curl_pull_headers_socklen_t="$tst_pull_headers"
  2089. ])
  2090. fi
  2091. done
  2092. done
  2093. AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
  2094. if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
  2095. AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
  2096. fi
  2097. #
  2098. case $curl_pull_headers_socklen_t in
  2099. ws2tcpip)
  2100. CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
  2101. ;;
  2102. systypes)
  2103. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
  2104. ;;
  2105. syssocket)
  2106. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
  2107. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
  2108. ;;
  2109. esac
  2110. CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
  2111. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
  2112. ])
  2113. dnl CURL_CONFIGURE_PULL_SYS_POLL
  2114. dnl -------------------------------------------------
  2115. dnl Find out if system header file sys/poll.h must be included by the
  2116. dnl external interface, making appropriate definitions for template file
  2117. dnl include/curl/curlbuild.h.in to properly configure and use the library.
  2118. dnl
  2119. dnl The need for the sys/poll.h inclusion arises mainly to properly
  2120. dnl interface AIX systems which define macros 'events' and 'revents'.
  2121. AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
  2122. AC_REQUIRE([CURL_INCLUDES_POLL])dnl
  2123. #
  2124. tst_poll_events_macro_defined="unknown"
  2125. #
  2126. AC_COMPILE_IFELSE([
  2127. AC_LANG_PROGRAM([[
  2128. $curl_includes_poll
  2129. ]],[[
  2130. #if defined(events) || defined(revents)
  2131. return 0;
  2132. #else
  2133. force compilation error
  2134. #endif
  2135. ]])
  2136. ],[
  2137. tst_poll_events_macro_defined="yes"
  2138. ],[
  2139. tst_poll_events_macro_defined="no"
  2140. ])
  2141. #
  2142. if test "$tst_poll_events_macro_defined" = "yes"; then
  2143. if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
  2144. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
  2145. fi
  2146. fi
  2147. #
  2148. ])
  2149. dnl CURL_CHECK_FUNC_SELECT
  2150. dnl -------------------------------------------------
  2151. dnl Test if the socket select() function is available,
  2152. dnl and check its return type and the types of its
  2153. dnl arguments. If the function succeeds HAVE_SELECT
  2154. dnl will be defined, defining the types of the
  2155. dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
  2156. dnl and SELECT_TYPE_ARG5, defining the type of the
  2157. dnl function return value in SELECT_TYPE_RETV, and
  2158. dnl also defining the type qualifier of fifth argument
  2159. dnl in SELECT_QUAL_ARG5.
  2160. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  2161. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  2162. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  2163. #
  2164. AC_MSG_CHECKING([for select])
  2165. AC_LINK_IFELSE([
  2166. AC_LANG_PROGRAM([[
  2167. #undef inline
  2168. #ifdef HAVE_WINDOWS_H
  2169. #ifndef WIN32_LEAN_AND_MEAN
  2170. #define WIN32_LEAN_AND_MEAN
  2171. #endif
  2172. #include <windows.h>
  2173. #ifdef HAVE_WINSOCK2_H
  2174. #include <winsock2.h>
  2175. #else
  2176. #ifdef HAVE_WINSOCK_H
  2177. #include <winsock.h>
  2178. #endif
  2179. #endif
  2180. #endif
  2181. #ifdef HAVE_SYS_TYPES_H
  2182. #include <sys/types.h>
  2183. #endif
  2184. #ifdef HAVE_SYS_TIME_H
  2185. #include <sys/time.h>
  2186. #ifdef TIME_WITH_SYS_TIME
  2187. #include <time.h>
  2188. #endif
  2189. #else
  2190. #ifdef HAVE_TIME_H
  2191. #include <time.h>
  2192. #endif
  2193. #endif
  2194. #ifndef HAVE_WINDOWS_H
  2195. #ifdef HAVE_SYS_SELECT_H
  2196. #include <sys/select.h>
  2197. #endif
  2198. #ifdef HAVE_SYS_SOCKET_H
  2199. #include <sys/socket.h>
  2200. #endif
  2201. #endif
  2202. ]],[[
  2203. select(0, 0, 0, 0, 0);
  2204. ]])
  2205. ],[
  2206. AC_MSG_RESULT([yes])
  2207. curl_cv_select="yes"
  2208. ],[
  2209. AC_MSG_RESULT([no])
  2210. curl_cv_select="no"
  2211. ])
  2212. #
  2213. if test "$curl_cv_select" = "yes"; then
  2214. AC_CACHE_CHECK([types of args and return type for select],
  2215. [curl_cv_func_select_args], [
  2216. curl_cv_func_select_args="unknown"
  2217. for sel_retv in 'int' 'ssize_t'; do
  2218. for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
  2219. for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
  2220. for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
  2221. if test "$curl_cv_func_select_args" = "unknown"; then
  2222. AC_COMPILE_IFELSE([
  2223. AC_LANG_PROGRAM([[
  2224. #undef inline
  2225. #ifdef HAVE_WINDOWS_H
  2226. #ifndef WIN32_LEAN_AND_MEAN
  2227. #define WIN32_LEAN_AND_MEAN
  2228. #endif
  2229. #include <windows.h>
  2230. #ifdef HAVE_WINSOCK2_H
  2231. #include <winsock2.h>
  2232. #else
  2233. #ifdef HAVE_WINSOCK_H
  2234. #include <winsock.h>
  2235. #endif
  2236. #endif
  2237. #define SELECTCALLCONV PASCAL
  2238. #endif
  2239. #ifdef HAVE_SYS_TYPES_H
  2240. #include <sys/types.h>
  2241. #endif
  2242. #ifdef HAVE_SYS_TIME_H
  2243. #include <sys/time.h>
  2244. #ifdef TIME_WITH_SYS_TIME
  2245. #include <time.h>
  2246. #endif
  2247. #else
  2248. #ifdef HAVE_TIME_H
  2249. #include <time.h>
  2250. #endif
  2251. #endif
  2252. #ifndef HAVE_WINDOWS_H
  2253. #ifdef HAVE_SYS_SELECT_H
  2254. #include <sys/select.h>
  2255. #endif
  2256. #ifdef HAVE_SYS_SOCKET_H
  2257. #include <sys/socket.h>
  2258. #endif
  2259. #define SELECTCALLCONV
  2260. #endif
  2261. #ifndef HAVE_STRUCT_TIMEVAL
  2262. struct timeval {
  2263. long tv_sec;
  2264. long tv_usec;
  2265. };
  2266. #endif
  2267. extern $sel_retv SELECTCALLCONV select($sel_arg1,
  2268. $sel_arg234,
  2269. $sel_arg234,
  2270. $sel_arg234,
  2271. $sel_arg5);
  2272. ]],[[
  2273. $sel_arg1 nfds=0;
  2274. $sel_arg234 rfds=0;
  2275. $sel_arg234 wfds=0;
  2276. $sel_arg234 efds=0;
  2277. $sel_retv res = select(nfds, rfds, wfds, efds, 0);
  2278. ]])
  2279. ],[
  2280. curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
  2281. ])
  2282. fi
  2283. done
  2284. done
  2285. done
  2286. done
  2287. ]) # AC-CACHE-CHECK
  2288. if test "$curl_cv_func_select_args" = "unknown"; then
  2289. AC_MSG_WARN([Cannot find proper types to use for select args])
  2290. AC_MSG_WARN([HAVE_SELECT will not be defined])
  2291. else
  2292. select_prev_IFS=$IFS; IFS=','
  2293. set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
  2294. IFS=$select_prev_IFS
  2295. shift
  2296. #
  2297. sel_qual_type_arg5=$[3]
  2298. #
  2299. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
  2300. [Define to the type of arg 1 for select.])
  2301. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
  2302. [Define to the type of args 2, 3 and 4 for select.])
  2303. AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
  2304. [Define to the function return type for select.])
  2305. #
  2306. prev_sh_opts=$-
  2307. #
  2308. case $prev_sh_opts in
  2309. *f*)
  2310. ;;
  2311. *)
  2312. set -f
  2313. ;;
  2314. esac
  2315. #
  2316. case "$sel_qual_type_arg5" in
  2317. const*)
  2318. sel_qual_arg5=const
  2319. sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
  2320. ;;
  2321. *)
  2322. sel_qual_arg5=
  2323. sel_type_arg5=$sel_qual_type_arg5
  2324. ;;
  2325. esac
  2326. #
  2327. AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
  2328. [Define to the type qualifier of arg 5 for select.])
  2329. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
  2330. [Define to the type of arg 5 for select.])
  2331. #
  2332. case $prev_sh_opts in
  2333. *f*)
  2334. ;;
  2335. *)
  2336. set +f
  2337. ;;
  2338. esac
  2339. #
  2340. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  2341. [Define to 1 if you have the select function.])
  2342. ac_cv_func_select="yes"
  2343. fi
  2344. fi
  2345. ])
  2346. # This is only a temporary fix. This macro is here to replace the broken one
  2347. # delivered by the automake project (including the 1.9.6 release). As soon as
  2348. # they ship a working version we SHOULD remove this work-around.
  2349. AC_DEFUN([AM_MISSING_HAS_RUN],
  2350. [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
  2351. test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
  2352. # Use eval to expand $SHELL
  2353. if eval "$MISSING --run true"; then
  2354. am_missing_run="$MISSING --run "
  2355. else
  2356. am_missing_run=
  2357. AC_MSG_WARN([`missing' script is too old or missing])
  2358. fi
  2359. ])
  2360. dnl CURL_VERIFY_RUNTIMELIBS
  2361. dnl -------------------------------------------------
  2362. dnl Verify that the shared libs found so far can be used when running
  2363. dnl programs, since otherwise the situation will create odd configure errors
  2364. dnl that are misleading people.
  2365. dnl
  2366. dnl Make sure this test is run BEFORE the first test in the script that
  2367. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  2368. dnl macro. It must also run AFTER all lib-checking macros are complete.
  2369. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  2370. dnl this test is of course not sensible if we are cross-compiling!
  2371. if test "x$cross_compiling" != xyes; then
  2372. dnl just run a program to verify that the libs checked for previous to this
  2373. dnl point also is available run-time!
  2374. AC_MSG_CHECKING([run-time libs availability])
  2375. AC_TRY_RUN([
  2376. main()
  2377. {
  2378. return 0;
  2379. }
  2380. ],
  2381. AC_MSG_RESULT([fine]),
  2382. AC_MSG_RESULT([failed])
  2383. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  2384. )
  2385. dnl if this test fails, configure has already stopped
  2386. fi
  2387. ])
  2388. dnl CURL_CHECK_VARIADIC_MACROS
  2389. dnl -------------------------------------------------
  2390. dnl Check compiler support of variadic macros
  2391. AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
  2392. AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
  2393. [curl_cv_variadic_macros_c99], [
  2394. AC_COMPILE_IFELSE([
  2395. AC_LANG_PROGRAM([[
  2396. #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
  2397. #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
  2398. int fun3(int arg1, int arg2, int arg3);
  2399. int fun2(int arg1, int arg2);
  2400. int fun3(int arg1, int arg2, int arg3)
  2401. { return arg1 + arg2 + arg3; }
  2402. int fun2(int arg1, int arg2)
  2403. { return arg1 + arg2; }
  2404. ]],[[
  2405. int res3 = c99_vmacro3(1, 2, 3);
  2406. int res2 = c99_vmacro2(1, 2);
  2407. ]])
  2408. ],[
  2409. curl_cv_variadic_macros_c99="yes"
  2410. ],[
  2411. curl_cv_variadic_macros_c99="no"
  2412. ])
  2413. ])
  2414. case "$curl_cv_variadic_macros_c99" in
  2415. yes)
  2416. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
  2417. [Define to 1 if compiler supports C99 variadic macro style.])
  2418. ;;
  2419. esac
  2420. AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
  2421. [curl_cv_variadic_macros_gcc], [
  2422. AC_COMPILE_IFELSE([
  2423. AC_LANG_PROGRAM([[
  2424. #define gcc_vmacro3(first, args...) fun3(first, args)
  2425. #define gcc_vmacro2(first, args...) fun2(first, args)
  2426. int fun3(int arg1, int arg2, int arg3);
  2427. int fun2(int arg1, int arg2);
  2428. int fun3(int arg1, int arg2, int arg3)
  2429. { return arg1 + arg2 + arg3; }
  2430. int fun2(int arg1, int arg2)
  2431. { return arg1 + arg2; }
  2432. ]],[[
  2433. int res3 = gcc_vmacro3(1, 2, 3);
  2434. int res2 = gcc_vmacro2(1, 2);
  2435. ]])
  2436. ],[
  2437. curl_cv_variadic_macros_gcc="yes"
  2438. ],[
  2439. curl_cv_variadic_macros_gcc="no"
  2440. ])
  2441. ])
  2442. case "$curl_cv_variadic_macros_gcc" in
  2443. yes)
  2444. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
  2445. [Define to 1 if compiler supports old gcc variadic macro style.])
  2446. ;;
  2447. esac
  2448. ])
  2449. dnl CURL_CHECK_CA_BUNDLE
  2450. dnl -------------------------------------------------
  2451. dnl Check if a default ca-bundle should be used
  2452. dnl
  2453. dnl regarding the paths this will scan:
  2454. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  2455. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  2456. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  2457. dnl /usr/local/share/certs/ca-root.crt FreeBSD
  2458. dnl /etc/ssl/cert.pem OpenBSD
  2459. dnl /etc/ssl/certs/ (ca path) SUSE
  2460. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  2461. AC_MSG_CHECKING([default CA cert bundle/path])
  2462. AC_ARG_WITH(ca-bundle,
  2463. AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
  2464. AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  2465. [
  2466. want_ca="$withval"
  2467. if test "x$want_ca" = "xyes"; then
  2468. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  2469. fi
  2470. ],
  2471. [ want_ca="unset" ])
  2472. AC_ARG_WITH(ca-path,
  2473. AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
  2474. AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  2475. [
  2476. want_capath="$withval"
  2477. if test "x$want_capath" = "xyes"; then
  2478. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  2479. fi
  2480. ],
  2481. [ want_capath="unset"])
  2482. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  2483. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2484. dnl both given
  2485. AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
  2486. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  2487. dnl --with-ca-bundle given
  2488. ca="$want_ca"
  2489. capath="no"
  2490. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2491. dnl --with-ca-path given
  2492. if test "x$OPENSSL_ENABLED" != "x1" -a "x$POLARSSL_ENABLED" != "x1"; then
  2493. AC_MSG_ERROR([--with-ca-path only works with openSSL or PolarSSL])
  2494. fi
  2495. capath="$want_capath"
  2496. ca="no"
  2497. else
  2498. dnl first try autodetecting a CA bundle , then a CA path
  2499. dnl both autodetections can be skipped by --without-ca-*
  2500. ca="no"
  2501. capath="no"
  2502. if test "x$cross_compiling" != "xyes"; then
  2503. dnl NOT cross-compiling and...
  2504. dnl neither of the --with-ca-* options are provided
  2505. if test "x$want_ca" = "xunset"; then
  2506. dnl the path we previously would have installed the curl ca bundle
  2507. dnl to, and thus we now check for an already existing cert in that
  2508. dnl place in case we find no other
  2509. if test "x$prefix" != xNONE; then
  2510. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  2511. else
  2512. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  2513. fi
  2514. for a in /etc/ssl/certs/ca-certificates.crt \
  2515. /etc/pki/tls/certs/ca-bundle.crt \
  2516. /usr/share/ssl/certs/ca-bundle.crt \
  2517. /usr/local/share/certs/ca-root.crt \
  2518. /etc/ssl/cert.pem \
  2519. "$cac"; do
  2520. if test -f "$a"; then
  2521. ca="$a"
  2522. break
  2523. fi
  2524. done
  2525. fi
  2526. if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
  2527. "x$OPENSSL_ENABLED" = "x1"; then
  2528. for a in /etc/ssl/certs/; do
  2529. 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
  2530. capath="$a"
  2531. break
  2532. fi
  2533. done
  2534. fi
  2535. else
  2536. dnl no option given and cross-compiling
  2537. AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
  2538. fi
  2539. fi
  2540. if test "x$ca" != "xno"; then
  2541. CURL_CA_BUNDLE='"'$ca'"'
  2542. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  2543. AC_SUBST(CURL_CA_BUNDLE)
  2544. AC_MSG_RESULT([$ca])
  2545. elif test "x$capath" != "xno"; then
  2546. CURL_CA_PATH="\"$capath\""
  2547. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  2548. AC_MSG_RESULT([$capath (capath)])
  2549. else
  2550. AC_MSG_RESULT([no])
  2551. fi
  2552. ])
  2553. dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
  2554. dnl -------------------------------------------------
  2555. dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
  2556. AC_DEFUN([DO_CURL_OFF_T_CHECK], [
  2557. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  2558. if test "$curl_typeof_curl_off_t" = "unknown" && test ! -z "$1"; then
  2559. tmp_includes=""
  2560. tmp_source=""
  2561. tmp_fmt=""
  2562. case XC_SH_TR_SH([$1]) in
  2563. int64_t)
  2564. tmp_includes="$curl_includes_inttypes"
  2565. tmp_source="char f@<:@@:>@ = PRId64;"
  2566. tmp_fmt="PRId64"
  2567. ;;
  2568. int32_t)
  2569. tmp_includes="$curl_includes_inttypes"
  2570. tmp_source="char f@<:@@:>@ = PRId32;"
  2571. tmp_fmt="PRId32"
  2572. ;;
  2573. int16_t)
  2574. tmp_includes="$curl_includes_inttypes"
  2575. tmp_source="char f@<:@@:>@ = PRId16;"
  2576. tmp_fmt="PRId16"
  2577. ;;
  2578. esac
  2579. AC_COMPILE_IFELSE([
  2580. AC_LANG_PROGRAM([[
  2581. $tmp_includes
  2582. typedef $1 curl_off_t;
  2583. typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
  2584. ]],[[
  2585. $tmp_source
  2586. curl_off_t dummy;
  2587. ]])
  2588. ],[
  2589. if test -z "$tmp_fmt"; then
  2590. curl_typeof_curl_off_t="$1"
  2591. curl_sizeof_curl_off_t="$2"
  2592. else
  2593. CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
  2594. AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
  2595. AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
  2596. if test AS_VAR_GET(tmp_HaveFmtDef) = "yes"; then
  2597. curl_format_curl_off_t=AS_VAR_GET(tmp_FmtDef)
  2598. curl_typeof_curl_off_t="$1"
  2599. curl_sizeof_curl_off_t="$2"
  2600. fi
  2601. AS_VAR_POPDEF([tmp_FmtDef])dnl
  2602. AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
  2603. fi
  2604. ])
  2605. fi
  2606. ])
  2607. dnl DO_CURL_OFF_T_SUFFIX_CHECK (TYPE)
  2608. dnl -------------------------------------------------
  2609. dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
  2610. AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [
  2611. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  2612. AC_MSG_CHECKING([constant suffix string for curl_off_t])
  2613. #
  2614. curl_suffix_curl_off_t="unknown"
  2615. curl_suffix_curl_off_tu="unknown"
  2616. #
  2617. case XC_SH_TR_SH([$1]) in
  2618. long_long | __longlong | __longlong_t)
  2619. tst_suffixes="LL::"
  2620. ;;
  2621. long)
  2622. tst_suffixes="L::"
  2623. ;;
  2624. int)
  2625. tst_suffixes="::"
  2626. ;;
  2627. __int64 | int64_t)
  2628. tst_suffixes="LL:i64::"
  2629. ;;
  2630. __int32 | int32_t)
  2631. tst_suffixes="L:i32::"
  2632. ;;
  2633. __int16 | int16_t)
  2634. tst_suffixes="L:i16::"
  2635. ;;
  2636. *)
  2637. AC_MSG_ERROR([unexpected data type $1])
  2638. ;;
  2639. esac
  2640. #
  2641. old_IFS=$IFS; IFS=':'
  2642. for tmp_ssuf in $tst_suffixes ; do
  2643. IFS=$old_IFS
  2644. if test "x$curl_suffix_curl_off_t" = "xunknown"; then
  2645. case $tmp_ssuf in
  2646. i64 | i32 | i16)
  2647. tmp_usuf="u$tmp_ssuf"
  2648. ;;
  2649. LL | L)
  2650. tmp_usuf="U$tmp_ssuf"
  2651. ;;
  2652. *)
  2653. tmp_usuf=""
  2654. ;;
  2655. esac
  2656. AC_COMPILE_IFELSE([
  2657. AC_LANG_PROGRAM([[
  2658. $curl_includes_inttypes
  2659. typedef $1 new_t;
  2660. ]],[[
  2661. new_t s1;
  2662. new_t s2;
  2663. s1 = -10$tmp_ssuf ;
  2664. s2 = 20$tmp_ssuf ;
  2665. if(s1 > s2)
  2666. return 1;
  2667. ]])
  2668. ],[
  2669. curl_suffix_curl_off_t="$tmp_ssuf"
  2670. curl_suffix_curl_off_tu="$tmp_usuf"
  2671. ])
  2672. fi
  2673. done
  2674. IFS=$old_IFS
  2675. #
  2676. if test "x$curl_suffix_curl_off_t" = "xunknown"; then
  2677. AC_MSG_ERROR([cannot find constant suffix string for curl_off_t.])
  2678. else
  2679. AC_MSG_RESULT([$curl_suffix_curl_off_t])
  2680. AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
  2681. AC_MSG_RESULT([$curl_suffix_curl_off_tu])
  2682. fi
  2683. #
  2684. ])
  2685. dnl CURL_CONFIGURE_CURL_OFF_T
  2686. dnl -------------------------------------------------
  2687. dnl Find out suitable curl_off_t data type definition and associated
  2688. dnl items, and make the appropriate definitions used in template file
  2689. dnl include/curl/curlbuild.h.in to properly configure the library.
  2690. AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
  2691. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  2692. #
  2693. AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
  2694. AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
  2695. AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
  2696. #
  2697. if test -z "$SED"; then
  2698. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  2699. fi
  2700. #
  2701. AC_CHECK_SIZEOF(long)
  2702. AC_CHECK_SIZEOF(void*)
  2703. #
  2704. if test -z "$ac_cv_sizeof_long" ||
  2705. test "$ac_cv_sizeof_long" -eq "0"; then
  2706. AC_MSG_ERROR([cannot find out size of long.])
  2707. fi
  2708. if test -z "$ac_cv_sizeof_voidp" ||
  2709. test "$ac_cv_sizeof_voidp" -eq "0"; then
  2710. AC_MSG_ERROR([cannot find out size of void*.])
  2711. fi
  2712. #
  2713. x_LP64_long=""
  2714. x_LP32_long=""
  2715. x_LP16_long=""
  2716. #
  2717. if test "$ac_cv_sizeof_long" -eq "8" &&
  2718. test "$ac_cv_sizeof_voidp" -ge "8"; then
  2719. x_LP64_long="long"
  2720. elif test "$ac_cv_sizeof_long" -eq "4" &&
  2721. test "$ac_cv_sizeof_voidp" -ge "4"; then
  2722. x_LP32_long="long"
  2723. elif test "$ac_cv_sizeof_long" -eq "2" &&
  2724. test "$ac_cv_sizeof_voidp" -ge "2"; then
  2725. x_LP16_long="long"
  2726. fi
  2727. #
  2728. dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
  2729. #
  2730. curl_typeof_curl_off_t="unknown"
  2731. curl_sizeof_curl_off_t="unknown"
  2732. curl_format_curl_off_t="unknown"
  2733. curl_format_curl_off_tu="unknown"
  2734. #
  2735. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2736. AC_MSG_CHECKING([for 64-bit curl_off_t data type])
  2737. for t8 in \
  2738. "$x_LP64_long" \
  2739. 'int64_t' \
  2740. '__int64' \
  2741. 'long long' \
  2742. '__longlong' \
  2743. '__longlong_t' ; do
  2744. DO_CURL_OFF_T_CHECK([$t8], [8])
  2745. done
  2746. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  2747. fi
  2748. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2749. AC_MSG_CHECKING([for 32-bit curl_off_t data type])
  2750. for t4 in \
  2751. "$x_LP32_long" \
  2752. 'int32_t' \
  2753. '__int32' \
  2754. 'int' ; do
  2755. DO_CURL_OFF_T_CHECK([$t4], [4])
  2756. done
  2757. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  2758. fi
  2759. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2760. AC_MSG_CHECKING([for 16-bit curl_off_t data type])
  2761. for t2 in \
  2762. "$x_LP16_long" \
  2763. 'int16_t' \
  2764. '__int16' \
  2765. 'int' ; do
  2766. DO_CURL_OFF_T_CHECK([$t2], [2])
  2767. done
  2768. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  2769. fi
  2770. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2771. AC_MSG_ERROR([cannot find data type for curl_off_t.])
  2772. fi
  2773. #
  2774. AC_MSG_CHECKING([size of curl_off_t])
  2775. AC_MSG_RESULT([$curl_sizeof_curl_off_t])
  2776. #
  2777. AC_MSG_CHECKING([formatting string directive for curl_off_t])
  2778. if test "$curl_format_curl_off_t" != "unknown"; then
  2779. x_pull_headers="yes"
  2780. curl_format_curl_off_t=`echo "$curl_format_curl_off_t" | "$SED" 's/[["]]//g'`
  2781. curl_format_curl_off_tu=`echo "$curl_format_curl_off_t" | "$SED" 's/i$/u/'`
  2782. curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/d$/u/'`
  2783. curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'`
  2784. else
  2785. x_pull_headers="no"
  2786. case XC_SH_TR_SH([$curl_typeof_curl_off_t]) in
  2787. long_long | __longlong | __longlong_t)
  2788. curl_format_curl_off_t="lld"
  2789. curl_format_curl_off_tu="llu"
  2790. ;;
  2791. long)
  2792. curl_format_curl_off_t="ld"
  2793. curl_format_curl_off_tu="lu"
  2794. ;;
  2795. int)
  2796. curl_format_curl_off_t="d"
  2797. curl_format_curl_off_tu="u"
  2798. ;;
  2799. __int64)
  2800. curl_format_curl_off_t="I64d"
  2801. curl_format_curl_off_tu="I64u"
  2802. ;;
  2803. __int32)
  2804. curl_format_curl_off_t="I32d"
  2805. curl_format_curl_off_tu="I32u"
  2806. ;;
  2807. __int16)
  2808. curl_format_curl_off_t="I16d"
  2809. curl_format_curl_off_tu="I16u"
  2810. ;;
  2811. *)
  2812. AC_MSG_ERROR([cannot find print format string for curl_off_t.])
  2813. ;;
  2814. esac
  2815. fi
  2816. AC_MSG_RESULT(["$curl_format_curl_off_t"])
  2817. #
  2818. AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
  2819. AC_MSG_RESULT(["$curl_format_curl_off_tu"])
  2820. #
  2821. DO_CURL_OFF_T_SUFFIX_CHECK([$curl_typeof_curl_off_t])
  2822. #
  2823. if test "$x_pull_headers" = "yes"; then
  2824. if test "x$ac_cv_header_sys_types_h" = "xyes"; then
  2825. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
  2826. fi
  2827. if test "x$ac_cv_header_stdint_h" = "xyes"; then
  2828. CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
  2829. fi
  2830. if test "x$ac_cv_header_inttypes_h" = "xyes"; then
  2831. CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
  2832. fi
  2833. fi
  2834. #
  2835. CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_OFF_T], [$curl_typeof_curl_off_t])
  2836. CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_T], ["$curl_format_curl_off_t"])
  2837. CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_TU], ["$curl_format_curl_off_tu"])
  2838. CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$curl_format_curl_off_t"])
  2839. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$curl_sizeof_curl_off_t])
  2840. CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$curl_suffix_curl_off_t])
  2841. CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$curl_suffix_curl_off_tu])
  2842. #
  2843. ])
  2844. dnl CURL_CHECK_WIN32_LARGEFILE
  2845. dnl -------------------------------------------------
  2846. dnl Check if curl's WIN32 large file will be used
  2847. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  2848. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  2849. AC_MSG_CHECKING([whether build target supports WIN32 file API])
  2850. curl_win32_file_api="no"
  2851. if test "$ac_cv_header_windows_h" = "yes"; then
  2852. if test x"$enable_largefile" != "xno"; then
  2853. AC_COMPILE_IFELSE([
  2854. AC_LANG_PROGRAM([[
  2855. ]],[[
  2856. #if !defined(_WIN32_WCE) && \
  2857. (defined(__MINGW32__) || \
  2858. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
  2859. int dummy=1;
  2860. #else
  2861. WIN32 large file API not supported.
  2862. #endif
  2863. ]])
  2864. ],[
  2865. curl_win32_file_api="win32_large_files"
  2866. ])
  2867. fi
  2868. if test "$curl_win32_file_api" = "no"; then
  2869. AC_COMPILE_IFELSE([
  2870. AC_LANG_PROGRAM([[
  2871. ]],[[
  2872. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  2873. int dummy=1;
  2874. #else
  2875. WIN32 small file API not supported.
  2876. #endif
  2877. ]])
  2878. ],[
  2879. curl_win32_file_api="win32_small_files"
  2880. ])
  2881. fi
  2882. fi
  2883. case "$curl_win32_file_api" in
  2884. win32_large_files)
  2885. AC_MSG_RESULT([yes (large file enabled)])
  2886. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  2887. [Define to 1 if you are building a Windows target with large file support.])
  2888. ;;
  2889. win32_small_files)
  2890. AC_MSG_RESULT([yes (large file disabled)])
  2891. AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
  2892. [Define to 1 if you are building a Windows target without large file support.])
  2893. ;;
  2894. *)
  2895. AC_MSG_RESULT([no])
  2896. ;;
  2897. esac
  2898. ])
  2899. dnl CURL_EXPORT_PCDIR ($pcdir)
  2900. dnl ------------------------
  2901. dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
  2902. dnl
  2903. dnl we need this macro since pkg-config distinguishes among empty and unset
  2904. dnl variable while checking PKG_CONFIG_LIBDIR
  2905. dnl
  2906. AC_DEFUN([CURL_EXPORT_PCDIR], [
  2907. if test -n "$1"; then
  2908. PKG_CONFIG_LIBDIR="$1"
  2909. export PKG_CONFIG_LIBDIR
  2910. fi
  2911. ])
  2912. dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
  2913. dnl ------------------------
  2914. dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
  2915. dnl path to it, or 'no' if not found/present.
  2916. dnl
  2917. dnl If pkg-config is present, check that it has info about the $module or
  2918. dnl return "no" anyway!
  2919. dnl
  2920. dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
  2921. dnl
  2922. AC_DEFUN([CURL_CHECK_PKGCONFIG], [
  2923. PKGCONFIG="no"
  2924. AC_PATH_TOOL( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
  2925. if test x$PKGCONFIG != xno; then
  2926. AC_MSG_CHECKING([for $1 options with pkg-config])
  2927. dnl ask pkg-config about $1
  2928. itexists=`CURL_EXPORT_PCDIR([$2]) dnl
  2929. $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
  2930. if test -z "$itexists"; then
  2931. dnl pkg-config does not have info about the given module! set the
  2932. dnl variable to 'no'
  2933. PKGCONFIG="no"
  2934. AC_MSG_RESULT([no])
  2935. else
  2936. AC_MSG_RESULT([found])
  2937. fi
  2938. fi
  2939. ])
  2940. dnl CURL_GENERATE_CONFIGUREHELP_PM
  2941. dnl -------------------------------------------------
  2942. dnl Generate test harness configurehelp.pm module, defining and
  2943. dnl initializing some perl variables with values which are known
  2944. dnl when the configure script runs. For portability reasons, test
  2945. dnl harness needs information on how to run the C preprocessor.
  2946. AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
  2947. AC_REQUIRE([AC_PROG_CPP])dnl
  2948. tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
  2949. if test -z "$tmp_cpp"; then
  2950. tmp_cpp='cpp'
  2951. fi
  2952. cat >./tests/configurehelp.pm <<_EOF
  2953. [@%:@] This is a generated file. Do not edit.
  2954. package configurehelp;
  2955. use strict;
  2956. use warnings;
  2957. use Exporter;
  2958. use vars qw(
  2959. @ISA
  2960. @EXPORT_OK
  2961. \$Cpreprocessor
  2962. );
  2963. @ISA = qw(Exporter);
  2964. @EXPORT_OK = qw(
  2965. \$Cpreprocessor
  2966. );
  2967. \$Cpreprocessor = '$tmp_cpp';
  2968. 1;
  2969. _EOF
  2970. ])