acinclude.m4 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2020, 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_PROTO_BSDSOCKET_H
  974. #include <proto/bsdsocket.h>
  975. struct Library *SocketBase = NULL;
  976. #endif
  977. #ifdef HAVE_SYS_TYPES_H
  978. #include <sys/types.h>
  979. #endif
  980. #ifdef HAVE_SYS_SOCKET_H
  981. #include <sys/socket.h>
  982. #endif
  983. #endif
  984. ]],[[
  985. recv(0, 0, 0, 0);
  986. ]])
  987. ],[
  988. AC_MSG_RESULT([yes])
  989. curl_cv_recv="yes"
  990. ],[
  991. AC_MSG_RESULT([no])
  992. curl_cv_recv="no"
  993. ])
  994. #
  995. if test "$curl_cv_recv" = "yes"; then
  996. AC_CACHE_CHECK([types of args and return type for recv],
  997. [curl_cv_func_recv_args], [
  998. curl_cv_func_recv_args="unknown"
  999. for recv_retv in 'int' 'ssize_t'; do
  1000. for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1001. for recv_arg2 in 'char *' 'void *'; do
  1002. for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1003. for recv_arg4 in 'int' 'unsigned int'; do
  1004. if test "$curl_cv_func_recv_args" = "unknown"; then
  1005. AC_COMPILE_IFELSE([
  1006. AC_LANG_PROGRAM([[
  1007. #undef inline
  1008. #ifdef HAVE_WINDOWS_H
  1009. #ifndef WIN32_LEAN_AND_MEAN
  1010. #define WIN32_LEAN_AND_MEAN
  1011. #endif
  1012. #include <windows.h>
  1013. #ifdef HAVE_WINSOCK2_H
  1014. #include <winsock2.h>
  1015. #else
  1016. #ifdef HAVE_WINSOCK_H
  1017. #include <winsock.h>
  1018. #endif
  1019. #endif
  1020. #define RECVCALLCONV PASCAL
  1021. #else
  1022. #ifdef HAVE_PROTO_BSDSOCKET_H
  1023. #include <proto/bsdsocket.h>
  1024. struct Library *SocketBase = NULL;
  1025. #endif
  1026. #ifdef HAVE_SYS_TYPES_H
  1027. #include <sys/types.h>
  1028. #endif
  1029. #ifdef HAVE_SYS_SOCKET_H
  1030. #include <sys/socket.h>
  1031. #endif
  1032. #define RECVCALLCONV
  1033. #endif
  1034. #ifndef HAVE_PROTO_BSDSOCKET_H
  1035. extern $recv_retv RECVCALLCONV
  1036. recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
  1037. #endif
  1038. ]],[[
  1039. $recv_arg1 s=0;
  1040. $recv_arg2 buf=0;
  1041. $recv_arg3 len=0;
  1042. $recv_arg4 flags=0;
  1043. $recv_retv res = recv(s, buf, len, flags);
  1044. ]])
  1045. ],[
  1046. curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
  1047. ])
  1048. fi
  1049. done
  1050. done
  1051. done
  1052. done
  1053. done
  1054. ]) # AC-CACHE-CHECK
  1055. if test "$curl_cv_func_recv_args" = "unknown"; then
  1056. AC_MSG_ERROR([Cannot find proper types to use for recv args])
  1057. else
  1058. recv_prev_IFS=$IFS; IFS=','
  1059. set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
  1060. IFS=$recv_prev_IFS
  1061. shift
  1062. #
  1063. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
  1064. [Define to the type of arg 1 for recv.])
  1065. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
  1066. [Define to the type of arg 2 for recv.])
  1067. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
  1068. [Define to the type of arg 3 for recv.])
  1069. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
  1070. [Define to the type of arg 4 for recv.])
  1071. AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
  1072. [Define to the function return type for recv.])
  1073. #
  1074. AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
  1075. [Define to 1 if you have the recv function.])
  1076. curl_cv_func_recv="yes"
  1077. fi
  1078. else
  1079. AC_MSG_ERROR([Unable to link function recv])
  1080. fi
  1081. ])
  1082. dnl CURL_CHECK_FUNC_SEND
  1083. dnl -------------------------------------------------
  1084. dnl Test if the socket send() function is available,
  1085. dnl and check its return type and the types of its
  1086. dnl arguments. If the function succeeds HAVE_SEND
  1087. dnl will be defined, defining the types of the arguments
  1088. dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
  1089. dnl and SEND_TYPE_ARG4, defining the type of the function
  1090. dnl return value in SEND_TYPE_RETV, and also defining the
  1091. dnl type qualifier of second argument in SEND_QUAL_ARG2.
  1092. AC_DEFUN([CURL_CHECK_FUNC_SEND], [
  1093. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1094. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1095. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1096. #
  1097. AC_MSG_CHECKING([for send])
  1098. AC_LINK_IFELSE([
  1099. AC_LANG_PROGRAM([[
  1100. #undef inline
  1101. #ifdef HAVE_WINDOWS_H
  1102. #ifndef WIN32_LEAN_AND_MEAN
  1103. #define WIN32_LEAN_AND_MEAN
  1104. #endif
  1105. #include <windows.h>
  1106. #ifdef HAVE_WINSOCK2_H
  1107. #include <winsock2.h>
  1108. #else
  1109. #ifdef HAVE_WINSOCK_H
  1110. #include <winsock.h>
  1111. #endif
  1112. #endif
  1113. #else
  1114. #ifdef HAVE_PROTO_BSDSOCKET_H
  1115. #include <proto/bsdsocket.h>
  1116. struct Library *SocketBase = NULL;
  1117. #endif
  1118. #ifdef HAVE_SYS_TYPES_H
  1119. #include <sys/types.h>
  1120. #endif
  1121. #ifdef HAVE_SYS_SOCKET_H
  1122. #include <sys/socket.h>
  1123. #endif
  1124. #endif
  1125. ]],[[
  1126. send(0, 0, 0, 0);
  1127. ]])
  1128. ],[
  1129. AC_MSG_RESULT([yes])
  1130. curl_cv_send="yes"
  1131. ],[
  1132. AC_MSG_RESULT([no])
  1133. curl_cv_send="no"
  1134. ])
  1135. #
  1136. if test "$curl_cv_send" = "yes"; then
  1137. AC_CACHE_CHECK([types of args and return type for send],
  1138. [curl_cv_func_send_args], [
  1139. curl_cv_func_send_args="unknown"
  1140. for send_retv in 'int' 'ssize_t'; do
  1141. for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1142. for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
  1143. for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1144. for send_arg4 in 'int' 'unsigned int'; do
  1145. if test "$curl_cv_func_send_args" = "unknown"; then
  1146. AC_COMPILE_IFELSE([
  1147. AC_LANG_PROGRAM([[
  1148. #undef inline
  1149. #ifdef HAVE_WINDOWS_H
  1150. #ifndef WIN32_LEAN_AND_MEAN
  1151. #define WIN32_LEAN_AND_MEAN
  1152. #endif
  1153. #include <windows.h>
  1154. #ifdef HAVE_WINSOCK2_H
  1155. #include <winsock2.h>
  1156. #else
  1157. #ifdef HAVE_WINSOCK_H
  1158. #include <winsock.h>
  1159. #endif
  1160. #endif
  1161. #define SENDCALLCONV PASCAL
  1162. #else
  1163. #ifdef HAVE_PROTO_BSDSOCKET_H
  1164. #include <proto/bsdsocket.h>
  1165. struct Library *SocketBase = NULL;
  1166. #endif
  1167. #ifdef HAVE_SYS_TYPES_H
  1168. #include <sys/types.h>
  1169. #endif
  1170. #ifdef HAVE_SYS_SOCKET_H
  1171. #include <sys/socket.h>
  1172. #endif
  1173. #define SENDCALLCONV
  1174. #endif
  1175. #ifndef HAVE_PROTO_BSDSOCKET_H
  1176. extern $send_retv SENDCALLCONV
  1177. send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
  1178. #endif
  1179. ]],[[
  1180. $send_arg1 s=0;
  1181. $send_arg3 len=0;
  1182. $send_arg4 flags=0;
  1183. $send_retv res = send(s, 0, len, flags);
  1184. ]])
  1185. ],[
  1186. curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
  1187. ])
  1188. fi
  1189. done
  1190. done
  1191. done
  1192. done
  1193. done
  1194. ]) # AC-CACHE-CHECK
  1195. if test "$curl_cv_func_send_args" = "unknown"; then
  1196. AC_MSG_ERROR([Cannot find proper types to use for send args])
  1197. else
  1198. send_prev_IFS=$IFS; IFS=','
  1199. set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
  1200. IFS=$send_prev_IFS
  1201. shift
  1202. #
  1203. send_qual_type_arg2=$[2]
  1204. #
  1205. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
  1206. [Define to the type of arg 1 for send.])
  1207. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
  1208. [Define to the type of arg 3 for send.])
  1209. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
  1210. [Define to the type of arg 4 for send.])
  1211. AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
  1212. [Define to the function return type for send.])
  1213. #
  1214. prev_sh_opts=$-
  1215. #
  1216. case $prev_sh_opts in
  1217. *f*)
  1218. ;;
  1219. *)
  1220. set -f
  1221. ;;
  1222. esac
  1223. #
  1224. case "$send_qual_type_arg2" in
  1225. const*)
  1226. send_qual_arg2=const
  1227. send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
  1228. ;;
  1229. *)
  1230. send_qual_arg2=
  1231. send_type_arg2=$send_qual_type_arg2
  1232. ;;
  1233. esac
  1234. #
  1235. AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
  1236. [Define to the type qualifier of arg 2 for send.])
  1237. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
  1238. [Define to the type of arg 2 for send.])
  1239. #
  1240. case $prev_sh_opts in
  1241. *f*)
  1242. ;;
  1243. *)
  1244. set +f
  1245. ;;
  1246. esac
  1247. #
  1248. AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
  1249. [Define to 1 if you have the send function.])
  1250. curl_cv_func_send="yes"
  1251. fi
  1252. else
  1253. AC_MSG_ERROR([Unable to link function send])
  1254. fi
  1255. ])
  1256. dnl CURL_CHECK_MSG_NOSIGNAL
  1257. dnl -------------------------------------------------
  1258. dnl Check for MSG_NOSIGNAL
  1259. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  1260. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1261. AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
  1262. AC_COMPILE_IFELSE([
  1263. AC_LANG_PROGRAM([[
  1264. #undef inline
  1265. #ifdef HAVE_WINDOWS_H
  1266. #ifndef WIN32_LEAN_AND_MEAN
  1267. #define WIN32_LEAN_AND_MEAN
  1268. #endif
  1269. #include <windows.h>
  1270. #ifdef HAVE_WINSOCK2_H
  1271. #include <winsock2.h>
  1272. #else
  1273. #ifdef HAVE_WINSOCK_H
  1274. #include <winsock.h>
  1275. #endif
  1276. #endif
  1277. #else
  1278. #ifdef HAVE_PROTO_BSDSOCKET_H
  1279. #include <proto/bsdsocket.h>
  1280. struct Library *SocketBase = NULL;
  1281. #endif
  1282. #ifdef HAVE_SYS_TYPES_H
  1283. #include <sys/types.h>
  1284. #endif
  1285. #ifdef HAVE_SYS_SOCKET_H
  1286. #include <sys/socket.h>
  1287. #endif
  1288. #endif
  1289. ]],[[
  1290. int flag=MSG_NOSIGNAL;
  1291. ]])
  1292. ],[
  1293. curl_cv_msg_nosignal="yes"
  1294. ],[
  1295. curl_cv_msg_nosignal="no"
  1296. ])
  1297. ])
  1298. case "$curl_cv_msg_nosignal" in
  1299. yes)
  1300. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  1301. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  1302. ;;
  1303. esac
  1304. ])
  1305. dnl CURL_CHECK_STRUCT_TIMEVAL
  1306. dnl -------------------------------------------------
  1307. dnl Check for timeval struct
  1308. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  1309. AC_REQUIRE([AC_HEADER_TIME])dnl
  1310. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1311. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1312. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
  1313. AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
  1314. AC_COMPILE_IFELSE([
  1315. AC_LANG_PROGRAM([[
  1316. #undef inline
  1317. #ifdef HAVE_WINDOWS_H
  1318. #ifndef WIN32_LEAN_AND_MEAN
  1319. #define WIN32_LEAN_AND_MEAN
  1320. #endif
  1321. #include <windows.h>
  1322. #ifdef HAVE_WINSOCK2_H
  1323. #include <winsock2.h>
  1324. #else
  1325. #ifdef HAVE_WINSOCK_H
  1326. #include <winsock.h>
  1327. #endif
  1328. #endif
  1329. #endif
  1330. #ifdef HAVE_SYS_TYPES_H
  1331. #include <sys/types.h>
  1332. #endif
  1333. #ifdef HAVE_SYS_TIME_H
  1334. #include <sys/time.h>
  1335. #ifdef TIME_WITH_SYS_TIME
  1336. #include <time.h>
  1337. #endif
  1338. #else
  1339. #ifdef HAVE_TIME_H
  1340. #include <time.h>
  1341. #endif
  1342. #endif
  1343. #ifdef HAVE_SYS_SOCKET_H
  1344. #include <sys/socket.h>
  1345. #endif
  1346. ]],[[
  1347. struct timeval ts;
  1348. ts.tv_sec = 0;
  1349. ts.tv_usec = 0;
  1350. ]])
  1351. ],[
  1352. curl_cv_struct_timeval="yes"
  1353. ],[
  1354. curl_cv_struct_timeval="no"
  1355. ])
  1356. ])
  1357. case "$curl_cv_struct_timeval" in
  1358. yes)
  1359. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  1360. [Define to 1 if you have the timeval struct.])
  1361. ;;
  1362. esac
  1363. ])
  1364. dnl TYPE_SIG_ATOMIC_T
  1365. dnl -------------------------------------------------
  1366. dnl Check if the sig_atomic_t type is available, and
  1367. dnl verify if it is already defined as volatile.
  1368. AC_DEFUN([TYPE_SIG_ATOMIC_T], [
  1369. AC_CHECK_HEADERS(signal.h)
  1370. AC_CHECK_TYPE([sig_atomic_t],[
  1371. AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
  1372. [Define to 1 if sig_atomic_t is an available typedef.])
  1373. ], ,[
  1374. #ifdef HAVE_SIGNAL_H
  1375. #include <signal.h>
  1376. #endif
  1377. ])
  1378. case "$ac_cv_type_sig_atomic_t" in
  1379. yes)
  1380. #
  1381. AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
  1382. AC_LINK_IFELSE([
  1383. AC_LANG_PROGRAM([[
  1384. #ifdef HAVE_SIGNAL_H
  1385. #include <signal.h>
  1386. #endif
  1387. ]],[[
  1388. static volatile sig_atomic_t dummy = 0;
  1389. ]])
  1390. ],[
  1391. AC_MSG_RESULT([no])
  1392. curl_cv_sig_atomic_t_volatile="no"
  1393. ],[
  1394. AC_MSG_RESULT([yes])
  1395. curl_cv_sig_atomic_t_volatile="yes"
  1396. ])
  1397. #
  1398. if test "$curl_cv_sig_atomic_t_volatile" = "yes"; then
  1399. AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
  1400. [Define to 1 if sig_atomic_t is already defined as volatile.])
  1401. fi
  1402. ;;
  1403. esac
  1404. ])
  1405. dnl TYPE_IN_ADDR_T
  1406. dnl -------------------------------------------------
  1407. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  1408. dnl and a few other things.
  1409. AC_DEFUN([TYPE_IN_ADDR_T], [
  1410. AC_CHECK_TYPE([in_addr_t], ,[
  1411. dnl in_addr_t not available
  1412. AC_CACHE_CHECK([for in_addr_t equivalent],
  1413. [curl_cv_in_addr_t_equiv], [
  1414. curl_cv_in_addr_t_equiv="unknown"
  1415. for t in "unsigned long" int size_t unsigned long; do
  1416. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  1417. AC_LINK_IFELSE([
  1418. AC_LANG_PROGRAM([[
  1419. #undef inline
  1420. #ifdef HAVE_WINDOWS_H
  1421. #ifndef WIN32_LEAN_AND_MEAN
  1422. #define WIN32_LEAN_AND_MEAN
  1423. #endif
  1424. #include <windows.h>
  1425. #ifdef HAVE_WINSOCK2_H
  1426. #include <winsock2.h>
  1427. #else
  1428. #ifdef HAVE_WINSOCK_H
  1429. #include <winsock.h>
  1430. #endif
  1431. #endif
  1432. #else
  1433. #ifdef HAVE_SYS_TYPES_H
  1434. #include <sys/types.h>
  1435. #endif
  1436. #ifdef HAVE_SYS_SOCKET_H
  1437. #include <sys/socket.h>
  1438. #endif
  1439. #ifdef HAVE_NETINET_IN_H
  1440. #include <netinet/in.h>
  1441. #endif
  1442. #ifdef HAVE_ARPA_INET_H
  1443. #include <arpa/inet.h>
  1444. #endif
  1445. #endif
  1446. ]],[[
  1447. $t data = inet_addr ("1.2.3.4");
  1448. ]])
  1449. ],[
  1450. curl_cv_in_addr_t_equiv="$t"
  1451. ])
  1452. fi
  1453. done
  1454. ])
  1455. case "$curl_cv_in_addr_t_equiv" in
  1456. unknown)
  1457. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  1458. ;;
  1459. *)
  1460. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  1461. [Type to use in place of in_addr_t when system does not provide it.])
  1462. ;;
  1463. esac
  1464. ],[
  1465. #undef inline
  1466. #ifdef HAVE_WINDOWS_H
  1467. #ifndef WIN32_LEAN_AND_MEAN
  1468. #define WIN32_LEAN_AND_MEAN
  1469. #endif
  1470. #include <windows.h>
  1471. #ifdef HAVE_WINSOCK2_H
  1472. #include <winsock2.h>
  1473. #else
  1474. #ifdef HAVE_WINSOCK_H
  1475. #include <winsock.h>
  1476. #endif
  1477. #endif
  1478. #else
  1479. #ifdef HAVE_SYS_TYPES_H
  1480. #include <sys/types.h>
  1481. #endif
  1482. #ifdef HAVE_SYS_SOCKET_H
  1483. #include <sys/socket.h>
  1484. #endif
  1485. #ifdef HAVE_NETINET_IN_H
  1486. #include <netinet/in.h>
  1487. #endif
  1488. #ifdef HAVE_ARPA_INET_H
  1489. #include <arpa/inet.h>
  1490. #endif
  1491. #endif
  1492. ])
  1493. ])
  1494. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  1495. dnl -------------------------------------------------
  1496. dnl Check if monotonic clock_gettime is available.
  1497. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  1498. AC_REQUIRE([AC_HEADER_TIME])dnl
  1499. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
  1500. AC_MSG_CHECKING([for monotonic clock_gettime])
  1501. #
  1502. if test "x$dontwant_rt" = "xno" ; then
  1503. AC_COMPILE_IFELSE([
  1504. AC_LANG_PROGRAM([[
  1505. #ifdef HAVE_SYS_TYPES_H
  1506. #include <sys/types.h>
  1507. #endif
  1508. #ifdef HAVE_SYS_TIME_H
  1509. #include <sys/time.h>
  1510. #ifdef TIME_WITH_SYS_TIME
  1511. #include <time.h>
  1512. #endif
  1513. #else
  1514. #ifdef HAVE_TIME_H
  1515. #include <time.h>
  1516. #endif
  1517. #endif
  1518. ]],[[
  1519. struct timespec ts;
  1520. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1521. ]])
  1522. ],[
  1523. AC_MSG_RESULT([yes])
  1524. curl_func_clock_gettime="yes"
  1525. ],[
  1526. AC_MSG_RESULT([no])
  1527. curl_func_clock_gettime="no"
  1528. ])
  1529. fi
  1530. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  1531. dnl until library linking and run-time checks for clock_gettime succeed.
  1532. ])
  1533. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  1534. dnl -------------------------------------------------
  1535. dnl If monotonic clock_gettime is available then,
  1536. dnl check and prepended to LIBS any needed libraries.
  1537. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  1538. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  1539. #
  1540. if test "$curl_func_clock_gettime" = "yes"; then
  1541. #
  1542. AC_MSG_CHECKING([for clock_gettime in libraries])
  1543. #
  1544. curl_cv_save_LIBS="$LIBS"
  1545. curl_cv_gclk_LIBS="unknown"
  1546. #
  1547. for x_xlibs in '' '-lrt' '-lposix4' ; do
  1548. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  1549. if test -z "$x_xlibs"; then
  1550. LIBS="$curl_cv_save_LIBS"
  1551. else
  1552. LIBS="$x_xlibs $curl_cv_save_LIBS"
  1553. fi
  1554. AC_LINK_IFELSE([
  1555. AC_LANG_PROGRAM([[
  1556. #ifdef HAVE_SYS_TYPES_H
  1557. #include <sys/types.h>
  1558. #endif
  1559. #ifdef HAVE_SYS_TIME_H
  1560. #include <sys/time.h>
  1561. #ifdef TIME_WITH_SYS_TIME
  1562. #include <time.h>
  1563. #endif
  1564. #else
  1565. #ifdef HAVE_TIME_H
  1566. #include <time.h>
  1567. #endif
  1568. #endif
  1569. ]],[[
  1570. struct timespec ts;
  1571. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1572. ]])
  1573. ],[
  1574. curl_cv_gclk_LIBS="$x_xlibs"
  1575. ])
  1576. fi
  1577. done
  1578. #
  1579. LIBS="$curl_cv_save_LIBS"
  1580. #
  1581. case X-"$curl_cv_gclk_LIBS" in
  1582. X-unknown)
  1583. AC_MSG_RESULT([cannot find clock_gettime])
  1584. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1585. curl_func_clock_gettime="no"
  1586. ;;
  1587. X-)
  1588. AC_MSG_RESULT([no additional lib required])
  1589. curl_func_clock_gettime="yes"
  1590. ;;
  1591. *)
  1592. if test -z "$curl_cv_save_LIBS"; then
  1593. LIBS="$curl_cv_gclk_LIBS"
  1594. else
  1595. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  1596. fi
  1597. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  1598. curl_func_clock_gettime="yes"
  1599. ;;
  1600. esac
  1601. #
  1602. dnl only do runtime verification when not cross-compiling
  1603. if test "x$cross_compiling" != "xyes" &&
  1604. test "$curl_func_clock_gettime" = "yes"; then
  1605. AC_MSG_CHECKING([if monotonic clock_gettime works])
  1606. CURL_RUN_IFELSE([
  1607. AC_LANG_PROGRAM([[
  1608. #ifdef HAVE_STDLIB_H
  1609. #include <stdlib.h>
  1610. #endif
  1611. #ifdef HAVE_SYS_TYPES_H
  1612. #include <sys/types.h>
  1613. #endif
  1614. #ifdef HAVE_SYS_TIME_H
  1615. #include <sys/time.h>
  1616. #ifdef TIME_WITH_SYS_TIME
  1617. #include <time.h>
  1618. #endif
  1619. #else
  1620. #ifdef HAVE_TIME_H
  1621. #include <time.h>
  1622. #endif
  1623. #endif
  1624. ]],[[
  1625. struct timespec ts;
  1626. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  1627. exit(0);
  1628. else
  1629. exit(1);
  1630. ]])
  1631. ],[
  1632. AC_MSG_RESULT([yes])
  1633. ],[
  1634. AC_MSG_RESULT([no])
  1635. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1636. curl_func_clock_gettime="no"
  1637. LIBS="$curl_cv_save_LIBS"
  1638. ])
  1639. fi
  1640. #
  1641. case "$curl_func_clock_gettime" in
  1642. yes)
  1643. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  1644. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  1645. ;;
  1646. esac
  1647. #
  1648. fi
  1649. #
  1650. ])
  1651. dnl CURL_CHECK_LIBS_CONNECT
  1652. dnl -------------------------------------------------
  1653. dnl Verify if network connect function is already available
  1654. dnl using current libraries or if another one is required.
  1655. AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
  1656. AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
  1657. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  1658. AC_MSG_CHECKING([for connect in libraries])
  1659. tst_connect_save_LIBS="$LIBS"
  1660. tst_connect_need_LIBS="unknown"
  1661. for tst_lib in '' '-lsocket' ; do
  1662. if test "$tst_connect_need_LIBS" = "unknown"; then
  1663. LIBS="$tst_lib $tst_connect_save_LIBS"
  1664. AC_LINK_IFELSE([
  1665. AC_LANG_PROGRAM([[
  1666. $curl_includes_winsock2
  1667. $curl_includes_bsdsocket
  1668. #if !defined(HAVE_WINDOWS_H) && !defined(HAVE_PROTO_BSDSOCKET_H)
  1669. int connect(int, void*, int);
  1670. #endif
  1671. ]],[[
  1672. if(0 != connect(0, 0, 0))
  1673. return 1;
  1674. ]])
  1675. ],[
  1676. tst_connect_need_LIBS="$tst_lib"
  1677. ])
  1678. fi
  1679. done
  1680. LIBS="$tst_connect_save_LIBS"
  1681. #
  1682. case X-"$tst_connect_need_LIBS" in
  1683. X-unknown)
  1684. AC_MSG_RESULT([cannot find connect])
  1685. AC_MSG_ERROR([cannot find connect function in libraries.])
  1686. ;;
  1687. X-)
  1688. AC_MSG_RESULT([yes])
  1689. ;;
  1690. *)
  1691. AC_MSG_RESULT([$tst_connect_need_LIBS])
  1692. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  1693. ;;
  1694. esac
  1695. ])
  1696. dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
  1697. dnl -------------------------------------------------
  1698. dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
  1699. dnl symbol that can be further used in custom template configuration
  1700. dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
  1701. dnl argument for the description. Symbol definitions done with this
  1702. dnl macro are intended to be exclusively used in handcrafted *.h.in
  1703. dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
  1704. dnl prevents autoheader generation and insertion of symbol template
  1705. dnl stub and definition into the first configuration header file. Do
  1706. dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
  1707. dnl one serves different functional needs.
  1708. AC_DEFUN([CURL_DEFINE_UNQUOTED], [
  1709. cat >>confdefs.h <<_EOF
  1710. [@%:@define] $1 ifelse($#, 2, [$2], 1)
  1711. _EOF
  1712. ])
  1713. dnl CURL_CONFIGURE_PULL_SYS_POLL
  1714. dnl -------------------------------------------------
  1715. dnl The need for the sys/poll.h inclusion arises mainly to properly
  1716. dnl interface AIX systems which define macros 'events' and 'revents'.
  1717. AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
  1718. AC_REQUIRE([CURL_INCLUDES_POLL])dnl
  1719. #
  1720. tst_poll_events_macro_defined="unknown"
  1721. #
  1722. AC_COMPILE_IFELSE([
  1723. AC_LANG_PROGRAM([[
  1724. $curl_includes_poll
  1725. ]],[[
  1726. #if defined(events) || defined(revents)
  1727. return 0;
  1728. #else
  1729. force compilation error
  1730. #endif
  1731. ]])
  1732. ],[
  1733. tst_poll_events_macro_defined="yes"
  1734. ],[
  1735. tst_poll_events_macro_defined="no"
  1736. ])
  1737. #
  1738. if test "$tst_poll_events_macro_defined" = "yes"; then
  1739. if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
  1740. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
  1741. fi
  1742. fi
  1743. #
  1744. ])
  1745. dnl CURL_CHECK_FUNC_SELECT
  1746. dnl -------------------------------------------------
  1747. dnl Test if the socket select() function is available,
  1748. dnl and check its return type and the types of its
  1749. dnl arguments. If the function succeeds HAVE_SELECT
  1750. dnl will be defined, defining the types of the
  1751. dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
  1752. dnl and SELECT_TYPE_ARG5, defining the type of the
  1753. dnl function return value in SELECT_TYPE_RETV, and
  1754. dnl also defining the type qualifier of fifth argument
  1755. dnl in SELECT_QUAL_ARG5.
  1756. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  1757. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  1758. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  1759. #
  1760. AC_MSG_CHECKING([for select])
  1761. AC_LINK_IFELSE([
  1762. AC_LANG_PROGRAM([[
  1763. #undef inline
  1764. #ifdef HAVE_WINDOWS_H
  1765. #ifndef WIN32_LEAN_AND_MEAN
  1766. #define WIN32_LEAN_AND_MEAN
  1767. #endif
  1768. #include <windows.h>
  1769. #ifdef HAVE_WINSOCK2_H
  1770. #include <winsock2.h>
  1771. #else
  1772. #ifdef HAVE_WINSOCK_H
  1773. #include <winsock.h>
  1774. #endif
  1775. #endif
  1776. #endif
  1777. #ifdef HAVE_SYS_TYPES_H
  1778. #include <sys/types.h>
  1779. #endif
  1780. #ifdef HAVE_SYS_TIME_H
  1781. #include <sys/time.h>
  1782. #ifdef TIME_WITH_SYS_TIME
  1783. #include <time.h>
  1784. #endif
  1785. #else
  1786. #ifdef HAVE_TIME_H
  1787. #include <time.h>
  1788. #endif
  1789. #endif
  1790. #ifndef HAVE_WINDOWS_H
  1791. #ifdef HAVE_PROTO_BSDSOCKET_H
  1792. #include <proto/bsdsocket.h>
  1793. struct Library *SocketBase = NULL;
  1794. #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
  1795. #endif
  1796. #ifdef HAVE_SYS_SELECT_H
  1797. #include <sys/select.h>
  1798. #elif defined(HAVE_UNISTD_H)
  1799. #include <unistd.h>
  1800. #endif
  1801. #ifdef HAVE_SYS_SOCKET_H
  1802. #include <sys/socket.h>
  1803. #endif
  1804. #endif
  1805. ]],[[
  1806. select(0, 0, 0, 0, 0);
  1807. ]])
  1808. ],[
  1809. AC_MSG_RESULT([yes])
  1810. curl_cv_select="yes"
  1811. ],[
  1812. AC_MSG_RESULT([no])
  1813. curl_cv_select="no"
  1814. ])
  1815. #
  1816. if test "$curl_cv_select" = "yes"; then
  1817. AC_CACHE_CHECK([types of args and return type for select],
  1818. [curl_cv_func_select_args], [
  1819. curl_cv_func_select_args="unknown"
  1820. for sel_retv in 'int' 'ssize_t'; do
  1821. for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
  1822. for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
  1823. for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
  1824. if test "$curl_cv_func_select_args" = "unknown"; then
  1825. AC_COMPILE_IFELSE([
  1826. AC_LANG_PROGRAM([[
  1827. #undef inline
  1828. #ifdef HAVE_WINDOWS_H
  1829. #ifndef WIN32_LEAN_AND_MEAN
  1830. #define WIN32_LEAN_AND_MEAN
  1831. #endif
  1832. #include <windows.h>
  1833. #ifdef HAVE_WINSOCK2_H
  1834. #include <winsock2.h>
  1835. #else
  1836. #ifdef HAVE_WINSOCK_H
  1837. #include <winsock.h>
  1838. #endif
  1839. #endif
  1840. #define SELECTCALLCONV PASCAL
  1841. #endif
  1842. #ifdef HAVE_SYS_TYPES_H
  1843. #include <sys/types.h>
  1844. #endif
  1845. #ifdef HAVE_SYS_TIME_H
  1846. #include <sys/time.h>
  1847. #ifdef TIME_WITH_SYS_TIME
  1848. #include <time.h>
  1849. #endif
  1850. #else
  1851. #ifdef HAVE_TIME_H
  1852. #include <time.h>
  1853. #endif
  1854. #endif
  1855. #ifndef HAVE_WINDOWS_H
  1856. #ifdef HAVE_PROTO_BSDSOCKET_H
  1857. #include <proto/bsdsocket.h>
  1858. struct Library *SocketBase = NULL;
  1859. #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
  1860. #endif
  1861. #ifdef HAVE_SYS_SELECT_H
  1862. #include <sys/select.h>
  1863. #elif defined(HAVE_UNISTD_H)
  1864. #include <unistd.h>
  1865. #endif
  1866. #ifdef HAVE_SYS_SOCKET_H
  1867. #include <sys/socket.h>
  1868. #endif
  1869. #define SELECTCALLCONV
  1870. #endif
  1871. #ifndef HAVE_STRUCT_TIMEVAL
  1872. struct timeval {
  1873. long tv_sec;
  1874. long tv_usec;
  1875. };
  1876. #endif
  1877. #ifndef HAVE_PROTO_BSDSOCKET_H
  1878. extern $sel_retv SELECTCALLCONV
  1879. select($sel_arg1,
  1880. $sel_arg234,
  1881. $sel_arg234,
  1882. $sel_arg234,
  1883. $sel_arg5);
  1884. #endif
  1885. ]],[[
  1886. $sel_arg1 nfds=0;
  1887. $sel_arg234 rfds=0;
  1888. $sel_arg234 wfds=0;
  1889. $sel_arg234 efds=0;
  1890. $sel_retv res = select(nfds, rfds, wfds, efds, 0);
  1891. ]])
  1892. ],[
  1893. curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
  1894. ])
  1895. fi
  1896. done
  1897. done
  1898. done
  1899. done
  1900. ]) # AC-CACHE-CHECK
  1901. if test "$curl_cv_func_select_args" = "unknown"; then
  1902. AC_MSG_WARN([Cannot find proper types to use for select args])
  1903. AC_MSG_WARN([HAVE_SELECT will not be defined])
  1904. else
  1905. select_prev_IFS=$IFS; IFS=','
  1906. set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
  1907. IFS=$select_prev_IFS
  1908. shift
  1909. #
  1910. sel_qual_type_arg5=$[3]
  1911. #
  1912. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
  1913. [Define to the type of arg 1 for select.])
  1914. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
  1915. [Define to the type of args 2, 3 and 4 for select.])
  1916. AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
  1917. [Define to the function return type for select.])
  1918. #
  1919. prev_sh_opts=$-
  1920. #
  1921. case $prev_sh_opts in
  1922. *f*)
  1923. ;;
  1924. *)
  1925. set -f
  1926. ;;
  1927. esac
  1928. #
  1929. case "$sel_qual_type_arg5" in
  1930. const*)
  1931. sel_qual_arg5=const
  1932. sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
  1933. ;;
  1934. *)
  1935. sel_qual_arg5=
  1936. sel_type_arg5=$sel_qual_type_arg5
  1937. ;;
  1938. esac
  1939. #
  1940. AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
  1941. [Define to the type qualifier of arg 5 for select.])
  1942. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
  1943. [Define to the type of arg 5 for select.])
  1944. #
  1945. case $prev_sh_opts in
  1946. *f*)
  1947. ;;
  1948. *)
  1949. set +f
  1950. ;;
  1951. esac
  1952. #
  1953. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  1954. [Define to 1 if you have the select function.])
  1955. curl_cv_func_select="yes"
  1956. fi
  1957. fi
  1958. ])
  1959. dnl CURL_VERIFY_RUNTIMELIBS
  1960. dnl -------------------------------------------------
  1961. dnl Verify that the shared libs found so far can be used when running
  1962. dnl programs, since otherwise the situation will create odd configure errors
  1963. dnl that are misleading people.
  1964. dnl
  1965. dnl Make sure this test is run BEFORE the first test in the script that
  1966. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  1967. dnl macro. It must also run AFTER all lib-checking macros are complete.
  1968. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  1969. dnl this test is of course not sensible if we are cross-compiling!
  1970. if test "x$cross_compiling" != xyes; then
  1971. dnl just run a program to verify that the libs checked for previous to this
  1972. dnl point also is available run-time!
  1973. AC_MSG_CHECKING([run-time libs availability])
  1974. CURL_RUN_IFELSE([
  1975. int main()
  1976. {
  1977. return 0;
  1978. }
  1979. ],
  1980. AC_MSG_RESULT([fine]),
  1981. AC_MSG_RESULT([failed])
  1982. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  1983. )
  1984. dnl if this test fails, configure has already stopped
  1985. fi
  1986. ])
  1987. dnl CURL_CHECK_VARIADIC_MACROS
  1988. dnl -------------------------------------------------
  1989. dnl Check compiler support of variadic macros
  1990. AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
  1991. AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
  1992. [curl_cv_variadic_macros_c99], [
  1993. AC_COMPILE_IFELSE([
  1994. AC_LANG_PROGRAM([[
  1995. #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
  1996. #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
  1997. int fun3(int arg1, int arg2, int arg3);
  1998. int fun2(int arg1, int arg2);
  1999. int fun3(int arg1, int arg2, int arg3)
  2000. { return arg1 + arg2 + arg3; }
  2001. int fun2(int arg1, int arg2)
  2002. { return arg1 + arg2; }
  2003. ]],[[
  2004. int res3 = c99_vmacro3(1, 2, 3);
  2005. int res2 = c99_vmacro2(1, 2);
  2006. ]])
  2007. ],[
  2008. curl_cv_variadic_macros_c99="yes"
  2009. ],[
  2010. curl_cv_variadic_macros_c99="no"
  2011. ])
  2012. ])
  2013. case "$curl_cv_variadic_macros_c99" in
  2014. yes)
  2015. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
  2016. [Define to 1 if compiler supports C99 variadic macro style.])
  2017. ;;
  2018. esac
  2019. AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
  2020. [curl_cv_variadic_macros_gcc], [
  2021. AC_COMPILE_IFELSE([
  2022. AC_LANG_PROGRAM([[
  2023. #define gcc_vmacro3(first, args...) fun3(first, args)
  2024. #define gcc_vmacro2(first, args...) fun2(first, args)
  2025. int fun3(int arg1, int arg2, int arg3);
  2026. int fun2(int arg1, int arg2);
  2027. int fun3(int arg1, int arg2, int arg3)
  2028. { return arg1 + arg2 + arg3; }
  2029. int fun2(int arg1, int arg2)
  2030. { return arg1 + arg2; }
  2031. ]],[[
  2032. int res3 = gcc_vmacro3(1, 2, 3);
  2033. int res2 = gcc_vmacro2(1, 2);
  2034. ]])
  2035. ],[
  2036. curl_cv_variadic_macros_gcc="yes"
  2037. ],[
  2038. curl_cv_variadic_macros_gcc="no"
  2039. ])
  2040. ])
  2041. case "$curl_cv_variadic_macros_gcc" in
  2042. yes)
  2043. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
  2044. [Define to 1 if compiler supports old gcc variadic macro style.])
  2045. ;;
  2046. esac
  2047. ])
  2048. dnl CURL_CHECK_CA_BUNDLE
  2049. dnl -------------------------------------------------
  2050. dnl Check if a default ca-bundle should be used
  2051. dnl
  2052. dnl regarding the paths this will scan:
  2053. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  2054. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  2055. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  2056. dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD
  2057. dnl /etc/ssl/cert.pem OpenBSD, FreeBSD (symlink)
  2058. dnl /etc/ssl/certs/ (ca path) SUSE
  2059. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  2060. AC_MSG_CHECKING([default CA cert bundle/path])
  2061. AC_ARG_WITH(ca-bundle,
  2062. AC_HELP_STRING([--with-ca-bundle=FILE],
  2063. [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
  2064. AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  2065. [
  2066. want_ca="$withval"
  2067. if test "x$want_ca" = "xyes"; then
  2068. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  2069. fi
  2070. ],
  2071. [ want_ca="unset" ])
  2072. AC_ARG_WITH(ca-path,
  2073. AC_HELP_STRING([--with-ca-path=DIRECTORY],
  2074. [Path to a directory containing CA certificates stored individually, with \
  2075. their filenames in a hash format. This option can be used with the OpenSSL, \
  2076. GnuTLS and mbedTLS backends. Refer to OpenSSL c_rehash for details. \
  2077. (example: /etc/certificates)])
  2078. AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  2079. [
  2080. want_capath="$withval"
  2081. if test "x$want_capath" = "xyes"; then
  2082. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  2083. fi
  2084. ],
  2085. [ want_capath="unset"])
  2086. ca_warning=" (warning: certs not found)"
  2087. capath_warning=" (warning: certs not found)"
  2088. check_capath=""
  2089. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  2090. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2091. dnl both given
  2092. ca="$want_ca"
  2093. capath="$want_capath"
  2094. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  2095. dnl --with-ca-bundle given
  2096. ca="$want_ca"
  2097. capath="no"
  2098. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2099. dnl --with-ca-path given
  2100. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$MBEDTLS_ENABLED" != "x1"; then
  2101. AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or mbedTLS])
  2102. fi
  2103. capath="$want_capath"
  2104. ca="no"
  2105. else
  2106. dnl first try autodetecting a CA bundle , then a CA path
  2107. dnl both autodetections can be skipped by --without-ca-*
  2108. ca="no"
  2109. capath="no"
  2110. if test "x$cross_compiling" != "xyes"; then
  2111. dnl NOT cross-compiling and...
  2112. dnl neither of the --with-ca-* options are provided
  2113. if test "x$want_ca" = "xunset"; then
  2114. dnl the path we previously would have installed the curl ca bundle
  2115. dnl to, and thus we now check for an already existing cert in that
  2116. dnl place in case we find no other
  2117. if test "x$prefix" != xNONE; then
  2118. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  2119. else
  2120. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  2121. fi
  2122. for a in /etc/ssl/certs/ca-certificates.crt \
  2123. /etc/pki/tls/certs/ca-bundle.crt \
  2124. /usr/share/ssl/certs/ca-bundle.crt \
  2125. /usr/local/share/certs/ca-root-nss.crt \
  2126. /etc/ssl/cert.pem \
  2127. "$cac"; do
  2128. if test -f "$a"; then
  2129. ca="$a"
  2130. break
  2131. fi
  2132. done
  2133. fi
  2134. if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
  2135. "x$OPENSSL_ENABLED" = "x1"; then
  2136. check_capath="/etc/ssl/certs/"
  2137. fi
  2138. else
  2139. dnl no option given and cross-compiling
  2140. AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
  2141. fi
  2142. fi
  2143. if test "x$ca" = "xno" || test -f "$ca"; then
  2144. ca_warning=""
  2145. fi
  2146. if test "x$capath" != "xno"; then
  2147. check_capath="$capath"
  2148. fi
  2149. if test ! -z "$check_capath"; then
  2150. for a in "$check_capath"; do
  2151. 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
  2152. if test "x$capath" = "xno"; then
  2153. capath="$a"
  2154. fi
  2155. capath_warning=""
  2156. break
  2157. fi
  2158. done
  2159. fi
  2160. if test "x$capath" = "xno"; then
  2161. capath_warning=""
  2162. fi
  2163. if test "x$ca" != "xno"; then
  2164. CURL_CA_BUNDLE='"'$ca'"'
  2165. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  2166. AC_SUBST(CURL_CA_BUNDLE)
  2167. AC_MSG_RESULT([$ca])
  2168. fi
  2169. if test "x$capath" != "xno"; then
  2170. CURL_CA_PATH="\"$capath\""
  2171. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  2172. AC_MSG_RESULT([$capath (capath)])
  2173. fi
  2174. if test "x$ca" = "xno" && test "x$capath" = "xno"; then
  2175. AC_MSG_RESULT([no])
  2176. fi
  2177. AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
  2178. AC_ARG_WITH(ca-fallback,
  2179. AC_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
  2180. AC_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
  2181. [
  2182. if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
  2183. AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
  2184. fi
  2185. ],
  2186. [ with_ca_fallback="no"])
  2187. AC_MSG_RESULT([$with_ca_fallback])
  2188. if test "x$with_ca_fallback" = "xyes"; then
  2189. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
  2190. AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
  2191. fi
  2192. AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
  2193. fi
  2194. ])
  2195. dnl CURL_CHECK_WIN32_LARGEFILE
  2196. dnl -------------------------------------------------
  2197. dnl Check if curl's WIN32 large file will be used
  2198. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  2199. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  2200. AC_MSG_CHECKING([whether build target supports WIN32 file API])
  2201. curl_win32_file_api="no"
  2202. if test "$curl_cv_header_windows_h" = "yes"; then
  2203. if test x"$enable_largefile" != "xno"; then
  2204. AC_COMPILE_IFELSE([
  2205. AC_LANG_PROGRAM([[
  2206. ]],[[
  2207. #if !defined(_WIN32_WCE) && \
  2208. (defined(__MINGW32__) || \
  2209. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
  2210. int dummy=1;
  2211. #else
  2212. WIN32 large file API not supported.
  2213. #endif
  2214. ]])
  2215. ],[
  2216. curl_win32_file_api="win32_large_files"
  2217. ])
  2218. fi
  2219. if test "$curl_win32_file_api" = "no"; then
  2220. AC_COMPILE_IFELSE([
  2221. AC_LANG_PROGRAM([[
  2222. ]],[[
  2223. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  2224. int dummy=1;
  2225. #else
  2226. WIN32 small file API not supported.
  2227. #endif
  2228. ]])
  2229. ],[
  2230. curl_win32_file_api="win32_small_files"
  2231. ])
  2232. fi
  2233. fi
  2234. case "$curl_win32_file_api" in
  2235. win32_large_files)
  2236. AC_MSG_RESULT([yes (large file enabled)])
  2237. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  2238. [Define to 1 if you are building a Windows target with large file support.])
  2239. ;;
  2240. win32_small_files)
  2241. AC_MSG_RESULT([yes (large file disabled)])
  2242. AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
  2243. [Define to 1 if you are building a Windows target without large file support.])
  2244. ;;
  2245. *)
  2246. AC_MSG_RESULT([no])
  2247. ;;
  2248. esac
  2249. ])
  2250. dnl CURL_EXPORT_PCDIR ($pcdir)
  2251. dnl ------------------------
  2252. dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
  2253. dnl
  2254. dnl we need this macro since pkg-config distinguishes among empty and unset
  2255. dnl variable while checking PKG_CONFIG_LIBDIR
  2256. dnl
  2257. AC_DEFUN([CURL_EXPORT_PCDIR], [
  2258. if test -n "$1"; then
  2259. PKG_CONFIG_LIBDIR="$1"
  2260. export PKG_CONFIG_LIBDIR
  2261. fi
  2262. ])
  2263. dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
  2264. dnl ------------------------
  2265. dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
  2266. dnl path to it, or 'no' if not found/present.
  2267. dnl
  2268. dnl If pkg-config is present, check that it has info about the $module or
  2269. dnl return "no" anyway!
  2270. dnl
  2271. dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
  2272. dnl
  2273. AC_DEFUN([CURL_CHECK_PKGCONFIG], [
  2274. if test -n "$PKG_CONFIG"; then
  2275. PKGCONFIG="$PKG_CONFIG"
  2276. else
  2277. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
  2278. [$PATH:/usr/bin:/usr/local/bin])
  2279. fi
  2280. if test "x$PKGCONFIG" != "xno"; then
  2281. AC_MSG_CHECKING([for $1 options with pkg-config])
  2282. dnl ask pkg-config about $1
  2283. itexists=`CURL_EXPORT_PCDIR([$2]) dnl
  2284. $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
  2285. if test -z "$itexists"; then
  2286. dnl pkg-config does not have info about the given module! set the
  2287. dnl variable to 'no'
  2288. PKGCONFIG="no"
  2289. AC_MSG_RESULT([no])
  2290. else
  2291. AC_MSG_RESULT([found])
  2292. fi
  2293. fi
  2294. ])
  2295. dnl CURL_GENERATE_CONFIGUREHELP_PM
  2296. dnl -------------------------------------------------
  2297. dnl Generate test harness configurehelp.pm module, defining and
  2298. dnl initializing some perl variables with values which are known
  2299. dnl when the configure script runs. For portability reasons, test
  2300. dnl harness needs information on how to run the C preprocessor.
  2301. AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
  2302. AC_REQUIRE([AC_PROG_CPP])dnl
  2303. tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
  2304. if test -z "$tmp_cpp"; then
  2305. tmp_cpp='cpp'
  2306. fi
  2307. cat >./tests/configurehelp.pm <<_EOF
  2308. [@%:@] This is a generated file. Do not edit.
  2309. package configurehelp;
  2310. use strict;
  2311. use warnings;
  2312. use Exporter;
  2313. use vars qw(
  2314. @ISA
  2315. @EXPORT_OK
  2316. \$Cpreprocessor
  2317. );
  2318. @ISA = qw(Exporter);
  2319. @EXPORT_OK = qw(
  2320. \$Cpreprocessor
  2321. );
  2322. \$Cpreprocessor = '$tmp_cpp';
  2323. 1;
  2324. _EOF
  2325. ])
  2326. dnl CURL_CPP_P
  2327. dnl
  2328. dnl Check if $cpp -P should be used for extract define values due to gcc 5
  2329. dnl splitting up strings and defines between line outputs. gcc by default
  2330. dnl (without -P) will show TEST EINVAL TEST as
  2331. dnl
  2332. dnl # 13 "conftest.c"
  2333. dnl TEST
  2334. dnl # 13 "conftest.c" 3 4
  2335. dnl 22
  2336. dnl # 13 "conftest.c"
  2337. dnl TEST
  2338. AC_DEFUN([CURL_CPP_P], [
  2339. AC_MSG_CHECKING([if cpp -P is needed])
  2340. AC_EGREP_CPP([TEST.*TEST], [
  2341. #include <errno.h>
  2342. TEST EINVAL TEST
  2343. ], [cpp=no], [cpp=yes])
  2344. AC_MSG_RESULT([$cpp])
  2345. dnl we need cpp -P so check if it works then
  2346. if test "x$cpp" = "xyes"; then
  2347. AC_MSG_CHECKING([if cpp -P works])
  2348. OLDCPPFLAGS=$CPPFLAGS
  2349. CPPFLAGS="$CPPFLAGS -P"
  2350. AC_EGREP_CPP([TEST.*TEST], [
  2351. #include <errno.h>
  2352. TEST EINVAL TEST
  2353. ], [cpp_p=yes], [cpp_p=no])
  2354. AC_MSG_RESULT([$cpp_p])
  2355. if test "x$cpp_p" = "xno"; then
  2356. AC_MSG_WARN([failed to figure out cpp -P alternative])
  2357. # without -P
  2358. CPPPFLAG=""
  2359. else
  2360. # with -P
  2361. CPPPFLAG="-P"
  2362. fi
  2363. dnl restore CPPFLAGS
  2364. CPPFLAGS=$OLDCPPFLAGS
  2365. else
  2366. # without -P
  2367. CPPPFLAG=""
  2368. fi
  2369. ])
  2370. dnl CURL_MAC_CFLAGS
  2371. dnl
  2372. dnl Check if -mmacosx-version-min, -miphoneos-version-min or any
  2373. dnl similar are set manually, otherwise do. And set
  2374. dnl -Werror=partial-availability.
  2375. dnl
  2376. AC_DEFUN([CURL_MAC_CFLAGS], [
  2377. tst_cflags="no"
  2378. case $host_os in
  2379. darwin*)
  2380. tst_cflags="yes"
  2381. ;;
  2382. esac
  2383. AC_MSG_CHECKING([for good-to-use Mac CFLAGS])
  2384. AC_MSG_RESULT([$tst_cflags]);
  2385. if test "$tst_cflags" = "yes"; then
  2386. AC_MSG_CHECKING([for *version-min in CFLAGS])
  2387. min=""
  2388. if test -z "$(echo $CFLAGS | grep m.*os.*-version-min)"; then
  2389. min="-mmacosx-version-min=10.8"
  2390. CFLAGS="$CFLAGS $min"
  2391. fi
  2392. if test -z "$min"; then
  2393. AC_MSG_RESULT([set by user])
  2394. else
  2395. AC_MSG_RESULT([$min set])
  2396. fi
  2397. old_CFLAGS=$CFLAGS
  2398. CFLAGS="$CFLAGS -Werror=partial-availability"
  2399. AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
  2400. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  2401. [AC_MSG_RESULT([yes])],
  2402. [AC_MSG_RESULT([no])
  2403. CFLAGS=$old_CFLAGS])
  2404. fi
  2405. ])
  2406. dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
  2407. dnl
  2408. dnl Check to see if the compiler supports __builtin_available. This built-in
  2409. dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
  2410. dnl the time this macro was written, the function was not yet documented. Its
  2411. dnl purpose is to return true if the code is running under a certain OS version
  2412. dnl or later.
  2413. AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
  2414. AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
  2415. AC_COMPILE_IFELSE([
  2416. AC_LANG_PROGRAM([[
  2417. #include <stdlib.h>
  2418. ]],[[
  2419. if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
  2420. ]])
  2421. ],[
  2422. AC_MSG_RESULT([yes])
  2423. AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
  2424. [Define to 1 if you have the __builtin_available function.])
  2425. ],[
  2426. AC_MSG_RESULT([no])
  2427. ])
  2428. ])