acinclude.m4 106 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2008, Daniel Stenberg, <[email protected]>, 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 http://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. # $Id$
  22. #***************************************************************************
  23. dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
  24. dnl -------------------------------------------------
  25. dnl Verifies if the compiler actually halts after the
  26. dnl compilation phase without generating any object
  27. dnl code file, when the source compiles with errors.
  28. AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
  29. AC_MSG_CHECKING([if compiler halts on compilation errors])
  30. AC_COMPILE_IFELSE([
  31. AC_LANG_PROGRAM([[
  32. ]],[[
  33. force compilation error
  34. ]])
  35. ],[
  36. AC_MSG_RESULT([no])
  37. AC_MSG_ERROR([compiler does not halt on compilation errors.])
  38. ],[
  39. AC_MSG_RESULT([yes])
  40. ])
  41. ])
  42. dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
  43. dnl -------------------------------------------------
  44. dnl Verifies if the compiler actually halts after the
  45. dnl compilation phase without generating any object
  46. dnl code file, when the source code tries to define a
  47. dnl type for a constant array with negative dimension.
  48. AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
  49. AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
  50. AC_MSG_CHECKING([if compiler halts on negative sized arrays])
  51. AC_COMPILE_IFELSE([
  52. AC_LANG_PROGRAM([[
  53. typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
  54. ]],[[
  55. bad_t dummy;
  56. ]])
  57. ],[
  58. AC_MSG_RESULT([no])
  59. AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
  60. ],[
  61. AC_MSG_RESULT([yes])
  62. ])
  63. ])
  64. dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
  65. dnl -------------------------------------------------
  66. dnl Use the C preprocessor to find out if the given object-style symbol
  67. dnl is defined and get its expansion. This macro will not use default
  68. dnl includes even if no INCLUDES argument is given. This macro will run
  69. dnl silently when invoked with three arguments. If the expansion would
  70. dnl result in a set of double-quoted strings the returned expansion will
  71. dnl actually be a single double-quoted string concatenating all them.
  72. AC_DEFUN([CURL_CHECK_DEF], [
  73. AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
  74. AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
  75. if test -z "$SED"; then
  76. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  77. fi
  78. if test -z "$GREP"; then
  79. AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
  80. fi
  81. ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
  82. tmp_exp=""
  83. AC_PREPROC_IFELSE([
  84. AC_LANG_SOURCE(
  85. ifelse($2,,,[$2])[[
  86. #ifdef $1
  87. CURL_DEF_TOKEN $1
  88. #endif
  89. ]])
  90. ],[
  91. tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
  92. "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
  93. "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
  94. "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
  95. if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
  96. tmp_exp=""
  97. fi
  98. ])
  99. if test -z "$tmp_exp"; then
  100. AS_VAR_SET(ac_HaveDef, no)
  101. ifelse($3,,[AC_MSG_RESULT([no])])
  102. else
  103. AS_VAR_SET(ac_HaveDef, yes)
  104. AS_VAR_SET(ac_Def, $tmp_exp)
  105. ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
  106. fi
  107. AS_VAR_POPDEF([ac_Def])dnl
  108. AS_VAR_POPDEF([ac_HaveDef])dnl
  109. ])
  110. dnl CURL_CHECK_AIX_ALL_SOURCE
  111. dnl -------------------------------------------------
  112. dnl Provides a replacement of traditional AC_AIX with
  113. dnl an uniform behaviour across all autoconf versions,
  114. dnl and with our own placement rules.
  115. AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
  116. AH_VERBATIM([_ALL_SOURCE],
  117. [/* Define to 1 if OS is AIX. */
  118. #ifndef _ALL_SOURCE
  119. # undef _ALL_SOURCE
  120. #endif])
  121. AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
  122. AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
  123. AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
  124. AC_EGREP_CPP([yes_this_is_aix],[
  125. #ifdef _AIX
  126. yes_this_is_aix
  127. #endif
  128. ],[
  129. AC_MSG_RESULT([yes])
  130. AC_DEFINE(_ALL_SOURCE)
  131. ],[
  132. AC_MSG_RESULT([no])
  133. ])
  134. ])
  135. dnl CURL_CHECK_HEADER_WINDOWS
  136. dnl -------------------------------------------------
  137. dnl Check for compilable and valid windows.h header
  138. AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
  139. AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
  140. AC_COMPILE_IFELSE([
  141. AC_LANG_PROGRAM([[
  142. #undef inline
  143. #ifndef WIN32_LEAN_AND_MEAN
  144. #define WIN32_LEAN_AND_MEAN
  145. #endif
  146. #include <windows.h>
  147. ]],[[
  148. #if defined(__CYGWIN__) || defined(__CEGCC__)
  149. HAVE_WINDOWS_H shall not be defined.
  150. #else
  151. int dummy=2*WINVER;
  152. #endif
  153. ]])
  154. ],[
  155. ac_cv_header_windows_h="yes"
  156. ],[
  157. ac_cv_header_windows_h="no"
  158. ])
  159. ])
  160. case "$ac_cv_header_windows_h" in
  161. yes)
  162. AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
  163. [Define to 1 if you have the windows.h header file.])
  164. AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
  165. [Define to avoid automatic inclusion of winsock.h])
  166. ;;
  167. esac
  168. ])
  169. dnl CURL_CHECK_NATIVE_WINDOWS
  170. dnl -------------------------------------------------
  171. dnl Check if building a native Windows target
  172. AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
  173. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  174. AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
  175. if test "$ac_cv_header_windows_h" = "no"; then
  176. ac_cv_native_windows="no"
  177. else
  178. AC_COMPILE_IFELSE([
  179. AC_LANG_PROGRAM([[
  180. ]],[[
  181. #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
  182. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
  183. int dummy=1;
  184. #else
  185. Not a native Windows build target.
  186. #endif
  187. ]])
  188. ],[
  189. ac_cv_native_windows="yes"
  190. ],[
  191. ac_cv_native_windows="no"
  192. ])
  193. fi
  194. ])
  195. case "$ac_cv_native_windows" in
  196. yes)
  197. AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
  198. [Define to 1 if you are building a native Windows target.])
  199. ;;
  200. esac
  201. ])
  202. dnl CURL_CHECK_HEADER_WINSOCK
  203. dnl -------------------------------------------------
  204. dnl Check for compilable and valid winsock.h header
  205. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
  206. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  207. AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
  208. AC_COMPILE_IFELSE([
  209. AC_LANG_PROGRAM([[
  210. #undef inline
  211. #ifndef WIN32_LEAN_AND_MEAN
  212. #define WIN32_LEAN_AND_MEAN
  213. #endif
  214. #include <windows.h>
  215. #include <winsock.h>
  216. ]],[[
  217. #if defined(__CYGWIN__) || defined(__CEGCC__)
  218. HAVE_WINSOCK_H shall not be defined.
  219. #else
  220. int dummy=WSACleanup();
  221. #endif
  222. ]])
  223. ],[
  224. ac_cv_header_winsock_h="yes"
  225. ],[
  226. ac_cv_header_winsock_h="no"
  227. ])
  228. ])
  229. case "$ac_cv_header_winsock_h" in
  230. yes)
  231. AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
  232. [Define to 1 if you have the winsock.h header file.])
  233. ;;
  234. esac
  235. ])
  236. dnl CURL_CHECK_HEADER_WINSOCK2
  237. dnl -------------------------------------------------
  238. dnl Check for compilable and valid winsock2.h header
  239. AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
  240. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  241. AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
  242. AC_COMPILE_IFELSE([
  243. AC_LANG_PROGRAM([[
  244. #undef inline
  245. #ifndef WIN32_LEAN_AND_MEAN
  246. #define WIN32_LEAN_AND_MEAN
  247. #endif
  248. #include <windows.h>
  249. #include <winsock2.h>
  250. ]],[[
  251. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  252. HAVE_WINSOCK2_H shall not be defined.
  253. #else
  254. int dummy=2*IPPROTO_ESP;
  255. #endif
  256. ]])
  257. ],[
  258. ac_cv_header_winsock2_h="yes"
  259. ],[
  260. ac_cv_header_winsock2_h="no"
  261. ])
  262. ])
  263. case "$ac_cv_header_winsock2_h" in
  264. yes)
  265. AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
  266. [Define to 1 if you have the winsock2.h header file.])
  267. ;;
  268. esac
  269. ])
  270. dnl CURL_CHECK_HEADER_WS2TCPIP
  271. dnl -------------------------------------------------
  272. dnl Check for compilable and valid ws2tcpip.h header
  273. AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
  274. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  275. AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
  276. AC_COMPILE_IFELSE([
  277. AC_LANG_PROGRAM([[
  278. #undef inline
  279. #ifndef WIN32_LEAN_AND_MEAN
  280. #define WIN32_LEAN_AND_MEAN
  281. #endif
  282. #include <windows.h>
  283. #include <winsock2.h>
  284. #include <ws2tcpip.h>
  285. ]],[[
  286. #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
  287. HAVE_WS2TCPIP_H shall not be defined.
  288. #else
  289. int dummy=2*IP_PKTINFO;
  290. #endif
  291. ]])
  292. ],[
  293. ac_cv_header_ws2tcpip_h="yes"
  294. ],[
  295. ac_cv_header_ws2tcpip_h="no"
  296. ])
  297. ])
  298. case "$ac_cv_header_ws2tcpip_h" in
  299. yes)
  300. AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
  301. [Define to 1 if you have the ws2tcpip.h header file.])
  302. ;;
  303. esac
  304. ])
  305. dnl CURL_CHECK_HEADER_WINLDAP
  306. dnl -------------------------------------------------
  307. dnl Check for compilable and valid winldap.h header
  308. AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
  309. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  310. AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
  311. AC_COMPILE_IFELSE([
  312. AC_LANG_PROGRAM([[
  313. #undef inline
  314. #ifdef HAVE_WINDOWS_H
  315. #ifndef WIN32_LEAN_AND_MEAN
  316. #define WIN32_LEAN_AND_MEAN
  317. #endif
  318. #include <windows.h>
  319. #endif
  320. #include <winldap.h>
  321. ]],[[
  322. #if defined(__CYGWIN__) || defined(__CEGCC__)
  323. HAVE_WINLDAP_H shall not be defined.
  324. #else
  325. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  326. ULONG res = ldap_unbind(ldp);
  327. #endif
  328. ]])
  329. ],[
  330. ac_cv_header_winldap_h="yes"
  331. ],[
  332. ac_cv_header_winldap_h="no"
  333. ])
  334. ])
  335. case "$ac_cv_header_winldap_h" in
  336. yes)
  337. AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
  338. [Define to 1 if you have the winldap.h header file.])
  339. ;;
  340. esac
  341. ])
  342. dnl CURL_CHECK_HEADER_WINBER
  343. dnl -------------------------------------------------
  344. dnl Check for compilable and valid winber.h header
  345. AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
  346. AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
  347. AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
  348. AC_COMPILE_IFELSE([
  349. AC_LANG_PROGRAM([[
  350. #undef inline
  351. #ifdef HAVE_WINDOWS_H
  352. #ifndef WIN32_LEAN_AND_MEAN
  353. #define WIN32_LEAN_AND_MEAN
  354. #endif
  355. #include <windows.h>
  356. #endif
  357. #include <winldap.h>
  358. #include <winber.h>
  359. ]],[[
  360. #if defined(__CYGWIN__) || defined(__CEGCC__)
  361. HAVE_WINBER_H shall not be defined.
  362. #else
  363. BERVAL *bvp = NULL;
  364. BerElement *bep = ber_init(bvp);
  365. ber_free(bep, 1);
  366. #endif
  367. ]])
  368. ],[
  369. ac_cv_header_winber_h="yes"
  370. ],[
  371. ac_cv_header_winber_h="no"
  372. ])
  373. ])
  374. case "$ac_cv_header_winber_h" in
  375. yes)
  376. AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
  377. [Define to 1 if you have the winber.h header file.])
  378. ;;
  379. esac
  380. ])
  381. dnl CURL_CHECK_HEADER_LBER
  382. dnl -------------------------------------------------
  383. dnl Check for compilable and valid lber.h header,
  384. dnl and check if it is needed even with ldap.h
  385. AC_DEFUN([CURL_CHECK_HEADER_LBER], [
  386. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  387. AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
  388. AC_COMPILE_IFELSE([
  389. AC_LANG_PROGRAM([[
  390. #undef inline
  391. #ifdef HAVE_WINDOWS_H
  392. #ifndef WIN32_LEAN_AND_MEAN
  393. #define WIN32_LEAN_AND_MEAN
  394. #endif
  395. #include <windows.h>
  396. #else
  397. #ifdef HAVE_SYS_TYPES_H
  398. #include <sys/types.h>
  399. #endif
  400. #endif
  401. #ifndef NULL
  402. #define NULL (void *)0
  403. #endif
  404. #include <lber.h>
  405. ]],[[
  406. BerValue *bvp = NULL;
  407. BerElement *bep = ber_init(bvp);
  408. ber_free(bep, 1);
  409. ]])
  410. ],[
  411. ac_cv_header_lber_h="yes"
  412. ],[
  413. ac_cv_header_lber_h="no"
  414. ])
  415. ])
  416. if test "$ac_cv_header_lber_h" = "yes"; then
  417. AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
  418. [Define to 1 if you have the lber.h header file.])
  419. #
  420. AC_COMPILE_IFELSE([
  421. AC_LANG_PROGRAM([[
  422. #undef inline
  423. #ifdef HAVE_WINDOWS_H
  424. #ifndef WIN32_LEAN_AND_MEAN
  425. #define WIN32_LEAN_AND_MEAN
  426. #endif
  427. #include <windows.h>
  428. #else
  429. #ifdef HAVE_SYS_TYPES_H
  430. #include <sys/types.h>
  431. #endif
  432. #endif
  433. #ifndef NULL
  434. #define NULL (void *)0
  435. #endif
  436. #ifndef LDAP_DEPRECATED
  437. #define LDAP_DEPRECATED 1
  438. #endif
  439. #include <ldap.h>
  440. ]],[[
  441. BerValue *bvp = NULL;
  442. BerElement *bep = ber_init(bvp);
  443. ber_free(bep, 1);
  444. ]])
  445. ],[
  446. curl_cv_need_header_lber_h="no"
  447. ],[
  448. curl_cv_need_header_lber_h="yes"
  449. ])
  450. #
  451. case "$curl_cv_need_header_lber_h" in
  452. yes)
  453. AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
  454. [Define to 1 if you need the lber.h header file even with ldap.h])
  455. ;;
  456. esac
  457. fi
  458. ])
  459. dnl CURL_CHECK_HEADER_LDAP
  460. dnl -------------------------------------------------
  461. dnl Check for compilable and valid ldap.h header
  462. AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
  463. AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
  464. AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
  465. AC_COMPILE_IFELSE([
  466. AC_LANG_PROGRAM([[
  467. #undef inline
  468. #ifdef HAVE_WINDOWS_H
  469. #ifndef WIN32_LEAN_AND_MEAN
  470. #define WIN32_LEAN_AND_MEAN
  471. #endif
  472. #include <windows.h>
  473. #else
  474. #ifdef HAVE_SYS_TYPES_H
  475. #include <sys/types.h>
  476. #endif
  477. #endif
  478. #ifndef LDAP_DEPRECATED
  479. #define LDAP_DEPRECATED 1
  480. #endif
  481. #ifdef NEED_LBER_H
  482. #include <lber.h>
  483. #endif
  484. #include <ldap.h>
  485. ]],[[
  486. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  487. int res = ldap_unbind(ldp);
  488. ]])
  489. ],[
  490. ac_cv_header_ldap_h="yes"
  491. ],[
  492. ac_cv_header_ldap_h="no"
  493. ])
  494. ])
  495. case "$ac_cv_header_ldap_h" in
  496. yes)
  497. AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
  498. [Define to 1 if you have the ldap.h header file.])
  499. ;;
  500. esac
  501. ])
  502. dnl CURL_CHECK_HEADER_LDAP_SSL
  503. dnl -------------------------------------------------
  504. dnl Check for compilable and valid ldap_ssl.h header
  505. AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
  506. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  507. AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
  508. AC_COMPILE_IFELSE([
  509. AC_LANG_PROGRAM([[
  510. #undef inline
  511. #ifdef HAVE_WINDOWS_H
  512. #ifndef WIN32_LEAN_AND_MEAN
  513. #define WIN32_LEAN_AND_MEAN
  514. #endif
  515. #include <windows.h>
  516. #else
  517. #ifdef HAVE_SYS_TYPES_H
  518. #include <sys/types.h>
  519. #endif
  520. #endif
  521. #ifndef LDAP_DEPRECATED
  522. #define LDAP_DEPRECATED 1
  523. #endif
  524. #ifdef NEED_LBER_H
  525. #include <lber.h>
  526. #endif
  527. #ifdef HAVE_LDAP_H
  528. #include <ldap.h>
  529. #endif
  530. #include <ldap_ssl.h>
  531. ]],[[
  532. LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
  533. ]])
  534. ],[
  535. ac_cv_header_ldap_ssl_h="yes"
  536. ],[
  537. ac_cv_header_ldap_ssl_h="no"
  538. ])
  539. ])
  540. case "$ac_cv_header_ldap_ssl_h" in
  541. yes)
  542. AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
  543. [Define to 1 if you have the ldap_ssl.h header file.])
  544. ;;
  545. esac
  546. ])
  547. dnl CURL_CHECK_HEADER_LDAPSSL
  548. dnl -------------------------------------------------
  549. dnl Check for compilable and valid ldapssl.h header
  550. AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
  551. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  552. AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
  553. AC_COMPILE_IFELSE([
  554. AC_LANG_PROGRAM([[
  555. #undef inline
  556. #ifdef HAVE_WINDOWS_H
  557. #ifndef WIN32_LEAN_AND_MEAN
  558. #define WIN32_LEAN_AND_MEAN
  559. #endif
  560. #include <windows.h>
  561. #else
  562. #ifdef HAVE_SYS_TYPES_H
  563. #include <sys/types.h>
  564. #endif
  565. #endif
  566. #ifndef NULL
  567. #define NULL (void *)0
  568. #endif
  569. #ifndef LDAP_DEPRECATED
  570. #define LDAP_DEPRECATED 1
  571. #endif
  572. #ifdef NEED_LBER_H
  573. #include <lber.h>
  574. #endif
  575. #ifdef HAVE_LDAP_H
  576. #include <ldap.h>
  577. #endif
  578. #include <ldapssl.h>
  579. ]],[[
  580. char *cert_label = NULL;
  581. LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
  582. ]])
  583. ],[
  584. ac_cv_header_ldapssl_h="yes"
  585. ],[
  586. ac_cv_header_ldapssl_h="no"
  587. ])
  588. ])
  589. case "$ac_cv_header_ldapssl_h" in
  590. yes)
  591. AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
  592. [Define to 1 if you have the ldapssl.h header file.])
  593. ;;
  594. esac
  595. ])
  596. dnl CURL_CHECK_LIBS_WINLDAP
  597. dnl -------------------------------------------------
  598. dnl Check for libraries needed for WINLDAP support,
  599. dnl and prepended to LIBS any needed libraries.
  600. dnl This macro can take an optional parameter with a
  601. dnl white space separated list of libraries to check
  602. dnl before the WINLDAP default ones.
  603. AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
  604. AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
  605. #
  606. AC_MSG_CHECKING([for WINLDAP libraries])
  607. #
  608. u_libs=""
  609. #
  610. ifelse($1,,,[
  611. for x_lib in $1; do
  612. case "$x_lib" in
  613. -l*)
  614. l_lib="$x_lib"
  615. ;;
  616. *)
  617. l_lib="-l$x_lib"
  618. ;;
  619. esac
  620. if test -z "$u_libs"; then
  621. u_libs="$l_lib"
  622. else
  623. u_libs="$u_libs $l_lib"
  624. fi
  625. done
  626. ])
  627. #
  628. curl_cv_save_LIBS="$LIBS"
  629. curl_cv_ldap_LIBS="unknown"
  630. #
  631. for x_nlibs in '' "$u_libs" \
  632. '-lwldap32' ; do
  633. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  634. if test -z "$x_nlibs"; then
  635. LIBS="$curl_cv_save_LIBS"
  636. else
  637. LIBS="$x_nlibs $curl_cv_save_LIBS"
  638. fi
  639. AC_LINK_IFELSE([
  640. AC_LANG_PROGRAM([[
  641. #undef inline
  642. #ifdef HAVE_WINDOWS_H
  643. #ifndef WIN32_LEAN_AND_MEAN
  644. #define WIN32_LEAN_AND_MEAN
  645. #endif
  646. #include <windows.h>
  647. #ifdef HAVE_WINLDAP_H
  648. #include <winldap.h>
  649. #endif
  650. #ifdef HAVE_WINBER_H
  651. #include <winber.h>
  652. #endif
  653. #endif
  654. ]],[[
  655. BERVAL *bvp = NULL;
  656. BerElement *bep = ber_init(bvp);
  657. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  658. ULONG res = ldap_unbind(ldp);
  659. ber_free(bep, 1);
  660. ]])
  661. ],[
  662. curl_cv_ldap_LIBS="$x_nlibs"
  663. ])
  664. fi
  665. done
  666. #
  667. LIBS="$curl_cv_save_LIBS"
  668. #
  669. case X-"$curl_cv_ldap_LIBS" in
  670. X-unknown)
  671. AC_MSG_RESULT([cannot find WINLDAP libraries])
  672. ;;
  673. X-)
  674. AC_MSG_RESULT([no additional lib required])
  675. ;;
  676. *)
  677. if test -z "$curl_cv_save_LIBS"; then
  678. LIBS="$curl_cv_ldap_LIBS"
  679. else
  680. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  681. fi
  682. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  683. ;;
  684. esac
  685. #
  686. ])
  687. dnl CURL_CHECK_LIBS_LDAP
  688. dnl -------------------------------------------------
  689. dnl Check for libraries needed for LDAP support,
  690. dnl and prepended to LIBS any needed libraries.
  691. dnl This macro can take an optional parameter with a
  692. dnl white space separated list of libraries to check
  693. dnl before the default ones.
  694. AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
  695. AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
  696. #
  697. AC_MSG_CHECKING([for LDAP libraries])
  698. #
  699. u_libs=""
  700. #
  701. ifelse($1,,,[
  702. for x_lib in $1; do
  703. case "$x_lib" in
  704. -l*)
  705. l_lib="$x_lib"
  706. ;;
  707. *)
  708. l_lib="-l$x_lib"
  709. ;;
  710. esac
  711. if test -z "$u_libs"; then
  712. u_libs="$l_lib"
  713. else
  714. u_libs="$u_libs $l_lib"
  715. fi
  716. done
  717. ])
  718. #
  719. curl_cv_save_LIBS="$LIBS"
  720. curl_cv_ldap_LIBS="unknown"
  721. #
  722. for x_nlibs in '' "$u_libs" \
  723. '-lldap' \
  724. '-llber -lldap' \
  725. '-lldap -llber' \
  726. '-lldapssl -lldapx -lldapsdk' \
  727. '-lldapsdk -lldapx -lldapssl' ; do
  728. if test "$curl_cv_ldap_LIBS" = "unknown"; then
  729. if test -z "$x_nlibs"; then
  730. LIBS="$curl_cv_save_LIBS"
  731. else
  732. LIBS="$x_nlibs $curl_cv_save_LIBS"
  733. fi
  734. AC_LINK_IFELSE([
  735. AC_LANG_PROGRAM([[
  736. #undef inline
  737. #ifdef HAVE_WINDOWS_H
  738. #ifndef WIN32_LEAN_AND_MEAN
  739. #define WIN32_LEAN_AND_MEAN
  740. #endif
  741. #include <windows.h>
  742. #else
  743. #ifdef HAVE_SYS_TYPES_H
  744. #include <sys/types.h>
  745. #endif
  746. #endif
  747. #ifndef NULL
  748. #define NULL (void *)0
  749. #endif
  750. #ifndef LDAP_DEPRECATED
  751. #define LDAP_DEPRECATED 1
  752. #endif
  753. #ifdef NEED_LBER_H
  754. #include <lber.h>
  755. #endif
  756. #ifdef HAVE_LDAP_H
  757. #include <ldap.h>
  758. #endif
  759. ]],[[
  760. BerValue *bvp = NULL;
  761. BerElement *bep = ber_init(bvp);
  762. LDAP *ldp = ldap_init("dummy", LDAP_PORT);
  763. int res = ldap_unbind(ldp);
  764. ber_free(bep, 1);
  765. ]])
  766. ],[
  767. curl_cv_ldap_LIBS="$x_nlibs"
  768. ])
  769. fi
  770. done
  771. #
  772. LIBS="$curl_cv_save_LIBS"
  773. #
  774. case X-"$curl_cv_ldap_LIBS" in
  775. X-unknown)
  776. AC_MSG_RESULT([cannot find LDAP libraries])
  777. ;;
  778. X-)
  779. AC_MSG_RESULT([no additional lib required])
  780. ;;
  781. *)
  782. if test -z "$curl_cv_save_LIBS"; then
  783. LIBS="$curl_cv_ldap_LIBS"
  784. else
  785. LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
  786. fi
  787. AC_MSG_RESULT([$curl_cv_ldap_LIBS])
  788. ;;
  789. esac
  790. #
  791. ])
  792. dnl CURL_CHECK_HEADER_MALLOC
  793. dnl -------------------------------------------------
  794. dnl Check for compilable and valid malloc.h header,
  795. dnl and check if it is needed even with stdlib.h
  796. AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
  797. AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
  798. AC_COMPILE_IFELSE([
  799. AC_LANG_PROGRAM([[
  800. #include <malloc.h>
  801. ]],[[
  802. void *p = malloc(10);
  803. void *q = calloc(10,10);
  804. free(p);
  805. free(q);
  806. ]])
  807. ],[
  808. ac_cv_header_malloc_h="yes"
  809. ],[
  810. ac_cv_header_malloc_h="no"
  811. ])
  812. ])
  813. if test "$ac_cv_header_malloc_h" = "yes"; then
  814. AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
  815. [Define to 1 if you have the malloc.h header file.])
  816. #
  817. AC_COMPILE_IFELSE([
  818. AC_LANG_PROGRAM([[
  819. #include <stdlib.h>
  820. ]],[[
  821. void *p = malloc(10);
  822. void *q = calloc(10,10);
  823. free(p);
  824. free(q);
  825. ]])
  826. ],[
  827. curl_cv_need_header_malloc_h="no"
  828. ],[
  829. curl_cv_need_header_malloc_h="yes"
  830. ])
  831. #
  832. case "$curl_cv_need_header_malloc_h" in
  833. yes)
  834. AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
  835. [Define to 1 if you need the malloc.h header file even with stdlib.h])
  836. ;;
  837. esac
  838. fi
  839. ])
  840. dnl CURL_CHECK_TYPE_SOCKLEN_T
  841. dnl -------------------------------------------------
  842. dnl Check for existing socklen_t type, and provide
  843. dnl an equivalent type if socklen_t not available
  844. AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
  845. AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
  846. AC_CHECK_TYPE([socklen_t], ,[
  847. dnl socklen_t not available
  848. AC_CACHE_CHECK([for socklen_t equivalent],
  849. [curl_cv_socklen_t_equiv], [
  850. curl_cv_socklen_t_equiv="unknown"
  851. for arg1 in 'int' 'SOCKET'; do
  852. for arg2 in "struct sockaddr" void; do
  853. for t in int size_t unsigned long "unsigned long"; do
  854. if test "$curl_cv_socklen_t_equiv" = "unknown"; then
  855. AC_COMPILE_IFELSE([
  856. AC_LANG_PROGRAM([[
  857. #undef inline
  858. #ifdef HAVE_WINDOWS_H
  859. #ifndef WIN32_LEAN_AND_MEAN
  860. #define WIN32_LEAN_AND_MEAN
  861. #endif
  862. #include <windows.h>
  863. #ifdef HAVE_WINSOCK2_H
  864. #include <winsock2.h>
  865. #else
  866. #ifdef HAVE_WINSOCK_H
  867. #include <winsock.h>
  868. #endif
  869. #endif
  870. #define GETPEERNCALLCONV PASCAL
  871. #else
  872. #ifdef HAVE_SYS_TYPES_H
  873. #include <sys/types.h>
  874. #endif
  875. #ifdef HAVE_SYS_SOCKET_H
  876. #include <sys/socket.h>
  877. #endif
  878. #define GETPEERNCALLCONV
  879. #endif
  880. extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
  881. ]],[[
  882. $t len=0;
  883. getpeername(0,0,&len);
  884. ]])
  885. ],[
  886. curl_cv_socklen_t_equiv="$t"
  887. ])
  888. fi
  889. done
  890. done
  891. done
  892. ])
  893. case "$curl_cv_socklen_t_equiv" in
  894. unknown)
  895. AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
  896. ;;
  897. *)
  898. AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
  899. [Type to use in place of socklen_t when system does not provide it.])
  900. ;;
  901. esac
  902. ],[
  903. #undef inline
  904. #ifdef HAVE_WINDOWS_H
  905. #ifndef WIN32_LEAN_AND_MEAN
  906. #define WIN32_LEAN_AND_MEAN
  907. #endif
  908. #include <windows.h>
  909. #ifdef HAVE_WINSOCK2_H
  910. #include <winsock2.h>
  911. #ifdef HAVE_WS2TCPIP_H
  912. #include <ws2tcpip.h>
  913. #endif
  914. #endif
  915. #else
  916. #ifdef HAVE_SYS_TYPES_H
  917. #include <sys/types.h>
  918. #endif
  919. #ifdef HAVE_SYS_SOCKET_H
  920. #include <sys/socket.h>
  921. #endif
  922. #endif
  923. ])
  924. ])
  925. dnl CURL_CHECK_FUNC_GETNAMEINFO
  926. dnl -------------------------------------------------
  927. dnl Test if the getnameinfo function is available,
  928. dnl and check the types of five of its arguments.
  929. dnl If the function succeeds HAVE_GETNAMEINFO will be
  930. dnl defined, defining the types of the arguments in
  931. dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
  932. dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
  933. dnl and also defining the type qualifier of first
  934. dnl argument in GETNAMEINFO_QUAL_ARG1.
  935. AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
  936. AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
  937. AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
  938. AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
  939. #
  940. AC_MSG_CHECKING([for getnameinfo])
  941. AC_LINK_IFELSE([
  942. AC_LANG_FUNC_LINK_TRY([getnameinfo])
  943. ],[
  944. AC_MSG_RESULT([yes])
  945. curl_cv_getnameinfo="yes"
  946. ],[
  947. AC_MSG_RESULT([no])
  948. curl_cv_getnameinfo="no"
  949. ])
  950. #
  951. if test "$curl_cv_getnameinfo" != "yes"; then
  952. AC_MSG_CHECKING([deeper for getnameinfo])
  953. AC_LINK_IFELSE([
  954. AC_LANG_PROGRAM([[
  955. ]],[[
  956. getnameinfo();
  957. ]])
  958. ],[
  959. AC_MSG_RESULT([yes])
  960. curl_cv_getnameinfo="yes"
  961. ],[
  962. AC_MSG_RESULT([but still no])
  963. curl_cv_getnameinfo="no"
  964. ])
  965. fi
  966. #
  967. if test "$curl_cv_getnameinfo" != "yes"; then
  968. AC_MSG_CHECKING([deeper and deeper for getnameinfo])
  969. AC_LINK_IFELSE([
  970. AC_LANG_PROGRAM([[
  971. #undef inline
  972. #ifdef HAVE_WINDOWS_H
  973. #ifndef WIN32_LEAN_AND_MEAN
  974. #define WIN32_LEAN_AND_MEAN
  975. #endif
  976. #include <windows.h>
  977. #ifdef HAVE_WINSOCK2_H
  978. #include <winsock2.h>
  979. #ifdef HAVE_WS2TCPIP_H
  980. #include <ws2tcpip.h>
  981. #endif
  982. #endif
  983. #else
  984. #ifdef HAVE_SYS_TYPES_H
  985. #include <sys/types.h>
  986. #endif
  987. #ifdef HAVE_SYS_SOCKET_H
  988. #include <sys/socket.h>
  989. #endif
  990. #ifdef HAVE_NETDB_H
  991. #include <netdb.h>
  992. #endif
  993. #endif
  994. ]],[[
  995. getnameinfo(0, 0, 0, 0, 0, 0, 0);
  996. ]])
  997. ],[
  998. AC_MSG_RESULT([yes])
  999. curl_cv_getnameinfo="yes"
  1000. ],[
  1001. AC_MSG_RESULT([but still no])
  1002. curl_cv_getnameinfo="no"
  1003. ])
  1004. fi
  1005. #
  1006. if test "$curl_cv_getnameinfo" = "yes"; then
  1007. AC_CACHE_CHECK([types of arguments for getnameinfo],
  1008. [curl_cv_func_getnameinfo_args], [
  1009. curl_cv_func_getnameinfo_args="unknown"
  1010. for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
  1011. for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
  1012. for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
  1013. for gni_arg7 in 'int' 'unsigned int'; do
  1014. if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
  1015. AC_COMPILE_IFELSE([
  1016. AC_LANG_PROGRAM([[
  1017. #undef inline
  1018. #ifdef HAVE_WINDOWS_H
  1019. #ifndef WIN32_LEAN_AND_MEAN
  1020. #define WIN32_LEAN_AND_MEAN
  1021. #endif
  1022. #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
  1023. #undef _WIN32_WINNT
  1024. #define _WIN32_WINNT 0x0501
  1025. #endif
  1026. #include <windows.h>
  1027. #ifdef HAVE_WINSOCK2_H
  1028. #include <winsock2.h>
  1029. #ifdef HAVE_WS2TCPIP_H
  1030. #include <ws2tcpip.h>
  1031. #endif
  1032. #endif
  1033. #define GNICALLCONV WSAAPI
  1034. #else
  1035. #ifdef HAVE_SYS_TYPES_H
  1036. #include <sys/types.h>
  1037. #endif
  1038. #ifdef HAVE_SYS_SOCKET_H
  1039. #include <sys/socket.h>
  1040. #endif
  1041. #ifdef HAVE_NETDB_H
  1042. #include <netdb.h>
  1043. #endif
  1044. #define GNICALLCONV
  1045. #endif
  1046. extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
  1047. char *, $gni_arg46,
  1048. char *, $gni_arg46,
  1049. $gni_arg7);
  1050. ]],[[
  1051. $gni_arg2 salen=0;
  1052. $gni_arg46 hostlen=0;
  1053. $gni_arg46 servlen=0;
  1054. $gni_arg7 flags=0;
  1055. int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
  1056. ]])
  1057. ],[
  1058. curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
  1059. ])
  1060. fi
  1061. done
  1062. done
  1063. done
  1064. done
  1065. ]) # AC-CACHE-CHECK
  1066. if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
  1067. AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
  1068. AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
  1069. else
  1070. gni_prev_IFS=$IFS; IFS=','
  1071. set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
  1072. IFS=$gni_prev_IFS
  1073. shift
  1074. #
  1075. gni_qual_type_arg1=$[1]
  1076. #
  1077. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
  1078. [Define to the type of arg 2 for getnameinfo.])
  1079. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
  1080. [Define to the type of args 4 and 6 for getnameinfo.])
  1081. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
  1082. [Define to the type of arg 7 for getnameinfo.])
  1083. #
  1084. prev_sh_opts=$-
  1085. #
  1086. case $prev_sh_opts in
  1087. *f*)
  1088. ;;
  1089. *)
  1090. set -f
  1091. ;;
  1092. esac
  1093. #
  1094. case "$gni_qual_type_arg1" in
  1095. const*)
  1096. gni_qual_arg1=const
  1097. gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
  1098. ;;
  1099. *)
  1100. gni_qual_arg1=
  1101. gni_type_arg1=$gni_qual_type_arg1
  1102. ;;
  1103. esac
  1104. #
  1105. AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
  1106. [Define to the type qualifier of arg 1 for getnameinfo.])
  1107. AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
  1108. [Define to the type of arg 1 for getnameinfo.])
  1109. #
  1110. case $prev_sh_opts in
  1111. *f*)
  1112. ;;
  1113. *)
  1114. set +f
  1115. ;;
  1116. esac
  1117. #
  1118. AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
  1119. [Define to 1 if you have the getnameinfo function.])
  1120. ac_cv_func_getnameinfo="yes"
  1121. fi
  1122. fi
  1123. ])
  1124. dnl TYPE_SOCKADDR_STORAGE
  1125. dnl -------------------------------------------------
  1126. dnl Check for struct sockaddr_storage. Most IPv6-enabled
  1127. dnl hosts have it, but AIX 4.3 is one known exception.
  1128. AC_DEFUN([TYPE_SOCKADDR_STORAGE],
  1129. [
  1130. AC_CHECK_TYPE([struct sockaddr_storage],
  1131. AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
  1132. [if struct sockaddr_storage is defined]), ,
  1133. [
  1134. #undef inline
  1135. #ifdef HAVE_WINDOWS_H
  1136. #ifndef WIN32_LEAN_AND_MEAN
  1137. #define WIN32_LEAN_AND_MEAN
  1138. #endif
  1139. #include <windows.h>
  1140. #ifdef HAVE_WINSOCK2_H
  1141. #include <winsock2.h>
  1142. #endif
  1143. #else
  1144. #ifdef HAVE_SYS_TYPES_H
  1145. #include <sys/types.h>
  1146. #endif
  1147. #ifdef HAVE_SYS_SOCKET_H
  1148. #include <sys/socket.h>
  1149. #endif
  1150. #ifdef HAVE_NETINET_IN_H
  1151. #include <netinet/in.h>
  1152. #endif
  1153. #ifdef HAVE_ARPA_INET_H
  1154. #include <arpa/inet.h>
  1155. #endif
  1156. #endif
  1157. ])
  1158. ])
  1159. dnl CURL_CHECK_NI_WITHSCOPEID
  1160. dnl -------------------------------------------------
  1161. dnl Check for working NI_WITHSCOPEID in getnameinfo()
  1162. AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
  1163. AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
  1164. AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
  1165. AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
  1166. netdb.h netinet/in.h arpa/inet.h)
  1167. #
  1168. AC_CACHE_CHECK([for working NI_WITHSCOPEID],
  1169. [ac_cv_working_ni_withscopeid], [
  1170. AC_RUN_IFELSE([
  1171. AC_LANG_PROGRAM([[
  1172. #ifdef HAVE_STDIO_H
  1173. #include <stdio.h>
  1174. #endif
  1175. #ifdef HAVE_SYS_TYPES_H
  1176. #include <sys/types.h>
  1177. #endif
  1178. #ifdef HAVE_SYS_SOCKET_H
  1179. #include <sys/socket.h>
  1180. #endif
  1181. #ifdef HAVE_NETDB_H
  1182. #include <netdb.h>
  1183. #endif
  1184. #ifdef HAVE_NETINET_IN_H
  1185. #include <netinet/in.h>
  1186. #endif
  1187. #ifdef HAVE_ARPA_INET_H
  1188. #include <arpa/inet.h>
  1189. #endif
  1190. ]],[[
  1191. #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
  1192. #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
  1193. struct sockaddr_storage sa;
  1194. #else
  1195. unsigned char sa[256];
  1196. #endif
  1197. char hostbuf[NI_MAXHOST];
  1198. int rc;
  1199. GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
  1200. GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
  1201. GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
  1202. int fd = socket(AF_INET6, SOCK_STREAM, 0);
  1203. if(fd < 0) {
  1204. perror("socket()");
  1205. return 1; /* Error creating socket */
  1206. }
  1207. rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
  1208. if(rc) {
  1209. perror("getsockname()");
  1210. return 2; /* Error retrieving socket name */
  1211. }
  1212. rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
  1213. if(rc) {
  1214. printf("rc = %s\n", gai_strerror(rc));
  1215. return 3; /* Error translating socket address */
  1216. }
  1217. return 0; /* Ok, NI_WITHSCOPEID works */
  1218. #else
  1219. return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
  1220. #endif
  1221. ]]) # AC-LANG-PROGRAM
  1222. ],[
  1223. # Exit code == 0. Program worked.
  1224. ac_cv_working_ni_withscopeid="yes"
  1225. ],[
  1226. # Exit code != 0. Program failed.
  1227. ac_cv_working_ni_withscopeid="no"
  1228. ],[
  1229. # Program is not run when cross-compiling. So we assume
  1230. # NI_WITHSCOPEID will work if we are able to compile it.
  1231. AC_COMPILE_IFELSE([
  1232. AC_LANG_PROGRAM([[
  1233. #include <sys/types.h>
  1234. #include <sys/socket.h>
  1235. #include <netdb.h>
  1236. ]],[[
  1237. unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
  1238. ]])
  1239. ],[
  1240. ac_cv_working_ni_withscopeid="yes"
  1241. ],[
  1242. ac_cv_working_ni_withscopeid="no"
  1243. ]) # AC-COMPILE-IFELSE
  1244. ]) # AC-RUN-IFELSE
  1245. ]) # AC-CACHE-CHECK
  1246. case "$ac_cv_working_ni_withscopeid" in
  1247. yes)
  1248. AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
  1249. [Define to 1 if NI_WITHSCOPEID exists and works.])
  1250. ;;
  1251. esac
  1252. ])
  1253. dnl CURL_CHECK_FUNC_RECV
  1254. dnl -------------------------------------------------
  1255. dnl Test if the socket recv() function is available,
  1256. dnl and check its return type and the types of its
  1257. dnl arguments. If the function succeeds HAVE_RECV
  1258. dnl will be defined, defining the types of the arguments
  1259. dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
  1260. dnl and RECV_TYPE_ARG4, defining the type of the function
  1261. dnl return value in RECV_TYPE_RETV.
  1262. AC_DEFUN([CURL_CHECK_FUNC_RECV], [
  1263. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1264. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1265. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1266. #
  1267. AC_MSG_CHECKING([for recv])
  1268. AC_LINK_IFELSE([
  1269. AC_LANG_PROGRAM([[
  1270. #undef inline
  1271. #ifdef HAVE_WINDOWS_H
  1272. #ifndef WIN32_LEAN_AND_MEAN
  1273. #define WIN32_LEAN_AND_MEAN
  1274. #endif
  1275. #include <windows.h>
  1276. #ifdef HAVE_WINSOCK2_H
  1277. #include <winsock2.h>
  1278. #else
  1279. #ifdef HAVE_WINSOCK_H
  1280. #include <winsock.h>
  1281. #endif
  1282. #endif
  1283. #else
  1284. #ifdef HAVE_SYS_TYPES_H
  1285. #include <sys/types.h>
  1286. #endif
  1287. #ifdef HAVE_SYS_SOCKET_H
  1288. #include <sys/socket.h>
  1289. #endif
  1290. #endif
  1291. ]],[[
  1292. recv(0, 0, 0, 0);
  1293. ]])
  1294. ],[
  1295. AC_MSG_RESULT([yes])
  1296. curl_cv_recv="yes"
  1297. ],[
  1298. AC_MSG_RESULT([no])
  1299. curl_cv_recv="no"
  1300. ])
  1301. #
  1302. if test "$curl_cv_recv" = "yes"; then
  1303. AC_CACHE_CHECK([types of args and return type for recv],
  1304. [curl_cv_func_recv_args], [
  1305. curl_cv_func_recv_args="unknown"
  1306. for recv_retv in 'int' 'ssize_t'; do
  1307. for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1308. for recv_arg2 in 'char *' 'void *'; do
  1309. for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1310. for recv_arg4 in 'int' 'unsigned int'; do
  1311. if test "$curl_cv_func_recv_args" = "unknown"; then
  1312. AC_COMPILE_IFELSE([
  1313. AC_LANG_PROGRAM([[
  1314. #undef inline
  1315. #ifdef HAVE_WINDOWS_H
  1316. #ifndef WIN32_LEAN_AND_MEAN
  1317. #define WIN32_LEAN_AND_MEAN
  1318. #endif
  1319. #include <windows.h>
  1320. #ifdef HAVE_WINSOCK2_H
  1321. #include <winsock2.h>
  1322. #else
  1323. #ifdef HAVE_WINSOCK_H
  1324. #include <winsock.h>
  1325. #endif
  1326. #endif
  1327. #define RECVCALLCONV PASCAL
  1328. #else
  1329. #ifdef HAVE_SYS_TYPES_H
  1330. #include <sys/types.h>
  1331. #endif
  1332. #ifdef HAVE_SYS_SOCKET_H
  1333. #include <sys/socket.h>
  1334. #endif
  1335. #define RECVCALLCONV
  1336. #endif
  1337. extern $recv_retv RECVCALLCONV
  1338. recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
  1339. ]],[[
  1340. $recv_arg1 s=0;
  1341. $recv_arg2 buf=0;
  1342. $recv_arg3 len=0;
  1343. $recv_arg4 flags=0;
  1344. $recv_retv res = recv(s, buf, len, flags);
  1345. ]])
  1346. ],[
  1347. curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
  1348. ])
  1349. fi
  1350. done
  1351. done
  1352. done
  1353. done
  1354. done
  1355. ]) # AC-CACHE-CHECK
  1356. if test "$curl_cv_func_recv_args" = "unknown"; then
  1357. AC_MSG_ERROR([Cannot find proper types to use for recv args])
  1358. else
  1359. recv_prev_IFS=$IFS; IFS=','
  1360. set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
  1361. IFS=$recv_prev_IFS
  1362. shift
  1363. #
  1364. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
  1365. [Define to the type of arg 1 for recv.])
  1366. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
  1367. [Define to the type of arg 2 for recv.])
  1368. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
  1369. [Define to the type of arg 3 for recv.])
  1370. AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
  1371. [Define to the type of arg 4 for recv.])
  1372. AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
  1373. [Define to the function return type for recv.])
  1374. #
  1375. AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
  1376. [Define to 1 if you have the recv function.])
  1377. ac_cv_func_recv="yes"
  1378. fi
  1379. else
  1380. AC_MSG_ERROR([Unable to link function recv])
  1381. fi
  1382. ])
  1383. dnl CURL_CHECK_FUNC_SEND
  1384. dnl -------------------------------------------------
  1385. dnl Test if the socket send() function is available,
  1386. dnl and check its return type and the types of its
  1387. dnl arguments. If the function succeeds HAVE_SEND
  1388. dnl will be defined, defining the types of the arguments
  1389. dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
  1390. dnl and SEND_TYPE_ARG4, defining the type of the function
  1391. dnl return value in SEND_TYPE_RETV, and also defining the
  1392. dnl type qualifier of second argument in SEND_QUAL_ARG2.
  1393. AC_DEFUN([CURL_CHECK_FUNC_SEND], [
  1394. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1395. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1396. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1397. #
  1398. AC_MSG_CHECKING([for send])
  1399. AC_LINK_IFELSE([
  1400. AC_LANG_PROGRAM([[
  1401. #undef inline
  1402. #ifdef HAVE_WINDOWS_H
  1403. #ifndef WIN32_LEAN_AND_MEAN
  1404. #define WIN32_LEAN_AND_MEAN
  1405. #endif
  1406. #include <windows.h>
  1407. #ifdef HAVE_WINSOCK2_H
  1408. #include <winsock2.h>
  1409. #else
  1410. #ifdef HAVE_WINSOCK_H
  1411. #include <winsock.h>
  1412. #endif
  1413. #endif
  1414. #else
  1415. #ifdef HAVE_SYS_TYPES_H
  1416. #include <sys/types.h>
  1417. #endif
  1418. #ifdef HAVE_SYS_SOCKET_H
  1419. #include <sys/socket.h>
  1420. #endif
  1421. #endif
  1422. ]],[[
  1423. send(0, 0, 0, 0);
  1424. ]])
  1425. ],[
  1426. AC_MSG_RESULT([yes])
  1427. curl_cv_send="yes"
  1428. ],[
  1429. AC_MSG_RESULT([no])
  1430. curl_cv_send="no"
  1431. ])
  1432. #
  1433. if test "$curl_cv_send" = "yes"; then
  1434. AC_CACHE_CHECK([types of args and return type for send],
  1435. [curl_cv_func_send_args], [
  1436. curl_cv_func_send_args="unknown"
  1437. for send_retv in 'int' 'ssize_t'; do
  1438. for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1439. for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
  1440. for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1441. for send_arg4 in 'int' 'unsigned int'; do
  1442. if test "$curl_cv_func_send_args" = "unknown"; then
  1443. AC_COMPILE_IFELSE([
  1444. AC_LANG_PROGRAM([[
  1445. #undef inline
  1446. #ifdef HAVE_WINDOWS_H
  1447. #ifndef WIN32_LEAN_AND_MEAN
  1448. #define WIN32_LEAN_AND_MEAN
  1449. #endif
  1450. #include <windows.h>
  1451. #ifdef HAVE_WINSOCK2_H
  1452. #include <winsock2.h>
  1453. #else
  1454. #ifdef HAVE_WINSOCK_H
  1455. #include <winsock.h>
  1456. #endif
  1457. #endif
  1458. #define SENDCALLCONV PASCAL
  1459. #else
  1460. #ifdef HAVE_SYS_TYPES_H
  1461. #include <sys/types.h>
  1462. #endif
  1463. #ifdef HAVE_SYS_SOCKET_H
  1464. #include <sys/socket.h>
  1465. #endif
  1466. #define SENDCALLCONV
  1467. #endif
  1468. extern $send_retv SENDCALLCONV
  1469. send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
  1470. ]],[[
  1471. $send_arg1 s=0;
  1472. $send_arg3 len=0;
  1473. $send_arg4 flags=0;
  1474. $send_retv res = send(s, 0, len, flags);
  1475. ]])
  1476. ],[
  1477. curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
  1478. ])
  1479. fi
  1480. done
  1481. done
  1482. done
  1483. done
  1484. done
  1485. ]) # AC-CACHE-CHECK
  1486. if test "$curl_cv_func_send_args" = "unknown"; then
  1487. AC_MSG_ERROR([Cannot find proper types to use for send args])
  1488. else
  1489. send_prev_IFS=$IFS; IFS=','
  1490. set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
  1491. IFS=$send_prev_IFS
  1492. shift
  1493. #
  1494. send_qual_type_arg2=$[2]
  1495. #
  1496. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
  1497. [Define to the type of arg 1 for send.])
  1498. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
  1499. [Define to the type of arg 3 for send.])
  1500. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
  1501. [Define to the type of arg 4 for send.])
  1502. AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
  1503. [Define to the function return type for send.])
  1504. #
  1505. prev_sh_opts=$-
  1506. #
  1507. case $prev_sh_opts in
  1508. *f*)
  1509. ;;
  1510. *)
  1511. set -f
  1512. ;;
  1513. esac
  1514. #
  1515. case "$send_qual_type_arg2" in
  1516. const*)
  1517. send_qual_arg2=const
  1518. send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
  1519. ;;
  1520. *)
  1521. send_qual_arg2=
  1522. send_type_arg2=$send_qual_type_arg2
  1523. ;;
  1524. esac
  1525. #
  1526. AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
  1527. [Define to the type qualifier of arg 2 for send.])
  1528. AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
  1529. [Define to the type of arg 2 for send.])
  1530. #
  1531. case $prev_sh_opts in
  1532. *f*)
  1533. ;;
  1534. *)
  1535. set +f
  1536. ;;
  1537. esac
  1538. #
  1539. AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
  1540. [Define to 1 if you have the send function.])
  1541. ac_cv_func_send="yes"
  1542. fi
  1543. else
  1544. AC_MSG_ERROR([Unable to link function send])
  1545. fi
  1546. ])
  1547. dnl CURL_CHECK_FUNC_RECVFROM
  1548. dnl -------------------------------------------------
  1549. dnl Test if the socket recvfrom() function is available,
  1550. dnl and check its return type and the types of its
  1551. dnl arguments. If the function succeeds HAVE_RECVFROM
  1552. dnl will be defined, defining the types of the arguments
  1553. dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
  1554. dnl to RECVFROM_TYPE_ARG6, defining also the type of the
  1555. dnl function return value in RECVFROM_TYPE_RETV.
  1556. dnl Notice that the types returned for pointer arguments
  1557. dnl will actually be the type pointed by the pointer.
  1558. AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
  1559. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1560. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1561. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1562. #
  1563. AC_MSG_CHECKING([for recvfrom])
  1564. AC_LINK_IFELSE([
  1565. AC_LANG_PROGRAM([[
  1566. #undef inline
  1567. #ifdef HAVE_WINDOWS_H
  1568. #ifndef WIN32_LEAN_AND_MEAN
  1569. #define WIN32_LEAN_AND_MEAN
  1570. #endif
  1571. #include <windows.h>
  1572. #ifdef HAVE_WINSOCK2_H
  1573. #include <winsock2.h>
  1574. #else
  1575. #ifdef HAVE_WINSOCK_H
  1576. #include <winsock.h>
  1577. #endif
  1578. #endif
  1579. #else
  1580. #ifdef HAVE_SYS_TYPES_H
  1581. #include <sys/types.h>
  1582. #endif
  1583. #ifdef HAVE_SYS_SOCKET_H
  1584. #include <sys/socket.h>
  1585. #endif
  1586. #endif
  1587. ]],[[
  1588. recvfrom(0, 0, 0, 0, 0, 0);
  1589. ]])
  1590. ],[
  1591. AC_MSG_RESULT([yes])
  1592. curl_cv_recvfrom="yes"
  1593. ],[
  1594. AC_MSG_RESULT([no])
  1595. curl_cv_recvfrom="no"
  1596. ])
  1597. #
  1598. if test "$curl_cv_recvfrom" = "yes"; then
  1599. AC_CACHE_CHECK([types of args and return type for recvfrom],
  1600. [curl_cv_func_recvfrom_args], [
  1601. curl_cv_func_recvfrom_args="unknown"
  1602. for recvfrom_retv in 'int' 'ssize_t'; do
  1603. for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
  1604. for recvfrom_arg2 in 'char *' 'void *'; do
  1605. for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
  1606. for recvfrom_arg4 in 'int' 'unsigned int'; do
  1607. for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
  1608. for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
  1609. if test "$curl_cv_func_recvfrom_args" = "unknown"; then
  1610. AC_COMPILE_IFELSE([
  1611. AC_LANG_PROGRAM([[
  1612. #undef inline
  1613. #ifdef HAVE_WINDOWS_H
  1614. #ifndef WIN32_LEAN_AND_MEAN
  1615. #define WIN32_LEAN_AND_MEAN
  1616. #endif
  1617. #include <windows.h>
  1618. #ifdef HAVE_WINSOCK2_H
  1619. #include <winsock2.h>
  1620. #else
  1621. #ifdef HAVE_WINSOCK_H
  1622. #include <winsock.h>
  1623. #endif
  1624. #endif
  1625. #define RECVFROMCALLCONV PASCAL
  1626. #else
  1627. #ifdef HAVE_SYS_TYPES_H
  1628. #include <sys/types.h>
  1629. #endif
  1630. #ifdef HAVE_SYS_SOCKET_H
  1631. #include <sys/socket.h>
  1632. #endif
  1633. #define RECVFROMCALLCONV
  1634. #endif
  1635. extern $recvfrom_retv RECVFROMCALLCONV
  1636. recvfrom($recvfrom_arg1, $recvfrom_arg2,
  1637. $recvfrom_arg3, $recvfrom_arg4,
  1638. $recvfrom_arg5, $recvfrom_arg6);
  1639. ]],[[
  1640. $recvfrom_arg1 s=0;
  1641. $recvfrom_arg2 buf=0;
  1642. $recvfrom_arg3 len=0;
  1643. $recvfrom_arg4 flags=0;
  1644. $recvfrom_arg5 addr=0;
  1645. $recvfrom_arg6 addrlen=0;
  1646. $recvfrom_retv res=0;
  1647. res = recvfrom(s, buf, len, flags, addr, addrlen);
  1648. ]])
  1649. ],[
  1650. curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
  1651. ])
  1652. fi
  1653. done
  1654. done
  1655. done
  1656. done
  1657. done
  1658. done
  1659. done
  1660. ]) # AC-CACHE-CHECK
  1661. # Nearly last minute change for this release starts here
  1662. AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
  1663. [Define to 1 if you have the recvfrom function.])
  1664. ac_cv_func_recvfrom="yes"
  1665. # Nearly last minute change for this release ends here
  1666. if test "$curl_cv_func_recvfrom_args" = "unknown"; then
  1667. AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
  1668. else
  1669. recvfrom_prev_IFS=$IFS; IFS=','
  1670. set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
  1671. IFS=$recvfrom_prev_IFS
  1672. shift
  1673. #
  1674. recvfrom_ptrt_arg2=$[2]
  1675. recvfrom_ptrt_arg5=$[5]
  1676. recvfrom_ptrt_arg6=$[6]
  1677. #
  1678. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
  1679. [Define to the type of arg 1 for recvfrom.])
  1680. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
  1681. [Define to the type of arg 3 for recvfrom.])
  1682. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
  1683. [Define to the type of arg 4 for recvfrom.])
  1684. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
  1685. [Define to the function return type for recvfrom.])
  1686. #
  1687. prev_sh_opts=$-
  1688. #
  1689. case $prev_sh_opts in
  1690. *f*)
  1691. ;;
  1692. *)
  1693. set -f
  1694. ;;
  1695. esac
  1696. #
  1697. recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
  1698. recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
  1699. recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
  1700. #
  1701. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
  1702. [Define to the type pointed by arg 2 for recvfrom.])
  1703. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
  1704. [Define to the type pointed by arg 5 for recvfrom.])
  1705. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
  1706. [Define to the type pointed by arg 6 for recvfrom.])
  1707. #
  1708. if test "$recvfrom_type_arg2" = "void"; then
  1709. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
  1710. [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
  1711. fi
  1712. if test "$recvfrom_type_arg5" = "void"; then
  1713. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
  1714. [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
  1715. fi
  1716. if test "$recvfrom_type_arg6" = "void"; then
  1717. AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
  1718. [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
  1719. fi
  1720. #
  1721. case $prev_sh_opts in
  1722. *f*)
  1723. ;;
  1724. *)
  1725. set +f
  1726. ;;
  1727. esac
  1728. #
  1729. AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
  1730. [Define to 1 if you have the recvfrom function.])
  1731. ac_cv_func_recvfrom="yes"
  1732. fi
  1733. else
  1734. AC_MSG_WARN([Unable to link function recvfrom])
  1735. fi
  1736. ])
  1737. dnl CURL_CHECK_MSG_NOSIGNAL
  1738. dnl -------------------------------------------------
  1739. dnl Check for MSG_NOSIGNAL
  1740. AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
  1741. AC_CHECK_HEADERS(sys/types.h sys/socket.h)
  1742. AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
  1743. AC_COMPILE_IFELSE([
  1744. AC_LANG_PROGRAM([[
  1745. #undef inline
  1746. #ifdef HAVE_WINDOWS_H
  1747. #ifndef WIN32_LEAN_AND_MEAN
  1748. #define WIN32_LEAN_AND_MEAN
  1749. #endif
  1750. #include <windows.h>
  1751. #ifdef HAVE_WINSOCK2_H
  1752. #include <winsock2.h>
  1753. #else
  1754. #ifdef HAVE_WINSOCK_H
  1755. #include <winsock.h>
  1756. #endif
  1757. #endif
  1758. #else
  1759. #ifdef HAVE_SYS_TYPES_H
  1760. #include <sys/types.h>
  1761. #endif
  1762. #ifdef HAVE_SYS_SOCKET_H
  1763. #include <sys/socket.h>
  1764. #endif
  1765. #endif
  1766. ]],[[
  1767. int flag=MSG_NOSIGNAL;
  1768. ]])
  1769. ],[
  1770. ac_cv_msg_nosignal="yes"
  1771. ],[
  1772. ac_cv_msg_nosignal="no"
  1773. ])
  1774. ])
  1775. case "$ac_cv_msg_nosignal" in
  1776. yes)
  1777. AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
  1778. [Define to 1 if you have the MSG_NOSIGNAL flag.])
  1779. ;;
  1780. esac
  1781. ])
  1782. dnl CURL_CHECK_STRUCT_TIMEVAL
  1783. dnl -------------------------------------------------
  1784. dnl Check for timeval struct
  1785. AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
  1786. AC_REQUIRE([AC_HEADER_TIME])dnl
  1787. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
  1788. AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  1789. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
  1790. AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
  1791. AC_COMPILE_IFELSE([
  1792. AC_LANG_PROGRAM([[
  1793. #undef inline
  1794. #ifdef HAVE_WINDOWS_H
  1795. #ifndef WIN32_LEAN_AND_MEAN
  1796. #define WIN32_LEAN_AND_MEAN
  1797. #endif
  1798. #include <windows.h>
  1799. #ifdef HAVE_WINSOCK2_H
  1800. #include <winsock2.h>
  1801. #else
  1802. #ifdef HAVE_WINSOCK_H
  1803. #include <winsock.h>
  1804. #endif
  1805. #endif
  1806. #endif
  1807. #ifdef HAVE_SYS_TYPES_H
  1808. #include <sys/types.h>
  1809. #endif
  1810. #ifdef HAVE_SYS_TIME_H
  1811. #include <sys/time.h>
  1812. #ifdef TIME_WITH_SYS_TIME
  1813. #include <time.h>
  1814. #endif
  1815. #else
  1816. #ifdef HAVE_TIME_H
  1817. #include <time.h>
  1818. #endif
  1819. #endif
  1820. ]],[[
  1821. struct timeval ts;
  1822. ts.tv_sec = 0;
  1823. ts.tv_usec = 0;
  1824. ]])
  1825. ],[
  1826. ac_cv_struct_timeval="yes"
  1827. ],[
  1828. ac_cv_struct_timeval="no"
  1829. ])
  1830. ])
  1831. case "$ac_cv_struct_timeval" in
  1832. yes)
  1833. AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
  1834. [Define to 1 if you have the timeval struct.])
  1835. ;;
  1836. esac
  1837. ])
  1838. dnl TYPE_SIG_ATOMIC_T
  1839. dnl -------------------------------------------------
  1840. dnl Check if the sig_atomic_t type is available, and
  1841. dnl verify if it is already defined as volatile.
  1842. AC_DEFUN([TYPE_SIG_ATOMIC_T], [
  1843. AC_CHECK_HEADERS(signal.h)
  1844. AC_CHECK_TYPE([sig_atomic_t],[
  1845. AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
  1846. [Define to 1 if sig_atomic_t is an available typedef.])
  1847. ], ,[
  1848. #ifdef HAVE_SIGNAL_H
  1849. #include <signal.h>
  1850. #endif
  1851. ])
  1852. case "$ac_cv_type_sig_atomic_t" in
  1853. yes)
  1854. #
  1855. AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
  1856. AC_LINK_IFELSE([
  1857. AC_LANG_PROGRAM([[
  1858. #ifdef HAVE_SIGNAL_H
  1859. #include <signal.h>
  1860. #endif
  1861. ]],[[
  1862. static volatile sig_atomic_t dummy = 0;
  1863. ]])
  1864. ],[
  1865. AC_MSG_RESULT([no])
  1866. ac_cv_sig_atomic_t_volatile="no"
  1867. ],[
  1868. AC_MSG_RESULT([yes])
  1869. ac_cv_sig_atomic_t_volatile="yes"
  1870. ])
  1871. #
  1872. if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
  1873. AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
  1874. [Define to 1 if sig_atomic_t is already defined as volatile.])
  1875. fi
  1876. ;;
  1877. esac
  1878. ])
  1879. dnl CURL_CHECK_NONBLOCKING_SOCKET
  1880. dnl -------------------------------------------------
  1881. dnl Check for how to set a socket to non-blocking state. There seems to exist
  1882. dnl four known different ways, with the one used almost everywhere being POSIX
  1883. dnl and XPG3, while the other different ways for different systems (old BSD,
  1884. dnl Windows and Amiga).
  1885. dnl
  1886. dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
  1887. dnl O_NONBLOCK define is found but does not work. This condition is attempted
  1888. dnl to get caught in this script by using an excessive number of #ifdefs...
  1889. AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
  1890. AC_MSG_CHECKING([non-blocking sockets style])
  1891. nonblock="unknown"
  1892. #
  1893. AC_COMPILE_IFELSE([
  1894. AC_LANG_PROGRAM([[
  1895. /* headers for O_NONBLOCK test */
  1896. #include <sys/types.h>
  1897. #include <unistd.h>
  1898. #include <fcntl.h>
  1899. /* */
  1900. #if defined(sun) || defined(__sun__) || \
  1901. defined(__SUNPRO_C) || defined(__SUNPRO_CC)
  1902. # if defined(__SVR4) || defined(__srv4__)
  1903. # define PLATFORM_SOLARIS
  1904. # else
  1905. # define PLATFORM_SUNOS4
  1906. # endif
  1907. #endif
  1908. #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
  1909. # define PLATFORM_AIX_V3
  1910. #endif
  1911. /* */
  1912. #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
  1913. #error "O_NONBLOCK does not work on this platform"
  1914. #endif
  1915. ]],[[
  1916. /* O_NONBLOCK source test */
  1917. int socket;
  1918. int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
  1919. ]])
  1920. ],[
  1921. dnl the O_NONBLOCK test was fine
  1922. nonblock="O_NONBLOCK"
  1923. AC_DEFINE(HAVE_O_NONBLOCK, 1,
  1924. [use O_NONBLOCK for non-blocking sockets])
  1925. ])
  1926. #
  1927. if test "$nonblock" = "unknown"; then
  1928. AC_COMPILE_IFELSE([
  1929. AC_LANG_PROGRAM([[
  1930. /* headers for FIONBIO test */
  1931. #include <unistd.h>
  1932. #include <stropts.h>
  1933. ]],[[
  1934. /* FIONBIO source test (old-style unix) */
  1935. int socket;
  1936. int flags = ioctl(socket, FIONBIO, &flags);
  1937. ]])
  1938. ],[
  1939. dnl FIONBIO test was good
  1940. nonblock="FIONBIO"
  1941. AC_DEFINE(HAVE_FIONBIO, 1,
  1942. [use FIONBIO for non-blocking sockets])
  1943. ])
  1944. fi
  1945. #
  1946. if test "$nonblock" = "unknown"; then
  1947. AC_COMPILE_IFELSE([
  1948. AC_LANG_PROGRAM([[
  1949. /* headers for ioctlsocket test (Windows) */
  1950. #undef inline
  1951. #ifdef HAVE_WINDOWS_H
  1952. #ifndef WIN32_LEAN_AND_MEAN
  1953. #define WIN32_LEAN_AND_MEAN
  1954. #endif
  1955. #include <windows.h>
  1956. #ifdef HAVE_WINSOCK2_H
  1957. #include <winsock2.h>
  1958. #else
  1959. #ifdef HAVE_WINSOCK_H
  1960. #include <winsock.h>
  1961. #endif
  1962. #endif
  1963. #endif
  1964. ]],[[
  1965. /* ioctlsocket source code (Windows) */
  1966. SOCKET sd;
  1967. unsigned long flags = 0;
  1968. sd = socket(0, 0, 0);
  1969. ioctlsocket(sd, FIONBIO, &flags);
  1970. ]])
  1971. ],[
  1972. dnl ioctlsocket test was good
  1973. nonblock="ioctlsocket"
  1974. AC_DEFINE(HAVE_IOCTLSOCKET, 1,
  1975. [use ioctlsocket() for non-blocking sockets])
  1976. ])
  1977. fi
  1978. #
  1979. if test "$nonblock" = "unknown"; then
  1980. AC_LINK_IFELSE([
  1981. AC_LANG_PROGRAM([[
  1982. /* headers for IoctlSocket test (Amiga?) */
  1983. #include <sys/ioctl.h>
  1984. ]],[[
  1985. /* IoctlSocket source code (Amiga?) */
  1986. int socket;
  1987. int flags = IoctlSocket(socket, FIONBIO, (long)1);
  1988. ]])
  1989. ],[
  1990. dnl Ioctlsocket test was good
  1991. nonblock="IoctlSocket"
  1992. AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
  1993. [use Ioctlsocket() for non-blocking sockets])
  1994. ])
  1995. fi
  1996. #
  1997. if test "$nonblock" = "unknown"; then
  1998. AC_COMPILE_IFELSE([
  1999. AC_LANG_PROGRAM([[
  2000. /* headers for SO_NONBLOCK test (BeOS) */
  2001. #include <socket.h>
  2002. ]],[[
  2003. /* SO_NONBLOCK source code (BeOS) */
  2004. long b = 1;
  2005. int socket;
  2006. int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
  2007. ]])
  2008. ],[
  2009. dnl the SO_NONBLOCK test was good
  2010. nonblock="SO_NONBLOCK"
  2011. AC_DEFINE(HAVE_SO_NONBLOCK, 1,
  2012. [use SO_NONBLOCK for non-blocking sockets])
  2013. ])
  2014. fi
  2015. #
  2016. AC_MSG_RESULT($nonblock)
  2017. #
  2018. if test "$nonblock" = "unknown"; then
  2019. AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
  2020. [disabled non-blocking sockets])
  2021. AC_MSG_WARN([non-block sockets disabled])
  2022. fi
  2023. ])
  2024. dnl TYPE_IN_ADDR_T
  2025. dnl -------------------------------------------------
  2026. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  2027. dnl and a few other things.
  2028. AC_DEFUN([TYPE_IN_ADDR_T], [
  2029. AC_CHECK_TYPE([in_addr_t], ,[
  2030. dnl in_addr_t not available
  2031. AC_CACHE_CHECK([for in_addr_t equivalent],
  2032. [curl_cv_in_addr_t_equiv], [
  2033. curl_cv_in_addr_t_equiv="unknown"
  2034. for t in "unsigned long" int size_t unsigned long; do
  2035. if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
  2036. AC_LINK_IFELSE([
  2037. AC_LANG_PROGRAM([[
  2038. #undef inline
  2039. #ifdef HAVE_WINDOWS_H
  2040. #ifndef WIN32_LEAN_AND_MEAN
  2041. #define WIN32_LEAN_AND_MEAN
  2042. #endif
  2043. #include <windows.h>
  2044. #ifdef HAVE_WINSOCK2_H
  2045. #include <winsock2.h>
  2046. #else
  2047. #ifdef HAVE_WINSOCK_H
  2048. #include <winsock.h>
  2049. #endif
  2050. #endif
  2051. #else
  2052. #ifdef HAVE_SYS_TYPES_H
  2053. #include <sys/types.h>
  2054. #endif
  2055. #ifdef HAVE_SYS_SOCKET_H
  2056. #include <sys/socket.h>
  2057. #endif
  2058. #ifdef HAVE_NETINET_IN_H
  2059. #include <netinet/in.h>
  2060. #endif
  2061. #ifdef HAVE_ARPA_INET_H
  2062. #include <arpa/inet.h>
  2063. #endif
  2064. #endif
  2065. ]],[[
  2066. $t data = inet_addr ("1.2.3.4");
  2067. ]])
  2068. ],[
  2069. curl_cv_in_addr_t_equiv="$t"
  2070. ])
  2071. fi
  2072. done
  2073. ])
  2074. case "$curl_cv_in_addr_t_equiv" in
  2075. unknown)
  2076. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  2077. ;;
  2078. *)
  2079. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  2080. [Type to use in place of in_addr_t when system does not provide it.])
  2081. ;;
  2082. esac
  2083. ],[
  2084. #undef inline
  2085. #ifdef HAVE_WINDOWS_H
  2086. #ifndef WIN32_LEAN_AND_MEAN
  2087. #define WIN32_LEAN_AND_MEAN
  2088. #endif
  2089. #include <windows.h>
  2090. #ifdef HAVE_WINSOCK2_H
  2091. #include <winsock2.h>
  2092. #else
  2093. #ifdef HAVE_WINSOCK_H
  2094. #include <winsock.h>
  2095. #endif
  2096. #endif
  2097. #else
  2098. #ifdef HAVE_SYS_TYPES_H
  2099. #include <sys/types.h>
  2100. #endif
  2101. #ifdef HAVE_SYS_SOCKET_H
  2102. #include <sys/socket.h>
  2103. #endif
  2104. #ifdef HAVE_NETINET_IN_H
  2105. #include <netinet/in.h>
  2106. #endif
  2107. #ifdef HAVE_ARPA_INET_H
  2108. #include <arpa/inet.h>
  2109. #endif
  2110. #endif
  2111. ])
  2112. ])
  2113. dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
  2114. dnl -------------------------------------------------
  2115. dnl Check if monotonic clock_gettime is available.
  2116. AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
  2117. AC_REQUIRE([AC_HEADER_TIME])dnl
  2118. AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
  2119. AC_MSG_CHECKING([for monotonic clock_gettime])
  2120. AC_COMPILE_IFELSE([
  2121. AC_LANG_PROGRAM([[
  2122. #ifdef HAVE_SYS_TYPES_H
  2123. #include <sys/types.h>
  2124. #endif
  2125. #ifdef HAVE_SYS_TIME_H
  2126. #include <sys/time.h>
  2127. #ifdef TIME_WITH_SYS_TIME
  2128. #include <time.h>
  2129. #endif
  2130. #else
  2131. #ifdef HAVE_TIME_H
  2132. #include <time.h>
  2133. #endif
  2134. #endif
  2135. ]],[[
  2136. struct timespec ts;
  2137. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  2138. ]])
  2139. ],[
  2140. AC_MSG_RESULT([yes])
  2141. ac_cv_func_clock_gettime="yes"
  2142. ],[
  2143. AC_MSG_RESULT([no])
  2144. ac_cv_func_clock_gettime="no"
  2145. ])
  2146. dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
  2147. dnl until library linking and run-time checks for clock_gettime succeed.
  2148. ])
  2149. dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
  2150. dnl -------------------------------------------------
  2151. dnl If monotonic clock_gettime is available then,
  2152. dnl check and prepended to LIBS any needed libraries.
  2153. AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
  2154. AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
  2155. #
  2156. if test "$ac_cv_func_clock_gettime" = "yes"; then
  2157. #
  2158. AC_MSG_CHECKING([for clock_gettime in libraries])
  2159. #
  2160. curl_cv_save_LIBS="$LIBS"
  2161. curl_cv_gclk_LIBS="unknown"
  2162. #
  2163. for x_xlibs in '' '-lrt' '-lposix4' ; do
  2164. if test "$curl_cv_gclk_LIBS" = "unknown"; then
  2165. if test -z "$x_xlibs"; then
  2166. LIBS="$curl_cv_save_LIBS"
  2167. else
  2168. LIBS="$x_xlibs $curl_cv_save_LIBS"
  2169. fi
  2170. AC_LINK_IFELSE([
  2171. AC_LANG_PROGRAM([[
  2172. #ifdef HAVE_SYS_TYPES_H
  2173. #include <sys/types.h>
  2174. #endif
  2175. #ifdef HAVE_SYS_TIME_H
  2176. #include <sys/time.h>
  2177. #ifdef TIME_WITH_SYS_TIME
  2178. #include <time.h>
  2179. #endif
  2180. #else
  2181. #ifdef HAVE_TIME_H
  2182. #include <time.h>
  2183. #endif
  2184. #endif
  2185. ]],[[
  2186. struct timespec ts;
  2187. (void)clock_gettime(CLOCK_MONOTONIC, &ts);
  2188. ]])
  2189. ],[
  2190. curl_cv_gclk_LIBS="$x_xlibs"
  2191. ])
  2192. fi
  2193. done
  2194. #
  2195. LIBS="$curl_cv_save_LIBS"
  2196. #
  2197. case X-"$curl_cv_gclk_LIBS" in
  2198. X-unknown)
  2199. AC_MSG_RESULT([cannot find clock_gettime])
  2200. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  2201. ac_cv_func_clock_gettime="no"
  2202. ;;
  2203. X-)
  2204. AC_MSG_RESULT([no additional lib required])
  2205. ac_cv_func_clock_gettime="yes"
  2206. ;;
  2207. *)
  2208. if test -z "$curl_cv_save_LIBS"; then
  2209. LIBS="$curl_cv_gclk_LIBS"
  2210. else
  2211. LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
  2212. fi
  2213. AC_MSG_RESULT([$curl_cv_gclk_LIBS])
  2214. ac_cv_func_clock_gettime="yes"
  2215. ;;
  2216. esac
  2217. #
  2218. dnl only do runtime verification when not cross-compiling
  2219. if test "x$cross_compiling" != "xyes" &&
  2220. test "$ac_cv_func_clock_gettime" = "yes"; then
  2221. AC_MSG_CHECKING([if monotonic clock_gettime works])
  2222. AC_RUN_IFELSE([
  2223. AC_LANG_PROGRAM([[
  2224. #ifdef HAVE_SYS_TYPES_H
  2225. #include <sys/types.h>
  2226. #endif
  2227. #ifdef HAVE_SYS_TIME_H
  2228. #include <sys/time.h>
  2229. #ifdef TIME_WITH_SYS_TIME
  2230. #include <time.h>
  2231. #endif
  2232. #else
  2233. #ifdef HAVE_TIME_H
  2234. #include <time.h>
  2235. #endif
  2236. #endif
  2237. ]],[[
  2238. struct timespec ts;
  2239. if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
  2240. exit(0);
  2241. else
  2242. exit(1);
  2243. ]])
  2244. ],[
  2245. AC_MSG_RESULT([yes])
  2246. ],[
  2247. AC_MSG_RESULT([no])
  2248. AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
  2249. ac_cv_func_clock_gettime="no"
  2250. LIBS="$curl_cv_save_LIBS"
  2251. ])
  2252. fi
  2253. #
  2254. case "$ac_cv_func_clock_gettime" in
  2255. yes)
  2256. AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
  2257. [Define to 1 if you have the clock_gettime function and monotonic timer.])
  2258. ;;
  2259. esac
  2260. #
  2261. fi
  2262. #
  2263. ])
  2264. dnl CURL_CHECK_FUNC_SELECT
  2265. dnl -------------------------------------------------
  2266. dnl Test if the socket select() function is available,
  2267. dnl and check its return type and the types of its
  2268. dnl arguments. If the function succeeds HAVE_SELECT
  2269. dnl will be defined, defining the types of the
  2270. dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
  2271. dnl and SELECT_TYPE_ARG5, defining the type of the
  2272. dnl function return value in SELECT_TYPE_RETV, and
  2273. dnl also defining the type qualifier of fifth argument
  2274. dnl in SELECT_QUAL_ARG5.
  2275. AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
  2276. AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
  2277. AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  2278. #
  2279. AC_MSG_CHECKING([for select])
  2280. AC_LINK_IFELSE([
  2281. AC_LANG_PROGRAM([[
  2282. #undef inline
  2283. #ifdef HAVE_WINDOWS_H
  2284. #ifndef WIN32_LEAN_AND_MEAN
  2285. #define WIN32_LEAN_AND_MEAN
  2286. #endif
  2287. #include <windows.h>
  2288. #ifdef HAVE_WINSOCK2_H
  2289. #include <winsock2.h>
  2290. #else
  2291. #ifdef HAVE_WINSOCK_H
  2292. #include <winsock.h>
  2293. #endif
  2294. #endif
  2295. #endif
  2296. #ifdef HAVE_SYS_TYPES_H
  2297. #include <sys/types.h>
  2298. #endif
  2299. #ifdef HAVE_SYS_TIME_H
  2300. #include <sys/time.h>
  2301. #ifdef TIME_WITH_SYS_TIME
  2302. #include <time.h>
  2303. #endif
  2304. #else
  2305. #ifdef HAVE_TIME_H
  2306. #include <time.h>
  2307. #endif
  2308. #endif
  2309. #ifndef HAVE_WINDOWS_H
  2310. #ifdef HAVE_SYS_SELECT_H
  2311. #include <sys/select.h>
  2312. #endif
  2313. #ifdef HAVE_SYS_SOCKET_H
  2314. #include <sys/socket.h>
  2315. #endif
  2316. #endif
  2317. ]],[[
  2318. select(0, 0, 0, 0, 0);
  2319. ]])
  2320. ],[
  2321. AC_MSG_RESULT([yes])
  2322. curl_cv_select="yes"
  2323. ],[
  2324. AC_MSG_RESULT([no])
  2325. curl_cv_select="no"
  2326. ])
  2327. #
  2328. if test "$curl_cv_select" = "yes"; then
  2329. AC_CACHE_CHECK([types of args and return type for select],
  2330. [curl_cv_func_select_args], [
  2331. curl_cv_func_select_args="unknown"
  2332. for sel_retv in 'int' 'ssize_t'; do
  2333. for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
  2334. for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
  2335. for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
  2336. if test "$curl_cv_func_select_args" = "unknown"; then
  2337. AC_COMPILE_IFELSE([
  2338. AC_LANG_PROGRAM([[
  2339. #undef inline
  2340. #ifdef HAVE_WINDOWS_H
  2341. #ifndef WIN32_LEAN_AND_MEAN
  2342. #define WIN32_LEAN_AND_MEAN
  2343. #endif
  2344. #include <windows.h>
  2345. #ifdef HAVE_WINSOCK2_H
  2346. #include <winsock2.h>
  2347. #else
  2348. #ifdef HAVE_WINSOCK_H
  2349. #include <winsock.h>
  2350. #endif
  2351. #endif
  2352. #define SELECTCALLCONV PASCAL
  2353. #endif
  2354. #ifdef HAVE_SYS_TYPES_H
  2355. #include <sys/types.h>
  2356. #endif
  2357. #ifdef HAVE_SYS_TIME_H
  2358. #include <sys/time.h>
  2359. #ifdef TIME_WITH_SYS_TIME
  2360. #include <time.h>
  2361. #endif
  2362. #else
  2363. #ifdef HAVE_TIME_H
  2364. #include <time.h>
  2365. #endif
  2366. #endif
  2367. #ifndef HAVE_WINDOWS_H
  2368. #ifdef HAVE_SYS_SELECT_H
  2369. #include <sys/select.h>
  2370. #endif
  2371. #ifdef HAVE_SYS_SOCKET_H
  2372. #include <sys/socket.h>
  2373. #endif
  2374. #define SELECTCALLCONV
  2375. #endif
  2376. #ifndef HAVE_STRUCT_TIMEVAL
  2377. struct timeval {
  2378. long tv_sec;
  2379. long tv_usec;
  2380. };
  2381. #endif
  2382. extern $sel_retv SELECTCALLCONV select($sel_arg1,
  2383. $sel_arg234,
  2384. $sel_arg234,
  2385. $sel_arg234,
  2386. $sel_arg5);
  2387. ]],[[
  2388. $sel_arg1 nfds=0;
  2389. $sel_arg234 rfds=0;
  2390. $sel_arg234 wfds=0;
  2391. $sel_arg234 efds=0;
  2392. $sel_retv res = select(nfds, rfds, wfds, efds, 0);
  2393. ]])
  2394. ],[
  2395. curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
  2396. ])
  2397. fi
  2398. done
  2399. done
  2400. done
  2401. done
  2402. ]) # AC-CACHE-CHECK
  2403. if test "$curl_cv_func_select_args" = "unknown"; then
  2404. AC_MSG_WARN([Cannot find proper types to use for select args])
  2405. AC_MSG_WARN([HAVE_SELECT will not be defined])
  2406. else
  2407. select_prev_IFS=$IFS; IFS=','
  2408. set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
  2409. IFS=$select_prev_IFS
  2410. shift
  2411. #
  2412. sel_qual_type_arg5=$[3]
  2413. #
  2414. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
  2415. [Define to the type of arg 1 for select.])
  2416. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
  2417. [Define to the type of args 2, 3 and 4 for select.])
  2418. AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
  2419. [Define to the function return type for select.])
  2420. #
  2421. prev_sh_opts=$-
  2422. #
  2423. case $prev_sh_opts in
  2424. *f*)
  2425. ;;
  2426. *)
  2427. set -f
  2428. ;;
  2429. esac
  2430. #
  2431. case "$sel_qual_type_arg5" in
  2432. const*)
  2433. sel_qual_arg5=const
  2434. sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
  2435. ;;
  2436. *)
  2437. sel_qual_arg5=
  2438. sel_type_arg5=$sel_qual_type_arg5
  2439. ;;
  2440. esac
  2441. #
  2442. AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
  2443. [Define to the type qualifier of arg 5 for select.])
  2444. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
  2445. [Define to the type of arg 5 for select.])
  2446. #
  2447. case $prev_sh_opts in
  2448. *f*)
  2449. ;;
  2450. *)
  2451. set +f
  2452. ;;
  2453. esac
  2454. #
  2455. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  2456. [Define to 1 if you have the select function.])
  2457. ac_cv_func_select="yes"
  2458. fi
  2459. fi
  2460. ])
  2461. dnl ************************************************************
  2462. dnl check for working getaddrinfo() that works with AI_NUMERICHOST
  2463. dnl
  2464. AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
  2465. AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
  2466. AC_TRY_RUN( [
  2467. #include <netdb.h>
  2468. #include <sys/types.h>
  2469. #include <sys/socket.h>
  2470. int main(void)
  2471. {
  2472. struct addrinfo hints, *ai;
  2473. int error;
  2474. memset(&hints, 0, sizeof(hints));
  2475. hints.ai_flags = AI_NUMERICHOST;
  2476. hints.ai_family = AF_UNSPEC;
  2477. hints.ai_socktype = SOCK_STREAM;
  2478. error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
  2479. if (error) {
  2480. return 1;
  2481. }
  2482. return 0;
  2483. }
  2484. ],[
  2485. ac_cv_working_getaddrinfo="yes"
  2486. ],[
  2487. ac_cv_working_getaddrinfo="no"
  2488. ],[
  2489. ac_cv_working_getaddrinfo="yes"
  2490. ])])
  2491. if test "$ac_cv_working_getaddrinfo" = "yes"; then
  2492. AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
  2493. AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
  2494. IPV6_ENABLED=1
  2495. AC_SUBST(IPV6_ENABLED)
  2496. fi
  2497. ])
  2498. AC_DEFUN([CURL_CHECK_LOCALTIME_R],
  2499. [
  2500. dnl check for localtime_r
  2501. AC_CHECK_FUNCS(localtime_r,[
  2502. AC_MSG_CHECKING(whether localtime_r is declared)
  2503. AC_EGREP_CPP(localtime_r,[
  2504. #undef _REENTRANT
  2505. #include <time.h>],[
  2506. AC_MSG_RESULT(yes)],[
  2507. AC_MSG_RESULT(no)
  2508. AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
  2509. AC_EGREP_CPP(localtime_r,[
  2510. #undef _REENTRANT
  2511. #define _REENTRANT
  2512. #include <time.h>],[
  2513. AC_MSG_RESULT(yes)],
  2514. AC_MSG_RESULT(no))])])
  2515. ])
  2516. dnl
  2517. dnl This function checks for strerror_r(). If it isn't found at first, it
  2518. dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
  2519. dnl in order to find this function.
  2520. dnl
  2521. dnl If the function is found, it will then proceed to check how the function
  2522. dnl actually works: glibc-style or POSIX-style.
  2523. dnl
  2524. dnl glibc:
  2525. dnl char *strerror_r(int errnum, char *buf, size_t n);
  2526. dnl
  2527. dnl What this one does is to return the error string (no surprises there),
  2528. dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
  2529. dnl parameters are only meant as an optional working area, in case strerror_r
  2530. dnl needs it. A quick test on a few systems shows that it's generally not
  2531. dnl touched at all.
  2532. dnl
  2533. dnl POSIX:
  2534. dnl int strerror_r(int errnum, char *buf, size_t n);
  2535. dnl
  2536. AC_DEFUN([CURL_CHECK_STRERROR_R],
  2537. [
  2538. AC_CHECK_FUNCS(strerror_r)
  2539. if test "x$ac_cv_func_strerror_r" = "xyes"; then
  2540. AC_MSG_CHECKING(whether strerror_r is declared)
  2541. AC_EGREP_CPP(strerror_r,[
  2542. #undef _REENTRANT
  2543. #include <string.h>],[
  2544. AC_MSG_RESULT(yes)],[
  2545. AC_MSG_RESULT(no)
  2546. AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
  2547. AC_EGREP_CPP(strerror_r,[
  2548. #undef _REENTRANT
  2549. #define _REENTRANT
  2550. #include <string.h>],[
  2551. AC_MSG_RESULT(yes)],
  2552. AC_MSG_RESULT(no)
  2553. AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
  2554. ) dnl with _THREAD_SAFE
  2555. ]) dnl plain cpp for it
  2556. dnl determine if this strerror_r() is glibc or POSIX
  2557. AC_MSG_CHECKING([for a glibc strerror_r API])
  2558. AC_TRY_RUN([
  2559. #include <string.h>
  2560. #include <errno.h>
  2561. int
  2562. main () {
  2563. char buffer[1024]; /* big enough to play with */
  2564. char *string =
  2565. strerror_r(EACCES, buffer, sizeof(buffer));
  2566. /* this should've returned a string */
  2567. if(!string || !string[0])
  2568. return 99;
  2569. return 0;
  2570. }
  2571. ],
  2572. GLIBC_STRERROR_R="1"
  2573. AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
  2574. AC_MSG_RESULT([yes]),
  2575. AC_MSG_RESULT([no]),
  2576. dnl Use an inferior method of strerror_r detection while cross-compiling
  2577. AC_EGREP_CPP(yes, [
  2578. #include <features.h>
  2579. #ifdef __GLIBC__
  2580. yes
  2581. #endif
  2582. ],
  2583. dnl looks like glibc, so assume a glibc-style strerror_r()
  2584. GLIBC_STRERROR_R="1"
  2585. AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
  2586. AC_MSG_RESULT([yes]),
  2587. AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
  2588. ) dnl while cross-compiling
  2589. )
  2590. if test -z "$GLIBC_STRERROR_R"; then
  2591. AC_MSG_CHECKING([for a POSIX strerror_r API])
  2592. AC_TRY_RUN([
  2593. #include <string.h>
  2594. #include <errno.h>
  2595. int
  2596. main () {
  2597. char buffer[1024]; /* big enough to play with */
  2598. int error =
  2599. strerror_r(EACCES, buffer, sizeof(buffer));
  2600. /* This should've returned zero, and written an error string in the
  2601. buffer.*/
  2602. if(!buffer[0] || error)
  2603. return 99;
  2604. return 0;
  2605. }
  2606. ],
  2607. AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
  2608. AC_MSG_RESULT([yes]),
  2609. AC_MSG_RESULT([no]) ,
  2610. dnl cross-compiling!
  2611. AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
  2612. )
  2613. fi dnl if not using glibc API
  2614. fi dnl we have a strerror_r
  2615. ])
  2616. AC_DEFUN([CURL_CHECK_INET_NTOA_R],
  2617. [
  2618. dnl determine if function definition for inet_ntoa_r exists.
  2619. AC_CHECK_FUNCS(inet_ntoa_r,[
  2620. AC_MSG_CHECKING(whether inet_ntoa_r is declared)
  2621. AC_EGREP_CPP(inet_ntoa_r,[
  2622. #undef _REENTRANT
  2623. #include <arpa/inet.h>],[
  2624. AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
  2625. AC_MSG_RESULT(yes)],[
  2626. AC_MSG_RESULT(no)
  2627. AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
  2628. AC_EGREP_CPP(inet_ntoa_r,[
  2629. #undef _REENTRANT
  2630. #define _REENTRANT
  2631. #include <arpa/inet.h>],[
  2632. AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
  2633. AC_MSG_RESULT(yes)],
  2634. AC_MSG_RESULT(no))])])
  2635. ])
  2636. dnl CURL_CHECK_GETHOSTBYADDR_R
  2637. dnl -------------------------------------------------
  2638. dnl check number of arguments for gethostbyaddr_r, it
  2639. dnl might take either 5, 7, or 8 arguments.
  2640. AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], [
  2641. #
  2642. AC_MSG_CHECKING([for gethostbyaddr_r])
  2643. AC_LINK_IFELSE([
  2644. AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
  2645. ],[
  2646. AC_MSG_RESULT([yes])
  2647. tmp_cv_gethostbyaddr_r="yes"
  2648. ],[
  2649. AC_MSG_RESULT([no])
  2650. tmp_cv_gethostbyaddr_r="no"
  2651. ])
  2652. #
  2653. if test "$tmp_cv_gethostbyaddr_r" != "yes"; then
  2654. AC_MSG_CHECKING([deeper for gethostbyaddr_r])
  2655. AC_LINK_IFELSE([
  2656. AC_LANG_PROGRAM([[
  2657. ]],[[
  2658. gethostbyaddr_r();
  2659. ]])
  2660. ],[
  2661. AC_MSG_RESULT([yes])
  2662. tmp_cv_gethostbyaddr_r="yes"
  2663. ],[
  2664. AC_MSG_RESULT([but still no])
  2665. tmp_cv_gethostbyaddr_r="no"
  2666. ])
  2667. fi
  2668. #
  2669. if test "$tmp_cv_gethostbyaddr_r" = "yes"; then
  2670. ac_cv_gethostbyaddr_r_args="unknown"
  2671. AC_MSG_CHECKING([if gethostbyaddr_r takes 5 arguments])
  2672. AC_COMPILE_IFELSE([
  2673. AC_LANG_PROGRAM([[
  2674. #undef _REENTRANT
  2675. #include <sys/types.h>
  2676. #include <netdb.h>
  2677. ]],[[
  2678. char * address;
  2679. int length;
  2680. int type;
  2681. struct hostent h;
  2682. struct hostent_data hdata;
  2683. int rc;
  2684. rc = gethostbyaddr_r(address, length, type, &h, &hdata);
  2685. ]])
  2686. ],[
  2687. AC_MSG_RESULT([yes])
  2688. AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
  2689. ac_cv_gethostbyaddr_r_args="5"
  2690. ],[
  2691. AC_MSG_RESULT([no])
  2692. ])
  2693. if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
  2694. AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 5 arguments])
  2695. AC_COMPILE_IFELSE([
  2696. AC_LANG_PROGRAM([[
  2697. #undef _REENTRANT
  2698. #define _REENTRANT
  2699. #include <sys/types.h>
  2700. #include <netdb.h>
  2701. ]],[[
  2702. char * address;
  2703. int length;
  2704. int type;
  2705. struct hostent h;
  2706. struct hostent_data hdata;
  2707. int rc;
  2708. rc = gethostbyaddr_r(address, length, type, &h, &hdata);
  2709. ]])
  2710. ],[
  2711. AC_MSG_RESULT([yes])
  2712. AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
  2713. ac_cv_gethostbyaddr_r_args="5"
  2714. ],[
  2715. AC_MSG_RESULT([no])
  2716. ])
  2717. fi
  2718. if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
  2719. AC_MSG_CHECKING([if gethostbyaddr_r takes 7 arguments])
  2720. AC_COMPILE_IFELSE([
  2721. AC_LANG_PROGRAM([[
  2722. #undef _REENTRANT
  2723. #include <sys/types.h>
  2724. #include <netdb.h>
  2725. ]],[[
  2726. char * address;
  2727. int length;
  2728. int type;
  2729. struct hostent h;
  2730. char buffer[8192];
  2731. int h_errnop;
  2732. struct hostent * hp;
  2733. hp = gethostbyaddr_r(address, length, type, &h,
  2734. buffer, 8192, &h_errnop);
  2735. ]])
  2736. ],[
  2737. AC_MSG_RESULT([yes])
  2738. AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
  2739. ac_cv_gethostbyaddr_r_args="7"
  2740. ],[
  2741. AC_MSG_RESULT([no])
  2742. ])
  2743. fi
  2744. if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
  2745. AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 7 arguments])
  2746. AC_COMPILE_IFELSE([
  2747. AC_LANG_PROGRAM([[
  2748. #undef _REENTRANT
  2749. #define _REENTRANT
  2750. #include <sys/types.h>
  2751. #include <netdb.h>
  2752. ]],[[
  2753. char * address;
  2754. int length;
  2755. int type;
  2756. struct hostent h;
  2757. char buffer[8192];
  2758. int h_errnop;
  2759. struct hostent * hp;
  2760. hp = gethostbyaddr_r(address, length, type, &h,
  2761. buffer, 8192, &h_errnop);
  2762. ]])
  2763. ],[
  2764. AC_MSG_RESULT([yes])
  2765. AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
  2766. ac_cv_gethostbyaddr_r_args="7"
  2767. ],[
  2768. AC_MSG_RESULT([no])
  2769. ])
  2770. fi
  2771. if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
  2772. AC_MSG_CHECKING([if gethostbyaddr_r takes 8 arguments])
  2773. AC_COMPILE_IFELSE([
  2774. AC_LANG_PROGRAM([[
  2775. #undef _REENTRANT
  2776. #include <sys/types.h>
  2777. #include <netdb.h>
  2778. ]],[[
  2779. char * address;
  2780. int length;
  2781. int type;
  2782. struct hostent h;
  2783. char buffer[8192];
  2784. int h_errnop;
  2785. struct hostent * hp;
  2786. int rc;
  2787. rc = gethostbyaddr_r(address, length, type, &h,
  2788. buffer, 8192, &hp, &h_errnop);
  2789. ]])
  2790. ],[
  2791. AC_MSG_RESULT([yes])
  2792. AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
  2793. ac_cv_gethostbyaddr_r_args="8"
  2794. ],[
  2795. AC_MSG_RESULT([no])
  2796. ])
  2797. fi
  2798. if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
  2799. AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 8 arguments])
  2800. AC_COMPILE_IFELSE([
  2801. AC_LANG_PROGRAM([[
  2802. #undef _REENTRANT
  2803. #define _REENTRANT
  2804. #include <sys/types.h>
  2805. #include <netdb.h>
  2806. ]],[[
  2807. char * address;
  2808. int length;
  2809. int type;
  2810. struct hostent h;
  2811. char buffer[8192];
  2812. int h_errnop;
  2813. struct hostent * hp;
  2814. int rc;
  2815. rc = gethostbyaddr_r(address, length, type, &h,
  2816. buffer, 8192, &hp, &h_errnop);
  2817. ]])
  2818. ],[
  2819. AC_MSG_RESULT([yes])
  2820. AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
  2821. ac_cv_gethostbyaddr_r_args="8"
  2822. ],[
  2823. AC_MSG_RESULT([no])
  2824. ])
  2825. fi
  2826. if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
  2827. AC_MSG_WARN([Cannot find out how to use gethostbyaddr_r])
  2828. AC_MSG_WARN([HAVE_GETHOSTBYADDR_R will not be defined])
  2829. ac_cv_func_gethostbyaddr_r="no"
  2830. else
  2831. AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
  2832. [Define to 1 if you have the gethostbyaddr_r function.])
  2833. ac_cv_func_gethostbyaddr_r="yes"
  2834. fi
  2835. else
  2836. ac_cv_func_gethostbyaddr_r="no"
  2837. fi
  2838. ])
  2839. dnl CURL_CHECK_GETHOSTBYNAME_R
  2840. dnl -------------------------------------------------
  2841. dnl check number of arguments for gethostbyname_r, it
  2842. dnl might take either 3, 5, or 6 arguments.
  2843. AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], [
  2844. #
  2845. AC_MSG_CHECKING([for gethostbyname_r])
  2846. AC_LINK_IFELSE([
  2847. AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
  2848. ],[
  2849. AC_MSG_RESULT([yes])
  2850. tmp_cv_gethostbyname_r="yes"
  2851. ],[
  2852. AC_MSG_RESULT([no])
  2853. tmp_cv_gethostbyname_r="no"
  2854. ])
  2855. #
  2856. if test "$tmp_cv_gethostbyname_r" != "yes"; then
  2857. AC_MSG_CHECKING([deeper for gethostbyname_r])
  2858. AC_LINK_IFELSE([
  2859. AC_LANG_PROGRAM([[
  2860. ]],[[
  2861. gethostbyname_r();
  2862. ]])
  2863. ],[
  2864. AC_MSG_RESULT([yes])
  2865. tmp_cv_gethostbyname_r="yes"
  2866. ],[
  2867. AC_MSG_RESULT([but still no])
  2868. tmp_cv_gethostbyname_r="no"
  2869. ])
  2870. fi
  2871. #
  2872. if test "$tmp_cv_gethostbyname_r" = "yes"; then
  2873. ac_cv_gethostbyname_r_args="unknown"
  2874. AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
  2875. AC_COMPILE_IFELSE([
  2876. AC_LANG_PROGRAM([[
  2877. #undef _REENTRANT
  2878. #include <string.h>
  2879. #include <sys/types.h>
  2880. #include <netdb.h>
  2881. #undef NULL
  2882. #define NULL (void *)0
  2883. int
  2884. gethostbyname_r(const char *, struct hostent *,
  2885. struct hostent_data *);
  2886. ]],[[
  2887. struct hostent_data data;
  2888. gethostbyname_r(NULL, NULL, NULL);
  2889. ]])
  2890. ],[
  2891. AC_MSG_RESULT([yes])
  2892. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
  2893. ac_cv_gethostbyname_r_args="3"
  2894. ],[
  2895. AC_MSG_RESULT([no])
  2896. ])
  2897. if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
  2898. AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
  2899. AC_COMPILE_IFELSE([
  2900. AC_LANG_PROGRAM([[
  2901. #undef _REENTRANT
  2902. #define _REENTRANT
  2903. #include <string.h>
  2904. #include <sys/types.h>
  2905. #include <netdb.h>
  2906. #undef NULL
  2907. #define NULL (void *)0
  2908. int
  2909. gethostbyname_r(const char *, struct hostent *,
  2910. struct hostent_data *);
  2911. ]],[[
  2912. struct hostent_data data;
  2913. gethostbyname_r(NULL, NULL, NULL);
  2914. ]])
  2915. ],[
  2916. AC_MSG_RESULT([yes])
  2917. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
  2918. ac_cv_gethostbyname_r_args="3"
  2919. ],[
  2920. AC_MSG_RESULT([no])
  2921. ])
  2922. fi
  2923. if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
  2924. AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
  2925. AC_COMPILE_IFELSE([
  2926. AC_LANG_PROGRAM([[
  2927. #undef _REENTRANT
  2928. #include <sys/types.h>
  2929. #include <netdb.h>
  2930. #undef NULL
  2931. #define NULL (void *)0
  2932. struct hostent *
  2933. gethostbyname_r(const char *, struct hostent *,
  2934. char *, int, int *);
  2935. ]],[[
  2936. gethostbyname_r(NULL, NULL, NULL, 0, NULL);
  2937. ]])
  2938. ],[
  2939. AC_MSG_RESULT([yes])
  2940. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
  2941. ac_cv_gethostbyname_r_args="5"
  2942. ],[
  2943. AC_MSG_RESULT([no])
  2944. ])
  2945. fi
  2946. if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
  2947. AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 5 arguments])
  2948. AC_COMPILE_IFELSE([
  2949. AC_LANG_PROGRAM([[
  2950. #undef _REENTRANT
  2951. #define _REENTRANT
  2952. #include <sys/types.h>
  2953. #include <netdb.h>
  2954. #undef NULL
  2955. #define NULL (void *)0
  2956. struct hostent *
  2957. gethostbyname_r(const char *, struct hostent *,
  2958. char *, int, int *);
  2959. ]],[[
  2960. gethostbyname_r(NULL, NULL, NULL, 0, NULL);
  2961. ]])
  2962. ],[
  2963. AC_MSG_RESULT([yes])
  2964. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
  2965. ac_cv_gethostbyname_r_args="5"
  2966. ],[
  2967. AC_MSG_RESULT([no])
  2968. ])
  2969. fi
  2970. if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
  2971. AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
  2972. AC_COMPILE_IFELSE([
  2973. AC_LANG_PROGRAM([[
  2974. #undef _REENTRANT
  2975. #include <sys/types.h>
  2976. #include <netdb.h>
  2977. #undef NULL
  2978. #define NULL (void *)0
  2979. int
  2980. gethostbyname_r(const char *, struct hostent *,
  2981. char *, size_t, struct hostent **, int *);
  2982. ]],[[
  2983. gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
  2984. ]])
  2985. ],[
  2986. AC_MSG_RESULT([yes])
  2987. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
  2988. ac_cv_gethostbyname_r_args="6"
  2989. ],[
  2990. AC_MSG_RESULT([no])
  2991. ])
  2992. fi
  2993. if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
  2994. AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 6 arguments])
  2995. AC_COMPILE_IFELSE([
  2996. AC_LANG_PROGRAM([[
  2997. #undef _REENTRANT
  2998. #define _REENTRANT
  2999. #include <sys/types.h>
  3000. #include <netdb.h>
  3001. #undef NULL
  3002. #define NULL (void *)0
  3003. int
  3004. gethostbyname_r(const char *, struct hostent *,
  3005. char *, size_t, struct hostent **, int *);
  3006. ]],[[
  3007. gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
  3008. ]])
  3009. ],[
  3010. AC_MSG_RESULT([yes])
  3011. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
  3012. ac_cv_gethostbyname_r_args="6"
  3013. ],[
  3014. AC_MSG_RESULT([no])
  3015. ])
  3016. fi
  3017. if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
  3018. AC_MSG_WARN([Cannot find out how to use gethostbyname_r])
  3019. AC_MSG_WARN([HAVE_GETHOSTBYNAME_R will not be defined])
  3020. ac_cv_func_gethostbyname_r="no"
  3021. else
  3022. AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
  3023. [Define to 1 if you have the gethostbyname_r function.])
  3024. ac_cv_func_gethostbyname_r="yes"
  3025. fi
  3026. else
  3027. ac_cv_func_gethostbyname_r="no"
  3028. fi
  3029. ])
  3030. dnl **********************************************************************
  3031. dnl CURL_DETECT_ICC ([ACTION-IF-YES])
  3032. dnl
  3033. dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
  3034. dnl sets the $ICC variable to "yes" or "no"
  3035. dnl **********************************************************************
  3036. AC_DEFUN([CURL_DETECT_ICC],
  3037. [
  3038. ICC="no"
  3039. AC_MSG_CHECKING([for icc in use])
  3040. if test "$GCC" = "yes"; then
  3041. dnl check if this is icc acting as gcc in disguise
  3042. AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
  3043. dnl action if the text is found, this it has not been replaced by the
  3044. dnl cpp
  3045. ICC="no",
  3046. dnl the text was not found, it was replaced by the cpp
  3047. ICC="yes"
  3048. AC_MSG_RESULT([yes])
  3049. [$1]
  3050. )
  3051. fi
  3052. if test "$ICC" = "no"; then
  3053. # this is not ICC
  3054. AC_MSG_RESULT([no])
  3055. fi
  3056. ])
  3057. dnl We create a function for detecting which compiler we use and then set as
  3058. dnl pendantic compiler options as possible for that particular compiler. The
  3059. dnl options are only used for debug-builds.
  3060. AC_DEFUN([CURL_CC_DEBUG_OPTS],
  3061. [
  3062. if test "z$ICC" = "z"; then
  3063. CURL_DETECT_ICC
  3064. fi
  3065. if test "$GCC" = "yes"; then
  3066. dnl figure out gcc version!
  3067. AC_MSG_CHECKING([gcc version])
  3068. gccver=`$CC -dumpversion`
  3069. num1=`echo $gccver | cut -d . -f1`
  3070. num2=`echo $gccver | cut -d . -f2`
  3071. gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
  3072. AC_MSG_RESULT($gccver)
  3073. if test "$ICC" = "yes"; then
  3074. dnl this is icc, not gcc.
  3075. dnl ICC warnings we ignore:
  3076. dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
  3077. dnl "invalid format string conversion"
  3078. dnl * 279 warns on static conditions in while expressions
  3079. dnl * 981 warns on "operands are evaluated in unspecified order"
  3080. dnl * 1418 "external definition with no prior declaration"
  3081. dnl * 1419 warns on "external declaration in primary source file"
  3082. dnl which we know and do on purpose.
  3083. WARN="-wd279,269,981,1418,1419"
  3084. if test "$gccnum" -gt "600"; then
  3085. dnl icc 6.0 and older doesn't have the -Wall flag
  3086. WARN="-Wall $WARN"
  3087. fi
  3088. else dnl $ICC = yes
  3089. dnl this is a set of options we believe *ALL* gcc versions support:
  3090. WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
  3091. dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
  3092. if test "$gccnum" -ge "207"; then
  3093. dnl gcc 2.7 or later
  3094. WARN="$WARN -Wmissing-declarations"
  3095. fi
  3096. if test "$gccnum" -gt "295"; then
  3097. dnl only if the compiler is newer than 2.95 since we got lots of
  3098. dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
  3099. dnl gcc 2.95.4 on FreeBSD 4.9!
  3100. WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
  3101. fi
  3102. if test "$gccnum" -ge "296"; then
  3103. dnl gcc 2.96 or later
  3104. WARN="$WARN -Wfloat-equal"
  3105. fi
  3106. if test "$gccnum" -gt "296"; then
  3107. dnl this option does not exist in 2.96
  3108. WARN="$WARN -Wno-format-nonliteral"
  3109. fi
  3110. dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
  3111. dnl on i686-Linux as it gives us heaps with false positives.
  3112. dnl Also, on gcc 4.0.X it is totally unbearable and complains all
  3113. dnl over making it unusable for generic purposes. Let's not use it.
  3114. if test "$gccnum" -ge "303"; then
  3115. dnl gcc 3.3 and later
  3116. WARN="$WARN -Wendif-labels -Wstrict-prototypes"
  3117. fi
  3118. if test "$gccnum" -ge "304"; then
  3119. # try these on gcc 3.4
  3120. WARN="$WARN -Wdeclaration-after-statement"
  3121. fi
  3122. for flag in $CPPFLAGS; do
  3123. case "$flag" in
  3124. -I*)
  3125. dnl Include path, provide a -isystem option for the same dir
  3126. dnl to prevent warnings in those dirs. The -isystem was not very
  3127. dnl reliable on earlier gcc versions.
  3128. add=`echo $flag | sed 's/^-I/-isystem /g'`
  3129. WARN="$WARN $add"
  3130. ;;
  3131. esac
  3132. done
  3133. fi dnl $ICC = no
  3134. CFLAGS="$CFLAGS $WARN"
  3135. AC_MSG_NOTICE([Added this set of compiler options: $WARN])
  3136. else dnl $GCC = yes
  3137. AC_MSG_NOTICE([Added no extra compiler options])
  3138. fi dnl $GCC = yes
  3139. dnl strip off optimizer flags
  3140. NEWFLAGS=""
  3141. for flag in $CFLAGS; do
  3142. case "$flag" in
  3143. -O*)
  3144. dnl echo "cut off $flag"
  3145. ;;
  3146. *)
  3147. NEWFLAGS="$NEWFLAGS $flag"
  3148. ;;
  3149. esac
  3150. done
  3151. CFLAGS=$NEWFLAGS
  3152. ]) # AC-DEFUN
  3153. # This is only a temporary fix. This macro is here to replace the broken one
  3154. # delivered by the automake project (including the 1.9.6 release). As soon as
  3155. # they ship a working version we SHOULD remove this work-around.
  3156. AC_DEFUN([AM_MISSING_HAS_RUN],
  3157. [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
  3158. test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
  3159. # Use eval to expand $SHELL
  3160. if eval "$MISSING --run true"; then
  3161. am_missing_run="$MISSING --run "
  3162. else
  3163. am_missing_run=
  3164. AC_MSG_WARN([`missing' script is too old or missing])
  3165. fi
  3166. ])
  3167. dnl CURL_VERIFY_RUNTIMELIBS
  3168. dnl -------------------------------------------------
  3169. dnl Verify that the shared libs found so far can be used when running
  3170. dnl programs, since otherwise the situation will create odd configure errors
  3171. dnl that are misleading people.
  3172. dnl
  3173. dnl Make sure this test is run BEFORE the first test in the script that
  3174. dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
  3175. dnl macro. It must also run AFTER all lib-checking macros are complete.
  3176. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
  3177. dnl this test is of course not sensible if we are cross-compiling!
  3178. if test "x$cross_compiling" != xyes; then
  3179. dnl just run a program to verify that the libs checked for previous to this
  3180. dnl point also is available run-time!
  3181. AC_MSG_CHECKING([run-time libs availability])
  3182. AC_TRY_RUN([
  3183. main()
  3184. {
  3185. return 0;
  3186. }
  3187. ],
  3188. AC_MSG_RESULT([fine]),
  3189. AC_MSG_RESULT([failed])
  3190. AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
  3191. )
  3192. dnl if this test fails, configure has already stopped
  3193. fi
  3194. ])
  3195. dnl CURL_CHECK_VARIADIC_MACROS
  3196. dnl -------------------------------------------------
  3197. dnl Check compiler support of variadic macros
  3198. AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
  3199. AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
  3200. [curl_cv_variadic_macros_c99], [
  3201. AC_COMPILE_IFELSE([
  3202. AC_LANG_PROGRAM([[
  3203. #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
  3204. #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
  3205. int fun3(int arg1, int arg2, int arg3);
  3206. int fun2(int arg1, int arg2);
  3207. int fun3(int arg1, int arg2, int arg3)
  3208. { return arg1 + arg2 + arg3; }
  3209. int fun2(int arg1, int arg2)
  3210. { return arg1 + arg2; }
  3211. ]],[[
  3212. int res3 = c99_vmacro3(1, 2, 3);
  3213. int res2 = c99_vmacro2(1, 2);
  3214. ]])
  3215. ],[
  3216. curl_cv_variadic_macros_c99="yes"
  3217. ],[
  3218. curl_cv_variadic_macros_c99="no"
  3219. ])
  3220. ])
  3221. case "$curl_cv_variadic_macros_c99" in
  3222. yes)
  3223. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
  3224. [Define to 1 if compiler supports C99 variadic macro style.])
  3225. ;;
  3226. esac
  3227. AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
  3228. [curl_cv_variadic_macros_gcc], [
  3229. AC_COMPILE_IFELSE([
  3230. AC_LANG_PROGRAM([[
  3231. #define gcc_vmacro3(first, args...) fun3(first, args)
  3232. #define gcc_vmacro2(first, args...) fun2(first, args)
  3233. int fun3(int arg1, int arg2, int arg3);
  3234. int fun2(int arg1, int arg2);
  3235. int fun3(int arg1, int arg2, int arg3)
  3236. { return arg1 + arg2 + arg3; }
  3237. int fun2(int arg1, int arg2)
  3238. { return arg1 + arg2; }
  3239. ]],[[
  3240. int res3 = gcc_vmacro3(1, 2, 3);
  3241. int res2 = gcc_vmacro2(1, 2);
  3242. ]])
  3243. ],[
  3244. curl_cv_variadic_macros_gcc="yes"
  3245. ],[
  3246. curl_cv_variadic_macros_gcc="no"
  3247. ])
  3248. ])
  3249. case "$curl_cv_variadic_macros_gcc" in
  3250. yes)
  3251. AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
  3252. [Define to 1 if compiler supports old gcc variadic macro style.])
  3253. ;;
  3254. esac
  3255. ])
  3256. dnl CURL_CHECK_CA_BUNDLE
  3257. dnl -------------------------------------------------
  3258. dnl Check if a default ca-bundle should be used
  3259. dnl
  3260. dnl regarding the paths this will scan:
  3261. dnl /etc/ssl/certs/ca-certificates.crt Debian systems
  3262. dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
  3263. dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
  3264. dnl /etc/ssl/certs/ (ca path) SUSE
  3265. AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
  3266. AC_MSG_CHECKING([default CA cert bundle/path])
  3267. AC_ARG_WITH(ca-bundle,
  3268. AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
  3269. AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
  3270. [
  3271. want_ca="$withval"
  3272. if test "x$want_ca" = "xyes"; then
  3273. AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
  3274. fi
  3275. ],
  3276. [ want_ca="unset" ])
  3277. AC_ARG_WITH(ca-path,
  3278. AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
  3279. AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
  3280. [
  3281. want_capath="$withval"
  3282. if test "x$want_capath" = "xyes"; then
  3283. AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
  3284. fi
  3285. ],
  3286. [ want_capath="unset"])
  3287. if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
  3288. "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  3289. dnl both given
  3290. AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
  3291. elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
  3292. dnl --with-ca-bundle given
  3293. ca="$want_ca"
  3294. capath="no"
  3295. elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
  3296. dnl --with-ca-path given
  3297. if test "x$OPENSSL_ENABLED" != "x1"; then
  3298. AC_MSG_ERROR([--with-ca-path only works with openSSL])
  3299. fi
  3300. capath="$want_capath"
  3301. ca="no"
  3302. else
  3303. dnl neither of --with-ca-* given
  3304. dnl first try autodetecting a CA bundle , then a CA path
  3305. dnl both autodetections can be skipped by --without-ca-*
  3306. ca="no"
  3307. capath="no"
  3308. if test "x$want_ca" = "xunset"; then
  3309. dnl the path we previously would have installed the curl ca bundle
  3310. dnl to, and thus we now check for an already existing cert in that place
  3311. dnl in case we find no other
  3312. if test "x$prefix" != xNONE; then
  3313. cac="${prefix}/share/curl/curl-ca-bundle.crt"
  3314. else
  3315. cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
  3316. fi
  3317. for a in /etc/ssl/certs/ca-certificates.crt \
  3318. /etc/pki/tls/certs/ca-bundle.crt \
  3319. /usr/share/ssl/certs/ca-bundle.crt \
  3320. "$cac"; do
  3321. if test -f "$a"; then
  3322. ca="$a"
  3323. break
  3324. fi
  3325. done
  3326. fi
  3327. if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
  3328. "x$OPENSSL_ENABLED" = "x1"; then
  3329. for a in /etc/ssl/certs/; do
  3330. 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
  3331. capath="$a"
  3332. break
  3333. fi
  3334. done
  3335. fi
  3336. fi
  3337. if test "x$ca" != "xno"; then
  3338. CURL_CA_BUNDLE='"'$ca'"'
  3339. AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
  3340. AC_SUBST(CURL_CA_BUNDLE)
  3341. AC_MSG_RESULT([$ca])
  3342. elif test "x$capath" != "xno"; then
  3343. CURL_CA_PATH="\"$capath\""
  3344. AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
  3345. AC_MSG_RESULT([$capath (capath)])
  3346. else
  3347. AC_MSG_RESULT([no])
  3348. fi
  3349. ])
  3350. dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
  3351. dnl -------------------------------------------------
  3352. dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
  3353. dnl symbol that can be further used in custom template configuration
  3354. dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
  3355. dnl argument for the description. Symbol definitions done with this
  3356. dnl macro are intended to be exclusively used in handcrafted *.h.in
  3357. dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
  3358. dnl prevents autoheader generation and insertion of symbol template
  3359. dnl stub and definition into the first configuration header file. Do
  3360. dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
  3361. dnl one serves different functional needs.
  3362. AC_DEFUN([CURL_DEFINE_UNQUOTED], [
  3363. cat >>confdefs.h <<_EOF
  3364. [@%:@define] $1 ifelse($#, 2, [$2], 1)
  3365. _EOF
  3366. ])
  3367. dnl CURL_INCLUDES_INTTYPES
  3368. dnl -------------------------------------------------
  3369. dnl Set up variable with list of headers that must be
  3370. dnl included when inttypes.h is to be included.
  3371. AC_DEFUN([CURL_INCLUDES_INTTYPES], [
  3372. curl_includes_inttypes="\
  3373. /* includes start */
  3374. #ifdef HAVE_SYS_TYPES_H
  3375. # include <sys/types.h>
  3376. #endif
  3377. #ifdef HAVE_STDINT_H
  3378. # include <stdint.h>
  3379. #endif
  3380. #ifdef HAVE_INTTYPES_H
  3381. # include <inttypes.h>
  3382. #endif
  3383. /* includes end */"
  3384. AC_CHECK_HEADERS(
  3385. sys/types.h stdint.h inttypes.h,
  3386. [], [], [$curl_includes_inttypes])
  3387. ])
  3388. dnl CURL_CONFIGURE_LONG
  3389. dnl -------------------------------------------------
  3390. dnl Find out the size of long as reported by sizeof() and define
  3391. dnl CURL_SIZEOF_LONG as appropriate to be used in template file
  3392. dnl include/curl/curlbuild.h.in to properly configure the library.
  3393. dnl The size of long is a build time characteristic and as such
  3394. dnl must be recorded in curlbuild.h
  3395. AC_DEFUN([CURL_CONFIGURE_LONG], [
  3396. if test -z "$ac_cv_sizeof_long" ||
  3397. test "$ac_cv_sizeof_long" -eq "0"; then
  3398. AC_MSG_ERROR([cannot find out size of long.])
  3399. fi
  3400. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
  3401. ])
  3402. dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
  3403. dnl -------------------------------------------------
  3404. dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
  3405. AC_DEFUN([DO_CURL_OFF_T_CHECK], [
  3406. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  3407. if test "$curl_typeof_curl_off_t" = "unknown" && test ! -z "$1"; then
  3408. tmp_includes=""
  3409. tmp_source=""
  3410. tmp_fmt=""
  3411. case AS_TR_SH([$1]) in
  3412. int64_t)
  3413. tmp_includes="$curl_includes_inttypes"
  3414. tmp_source="char f@<:@@:>@ = PRId64;"
  3415. tmp_fmt="PRId64"
  3416. ;;
  3417. int32_t)
  3418. tmp_includes="$curl_includes_inttypes"
  3419. tmp_source="char f@<:@@:>@ = PRId32;"
  3420. tmp_fmt="PRId32"
  3421. ;;
  3422. int16_t)
  3423. tmp_includes="$curl_includes_inttypes"
  3424. tmp_source="char f@<:@@:>@ = PRId16;"
  3425. tmp_fmt="PRId16"
  3426. ;;
  3427. esac
  3428. AC_COMPILE_IFELSE([
  3429. AC_LANG_PROGRAM([[
  3430. $tmp_includes
  3431. typedef $1 curl_off_t;
  3432. typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
  3433. ]],[[
  3434. $tmp_source
  3435. curl_off_t dummy;
  3436. ]])
  3437. ],[
  3438. if test -z "$tmp_fmt"; then
  3439. curl_typeof_curl_off_t="$1"
  3440. curl_sizeof_curl_off_t="$2"
  3441. else
  3442. CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
  3443. AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
  3444. AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
  3445. if test AS_VAR_GET(tmp_HaveFmtDef) = "yes"; then
  3446. curl_format_curl_off_t=AS_VAR_GET(tmp_FmtDef)
  3447. curl_typeof_curl_off_t="$1"
  3448. curl_sizeof_curl_off_t="$2"
  3449. fi
  3450. AS_VAR_POPDEF([tmp_FmtDef])dnl
  3451. AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
  3452. fi
  3453. ])
  3454. fi
  3455. ])
  3456. dnl DO_CURL_OFF_T_SUFFIX_CHECK (TYPE)
  3457. dnl -------------------------------------------------
  3458. dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
  3459. AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [
  3460. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  3461. AC_MSG_CHECKING([constant suffix string for curl_off_t])
  3462. #
  3463. curl_suffix_curl_off_t="unknown"
  3464. curl_suffix_curl_off_tu="unknown"
  3465. #
  3466. case AS_TR_SH([$1]) in
  3467. long_long | __longlong | __longlong_t)
  3468. tst_suffixes="LL::"
  3469. ;;
  3470. long)
  3471. tst_suffixes="L::"
  3472. ;;
  3473. int)
  3474. tst_suffixes="::"
  3475. ;;
  3476. __int64 | int64_t)
  3477. tst_suffixes="LL:i64::"
  3478. ;;
  3479. __int32 | int32_t)
  3480. tst_suffixes="L:i32::"
  3481. ;;
  3482. __int16 | int16_t)
  3483. tst_suffixes="L:i16::"
  3484. ;;
  3485. *)
  3486. AC_MSG_ERROR([unexpected data type $1])
  3487. ;;
  3488. esac
  3489. #
  3490. old_IFS=$IFS; IFS=':'
  3491. for tmp_ssuf in $tst_suffixes ; do
  3492. IFS=$old_IFS
  3493. if test "x$curl_suffix_curl_off_t" = "xunknown"; then
  3494. case $tmp_ssuf in
  3495. i64 | i32 | i16)
  3496. tmp_usuf="u$tmp_ssuf"
  3497. ;;
  3498. LL | L)
  3499. tmp_usuf="U$tmp_ssuf"
  3500. ;;
  3501. *)
  3502. tmp_usuf=""
  3503. ;;
  3504. esac
  3505. AC_COMPILE_IFELSE([
  3506. AC_LANG_PROGRAM([[
  3507. $curl_includes_inttypes
  3508. typedef $1 new_t;
  3509. ]],[[
  3510. new_t s1;
  3511. new_t s2;
  3512. s1 = -10$tmp_ssuf ;
  3513. s2 = 20$tmp_ssuf ;
  3514. if(s1 > s2)
  3515. return 1;
  3516. ]])
  3517. ],[
  3518. curl_suffix_curl_off_t="$tmp_ssuf"
  3519. curl_suffix_curl_off_tu="$tmp_usuf"
  3520. ])
  3521. fi
  3522. done
  3523. IFS=$old_IFS
  3524. #
  3525. if test "x$curl_suffix_curl_off_t" = "xunknown"; then
  3526. AC_MSG_ERROR([cannot find constant suffix string for curl_off_t.])
  3527. else
  3528. AC_MSG_RESULT([$curl_suffix_curl_off_t])
  3529. AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
  3530. AC_MSG_RESULT([$curl_suffix_curl_off_tu])
  3531. fi
  3532. #
  3533. ])
  3534. dnl CURL_CONFIGURE_CURL_OFF_T
  3535. dnl -------------------------------------------------
  3536. dnl Find out suitable curl_off_t data type definition and associated
  3537. dnl items, and make the appropriate definitions used in template file
  3538. dnl include/curl/curlbuild.h.in to properly configure the library.
  3539. AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
  3540. AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
  3541. #
  3542. AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
  3543. AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
  3544. AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
  3545. #
  3546. if test -z "$SED"; then
  3547. AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
  3548. fi
  3549. #
  3550. AC_CHECK_SIZEOF(long)
  3551. AC_CHECK_SIZEOF(void*)
  3552. #
  3553. if test -z "$ac_cv_sizeof_long" ||
  3554. test "$ac_cv_sizeof_long" -eq "0"; then
  3555. AC_MSG_ERROR([cannot find out size of long.])
  3556. fi
  3557. if test -z "$ac_cv_sizeof_voidp" ||
  3558. test "$ac_cv_sizeof_voidp" -eq "0"; then
  3559. AC_MSG_ERROR([cannot find out size of void*.])
  3560. fi
  3561. #
  3562. x_LP64_long=""
  3563. x_LP32_long=""
  3564. x_LP16_long=""
  3565. #
  3566. if test "$ac_cv_sizeof_long" -eq "8" &&
  3567. test "$ac_cv_sizeof_voidp" -ge "8"; then
  3568. x_LP64_long="long"
  3569. elif test "$ac_cv_sizeof_long" -eq "4" &&
  3570. test "$ac_cv_sizeof_voidp" -ge "4"; then
  3571. x_LP32_long="long"
  3572. elif test "$ac_cv_sizeof_long" -eq "2" &&
  3573. test "$ac_cv_sizeof_voidp" -ge "2"; then
  3574. x_LP16_long="long"
  3575. fi
  3576. #
  3577. dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
  3578. #
  3579. curl_typeof_curl_off_t="unknown"
  3580. curl_sizeof_curl_off_t="unknown"
  3581. curl_format_curl_off_t="unknown"
  3582. curl_format_curl_off_tu="unknown"
  3583. #
  3584. if test "$curl_typeof_curl_off_t" = "unknown"; then
  3585. AC_MSG_CHECKING([for 64-bit curl_off_t data type])
  3586. for t8 in \
  3587. "$x_LP64_long" \
  3588. 'int64_t' \
  3589. '__int64' \
  3590. 'long long' \
  3591. '__longlong' \
  3592. '__longlong_t' ; do
  3593. DO_CURL_OFF_T_CHECK([$t8], [8])
  3594. done
  3595. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  3596. fi
  3597. if test "$curl_typeof_curl_off_t" = "unknown"; then
  3598. AC_MSG_CHECKING([for 32-bit curl_off_t data type])
  3599. for t4 in \
  3600. "$x_LP32_long" \
  3601. 'int32_t' \
  3602. '__int32' \
  3603. 'int' ; do
  3604. DO_CURL_OFF_T_CHECK([$t4], [4])
  3605. done
  3606. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  3607. fi
  3608. if test "$curl_typeof_curl_off_t" = "unknown"; then
  3609. AC_MSG_CHECKING([for 16-bit curl_off_t data type])
  3610. for t2 in \
  3611. "$x_LP16_long" \
  3612. 'int16_t' \
  3613. '__int16' \
  3614. 'int' ; do
  3615. DO_CURL_OFF_T_CHECK([$t2], [2])
  3616. done
  3617. AC_MSG_RESULT([$curl_typeof_curl_off_t])
  3618. fi
  3619. if test "$curl_typeof_curl_off_t" = "unknown"; then
  3620. AC_MSG_ERROR([cannot find data type for curl_off_t.])
  3621. fi
  3622. #
  3623. AC_MSG_CHECKING([size of curl_off_t])
  3624. AC_MSG_RESULT([$curl_sizeof_curl_off_t])
  3625. #
  3626. AC_MSG_CHECKING([formatting string directive for curl_off_t])
  3627. if test "$curl_format_curl_off_t" != "unknown"; then
  3628. x_pull_headers="yes"
  3629. curl_format_curl_off_t=`echo "$curl_format_curl_off_t" | "$SED" 's/[["]]//g'`
  3630. curl_format_curl_off_tu=`echo "$curl_format_curl_off_t" | "$SED" 's/i$/u/'`
  3631. curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/d$/u/'`
  3632. curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'`
  3633. else
  3634. x_pull_headers="no"
  3635. case AS_TR_SH([$curl_typeof_curl_off_t]) in
  3636. long_long | __longlong | __longlong_t)
  3637. curl_format_curl_off_t="lld"
  3638. curl_format_curl_off_tu="llu"
  3639. ;;
  3640. long)
  3641. curl_format_curl_off_t="ld"
  3642. curl_format_curl_off_tu="lu"
  3643. ;;
  3644. int)
  3645. curl_format_curl_off_t="d"
  3646. curl_format_curl_off_tu="u"
  3647. ;;
  3648. __int64)
  3649. curl_format_curl_off_t="I64d"
  3650. curl_format_curl_off_tu="I64u"
  3651. ;;
  3652. __int32)
  3653. curl_format_curl_off_t="I32d"
  3654. curl_format_curl_off_tu="I32u"
  3655. ;;
  3656. __int16)
  3657. curl_format_curl_off_t="I16d"
  3658. curl_format_curl_off_tu="I16u"
  3659. ;;
  3660. *)
  3661. AC_MSG_ERROR([cannot find print format string for curl_off_t.])
  3662. ;;
  3663. esac
  3664. fi
  3665. AC_MSG_RESULT(["$curl_format_curl_off_t"])
  3666. #
  3667. AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
  3668. AC_MSG_RESULT(["$curl_format_curl_off_tu"])
  3669. #
  3670. DO_CURL_OFF_T_SUFFIX_CHECK([$curl_typeof_curl_off_t])
  3671. #
  3672. if test "$x_pull_headers" = "yes"; then
  3673. if test "x$ac_cv_header_sys_types_h" = "xyes"; then
  3674. CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
  3675. fi
  3676. if test "x$ac_cv_header_stdint_h" = "xyes"; then
  3677. CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
  3678. fi
  3679. if test "x$ac_cv_header_inttypes_h" = "xyes"; then
  3680. CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
  3681. fi
  3682. fi
  3683. #
  3684. CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_OFF_T], [$curl_typeof_curl_off_t])
  3685. CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_T], ["$curl_format_curl_off_t"])
  3686. CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_TU], ["$curl_format_curl_off_tu"])
  3687. CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$curl_format_curl_off_t"])
  3688. CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$curl_sizeof_curl_off_t])
  3689. CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$curl_suffix_curl_off_t])
  3690. CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$curl_suffix_curl_off_tu])
  3691. #
  3692. ])
  3693. dnl CURL_CHECK_WIN32_LARGEFILE
  3694. dnl -------------------------------------------------
  3695. dnl Check if curl's WIN32 large file will be used
  3696. AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
  3697. AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  3698. AC_MSG_CHECKING([whether build target supports WIN32 file API])
  3699. curl_win32_file_api="no"
  3700. if test "$ac_cv_header_windows_h" = "yes"; then
  3701. if test x"$enable_largefile" != "xno"; then
  3702. AC_COMPILE_IFELSE([
  3703. AC_LANG_PROGRAM([[
  3704. ]],[[
  3705. #if !defined(_WIN32_WCE) && \
  3706. (defined(__MINGW32__) || \
  3707. (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
  3708. int dummy=1;
  3709. #else
  3710. WIN32 large file API not supported.
  3711. #endif
  3712. ]])
  3713. ],[
  3714. curl_win32_file_api="win32_large_files"
  3715. ])
  3716. fi
  3717. if test "$curl_win32_file_api" = "no"; then
  3718. AC_COMPILE_IFELSE([
  3719. AC_LANG_PROGRAM([[
  3720. ]],[[
  3721. #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
  3722. int dummy=1;
  3723. #else
  3724. WIN32 small file API not supported.
  3725. #endif
  3726. ]])
  3727. ],[
  3728. curl_win32_file_api="win32_small_files"
  3729. ])
  3730. fi
  3731. fi
  3732. case "$curl_win32_file_api" in
  3733. win32_large_files)
  3734. AC_MSG_RESULT([yes (large file enabled)])
  3735. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  3736. [Define to 1 if you are building a Windows target with large file support.])
  3737. ;;
  3738. win32_small_files)
  3739. AC_MSG_RESULT([yes (large file disabled)])
  3740. AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
  3741. [Define to 1 if you are building a Windows target without large file support.])
  3742. ;;
  3743. *)
  3744. AC_MSG_RESULT([no])
  3745. ;;
  3746. esac
  3747. ])