acinclude.m4 46 KB

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