acinclude.m4 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2021, 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. #***************************************************************************
  22. dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
  23. dnl -------------------------------------------------
  24. dnl Use the C preprocessor to find out if the given object-style symbol
  25. dnl is defined and get its expansion. This macro will not use default
  26. dnl includes even if no INCLUDES argument is given. This macro will run
  27. dnl silently when invoked with three arguments. If the expansion would
  28. dnl result in a set of double-quoted strings the returned expansion will
  29. dnl actually be a single double-quoted string concatenating all them.
  30. AC_DEFUN([CURL_CHECK_DEF], [
  31. AC_REQUIRE([CURL_CPP_P])dnl
  32. OLDCPPFLAGS=$CPPFLAGS
  33. # CPPPFLAG comes from CURL_CPP_P
  34. CPPFLAGS="$CPPFLAGS $CPPPFLAG"
  35. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  36. AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
  37. if test -z "$SED"; then
  38. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  39. fi
  40. if test -z "$GREP"; then
  41. AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
  42. fi
  43. ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
  44. tmp_exp=""
  45. AC_PREPROC_IFELSE([
  46. AC_LANG_SOURCE(
  47. ifelse($2,,,[$2])[[
  48. #ifdef $1
  49. CURL_DEF_TOKEN $1
  50. #endif
  51. ]])
  52. ],[
  53. tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
  54. "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
  55. "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
  56. "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
  57. if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
  58. tmp_exp=""
  59. fi
  60. ])
  61. if test -z "$tmp_exp"; then
  62. AS_VAR_SET(ac_HaveDef, no)
  63. ifelse($3,,[AC_MSG_RESULT([no])])
  64. else
  65. AS_VAR_SET(ac_HaveDef, yes)
  66. AS_VAR_SET(ac_Def, $tmp_exp)
  67. ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
  68. fi
  69. AS_VAR_POPDEF([ac_Def])dnl
  70. AS_VAR_POPDEF([ac_HaveDef])dnl
  71. CPPFLAGS=$OLDCPPFLAGS
  72. ])
  73. dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
  74. dnl -------------------------------------------------
  75. dnl Use the C compiler to find out only if the given symbol is defined
  76. dnl or not, this can not find out its expansion. This macro will not use
  77. dnl default includes even if no INCLUDES argument is given. This macro
  78. dnl will run silently when invoked with three arguments.
  79. AC_DEFUN([CURL_CHECK_DEF_CC], [
  80. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  81. ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
  82. AC_COMPILE_IFELSE([
  83. AC_LANG_SOURCE(
  84. ifelse($2,,,[$2])[[
  85. int main (void)
  86. {
  87. #ifdef $1
  88. return 0;
  89. #else
  90. force compilation error
  91. #endif
  92. }
  93. ]])
  94. ],[
  95. tst_symbol_defined="yes"
  96. ],[
  97. tst_symbol_defined="no"
  98. ])
  99. if test "$tst_symbol_defined" = "yes"; then
  100. AS_VAR_SET(ac_HaveDef, yes)
  101. ifelse($3,,[AC_MSG_RESULT([yes])])
  102. else
  103. AS_VAR_SET(ac_HaveDef, no)
  104. ifelse($3,,[AC_MSG_RESULT([no])])
  105. fi
  106. AS_VAR_POPDEF([ac_HaveDef])dnl
  107. ])
  108. dnl CURL_CHECK_LIB_XNET
  109. dnl -------------------------------------------------
  110. dnl Verify if X/Open network library is required.
  111. AC_DEFUN([CURL_CHECK_LIB_XNET], [
  112. AC_MSG_CHECKING([if X/Open network library is required])
  113. tst_lib_xnet_required="no"
  114. AC_COMPILE_IFELSE([
  115. AC_LANG_SOURCE([[
  116. int main (void)
  117. {
  118. #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
  119. return 0;
  120. #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
  121. return 0;
  122. #else
  123. force compilation error
  124. #endif
  125. }
  126. ]])
  127. ],[
  128. tst_lib_xnet_required="yes"
  129. LIBS="-lxnet $LIBS"
  130. ])
  131. AC_MSG_RESULT([$tst_lib_xnet_required])
  132. ])
  133. dnl CURL_CHECK_AIX_ALL_SOURCE
  134. dnl -------------------------------------------------
  135. dnl Provides a replacement of traditional AC_AIX with
  136. dnl an uniform behavior across all autoconf versions,
  137. dnl and with our own placement rules.
  138. AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
  139. AH_VERBATIM([_ALL_SOURCE],
  140. [/* Define to 1 if OS is AIX. */
  141. #ifndef _ALL_SOURCE
  142. # undef _ALL_SOURCE
  143. #endif])
  144. AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
  145. AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
  146. AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
  147. AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
  148. AC_EGREP_CPP([yes_this_is_aix],[
  149. #ifdef _AIX
  150. yes_this_is_aix
  151. #endif
  152. ],[
  153. AC_MSG_RESULT([yes])
  154. AC_DEFINE(_ALL_SOURCE)
  155. ],[
  156. AC_MSG_RESULT([no])
  157. ])
  158. ])
  159. dnl CURL_CHECK_HEADER_WINDOWS
  160. dnl -------------------------------------------------
  161. dnl Check for compilable and valid windows.h header
  162. AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
  163. AC_CACHE_CHECK([for windows.h], [curl_cv_header_windows_h], [
  164. AC_COMPILE_IFELSE([
  165. AC_LANG_PROGRAM([[
  166. #undef inline
  167. #ifndef WIN32_LEAN_AND_MEAN
  168. #define WIN32_LEAN_AND_MEAN
  169. #endif
  170. #include <windows.h>
  171. ]],[[
  172. #if defined(__CYGWIN__) || defined(__CEGCC__)
  173. HAVE_WINDOWS_H shall not be defined.
  174. #else
  175. int dummy=2*WINVER;
  176. #endif
  177. ]])
  178. ],[
  179. curl_cv_header_windows_h="yes"
  180. ],[
  181. curl_cv_header_windows_h="no"
  182. ])
  183. ])
  184. case "$curl_cv_header_windows_h" in
  185. yes)
  186. AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
  187. [Define to 1 if you have the windows.h header file.])
  188. ;;
  189. esac
  190. ])
  191. dnl CURL_CHECK_NATIVE_WINDOWS
  192. dnl -------------------------------------------------
  193. dnl Check if building a native Windows target
  194. AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
  195. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  196. AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
  197. if test "$curl_cv_header_windows_h" = "no"; then
  198. curl_cv_native_windows="no"
  199. else
  200. AC_COMPILE_IFELSE([
  201. AC_LANG_PROGRAM([[
  202. ]],[[
  203. #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
  204. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
  205. int dummy=1;
  206. #else
  207. Not a native Windows build target.
  208. #endif
  209. ]])
  210. ],[
  211. curl_cv_native_windows="yes"
  212. ],[
  213. curl_cv_native_windows="no"
  214. ])
  215. fi
  216. ])
  217. AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
  218. ])
  219. dnl CURL_CHECK_HEADER_WINSOCK
  220. dnl -------------------------------------------------
  221. dnl Check for compilable and valid winsock.h header
  222. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
  223. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  224. AC_CACHE_CHECK([for winsock.h], [curl_cv_header_winsock_h], [
  225. AC_COMPILE_IFELSE([
  226. AC_LANG_PROGRAM([[
  227. #undef inline
  228. #ifndef WIN32_LEAN_AND_MEAN
  229. #define WIN32_LEAN_AND_MEAN
  230. #endif
  231. #include <windows.h>
  232. #include <winsock.h>
  233. ]],[[
  234. #if defined(__CYGWIN__) || defined(__CEGCC__)
  235. HAVE_WINSOCK_H shall not be defined.
  236. #else
  237. int dummy=WSACleanup();
  238. #endif
  239. ]])
  240. ],[
  241. curl_cv_header_winsock_h="yes"
  242. ],[
  243. curl_cv_header_winsock_h="no"
  244. ])
  245. ])
  246. case "$curl_cv_header_winsock_h" in
  247. yes)
  248. AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
  249. [Define to 1 if you have the winsock.h header file.])
  250. ;;
  251. esac
  252. ])
  253. dnl CURL_CHECK_HEADER_WINSOCK2
  254. dnl -------------------------------------------------
  255. dnl Check for compilable and valid winsock2.h header
  256. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
  257. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  258. AC_CACHE_CHECK([for winsock2.h], [curl_cv_header_winsock2_h], [
  259. AC_COMPILE_IFELSE([
  260. AC_LANG_PROGRAM([[
  261. #undef inline
  262. #ifndef WIN32_LEAN_AND_MEAN
  263. #define WIN32_LEAN_AND_MEAN
  264. #endif
  265. #include <windows.h>
  266. #include <winsock2.h>
  267. ]],[[
  268. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  269. HAVE_WINSOCK2_H shall not be defined.
  270. #else
  271. int dummy=2*IPPROTO_ESP;
  272. #endif
  273. ]])
  274. ],[
  275. curl_cv_header_winsock2_h="yes"
  276. ],[
  277. curl_cv_header_winsock2_h="no"
  278. ])
  279. ])
  280. case "$curl_cv_header_winsock2_h" in
  281. yes)
  282. AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
  283. [Define to 1 if you have the winsock2.h header file.])
  284. ;;
  285. esac
  286. ])
  287. dnl CURL_CHECK_HEADER_WS2TCPIP
  288. dnl -------------------------------------------------
  289. dnl Check for compilable and valid ws2tcpip.h header
  290. AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
  291. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  292. AC_CACHE_CHECK([for ws2tcpip.h], [curl_cv_header_ws2tcpip_h], [
  293. AC_COMPILE_IFELSE([
  294. AC_LANG_PROGRAM([[
  295. #undef inline
  296. #ifndef WIN32_LEAN_AND_MEAN
  297. #define WIN32_LEAN_AND_MEAN
  298. #endif
  299. #include <windows.h>
  300. #include <winsock2.h>
  301. #include <ws2tcpip.h>
  302. ]],[[
  303. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  304. HAVE_WS2TCPIP_H shall not be defined.
  305. #else
  306. int dummy=2*IP_PKTINFO;
  307. #endif
  308. ]])
  309. ],[
  310. curl_cv_header_ws2tcpip_h="yes"
  311. ],[
  312. curl_cv_header_ws2tcpip_h="no"
  313. ])
  314. ])
  315. case "$curl_cv_header_ws2tcpip_h" in
  316. yes)
  317. AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
  318. [Define to 1 if you have the ws2tcpip.h header file.])
  319. ;;
  320. esac
  321. ])
  322. dnl CURL_CHECK_HEADER_WINCRYPT
  323. dnl -------------------------------------------------
  324. dnl Check for compilable and valid wincrypt.h header
  325. AC_DEFUN([CURL_CHECK_HEADER_WINCRYPT], [
  326. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  327. AC_CACHE_CHECK([for wincrypt.h], [curl_cv_header_wincrypt_h], [
  328. AC_COMPILE_IFELSE([
  329. AC_LANG_PROGRAM([[
  330. #undef inline
  331. #ifndef WIN32_LEAN_AND_MEAN
  332. #define WIN32_LEAN_AND_MEAN
  333. #endif
  334. #include <windows.h>
  335. #include <wincrypt.h>
  336. ]],[[
  337. int dummy=2*PROV_RSA_FULL;
  338. ]])
  339. ],[
  340. curl_cv_header_wincrypt_h="yes"
  341. ],[
  342. curl_cv_header_wincrypt_h="no"
  343. ])
  344. ])
  345. case "$curl_cv_header_wincrypt_h" in
  346. yes)
  347. AC_DEFINE_UNQUOTED(HAVE_WINCRYPT_H, 1,
  348. [Define to 1 if you have the wincrypt.h header file.])
  349. ;;
  350. esac
  351. ])
  352. dnl CURL_CHECK_HEADER_WINLDAP
  353. dnl -------------------------------------------------
  354. dnl Check for compilable and valid winldap.h header
  355. AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
  356. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  357. AC_CACHE_CHECK([for winldap.h], [curl_cv_header_winldap_h], [
  358. AC_COMPILE_IFELSE([
  359. AC_LANG_PROGRAM([[
  360. #undef inline
  361. #ifdef HAVE_WINDOWS_H
  362. #ifndef WIN32_LEAN_AND_MEAN
  363. #define WIN32_LEAN_AND_MEAN
  364. #endif
  365. #include <windows.h>
  366. #endif
  367. #include <winldap.h>
  368. ]],[[
  369. #if defined(__CYGWIN__) || defined(__CEGCC__)
  370. HAVE_WINLDAP_H shall not be defined.
  371. #else
  372. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  373. ULONG res = ldap_unbind(ldp);
  374. #endif
  375. ]])
  376. ],[
  377. curl_cv_header_winldap_h="yes"
  378. ],[
  379. curl_cv_header_winldap_h="no"
  380. ])
  381. ])
  382. case "$curl_cv_header_winldap_h" in
  383. yes)
  384. AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
  385. [Define to 1 if you have the winldap.h header file.])
  386. ;;
  387. esac
  388. ])
  389. dnl CURL_CHECK_HEADER_WINBER
  390. dnl -------------------------------------------------
  391. dnl Check for compilable and valid winber.h header
  392. AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
  393. AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
  394. AC_CACHE_CHECK([for winber.h], [curl_cv_header_winber_h], [
  395. AC_COMPILE_IFELSE([
  396. AC_LANG_PROGRAM([[
  397. #undef inline
  398. #ifdef HAVE_WINDOWS_H
  399. #ifndef WIN32_LEAN_AND_MEAN
  400. #define WIN32_LEAN_AND_MEAN
  401. #endif
  402. #include <windows.h>
  403. #endif
  404. #include <winldap.h>
  405. #include <winber.h>
  406. ]],[[
  407. #if defined(__CYGWIN__) || defined(__CEGCC__)
  408. HAVE_WINBER_H shall not be defined.
  409. #else
  410. BERVAL *bvp = NULL;
  411. BerElement *bep = ber_init(bvp);
  412. ber_free(bep, 1);
  413. #endif
  414. ]])
  415. ],[
  416. curl_cv_header_winber_h="yes"
  417. ],[
  418. curl_cv_header_winber_h="no"
  419. ])
  420. ])
  421. case "$curl_cv_header_winber_h" in
  422. yes)
  423. AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
  424. [Define to 1 if you have the winber.h header file.])
  425. ;;
  426. esac
  427. ])
  428. dnl CURL_CHECK_HEADER_LBER
  429. dnl -------------------------------------------------
  430. dnl Check for compilable and valid lber.h header,
  431. dnl and check if it is needed even with ldap.h
  432. AC_DEFUN([CURL_CHECK_HEADER_LBER], [
  433. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  434. AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
  435. AC_COMPILE_IFELSE([
  436. AC_LANG_PROGRAM([[
  437. #undef inline
  438. #ifdef HAVE_WINDOWS_H
  439. #ifndef WIN32_LEAN_AND_MEAN
  440. #define WIN32_LEAN_AND_MEAN
  441. #endif
  442. #include <windows.h>
  443. #else
  444. #ifdef HAVE_SYS_TYPES_H
  445. #include <sys/types.h>
  446. #endif
  447. #endif
  448. #ifndef NULL
  449. #define NULL (void *)0
  450. #endif
  451. #include <lber.h>
  452. ]],[[
  453. BerValue *bvp = NULL;
  454. BerElement *bep = ber_init(bvp);
  455. ber_free(bep, 1);
  456. ]])
  457. ],[
  458. curl_cv_header_lber_h="yes"
  459. ],[
  460. curl_cv_header_lber_h="no"
  461. ])
  462. ])
  463. if test "$curl_cv_header_lber_h" = "yes"; then
  464. AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
  465. [Define to 1 if you have the lber.h header file.])
  466. #
  467. AC_COMPILE_IFELSE([
  468. AC_LANG_PROGRAM([[
  469. #undef inline
  470. #ifdef HAVE_WINDOWS_H
  471. #ifndef WIN32_LEAN_AND_MEAN
  472. #define WIN32_LEAN_AND_MEAN
  473. #endif
  474. #include <windows.h>
  475. #else
  476. #ifdef HAVE_SYS_TYPES_H
  477. #include <sys/types.h>
  478. #endif
  479. #endif
  480. #ifndef NULL
  481. #define NULL (void *)0
  482. #endif
  483. #ifndef LDAP_DEPRECATED
  484. #define LDAP_DEPRECATED 1
  485. #endif
  486. #include <ldap.h>
  487. ]],[[
  488. BerValue *bvp = NULL;
  489. BerElement *bep = ber_init(bvp);
  490. ber_free(bep, 1);
  491. ]])
  492. ],[
  493. curl_cv_need_header_lber_h="no"
  494. ],[
  495. curl_cv_need_header_lber_h="yes"
  496. ])
  497. #
  498. case "$curl_cv_need_header_lber_h" in
  499. yes)
  500. AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
  501. [Define to 1 if you need the lber.h header file even with ldap.h])
  502. ;;
  503. esac
  504. fi
  505. ])
  506. dnl CURL_CHECK_HEADER_LDAP
  507. dnl -------------------------------------------------
  508. dnl Check for compilable and valid ldap.h header
  509. AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
  510. AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
  511. AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
  512. AC_COMPILE_IFELSE([
  513. AC_LANG_PROGRAM([[
  514. #undef inline
  515. #ifdef HAVE_WINDOWS_H
  516. #ifndef WIN32_LEAN_AND_MEAN
  517. #define WIN32_LEAN_AND_MEAN
  518. #endif
  519. #include <windows.h>
  520. #else
  521. #ifdef HAVE_SYS_TYPES_H
  522. #include <sys/types.h>
  523. #endif
  524. #endif
  525. #ifndef LDAP_DEPRECATED
  526. #define LDAP_DEPRECATED 1
  527. #endif
  528. #ifdef NEED_LBER_H
  529. #include <lber.h>
  530. #endif
  531. #include <ldap.h>
  532. ]],[[
  533. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  534. int res = ldap_unbind(ldp);
  535. ]])
  536. ],[
  537. curl_cv_header_ldap_h="yes"
  538. ],[
  539. curl_cv_header_ldap_h="no"
  540. ])
  541. ])
  542. case "$curl_cv_header_ldap_h" in
  543. yes)
  544. AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
  545. [Define to 1 if you have the ldap.h header file.])
  546. ;;
  547. esac
  548. ])
  549. dnl CURL_CHECK_HEADER_LDAP_SSL
  550. dnl -------------------------------------------------
  551. dnl Check for compilable and valid ldap_ssl.h header
  552. AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
  553. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  554. AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
  555. AC_COMPILE_IFELSE([
  556. AC_LANG_PROGRAM([[
  557. #undef inline
  558. #ifdef HAVE_WINDOWS_H
  559. #ifndef WIN32_LEAN_AND_MEAN
  560. #define WIN32_LEAN_AND_MEAN
  561. #endif
  562. #include <windows.h>
  563. #else
  564. #ifdef HAVE_SYS_TYPES_H
  565. #include <sys/types.h>
  566. #endif
  567. #endif
  568. #ifndef LDAP_DEPRECATED
  569. #define LDAP_DEPRECATED 1
  570. #endif
  571. #ifdef NEED_LBER_H
  572. #include <lber.h>
  573. #endif
  574. #ifdef HAVE_LDAP_H
  575. #include <ldap.h>
  576. #endif
  577. #include <ldap_ssl.h>
  578. ]],[[
  579. LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
  580. ]])
  581. ],[
  582. curl_cv_header_ldap_ssl_h="yes"
  583. ],[
  584. curl_cv_header_ldap_ssl_h="no"
  585. ])
  586. ])
  587. case "$curl_cv_header_ldap_ssl_h" in
  588. yes)
  589. AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
  590. [Define to 1 if you have the ldap_ssl.h header file.])
  591. ;;
  592. esac
  593. ])
  594. dnl CURL_CHECK_HEADER_LDAPSSL
  595. dnl -------------------------------------------------
  596. dnl Check for compilable and valid ldapssl.h header
  597. AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
  598. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  599. AC_CACHE_CHECK([for ldapssl.h], [curl_cv_header_ldapssl_h], [
  600. AC_COMPILE_IFELSE([
  601. AC_LANG_PROGRAM([[
  602. #undef inline
  603. #ifdef HAVE_WINDOWS_H
  604. #ifndef WIN32_LEAN_AND_MEAN
  605. #define WIN32_LEAN_AND_MEAN
  606. #endif
  607. #include <windows.h>
  608. #else
  609. #ifdef HAVE_SYS_TYPES_H
  610. #include <sys/types.h>
  611. #endif
  612. #endif
  613. #ifndef NULL
  614. #define NULL (void *)0
  615. #endif
  616. #ifndef LDAP_DEPRECATED
  617. #define LDAP_DEPRECATED 1
  618. #endif
  619. #ifdef NEED_LBER_H
  620. #include <lber.h>
  621. #endif
  622. #ifdef HAVE_LDAP_H
  623. #include <ldap.h>
  624. #endif
  625. #include <ldapssl.h>
  626. ]],[[
  627. char *cert_label = NULL;
  628. LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
  629. ]])
  630. ],[
  631. curl_cv_header_ldapssl_h="yes"
  632. ],[
  633. curl_cv_header_ldapssl_h="no"
  634. ])
  635. ])
  636. case "$curl_cv_header_ldapssl_h" in
  637. yes)
  638. AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
  639. [Define to 1 if you have the ldapssl.h header file.])
  640. ;;
  641. esac
  642. ])
  643. dnl CURL_CHECK_LIBS_WINLDAP
  644. dnl -------------------------------------------------
  645. dnl Check for libraries needed for WINLDAP support,
  646. dnl and prepended to LIBS any needed libraries.
  647. dnl This macro can take an optional parameter with a
  648. dnl whitespace separated list of libraries to check
  649. dnl before the WINLDAP default ones.
  650. AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
  651. AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
  652. #
  653. AC_MSG_CHECKING([for WINLDAP libraries])
  654. #
  655. u_libs=""
  656. #
  657. ifelse($1,,,[
  658. for x_lib in $1; do
  659. case "$x_lib" in
  660. -l*)
  661. l_lib="$x_lib"
  662. ;;
  663. *)
  664. l_lib="-l$x_lib"
  665. ;;
  666. esac
  667. if test -z "$u_libs"; then
  668. u_libs="$l_lib"
  669. else
  670. u_libs="$u_libs $l_lib"
  671. fi
  672. done
  673. ])
  674. #
  675. curl_cv_save_LIBS="$LIBS"
  676. curl_cv_ldap_LIBS="unknown"
  677. #
  678. for x_nlibs in '' "$u_libs" \
  679. '-lwldap32' ; do
  680. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  681. if test -z "$x_nlibs"; then
  682. LIBS="$curl_cv_save_LIBS"
  683. else
  684. LIBS="$x_nlibs $curl_cv_save_LIBS"
  685. fi
  686. AC_LINK_IFELSE([
  687. AC_LANG_PROGRAM([[
  688. #undef inline
  689. #ifdef HAVE_WINDOWS_H
  690. #ifndef WIN32_LEAN_AND_MEAN
  691. #define WIN32_LEAN_AND_MEAN
  692. #endif
  693. #include <windows.h>
  694. #ifdef HAVE_WINLDAP_H
  695. #include <winldap.h>
  696. #endif
  697. #ifdef HAVE_WINBER_H
  698. #include <winber.h>
  699. #endif
  700. #endif
  701. ]],[[
  702. BERVAL *bvp = NULL;
  703. BerElement *bep = ber_init(bvp);
  704. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  705. ULONG res = ldap_unbind(ldp);
  706. ber_free(bep, 1);
  707. ]])
  708. ],[
  709. curl_cv_ldap_LIBS="$x_nlibs"
  710. ])
  711. fi
  712. done
  713. #
  714. LIBS="$curl_cv_save_LIBS"
  715. #
  716. case X-"$curl_cv_ldap_LIBS" in
  717. X-unknown)
  718. AC_MSG_RESULT([cannot find WINLDAP libraries])
  719. ;;
  720. X-)
  721. AC_MSG_RESULT([no additional lib required])
  722. ;;
  723. *)
  724. if test -z "$curl_cv_save_LIBS"; then
  725. LIBS="$curl_cv_ldap_LIBS"
  726. else
  727. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  728. fi
  729. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  730. ;;
  731. esac
  732. #
  733. ])
  734. dnl CURL_CHECK_LIBS_LDAP
  735. dnl -------------------------------------------------
  736. dnl Check for libraries needed for LDAP support,
  737. dnl and prepended to LIBS any needed libraries.
  738. dnl This macro can take an optional parameter with a
  739. dnl whitespace separated list of libraries to check
  740. dnl before the default ones.
  741. AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
  742. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  743. #
  744. AC_MSG_CHECKING([for LDAP libraries])
  745. #
  746. u_libs=""
  747. #
  748. ifelse($1,,,[
  749. for x_lib in $1; do
  750. case "$x_lib" in
  751. -l*)
  752. l_lib="$x_lib"
  753. ;;
  754. *)
  755. l_lib="-l$x_lib"
  756. ;;
  757. esac
  758. if test -z "$u_libs"; then
  759. u_libs="$l_lib"
  760. else
  761. u_libs="$u_libs $l_lib"
  762. fi
  763. done
  764. ])
  765. #
  766. curl_cv_save_LIBS="$LIBS"
  767. curl_cv_ldap_LIBS="unknown"
  768. #
  769. for x_nlibs in '' "$u_libs" \
  770. '-lldap' \
  771. '-lldap -llber' \
  772. '-llber -lldap' \
  773. '-lldapssl -lldapx -lldapsdk' \
  774. '-lldapsdk -lldapx -lldapssl' \
  775. '-lldap -llber -lssl -lcrypto' ; do
  776. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  777. if test -z "$x_nlibs"; then
  778. LIBS="$curl_cv_save_LIBS"
  779. else
  780. LIBS="$x_nlibs $curl_cv_save_LIBS"
  781. fi
  782. AC_LINK_IFELSE([
  783. AC_LANG_PROGRAM([[
  784. #undef inline
  785. #ifdef HAVE_WINDOWS_H
  786. #ifndef WIN32_LEAN_AND_MEAN
  787. #define WIN32_LEAN_AND_MEAN
  788. #endif
  789. #include <windows.h>
  790. #else
  791. #ifdef HAVE_SYS_TYPES_H
  792. #include <sys/types.h>
  793. #endif
  794. #endif
  795. #ifndef NULL
  796. #define NULL (void *)0
  797. #endif
  798. #ifndef LDAP_DEPRECATED
  799. #define LDAP_DEPRECATED 1
  800. #endif
  801. #ifdef NEED_LBER_H
  802. #include <lber.h>
  803. #endif
  804. #ifdef HAVE_LDAP_H
  805. #include <ldap.h>
  806. #endif
  807. ]],[[
  808. BerValue *bvp = NULL;
  809. BerElement *bep = ber_init(bvp);
  810. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  811. int res = ldap_unbind(ldp);
  812. ber_free(bep, 1);
  813. ]])
  814. ],[
  815. curl_cv_ldap_LIBS="$x_nlibs"
  816. ])
  817. fi
  818. done
  819. #
  820. LIBS="$curl_cv_save_LIBS"
  821. #
  822. case X-"$curl_cv_ldap_LIBS" in
  823. X-unknown)
  824. AC_MSG_RESULT([cannot find LDAP libraries])
  825. ;;
  826. X-)
  827. AC_MSG_RESULT([no additional lib required])
  828. ;;
  829. *)
  830. if test -z "$curl_cv_save_LIBS"; then
  831. LIBS="$curl_cv_ldap_LIBS"
  832. else
  833. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  834. fi
  835. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  836. ;;
  837. esac
  838. #
  839. ])
  840. dnl CURL_CHECK_HEADER_MALLOC
  841. dnl -------------------------------------------------
  842. dnl Check for compilable and valid malloc.h header,
  843. dnl and check if it is needed even with stdlib.h
  844. AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
  845. AC_CACHE_CHECK([for malloc.h], [curl_cv_header_malloc_h], [
  846. AC_COMPILE_IFELSE([
  847. AC_LANG_PROGRAM([[
  848. #include <malloc.h>
  849. ]],[[
  850. void *p = malloc(10);
  851. void *q = calloc(10,10);
  852. free(p);
  853. free(q);
  854. ]])
  855. ],[
  856. curl_cv_header_malloc_h="yes"
  857. ],[
  858. curl_cv_header_malloc_h="no"
  859. ])
  860. ])
  861. if test "$curl_cv_header_malloc_h" = "yes"; then
  862. AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
  863. [Define to 1 if you have the malloc.h header file.])
  864. #
  865. AC_COMPILE_IFELSE([
  866. AC_LANG_PROGRAM([[
  867. #include <stdlib.h>
  868. ]],[[
  869. void *p = malloc(10);
  870. void *q = calloc(10,10);
  871. free(p);
  872. free(q);
  873. ]])
  874. ],[
  875. curl_cv_need_header_malloc_h="no"
  876. ],[
  877. curl_cv_need_header_malloc_h="yes"
  878. ])
  879. #
  880. case "$curl_cv_need_header_malloc_h" in
  881. yes)
  882. AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
  883. [Define to 1 if you need the malloc.h header file even with stdlib.h])
  884. ;;
  885. esac
  886. fi
  887. ])
  888. dnl CURL_CHECK_HEADER_MEMORY
  889. dnl -------------------------------------------------
  890. dnl Check for compilable and valid memory.h header,
  891. dnl and check if it is needed even with stdlib.h for
  892. dnl memory related functions.
  893. AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
  894. AC_CACHE_CHECK([for memory.h], [curl_cv_header_memory_h], [
  895. AC_COMPILE_IFELSE([
  896. AC_LANG_PROGRAM([[
  897. #include <memory.h>
  898. ]],[[
  899. void *p = malloc(10);
  900. void *q = calloc(10,10);
  901. free(p);
  902. free(q);
  903. ]])
  904. ],[
  905. curl_cv_header_memory_h="yes"
  906. ],[
  907. curl_cv_header_memory_h="no"
  908. ])
  909. ])
  910. if test "$curl_cv_header_memory_h" = "yes"; then
  911. AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
  912. [Define to 1 if you have the memory.h header file.])
  913. #
  914. AC_COMPILE_IFELSE([
  915. AC_LANG_PROGRAM([[
  916. #include <stdlib.h>
  917. ]],[[
  918. void *p = malloc(10);
  919. void *q = calloc(10,10);
  920. free(p);
  921. free(q);
  922. ]])
  923. ],[
  924. curl_cv_need_header_memory_h="no"
  925. ],[
  926. curl_cv_need_header_memory_h="yes"
  927. ])
  928. #
  929. case "$curl_cv_need_header_memory_h" in
  930. yes)
  931. AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
  932. [Define to 1 if you need the memory.h header file even with stdlib.h])
  933. ;;
  934. esac
  935. fi
  936. ])
  937. dnl TYPE_SOCKADDR_STORAGE
  938. dnl -------------------------------------------------
  939. dnl Check for struct sockaddr_storage. Most IPv6-enabled
  940. dnl hosts have it, but AIX 4.3 is one known exception.
  941. AC_DEFUN([TYPE_SOCKADDR_STORAGE],
  942. [
  943. AC_CHECK_TYPE([struct sockaddr_storage],
  944. AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
  945. [if struct sockaddr_storage is defined]), ,
  946. [
  947. #undef inline
  948. #ifdef HAVE_WINDOWS_H
  949. #ifndef WIN32_LEAN_AND_MEAN
  950. #define WIN32_LEAN_AND_MEAN
  951. #endif
  952. #include <windows.h>
  953. #ifdef HAVE_WINSOCK2_H
  954. #include <winsock2.h>
  955. #endif
  956. #else
  957. #ifdef HAVE_SYS_TYPES_H
  958. #include <sys/types.h>
  959. #endif
  960. #ifdef HAVE_SYS_SOCKET_H
  961. #include <sys/socket.h>
  962. #endif
  963. #ifdef HAVE_NETINET_IN_H
  964. #include <netinet/in.h>
  965. #endif
  966. #ifdef HAVE_ARPA_INET_H
  967. #include <arpa/inet.h>
  968. #endif
  969. #endif
  970. ])
  971. ])
  972. dnl CURL_CHECK_FUNC_RECV
  973. dnl -------------------------------------------------
  974. dnl Test if the socket recv() function is available,
  975. dnl and check its return type and the types of its
  976. dnl arguments. If the function succeeds HAVE_RECV
  977. dnl will be defined, defining the types of the arguments
  978. dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
  979. dnl and RECV_TYPE_ARG4, defining the type of the function
  980. dnl return value in RECV_TYPE_RETV.
  981. AC_DEFUN([CURL_CHECK_FUNC_RECV], [
  982. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  983. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  984. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  985. #
  986. AC_MSG_CHECKING([for recv])
  987. AC_LINK_IFELSE([
  988. AC_LANG_PROGRAM([[
  989. #undef inline
  990. #ifdef HAVE_WINDOWS_H
  991. #ifndef WIN32_LEAN_AND_MEAN
  992. #define WIN32_LEAN_AND_MEAN
  993. #endif
  994. #include <windows.h>
  995. #ifdef HAVE_WINSOCK2_H
  996. #include <winsock2.h>
  997. #else
  998. #ifdef HAVE_WINSOCK_H
  999. #include <winsock.h>
  1000. #endif
  1001. #endif
  1002. #else
  1003. #ifdef HAVE_PROTO_BSDSOCKET_H
  1004. #include <proto/bsdsocket.h>
  1005. struct Library *SocketBase = NULL;
  1006. #endif
  1007. #ifdef HAVE_SYS_TYPES_H
  1008. #include <sys/types.h>
  1009. #endif
  1010. #ifdef HAVE_SYS_SOCKET_H
  1011. #include <sys/socket.h>
  1012. #endif
  1013. #endif
  1014. ]],[[
  1015. recv(0, 0, 0, 0);
  1016. ]])
  1017. ],[
  1018. AC_MSG_RESULT([yes])
  1019. curl_cv_recv="yes"
  1020. ],[
  1021. AC_MSG_RESULT([no])
  1022. curl_cv_recv="no"
  1023. ])
  1024. #
  1025. if test "$curl_cv_recv" = "yes"; then
  1026. AC_CACHE_CHECK([types of args and return type for recv],
  1027. [curl_cv_func_recv_args], [
  1028. curl_cv_func_recv_args="unknown"
  1029. for recv_retv in 'int' 'ssize_t'; do
  1030. for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1031. for recv_arg2 in 'char *' 'void *'; do
  1032. for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1033. for recv_arg4 in 'int' 'unsigned int'; do
  1034. if test "$curl_cv_func_recv_args" = "unknown"; then
  1035. AC_COMPILE_IFELSE([
  1036. AC_LANG_PROGRAM([[
  1037. #undef inline
  1038. #ifdef HAVE_WINDOWS_H
  1039. #ifndef WIN32_LEAN_AND_MEAN
  1040. #define WIN32_LEAN_AND_MEAN
  1041. #endif
  1042. #include <windows.h>
  1043. #ifdef HAVE_WINSOCK2_H
  1044. #include <winsock2.h>
  1045. #else
  1046. #ifdef HAVE_WINSOCK_H
  1047. #include <winsock.h>
  1048. #endif
  1049. #endif
  1050. #define RECVCALLCONV PASCAL
  1051. #else
  1052. #ifdef HAVE_PROTO_BSDSOCKET_H
  1053. #include <proto/bsdsocket.h>
  1054. struct Library *SocketBase = NULL;
  1055. #endif
  1056. #ifdef HAVE_SYS_TYPES_H
  1057. #include <sys/types.h>
  1058. #endif
  1059. #ifdef HAVE_SYS_SOCKET_H
  1060. #include <sys/socket.h>
  1061. #endif
  1062. #define RECVCALLCONV
  1063. #endif
  1064. #ifndef HAVE_PROTO_BSDSOCKET_H
  1065. extern $recv_retv RECVCALLCONV
  1066. recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
  1067. #endif
  1068. ]],[[
  1069. $recv_arg1 s=0;
  1070. $recv_arg2 buf=0;
  1071. $recv_arg3 len=0;
  1072. $recv_arg4 flags=0;
  1073. $recv_retv res = recv(s, buf, len, flags);
  1074. ]])
  1075. ],[
  1076. curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
  1077. ])
  1078. fi
  1079. done
  1080. done
  1081. done
  1082. done
  1083. done
  1084. ]) # AC-CACHE-CHECK
  1085. if test "$curl_cv_func_recv_args" = "unknown"; then
  1086. AC_MSG_ERROR([Cannot find proper types to use for recv args])
  1087. else
  1088. recv_prev_IFS=$IFS; IFS=','
  1089. set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
  1090. IFS=$recv_prev_IFS
  1091. shift
  1092. #
  1093. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
  1094. [Define to the type of arg 1 for recv.])
  1095. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
  1096. [Define to the type of arg 2 for recv.])
  1097. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
  1098. [Define to the type of arg 3 for recv.])
  1099. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
  1100. [Define to the type of arg 4 for recv.])
  1101. AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
  1102. [Define to the function return type for recv.])
  1103. #
  1104. AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
  1105. [Define to 1 if you have the recv function.])
  1106. curl_cv_func_recv="yes"
  1107. fi
  1108. else
  1109. AC_MSG_ERROR([Unable to link function recv])
  1110. fi
  1111. ])
  1112. dnl CURL_CHECK_FUNC_SEND
  1113. dnl -------------------------------------------------
  1114. dnl Test if the socket send() function is available,
  1115. dnl and check its return type and the types of its
  1116. dnl arguments. If the function succeeds HAVE_SEND
  1117. dnl will be defined, defining the types of the arguments
  1118. dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
  1119. dnl and SEND_TYPE_ARG4, defining the type of the function
  1120. dnl return value in SEND_TYPE_RETV, and also defining the
  1121. dnl type qualifier of second argument in SEND_QUAL_ARG2.
  1122. AC_DEFUN([CURL_CHECK_FUNC_SEND], [
  1123. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1124. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1125. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1126. #
  1127. AC_MSG_CHECKING([for send])
  1128. AC_LINK_IFELSE([
  1129. AC_LANG_PROGRAM([[
  1130. #undef inline
  1131. #ifdef HAVE_WINDOWS_H
  1132. #ifndef WIN32_LEAN_AND_MEAN
  1133. #define WIN32_LEAN_AND_MEAN
  1134. #endif
  1135. #include <windows.h>
  1136. #ifdef HAVE_WINSOCK2_H
  1137. #include <winsock2.h>
  1138. #else
  1139. #ifdef HAVE_WINSOCK_H
  1140. #include <winsock.h>
  1141. #endif
  1142. #endif
  1143. #else
  1144. #ifdef HAVE_PROTO_BSDSOCKET_H
  1145. #include <proto/bsdsocket.h>
  1146. struct Library *SocketBase = NULL;
  1147. #endif
  1148. #ifdef HAVE_SYS_TYPES_H
  1149. #include <sys/types.h>
  1150. #endif
  1151. #ifdef HAVE_SYS_SOCKET_H
  1152. #include <sys/socket.h>
  1153. #endif
  1154. #endif
  1155. ]],[[
  1156. send(0, 0, 0, 0);
  1157. ]])
  1158. ],[
  1159. AC_MSG_RESULT([yes])
  1160. curl_cv_send="yes"
  1161. ],[
  1162. AC_MSG_RESULT([no])
  1163. curl_cv_send="no"
  1164. ])
  1165. #
  1166. if test "$curl_cv_send" = "yes"; then
  1167. AC_CACHE_CHECK([types of args and return type for send],
  1168. [curl_cv_func_send_args], [
  1169. curl_cv_func_send_args="unknown"
  1170. for send_retv in 'int' 'ssize_t'; do
  1171. for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1172. for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
  1173. for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1174. for send_arg4 in 'int' 'unsigned int'; do
  1175. if test "$curl_cv_func_send_args" = "unknown"; then
  1176. AC_COMPILE_IFELSE([
  1177. AC_LANG_PROGRAM([[
  1178. #undef inline
  1179. #ifdef HAVE_WINDOWS_H
  1180. #ifndef WIN32_LEAN_AND_MEAN
  1181. #define WIN32_LEAN_AND_MEAN
  1182. #endif
  1183. #include <windows.h>
  1184. #ifdef HAVE_WINSOCK2_H
  1185. #include <winsock2.h>
  1186. #else
  1187. #ifdef HAVE_WINSOCK_H
  1188. #include <winsock.h>
  1189. #endif
  1190. #endif
  1191. #define SENDCALLCONV PASCAL
  1192. #else
  1193. #ifdef HAVE_PROTO_BSDSOCKET_H
  1194. #include <proto/bsdsocket.h>
  1195. struct Library *SocketBase = NULL;
  1196. #endif
  1197. #ifdef HAVE_SYS_TYPES_H
  1198. #include <sys/types.h>
  1199. #endif
  1200. #ifdef HAVE_SYS_SOCKET_H
  1201. #include <sys/socket.h>
  1202. #endif
  1203. #define SENDCALLCONV
  1204. #endif
  1205. #ifndef HAVE_PROTO_BSDSOCKET_H
  1206. extern $send_retv SENDCALLCONV
  1207. send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
  1208. #endif
  1209. ]],[[
  1210. $send_arg1 s=0;
  1211. $send_arg3 len=0;
  1212. $send_arg4 flags=0;
  1213. $send_retv res = send(s, 0, len, flags);
  1214. ]])
  1215. ],[
  1216. curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
  1217. ])
  1218. fi
  1219. done
  1220. done
  1221. done
  1222. done
  1223. done
  1224. ]) # AC-CACHE-CHECK
  1225. if test "$curl_cv_func_send_args" = "unknown"; then
  1226. AC_MSG_ERROR([Cannot find proper types to use for send args])
  1227. else
  1228. send_prev_IFS=$IFS; IFS=','
  1229. set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
  1230. IFS=$send_prev_IFS
  1231. shift
  1232. #
  1233. send_qual_type_arg2=$[2]
  1234. #
  1235. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
  1236. [Define to the type of arg 1 for send.])
  1237. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
  1238. [Define to the type of arg 3 for send.])
  1239. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
  1240. [Define to the type of arg 4 for send.])
  1241. AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
  1242. [Define to the function return type for send.])
  1243. #
  1244. prev_sh_opts=$-
  1245. #
  1246. case $prev_sh_opts in
  1247. *f*)
  1248. ;;
  1249. *)
  1250. set -f
  1251. ;;
  1252. esac
  1253. #
  1254. case "$send_qual_type_arg2" in
  1255. const*)
  1256. send_qual_arg2=const
  1257. send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
  1258. ;;
  1259. *)
  1260. send_qual_arg2=
  1261. send_type_arg2=$send_qual_type_arg2
  1262. ;;
  1263. esac
  1264. #
  1265. AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
  1266. [Define to the type qualifier of arg 2 for send.])
  1267. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
  1268. [Define to the type of arg 2 for send.])
  1269. #
  1270. case $prev_sh_opts in
  1271. *f*)
  1272. ;;
  1273. *)
  1274. set +f
  1275. ;;
  1276. esac
  1277. #
  1278. AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
  1279. [Define to 1 if you have the send function.])
  1280. curl_cv_func_send="yes"
  1281. fi
  1282. else
  1283. AC_MSG_ERROR([Unable to link function send])
  1284. fi
  1285. ])
  1286. dnl CURL_CHECK_MSG_NOSIGNAL
  1287. dnl -------------------------------------------------
  1288. dnl Check for MSG_NOSIGNAL
  1289. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  1290. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1291. AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
  1292. AC_COMPILE_IFELSE([
  1293. AC_LANG_PROGRAM([[
  1294. #undef inline
  1295. #ifdef HAVE_WINDOWS_H
  1296. #ifndef WIN32_LEAN_AND_MEAN
  1297. #define WIN32_LEAN_AND_MEAN
  1298. #endif
  1299. #include <windows.h>
  1300. #ifdef HAVE_WINSOCK2_H
  1301. #include <winsock2.h>
  1302. #else
  1303. #ifdef HAVE_WINSOCK_H
  1304. #include <winsock.h>
  1305. #endif
  1306. #endif
  1307. #else
  1308. #ifdef HAVE_PROTO_BSDSOCKET_H
  1309. #include <proto/bsdsocket.h>
  1310. struct Library *SocketBase = NULL;
  1311. #endif
  1312. #ifdef HAVE_SYS_TYPES_H
  1313. #include <sys/types.h>
  1314. #endif
  1315. #ifdef HAVE_SYS_SOCKET_H
  1316. #include <sys/socket.h>
  1317. #endif
  1318. #endif
  1319. ]],[[
  1320. int flag=MSG_NOSIGNAL;
  1321. ]])
  1322. ],[
  1323. curl_cv_msg_nosignal="yes"
  1324. ],[
  1325. curl_cv_msg_nosignal="no"
  1326. ])
  1327. ])
  1328. case "$curl_cv_msg_nosignal" in
  1329. yes)
  1330. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  1331. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  1332. ;;
  1333. esac
  1334. ])
  1335. dnl CURL_CHECK_STRUCT_TIMEVAL
  1336. dnl -------------------------------------------------
  1337. dnl Check for timeval struct
  1338. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  1339. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1340. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1341. AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h)
  1342. AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
  1343. AC_COMPILE_IFELSE([
  1344. AC_LANG_PROGRAM([[
  1345. #undef inline
  1346. #ifdef HAVE_WINDOWS_H
  1347. #ifndef WIN32_LEAN_AND_MEAN
  1348. #define WIN32_LEAN_AND_MEAN
  1349. #endif
  1350. #include <windows.h>
  1351. #ifdef HAVE_WINSOCK2_H
  1352. #include <winsock2.h>
  1353. #else
  1354. #ifdef HAVE_WINSOCK_H
  1355. #include <winsock.h>
  1356. #endif
  1357. #endif
  1358. #endif
  1359. #ifdef HAVE_SYS_TYPES_H
  1360. #include <sys/types.h>
  1361. #endif
  1362. #ifdef HAVE_SYS_TIME_H
  1363. #include <sys/time.h>
  1364. #endif
  1365. #include <time.h>
  1366. #ifdef HAVE_SYS_SOCKET_H
  1367. #include <sys/socket.h>
  1368. #endif
  1369. ]],[[
  1370. struct timeval ts;
  1371. ts.tv_sec = 0;
  1372. ts.tv_usec = 0;
  1373. ]])
  1374. ],[
  1375. curl_cv_struct_timeval="yes"
  1376. ],[
  1377. curl_cv_struct_timeval="no"
  1378. ])
  1379. ])
  1380. case "$curl_cv_struct_timeval" in
  1381. yes)
  1382. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  1383. [Define to 1 if you have the timeval struct.])
  1384. ;;
  1385. esac
  1386. ])
  1387. dnl TYPE_IN_ADDR_T
  1388. dnl -------------------------------------------------
  1389. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  1390. dnl and a few other things.
  1391. AC_DEFUN([TYPE_IN_ADDR_T], [
  1392. AC_CHECK_TYPE([in_addr_t], ,[
  1393. dnl in_addr_t not available
  1394. AC_CACHE_CHECK([for in_addr_t equivalent],
  1395. [curl_cv_in_addr_t_equiv], [
  1396. curl_cv_in_addr_t_equiv="unknown"
  1397. for t in "unsigned long" int size_t unsigned long; do
  1398. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  1399. AC_LINK_IFELSE([
  1400. AC_LANG_PROGRAM([[
  1401. #undef inline
  1402. #ifdef HAVE_WINDOWS_H
  1403. #ifndef WIN32_LEAN_AND_MEAN
  1404. #define WIN32_LEAN_AND_MEAN
  1405. #endif
  1406. #include <windows.h>
  1407. #ifdef HAVE_WINSOCK2_H
  1408. #include <winsock2.h>
  1409. #else
  1410. #ifdef HAVE_WINSOCK_H
  1411. #include <winsock.h>
  1412. #endif
  1413. #endif
  1414. #else
  1415. #ifdef HAVE_SYS_TYPES_H
  1416. #include <sys/types.h>
  1417. #endif
  1418. #ifdef HAVE_SYS_SOCKET_H
  1419. #include <sys/socket.h>
  1420. #endif
  1421. #ifdef HAVE_NETINET_IN_H
  1422. #include <netinet/in.h>
  1423. #endif
  1424. #ifdef HAVE_ARPA_INET_H
  1425. #include <arpa/inet.h>
  1426. #endif
  1427. #endif
  1428. ]],[[
  1429. $t data = inet_addr ("1.2.3.4");
  1430. ]])
  1431. ],[
  1432. curl_cv_in_addr_t_equiv="$t"
  1433. ])
  1434. fi
  1435. done
  1436. ])
  1437. case "$curl_cv_in_addr_t_equiv" in
  1438. unknown)
  1439. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  1440. ;;
  1441. *)
  1442. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  1443. [Type to use in place of in_addr_t when system does not provide it.])
  1444. ;;
  1445. esac
  1446. ],[
  1447. #undef inline
  1448. #ifdef HAVE_WINDOWS_H
  1449. #ifndef WIN32_LEAN_AND_MEAN
  1450. #define WIN32_LEAN_AND_MEAN
  1451. #endif
  1452. #include <windows.h>
  1453. #ifdef HAVE_WINSOCK2_H
  1454. #include <winsock2.h>
  1455. #else
  1456. #ifdef HAVE_WINSOCK_H
  1457. #include <winsock.h>
  1458. #endif
  1459. #endif
  1460. #else
  1461. #ifdef HAVE_SYS_TYPES_H
  1462. #include <sys/types.h>
  1463. #endif
  1464. #ifdef HAVE_SYS_SOCKET_H
  1465. #include <sys/socket.h>
  1466. #endif
  1467. #ifdef HAVE_NETINET_IN_H
  1468. #include <netinet/in.h>
  1469. #endif
  1470. #ifdef HAVE_ARPA_INET_H
  1471. #include <arpa/inet.h>
  1472. #endif
  1473. #endif
  1474. ])
  1475. ])
  1476. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  1477. dnl -------------------------------------------------
  1478. dnl Check if monotonic clock_gettime is available.
  1479. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  1480. AC_CHECK_HEADERS(sys/types.h sys/time.h)
  1481. AC_MSG_CHECKING([for monotonic clock_gettime])
  1482. #
  1483. if test "x$dontwant_rt" = "xno" ; then
  1484. AC_COMPILE_IFELSE([
  1485. AC_LANG_PROGRAM([[
  1486. #ifdef HAVE_SYS_TYPES_H
  1487. #include <sys/types.h>
  1488. #endif
  1489. #ifdef HAVE_SYS_TIME_H
  1490. #include <sys/time.h>
  1491. #endif
  1492. #include <time.h>
  1493. ]],[[
  1494. struct timespec ts;
  1495. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1496. ]])
  1497. ],[
  1498. AC_MSG_RESULT([yes])
  1499. curl_func_clock_gettime="yes"
  1500. ],[
  1501. AC_MSG_RESULT([no])
  1502. curl_func_clock_gettime="no"
  1503. ])
  1504. fi
  1505. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  1506. dnl until library linking and run-time checks for clock_gettime succeed.
  1507. ])
  1508. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  1509. dnl -------------------------------------------------
  1510. dnl If monotonic clock_gettime is available then,
  1511. dnl check and prepended to LIBS any needed libraries.
  1512. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  1513. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  1514. #
  1515. if test "$curl_func_clock_gettime" = "yes"; then
  1516. #
  1517. AC_MSG_CHECKING([for clock_gettime in libraries])
  1518. #
  1519. curl_cv_save_LIBS="$LIBS"
  1520. curl_cv_gclk_LIBS="unknown"
  1521. #
  1522. for x_xlibs in '' '-lrt' '-lposix4' ; do
  1523. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  1524. if test -z "$x_xlibs"; then
  1525. LIBS="$curl_cv_save_LIBS"
  1526. else
  1527. LIBS="$x_xlibs $curl_cv_save_LIBS"
  1528. fi
  1529. AC_LINK_IFELSE([
  1530. AC_LANG_PROGRAM([[
  1531. #ifdef HAVE_SYS_TYPES_H
  1532. #include <sys/types.h>
  1533. #endif
  1534. #ifdef HAVE_SYS_TIME_H
  1535. #include <sys/time.h>
  1536. #endif
  1537. #include <time.h>
  1538. ]],[[
  1539. struct timespec ts;
  1540. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1541. ]])
  1542. ],[
  1543. curl_cv_gclk_LIBS="$x_xlibs"
  1544. ])
  1545. fi
  1546. done
  1547. #
  1548. LIBS="$curl_cv_save_LIBS"
  1549. #
  1550. case X-"$curl_cv_gclk_LIBS" in
  1551. X-unknown)
  1552. AC_MSG_RESULT([cannot find clock_gettime])
  1553. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1554. curl_func_clock_gettime="no"
  1555. ;;
  1556. X-)
  1557. AC_MSG_RESULT([no additional lib required])
  1558. curl_func_clock_gettime="yes"
  1559. ;;
  1560. *)
  1561. if test -z "$curl_cv_save_LIBS"; then
  1562. LIBS="$curl_cv_gclk_LIBS"
  1563. else
  1564. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  1565. fi
  1566. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  1567. curl_func_clock_gettime="yes"
  1568. ;;
  1569. esac
  1570. #
  1571. dnl only do runtime verification when not cross-compiling
  1572. if test "x$cross_compiling" != "xyes" &&
  1573. test "$curl_func_clock_gettime" = "yes"; then
  1574. AC_MSG_CHECKING([if monotonic clock_gettime works])
  1575. CURL_RUN_IFELSE([
  1576. AC_LANG_PROGRAM([[
  1577. #ifdef HAVE_STDLIB_H
  1578. #include <stdlib.h>
  1579. #endif
  1580. #ifdef HAVE_SYS_TYPES_H
  1581. #include <sys/types.h>
  1582. #endif
  1583. #ifdef HAVE_SYS_TIME_H
  1584. #include <sys/time.h>
  1585. #endif
  1586. #include <time.h>
  1587. ]],[[
  1588. struct timespec ts;
  1589. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  1590. exit(0);
  1591. else
  1592. exit(1);
  1593. ]])
  1594. ],[
  1595. AC_MSG_RESULT([yes])
  1596. ],[
  1597. AC_MSG_RESULT([no])
  1598. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1599. curl_func_clock_gettime="no"
  1600. LIBS="$curl_cv_save_LIBS"
  1601. ])
  1602. fi
  1603. #
  1604. case "$curl_func_clock_gettime" in
  1605. yes)
  1606. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  1607. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  1608. ;;
  1609. esac
  1610. #
  1611. fi
  1612. #
  1613. ])
  1614. dnl CURL_CHECK_LIBS_CONNECT
  1615. dnl -------------------------------------------------
  1616. dnl Verify if network connect function is already available
  1617. dnl using current libraries or if another one is required.
  1618. AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
  1619. AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
  1620. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  1621. AC_MSG_CHECKING([for connect in libraries])
  1622. tst_connect_save_LIBS="$LIBS"
  1623. tst_connect_need_LIBS="unknown"
  1624. for tst_lib in '' '-lsocket' ; do
  1625. if test "$tst_connect_need_LIBS" = "unknown"; then
  1626. LIBS="$tst_lib $tst_connect_save_LIBS"
  1627. AC_LINK_IFELSE([
  1628. AC_LANG_PROGRAM([[
  1629. $curl_includes_winsock2
  1630. $curl_includes_bsdsocket
  1631. #if !defined(HAVE_WINDOWS_H) && !defined(HAVE_PROTO_BSDSOCKET_H)
  1632. int connect(int, void*, int);
  1633. #endif
  1634. ]],[[
  1635. if(0 != connect(0, 0, 0))
  1636. return 1;
  1637. ]])
  1638. ],[
  1639. tst_connect_need_LIBS="$tst_lib"
  1640. ])
  1641. fi
  1642. done
  1643. LIBS="$tst_connect_save_LIBS"
  1644. #
  1645. case X-"$tst_connect_need_LIBS" in
  1646. X-unknown)
  1647. AC_MSG_RESULT([cannot find connect])
  1648. AC_MSG_ERROR([cannot find connect function in libraries.])
  1649. ;;
  1650. X-)
  1651. AC_MSG_RESULT([yes])
  1652. ;;
  1653. *)
  1654. AC_MSG_RESULT([$tst_connect_need_LIBS])
  1655. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  1656. ;;
  1657. esac
  1658. ])
  1659. dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
  1660. dnl -------------------------------------------------
  1661. dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
  1662. dnl symbol that can be further used in custom template configuration
  1663. dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
  1664. dnl argument for the description. Symbol definitions done with this
  1665. dnl macro are intended to be exclusively used in handcrafted *.h.in
  1666. dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
  1667. dnl prevents autoheader generation and insertion of symbol template
  1668. dnl stub and definition into the first configuration header file. Do
  1669. dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
  1670. dnl one serves different functional needs.
  1671. AC_DEFUN([CURL_DEFINE_UNQUOTED], [
  1672. cat >>confdefs.h <<_EOF
  1673. [@%:@define] $1 ifelse($#, 2, [$2], 1)
  1674. _EOF
  1675. ])
  1676. dnl CURL_CONFIGURE_PULL_SYS_POLL
  1677. dnl -------------------------------------------------
  1678. dnl The need for the sys/poll.h inclusion arises mainly to properly
  1679. dnl interface AIX systems which define macros 'events' and 'revents'.
  1680. AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
  1681. AC_REQUIRE([CURL_INCLUDES_POLL])dnl
  1682. #
  1683. tst_poll_events_macro_defined="unknown"
  1684. #
  1685. AC_COMPILE_IFELSE([
  1686. AC_LANG_PROGRAM([[
  1687. $curl_includes_poll
  1688. ]],[[
  1689. #if defined(events) || defined(revents)
  1690. return 0;
  1691. #else
  1692. force compilation error
  1693. #endif
  1694. ]])
  1695. ],[
  1696. tst_poll_events_macro_defined="yes"
  1697. ],[
  1698. tst_poll_events_macro_defined="no"
  1699. ])
  1700. #
  1701. if test "$tst_poll_events_macro_defined" = "yes"; then
  1702. if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
  1703. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
  1704. fi
  1705. fi
  1706. #
  1707. ])
  1708. dnl CURL_CHECK_FUNC_SELECT
  1709. dnl -------------------------------------------------
  1710. dnl Test if the socket select() function is available,
  1711. dnl and check its return type and the types of its
  1712. dnl arguments. If the function succeeds HAVE_SELECT
  1713. dnl will be defined, defining the types of the
  1714. dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
  1715. dnl and SELECT_TYPE_ARG5, defining the type of the
  1716. dnl function return value in SELECT_TYPE_RETV, and
  1717. dnl also defining the type qualifier of fifth argument
  1718. dnl in SELECT_QUAL_ARG5.
  1719. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  1720. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  1721. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  1722. #
  1723. AC_MSG_CHECKING([for select])
  1724. AC_LINK_IFELSE([
  1725. AC_LANG_PROGRAM([[
  1726. #undef inline
  1727. #ifdef HAVE_WINDOWS_H
  1728. #ifndef WIN32_LEAN_AND_MEAN
  1729. #define WIN32_LEAN_AND_MEAN
  1730. #endif
  1731. #include <windows.h>
  1732. #ifdef HAVE_WINSOCK2_H
  1733. #include <winsock2.h>
  1734. #else
  1735. #ifdef HAVE_WINSOCK_H
  1736. #include <winsock.h>
  1737. #endif
  1738. #endif
  1739. #endif
  1740. #ifdef HAVE_SYS_TYPES_H
  1741. #include <sys/types.h>
  1742. #endif
  1743. #ifdef HAVE_SYS_TIME_H
  1744. #include <sys/time.h>
  1745. #endif
  1746. #include <time.h>
  1747. #ifndef HAVE_WINDOWS_H
  1748. #ifdef HAVE_SYS_SELECT_H
  1749. #include <sys/select.h>
  1750. #elif defined(HAVE_UNISTD_H)
  1751. #include <unistd.h>
  1752. #endif
  1753. #ifdef HAVE_SYS_SOCKET_H
  1754. #include <sys/socket.h>
  1755. #endif
  1756. #ifdef HAVE_PROTO_BSDSOCKET_H
  1757. #include <proto/bsdsocket.h>
  1758. struct Library *SocketBase = NULL;
  1759. #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
  1760. #endif
  1761. #endif
  1762. ]],[[
  1763. select(0, 0, 0, 0, 0);
  1764. ]])
  1765. ],[
  1766. AC_MSG_RESULT([yes])
  1767. curl_cv_select="yes"
  1768. ],[
  1769. AC_MSG_RESULT([no])
  1770. curl_cv_select="no"
  1771. ])
  1772. #
  1773. if test "$curl_cv_select" = "yes"; then
  1774. AC_CACHE_CHECK([types of args and return type for select],
  1775. [curl_cv_func_select_args], [
  1776. curl_cv_func_select_args="unknown"
  1777. for sel_retv in 'int' 'ssize_t'; do
  1778. for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
  1779. for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
  1780. for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
  1781. if test "$curl_cv_func_select_args" = "unknown"; then
  1782. AC_COMPILE_IFELSE([
  1783. AC_LANG_PROGRAM([[
  1784. #undef inline
  1785. #ifdef HAVE_WINDOWS_H
  1786. #ifndef WIN32_LEAN_AND_MEAN
  1787. #define WIN32_LEAN_AND_MEAN
  1788. #endif
  1789. #include <windows.h>
  1790. #ifdef HAVE_WINSOCK2_H
  1791. #include <winsock2.h>
  1792. #else
  1793. #ifdef HAVE_WINSOCK_H
  1794. #include <winsock.h>
  1795. #endif
  1796. #endif
  1797. #define SELECTCALLCONV PASCAL
  1798. #endif
  1799. #ifdef HAVE_SYS_TYPES_H
  1800. #include <sys/types.h>
  1801. #endif
  1802. #ifdef HAVE_SYS_TIME_H
  1803. #include <sys/time.h>
  1804. #endif
  1805. #include <time.h>
  1806. #ifndef HAVE_WINDOWS_H
  1807. #ifdef HAVE_SYS_SELECT_H
  1808. #include <sys/select.h>
  1809. #elif defined(HAVE_UNISTD_H)
  1810. #include <unistd.h>
  1811. #endif
  1812. #ifdef HAVE_SYS_SOCKET_H
  1813. #include <sys/socket.h>
  1814. #endif
  1815. #ifdef HAVE_PROTO_BSDSOCKET_H
  1816. #include <proto/bsdsocket.h>
  1817. struct Library *SocketBase = NULL;
  1818. #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
  1819. #endif
  1820. #define SELECTCALLCONV
  1821. #endif
  1822. #ifndef HAVE_STRUCT_TIMEVAL
  1823. struct timeval {
  1824. long tv_sec;
  1825. long tv_usec;
  1826. };
  1827. #endif
  1828. #ifndef HAVE_PROTO_BSDSOCKET_H
  1829. extern $sel_retv SELECTCALLCONV
  1830. select($sel_arg1,
  1831. $sel_arg234,
  1832. $sel_arg234,
  1833. $sel_arg234,
  1834. $sel_arg5);
  1835. #endif
  1836. ]],[[
  1837. $sel_arg1 nfds=0;
  1838. $sel_arg234 rfds=0;
  1839. $sel_arg234 wfds=0;
  1840. $sel_arg234 efds=0;
  1841. $sel_retv res = select(nfds, rfds, wfds, efds, 0);
  1842. ]])
  1843. ],[
  1844. curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
  1845. ])
  1846. fi
  1847. done
  1848. done
  1849. done
  1850. done
  1851. ]) # AC-CACHE-CHECK
  1852. if test "$curl_cv_func_select_args" = "unknown"; then
  1853. AC_MSG_WARN([Cannot find proper types to use for select args])
  1854. AC_MSG_WARN([HAVE_SELECT will not be defined])
  1855. else
  1856. select_prev_IFS=$IFS; IFS=','
  1857. set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
  1858. IFS=$select_prev_IFS
  1859. shift
  1860. #
  1861. sel_qual_type_arg5=$[3]
  1862. #
  1863. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
  1864. [Define to the type of arg 1 for select.])
  1865. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
  1866. [Define to the type of args 2, 3 and 4 for select.])
  1867. AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
  1868. [Define to the function return type for select.])
  1869. #
  1870. prev_sh_opts=$-
  1871. #
  1872. case $prev_sh_opts in
  1873. *f*)
  1874. ;;
  1875. *)
  1876. set -f
  1877. ;;
  1878. esac
  1879. #
  1880. case "$sel_qual_type_arg5" in
  1881. const*)
  1882. sel_qual_arg5=const
  1883. sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
  1884. ;;
  1885. *)
  1886. sel_qual_arg5=
  1887. sel_type_arg5=$sel_qual_type_arg5
  1888. ;;
  1889. esac
  1890. #
  1891. AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
  1892. [Define to the type qualifier of arg 5 for select.])
  1893. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
  1894. [Define to the type of arg 5 for select.])
  1895. #
  1896. case $prev_sh_opts in
  1897. *f*)
  1898. ;;
  1899. *)
  1900. set +f
  1901. ;;
  1902. esac
  1903. #
  1904. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  1905. [Define to 1 if you have the select function.])
  1906. curl_cv_func_select="yes"
  1907. fi
  1908. fi
  1909. ])
  1910. dnl CURL_VERIFY_RUNTIMELIBS
  1911. dnl -------------------------------------------------
  1912. dnl Verify that the shared libs found so far can be used when running
  1913. dnl programs, since otherwise the situation will create odd configure errors
  1914. dnl that are misleading people.
  1915. dnl
  1916. dnl Make sure this test is run BEFORE the first test in the script that
  1917. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  1918. dnl macro. It must also run AFTER all lib-checking macros are complete.
  1919. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  1920. dnl this test is of course not sensible if we are cross-compiling!
  1921. if test "x$cross_compiling" != xyes; then
  1922. dnl just run a program to verify that the libs checked for previous to this
  1923. dnl point also is available run-time!
  1924. AC_MSG_CHECKING([run-time libs availability])
  1925. CURL_RUN_IFELSE([
  1926. int main()
  1927. {
  1928. return 0;
  1929. }
  1930. ],
  1931. AC_MSG_RESULT([fine]),
  1932. AC_MSG_RESULT([failed])
  1933. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  1934. )
  1935. dnl if this test fails, configure has already stopped
  1936. fi
  1937. ])
  1938. dnl CURL_CHECK_VARIADIC_MACROS
  1939. dnl -------------------------------------------------
  1940. dnl Check compiler support of variadic macros
  1941. AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
  1942. AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
  1943. [curl_cv_variadic_macros_c99], [
  1944. AC_COMPILE_IFELSE([
  1945. AC_LANG_PROGRAM([[
  1946. #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
  1947. #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
  1948. int fun3(int arg1, int arg2, int arg3);
  1949. int fun2(int arg1, int arg2);
  1950. int fun3(int arg1, int arg2, int arg3)
  1951. { return arg1 + arg2 + arg3; }
  1952. int fun2(int arg1, int arg2)
  1953. { return arg1 + arg2; }
  1954. ]],[[
  1955. int res3 = c99_vmacro3(1, 2, 3);
  1956. int res2 = c99_vmacro2(1, 2);
  1957. ]])
  1958. ],[
  1959. curl_cv_variadic_macros_c99="yes"
  1960. ],[
  1961. curl_cv_variadic_macros_c99="no"
  1962. ])
  1963. ])
  1964. case "$curl_cv_variadic_macros_c99" in
  1965. yes)
  1966. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
  1967. [Define to 1 if compiler supports C99 variadic macro style.])
  1968. ;;
  1969. esac
  1970. AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
  1971. [curl_cv_variadic_macros_gcc], [
  1972. AC_COMPILE_IFELSE([
  1973. AC_LANG_PROGRAM([[
  1974. #define gcc_vmacro3(first, args...) fun3(first, args)
  1975. #define gcc_vmacro2(first, args...) fun2(first, args)
  1976. int fun3(int arg1, int arg2, int arg3);
  1977. int fun2(int arg1, int arg2);
  1978. int fun3(int arg1, int arg2, int arg3)
  1979. { return arg1 + arg2 + arg3; }
  1980. int fun2(int arg1, int arg2)
  1981. { return arg1 + arg2; }
  1982. ]],[[
  1983. int res3 = gcc_vmacro3(1, 2, 3);
  1984. int res2 = gcc_vmacro2(1, 2);
  1985. ]])
  1986. ],[
  1987. curl_cv_variadic_macros_gcc="yes"
  1988. ],[
  1989. curl_cv_variadic_macros_gcc="no"
  1990. ])
  1991. ])
  1992. case "$curl_cv_variadic_macros_gcc" in
  1993. yes)
  1994. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
  1995. [Define to 1 if compiler supports old gcc variadic macro style.])
  1996. ;;
  1997. esac
  1998. ])
  1999. dnl CURL_CHECK_CA_BUNDLE
  2000. dnl -------------------------------------------------
  2001. dnl Check if a default ca-bundle should be used
  2002. dnl
  2003. dnl regarding the paths this will scan:
  2004. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  2005. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  2006. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  2007. dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD
  2008. dnl /etc/ssl/cert.pem OpenBSD, FreeBSD (symlink)
  2009. dnl /etc/ssl/certs/ (ca path) SUSE
  2010. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  2011. AC_MSG_CHECKING([default CA cert bundle/path])
  2012. AC_ARG_WITH(ca-bundle,
  2013. AS_HELP_STRING([--with-ca-bundle=FILE],
  2014. [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
  2015. AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  2016. [
  2017. want_ca="$withval"
  2018. if test "x$want_ca" = "xyes"; then
  2019. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  2020. fi
  2021. ],
  2022. [ want_ca="unset" ])
  2023. AC_ARG_WITH(ca-path,
  2024. AS_HELP_STRING([--with-ca-path=DIRECTORY],
  2025. [Path to a directory containing CA certificates stored individually, with \
  2026. their filenames in a hash format. This option can be used with the OpenSSL, \
  2027. GnuTLS and mbedTLS backends. Refer to OpenSSL c_rehash for details. \
  2028. (example: /etc/certificates)])
  2029. AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  2030. [
  2031. want_capath="$withval"
  2032. if test "x$want_capath" = "xyes"; then
  2033. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  2034. fi
  2035. ],
  2036. [ want_capath="unset"])
  2037. ca_warning=" (warning: certs not found)"
  2038. capath_warning=" (warning: certs not found)"
  2039. check_capath=""
  2040. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  2041. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2042. dnl both given
  2043. ca="$want_ca"
  2044. capath="$want_capath"
  2045. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  2046. dnl --with-ca-bundle given
  2047. ca="$want_ca"
  2048. capath="no"
  2049. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2050. dnl --with-ca-path given
  2051. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$MBEDTLS_ENABLED" != "x1"; then
  2052. AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or mbedTLS])
  2053. fi
  2054. capath="$want_capath"
  2055. ca="no"
  2056. else
  2057. dnl first try autodetecting a CA bundle , then a CA path
  2058. dnl both autodetections can be skipped by --without-ca-*
  2059. ca="no"
  2060. capath="no"
  2061. if test "x$cross_compiling" != "xyes"; then
  2062. dnl NOT cross-compiling and...
  2063. dnl neither of the --with-ca-* options are provided
  2064. if test "x$want_ca" = "xunset"; then
  2065. dnl the path we previously would have installed the curl ca bundle
  2066. dnl to, and thus we now check for an already existing cert in that
  2067. dnl place in case we find no other
  2068. if test "x$prefix" != xNONE; then
  2069. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  2070. else
  2071. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  2072. fi
  2073. for a in /etc/ssl/certs/ca-certificates.crt \
  2074. /etc/pki/tls/certs/ca-bundle.crt \
  2075. /usr/share/ssl/certs/ca-bundle.crt \
  2076. /usr/local/share/certs/ca-root-nss.crt \
  2077. /etc/ssl/cert.pem \
  2078. "$cac"; do
  2079. if test -f "$a"; then
  2080. ca="$a"
  2081. break
  2082. fi
  2083. done
  2084. fi
  2085. if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
  2086. "x$OPENSSL_ENABLED" = "x1"; then
  2087. check_capath="/etc/ssl/certs/"
  2088. fi
  2089. else
  2090. dnl no option given and cross-compiling
  2091. AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
  2092. fi
  2093. fi
  2094. if test "x$ca" = "xno" || test -f "$ca"; then
  2095. ca_warning=""
  2096. fi
  2097. if test "x$capath" != "xno"; then
  2098. check_capath="$capath"
  2099. fi
  2100. if test ! -z "$check_capath"; then
  2101. for a in "$check_capath"; do
  2102. 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
  2103. if test "x$capath" = "xno"; then
  2104. capath="$a"
  2105. fi
  2106. capath_warning=""
  2107. break
  2108. fi
  2109. done
  2110. fi
  2111. if test "x$capath" = "xno"; then
  2112. capath_warning=""
  2113. fi
  2114. if test "x$ca" != "xno"; then
  2115. CURL_CA_BUNDLE='"'$ca'"'
  2116. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  2117. AC_SUBST(CURL_CA_BUNDLE)
  2118. AC_MSG_RESULT([$ca])
  2119. fi
  2120. if test "x$capath" != "xno"; then
  2121. CURL_CA_PATH="\"$capath\""
  2122. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  2123. AC_MSG_RESULT([$capath (capath)])
  2124. fi
  2125. if test "x$ca" = "xno" && test "x$capath" = "xno"; then
  2126. AC_MSG_RESULT([no])
  2127. fi
  2128. AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
  2129. AC_ARG_WITH(ca-fallback,
  2130. AS_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
  2131. AS_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
  2132. [
  2133. if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
  2134. AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
  2135. fi
  2136. ],
  2137. [ with_ca_fallback="no"])
  2138. AC_MSG_RESULT([$with_ca_fallback])
  2139. if test "x$with_ca_fallback" = "xyes"; then
  2140. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
  2141. AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
  2142. fi
  2143. AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
  2144. fi
  2145. ])
  2146. dnl CURL_CHECK_WIN32_LARGEFILE
  2147. dnl -------------------------------------------------
  2148. dnl Check if curl's WIN32 large file will be used
  2149. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  2150. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  2151. AC_MSG_CHECKING([whether build target supports WIN32 file API])
  2152. curl_win32_file_api="no"
  2153. if test "$curl_cv_header_windows_h" = "yes"; then
  2154. if test x"$enable_largefile" != "xno"; then
  2155. AC_COMPILE_IFELSE([
  2156. AC_LANG_PROGRAM([[
  2157. ]],[[
  2158. #if !defined(_WIN32_WCE) && \
  2159. (defined(__MINGW32__) || \
  2160. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
  2161. int dummy=1;
  2162. #else
  2163. WIN32 large file API not supported.
  2164. #endif
  2165. ]])
  2166. ],[
  2167. curl_win32_file_api="win32_large_files"
  2168. ])
  2169. fi
  2170. if test "$curl_win32_file_api" = "no"; then
  2171. AC_COMPILE_IFELSE([
  2172. AC_LANG_PROGRAM([[
  2173. ]],[[
  2174. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  2175. int dummy=1;
  2176. #else
  2177. WIN32 small file API not supported.
  2178. #endif
  2179. ]])
  2180. ],[
  2181. curl_win32_file_api="win32_small_files"
  2182. ])
  2183. fi
  2184. fi
  2185. case "$curl_win32_file_api" in
  2186. win32_large_files)
  2187. AC_MSG_RESULT([yes (large file enabled)])
  2188. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  2189. [Define to 1 if you are building a Windows target with large file support.])
  2190. AC_SUBST(USE_WIN32_LARGE_FILES, [1])
  2191. ;;
  2192. win32_small_files)
  2193. AC_MSG_RESULT([yes (large file disabled)])
  2194. AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
  2195. [Define to 1 if you are building a Windows target without large file support.])
  2196. AC_SUBST(USE_WIN32_SMALL_FILES, [1])
  2197. ;;
  2198. *)
  2199. AC_MSG_RESULT([no])
  2200. ;;
  2201. esac
  2202. ])
  2203. dnl CURL_CHECK_WIN32_CRYPTO
  2204. dnl -------------------------------------------------
  2205. dnl Check if curl's WIN32 crypto lib can be used
  2206. AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
  2207. AC_REQUIRE([CURL_CHECK_HEADER_WINCRYPT])dnl
  2208. AC_MSG_CHECKING([whether build target supports WIN32 crypto API])
  2209. curl_win32_crypto_api="no"
  2210. if test "$curl_cv_header_wincrypt_h" = "yes"; then
  2211. AC_COMPILE_IFELSE([
  2212. AC_LANG_PROGRAM([[
  2213. #undef inline
  2214. #ifndef WIN32_LEAN_AND_MEAN
  2215. #define WIN32_LEAN_AND_MEAN
  2216. #endif
  2217. #include <windows.h>
  2218. #include <wincrypt.h>
  2219. ]],[[
  2220. HCRYPTPROV hCryptProv;
  2221. if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
  2222. CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
  2223. CryptReleaseContext(hCryptProv, 0);
  2224. }
  2225. ]])
  2226. ],[
  2227. curl_win32_crypto_api="yes"
  2228. ])
  2229. fi
  2230. case "$curl_win32_crypto_api" in
  2231. yes)
  2232. AC_MSG_RESULT([yes])
  2233. AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
  2234. [Define to 1 if you are building a Windows target with crypto API support.])
  2235. AC_SUBST(USE_WIN32_CRYPTO, [1])
  2236. ;;
  2237. *)
  2238. AC_MSG_RESULT([no])
  2239. ;;
  2240. esac
  2241. ])
  2242. dnl CURL_EXPORT_PCDIR ($pcdir)
  2243. dnl ------------------------
  2244. dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
  2245. dnl
  2246. dnl we need this macro since pkg-config distinguishes among empty and unset
  2247. dnl variable while checking PKG_CONFIG_LIBDIR
  2248. dnl
  2249. AC_DEFUN([CURL_EXPORT_PCDIR], [
  2250. if test -n "$1"; then
  2251. PKG_CONFIG_LIBDIR="$1"
  2252. export PKG_CONFIG_LIBDIR
  2253. fi
  2254. ])
  2255. dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
  2256. dnl ------------------------
  2257. dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
  2258. dnl path to it, or 'no' if not found/present.
  2259. dnl
  2260. dnl If pkg-config is present, check that it has info about the $module or
  2261. dnl return "no" anyway!
  2262. dnl
  2263. dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
  2264. dnl
  2265. AC_DEFUN([CURL_CHECK_PKGCONFIG], [
  2266. if test -n "$PKG_CONFIG"; then
  2267. PKGCONFIG="$PKG_CONFIG"
  2268. else
  2269. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
  2270. [$PATH:/usr/bin:/usr/local/bin])
  2271. fi
  2272. if test "x$PKGCONFIG" != "xno"; then
  2273. AC_MSG_CHECKING([for $1 options with pkg-config])
  2274. dnl ask pkg-config about $1
  2275. itexists=`CURL_EXPORT_PCDIR([$2]) dnl
  2276. $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
  2277. if test -z "$itexists"; then
  2278. dnl pkg-config does not have info about the given module! set the
  2279. dnl variable to 'no'
  2280. PKGCONFIG="no"
  2281. AC_MSG_RESULT([no])
  2282. else
  2283. AC_MSG_RESULT([found])
  2284. fi
  2285. fi
  2286. ])
  2287. dnl CURL_GENERATE_CONFIGUREHELP_PM
  2288. dnl -------------------------------------------------
  2289. dnl Generate test harness configurehelp.pm module, defining and
  2290. dnl initializing some perl variables with values which are known
  2291. dnl when the configure script runs. For portability reasons, test
  2292. dnl harness needs information on how to run the C preprocessor.
  2293. AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
  2294. AC_REQUIRE([AC_PROG_CPP])dnl
  2295. tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
  2296. if test -z "$tmp_cpp"; then
  2297. tmp_cpp='cpp'
  2298. fi
  2299. cat >./tests/configurehelp.pm <<_EOF
  2300. [@%:@] This is a generated file. Do not edit.
  2301. package configurehelp;
  2302. use strict;
  2303. use warnings;
  2304. use Exporter;
  2305. use vars qw(
  2306. @ISA
  2307. @EXPORT_OK
  2308. \$Cpreprocessor
  2309. );
  2310. @ISA = qw(Exporter);
  2311. @EXPORT_OK = qw(
  2312. \$Cpreprocessor
  2313. );
  2314. \$Cpreprocessor = '$tmp_cpp';
  2315. 1;
  2316. _EOF
  2317. ])
  2318. dnl CURL_CPP_P
  2319. dnl
  2320. dnl Check if $cpp -P should be used for extract define values due to gcc 5
  2321. dnl splitting up strings and defines between line outputs. gcc by default
  2322. dnl (without -P) will show TEST EINVAL TEST as
  2323. dnl
  2324. dnl # 13 "conftest.c"
  2325. dnl TEST
  2326. dnl # 13 "conftest.c" 3 4
  2327. dnl 22
  2328. dnl # 13 "conftest.c"
  2329. dnl TEST
  2330. AC_DEFUN([CURL_CPP_P], [
  2331. AC_MSG_CHECKING([if cpp -P is needed])
  2332. AC_EGREP_CPP([TEST.*TEST], [
  2333. #include <errno.h>
  2334. TEST EINVAL TEST
  2335. ], [cpp=no], [cpp=yes])
  2336. AC_MSG_RESULT([$cpp])
  2337. dnl we need cpp -P so check if it works then
  2338. if test "x$cpp" = "xyes"; then
  2339. AC_MSG_CHECKING([if cpp -P works])
  2340. OLDCPPFLAGS=$CPPFLAGS
  2341. CPPFLAGS="$CPPFLAGS -P"
  2342. AC_EGREP_CPP([TEST.*TEST], [
  2343. #include <errno.h>
  2344. TEST EINVAL TEST
  2345. ], [cpp_p=yes], [cpp_p=no])
  2346. AC_MSG_RESULT([$cpp_p])
  2347. if test "x$cpp_p" = "xno"; then
  2348. AC_MSG_WARN([failed to figure out cpp -P alternative])
  2349. # without -P
  2350. CPPPFLAG=""
  2351. else
  2352. # with -P
  2353. CPPPFLAG="-P"
  2354. fi
  2355. dnl restore CPPFLAGS
  2356. CPPFLAGS=$OLDCPPFLAGS
  2357. else
  2358. # without -P
  2359. CPPPFLAG=""
  2360. fi
  2361. ])
  2362. dnl CURL_DARWIN_CFLAGS
  2363. dnl
  2364. dnl Set -Werror=partial-availability to detect possible breaking code
  2365. dnl with very low deployment targets.
  2366. dnl
  2367. AC_DEFUN([CURL_DARWIN_CFLAGS], [
  2368. tst_cflags="no"
  2369. case $host_os in
  2370. darwin*)
  2371. tst_cflags="yes"
  2372. ;;
  2373. esac
  2374. AC_MSG_CHECKING([for good-to-use Darwin CFLAGS])
  2375. AC_MSG_RESULT([$tst_cflags]);
  2376. if test "$tst_cflags" = "yes"; then
  2377. old_CFLAGS=$CFLAGS
  2378. CFLAGS="$CFLAGS -Werror=partial-availability"
  2379. AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
  2380. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  2381. [AC_MSG_RESULT([yes])],
  2382. [AC_MSG_RESULT([no])
  2383. CFLAGS=$old_CFLAGS])
  2384. fi
  2385. ])
  2386. dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
  2387. dnl
  2388. dnl Check to see if the compiler supports __builtin_available. This built-in
  2389. dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
  2390. dnl the time this macro was written, the function was not yet documented. Its
  2391. dnl purpose is to return true if the code is running under a certain OS version
  2392. dnl or later.
  2393. AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
  2394. AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
  2395. AC_COMPILE_IFELSE([
  2396. AC_LANG_PROGRAM([[
  2397. #include <stdlib.h>
  2398. ]],[[
  2399. if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
  2400. ]])
  2401. ],[
  2402. AC_MSG_RESULT([yes])
  2403. AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
  2404. [Define to 1 if you have the __builtin_available function.])
  2405. ],[
  2406. AC_MSG_RESULT([no])
  2407. ])
  2408. ])