acinclude.m4 64 KB

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