2
0

acinclude.m4 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690
  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. LIBCURL_PC_REQUIRES_PRIVATE="ldap $LIBCURL_PC_REQUIRES_PRIVATE"
  539. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  540. ;;
  541. esac
  542. #
  543. ])
  544. dnl TYPE_SOCKADDR_STORAGE
  545. dnl -------------------------------------------------
  546. dnl Check for struct sockaddr_storage. Most IPv6-enabled
  547. dnl hosts have it, but AIX 4.3 is one known exception.
  548. AC_DEFUN([TYPE_SOCKADDR_STORAGE],
  549. [
  550. AC_CHECK_TYPE([struct sockaddr_storage],
  551. AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
  552. [if struct sockaddr_storage is defined]), ,
  553. [
  554. #undef inline
  555. #ifdef _WIN32
  556. #ifndef WIN32_LEAN_AND_MEAN
  557. #define WIN32_LEAN_AND_MEAN
  558. #endif
  559. #include <winsock2.h>
  560. #else
  561. #ifdef HAVE_SYS_TYPES_H
  562. #include <sys/types.h>
  563. #endif
  564. #ifdef HAVE_SYS_SOCKET_H
  565. #include <sys/socket.h>
  566. #endif
  567. #ifdef HAVE_NETINET_IN_H
  568. #include <netinet/in.h>
  569. #endif
  570. #ifdef HAVE_ARPA_INET_H
  571. #include <arpa/inet.h>
  572. #endif
  573. #endif
  574. ])
  575. ])
  576. dnl CURL_CHECK_FUNC_RECV
  577. dnl -------------------------------------------------
  578. dnl Test if the socket recv() function is available,
  579. AC_DEFUN([CURL_CHECK_FUNC_RECV], [
  580. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  581. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  582. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  583. #
  584. AC_MSG_CHECKING([for recv])
  585. AC_LINK_IFELSE([
  586. AC_LANG_PROGRAM([[
  587. #undef inline
  588. #ifdef _WIN32
  589. #ifndef WIN32_LEAN_AND_MEAN
  590. #define WIN32_LEAN_AND_MEAN
  591. #endif
  592. #include <winsock2.h>
  593. #else
  594. $curl_includes_bsdsocket
  595. #ifdef HAVE_SYS_TYPES_H
  596. #include <sys/types.h>
  597. #endif
  598. #ifdef HAVE_SYS_SOCKET_H
  599. #include <sys/socket.h>
  600. #endif
  601. #endif
  602. ]],[[
  603. recv(0, 0, 0, 0);
  604. ]])
  605. ],[
  606. AC_MSG_RESULT([yes])
  607. curl_cv_recv="yes"
  608. ],[
  609. AC_MSG_RESULT([no])
  610. curl_cv_recv="no"
  611. ])
  612. #
  613. if test "$curl_cv_recv" = "yes"; then
  614. AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
  615. [Define to 1 if you have the recv function.])
  616. curl_cv_func_recv="yes"
  617. else
  618. AC_MSG_ERROR([Unable to link function recv])
  619. fi
  620. ])
  621. dnl CURL_CHECK_FUNC_SEND
  622. dnl -------------------------------------------------
  623. dnl Test if the socket send() function is available,
  624. AC_DEFUN([CURL_CHECK_FUNC_SEND], [
  625. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  626. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  627. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  628. #
  629. AC_MSG_CHECKING([for send])
  630. AC_LINK_IFELSE([
  631. AC_LANG_PROGRAM([[
  632. #undef inline
  633. #ifdef _WIN32
  634. #ifndef WIN32_LEAN_AND_MEAN
  635. #define WIN32_LEAN_AND_MEAN
  636. #endif
  637. #include <winsock2.h>
  638. #else
  639. $curl_includes_bsdsocket
  640. #ifdef HAVE_SYS_TYPES_H
  641. #include <sys/types.h>
  642. #endif
  643. #ifdef HAVE_SYS_SOCKET_H
  644. #include <sys/socket.h>
  645. #endif
  646. #endif
  647. ]],[[
  648. send(0, 0, 0, 0);
  649. ]])
  650. ],[
  651. AC_MSG_RESULT([yes])
  652. curl_cv_send="yes"
  653. ],[
  654. AC_MSG_RESULT([no])
  655. curl_cv_send="no"
  656. ])
  657. #
  658. if test "$curl_cv_send" = "yes"; then
  659. AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
  660. [Define to 1 if you have the send function.])
  661. curl_cv_func_send="yes"
  662. else
  663. AC_MSG_ERROR([Unable to link function send])
  664. fi
  665. ])
  666. dnl CURL_CHECK_MSG_NOSIGNAL
  667. dnl -------------------------------------------------
  668. dnl Check for MSG_NOSIGNAL
  669. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  670. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  671. AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
  672. AC_COMPILE_IFELSE([
  673. AC_LANG_PROGRAM([[
  674. #undef inline
  675. #ifdef _WIN32
  676. #ifndef WIN32_LEAN_AND_MEAN
  677. #define WIN32_LEAN_AND_MEAN
  678. #endif
  679. #include <winsock2.h>
  680. #else
  681. #ifdef HAVE_SYS_TYPES_H
  682. #include <sys/types.h>
  683. #endif
  684. #ifdef HAVE_SYS_SOCKET_H
  685. #include <sys/socket.h>
  686. #endif
  687. #endif
  688. ]],[[
  689. int flag=MSG_NOSIGNAL;
  690. ]])
  691. ],[
  692. curl_cv_msg_nosignal="yes"
  693. ],[
  694. curl_cv_msg_nosignal="no"
  695. ])
  696. ])
  697. case "$curl_cv_msg_nosignal" in
  698. yes)
  699. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  700. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  701. ;;
  702. esac
  703. ])
  704. dnl CURL_CHECK_STRUCT_TIMEVAL
  705. dnl -------------------------------------------------
  706. dnl Check for timeval struct
  707. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  708. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  709. AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h)
  710. AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
  711. AC_COMPILE_IFELSE([
  712. AC_LANG_PROGRAM([[
  713. #undef inline
  714. #ifdef _WIN32
  715. #ifndef WIN32_LEAN_AND_MEAN
  716. #define WIN32_LEAN_AND_MEAN
  717. #endif
  718. #include <winsock2.h>
  719. #endif
  720. #ifdef HAVE_SYS_TYPES_H
  721. #include <sys/types.h>
  722. #endif
  723. #ifdef HAVE_SYS_TIME_H
  724. #include <sys/time.h>
  725. #endif
  726. #include <time.h>
  727. #ifdef HAVE_SYS_SOCKET_H
  728. #include <sys/socket.h>
  729. #endif
  730. ]],[[
  731. struct timeval ts;
  732. ts.tv_sec = 0;
  733. ts.tv_usec = 0;
  734. ]])
  735. ],[
  736. curl_cv_struct_timeval="yes"
  737. ],[
  738. curl_cv_struct_timeval="no"
  739. ])
  740. ])
  741. case "$curl_cv_struct_timeval" in
  742. yes)
  743. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  744. [Define to 1 if you have the timeval struct.])
  745. ;;
  746. esac
  747. ])
  748. dnl TYPE_IN_ADDR_T
  749. dnl -------------------------------------------------
  750. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  751. dnl and a few other things.
  752. AC_DEFUN([TYPE_IN_ADDR_T], [
  753. AC_CHECK_TYPE([in_addr_t], ,[
  754. dnl in_addr_t not available
  755. AC_CACHE_CHECK([for in_addr_t equivalent],
  756. [curl_cv_in_addr_t_equiv], [
  757. curl_cv_in_addr_t_equiv="unknown"
  758. for t in "unsigned long" int size_t unsigned long; do
  759. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  760. AC_LINK_IFELSE([
  761. AC_LANG_PROGRAM([[
  762. #undef inline
  763. #ifdef _WIN32
  764. #ifndef WIN32_LEAN_AND_MEAN
  765. #define WIN32_LEAN_AND_MEAN
  766. #endif
  767. #include <winsock2.h>
  768. #else
  769. #ifdef HAVE_SYS_TYPES_H
  770. #include <sys/types.h>
  771. #endif
  772. #ifdef HAVE_SYS_SOCKET_H
  773. #include <sys/socket.h>
  774. #endif
  775. #ifdef HAVE_NETINET_IN_H
  776. #include <netinet/in.h>
  777. #endif
  778. #ifdef HAVE_ARPA_INET_H
  779. #include <arpa/inet.h>
  780. #endif
  781. #endif
  782. ]],[[
  783. $t data = inet_addr ("1.2.3.4");
  784. ]])
  785. ],[
  786. curl_cv_in_addr_t_equiv="$t"
  787. ])
  788. fi
  789. done
  790. ])
  791. case "$curl_cv_in_addr_t_equiv" in
  792. unknown)
  793. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  794. ;;
  795. *)
  796. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  797. [Type to use in place of in_addr_t when system does not provide it.])
  798. ;;
  799. esac
  800. ],[
  801. #undef inline
  802. #ifdef _WIN32
  803. #ifndef WIN32_LEAN_AND_MEAN
  804. #define WIN32_LEAN_AND_MEAN
  805. #endif
  806. #include <winsock2.h>
  807. #else
  808. #ifdef HAVE_SYS_TYPES_H
  809. #include <sys/types.h>
  810. #endif
  811. #ifdef HAVE_SYS_SOCKET_H
  812. #include <sys/socket.h>
  813. #endif
  814. #ifdef HAVE_NETINET_IN_H
  815. #include <netinet/in.h>
  816. #endif
  817. #ifdef HAVE_ARPA_INET_H
  818. #include <arpa/inet.h>
  819. #endif
  820. #endif
  821. ])
  822. ])
  823. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  824. dnl -------------------------------------------------
  825. dnl Check if monotonic clock_gettime is available.
  826. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  827. AC_CHECK_HEADERS(sys/types.h sys/time.h)
  828. AC_MSG_CHECKING([for monotonic clock_gettime])
  829. #
  830. if test "x$dontwant_rt" = "xno" ; then
  831. AC_COMPILE_IFELSE([
  832. AC_LANG_PROGRAM([[
  833. #ifdef HAVE_SYS_TYPES_H
  834. #include <sys/types.h>
  835. #endif
  836. #ifdef HAVE_SYS_TIME_H
  837. #include <sys/time.h>
  838. #endif
  839. #include <time.h>
  840. ]],[[
  841. struct timespec ts;
  842. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  843. ]])
  844. ],[
  845. AC_MSG_RESULT([yes])
  846. curl_func_clock_gettime="yes"
  847. ],[
  848. AC_MSG_RESULT([no])
  849. curl_func_clock_gettime="no"
  850. ])
  851. fi
  852. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  853. dnl until library linking and run-time checks for clock_gettime succeed.
  854. ])
  855. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW
  856. dnl -------------------------------------------------
  857. dnl Check if monotonic clock_gettime is available.
  858. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW], [
  859. AC_CHECK_HEADERS(sys/types.h sys/time.h)
  860. AC_MSG_CHECKING([for raw monotonic clock_gettime])
  861. #
  862. if test "x$dontwant_rt" = "xno" ; then
  863. AC_COMPILE_IFELSE([
  864. AC_LANG_PROGRAM([[
  865. #ifdef HAVE_SYS_TYPES_H
  866. #include <sys/types.h>
  867. #endif
  868. #ifdef HAVE_SYS_TIME_H
  869. #include <sys/time.h>
  870. #endif
  871. #include <time.h>
  872. ]],[[
  873. struct timespec ts;
  874. (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
  875. ]])
  876. ],[
  877. AC_MSG_RESULT([yes])
  878. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC_RAW, 1,
  879. [Define to 1 if you have the clock_gettime function and raw monotonic timer.])
  880. ],[
  881. AC_MSG_RESULT([no])
  882. ])
  883. fi
  884. ])
  885. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  886. dnl -------------------------------------------------
  887. dnl If monotonic clock_gettime is available then,
  888. dnl check and prepended to LIBS any needed libraries.
  889. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  890. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  891. #
  892. if test "$curl_func_clock_gettime" = "yes"; then
  893. #
  894. AC_MSG_CHECKING([for clock_gettime in libraries])
  895. #
  896. curl_cv_save_LIBS="$LIBS"
  897. curl_cv_gclk_LIBS="unknown"
  898. #
  899. for x_xlibs in '' '-lrt' '-lposix4' ; do
  900. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  901. if test -z "$x_xlibs"; then
  902. LIBS="$curl_cv_save_LIBS"
  903. else
  904. LIBS="$x_xlibs $curl_cv_save_LIBS"
  905. fi
  906. AC_LINK_IFELSE([
  907. AC_LANG_PROGRAM([[
  908. #ifdef HAVE_SYS_TYPES_H
  909. #include <sys/types.h>
  910. #endif
  911. #ifdef HAVE_SYS_TIME_H
  912. #include <sys/time.h>
  913. #endif
  914. #include <time.h>
  915. ]],[[
  916. struct timespec ts;
  917. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  918. ]])
  919. ],[
  920. curl_cv_gclk_LIBS="$x_xlibs"
  921. ])
  922. fi
  923. done
  924. #
  925. LIBS="$curl_cv_save_LIBS"
  926. #
  927. case X-"$curl_cv_gclk_LIBS" in
  928. X-unknown)
  929. AC_MSG_RESULT([cannot find clock_gettime])
  930. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  931. curl_func_clock_gettime="no"
  932. ;;
  933. X-)
  934. AC_MSG_RESULT([no additional lib required])
  935. curl_func_clock_gettime="yes"
  936. ;;
  937. *)
  938. if test -z "$curl_cv_save_LIBS"; then
  939. LIBS="$curl_cv_gclk_LIBS"
  940. else
  941. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  942. fi
  943. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  944. curl_func_clock_gettime="yes"
  945. ;;
  946. esac
  947. #
  948. dnl only do runtime verification when not cross-compiling
  949. if test "x$cross_compiling" != "xyes" &&
  950. test "$curl_func_clock_gettime" = "yes"; then
  951. AC_MSG_CHECKING([if monotonic clock_gettime works])
  952. CURL_RUN_IFELSE([
  953. AC_LANG_PROGRAM([[
  954. #include <stdlib.h>
  955. #ifdef HAVE_SYS_TYPES_H
  956. #include <sys/types.h>
  957. #endif
  958. #ifdef HAVE_SYS_TIME_H
  959. #include <sys/time.h>
  960. #endif
  961. #include <time.h>
  962. ]],[[
  963. struct timespec ts;
  964. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  965. exit(0);
  966. else
  967. exit(1);
  968. ]])
  969. ],[
  970. AC_MSG_RESULT([yes])
  971. ],[
  972. AC_MSG_RESULT([no])
  973. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  974. curl_func_clock_gettime="no"
  975. LIBS="$curl_cv_save_LIBS"
  976. ])
  977. fi
  978. #
  979. case "$curl_func_clock_gettime" in
  980. yes)
  981. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  982. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  983. ;;
  984. esac
  985. #
  986. fi
  987. #
  988. ])
  989. dnl CURL_CHECK_LIBS_CONNECT
  990. dnl -------------------------------------------------
  991. dnl Verify if network connect function is already available
  992. dnl using current libraries or if another one is required.
  993. AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
  994. AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
  995. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  996. AC_MSG_CHECKING([for connect in libraries])
  997. tst_connect_save_LIBS="$LIBS"
  998. tst_connect_need_LIBS="unknown"
  999. for tst_lib in '' '-lsocket' ; do
  1000. if test "$tst_connect_need_LIBS" = "unknown"; then
  1001. LIBS="$tst_lib $tst_connect_save_LIBS"
  1002. AC_LINK_IFELSE([
  1003. AC_LANG_PROGRAM([[
  1004. $curl_includes_winsock2
  1005. $curl_includes_bsdsocket
  1006. #if !defined(_WIN32) && !defined(HAVE_PROTO_BSDSOCKET_H)
  1007. int connect(int, void*, int);
  1008. #endif
  1009. ]],[[
  1010. if(0 != connect(0, 0, 0))
  1011. return 1;
  1012. ]])
  1013. ],[
  1014. tst_connect_need_LIBS="$tst_lib"
  1015. ])
  1016. fi
  1017. done
  1018. LIBS="$tst_connect_save_LIBS"
  1019. #
  1020. case X-"$tst_connect_need_LIBS" in
  1021. X-unknown)
  1022. AC_MSG_RESULT([cannot find connect])
  1023. AC_MSG_ERROR([cannot find connect function in libraries.])
  1024. ;;
  1025. X-)
  1026. AC_MSG_RESULT([yes])
  1027. ;;
  1028. *)
  1029. AC_MSG_RESULT([$tst_connect_need_LIBS])
  1030. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  1031. ;;
  1032. esac
  1033. ])
  1034. dnl CURL_CHECK_FUNC_SELECT
  1035. dnl -------------------------------------------------
  1036. dnl Test if the socket select() function is available.
  1037. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  1038. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  1039. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  1040. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  1041. #
  1042. AC_MSG_CHECKING([for select])
  1043. AC_LINK_IFELSE([
  1044. AC_LANG_PROGRAM([[
  1045. #undef inline
  1046. #ifdef _WIN32
  1047. #ifndef WIN32_LEAN_AND_MEAN
  1048. #define WIN32_LEAN_AND_MEAN
  1049. #endif
  1050. #include <winsock2.h>
  1051. #endif
  1052. #ifdef HAVE_SYS_TYPES_H
  1053. #include <sys/types.h>
  1054. #endif
  1055. #ifdef HAVE_SYS_TIME_H
  1056. #include <sys/time.h>
  1057. #endif
  1058. #include <time.h>
  1059. #ifndef _WIN32
  1060. #ifdef HAVE_SYS_SELECT_H
  1061. #include <sys/select.h>
  1062. #elif defined(HAVE_UNISTD_H)
  1063. #include <unistd.h>
  1064. #endif
  1065. #ifdef HAVE_SYS_SOCKET_H
  1066. #include <sys/socket.h>
  1067. #endif
  1068. $curl_includes_bsdsocket
  1069. #endif
  1070. ]],[[
  1071. select(0, 0, 0, 0, 0);
  1072. ]])
  1073. ],[
  1074. AC_MSG_RESULT([yes])
  1075. curl_cv_select="yes"
  1076. ],[
  1077. AC_MSG_RESULT([no])
  1078. curl_cv_select="no"
  1079. ])
  1080. #
  1081. if test "$curl_cv_select" = "yes"; then
  1082. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  1083. [Define to 1 if you have the select function.])
  1084. curl_cv_func_select="yes"
  1085. fi
  1086. ])
  1087. dnl CURL_VERIFY_RUNTIMELIBS
  1088. dnl -------------------------------------------------
  1089. dnl Verify that the shared libs found so far can be used when running
  1090. dnl programs, since otherwise the situation will create odd configure errors
  1091. dnl that are misleading people.
  1092. dnl
  1093. dnl Make sure this test is run BEFORE the first test in the script that
  1094. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  1095. dnl macro. It must also run AFTER all lib-checking macros are complete.
  1096. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  1097. dnl this test is of course not sensible if we are cross-compiling!
  1098. if test "x$cross_compiling" != xyes; then
  1099. dnl just run a program to verify that the libs checked for previous to this
  1100. dnl point also is available run-time!
  1101. AC_MSG_CHECKING([run-time libs availability])
  1102. CURL_RUN_IFELSE([
  1103. int main()
  1104. {
  1105. return 0;
  1106. }
  1107. ],
  1108. AC_MSG_RESULT([fine]),
  1109. AC_MSG_RESULT([failed])
  1110. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  1111. )
  1112. dnl if this test fails, configure has already stopped
  1113. fi
  1114. ])
  1115. dnl CURL_CHECK_CA_BUNDLE
  1116. dnl -------------------------------------------------
  1117. dnl Check if a default ca-bundle should be used
  1118. dnl
  1119. dnl regarding the paths this will scan:
  1120. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  1121. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  1122. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  1123. dnl /usr/local/share/certs/ca-root-nss.crt MidnightBSD
  1124. dnl /etc/ssl/cert.pem OpenBSD, MidnightBSD (symlink)
  1125. dnl /etc/ssl/certs (CA path) SUSE, FreeBSD
  1126. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  1127. AC_MSG_CHECKING([default CA cert bundle/path])
  1128. AC_ARG_WITH(ca-bundle,
  1129. AS_HELP_STRING([--with-ca-bundle=FILE],
  1130. [Absolute path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
  1131. AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  1132. [
  1133. want_ca="$withval"
  1134. if test "x$want_ca" = "xyes"; then
  1135. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  1136. fi
  1137. ],
  1138. [ want_ca="unset" ])
  1139. AC_ARG_WITH(ca-path,
  1140. AS_HELP_STRING([--with-ca-path=DIRECTORY],
  1141. [Absolute path to a directory containing CA certificates stored individually, with \
  1142. their filenames in a hash format. This option can be used with the OpenSSL, \
  1143. GnuTLS, mbedTLS and wolfSSL backends. Refer to OpenSSL c_rehash for details. \
  1144. (example: /etc/certificates)])
  1145. AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  1146. [
  1147. want_capath="$withval"
  1148. if test "x$want_capath" = "xyes"; then
  1149. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  1150. fi
  1151. ],
  1152. [ want_capath="unset"])
  1153. ca_warning=" (warning: certs not found)"
  1154. capath_warning=" (warning: certs not found)"
  1155. check_capath=""
  1156. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  1157. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  1158. dnl both given
  1159. ca="$want_ca"
  1160. capath="$want_capath"
  1161. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  1162. dnl --with-ca-bundle given
  1163. ca="$want_ca"
  1164. capath="no"
  1165. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  1166. dnl --with-ca-path given
  1167. capath="$want_capath"
  1168. ca="no"
  1169. else
  1170. dnl First try auto-detecting a CA bundle, then a CA path.
  1171. dnl Both auto-detections can be skipped by --without-ca-*
  1172. ca="no"
  1173. capath="no"
  1174. if test "x$cross_compiling" != "xyes" -a \
  1175. "x$curl_cv_native_windows" != "xyes"; then
  1176. dnl NOT cross-compiling and...
  1177. dnl neither of the --with-ca-* options are provided
  1178. if test "x$want_ca" = "xunset"; then
  1179. dnl the path we previously would have installed the curl CA bundle
  1180. dnl to, and thus we now check for an already existing cert in that
  1181. dnl place in case we find no other
  1182. if test "x$prefix" != xNONE; then
  1183. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  1184. else
  1185. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  1186. fi
  1187. for a in /etc/ssl/certs/ca-certificates.crt \
  1188. /etc/pki/tls/certs/ca-bundle.crt \
  1189. /usr/share/ssl/certs/ca-bundle.crt \
  1190. /usr/local/share/certs/ca-root-nss.crt \
  1191. /etc/ssl/cert.pem \
  1192. "$cac"; do
  1193. if test -f "$a"; then
  1194. ca="$a"
  1195. break
  1196. fi
  1197. done
  1198. fi
  1199. AC_MSG_NOTICE([want $want_capath ca $ca])
  1200. if test "x$want_capath" = "xunset"; then
  1201. check_capath="/etc/ssl/certs"
  1202. fi
  1203. else
  1204. dnl no option given and cross-compiling
  1205. AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
  1206. fi
  1207. fi
  1208. if test "x$ca" = "xno" || test -f "$ca"; then
  1209. ca_warning=""
  1210. fi
  1211. if test "x$capath" != "xno"; then
  1212. check_capath="$capath"
  1213. fi
  1214. if test ! -z "$check_capath"; then
  1215. for a in "$check_capath"; do
  1216. 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
  1217. if test "x$capath" = "xno"; then
  1218. capath="$a"
  1219. fi
  1220. capath_warning=""
  1221. break
  1222. fi
  1223. done
  1224. fi
  1225. if test "x$capath" = "xno"; then
  1226. capath_warning=""
  1227. fi
  1228. if test "x$ca" != "xno"; then
  1229. CURL_CA_BUNDLE="$ca"
  1230. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  1231. AC_SUBST(CURL_CA_BUNDLE)
  1232. AC_MSG_RESULT([$ca])
  1233. fi
  1234. if test "x$capath" != "xno"; then
  1235. CURL_CA_PATH="\"$capath\""
  1236. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  1237. AC_MSG_RESULT([$capath (capath)])
  1238. fi
  1239. if test "x$ca" = "xno" && test "x$capath" = "xno"; then
  1240. AC_MSG_RESULT([no])
  1241. fi
  1242. AC_MSG_CHECKING([whether to use built-in CA store of SSL library])
  1243. AC_ARG_WITH(ca-fallback,
  1244. AS_HELP_STRING([--with-ca-fallback], [Use the built-in CA store of the SSL library])
  1245. AS_HELP_STRING([--without-ca-fallback], [Don't use the built-in CA store of the SSL library]),
  1246. [
  1247. if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
  1248. AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
  1249. fi
  1250. ],
  1251. [ with_ca_fallback="no"])
  1252. AC_MSG_RESULT([$with_ca_fallback])
  1253. if test "x$with_ca_fallback" = "xyes"; then
  1254. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
  1255. AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
  1256. fi
  1257. AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built-in CA store of SSL library])
  1258. fi
  1259. ])
  1260. dnl CURL_CHECK_CA_EMBED
  1261. dnl -------------------------------------------------
  1262. dnl Check if a ca-bundle should be embedded
  1263. AC_DEFUN([CURL_CHECK_CA_EMBED], [
  1264. AC_MSG_CHECKING([CA cert bundle path to embed in the curl tool])
  1265. AC_ARG_WITH(ca-embed,
  1266. AS_HELP_STRING([--with-ca-embed=FILE],
  1267. [Absolute path to a file containing CA certificates to embed in the curl tool (example: /etc/ca-bundle.crt)])
  1268. AS_HELP_STRING([--without-ca-embed], [Don't embed a default CA bundle in the curl tool]),
  1269. [
  1270. want_ca_embed="$withval"
  1271. if test "x$want_ca_embed" = "xyes"; then
  1272. AC_MSG_ERROR([--with-ca-embed=FILE requires a path to the CA bundle])
  1273. fi
  1274. ],
  1275. [ want_ca_embed="unset" ])
  1276. CURL_CA_EMBED=''
  1277. if test "x$want_ca_embed" != "xno" -a "x$want_ca_embed" != "xunset" -a -f "$want_ca_embed"; then
  1278. CURL_CA_EMBED="$want_ca_embed"
  1279. AC_SUBST(CURL_CA_EMBED)
  1280. AC_MSG_RESULT([$want_ca_embed])
  1281. else
  1282. AC_MSG_RESULT([no])
  1283. fi
  1284. ])
  1285. dnl CURL_CHECK_WIN32_LARGEFILE
  1286. dnl -------------------------------------------------
  1287. dnl Check if curl's Win32 large file will be used
  1288. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  1289. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  1290. AC_MSG_CHECKING([whether build target supports Win32 file API])
  1291. curl_win32_file_api="no"
  1292. if test "$curl_cv_native_windows" = "yes"; then
  1293. if test x"$enable_largefile" != "xno"; then
  1294. AC_COMPILE_IFELSE([
  1295. AC_LANG_PROGRAM([[
  1296. ]],[[
  1297. #if !defined(_WIN32_WCE) && (defined(__MINGW32__) || defined(_MSC_VER))
  1298. int dummy=1;
  1299. #else
  1300. #error Win32 large file API not supported.
  1301. #endif
  1302. ]])
  1303. ],[
  1304. curl_win32_file_api="win32_large_files"
  1305. ])
  1306. fi
  1307. if test "$curl_win32_file_api" = "no"; then
  1308. AC_COMPILE_IFELSE([
  1309. AC_LANG_PROGRAM([[
  1310. ]],[[
  1311. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  1312. int dummy=1;
  1313. #else
  1314. #error Win32 small file API not supported.
  1315. #endif
  1316. ]])
  1317. ],[
  1318. curl_win32_file_api="win32_small_files"
  1319. ])
  1320. fi
  1321. fi
  1322. case "$curl_win32_file_api" in
  1323. win32_large_files)
  1324. AC_MSG_RESULT([yes (large file enabled)])
  1325. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  1326. [Define to 1 if you are building a Windows target with large file support.])
  1327. AC_SUBST(USE_WIN32_LARGE_FILES, [1])
  1328. ;;
  1329. win32_small_files)
  1330. AC_MSG_RESULT([yes (large file disabled)])
  1331. AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
  1332. [Define to 1 if you are building a Windows target without large file support.])
  1333. AC_SUBST(USE_WIN32_SMALL_FILES, [1])
  1334. ;;
  1335. *)
  1336. AC_MSG_RESULT([no])
  1337. ;;
  1338. esac
  1339. ])
  1340. dnl CURL_CHECK_WIN32_CRYPTO
  1341. dnl -------------------------------------------------
  1342. dnl Check if curl's Win32 crypto lib can be used
  1343. AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
  1344. AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
  1345. AC_MSG_CHECKING([whether build target supports Win32 crypto API])
  1346. curl_win32_crypto_api="no"
  1347. if test "$curl_cv_native_windows" = "yes"; then
  1348. AC_COMPILE_IFELSE([
  1349. AC_LANG_PROGRAM([[
  1350. #undef inline
  1351. #ifndef WIN32_LEAN_AND_MEAN
  1352. #define WIN32_LEAN_AND_MEAN
  1353. #endif
  1354. #include <windows.h>
  1355. #include <wincrypt.h>
  1356. ]],[[
  1357. HCRYPTPROV hCryptProv;
  1358. if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
  1359. CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
  1360. CryptReleaseContext(hCryptProv, 0);
  1361. }
  1362. ]])
  1363. ],[
  1364. curl_win32_crypto_api="yes"
  1365. ])
  1366. fi
  1367. case "$curl_win32_crypto_api" in
  1368. yes)
  1369. AC_MSG_RESULT([yes])
  1370. AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
  1371. [Define to 1 if you are building a Windows target with crypto API support.])
  1372. AC_SUBST(USE_WIN32_CRYPTO, [1])
  1373. ;;
  1374. *)
  1375. AC_MSG_RESULT([no])
  1376. ;;
  1377. esac
  1378. ])
  1379. dnl CURL_EXPORT_PCDIR ($pcdir)
  1380. dnl ------------------------
  1381. dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
  1382. dnl
  1383. dnl we need this macro since pkg-config distinguishes among empty and unset
  1384. dnl variable while checking PKG_CONFIG_LIBDIR
  1385. dnl
  1386. AC_DEFUN([CURL_EXPORT_PCDIR], [
  1387. if test -n "$1"; then
  1388. PKG_CONFIG_LIBDIR="$1"
  1389. export PKG_CONFIG_LIBDIR
  1390. fi
  1391. ])
  1392. dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
  1393. dnl ------------------------
  1394. dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
  1395. dnl path to it, or 'no' if not found/present.
  1396. dnl
  1397. dnl If pkg-config is present, check that it has info about the $module or
  1398. dnl return "no" anyway!
  1399. dnl
  1400. dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
  1401. dnl
  1402. AC_DEFUN([CURL_CHECK_PKGCONFIG], [
  1403. if test -n "$PKG_CONFIG"; then
  1404. PKGCONFIG="$PKG_CONFIG"
  1405. else
  1406. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
  1407. [$PATH:/usr/bin:/usr/local/bin])
  1408. fi
  1409. if test "x$PKGCONFIG" != "xno"; then
  1410. AC_MSG_CHECKING([for $1 options with pkg-config])
  1411. dnl ask pkg-config about $1
  1412. itexists=`CURL_EXPORT_PCDIR([$2]) dnl
  1413. $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
  1414. if test -z "$itexists"; then
  1415. dnl pkg-config does not have info about the given module! set the
  1416. dnl variable to 'no'
  1417. PKGCONFIG="no"
  1418. AC_MSG_RESULT([no])
  1419. else
  1420. AC_MSG_RESULT([found])
  1421. fi
  1422. fi
  1423. ])
  1424. dnl CURL_PREPARE_CONFIGUREHELP_PM
  1425. dnl -------------------------------------------------
  1426. dnl Prepare test harness configurehelp.pm module, defining and
  1427. dnl initializing some perl variables with values which are known
  1428. dnl when the configure script runs. For portability reasons, test
  1429. dnl harness needs information on how to run the C preprocessor.
  1430. AC_DEFUN([CURL_PREPARE_CONFIGUREHELP_PM], [
  1431. AC_REQUIRE([AC_PROG_CPP])dnl
  1432. tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
  1433. if test -z "$tmp_cpp"; then
  1434. tmp_cpp='cpp'
  1435. fi
  1436. AC_SUBST(CURL_CPP, $tmp_cpp)
  1437. ])
  1438. dnl CURL_PREPARE_BUILDINFO
  1439. dnl -------------------------------------------------
  1440. dnl Save build info for test runner to pick up and log
  1441. AC_DEFUN([CURL_PREPARE_BUILDINFO], [
  1442. curl_pflags=""
  1443. case $host in
  1444. *-apple-*) curl_pflags="${curl_pflags} APPLE";;
  1445. esac
  1446. if test "$curl_cv_native_windows" = 'yes'; then
  1447. curl_pflags="${curl_pflags} WIN32"
  1448. else
  1449. case $host in
  1450. *-*-*bsd*|*-*-aix*|*-*-hpux*|*-*-interix*|*-*-irix*|*-*-linux*|*-*-solaris*|*-*-sunos*|*-apple-*|*-*-cygwin*|*-*-msys*)
  1451. curl_pflags="${curl_pflags} UNIX";;
  1452. esac
  1453. fi
  1454. if test "$curl_cv_cygwin" = 'yes'; then
  1455. curl_pflags="${curl_pflags} CYGWIN"
  1456. fi
  1457. case $host_os in
  1458. msys*) curl_pflags="${curl_pflags} MSYS";;
  1459. esac
  1460. if test "x$compiler_id" = 'xGNU_C'; then
  1461. curl_pflags="${curl_pflags} GCC"
  1462. fi
  1463. case $host_os in
  1464. mingw*) curl_pflags="${curl_pflags} MINGW";;
  1465. esac
  1466. if test "x$cross_compiling" = 'xyes'; then
  1467. curl_pflags="${curl_pflags} CROSS"
  1468. fi
  1469. squeeze curl_pflags
  1470. curl_buildinfo="
  1471. buildinfo.configure.tool: configure
  1472. buildinfo.configure.args: $ac_configure_args
  1473. buildinfo.host: $build
  1474. buildinfo.host.cpu: $build_cpu
  1475. buildinfo.host.os: $build_os
  1476. buildinfo.target: $host
  1477. buildinfo.target.cpu: $host_cpu
  1478. buildinfo.target.os: $host_os
  1479. buildinfo.target.flags: $curl_pflags
  1480. buildinfo.compiler: $compiler_id
  1481. buildinfo.compiler.version: $compiler_ver
  1482. buildinfo.sysroot: $lt_sysroot"
  1483. ])
  1484. dnl CURL_CPP_P
  1485. dnl
  1486. dnl Check if $cpp -P should be used for extract define values due to gcc 5
  1487. dnl splitting up strings and defines between line outputs. gcc by default
  1488. dnl (without -P) will show TEST EINVAL TEST as
  1489. dnl
  1490. dnl # 13 "conftest.c"
  1491. dnl TEST
  1492. dnl # 13 "conftest.c" 3 4
  1493. dnl 22
  1494. dnl # 13 "conftest.c"
  1495. dnl TEST
  1496. AC_DEFUN([CURL_CPP_P], [
  1497. AC_MSG_CHECKING([if cpp -P is needed])
  1498. AC_EGREP_CPP([TEST.*TEST], [
  1499. #include <errno.h>
  1500. TEST EINVAL TEST
  1501. ], [cpp=no], [cpp=yes])
  1502. AC_MSG_RESULT([$cpp])
  1503. dnl we need cpp -P so check if it works then
  1504. if test "x$cpp" = "xyes"; then
  1505. AC_MSG_CHECKING([if cpp -P works])
  1506. OLDCPPFLAGS=$CPPFLAGS
  1507. CPPFLAGS="$CPPFLAGS -P"
  1508. AC_EGREP_CPP([TEST.*TEST], [
  1509. #include <errno.h>
  1510. TEST EINVAL TEST
  1511. ], [cpp_p=yes], [cpp_p=no])
  1512. AC_MSG_RESULT([$cpp_p])
  1513. if test "x$cpp_p" = "xno"; then
  1514. AC_MSG_WARN([failed to figure out cpp -P alternative])
  1515. # without -P
  1516. CPPPFLAG=""
  1517. else
  1518. # with -P
  1519. CPPPFLAG="-P"
  1520. fi
  1521. dnl restore CPPFLAGS
  1522. CPPFLAGS=$OLDCPPFLAGS
  1523. else
  1524. # without -P
  1525. CPPPFLAG=""
  1526. fi
  1527. ])
  1528. dnl CURL_DARWIN_CFLAGS
  1529. dnl
  1530. dnl Set -Werror=partial-availability to detect possible breaking code
  1531. dnl with very low deployment targets.
  1532. dnl
  1533. AC_DEFUN([CURL_DARWIN_CFLAGS], [
  1534. tst_cflags="no"
  1535. case $host in
  1536. *-apple-*)
  1537. tst_cflags="yes"
  1538. ;;
  1539. esac
  1540. AC_MSG_CHECKING([for good-to-use Darwin CFLAGS])
  1541. AC_MSG_RESULT([$tst_cflags]);
  1542. if test "$tst_cflags" = "yes"; then
  1543. old_CFLAGS=$CFLAGS
  1544. CFLAGS="$CFLAGS -Werror=partial-availability"
  1545. AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
  1546. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  1547. [AC_MSG_RESULT([yes])],
  1548. [AC_MSG_RESULT([no])
  1549. CFLAGS=$old_CFLAGS])
  1550. fi
  1551. ])
  1552. dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
  1553. dnl
  1554. dnl Check to see if the compiler supports __builtin_available. This built-in
  1555. dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
  1556. dnl the time this macro was written, the function was not yet documented. Its
  1557. dnl purpose is to return true if the code is running under a certain OS version
  1558. dnl or later.
  1559. AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
  1560. AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
  1561. AC_COMPILE_IFELSE([
  1562. AC_LANG_PROGRAM([[
  1563. ]],[[
  1564. if(__builtin_available(macOS 10.12, iOS 5.0, *)) {}
  1565. ]])
  1566. ],[
  1567. AC_MSG_RESULT([yes])
  1568. AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
  1569. [Define to 1 if you have the __builtin_available function.])
  1570. ],[
  1571. AC_MSG_RESULT([no])
  1572. ])
  1573. ])