acinclude.m4 82 KB

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