acinclude.m4 64 KB

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