acinclude.m4 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at http://curl.haxx.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. # $Id$
  22. #***************************************************************************
  23. dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
  24. dnl -------------------------------------------------
  25. dnl Use the C preprocessor to find out if the given object-style symbol
  26. dnl is defined and get its expansion. This macro will not use default
  27. dnl includes even if no INCLUDES argument is given. This macro will run
  28. dnl silently when invoked with three arguments. If the expansion would
  29. dnl result in a set of double-quoted strings the returned expansion will
  30. dnl actually be a single double-quoted string concatenating all them.
  31. AC_DEFUN([CURL_CHECK_DEF], [
  32. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  33. AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
  34. if test -z "$SED"; then
  35. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  36. fi
  37. if test -z "$GREP"; then
  38. AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
  39. fi
  40. ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
  41. tmp_exp=""
  42. AC_PREPROC_IFELSE([
  43. AC_LANG_SOURCE(
  44. ifelse($2,,,[$2])[[
  45. #ifdef $1
  46. CURL_DEF_TOKEN $1
  47. #endif
  48. ]])
  49. ],[
  50. tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
  51. "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
  52. "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
  53. "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
  54. if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
  55. tmp_exp=""
  56. fi
  57. ])
  58. if test -z "$tmp_exp"; then
  59. AS_VAR_SET(ac_HaveDef, no)
  60. ifelse($3,,[AC_MSG_RESULT([no])])
  61. else
  62. AS_VAR_SET(ac_HaveDef, yes)
  63. AS_VAR_SET(ac_Def, $tmp_exp)
  64. ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
  65. fi
  66. AS_VAR_POPDEF([ac_Def])dnl
  67. AS_VAR_POPDEF([ac_HaveDef])dnl
  68. ])
  69. dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
  70. dnl -------------------------------------------------
  71. dnl Use the C compiler to find out only if the given symbol is defined
  72. dnl or not, this can not find out its expansion. This macro will not use
  73. dnl default includes even if no INCLUDES argument is given. This macro
  74. dnl will run silently when invoked with three arguments.
  75. AC_DEFUN([CURL_CHECK_DEF_CC], [
  76. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  77. ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
  78. AC_COMPILE_IFELSE([
  79. AC_LANG_SOURCE(
  80. ifelse($2,,,[$2])[[
  81. int main (void)
  82. {
  83. #ifdef $1
  84. return 0;
  85. #else
  86. force compilation error
  87. #endif
  88. }
  89. ]])
  90. ],[
  91. tst_symbol_defined="yes"
  92. ],[
  93. tst_symbol_defined="no"
  94. ])
  95. if test "$tst_symbol_defined" = "yes"; then
  96. AS_VAR_SET(ac_HaveDef, yes)
  97. ifelse($3,,[AC_MSG_RESULT([yes])])
  98. else
  99. AS_VAR_SET(ac_HaveDef, no)
  100. ifelse($3,,[AC_MSG_RESULT([no])])
  101. fi
  102. AS_VAR_POPDEF([ac_HaveDef])dnl
  103. ])
  104. dnl CURL_CHECK_LIB_XNET
  105. dnl -------------------------------------------------
  106. dnl Verify if X/Open network library is required.
  107. AC_DEFUN([CURL_CHECK_LIB_XNET], [
  108. AC_MSG_CHECKING([if X/Open network library is required])
  109. tst_lib_xnet_required="no"
  110. AC_COMPILE_IFELSE([
  111. AC_LANG_SOURCE([[
  112. int main (void)
  113. {
  114. #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
  115. return 0;
  116. #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
  117. return 0;
  118. #else
  119. force compilation error
  120. #endif
  121. }
  122. ]])
  123. ],[
  124. tst_lib_xnet_required="yes"
  125. LIBS="$LIBS -lxnet"
  126. ])
  127. AC_MSG_RESULT([$tst_lib_xnet_required])
  128. ])
  129. dnl CURL_CHECK_AIX_ALL_SOURCE
  130. dnl -------------------------------------------------
  131. dnl Provides a replacement of traditional AC_AIX with
  132. dnl an uniform behaviour across all autoconf versions,
  133. dnl and with our own placement rules.
  134. AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
  135. AH_VERBATIM([_ALL_SOURCE],
  136. [/* Define to 1 if OS is AIX. */
  137. #ifndef _ALL_SOURCE
  138. # undef _ALL_SOURCE
  139. #endif])
  140. AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
  141. AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
  142. AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
  143. AC_EGREP_CPP([yes_this_is_aix],[
  144. #ifdef _AIX
  145. yes_this_is_aix
  146. #endif
  147. ],[
  148. AC_MSG_RESULT([yes])
  149. AC_DEFINE(_ALL_SOURCE)
  150. ],[
  151. AC_MSG_RESULT([no])
  152. ])
  153. ])
  154. dnl CURL_CHECK_HEADER_WINDOWS
  155. dnl -------------------------------------------------
  156. dnl Check for compilable and valid windows.h header
  157. AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
  158. AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
  159. AC_COMPILE_IFELSE([
  160. AC_LANG_PROGRAM([[
  161. #undef inline
  162. #ifndef WIN32_LEAN_AND_MEAN
  163. #define WIN32_LEAN_AND_MEAN
  164. #endif
  165. #include <windows.h>
  166. ]],[[
  167. #if defined(__CYGWIN__) || defined(__CEGCC__)
  168. HAVE_WINDOWS_H shall not be defined.
  169. #else
  170. int dummy=2*WINVER;
  171. #endif
  172. ]])
  173. ],[
  174. ac_cv_header_windows_h="yes"
  175. ],[
  176. ac_cv_header_windows_h="no"
  177. ])
  178. ])
  179. case "$ac_cv_header_windows_h" in
  180. yes)
  181. AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
  182. [Define to 1 if you have the windows.h header file.])
  183. AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
  184. [Define to avoid automatic inclusion of winsock.h])
  185. ;;
  186. esac
  187. ])
  188. dnl CURL_CHECK_NATIVE_WINDOWS
  189. dnl -------------------------------------------------
  190. dnl Check if building a native Windows target
  191. AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
  192. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  193. AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
  194. if test "$ac_cv_header_windows_h" = "no"; then
  195. ac_cv_native_windows="no"
  196. else
  197. AC_COMPILE_IFELSE([
  198. AC_LANG_PROGRAM([[
  199. ]],[[
  200. #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
  201. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
  202. int dummy=1;
  203. #else
  204. Not a native Windows build target.
  205. #endif
  206. ]])
  207. ],[
  208. ac_cv_native_windows="yes"
  209. ],[
  210. ac_cv_native_windows="no"
  211. ])
  212. fi
  213. ])
  214. case "$ac_cv_native_windows" in
  215. yes)
  216. AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
  217. [Define to 1 if you are building a native Windows target.])
  218. ;;
  219. esac
  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], [ac_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. ac_cv_header_winsock_h="yes"
  244. ],[
  245. ac_cv_header_winsock_h="no"
  246. ])
  247. ])
  248. case "$ac_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], [ac_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. ac_cv_header_winsock2_h="yes"
  278. ],[
  279. ac_cv_header_winsock2_h="no"
  280. ])
  281. ])
  282. case "$ac_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], [ac_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. ac_cv_header_ws2tcpip_h="yes"
  313. ],[
  314. ac_cv_header_ws2tcpip_h="no"
  315. ])
  316. ])
  317. case "$ac_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], [ac_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. ac_cv_header_winldap_h="yes"
  350. ],[
  351. ac_cv_header_winldap_h="no"
  352. ])
  353. ])
  354. case "$ac_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], [ac_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. ac_cv_header_winber_h="yes"
  389. ],[
  390. ac_cv_header_winber_h="no"
  391. ])
  392. ])
  393. case "$ac_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], [ac_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. ac_cv_header_lber_h="yes"
  431. ],[
  432. ac_cv_header_lber_h="no"
  433. ])
  434. ])
  435. if test "$ac_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], [ac_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. ac_cv_header_ldap_h="yes"
  510. ],[
  511. ac_cv_header_ldap_h="no"
  512. ])
  513. ])
  514. case "$ac_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], [ac_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. ac_cv_header_ldap_ssl_h="yes"
  555. ],[
  556. ac_cv_header_ldap_ssl_h="no"
  557. ])
  558. ])
  559. case "$ac_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], [ac_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. ac_cv_header_ldapssl_h="yes"
  604. ],[
  605. ac_cv_header_ldapssl_h="no"
  606. ])
  607. ])
  608. case "$ac_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], [ac_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. ac_cv_header_malloc_h="yes"
  828. ],[
  829. ac_cv_header_malloc_h="no"
  830. ])
  831. ])
  832. if test "$ac_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], [ac_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. ac_cv_header_memory_h="yes"
  877. ],[
  878. ac_cv_header_memory_h="no"
  879. ])
  880. ])
  881. if test "$ac_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. ac_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. [ac_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. ac_cv_working_ni_withscopeid="yes"
  1210. ],[
  1211. # Exit code != 0. Program failed.
  1212. ac_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. ac_cv_working_ni_withscopeid="yes"
  1226. ],[
  1227. ac_cv_working_ni_withscopeid="no"
  1228. ]) # AC-COMPILE-IFELSE
  1229. ]) # AC-RUN-IFELSE
  1230. ]) # AC-CACHE-CHECK
  1231. case "$ac_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. ac_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. ac_cv_func_send="yes"
  1527. fi
  1528. else
  1529. AC_MSG_ERROR([Unable to link function send])
  1530. fi
  1531. ])
  1532. dnl CURL_CHECK_FUNC_RECVFROM
  1533. dnl -------------------------------------------------
  1534. dnl Test if the socket recvfrom() function is available,
  1535. dnl and check its return type and the types of its
  1536. dnl arguments. If the function succeeds HAVE_RECVFROM
  1537. dnl will be defined, defining the types of the arguments
  1538. dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
  1539. dnl to RECVFROM_TYPE_ARG6, defining also the type of the
  1540. dnl function return value in RECVFROM_TYPE_RETV.
  1541. dnl Notice that the types returned for pointer arguments
  1542. dnl will actually be the type pointed by the pointer.
  1543. AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
  1544. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1545. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1546. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1547. #
  1548. AC_MSG_CHECKING([for recvfrom])
  1549. AC_LINK_IFELSE([
  1550. AC_LANG_PROGRAM([[
  1551. #undef inline
  1552. #ifdef HAVE_WINDOWS_H
  1553. #ifndef WIN32_LEAN_AND_MEAN
  1554. #define WIN32_LEAN_AND_MEAN
  1555. #endif
  1556. #include <windows.h>
  1557. #ifdef HAVE_WINSOCK2_H
  1558. #include <winsock2.h>
  1559. #else
  1560. #ifdef HAVE_WINSOCK_H
  1561. #include <winsock.h>
  1562. #endif
  1563. #endif
  1564. #else
  1565. #ifdef HAVE_SYS_TYPES_H
  1566. #include <sys/types.h>
  1567. #endif
  1568. #ifdef HAVE_SYS_SOCKET_H
  1569. #include <sys/socket.h>
  1570. #endif
  1571. #endif
  1572. ]],[[
  1573. recvfrom(0, 0, 0, 0, 0, 0);
  1574. ]])
  1575. ],[
  1576. AC_MSG_RESULT([yes])
  1577. curl_cv_recvfrom="yes"
  1578. ],[
  1579. AC_MSG_RESULT([no])
  1580. curl_cv_recvfrom="no"
  1581. ])
  1582. #
  1583. if test "$curl_cv_recvfrom" = "yes"; then
  1584. AC_CACHE_CHECK([types of args and return type for recvfrom],
  1585. [curl_cv_func_recvfrom_args], [
  1586. curl_cv_func_recvfrom_args="unknown"
  1587. for recvfrom_retv in 'int' 'ssize_t'; do
  1588. for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1589. for recvfrom_arg2 in 'char *' 'void *'; do
  1590. for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1591. for recvfrom_arg4 in 'int' 'unsigned int'; do
  1592. for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
  1593. for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
  1594. if test "$curl_cv_func_recvfrom_args" = "unknown"; then
  1595. AC_COMPILE_IFELSE([
  1596. AC_LANG_PROGRAM([[
  1597. #undef inline
  1598. #ifdef HAVE_WINDOWS_H
  1599. #ifndef WIN32_LEAN_AND_MEAN
  1600. #define WIN32_LEAN_AND_MEAN
  1601. #endif
  1602. #include <windows.h>
  1603. #ifdef HAVE_WINSOCK2_H
  1604. #include <winsock2.h>
  1605. #else
  1606. #ifdef HAVE_WINSOCK_H
  1607. #include <winsock.h>
  1608. #endif
  1609. #endif
  1610. #define RECVFROMCALLCONV PASCAL
  1611. #else
  1612. #ifdef HAVE_SYS_TYPES_H
  1613. #include <sys/types.h>
  1614. #endif
  1615. #ifdef HAVE_SYS_SOCKET_H
  1616. #include <sys/socket.h>
  1617. #endif
  1618. #define RECVFROMCALLCONV
  1619. #endif
  1620. extern $recvfrom_retv RECVFROMCALLCONV
  1621. recvfrom($recvfrom_arg1, $recvfrom_arg2,
  1622. $recvfrom_arg3, $recvfrom_arg4,
  1623. $recvfrom_arg5, $recvfrom_arg6);
  1624. ]],[[
  1625. $recvfrom_arg1 s=0;
  1626. $recvfrom_arg2 buf=0;
  1627. $recvfrom_arg3 len=0;
  1628. $recvfrom_arg4 flags=0;
  1629. $recvfrom_arg5 addr=0;
  1630. $recvfrom_arg6 addrlen=0;
  1631. $recvfrom_retv res=0;
  1632. res = recvfrom(s, buf, len, flags, addr, addrlen);
  1633. ]])
  1634. ],[
  1635. curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
  1636. ])
  1637. fi
  1638. done
  1639. done
  1640. done
  1641. done
  1642. done
  1643. done
  1644. done
  1645. ]) # AC-CACHE-CHECK
  1646. # Nearly last minute change for this release starts here
  1647. AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
  1648. [Define to 1 if you have the recvfrom function.])
  1649. ac_cv_func_recvfrom="yes"
  1650. # Nearly last minute change for this release ends here
  1651. if test "$curl_cv_func_recvfrom_args" = "unknown"; then
  1652. AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
  1653. else
  1654. recvfrom_prev_IFS=$IFS; IFS=','
  1655. set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
  1656. IFS=$recvfrom_prev_IFS
  1657. shift
  1658. #
  1659. recvfrom_ptrt_arg2=$[2]
  1660. recvfrom_ptrt_arg5=$[5]
  1661. recvfrom_ptrt_arg6=$[6]
  1662. #
  1663. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
  1664. [Define to the type of arg 1 for recvfrom.])
  1665. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
  1666. [Define to the type of arg 3 for recvfrom.])
  1667. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
  1668. [Define to the type of arg 4 for recvfrom.])
  1669. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
  1670. [Define to the function return type for recvfrom.])
  1671. #
  1672. prev_sh_opts=$-
  1673. #
  1674. case $prev_sh_opts in
  1675. *f*)
  1676. ;;
  1677. *)
  1678. set -f
  1679. ;;
  1680. esac
  1681. #
  1682. recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
  1683. recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
  1684. recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
  1685. #
  1686. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
  1687. [Define to the type pointed by arg 2 for recvfrom.])
  1688. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
  1689. [Define to the type pointed by arg 5 for recvfrom.])
  1690. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
  1691. [Define to the type pointed by arg 6 for recvfrom.])
  1692. #
  1693. if test "$recvfrom_type_arg2" = "void"; then
  1694. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
  1695. [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
  1696. fi
  1697. if test "$recvfrom_type_arg5" = "void"; then
  1698. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
  1699. [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
  1700. fi
  1701. if test "$recvfrom_type_arg6" = "void"; then
  1702. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
  1703. [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
  1704. fi
  1705. #
  1706. case $prev_sh_opts in
  1707. *f*)
  1708. ;;
  1709. *)
  1710. set +f
  1711. ;;
  1712. esac
  1713. #
  1714. AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
  1715. [Define to 1 if you have the recvfrom function.])
  1716. ac_cv_func_recvfrom="yes"
  1717. fi
  1718. else
  1719. AC_MSG_WARN([Unable to link function recvfrom])
  1720. fi
  1721. ])
  1722. dnl CURL_CHECK_MSG_NOSIGNAL
  1723. dnl -------------------------------------------------
  1724. dnl Check for MSG_NOSIGNAL
  1725. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  1726. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1727. AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
  1728. AC_COMPILE_IFELSE([
  1729. AC_LANG_PROGRAM([[
  1730. #undef inline
  1731. #ifdef HAVE_WINDOWS_H
  1732. #ifndef WIN32_LEAN_AND_MEAN
  1733. #define WIN32_LEAN_AND_MEAN
  1734. #endif
  1735. #include <windows.h>
  1736. #ifdef HAVE_WINSOCK2_H
  1737. #include <winsock2.h>
  1738. #else
  1739. #ifdef HAVE_WINSOCK_H
  1740. #include <winsock.h>
  1741. #endif
  1742. #endif
  1743. #else
  1744. #ifdef HAVE_SYS_TYPES_H
  1745. #include <sys/types.h>
  1746. #endif
  1747. #ifdef HAVE_SYS_SOCKET_H
  1748. #include <sys/socket.h>
  1749. #endif
  1750. #endif
  1751. ]],[[
  1752. int flag=MSG_NOSIGNAL;
  1753. ]])
  1754. ],[
  1755. ac_cv_msg_nosignal="yes"
  1756. ],[
  1757. ac_cv_msg_nosignal="no"
  1758. ])
  1759. ])
  1760. case "$ac_cv_msg_nosignal" in
  1761. yes)
  1762. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  1763. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  1764. ;;
  1765. esac
  1766. ])
  1767. dnl CURL_CHECK_STRUCT_TIMEVAL
  1768. dnl -------------------------------------------------
  1769. dnl Check for timeval struct
  1770. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  1771. AC_REQUIRE([AC_HEADER_TIME])dnl
  1772. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1773. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1774. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
  1775. AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
  1776. AC_COMPILE_IFELSE([
  1777. AC_LANG_PROGRAM([[
  1778. #undef inline
  1779. #ifdef HAVE_WINDOWS_H
  1780. #ifndef WIN32_LEAN_AND_MEAN
  1781. #define WIN32_LEAN_AND_MEAN
  1782. #endif
  1783. #include <windows.h>
  1784. #ifdef HAVE_WINSOCK2_H
  1785. #include <winsock2.h>
  1786. #else
  1787. #ifdef HAVE_WINSOCK_H
  1788. #include <winsock.h>
  1789. #endif
  1790. #endif
  1791. #endif
  1792. #ifdef HAVE_SYS_TYPES_H
  1793. #include <sys/types.h>
  1794. #endif
  1795. #ifdef HAVE_SYS_TIME_H
  1796. #include <sys/time.h>
  1797. #ifdef TIME_WITH_SYS_TIME
  1798. #include <time.h>
  1799. #endif
  1800. #else
  1801. #ifdef HAVE_TIME_H
  1802. #include <time.h>
  1803. #endif
  1804. #endif
  1805. #ifdef HAVE_SYS_SOCKET_H
  1806. #include <sys/socket.h>
  1807. #endif
  1808. ]],[[
  1809. struct timeval ts;
  1810. ts.tv_sec = 0;
  1811. ts.tv_usec = 0;
  1812. ]])
  1813. ],[
  1814. ac_cv_struct_timeval="yes"
  1815. ],[
  1816. ac_cv_struct_timeval="no"
  1817. ])
  1818. ])
  1819. case "$ac_cv_struct_timeval" in
  1820. yes)
  1821. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  1822. [Define to 1 if you have the timeval struct.])
  1823. ;;
  1824. esac
  1825. ])
  1826. dnl TYPE_SIG_ATOMIC_T
  1827. dnl -------------------------------------------------
  1828. dnl Check if the sig_atomic_t type is available, and
  1829. dnl verify if it is already defined as volatile.
  1830. AC_DEFUN([TYPE_SIG_ATOMIC_T], [
  1831. AC_CHECK_HEADERS(signal.h)
  1832. AC_CHECK_TYPE([sig_atomic_t],[
  1833. AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
  1834. [Define to 1 if sig_atomic_t is an available typedef.])
  1835. ], ,[
  1836. #ifdef HAVE_SIGNAL_H
  1837. #include <signal.h>
  1838. #endif
  1839. ])
  1840. case "$ac_cv_type_sig_atomic_t" in
  1841. yes)
  1842. #
  1843. AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
  1844. AC_LINK_IFELSE([
  1845. AC_LANG_PROGRAM([[
  1846. #ifdef HAVE_SIGNAL_H
  1847. #include <signal.h>
  1848. #endif
  1849. ]],[[
  1850. static volatile sig_atomic_t dummy = 0;
  1851. ]])
  1852. ],[
  1853. AC_MSG_RESULT([no])
  1854. ac_cv_sig_atomic_t_volatile="no"
  1855. ],[
  1856. AC_MSG_RESULT([yes])
  1857. ac_cv_sig_atomic_t_volatile="yes"
  1858. ])
  1859. #
  1860. if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
  1861. AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
  1862. [Define to 1 if sig_atomic_t is already defined as volatile.])
  1863. fi
  1864. ;;
  1865. esac
  1866. ])
  1867. dnl TYPE_IN_ADDR_T
  1868. dnl -------------------------------------------------
  1869. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  1870. dnl and a few other things.
  1871. AC_DEFUN([TYPE_IN_ADDR_T], [
  1872. AC_CHECK_TYPE([in_addr_t], ,[
  1873. dnl in_addr_t not available
  1874. AC_CACHE_CHECK([for in_addr_t equivalent],
  1875. [curl_cv_in_addr_t_equiv], [
  1876. curl_cv_in_addr_t_equiv="unknown"
  1877. for t in "unsigned long" int size_t unsigned long; do
  1878. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  1879. AC_LINK_IFELSE([
  1880. AC_LANG_PROGRAM([[
  1881. #undef inline
  1882. #ifdef HAVE_WINDOWS_H
  1883. #ifndef WIN32_LEAN_AND_MEAN
  1884. #define WIN32_LEAN_AND_MEAN
  1885. #endif
  1886. #include <windows.h>
  1887. #ifdef HAVE_WINSOCK2_H
  1888. #include <winsock2.h>
  1889. #else
  1890. #ifdef HAVE_WINSOCK_H
  1891. #include <winsock.h>
  1892. #endif
  1893. #endif
  1894. #else
  1895. #ifdef HAVE_SYS_TYPES_H
  1896. #include <sys/types.h>
  1897. #endif
  1898. #ifdef HAVE_SYS_SOCKET_H
  1899. #include <sys/socket.h>
  1900. #endif
  1901. #ifdef HAVE_NETINET_IN_H
  1902. #include <netinet/in.h>
  1903. #endif
  1904. #ifdef HAVE_ARPA_INET_H
  1905. #include <arpa/inet.h>
  1906. #endif
  1907. #endif
  1908. ]],[[
  1909. $t data = inet_addr ("1.2.3.4");
  1910. ]])
  1911. ],[
  1912. curl_cv_in_addr_t_equiv="$t"
  1913. ])
  1914. fi
  1915. done
  1916. ])
  1917. case "$curl_cv_in_addr_t_equiv" in
  1918. unknown)
  1919. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  1920. ;;
  1921. *)
  1922. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  1923. [Type to use in place of in_addr_t when system does not provide it.])
  1924. ;;
  1925. esac
  1926. ],[
  1927. #undef inline
  1928. #ifdef HAVE_WINDOWS_H
  1929. #ifndef WIN32_LEAN_AND_MEAN
  1930. #define WIN32_LEAN_AND_MEAN
  1931. #endif
  1932. #include <windows.h>
  1933. #ifdef HAVE_WINSOCK2_H
  1934. #include <winsock2.h>
  1935. #else
  1936. #ifdef HAVE_WINSOCK_H
  1937. #include <winsock.h>
  1938. #endif
  1939. #endif
  1940. #else
  1941. #ifdef HAVE_SYS_TYPES_H
  1942. #include <sys/types.h>
  1943. #endif
  1944. #ifdef HAVE_SYS_SOCKET_H
  1945. #include <sys/socket.h>
  1946. #endif
  1947. #ifdef HAVE_NETINET_IN_H
  1948. #include <netinet/in.h>
  1949. #endif
  1950. #ifdef HAVE_ARPA_INET_H
  1951. #include <arpa/inet.h>
  1952. #endif
  1953. #endif
  1954. ])
  1955. ])
  1956. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  1957. dnl -------------------------------------------------
  1958. dnl Check if monotonic clock_gettime is available.
  1959. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  1960. AC_REQUIRE([AC_HEADER_TIME])dnl
  1961. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
  1962. AC_MSG_CHECKING([for monotonic clock_gettime])
  1963. AC_COMPILE_IFELSE([
  1964. AC_LANG_PROGRAM([[
  1965. #ifdef HAVE_SYS_TYPES_H
  1966. #include <sys/types.h>
  1967. #endif
  1968. #ifdef HAVE_SYS_TIME_H
  1969. #include <sys/time.h>
  1970. #ifdef TIME_WITH_SYS_TIME
  1971. #include <time.h>
  1972. #endif
  1973. #else
  1974. #ifdef HAVE_TIME_H
  1975. #include <time.h>
  1976. #endif
  1977. #endif
  1978. ]],[[
  1979. struct timespec ts;
  1980. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1981. ]])
  1982. ],[
  1983. AC_MSG_RESULT([yes])
  1984. ac_cv_func_clock_gettime="yes"
  1985. ],[
  1986. AC_MSG_RESULT([no])
  1987. ac_cv_func_clock_gettime="no"
  1988. ])
  1989. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  1990. dnl until library linking and run-time checks for clock_gettime succeed.
  1991. ])
  1992. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  1993. dnl -------------------------------------------------
  1994. dnl If monotonic clock_gettime is available then,
  1995. dnl check and prepended to LIBS any needed libraries.
  1996. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  1997. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  1998. #
  1999. if test "$ac_cv_func_clock_gettime" = "yes"; then
  2000. #
  2001. AC_MSG_CHECKING([for clock_gettime in libraries])
  2002. #
  2003. curl_cv_save_LIBS="$LIBS"
  2004. curl_cv_gclk_LIBS="unknown"
  2005. #
  2006. for x_xlibs in '' '-lrt' '-lposix4' ; do
  2007. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  2008. if test -z "$x_xlibs"; then
  2009. LIBS="$curl_cv_save_LIBS"
  2010. else
  2011. LIBS="$x_xlibs $curl_cv_save_LIBS"
  2012. fi
  2013. AC_LINK_IFELSE([
  2014. AC_LANG_PROGRAM([[
  2015. #ifdef HAVE_SYS_TYPES_H
  2016. #include <sys/types.h>
  2017. #endif
  2018. #ifdef HAVE_SYS_TIME_H
  2019. #include <sys/time.h>
  2020. #ifdef TIME_WITH_SYS_TIME
  2021. #include <time.h>
  2022. #endif
  2023. #else
  2024. #ifdef HAVE_TIME_H
  2025. #include <time.h>
  2026. #endif
  2027. #endif
  2028. ]],[[
  2029. struct timespec ts;
  2030. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  2031. ]])
  2032. ],[
  2033. curl_cv_gclk_LIBS="$x_xlibs"
  2034. ])
  2035. fi
  2036. done
  2037. #
  2038. LIBS="$curl_cv_save_LIBS"
  2039. #
  2040. case X-"$curl_cv_gclk_LIBS" in
  2041. X-unknown)
  2042. AC_MSG_RESULT([cannot find clock_gettime])
  2043. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  2044. ac_cv_func_clock_gettime="no"
  2045. ;;
  2046. X-)
  2047. AC_MSG_RESULT([no additional lib required])
  2048. ac_cv_func_clock_gettime="yes"
  2049. ;;
  2050. *)
  2051. if test -z "$curl_cv_save_LIBS"; then
  2052. LIBS="$curl_cv_gclk_LIBS"
  2053. else
  2054. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  2055. fi
  2056. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  2057. ac_cv_func_clock_gettime="yes"
  2058. ;;
  2059. esac
  2060. #
  2061. dnl only do runtime verification when not cross-compiling
  2062. if test "x$cross_compiling" != "xyes" &&
  2063. test "$ac_cv_func_clock_gettime" = "yes"; then
  2064. AC_MSG_CHECKING([if monotonic clock_gettime works])
  2065. AC_RUN_IFELSE([
  2066. AC_LANG_PROGRAM([[
  2067. #ifdef HAVE_STDLIB_H
  2068. #include <stdlib.h>
  2069. #endif
  2070. #ifdef HAVE_SYS_TYPES_H
  2071. #include <sys/types.h>
  2072. #endif
  2073. #ifdef HAVE_SYS_TIME_H
  2074. #include <sys/time.h>
  2075. #ifdef TIME_WITH_SYS_TIME
  2076. #include <time.h>
  2077. #endif
  2078. #else
  2079. #ifdef HAVE_TIME_H
  2080. #include <time.h>
  2081. #endif
  2082. #endif
  2083. ]],[[
  2084. struct timespec ts;
  2085. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  2086. exit(0);
  2087. else
  2088. exit(1);
  2089. ]])
  2090. ],[
  2091. AC_MSG_RESULT([yes])
  2092. ],[
  2093. AC_MSG_RESULT([no])
  2094. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  2095. ac_cv_func_clock_gettime="no"
  2096. LIBS="$curl_cv_save_LIBS"
  2097. ])
  2098. fi
  2099. #
  2100. case "$ac_cv_func_clock_gettime" in
  2101. yes)
  2102. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  2103. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  2104. ;;
  2105. esac
  2106. #
  2107. fi
  2108. #
  2109. ])
  2110. dnl CURL_CHECK_LIBS_CONNECT
  2111. dnl -------------------------------------------------
  2112. dnl Verify if network connect function is already available
  2113. dnl using current libraries or if another one is required.
  2114. AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
  2115. AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
  2116. AC_MSG_CHECKING([for connect in libraries])
  2117. tst_connect_save_LIBS="$LIBS"
  2118. tst_connect_need_LIBS="unknown"
  2119. for tst_lib in '' '-lsocket' ; do
  2120. if test "$tst_connect_need_LIBS" = "unknown"; then
  2121. LIBS="$tst_lib $tst_connect_save_LIBS"
  2122. AC_LINK_IFELSE([
  2123. AC_LANG_PROGRAM([[
  2124. $curl_includes_winsock2
  2125. #ifndef HAVE_WINDOWS_H
  2126. int connect(int, void*, int);
  2127. #endif
  2128. ]],[[
  2129. if(0 != connect(0, 0, 0))
  2130. return 1;
  2131. ]])
  2132. ],[
  2133. tst_connect_need_LIBS="$tst_lib"
  2134. ])
  2135. fi
  2136. done
  2137. LIBS="$tst_connect_save_LIBS"
  2138. #
  2139. case X-"$tst_connect_need_LIBS" in
  2140. X-unknown)
  2141. AC_MSG_RESULT([cannot find connect])
  2142. AC_MSG_ERROR([cannot find connect function in libraries.])
  2143. ;;
  2144. X-)
  2145. AC_MSG_RESULT([yes])
  2146. ;;
  2147. *)
  2148. AC_MSG_RESULT([$tst_connect_need_LIBS])
  2149. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  2150. ;;
  2151. esac
  2152. ])
  2153. dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
  2154. dnl -------------------------------------------------
  2155. dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
  2156. dnl symbol that can be further used in custom template configuration
  2157. dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
  2158. dnl argument for the description. Symbol definitions done with this
  2159. dnl macro are intended to be exclusively used in handcrafted *.h.in
  2160. dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
  2161. dnl prevents autoheader generation and insertion of symbol template
  2162. dnl stub and definition into the first configuration header file. Do
  2163. dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
  2164. dnl one serves different functional needs.
  2165. AC_DEFUN([CURL_DEFINE_UNQUOTED], [
  2166. cat >>confdefs.h <<_EOF
  2167. [@%:@define] $1 ifelse($#, 2, [$2], 1)
  2168. _EOF
  2169. ])
  2170. dnl CURL_CONFIGURE_LONG
  2171. dnl -------------------------------------------------
  2172. dnl Find out the size of long as reported by sizeof() and define
  2173. dnl CURL_SIZEOF_LONG as appropriate to be used in template file
  2174. dnl include/curl/curlbuild.h.in to properly configure the library.
  2175. dnl The size of long is a build time characteristic and as such
  2176. dnl must be recorded in curlbuild.h
  2177. AC_DEFUN([CURL_CONFIGURE_LONG], [
  2178. if test -z "$ac_cv_sizeof_long" ||
  2179. test "$ac_cv_sizeof_long" -eq "0"; then
  2180. AC_MSG_ERROR([cannot find out size of long.])
  2181. fi
  2182. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
  2183. ])
  2184. dnl CURL_CONFIGURE_CURL_SOCKLEN_T
  2185. dnl -------------------------------------------------
  2186. dnl Find out suitable curl_socklen_t data type definition and size, making
  2187. dnl appropriate definitions for template file include/curl/curlbuild.h.in
  2188. dnl to properly configure and use the library.
  2189. dnl
  2190. dnl The need for the curl_socklen_t definition arises mainly to properly
  2191. dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
  2192. dnl data type which is 32 or 64-Bit wide depending on the data model being
  2193. dnl used, and that on the other hand is only actually used when interfacing
  2194. dnl the X/Open sockets provided in the xnet library.
  2195. AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
  2196. AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
  2197. AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
  2198. AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
  2199. #
  2200. AC_MSG_CHECKING([for curl_socklen_t data type])
  2201. curl_typeof_curl_socklen_t="unknown"
  2202. for arg1 in int SOCKET; do
  2203. for arg2 in 'struct sockaddr' void; do
  2204. for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
  2205. if test "$curl_typeof_curl_socklen_t" = "unknown"; then
  2206. AC_COMPILE_IFELSE([
  2207. AC_LANG_PROGRAM([[
  2208. $curl_includes_ws2tcpip
  2209. $curl_includes_sys_socket
  2210. $curl_preprocess_callconv
  2211. extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
  2212. ]],[[
  2213. $t *lenptr = 0;
  2214. if(0 != getpeername(0, 0, lenptr))
  2215. return 1;
  2216. ]])
  2217. ],[
  2218. curl_typeof_curl_socklen_t="$t"
  2219. ])
  2220. fi
  2221. done
  2222. done
  2223. done
  2224. for t in socklen_t int; do
  2225. if test "$curl_typeof_curl_socklen_t" = "void"; then
  2226. AC_COMPILE_IFELSE([
  2227. AC_LANG_PROGRAM([[
  2228. $curl_includes_sys_socket
  2229. typedef $t curl_socklen_t;
  2230. ]],[[
  2231. curl_socklen_t dummy;
  2232. ]])
  2233. ],[
  2234. curl_typeof_curl_socklen_t="$t"
  2235. ])
  2236. fi
  2237. done
  2238. AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
  2239. if test "$curl_typeof_curl_socklen_t" = "void" ||
  2240. test "$curl_typeof_curl_socklen_t" = "unknown"; then
  2241. AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
  2242. fi
  2243. #
  2244. AC_MSG_CHECKING([size of curl_socklen_t])
  2245. curl_sizeof_curl_socklen_t="unknown"
  2246. curl_pull_headers_socklen_t="unknown"
  2247. if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
  2248. tst_pull_header_checks='none ws2tcpip'
  2249. tst_size_checks='4'
  2250. else
  2251. tst_pull_header_checks='none systypes syssocket'
  2252. tst_size_checks='4 8 2'
  2253. fi
  2254. for tst_size in $tst_size_checks; do
  2255. for tst_pull_headers in $tst_pull_header_checks; do
  2256. if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
  2257. case $tst_pull_headers in
  2258. ws2tcpip)
  2259. tmp_includes="$curl_includes_ws2tcpip"
  2260. ;;
  2261. systypes)
  2262. tmp_includes="$curl_includes_sys_types"
  2263. ;;
  2264. syssocket)
  2265. tmp_includes="$curl_includes_sys_socket"
  2266. ;;
  2267. *)
  2268. tmp_includes=""
  2269. ;;
  2270. esac
  2271. AC_COMPILE_IFELSE([
  2272. AC_LANG_PROGRAM([[
  2273. $tmp_includes
  2274. typedef $curl_typeof_curl_socklen_t curl_socklen_t;
  2275. typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
  2276. ]],[[
  2277. curl_socklen_t dummy;
  2278. ]])
  2279. ],[
  2280. curl_sizeof_curl_socklen_t="$tst_size"
  2281. curl_pull_headers_socklen_t="$tst_pull_headers"
  2282. ])
  2283. fi
  2284. done
  2285. done
  2286. AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
  2287. if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
  2288. AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
  2289. fi
  2290. #
  2291. case $curl_pull_headers_socklen_t in
  2292. ws2tcpip)
  2293. CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
  2294. ;;
  2295. systypes)
  2296. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
  2297. ;;
  2298. syssocket)
  2299. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
  2300. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
  2301. ;;
  2302. esac
  2303. CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
  2304. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
  2305. ])
  2306. dnl CURL_CHECK_FUNC_SELECT
  2307. dnl -------------------------------------------------
  2308. dnl Test if the socket select() function is available,
  2309. dnl and check its return type and the types of its
  2310. dnl arguments. If the function succeeds HAVE_SELECT
  2311. dnl will be defined, defining the types of the
  2312. dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
  2313. dnl and SELECT_TYPE_ARG5, defining the type of the
  2314. dnl function return value in SELECT_TYPE_RETV, and
  2315. dnl also defining the type qualifier of fifth argument
  2316. dnl in SELECT_QUAL_ARG5.
  2317. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  2318. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  2319. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  2320. #
  2321. AC_MSG_CHECKING([for select])
  2322. AC_LINK_IFELSE([
  2323. AC_LANG_PROGRAM([[
  2324. #undef inline
  2325. #ifdef HAVE_WINDOWS_H
  2326. #ifndef WIN32_LEAN_AND_MEAN
  2327. #define WIN32_LEAN_AND_MEAN
  2328. #endif
  2329. #include <windows.h>
  2330. #ifdef HAVE_WINSOCK2_H
  2331. #include <winsock2.h>
  2332. #else
  2333. #ifdef HAVE_WINSOCK_H
  2334. #include <winsock.h>
  2335. #endif
  2336. #endif
  2337. #endif
  2338. #ifdef HAVE_SYS_TYPES_H
  2339. #include <sys/types.h>
  2340. #endif
  2341. #ifdef HAVE_SYS_TIME_H
  2342. #include <sys/time.h>
  2343. #ifdef TIME_WITH_SYS_TIME
  2344. #include <time.h>
  2345. #endif
  2346. #else
  2347. #ifdef HAVE_TIME_H
  2348. #include <time.h>
  2349. #endif
  2350. #endif
  2351. #ifndef HAVE_WINDOWS_H
  2352. #ifdef HAVE_SYS_SELECT_H
  2353. #include <sys/select.h>
  2354. #endif
  2355. #ifdef HAVE_SYS_SOCKET_H
  2356. #include <sys/socket.h>
  2357. #endif
  2358. #endif
  2359. ]],[[
  2360. select(0, 0, 0, 0, 0);
  2361. ]])
  2362. ],[
  2363. AC_MSG_RESULT([yes])
  2364. curl_cv_select="yes"
  2365. ],[
  2366. AC_MSG_RESULT([no])
  2367. curl_cv_select="no"
  2368. ])
  2369. #
  2370. if test "$curl_cv_select" = "yes"; then
  2371. AC_CACHE_CHECK([types of args and return type for select],
  2372. [curl_cv_func_select_args], [
  2373. curl_cv_func_select_args="unknown"
  2374. for sel_retv in 'int' 'ssize_t'; do
  2375. for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
  2376. for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
  2377. for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
  2378. if test "$curl_cv_func_select_args" = "unknown"; then
  2379. AC_COMPILE_IFELSE([
  2380. AC_LANG_PROGRAM([[
  2381. #undef inline
  2382. #ifdef HAVE_WINDOWS_H
  2383. #ifndef WIN32_LEAN_AND_MEAN
  2384. #define WIN32_LEAN_AND_MEAN
  2385. #endif
  2386. #include <windows.h>
  2387. #ifdef HAVE_WINSOCK2_H
  2388. #include <winsock2.h>
  2389. #else
  2390. #ifdef HAVE_WINSOCK_H
  2391. #include <winsock.h>
  2392. #endif
  2393. #endif
  2394. #define SELECTCALLCONV PASCAL
  2395. #endif
  2396. #ifdef HAVE_SYS_TYPES_H
  2397. #include <sys/types.h>
  2398. #endif
  2399. #ifdef HAVE_SYS_TIME_H
  2400. #include <sys/time.h>
  2401. #ifdef TIME_WITH_SYS_TIME
  2402. #include <time.h>
  2403. #endif
  2404. #else
  2405. #ifdef HAVE_TIME_H
  2406. #include <time.h>
  2407. #endif
  2408. #endif
  2409. #ifndef HAVE_WINDOWS_H
  2410. #ifdef HAVE_SYS_SELECT_H
  2411. #include <sys/select.h>
  2412. #endif
  2413. #ifdef HAVE_SYS_SOCKET_H
  2414. #include <sys/socket.h>
  2415. #endif
  2416. #define SELECTCALLCONV
  2417. #endif
  2418. #ifndef HAVE_STRUCT_TIMEVAL
  2419. struct timeval {
  2420. long tv_sec;
  2421. long tv_usec;
  2422. };
  2423. #endif
  2424. extern $sel_retv SELECTCALLCONV select($sel_arg1,
  2425. $sel_arg234,
  2426. $sel_arg234,
  2427. $sel_arg234,
  2428. $sel_arg5);
  2429. ]],[[
  2430. $sel_arg1 nfds=0;
  2431. $sel_arg234 rfds=0;
  2432. $sel_arg234 wfds=0;
  2433. $sel_arg234 efds=0;
  2434. $sel_retv res = select(nfds, rfds, wfds, efds, 0);
  2435. ]])
  2436. ],[
  2437. curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
  2438. ])
  2439. fi
  2440. done
  2441. done
  2442. done
  2443. done
  2444. ]) # AC-CACHE-CHECK
  2445. if test "$curl_cv_func_select_args" = "unknown"; then
  2446. AC_MSG_WARN([Cannot find proper types to use for select args])
  2447. AC_MSG_WARN([HAVE_SELECT will not be defined])
  2448. else
  2449. select_prev_IFS=$IFS; IFS=','
  2450. set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
  2451. IFS=$select_prev_IFS
  2452. shift
  2453. #
  2454. sel_qual_type_arg5=$[3]
  2455. #
  2456. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
  2457. [Define to the type of arg 1 for select.])
  2458. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
  2459. [Define to the type of args 2, 3 and 4 for select.])
  2460. AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
  2461. [Define to the function return type for select.])
  2462. #
  2463. prev_sh_opts=$-
  2464. #
  2465. case $prev_sh_opts in
  2466. *f*)
  2467. ;;
  2468. *)
  2469. set -f
  2470. ;;
  2471. esac
  2472. #
  2473. case "$sel_qual_type_arg5" in
  2474. const*)
  2475. sel_qual_arg5=const
  2476. sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
  2477. ;;
  2478. *)
  2479. sel_qual_arg5=
  2480. sel_type_arg5=$sel_qual_type_arg5
  2481. ;;
  2482. esac
  2483. #
  2484. AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
  2485. [Define to the type qualifier of arg 5 for select.])
  2486. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
  2487. [Define to the type of arg 5 for select.])
  2488. #
  2489. case $prev_sh_opts in
  2490. *f*)
  2491. ;;
  2492. *)
  2493. set +f
  2494. ;;
  2495. esac
  2496. #
  2497. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  2498. [Define to 1 if you have the select function.])
  2499. ac_cv_func_select="yes"
  2500. fi
  2501. fi
  2502. ])
  2503. # This is only a temporary fix. This macro is here to replace the broken one
  2504. # delivered by the automake project (including the 1.9.6 release). As soon as
  2505. # they ship a working version we SHOULD remove this work-around.
  2506. AC_DEFUN([AM_MISSING_HAS_RUN],
  2507. [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
  2508. test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
  2509. # Use eval to expand $SHELL
  2510. if eval "$MISSING --run true"; then
  2511. am_missing_run="$MISSING --run "
  2512. else
  2513. am_missing_run=
  2514. AC_MSG_WARN([`missing' script is too old or missing])
  2515. fi
  2516. ])
  2517. dnl CURL_VERIFY_RUNTIMELIBS
  2518. dnl -------------------------------------------------
  2519. dnl Verify that the shared libs found so far can be used when running
  2520. dnl programs, since otherwise the situation will create odd configure errors
  2521. dnl that are misleading people.
  2522. dnl
  2523. dnl Make sure this test is run BEFORE the first test in the script that
  2524. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  2525. dnl macro. It must also run AFTER all lib-checking macros are complete.
  2526. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  2527. dnl this test is of course not sensible if we are cross-compiling!
  2528. if test "x$cross_compiling" != xyes; then
  2529. dnl just run a program to verify that the libs checked for previous to this
  2530. dnl point also is available run-time!
  2531. AC_MSG_CHECKING([run-time libs availability])
  2532. AC_TRY_RUN([
  2533. main()
  2534. {
  2535. return 0;
  2536. }
  2537. ],
  2538. AC_MSG_RESULT([fine]),
  2539. AC_MSG_RESULT([failed])
  2540. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  2541. )
  2542. dnl if this test fails, configure has already stopped
  2543. fi
  2544. ])
  2545. dnl CURL_CHECK_VARIADIC_MACROS
  2546. dnl -------------------------------------------------
  2547. dnl Check compiler support of variadic macros
  2548. AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
  2549. AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
  2550. [curl_cv_variadic_macros_c99], [
  2551. AC_COMPILE_IFELSE([
  2552. AC_LANG_PROGRAM([[
  2553. #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
  2554. #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
  2555. int fun3(int arg1, int arg2, int arg3);
  2556. int fun2(int arg1, int arg2);
  2557. int fun3(int arg1, int arg2, int arg3)
  2558. { return arg1 + arg2 + arg3; }
  2559. int fun2(int arg1, int arg2)
  2560. { return arg1 + arg2; }
  2561. ]],[[
  2562. int res3 = c99_vmacro3(1, 2, 3);
  2563. int res2 = c99_vmacro2(1, 2);
  2564. ]])
  2565. ],[
  2566. curl_cv_variadic_macros_c99="yes"
  2567. ],[
  2568. curl_cv_variadic_macros_c99="no"
  2569. ])
  2570. ])
  2571. case "$curl_cv_variadic_macros_c99" in
  2572. yes)
  2573. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
  2574. [Define to 1 if compiler supports C99 variadic macro style.])
  2575. ;;
  2576. esac
  2577. AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
  2578. [curl_cv_variadic_macros_gcc], [
  2579. AC_COMPILE_IFELSE([
  2580. AC_LANG_PROGRAM([[
  2581. #define gcc_vmacro3(first, args...) fun3(first, args)
  2582. #define gcc_vmacro2(first, args...) fun2(first, args)
  2583. int fun3(int arg1, int arg2, int arg3);
  2584. int fun2(int arg1, int arg2);
  2585. int fun3(int arg1, int arg2, int arg3)
  2586. { return arg1 + arg2 + arg3; }
  2587. int fun2(int arg1, int arg2)
  2588. { return arg1 + arg2; }
  2589. ]],[[
  2590. int res3 = gcc_vmacro3(1, 2, 3);
  2591. int res2 = gcc_vmacro2(1, 2);
  2592. ]])
  2593. ],[
  2594. curl_cv_variadic_macros_gcc="yes"
  2595. ],[
  2596. curl_cv_variadic_macros_gcc="no"
  2597. ])
  2598. ])
  2599. case "$curl_cv_variadic_macros_gcc" in
  2600. yes)
  2601. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
  2602. [Define to 1 if compiler supports old gcc variadic macro style.])
  2603. ;;
  2604. esac
  2605. ])
  2606. dnl CURL_CHECK_CA_BUNDLE
  2607. dnl -------------------------------------------------
  2608. dnl Check if a default ca-bundle should be used
  2609. dnl
  2610. dnl regarding the paths this will scan:
  2611. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  2612. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  2613. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  2614. dnl /usr/local/share/certs/ca-root.crt FreeBSD
  2615. dnl /etc/ssl/cert.pem OpenBSD
  2616. dnl /etc/ssl/certs/ (ca path) SUSE
  2617. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  2618. AC_MSG_CHECKING([default CA cert bundle/path])
  2619. AC_ARG_WITH(ca-bundle,
  2620. AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
  2621. AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  2622. [
  2623. want_ca="$withval"
  2624. if test "x$want_ca" = "xyes"; then
  2625. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  2626. fi
  2627. ],
  2628. [ want_ca="unset" ])
  2629. AC_ARG_WITH(ca-path,
  2630. AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
  2631. AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  2632. [
  2633. want_capath="$withval"
  2634. if test "x$want_capath" = "xyes"; then
  2635. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  2636. fi
  2637. ],
  2638. [ want_capath="unset"])
  2639. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  2640. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2641. dnl both given
  2642. AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
  2643. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  2644. dnl --with-ca-bundle given
  2645. ca="$want_ca"
  2646. capath="no"
  2647. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2648. dnl --with-ca-path given
  2649. if test "x$OPENSSL_ENABLED" != "x1"; then
  2650. AC_MSG_ERROR([--with-ca-path only works with openSSL])
  2651. fi
  2652. capath="$want_capath"
  2653. ca="no"
  2654. else
  2655. dnl neither of --with-ca-* given
  2656. dnl first try autodetecting a CA bundle , then a CA path
  2657. dnl both autodetections can be skipped by --without-ca-*
  2658. ca="no"
  2659. capath="no"
  2660. if test "x$want_ca" = "xunset"; then
  2661. dnl the path we previously would have installed the curl ca bundle
  2662. dnl to, and thus we now check for an already existing cert in that place
  2663. dnl in case we find no other
  2664. if test "x$prefix" != xNONE; then
  2665. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  2666. else
  2667. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  2668. fi
  2669. for a in /etc/ssl/certs/ca-certificates.crt \
  2670. /etc/pki/tls/certs/ca-bundle.crt \
  2671. /usr/share/ssl/certs/ca-bundle.crt \
  2672. /usr/local/share/certs/ca-root.crt \
  2673. /etc/ssl/cert.pem \
  2674. "$cac"; do
  2675. if test -f "$a"; then
  2676. ca="$a"
  2677. break
  2678. fi
  2679. done
  2680. fi
  2681. if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
  2682. "x$OPENSSL_ENABLED" = "x1"; then
  2683. for a in /etc/ssl/certs/; do
  2684. 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
  2685. capath="$a"
  2686. break
  2687. fi
  2688. done
  2689. fi
  2690. fi
  2691. if test "x$ca" != "xno"; then
  2692. CURL_CA_BUNDLE='"'$ca'"'
  2693. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  2694. AC_SUBST(CURL_CA_BUNDLE)
  2695. AC_MSG_RESULT([$ca])
  2696. elif test "x$capath" != "xno"; then
  2697. CURL_CA_PATH="\"$capath\""
  2698. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  2699. AC_MSG_RESULT([$capath (capath)])
  2700. else
  2701. AC_MSG_RESULT([no])
  2702. fi
  2703. ])
  2704. dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
  2705. dnl -------------------------------------------------
  2706. dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
  2707. AC_DEFUN([DO_CURL_OFF_T_CHECK], [
  2708. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  2709. if test "$curl_typeof_curl_off_t" = "unknown" && test ! -z "$1"; then
  2710. tmp_includes=""
  2711. tmp_source=""
  2712. tmp_fmt=""
  2713. case AS_TR_SH([$1]) in
  2714. int64_t)
  2715. tmp_includes="$curl_includes_inttypes"
  2716. tmp_source="char f@<:@@:>@ = PRId64;"
  2717. tmp_fmt="PRId64"
  2718. ;;
  2719. int32_t)
  2720. tmp_includes="$curl_includes_inttypes"
  2721. tmp_source="char f@<:@@:>@ = PRId32;"
  2722. tmp_fmt="PRId32"
  2723. ;;
  2724. int16_t)
  2725. tmp_includes="$curl_includes_inttypes"
  2726. tmp_source="char f@<:@@:>@ = PRId16;"
  2727. tmp_fmt="PRId16"
  2728. ;;
  2729. esac
  2730. AC_COMPILE_IFELSE([
  2731. AC_LANG_PROGRAM([[
  2732. $tmp_includes
  2733. typedef $1 curl_off_t;
  2734. typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
  2735. ]],[[
  2736. $tmp_source
  2737. curl_off_t dummy;
  2738. ]])
  2739. ],[
  2740. if test -z "$tmp_fmt"; then
  2741. curl_typeof_curl_off_t="$1"
  2742. curl_sizeof_curl_off_t="$2"
  2743. else
  2744. CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
  2745. AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
  2746. AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
  2747. if test AS_VAR_GET(tmp_HaveFmtDef) = "yes"; then
  2748. curl_format_curl_off_t=AS_VAR_GET(tmp_FmtDef)
  2749. curl_typeof_curl_off_t="$1"
  2750. curl_sizeof_curl_off_t="$2"
  2751. fi
  2752. AS_VAR_POPDEF([tmp_FmtDef])dnl
  2753. AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
  2754. fi
  2755. ])
  2756. fi
  2757. ])
  2758. dnl DO_CURL_OFF_T_SUFFIX_CHECK (TYPE)
  2759. dnl -------------------------------------------------
  2760. dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
  2761. AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [
  2762. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  2763. AC_MSG_CHECKING([constant suffix string for curl_off_t])
  2764. #
  2765. curl_suffix_curl_off_t="unknown"
  2766. curl_suffix_curl_off_tu="unknown"
  2767. #
  2768. case AS_TR_SH([$1]) in
  2769. long_long | __longlong | __longlong_t)
  2770. tst_suffixes="LL::"
  2771. ;;
  2772. long)
  2773. tst_suffixes="L::"
  2774. ;;
  2775. int)
  2776. tst_suffixes="::"
  2777. ;;
  2778. __int64 | int64_t)
  2779. tst_suffixes="LL:i64::"
  2780. ;;
  2781. __int32 | int32_t)
  2782. tst_suffixes="L:i32::"
  2783. ;;
  2784. __int16 | int16_t)
  2785. tst_suffixes="L:i16::"
  2786. ;;
  2787. *)
  2788. AC_MSG_ERROR([unexpected data type $1])
  2789. ;;
  2790. esac
  2791. #
  2792. old_IFS=$IFS; IFS=':'
  2793. for tmp_ssuf in $tst_suffixes ; do
  2794. IFS=$old_IFS
  2795. if test "x$curl_suffix_curl_off_t" = "xunknown"; then
  2796. case $tmp_ssuf in
  2797. i64 | i32 | i16)
  2798. tmp_usuf="u$tmp_ssuf"
  2799. ;;
  2800. LL | L)
  2801. tmp_usuf="U$tmp_ssuf"
  2802. ;;
  2803. *)
  2804. tmp_usuf=""
  2805. ;;
  2806. esac
  2807. AC_COMPILE_IFELSE([
  2808. AC_LANG_PROGRAM([[
  2809. $curl_includes_inttypes
  2810. typedef $1 new_t;
  2811. ]],[[
  2812. new_t s1;
  2813. new_t s2;
  2814. s1 = -10$tmp_ssuf ;
  2815. s2 = 20$tmp_ssuf ;
  2816. if(s1 > s2)
  2817. return 1;
  2818. ]])
  2819. ],[
  2820. curl_suffix_curl_off_t="$tmp_ssuf"
  2821. curl_suffix_curl_off_tu="$tmp_usuf"
  2822. ])
  2823. fi
  2824. done
  2825. IFS=$old_IFS
  2826. #
  2827. if test "x$curl_suffix_curl_off_t" = "xunknown"; then
  2828. AC_MSG_ERROR([cannot find constant suffix string for curl_off_t.])
  2829. else
  2830. AC_MSG_RESULT([$curl_suffix_curl_off_t])
  2831. AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
  2832. AC_MSG_RESULT([$curl_suffix_curl_off_tu])
  2833. fi
  2834. #
  2835. ])
  2836. dnl CURL_CONFIGURE_CURL_OFF_T
  2837. dnl -------------------------------------------------
  2838. dnl Find out suitable curl_off_t data type definition and associated
  2839. dnl items, and make the appropriate definitions used in template file
  2840. dnl include/curl/curlbuild.h.in to properly configure the library.
  2841. AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
  2842. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  2843. #
  2844. AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
  2845. AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
  2846. AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
  2847. #
  2848. if test -z "$SED"; then
  2849. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  2850. fi
  2851. #
  2852. AC_CHECK_SIZEOF(long)
  2853. AC_CHECK_SIZEOF(void*)
  2854. #
  2855. if test -z "$ac_cv_sizeof_long" ||
  2856. test "$ac_cv_sizeof_long" -eq "0"; then
  2857. AC_MSG_ERROR([cannot find out size of long.])
  2858. fi
  2859. if test -z "$ac_cv_sizeof_voidp" ||
  2860. test "$ac_cv_sizeof_voidp" -eq "0"; then
  2861. AC_MSG_ERROR([cannot find out size of void*.])
  2862. fi
  2863. #
  2864. x_LP64_long=""
  2865. x_LP32_long=""
  2866. x_LP16_long=""
  2867. #
  2868. if test "$ac_cv_sizeof_long" -eq "8" &&
  2869. test "$ac_cv_sizeof_voidp" -ge "8"; then
  2870. x_LP64_long="long"
  2871. elif test "$ac_cv_sizeof_long" -eq "4" &&
  2872. test "$ac_cv_sizeof_voidp" -ge "4"; then
  2873. x_LP32_long="long"
  2874. elif test "$ac_cv_sizeof_long" -eq "2" &&
  2875. test "$ac_cv_sizeof_voidp" -ge "2"; then
  2876. x_LP16_long="long"
  2877. fi
  2878. #
  2879. dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
  2880. #
  2881. curl_typeof_curl_off_t="unknown"
  2882. curl_sizeof_curl_off_t="unknown"
  2883. curl_format_curl_off_t="unknown"
  2884. curl_format_curl_off_tu="unknown"
  2885. #
  2886. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2887. AC_MSG_CHECKING([for 64-bit curl_off_t data type])
  2888. for t8 in \
  2889. "$x_LP64_long" \
  2890. 'int64_t' \
  2891. '__int64' \
  2892. 'long long' \
  2893. '__longlong' \
  2894. '__longlong_t' ; do
  2895. DO_CURL_OFF_T_CHECK([$t8], [8])
  2896. done
  2897. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  2898. fi
  2899. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2900. AC_MSG_CHECKING([for 32-bit curl_off_t data type])
  2901. for t4 in \
  2902. "$x_LP32_long" \
  2903. 'int32_t' \
  2904. '__int32' \
  2905. 'int' ; do
  2906. DO_CURL_OFF_T_CHECK([$t4], [4])
  2907. done
  2908. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  2909. fi
  2910. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2911. AC_MSG_CHECKING([for 16-bit curl_off_t data type])
  2912. for t2 in \
  2913. "$x_LP16_long" \
  2914. 'int16_t' \
  2915. '__int16' \
  2916. 'int' ; do
  2917. DO_CURL_OFF_T_CHECK([$t2], [2])
  2918. done
  2919. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  2920. fi
  2921. if test "$curl_typeof_curl_off_t" = "unknown"; then
  2922. AC_MSG_ERROR([cannot find data type for curl_off_t.])
  2923. fi
  2924. #
  2925. AC_MSG_CHECKING([size of curl_off_t])
  2926. AC_MSG_RESULT([$curl_sizeof_curl_off_t])
  2927. #
  2928. AC_MSG_CHECKING([formatting string directive for curl_off_t])
  2929. if test "$curl_format_curl_off_t" != "unknown"; then
  2930. x_pull_headers="yes"
  2931. curl_format_curl_off_t=`echo "$curl_format_curl_off_t" | "$SED" 's/[["]]//g'`
  2932. curl_format_curl_off_tu=`echo "$curl_format_curl_off_t" | "$SED" 's/i$/u/'`
  2933. curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/d$/u/'`
  2934. curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'`
  2935. else
  2936. x_pull_headers="no"
  2937. case AS_TR_SH([$curl_typeof_curl_off_t]) in
  2938. long_long | __longlong | __longlong_t)
  2939. curl_format_curl_off_t="lld"
  2940. curl_format_curl_off_tu="llu"
  2941. ;;
  2942. long)
  2943. curl_format_curl_off_t="ld"
  2944. curl_format_curl_off_tu="lu"
  2945. ;;
  2946. int)
  2947. curl_format_curl_off_t="d"
  2948. curl_format_curl_off_tu="u"
  2949. ;;
  2950. __int64)
  2951. curl_format_curl_off_t="I64d"
  2952. curl_format_curl_off_tu="I64u"
  2953. ;;
  2954. __int32)
  2955. curl_format_curl_off_t="I32d"
  2956. curl_format_curl_off_tu="I32u"
  2957. ;;
  2958. __int16)
  2959. curl_format_curl_off_t="I16d"
  2960. curl_format_curl_off_tu="I16u"
  2961. ;;
  2962. *)
  2963. AC_MSG_ERROR([cannot find print format string for curl_off_t.])
  2964. ;;
  2965. esac
  2966. fi
  2967. AC_MSG_RESULT(["$curl_format_curl_off_t"])
  2968. #
  2969. AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
  2970. AC_MSG_RESULT(["$curl_format_curl_off_tu"])
  2971. #
  2972. DO_CURL_OFF_T_SUFFIX_CHECK([$curl_typeof_curl_off_t])
  2973. #
  2974. if test "$x_pull_headers" = "yes"; then
  2975. if test "x$ac_cv_header_sys_types_h" = "xyes"; then
  2976. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
  2977. fi
  2978. if test "x$ac_cv_header_stdint_h" = "xyes"; then
  2979. CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
  2980. fi
  2981. if test "x$ac_cv_header_inttypes_h" = "xyes"; then
  2982. CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
  2983. fi
  2984. fi
  2985. #
  2986. CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_OFF_T], [$curl_typeof_curl_off_t])
  2987. CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_T], ["$curl_format_curl_off_t"])
  2988. CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_TU], ["$curl_format_curl_off_tu"])
  2989. CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$curl_format_curl_off_t"])
  2990. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$curl_sizeof_curl_off_t])
  2991. CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$curl_suffix_curl_off_t])
  2992. CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$curl_suffix_curl_off_tu])
  2993. #
  2994. ])
  2995. dnl CURL_CHECK_WIN32_LARGEFILE
  2996. dnl -------------------------------------------------
  2997. dnl Check if curl's WIN32 large file will be used
  2998. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  2999. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  3000. AC_MSG_CHECKING([whether build target supports WIN32 file API])
  3001. curl_win32_file_api="no"
  3002. if test "$ac_cv_header_windows_h" = "yes"; then
  3003. if test x"$enable_largefile" != "xno"; then
  3004. AC_COMPILE_IFELSE([
  3005. AC_LANG_PROGRAM([[
  3006. ]],[[
  3007. #if !defined(_WIN32_WCE) && \
  3008. (defined(__MINGW32__) || \
  3009. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
  3010. int dummy=1;
  3011. #else
  3012. WIN32 large file API not supported.
  3013. #endif
  3014. ]])
  3015. ],[
  3016. curl_win32_file_api="win32_large_files"
  3017. ])
  3018. fi
  3019. if test "$curl_win32_file_api" = "no"; then
  3020. AC_COMPILE_IFELSE([
  3021. AC_LANG_PROGRAM([[
  3022. ]],[[
  3023. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  3024. int dummy=1;
  3025. #else
  3026. WIN32 small file API not supported.
  3027. #endif
  3028. ]])
  3029. ],[
  3030. curl_win32_file_api="win32_small_files"
  3031. ])
  3032. fi
  3033. fi
  3034. case "$curl_win32_file_api" in
  3035. win32_large_files)
  3036. AC_MSG_RESULT([yes (large file enabled)])
  3037. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  3038. [Define to 1 if you are building a Windows target with large file support.])
  3039. ;;
  3040. win32_small_files)
  3041. AC_MSG_RESULT([yes (large file disabled)])
  3042. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  3043. [Define to 1 if you are building a Windows target without large file support.])
  3044. ;;
  3045. *)
  3046. AC_MSG_RESULT([no])
  3047. ;;
  3048. esac
  3049. ])
  3050. dnl CURL_EXPORT_PCDIR ($pcdir)
  3051. dnl ------------------------
  3052. dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
  3053. dnl
  3054. dnl we need this macro since pkg-config distinguishes among empty and unset
  3055. dnl variable while checking PKG_CONFIG_LIBDIR
  3056. dnl
  3057. AC_DEFUN([CURL_EXPORT_PCDIR], [
  3058. if test -n "$1"; then
  3059. PKG_CONFIG_LIBDIR="$1"
  3060. export PKG_CONFIG_LIBDIR
  3061. fi
  3062. ])
  3063. dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
  3064. dnl ------------------------
  3065. dnl search for the pkg-config tool (if not cross-compiling). Set the PKGCONFIG
  3066. dnl variable to hold the path to it, or 'no' if not found/present.
  3067. dnl
  3068. dnl If pkg-config is present, check that it has info about the $module or
  3069. dnl return "no" anyway!
  3070. dnl
  3071. dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
  3072. dnl
  3073. AC_DEFUN([CURL_CHECK_PKGCONFIG], [
  3074. PKGCONFIG="no"
  3075. if test x$cross_compiling = xyes; then
  3076. dnl see if there's a pkg-specific for this host setup
  3077. AC_PATH_PROG( PKGCONFIG, ${host}-pkg-config, no,
  3078. $PATH:/usr/bin:/usr/local/bin)
  3079. fi
  3080. if test x$PKGCONFIG = xno; then
  3081. AC_PATH_PROG( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
  3082. fi
  3083. if test x$PKGCONFIG != xno; then
  3084. AC_MSG_CHECKING([for $1 options with pkg-config])
  3085. dnl ask pkg-config about $1
  3086. itexists=`CURL_EXPORT_PCDIR([$2]) dnl
  3087. $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
  3088. if test -z "$itexists"; then
  3089. dnl pkg-config does not have info about the given module! set the
  3090. dnl variable to 'no'
  3091. PKGCONFIG="no"
  3092. AC_MSG_RESULT([no])
  3093. else
  3094. AC_MSG_RESULT([found])
  3095. fi
  3096. fi
  3097. ])