2
0

acinclude.m4 49 KB

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