acinclude.m4 67 KB

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