acinclude.m4 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 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.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. # SPDX-License-Identifier: curl
  22. #
  23. #***************************************************************************
  24. dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
  25. dnl -------------------------------------------------
  26. dnl Use the C preprocessor to find out if the given object-style symbol
  27. dnl is defined and get its expansion. This macro will not use default
  28. dnl includes even if no INCLUDES argument is given. This macro will run
  29. dnl silently when invoked with three arguments. If the expansion would
  30. dnl result in a set of double-quoted strings the returned expansion will
  31. dnl actually be a single double-quoted string concatenating all them.
  32. AC_DEFUN([CURL_CHECK_DEF], [
  33. AC_REQUIRE([CURL_CPP_P])dnl
  34. OLDCPPFLAGS=$CPPFLAGS
  35. # CPPPFLAG comes from CURL_CPP_P
  36. CPPFLAGS="$CPPFLAGS $CPPPFLAG"
  37. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  38. AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
  39. if test -z "$SED"; then
  40. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  41. fi
  42. if test -z "$GREP"; then
  43. AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
  44. fi
  45. ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
  46. tmp_exp=""
  47. AC_PREPROC_IFELSE([
  48. AC_LANG_SOURCE(
  49. ifelse($2,,,[$2])[[
  50. #ifdef $1
  51. CURL_DEF_TOKEN $1
  52. #endif
  53. ]])
  54. ],[
  55. tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
  56. "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
  57. "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
  58. "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
  59. if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
  60. tmp_exp=""
  61. fi
  62. ])
  63. if test -z "$tmp_exp"; then
  64. AS_VAR_SET(ac_HaveDef, no)
  65. ifelse($3,,[AC_MSG_RESULT([no])])
  66. else
  67. AS_VAR_SET(ac_HaveDef, yes)
  68. AS_VAR_SET(ac_Def, $tmp_exp)
  69. ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
  70. fi
  71. AS_VAR_POPDEF([ac_Def])dnl
  72. AS_VAR_POPDEF([ac_HaveDef])dnl
  73. CPPFLAGS=$OLDCPPFLAGS
  74. ])
  75. dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
  76. dnl -------------------------------------------------
  77. dnl Use the C compiler to find out only if the given symbol is defined
  78. dnl or not, this can not find out its expansion. This macro will not use
  79. dnl default includes even if no INCLUDES argument is given. This macro
  80. dnl will run silently when invoked with three arguments.
  81. AC_DEFUN([CURL_CHECK_DEF_CC], [
  82. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  83. ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
  84. AC_COMPILE_IFELSE([
  85. AC_LANG_SOURCE(
  86. ifelse($2,,,[$2])[[
  87. int main (void)
  88. {
  89. #ifdef $1
  90. return 0;
  91. #else
  92. force compilation error
  93. #endif
  94. }
  95. ]])
  96. ],[
  97. tst_symbol_defined="yes"
  98. ],[
  99. tst_symbol_defined="no"
  100. ])
  101. if test "$tst_symbol_defined" = "yes"; then
  102. AS_VAR_SET(ac_HaveDef, yes)
  103. ifelse($3,,[AC_MSG_RESULT([yes])])
  104. else
  105. AS_VAR_SET(ac_HaveDef, no)
  106. ifelse($3,,[AC_MSG_RESULT([no])])
  107. fi
  108. AS_VAR_POPDEF([ac_HaveDef])dnl
  109. ])
  110. dnl CURL_CHECK_LIB_XNET
  111. dnl -------------------------------------------------
  112. dnl Verify if X/Open network library is required.
  113. AC_DEFUN([CURL_CHECK_LIB_XNET], [
  114. AC_MSG_CHECKING([if X/Open network library is required])
  115. tst_lib_xnet_required="no"
  116. AC_COMPILE_IFELSE([
  117. AC_LANG_SOURCE([[
  118. int main (void)
  119. {
  120. #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
  121. return 0;
  122. #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
  123. return 0;
  124. #else
  125. force compilation error
  126. #endif
  127. }
  128. ]])
  129. ],[
  130. tst_lib_xnet_required="yes"
  131. LIBS="-lxnet $LIBS"
  132. ])
  133. AC_MSG_RESULT([$tst_lib_xnet_required])
  134. ])
  135. dnl CURL_CHECK_AIX_ALL_SOURCE
  136. dnl -------------------------------------------------
  137. dnl Provides a replacement of traditional AC_AIX with
  138. dnl an uniform behavior across all autoconf versions,
  139. dnl and with our own placement rules.
  140. AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
  141. AH_VERBATIM([_ALL_SOURCE],
  142. [/* Define to 1 if OS is AIX. */
  143. #ifndef _ALL_SOURCE
  144. # undef _ALL_SOURCE
  145. #endif])
  146. AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
  147. AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
  148. AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
  149. AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
  150. AC_EGREP_CPP([yes_this_is_aix],[
  151. #ifdef _AIX
  152. yes_this_is_aix
  153. #endif
  154. ],[
  155. AC_MSG_RESULT([yes])
  156. AC_DEFINE(_ALL_SOURCE)
  157. ],[
  158. AC_MSG_RESULT([no])
  159. ])
  160. ])
  161. dnl CURL_CHECK_HEADER_WINDOWS
  162. dnl -------------------------------------------------
  163. dnl Check for compilable and valid windows.h header
  164. AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
  165. AC_CACHE_CHECK([for windows.h], [curl_cv_header_windows_h], [
  166. AC_COMPILE_IFELSE([
  167. AC_LANG_PROGRAM([[
  168. #undef inline
  169. #ifndef WIN32_LEAN_AND_MEAN
  170. #define WIN32_LEAN_AND_MEAN
  171. #endif
  172. #include <windows.h>
  173. ]],[[
  174. #if defined(__CYGWIN__) || defined(__CEGCC__)
  175. HAVE_WINDOWS_H shall not be defined.
  176. #else
  177. int dummy=2*WINVER;
  178. #endif
  179. ]])
  180. ],[
  181. curl_cv_header_windows_h="yes"
  182. ],[
  183. curl_cv_header_windows_h="no"
  184. ])
  185. ])
  186. case "$curl_cv_header_windows_h" in
  187. yes)
  188. AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
  189. [Define to 1 if you have the windows.h header file.])
  190. ;;
  191. esac
  192. ])
  193. dnl CURL_CHECK_NATIVE_WINDOWS
  194. dnl -------------------------------------------------
  195. dnl Check if building a native Windows target
  196. AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
  197. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  198. AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
  199. if test "$curl_cv_header_windows_h" = "no"; then
  200. curl_cv_native_windows="no"
  201. else
  202. AC_COMPILE_IFELSE([
  203. AC_LANG_PROGRAM([[
  204. ]],[[
  205. #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
  206. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
  207. int dummy=1;
  208. #else
  209. Not a native Windows build target.
  210. #endif
  211. ]])
  212. ],[
  213. curl_cv_native_windows="yes"
  214. ],[
  215. curl_cv_native_windows="no"
  216. ])
  217. fi
  218. ])
  219. AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
  220. ])
  221. dnl CURL_CHECK_HEADER_WINSOCK2
  222. dnl -------------------------------------------------
  223. dnl Check for compilable and valid winsock2.h header
  224. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
  225. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  226. AC_CACHE_CHECK([for winsock2.h], [curl_cv_header_winsock2_h], [
  227. AC_COMPILE_IFELSE([
  228. AC_LANG_PROGRAM([[
  229. #undef inline
  230. #ifndef WIN32_LEAN_AND_MEAN
  231. #define WIN32_LEAN_AND_MEAN
  232. #endif
  233. #include <windows.h>
  234. #include <winsock2.h>
  235. ]],[[
  236. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  237. HAVE_WINSOCK2_H shall not be defined.
  238. #else
  239. int dummy=2*IPPROTO_ESP;
  240. #endif
  241. ]])
  242. ],[
  243. curl_cv_header_winsock2_h="yes"
  244. ],[
  245. curl_cv_header_winsock2_h="no"
  246. ])
  247. ])
  248. case "$curl_cv_header_winsock2_h" in
  249. yes)
  250. AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
  251. [Define to 1 if you have the winsock2.h header file.])
  252. ;;
  253. esac
  254. ])
  255. dnl CURL_CHECK_HEADER_WS2TCPIP
  256. dnl -------------------------------------------------
  257. dnl Check for compilable and valid ws2tcpip.h header
  258. AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
  259. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  260. AC_CACHE_CHECK([for ws2tcpip.h], [curl_cv_header_ws2tcpip_h], [
  261. AC_COMPILE_IFELSE([
  262. AC_LANG_PROGRAM([[
  263. #undef inline
  264. #ifndef WIN32_LEAN_AND_MEAN
  265. #define WIN32_LEAN_AND_MEAN
  266. #endif
  267. #include <windows.h>
  268. #include <winsock2.h>
  269. #include <ws2tcpip.h>
  270. ]],[[
  271. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  272. HAVE_WS2TCPIP_H shall not be defined.
  273. #else
  274. int dummy=2*IP_PKTINFO;
  275. #endif
  276. ]])
  277. ],[
  278. curl_cv_header_ws2tcpip_h="yes"
  279. ],[
  280. curl_cv_header_ws2tcpip_h="no"
  281. ])
  282. ])
  283. case "$curl_cv_header_ws2tcpip_h" in
  284. yes)
  285. AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
  286. [Define to 1 if you have the ws2tcpip.h header file.])
  287. ;;
  288. esac
  289. ])
  290. dnl CURL_CHECK_HEADER_LBER
  291. dnl -------------------------------------------------
  292. dnl Check for compilable and valid lber.h header,
  293. dnl and check if it is needed even with ldap.h
  294. AC_DEFUN([CURL_CHECK_HEADER_LBER], [
  295. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  296. AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
  297. AC_COMPILE_IFELSE([
  298. AC_LANG_PROGRAM([[
  299. #undef inline
  300. #ifdef HAVE_WINDOWS_H
  301. #ifndef WIN32_LEAN_AND_MEAN
  302. #define WIN32_LEAN_AND_MEAN
  303. #endif
  304. #include <windows.h>
  305. #else
  306. #ifdef HAVE_SYS_TYPES_H
  307. #include <sys/types.h>
  308. #endif
  309. #endif
  310. #ifndef NULL
  311. #define NULL (void *)0
  312. #endif
  313. #include <lber.h>
  314. ]],[[
  315. BerValue *bvp = NULL;
  316. BerElement *bep = ber_init(bvp);
  317. ber_free(bep, 1);
  318. ]])
  319. ],[
  320. curl_cv_header_lber_h="yes"
  321. ],[
  322. curl_cv_header_lber_h="no"
  323. ])
  324. ])
  325. if test "$curl_cv_header_lber_h" = "yes"; then
  326. AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
  327. [Define to 1 if you have the lber.h header file.])
  328. #
  329. AC_COMPILE_IFELSE([
  330. AC_LANG_PROGRAM([[
  331. #undef inline
  332. #ifdef HAVE_WINDOWS_H
  333. #ifndef WIN32_LEAN_AND_MEAN
  334. #define WIN32_LEAN_AND_MEAN
  335. #endif
  336. #include <windows.h>
  337. #else
  338. #ifdef HAVE_SYS_TYPES_H
  339. #include <sys/types.h>
  340. #endif
  341. #endif
  342. #ifndef NULL
  343. #define NULL (void *)0
  344. #endif
  345. #ifndef LDAP_DEPRECATED
  346. #define LDAP_DEPRECATED 1
  347. #endif
  348. #include <ldap.h>
  349. ]],[[
  350. BerValue *bvp = NULL;
  351. BerElement *bep = ber_init(bvp);
  352. ber_free(bep, 1);
  353. ]])
  354. ],[
  355. curl_cv_need_header_lber_h="no"
  356. ],[
  357. curl_cv_need_header_lber_h="yes"
  358. ])
  359. #
  360. case "$curl_cv_need_header_lber_h" in
  361. yes)
  362. AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
  363. [Define to 1 if you need the lber.h header file even with ldap.h])
  364. ;;
  365. esac
  366. fi
  367. ])
  368. dnl CURL_CHECK_HEADER_LDAP
  369. dnl -------------------------------------------------
  370. dnl Check for compilable and valid ldap.h header
  371. AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
  372. AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
  373. AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
  374. AC_COMPILE_IFELSE([
  375. AC_LANG_PROGRAM([[
  376. #undef inline
  377. #ifdef HAVE_WINDOWS_H
  378. #ifndef WIN32_LEAN_AND_MEAN
  379. #define WIN32_LEAN_AND_MEAN
  380. #endif
  381. #include <windows.h>
  382. #else
  383. #ifdef HAVE_SYS_TYPES_H
  384. #include <sys/types.h>
  385. #endif
  386. #endif
  387. #ifndef LDAP_DEPRECATED
  388. #define LDAP_DEPRECATED 1
  389. #endif
  390. #ifdef NEED_LBER_H
  391. #include <lber.h>
  392. #endif
  393. #include <ldap.h>
  394. ]],[[
  395. LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
  396. int res = ldap_unbind(ldp);
  397. ]])
  398. ],[
  399. curl_cv_header_ldap_h="yes"
  400. ],[
  401. curl_cv_header_ldap_h="no"
  402. ])
  403. ])
  404. case "$curl_cv_header_ldap_h" in
  405. yes)
  406. AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
  407. [Define to 1 if you have the ldap.h header file.])
  408. ;;
  409. esac
  410. ])
  411. dnl CURL_CHECK_HEADER_LDAP_SSL
  412. dnl -------------------------------------------------
  413. dnl Check for compilable and valid ldap_ssl.h header
  414. AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
  415. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  416. AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
  417. AC_COMPILE_IFELSE([
  418. AC_LANG_PROGRAM([[
  419. #undef inline
  420. #ifdef HAVE_WINDOWS_H
  421. #ifndef WIN32_LEAN_AND_MEAN
  422. #define WIN32_LEAN_AND_MEAN
  423. #endif
  424. #include <windows.h>
  425. #else
  426. #ifdef HAVE_SYS_TYPES_H
  427. #include <sys/types.h>
  428. #endif
  429. #endif
  430. #ifndef LDAP_DEPRECATED
  431. #define LDAP_DEPRECATED 1
  432. #endif
  433. #ifdef NEED_LBER_H
  434. #include <lber.h>
  435. #endif
  436. #ifdef HAVE_LDAP_H
  437. #include <ldap.h>
  438. #endif
  439. #include <ldap_ssl.h>
  440. ]],[[
  441. LDAP *ldp = ldapssl_init("0.0.0.0", LDAPS_PORT, 1);
  442. ]])
  443. ],[
  444. curl_cv_header_ldap_ssl_h="yes"
  445. ],[
  446. curl_cv_header_ldap_ssl_h="no"
  447. ])
  448. ])
  449. case "$curl_cv_header_ldap_ssl_h" in
  450. yes)
  451. AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
  452. [Define to 1 if you have the ldap_ssl.h header file.])
  453. ;;
  454. esac
  455. ])
  456. dnl CURL_CHECK_LIBS_WINLDAP
  457. dnl -------------------------------------------------
  458. dnl Check for libraries needed for WINLDAP support,
  459. dnl and prepended to LIBS any needed libraries.
  460. dnl This macro can take an optional parameter with a
  461. dnl whitespace separated list of libraries to check
  462. dnl before the WINLDAP default ones.
  463. AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
  464. AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
  465. #
  466. AC_MSG_CHECKING([for WINLDAP libraries])
  467. #
  468. u_libs=""
  469. #
  470. ifelse($1,,,[
  471. for x_lib in $1; do
  472. case "$x_lib" in
  473. -l*)
  474. l_lib="$x_lib"
  475. ;;
  476. *)
  477. l_lib="-l$x_lib"
  478. ;;
  479. esac
  480. if test -z "$u_libs"; then
  481. u_libs="$l_lib"
  482. else
  483. u_libs="$u_libs $l_lib"
  484. fi
  485. done
  486. ])
  487. #
  488. curl_cv_save_LIBS="$LIBS"
  489. curl_cv_ldap_LIBS="unknown"
  490. #
  491. for x_nlibs in '' "$u_libs" \
  492. '-lwldap32' ; do
  493. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  494. if test -z "$x_nlibs"; then
  495. LIBS="$curl_cv_save_LIBS"
  496. else
  497. LIBS="$x_nlibs $curl_cv_save_LIBS"
  498. fi
  499. AC_LINK_IFELSE([
  500. AC_LANG_PROGRAM([[
  501. #undef inline
  502. #ifdef HAVE_WINDOWS_H
  503. #ifndef WIN32_LEAN_AND_MEAN
  504. #define WIN32_LEAN_AND_MEAN
  505. #endif
  506. #include <windows.h>
  507. #include <winldap.h>
  508. #ifdef HAVE_WINBER_H
  509. #include <winber.h>
  510. #endif
  511. #endif
  512. ]],[[
  513. BERVAL *bvp = NULL;
  514. BerElement *bep = ber_init(bvp);
  515. LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
  516. ULONG res = ldap_unbind(ldp);
  517. ber_free(bep, 1);
  518. ]])
  519. ],[
  520. curl_cv_ldap_LIBS="$x_nlibs"
  521. ])
  522. fi
  523. done
  524. #
  525. LIBS="$curl_cv_save_LIBS"
  526. #
  527. case X-"$curl_cv_ldap_LIBS" in
  528. X-unknown)
  529. AC_MSG_RESULT([cannot find WINLDAP libraries])
  530. ;;
  531. X-)
  532. AC_MSG_RESULT([no additional lib required])
  533. ;;
  534. *)
  535. if test -z "$curl_cv_save_LIBS"; then
  536. LIBS="$curl_cv_ldap_LIBS"
  537. else
  538. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  539. fi
  540. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  541. ;;
  542. esac
  543. #
  544. ])
  545. dnl CURL_CHECK_LIBS_LDAP
  546. dnl -------------------------------------------------
  547. dnl Check for libraries needed for LDAP support,
  548. dnl and prepended to LIBS any needed libraries.
  549. dnl This macro can take an optional parameter with a
  550. dnl whitespace separated list of libraries to check
  551. dnl before the default ones.
  552. AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
  553. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  554. #
  555. AC_MSG_CHECKING([for LDAP libraries])
  556. #
  557. u_libs=""
  558. #
  559. ifelse($1,,,[
  560. for x_lib in $1; do
  561. case "$x_lib" in
  562. -l*)
  563. l_lib="$x_lib"
  564. ;;
  565. *)
  566. l_lib="-l$x_lib"
  567. ;;
  568. esac
  569. if test -z "$u_libs"; then
  570. u_libs="$l_lib"
  571. else
  572. u_libs="$u_libs $l_lib"
  573. fi
  574. done
  575. ])
  576. #
  577. curl_cv_save_LIBS="$LIBS"
  578. curl_cv_ldap_LIBS="unknown"
  579. #
  580. for x_nlibs in '' "$u_libs" \
  581. '-lldap' \
  582. '-lldap -llber' \
  583. '-llber -lldap' \
  584. '-lldapssl -lldapx -lldapsdk' \
  585. '-lldapsdk -lldapx -lldapssl' \
  586. '-lldap -llber -lssl -lcrypto' ; do
  587. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  588. if test -z "$x_nlibs"; then
  589. LIBS="$curl_cv_save_LIBS"
  590. else
  591. LIBS="$x_nlibs $curl_cv_save_LIBS"
  592. fi
  593. AC_LINK_IFELSE([
  594. AC_LANG_PROGRAM([[
  595. #undef inline
  596. #ifdef HAVE_WINDOWS_H
  597. #ifndef WIN32_LEAN_AND_MEAN
  598. #define WIN32_LEAN_AND_MEAN
  599. #endif
  600. #include <windows.h>
  601. #else
  602. #ifdef HAVE_SYS_TYPES_H
  603. #include <sys/types.h>
  604. #endif
  605. #endif
  606. #ifndef NULL
  607. #define NULL (void *)0
  608. #endif
  609. #ifndef LDAP_DEPRECATED
  610. #define LDAP_DEPRECATED 1
  611. #endif
  612. #ifdef NEED_LBER_H
  613. #include <lber.h>
  614. #endif
  615. #ifdef HAVE_LDAP_H
  616. #include <ldap.h>
  617. #endif
  618. ]],[[
  619. BerValue *bvp = NULL;
  620. BerElement *bep = ber_init(bvp);
  621. LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
  622. int res = ldap_unbind(ldp);
  623. ber_free(bep, 1);
  624. ]])
  625. ],[
  626. curl_cv_ldap_LIBS="$x_nlibs"
  627. ])
  628. fi
  629. done
  630. #
  631. LIBS="$curl_cv_save_LIBS"
  632. #
  633. case X-"$curl_cv_ldap_LIBS" in
  634. X-unknown)
  635. AC_MSG_RESULT([cannot find LDAP libraries])
  636. ;;
  637. X-)
  638. AC_MSG_RESULT([no additional lib required])
  639. ;;
  640. *)
  641. if test -z "$curl_cv_save_LIBS"; then
  642. LIBS="$curl_cv_ldap_LIBS"
  643. else
  644. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  645. fi
  646. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  647. ;;
  648. esac
  649. #
  650. ])
  651. dnl TYPE_SOCKADDR_STORAGE
  652. dnl -------------------------------------------------
  653. dnl Check for struct sockaddr_storage. Most IPv6-enabled
  654. dnl hosts have it, but AIX 4.3 is one known exception.
  655. AC_DEFUN([TYPE_SOCKADDR_STORAGE],
  656. [
  657. AC_CHECK_TYPE([struct sockaddr_storage],
  658. AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
  659. [if struct sockaddr_storage is defined]), ,
  660. [
  661. #undef inline
  662. #ifdef HAVE_WINDOWS_H
  663. #ifndef WIN32_LEAN_AND_MEAN
  664. #define WIN32_LEAN_AND_MEAN
  665. #endif
  666. #include <windows.h>
  667. #ifdef HAVE_WINSOCK2_H
  668. #include <winsock2.h>
  669. #endif
  670. #else
  671. #ifdef HAVE_SYS_TYPES_H
  672. #include <sys/types.h>
  673. #endif
  674. #ifdef HAVE_SYS_SOCKET_H
  675. #include <sys/socket.h>
  676. #endif
  677. #ifdef HAVE_NETINET_IN_H
  678. #include <netinet/in.h>
  679. #endif
  680. #ifdef HAVE_ARPA_INET_H
  681. #include <arpa/inet.h>
  682. #endif
  683. #endif
  684. ])
  685. ])
  686. dnl CURL_CHECK_FUNC_RECV
  687. dnl -------------------------------------------------
  688. dnl Test if the socket recv() function is available,
  689. AC_DEFUN([CURL_CHECK_FUNC_RECV], [
  690. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  691. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  692. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  693. #
  694. AC_MSG_CHECKING([for recv])
  695. AC_LINK_IFELSE([
  696. AC_LANG_PROGRAM([[
  697. #undef inline
  698. #ifdef HAVE_WINDOWS_H
  699. #ifndef WIN32_LEAN_AND_MEAN
  700. #define WIN32_LEAN_AND_MEAN
  701. #endif
  702. #include <windows.h>
  703. #ifdef HAVE_WINSOCK2_H
  704. #include <winsock2.h>
  705. #endif
  706. #else
  707. $curl_includes_bsdsocket
  708. #ifdef HAVE_SYS_TYPES_H
  709. #include <sys/types.h>
  710. #endif
  711. #ifdef HAVE_SYS_SOCKET_H
  712. #include <sys/socket.h>
  713. #endif
  714. #endif
  715. ]],[[
  716. recv(0, 0, 0, 0);
  717. ]])
  718. ],[
  719. AC_MSG_RESULT([yes])
  720. curl_cv_recv="yes"
  721. ],[
  722. AC_MSG_RESULT([no])
  723. curl_cv_recv="no"
  724. ])
  725. #
  726. if test "$curl_cv_recv" = "yes"; then
  727. AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
  728. [Define to 1 if you have the recv function.])
  729. curl_cv_func_recv="yes"
  730. else
  731. AC_MSG_ERROR([Unable to link function recv])
  732. fi
  733. ])
  734. dnl CURL_CHECK_FUNC_SEND
  735. dnl -------------------------------------------------
  736. dnl Test if the socket send() function is available,
  737. AC_DEFUN([CURL_CHECK_FUNC_SEND], [
  738. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  739. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  740. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  741. #
  742. AC_MSG_CHECKING([for send])
  743. AC_LINK_IFELSE([
  744. AC_LANG_PROGRAM([[
  745. #undef inline
  746. #ifdef HAVE_WINDOWS_H
  747. #ifndef WIN32_LEAN_AND_MEAN
  748. #define WIN32_LEAN_AND_MEAN
  749. #endif
  750. #include <windows.h>
  751. #ifdef HAVE_WINSOCK2_H
  752. #include <winsock2.h>
  753. #endif
  754. #else
  755. $curl_includes_bsdsocket
  756. #ifdef HAVE_SYS_TYPES_H
  757. #include <sys/types.h>
  758. #endif
  759. #ifdef HAVE_SYS_SOCKET_H
  760. #include <sys/socket.h>
  761. #endif
  762. #endif
  763. ]],[[
  764. send(0, 0, 0, 0);
  765. ]])
  766. ],[
  767. AC_MSG_RESULT([yes])
  768. curl_cv_send="yes"
  769. ],[
  770. AC_MSG_RESULT([no])
  771. curl_cv_send="no"
  772. ])
  773. #
  774. if test "$curl_cv_send" = "yes"; then
  775. AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
  776. [Define to 1 if you have the send function.])
  777. curl_cv_func_send="yes"
  778. else
  779. AC_MSG_ERROR([Unable to link function send])
  780. fi
  781. ])
  782. dnl CURL_CHECK_MSG_NOSIGNAL
  783. dnl -------------------------------------------------
  784. dnl Check for MSG_NOSIGNAL
  785. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  786. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  787. AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
  788. AC_COMPILE_IFELSE([
  789. AC_LANG_PROGRAM([[
  790. #undef inline
  791. #ifdef HAVE_WINDOWS_H
  792. #ifndef WIN32_LEAN_AND_MEAN
  793. #define WIN32_LEAN_AND_MEAN
  794. #endif
  795. #include <windows.h>
  796. #ifdef HAVE_WINSOCK2_H
  797. #include <winsock2.h>
  798. #endif
  799. #else
  800. #ifdef HAVE_SYS_TYPES_H
  801. #include <sys/types.h>
  802. #endif
  803. #ifdef HAVE_SYS_SOCKET_H
  804. #include <sys/socket.h>
  805. #endif
  806. #endif
  807. ]],[[
  808. int flag=MSG_NOSIGNAL;
  809. ]])
  810. ],[
  811. curl_cv_msg_nosignal="yes"
  812. ],[
  813. curl_cv_msg_nosignal="no"
  814. ])
  815. ])
  816. case "$curl_cv_msg_nosignal" in
  817. yes)
  818. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  819. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  820. ;;
  821. esac
  822. ])
  823. dnl CURL_CHECK_STRUCT_TIMEVAL
  824. dnl -------------------------------------------------
  825. dnl Check for timeval struct
  826. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  827. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  828. AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h)
  829. AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
  830. AC_COMPILE_IFELSE([
  831. AC_LANG_PROGRAM([[
  832. #undef inline
  833. #ifdef HAVE_WINDOWS_H
  834. #ifndef WIN32_LEAN_AND_MEAN
  835. #define WIN32_LEAN_AND_MEAN
  836. #endif
  837. #include <windows.h>
  838. #ifdef HAVE_WINSOCK2_H
  839. #include <winsock2.h>
  840. #endif
  841. #endif
  842. #ifdef HAVE_SYS_TYPES_H
  843. #include <sys/types.h>
  844. #endif
  845. #ifdef HAVE_SYS_TIME_H
  846. #include <sys/time.h>
  847. #endif
  848. #include <time.h>
  849. #ifdef HAVE_SYS_SOCKET_H
  850. #include <sys/socket.h>
  851. #endif
  852. ]],[[
  853. struct timeval ts;
  854. ts.tv_sec = 0;
  855. ts.tv_usec = 0;
  856. ]])
  857. ],[
  858. curl_cv_struct_timeval="yes"
  859. ],[
  860. curl_cv_struct_timeval="no"
  861. ])
  862. ])
  863. case "$curl_cv_struct_timeval" in
  864. yes)
  865. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  866. [Define to 1 if you have the timeval struct.])
  867. ;;
  868. esac
  869. ])
  870. dnl TYPE_IN_ADDR_T
  871. dnl -------------------------------------------------
  872. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  873. dnl and a few other things.
  874. AC_DEFUN([TYPE_IN_ADDR_T], [
  875. AC_CHECK_TYPE([in_addr_t], ,[
  876. dnl in_addr_t not available
  877. AC_CACHE_CHECK([for in_addr_t equivalent],
  878. [curl_cv_in_addr_t_equiv], [
  879. curl_cv_in_addr_t_equiv="unknown"
  880. for t in "unsigned long" int size_t unsigned long; do
  881. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  882. AC_LINK_IFELSE([
  883. AC_LANG_PROGRAM([[
  884. #undef inline
  885. #ifdef HAVE_WINDOWS_H
  886. #ifndef WIN32_LEAN_AND_MEAN
  887. #define WIN32_LEAN_AND_MEAN
  888. #endif
  889. #include <windows.h>
  890. #ifdef HAVE_WINSOCK2_H
  891. #include <winsock2.h>
  892. #endif
  893. #else
  894. #ifdef HAVE_SYS_TYPES_H
  895. #include <sys/types.h>
  896. #endif
  897. #ifdef HAVE_SYS_SOCKET_H
  898. #include <sys/socket.h>
  899. #endif
  900. #ifdef HAVE_NETINET_IN_H
  901. #include <netinet/in.h>
  902. #endif
  903. #ifdef HAVE_ARPA_INET_H
  904. #include <arpa/inet.h>
  905. #endif
  906. #endif
  907. ]],[[
  908. $t data = inet_addr ("1.2.3.4");
  909. ]])
  910. ],[
  911. curl_cv_in_addr_t_equiv="$t"
  912. ])
  913. fi
  914. done
  915. ])
  916. case "$curl_cv_in_addr_t_equiv" in
  917. unknown)
  918. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  919. ;;
  920. *)
  921. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  922. [Type to use in place of in_addr_t when system does not provide it.])
  923. ;;
  924. esac
  925. ],[
  926. #undef inline
  927. #ifdef HAVE_WINDOWS_H
  928. #ifndef WIN32_LEAN_AND_MEAN
  929. #define WIN32_LEAN_AND_MEAN
  930. #endif
  931. #include <windows.h>
  932. #ifdef HAVE_WINSOCK2_H
  933. #include <winsock2.h>
  934. #endif
  935. #else
  936. #ifdef HAVE_SYS_TYPES_H
  937. #include <sys/types.h>
  938. #endif
  939. #ifdef HAVE_SYS_SOCKET_H
  940. #include <sys/socket.h>
  941. #endif
  942. #ifdef HAVE_NETINET_IN_H
  943. #include <netinet/in.h>
  944. #endif
  945. #ifdef HAVE_ARPA_INET_H
  946. #include <arpa/inet.h>
  947. #endif
  948. #endif
  949. ])
  950. ])
  951. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  952. dnl -------------------------------------------------
  953. dnl Check if monotonic clock_gettime is available.
  954. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  955. AC_CHECK_HEADERS(sys/types.h sys/time.h)
  956. AC_MSG_CHECKING([for monotonic clock_gettime])
  957. #
  958. if test "x$dontwant_rt" = "xno" ; then
  959. AC_COMPILE_IFELSE([
  960. AC_LANG_PROGRAM([[
  961. #ifdef HAVE_SYS_TYPES_H
  962. #include <sys/types.h>
  963. #endif
  964. #ifdef HAVE_SYS_TIME_H
  965. #include <sys/time.h>
  966. #endif
  967. #include <time.h>
  968. ]],[[
  969. struct timespec ts;
  970. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  971. ]])
  972. ],[
  973. AC_MSG_RESULT([yes])
  974. curl_func_clock_gettime="yes"
  975. ],[
  976. AC_MSG_RESULT([no])
  977. curl_func_clock_gettime="no"
  978. ])
  979. fi
  980. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  981. dnl until library linking and run-time checks for clock_gettime succeed.
  982. ])
  983. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW
  984. dnl -------------------------------------------------
  985. dnl Check if monotonic clock_gettime is available.
  986. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW], [
  987. AC_CHECK_HEADERS(sys/types.h sys/time.h)
  988. AC_MSG_CHECKING([for raw monotonic clock_gettime])
  989. #
  990. if test "x$dontwant_rt" = "xno" ; then
  991. AC_COMPILE_IFELSE([
  992. AC_LANG_PROGRAM([[
  993. #ifdef HAVE_SYS_TYPES_H
  994. #include <sys/types.h>
  995. #endif
  996. #ifdef HAVE_SYS_TIME_H
  997. #include <sys/time.h>
  998. #endif
  999. #include <time.h>
  1000. ]],[[
  1001. struct timespec ts;
  1002. (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
  1003. ]])
  1004. ],[
  1005. AC_MSG_RESULT([yes])
  1006. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC_RAW, 1,
  1007. [Define to 1 if you have the clock_gettime function and raw monotonic timer.])
  1008. ],[
  1009. AC_MSG_RESULT([no])
  1010. ])
  1011. fi
  1012. ])
  1013. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  1014. dnl -------------------------------------------------
  1015. dnl If monotonic clock_gettime is available then,
  1016. dnl check and prepended to LIBS any needed libraries.
  1017. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  1018. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  1019. #
  1020. if test "$curl_func_clock_gettime" = "yes"; then
  1021. #
  1022. AC_MSG_CHECKING([for clock_gettime in libraries])
  1023. #
  1024. curl_cv_save_LIBS="$LIBS"
  1025. curl_cv_gclk_LIBS="unknown"
  1026. #
  1027. for x_xlibs in '' '-lrt' '-lposix4' ; do
  1028. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  1029. if test -z "$x_xlibs"; then
  1030. LIBS="$curl_cv_save_LIBS"
  1031. else
  1032. LIBS="$x_xlibs $curl_cv_save_LIBS"
  1033. fi
  1034. AC_LINK_IFELSE([
  1035. AC_LANG_PROGRAM([[
  1036. #ifdef HAVE_SYS_TYPES_H
  1037. #include <sys/types.h>
  1038. #endif
  1039. #ifdef HAVE_SYS_TIME_H
  1040. #include <sys/time.h>
  1041. #endif
  1042. #include <time.h>
  1043. ]],[[
  1044. struct timespec ts;
  1045. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1046. ]])
  1047. ],[
  1048. curl_cv_gclk_LIBS="$x_xlibs"
  1049. ])
  1050. fi
  1051. done
  1052. #
  1053. LIBS="$curl_cv_save_LIBS"
  1054. #
  1055. case X-"$curl_cv_gclk_LIBS" in
  1056. X-unknown)
  1057. AC_MSG_RESULT([cannot find clock_gettime])
  1058. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1059. curl_func_clock_gettime="no"
  1060. ;;
  1061. X-)
  1062. AC_MSG_RESULT([no additional lib required])
  1063. curl_func_clock_gettime="yes"
  1064. ;;
  1065. *)
  1066. if test -z "$curl_cv_save_LIBS"; then
  1067. LIBS="$curl_cv_gclk_LIBS"
  1068. else
  1069. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  1070. fi
  1071. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  1072. curl_func_clock_gettime="yes"
  1073. ;;
  1074. esac
  1075. #
  1076. dnl only do runtime verification when not cross-compiling
  1077. if test "x$cross_compiling" != "xyes" &&
  1078. test "$curl_func_clock_gettime" = "yes"; then
  1079. AC_MSG_CHECKING([if monotonic clock_gettime works])
  1080. CURL_RUN_IFELSE([
  1081. AC_LANG_PROGRAM([[
  1082. #include <stdlib.h>
  1083. #ifdef HAVE_SYS_TYPES_H
  1084. #include <sys/types.h>
  1085. #endif
  1086. #ifdef HAVE_SYS_TIME_H
  1087. #include <sys/time.h>
  1088. #endif
  1089. #include <time.h>
  1090. ]],[[
  1091. struct timespec ts;
  1092. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  1093. exit(0);
  1094. else
  1095. exit(1);
  1096. ]])
  1097. ],[
  1098. AC_MSG_RESULT([yes])
  1099. ],[
  1100. AC_MSG_RESULT([no])
  1101. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1102. curl_func_clock_gettime="no"
  1103. LIBS="$curl_cv_save_LIBS"
  1104. ])
  1105. fi
  1106. #
  1107. case "$curl_func_clock_gettime" in
  1108. yes)
  1109. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  1110. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  1111. ;;
  1112. esac
  1113. #
  1114. fi
  1115. #
  1116. ])
  1117. dnl CURL_CHECK_LIBS_CONNECT
  1118. dnl -------------------------------------------------
  1119. dnl Verify if network connect function is already available
  1120. dnl using current libraries or if another one is required.
  1121. AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
  1122. AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
  1123. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  1124. AC_MSG_CHECKING([for connect in libraries])
  1125. tst_connect_save_LIBS="$LIBS"
  1126. tst_connect_need_LIBS="unknown"
  1127. for tst_lib in '' '-lsocket' ; do
  1128. if test "$tst_connect_need_LIBS" = "unknown"; then
  1129. LIBS="$tst_lib $tst_connect_save_LIBS"
  1130. AC_LINK_IFELSE([
  1131. AC_LANG_PROGRAM([[
  1132. $curl_includes_winsock2
  1133. $curl_includes_bsdsocket
  1134. #if !defined(HAVE_WINDOWS_H) && !defined(HAVE_PROTO_BSDSOCKET_H)
  1135. int connect(int, void*, int);
  1136. #endif
  1137. ]],[[
  1138. if(0 != connect(0, 0, 0))
  1139. return 1;
  1140. ]])
  1141. ],[
  1142. tst_connect_need_LIBS="$tst_lib"
  1143. ])
  1144. fi
  1145. done
  1146. LIBS="$tst_connect_save_LIBS"
  1147. #
  1148. case X-"$tst_connect_need_LIBS" in
  1149. X-unknown)
  1150. AC_MSG_RESULT([cannot find connect])
  1151. AC_MSG_ERROR([cannot find connect function in libraries.])
  1152. ;;
  1153. X-)
  1154. AC_MSG_RESULT([yes])
  1155. ;;
  1156. *)
  1157. AC_MSG_RESULT([$tst_connect_need_LIBS])
  1158. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  1159. ;;
  1160. esac
  1161. ])
  1162. dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
  1163. dnl -------------------------------------------------
  1164. dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
  1165. dnl symbol that can be further used in custom template configuration
  1166. dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
  1167. dnl argument for the description. Symbol definitions done with this
  1168. dnl macro are intended to be exclusively used in handcrafted *.h.in
  1169. dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
  1170. dnl prevents autoheader generation and insertion of symbol template
  1171. dnl stub and definition into the first configuration header file. Do
  1172. dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
  1173. dnl one serves different functional needs.
  1174. AC_DEFUN([CURL_DEFINE_UNQUOTED], [
  1175. cat >>confdefs.h <<_EOF
  1176. [@%:@define] $1 ifelse($#, 2, [$2], 1)
  1177. _EOF
  1178. ])
  1179. dnl CURL_CONFIGURE_PULL_SYS_POLL
  1180. dnl -------------------------------------------------
  1181. dnl The need for the sys/poll.h inclusion arises mainly to properly
  1182. dnl interface AIX systems which define macros 'events' and 'revents'.
  1183. AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
  1184. AC_REQUIRE([CURL_INCLUDES_POLL])dnl
  1185. #
  1186. tst_poll_events_macro_defined="unknown"
  1187. #
  1188. AC_COMPILE_IFELSE([
  1189. AC_LANG_PROGRAM([[
  1190. $curl_includes_poll
  1191. ]],[[
  1192. #if defined(events) || defined(revents)
  1193. return 0;
  1194. #else
  1195. force compilation error
  1196. #endif
  1197. ]])
  1198. ],[
  1199. tst_poll_events_macro_defined="yes"
  1200. ],[
  1201. tst_poll_events_macro_defined="no"
  1202. ])
  1203. #
  1204. if test "$tst_poll_events_macro_defined" = "yes"; then
  1205. if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
  1206. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
  1207. fi
  1208. fi
  1209. #
  1210. ])
  1211. dnl CURL_CHECK_FUNC_SELECT
  1212. dnl -------------------------------------------------
  1213. dnl Test if the socket select() function is available.
  1214. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  1215. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  1216. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  1217. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  1218. #
  1219. AC_MSG_CHECKING([for select])
  1220. AC_LINK_IFELSE([
  1221. AC_LANG_PROGRAM([[
  1222. #undef inline
  1223. #ifdef HAVE_WINDOWS_H
  1224. #ifndef WIN32_LEAN_AND_MEAN
  1225. #define WIN32_LEAN_AND_MEAN
  1226. #endif
  1227. #include <windows.h>
  1228. #ifdef HAVE_WINSOCK2_H
  1229. #include <winsock2.h>
  1230. #endif
  1231. #endif
  1232. #ifdef HAVE_SYS_TYPES_H
  1233. #include <sys/types.h>
  1234. #endif
  1235. #ifdef HAVE_SYS_TIME_H
  1236. #include <sys/time.h>
  1237. #endif
  1238. #include <time.h>
  1239. #ifndef HAVE_WINDOWS_H
  1240. #ifdef HAVE_SYS_SELECT_H
  1241. #include <sys/select.h>
  1242. #elif defined(HAVE_UNISTD_H)
  1243. #include <unistd.h>
  1244. #endif
  1245. #ifdef HAVE_SYS_SOCKET_H
  1246. #include <sys/socket.h>
  1247. #endif
  1248. $curl_includes_bsdsocket
  1249. #endif
  1250. ]],[[
  1251. select(0, 0, 0, 0, 0);
  1252. ]])
  1253. ],[
  1254. AC_MSG_RESULT([yes])
  1255. curl_cv_select="yes"
  1256. ],[
  1257. AC_MSG_RESULT([no])
  1258. curl_cv_select="no"
  1259. ])
  1260. #
  1261. if test "$curl_cv_select" = "yes"; then
  1262. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  1263. [Define to 1 if you have the select function.])
  1264. curl_cv_func_select="yes"
  1265. fi
  1266. ])
  1267. dnl CURL_VERIFY_RUNTIMELIBS
  1268. dnl -------------------------------------------------
  1269. dnl Verify that the shared libs found so far can be used when running
  1270. dnl programs, since otherwise the situation will create odd configure errors
  1271. dnl that are misleading people.
  1272. dnl
  1273. dnl Make sure this test is run BEFORE the first test in the script that
  1274. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  1275. dnl macro. It must also run AFTER all lib-checking macros are complete.
  1276. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  1277. dnl this test is of course not sensible if we are cross-compiling!
  1278. if test "x$cross_compiling" != xyes; then
  1279. dnl just run a program to verify that the libs checked for previous to this
  1280. dnl point also is available run-time!
  1281. AC_MSG_CHECKING([run-time libs availability])
  1282. CURL_RUN_IFELSE([
  1283. int main()
  1284. {
  1285. return 0;
  1286. }
  1287. ],
  1288. AC_MSG_RESULT([fine]),
  1289. AC_MSG_RESULT([failed])
  1290. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  1291. )
  1292. dnl if this test fails, configure has already stopped
  1293. fi
  1294. ])
  1295. dnl CURL_CHECK_VARIADIC_MACROS
  1296. dnl -------------------------------------------------
  1297. dnl Check compiler support of variadic macros
  1298. AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
  1299. AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
  1300. [curl_cv_variadic_macros_c99], [
  1301. AC_COMPILE_IFELSE([
  1302. AC_LANG_PROGRAM([[
  1303. #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
  1304. #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
  1305. int fun3(int arg1, int arg2, int arg3);
  1306. int fun2(int arg1, int arg2);
  1307. int fun3(int arg1, int arg2, int arg3)
  1308. { return arg1 + arg2 + arg3; }
  1309. int fun2(int arg1, int arg2)
  1310. { return arg1 + arg2; }
  1311. ]],[[
  1312. int res3 = c99_vmacro3(1, 2, 3);
  1313. int res2 = c99_vmacro2(1, 2);
  1314. ]])
  1315. ],[
  1316. curl_cv_variadic_macros_c99="yes"
  1317. ],[
  1318. curl_cv_variadic_macros_c99="no"
  1319. ])
  1320. ])
  1321. case "$curl_cv_variadic_macros_c99" in
  1322. yes)
  1323. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
  1324. [Define to 1 if compiler supports C99 variadic macro style.])
  1325. ;;
  1326. esac
  1327. AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
  1328. [curl_cv_variadic_macros_gcc], [
  1329. AC_COMPILE_IFELSE([
  1330. AC_LANG_PROGRAM([[
  1331. #define gcc_vmacro3(first, args...) fun3(first, args)
  1332. #define gcc_vmacro2(first, args...) fun2(first, args)
  1333. int fun3(int arg1, int arg2, int arg3);
  1334. int fun2(int arg1, int arg2);
  1335. int fun3(int arg1, int arg2, int arg3)
  1336. { return arg1 + arg2 + arg3; }
  1337. int fun2(int arg1, int arg2)
  1338. { return arg1 + arg2; }
  1339. ]],[[
  1340. int res3 = gcc_vmacro3(1, 2, 3);
  1341. int res2 = gcc_vmacro2(1, 2);
  1342. ]])
  1343. ],[
  1344. curl_cv_variadic_macros_gcc="yes"
  1345. ],[
  1346. curl_cv_variadic_macros_gcc="no"
  1347. ])
  1348. ])
  1349. case "$curl_cv_variadic_macros_gcc" in
  1350. yes)
  1351. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
  1352. [Define to 1 if compiler supports old gcc variadic macro style.])
  1353. ;;
  1354. esac
  1355. ])
  1356. dnl CURL_CHECK_CA_BUNDLE
  1357. dnl -------------------------------------------------
  1358. dnl Check if a default ca-bundle should be used
  1359. dnl
  1360. dnl regarding the paths this will scan:
  1361. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  1362. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  1363. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  1364. dnl /usr/local/share/certs/ca-root-nss.crt MidnightBSD
  1365. dnl /etc/ssl/cert.pem OpenBSD, MidnightBSD (symlink)
  1366. dnl /etc/ssl/certs (CA path) SUSE, FreeBSD
  1367. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  1368. AC_MSG_CHECKING([default CA cert bundle/path])
  1369. AC_ARG_WITH(ca-bundle,
  1370. AS_HELP_STRING([--with-ca-bundle=FILE],
  1371. [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
  1372. AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  1373. [
  1374. want_ca="$withval"
  1375. if test "x$want_ca" = "xyes"; then
  1376. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  1377. fi
  1378. ],
  1379. [ want_ca="unset" ])
  1380. AC_ARG_WITH(ca-path,
  1381. AS_HELP_STRING([--with-ca-path=DIRECTORY],
  1382. [Path to a directory containing CA certificates stored individually, with \
  1383. their filenames in a hash format. This option can be used with the OpenSSL, \
  1384. GnuTLS, mbedTLS and wolfSSL backends. Refer to OpenSSL c_rehash for details. \
  1385. (example: /etc/certificates)])
  1386. AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  1387. [
  1388. want_capath="$withval"
  1389. if test "x$want_capath" = "xyes"; then
  1390. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  1391. fi
  1392. ],
  1393. [ want_capath="unset"])
  1394. ca_warning=" (warning: certs not found)"
  1395. capath_warning=" (warning: certs not found)"
  1396. check_capath=""
  1397. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  1398. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  1399. dnl both given
  1400. ca="$want_ca"
  1401. capath="$want_capath"
  1402. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  1403. dnl --with-ca-bundle given
  1404. ca="$want_ca"
  1405. capath="no"
  1406. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  1407. dnl --with-ca-path given
  1408. if test "x$OPENSSL_ENABLED" != "x1" -a \
  1409. "x$GNUTLS_ENABLED" != "x1" -a \
  1410. "x$MBEDTLS_ENABLED" != "x1" -a \
  1411. "x$WOLFSSL_ENABLED" != "x1"; then
  1412. AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS, mbedTLS or wolfSSL])
  1413. fi
  1414. capath="$want_capath"
  1415. ca="no"
  1416. else
  1417. dnl first try autodetecting a CA bundle , then a CA path
  1418. dnl both autodetections can be skipped by --without-ca-*
  1419. ca="no"
  1420. capath="no"
  1421. if test "x$cross_compiling" != "xyes"; then
  1422. dnl NOT cross-compiling and...
  1423. dnl neither of the --with-ca-* options are provided
  1424. if test "x$want_ca" = "xunset"; then
  1425. dnl the path we previously would have installed the curl ca bundle
  1426. dnl to, and thus we now check for an already existing cert in that
  1427. dnl place in case we find no other
  1428. if test "x$prefix" != xNONE; then
  1429. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  1430. else
  1431. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  1432. fi
  1433. for a in /etc/ssl/certs/ca-certificates.crt \
  1434. /etc/pki/tls/certs/ca-bundle.crt \
  1435. /usr/share/ssl/certs/ca-bundle.crt \
  1436. /usr/local/share/certs/ca-root-nss.crt \
  1437. /etc/ssl/cert.pem \
  1438. "$cac"; do
  1439. if test -f "$a"; then
  1440. ca="$a"
  1441. break
  1442. fi
  1443. done
  1444. fi
  1445. AC_MSG_NOTICE([want $want_capath ca $ca])
  1446. if test "x$want_capath" = "xunset"; then
  1447. if test "x$OPENSSL_ENABLED" = "x1" -o \
  1448. "x$GNUTLS_ENABLED" = "x1" -o \
  1449. "x$MBEDTLS_ENABLED" = "x1" -o \
  1450. "x$WOLFSSL_ENABLED" = "x1"; then
  1451. check_capath="/etc/ssl/certs"
  1452. fi
  1453. fi
  1454. else
  1455. dnl no option given and cross-compiling
  1456. AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
  1457. fi
  1458. fi
  1459. if test "x$ca" = "xno" || test -f "$ca"; then
  1460. ca_warning=""
  1461. fi
  1462. if test "x$capath" != "xno"; then
  1463. check_capath="$capath"
  1464. fi
  1465. if test ! -z "$check_capath"; then
  1466. for a in "$check_capath"; do
  1467. 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
  1468. if test "x$capath" = "xno"; then
  1469. capath="$a"
  1470. fi
  1471. capath_warning=""
  1472. break
  1473. fi
  1474. done
  1475. fi
  1476. if test "x$capath" = "xno"; then
  1477. capath_warning=""
  1478. fi
  1479. if test "x$ca" != "xno"; then
  1480. CURL_CA_BUNDLE='"'$ca'"'
  1481. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  1482. AC_SUBST(CURL_CA_BUNDLE)
  1483. AC_MSG_RESULT([$ca])
  1484. fi
  1485. if test "x$capath" != "xno"; then
  1486. CURL_CA_PATH="\"$capath\""
  1487. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  1488. AC_MSG_RESULT([$capath (capath)])
  1489. fi
  1490. if test "x$ca" = "xno" && test "x$capath" = "xno"; then
  1491. AC_MSG_RESULT([no])
  1492. fi
  1493. AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
  1494. AC_ARG_WITH(ca-fallback,
  1495. AS_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
  1496. AS_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
  1497. [
  1498. if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
  1499. AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
  1500. fi
  1501. ],
  1502. [ with_ca_fallback="no"])
  1503. AC_MSG_RESULT([$with_ca_fallback])
  1504. if test "x$with_ca_fallback" = "xyes"; then
  1505. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
  1506. AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
  1507. fi
  1508. AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
  1509. fi
  1510. ])
  1511. dnl CURL_CHECK_WIN32_LARGEFILE
  1512. dnl -------------------------------------------------
  1513. dnl Check if curl's WIN32 large file will be used
  1514. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  1515. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  1516. AC_MSG_CHECKING([whether build target supports WIN32 file API])
  1517. curl_win32_file_api="no"
  1518. if test "$curl_cv_header_windows_h" = "yes"; then
  1519. if test x"$enable_largefile" != "xno"; then
  1520. AC_COMPILE_IFELSE([
  1521. AC_LANG_PROGRAM([[
  1522. ]],[[
  1523. #if !defined(_WIN32_WCE) && \
  1524. (defined(__MINGW32__) || \
  1525. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
  1526. int dummy=1;
  1527. #else
  1528. WIN32 large file API not supported.
  1529. #endif
  1530. ]])
  1531. ],[
  1532. curl_win32_file_api="win32_large_files"
  1533. ])
  1534. fi
  1535. if test "$curl_win32_file_api" = "no"; then
  1536. AC_COMPILE_IFELSE([
  1537. AC_LANG_PROGRAM([[
  1538. ]],[[
  1539. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  1540. int dummy=1;
  1541. #else
  1542. WIN32 small file API not supported.
  1543. #endif
  1544. ]])
  1545. ],[
  1546. curl_win32_file_api="win32_small_files"
  1547. ])
  1548. fi
  1549. fi
  1550. case "$curl_win32_file_api" in
  1551. win32_large_files)
  1552. AC_MSG_RESULT([yes (large file enabled)])
  1553. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  1554. [Define to 1 if you are building a Windows target with large file support.])
  1555. AC_SUBST(USE_WIN32_LARGE_FILES, [1])
  1556. ;;
  1557. win32_small_files)
  1558. AC_MSG_RESULT([yes (large file disabled)])
  1559. AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
  1560. [Define to 1 if you are building a Windows target without large file support.])
  1561. AC_SUBST(USE_WIN32_SMALL_FILES, [1])
  1562. ;;
  1563. *)
  1564. AC_MSG_RESULT([no])
  1565. ;;
  1566. esac
  1567. ])
  1568. dnl CURL_CHECK_WIN32_CRYPTO
  1569. dnl -------------------------------------------------
  1570. dnl Check if curl's WIN32 crypto lib can be used
  1571. AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
  1572. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  1573. AC_MSG_CHECKING([whether build target supports WIN32 crypto API])
  1574. curl_win32_crypto_api="no"
  1575. if test "$curl_cv_header_windows_h" = "yes"; then
  1576. AC_COMPILE_IFELSE([
  1577. AC_LANG_PROGRAM([[
  1578. #undef inline
  1579. #ifndef WIN32_LEAN_AND_MEAN
  1580. #define WIN32_LEAN_AND_MEAN
  1581. #endif
  1582. #include <windows.h>
  1583. #include <wincrypt.h>
  1584. ]],[[
  1585. HCRYPTPROV hCryptProv;
  1586. if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
  1587. CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
  1588. CryptReleaseContext(hCryptProv, 0);
  1589. }
  1590. ]])
  1591. ],[
  1592. curl_win32_crypto_api="yes"
  1593. ])
  1594. fi
  1595. case "$curl_win32_crypto_api" in
  1596. yes)
  1597. AC_MSG_RESULT([yes])
  1598. AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
  1599. [Define to 1 if you are building a Windows target with crypto API support.])
  1600. AC_SUBST(USE_WIN32_CRYPTO, [1])
  1601. ;;
  1602. *)
  1603. AC_MSG_RESULT([no])
  1604. ;;
  1605. esac
  1606. ])
  1607. dnl CURL_EXPORT_PCDIR ($pcdir)
  1608. dnl ------------------------
  1609. dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
  1610. dnl
  1611. dnl we need this macro since pkg-config distinguishes among empty and unset
  1612. dnl variable while checking PKG_CONFIG_LIBDIR
  1613. dnl
  1614. AC_DEFUN([CURL_EXPORT_PCDIR], [
  1615. if test -n "$1"; then
  1616. PKG_CONFIG_LIBDIR="$1"
  1617. export PKG_CONFIG_LIBDIR
  1618. fi
  1619. ])
  1620. dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
  1621. dnl ------------------------
  1622. dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
  1623. dnl path to it, or 'no' if not found/present.
  1624. dnl
  1625. dnl If pkg-config is present, check that it has info about the $module or
  1626. dnl return "no" anyway!
  1627. dnl
  1628. dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
  1629. dnl
  1630. AC_DEFUN([CURL_CHECK_PKGCONFIG], [
  1631. if test -n "$PKG_CONFIG"; then
  1632. PKGCONFIG="$PKG_CONFIG"
  1633. else
  1634. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
  1635. [$PATH:/usr/bin:/usr/local/bin])
  1636. fi
  1637. if test "x$PKGCONFIG" != "xno"; then
  1638. AC_MSG_CHECKING([for $1 options with pkg-config])
  1639. dnl ask pkg-config about $1
  1640. itexists=`CURL_EXPORT_PCDIR([$2]) dnl
  1641. $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
  1642. if test -z "$itexists"; then
  1643. dnl pkg-config does not have info about the given module! set the
  1644. dnl variable to 'no'
  1645. PKGCONFIG="no"
  1646. AC_MSG_RESULT([no])
  1647. else
  1648. AC_MSG_RESULT([found])
  1649. fi
  1650. fi
  1651. ])
  1652. dnl CURL_GENERATE_CONFIGUREHELP_PM
  1653. dnl -------------------------------------------------
  1654. dnl Generate test harness configurehelp.pm module, defining and
  1655. dnl initializing some perl variables with values which are known
  1656. dnl when the configure script runs. For portability reasons, test
  1657. dnl harness needs information on how to run the C preprocessor.
  1658. AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
  1659. AC_REQUIRE([AC_PROG_CPP])dnl
  1660. tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
  1661. if test -z "$tmp_cpp"; then
  1662. tmp_cpp='cpp'
  1663. fi
  1664. cat >./tests/configurehelp.pm <<_EOF
  1665. [@%:@] This is a generated file. Do not edit.
  1666. package configurehelp;
  1667. use strict;
  1668. use warnings;
  1669. use Exporter;
  1670. use vars qw(
  1671. @ISA
  1672. @EXPORT_OK
  1673. \$Cpreprocessor
  1674. );
  1675. @ISA = qw(Exporter);
  1676. @EXPORT_OK = qw(
  1677. \$Cpreprocessor
  1678. );
  1679. \$Cpreprocessor = '$tmp_cpp';
  1680. 1;
  1681. _EOF
  1682. ])
  1683. dnl CURL_CPP_P
  1684. dnl
  1685. dnl Check if $cpp -P should be used for extract define values due to gcc 5
  1686. dnl splitting up strings and defines between line outputs. gcc by default
  1687. dnl (without -P) will show TEST EINVAL TEST as
  1688. dnl
  1689. dnl # 13 "conftest.c"
  1690. dnl TEST
  1691. dnl # 13 "conftest.c" 3 4
  1692. dnl 22
  1693. dnl # 13 "conftest.c"
  1694. dnl TEST
  1695. AC_DEFUN([CURL_CPP_P], [
  1696. AC_MSG_CHECKING([if cpp -P is needed])
  1697. AC_EGREP_CPP([TEST.*TEST], [
  1698. #include <errno.h>
  1699. TEST EINVAL TEST
  1700. ], [cpp=no], [cpp=yes])
  1701. AC_MSG_RESULT([$cpp])
  1702. dnl we need cpp -P so check if it works then
  1703. if test "x$cpp" = "xyes"; then
  1704. AC_MSG_CHECKING([if cpp -P works])
  1705. OLDCPPFLAGS=$CPPFLAGS
  1706. CPPFLAGS="$CPPFLAGS -P"
  1707. AC_EGREP_CPP([TEST.*TEST], [
  1708. #include <errno.h>
  1709. TEST EINVAL TEST
  1710. ], [cpp_p=yes], [cpp_p=no])
  1711. AC_MSG_RESULT([$cpp_p])
  1712. if test "x$cpp_p" = "xno"; then
  1713. AC_MSG_WARN([failed to figure out cpp -P alternative])
  1714. # without -P
  1715. CPPPFLAG=""
  1716. else
  1717. # with -P
  1718. CPPPFLAG="-P"
  1719. fi
  1720. dnl restore CPPFLAGS
  1721. CPPFLAGS=$OLDCPPFLAGS
  1722. else
  1723. # without -P
  1724. CPPPFLAG=""
  1725. fi
  1726. ])
  1727. dnl CURL_DARWIN_CFLAGS
  1728. dnl
  1729. dnl Set -Werror=partial-availability to detect possible breaking code
  1730. dnl with very low deployment targets.
  1731. dnl
  1732. AC_DEFUN([CURL_DARWIN_CFLAGS], [
  1733. tst_cflags="no"
  1734. case $host_os in
  1735. darwin*)
  1736. tst_cflags="yes"
  1737. ;;
  1738. esac
  1739. AC_MSG_CHECKING([for good-to-use Darwin CFLAGS])
  1740. AC_MSG_RESULT([$tst_cflags]);
  1741. if test "$tst_cflags" = "yes"; then
  1742. old_CFLAGS=$CFLAGS
  1743. CFLAGS="$CFLAGS -Werror=partial-availability"
  1744. AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
  1745. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  1746. [AC_MSG_RESULT([yes])],
  1747. [AC_MSG_RESULT([no])
  1748. CFLAGS=$old_CFLAGS])
  1749. fi
  1750. ])
  1751. dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
  1752. dnl
  1753. dnl Check to see if the compiler supports __builtin_available. This built-in
  1754. dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
  1755. dnl the time this macro was written, the function was not yet documented. Its
  1756. dnl purpose is to return true if the code is running under a certain OS version
  1757. dnl or later.
  1758. AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
  1759. AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
  1760. AC_COMPILE_IFELSE([
  1761. AC_LANG_PROGRAM([[
  1762. #include <stdlib.h>
  1763. ]],[[
  1764. if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
  1765. ]])
  1766. ],[
  1767. AC_MSG_RESULT([yes])
  1768. AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
  1769. [Define to 1 if you have the __builtin_available function.])
  1770. ],[
  1771. AC_MSG_RESULT([no])
  1772. ])
  1773. ])