acinclude.m4 49 KB

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