acinclude.m4 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at https://curl.haxx.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. #***************************************************************************
  22. dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
  23. dnl -------------------------------------------------
  24. dnl Use the C preprocessor to find out if the given object-style symbol
  25. dnl is defined and get its expansion. This macro will not use default
  26. dnl includes even if no INCLUDES argument is given. This macro will run
  27. dnl silently when invoked with three arguments. If the expansion would
  28. dnl result in a set of double-quoted strings the returned expansion will
  29. dnl actually be a single double-quoted string concatenating all them.
  30. AC_DEFUN([CURL_CHECK_DEF], [
  31. AC_REQUIRE([CURL_CPP_P])dnl
  32. OLDCPPFLAGS=$CPPFLAGS
  33. # CPPPFLAG comes from CURL_CPP_P
  34. CPPFLAGS="$CPPFLAGS $CPPPFLAG"
  35. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  36. AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
  37. if test -z "$SED"; then
  38. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  39. fi
  40. if test -z "$GREP"; then
  41. AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
  42. fi
  43. ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
  44. tmp_exp=""
  45. AC_PREPROC_IFELSE([
  46. AC_LANG_SOURCE(
  47. ifelse($2,,,[$2])[[
  48. #ifdef $1
  49. CURL_DEF_TOKEN $1
  50. #endif
  51. ]])
  52. ],[
  53. tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
  54. "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
  55. "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
  56. "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
  57. if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
  58. tmp_exp=""
  59. fi
  60. ])
  61. if test -z "$tmp_exp"; then
  62. AS_VAR_SET(ac_HaveDef, no)
  63. ifelse($3,,[AC_MSG_RESULT([no])])
  64. else
  65. AS_VAR_SET(ac_HaveDef, yes)
  66. AS_VAR_SET(ac_Def, $tmp_exp)
  67. ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
  68. fi
  69. AS_VAR_POPDEF([ac_Def])dnl
  70. AS_VAR_POPDEF([ac_HaveDef])dnl
  71. CPPFLAGS=$OLDCPPFLAGS
  72. ])
  73. dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
  74. dnl -------------------------------------------------
  75. dnl Use the C compiler to find out only if the given symbol is defined
  76. dnl or not, this can not find out its expansion. This macro will not use
  77. dnl default includes even if no INCLUDES argument is given. This macro
  78. dnl will run silently when invoked with three arguments.
  79. AC_DEFUN([CURL_CHECK_DEF_CC], [
  80. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  81. ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
  82. AC_COMPILE_IFELSE([
  83. AC_LANG_SOURCE(
  84. ifelse($2,,,[$2])[[
  85. int main (void)
  86. {
  87. #ifdef $1
  88. return 0;
  89. #else
  90. force compilation error
  91. #endif
  92. }
  93. ]])
  94. ],[
  95. tst_symbol_defined="yes"
  96. ],[
  97. tst_symbol_defined="no"
  98. ])
  99. if test "$tst_symbol_defined" = "yes"; then
  100. AS_VAR_SET(ac_HaveDef, yes)
  101. ifelse($3,,[AC_MSG_RESULT([yes])])
  102. else
  103. AS_VAR_SET(ac_HaveDef, no)
  104. ifelse($3,,[AC_MSG_RESULT([no])])
  105. fi
  106. AS_VAR_POPDEF([ac_HaveDef])dnl
  107. ])
  108. dnl CURL_CHECK_LIB_XNET
  109. dnl -------------------------------------------------
  110. dnl Verify if X/Open network library is required.
  111. AC_DEFUN([CURL_CHECK_LIB_XNET], [
  112. AC_MSG_CHECKING([if X/Open network library is required])
  113. tst_lib_xnet_required="no"
  114. AC_COMPILE_IFELSE([
  115. AC_LANG_SOURCE([[
  116. int main (void)
  117. {
  118. #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
  119. return 0;
  120. #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
  121. return 0;
  122. #else
  123. force compilation error
  124. #endif
  125. }
  126. ]])
  127. ],[
  128. tst_lib_xnet_required="yes"
  129. LIBS="-lxnet $LIBS"
  130. ])
  131. AC_MSG_RESULT([$tst_lib_xnet_required])
  132. ])
  133. dnl CURL_CHECK_AIX_ALL_SOURCE
  134. dnl -------------------------------------------------
  135. dnl Provides a replacement of traditional AC_AIX with
  136. dnl an uniform behaviour across all autoconf versions,
  137. dnl and with our own placement rules.
  138. AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
  139. AH_VERBATIM([_ALL_SOURCE],
  140. [/* Define to 1 if OS is AIX. */
  141. #ifndef _ALL_SOURCE
  142. # undef _ALL_SOURCE
  143. #endif])
  144. AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
  145. AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
  146. AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
  147. AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
  148. AC_EGREP_CPP([yes_this_is_aix],[
  149. #ifdef _AIX
  150. yes_this_is_aix
  151. #endif
  152. ],[
  153. AC_MSG_RESULT([yes])
  154. AC_DEFINE(_ALL_SOURCE)
  155. ],[
  156. AC_MSG_RESULT([no])
  157. ])
  158. ])
  159. dnl CURL_CHECK_HEADER_WINDOWS
  160. dnl -------------------------------------------------
  161. dnl Check for compilable and valid windows.h header
  162. AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
  163. AC_CACHE_CHECK([for windows.h], [curl_cv_header_windows_h], [
  164. AC_COMPILE_IFELSE([
  165. AC_LANG_PROGRAM([[
  166. #undef inline
  167. #ifndef WIN32_LEAN_AND_MEAN
  168. #define WIN32_LEAN_AND_MEAN
  169. #endif
  170. #include <windows.h>
  171. ]],[[
  172. #if defined(__CYGWIN__) || defined(__CEGCC__)
  173. HAVE_WINDOWS_H shall not be defined.
  174. #else
  175. int dummy=2*WINVER;
  176. #endif
  177. ]])
  178. ],[
  179. curl_cv_header_windows_h="yes"
  180. ],[
  181. curl_cv_header_windows_h="no"
  182. ])
  183. ])
  184. case "$curl_cv_header_windows_h" in
  185. yes)
  186. AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
  187. [Define to 1 if you have the windows.h header file.])
  188. ;;
  189. esac
  190. ])
  191. dnl CURL_CHECK_NATIVE_WINDOWS
  192. dnl -------------------------------------------------
  193. dnl Check if building a native Windows target
  194. AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
  195. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  196. AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
  197. if test "$curl_cv_header_windows_h" = "no"; then
  198. curl_cv_native_windows="no"
  199. else
  200. AC_COMPILE_IFELSE([
  201. AC_LANG_PROGRAM([[
  202. ]],[[
  203. #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
  204. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
  205. int dummy=1;
  206. #else
  207. Not a native Windows build target.
  208. #endif
  209. ]])
  210. ],[
  211. curl_cv_native_windows="yes"
  212. ],[
  213. curl_cv_native_windows="no"
  214. ])
  215. fi
  216. ])
  217. AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
  218. ])
  219. dnl CURL_CHECK_HEADER_WINSOCK
  220. dnl -------------------------------------------------
  221. dnl Check for compilable and valid winsock.h header
  222. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
  223. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  224. AC_CACHE_CHECK([for winsock.h], [curl_cv_header_winsock_h], [
  225. AC_COMPILE_IFELSE([
  226. AC_LANG_PROGRAM([[
  227. #undef inline
  228. #ifndef WIN32_LEAN_AND_MEAN
  229. #define WIN32_LEAN_AND_MEAN
  230. #endif
  231. #include <windows.h>
  232. #include <winsock.h>
  233. ]],[[
  234. #if defined(__CYGWIN__) || defined(__CEGCC__)
  235. HAVE_WINSOCK_H shall not be defined.
  236. #else
  237. int dummy=WSACleanup();
  238. #endif
  239. ]])
  240. ],[
  241. curl_cv_header_winsock_h="yes"
  242. ],[
  243. curl_cv_header_winsock_h="no"
  244. ])
  245. ])
  246. case "$curl_cv_header_winsock_h" in
  247. yes)
  248. AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
  249. [Define to 1 if you have the winsock.h header file.])
  250. ;;
  251. esac
  252. ])
  253. dnl CURL_CHECK_HEADER_WINSOCK2
  254. dnl -------------------------------------------------
  255. dnl Check for compilable and valid winsock2.h header
  256. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
  257. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  258. AC_CACHE_CHECK([for winsock2.h], [curl_cv_header_winsock2_h], [
  259. AC_COMPILE_IFELSE([
  260. AC_LANG_PROGRAM([[
  261. #undef inline
  262. #ifndef WIN32_LEAN_AND_MEAN
  263. #define WIN32_LEAN_AND_MEAN
  264. #endif
  265. #include <windows.h>
  266. #include <winsock2.h>
  267. ]],[[
  268. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  269. HAVE_WINSOCK2_H shall not be defined.
  270. #else
  271. int dummy=2*IPPROTO_ESP;
  272. #endif
  273. ]])
  274. ],[
  275. curl_cv_header_winsock2_h="yes"
  276. ],[
  277. curl_cv_header_winsock2_h="no"
  278. ])
  279. ])
  280. case "$curl_cv_header_winsock2_h" in
  281. yes)
  282. AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
  283. [Define to 1 if you have the winsock2.h header file.])
  284. ;;
  285. esac
  286. ])
  287. dnl CURL_CHECK_HEADER_WS2TCPIP
  288. dnl -------------------------------------------------
  289. dnl Check for compilable and valid ws2tcpip.h header
  290. AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
  291. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  292. AC_CACHE_CHECK([for ws2tcpip.h], [curl_cv_header_ws2tcpip_h], [
  293. AC_COMPILE_IFELSE([
  294. AC_LANG_PROGRAM([[
  295. #undef inline
  296. #ifndef WIN32_LEAN_AND_MEAN
  297. #define WIN32_LEAN_AND_MEAN
  298. #endif
  299. #include <windows.h>
  300. #include <winsock2.h>
  301. #include <ws2tcpip.h>
  302. ]],[[
  303. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  304. HAVE_WS2TCPIP_H shall not be defined.
  305. #else
  306. int dummy=2*IP_PKTINFO;
  307. #endif
  308. ]])
  309. ],[
  310. curl_cv_header_ws2tcpip_h="yes"
  311. ],[
  312. curl_cv_header_ws2tcpip_h="no"
  313. ])
  314. ])
  315. case "$curl_cv_header_ws2tcpip_h" in
  316. yes)
  317. AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
  318. [Define to 1 if you have the ws2tcpip.h header file.])
  319. ;;
  320. esac
  321. ])
  322. dnl CURL_CHECK_HEADER_WINLDAP
  323. dnl -------------------------------------------------
  324. dnl Check for compilable and valid winldap.h header
  325. AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
  326. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  327. AC_CACHE_CHECK([for winldap.h], [curl_cv_header_winldap_h], [
  328. AC_COMPILE_IFELSE([
  329. AC_LANG_PROGRAM([[
  330. #undef inline
  331. #ifdef HAVE_WINDOWS_H
  332. #ifndef WIN32_LEAN_AND_MEAN
  333. #define WIN32_LEAN_AND_MEAN
  334. #endif
  335. #include <windows.h>
  336. #endif
  337. #include <winldap.h>
  338. ]],[[
  339. #if defined(__CYGWIN__) || defined(__CEGCC__)
  340. HAVE_WINLDAP_H shall not be defined.
  341. #else
  342. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  343. ULONG res = ldap_unbind(ldp);
  344. #endif
  345. ]])
  346. ],[
  347. curl_cv_header_winldap_h="yes"
  348. ],[
  349. curl_cv_header_winldap_h="no"
  350. ])
  351. ])
  352. case "$curl_cv_header_winldap_h" in
  353. yes)
  354. AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
  355. [Define to 1 if you have the winldap.h header file.])
  356. ;;
  357. esac
  358. ])
  359. dnl CURL_CHECK_HEADER_WINBER
  360. dnl -------------------------------------------------
  361. dnl Check for compilable and valid winber.h header
  362. AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
  363. AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
  364. AC_CACHE_CHECK([for winber.h], [curl_cv_header_winber_h], [
  365. AC_COMPILE_IFELSE([
  366. AC_LANG_PROGRAM([[
  367. #undef inline
  368. #ifdef HAVE_WINDOWS_H
  369. #ifndef WIN32_LEAN_AND_MEAN
  370. #define WIN32_LEAN_AND_MEAN
  371. #endif
  372. #include <windows.h>
  373. #endif
  374. #include <winldap.h>
  375. #include <winber.h>
  376. ]],[[
  377. #if defined(__CYGWIN__) || defined(__CEGCC__)
  378. HAVE_WINBER_H shall not be defined.
  379. #else
  380. BERVAL *bvp = NULL;
  381. BerElement *bep = ber_init(bvp);
  382. ber_free(bep, 1);
  383. #endif
  384. ]])
  385. ],[
  386. curl_cv_header_winber_h="yes"
  387. ],[
  388. curl_cv_header_winber_h="no"
  389. ])
  390. ])
  391. case "$curl_cv_header_winber_h" in
  392. yes)
  393. AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
  394. [Define to 1 if you have the winber.h header file.])
  395. ;;
  396. esac
  397. ])
  398. dnl CURL_CHECK_HEADER_LBER
  399. dnl -------------------------------------------------
  400. dnl Check for compilable and valid lber.h header,
  401. dnl and check if it is needed even with ldap.h
  402. AC_DEFUN([CURL_CHECK_HEADER_LBER], [
  403. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  404. AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
  405. AC_COMPILE_IFELSE([
  406. AC_LANG_PROGRAM([[
  407. #undef inline
  408. #ifdef HAVE_WINDOWS_H
  409. #ifndef WIN32_LEAN_AND_MEAN
  410. #define WIN32_LEAN_AND_MEAN
  411. #endif
  412. #include <windows.h>
  413. #else
  414. #ifdef HAVE_SYS_TYPES_H
  415. #include <sys/types.h>
  416. #endif
  417. #endif
  418. #ifndef NULL
  419. #define NULL (void *)0
  420. #endif
  421. #include <lber.h>
  422. ]],[[
  423. BerValue *bvp = NULL;
  424. BerElement *bep = ber_init(bvp);
  425. ber_free(bep, 1);
  426. ]])
  427. ],[
  428. curl_cv_header_lber_h="yes"
  429. ],[
  430. curl_cv_header_lber_h="no"
  431. ])
  432. ])
  433. if test "$curl_cv_header_lber_h" = "yes"; then
  434. AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
  435. [Define to 1 if you have the lber.h header file.])
  436. #
  437. AC_COMPILE_IFELSE([
  438. AC_LANG_PROGRAM([[
  439. #undef inline
  440. #ifdef HAVE_WINDOWS_H
  441. #ifndef WIN32_LEAN_AND_MEAN
  442. #define WIN32_LEAN_AND_MEAN
  443. #endif
  444. #include <windows.h>
  445. #else
  446. #ifdef HAVE_SYS_TYPES_H
  447. #include <sys/types.h>
  448. #endif
  449. #endif
  450. #ifndef NULL
  451. #define NULL (void *)0
  452. #endif
  453. #ifndef LDAP_DEPRECATED
  454. #define LDAP_DEPRECATED 1
  455. #endif
  456. #include <ldap.h>
  457. ]],[[
  458. BerValue *bvp = NULL;
  459. BerElement *bep = ber_init(bvp);
  460. ber_free(bep, 1);
  461. ]])
  462. ],[
  463. curl_cv_need_header_lber_h="no"
  464. ],[
  465. curl_cv_need_header_lber_h="yes"
  466. ])
  467. #
  468. case "$curl_cv_need_header_lber_h" in
  469. yes)
  470. AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
  471. [Define to 1 if you need the lber.h header file even with ldap.h])
  472. ;;
  473. esac
  474. fi
  475. ])
  476. dnl CURL_CHECK_HEADER_LDAP
  477. dnl -------------------------------------------------
  478. dnl Check for compilable and valid ldap.h header
  479. AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
  480. AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
  481. AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
  482. AC_COMPILE_IFELSE([
  483. AC_LANG_PROGRAM([[
  484. #undef inline
  485. #ifdef HAVE_WINDOWS_H
  486. #ifndef WIN32_LEAN_AND_MEAN
  487. #define WIN32_LEAN_AND_MEAN
  488. #endif
  489. #include <windows.h>
  490. #else
  491. #ifdef HAVE_SYS_TYPES_H
  492. #include <sys/types.h>
  493. #endif
  494. #endif
  495. #ifndef LDAP_DEPRECATED
  496. #define LDAP_DEPRECATED 1
  497. #endif
  498. #ifdef NEED_LBER_H
  499. #include <lber.h>
  500. #endif
  501. #include <ldap.h>
  502. ]],[[
  503. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  504. int res = ldap_unbind(ldp);
  505. ]])
  506. ],[
  507. curl_cv_header_ldap_h="yes"
  508. ],[
  509. curl_cv_header_ldap_h="no"
  510. ])
  511. ])
  512. case "$curl_cv_header_ldap_h" in
  513. yes)
  514. AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
  515. [Define to 1 if you have the ldap.h header file.])
  516. ;;
  517. esac
  518. ])
  519. dnl CURL_CHECK_HEADER_LDAP_SSL
  520. dnl -------------------------------------------------
  521. dnl Check for compilable and valid ldap_ssl.h header
  522. AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
  523. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  524. AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
  525. AC_COMPILE_IFELSE([
  526. AC_LANG_PROGRAM([[
  527. #undef inline
  528. #ifdef HAVE_WINDOWS_H
  529. #ifndef WIN32_LEAN_AND_MEAN
  530. #define WIN32_LEAN_AND_MEAN
  531. #endif
  532. #include <windows.h>
  533. #else
  534. #ifdef HAVE_SYS_TYPES_H
  535. #include <sys/types.h>
  536. #endif
  537. #endif
  538. #ifndef LDAP_DEPRECATED
  539. #define LDAP_DEPRECATED 1
  540. #endif
  541. #ifdef NEED_LBER_H
  542. #include <lber.h>
  543. #endif
  544. #ifdef HAVE_LDAP_H
  545. #include <ldap.h>
  546. #endif
  547. #include <ldap_ssl.h>
  548. ]],[[
  549. LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
  550. ]])
  551. ],[
  552. curl_cv_header_ldap_ssl_h="yes"
  553. ],[
  554. curl_cv_header_ldap_ssl_h="no"
  555. ])
  556. ])
  557. case "$curl_cv_header_ldap_ssl_h" in
  558. yes)
  559. AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
  560. [Define to 1 if you have the ldap_ssl.h header file.])
  561. ;;
  562. esac
  563. ])
  564. dnl CURL_CHECK_HEADER_LDAPSSL
  565. dnl -------------------------------------------------
  566. dnl Check for compilable and valid ldapssl.h header
  567. AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
  568. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  569. AC_CACHE_CHECK([for ldapssl.h], [curl_cv_header_ldapssl_h], [
  570. AC_COMPILE_IFELSE([
  571. AC_LANG_PROGRAM([[
  572. #undef inline
  573. #ifdef HAVE_WINDOWS_H
  574. #ifndef WIN32_LEAN_AND_MEAN
  575. #define WIN32_LEAN_AND_MEAN
  576. #endif
  577. #include <windows.h>
  578. #else
  579. #ifdef HAVE_SYS_TYPES_H
  580. #include <sys/types.h>
  581. #endif
  582. #endif
  583. #ifndef NULL
  584. #define NULL (void *)0
  585. #endif
  586. #ifndef LDAP_DEPRECATED
  587. #define LDAP_DEPRECATED 1
  588. #endif
  589. #ifdef NEED_LBER_H
  590. #include <lber.h>
  591. #endif
  592. #ifdef HAVE_LDAP_H
  593. #include <ldap.h>
  594. #endif
  595. #include <ldapssl.h>
  596. ]],[[
  597. char *cert_label = NULL;
  598. LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
  599. ]])
  600. ],[
  601. curl_cv_header_ldapssl_h="yes"
  602. ],[
  603. curl_cv_header_ldapssl_h="no"
  604. ])
  605. ])
  606. case "$curl_cv_header_ldapssl_h" in
  607. yes)
  608. AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
  609. [Define to 1 if you have the ldapssl.h header file.])
  610. ;;
  611. esac
  612. ])
  613. dnl CURL_CHECK_LIBS_WINLDAP
  614. dnl -------------------------------------------------
  615. dnl Check for libraries needed for WINLDAP support,
  616. dnl and prepended to LIBS any needed libraries.
  617. dnl This macro can take an optional parameter with a
  618. dnl white space separated list of libraries to check
  619. dnl before the WINLDAP default ones.
  620. AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
  621. AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
  622. #
  623. AC_MSG_CHECKING([for WINLDAP libraries])
  624. #
  625. u_libs=""
  626. #
  627. ifelse($1,,,[
  628. for x_lib in $1; do
  629. case "$x_lib" in
  630. -l*)
  631. l_lib="$x_lib"
  632. ;;
  633. *)
  634. l_lib="-l$x_lib"
  635. ;;
  636. esac
  637. if test -z "$u_libs"; then
  638. u_libs="$l_lib"
  639. else
  640. u_libs="$u_libs $l_lib"
  641. fi
  642. done
  643. ])
  644. #
  645. curl_cv_save_LIBS="$LIBS"
  646. curl_cv_ldap_LIBS="unknown"
  647. #
  648. for x_nlibs in '' "$u_libs" \
  649. '-lwldap32' ; do
  650. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  651. if test -z "$x_nlibs"; then
  652. LIBS="$curl_cv_save_LIBS"
  653. else
  654. LIBS="$x_nlibs $curl_cv_save_LIBS"
  655. fi
  656. AC_LINK_IFELSE([
  657. AC_LANG_PROGRAM([[
  658. #undef inline
  659. #ifdef HAVE_WINDOWS_H
  660. #ifndef WIN32_LEAN_AND_MEAN
  661. #define WIN32_LEAN_AND_MEAN
  662. #endif
  663. #include <windows.h>
  664. #ifdef HAVE_WINLDAP_H
  665. #include <winldap.h>
  666. #endif
  667. #ifdef HAVE_WINBER_H
  668. #include <winber.h>
  669. #endif
  670. #endif
  671. ]],[[
  672. BERVAL *bvp = NULL;
  673. BerElement *bep = ber_init(bvp);
  674. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  675. ULONG res = ldap_unbind(ldp);
  676. ber_free(bep, 1);
  677. ]])
  678. ],[
  679. curl_cv_ldap_LIBS="$x_nlibs"
  680. ])
  681. fi
  682. done
  683. #
  684. LIBS="$curl_cv_save_LIBS"
  685. #
  686. case X-"$curl_cv_ldap_LIBS" in
  687. X-unknown)
  688. AC_MSG_RESULT([cannot find WINLDAP libraries])
  689. ;;
  690. X-)
  691. AC_MSG_RESULT([no additional lib required])
  692. ;;
  693. *)
  694. if test -z "$curl_cv_save_LIBS"; then
  695. LIBS="$curl_cv_ldap_LIBS"
  696. else
  697. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  698. fi
  699. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  700. ;;
  701. esac
  702. #
  703. ])
  704. dnl CURL_CHECK_LIBS_LDAP
  705. dnl -------------------------------------------------
  706. dnl Check for libraries needed for LDAP support,
  707. dnl and prepended to LIBS any needed libraries.
  708. dnl This macro can take an optional parameter with a
  709. dnl white space separated list of libraries to check
  710. dnl before the default ones.
  711. AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
  712. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  713. #
  714. AC_MSG_CHECKING([for LDAP libraries])
  715. #
  716. u_libs=""
  717. #
  718. ifelse($1,,,[
  719. for x_lib in $1; do
  720. case "$x_lib" in
  721. -l*)
  722. l_lib="$x_lib"
  723. ;;
  724. *)
  725. l_lib="-l$x_lib"
  726. ;;
  727. esac
  728. if test -z "$u_libs"; then
  729. u_libs="$l_lib"
  730. else
  731. u_libs="$u_libs $l_lib"
  732. fi
  733. done
  734. ])
  735. #
  736. curl_cv_save_LIBS="$LIBS"
  737. curl_cv_ldap_LIBS="unknown"
  738. #
  739. for x_nlibs in '' "$u_libs" \
  740. '-lldap' \
  741. '-lldap -llber' \
  742. '-llber -lldap' \
  743. '-lldapssl -lldapx -lldapsdk' \
  744. '-lldapsdk -lldapx -lldapssl' \
  745. '-lldap -llber -lssl -lcrypto' ; do
  746. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  747. if test -z "$x_nlibs"; then
  748. LIBS="$curl_cv_save_LIBS"
  749. else
  750. LIBS="$x_nlibs $curl_cv_save_LIBS"
  751. fi
  752. AC_LINK_IFELSE([
  753. AC_LANG_PROGRAM([[
  754. #undef inline
  755. #ifdef HAVE_WINDOWS_H
  756. #ifndef WIN32_LEAN_AND_MEAN
  757. #define WIN32_LEAN_AND_MEAN
  758. #endif
  759. #include <windows.h>
  760. #else
  761. #ifdef HAVE_SYS_TYPES_H
  762. #include <sys/types.h>
  763. #endif
  764. #endif
  765. #ifndef NULL
  766. #define NULL (void *)0
  767. #endif
  768. #ifndef LDAP_DEPRECATED
  769. #define LDAP_DEPRECATED 1
  770. #endif
  771. #ifdef NEED_LBER_H
  772. #include <lber.h>
  773. #endif
  774. #ifdef HAVE_LDAP_H
  775. #include <ldap.h>
  776. #endif
  777. ]],[[
  778. BerValue *bvp = NULL;
  779. BerElement *bep = ber_init(bvp);
  780. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  781. int res = ldap_unbind(ldp);
  782. ber_free(bep, 1);
  783. ]])
  784. ],[
  785. curl_cv_ldap_LIBS="$x_nlibs"
  786. ])
  787. fi
  788. done
  789. #
  790. LIBS="$curl_cv_save_LIBS"
  791. #
  792. case X-"$curl_cv_ldap_LIBS" in
  793. X-unknown)
  794. AC_MSG_RESULT([cannot find LDAP libraries])
  795. ;;
  796. X-)
  797. AC_MSG_RESULT([no additional lib required])
  798. ;;
  799. *)
  800. if test -z "$curl_cv_save_LIBS"; then
  801. LIBS="$curl_cv_ldap_LIBS"
  802. else
  803. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  804. fi
  805. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  806. ;;
  807. esac
  808. #
  809. ])
  810. dnl CURL_CHECK_HEADER_MALLOC
  811. dnl -------------------------------------------------
  812. dnl Check for compilable and valid malloc.h header,
  813. dnl and check if it is needed even with stdlib.h
  814. AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
  815. AC_CACHE_CHECK([for malloc.h], [curl_cv_header_malloc_h], [
  816. AC_COMPILE_IFELSE([
  817. AC_LANG_PROGRAM([[
  818. #include <malloc.h>
  819. ]],[[
  820. void *p = malloc(10);
  821. void *q = calloc(10,10);
  822. free(p);
  823. free(q);
  824. ]])
  825. ],[
  826. curl_cv_header_malloc_h="yes"
  827. ],[
  828. curl_cv_header_malloc_h="no"
  829. ])
  830. ])
  831. if test "$curl_cv_header_malloc_h" = "yes"; then
  832. AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
  833. [Define to 1 if you have the malloc.h header file.])
  834. #
  835. AC_COMPILE_IFELSE([
  836. AC_LANG_PROGRAM([[
  837. #include <stdlib.h>
  838. ]],[[
  839. void *p = malloc(10);
  840. void *q = calloc(10,10);
  841. free(p);
  842. free(q);
  843. ]])
  844. ],[
  845. curl_cv_need_header_malloc_h="no"
  846. ],[
  847. curl_cv_need_header_malloc_h="yes"
  848. ])
  849. #
  850. case "$curl_cv_need_header_malloc_h" in
  851. yes)
  852. AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
  853. [Define to 1 if you need the malloc.h header file even with stdlib.h])
  854. ;;
  855. esac
  856. fi
  857. ])
  858. dnl CURL_CHECK_HEADER_MEMORY
  859. dnl -------------------------------------------------
  860. dnl Check for compilable and valid memory.h header,
  861. dnl and check if it is needed even with stdlib.h for
  862. dnl memory related functions.
  863. AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
  864. AC_CACHE_CHECK([for memory.h], [curl_cv_header_memory_h], [
  865. AC_COMPILE_IFELSE([
  866. AC_LANG_PROGRAM([[
  867. #include <memory.h>
  868. ]],[[
  869. void *p = malloc(10);
  870. void *q = calloc(10,10);
  871. free(p);
  872. free(q);
  873. ]])
  874. ],[
  875. curl_cv_header_memory_h="yes"
  876. ],[
  877. curl_cv_header_memory_h="no"
  878. ])
  879. ])
  880. if test "$curl_cv_header_memory_h" = "yes"; then
  881. AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
  882. [Define to 1 if you have the memory.h header file.])
  883. #
  884. AC_COMPILE_IFELSE([
  885. AC_LANG_PROGRAM([[
  886. #include <stdlib.h>
  887. ]],[[
  888. void *p = malloc(10);
  889. void *q = calloc(10,10);
  890. free(p);
  891. free(q);
  892. ]])
  893. ],[
  894. curl_cv_need_header_memory_h="no"
  895. ],[
  896. curl_cv_need_header_memory_h="yes"
  897. ])
  898. #
  899. case "$curl_cv_need_header_memory_h" in
  900. yes)
  901. AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
  902. [Define to 1 if you need the memory.h header file even with stdlib.h])
  903. ;;
  904. esac
  905. fi
  906. ])
  907. dnl TYPE_SOCKADDR_STORAGE
  908. dnl -------------------------------------------------
  909. dnl Check for struct sockaddr_storage. Most IPv6-enabled
  910. dnl hosts have it, but AIX 4.3 is one known exception.
  911. AC_DEFUN([TYPE_SOCKADDR_STORAGE],
  912. [
  913. AC_CHECK_TYPE([struct sockaddr_storage],
  914. AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
  915. [if struct sockaddr_storage is defined]), ,
  916. [
  917. #undef inline
  918. #ifdef HAVE_WINDOWS_H
  919. #ifndef WIN32_LEAN_AND_MEAN
  920. #define WIN32_LEAN_AND_MEAN
  921. #endif
  922. #include <windows.h>
  923. #ifdef HAVE_WINSOCK2_H
  924. #include <winsock2.h>
  925. #endif
  926. #else
  927. #ifdef HAVE_SYS_TYPES_H
  928. #include <sys/types.h>
  929. #endif
  930. #ifdef HAVE_SYS_SOCKET_H
  931. #include <sys/socket.h>
  932. #endif
  933. #ifdef HAVE_NETINET_IN_H
  934. #include <netinet/in.h>
  935. #endif
  936. #ifdef HAVE_ARPA_INET_H
  937. #include <arpa/inet.h>
  938. #endif
  939. #endif
  940. ])
  941. ])
  942. dnl CURL_CHECK_FUNC_RECV
  943. dnl -------------------------------------------------
  944. dnl Test if the socket recv() function is available,
  945. dnl and check its return type and the types of its
  946. dnl arguments. If the function succeeds HAVE_RECV
  947. dnl will be defined, defining the types of the arguments
  948. dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
  949. dnl and RECV_TYPE_ARG4, defining the type of the function
  950. dnl return value in RECV_TYPE_RETV.
  951. AC_DEFUN([CURL_CHECK_FUNC_RECV], [
  952. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  953. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  954. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  955. #
  956. AC_MSG_CHECKING([for recv])
  957. AC_LINK_IFELSE([
  958. AC_LANG_PROGRAM([[
  959. #undef inline
  960. #ifdef HAVE_WINDOWS_H
  961. #ifndef WIN32_LEAN_AND_MEAN
  962. #define WIN32_LEAN_AND_MEAN
  963. #endif
  964. #include <windows.h>
  965. #ifdef HAVE_WINSOCK2_H
  966. #include <winsock2.h>
  967. #else
  968. #ifdef HAVE_WINSOCK_H
  969. #include <winsock.h>
  970. #endif
  971. #endif
  972. #else
  973. #ifdef HAVE_SYS_TYPES_H
  974. #include <sys/types.h>
  975. #endif
  976. #ifdef HAVE_SYS_SOCKET_H
  977. #include <sys/socket.h>
  978. #endif
  979. #endif
  980. ]],[[
  981. recv(0, 0, 0, 0);
  982. ]])
  983. ],[
  984. AC_MSG_RESULT([yes])
  985. curl_cv_recv="yes"
  986. ],[
  987. AC_MSG_RESULT([no])
  988. curl_cv_recv="no"
  989. ])
  990. #
  991. if test "$curl_cv_recv" = "yes"; then
  992. AC_CACHE_CHECK([types of args and return type for recv],
  993. [curl_cv_func_recv_args], [
  994. curl_cv_func_recv_args="unknown"
  995. for recv_retv in 'int' 'ssize_t'; do
  996. for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  997. for recv_arg2 in 'char *' 'void *'; do
  998. for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  999. for recv_arg4 in 'int' 'unsigned int'; do
  1000. if test "$curl_cv_func_recv_args" = "unknown"; then
  1001. AC_COMPILE_IFELSE([
  1002. AC_LANG_PROGRAM([[
  1003. #undef inline
  1004. #ifdef HAVE_WINDOWS_H
  1005. #ifndef WIN32_LEAN_AND_MEAN
  1006. #define WIN32_LEAN_AND_MEAN
  1007. #endif
  1008. #include <windows.h>
  1009. #ifdef HAVE_WINSOCK2_H
  1010. #include <winsock2.h>
  1011. #else
  1012. #ifdef HAVE_WINSOCK_H
  1013. #include <winsock.h>
  1014. #endif
  1015. #endif
  1016. #define RECVCALLCONV PASCAL
  1017. #else
  1018. #ifdef HAVE_SYS_TYPES_H
  1019. #include <sys/types.h>
  1020. #endif
  1021. #ifdef HAVE_SYS_SOCKET_H
  1022. #include <sys/socket.h>
  1023. #endif
  1024. #define RECVCALLCONV
  1025. #endif
  1026. extern $recv_retv RECVCALLCONV
  1027. recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
  1028. ]],[[
  1029. $recv_arg1 s=0;
  1030. $recv_arg2 buf=0;
  1031. $recv_arg3 len=0;
  1032. $recv_arg4 flags=0;
  1033. $recv_retv res = recv(s, buf, len, flags);
  1034. ]])
  1035. ],[
  1036. curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
  1037. ])
  1038. fi
  1039. done
  1040. done
  1041. done
  1042. done
  1043. done
  1044. ]) # AC-CACHE-CHECK
  1045. if test "$curl_cv_func_recv_args" = "unknown"; then
  1046. AC_MSG_ERROR([Cannot find proper types to use for recv args])
  1047. else
  1048. recv_prev_IFS=$IFS; IFS=','
  1049. set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
  1050. IFS=$recv_prev_IFS
  1051. shift
  1052. #
  1053. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
  1054. [Define to the type of arg 1 for recv.])
  1055. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
  1056. [Define to the type of arg 2 for recv.])
  1057. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
  1058. [Define to the type of arg 3 for recv.])
  1059. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
  1060. [Define to the type of arg 4 for recv.])
  1061. AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
  1062. [Define to the function return type for recv.])
  1063. #
  1064. AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
  1065. [Define to 1 if you have the recv function.])
  1066. curl_cv_func_recv="yes"
  1067. fi
  1068. else
  1069. AC_MSG_ERROR([Unable to link function recv])
  1070. fi
  1071. ])
  1072. dnl CURL_CHECK_FUNC_SEND
  1073. dnl -------------------------------------------------
  1074. dnl Test if the socket send() function is available,
  1075. dnl and check its return type and the types of its
  1076. dnl arguments. If the function succeeds HAVE_SEND
  1077. dnl will be defined, defining the types of the arguments
  1078. dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
  1079. dnl and SEND_TYPE_ARG4, defining the type of the function
  1080. dnl return value in SEND_TYPE_RETV, and also defining the
  1081. dnl type qualifier of second argument in SEND_QUAL_ARG2.
  1082. AC_DEFUN([CURL_CHECK_FUNC_SEND], [
  1083. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1084. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1085. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1086. #
  1087. AC_MSG_CHECKING([for send])
  1088. AC_LINK_IFELSE([
  1089. AC_LANG_PROGRAM([[
  1090. #undef inline
  1091. #ifdef HAVE_WINDOWS_H
  1092. #ifndef WIN32_LEAN_AND_MEAN
  1093. #define WIN32_LEAN_AND_MEAN
  1094. #endif
  1095. #include <windows.h>
  1096. #ifdef HAVE_WINSOCK2_H
  1097. #include <winsock2.h>
  1098. #else
  1099. #ifdef HAVE_WINSOCK_H
  1100. #include <winsock.h>
  1101. #endif
  1102. #endif
  1103. #else
  1104. #ifdef HAVE_SYS_TYPES_H
  1105. #include <sys/types.h>
  1106. #endif
  1107. #ifdef HAVE_SYS_SOCKET_H
  1108. #include <sys/socket.h>
  1109. #endif
  1110. #endif
  1111. ]],[[
  1112. send(0, 0, 0, 0);
  1113. ]])
  1114. ],[
  1115. AC_MSG_RESULT([yes])
  1116. curl_cv_send="yes"
  1117. ],[
  1118. AC_MSG_RESULT([no])
  1119. curl_cv_send="no"
  1120. ])
  1121. #
  1122. if test "$curl_cv_send" = "yes"; then
  1123. AC_CACHE_CHECK([types of args and return type for send],
  1124. [curl_cv_func_send_args], [
  1125. curl_cv_func_send_args="unknown"
  1126. for send_retv in 'int' 'ssize_t'; do
  1127. for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1128. for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
  1129. for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1130. for send_arg4 in 'int' 'unsigned int'; do
  1131. if test "$curl_cv_func_send_args" = "unknown"; then
  1132. AC_COMPILE_IFELSE([
  1133. AC_LANG_PROGRAM([[
  1134. #undef inline
  1135. #ifdef HAVE_WINDOWS_H
  1136. #ifndef WIN32_LEAN_AND_MEAN
  1137. #define WIN32_LEAN_AND_MEAN
  1138. #endif
  1139. #include <windows.h>
  1140. #ifdef HAVE_WINSOCK2_H
  1141. #include <winsock2.h>
  1142. #else
  1143. #ifdef HAVE_WINSOCK_H
  1144. #include <winsock.h>
  1145. #endif
  1146. #endif
  1147. #define SENDCALLCONV PASCAL
  1148. #else
  1149. #ifdef HAVE_SYS_TYPES_H
  1150. #include <sys/types.h>
  1151. #endif
  1152. #ifdef HAVE_SYS_SOCKET_H
  1153. #include <sys/socket.h>
  1154. #endif
  1155. #define SENDCALLCONV
  1156. #endif
  1157. extern $send_retv SENDCALLCONV
  1158. send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
  1159. ]],[[
  1160. $send_arg1 s=0;
  1161. $send_arg3 len=0;
  1162. $send_arg4 flags=0;
  1163. $send_retv res = send(s, 0, len, flags);
  1164. ]])
  1165. ],[
  1166. curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
  1167. ])
  1168. fi
  1169. done
  1170. done
  1171. done
  1172. done
  1173. done
  1174. ]) # AC-CACHE-CHECK
  1175. if test "$curl_cv_func_send_args" = "unknown"; then
  1176. AC_MSG_ERROR([Cannot find proper types to use for send args])
  1177. else
  1178. send_prev_IFS=$IFS; IFS=','
  1179. set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
  1180. IFS=$send_prev_IFS
  1181. shift
  1182. #
  1183. send_qual_type_arg2=$[2]
  1184. #
  1185. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
  1186. [Define to the type of arg 1 for send.])
  1187. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
  1188. [Define to the type of arg 3 for send.])
  1189. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
  1190. [Define to the type of arg 4 for send.])
  1191. AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
  1192. [Define to the function return type for send.])
  1193. #
  1194. prev_sh_opts=$-
  1195. #
  1196. case $prev_sh_opts in
  1197. *f*)
  1198. ;;
  1199. *)
  1200. set -f
  1201. ;;
  1202. esac
  1203. #
  1204. case "$send_qual_type_arg2" in
  1205. const*)
  1206. send_qual_arg2=const
  1207. send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
  1208. ;;
  1209. *)
  1210. send_qual_arg2=
  1211. send_type_arg2=$send_qual_type_arg2
  1212. ;;
  1213. esac
  1214. #
  1215. AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
  1216. [Define to the type qualifier of arg 2 for send.])
  1217. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
  1218. [Define to the type of arg 2 for send.])
  1219. #
  1220. case $prev_sh_opts in
  1221. *f*)
  1222. ;;
  1223. *)
  1224. set +f
  1225. ;;
  1226. esac
  1227. #
  1228. AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
  1229. [Define to 1 if you have the send function.])
  1230. curl_cv_func_send="yes"
  1231. fi
  1232. else
  1233. AC_MSG_ERROR([Unable to link function send])
  1234. fi
  1235. ])
  1236. dnl CURL_CHECK_MSG_NOSIGNAL
  1237. dnl -------------------------------------------------
  1238. dnl Check for MSG_NOSIGNAL
  1239. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  1240. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1241. AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
  1242. AC_COMPILE_IFELSE([
  1243. AC_LANG_PROGRAM([[
  1244. #undef inline
  1245. #ifdef HAVE_WINDOWS_H
  1246. #ifndef WIN32_LEAN_AND_MEAN
  1247. #define WIN32_LEAN_AND_MEAN
  1248. #endif
  1249. #include <windows.h>
  1250. #ifdef HAVE_WINSOCK2_H
  1251. #include <winsock2.h>
  1252. #else
  1253. #ifdef HAVE_WINSOCK_H
  1254. #include <winsock.h>
  1255. #endif
  1256. #endif
  1257. #else
  1258. #ifdef HAVE_SYS_TYPES_H
  1259. #include <sys/types.h>
  1260. #endif
  1261. #ifdef HAVE_SYS_SOCKET_H
  1262. #include <sys/socket.h>
  1263. #endif
  1264. #endif
  1265. ]],[[
  1266. int flag=MSG_NOSIGNAL;
  1267. ]])
  1268. ],[
  1269. curl_cv_msg_nosignal="yes"
  1270. ],[
  1271. curl_cv_msg_nosignal="no"
  1272. ])
  1273. ])
  1274. case "$curl_cv_msg_nosignal" in
  1275. yes)
  1276. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  1277. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  1278. ;;
  1279. esac
  1280. ])
  1281. dnl CURL_CHECK_STRUCT_TIMEVAL
  1282. dnl -------------------------------------------------
  1283. dnl Check for timeval struct
  1284. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  1285. AC_REQUIRE([AC_HEADER_TIME])dnl
  1286. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1287. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1288. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
  1289. AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
  1290. AC_COMPILE_IFELSE([
  1291. AC_LANG_PROGRAM([[
  1292. #undef inline
  1293. #ifdef HAVE_WINDOWS_H
  1294. #ifndef WIN32_LEAN_AND_MEAN
  1295. #define WIN32_LEAN_AND_MEAN
  1296. #endif
  1297. #include <windows.h>
  1298. #ifdef HAVE_WINSOCK2_H
  1299. #include <winsock2.h>
  1300. #else
  1301. #ifdef HAVE_WINSOCK_H
  1302. #include <winsock.h>
  1303. #endif
  1304. #endif
  1305. #endif
  1306. #ifdef HAVE_SYS_TYPES_H
  1307. #include <sys/types.h>
  1308. #endif
  1309. #ifdef HAVE_SYS_TIME_H
  1310. #include <sys/time.h>
  1311. #ifdef TIME_WITH_SYS_TIME
  1312. #include <time.h>
  1313. #endif
  1314. #else
  1315. #ifdef HAVE_TIME_H
  1316. #include <time.h>
  1317. #endif
  1318. #endif
  1319. #ifdef HAVE_SYS_SOCKET_H
  1320. #include <sys/socket.h>
  1321. #endif
  1322. ]],[[
  1323. struct timeval ts;
  1324. ts.tv_sec = 0;
  1325. ts.tv_usec = 0;
  1326. ]])
  1327. ],[
  1328. curl_cv_struct_timeval="yes"
  1329. ],[
  1330. curl_cv_struct_timeval="no"
  1331. ])
  1332. ])
  1333. case "$curl_cv_struct_timeval" in
  1334. yes)
  1335. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  1336. [Define to 1 if you have the timeval struct.])
  1337. ;;
  1338. esac
  1339. ])
  1340. dnl TYPE_SIG_ATOMIC_T
  1341. dnl -------------------------------------------------
  1342. dnl Check if the sig_atomic_t type is available, and
  1343. dnl verify if it is already defined as volatile.
  1344. AC_DEFUN([TYPE_SIG_ATOMIC_T], [
  1345. AC_CHECK_HEADERS(signal.h)
  1346. AC_CHECK_TYPE([sig_atomic_t],[
  1347. AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
  1348. [Define to 1 if sig_atomic_t is an available typedef.])
  1349. ], ,[
  1350. #ifdef HAVE_SIGNAL_H
  1351. #include <signal.h>
  1352. #endif
  1353. ])
  1354. case "$ac_cv_type_sig_atomic_t" in
  1355. yes)
  1356. #
  1357. AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
  1358. AC_LINK_IFELSE([
  1359. AC_LANG_PROGRAM([[
  1360. #ifdef HAVE_SIGNAL_H
  1361. #include <signal.h>
  1362. #endif
  1363. ]],[[
  1364. static volatile sig_atomic_t dummy = 0;
  1365. ]])
  1366. ],[
  1367. AC_MSG_RESULT([no])
  1368. curl_cv_sig_atomic_t_volatile="no"
  1369. ],[
  1370. AC_MSG_RESULT([yes])
  1371. curl_cv_sig_atomic_t_volatile="yes"
  1372. ])
  1373. #
  1374. if test "$curl_cv_sig_atomic_t_volatile" = "yes"; then
  1375. AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
  1376. [Define to 1 if sig_atomic_t is already defined as volatile.])
  1377. fi
  1378. ;;
  1379. esac
  1380. ])
  1381. dnl TYPE_IN_ADDR_T
  1382. dnl -------------------------------------------------
  1383. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  1384. dnl and a few other things.
  1385. AC_DEFUN([TYPE_IN_ADDR_T], [
  1386. AC_CHECK_TYPE([in_addr_t], ,[
  1387. dnl in_addr_t not available
  1388. AC_CACHE_CHECK([for in_addr_t equivalent],
  1389. [curl_cv_in_addr_t_equiv], [
  1390. curl_cv_in_addr_t_equiv="unknown"
  1391. for t in "unsigned long" int size_t unsigned long; do
  1392. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  1393. AC_LINK_IFELSE([
  1394. AC_LANG_PROGRAM([[
  1395. #undef inline
  1396. #ifdef HAVE_WINDOWS_H
  1397. #ifndef WIN32_LEAN_AND_MEAN
  1398. #define WIN32_LEAN_AND_MEAN
  1399. #endif
  1400. #include <windows.h>
  1401. #ifdef HAVE_WINSOCK2_H
  1402. #include <winsock2.h>
  1403. #else
  1404. #ifdef HAVE_WINSOCK_H
  1405. #include <winsock.h>
  1406. #endif
  1407. #endif
  1408. #else
  1409. #ifdef HAVE_SYS_TYPES_H
  1410. #include <sys/types.h>
  1411. #endif
  1412. #ifdef HAVE_SYS_SOCKET_H
  1413. #include <sys/socket.h>
  1414. #endif
  1415. #ifdef HAVE_NETINET_IN_H
  1416. #include <netinet/in.h>
  1417. #endif
  1418. #ifdef HAVE_ARPA_INET_H
  1419. #include <arpa/inet.h>
  1420. #endif
  1421. #endif
  1422. ]],[[
  1423. $t data = inet_addr ("1.2.3.4");
  1424. ]])
  1425. ],[
  1426. curl_cv_in_addr_t_equiv="$t"
  1427. ])
  1428. fi
  1429. done
  1430. ])
  1431. case "$curl_cv_in_addr_t_equiv" in
  1432. unknown)
  1433. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  1434. ;;
  1435. *)
  1436. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  1437. [Type to use in place of in_addr_t when system does not provide it.])
  1438. ;;
  1439. esac
  1440. ],[
  1441. #undef inline
  1442. #ifdef HAVE_WINDOWS_H
  1443. #ifndef WIN32_LEAN_AND_MEAN
  1444. #define WIN32_LEAN_AND_MEAN
  1445. #endif
  1446. #include <windows.h>
  1447. #ifdef HAVE_WINSOCK2_H
  1448. #include <winsock2.h>
  1449. #else
  1450. #ifdef HAVE_WINSOCK_H
  1451. #include <winsock.h>
  1452. #endif
  1453. #endif
  1454. #else
  1455. #ifdef HAVE_SYS_TYPES_H
  1456. #include <sys/types.h>
  1457. #endif
  1458. #ifdef HAVE_SYS_SOCKET_H
  1459. #include <sys/socket.h>
  1460. #endif
  1461. #ifdef HAVE_NETINET_IN_H
  1462. #include <netinet/in.h>
  1463. #endif
  1464. #ifdef HAVE_ARPA_INET_H
  1465. #include <arpa/inet.h>
  1466. #endif
  1467. #endif
  1468. ])
  1469. ])
  1470. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  1471. dnl -------------------------------------------------
  1472. dnl Check if monotonic clock_gettime is available.
  1473. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  1474. AC_REQUIRE([AC_HEADER_TIME])dnl
  1475. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
  1476. AC_MSG_CHECKING([for monotonic clock_gettime])
  1477. #
  1478. if test "x$dontwant_rt" = "xno" ; then
  1479. AC_COMPILE_IFELSE([
  1480. AC_LANG_PROGRAM([[
  1481. #ifdef HAVE_SYS_TYPES_H
  1482. #include <sys/types.h>
  1483. #endif
  1484. #ifdef HAVE_SYS_TIME_H
  1485. #include <sys/time.h>
  1486. #ifdef TIME_WITH_SYS_TIME
  1487. #include <time.h>
  1488. #endif
  1489. #else
  1490. #ifdef HAVE_TIME_H
  1491. #include <time.h>
  1492. #endif
  1493. #endif
  1494. ]],[[
  1495. struct timespec ts;
  1496. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1497. ]])
  1498. ],[
  1499. AC_MSG_RESULT([yes])
  1500. curl_func_clock_gettime="yes"
  1501. ],[
  1502. AC_MSG_RESULT([no])
  1503. curl_func_clock_gettime="no"
  1504. ])
  1505. fi
  1506. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  1507. dnl until library linking and run-time checks for clock_gettime succeed.
  1508. ])
  1509. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  1510. dnl -------------------------------------------------
  1511. dnl If monotonic clock_gettime is available then,
  1512. dnl check and prepended to LIBS any needed libraries.
  1513. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  1514. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  1515. #
  1516. if test "$curl_func_clock_gettime" = "yes"; then
  1517. #
  1518. AC_MSG_CHECKING([for clock_gettime in libraries])
  1519. #
  1520. curl_cv_save_LIBS="$LIBS"
  1521. curl_cv_gclk_LIBS="unknown"
  1522. #
  1523. for x_xlibs in '' '-lrt' '-lposix4' ; do
  1524. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  1525. if test -z "$x_xlibs"; then
  1526. LIBS="$curl_cv_save_LIBS"
  1527. else
  1528. LIBS="$x_xlibs $curl_cv_save_LIBS"
  1529. fi
  1530. AC_LINK_IFELSE([
  1531. AC_LANG_PROGRAM([[
  1532. #ifdef HAVE_SYS_TYPES_H
  1533. #include <sys/types.h>
  1534. #endif
  1535. #ifdef HAVE_SYS_TIME_H
  1536. #include <sys/time.h>
  1537. #ifdef TIME_WITH_SYS_TIME
  1538. #include <time.h>
  1539. #endif
  1540. #else
  1541. #ifdef HAVE_TIME_H
  1542. #include <time.h>
  1543. #endif
  1544. #endif
  1545. ]],[[
  1546. struct timespec ts;
  1547. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1548. ]])
  1549. ],[
  1550. curl_cv_gclk_LIBS="$x_xlibs"
  1551. ])
  1552. fi
  1553. done
  1554. #
  1555. LIBS="$curl_cv_save_LIBS"
  1556. #
  1557. case X-"$curl_cv_gclk_LIBS" in
  1558. X-unknown)
  1559. AC_MSG_RESULT([cannot find clock_gettime])
  1560. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1561. curl_func_clock_gettime="no"
  1562. ;;
  1563. X-)
  1564. AC_MSG_RESULT([no additional lib required])
  1565. curl_func_clock_gettime="yes"
  1566. ;;
  1567. *)
  1568. if test -z "$curl_cv_save_LIBS"; then
  1569. LIBS="$curl_cv_gclk_LIBS"
  1570. else
  1571. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  1572. fi
  1573. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  1574. curl_func_clock_gettime="yes"
  1575. ;;
  1576. esac
  1577. #
  1578. dnl only do runtime verification when not cross-compiling
  1579. if test "x$cross_compiling" != "xyes" &&
  1580. test "$curl_func_clock_gettime" = "yes"; then
  1581. AC_MSG_CHECKING([if monotonic clock_gettime works])
  1582. CURL_RUN_IFELSE([
  1583. AC_LANG_PROGRAM([[
  1584. #ifdef HAVE_STDLIB_H
  1585. #include <stdlib.h>
  1586. #endif
  1587. #ifdef HAVE_SYS_TYPES_H
  1588. #include <sys/types.h>
  1589. #endif
  1590. #ifdef HAVE_SYS_TIME_H
  1591. #include <sys/time.h>
  1592. #ifdef TIME_WITH_SYS_TIME
  1593. #include <time.h>
  1594. #endif
  1595. #else
  1596. #ifdef HAVE_TIME_H
  1597. #include <time.h>
  1598. #endif
  1599. #endif
  1600. ]],[[
  1601. struct timespec ts;
  1602. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  1603. exit(0);
  1604. else
  1605. exit(1);
  1606. ]])
  1607. ],[
  1608. AC_MSG_RESULT([yes])
  1609. ],[
  1610. AC_MSG_RESULT([no])
  1611. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1612. curl_func_clock_gettime="no"
  1613. LIBS="$curl_cv_save_LIBS"
  1614. ])
  1615. fi
  1616. #
  1617. case "$curl_func_clock_gettime" in
  1618. yes)
  1619. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  1620. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  1621. ;;
  1622. esac
  1623. #
  1624. fi
  1625. #
  1626. ])
  1627. dnl CURL_CHECK_LIBS_CONNECT
  1628. dnl -------------------------------------------------
  1629. dnl Verify if network connect function is already available
  1630. dnl using current libraries or if another one is required.
  1631. AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
  1632. AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
  1633. AC_MSG_CHECKING([for connect in libraries])
  1634. tst_connect_save_LIBS="$LIBS"
  1635. tst_connect_need_LIBS="unknown"
  1636. for tst_lib in '' '-lsocket' ; do
  1637. if test "$tst_connect_need_LIBS" = "unknown"; then
  1638. LIBS="$tst_lib $tst_connect_save_LIBS"
  1639. AC_LINK_IFELSE([
  1640. AC_LANG_PROGRAM([[
  1641. $curl_includes_winsock2
  1642. #ifndef HAVE_WINDOWS_H
  1643. int connect(int, void*, int);
  1644. #endif
  1645. ]],[[
  1646. if(0 != connect(0, 0, 0))
  1647. return 1;
  1648. ]])
  1649. ],[
  1650. tst_connect_need_LIBS="$tst_lib"
  1651. ])
  1652. fi
  1653. done
  1654. LIBS="$tst_connect_save_LIBS"
  1655. #
  1656. case X-"$tst_connect_need_LIBS" in
  1657. X-unknown)
  1658. AC_MSG_RESULT([cannot find connect])
  1659. AC_MSG_ERROR([cannot find connect function in libraries.])
  1660. ;;
  1661. X-)
  1662. AC_MSG_RESULT([yes])
  1663. ;;
  1664. *)
  1665. AC_MSG_RESULT([$tst_connect_need_LIBS])
  1666. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  1667. ;;
  1668. esac
  1669. ])
  1670. dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
  1671. dnl -------------------------------------------------
  1672. dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
  1673. dnl symbol that can be further used in custom template configuration
  1674. dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
  1675. dnl argument for the description. Symbol definitions done with this
  1676. dnl macro are intended to be exclusively used in handcrafted *.h.in
  1677. dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
  1678. dnl prevents autoheader generation and insertion of symbol template
  1679. dnl stub and definition into the first configuration header file. Do
  1680. dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
  1681. dnl one serves different functional needs.
  1682. AC_DEFUN([CURL_DEFINE_UNQUOTED], [
  1683. cat >>confdefs.h <<_EOF
  1684. [@%:@define] $1 ifelse($#, 2, [$2], 1)
  1685. _EOF
  1686. ])
  1687. dnl CURL_CONFIGURE_PULL_SYS_POLL
  1688. dnl -------------------------------------------------
  1689. dnl The need for the sys/poll.h inclusion arises mainly to properly
  1690. dnl interface AIX systems which define macros 'events' and 'revents'.
  1691. AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
  1692. AC_REQUIRE([CURL_INCLUDES_POLL])dnl
  1693. #
  1694. tst_poll_events_macro_defined="unknown"
  1695. #
  1696. AC_COMPILE_IFELSE([
  1697. AC_LANG_PROGRAM([[
  1698. $curl_includes_poll
  1699. ]],[[
  1700. #if defined(events) || defined(revents)
  1701. return 0;
  1702. #else
  1703. force compilation error
  1704. #endif
  1705. ]])
  1706. ],[
  1707. tst_poll_events_macro_defined="yes"
  1708. ],[
  1709. tst_poll_events_macro_defined="no"
  1710. ])
  1711. #
  1712. if test "$tst_poll_events_macro_defined" = "yes"; then
  1713. if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
  1714. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
  1715. fi
  1716. fi
  1717. #
  1718. ])
  1719. dnl CURL_CHECK_FUNC_SELECT
  1720. dnl -------------------------------------------------
  1721. dnl Test if the socket select() function is available,
  1722. dnl and check its return type and the types of its
  1723. dnl arguments. If the function succeeds HAVE_SELECT
  1724. dnl will be defined, defining the types of the
  1725. dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
  1726. dnl and SELECT_TYPE_ARG5, defining the type of the
  1727. dnl function return value in SELECT_TYPE_RETV, and
  1728. dnl also defining the type qualifier of fifth argument
  1729. dnl in SELECT_QUAL_ARG5.
  1730. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  1731. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  1732. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  1733. #
  1734. AC_MSG_CHECKING([for select])
  1735. AC_LINK_IFELSE([
  1736. AC_LANG_PROGRAM([[
  1737. #undef inline
  1738. #ifdef HAVE_WINDOWS_H
  1739. #ifndef WIN32_LEAN_AND_MEAN
  1740. #define WIN32_LEAN_AND_MEAN
  1741. #endif
  1742. #include <windows.h>
  1743. #ifdef HAVE_WINSOCK2_H
  1744. #include <winsock2.h>
  1745. #else
  1746. #ifdef HAVE_WINSOCK_H
  1747. #include <winsock.h>
  1748. #endif
  1749. #endif
  1750. #endif
  1751. #ifdef HAVE_SYS_TYPES_H
  1752. #include <sys/types.h>
  1753. #endif
  1754. #ifdef HAVE_SYS_TIME_H
  1755. #include <sys/time.h>
  1756. #ifdef TIME_WITH_SYS_TIME
  1757. #include <time.h>
  1758. #endif
  1759. #else
  1760. #ifdef HAVE_TIME_H
  1761. #include <time.h>
  1762. #endif
  1763. #endif
  1764. #ifndef HAVE_WINDOWS_H
  1765. #ifdef HAVE_SYS_SELECT_H
  1766. #include <sys/select.h>
  1767. #endif
  1768. #ifdef HAVE_SYS_SOCKET_H
  1769. #include <sys/socket.h>
  1770. #endif
  1771. #endif
  1772. ]],[[
  1773. select(0, 0, 0, 0, 0);
  1774. ]])
  1775. ],[
  1776. AC_MSG_RESULT([yes])
  1777. curl_cv_select="yes"
  1778. ],[
  1779. AC_MSG_RESULT([no])
  1780. curl_cv_select="no"
  1781. ])
  1782. #
  1783. if test "$curl_cv_select" = "yes"; then
  1784. AC_CACHE_CHECK([types of args and return type for select],
  1785. [curl_cv_func_select_args], [
  1786. curl_cv_func_select_args="unknown"
  1787. for sel_retv in 'int' 'ssize_t'; do
  1788. for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
  1789. for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
  1790. for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
  1791. if test "$curl_cv_func_select_args" = "unknown"; then
  1792. AC_COMPILE_IFELSE([
  1793. AC_LANG_PROGRAM([[
  1794. #undef inline
  1795. #ifdef HAVE_WINDOWS_H
  1796. #ifndef WIN32_LEAN_AND_MEAN
  1797. #define WIN32_LEAN_AND_MEAN
  1798. #endif
  1799. #include <windows.h>
  1800. #ifdef HAVE_WINSOCK2_H
  1801. #include <winsock2.h>
  1802. #else
  1803. #ifdef HAVE_WINSOCK_H
  1804. #include <winsock.h>
  1805. #endif
  1806. #endif
  1807. #define SELECTCALLCONV PASCAL
  1808. #endif
  1809. #ifdef HAVE_SYS_TYPES_H
  1810. #include <sys/types.h>
  1811. #endif
  1812. #ifdef HAVE_SYS_TIME_H
  1813. #include <sys/time.h>
  1814. #ifdef TIME_WITH_SYS_TIME
  1815. #include <time.h>
  1816. #endif
  1817. #else
  1818. #ifdef HAVE_TIME_H
  1819. #include <time.h>
  1820. #endif
  1821. #endif
  1822. #ifndef HAVE_WINDOWS_H
  1823. #ifdef HAVE_SYS_SELECT_H
  1824. #include <sys/select.h>
  1825. #endif
  1826. #ifdef HAVE_SYS_SOCKET_H
  1827. #include <sys/socket.h>
  1828. #endif
  1829. #define SELECTCALLCONV
  1830. #endif
  1831. #ifndef HAVE_STRUCT_TIMEVAL
  1832. struct timeval {
  1833. long tv_sec;
  1834. long tv_usec;
  1835. };
  1836. #endif
  1837. extern $sel_retv SELECTCALLCONV
  1838. select($sel_arg1,
  1839. $sel_arg234,
  1840. $sel_arg234,
  1841. $sel_arg234,
  1842. $sel_arg5);
  1843. ]],[[
  1844. $sel_arg1 nfds=0;
  1845. $sel_arg234 rfds=0;
  1846. $sel_arg234 wfds=0;
  1847. $sel_arg234 efds=0;
  1848. $sel_retv res = select(nfds, rfds, wfds, efds, 0);
  1849. ]])
  1850. ],[
  1851. curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
  1852. ])
  1853. fi
  1854. done
  1855. done
  1856. done
  1857. done
  1858. ]) # AC-CACHE-CHECK
  1859. if test "$curl_cv_func_select_args" = "unknown"; then
  1860. AC_MSG_WARN([Cannot find proper types to use for select args])
  1861. AC_MSG_WARN([HAVE_SELECT will not be defined])
  1862. else
  1863. select_prev_IFS=$IFS; IFS=','
  1864. set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
  1865. IFS=$select_prev_IFS
  1866. shift
  1867. #
  1868. sel_qual_type_arg5=$[3]
  1869. #
  1870. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
  1871. [Define to the type of arg 1 for select.])
  1872. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
  1873. [Define to the type of args 2, 3 and 4 for select.])
  1874. AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
  1875. [Define to the function return type for select.])
  1876. #
  1877. prev_sh_opts=$-
  1878. #
  1879. case $prev_sh_opts in
  1880. *f*)
  1881. ;;
  1882. *)
  1883. set -f
  1884. ;;
  1885. esac
  1886. #
  1887. case "$sel_qual_type_arg5" in
  1888. const*)
  1889. sel_qual_arg5=const
  1890. sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
  1891. ;;
  1892. *)
  1893. sel_qual_arg5=
  1894. sel_type_arg5=$sel_qual_type_arg5
  1895. ;;
  1896. esac
  1897. #
  1898. AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
  1899. [Define to the type qualifier of arg 5 for select.])
  1900. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
  1901. [Define to the type of arg 5 for select.])
  1902. #
  1903. case $prev_sh_opts in
  1904. *f*)
  1905. ;;
  1906. *)
  1907. set +f
  1908. ;;
  1909. esac
  1910. #
  1911. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  1912. [Define to 1 if you have the select function.])
  1913. curl_cv_func_select="yes"
  1914. fi
  1915. fi
  1916. ])
  1917. dnl CURL_VERIFY_RUNTIMELIBS
  1918. dnl -------------------------------------------------
  1919. dnl Verify that the shared libs found so far can be used when running
  1920. dnl programs, since otherwise the situation will create odd configure errors
  1921. dnl that are misleading people.
  1922. dnl
  1923. dnl Make sure this test is run BEFORE the first test in the script that
  1924. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  1925. dnl macro. It must also run AFTER all lib-checking macros are complete.
  1926. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  1927. dnl this test is of course not sensible if we are cross-compiling!
  1928. if test "x$cross_compiling" != xyes; then
  1929. dnl just run a program to verify that the libs checked for previous to this
  1930. dnl point also is available run-time!
  1931. AC_MSG_CHECKING([run-time libs availability])
  1932. CURL_RUN_IFELSE([
  1933. int main()
  1934. {
  1935. return 0;
  1936. }
  1937. ],
  1938. AC_MSG_RESULT([fine]),
  1939. AC_MSG_RESULT([failed])
  1940. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  1941. )
  1942. dnl if this test fails, configure has already stopped
  1943. fi
  1944. ])
  1945. dnl CURL_CHECK_VARIADIC_MACROS
  1946. dnl -------------------------------------------------
  1947. dnl Check compiler support of variadic macros
  1948. AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
  1949. AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
  1950. [curl_cv_variadic_macros_c99], [
  1951. AC_COMPILE_IFELSE([
  1952. AC_LANG_PROGRAM([[
  1953. #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
  1954. #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
  1955. int fun3(int arg1, int arg2, int arg3);
  1956. int fun2(int arg1, int arg2);
  1957. int fun3(int arg1, int arg2, int arg3)
  1958. { return arg1 + arg2 + arg3; }
  1959. int fun2(int arg1, int arg2)
  1960. { return arg1 + arg2; }
  1961. ]],[[
  1962. int res3 = c99_vmacro3(1, 2, 3);
  1963. int res2 = c99_vmacro2(1, 2);
  1964. ]])
  1965. ],[
  1966. curl_cv_variadic_macros_c99="yes"
  1967. ],[
  1968. curl_cv_variadic_macros_c99="no"
  1969. ])
  1970. ])
  1971. case "$curl_cv_variadic_macros_c99" in
  1972. yes)
  1973. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
  1974. [Define to 1 if compiler supports C99 variadic macro style.])
  1975. ;;
  1976. esac
  1977. AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
  1978. [curl_cv_variadic_macros_gcc], [
  1979. AC_COMPILE_IFELSE([
  1980. AC_LANG_PROGRAM([[
  1981. #define gcc_vmacro3(first, args...) fun3(first, args)
  1982. #define gcc_vmacro2(first, args...) fun2(first, args)
  1983. int fun3(int arg1, int arg2, int arg3);
  1984. int fun2(int arg1, int arg2);
  1985. int fun3(int arg1, int arg2, int arg3)
  1986. { return arg1 + arg2 + arg3; }
  1987. int fun2(int arg1, int arg2)
  1988. { return arg1 + arg2; }
  1989. ]],[[
  1990. int res3 = gcc_vmacro3(1, 2, 3);
  1991. int res2 = gcc_vmacro2(1, 2);
  1992. ]])
  1993. ],[
  1994. curl_cv_variadic_macros_gcc="yes"
  1995. ],[
  1996. curl_cv_variadic_macros_gcc="no"
  1997. ])
  1998. ])
  1999. case "$curl_cv_variadic_macros_gcc" in
  2000. yes)
  2001. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
  2002. [Define to 1 if compiler supports old gcc variadic macro style.])
  2003. ;;
  2004. esac
  2005. ])
  2006. dnl CURL_CHECK_CA_BUNDLE
  2007. dnl -------------------------------------------------
  2008. dnl Check if a default ca-bundle should be used
  2009. dnl
  2010. dnl regarding the paths this will scan:
  2011. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  2012. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  2013. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  2014. dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD
  2015. dnl /etc/ssl/cert.pem OpenBSD, FreeBSD (symlink)
  2016. dnl /etc/ssl/certs/ (ca path) SUSE
  2017. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  2018. AC_MSG_CHECKING([default CA cert bundle/path])
  2019. AC_ARG_WITH(ca-bundle,
  2020. AC_HELP_STRING([--with-ca-bundle=FILE],
  2021. [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
  2022. AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  2023. [
  2024. want_ca="$withval"
  2025. if test "x$want_ca" = "xyes"; then
  2026. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  2027. fi
  2028. ],
  2029. [ want_ca="unset" ])
  2030. AC_ARG_WITH(ca-path,
  2031. AC_HELP_STRING([--with-ca-path=DIRECTORY],
  2032. [Path to a directory containing CA certificates stored individually, with \
  2033. their filenames in a hash format. This option can be used with OpenSSL, \
  2034. GnuTLS and PolarSSL backends. Refer to OpenSSL c_rehash for details. \
  2035. (example: /etc/certificates)])
  2036. AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  2037. [
  2038. want_capath="$withval"
  2039. if test "x$want_capath" = "xyes"; then
  2040. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  2041. fi
  2042. ],
  2043. [ want_capath="unset"])
  2044. ca_warning=" (warning: certs not found)"
  2045. capath_warning=" (warning: certs not found)"
  2046. check_capath=""
  2047. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  2048. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2049. dnl both given
  2050. ca="$want_ca"
  2051. capath="$want_capath"
  2052. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  2053. dnl --with-ca-bundle given
  2054. ca="$want_ca"
  2055. capath="no"
  2056. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2057. dnl --with-ca-path given
  2058. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$POLARSSL_ENABLED" != "x1"; then
  2059. AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or PolarSSL])
  2060. fi
  2061. capath="$want_capath"
  2062. ca="no"
  2063. else
  2064. dnl first try autodetecting a CA bundle , then a CA path
  2065. dnl both autodetections can be skipped by --without-ca-*
  2066. ca="no"
  2067. capath="no"
  2068. if test "x$cross_compiling" != "xyes"; then
  2069. dnl NOT cross-compiling and...
  2070. dnl neither of the --with-ca-* options are provided
  2071. if test "x$want_ca" = "xunset"; then
  2072. dnl the path we previously would have installed the curl ca bundle
  2073. dnl to, and thus we now check for an already existing cert in that
  2074. dnl place in case we find no other
  2075. if test "x$prefix" != xNONE; then
  2076. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  2077. else
  2078. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  2079. fi
  2080. for a in /etc/ssl/certs/ca-certificates.crt \
  2081. /etc/pki/tls/certs/ca-bundle.crt \
  2082. /usr/share/ssl/certs/ca-bundle.crt \
  2083. /usr/local/share/certs/ca-root-nss.crt \
  2084. /etc/ssl/cert.pem \
  2085. "$cac"; do
  2086. if test -f "$a"; then
  2087. ca="$a"
  2088. break
  2089. fi
  2090. done
  2091. fi
  2092. if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
  2093. "x$OPENSSL_ENABLED" = "x1"; then
  2094. check_capath="/etc/ssl/certs/"
  2095. fi
  2096. else
  2097. dnl no option given and cross-compiling
  2098. AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
  2099. fi
  2100. fi
  2101. if test "x$ca" = "xno" || test -f "$ca"; then
  2102. ca_warning=""
  2103. fi
  2104. if test "x$capath" != "xno"; then
  2105. check_capath="$capath"
  2106. fi
  2107. if test ! -z "$check_capath"; then
  2108. for a in "$check_capath"; do
  2109. 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
  2110. if test "x$capath" = "xno"; then
  2111. capath="$a"
  2112. fi
  2113. capath_warning=""
  2114. break
  2115. fi
  2116. done
  2117. fi
  2118. if test "x$capath" = "xno"; then
  2119. capath_warning=""
  2120. fi
  2121. if test "x$ca" != "xno"; then
  2122. CURL_CA_BUNDLE='"'$ca'"'
  2123. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  2124. AC_SUBST(CURL_CA_BUNDLE)
  2125. AC_MSG_RESULT([$ca])
  2126. fi
  2127. if test "x$capath" != "xno"; then
  2128. CURL_CA_PATH="\"$capath\""
  2129. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  2130. AC_MSG_RESULT([$capath (capath)])
  2131. fi
  2132. if test "x$ca" = "xno" && test "x$capath" = "xno"; then
  2133. AC_MSG_RESULT([no])
  2134. fi
  2135. AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
  2136. AC_ARG_WITH(ca-fallback,
  2137. AC_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
  2138. AC_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
  2139. [
  2140. if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
  2141. AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
  2142. fi
  2143. ],
  2144. [ with_ca_fallback="no"])
  2145. AC_MSG_RESULT([$with_ca_fallback])
  2146. if test "x$with_ca_fallback" = "xyes"; then
  2147. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
  2148. AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
  2149. fi
  2150. AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
  2151. fi
  2152. ])
  2153. dnl CURL_CHECK_WIN32_LARGEFILE
  2154. dnl -------------------------------------------------
  2155. dnl Check if curl's WIN32 large file will be used
  2156. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  2157. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  2158. AC_MSG_CHECKING([whether build target supports WIN32 file API])
  2159. curl_win32_file_api="no"
  2160. if test "$curl_cv_header_windows_h" = "yes"; then
  2161. if test x"$enable_largefile" != "xno"; then
  2162. AC_COMPILE_IFELSE([
  2163. AC_LANG_PROGRAM([[
  2164. ]],[[
  2165. #if !defined(_WIN32_WCE) && \
  2166. (defined(__MINGW32__) || \
  2167. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
  2168. int dummy=1;
  2169. #else
  2170. WIN32 large file API not supported.
  2171. #endif
  2172. ]])
  2173. ],[
  2174. curl_win32_file_api="win32_large_files"
  2175. ])
  2176. fi
  2177. if test "$curl_win32_file_api" = "no"; then
  2178. AC_COMPILE_IFELSE([
  2179. AC_LANG_PROGRAM([[
  2180. ]],[[
  2181. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  2182. int dummy=1;
  2183. #else
  2184. WIN32 small file API not supported.
  2185. #endif
  2186. ]])
  2187. ],[
  2188. curl_win32_file_api="win32_small_files"
  2189. ])
  2190. fi
  2191. fi
  2192. case "$curl_win32_file_api" in
  2193. win32_large_files)
  2194. AC_MSG_RESULT([yes (large file enabled)])
  2195. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  2196. [Define to 1 if you are building a Windows target with large file support.])
  2197. ;;
  2198. win32_small_files)
  2199. AC_MSG_RESULT([yes (large file disabled)])
  2200. AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
  2201. [Define to 1 if you are building a Windows target without large file support.])
  2202. ;;
  2203. *)
  2204. AC_MSG_RESULT([no])
  2205. ;;
  2206. esac
  2207. ])
  2208. dnl CURL_EXPORT_PCDIR ($pcdir)
  2209. dnl ------------------------
  2210. dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
  2211. dnl
  2212. dnl we need this macro since pkg-config distinguishes among empty and unset
  2213. dnl variable while checking PKG_CONFIG_LIBDIR
  2214. dnl
  2215. AC_DEFUN([CURL_EXPORT_PCDIR], [
  2216. if test -n "$1"; then
  2217. PKG_CONFIG_LIBDIR="$1"
  2218. export PKG_CONFIG_LIBDIR
  2219. fi
  2220. ])
  2221. dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
  2222. dnl ------------------------
  2223. dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
  2224. dnl path to it, or 'no' if not found/present.
  2225. dnl
  2226. dnl If pkg-config is present, check that it has info about the $module or
  2227. dnl return "no" anyway!
  2228. dnl
  2229. dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
  2230. dnl
  2231. AC_DEFUN([CURL_CHECK_PKGCONFIG], [
  2232. if test -n "$PKG_CONFIG"; then
  2233. PKGCONFIG="$PKG_CONFIG"
  2234. else
  2235. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
  2236. [$PATH:/usr/bin:/usr/local/bin])
  2237. fi
  2238. if test "x$PKGCONFIG" != "xno"; then
  2239. AC_MSG_CHECKING([for $1 options with pkg-config])
  2240. dnl ask pkg-config about $1
  2241. itexists=`CURL_EXPORT_PCDIR([$2]) dnl
  2242. $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
  2243. if test -z "$itexists"; then
  2244. dnl pkg-config does not have info about the given module! set the
  2245. dnl variable to 'no'
  2246. PKGCONFIG="no"
  2247. AC_MSG_RESULT([no])
  2248. else
  2249. AC_MSG_RESULT([found])
  2250. fi
  2251. fi
  2252. ])
  2253. dnl CURL_GENERATE_CONFIGUREHELP_PM
  2254. dnl -------------------------------------------------
  2255. dnl Generate test harness configurehelp.pm module, defining and
  2256. dnl initializing some perl variables with values which are known
  2257. dnl when the configure script runs. For portability reasons, test
  2258. dnl harness needs information on how to run the C preprocessor.
  2259. AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
  2260. AC_REQUIRE([AC_PROG_CPP])dnl
  2261. tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
  2262. if test -z "$tmp_cpp"; then
  2263. tmp_cpp='cpp'
  2264. fi
  2265. cat >./tests/configurehelp.pm <<_EOF
  2266. [@%:@] This is a generated file. Do not edit.
  2267. package configurehelp;
  2268. use strict;
  2269. use warnings;
  2270. use Exporter;
  2271. use vars qw(
  2272. @ISA
  2273. @EXPORT_OK
  2274. \$Cpreprocessor
  2275. );
  2276. @ISA = qw(Exporter);
  2277. @EXPORT_OK = qw(
  2278. \$Cpreprocessor
  2279. );
  2280. \$Cpreprocessor = '$tmp_cpp';
  2281. 1;
  2282. _EOF
  2283. ])
  2284. dnl CURL_CPP_P
  2285. dnl
  2286. dnl Check if $cpp -P should be used for extract define values due to gcc 5
  2287. dnl splitting up strings and defines between line outputs. gcc by default
  2288. dnl (without -P) will show TEST EINVAL TEST as
  2289. dnl
  2290. dnl # 13 "conftest.c"
  2291. dnl TEST
  2292. dnl # 13 "conftest.c" 3 4
  2293. dnl 22
  2294. dnl # 13 "conftest.c"
  2295. dnl TEST
  2296. AC_DEFUN([CURL_CPP_P], [
  2297. AC_MSG_CHECKING([if cpp -P is needed])
  2298. AC_EGREP_CPP([TEST.*TEST], [
  2299. #include <errno.h>
  2300. TEST EINVAL TEST
  2301. ], [cpp=no], [cpp=yes])
  2302. AC_MSG_RESULT([$cpp])
  2303. dnl we need cpp -P so check if it works then
  2304. if test "x$cpp" = "xyes"; then
  2305. AC_MSG_CHECKING([if cpp -P works])
  2306. OLDCPPFLAGS=$CPPFLAGS
  2307. CPPFLAGS="$CPPFLAGS -P"
  2308. AC_EGREP_CPP([TEST.*TEST], [
  2309. #include <errno.h>
  2310. TEST EINVAL TEST
  2311. ], [cpp_p=yes], [cpp_p=no])
  2312. AC_MSG_RESULT([$cpp_p])
  2313. if test "x$cpp_p" = "xno"; then
  2314. AC_MSG_WARN([failed to figure out cpp -P alternative])
  2315. # without -P
  2316. CPPPFLAG=""
  2317. else
  2318. # with -P
  2319. CPPPFLAG="-P"
  2320. fi
  2321. dnl restore CPPFLAGS
  2322. CPPFLAGS=$OLDCPPFLAGS
  2323. else
  2324. # without -P
  2325. CPPPFLAG=""
  2326. fi
  2327. ])
  2328. dnl CURL_MAC_CFLAGS
  2329. dnl
  2330. dnl Check if -mmacosx-version-min, -miphoneos-version-min or any
  2331. dnl similar are set manually, otherwise do. And set
  2332. dnl -Werror=partial-availability.
  2333. dnl
  2334. AC_DEFUN([CURL_MAC_CFLAGS], [
  2335. tst_cflags="no"
  2336. case $host_os in
  2337. darwin*)
  2338. tst_cflags="yes"
  2339. ;;
  2340. esac
  2341. AC_MSG_CHECKING([for good-to-use Mac CFLAGS])
  2342. AC_MSG_RESULT([$tst_cflags]);
  2343. if test "$tst_cflags" = "yes"; then
  2344. AC_MSG_CHECKING([for *version-min in CFLAGS])
  2345. min=""
  2346. if test -z "$(echo $CFLAGS | grep m.*os.*-version-min)"; then
  2347. min="-mmacosx-version-min=10.8"
  2348. CFLAGS="$CFLAGS $min"
  2349. fi
  2350. if test -z "$min"; then
  2351. AC_MSG_RESULT([set by user])
  2352. else
  2353. AC_MSG_RESULT([$min set])
  2354. fi
  2355. old_CFLAGS=$CFLAGS
  2356. CFLAGS="$CFLAGS -Werror=partial-availability"
  2357. AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
  2358. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  2359. [AC_MSG_RESULT([yes])],
  2360. [AC_MSG_RESULT([no])
  2361. CFLAGS=$old_CFLAGS])
  2362. fi
  2363. ])
  2364. dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
  2365. dnl
  2366. dnl Check to see if the compiler supports __builtin_available. This built-in
  2367. dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
  2368. dnl the time this macro was written, the function was not yet documented. Its
  2369. dnl purpose is to return true if the code is running under a certain OS version
  2370. dnl or later.
  2371. AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
  2372. AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
  2373. AC_COMPILE_IFELSE([
  2374. AC_LANG_PROGRAM([[
  2375. #include <stdlib.h>
  2376. ]],[[
  2377. if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
  2378. ]])
  2379. ],[
  2380. AC_MSG_RESULT([yes])
  2381. AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
  2382. [Define to 1 if you have the __builtin_available function.])
  2383. ],[
  2384. AC_MSG_RESULT([no])
  2385. ])
  2386. ])