acinclude.m4 43 KB

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