acinclude.m4 85 KB

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