acinclude.m4 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689
  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. #error 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. #error 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_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
  149. AC_EGREP_CPP([yes_this_is_aix],[
  150. #ifdef _AIX
  151. yes_this_is_aix
  152. #endif
  153. ],[
  154. AC_MSG_RESULT([yes])
  155. AC_DEFINE(_ALL_SOURCE)
  156. ],[
  157. AC_MSG_RESULT([no])
  158. ])
  159. ])
  160. dnl CURL_CHECK_NATIVE_WINDOWS
  161. dnl -------------------------------------------------
  162. dnl Check if building a native Windows target
  163. AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
  164. AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
  165. AC_COMPILE_IFELSE([
  166. AC_LANG_PROGRAM([[
  167. ]],[[
  168. #ifdef _WIN32
  169. int dummy=1;
  170. #else
  171. #error Not a native Windows build target.
  172. #endif
  173. ]])
  174. ],[
  175. curl_cv_native_windows="yes"
  176. ],[
  177. curl_cv_native_windows="no"
  178. ])
  179. ])
  180. AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
  181. ])
  182. dnl CURL_CHECK_HEADER_LBER
  183. dnl -------------------------------------------------
  184. dnl Check for compilable and valid lber.h header,
  185. dnl and check if it is needed even with ldap.h
  186. AC_DEFUN([CURL_CHECK_HEADER_LBER], [
  187. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  188. AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
  189. AC_COMPILE_IFELSE([
  190. AC_LANG_PROGRAM([[
  191. #undef inline
  192. #ifdef _WIN32
  193. #ifndef WIN32_LEAN_AND_MEAN
  194. #define WIN32_LEAN_AND_MEAN
  195. #endif
  196. #include <windows.h>
  197. #else
  198. #ifdef HAVE_SYS_TYPES_H
  199. #include <sys/types.h>
  200. #endif
  201. #endif
  202. #ifndef NULL
  203. #define NULL (void *)0
  204. #endif
  205. #include <lber.h>
  206. ]],[[
  207. BerValue *bvp = NULL;
  208. BerElement *bep = ber_init(bvp);
  209. ber_free(bep, 1);
  210. ]])
  211. ],[
  212. curl_cv_header_lber_h="yes"
  213. ],[
  214. curl_cv_header_lber_h="no"
  215. ])
  216. ])
  217. if test "$curl_cv_header_lber_h" = "yes"; then
  218. AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
  219. [Define to 1 if you have the lber.h header file.])
  220. #
  221. AC_COMPILE_IFELSE([
  222. AC_LANG_PROGRAM([[
  223. #undef inline
  224. #ifdef _WIN32
  225. #ifndef WIN32_LEAN_AND_MEAN
  226. #define WIN32_LEAN_AND_MEAN
  227. #endif
  228. #include <windows.h>
  229. #else
  230. #ifdef HAVE_SYS_TYPES_H
  231. #include <sys/types.h>
  232. #endif
  233. #endif
  234. #ifndef NULL
  235. #define NULL (void *)0
  236. #endif
  237. #ifndef LDAP_DEPRECATED
  238. #define LDAP_DEPRECATED 1
  239. #endif
  240. #include <ldap.h>
  241. ]],[[
  242. BerValue *bvp = NULL;
  243. BerElement *bep = ber_init(bvp);
  244. ber_free(bep, 1);
  245. ]])
  246. ],[
  247. curl_cv_need_header_lber_h="no"
  248. ],[
  249. curl_cv_need_header_lber_h="yes"
  250. ])
  251. #
  252. case "$curl_cv_need_header_lber_h" in
  253. yes)
  254. AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
  255. [Define to 1 if you need the lber.h header file even with ldap.h])
  256. ;;
  257. esac
  258. fi
  259. ])
  260. dnl CURL_CHECK_HEADER_LDAP
  261. dnl -------------------------------------------------
  262. dnl Check for compilable and valid ldap.h header
  263. AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
  264. AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
  265. AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
  266. AC_COMPILE_IFELSE([
  267. AC_LANG_PROGRAM([[
  268. #undef inline
  269. #ifdef _WIN32
  270. #ifndef WIN32_LEAN_AND_MEAN
  271. #define WIN32_LEAN_AND_MEAN
  272. #endif
  273. #include <windows.h>
  274. #else
  275. #ifdef HAVE_SYS_TYPES_H
  276. #include <sys/types.h>
  277. #endif
  278. #endif
  279. #ifndef LDAP_DEPRECATED
  280. #define LDAP_DEPRECATED 1
  281. #endif
  282. #ifdef NEED_LBER_H
  283. #include <lber.h>
  284. #endif
  285. #include <ldap.h>
  286. ]],[[
  287. LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
  288. int res = ldap_unbind(ldp);
  289. ]])
  290. ],[
  291. curl_cv_header_ldap_h="yes"
  292. ],[
  293. curl_cv_header_ldap_h="no"
  294. ])
  295. ])
  296. case "$curl_cv_header_ldap_h" in
  297. yes)
  298. AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
  299. [Define to 1 if you have the ldap.h header file.])
  300. ;;
  301. esac
  302. ])
  303. dnl CURL_CHECK_HEADER_LDAP_SSL
  304. dnl -------------------------------------------------
  305. dnl Check for compilable and valid ldap_ssl.h header
  306. AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
  307. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  308. AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
  309. AC_COMPILE_IFELSE([
  310. AC_LANG_PROGRAM([[
  311. #undef inline
  312. #ifdef _WIN32
  313. #ifndef WIN32_LEAN_AND_MEAN
  314. #define WIN32_LEAN_AND_MEAN
  315. #endif
  316. #include <windows.h>
  317. #else
  318. #ifdef HAVE_SYS_TYPES_H
  319. #include <sys/types.h>
  320. #endif
  321. #endif
  322. #ifndef LDAP_DEPRECATED
  323. #define LDAP_DEPRECATED 1
  324. #endif
  325. #ifdef NEED_LBER_H
  326. #include <lber.h>
  327. #endif
  328. #ifdef HAVE_LDAP_H
  329. #include <ldap.h>
  330. #endif
  331. #include <ldap_ssl.h>
  332. ]],[[
  333. LDAP *ldp = ldapssl_init("0.0.0.0", LDAPS_PORT, 1);
  334. ]])
  335. ],[
  336. curl_cv_header_ldap_ssl_h="yes"
  337. ],[
  338. curl_cv_header_ldap_ssl_h="no"
  339. ])
  340. ])
  341. case "$curl_cv_header_ldap_ssl_h" in
  342. yes)
  343. AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
  344. [Define to 1 if you have the ldap_ssl.h header file.])
  345. ;;
  346. esac
  347. ])
  348. dnl CURL_CHECK_LIBS_WINLDAP
  349. dnl -------------------------------------------------
  350. dnl Check for libraries needed for WINLDAP support,
  351. dnl and prepended to LIBS any needed libraries.
  352. dnl This macro can take an optional parameter with a
  353. dnl whitespace separated list of libraries to check
  354. dnl before the WINLDAP default ones.
  355. AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
  356. AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
  357. #
  358. AC_MSG_CHECKING([for WINLDAP libraries])
  359. #
  360. u_libs=""
  361. #
  362. ifelse($1,,,[
  363. for x_lib in $1; do
  364. case "$x_lib" in
  365. -l*)
  366. l_lib="$x_lib"
  367. ;;
  368. *)
  369. l_lib="-l$x_lib"
  370. ;;
  371. esac
  372. if test -z "$u_libs"; then
  373. u_libs="$l_lib"
  374. else
  375. u_libs="$u_libs $l_lib"
  376. fi
  377. done
  378. ])
  379. #
  380. curl_cv_save_LIBS="$LIBS"
  381. curl_cv_ldap_LIBS="unknown"
  382. #
  383. for x_nlibs in '' "$u_libs" \
  384. '-lwldap32' ; do
  385. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  386. if test -z "$x_nlibs"; then
  387. LIBS="$curl_cv_save_LIBS"
  388. else
  389. LIBS="$x_nlibs $curl_cv_save_LIBS"
  390. fi
  391. AC_LINK_IFELSE([
  392. AC_LANG_PROGRAM([[
  393. #undef inline
  394. #ifdef _WIN32
  395. #ifndef WIN32_LEAN_AND_MEAN
  396. #define WIN32_LEAN_AND_MEAN
  397. #endif
  398. #include <windows.h>
  399. #include <winldap.h>
  400. #ifdef HAVE_WINBER_H
  401. #include <winber.h>
  402. #endif
  403. #endif
  404. ]],[[
  405. BERVAL *bvp = NULL;
  406. BerElement *bep = ber_init(bvp);
  407. LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
  408. ULONG res = ldap_unbind(ldp);
  409. ber_free(bep, 1);
  410. ]])
  411. ],[
  412. curl_cv_ldap_LIBS="$x_nlibs"
  413. ])
  414. fi
  415. done
  416. #
  417. LIBS="$curl_cv_save_LIBS"
  418. #
  419. case X-"$curl_cv_ldap_LIBS" in
  420. X-unknown)
  421. AC_MSG_RESULT([cannot find WINLDAP libraries])
  422. ;;
  423. X-)
  424. AC_MSG_RESULT([no additional lib required])
  425. ;;
  426. *)
  427. if test -z "$curl_cv_save_LIBS"; then
  428. LIBS="$curl_cv_ldap_LIBS"
  429. else
  430. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  431. fi
  432. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  433. ;;
  434. esac
  435. #
  436. ])
  437. dnl CURL_CHECK_LIBS_LDAP
  438. dnl -------------------------------------------------
  439. dnl Check for libraries needed for LDAP support,
  440. dnl and prepended to LIBS any needed libraries.
  441. dnl This macro can take an optional parameter with a
  442. dnl whitespace separated list of libraries to check
  443. dnl before the default ones.
  444. AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
  445. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  446. #
  447. AC_MSG_CHECKING([for LDAP libraries])
  448. #
  449. u_libs=""
  450. #
  451. ifelse($1,,,[
  452. for x_lib in $1; do
  453. case "$x_lib" in
  454. -l*)
  455. l_lib="$x_lib"
  456. ;;
  457. *)
  458. l_lib="-l$x_lib"
  459. ;;
  460. esac
  461. if test -z "$u_libs"; then
  462. u_libs="$l_lib"
  463. else
  464. u_libs="$u_libs $l_lib"
  465. fi
  466. done
  467. ])
  468. #
  469. curl_cv_save_LIBS="$LIBS"
  470. curl_cv_ldap_LIBS="unknown"
  471. #
  472. for x_nlibs in '' "$u_libs" \
  473. '-lldap' \
  474. '-lldap -llber' \
  475. '-llber -lldap' \
  476. '-lldapssl -lldapx -lldapsdk' \
  477. '-lldapsdk -lldapx -lldapssl' \
  478. '-lldap -llber -lssl -lcrypto' ; do
  479. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  480. if test -z "$x_nlibs"; then
  481. LIBS="$curl_cv_save_LIBS"
  482. else
  483. LIBS="$x_nlibs $curl_cv_save_LIBS"
  484. fi
  485. AC_LINK_IFELSE([
  486. AC_LANG_PROGRAM([[
  487. #undef inline
  488. #ifdef _WIN32
  489. #ifndef WIN32_LEAN_AND_MEAN
  490. #define WIN32_LEAN_AND_MEAN
  491. #endif
  492. #include <windows.h>
  493. #else
  494. #ifdef HAVE_SYS_TYPES_H
  495. #include <sys/types.h>
  496. #endif
  497. #endif
  498. #ifndef NULL
  499. #define NULL (void *)0
  500. #endif
  501. #ifndef LDAP_DEPRECATED
  502. #define LDAP_DEPRECATED 1
  503. #endif
  504. #ifdef NEED_LBER_H
  505. #include <lber.h>
  506. #endif
  507. #ifdef HAVE_LDAP_H
  508. #include <ldap.h>
  509. #endif
  510. ]],[[
  511. BerValue *bvp = NULL;
  512. BerElement *bep = ber_init(bvp);
  513. LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
  514. int res = ldap_unbind(ldp);
  515. ber_free(bep, 1);
  516. ]])
  517. ],[
  518. curl_cv_ldap_LIBS="$x_nlibs"
  519. ])
  520. fi
  521. done
  522. #
  523. LIBS="$curl_cv_save_LIBS"
  524. #
  525. case X-"$curl_cv_ldap_LIBS" in
  526. X-unknown)
  527. AC_MSG_RESULT([cannot find LDAP libraries])
  528. ;;
  529. X-)
  530. AC_MSG_RESULT([no additional lib required])
  531. ;;
  532. *)
  533. if test -z "$curl_cv_save_LIBS"; then
  534. LIBS="$curl_cv_ldap_LIBS"
  535. else
  536. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  537. fi
  538. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  539. ;;
  540. esac
  541. #
  542. ])
  543. dnl TYPE_SOCKADDR_STORAGE
  544. dnl -------------------------------------------------
  545. dnl Check for struct sockaddr_storage. Most IPv6-enabled
  546. dnl hosts have it, but AIX 4.3 is one known exception.
  547. AC_DEFUN([TYPE_SOCKADDR_STORAGE],
  548. [
  549. AC_CHECK_TYPE([struct sockaddr_storage],
  550. AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
  551. [if struct sockaddr_storage is defined]), ,
  552. [
  553. #undef inline
  554. #ifdef _WIN32
  555. #ifndef WIN32_LEAN_AND_MEAN
  556. #define WIN32_LEAN_AND_MEAN
  557. #endif
  558. #include <winsock2.h>
  559. #else
  560. #ifdef HAVE_SYS_TYPES_H
  561. #include <sys/types.h>
  562. #endif
  563. #ifdef HAVE_SYS_SOCKET_H
  564. #include <sys/socket.h>
  565. #endif
  566. #ifdef HAVE_NETINET_IN_H
  567. #include <netinet/in.h>
  568. #endif
  569. #ifdef HAVE_ARPA_INET_H
  570. #include <arpa/inet.h>
  571. #endif
  572. #endif
  573. ])
  574. ])
  575. dnl CURL_CHECK_FUNC_RECV
  576. dnl -------------------------------------------------
  577. dnl Test if the socket recv() function is available,
  578. AC_DEFUN([CURL_CHECK_FUNC_RECV], [
  579. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  580. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  581. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  582. #
  583. AC_MSG_CHECKING([for recv])
  584. AC_LINK_IFELSE([
  585. AC_LANG_PROGRAM([[
  586. #undef inline
  587. #ifdef _WIN32
  588. #ifndef WIN32_LEAN_AND_MEAN
  589. #define WIN32_LEAN_AND_MEAN
  590. #endif
  591. #include <winsock2.h>
  592. #else
  593. $curl_includes_bsdsocket
  594. #ifdef HAVE_SYS_TYPES_H
  595. #include <sys/types.h>
  596. #endif
  597. #ifdef HAVE_SYS_SOCKET_H
  598. #include <sys/socket.h>
  599. #endif
  600. #endif
  601. ]],[[
  602. recv(0, 0, 0, 0);
  603. ]])
  604. ],[
  605. AC_MSG_RESULT([yes])
  606. curl_cv_recv="yes"
  607. ],[
  608. AC_MSG_RESULT([no])
  609. curl_cv_recv="no"
  610. ])
  611. #
  612. if test "$curl_cv_recv" = "yes"; then
  613. AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
  614. [Define to 1 if you have the recv function.])
  615. curl_cv_func_recv="yes"
  616. else
  617. AC_MSG_ERROR([Unable to link function recv])
  618. fi
  619. ])
  620. dnl CURL_CHECK_FUNC_SEND
  621. dnl -------------------------------------------------
  622. dnl Test if the socket send() function is available,
  623. AC_DEFUN([CURL_CHECK_FUNC_SEND], [
  624. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  625. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  626. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  627. #
  628. AC_MSG_CHECKING([for send])
  629. AC_LINK_IFELSE([
  630. AC_LANG_PROGRAM([[
  631. #undef inline
  632. #ifdef _WIN32
  633. #ifndef WIN32_LEAN_AND_MEAN
  634. #define WIN32_LEAN_AND_MEAN
  635. #endif
  636. #include <winsock2.h>
  637. #else
  638. $curl_includes_bsdsocket
  639. #ifdef HAVE_SYS_TYPES_H
  640. #include <sys/types.h>
  641. #endif
  642. #ifdef HAVE_SYS_SOCKET_H
  643. #include <sys/socket.h>
  644. #endif
  645. #endif
  646. ]],[[
  647. send(0, 0, 0, 0);
  648. ]])
  649. ],[
  650. AC_MSG_RESULT([yes])
  651. curl_cv_send="yes"
  652. ],[
  653. AC_MSG_RESULT([no])
  654. curl_cv_send="no"
  655. ])
  656. #
  657. if test "$curl_cv_send" = "yes"; then
  658. AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
  659. [Define to 1 if you have the send function.])
  660. curl_cv_func_send="yes"
  661. else
  662. AC_MSG_ERROR([Unable to link function send])
  663. fi
  664. ])
  665. dnl CURL_CHECK_MSG_NOSIGNAL
  666. dnl -------------------------------------------------
  667. dnl Check for MSG_NOSIGNAL
  668. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  669. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  670. AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
  671. AC_COMPILE_IFELSE([
  672. AC_LANG_PROGRAM([[
  673. #undef inline
  674. #ifdef _WIN32
  675. #ifndef WIN32_LEAN_AND_MEAN
  676. #define WIN32_LEAN_AND_MEAN
  677. #endif
  678. #include <winsock2.h>
  679. #else
  680. #ifdef HAVE_SYS_TYPES_H
  681. #include <sys/types.h>
  682. #endif
  683. #ifdef HAVE_SYS_SOCKET_H
  684. #include <sys/socket.h>
  685. #endif
  686. #endif
  687. ]],[[
  688. int flag=MSG_NOSIGNAL;
  689. ]])
  690. ],[
  691. curl_cv_msg_nosignal="yes"
  692. ],[
  693. curl_cv_msg_nosignal="no"
  694. ])
  695. ])
  696. case "$curl_cv_msg_nosignal" in
  697. yes)
  698. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  699. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  700. ;;
  701. esac
  702. ])
  703. dnl CURL_CHECK_STRUCT_TIMEVAL
  704. dnl -------------------------------------------------
  705. dnl Check for timeval struct
  706. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  707. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  708. AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h)
  709. AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
  710. AC_COMPILE_IFELSE([
  711. AC_LANG_PROGRAM([[
  712. #undef inline
  713. #ifdef _WIN32
  714. #ifndef WIN32_LEAN_AND_MEAN
  715. #define WIN32_LEAN_AND_MEAN
  716. #endif
  717. #include <winsock2.h>
  718. #endif
  719. #ifdef HAVE_SYS_TYPES_H
  720. #include <sys/types.h>
  721. #endif
  722. #ifdef HAVE_SYS_TIME_H
  723. #include <sys/time.h>
  724. #endif
  725. #include <time.h>
  726. #ifdef HAVE_SYS_SOCKET_H
  727. #include <sys/socket.h>
  728. #endif
  729. ]],[[
  730. struct timeval ts;
  731. ts.tv_sec = 0;
  732. ts.tv_usec = 0;
  733. ]])
  734. ],[
  735. curl_cv_struct_timeval="yes"
  736. ],[
  737. curl_cv_struct_timeval="no"
  738. ])
  739. ])
  740. case "$curl_cv_struct_timeval" in
  741. yes)
  742. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  743. [Define to 1 if you have the timeval struct.])
  744. ;;
  745. esac
  746. ])
  747. dnl TYPE_IN_ADDR_T
  748. dnl -------------------------------------------------
  749. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  750. dnl and a few other things.
  751. AC_DEFUN([TYPE_IN_ADDR_T], [
  752. AC_CHECK_TYPE([in_addr_t], ,[
  753. dnl in_addr_t not available
  754. AC_CACHE_CHECK([for in_addr_t equivalent],
  755. [curl_cv_in_addr_t_equiv], [
  756. curl_cv_in_addr_t_equiv="unknown"
  757. for t in "unsigned long" int size_t unsigned long; do
  758. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  759. AC_LINK_IFELSE([
  760. AC_LANG_PROGRAM([[
  761. #undef inline
  762. #ifdef _WIN32
  763. #ifndef WIN32_LEAN_AND_MEAN
  764. #define WIN32_LEAN_AND_MEAN
  765. #endif
  766. #include <winsock2.h>
  767. #else
  768. #ifdef HAVE_SYS_TYPES_H
  769. #include <sys/types.h>
  770. #endif
  771. #ifdef HAVE_SYS_SOCKET_H
  772. #include <sys/socket.h>
  773. #endif
  774. #ifdef HAVE_NETINET_IN_H
  775. #include <netinet/in.h>
  776. #endif
  777. #ifdef HAVE_ARPA_INET_H
  778. #include <arpa/inet.h>
  779. #endif
  780. #endif
  781. ]],[[
  782. $t data = inet_addr ("1.2.3.4");
  783. ]])
  784. ],[
  785. curl_cv_in_addr_t_equiv="$t"
  786. ])
  787. fi
  788. done
  789. ])
  790. case "$curl_cv_in_addr_t_equiv" in
  791. unknown)
  792. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  793. ;;
  794. *)
  795. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  796. [Type to use in place of in_addr_t when system does not provide it.])
  797. ;;
  798. esac
  799. ],[
  800. #undef inline
  801. #ifdef _WIN32
  802. #ifndef WIN32_LEAN_AND_MEAN
  803. #define WIN32_LEAN_AND_MEAN
  804. #endif
  805. #include <winsock2.h>
  806. #else
  807. #ifdef HAVE_SYS_TYPES_H
  808. #include <sys/types.h>
  809. #endif
  810. #ifdef HAVE_SYS_SOCKET_H
  811. #include <sys/socket.h>
  812. #endif
  813. #ifdef HAVE_NETINET_IN_H
  814. #include <netinet/in.h>
  815. #endif
  816. #ifdef HAVE_ARPA_INET_H
  817. #include <arpa/inet.h>
  818. #endif
  819. #endif
  820. ])
  821. ])
  822. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  823. dnl -------------------------------------------------
  824. dnl Check if monotonic clock_gettime is available.
  825. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  826. AC_CHECK_HEADERS(sys/types.h sys/time.h)
  827. AC_MSG_CHECKING([for monotonic clock_gettime])
  828. #
  829. if test "x$dontwant_rt" = "xno" ; then
  830. AC_COMPILE_IFELSE([
  831. AC_LANG_PROGRAM([[
  832. #ifdef HAVE_SYS_TYPES_H
  833. #include <sys/types.h>
  834. #endif
  835. #ifdef HAVE_SYS_TIME_H
  836. #include <sys/time.h>
  837. #endif
  838. #include <time.h>
  839. ]],[[
  840. struct timespec ts;
  841. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  842. ]])
  843. ],[
  844. AC_MSG_RESULT([yes])
  845. curl_func_clock_gettime="yes"
  846. ],[
  847. AC_MSG_RESULT([no])
  848. curl_func_clock_gettime="no"
  849. ])
  850. fi
  851. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  852. dnl until library linking and run-time checks for clock_gettime succeed.
  853. ])
  854. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW
  855. dnl -------------------------------------------------
  856. dnl Check if monotonic clock_gettime is available.
  857. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW], [
  858. AC_CHECK_HEADERS(sys/types.h sys/time.h)
  859. AC_MSG_CHECKING([for raw monotonic clock_gettime])
  860. #
  861. if test "x$dontwant_rt" = "xno" ; then
  862. AC_COMPILE_IFELSE([
  863. AC_LANG_PROGRAM([[
  864. #ifdef HAVE_SYS_TYPES_H
  865. #include <sys/types.h>
  866. #endif
  867. #ifdef HAVE_SYS_TIME_H
  868. #include <sys/time.h>
  869. #endif
  870. #include <time.h>
  871. ]],[[
  872. struct timespec ts;
  873. (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
  874. ]])
  875. ],[
  876. AC_MSG_RESULT([yes])
  877. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC_RAW, 1,
  878. [Define to 1 if you have the clock_gettime function and raw monotonic timer.])
  879. ],[
  880. AC_MSG_RESULT([no])
  881. ])
  882. fi
  883. ])
  884. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  885. dnl -------------------------------------------------
  886. dnl If monotonic clock_gettime is available then,
  887. dnl check and prepended to LIBS any needed libraries.
  888. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  889. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  890. #
  891. if test "$curl_func_clock_gettime" = "yes"; then
  892. #
  893. AC_MSG_CHECKING([for clock_gettime in libraries])
  894. #
  895. curl_cv_save_LIBS="$LIBS"
  896. curl_cv_gclk_LIBS="unknown"
  897. #
  898. for x_xlibs in '' '-lrt' '-lposix4' ; do
  899. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  900. if test -z "$x_xlibs"; then
  901. LIBS="$curl_cv_save_LIBS"
  902. else
  903. LIBS="$x_xlibs $curl_cv_save_LIBS"
  904. fi
  905. AC_LINK_IFELSE([
  906. AC_LANG_PROGRAM([[
  907. #ifdef HAVE_SYS_TYPES_H
  908. #include <sys/types.h>
  909. #endif
  910. #ifdef HAVE_SYS_TIME_H
  911. #include <sys/time.h>
  912. #endif
  913. #include <time.h>
  914. ]],[[
  915. struct timespec ts;
  916. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  917. ]])
  918. ],[
  919. curl_cv_gclk_LIBS="$x_xlibs"
  920. ])
  921. fi
  922. done
  923. #
  924. LIBS="$curl_cv_save_LIBS"
  925. #
  926. case X-"$curl_cv_gclk_LIBS" in
  927. X-unknown)
  928. AC_MSG_RESULT([cannot find clock_gettime])
  929. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  930. curl_func_clock_gettime="no"
  931. ;;
  932. X-)
  933. AC_MSG_RESULT([no additional lib required])
  934. curl_func_clock_gettime="yes"
  935. ;;
  936. *)
  937. if test -z "$curl_cv_save_LIBS"; then
  938. LIBS="$curl_cv_gclk_LIBS"
  939. else
  940. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  941. fi
  942. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  943. curl_func_clock_gettime="yes"
  944. ;;
  945. esac
  946. #
  947. dnl only do runtime verification when not cross-compiling
  948. if test "x$cross_compiling" != "xyes" &&
  949. test "$curl_func_clock_gettime" = "yes"; then
  950. AC_MSG_CHECKING([if monotonic clock_gettime works])
  951. CURL_RUN_IFELSE([
  952. AC_LANG_PROGRAM([[
  953. #include <stdlib.h>
  954. #ifdef HAVE_SYS_TYPES_H
  955. #include <sys/types.h>
  956. #endif
  957. #ifdef HAVE_SYS_TIME_H
  958. #include <sys/time.h>
  959. #endif
  960. #include <time.h>
  961. ]],[[
  962. struct timespec ts;
  963. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  964. exit(0);
  965. else
  966. exit(1);
  967. ]])
  968. ],[
  969. AC_MSG_RESULT([yes])
  970. ],[
  971. AC_MSG_RESULT([no])
  972. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  973. curl_func_clock_gettime="no"
  974. LIBS="$curl_cv_save_LIBS"
  975. ])
  976. fi
  977. #
  978. case "$curl_func_clock_gettime" in
  979. yes)
  980. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  981. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  982. ;;
  983. esac
  984. #
  985. fi
  986. #
  987. ])
  988. dnl CURL_CHECK_LIBS_CONNECT
  989. dnl -------------------------------------------------
  990. dnl Verify if network connect function is already available
  991. dnl using current libraries or if another one is required.
  992. AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
  993. AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
  994. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  995. AC_MSG_CHECKING([for connect in libraries])
  996. tst_connect_save_LIBS="$LIBS"
  997. tst_connect_need_LIBS="unknown"
  998. for tst_lib in '' '-lsocket' ; do
  999. if test "$tst_connect_need_LIBS" = "unknown"; then
  1000. LIBS="$tst_lib $tst_connect_save_LIBS"
  1001. AC_LINK_IFELSE([
  1002. AC_LANG_PROGRAM([[
  1003. $curl_includes_winsock2
  1004. $curl_includes_bsdsocket
  1005. #if !defined(_WIN32) && !defined(HAVE_PROTO_BSDSOCKET_H)
  1006. int connect(int, void*, int);
  1007. #endif
  1008. ]],[[
  1009. if(0 != connect(0, 0, 0))
  1010. return 1;
  1011. ]])
  1012. ],[
  1013. tst_connect_need_LIBS="$tst_lib"
  1014. ])
  1015. fi
  1016. done
  1017. LIBS="$tst_connect_save_LIBS"
  1018. #
  1019. case X-"$tst_connect_need_LIBS" in
  1020. X-unknown)
  1021. AC_MSG_RESULT([cannot find connect])
  1022. AC_MSG_ERROR([cannot find connect function in libraries.])
  1023. ;;
  1024. X-)
  1025. AC_MSG_RESULT([yes])
  1026. ;;
  1027. *)
  1028. AC_MSG_RESULT([$tst_connect_need_LIBS])
  1029. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  1030. ;;
  1031. esac
  1032. ])
  1033. dnl CURL_CHECK_FUNC_SELECT
  1034. dnl -------------------------------------------------
  1035. dnl Test if the socket select() function is available.
  1036. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  1037. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  1038. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  1039. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  1040. #
  1041. AC_MSG_CHECKING([for select])
  1042. AC_LINK_IFELSE([
  1043. AC_LANG_PROGRAM([[
  1044. #undef inline
  1045. #ifdef _WIN32
  1046. #ifndef WIN32_LEAN_AND_MEAN
  1047. #define WIN32_LEAN_AND_MEAN
  1048. #endif
  1049. #include <winsock2.h>
  1050. #endif
  1051. #ifdef HAVE_SYS_TYPES_H
  1052. #include <sys/types.h>
  1053. #endif
  1054. #ifdef HAVE_SYS_TIME_H
  1055. #include <sys/time.h>
  1056. #endif
  1057. #include <time.h>
  1058. #ifndef _WIN32
  1059. #ifdef HAVE_SYS_SELECT_H
  1060. #include <sys/select.h>
  1061. #elif defined(HAVE_UNISTD_H)
  1062. #include <unistd.h>
  1063. #endif
  1064. #ifdef HAVE_SYS_SOCKET_H
  1065. #include <sys/socket.h>
  1066. #endif
  1067. $curl_includes_bsdsocket
  1068. #endif
  1069. ]],[[
  1070. select(0, 0, 0, 0, 0);
  1071. ]])
  1072. ],[
  1073. AC_MSG_RESULT([yes])
  1074. curl_cv_select="yes"
  1075. ],[
  1076. AC_MSG_RESULT([no])
  1077. curl_cv_select="no"
  1078. ])
  1079. #
  1080. if test "$curl_cv_select" = "yes"; then
  1081. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  1082. [Define to 1 if you have the select function.])
  1083. curl_cv_func_select="yes"
  1084. fi
  1085. ])
  1086. dnl CURL_VERIFY_RUNTIMELIBS
  1087. dnl -------------------------------------------------
  1088. dnl Verify that the shared libs found so far can be used when running
  1089. dnl programs, since otherwise the situation will create odd configure errors
  1090. dnl that are misleading people.
  1091. dnl
  1092. dnl Make sure this test is run BEFORE the first test in the script that
  1093. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  1094. dnl macro. It must also run AFTER all lib-checking macros are complete.
  1095. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  1096. dnl this test is of course not sensible if we are cross-compiling!
  1097. if test "x$cross_compiling" != xyes; then
  1098. dnl just run a program to verify that the libs checked for previous to this
  1099. dnl point also is available run-time!
  1100. AC_MSG_CHECKING([run-time libs availability])
  1101. CURL_RUN_IFELSE([
  1102. int main()
  1103. {
  1104. return 0;
  1105. }
  1106. ],
  1107. AC_MSG_RESULT([fine]),
  1108. AC_MSG_RESULT([failed])
  1109. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  1110. )
  1111. dnl if this test fails, configure has already stopped
  1112. fi
  1113. ])
  1114. dnl CURL_CHECK_CA_BUNDLE
  1115. dnl -------------------------------------------------
  1116. dnl Check if a default ca-bundle should be used
  1117. dnl
  1118. dnl regarding the paths this will scan:
  1119. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  1120. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  1121. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  1122. dnl /usr/local/share/certs/ca-root-nss.crt MidnightBSD
  1123. dnl /etc/ssl/cert.pem OpenBSD, MidnightBSD (symlink)
  1124. dnl /etc/ssl/certs (CA path) SUSE, FreeBSD
  1125. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  1126. AC_MSG_CHECKING([default CA cert bundle/path])
  1127. AC_ARG_WITH(ca-bundle,
  1128. AS_HELP_STRING([--with-ca-bundle=FILE],
  1129. [Absolute path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
  1130. AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  1131. [
  1132. want_ca="$withval"
  1133. if test "x$want_ca" = "xyes"; then
  1134. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  1135. fi
  1136. ],
  1137. [ want_ca="unset" ])
  1138. AC_ARG_WITH(ca-path,
  1139. AS_HELP_STRING([--with-ca-path=DIRECTORY],
  1140. [Absolute path to a directory containing CA certificates stored individually, with \
  1141. their filenames in a hash format. This option can be used with the OpenSSL, \
  1142. GnuTLS, mbedTLS and wolfSSL backends. Refer to OpenSSL c_rehash for details. \
  1143. (example: /etc/certificates)])
  1144. AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  1145. [
  1146. want_capath="$withval"
  1147. if test "x$want_capath" = "xyes"; then
  1148. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  1149. fi
  1150. ],
  1151. [ want_capath="unset"])
  1152. ca_warning=" (warning: certs not found)"
  1153. capath_warning=" (warning: certs not found)"
  1154. check_capath=""
  1155. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  1156. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  1157. dnl both given
  1158. ca="$want_ca"
  1159. capath="$want_capath"
  1160. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  1161. dnl --with-ca-bundle given
  1162. ca="$want_ca"
  1163. capath="no"
  1164. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  1165. dnl --with-ca-path given
  1166. capath="$want_capath"
  1167. ca="no"
  1168. else
  1169. dnl First try auto-detecting a CA bundle, then a CA path.
  1170. dnl Both auto-detections can be skipped by --without-ca-*
  1171. ca="no"
  1172. capath="no"
  1173. if test "x$cross_compiling" != "xyes" -a \
  1174. "x$curl_cv_native_windows" != "xyes"; then
  1175. dnl NOT cross-compiling and...
  1176. dnl neither of the --with-ca-* options are provided
  1177. if test "x$want_ca" = "xunset"; then
  1178. dnl the path we previously would have installed the curl CA bundle
  1179. dnl to, and thus we now check for an already existing cert in that
  1180. dnl place in case we find no other
  1181. if test "x$prefix" != xNONE; then
  1182. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  1183. else
  1184. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  1185. fi
  1186. for a in /etc/ssl/certs/ca-certificates.crt \
  1187. /etc/pki/tls/certs/ca-bundle.crt \
  1188. /usr/share/ssl/certs/ca-bundle.crt \
  1189. /usr/local/share/certs/ca-root-nss.crt \
  1190. /etc/ssl/cert.pem \
  1191. "$cac"; do
  1192. if test -f "$a"; then
  1193. ca="$a"
  1194. break
  1195. fi
  1196. done
  1197. fi
  1198. AC_MSG_NOTICE([want $want_capath ca $ca])
  1199. if test "x$want_capath" = "xunset"; then
  1200. check_capath="/etc/ssl/certs"
  1201. fi
  1202. else
  1203. dnl no option given and cross-compiling
  1204. AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
  1205. fi
  1206. fi
  1207. if test "x$ca" = "xno" || test -f "$ca"; then
  1208. ca_warning=""
  1209. fi
  1210. if test "x$capath" != "xno"; then
  1211. check_capath="$capath"
  1212. fi
  1213. if test ! -z "$check_capath"; then
  1214. for a in "$check_capath"; do
  1215. 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
  1216. if test "x$capath" = "xno"; then
  1217. capath="$a"
  1218. fi
  1219. capath_warning=""
  1220. break
  1221. fi
  1222. done
  1223. fi
  1224. if test "x$capath" = "xno"; then
  1225. capath_warning=""
  1226. fi
  1227. if test "x$ca" != "xno"; then
  1228. CURL_CA_BUNDLE="$ca"
  1229. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  1230. AC_SUBST(CURL_CA_BUNDLE)
  1231. AC_MSG_RESULT([$ca])
  1232. fi
  1233. if test "x$capath" != "xno"; then
  1234. CURL_CA_PATH="\"$capath\""
  1235. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  1236. AC_MSG_RESULT([$capath (capath)])
  1237. fi
  1238. if test "x$ca" = "xno" && test "x$capath" = "xno"; then
  1239. AC_MSG_RESULT([no])
  1240. fi
  1241. AC_MSG_CHECKING([whether to use built-in CA store of SSL library])
  1242. AC_ARG_WITH(ca-fallback,
  1243. AS_HELP_STRING([--with-ca-fallback], [Use the built-in CA store of the SSL library])
  1244. AS_HELP_STRING([--without-ca-fallback], [Don't use the built-in CA store of the SSL library]),
  1245. [
  1246. if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
  1247. AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
  1248. fi
  1249. ],
  1250. [ with_ca_fallback="no"])
  1251. AC_MSG_RESULT([$with_ca_fallback])
  1252. if test "x$with_ca_fallback" = "xyes"; then
  1253. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
  1254. AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
  1255. fi
  1256. AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built-in CA store of SSL library])
  1257. fi
  1258. ])
  1259. dnl CURL_CHECK_CA_EMBED
  1260. dnl -------------------------------------------------
  1261. dnl Check if a ca-bundle should be embedded
  1262. AC_DEFUN([CURL_CHECK_CA_EMBED], [
  1263. AC_MSG_CHECKING([CA cert bundle path to embed in the curl tool])
  1264. AC_ARG_WITH(ca-embed,
  1265. AS_HELP_STRING([--with-ca-embed=FILE],
  1266. [Absolute path to a file containing CA certificates to embed in the curl tool (example: /etc/ca-bundle.crt)])
  1267. AS_HELP_STRING([--without-ca-embed], [Don't embed a default CA bundle in the curl tool]),
  1268. [
  1269. want_ca_embed="$withval"
  1270. if test "x$want_ca_embed" = "xyes"; then
  1271. AC_MSG_ERROR([--with-ca-embed=FILE requires a path to the CA bundle])
  1272. fi
  1273. ],
  1274. [ want_ca_embed="unset" ])
  1275. CURL_CA_EMBED=''
  1276. if test "x$want_ca_embed" != "xno" -a "x$want_ca_embed" != "xunset" -a -f "$want_ca_embed"; then
  1277. CURL_CA_EMBED="$want_ca_embed"
  1278. AC_SUBST(CURL_CA_EMBED)
  1279. AC_MSG_RESULT([$want_ca_embed])
  1280. else
  1281. AC_MSG_RESULT([no])
  1282. fi
  1283. ])
  1284. dnl CURL_CHECK_WIN32_LARGEFILE
  1285. dnl -------------------------------------------------
  1286. dnl Check if curl's Win32 large file will be used
  1287. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  1288. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  1289. AC_MSG_CHECKING([whether build target supports Win32 file API])
  1290. curl_win32_file_api="no"
  1291. if test "$curl_cv_native_windows" = "yes"; then
  1292. if test x"$enable_largefile" != "xno"; then
  1293. AC_COMPILE_IFELSE([
  1294. AC_LANG_PROGRAM([[
  1295. ]],[[
  1296. #if !defined(_WIN32_WCE) && (defined(__MINGW32__) || defined(_MSC_VER))
  1297. int dummy=1;
  1298. #else
  1299. #error Win32 large file API not supported.
  1300. #endif
  1301. ]])
  1302. ],[
  1303. curl_win32_file_api="win32_large_files"
  1304. ])
  1305. fi
  1306. if test "$curl_win32_file_api" = "no"; then
  1307. AC_COMPILE_IFELSE([
  1308. AC_LANG_PROGRAM([[
  1309. ]],[[
  1310. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  1311. int dummy=1;
  1312. #else
  1313. #error Win32 small file API not supported.
  1314. #endif
  1315. ]])
  1316. ],[
  1317. curl_win32_file_api="win32_small_files"
  1318. ])
  1319. fi
  1320. fi
  1321. case "$curl_win32_file_api" in
  1322. win32_large_files)
  1323. AC_MSG_RESULT([yes (large file enabled)])
  1324. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  1325. [Define to 1 if you are building a Windows target with large file support.])
  1326. AC_SUBST(USE_WIN32_LARGE_FILES, [1])
  1327. ;;
  1328. win32_small_files)
  1329. AC_MSG_RESULT([yes (large file disabled)])
  1330. AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
  1331. [Define to 1 if you are building a Windows target without large file support.])
  1332. AC_SUBST(USE_WIN32_SMALL_FILES, [1])
  1333. ;;
  1334. *)
  1335. AC_MSG_RESULT([no])
  1336. ;;
  1337. esac
  1338. ])
  1339. dnl CURL_CHECK_WIN32_CRYPTO
  1340. dnl -------------------------------------------------
  1341. dnl Check if curl's Win32 crypto lib can be used
  1342. AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
  1343. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  1344. AC_MSG_CHECKING([whether build target supports Win32 crypto API])
  1345. curl_win32_crypto_api="no"
  1346. if test "$curl_cv_native_windows" = "yes"; then
  1347. AC_COMPILE_IFELSE([
  1348. AC_LANG_PROGRAM([[
  1349. #undef inline
  1350. #ifndef WIN32_LEAN_AND_MEAN
  1351. #define WIN32_LEAN_AND_MEAN
  1352. #endif
  1353. #include <windows.h>
  1354. #include <wincrypt.h>
  1355. ]],[[
  1356. HCRYPTPROV hCryptProv;
  1357. if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
  1358. CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
  1359. CryptReleaseContext(hCryptProv, 0);
  1360. }
  1361. ]])
  1362. ],[
  1363. curl_win32_crypto_api="yes"
  1364. ])
  1365. fi
  1366. case "$curl_win32_crypto_api" in
  1367. yes)
  1368. AC_MSG_RESULT([yes])
  1369. AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
  1370. [Define to 1 if you are building a Windows target with crypto API support.])
  1371. AC_SUBST(USE_WIN32_CRYPTO, [1])
  1372. ;;
  1373. *)
  1374. AC_MSG_RESULT([no])
  1375. ;;
  1376. esac
  1377. ])
  1378. dnl CURL_EXPORT_PCDIR ($pcdir)
  1379. dnl ------------------------
  1380. dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
  1381. dnl
  1382. dnl we need this macro since pkg-config distinguishes among empty and unset
  1383. dnl variable while checking PKG_CONFIG_LIBDIR
  1384. dnl
  1385. AC_DEFUN([CURL_EXPORT_PCDIR], [
  1386. if test -n "$1"; then
  1387. PKG_CONFIG_LIBDIR="$1"
  1388. export PKG_CONFIG_LIBDIR
  1389. fi
  1390. ])
  1391. dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
  1392. dnl ------------------------
  1393. dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
  1394. dnl path to it, or 'no' if not found/present.
  1395. dnl
  1396. dnl If pkg-config is present, check that it has info about the $module or
  1397. dnl return "no" anyway!
  1398. dnl
  1399. dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
  1400. dnl
  1401. AC_DEFUN([CURL_CHECK_PKGCONFIG], [
  1402. if test -n "$PKG_CONFIG"; then
  1403. PKGCONFIG="$PKG_CONFIG"
  1404. else
  1405. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
  1406. [$PATH:/usr/bin:/usr/local/bin])
  1407. fi
  1408. if test "x$PKGCONFIG" != "xno"; then
  1409. AC_MSG_CHECKING([for $1 options with pkg-config])
  1410. dnl ask pkg-config about $1
  1411. itexists=`CURL_EXPORT_PCDIR([$2]) dnl
  1412. $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
  1413. if test -z "$itexists"; then
  1414. dnl pkg-config does not have info about the given module! set the
  1415. dnl variable to 'no'
  1416. PKGCONFIG="no"
  1417. AC_MSG_RESULT([no])
  1418. else
  1419. AC_MSG_RESULT([found])
  1420. fi
  1421. fi
  1422. ])
  1423. dnl CURL_PREPARE_CONFIGUREHELP_PM
  1424. dnl -------------------------------------------------
  1425. dnl Prepare test harness configurehelp.pm module, defining and
  1426. dnl initializing some perl variables with values which are known
  1427. dnl when the configure script runs. For portability reasons, test
  1428. dnl harness needs information on how to run the C preprocessor.
  1429. AC_DEFUN([CURL_PREPARE_CONFIGUREHELP_PM], [
  1430. AC_REQUIRE([AC_PROG_CPP])dnl
  1431. tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
  1432. if test -z "$tmp_cpp"; then
  1433. tmp_cpp='cpp'
  1434. fi
  1435. AC_SUBST(CURL_CPP, $tmp_cpp)
  1436. ])
  1437. dnl CURL_PREPARE_BUILDINFO
  1438. dnl -------------------------------------------------
  1439. dnl Save build info for test runner to pick up and log
  1440. AC_DEFUN([CURL_PREPARE_BUILDINFO], [
  1441. curl_pflags=""
  1442. case $host in
  1443. *-apple-*) curl_pflags="${curl_pflags} APPLE";;
  1444. esac
  1445. if test "$curl_cv_native_windows" = 'yes'; then
  1446. curl_pflags="${curl_pflags} WIN32"
  1447. else
  1448. case $host in
  1449. *-*-*bsd*|*-*-aix*|*-*-hpux*|*-*-interix*|*-*-irix*|*-*-linux*|*-*-solaris*|*-*-sunos*|*-apple-*|*-*-cygwin*|*-*-msys*)
  1450. curl_pflags="${curl_pflags} UNIX";;
  1451. esac
  1452. fi
  1453. case $host_os in
  1454. cygwin*|msys*) curl_pflags="${curl_pflags} CYGWIN";;
  1455. esac
  1456. case $host_os in
  1457. msys*) curl_pflags="${curl_pflags} MSYS";;
  1458. esac
  1459. if test "x$compiler_id" = 'xGNU_C'; then
  1460. curl_pflags="${curl_pflags} GCC"
  1461. fi
  1462. case $host_os in
  1463. mingw*) curl_pflags="${curl_pflags} MINGW";;
  1464. esac
  1465. if test "x$cross_compiling" = 'xyes'; then
  1466. curl_pflags="${curl_pflags} CROSS"
  1467. fi
  1468. squeeze curl_pflags
  1469. curl_buildinfo="
  1470. buildinfo.configure.tool: configure
  1471. buildinfo.configure.args: $ac_configure_args
  1472. buildinfo.host: $build
  1473. buildinfo.host.cpu: $build_cpu
  1474. buildinfo.host.os: $build_os
  1475. buildinfo.target: $host
  1476. buildinfo.target.cpu: $host_cpu
  1477. buildinfo.target.os: $host_os
  1478. buildinfo.target.flags: $curl_pflags
  1479. buildinfo.compiler: $compiler_id
  1480. buildinfo.compiler.version: $compiler_ver
  1481. buildinfo.sysroot: $lt_sysroot"
  1482. ])
  1483. dnl CURL_CPP_P
  1484. dnl
  1485. dnl Check if $cpp -P should be used for extract define values due to gcc 5
  1486. dnl splitting up strings and defines between line outputs. gcc by default
  1487. dnl (without -P) will show TEST EINVAL TEST as
  1488. dnl
  1489. dnl # 13 "conftest.c"
  1490. dnl TEST
  1491. dnl # 13 "conftest.c" 3 4
  1492. dnl 22
  1493. dnl # 13 "conftest.c"
  1494. dnl TEST
  1495. AC_DEFUN([CURL_CPP_P], [
  1496. AC_MSG_CHECKING([if cpp -P is needed])
  1497. AC_EGREP_CPP([TEST.*TEST], [
  1498. #include <errno.h>
  1499. TEST EINVAL TEST
  1500. ], [cpp=no], [cpp=yes])
  1501. AC_MSG_RESULT([$cpp])
  1502. dnl we need cpp -P so check if it works then
  1503. if test "x$cpp" = "xyes"; then
  1504. AC_MSG_CHECKING([if cpp -P works])
  1505. OLDCPPFLAGS=$CPPFLAGS
  1506. CPPFLAGS="$CPPFLAGS -P"
  1507. AC_EGREP_CPP([TEST.*TEST], [
  1508. #include <errno.h>
  1509. TEST EINVAL TEST
  1510. ], [cpp_p=yes], [cpp_p=no])
  1511. AC_MSG_RESULT([$cpp_p])
  1512. if test "x$cpp_p" = "xno"; then
  1513. AC_MSG_WARN([failed to figure out cpp -P alternative])
  1514. # without -P
  1515. CPPPFLAG=""
  1516. else
  1517. # with -P
  1518. CPPPFLAG="-P"
  1519. fi
  1520. dnl restore CPPFLAGS
  1521. CPPFLAGS=$OLDCPPFLAGS
  1522. else
  1523. # without -P
  1524. CPPPFLAG=""
  1525. fi
  1526. ])
  1527. dnl CURL_DARWIN_CFLAGS
  1528. dnl
  1529. dnl Set -Werror=partial-availability to detect possible breaking code
  1530. dnl with very low deployment targets.
  1531. dnl
  1532. AC_DEFUN([CURL_DARWIN_CFLAGS], [
  1533. tst_cflags="no"
  1534. case $host in
  1535. *-apple-*)
  1536. tst_cflags="yes"
  1537. ;;
  1538. esac
  1539. AC_MSG_CHECKING([for good-to-use Darwin CFLAGS])
  1540. AC_MSG_RESULT([$tst_cflags]);
  1541. if test "$tst_cflags" = "yes"; then
  1542. old_CFLAGS=$CFLAGS
  1543. CFLAGS="$CFLAGS -Werror=partial-availability"
  1544. AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
  1545. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  1546. [AC_MSG_RESULT([yes])],
  1547. [AC_MSG_RESULT([no])
  1548. CFLAGS=$old_CFLAGS])
  1549. fi
  1550. ])
  1551. dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
  1552. dnl
  1553. dnl Check to see if the compiler supports __builtin_available. This built-in
  1554. dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
  1555. dnl the time this macro was written, the function was not yet documented. Its
  1556. dnl purpose is to return true if the code is running under a certain OS version
  1557. dnl or later.
  1558. AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
  1559. AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
  1560. AC_COMPILE_IFELSE([
  1561. AC_LANG_PROGRAM([[
  1562. ]],[[
  1563. if(__builtin_available(macOS 10.12, iOS 5.0, *)) {}
  1564. ]])
  1565. ],[
  1566. AC_MSG_RESULT([yes])
  1567. AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
  1568. [Define to 1 if you have the __builtin_available function.])
  1569. ],[
  1570. AC_MSG_RESULT([no])
  1571. ])
  1572. ])