acinclude.m4 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572
  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' \
  745. '-lldap -llber -lssl -lcrypto' ; do
  746. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  747. if test -z "$x_nlibs"; then
  748. LIBS="$curl_cv_save_LIBS"
  749. else
  750. LIBS="$x_nlibs $curl_cv_save_LIBS"
  751. fi
  752. AC_LINK_IFELSE([
  753. AC_LANG_PROGRAM([[
  754. #undef inline
  755. #ifdef HAVE_WINDOWS_H
  756. #ifndef WIN32_LEAN_AND_MEAN
  757. #define WIN32_LEAN_AND_MEAN
  758. #endif
  759. #include <windows.h>
  760. #else
  761. #ifdef HAVE_SYS_TYPES_H
  762. #include <sys/types.h>
  763. #endif
  764. #endif
  765. #ifndef NULL
  766. #define NULL (void *)0
  767. #endif
  768. #ifndef LDAP_DEPRECATED
  769. #define LDAP_DEPRECATED 1
  770. #endif
  771. #ifdef NEED_LBER_H
  772. #include <lber.h>
  773. #endif
  774. #ifdef HAVE_LDAP_H
  775. #include <ldap.h>
  776. #endif
  777. ]],[[
  778. BerValue *bvp = NULL;
  779. BerElement *bep = ber_init(bvp);
  780. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  781. int res = ldap_unbind(ldp);
  782. ber_free(bep, 1);
  783. ]])
  784. ],[
  785. curl_cv_ldap_LIBS="$x_nlibs"
  786. ])
  787. fi
  788. done
  789. #
  790. LIBS="$curl_cv_save_LIBS"
  791. #
  792. case X-"$curl_cv_ldap_LIBS" in
  793. X-unknown)
  794. AC_MSG_RESULT([cannot find LDAP libraries])
  795. ;;
  796. X-)
  797. AC_MSG_RESULT([no additional lib required])
  798. ;;
  799. *)
  800. if test -z "$curl_cv_save_LIBS"; then
  801. LIBS="$curl_cv_ldap_LIBS"
  802. else
  803. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  804. fi
  805. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  806. ;;
  807. esac
  808. #
  809. ])
  810. dnl CURL_CHECK_HEADER_MALLOC
  811. dnl -------------------------------------------------
  812. dnl Check for compilable and valid malloc.h header,
  813. dnl and check if it is needed even with stdlib.h
  814. AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
  815. AC_CACHE_CHECK([for malloc.h], [curl_cv_header_malloc_h], [
  816. AC_COMPILE_IFELSE([
  817. AC_LANG_PROGRAM([[
  818. #include <malloc.h>
  819. ]],[[
  820. void *p = malloc(10);
  821. void *q = calloc(10,10);
  822. free(p);
  823. free(q);
  824. ]])
  825. ],[
  826. curl_cv_header_malloc_h="yes"
  827. ],[
  828. curl_cv_header_malloc_h="no"
  829. ])
  830. ])
  831. if test "$curl_cv_header_malloc_h" = "yes"; then
  832. AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
  833. [Define to 1 if you have the malloc.h header file.])
  834. #
  835. AC_COMPILE_IFELSE([
  836. AC_LANG_PROGRAM([[
  837. #include <stdlib.h>
  838. ]],[[
  839. void *p = malloc(10);
  840. void *q = calloc(10,10);
  841. free(p);
  842. free(q);
  843. ]])
  844. ],[
  845. curl_cv_need_header_malloc_h="no"
  846. ],[
  847. curl_cv_need_header_malloc_h="yes"
  848. ])
  849. #
  850. case "$curl_cv_need_header_malloc_h" in
  851. yes)
  852. AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
  853. [Define to 1 if you need the malloc.h header file even with stdlib.h])
  854. ;;
  855. esac
  856. fi
  857. ])
  858. dnl CURL_CHECK_HEADER_MEMORY
  859. dnl -------------------------------------------------
  860. dnl Check for compilable and valid memory.h header,
  861. dnl and check if it is needed even with stdlib.h for
  862. dnl memory related functions.
  863. AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
  864. AC_CACHE_CHECK([for memory.h], [curl_cv_header_memory_h], [
  865. AC_COMPILE_IFELSE([
  866. AC_LANG_PROGRAM([[
  867. #include <memory.h>
  868. ]],[[
  869. void *p = malloc(10);
  870. void *q = calloc(10,10);
  871. free(p);
  872. free(q);
  873. ]])
  874. ],[
  875. curl_cv_header_memory_h="yes"
  876. ],[
  877. curl_cv_header_memory_h="no"
  878. ])
  879. ])
  880. if test "$curl_cv_header_memory_h" = "yes"; then
  881. AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
  882. [Define to 1 if you have the memory.h header file.])
  883. #
  884. AC_COMPILE_IFELSE([
  885. AC_LANG_PROGRAM([[
  886. #include <stdlib.h>
  887. ]],[[
  888. void *p = malloc(10);
  889. void *q = calloc(10,10);
  890. free(p);
  891. free(q);
  892. ]])
  893. ],[
  894. curl_cv_need_header_memory_h="no"
  895. ],[
  896. curl_cv_need_header_memory_h="yes"
  897. ])
  898. #
  899. case "$curl_cv_need_header_memory_h" in
  900. yes)
  901. AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
  902. [Define to 1 if you need the memory.h header file even with stdlib.h])
  903. ;;
  904. esac
  905. fi
  906. ])
  907. dnl TYPE_SOCKADDR_STORAGE
  908. dnl -------------------------------------------------
  909. dnl Check for struct sockaddr_storage. Most IPv6-enabled
  910. dnl hosts have it, but AIX 4.3 is one known exception.
  911. AC_DEFUN([TYPE_SOCKADDR_STORAGE],
  912. [
  913. AC_CHECK_TYPE([struct sockaddr_storage],
  914. AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
  915. [if struct sockaddr_storage is defined]), ,
  916. [
  917. #undef inline
  918. #ifdef HAVE_WINDOWS_H
  919. #ifndef WIN32_LEAN_AND_MEAN
  920. #define WIN32_LEAN_AND_MEAN
  921. #endif
  922. #include <windows.h>
  923. #ifdef HAVE_WINSOCK2_H
  924. #include <winsock2.h>
  925. #endif
  926. #else
  927. #ifdef HAVE_SYS_TYPES_H
  928. #include <sys/types.h>
  929. #endif
  930. #ifdef HAVE_SYS_SOCKET_H
  931. #include <sys/socket.h>
  932. #endif
  933. #ifdef HAVE_NETINET_IN_H
  934. #include <netinet/in.h>
  935. #endif
  936. #ifdef HAVE_ARPA_INET_H
  937. #include <arpa/inet.h>
  938. #endif
  939. #endif
  940. ])
  941. ])
  942. dnl CURL_CHECK_FUNC_RECV
  943. dnl -------------------------------------------------
  944. dnl Test if the socket recv() function is available,
  945. dnl and check its return type and the types of its
  946. dnl arguments. If the function succeeds HAVE_RECV
  947. dnl will be defined, defining the types of the arguments
  948. dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
  949. dnl and RECV_TYPE_ARG4, defining the type of the function
  950. dnl return value in RECV_TYPE_RETV.
  951. AC_DEFUN([CURL_CHECK_FUNC_RECV], [
  952. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  953. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  954. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  955. #
  956. AC_MSG_CHECKING([for recv])
  957. AC_LINK_IFELSE([
  958. AC_LANG_PROGRAM([[
  959. #undef inline
  960. #ifdef HAVE_WINDOWS_H
  961. #ifndef WIN32_LEAN_AND_MEAN
  962. #define WIN32_LEAN_AND_MEAN
  963. #endif
  964. #include <windows.h>
  965. #ifdef HAVE_WINSOCK2_H
  966. #include <winsock2.h>
  967. #else
  968. #ifdef HAVE_WINSOCK_H
  969. #include <winsock.h>
  970. #endif
  971. #endif
  972. #else
  973. #ifdef HAVE_PROTO_BSDSOCKET_H
  974. #include <proto/bsdsocket.h>
  975. struct Library *SocketBase = NULL;
  976. #endif
  977. #ifdef HAVE_SYS_TYPES_H
  978. #include <sys/types.h>
  979. #endif
  980. #ifdef HAVE_SYS_SOCKET_H
  981. #include <sys/socket.h>
  982. #endif
  983. #endif
  984. ]],[[
  985. recv(0, 0, 0, 0);
  986. ]])
  987. ],[
  988. AC_MSG_RESULT([yes])
  989. curl_cv_recv="yes"
  990. ],[
  991. AC_MSG_RESULT([no])
  992. curl_cv_recv="no"
  993. ])
  994. #
  995. if test "$curl_cv_recv" = "yes"; then
  996. AC_CACHE_CHECK([types of args and return type for recv],
  997. [curl_cv_func_recv_args], [
  998. curl_cv_func_recv_args="unknown"
  999. for recv_retv in 'int' 'ssize_t'; do
  1000. for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1001. for recv_arg2 in 'char *' 'void *'; do
  1002. for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1003. for recv_arg4 in 'int' 'unsigned int'; do
  1004. if test "$curl_cv_func_recv_args" = "unknown"; then
  1005. AC_COMPILE_IFELSE([
  1006. AC_LANG_PROGRAM([[
  1007. #undef inline
  1008. #ifdef HAVE_WINDOWS_H
  1009. #ifndef WIN32_LEAN_AND_MEAN
  1010. #define WIN32_LEAN_AND_MEAN
  1011. #endif
  1012. #include <windows.h>
  1013. #ifdef HAVE_WINSOCK2_H
  1014. #include <winsock2.h>
  1015. #else
  1016. #ifdef HAVE_WINSOCK_H
  1017. #include <winsock.h>
  1018. #endif
  1019. #endif
  1020. #define RECVCALLCONV PASCAL
  1021. #else
  1022. #ifdef HAVE_PROTO_BSDSOCKET_H
  1023. #include <proto/bsdsocket.h>
  1024. struct Library *SocketBase = NULL;
  1025. #endif
  1026. #ifdef HAVE_SYS_TYPES_H
  1027. #include <sys/types.h>
  1028. #endif
  1029. #ifdef HAVE_SYS_SOCKET_H
  1030. #include <sys/socket.h>
  1031. #endif
  1032. #define RECVCALLCONV
  1033. #endif
  1034. #ifndef HAVE_PROTO_BSDSOCKET_H
  1035. extern $recv_retv RECVCALLCONV
  1036. recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
  1037. #endif
  1038. ]],[[
  1039. $recv_arg1 s=0;
  1040. $recv_arg2 buf=0;
  1041. $recv_arg3 len=0;
  1042. $recv_arg4 flags=0;
  1043. $recv_retv res = recv(s, buf, len, flags);
  1044. ]])
  1045. ],[
  1046. curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
  1047. ])
  1048. fi
  1049. done
  1050. done
  1051. done
  1052. done
  1053. done
  1054. ]) # AC-CACHE-CHECK
  1055. if test "$curl_cv_func_recv_args" = "unknown"; then
  1056. AC_MSG_ERROR([Cannot find proper types to use for recv args])
  1057. else
  1058. recv_prev_IFS=$IFS; IFS=','
  1059. set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
  1060. IFS=$recv_prev_IFS
  1061. shift
  1062. #
  1063. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
  1064. [Define to the type of arg 1 for recv.])
  1065. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
  1066. [Define to the type of arg 2 for recv.])
  1067. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
  1068. [Define to the type of arg 3 for recv.])
  1069. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
  1070. [Define to the type of arg 4 for recv.])
  1071. AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
  1072. [Define to the function return type for recv.])
  1073. #
  1074. AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
  1075. [Define to 1 if you have the recv function.])
  1076. curl_cv_func_recv="yes"
  1077. fi
  1078. else
  1079. AC_MSG_ERROR([Unable to link function recv])
  1080. fi
  1081. ])
  1082. dnl CURL_CHECK_FUNC_SEND
  1083. dnl -------------------------------------------------
  1084. dnl Test if the socket send() function is available,
  1085. dnl and check its return type and the types of its
  1086. dnl arguments. If the function succeeds HAVE_SEND
  1087. dnl will be defined, defining the types of the arguments
  1088. dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
  1089. dnl and SEND_TYPE_ARG4, defining the type of the function
  1090. dnl return value in SEND_TYPE_RETV, and also defining the
  1091. dnl type qualifier of second argument in SEND_QUAL_ARG2.
  1092. AC_DEFUN([CURL_CHECK_FUNC_SEND], [
  1093. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1094. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1095. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1096. #
  1097. AC_MSG_CHECKING([for send])
  1098. AC_LINK_IFELSE([
  1099. AC_LANG_PROGRAM([[
  1100. #undef inline
  1101. #ifdef HAVE_WINDOWS_H
  1102. #ifndef WIN32_LEAN_AND_MEAN
  1103. #define WIN32_LEAN_AND_MEAN
  1104. #endif
  1105. #include <windows.h>
  1106. #ifdef HAVE_WINSOCK2_H
  1107. #include <winsock2.h>
  1108. #else
  1109. #ifdef HAVE_WINSOCK_H
  1110. #include <winsock.h>
  1111. #endif
  1112. #endif
  1113. #else
  1114. #ifdef HAVE_PROTO_BSDSOCKET_H
  1115. #include <proto/bsdsocket.h>
  1116. struct Library *SocketBase = NULL;
  1117. #endif
  1118. #ifdef HAVE_SYS_TYPES_H
  1119. #include <sys/types.h>
  1120. #endif
  1121. #ifdef HAVE_SYS_SOCKET_H
  1122. #include <sys/socket.h>
  1123. #endif
  1124. #endif
  1125. ]],[[
  1126. send(0, 0, 0, 0);
  1127. ]])
  1128. ],[
  1129. AC_MSG_RESULT([yes])
  1130. curl_cv_send="yes"
  1131. ],[
  1132. AC_MSG_RESULT([no])
  1133. curl_cv_send="no"
  1134. ])
  1135. #
  1136. if test "$curl_cv_send" = "yes"; then
  1137. AC_CACHE_CHECK([types of args and return type for send],
  1138. [curl_cv_func_send_args], [
  1139. curl_cv_func_send_args="unknown"
  1140. for send_retv in 'int' 'ssize_t'; do
  1141. for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1142. for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
  1143. for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1144. for send_arg4 in 'int' 'unsigned int'; do
  1145. if test "$curl_cv_func_send_args" = "unknown"; then
  1146. AC_COMPILE_IFELSE([
  1147. AC_LANG_PROGRAM([[
  1148. #undef inline
  1149. #ifdef HAVE_WINDOWS_H
  1150. #ifndef WIN32_LEAN_AND_MEAN
  1151. #define WIN32_LEAN_AND_MEAN
  1152. #endif
  1153. #include <windows.h>
  1154. #ifdef HAVE_WINSOCK2_H
  1155. #include <winsock2.h>
  1156. #else
  1157. #ifdef HAVE_WINSOCK_H
  1158. #include <winsock.h>
  1159. #endif
  1160. #endif
  1161. #define SENDCALLCONV PASCAL
  1162. #else
  1163. #ifdef HAVE_PROTO_BSDSOCKET_H
  1164. #include <proto/bsdsocket.h>
  1165. struct Library *SocketBase = NULL;
  1166. #endif
  1167. #ifdef HAVE_SYS_TYPES_H
  1168. #include <sys/types.h>
  1169. #endif
  1170. #ifdef HAVE_SYS_SOCKET_H
  1171. #include <sys/socket.h>
  1172. #endif
  1173. #define SENDCALLCONV
  1174. #endif
  1175. #ifndef HAVE_PROTO_BSDSOCKET_H
  1176. extern $send_retv SENDCALLCONV
  1177. send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
  1178. #endif
  1179. ]],[[
  1180. $send_arg1 s=0;
  1181. $send_arg3 len=0;
  1182. $send_arg4 flags=0;
  1183. $send_retv res = send(s, 0, len, flags);
  1184. ]])
  1185. ],[
  1186. curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
  1187. ])
  1188. fi
  1189. done
  1190. done
  1191. done
  1192. done
  1193. done
  1194. ]) # AC-CACHE-CHECK
  1195. if test "$curl_cv_func_send_args" = "unknown"; then
  1196. AC_MSG_ERROR([Cannot find proper types to use for send args])
  1197. else
  1198. send_prev_IFS=$IFS; IFS=','
  1199. set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
  1200. IFS=$send_prev_IFS
  1201. shift
  1202. #
  1203. send_qual_type_arg2=$[2]
  1204. #
  1205. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
  1206. [Define to the type of arg 1 for send.])
  1207. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
  1208. [Define to the type of arg 3 for send.])
  1209. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
  1210. [Define to the type of arg 4 for send.])
  1211. AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
  1212. [Define to the function return type for send.])
  1213. #
  1214. prev_sh_opts=$-
  1215. #
  1216. case $prev_sh_opts in
  1217. *f*)
  1218. ;;
  1219. *)
  1220. set -f
  1221. ;;
  1222. esac
  1223. #
  1224. case "$send_qual_type_arg2" in
  1225. const*)
  1226. send_qual_arg2=const
  1227. send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
  1228. ;;
  1229. *)
  1230. send_qual_arg2=
  1231. send_type_arg2=$send_qual_type_arg2
  1232. ;;
  1233. esac
  1234. #
  1235. AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
  1236. [Define to the type qualifier of arg 2 for send.])
  1237. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
  1238. [Define to the type of arg 2 for send.])
  1239. #
  1240. case $prev_sh_opts in
  1241. *f*)
  1242. ;;
  1243. *)
  1244. set +f
  1245. ;;
  1246. esac
  1247. #
  1248. AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
  1249. [Define to 1 if you have the send function.])
  1250. curl_cv_func_send="yes"
  1251. fi
  1252. else
  1253. AC_MSG_ERROR([Unable to link function send])
  1254. fi
  1255. ])
  1256. dnl CURL_CHECK_MSG_NOSIGNAL
  1257. dnl -------------------------------------------------
  1258. dnl Check for MSG_NOSIGNAL
  1259. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  1260. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1261. AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
  1262. AC_COMPILE_IFELSE([
  1263. AC_LANG_PROGRAM([[
  1264. #undef inline
  1265. #ifdef HAVE_WINDOWS_H
  1266. #ifndef WIN32_LEAN_AND_MEAN
  1267. #define WIN32_LEAN_AND_MEAN
  1268. #endif
  1269. #include <windows.h>
  1270. #ifdef HAVE_WINSOCK2_H
  1271. #include <winsock2.h>
  1272. #else
  1273. #ifdef HAVE_WINSOCK_H
  1274. #include <winsock.h>
  1275. #endif
  1276. #endif
  1277. #else
  1278. #ifdef HAVE_PROTO_BSDSOCKET_H
  1279. #include <proto/bsdsocket.h>
  1280. struct Library *SocketBase = NULL;
  1281. #endif
  1282. #ifdef HAVE_SYS_TYPES_H
  1283. #include <sys/types.h>
  1284. #endif
  1285. #ifdef HAVE_SYS_SOCKET_H
  1286. #include <sys/socket.h>
  1287. #endif
  1288. #endif
  1289. ]],[[
  1290. int flag=MSG_NOSIGNAL;
  1291. ]])
  1292. ],[
  1293. curl_cv_msg_nosignal="yes"
  1294. ],[
  1295. curl_cv_msg_nosignal="no"
  1296. ])
  1297. ])
  1298. case "$curl_cv_msg_nosignal" in
  1299. yes)
  1300. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  1301. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  1302. ;;
  1303. esac
  1304. ])
  1305. dnl CURL_CHECK_STRUCT_TIMEVAL
  1306. dnl -------------------------------------------------
  1307. dnl Check for timeval struct
  1308. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  1309. AC_REQUIRE([AC_HEADER_TIME])dnl
  1310. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1311. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1312. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
  1313. AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
  1314. AC_COMPILE_IFELSE([
  1315. AC_LANG_PROGRAM([[
  1316. #undef inline
  1317. #ifdef HAVE_WINDOWS_H
  1318. #ifndef WIN32_LEAN_AND_MEAN
  1319. #define WIN32_LEAN_AND_MEAN
  1320. #endif
  1321. #include <windows.h>
  1322. #ifdef HAVE_WINSOCK2_H
  1323. #include <winsock2.h>
  1324. #else
  1325. #ifdef HAVE_WINSOCK_H
  1326. #include <winsock.h>
  1327. #endif
  1328. #endif
  1329. #endif
  1330. #ifdef HAVE_SYS_TYPES_H
  1331. #include <sys/types.h>
  1332. #endif
  1333. #ifdef HAVE_SYS_TIME_H
  1334. #include <sys/time.h>
  1335. #ifdef TIME_WITH_SYS_TIME
  1336. #include <time.h>
  1337. #endif
  1338. #else
  1339. #ifdef HAVE_TIME_H
  1340. #include <time.h>
  1341. #endif
  1342. #endif
  1343. #ifdef HAVE_SYS_SOCKET_H
  1344. #include <sys/socket.h>
  1345. #endif
  1346. ]],[[
  1347. struct timeval ts;
  1348. ts.tv_sec = 0;
  1349. ts.tv_usec = 0;
  1350. ]])
  1351. ],[
  1352. curl_cv_struct_timeval="yes"
  1353. ],[
  1354. curl_cv_struct_timeval="no"
  1355. ])
  1356. ])
  1357. case "$curl_cv_struct_timeval" in
  1358. yes)
  1359. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  1360. [Define to 1 if you have the timeval struct.])
  1361. ;;
  1362. esac
  1363. ])
  1364. dnl TYPE_SIG_ATOMIC_T
  1365. dnl -------------------------------------------------
  1366. dnl Check if the sig_atomic_t type is available, and
  1367. dnl verify if it is already defined as volatile.
  1368. AC_DEFUN([TYPE_SIG_ATOMIC_T], [
  1369. AC_CHECK_HEADERS(signal.h)
  1370. AC_CHECK_TYPE([sig_atomic_t],[
  1371. AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
  1372. [Define to 1 if sig_atomic_t is an available typedef.])
  1373. ], ,[
  1374. #ifdef HAVE_SIGNAL_H
  1375. #include <signal.h>
  1376. #endif
  1377. ])
  1378. case "$ac_cv_type_sig_atomic_t" in
  1379. yes)
  1380. #
  1381. AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
  1382. AC_LINK_IFELSE([
  1383. AC_LANG_PROGRAM([[
  1384. #ifdef HAVE_SIGNAL_H
  1385. #include <signal.h>
  1386. #endif
  1387. ]],[[
  1388. static volatile sig_atomic_t dummy = 0;
  1389. ]])
  1390. ],[
  1391. AC_MSG_RESULT([no])
  1392. curl_cv_sig_atomic_t_volatile="no"
  1393. ],[
  1394. AC_MSG_RESULT([yes])
  1395. curl_cv_sig_atomic_t_volatile="yes"
  1396. ])
  1397. #
  1398. if test "$curl_cv_sig_atomic_t_volatile" = "yes"; then
  1399. AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
  1400. [Define to 1 if sig_atomic_t is already defined as volatile.])
  1401. fi
  1402. ;;
  1403. esac
  1404. ])
  1405. dnl TYPE_IN_ADDR_T
  1406. dnl -------------------------------------------------
  1407. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  1408. dnl and a few other things.
  1409. AC_DEFUN([TYPE_IN_ADDR_T], [
  1410. AC_CHECK_TYPE([in_addr_t], ,[
  1411. dnl in_addr_t not available
  1412. AC_CACHE_CHECK([for in_addr_t equivalent],
  1413. [curl_cv_in_addr_t_equiv], [
  1414. curl_cv_in_addr_t_equiv="unknown"
  1415. for t in "unsigned long" int size_t unsigned long; do
  1416. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  1417. AC_LINK_IFELSE([
  1418. AC_LANG_PROGRAM([[
  1419. #undef inline
  1420. #ifdef HAVE_WINDOWS_H
  1421. #ifndef WIN32_LEAN_AND_MEAN
  1422. #define WIN32_LEAN_AND_MEAN
  1423. #endif
  1424. #include <windows.h>
  1425. #ifdef HAVE_WINSOCK2_H
  1426. #include <winsock2.h>
  1427. #else
  1428. #ifdef HAVE_WINSOCK_H
  1429. #include <winsock.h>
  1430. #endif
  1431. #endif
  1432. #else
  1433. #ifdef HAVE_SYS_TYPES_H
  1434. #include <sys/types.h>
  1435. #endif
  1436. #ifdef HAVE_SYS_SOCKET_H
  1437. #include <sys/socket.h>
  1438. #endif
  1439. #ifdef HAVE_NETINET_IN_H
  1440. #include <netinet/in.h>
  1441. #endif
  1442. #ifdef HAVE_ARPA_INET_H
  1443. #include <arpa/inet.h>
  1444. #endif
  1445. #endif
  1446. ]],[[
  1447. $t data = inet_addr ("1.2.3.4");
  1448. ]])
  1449. ],[
  1450. curl_cv_in_addr_t_equiv="$t"
  1451. ])
  1452. fi
  1453. done
  1454. ])
  1455. case "$curl_cv_in_addr_t_equiv" in
  1456. unknown)
  1457. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  1458. ;;
  1459. *)
  1460. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  1461. [Type to use in place of in_addr_t when system does not provide it.])
  1462. ;;
  1463. esac
  1464. ],[
  1465. #undef inline
  1466. #ifdef HAVE_WINDOWS_H
  1467. #ifndef WIN32_LEAN_AND_MEAN
  1468. #define WIN32_LEAN_AND_MEAN
  1469. #endif
  1470. #include <windows.h>
  1471. #ifdef HAVE_WINSOCK2_H
  1472. #include <winsock2.h>
  1473. #else
  1474. #ifdef HAVE_WINSOCK_H
  1475. #include <winsock.h>
  1476. #endif
  1477. #endif
  1478. #else
  1479. #ifdef HAVE_SYS_TYPES_H
  1480. #include <sys/types.h>
  1481. #endif
  1482. #ifdef HAVE_SYS_SOCKET_H
  1483. #include <sys/socket.h>
  1484. #endif
  1485. #ifdef HAVE_NETINET_IN_H
  1486. #include <netinet/in.h>
  1487. #endif
  1488. #ifdef HAVE_ARPA_INET_H
  1489. #include <arpa/inet.h>
  1490. #endif
  1491. #endif
  1492. ])
  1493. ])
  1494. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  1495. dnl -------------------------------------------------
  1496. dnl Check if monotonic clock_gettime is available.
  1497. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  1498. AC_REQUIRE([AC_HEADER_TIME])dnl
  1499. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
  1500. AC_MSG_CHECKING([for monotonic clock_gettime])
  1501. #
  1502. if test "x$dontwant_rt" = "xno" ; then
  1503. AC_COMPILE_IFELSE([
  1504. AC_LANG_PROGRAM([[
  1505. #ifdef HAVE_SYS_TYPES_H
  1506. #include <sys/types.h>
  1507. #endif
  1508. #ifdef HAVE_SYS_TIME_H
  1509. #include <sys/time.h>
  1510. #ifdef TIME_WITH_SYS_TIME
  1511. #include <time.h>
  1512. #endif
  1513. #else
  1514. #ifdef HAVE_TIME_H
  1515. #include <time.h>
  1516. #endif
  1517. #endif
  1518. ]],[[
  1519. struct timespec ts;
  1520. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1521. ]])
  1522. ],[
  1523. AC_MSG_RESULT([yes])
  1524. curl_func_clock_gettime="yes"
  1525. ],[
  1526. AC_MSG_RESULT([no])
  1527. curl_func_clock_gettime="no"
  1528. ])
  1529. fi
  1530. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  1531. dnl until library linking and run-time checks for clock_gettime succeed.
  1532. ])
  1533. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  1534. dnl -------------------------------------------------
  1535. dnl If monotonic clock_gettime is available then,
  1536. dnl check and prepended to LIBS any needed libraries.
  1537. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  1538. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  1539. #
  1540. if test "$curl_func_clock_gettime" = "yes"; then
  1541. #
  1542. AC_MSG_CHECKING([for clock_gettime in libraries])
  1543. #
  1544. curl_cv_save_LIBS="$LIBS"
  1545. curl_cv_gclk_LIBS="unknown"
  1546. #
  1547. for x_xlibs in '' '-lrt' '-lposix4' ; do
  1548. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  1549. if test -z "$x_xlibs"; then
  1550. LIBS="$curl_cv_save_LIBS"
  1551. else
  1552. LIBS="$x_xlibs $curl_cv_save_LIBS"
  1553. fi
  1554. AC_LINK_IFELSE([
  1555. AC_LANG_PROGRAM([[
  1556. #ifdef HAVE_SYS_TYPES_H
  1557. #include <sys/types.h>
  1558. #endif
  1559. #ifdef HAVE_SYS_TIME_H
  1560. #include <sys/time.h>
  1561. #ifdef TIME_WITH_SYS_TIME
  1562. #include <time.h>
  1563. #endif
  1564. #else
  1565. #ifdef HAVE_TIME_H
  1566. #include <time.h>
  1567. #endif
  1568. #endif
  1569. ]],[[
  1570. struct timespec ts;
  1571. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  1572. ]])
  1573. ],[
  1574. curl_cv_gclk_LIBS="$x_xlibs"
  1575. ])
  1576. fi
  1577. done
  1578. #
  1579. LIBS="$curl_cv_save_LIBS"
  1580. #
  1581. case X-"$curl_cv_gclk_LIBS" in
  1582. X-unknown)
  1583. AC_MSG_RESULT([cannot find clock_gettime])
  1584. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1585. curl_func_clock_gettime="no"
  1586. ;;
  1587. X-)
  1588. AC_MSG_RESULT([no additional lib required])
  1589. curl_func_clock_gettime="yes"
  1590. ;;
  1591. *)
  1592. if test -z "$curl_cv_save_LIBS"; then
  1593. LIBS="$curl_cv_gclk_LIBS"
  1594. else
  1595. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  1596. fi
  1597. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  1598. curl_func_clock_gettime="yes"
  1599. ;;
  1600. esac
  1601. #
  1602. dnl only do runtime verification when not cross-compiling
  1603. if test "x$cross_compiling" != "xyes" &&
  1604. test "$curl_func_clock_gettime" = "yes"; then
  1605. AC_MSG_CHECKING([if monotonic clock_gettime works])
  1606. CURL_RUN_IFELSE([
  1607. AC_LANG_PROGRAM([[
  1608. #ifdef HAVE_STDLIB_H
  1609. #include <stdlib.h>
  1610. #endif
  1611. #ifdef HAVE_SYS_TYPES_H
  1612. #include <sys/types.h>
  1613. #endif
  1614. #ifdef HAVE_SYS_TIME_H
  1615. #include <sys/time.h>
  1616. #ifdef TIME_WITH_SYS_TIME
  1617. #include <time.h>
  1618. #endif
  1619. #else
  1620. #ifdef HAVE_TIME_H
  1621. #include <time.h>
  1622. #endif
  1623. #endif
  1624. ]],[[
  1625. struct timespec ts;
  1626. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  1627. exit(0);
  1628. else
  1629. exit(1);
  1630. ]])
  1631. ],[
  1632. AC_MSG_RESULT([yes])
  1633. ],[
  1634. AC_MSG_RESULT([no])
  1635. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  1636. curl_func_clock_gettime="no"
  1637. LIBS="$curl_cv_save_LIBS"
  1638. ])
  1639. fi
  1640. #
  1641. case "$curl_func_clock_gettime" in
  1642. yes)
  1643. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  1644. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  1645. ;;
  1646. esac
  1647. #
  1648. fi
  1649. #
  1650. ])
  1651. dnl CURL_CHECK_LIBS_CONNECT
  1652. dnl -------------------------------------------------
  1653. dnl Verify if network connect function is already available
  1654. dnl using current libraries or if another one is required.
  1655. AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
  1656. AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
  1657. AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
  1658. AC_MSG_CHECKING([for connect in libraries])
  1659. tst_connect_save_LIBS="$LIBS"
  1660. tst_connect_need_LIBS="unknown"
  1661. for tst_lib in '' '-lsocket' ; do
  1662. if test "$tst_connect_need_LIBS" = "unknown"; then
  1663. LIBS="$tst_lib $tst_connect_save_LIBS"
  1664. AC_LINK_IFELSE([
  1665. AC_LANG_PROGRAM([[
  1666. $curl_includes_winsock2
  1667. $curl_includes_bsdsocket
  1668. #if !defined(HAVE_WINDOWS_H) && !defined(HAVE_PROTO_BSDSOCKET_H)
  1669. int connect(int, void*, int);
  1670. #endif
  1671. ]],[[
  1672. if(0 != connect(0, 0, 0))
  1673. return 1;
  1674. ]])
  1675. ],[
  1676. tst_connect_need_LIBS="$tst_lib"
  1677. ])
  1678. fi
  1679. done
  1680. LIBS="$tst_connect_save_LIBS"
  1681. #
  1682. case X-"$tst_connect_need_LIBS" in
  1683. X-unknown)
  1684. AC_MSG_RESULT([cannot find connect])
  1685. AC_MSG_ERROR([cannot find connect function in libraries.])
  1686. ;;
  1687. X-)
  1688. AC_MSG_RESULT([yes])
  1689. ;;
  1690. *)
  1691. AC_MSG_RESULT([$tst_connect_need_LIBS])
  1692. LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
  1693. ;;
  1694. esac
  1695. ])
  1696. dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
  1697. dnl -------------------------------------------------
  1698. dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
  1699. dnl symbol that can be further used in custom template configuration
  1700. dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
  1701. dnl argument for the description. Symbol definitions done with this
  1702. dnl macro are intended to be exclusively used in handcrafted *.h.in
  1703. dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
  1704. dnl prevents autoheader generation and insertion of symbol template
  1705. dnl stub and definition into the first configuration header file. Do
  1706. dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
  1707. dnl one serves different functional needs.
  1708. AC_DEFUN([CURL_DEFINE_UNQUOTED], [
  1709. cat >>confdefs.h <<_EOF
  1710. [@%:@define] $1 ifelse($#, 2, [$2], 1)
  1711. _EOF
  1712. ])
  1713. dnl CURL_CONFIGURE_PULL_SYS_POLL
  1714. dnl -------------------------------------------------
  1715. dnl The need for the sys/poll.h inclusion arises mainly to properly
  1716. dnl interface AIX systems which define macros 'events' and 'revents'.
  1717. AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
  1718. AC_REQUIRE([CURL_INCLUDES_POLL])dnl
  1719. #
  1720. tst_poll_events_macro_defined="unknown"
  1721. #
  1722. AC_COMPILE_IFELSE([
  1723. AC_LANG_PROGRAM([[
  1724. $curl_includes_poll
  1725. ]],[[
  1726. #if defined(events) || defined(revents)
  1727. return 0;
  1728. #else
  1729. force compilation error
  1730. #endif
  1731. ]])
  1732. ],[
  1733. tst_poll_events_macro_defined="yes"
  1734. ],[
  1735. tst_poll_events_macro_defined="no"
  1736. ])
  1737. #
  1738. if test "$tst_poll_events_macro_defined" = "yes"; then
  1739. if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
  1740. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
  1741. fi
  1742. fi
  1743. #
  1744. ])
  1745. dnl CURL_CHECK_FUNC_SELECT
  1746. dnl -------------------------------------------------
  1747. dnl Test if the socket select() function is available,
  1748. dnl and check its return type and the types of its
  1749. dnl arguments. If the function succeeds HAVE_SELECT
  1750. dnl will be defined, defining the types of the
  1751. dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
  1752. dnl and SELECT_TYPE_ARG5, defining the type of the
  1753. dnl function return value in SELECT_TYPE_RETV, and
  1754. dnl also defining the type qualifier of fifth argument
  1755. dnl in SELECT_QUAL_ARG5.
  1756. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  1757. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  1758. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  1759. #
  1760. AC_MSG_CHECKING([for select])
  1761. AC_LINK_IFELSE([
  1762. AC_LANG_PROGRAM([[
  1763. #undef inline
  1764. #ifdef HAVE_WINDOWS_H
  1765. #ifndef WIN32_LEAN_AND_MEAN
  1766. #define WIN32_LEAN_AND_MEAN
  1767. #endif
  1768. #include <windows.h>
  1769. #ifdef HAVE_WINSOCK2_H
  1770. #include <winsock2.h>
  1771. #else
  1772. #ifdef HAVE_WINSOCK_H
  1773. #include <winsock.h>
  1774. #endif
  1775. #endif
  1776. #endif
  1777. #ifdef HAVE_SYS_TYPES_H
  1778. #include <sys/types.h>
  1779. #endif
  1780. #ifdef HAVE_SYS_TIME_H
  1781. #include <sys/time.h>
  1782. #ifdef TIME_WITH_SYS_TIME
  1783. #include <time.h>
  1784. #endif
  1785. #else
  1786. #ifdef HAVE_TIME_H
  1787. #include <time.h>
  1788. #endif
  1789. #endif
  1790. #ifndef HAVE_WINDOWS_H
  1791. #ifdef HAVE_PROTO_BSDSOCKET_H
  1792. #include <proto/bsdsocket.h>
  1793. struct Library *SocketBase = NULL;
  1794. #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
  1795. #endif
  1796. #ifdef HAVE_SYS_SELECT_H
  1797. #include <sys/select.h>
  1798. #endif
  1799. #ifdef HAVE_SYS_SOCKET_H
  1800. #include <sys/socket.h>
  1801. #endif
  1802. #endif
  1803. ]],[[
  1804. select(0, 0, 0, 0, 0);
  1805. ]])
  1806. ],[
  1807. AC_MSG_RESULT([yes])
  1808. curl_cv_select="yes"
  1809. ],[
  1810. AC_MSG_RESULT([no])
  1811. curl_cv_select="no"
  1812. ])
  1813. #
  1814. if test "$curl_cv_select" = "yes"; then
  1815. AC_CACHE_CHECK([types of args and return type for select],
  1816. [curl_cv_func_select_args], [
  1817. curl_cv_func_select_args="unknown"
  1818. for sel_retv in 'int' 'ssize_t'; do
  1819. for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
  1820. for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
  1821. for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
  1822. if test "$curl_cv_func_select_args" = "unknown"; then
  1823. AC_COMPILE_IFELSE([
  1824. AC_LANG_PROGRAM([[
  1825. #undef inline
  1826. #ifdef HAVE_WINDOWS_H
  1827. #ifndef WIN32_LEAN_AND_MEAN
  1828. #define WIN32_LEAN_AND_MEAN
  1829. #endif
  1830. #include <windows.h>
  1831. #ifdef HAVE_WINSOCK2_H
  1832. #include <winsock2.h>
  1833. #else
  1834. #ifdef HAVE_WINSOCK_H
  1835. #include <winsock.h>
  1836. #endif
  1837. #endif
  1838. #define SELECTCALLCONV PASCAL
  1839. #endif
  1840. #ifdef HAVE_SYS_TYPES_H
  1841. #include <sys/types.h>
  1842. #endif
  1843. #ifdef HAVE_SYS_TIME_H
  1844. #include <sys/time.h>
  1845. #ifdef TIME_WITH_SYS_TIME
  1846. #include <time.h>
  1847. #endif
  1848. #else
  1849. #ifdef HAVE_TIME_H
  1850. #include <time.h>
  1851. #endif
  1852. #endif
  1853. #ifndef HAVE_WINDOWS_H
  1854. #ifdef HAVE_PROTO_BSDSOCKET_H
  1855. #include <proto/bsdsocket.h>
  1856. struct Library *SocketBase = NULL;
  1857. #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
  1858. #endif
  1859. #ifdef HAVE_SYS_SELECT_H
  1860. #include <sys/select.h>
  1861. #endif
  1862. #ifdef HAVE_SYS_SOCKET_H
  1863. #include <sys/socket.h>
  1864. #endif
  1865. #define SELECTCALLCONV
  1866. #endif
  1867. #ifndef HAVE_STRUCT_TIMEVAL
  1868. struct timeval {
  1869. long tv_sec;
  1870. long tv_usec;
  1871. };
  1872. #endif
  1873. #ifndef HAVE_PROTO_BSDSOCKET_H
  1874. extern $sel_retv SELECTCALLCONV
  1875. select($sel_arg1,
  1876. $sel_arg234,
  1877. $sel_arg234,
  1878. $sel_arg234,
  1879. $sel_arg5);
  1880. #endif
  1881. ]],[[
  1882. $sel_arg1 nfds=0;
  1883. $sel_arg234 rfds=0;
  1884. $sel_arg234 wfds=0;
  1885. $sel_arg234 efds=0;
  1886. $sel_retv res = select(nfds, rfds, wfds, efds, 0);
  1887. ]])
  1888. ],[
  1889. curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
  1890. ])
  1891. fi
  1892. done
  1893. done
  1894. done
  1895. done
  1896. ]) # AC-CACHE-CHECK
  1897. if test "$curl_cv_func_select_args" = "unknown"; then
  1898. AC_MSG_WARN([Cannot find proper types to use for select args])
  1899. AC_MSG_WARN([HAVE_SELECT will not be defined])
  1900. else
  1901. select_prev_IFS=$IFS; IFS=','
  1902. set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
  1903. IFS=$select_prev_IFS
  1904. shift
  1905. #
  1906. sel_qual_type_arg5=$[3]
  1907. #
  1908. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
  1909. [Define to the type of arg 1 for select.])
  1910. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
  1911. [Define to the type of args 2, 3 and 4 for select.])
  1912. AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
  1913. [Define to the function return type for select.])
  1914. #
  1915. prev_sh_opts=$-
  1916. #
  1917. case $prev_sh_opts in
  1918. *f*)
  1919. ;;
  1920. *)
  1921. set -f
  1922. ;;
  1923. esac
  1924. #
  1925. case "$sel_qual_type_arg5" in
  1926. const*)
  1927. sel_qual_arg5=const
  1928. sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
  1929. ;;
  1930. *)
  1931. sel_qual_arg5=
  1932. sel_type_arg5=$sel_qual_type_arg5
  1933. ;;
  1934. esac
  1935. #
  1936. AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
  1937. [Define to the type qualifier of arg 5 for select.])
  1938. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
  1939. [Define to the type of arg 5 for select.])
  1940. #
  1941. case $prev_sh_opts in
  1942. *f*)
  1943. ;;
  1944. *)
  1945. set +f
  1946. ;;
  1947. esac
  1948. #
  1949. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  1950. [Define to 1 if you have the select function.])
  1951. curl_cv_func_select="yes"
  1952. fi
  1953. fi
  1954. ])
  1955. dnl CURL_VERIFY_RUNTIMELIBS
  1956. dnl -------------------------------------------------
  1957. dnl Verify that the shared libs found so far can be used when running
  1958. dnl programs, since otherwise the situation will create odd configure errors
  1959. dnl that are misleading people.
  1960. dnl
  1961. dnl Make sure this test is run BEFORE the first test in the script that
  1962. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  1963. dnl macro. It must also run AFTER all lib-checking macros are complete.
  1964. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  1965. dnl this test is of course not sensible if we are cross-compiling!
  1966. if test "x$cross_compiling" != xyes; then
  1967. dnl just run a program to verify that the libs checked for previous to this
  1968. dnl point also is available run-time!
  1969. AC_MSG_CHECKING([run-time libs availability])
  1970. CURL_RUN_IFELSE([
  1971. int main()
  1972. {
  1973. return 0;
  1974. }
  1975. ],
  1976. AC_MSG_RESULT([fine]),
  1977. AC_MSG_RESULT([failed])
  1978. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  1979. )
  1980. dnl if this test fails, configure has already stopped
  1981. fi
  1982. ])
  1983. dnl CURL_CHECK_VARIADIC_MACROS
  1984. dnl -------------------------------------------------
  1985. dnl Check compiler support of variadic macros
  1986. AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
  1987. AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
  1988. [curl_cv_variadic_macros_c99], [
  1989. AC_COMPILE_IFELSE([
  1990. AC_LANG_PROGRAM([[
  1991. #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
  1992. #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
  1993. int fun3(int arg1, int arg2, int arg3);
  1994. int fun2(int arg1, int arg2);
  1995. int fun3(int arg1, int arg2, int arg3)
  1996. { return arg1 + arg2 + arg3; }
  1997. int fun2(int arg1, int arg2)
  1998. { return arg1 + arg2; }
  1999. ]],[[
  2000. int res3 = c99_vmacro3(1, 2, 3);
  2001. int res2 = c99_vmacro2(1, 2);
  2002. ]])
  2003. ],[
  2004. curl_cv_variadic_macros_c99="yes"
  2005. ],[
  2006. curl_cv_variadic_macros_c99="no"
  2007. ])
  2008. ])
  2009. case "$curl_cv_variadic_macros_c99" in
  2010. yes)
  2011. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
  2012. [Define to 1 if compiler supports C99 variadic macro style.])
  2013. ;;
  2014. esac
  2015. AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
  2016. [curl_cv_variadic_macros_gcc], [
  2017. AC_COMPILE_IFELSE([
  2018. AC_LANG_PROGRAM([[
  2019. #define gcc_vmacro3(first, args...) fun3(first, args)
  2020. #define gcc_vmacro2(first, args...) fun2(first, args)
  2021. int fun3(int arg1, int arg2, int arg3);
  2022. int fun2(int arg1, int arg2);
  2023. int fun3(int arg1, int arg2, int arg3)
  2024. { return arg1 + arg2 + arg3; }
  2025. int fun2(int arg1, int arg2)
  2026. { return arg1 + arg2; }
  2027. ]],[[
  2028. int res3 = gcc_vmacro3(1, 2, 3);
  2029. int res2 = gcc_vmacro2(1, 2);
  2030. ]])
  2031. ],[
  2032. curl_cv_variadic_macros_gcc="yes"
  2033. ],[
  2034. curl_cv_variadic_macros_gcc="no"
  2035. ])
  2036. ])
  2037. case "$curl_cv_variadic_macros_gcc" in
  2038. yes)
  2039. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
  2040. [Define to 1 if compiler supports old gcc variadic macro style.])
  2041. ;;
  2042. esac
  2043. ])
  2044. dnl CURL_CHECK_CA_BUNDLE
  2045. dnl -------------------------------------------------
  2046. dnl Check if a default ca-bundle should be used
  2047. dnl
  2048. dnl regarding the paths this will scan:
  2049. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  2050. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  2051. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  2052. dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD
  2053. dnl /etc/ssl/cert.pem OpenBSD, FreeBSD (symlink)
  2054. dnl /etc/ssl/certs/ (ca path) SUSE
  2055. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  2056. AC_MSG_CHECKING([default CA cert bundle/path])
  2057. AC_ARG_WITH(ca-bundle,
  2058. AC_HELP_STRING([--with-ca-bundle=FILE],
  2059. [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
  2060. AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  2061. [
  2062. want_ca="$withval"
  2063. if test "x$want_ca" = "xyes"; then
  2064. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  2065. fi
  2066. ],
  2067. [ want_ca="unset" ])
  2068. AC_ARG_WITH(ca-path,
  2069. AC_HELP_STRING([--with-ca-path=DIRECTORY],
  2070. [Path to a directory containing CA certificates stored individually, with \
  2071. their filenames in a hash format. This option can be used with OpenSSL, \
  2072. GnuTLS and PolarSSL backends. Refer to OpenSSL c_rehash for details. \
  2073. (example: /etc/certificates)])
  2074. AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  2075. [
  2076. want_capath="$withval"
  2077. if test "x$want_capath" = "xyes"; then
  2078. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  2079. fi
  2080. ],
  2081. [ want_capath="unset"])
  2082. ca_warning=" (warning: certs not found)"
  2083. capath_warning=" (warning: certs not found)"
  2084. check_capath=""
  2085. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  2086. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2087. dnl both given
  2088. ca="$want_ca"
  2089. capath="$want_capath"
  2090. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  2091. dnl --with-ca-bundle given
  2092. ca="$want_ca"
  2093. capath="no"
  2094. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  2095. dnl --with-ca-path given
  2096. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$POLARSSL_ENABLED" != "x1"; then
  2097. AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or PolarSSL])
  2098. fi
  2099. capath="$want_capath"
  2100. ca="no"
  2101. else
  2102. dnl first try autodetecting a CA bundle , then a CA path
  2103. dnl both autodetections can be skipped by --without-ca-*
  2104. ca="no"
  2105. capath="no"
  2106. if test "x$cross_compiling" != "xyes"; then
  2107. dnl NOT cross-compiling and...
  2108. dnl neither of the --with-ca-* options are provided
  2109. if test "x$want_ca" = "xunset"; then
  2110. dnl the path we previously would have installed the curl ca bundle
  2111. dnl to, and thus we now check for an already existing cert in that
  2112. dnl place in case we find no other
  2113. if test "x$prefix" != xNONE; then
  2114. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  2115. else
  2116. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  2117. fi
  2118. for a in /etc/ssl/certs/ca-certificates.crt \
  2119. /etc/pki/tls/certs/ca-bundle.crt \
  2120. /usr/share/ssl/certs/ca-bundle.crt \
  2121. /usr/local/share/certs/ca-root-nss.crt \
  2122. /etc/ssl/cert.pem \
  2123. "$cac"; do
  2124. if test -f "$a"; then
  2125. ca="$a"
  2126. break
  2127. fi
  2128. done
  2129. fi
  2130. if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
  2131. "x$OPENSSL_ENABLED" = "x1"; then
  2132. check_capath="/etc/ssl/certs/"
  2133. fi
  2134. else
  2135. dnl no option given and cross-compiling
  2136. AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
  2137. fi
  2138. fi
  2139. if test "x$ca" = "xno" || test -f "$ca"; then
  2140. ca_warning=""
  2141. fi
  2142. if test "x$capath" != "xno"; then
  2143. check_capath="$capath"
  2144. fi
  2145. if test ! -z "$check_capath"; then
  2146. for a in "$check_capath"; do
  2147. 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
  2148. if test "x$capath" = "xno"; then
  2149. capath="$a"
  2150. fi
  2151. capath_warning=""
  2152. break
  2153. fi
  2154. done
  2155. fi
  2156. if test "x$capath" = "xno"; then
  2157. capath_warning=""
  2158. fi
  2159. if test "x$ca" != "xno"; then
  2160. CURL_CA_BUNDLE='"'$ca'"'
  2161. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  2162. AC_SUBST(CURL_CA_BUNDLE)
  2163. AC_MSG_RESULT([$ca])
  2164. fi
  2165. if test "x$capath" != "xno"; then
  2166. CURL_CA_PATH="\"$capath\""
  2167. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  2168. AC_MSG_RESULT([$capath (capath)])
  2169. fi
  2170. if test "x$ca" = "xno" && test "x$capath" = "xno"; then
  2171. AC_MSG_RESULT([no])
  2172. fi
  2173. AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
  2174. AC_ARG_WITH(ca-fallback,
  2175. AC_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
  2176. AC_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
  2177. [
  2178. if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
  2179. AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
  2180. fi
  2181. ],
  2182. [ with_ca_fallback="no"])
  2183. AC_MSG_RESULT([$with_ca_fallback])
  2184. if test "x$with_ca_fallback" = "xyes"; then
  2185. if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
  2186. AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
  2187. fi
  2188. AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
  2189. fi
  2190. ])
  2191. dnl CURL_CHECK_WIN32_LARGEFILE
  2192. dnl -------------------------------------------------
  2193. dnl Check if curl's WIN32 large file will be used
  2194. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  2195. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  2196. AC_MSG_CHECKING([whether build target supports WIN32 file API])
  2197. curl_win32_file_api="no"
  2198. if test "$curl_cv_header_windows_h" = "yes"; then
  2199. if test x"$enable_largefile" != "xno"; then
  2200. AC_COMPILE_IFELSE([
  2201. AC_LANG_PROGRAM([[
  2202. ]],[[
  2203. #if !defined(_WIN32_WCE) && \
  2204. (defined(__MINGW32__) || \
  2205. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
  2206. int dummy=1;
  2207. #else
  2208. WIN32 large file API not supported.
  2209. #endif
  2210. ]])
  2211. ],[
  2212. curl_win32_file_api="win32_large_files"
  2213. ])
  2214. fi
  2215. if test "$curl_win32_file_api" = "no"; then
  2216. AC_COMPILE_IFELSE([
  2217. AC_LANG_PROGRAM([[
  2218. ]],[[
  2219. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  2220. int dummy=1;
  2221. #else
  2222. WIN32 small file API not supported.
  2223. #endif
  2224. ]])
  2225. ],[
  2226. curl_win32_file_api="win32_small_files"
  2227. ])
  2228. fi
  2229. fi
  2230. case "$curl_win32_file_api" in
  2231. win32_large_files)
  2232. AC_MSG_RESULT([yes (large file enabled)])
  2233. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  2234. [Define to 1 if you are building a Windows target with large file support.])
  2235. ;;
  2236. win32_small_files)
  2237. AC_MSG_RESULT([yes (large file disabled)])
  2238. AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
  2239. [Define to 1 if you are building a Windows target without large file support.])
  2240. ;;
  2241. *)
  2242. AC_MSG_RESULT([no])
  2243. ;;
  2244. esac
  2245. ])
  2246. dnl CURL_EXPORT_PCDIR ($pcdir)
  2247. dnl ------------------------
  2248. dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
  2249. dnl
  2250. dnl we need this macro since pkg-config distinguishes among empty and unset
  2251. dnl variable while checking PKG_CONFIG_LIBDIR
  2252. dnl
  2253. AC_DEFUN([CURL_EXPORT_PCDIR], [
  2254. if test -n "$1"; then
  2255. PKG_CONFIG_LIBDIR="$1"
  2256. export PKG_CONFIG_LIBDIR
  2257. fi
  2258. ])
  2259. dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
  2260. dnl ------------------------
  2261. dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
  2262. dnl path to it, or 'no' if not found/present.
  2263. dnl
  2264. dnl If pkg-config is present, check that it has info about the $module or
  2265. dnl return "no" anyway!
  2266. dnl
  2267. dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
  2268. dnl
  2269. AC_DEFUN([CURL_CHECK_PKGCONFIG], [
  2270. if test -n "$PKG_CONFIG"; then
  2271. PKGCONFIG="$PKG_CONFIG"
  2272. else
  2273. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
  2274. [$PATH:/usr/bin:/usr/local/bin])
  2275. fi
  2276. if test "x$PKGCONFIG" != "xno"; then
  2277. AC_MSG_CHECKING([for $1 options with pkg-config])
  2278. dnl ask pkg-config about $1
  2279. itexists=`CURL_EXPORT_PCDIR([$2]) dnl
  2280. $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
  2281. if test -z "$itexists"; then
  2282. dnl pkg-config does not have info about the given module! set the
  2283. dnl variable to 'no'
  2284. PKGCONFIG="no"
  2285. AC_MSG_RESULT([no])
  2286. else
  2287. AC_MSG_RESULT([found])
  2288. fi
  2289. fi
  2290. ])
  2291. dnl CURL_GENERATE_CONFIGUREHELP_PM
  2292. dnl -------------------------------------------------
  2293. dnl Generate test harness configurehelp.pm module, defining and
  2294. dnl initializing some perl variables with values which are known
  2295. dnl when the configure script runs. For portability reasons, test
  2296. dnl harness needs information on how to run the C preprocessor.
  2297. AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
  2298. AC_REQUIRE([AC_PROG_CPP])dnl
  2299. tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
  2300. if test -z "$tmp_cpp"; then
  2301. tmp_cpp='cpp'
  2302. fi
  2303. cat >./tests/configurehelp.pm <<_EOF
  2304. [@%:@] This is a generated file. Do not edit.
  2305. package configurehelp;
  2306. use strict;
  2307. use warnings;
  2308. use Exporter;
  2309. use vars qw(
  2310. @ISA
  2311. @EXPORT_OK
  2312. \$Cpreprocessor
  2313. );
  2314. @ISA = qw(Exporter);
  2315. @EXPORT_OK = qw(
  2316. \$Cpreprocessor
  2317. );
  2318. \$Cpreprocessor = '$tmp_cpp';
  2319. 1;
  2320. _EOF
  2321. ])
  2322. dnl CURL_CPP_P
  2323. dnl
  2324. dnl Check if $cpp -P should be used for extract define values due to gcc 5
  2325. dnl splitting up strings and defines between line outputs. gcc by default
  2326. dnl (without -P) will show TEST EINVAL TEST as
  2327. dnl
  2328. dnl # 13 "conftest.c"
  2329. dnl TEST
  2330. dnl # 13 "conftest.c" 3 4
  2331. dnl 22
  2332. dnl # 13 "conftest.c"
  2333. dnl TEST
  2334. AC_DEFUN([CURL_CPP_P], [
  2335. AC_MSG_CHECKING([if cpp -P is needed])
  2336. AC_EGREP_CPP([TEST.*TEST], [
  2337. #include <errno.h>
  2338. TEST EINVAL TEST
  2339. ], [cpp=no], [cpp=yes])
  2340. AC_MSG_RESULT([$cpp])
  2341. dnl we need cpp -P so check if it works then
  2342. if test "x$cpp" = "xyes"; then
  2343. AC_MSG_CHECKING([if cpp -P works])
  2344. OLDCPPFLAGS=$CPPFLAGS
  2345. CPPFLAGS="$CPPFLAGS -P"
  2346. AC_EGREP_CPP([TEST.*TEST], [
  2347. #include <errno.h>
  2348. TEST EINVAL TEST
  2349. ], [cpp_p=yes], [cpp_p=no])
  2350. AC_MSG_RESULT([$cpp_p])
  2351. if test "x$cpp_p" = "xno"; then
  2352. AC_MSG_WARN([failed to figure out cpp -P alternative])
  2353. # without -P
  2354. CPPPFLAG=""
  2355. else
  2356. # with -P
  2357. CPPPFLAG="-P"
  2358. fi
  2359. dnl restore CPPFLAGS
  2360. CPPFLAGS=$OLDCPPFLAGS
  2361. else
  2362. # without -P
  2363. CPPPFLAG=""
  2364. fi
  2365. ])
  2366. dnl CURL_MAC_CFLAGS
  2367. dnl
  2368. dnl Check if -mmacosx-version-min, -miphoneos-version-min or any
  2369. dnl similar are set manually, otherwise do. And set
  2370. dnl -Werror=partial-availability.
  2371. dnl
  2372. AC_DEFUN([CURL_MAC_CFLAGS], [
  2373. tst_cflags="no"
  2374. case $host_os in
  2375. darwin*)
  2376. tst_cflags="yes"
  2377. ;;
  2378. esac
  2379. AC_MSG_CHECKING([for good-to-use Mac CFLAGS])
  2380. AC_MSG_RESULT([$tst_cflags]);
  2381. if test "$tst_cflags" = "yes"; then
  2382. AC_MSG_CHECKING([for *version-min in CFLAGS])
  2383. min=""
  2384. if test -z "$(echo $CFLAGS | grep m.*os.*-version-min)"; then
  2385. min="-mmacosx-version-min=10.8"
  2386. CFLAGS="$CFLAGS $min"
  2387. fi
  2388. if test -z "$min"; then
  2389. AC_MSG_RESULT([set by user])
  2390. else
  2391. AC_MSG_RESULT([$min set])
  2392. fi
  2393. old_CFLAGS=$CFLAGS
  2394. CFLAGS="$CFLAGS -Werror=partial-availability"
  2395. AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
  2396. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  2397. [AC_MSG_RESULT([yes])],
  2398. [AC_MSG_RESULT([no])
  2399. CFLAGS=$old_CFLAGS])
  2400. fi
  2401. ])
  2402. dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
  2403. dnl
  2404. dnl Check to see if the compiler supports __builtin_available. This built-in
  2405. dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
  2406. dnl the time this macro was written, the function was not yet documented. Its
  2407. dnl purpose is to return true if the code is running under a certain OS version
  2408. dnl or later.
  2409. AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
  2410. AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
  2411. AC_COMPILE_IFELSE([
  2412. AC_LANG_PROGRAM([[
  2413. #include <stdlib.h>
  2414. ]],[[
  2415. if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
  2416. ]])
  2417. ],[
  2418. AC_MSG_RESULT([yes])
  2419. AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
  2420. [Define to 1 if you have the __builtin_available function.])
  2421. ],[
  2422. AC_MSG_RESULT([no])
  2423. ])
  2424. ])