You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

acinclude.m4 77KB

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