acinclude.m4 68 KB

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