configure.ac 118 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852
  1. # This file is part of libmicrohttpd.
  2. # (C) 2006-2021 Christian Grothoff (and other contributing authors)
  3. # (C) 2014-2022 Evgeny Grin (Karlson2k)
  4. #
  5. # libmicrohttpd is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published
  7. # by the Free Software Foundation; either version 3, or (at your
  8. # option) any later version.
  9. #
  10. # libmicrohttpd is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with libmicrohttpd; see the file COPYING. If not, write to the
  17. # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. # Boston, MA 02110-1301, USA.
  19. #
  20. #
  21. # Process this file with autoconf to produce a configure script.
  22. #
  23. #
  24. AC_PREREQ([2.64])
  25. LT_PREREQ([2.4.0])
  26. AC_INIT([GNU Libmicrohttpd],[0.9.77],[libmicrohttpd@gnu.org])
  27. AC_CONFIG_AUX_DIR([build-aux])
  28. AM_INIT_AUTOMAKE([gnu] [check-news] [filename-length-max=99] [tar-v7] [silent-rules] [subdir-objects])
  29. AC_CONFIG_HEADERS([MHD_config.h])
  30. AC_CONFIG_MACRO_DIR([m4])
  31. LIB_VERSION_CURRENT=73
  32. LIB_VERSION_REVISION=0
  33. LIB_VERSION_AGE=61
  34. AC_SUBST([LIB_VERSION_CURRENT])
  35. AC_SUBST([LIB_VERSION_REVISION])
  36. AC_SUBST([LIB_VERSION_AGE])
  37. AC_MSG_CHECKING([[whether z/OS special settings are required]])
  38. AS_IF([test `uname -s` = "OS/390"],
  39. [
  40. # configure binaries for z/OS
  41. AS_IF([test -z "$CC"],
  42. [CC=`pwd`"/contrib/xcc"
  43. chmod +x $CC || true])
  44. AS_IF([test -z "$CPP"],
  45. CPP="c89 -E")
  46. AS_IF([test -z "$CXXCPP"],
  47. CXXCPP="c++ -E -+")
  48. AC_MSG_RESULT([[yes]])
  49. # _CCC_CCMODE=1
  50. # _C89_CCMODE=1
  51. ],
  52. AC_MSG_RESULT([[no]])
  53. )
  54. # Checks for programs.
  55. AC_PROG_AWK
  56. AC_PROG_GREP
  57. AC_PROG_FGREP
  58. AC_PROG_INSTALL
  59. AC_PROG_LN_S
  60. AC_PROG_MAKE_SET
  61. AC_CANONICAL_HOST
  62. m4_version_prereq([2.70],
  63. [
  64. # Find C compiler and compiler options to support
  65. # the latest C standard (C11). Fallback to C99 and C89
  66. # if later C versions are not supported.
  67. AC_PROG_CC
  68. ],
  69. [
  70. # Find C compiler and compiler options to support
  71. # the latest C standard (C99). Fallback to C89
  72. # if later C versions are not supported.
  73. AC_PROG_CC_STDC
  74. ]
  75. )
  76. MHD_SYS_EXT
  77. LT_INIT([win32-dll])
  78. LT_LANG([Windows Resource])
  79. # Check for headers that are ALWAYS required
  80. AC_CHECK_HEADERS_ONCE([stdio.h string.h stdint.h errno.h limits.h fcntl.h], [],
  81. [AC_MSG_ERROR([Compiling libmicrohttpd requires standard POSIX headers files])], [AC_INCLUDES_DEFAULT])
  82. # Check for basic optional headers
  83. AC_CHECK_HEADERS([stddef.h stdlib.h inttypes.h sys/types.h sys/stat.h unistd.h \
  84. sys/uio.h], [], [], [AC_INCLUDES_DEFAULT])
  85. # Check for clock-specific optional headers
  86. AC_CHECK_HEADERS([sys/time.h time.h], [], [], [AC_INCLUDES_DEFAULT])
  87. # Check for system information and parameters optional headers
  88. AC_CHECK_HEADERS([endian.h machine/endian.h sys/endian.h sys/byteorder.h \
  89. sys/machine.h machine/param.h sys/param.h sys/isa_defs.h \
  90. sys/ioctl.h], [], [], [AC_INCLUDES_DEFAULT])
  91. # Check for network and sockets optional headers
  92. AC_CHECK_HEADERS([sys/socket.h sys/select.h netinet/in_systm.h netinet/in.h \
  93. arpa/inet.h netinet/ip.h netinet/tcp.h net/if.h \
  94. netdb.h sockLib.h inetLib.h], [], [],
  95. [AC_INCLUDES_DEFAULT
  96. [
  97. #ifdef HAVE_SYS_TYPES_H
  98. #include <sys/types.h>
  99. #endif /* HAVE_SYS_TYPES_H */
  100. #ifdef HAVE_INTTYPES_H
  101. #include <inttypes.h>
  102. #endif /* HAVE_INTTYPES_H */
  103. #ifdef HAVE_SYS_SOCKET_H
  104. #include <sys/socket.h>
  105. #endif /* HAVE_SYS_SOCKET_H */
  106. #ifdef HAVE_NETINET_IN_SYSTM_H
  107. #include <netinet/in_systm.h>
  108. #endif /* HAVE_NETINET_IN_SYSTM_H */
  109. #ifdef HAVE_NETINET_IN_H
  110. #include <netinet/in.h>
  111. #endif /* HAVE_NETINET_IN_H */
  112. #ifdef HAVE_NETINET_IP_H
  113. #include <netinet/ip.h>
  114. #endif /* HAVE_NETINET_IP_H */
  115. #ifdef HAVE_NETINET_TCP_H
  116. #include <netinet/tcp.h>
  117. #endif /* HAVE_NETINET_TCP_H */
  118. ]]
  119. )
  120. # Check for other optional headers
  121. AC_CHECK_HEADERS([sys/msg.h sys/mman.h signal.h], [], [], [AC_INCLUDES_DEFAULT])
  122. AC_CHECK_HEADER([[search.h]],
  123. [
  124. MHD_CHECK_LINK_RUN([[for proper tsearch(), tfind() and tdelete()]],[[mhd_cv_sys_tsearch_usable]],
  125. [
  126. AS_CASE([$host_os],
  127. [openbsd*],
  128. [[ # Some OpenBSD versions have wrong return value for tdelete()
  129. mhd_cv_sys_tsearch_usable='assuming no'
  130. ]],
  131. [netbsd*],
  132. [[ # NetBSD had leaked root node for years
  133. mhd_cv_sys_tsearch_usable='assuming no'
  134. ]],
  135. [[mhd_cv_sys_tsearch_usable='assuming yes']]
  136. )
  137. ],
  138. [
  139. AC_LANG_SOURCE(
  140. [[
  141. #ifdef HAVE_STDDEF_H
  142. #include <stddef.h>
  143. #endif /* HAVE_STDDEF_H */
  144. #ifdef HAVE_STDLIB_H
  145. #include <stdlib.h>
  146. #endif /* HAVE_STDLIB_H */
  147. #include <stdio.h>
  148. #include <search.h>
  149. static int cmp_func(const void *p1, const void *p2)
  150. {
  151. return (*((const int *)p1)) - (*((const int *)p2));
  152. }
  153. int main(void)
  154. {
  155. int ret = 0;
  156. void *root_ptr = NULL;
  157. int element1 = 1;
  158. int **element_ptr_ptr1;
  159. int **element_ptr_ptr2;
  160. element_ptr_ptr1 =
  161. (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func);
  162. if (NULL == element_ptr_ptr1)
  163. {
  164. fprintf (stderr, "NULL pointer has been returned when tsearch() called for the first time.\n");
  165. return ++ret;
  166. }
  167. if (*element_ptr_ptr1 != &element1)
  168. {
  169. fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the first time.\n");
  170. return ++ret;
  171. }
  172. if (NULL == root_ptr)
  173. {
  174. fprintf (stderr, "Root pointer has not been set by tsearch().\n");
  175. return ++ret;
  176. }
  177. element_ptr_ptr2 =
  178. (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func);
  179. if (NULL == element_ptr_ptr2)
  180. {
  181. fprintf (stderr, "NULL pointer has been returned when tsearch() called for the second time.\n");
  182. return ++ret;
  183. }
  184. if (*element_ptr_ptr2 != &element1)
  185. {
  186. fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the second time.\n");
  187. ++ret;
  188. }
  189. if (element_ptr_ptr2 != element_ptr_ptr1)
  190. {
  191. fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n");
  192. ++ret;
  193. }
  194. element_ptr_ptr2 =
  195. (int **) tfind ((void*) &element1, &root_ptr, &cmp_func);
  196. if (NULL == element_ptr_ptr2)
  197. {
  198. fprintf (stderr, "NULL pointer has been returned by tfind().\n");
  199. ++ret;
  200. }
  201. if (*element_ptr_ptr2 != &element1)
  202. {
  203. fprintf (stderr, "Wrong pointer has been returned when by tfind().\n");
  204. ++ret;
  205. }
  206. if (element_ptr_ptr2 != element_ptr_ptr1)
  207. {
  208. fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n");
  209. ++ret;
  210. }
  211. element_ptr_ptr1 =
  212. (int **) tdelete ((void*) &element1, &root_ptr, &cmp_func);
  213. if (NULL == element_ptr_ptr1)
  214. {
  215. fprintf (stderr, "NULL pointer has been returned by tdelete().\n");
  216. ++ret;
  217. }
  218. if (NULL != root_ptr)
  219. {
  220. fprintf (stderr, "Root pointer has not been set to NULL by tdelete().\n");
  221. ++ret;
  222. }
  223. return ret;
  224. }
  225. ]]
  226. )
  227. ],
  228. [AC_DEFINE([[MHD_USE_SYS_TSEARCH]], [[1]], [Define to 1 if you have properly working tsearch(), tfind() and tdelete() functions.])]
  229. )
  230. ],
  231. [], [AC_INCLUDES_DEFAULT]
  232. )
  233. AM_CONDITIONAL([MHD_USE_SYS_TSEARCH], [[test "x$mhd_cv_sys_tsearch_usable" = "xyes" || test "x$mhd_cv_sys_tsearch_usable" = "xassuming yes"]])
  234. # Optional headers used for tests
  235. AC_CHECK_HEADERS([sys/sysctl.h netinet/ip_icmp.h netinet/icmp_var.h], [], [],
  236. [[
  237. #ifdef HAVE_SYS_TYPES_H
  238. #include <sys/types.h>
  239. #endif /* HAVE_SYS_TYPES_H */
  240. #ifdef HAVE_SYS_SYSCTL_H
  241. #include <sys/sysctl.h>
  242. #endif /* HAVE_SYS_SYSCTL_H */
  243. #ifdef HAVE_SYS_SOCKET_H
  244. #include <sys/socket.h>
  245. #endif /* HAVE_SYS_SOCKET_H */
  246. #ifdef HAVE_NETINET_IN_SYSTM_H
  247. #include <netinet/in_systm.h>
  248. #endif /* HAVE_NETINET_IN_SYSTM_H */
  249. #ifdef HAVE_NETINET_IN_H
  250. #include <netinet/in.h>
  251. #endif /* HAVE_NETINET_IN_H */
  252. #ifdef HAVE_NETINET_IP_H
  253. #include <netinet/ip.h>
  254. #endif /* HAVE_NETINET_IP_H */
  255. #ifdef HAVE_NETINET_IP_ICMP_H
  256. #include <netinet/ip_icmp.h>
  257. #endif /* HAVE_NETINET_IP_ICMP_H */
  258. ]]
  259. )
  260. # Checks for gettext.
  261. m4_ifdef([AM_GNU_GETTEXT], [
  262. AS_VAR_SET_IF([enable_nls], [], [[enable_nls=no]])
  263. AM_GNU_GETTEXT([external],[need-ngettext])
  264. AC_CONFIG_FILES([po/Makefile.in])
  265. have_po=yes
  266. ], [
  267. have_po=no
  268. ])
  269. m4_ifdef([AM_GNU_GETTEXT_VERSION], [
  270. #do not indent here
  271. AM_GNU_GETTEXT_VERSION([0.21])
  272. ])
  273. AM_CONDITIONAL([HAVE_PO], [ test "$have_po" = yes ])
  274. # Adam shostack suggests the following for Windows:
  275. # -D_FORTIFY_SOURCE=2 -fstack-protector-all
  276. AC_ARG_ENABLE([gcc-hardening],
  277. [AS_HELP_STRING([--enable-gcc-hardening], [enable compiler security checks])],
  278. [AS_IF([test x$enableval = xyes],[
  279. CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all"
  280. CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector"
  281. CFLAGS="$CFLAGS --param ssp-buffer-size=1"
  282. LDFLAGS="$LDFLAGS -pie"
  283. ])])
  284. # Linker hardening options
  285. # Currently these options are ELF specific - you can't use this with MacOSX
  286. AC_ARG_ENABLE([linker-hardening],
  287. [AS_HELP_STRING([--enable-linker-hardening], [enable linker security fixups])],
  288. [AS_IF([test x$enableval = xyes],
  289. [LDFLAGS="$LDFLAGS -z relro -z now"])])
  290. # Workaround for libgcrypt
  291. AS_IF([[test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x"]], [[SYSROOT="$lt_sysroot"]])
  292. PACKAGE_VERSION_MAJOR='m4_car(m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  293. PACKAGE_VERSION_MINOR='m4_argn(2, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  294. PACKAGE_VERSION_SUBMINOR='m4_argn(3, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  295. AS_VAR_ARITH([MHD_W32_DLL_SUFF],[[$LIB_VERSION_CURRENT - $LIB_VERSION_AGE]])
  296. AC_SUBST([PACKAGE_VERSION_MAJOR])
  297. AC_SUBST([PACKAGE_VERSION_MINOR])
  298. AC_SUBST([PACKAGE_VERSION_SUBMINOR])
  299. AC_SUBST([MHD_W32_DLL_SUFF])
  300. AC_CONFIG_FILES([src/microhttpd/microhttpd_dll_res.rc])
  301. MHD_LIB_CPPFLAGS=""
  302. MHD_LIB_CFLAGS=""
  303. MHD_LIB_LDFLAGS=""
  304. MHD_LIBDEPS=""
  305. # for pkg-config
  306. MHD_REQ_PRIVATE=''
  307. MHD_LIBDEPS_PKGCFG=''
  308. AH_TEMPLATE([[HAVE_STDBOOL_H]], [Define to 1 if you have the <stdbool.h> header file and <stdbool.h> defines 'bool' type.])
  309. AH_TEMPLATE([[HAVE_BUILTIN_TYPE_BOOL]], [Define to 1 if you have the real boolean type.])
  310. AH_TEMPLATE([[bool]], [Define to type name which will be used as boolean type.])
  311. AC_CHECK_HEADER([stdbool.h],
  312. [
  313. AC_CHECK_TYPE([bool],
  314. [
  315. AC_DEFINE([[HAVE_STDBOOL_H]], [[1]])
  316. AC_DEFINE([[HAVE_BUILTIN_TYPE_BOOL]], [[1]])
  317. ],
  318. [
  319. AC_MSG_WARN([[Header <stdbool.h> is present, but "bool" type cannot be detected. Check compiler flags.]])
  320. AC_DEFINE([[bool]], [[int]])
  321. ], [
  322. #include <stdbool.h>
  323. ]
  324. )
  325. ],
  326. [
  327. AC_CHECK_TYPE([bool],
  328. [AC_DEFINE([[HAVE_BUILTIN_TYPE_BOOL]], [[1]])],
  329. [
  330. AC_CHECK_TYPE([_Bool],
  331. [
  332. AC_DEFINE([[HAVE_BUILTIN_TYPE_BOOL]], [[1]])
  333. AC_DEFINE([[bool]], [[_Bool]])
  334. ],
  335. [
  336. AC_DEFINE([[bool]], [[int]])
  337. ], []
  338. )
  339. ], []
  340. )
  341. ],
  342. [AC_INCLUDES_DEFAULT]
  343. )
  344. AC_CACHE_CHECK([[whether "true" is defined or builtin]], [[mhd_cv_macro_true_defined]],
  345. [AC_COMPILE_IFELSE(
  346. [AC_LANG_PROGRAM(
  347. [[
  348. #ifdef HAVE_STDBOOL_H
  349. #include <stdbool.h>
  350. #endif
  351. ]], [[
  352. #if defined(true)
  353. /* dummy */
  354. #else
  355. (void)true;
  356. #endif
  357. ]])
  358. ], [[mhd_cv_macro_true_defined='yes']], [[mhd_cv_macro_true_defined='no']])
  359. ])
  360. AS_VAR_IF([[mhd_cv_macro_true_defined]], [["yes"]], [[:]],
  361. [AC_DEFINE([[true]],[[(!0)]], [Define to value interpreted by compiler as boolean "true", if "true" is not defined by system headers.])])
  362. AC_CACHE_CHECK([[whether "false" is defined or builtin]], [[mhd_cv_macro_false_defined]],
  363. [AC_COMPILE_IFELSE(
  364. [AC_LANG_PROGRAM(
  365. [[
  366. #ifdef HAVE_STDBOOL_H
  367. #include <stdbool.h>
  368. #endif
  369. ]], [[
  370. #if !defined(false)
  371. (void)false;
  372. #else
  373. /* dummy */
  374. #endif
  375. ]])
  376. ], [[mhd_cv_macro_false_defined='yes']], [[mhd_cv_macro_false_defined='no']])
  377. ])
  378. AS_VAR_IF([[mhd_cv_macro_false_defined]], [["yes"]], [[:]],
  379. [AC_DEFINE([[false]],[[0]], [Define to value interpreted by compiler as boolean "false", if "false" is not defined by system headers.])])
  380. AC_CACHE_CHECK([[whether "true" and "false" could be used]], [[mhd_cv_macro_true_false_valid]],
  381. [AC_COMPILE_IFELSE(
  382. [AC_LANG_PROGRAM(
  383. [[
  384. #ifdef HAVE_STDBOOL_H
  385. #include <stdbool.h>
  386. #endif
  387. ]], [[
  388. int var1[true ? 1 : -1] = { 1 };
  389. int var2[false ? -1 : 1] = { 2 };
  390. int var3[!true ? -1 : 1] = { 3 };
  391. int var4[!false ? 1 : -1] = { 4 };
  392. if (var1[0] == var2[0] || var3[0] == var4[0])
  393. return 1;
  394. ]])
  395. ], [[mhd_cv_macro_true_false_valid='yes']], [[mhd_cv_macro_true_false_valid='no']])
  396. ])
  397. AS_VAR_IF([[mhd_cv_macro_true_false_valid]], [["yes"]], [[:]],
  398. [AC_MSG_ERROR([[Value of "true" or value of "false" is not valid. Check config.log for details.]])])
  399. AX_CHECK_COMPILE_FLAG([[-Werror=attributes]],
  400. [
  401. save_CFLAGS="$CFLAGS"
  402. CFLAGS="$CFLAGS -Werror=attributes"
  403. AC_MSG_CHECKING([[whether -Werror=attributes actually works]])
  404. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  405. [[__attribute__((non_existing_attrb_dummy)) static int SimpleFunc(void) {return 3;}]],
  406. [[int r = SimpleFunc(); if (r) return r;]])],
  407. [
  408. AC_MSG_RESULT([[no]])
  409. errattr_CFLAGS=""
  410. ], [
  411. AC_MSG_RESULT([[yes]])
  412. errattr_CFLAGS="-Werror=attributes"
  413. ])
  414. CFLAGS="$save_CFLAGS"
  415. ],
  416. [[errattr_CFLAGS=""]], [], [])
  417. AC_MSG_CHECKING([[for function inline keywords supported by $CC]])
  418. save_CFLAGS="$CFLAGS"
  419. CFLAGS="$CFLAGS $errattr_CFLAGS"
  420. inln_prfx="none"
  421. # Prefer always inline functions
  422. for inln_prfx_chk in InlineWithAttr __forceinline inline __inline__ __inline _inline _Inline
  423. do
  424. # Try to link to avoid "symbol undefined" problems at build time
  425. AS_IF([[test "x$inln_prfx_chk" = "xInlineWithAttr"]],
  426. [
  427. AS_IF([[test "x$errattr_CFLAGS" = "x"]],
  428. [[ # Skip test with attribute as negative result can't be detected
  429. inln_prfx_chk="__forceinline" # use next value
  430. ]],[[inln_prfx_chk="inline __attribute__((always_inline))"]])
  431. ])
  432. AC_LINK_IFELSE(
  433. [
  434. AC_LANG_PROGRAM(
  435. [[
  436. #ifdef __cplusplus
  437. #error This test is only for C.
  438. choke me
  439. #endif
  440. #ifdef HAVE_STDBOOL_H
  441. #include <stdbool.h>
  442. #endif
  443. static $inln_prfx_chk bool cmpfn(int x, int y)
  444. { return x > y; }
  445. static $inln_prfx_chk int sumfn(int x, int y)
  446. { return x + y; }
  447. ]],[[
  448. int a = 1, b = 100, c;
  449. if (cmpfn(a, b))
  450. c = sumfn(a, b);
  451. else
  452. c = 0 - sumfn(a, b);
  453. if (c)
  454. return 0;
  455. ]])
  456. ],
  457. [[ inln_prfx="$inln_prfx_chk" ]])
  458. test "x$inln_prfx" != "xnone" && break
  459. done
  460. AS_IF([[test "x$inln_prfx" != "xnone"]],
  461. [
  462. AC_DEFINE([INLINE_FUNC],[1],[Define to 1 if your C compiler supports inline functions.])
  463. AC_DEFINE_UNQUOTED([_MHD_static_inline],[static $inln_prfx],[Define to prefix which will be used with MHD static inline functions.])
  464. ], [
  465. AC_DEFINE([_MHD_static_inline],[static],[Define to prefix which will be used with MHD static inline functions.])
  466. ])
  467. AC_MSG_RESULT([[$inln_prfx]])
  468. CFLAGS="$save_CFLAGS"
  469. AC_CHECK_HEADERS([stdalign.h], [], [], [AC_INCLUDES_DEFAULT])
  470. AC_CACHE_CHECK([[for C11 'alignof()' support]], [[mhd_cv_c_alignof]],
  471. [AC_COMPILE_IFELSE(
  472. [AC_LANG_PROGRAM(
  473. [[
  474. #ifdef HAVE_STDALIGN_H
  475. #include <stdalign.h>
  476. #endif
  477. ]], [[
  478. int var1[(alignof(int) >= 2) ? 1 : -1];
  479. int var2[alignof(unsigned int) - 1];
  480. int var3[(alignof(char) > 0) ? 1 : -1];
  481. int var4[(alignof(long) >= 4) ? 1 : -1];
  482. /* Mute compiler warnings */
  483. var1[0] = var2[0] = var3[0] = 0;
  484. var4[0] = 1;
  485. if (var1[0] + var2[0] + var3[0] == var4[0])
  486. return 1;
  487. ]])
  488. ], [
  489. AC_COMPILE_IFELSE(
  490. [AC_LANG_PROGRAM(
  491. [[
  492. #ifdef HAVE_STDALIGN_H
  493. #include <stdalign.h>
  494. #endif
  495. ]], [[
  496. /* Should fail if 'alignof()' works */
  497. int var1[alignof(nonexisting_type) - 1];
  498. /* Mute compiler warnings */
  499. var1[0] = 1;
  500. if (var1[0] + 1 == 1)
  501. return 1;
  502. ]])
  503. ], [[mhd_cv_c_alignof='no']], [[mhd_cv_c_alignof='yes']])
  504. ], [[mhd_cv_c_alignof='no']])
  505. ])
  506. AS_VAR_IF([mhd_cv_c_alignof], ["yes"],
  507. [AC_DEFINE([[HAVE_C_ALIGNOF]], [1], [Define to 1 if your compiler supports 'alignof()'])])
  508. # Check system type
  509. shutdown_trig_select='no'
  510. AC_MSG_CHECKING([[for target host OS]])
  511. AS_CASE(["$host_os"],
  512. [*darwin* | *rhapsody* | *macosx*],
  513. [AC_DEFINE_UNQUOTED(OSX,1,[This is an OS X system])
  514. CFLAGS="-no-cpp-precomp -fno-common $CFLAGS"
  515. mhd_host_os='Darwin'
  516. AC_MSG_RESULT([[$mhd_host_os]])],
  517. [freebsd*],
  518. [AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
  519. AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system])
  520. mhd_host_os='FreeBSD'
  521. AC_MSG_RESULT([[$mhd_host_os]])],
  522. [openbsd*],
  523. [AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
  524. AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system])
  525. mhd_host_os='OpenBSD'
  526. AC_MSG_RESULT([[$mhd_host_os]])],
  527. [netbsd*],
  528. [AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
  529. AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system])
  530. mhd_host_os='NetBSD'
  531. AC_MSG_RESULT([[$mhd_host_os]])],
  532. [*solaris*],
  533. [AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system])
  534. AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno does not work])
  535. mhd_host_os='Solaris'
  536. AC_MSG_RESULT([[$mhd_host_os]])
  537. AC_SEARCH_LIBS([gethostbyname], [nsl])],
  538. [*arm-linux*],
  539. [AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel])
  540. mhd_host_os='ARM Linux'
  541. AC_MSG_RESULT([[$mhd_host_os]])
  542. CFLAGS="-fPIC -pipe $CFLAGS"],
  543. [*linux*],
  544. [AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel])
  545. mhd_host_os='Linux'
  546. AC_MSG_RESULT([[$mhd_host_os]])],
  547. [*cygwin*],
  548. [AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
  549. mhd_host_os='Windows/Cygwin'
  550. AC_MSG_RESULT([[$mhd_host_os]])
  551. os_is_windows=yes],
  552. [*mingw*],
  553. [
  554. AC_DEFINE([MINGW],[1],[This is a MinGW system])
  555. AC_DEFINE([WINDOWS],[1],[This is a Windows system])
  556. mhd_host_os='Windows/MinGW'
  557. AC_MSG_RESULT([[$mhd_host_os]])
  558. AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([[Winsock2 headers are required for W32]])], [AC_INCLUDES_DEFAULT])
  559. AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool],
  560. [mslibcheck=`lib 2>&1`
  561. AS_IF([echo "$mslibcheck" | $GREP -e '^Microsoft (R) Library Manager' - >/dev/null],
  562. [ac_cv_use_ms_lib_tool=yes],
  563. [ac_cv_use_ms_lib_tool=no])
  564. ])
  565. AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes"],
  566. [AC_SUBST([MS_LIB_TOOL], [[lib]])])
  567. AC_SUBST([lt_cv_objdir])
  568. os_is_windows=yes
  569. os_is_native_w32=yes
  570. ],
  571. [*openedition*],
  572. [AC_DEFINE_UNQUOTED(OS390,1,[This is a OS/390 system])
  573. mhd_host_os='OS/390'
  574. AC_MSG_RESULT([[$mhd_host_os]])],
  575. [gnu*],
  576. [AC_DEFINE([[GNU_HURD]], [[1]], [Define to `1' if host machine runs on GNU Hurd.])
  577. mhd_host_os='GNU Hurd'
  578. AC_MSG_RESULT([[$mhd_host_os]])
  579. ],
  580. [
  581. AC_MSG_RESULT([unrecognised OS])
  582. mhd_host_os="${host_os}"
  583. AC_MSG_WARN([Unrecognised OS $host_os])
  584. AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
  585. ])
  586. AM_CONDITIONAL([CYGWIN_TARGET], [[test "x$os_is_windows" = "xyes" && \
  587. test "x${os_is_native_w32}" != "xyes"]])
  588. AS_VAR_IF([os_is_windows], ["yes"],
  589. [
  590. AC_MSG_CHECKING([[whether target W32 version is specified by precompiler defines]])
  591. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  592. /* Note: check logic is reversed for easy log reading */
  593. #ifdef WINVER
  594. #error WINVER is defined
  595. choke me now;
  596. #endif
  597. #ifdef _WIN32_WINNT
  598. #error _WIN32_WINNT is defined
  599. choke me now;
  600. #endif
  601. #ifdef NTDDI
  602. #error NTDDI is defined
  603. choke me now;
  604. #endif
  605. ]],[[(void)0]])
  606. ], [[mhd_w32_ver_preselect=no]], [[mhd_w32_ver_preselect=yes]]
  607. )
  608. AC_MSG_RESULT([[${mhd_w32_ver_preselect}]])
  609. AC_CHECK_HEADERS([windows.h sdkddkver.h], [], [], [AC_INCLUDES_DEFAULT])
  610. AS_VAR_IF([mhd_w32_ver_preselect],["yes"],
  611. [
  612. AC_MSG_CHECKING([[for specified target W32 version]])
  613. AS_UNSET([[mhd_w32_ver]])
  614. AS_UNSET([[mhd_w32_ver_msg]])
  615. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  616. #if _WIN32_WINNT+0 < 0x0501
  617. /* Check before headers inclusion */
  618. #error _WIN32_WINNT is less than 0x0501
  619. choke me now;
  620. #endif
  621. #ifdef HAVE_SDKDDKVER_H
  622. #include <sdkddkver.h>
  623. #endif
  624. #ifdef HAVE_WINDOWS_H
  625. #include <windows.h>
  626. #endif
  627. #if _WIN32_WINNT+0 < 0x0501
  628. #error _WIN32_WINNT is less than 0x0501
  629. choke me now;
  630. #endif
  631. ]],[[(void)0]])
  632. ], [], [
  633. AC_MSG_RESULT([[pre-WinXP]])
  634. AC_MSG_ERROR([[libmicrohttpd cannot be compiled for Windows version before Windows XP]])
  635. ]
  636. )
  637. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  638. #ifdef HAVE_SDKDDKVER_H
  639. #include <sdkddkver.h>
  640. #endif
  641. #ifdef HAVE_WINDOWS_H
  642. #include <windows.h>
  643. #endif
  644. #if _WIN32_WINNT+0 == 0x0501
  645. #error _WIN32_WINNT is 0x0501
  646. choke me now;
  647. #endif
  648. #if _WIN32_WINNT+0 == 0x0502
  649. #error _WIN32_WINNT is 0x0502
  650. choke me now;
  651. #endif
  652. ]],[[(void)0]])
  653. ], [], [
  654. mhd_w32_ver="WinXP"
  655. mhd_w32_ver_msg="WinXP (selected by precompiler flags)"
  656. ]
  657. )
  658. AS_VAR_SET_IF([mhd_w32_ver], [],
  659. [
  660. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  661. #ifdef HAVE_SDKDDKVER_H
  662. #include <sdkddkver.h>
  663. #endif
  664. #ifdef HAVE_WINDOWS_H
  665. #include <windows.h>
  666. #endif
  667. #if _WIN32_WINNT+0 < 0x0600
  668. #error _WIN32_WINNT is less than 0x0600 but greater than 0x0502
  669. choke me now;
  670. #endif
  671. ]],[[(void)0]])
  672. ], [], [
  673. AC_MSG_ERROR([[_WIN32_WINNT value is wrong (less than 0x0600 but greater than 0x0502)]])
  674. ]
  675. )
  676. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  677. #ifdef HAVE_SDKDDKVER_H
  678. #include <sdkddkver.h>
  679. #endif
  680. #ifdef HAVE_WINDOWS_H
  681. #include <windows.h>
  682. #endif
  683. #if _WIN32_WINNT+0 == 0x0600
  684. #error _WIN32_WINNT is 0x0600
  685. choke me now;
  686. #endif
  687. ]],[[(void)0]])
  688. ], [], [
  689. mhd_w32_ver="Vista"
  690. mhd_w32_ver_msg="Vista (selected by precompiler flags)"
  691. ]
  692. )
  693. ]
  694. )
  695. AS_VAR_SET_IF([mhd_w32_ver], [],
  696. [
  697. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  698. #ifdef HAVE_SDKDDKVER_H
  699. #include <sdkddkver.h>
  700. #endif
  701. #ifdef HAVE_WINDOWS_H
  702. #include <windows.h>
  703. #endif
  704. #if _WIN32_WINNT+0 > 0x0600
  705. #error _WIN32_WINNT is greater than 0x0600
  706. choke me now;
  707. #endif
  708. ]],[[(void)0]])
  709. ], [
  710. mhd_w32_ver="unknown"
  711. mhd_w32_ver_msg="unknown (cannot be detected)"
  712. ], [
  713. mhd_w32_ver="newer than Vista"
  714. mhd_w32_ver_msg="newer than Vista (selected by precompiler flags)"
  715. ]
  716. )
  717. ]
  718. )
  719. AC_MSG_RESULT([[${mhd_w32_ver}]])
  720. ], [
  721. mhd_w32_ver="Vista"
  722. mhd_w32_ver_msg="Vista (default, override by CPPFLAGS=-D_WIN32_WINNT=0xNNNN)"
  723. CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600"
  724. AC_MSG_CHECKING([[whether headers accept _WIN32_WINNT=0x0600]])
  725. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  726. #ifdef HAVE_SDKDDKVER_H
  727. #include <sdkddkver.h>
  728. #endif
  729. #ifdef HAVE_WINDOWS_H
  730. #include <windows.h>
  731. #endif
  732. #include <stdio.h>
  733. ]],[[(void)0]])
  734. ], [
  735. AC_MSG_RESULT([[yes]])
  736. ], [
  737. AC_MSG_RESULT([[no]])
  738. AC_MSG_ERROR([Headers do not accept _WIN32_WINNT=0x0600. Consider override target W32 version by CPPFLAGS=-D_WIN32_WINNT=0xNNNN])
  739. ]
  740. )
  741. ]
  742. )
  743. ]
  744. )
  745. AS_IF([test "x${os_is_windows}" = "xyes" && test "x${os_is_native_w32}" = "xyes"],
  746. [
  747. AC_CACHE_CHECK([W32 run-time library type], [mhd_cv_wctr_type],
  748. [
  749. AC_EGREP_CPP([MHDMARKER: UCRT run-time library in use!], [
  750. #include <stdio.h>
  751. #if defined(_UCRT)
  752. #define CRT_STR "MHDMARKER: UCRT run-time library in use!"
  753. #endif
  754. #if defined(__MSVCRT_VERSION__)
  755. #if (__MSVCRT_VERSION__ >= 0xE00) && (__MSVCRT_VERSION__ < 0x1000)
  756. #define CRT_STR "MHDMARKER: UCRT run-time library in use!"
  757. #endif
  758. #if (__MSVCRT_VERSION__ > 0x1400)
  759. #define CRT_STR "MHDMARKER: UCRT run-time library in use!"
  760. #endif
  761. #endif
  762. #ifndef CRT_STR
  763. #define CRT_STR "MHDMARKER: MSVCRT run-time library in use!"
  764. #endif
  765. int main(void)
  766. {
  767. printf ("%\n", CRT_STR);
  768. return 0;
  769. }
  770. ],
  771. [mhd_cv_wctr_type="ucrt"], [mhd_cv_wctr_type="msvcrt"])
  772. ]
  773. )
  774. mhd_host_os="${mhd_host_os}-${mhd_cv_wctr_type}"
  775. AS_VAR_IF([mhd_cv_wctr_type], ["msvcrt"],
  776. [
  777. AX_APPEND_COMPILE_FLAGS([-U__USE_MINGW_ANSI_STDIO -D__USE_MINGW_ANSI_STDIO=0], [CPPFLAGS])
  778. AC_SUBST([W32CRT], [MSVCRT])
  779. ], [AC_SUBST([W32CRT], [UCRT])]
  780. )
  781. ]
  782. )
  783. AC_ARG_WITH([threads],
  784. [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto, none) [auto]])],
  785. [], [with_threads='auto'])
  786. AS_CASE([[$with_threads]],
  787. [[win32]], [[with_threads='w32']],
  788. [[pthreads]], [[with_threads='posix']],
  789. [[posix]], [[:]],
  790. [[w32]], [[:]],
  791. [[none]], [[with_threads='none']],
  792. [[no]], [[with_threads='none']],
  793. [[auto]], [[:]],
  794. [AC_MSG_ERROR([[incorrect parameter "$with_threads" specified for --with-threads]])]
  795. )
  796. # Check for posix threads support, regardless of configure parameters as
  797. # testsuite uses only posix threads.
  798. AX_PTHREAD(
  799. [
  800. mhd_have_posix_threads='yes'
  801. AC_DEFINE([[HAVE_PTHREAD_H]],[[1]],[Define to 1 if you have the <pthread.h> header file.])
  802. AC_CACHE_CHECK([[whether pthread_sigmask(3) is available]],
  803. [[mhd_cv_func_pthread_sigmask]], [dnl
  804. save_LIBS="$LIBS"
  805. save_CFLAGS="$CFLAGS"
  806. LIBS="$PTHREAD_LIBS $LIBS"
  807. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  808. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]],
  809. [[
  810. sigset_t nset, oset;
  811. sigemptyset (&nset);
  812. sigaddset (&nset, SIGPIPE);
  813. if (0 != pthread_sigmask(SIG_BLOCK, &nset, &oset)) return 1;
  814. ]])],
  815. [[mhd_cv_func_pthread_sigmask="yes"]],[[mhd_cv_func_pthread_sigmask="no"]])
  816. LIBS="${save_LIBS}"
  817. CFLAGS="${save_CFLAGS}"
  818. ])
  819. AS_VAR_IF([mhd_cv_func_pthread_sigmask],["yes"],
  820. [AC_DEFINE([[HAVE_PTHREAD_SIGMASK]],[[1]],[Define to 1 if you have the pthread_sigmask(3) function.])])
  821. ],[[mhd_have_posix_threads='no']])
  822. AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$mhd_have_posix_threads" = "xyes"])
  823. mhd_have_w32_threads='no'
  824. AS_IF([[test "x$with_threads" = "xauto"]],
  825. [
  826. AS_IF([[test "x$os_is_windows" = "xyes"]],
  827. [
  828. AC_MSG_CHECKING([[for W32 threads]])
  829. AC_LINK_IFELSE(
  830. [AC_LANG_PROGRAM([[
  831. #include <windows.h>
  832. ]], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])]
  833. , [[mhd_have_w32_threads='yes']], [[mhd_have_w32_threads='no']]
  834. )
  835. AC_MSG_RESULT([[$mhd_have_w32_threads]])
  836. ])
  837. ]
  838. )
  839. AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd ($with_threads)]])
  840. AS_IF([test "x$with_threads" = "xposix"],
  841. [ # forced posix threads
  842. AS_IF([test "x$mhd_have_posix_threads" = "xyes"], [USE_THREADS='posix'],
  843. [ AS_IF([[test "x$os_is_windows" = "xyes"]] ,
  844. [ AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]])],
  845. [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]])] )
  846. ])
  847. ])
  848. AS_IF([test "x$with_threads" = "xw32"],
  849. [ # forced w32 threads
  850. AS_IF([[test "x$mhd_have_w32_threads" = "xyes"]],
  851. [[ USE_THREADS='w32' ]],
  852. [ AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]])])
  853. ])
  854. AS_IF([test "x$with_threads" = "xauto"],
  855. [# automatic threads lib selection
  856. AS_IF([[test "x$os_is_native_w32" = "xyes" && test "x$mhd_have_w32_threads" = "xyes"]] ,
  857. [[ USE_THREADS='w32' ]] ,
  858. [[ test "x$mhd_have_posix_threads" = "xyes" ]], [[ USE_THREADS='posix' ]],
  859. [[ test "x$mhd_have_w32_threads" = "xyes" ]], [[ USE_THREADS='w32' ]],
  860. [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]]) ]
  861. )])
  862. AS_IF([test "x$with_threads" = "xnone"],
  863. [USE_THREADS='none'])
  864. AS_IF([test "x$USE_THREADS" = "xposix"],
  865. [CC="$PTHREAD_CC"
  866. AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads])
  867. MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS"
  868. MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS"
  869. MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG"],
  870. [AS_IF([test "x$USE_THREADS" = "xw32"],
  871. [AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads])])])
  872. AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"])
  873. AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"])
  874. AM_CONDITIONAL([USE_THREADS], [test "x$USE_THREADS" != "xnone"])
  875. AM_CONDITIONAL([DISABLE_THREADS], [test "x$USE_THREADS" = "xnone"])
  876. AC_MSG_RESULT([$USE_THREADS])
  877. AC_ARG_ENABLE([[thread-names]],
  878. [AS_HELP_STRING([--disable-thread-names],[do not set names on MHD generated threads [auto]])],
  879. [], [enable_thread_names='auto'])
  880. AS_IF([test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix"],[
  881. # Check for thread name function
  882. HAVE_THREAD_NAME_FUNC="no"
  883. SAVE_LIBS="$LIBS"
  884. SAVE_CFLAGS="$CFLAGS"
  885. LIBS="$PTHREAD_LIBS $LIBS"
  886. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  887. AC_CHECK_HEADERS([pthread_np.h],[],[],
  888. [
  889. AC_INCLUDES_DEFAULT
  890. [
  891. #include <pthread.h>
  892. ]
  893. ])
  894. # Try to find how to set thread name by thread attributes.
  895. # If pthread_attr_setname_np(3) is not declared, it's not possible to detect
  896. # form of pthread_attr_setname_np(3) due to C "feature" "implicit declaration".
  897. AC_CHECK_DECL([[pthread_attr_setname_np]],[],[],[[
  898. #include <pthread.h>
  899. #ifdef HAVE_PTHREAD_NP_H
  900. #include <pthread_np.h>
  901. #endif
  902. ]])
  903. AS_IF([[test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]],
  904. [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in NetBSD or OSF1 form]])
  905. AC_LINK_IFELSE(
  906. [AC_LANG_PROGRAM([[
  907. #include <pthread.h>
  908. #ifdef HAVE_PTHREAD_NP_H
  909. #include <pthread_np.h>
  910. #endif
  911. ]], [[
  912. pthread_attr_t thr_attr;
  913. pthread_attr_init(&thr_attr);
  914. pthread_attr_setname_np(&thr_attr, "name", 0);
  915. pthread_attr_destroy(&thr_attr);
  916. ]])],
  917. [AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_attr_setname_np(3) function.])
  918. HAVE_THREAD_NAME_FUNC="yes"
  919. AC_MSG_RESULT([[yes]])],
  920. [AC_MSG_RESULT([[no]])]
  921. )
  922. ])
  923. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]],
  924. [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in IBM i or Solaris form]])
  925. AC_LINK_IFELSE(
  926. [AC_LANG_PROGRAM([[
  927. #include <pthread.h>
  928. #ifdef HAVE_PTHREAD_NP_H
  929. #include <pthread_np.h>
  930. #endif
  931. ]], [[
  932. pthread_attr_t thr_attr;
  933. pthread_attr_init(&thr_attr);
  934. pthread_attr_setname_np(&thr_attr, "name");
  935. pthread_attr_destroy(&thr_attr);
  936. ]])],
  937. [AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI]], [[1]], [Define if you have IBM i form (or Solaris form) of pthread_attr_setname_np(3) function.])
  938. HAVE_THREAD_NAME_FUNC="yes"
  939. AC_MSG_RESULT([[yes]])],
  940. [AC_MSG_RESULT([[no]])]
  941. )
  942. ])
  943. # Try to find how to set thread name for started thread - less convenient
  944. # than setting name by attributes.
  945. # If pthread_setname_np(3) is not declared, it's not possible to detect
  946. # form of pthread_setname_np(3) due to C "feature" "implicit declaration".
  947. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]],
  948. [AC_CHECK_DECL([[pthread_setname_np]],[],[],[[
  949. #include <pthread.h>
  950. #ifdef HAVE_PTHREAD_NP_H
  951. #include <pthread_np.h>
  952. #endif
  953. ]])
  954. ])
  955. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  956. [AC_MSG_CHECKING([[for pthread_setname_np(3) in NetBSD or OSF1 form]])
  957. AC_LINK_IFELSE(
  958. [AC_LANG_PROGRAM([[
  959. #include <pthread.h>
  960. #ifdef HAVE_PTHREAD_NP_H
  961. #include <pthread_np.h>
  962. #endif
  963. ]], [[int res = pthread_setname_np(pthread_self(), "name", 0); if (res) return res;]])],
  964. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_setname_np(3) function.])
  965. HAVE_THREAD_NAME_FUNC="yes"
  966. AC_MSG_RESULT([[yes]])],
  967. [AC_MSG_RESULT([[no]])]
  968. )
  969. ])
  970. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  971. [AC_MSG_CHECKING([[for pthread_setname_np(3) in GNU/Linux form]])
  972. AC_LINK_IFELSE(
  973. [AC_LANG_PROGRAM([[
  974. #include <pthread.h>
  975. #ifdef HAVE_PTHREAD_NP_H
  976. #include <pthread_np.h>
  977. #endif
  978. ]], [[int res = pthread_setname_np(pthread_self(), "name"); if (res) return res;]])],
  979. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_GNU]], [[1]], [Define if you have GNU/Linux form of pthread_setname_np(3) function.])
  980. HAVE_THREAD_NAME_FUNC="yes"
  981. AC_MSG_RESULT([[yes]])],
  982. [AC_MSG_RESULT([[no]])]
  983. )
  984. ])
  985. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  986. [AC_MSG_CHECKING([[for pthread_setname_np(3) in Darwin form]])
  987. AC_LINK_IFELSE(
  988. [AC_LANG_PROGRAM([[
  989. #include <pthread.h>
  990. #ifdef HAVE_PTHREAD_NP_H
  991. #include <pthread_np.h>
  992. #endif
  993. ]], [[int res = pthread_setname_np("name"); if (res) return res;]])],
  994. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_DARWIN]], [[1]], [Define if you have Darwin form of pthread_setname_np(3) function.])
  995. HAVE_THREAD_NAME_FUNC="yes"
  996. AC_MSG_RESULT([[yes]])],
  997. [AC_MSG_RESULT([[no]])]
  998. )
  999. ])
  1000. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]],
  1001. [
  1002. AC_CHECK_DECL([[pthread_set_name_np]],
  1003. [
  1004. AC_MSG_CHECKING([[for pthread_set_name_np(3) in FreeBSD form]])
  1005. AC_LINK_IFELSE(
  1006. [AC_LANG_PROGRAM([[
  1007. #include <pthread.h>
  1008. #ifdef HAVE_PTHREAD_NP_H
  1009. #include <pthread_np.h>
  1010. #endif
  1011. ]], [[pthread_set_name_np(pthread_self(), "name");]])],
  1012. [AC_DEFINE([[HAVE_PTHREAD_SET_NAME_NP_FREEBSD]], [[1]], [Define if you have FreeBSD form of pthread_set_name_np(3) function.])
  1013. HAVE_THREAD_NAME_FUNC="yes"
  1014. AC_MSG_RESULT([[yes]])],
  1015. [AC_MSG_RESULT([[no]])]
  1016. )
  1017. ],[],[[
  1018. #include <pthread.h>
  1019. #ifdef HAVE_PTHREAD_NP_H
  1020. #include <pthread_np.h>
  1021. #endif
  1022. ]]
  1023. )
  1024. ])
  1025. LIBS="$SAVE_LIBS"
  1026. CFLAGS="$SAVE_CFLAGS"
  1027. ])
  1028. AS_IF([[test "x$enable_thread_names" != "xno"]],
  1029. [
  1030. AC_MSG_CHECKING([[whether to enable thread names]])
  1031. AC_COMPILE_IFELSE(
  1032. [AC_LANG_PROGRAM([], [[
  1033. #ifdef MHD_NO_THREAD_NAMES
  1034. #error Thread names are disabled.
  1035. choke me
  1036. #endif
  1037. /* Keep in sync with mhd_threads.h */
  1038. #if defined(MHD_USE_POSIX_THREADS) && (defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) || \
  1039. defined(HAVE_PTHREAD_SETNAME_NP_GNU) || defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || \
  1040. defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) )
  1041. (void) 0; /* no-op */
  1042. #elif defined(MHD_USE_W32_THREADS) && defined(_MSC_FULL_VER)
  1043. (void) 0; /* no-op */
  1044. #else
  1045. #error No thread name function is available.
  1046. choke me
  1047. #endif
  1048. ]])
  1049. ], [
  1050. enable_thread_names='yes'
  1051. ], [
  1052. AS_IF([[test "x$enable_thread_names" = "xyes"]],
  1053. [
  1054. AC_MSG_RESULT([[no]])
  1055. AC_MSG_ERROR([[thread names was explicitly requested, but thread name function is not available]])
  1056. ])
  1057. enable_thread_names='no'
  1058. ])
  1059. AC_MSG_RESULT([[$enable_thread_names]])
  1060. ])
  1061. AS_IF([[test "x$enable_thread_names" = "xno"]],
  1062. [AC_DEFINE([[MHD_NO_THREAD_NAMES]], [[1]], [Define to 1 to disable setting name on generated threads])])
  1063. AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"])
  1064. w32_shared_lib_exp=no
  1065. AS_IF([test "x$enable_shared" = "xyes" && test "x$os_is_native_w32" = "xyes"],
  1066. [
  1067. AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes" || test -n "$DLLTOOL"],
  1068. [
  1069. w32_shared_lib_exp=yes
  1070. use_expfile="no"
  1071. AS_VAR_IF([ac_cv_use_ms_lib_tool], ["yes"], [use_expfile="yes"],
  1072. [
  1073. AC_CACHE_CHECK([whether $DLLTOOL supports export file generation], [mhd_cv_dlltool_expfile],
  1074. [
  1075. AS_IF([AC_RUN_LOG([$DLLTOOL -e conftest.exp >&2 ])],
  1076. [
  1077. AS_IF([test -f conftest.exp], [mhd_cv_dlltool_expfile="yes"], [mhd_cv_dlltool_expfile="no"])
  1078. ], [mhd_cv_dlltool_expfile="no"]
  1079. )
  1080. rm -f conftest.exp
  1081. ]
  1082. )
  1083. use_expfile="${mhd_cv_dlltool_expfile}"
  1084. ]
  1085. )
  1086. ],
  1087. [
  1088. AC_MSG_WARN([[GNU dlltool or MS lib.exe is required for creating shared library export on W32]])
  1089. AC_MSG_WARN([[Export library libmicrohttpd.lib will not be created]])
  1090. ]
  1091. )
  1092. ]
  1093. )
  1094. AM_CONDITIONAL([W32_SHARED_LIB_EXP], [test "x$w32_shared_lib_exp" = "xyes"])
  1095. AM_CONDITIONAL([USE_MS_LIB_TOOL], [test "x$ac_cv_use_ms_lib_tool" = "xyes"])
  1096. AM_CONDITIONAL([USE_EXPORT_FILE], [test "x$use_expfile" = "xyes"])
  1097. MHD_FIND_LIB([socket],
  1098. [[
  1099. #ifdef HAVE_SYS_TYPES_H
  1100. #include <sys/types.h>
  1101. #endif
  1102. #ifdef HAVE_SYS_SOCKET_H
  1103. #include <sys/socket.h>
  1104. #endif
  1105. #ifdef HAVE_SOCKLIB_H
  1106. #include <sockLib.h>
  1107. #endif
  1108. #if defined(_WIN32) && ! defined(__CYGWIN__)
  1109. #include <winsock2.h>
  1110. #endif
  1111. ]],
  1112. [(void)socket(0, 0, 0);],
  1113. [socket ws2_32 xnet],
  1114. [
  1115. AS_VAR_IF([[mhd_cv_find_lib_socket]],[["none required"]], [],
  1116. [
  1117. MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_socket} $MHD_LIBDEPS_PKGCFG"
  1118. ]
  1119. )
  1120. ],
  1121. [AC_MSG_ERROR([[cannot find header or library required for function socket()]])]
  1122. )
  1123. MHD_CHECK_SOCKET_SHUTDOWN_TRIGGER([AC_DEFINE([HAVE_LISTEN_SHUTDOWN],[1],[can use shutdown on listen sockets])])
  1124. AM_CONDITIONAL([HAVE_LISTEN_SHUTDOWN], [test "x$mhd_cv_host_shtdwn_trgr_select" = "xyes"])
  1125. MHD_CHECK_FUNC([writev],
  1126. [[#include <sys/uio.h>]],
  1127. [[
  1128. struct iovec iov[2];
  1129. char some_str[4] = "OK\n";
  1130. iov[0].iov_base = (void *) some_str;
  1131. iov[0].iov_len = 3;
  1132. i][f (0 > writev(1, iov, 1))
  1133. return 2;
  1134. ]]
  1135. )
  1136. MHD_FIND_LIB([sendmsg],
  1137. [[
  1138. #ifdef HAVE_SYS_TYPES_H
  1139. #include <sys/types.h>
  1140. #endif
  1141. #ifdef HAVE_SYS_SOCKET_H
  1142. #include <sys/socket.h>
  1143. #endif
  1144. #ifdef HAVE_SOCKLIB_H
  1145. #include <sockLib.h>
  1146. #endif
  1147. #ifdef HAVE_SYS_UIO_H
  1148. #include <sys/uio.h>
  1149. #endif
  1150. ]],
  1151. [[
  1152. struct msghdr msg;
  1153. struct iovec iov;
  1154. unsigned int i;
  1155. char some_str[5] = "test";
  1156. iov.iov_base = (void*)some_str;
  1157. iov.iov_len = 4;
  1158. for (i = 0; i < (unsigned int) sizeof(msg); i++)
  1159. {
  1160. *(((unsigned char *)&msg) + i) = 0;
  1161. }
  1162. msg.msg_iov = &iov;
  1163. msg.msg_iovlen = 1;
  1164. i][f (0 > sendmsg(1, &msg, 0))
  1165. return -1;
  1166. ]],
  1167. [socket],
  1168. [
  1169. AC_DEFINE([HAVE_SENDMSG],[1],[Define to '1' if your have sendmsg() function])
  1170. AS_VAR_IF([[mhd_cv_find_lib_sendmsg]],[["none required"]], [],
  1171. [
  1172. MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_sendmsg} $MHD_LIBDEPS_PKGCFG"
  1173. ]
  1174. )
  1175. ],[],
  1176. [MHD_LIBDEPS]
  1177. )
  1178. # set GCC options
  1179. # use '-fno-strict-aliasing', but only if the compiler
  1180. # and linker can take it
  1181. AX_CHECK_LINK_FLAG([-fno-strict-aliasing],
  1182. [AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing])])
  1183. AC_C_BIGENDIAN
  1184. AC_C_VARARRAYS
  1185. AC_CACHE_CHECK([[whether __func__ magic-macro is available]],
  1186. [[mhd_cv_macro___func___avail]], [dnl
  1187. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]],[[const char *funcname = __func__ ; if (NULL == funcname) return 1;]])],
  1188. [[mhd_cv_macro___func___avail="yes"]],[[mhd_cv_macro___func___avail="no"]])
  1189. ])
  1190. AS_VAR_IF([mhd_cv_macro___func___avail], ["yes"],
  1191. [AC_DEFINE([HAVE___FUNC__], [1], [Define to 1 if your compiler supports __func__ magic-macro.])],
  1192. [
  1193. AC_CACHE_CHECK([[whether __FUNCTION__ magic-macro is available]],
  1194. [[mhd_cv_macro___function___avail]], [dnl
  1195. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]],[[const char *funcname = __FUNCTION__ ; if (NULL == funcname) return 1;]])],
  1196. [[mhd_cv_macro___function___avail="yes"]],[[mhd_cv_macro___function___avail="no"]])
  1197. ])
  1198. AS_VAR_IF([mhd_cv_macro___function___avail], ["yes"],
  1199. [AC_DEFINE([HAVE___FUNCTION__], [1], [Define to 1 if your compiler supports __FUNCTION__ magic-macro.])],
  1200. [
  1201. AC_CACHE_CHECK([[whether __PRETTY_FUNCTION__ magic-macro is available]],
  1202. [[mhd_cv_macro___pretty_function___avail]], [dnl
  1203. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]],[[const char *funcname = __PRETTY_FUNCTION__ ; if (NULL == funcname) return 1;]])],
  1204. [[mhd_cv_macro___pretty_function___avail="yes"]],[[mhd_cv_macro___pretty_function___avail="no"]])
  1205. ])
  1206. AS_VAR_IF([mhd_cv_macro___pretty_function___avail], ["yes"],
  1207. [AC_DEFINE([HAVE___PRETTY_FUNCTION__], [1], [Define to 1 if your compiler supports __PRETTY_FUNCTION__ magic-macro.])],
  1208. )
  1209. ]
  1210. )
  1211. ]
  1212. )
  1213. AC_CACHE_CHECK([[whether __builtin_bswap32() is available]],
  1214. [[mhd_cv_func___builtin_bswap32_avail]], [dnl
  1215. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint32_t a = 1; uint32_t b = __builtin_bswap32(a); a = b; (void) a;]])],
  1216. [[mhd_cv_func___builtin_bswap32_avail="yes"]],[[mhd_cv_func___builtin_bswap32_avail="no"]])
  1217. ])
  1218. AS_IF([[test "x$mhd_cv_func___builtin_bswap32_avail" = "xyes"]],
  1219. [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP32]], [[1]], [Define to 1 if you have __builtin_bswap32() builtin function])])
  1220. AC_CACHE_CHECK([[whether __builtin_bswap64() is available]],
  1221. [[mhd_cv_func___builtin_bswap64_avail]], [dnl
  1222. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint64_t a = 1; uint64_t b = __builtin_bswap64(a); a = b; (void) a;]])],
  1223. [[mhd_cv_func___builtin_bswap64_avail="yes"]], [[mhd_cv_func___builtin_bswap64_avail="no"]])
  1224. ])
  1225. AS_IF([[test "x$mhd_cv_func___builtin_bswap64_avail" = "xyes"]],
  1226. [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP64]], [[1]], [Define to 1 if you have __builtin_bswap64() builtin function])])
  1227. AC_CHECK_PROG([HAVE_CURL_BINARY],[curl],[yes],[no])
  1228. AM_CONDITIONAL([HAVE_CURL_BINARY],[test "x$HAVE_CURL_BINARY" = "xyes"])
  1229. AC_CHECK_PROG([HAVE_MAKEINFO_BINARY],[makeinfo],[yes],[no])
  1230. AM_CONDITIONAL([HAVE_MAKEINFO_BINARY],[test "x$HAVE_MAKEINFO_BINARY" = "xyes"])
  1231. AM_CONDITIONAL(W32_STATIC_LIB, [test "x$os_is_native_w32" = "xyes" && test "x$enable_static" = "xyes"])
  1232. AC_ARG_ENABLE([[doc]],
  1233. [AS_HELP_STRING([[--disable-doc]], [do not build any documentation])], ,
  1234. [enable_doc=yes])
  1235. test "x$enable_doc" = "xno" || enable_doc=yes
  1236. AM_CONDITIONAL([BUILD_DOC], [test "x$enable_doc" = "xyes"])
  1237. AC_ARG_ENABLE([[examples]],
  1238. [AS_HELP_STRING([[--disable-examples]], [do not build any examples])], ,
  1239. [enable_examples=yes])
  1240. test "x$enable_examples" = "xno" || enable_examples=yes
  1241. AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" = "xyes"])
  1242. AC_ARG_ENABLE([[heavy-tests]],
  1243. [AS_HELP_STRING([[--enable-heavy-tests]], [use heavy tests in test-suite. WARNING:]
  1244. [a dedicated host with minimal number of background processes and no network]
  1245. [activity is recommended to enable.])], [],
  1246. [enable_heavy_tests=no])
  1247. AS_VAR_IF([enable_heavy_tests], ["yes"],
  1248. [
  1249. HEAVY_TESTS_NOTPARALLEL='.NOTPARALLEL:'
  1250. AC_DEFINE([_MHD_HEAVY_TESTS], [1], [Define to 1 to enable "heavy" test paths.])
  1251. ],
  1252. [
  1253. enable_heavy_tests=no
  1254. HEAVY_TESTS_NOTPARALLEL=" "
  1255. ]
  1256. )
  1257. AM_CONDITIONAL([HEAVY_TESTS],[test "x$enable_heavy_tests" = "xyes"])
  1258. AM_CONDITIONAL([TESTS_STRESS_OS],[false])
  1259. AC_ARG_ENABLE([[poll]],
  1260. [AS_HELP_STRING([[--enable-poll[=ARG]]], [enable poll support (yes, no, auto) [auto]])],
  1261. [enable_poll=${enableval}],
  1262. [enable_poll='auto']
  1263. )
  1264. AS_IF([test "$enable_poll" != "no"],
  1265. [
  1266. AS_IF([test "$os_is_native_w32" != "yes"],
  1267. [
  1268. AC_CHECK_HEADERS([poll.h],
  1269. [
  1270. MHD_CHECK_FUNC([poll],
  1271. [[
  1272. #include <poll.h>
  1273. ]],
  1274. [[
  1275. struct pollfd fds[2];
  1276. fds[0].fd = 0;
  1277. fds[0].events = POLLIN;
  1278. if (0 > poll(fds, 1, 0))
  1279. return 2;
  1280. ]],
  1281. [have_poll='yes'], [have_poll='no']
  1282. )
  1283. ], [], [AC_INCLUDES_DEFAULT]
  1284. )
  1285. ],
  1286. [
  1287. MHD_CHECK_FUNC([WSAPoll],
  1288. [[
  1289. #include <winsock2.h>
  1290. ]],
  1291. [[
  1292. WSAPOLLFD fda[2];
  1293. WSAPoll(fda, 2, 0);
  1294. ]],
  1295. [
  1296. have_poll='yes'
  1297. AC_DEFINE([HAVE_POLL],[1])
  1298. ],
  1299. [have_poll='no']
  1300. )
  1301. ]
  1302. )
  1303. AS_IF([test "$enable_poll" = "yes" && test "$have_poll" != "yes"],
  1304. [AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]])])
  1305. enable_poll="$have_poll"
  1306. ]
  1307. )
  1308. AC_ARG_ENABLE([[epoll]],
  1309. [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])],
  1310. [enable_epoll=${enableval}],
  1311. [enable_epoll='auto']
  1312. )
  1313. AS_IF([test "$enable_epoll" != "no"],
  1314. [
  1315. AX_HAVE_EPOLL
  1316. AS_IF([test "${ax_cv_have_epoll}" = "yes"],
  1317. [
  1318. AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll support])
  1319. enable_epoll='yes'
  1320. ],
  1321. [
  1322. AS_IF([test "$enable_epoll" = "yes"],
  1323. [AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]])]
  1324. )
  1325. enable_epoll='no'
  1326. ]
  1327. )
  1328. ]
  1329. )
  1330. AM_CONDITIONAL([MHD_HAVE_EPOLL], [[test "x$enable_epoll" = xyes]])
  1331. AS_IF([test "x$enable_epoll" = "xyes"],
  1332. [
  1333. MHD_CHECK_FUNC([epoll_create1],
  1334. [[
  1335. #include <sys/epoll.h>
  1336. ]],
  1337. [[
  1338. i][f (0 > epoll_create1(EPOLL_CLOEXEC))
  1339. return 3;
  1340. ]]
  1341. )
  1342. ]
  1343. )
  1344. AC_CACHE_CHECK([for suported 'noreturn' keyword], [mhd_cv_decl_noreturn],
  1345. [
  1346. mhd_cv_decl_noreturn="none"
  1347. save_CFLAGS="${CFLAGS}"
  1348. CFLAGS="${CFLAGS} ${errattr_CFLAGS}"
  1349. for decl_noret in '_Noreturn' '__attribute__((__noreturn__))' '__declspec(noreturn)'
  1350. do
  1351. AC_LINK_IFELSE([AC_LANG_SOURCE(
  1352. [[
  1353. #ifdef HAVE_STDLIB_H
  1354. #include <stdlib.h>
  1355. #endif
  1356. ${decl_noret} static void myexitfunc(int code)
  1357. {
  1358. #ifdef HAVE_STDLIB_H
  1359. exit (code);
  1360. #else
  1361. (void)code;
  1362. #endif
  1363. }
  1364. int main (int argc, char *const *argv)
  1365. {
  1366. (void) argv;
  1367. if (argc > 2)
  1368. myexitfunc (2);
  1369. return 0;
  1370. }
  1371. ]]
  1372. )], [mhd_cv_decl_noreturn="${decl_noret}"]
  1373. )
  1374. AS_IF([test "x${mhd_cv_decl_noreturn}" != "xnone"], [break])
  1375. done
  1376. CFLAGS="${save_CFLAGS}"
  1377. ]
  1378. )
  1379. AS_VAR_IF([mhd_cv_decl_noreturn], ["none"],
  1380. [AC_DEFINE([_MHD_NORETURN], [], [Define to supported 'noreturn' function declaration])],
  1381. [AC_DEFINE_UNQUOTED([_MHD_NORETURN], [${mhd_cv_decl_noreturn}], [Define to supported 'noreturn' function declaration])]
  1382. )
  1383. # Check for types sizes
  1384. # Types sizes are used as an indirect indication of maximum allowed values for types
  1385. # which is used to exclude by preprocessor some compiler checks for values clips
  1386. # Assuming no staffing or uniform staffing for integer types
  1387. AC_CACHE_CHECK([size of tv_sec member of struct timeval], [mhd_cv_size_timeval_tv_sec],
  1388. [
  1389. AC_COMPUTE_INT([mhd_cv_size_timeval_tv_sec], [((long int)sizeof(test_var.tv_sec))],
  1390. [[
  1391. #ifdef HAVE_SYS_TIME_H
  1392. #include <sys/time.h>
  1393. #endif /* HAVE_SYS_TIME_H */
  1394. #ifdef HAVE_TIME_H
  1395. #include <time.h>
  1396. #endif /* HAVE_TIME_H */
  1397. #if HAVE_SYS_TYPES_H
  1398. #include <sys/types.h>
  1399. #endif /* HAVE_SYS_TYPES_H */
  1400. struct timeval test_var;
  1401. ]],
  1402. [
  1403. # The size is used only to exclude additional checks/comparison in code
  1404. # to avoid compiler warnings. With larger size MHD code will use
  1405. # additional checks which ensure that value will fit but it may produce
  1406. # a harmless compiler warning.
  1407. AC_MSG_WARN([The size cannot be determined, assuming 8.])
  1408. mhd_cv_size_timeval_tv_sec=8
  1409. ]
  1410. )
  1411. ]
  1412. )
  1413. AC_DEFINE_UNQUOTED([SIZEOF_STRUCT_TIMEVAL_TV_SEC], [$mhd_cv_size_timeval_tv_sec],
  1414. [The size of `tv_sec' member of `struct timeval', as computed by sizeof])
  1415. AC_CHECK_SIZEOF([uint64_t], [], [[#include <stdint.h>]])
  1416. AC_CHECK_SIZEOF([unsigned int], [], [[#include <stdint.h>]])
  1417. AC_CHECK_SIZEOF([size_t], [],
  1418. [[
  1419. #ifdef HAVE_STDLIB_H
  1420. #include <stdlib.h>
  1421. #endif /* HAVE_STDLIB_H */
  1422. #ifdef HAVE_STDDEF_H
  1423. #include <stddef.h>
  1424. #endif /* HAVE_STDDEF_H */
  1425. #include <stdio.h>
  1426. ]]
  1427. )
  1428. AC_CHECK_SIZEOF([unsigned long long], [], [[#include <stdint.h>]])
  1429. AC_CHECK_HEADERS([dlfcn.h],[have_tlsplugin=yes],[have_tlsplugin=no], [AC_INCLUDES_DEFAULT])
  1430. AM_CONDITIONAL([MHD_HAVE_TLS_PLUGIN], [[test "x$have_tlsplugin" = xyes]])
  1431. AC_CHECK_HEADERS([zlib.h],[have_zlib=yes],[have_zlib=no], [AC_INCLUDES_DEFAULT])
  1432. AM_CONDITIONAL([HAVE_ZLIB], [[test "x$have_zlib" = xyes]])
  1433. # Check for generic functions
  1434. MHD_CHECK_FUNC([random],
  1435. [
  1436. AC_INCLUDES_DEFAULT
  1437. [#include <stdlib.h>
  1438. ]],
  1439. [[long int r = random(); (void)r;]],
  1440. [],
  1441. [
  1442. MHD_CHECK_FUNC([rand],
  1443. [
  1444. AC_INCLUDES_DEFAULT
  1445. [#include <stdlib.h>
  1446. ]],
  1447. [[int r = rand(); (void)r;]],
  1448. )
  1449. ]
  1450. )
  1451. AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len,
  1452. struct sockaddr_storage.ss_len],
  1453. [], [],
  1454. [
  1455. #ifdef HAVE_SYS_TYPES_H
  1456. #include <sys/types.h>
  1457. #endif
  1458. #ifdef HAVE_SYS_SOCKET_H
  1459. #include <sys/socket.h>
  1460. #endif
  1461. #ifdef HAVE_NETINET_IN_H
  1462. #include <netinet/in.h>
  1463. #endif
  1464. ])
  1465. MHD_CHECK_LINK_RUN([[f][or working getsockname()]],[[mhd_cv_getsockname_usable]],
  1466. [[mhd_cv_getsockname_usable='assuming yes']],
  1467. [
  1468. AC_LANG_SOURCE(
  1469. [[
  1470. #ifdef HAVE_SYS_TYPES_H
  1471. #include <sys/types.h>
  1472. #endif
  1473. #ifdef HAVE_SYS_SOCKET_H
  1474. #include <sys/socket.h>
  1475. #endif
  1476. #ifdef HAVE_UNISTD_H
  1477. #include <unistd.h>
  1478. #endif
  1479. #ifdef HAVE_WINSOCK2_H
  1480. #include <winsock2.h>
  1481. #endif
  1482. #ifdef HAVE_WS2TCPIP_H
  1483. #include <ws2tcpip.h>
  1484. #endif
  1485. #ifdef HAVE_NETINET_IN_H
  1486. #include <netinet/in.h>
  1487. #endif
  1488. #ifdef HAVE_NETINET_IP_H
  1489. #include <netinet/ip.h>
  1490. #endif
  1491. #ifdef HAVE_ARPA_INET_H
  1492. #include <arpa/inet.h>
  1493. #endif
  1494. static void zr_mem(void *ptr, socklen_t size)
  1495. { char *mem = ptr; while(size--) {mem[0] = 0; mem++;} }
  1496. int main(void)
  1497. {
  1498. const socklen_t c_addr_size = (socklen_t)sizeof(struct sockaddr_in);
  1499. struct sockaddr_in sa;
  1500. socklen_t addr_size;
  1501. int ret = 1;
  1502. #if !defined(_WIN32) || defined(__CYGWIN__)
  1503. int sckt;
  1504. const int invld_sckt = -1;
  1505. #else
  1506. SOCKET sckt;
  1507. const SOCKET invld_sckt = INVALID_SOCKET;
  1508. WSADATA wsa_data;
  1509. if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data) || MAKEWORD(2, 2) != wsa_data.wVersion)
  1510. return 20;
  1511. #endif
  1512. sckt = socket (PF_INET, SOCK_STREAM, 0);
  1513. if (invld_sckt != sckt)
  1514. {
  1515. zr_mem(&sa, c_addr_size);
  1516. sa.sin_family = AF_INET;
  1517. #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
  1518. sa.sin_len = c_addr_size;
  1519. #endif
  1520. if (0 == bind (sckt, (struct sockaddr *)&sa, c_addr_size))
  1521. {
  1522. if (0 == listen (sckt, 1))
  1523. {
  1524. addr_size = c_addr_size;
  1525. if (0 == getsockname (sckt, (struct sockaddr *)&sa, &addr_size))
  1526. {
  1527. if (c_addr_size >= addr_size)
  1528. {
  1529. if (0 != ntohs(sa.sin_port))
  1530. { ret = 0;
  1531. } else ret = 7;
  1532. } else ret = 6;
  1533. } else ret = 5;
  1534. } else ret = 4;
  1535. } else ret = 3;
  1536. } else ret = 2;
  1537. #if !defined(_WIN32) || defined(__CYGWIN__)
  1538. close (sckt);
  1539. #else
  1540. closesocket (sckt);
  1541. WSACleanup();
  1542. #endif
  1543. return ret;
  1544. }
  1545. ]]
  1546. )
  1547. ],
  1548. [AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable `getsockname' function.])]
  1549. )
  1550. AC_CACHE_CHECK([for usable PAGESIZE macro], [mhd_cv_macro_pagesize_usable],
  1551. [
  1552. AC_LINK_IFELSE(
  1553. [
  1554. AC_LANG_PROGRAM(
  1555. [[
  1556. #ifdef HAVE_UNISTD_H
  1557. #include <unistd.h>
  1558. #endif
  1559. #ifdef HAVE_LIMITS_H
  1560. #include <limits.h>
  1561. #endif
  1562. #ifdef HAVE_SYS_PARAM_H
  1563. #include <sys/param.h>
  1564. #endif
  1565. #ifndef PAGESIZE
  1566. #error No PAGESIZE macro defined
  1567. choke me now
  1568. #endif
  1569. ]],
  1570. [[
  1571. long pgsz = PAGESIZE + 0;
  1572. if (1 > pgsz) return 1;
  1573. ]]
  1574. )
  1575. ],
  1576. [[mhd_cv_macro_pagesize_usable="yes"]], [[mhd_cv_macro_pagesize_usable="no"]]
  1577. )
  1578. ]
  1579. )
  1580. AS_VAR_IF([[mhd_cv_macro_pagesize_usable]], [["yes"]],
  1581. [
  1582. AC_DEFINE([[MHD_USE_PAGESIZE_MACRO]],[[1]],[Define if you have usable PAGESIZE macro])
  1583. AC_CACHE_CHECK([whether PAGESIZE macro could be used for static init], [mhd_cv_macro_pagesize_usable_static],
  1584. [
  1585. AC_LINK_IFELSE(
  1586. [
  1587. AC_LANG_PROGRAM(
  1588. [[
  1589. #ifdef HAVE_UNISTD_H
  1590. #include <unistd.h>
  1591. #endif
  1592. #ifdef HAVE_LIMITS_H
  1593. #include <limits.h>
  1594. #endif
  1595. #ifdef HAVE_SYS_PARAM_H
  1596. #include <sys/param.h>
  1597. #endif
  1598. #ifndef PAGESIZE
  1599. #error No PAGESIZE macro defined
  1600. choke me now
  1601. #endif
  1602. static long ac_pgsz = PAGESIZE + 0;
  1603. ]],
  1604. [[
  1605. if (1 > ac_pgsz) return 1;
  1606. ]]
  1607. )
  1608. ],
  1609. [[mhd_cv_macro_pagesize_usable_static="yes"]], [[mhd_cv_macro_pagesize_usable_static="no"]]
  1610. )
  1611. ]
  1612. )
  1613. AS_VAR_IF([[mhd_cv_macro_pagesize_usable_static]], [["yes"]],
  1614. [AC_DEFINE([[MHD_USE_PAGESIZE_MACRO_STATIC]],[[1]],[Define if you have PAGESIZE macro usable for static init])]
  1615. )
  1616. ],
  1617. [
  1618. AC_CACHE_CHECK([for usable PAGE_SIZE macro], [mhd_cv_macro_page_size_usable],
  1619. [
  1620. AC_LINK_IFELSE(
  1621. [
  1622. AC_LANG_PROGRAM(
  1623. [[
  1624. #ifdef HAVE_UNISTD_H
  1625. #include <unistd.h>
  1626. #endif
  1627. #ifdef HAVE_LIMITS_H
  1628. #include <limits.h>
  1629. #endif
  1630. #ifdef HAVE_SYS_PARAM_H
  1631. #include <sys/param.h>
  1632. #endif
  1633. #ifndef PAGE_SIZE
  1634. #error No PAGE_SIZE macro defined
  1635. choke me now
  1636. #endif
  1637. ]],
  1638. [[
  1639. long pgsz = PAGE_SIZE + 0;
  1640. if (1 > pgsz) return 1;
  1641. ]]
  1642. )
  1643. ],
  1644. [[mhd_cv_macro_page_size_usable="yes"]], [[mhd_cv_macro_page_size_usable="no"]]
  1645. )
  1646. ]
  1647. )
  1648. AS_VAR_IF([[mhd_cv_macro_page_size_usable]], [["yes"]],
  1649. [
  1650. AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO]],[[1]],[Define if you have usable PAGE_SIZE macro])
  1651. AC_CACHE_CHECK([whether PAGE_SIZE macro could be used for static init], [mhd_cv_macro_page_size_usable_static],
  1652. [
  1653. AC_LINK_IFELSE(
  1654. [
  1655. AC_LANG_PROGRAM(
  1656. [[
  1657. #ifdef HAVE_UNISTD_H
  1658. #include <unistd.h>
  1659. #endif
  1660. #ifdef HAVE_LIMITS_H
  1661. #include <limits.h>
  1662. #endif
  1663. #ifdef HAVE_SYS_PARAM_H
  1664. #include <sys/param.h>
  1665. #endif
  1666. #ifndef PAGE_SIZE
  1667. #error No PAGE_SIZE macro defined
  1668. choke me now
  1669. #endif
  1670. static long ac_pgsz = PAGE_SIZE + 0;
  1671. ]],
  1672. [[
  1673. if (1 > ac_pgsz) return 1;
  1674. ]]
  1675. )
  1676. ],
  1677. [[mhd_cv_macro_page_size_usable_static="yes"]], [[mhd_cv_macro_page_size_usable_static="no"]]
  1678. )
  1679. ]
  1680. )
  1681. AS_VAR_IF([[mhd_cv_macro_page_size_usable_static]], [["yes"]],
  1682. [AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO_STATIC]],[[1]],[Define if you have PAGE_SIZE macro usable for static init])]
  1683. )
  1684. ]
  1685. )
  1686. ]
  1687. )
  1688. # Check for inter-thread signaling type
  1689. AC_ARG_ENABLE([[itc]],
  1690. [AS_HELP_STRING([[--enable-itc=TYPE]], [use TYPE of inter-thread communication (pipe, socketpair, eventfd) [auto]])], [],
  1691. [[enable_itc='auto']]
  1692. )
  1693. AS_CASE([[$enable_itc]],
  1694. [[pipe]], [[:]],
  1695. [[socketpair]], [[:]],
  1696. [[eventfd]], [[:]],
  1697. [[auto]], [AS_VAR_IF([[os_is_windows]], [["yes"]], [[enable_itc='socketpair']])],
  1698. [[eventFD]], [[enable_itc='eventfd']],
  1699. [[socket]], [[enable_itc='socketpair']],
  1700. [[no]], [AC_MSG_ERROR([[inter-thread communication cannot be disabled]])],
  1701. [AC_MSG_ERROR([[unrecognized type "$enable_itc" of inter-thread communication specified by "--enable-itc=$enable_itc"]])]
  1702. )
  1703. AS_UNSET([[use_itc]])
  1704. AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]],
  1705. [
  1706. MHD_CHECK_LINK_RUN([[f][or working eventfd(2)]],[[mhd_cv_eventfd_usable]],[[mhd_cv_eventfd_usable='assuming no']],
  1707. [
  1708. AC_LANG_SOURCE([[
  1709. #include <sys/eventfd.h>
  1710. #include <unistd.h>
  1711. int main(void)
  1712. {
  1713. unsigned char buf[8];
  1714. int ret;
  1715. int efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
  1716. if (0 > efd)
  1717. return 2;
  1718. ret = 0;
  1719. buf[3] = 1;
  1720. if (8 != write(efd, buf, 8))
  1721. ret = 3;
  1722. else
  1723. {
  1724. if (8 != read(efd, buf, 8))
  1725. ret = 4;
  1726. }
  1727. close(efd);
  1728. return ret;
  1729. }
  1730. ]]
  1731. )
  1732. ],
  1733. [
  1734. use_itc='eventfd'
  1735. enable_itc="$use_itc"
  1736. AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for inter-thread communication])
  1737. ],
  1738. [
  1739. AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not usable, consider using other type of inter-thread communication]])])
  1740. ]
  1741. )
  1742. AS_VAR_IF([mhd_cv_eventfd_usable],["assuming no"],
  1743. [AC_MSG_WARN([if you have 'eventfd' support enabled on your target system consider overriding test result by "mhd_cv_eventfd_usable=yes" configure parameter])]
  1744. )
  1745. ]
  1746. )
  1747. AS_IF([[test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto"]], [
  1748. AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
  1749. AC_CACHE_CHECK([[whether pipe(3) is usable]], [[mhd_cv_pipe_usable]], [
  1750. AC_LINK_IFELSE([
  1751. AC_LANG_PROGRAM([
  1752. AC_INCLUDES_DEFAULT
  1753. #ifdef HAVE_UNISTD_H
  1754. #include <unistd.h>
  1755. #endif
  1756. ], [[
  1757. int arr[2];
  1758. int res;
  1759. res = pipe(arr);
  1760. if (res != 0) return 33;
  1761. close (arr[0]);
  1762. close (arr[1]);
  1763. ]])
  1764. ], [[mhd_cv_pipe_usable='yes']], [[mhd_cv_pipe_usable='no']])
  1765. ])
  1766. AS_VAR_IF([[mhd_cv_pipe_usable]], [["yes"]], [
  1767. use_itc='pipe'
  1768. enable_itc="$use_itc"
  1769. AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread communication])
  1770. MHD_CHECK_LINK_RUN([[whether pipe2(2) is usable]],[[mhd_cv_pipe2_usable]],
  1771. [
  1772. # Cross-compiling
  1773. AS_CASE([${host_os}], [kfreebsd*-gnu], [[mhd_cv_pipe2_usable='assuming no']],
  1774. [[mhd_cv_pipe2_usable='assuming yes']])
  1775. ],
  1776. [
  1777. AC_LANG_PROGRAM([
  1778. AC_INCLUDES_DEFAULT
  1779. #ifdef HAVE_FCNTL_H
  1780. #include <fcntl.h>
  1781. #endif
  1782. #ifdef HAVE_UNISTD_H
  1783. #include <unistd.h>
  1784. #endif
  1785. ], [[
  1786. int arr[2];
  1787. int res;
  1788. res = pipe2(arr, O_CLOEXEC | O_NONBLOCK);
  1789. if (res != 0) return 33;
  1790. close (arr[0]);
  1791. close (arr[1]);
  1792. ]]
  1793. )
  1794. ],
  1795. [AC_DEFINE([[HAVE_PIPE2_FUNC]], [[1]], [Define if you have usable pipe2(2) function])]
  1796. )
  1797. ], [
  1798. AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not usable, consider using other type of inter-thread communication]])])
  1799. ])
  1800. ])
  1801. ])
  1802. AS_IF([[test "x$enable_itc" = "xsocketpair" || test "x$enable_itc" = "xauto"]], [
  1803. AS_VAR_IF([[os_is_native_w32]], [["yes"]], [[mhd_cv_socketpair_usable='yes']], [
  1804. AC_CACHE_CHECK([[whether socketpair(3) is usable]], [[mhd_cv_socketpair_usable]], [
  1805. AC_LINK_IFELSE([
  1806. AC_LANG_PROGRAM([
  1807. AC_INCLUDES_DEFAULT
  1808. #ifdef HAVE_SYS_TYPES_H
  1809. #include <sys/types.h>
  1810. #endif
  1811. #ifdef HAVE_SYS_SOCKET_H
  1812. #include <sys/socket.h>
  1813. #endif
  1814. ], [[
  1815. int arr[2];
  1816. int res;
  1817. #if defined(AF_LOCAL)
  1818. res = socketpair(AF_LOCAL, SOCK_STREAM, 0, arr);
  1819. #elif defined(AF_UNIX)
  1820. res = socketpair(AF_UNIX, SOCK_STREAM, 0, arr);
  1821. #else
  1822. #error AF_LOCAL and AF_UNIX are both undefined
  1823. choke me now;
  1824. #endif
  1825. if (res != 0) return 1
  1826. ]])
  1827. ], [[mhd_cv_socketpair_usable='yes']], [[mhd_cv_socketpair_usable='no']])
  1828. ])
  1829. ])
  1830. AS_VAR_IF([[mhd_cv_socketpair_usable]], [["yes"]], [
  1831. use_itc='socketpair'
  1832. enable_itc="$use_itc"
  1833. AC_DEFINE([[_MHD_ITC_SOCKETPAIR]], [[1]], [Define to use socketpair for inter-thread communication])
  1834. ], [
  1835. AS_VAR_IF([[enable_itc]], [["socketpair"]], [AC_MSG_ERROR([[socketpair(3) is not usable, consider using other type of inter-thread communication]])])
  1836. ])
  1837. ])
  1838. AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find usable type of inter-thread communication]])])
  1839. MHD_CHECK_FUNC([accept4],
  1840. [[
  1841. #if defined(HAVE_SYS_TYPES_H)
  1842. # include <sys/types.h>
  1843. #endif
  1844. #include <sys/socket.h>
  1845. ]],
  1846. [[
  1847. struct sockaddr sk_addr;
  1848. socklen_t addr_size;
  1849. i][f (0 > accept4(0, &sk_addr, &addr_size, 0))
  1850. return 3;
  1851. ]]
  1852. )
  1853. MHD_CHECK_FUNC([gmtime_r],
  1854. [[
  1855. #if defined(HAVE_SYS_TYPES_H)
  1856. # include <sys/types.h>
  1857. #endif
  1858. #include <time.h>
  1859. ]],
  1860. [[
  1861. time_t timer = (time_t) 0;
  1862. struct tm res;
  1863. i][f (&res != gmtime_r(&timer, &res))
  1864. return 3;
  1865. ]]
  1866. )
  1867. MHD_CHECK_FUNC([memmem],
  1868. [[
  1869. #if defined(HAVE_STDDEF_H)
  1870. # include <stddef.h>
  1871. #elif defined(HAVE_STDLIB_H)
  1872. # include <stdlib.h>
  1873. #endif /* HAVE_STDLIB_H */
  1874. #include <string.h>
  1875. ]],
  1876. [[
  1877. const char *haystack = "abc";
  1878. size_t hslen = 3;
  1879. const char *needle = "b";
  1880. size_t needlelen = 1;
  1881. i][f ((haystack + 1) != memmem(haystack, hslen, needle, needlelen))
  1882. return 3;
  1883. ]]
  1884. )
  1885. MHD_CHECK_FUNC([snprintf],
  1886. [[
  1887. #include <stdio.h>
  1888. ]],
  1889. [[
  1890. char buf[2];
  1891. i][f (1 != snprintf(buf, 2, "a"))
  1892. return 3;
  1893. /* Do not use the next check to avoid compiler warning */
  1894. /* i][f (4 != snprintf(buf, 2, "abcd"))
  1895. return 4; */
  1896. ]]
  1897. )
  1898. AC_CHECK_DECL([gmtime_s],
  1899. [
  1900. AC_MSG_CHECKING([[whether gmtime_s is in C11 form]])
  1901. AC_LINK_IFELSE(
  1902. [ AC_LANG_PROGRAM(
  1903. [[
  1904. #define __STDC_WANT_LIB_EXT1__ 1
  1905. #include <time.h>
  1906. #ifdef __cplusplus
  1907. extern "C"
  1908. #endif
  1909. struct tm* gmtime_s(const time_t* time, struct tm* result);
  1910. ]], [[
  1911. struct tm res;
  1912. time_t t;
  1913. gmtime_s (&t, &res);
  1914. ]])
  1915. ],
  1916. [
  1917. AC_DEFINE([HAVE_C11_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in C11 form.])
  1918. AC_MSG_RESULT([[yes]])
  1919. ],
  1920. [
  1921. AC_MSG_RESULT([[no]])
  1922. AC_MSG_CHECKING([[whether gmtime_s is in W32 form]])
  1923. AC_LINK_IFELSE(
  1924. [ AC_LANG_PROGRAM(
  1925. [[
  1926. #include <time.h>
  1927. #ifdef __cplusplus
  1928. extern "C"
  1929. #endif
  1930. errno_t gmtime_s(struct tm* _tm, const time_t* time);
  1931. ]], [[
  1932. struct tm res;
  1933. time_t t;
  1934. gmtime_s (&res, &t);
  1935. ]])
  1936. ],
  1937. [
  1938. AC_DEFINE([HAVE_W32_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in W32 form.])
  1939. AC_MSG_RESULT([[yes]])
  1940. ],
  1941. [AC_MSG_RESULT([[no]])
  1942. ])
  1943. ])
  1944. ], [],
  1945. [[#define __STDC_WANT_LIB_EXT1__ 1
  1946. #include <time.h>]])
  1947. AC_CHECK_DECL([SOCK_NONBLOCK], [AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBLOCK is defined in a socket header])], [],
  1948. [[
  1949. #if defined(HAVE_SYS_TYPES_H)
  1950. # include <sys/types.h>
  1951. #endif
  1952. #if defined(HAVE_SYS_SOCKET_H)
  1953. # include <sys/socket.h>
  1954. #elif defined(HAVE_WINSOCK2_H)
  1955. # include <winsock2.h>
  1956. #endif
  1957. ]]
  1958. )
  1959. MHD_FIND_LIB([clock_gettime],[[#include <time.h>]],
  1960. [[
  1961. struct timespec tp;
  1962. i][f (0 > clock_gettime(CLOCK_REALTIME, &tp))
  1963. return 3;
  1964. ]],
  1965. [rt],
  1966. [
  1967. AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define to '1' if you have clock_gettime() function])
  1968. AS_VAR_IF([[mhd_cv_find_lib_clock_gettime]],[["none required"]], [],
  1969. [
  1970. MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_clock_gettime} $MHD_LIBDEPS_PKGCFG"
  1971. ]
  1972. )
  1973. ],[],
  1974. [MHD_LIBDEPS]
  1975. )
  1976. MHD_CHECK_FUNC([clock_get_time],
  1977. [[
  1978. #include <mach/clock.h>
  1979. #include <mach/mach.h>
  1980. ]],
  1981. [[
  1982. clock_serv_t cs;
  1983. mach_timespec_t mt;
  1984. host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
  1985. clock_get_time(cs, &mt);
  1986. mach_port_deallocate(mach_task_self(), cs);
  1987. ]]
  1988. )
  1989. MHD_CHECK_FUNC([gethrtime],
  1990. [[
  1991. #ifdef HAVE_SYS_TIME_H
  1992. /* Solaris define gethrtime() in sys/time.h */
  1993. #include <sys/time.h>
  1994. #endif /* HAVE_SYS_TIME_H */
  1995. #ifdef HAVE_TIME_H
  1996. /* HP-UX define gethrtime() in time.h */
  1997. #include <time.h>
  1998. #endif /* HAVE_TIME_H */
  1999. ]],
  2000. [[
  2001. hrtime_t hrt = gethrtime();
  2002. i][f (0 == hrt)
  2003. return 3;
  2004. ]]
  2005. )
  2006. AS_VAR_IF([ac_cv_header_time_h], ["yes"],
  2007. [
  2008. MHD_CHECK_FUNC([timespec_get],
  2009. [[
  2010. #include <time.h>
  2011. #ifndef TIME_UTC
  2012. #error TIME_UTC must be defined to use timespec_get()
  2013. choke me now
  2014. #endif
  2015. ]],
  2016. [[
  2017. struct timespec ts;
  2018. i][f (TIME_UTC != timespec_get (&ts, TIME_UTC))
  2019. return 3;
  2020. ]]
  2021. )
  2022. ]
  2023. )
  2024. MHD_CHECK_FUNC([[gettimeofday]],
  2025. [[
  2026. #ifdef HAVE_SYS_TIME_H
  2027. #include <sys/time.h>
  2028. #endif /* HAVE_SYS_TIME_H */
  2029. #ifdef HAVE_TIME_H
  2030. #include <time.h>
  2031. #endif /* HAVE_TIME_H */
  2032. ]],
  2033. [[
  2034. struct timeval tv;
  2035. i][f (0 != gettimeofday (&tv, (void*) 0))
  2036. return 1;
  2037. ]]
  2038. )
  2039. # IPv6
  2040. AC_CACHE_CHECK([for IPv6],[mhd_cv_have_inet6],
  2041. [
  2042. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2043. #include <stdio.h>
  2044. #ifdef HAVE_NETINET_IN_H
  2045. #include <netinet/in.h>
  2046. #endif
  2047. #ifdef HAVE_SYS_SOCKET_H
  2048. #include <sys/socket.h>
  2049. #endif
  2050. #ifdef HAVE_WINSOCK2_H
  2051. #include <winsock2.h>
  2052. #endif
  2053. #ifdef HAVE_WS2TCPIP_H
  2054. #include <ws2tcpip.h>
  2055. #endif
  2056. ]], [[
  2057. int af=AF_INET6;
  2058. int pf=PF_INET6;
  2059. struct sockaddr_in6 sa;
  2060. printf("%d %d %p\n", af, pf, (void*) &sa);
  2061. ]]
  2062. )
  2063. ],
  2064. [AS_VAR_SET([mhd_cv_have_inet6],["yes"])],
  2065. [AS_VAR_SET([mhd_cv_have_inet6],["no"])]
  2066. )
  2067. ]
  2068. )
  2069. AS_VAR_IF([mhd_cv_have_inet6],["yes"],
  2070. [AC_DEFINE([HAVE_INET6], [1], [Define to '1' if you have IPv6 headers])]
  2071. )
  2072. MHD_CHECK_FUNC([[sysconf]], [[#include <unistd.h>]], [[long a = sysconf(0); if (a) return 1;]])
  2073. MHD_CHECK_FUNC([[sysctl]], [[
  2074. #ifdef HAVE_SYS_TYPES_H
  2075. #include <sys/types.h>
  2076. #endif
  2077. #ifdef HAVE_SYS_SYSCTL_H
  2078. #include <sys/sysctl.h>
  2079. #endif
  2080. #if defined(HAVE_STDDEF_H)
  2081. #include <stddef.h>
  2082. #elif defined(HAVE_STDLIB_H)
  2083. #include <stdlib.h>
  2084. #endif
  2085. ]], [[
  2086. int mib[2] = {0, 0}; /* Avoid any platform-specific values */
  2087. i][f (sysctl(mib, 2, NULL, NULL, NULL, 0)) return 1;
  2088. ]],
  2089. [
  2090. AC_CHECK_DECLS([CTL_NET,PF_INET,IPPROTO_ICMP,ICMPCTL_ICMPLIM],[],[],
  2091. [[
  2092. #ifdef HAVE_SYS_TYPES_H
  2093. #include <sys/types.h>
  2094. #endif /* HAVE_SYS_TYPES_H */
  2095. #ifdef HAVE_SYS_SYSCTL_H
  2096. #include <sys/sysctl.h>
  2097. #endif /* HAVE_SYS_SYSCTL_H */
  2098. #ifdef HAVE_SYS_SYSCTL_H
  2099. #include <sys/sysctl.h>
  2100. #endif /* HAVE_SYS_SYSCTL_H */
  2101. #ifdef HAVE_SYS_SOCKET_H
  2102. #include <sys/socket.h>
  2103. #endif /* HAVE_SYS_SOCKET_H */
  2104. #ifdef HAVE_NETINET_IN_SYSTM_H
  2105. #include <netinet/in_systm.h>
  2106. #endif /* HAVE_NETINET_IN_SYSTM_H */
  2107. #ifdef HAVE_NETINET_IN_H
  2108. #include <netinet/in.h>
  2109. #endif /* HAVE_NETINET_IN_H */
  2110. #ifdef HAVE_NETINET_IP_H
  2111. #include <netinet/ip.h>
  2112. #endif /* HAVE_NETINET_IP_H */
  2113. #ifdef HAVE_NETINET_IP_ICMP_H
  2114. #include <netinet/ip_icmp.h>
  2115. #endif /* HAVE_NETINET_IP_ICMP_H */
  2116. #ifdef HAVE_NETINET_ICMP_VAR_H
  2117. #include <netinet/icmp_var.h>
  2118. #endif /* HAVE_NETINET_ICMP_VAR_H */
  2119. ]]
  2120. )
  2121. ]
  2122. )
  2123. MHD_CHECK_FUNC([[sysctlbyname]], [[
  2124. #ifdef HAVE_SYS_TYPES_H
  2125. #include <sys/types.h>
  2126. #endif
  2127. #ifdef HAVE_SYS_SYSCTL_H
  2128. #include <sys/sysctl.h>
  2129. #endif
  2130. #if defined(HAVE_STDDEF_H)
  2131. #include <stddef.h>
  2132. #elif defined(HAVE_STDLIB_H)
  2133. #include <stdlib.h>
  2134. #endif
  2135. ]], [[sysctlbyname("test", NULL, NULL, NULL, 0);]]
  2136. )
  2137. MHD_CHECK_FUNC([[usleep]], [[#include <unistd.h>]], [[usleep(100000);]])
  2138. MHD_CHECK_FUNC([[nanosleep]], [[#include <time.h>]], [[struct timespec ts2, ts1 = {0, 0}; nanosleep(&ts1, &ts2);]])
  2139. HIDDEN_VISIBILITY_CFLAGS=""
  2140. AS_CASE(["$host"],
  2141. [*-*-mingw*],[
  2142. dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
  2143. AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
  2144. [defines how to decorate public symbols while building])
  2145. HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
  2146. ],[
  2147. dnl on other compilers, check if we can do -fvisibility=hidden
  2148. AX_CHECK_LINK_FLAG([-fvisibility=hidden],
  2149. [AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],
  2150. [AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) extern],
  2151. [defines how to decorate public symbols while building])
  2152. HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"])])
  2153. ])
  2154. AC_SUBST(HIDDEN_VISIBILITY_CFLAGS)
  2155. # libcurl (required for testing)
  2156. AC_ARG_ENABLE([curl],
  2157. [AS_HELP_STRING([--disable-curl],[disable cURL based testcases])],
  2158. [enable_curl=${enableval}])
  2159. curl=0
  2160. AS_IF([test "$enable_curl" != "no"],
  2161. [LIBCURL_CHECK_CONFIG([yes],[7.16.4],[enable_curl=yes],
  2162. [
  2163. AS_IF([test "x$enable_curl" = "xyes"],
  2164. [AC_MSG_WARN([[cURL-based tests cannot be enabled because libcurl is missing]])])
  2165. enable_curl=no
  2166. ])
  2167. ])
  2168. AS_IF([test "$enable_curl" != "no"],
  2169. [
  2170. # Lib cURL & cURL - OpenSSL versions
  2171. AC_DEFINE([MHD_REQ_CURL_VERSION], ["7.16.4"], [required cURL version to run tests])
  2172. AC_DEFINE([MHD_REQ_CURL_OPENSSL_VERSION], ["0.9.8"], [required cURL SSL version to run tests])
  2173. AC_DEFINE([MHD_REQ_CURL_GNUTLS_VERSION], ["2.8.6"], [gnuTLS lib version - used in conjunction with cURL])
  2174. AC_DEFINE([MHD_REQ_CURL_NSS_VERSION], ["3.12.0"], [NSS lib version - used in conjunction with cURL])
  2175. ])
  2176. AM_CONDITIONAL([HAVE_CURL], [test "x$enable_curl" = "xyes"])
  2177. mhd_have_libmagic="no"
  2178. MHD_CHECK_FUNC([magic_open],
  2179. [[
  2180. #include <magic.h>
  2181. ]],
  2182. [[
  2183. char var_data[256];
  2184. const char *var_mime;
  2185. magic_t var_magic = magic_open (MAGIC_MIME_TYPE);
  2186. (void)magic_load (var_magic, "filename");
  2187. var_data[0] = 0;
  2188. var_mime = magic_buffer (var_magic, var_data, 1);
  2189. i][f (! var_mime)
  2190. return 1;
  2191. magic_close (var_magic);
  2192. ]],
  2193. [AC_DEFINE([MHD_HAVE_LIBMAGIC], [1], [Define to 1 if you have suitable libmagic.])],
  2194. [],
  2195. [-lmagic]
  2196. )
  2197. AM_CONDITIONAL([MHD_HAVE_LIBMAGIC], [[test "x$mhd_cv_func_magic_open" = "xyes"]])
  2198. # large file support (> 4 GB)
  2199. AC_SYS_LARGEFILE
  2200. AC_FUNC_FSEEKO
  2201. MHD_CHECK_FUNC([lseek64],
  2202. [[
  2203. #if defined(HAVE_SYS_TYPES_H)
  2204. # include <sys/types.h>
  2205. #endif
  2206. #include <unistd.h>
  2207. ]],
  2208. [[
  2209. i][f (((off64_t) -1) == lseek64(0, (off64_t) 0, SEEK_SET))
  2210. return 3;
  2211. ]]
  2212. )
  2213. MHD_CHECK_FUNC([pread64],
  2214. [[
  2215. #if defined(HAVE_SYS_TYPES_H)
  2216. # include <sys/types.h>
  2217. #endif
  2218. #include <unistd.h>
  2219. ]],
  2220. [[
  2221. char buf[5];
  2222. i][f (0 > pread64(0, (void *) buf, 1, (off64_t) 0))
  2223. return 3;
  2224. ]]
  2225. )
  2226. MHD_CHECK_FUNC([pread],
  2227. [[
  2228. #if defined(HAVE_SYS_TYPES_H)
  2229. # include <sys/types.h>
  2230. #endif
  2231. #include <unistd.h>
  2232. ]],
  2233. [[
  2234. char buf[5];
  2235. i][f (0 > pread(0, (void *) buf, 1, 0))
  2236. return 3;
  2237. ]]
  2238. )
  2239. # check for various sendfile functions
  2240. AC_ARG_ENABLE([sendfile],
  2241. [AS_HELP_STRING([--disable-sendfile],
  2242. [disable usage of sendfile() for HTTP connections [auto]])],
  2243. [],
  2244. [enable_sendfile="auto"])
  2245. AS_CASE([$enable_sendfile],
  2246. [[auto | yes]],[[found_sendfile="no"]],
  2247. [[no]],[[found_sendfile="disabled"]],
  2248. [AC_MSG_ERROR([[unknown value specified: --enable-sendfile=$enable_sendfile]])]
  2249. )
  2250. AS_VAR_IF([[found_sendfile]], [["no"]],
  2251. [
  2252. AC_MSG_CHECKING([[for Linux-style sendfile(2)]])
  2253. AC_LINK_IFELSE(
  2254. [AC_LANG_PROGRAM(
  2255. [[
  2256. #include <sys/sendfile.h>
  2257. static void empty_func(void)
  2258. {
  2259. /* Check for declaration */
  2260. (void)sendfile;
  2261. }
  2262. /* Declare again to check form match */
  2263. ssize_t sendfile(int, int, off_t*, size_t);
  2264. ]],
  2265. [[
  2266. int fd1=0, fd2=2;
  2267. off_t o = 0;
  2268. size_t s = 5;
  2269. ssize_t r;
  2270. r = sendfile (fd1, fd2, &o, s);
  2271. if (r)
  2272. empty_func();
  2273. ]]
  2274. )
  2275. ],
  2276. [
  2277. AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).])
  2278. found_sendfile="yes, Linux-style"
  2279. AC_MSG_RESULT([[yes]])
  2280. MHD_CHECK_FUNC([sendfile64],
  2281. [[
  2282. #include <sys/sendfile.h>
  2283. ]],
  2284. [[
  2285. off64_t f_offset = (off64_t) 0;
  2286. if (0 > sendfile64 (0, 1, &f_offset, 1))
  2287. return 3;
  2288. ]]
  2289. )
  2290. ],
  2291. [AC_MSG_RESULT([[no]])
  2292. ]
  2293. )
  2294. ]
  2295. )
  2296. AS_VAR_IF([[found_sendfile]], [["no"]],
  2297. [
  2298. AC_MSG_CHECKING([[for FreeBSD-style sendfile(2)]])
  2299. AC_LINK_IFELSE(
  2300. [AC_LANG_PROGRAM(
  2301. [[
  2302. #include <sys/types.h>
  2303. #include <sys/socket.h>
  2304. #include <sys/uio.h>
  2305. static void empty_func(void)
  2306. {
  2307. /* Check for declaration */
  2308. (void)sendfile;
  2309. }
  2310. /* Declare again to check form match */
  2311. int sendfile(int, int, off_t, size_t,
  2312. struct sf_hdtr*, off_t*, int);
  2313. ]],
  2314. [[
  2315. int fd1=0, fd2=1;
  2316. off_t o = 0;
  2317. size_t s = 5;
  2318. off_t r1;
  2319. int r2;
  2320. r2 = sendfile (fd1, fd2, o, s, (void*)0, &r1, 0);
  2321. if (r2)
  2322. empty_func();
  2323. ]]
  2324. )
  2325. ],
  2326. [
  2327. AC_DEFINE([HAVE_FREEBSD_SENDFILE], [1], [Define to 1 if you have FreeBSD-style sendfile(2).])
  2328. found_sendfile="yes, FreeBSD-style"
  2329. AC_MSG_RESULT([[yes]])
  2330. ],
  2331. [AC_MSG_RESULT([[no]])
  2332. ]
  2333. )
  2334. ]
  2335. )
  2336. AS_VAR_IF([[found_sendfile]], [["no"]],
  2337. [
  2338. AC_MSG_CHECKING([[for Darwin-style sendfile(2)]])
  2339. AC_LINK_IFELSE(
  2340. [AC_LANG_PROGRAM(
  2341. [[
  2342. #include <sys/types.h>
  2343. #include <sys/socket.h>
  2344. #include <sys/uio.h>
  2345. static void empty_func(void)
  2346. {
  2347. /* Check for declaration */
  2348. (void)sendfile;
  2349. }
  2350. /* Declare again to check form match */
  2351. int sendfile(int, int, off_t, off_t*,
  2352. struct sf_hdtr *, int);
  2353. ]],
  2354. [[
  2355. int fd=0, s=1;
  2356. off_t o = 0;
  2357. off_t l = 5;
  2358. int r;
  2359. r = sendfile (fd, s, o, &l, (void*)0, 0);
  2360. if (r)
  2361. empty_func();
  2362. ]]
  2363. )
  2364. ],
  2365. [
  2366. AC_DEFINE([HAVE_DARWIN_SENDFILE], [1], [Define to 1 if you have Darwin-style sendfile(2).])
  2367. found_sendfile="yes, Darwin-style"
  2368. AC_MSG_RESULT([[yes]])
  2369. ],
  2370. [AC_MSG_RESULT([[no]])
  2371. ]
  2372. )
  2373. ]
  2374. )
  2375. AS_VAR_IF([[found_sendfile]], [["no"]],
  2376. [
  2377. AC_MSG_CHECKING([[for Solaris-style sendfile(3)]])
  2378. SAVE_LIBS="$LIBS"
  2379. LIBS="$LIBS -lsendfile"
  2380. AC_LINK_IFELSE(
  2381. [AC_LANG_PROGRAM(
  2382. [[
  2383. #include <sys/types.h>
  2384. #include <sys/socket.h>
  2385. #include <sys/sendfile.h>
  2386. static void empty_func(void)
  2387. {
  2388. /* Check for declaration */
  2389. (void)sendfile;
  2390. }
  2391. /* Declare again to check form match */
  2392. ssize_t sendfile(int out_fd, int in_fd,
  2393. off_t *off, size_t len);
  2394. ]],
  2395. [[
  2396. int fd1=0, fd2=1;
  2397. off_t o = 0;
  2398. size_t l = 5;
  2399. ssize_t r;
  2400. r = sendfile (fd1, fd2, &o, l);
  2401. if (r)
  2402. empty_func();
  2403. ]]
  2404. )
  2405. ],
  2406. [
  2407. AC_DEFINE([HAVE_SOLARIS_SENDFILE], [1], [Define to 1 if you have Solaris-style sendfile(3).])
  2408. found_sendfile="yes, Solaris-style"
  2409. MHD_LIBDEPS="-lsendfile $MHD_LIBDEPS"
  2410. MHD_LIBDEPS_PKGCFG="-lsendfile $MHD_LIBDEPS_PKGCFG"
  2411. AC_MSG_RESULT([[yes]])
  2412. MHD_CHECK_FUNC([sendfile64],
  2413. [[
  2414. #include <sys/types.h>
  2415. #include <sys/socket.h>
  2416. #include <sys/sendfile.h>
  2417. ]],
  2418. [[
  2419. off64_t f_offset = (off64_t) 0;
  2420. if (0 > sendfile64 (0, 1, &f_offset, 1))
  2421. return 3;
  2422. ]]
  2423. )
  2424. ],
  2425. [AC_MSG_RESULT([[no]])
  2426. ]
  2427. )
  2428. LIBS="$SAVE_LIBS"
  2429. ]
  2430. )
  2431. AS_IF([[test "x$found_sendfile" = "xno" && test "x$enable_sendfile" = "xyes"]],
  2432. [AC_MSG_ERROR([[sendfile() usage was requested by configure parameter, but no usable sendfile() function is detected]])]
  2433. )
  2434. # optional: have error messages ?
  2435. AC_MSG_CHECKING([[whether to generate error messages]])
  2436. AC_ARG_ENABLE([messages],
  2437. [AS_HELP_STRING([--disable-messages],
  2438. [disable MHD error messages])],
  2439. [enable_messages=${enableval}],
  2440. [enable_messages=yes])
  2441. AS_IF([[test "x$enable_messages" = "xyes"]],
  2442. [ AC_DEFINE([HAVE_MESSAGES],[1],[Define to 1 to enable support for error messages.]) ],
  2443. [[ enable_messages=no ]])
  2444. AC_MSG_RESULT([[$enable_messages]])
  2445. # optional: have postprocessor?
  2446. AC_MSG_CHECKING([[whether to enable postprocessor]])
  2447. AC_ARG_ENABLE([postprocessor],
  2448. [AS_HELP_STRING([--disable-postprocessor],
  2449. [disable MHD PostProcessor functionality])],
  2450. [enable_postprocessor=${enableval}],
  2451. [enable_postprocessor=yes])
  2452. AS_IF([[test "x$enable_postprocessor" != "xno"]],
  2453. [ enable_postprocessor=yes
  2454. AC_DEFINE([HAVE_POSTPROCESSOR],[1],[Define to 1 if libmicrohttpd is compiled with postprocessor support.]) ])
  2455. AM_CONDITIONAL([HAVE_POSTPROCESSOR], [test "x$enable_postprocessor" != "xno"])
  2456. AC_MSG_RESULT([[$enable_postprocessor]])
  2457. # optional: have zzuf, socat?
  2458. AC_CHECK_PROG([have_zzuf],[zzuf], [yes], [no])
  2459. AC_CHECK_PROG([have_socat],[socat], [yes], [no])
  2460. AM_CONDITIONAL([HAVE_ZZUF], [test "x$have_zzuf" = "xyes"])
  2461. AM_CONDITIONAL([HAVE_SOCAT], [test "x$have_socat" = "xyes"])
  2462. have_gnutls=no
  2463. have_gnutls_sni=no
  2464. have_gcrypt=no
  2465. AS_UNSET([GNUTLS_CPPFLAGS])
  2466. AS_UNSET([GNUTLS_LDFLAGS])
  2467. # optional: HTTPS support. Enabled by default
  2468. AC_ARG_ENABLE([https],
  2469. [AS_HELP_STRING([--enable-https],
  2470. [enable HTTPS support (yes, no, auto)[auto]])],
  2471. [enable_https=${enableval}])
  2472. AS_IF([test "x$enable_https" != "xno"],[
  2473. #
  2474. # Next block is large unindented block
  2475. #
  2476. # gnutls
  2477. have_gnutls_pkgcfg=no
  2478. AC_MSG_CHECKING([[how to find GnuTLS library]])
  2479. AC_ARG_WITH([[gnutls]],
  2480. [AS_HELP_STRING([[--with-gnutls[=PFX]]],[use GnuTLS for HTTPS support, optional PFX overrides pkg-config data for GnuTLS headers (PFX/include) and libs (PFX/lib)])],
  2481. [
  2482. AS_CASE([$with_gnutls],
  2483. [no],[
  2484. AC_MSG_RESULT([[GnuTLS disabled]])
  2485. AS_UNSET([GNUTLS_CPPFLAGS])
  2486. AS_UNSET([GNUTLS_CFLAGS])
  2487. AS_UNSET([GNUTLS_LDFLAGS])
  2488. AS_UNSET([GNUTLS_LIBS])
  2489. ],
  2490. [yes],[
  2491. AC_MSG_RESULT([[automatically, forced]])
  2492. ],
  2493. [
  2494. AC_MSG_RESULT([[-I$with_gnutls/include -L$with_gnutls/lib -lgnutls]])
  2495. SAVE_LDFLAGS="$LDFLAGS"
  2496. SAVE_CPPFLAGS="$CPPFLAGS"
  2497. SAVE_CFLAGS="$CFLAGS"
  2498. SAVE_LIBS="$LIBS"
  2499. LDFLAGS="-L$with_gnutls/lib $LDFLAGS"
  2500. CPPFLAGS="-I$with_gnutls/include $CPPFLAGS"
  2501. have_gnutls_pkgcfg=no
  2502. MHD_CHECK_FUNC([gnutls_check_version],[[#include <gnutls/gnutls.h>]],
  2503. [
  2504. if(!gnutls_check_version("2.0.0"))
  2505. return 3;
  2506. ],
  2507. [
  2508. GNUTLS_CPPFLAGS="-I$with_gnutls/include"
  2509. GNUTLS_LDFLAGS="-L$with_gnutls/lib"
  2510. GNUTLS_LIBS="-lgnutls"
  2511. have_gnutls=yes
  2512. ],
  2513. [AC_MSG_ERROR([can't find usable libgnutls at specified prefix $with_gnutls])],
  2514. [-lgnutls]
  2515. )
  2516. CPPFLAGS="${SAVE_CPPFLAGS}"
  2517. CFLAGS="${SAVE_CFLAGS}"
  2518. LDFLAGS="${SAVE_LDFLAGS}"
  2519. LIBS="$SAVE_LIBS"
  2520. ])
  2521. ],
  2522. [AC_MSG_RESULT([[automatically]])
  2523. ])
  2524. AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"],
  2525. [
  2526. AC_CACHE_CHECK([[whether to add pkg-config special search directories]], [mhd_cv_pkgconf_add_dirs],
  2527. [
  2528. AS_IF([[test "x$host_os" = "xsolaris2.11" && test "x$cross_compiling" = "xno"]],
  2529. [
  2530. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2531. char size_chk[7-sizeof(char*)];
  2532. #if defined(_LP64) || defined(__LP64__) || defined(__x86_64) || defined(__x86_64__)
  2533. #error This is 64-bit target.
  2534. choke me now
  2535. #endif
  2536. #if defined(__amd64) || defined(__amd64__) || defined(__sparcv9) || defined(__sparc_v9__)
  2537. #error This is 64-bit target.
  2538. choke me now
  2539. #endif
  2540. ]], [[]]
  2541. )
  2542. ],
  2543. [
  2544. mhd_cv_pkgconf_add_dirs='/usr/lib/pkgconfig/gnutls-3'
  2545. ],
  2546. [
  2547. AS_IF([[test "x$host_cpu" = "xx86_64" || test "x$host_cpu" = "xi386"]],
  2548. [[mhd_cv_pkgconf_add_dirs='/usr/lib/amd64/pkgconfig/gnutls-3:/usr/lib/amd64/pkgconfig']],
  2549. [[test "x$host_cpu" = "xsparc"]],
  2550. [[mhd_cv_pkgconf_add_dirs='/usr/lib/sparkv9/pkgconfig/gnutls-3:/usr/lib/sparkv9/pkgconfig']],
  2551. [[mhd_cv_pkgconf_add_dirs='/usr/lib/64/pkgconfig/gnutls-3:/usr/lib/64/pkgconfig']]
  2552. )
  2553. ]
  2554. )
  2555. ],
  2556. [[ mhd_cv_pkgconf_add_dirs='no' ]]
  2557. )
  2558. ]
  2559. )
  2560. AS_IF([[test "x$mhd_cv_pkgconf_add_dirs" != "xno"]],
  2561. [
  2562. test "x$PKG_CONFIG_PATH" = "x" || PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${PATH_SEPARATOR}"
  2563. PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${mhd_cv_pkgconf_add_dirs}"
  2564. export PKG_CONFIG_PATH
  2565. ]
  2566. )
  2567. PKG_CHECK_MODULES(GNUTLS, [[gnutls]],
  2568. [
  2569. have_gnutls_pkgcfg='yes'
  2570. SAVE_CPPFLAGS="$CPPFLAGS"
  2571. SAVE_CFLAGS="$CFLAGS"
  2572. SAVE_LDFLAGS="$LDFLAGS"
  2573. SAVE_LIBS="$LIBS"
  2574. CFLAGS="$GNUTLS_CFLAGS $CFLAGS"
  2575. LIBS="$LIBS $GNUTLS_LIBS"
  2576. AC_MSG_CHECKING([[whether GnuTLS is usable]])
  2577. AC_LINK_IFELSE([
  2578. AC_LANG_PROGRAM([[
  2579. #include <gnutls/gnutls.h>
  2580. ]], [[
  2581. gnutls_session_t session;
  2582. gnutls_priority_t priorities;
  2583. gnutls_global_init();
  2584. gnutls_priority_init(&priorities, "NORMAL", NULL);
  2585. gnutls_init(&session, GNUTLS_SERVER);
  2586. gnutls_priority_set(session, priorities);
  2587. ]])],
  2588. [
  2589. AC_MSG_RESULT([[yes]])
  2590. have_gnutls=yes
  2591. # GNUTLS_CFLAGS is actually CPPFLAGS
  2592. GNUTLS_CPPFLAGS="$GNUTLS_CFLAGS"
  2593. # GNUTLS_CFLAGS is combination of LDFLAGS and LIBS
  2594. GNUTLS_LDFLAGS="$GNUTLS_LIBS"
  2595. ],
  2596. [
  2597. AC_MSG_RESULT([[no]])
  2598. have_gnutls=no
  2599. ])
  2600. AS_IF([test "x$have_gnutls" != "xyes"],
  2601. [
  2602. AC_MSG_WARN([pkg-config reports that GnuTLS is present, but GnuTLS can't be used])
  2603. AS_UNSET([GNUTLS_CPPFLAGS])
  2604. AS_UNSET([GNUTLS_CFLAGS])
  2605. AS_UNSET([GNUTLS_LDFLAGS])
  2606. AS_UNSET([GNUTLS_LIBS])
  2607. ]
  2608. )
  2609. CPPFLAGS="$SAVE_CPPFLAGS"
  2610. CFLAGS="$SAVE_CFLAGS"
  2611. LDFLAGS="$SAVE_LDFLAGS"
  2612. LIBS="$SAVE_LIBS"
  2613. ],
  2614. [
  2615. # check for GnuTLS at default paths
  2616. have_gnutls_pkgcfg='no'
  2617. AC_CHECK_HEADERS([gnutls/gnutls.h],
  2618. [AC_CHECK_LIB([gnutls], [gnutls_priority_set],
  2619. [
  2620. GNUTLS_LIBS="-lgnutls"
  2621. have_gnutls=yes
  2622. ])], [], [AC_INCLUDES_DEFAULT])
  2623. ])
  2624. ])
  2625. have_gcrypt='unknown'
  2626. AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"],
  2627. [
  2628. AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no])
  2629. AS_IF([[test "x$have_gcrypt" = "xyes"]],
  2630. [
  2631. SAVE_CPPFLAGS="$CPPFLAGS"
  2632. SAVE_CFLAGS="$CFLAGS"
  2633. SAVE_LIBS="$LIBS"
  2634. SAVE_LDFLAGS="$LDFLAGS"
  2635. CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
  2636. # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both
  2637. CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS"
  2638. AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT])
  2639. # Check for GnuTLS with gcrypt flags
  2640. LDFLAGS="$LDFLAGS $LIBGCRYPT_LIBS"
  2641. # A bit of hack: unset cache variable to force recheck
  2642. AS_UNSET([ac_cv_header_gnutls_gnutls_h])
  2643. AC_CHECK_HEADERS([gnutls/gnutls.h],
  2644. [AS_UNSET([ac_cv_lib_gnutls_gnutls_priority_set]) # A bit of hack: unset cache variable to force recheck
  2645. AC_CHECK_LIB([gnutls], [gnutls_priority_set],
  2646. [
  2647. GNUTLS_CPPFLAGS="$LIBGCRYPT_CFLAGS"
  2648. GNUTLS_CFLAGS="$LIBGCRYPT_CFLAGS"
  2649. GNUTLS_LDFLAGS="$LIBGCRYPT_LIBS"
  2650. GNUTLS_LIBS="-lgnutls"
  2651. have_gnutls=yes
  2652. ])], [], [AC_INCLUDES_DEFAULT])
  2653. CPPFLAGS="$SAVE_CPPFLAGS"
  2654. CFLAGS="$SAVE_CFLAGS"
  2655. LDFLAGS="$SAVE_LDFLAGS"
  2656. LIBS="$SAVE_LIBS"
  2657. ]
  2658. )
  2659. ]
  2660. )
  2661. AS_IF([test "x$have_gnutls" != "xyes" && test "x$with_gnutls" = "xyes"],
  2662. [AC_MSG_ERROR([[can't find usable libgnutls]])])
  2663. AS_IF([test "x$have_gnutls" = "xyes"],
  2664. [
  2665. SAVE_CPPFLAGS="$CPPFLAGS"
  2666. SAVE_CFLAGS="$CFLAGS"
  2667. SAVE_LDFLAGS="$LDFLAGS"
  2668. SAVE_LIBS="$LIBS"
  2669. CPPFLAGS="$GNUTLS_CPPFLAGS $CPPFLAGS"
  2670. CFLAGS="$GNUTLS_CFLAGS $CFLAGS"
  2671. LDFLAGS="$GNUTLS_LDFLAGS $LDFLAGS"
  2672. LIBS="$LIBS $GNUTLS_LIBS"
  2673. AC_MSG_CHECKING([[for gnutls_privkey_import_x509_raw()]])
  2674. AC_LINK_IFELSE([
  2675. AC_LANG_PROGRAM([[
  2676. #include <gnutls/gnutls.h>
  2677. #include <gnutls/abstract.h>
  2678. ]], [[
  2679. gnutls_datum_t data;
  2680. gnutls_privkey_t key = 0;
  2681. #ifndef gnutls_load_file
  2682. (void)gnutls_load_file; /* Check for declaration. */
  2683. #endif
  2684. #ifndef gnutls_privkey_import_x509_raw
  2685. (void)gnutls_privkey_import_x509_raw; /* Check for declaration. */
  2686. #endif
  2687. gnutls_load_file("key.pem", &data);
  2688. gnutls_privkey_import_x509_raw(key, &data, GNUTLS_X509_FMT_PEM, NULL, 0);
  2689. gnutls_free(data.data);
  2690. ]])], [[have_gnutls_sni=yes]], [[have_gnutls_sni=no]])
  2691. AC_MSG_RESULT([[$have_gnutls_sni]])
  2692. AC_CACHE_CHECK([[whether GnuTLS require libgcrypt initialisation]], [mhd_cv_gcrypt_required],
  2693. [
  2694. AC_COMPILE_IFELSE(
  2695. [
  2696. AC_LANG_PROGRAM(
  2697. [
  2698. #include <gnutls/gnutls.h>
  2699. ],
  2700. [
  2701. #if !defined(GNUTLS_VERSION_NUMBER) || GNUTLS_VERSION_NUMBER+0 <= 0x020c14
  2702. #error Old versions of GnuTLS require libgcript initialisation
  2703. choke me now
  2704. #endif
  2705. ]
  2706. )
  2707. ],
  2708. [[mhd_cv_gcrypt_required='no']], [[mhd_cv_gcrypt_required='yes']]
  2709. )
  2710. ]
  2711. )
  2712. CPPFLAGS="$SAVE_CPPFLAGS"
  2713. CFLAGS="$SAVE_CFLAGS"
  2714. LDFLAGS="$SAVE_LDFLAGS"
  2715. LIBS="$SAVE_LIBS"
  2716. ],
  2717. [
  2718. AS_UNSET([GNUTLS_CPPFLAGS])
  2719. AS_UNSET([GNUTLS_LDFLAGS])
  2720. ]
  2721. )
  2722. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" = "xunknown"]],
  2723. [
  2724. AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no])
  2725. AS_IF([[test "x$have_gcrypt" = "xyes"]],
  2726. [
  2727. SAVE_CPPFLAGS="$CPPFLAGS"
  2728. SAVE_CFLAGS="$CFLAGS"
  2729. CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
  2730. # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both
  2731. CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS"
  2732. AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT])
  2733. CPPFLAGS="$SAVE_CPPFLAGS"
  2734. CFLAGS="$SAVE_CFLAGS"
  2735. ]
  2736. )
  2737. ]
  2738. )
  2739. AS_UNSET([[crypt_missing]])
  2740. AS_IF([[test "x$have_gnutls" = "xyes"]],
  2741. [
  2742. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" != "xyes"]],
  2743. [
  2744. crypt_missing="required libgcrypt"
  2745. AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])])
  2746. enable_https=no
  2747. MSG_HTTPS="no (lacking $crypt_missing)"
  2748. AS_UNSET([LIBGCRYPT_CFLAGS])
  2749. AS_UNSET([LIBGCRYPT_LIBS])
  2750. AS_UNSET([GNUTLS_CPPFLAGS])
  2751. AS_UNSET([GNUTLS_CFLAGS])
  2752. AS_UNSET([GNUTLS_LDFLAGS])
  2753. AS_UNSET([GNUTLS_LIBS])
  2754. ],
  2755. [
  2756. AC_DEFINE([[HTTPS_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTPS support.])
  2757. enable_https=yes
  2758. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
  2759. [
  2760. MSG_HTTPS="yes (using libgnutls and libgcrypt)"
  2761. MHD_TLS_LIB_CPPFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CPPFLAGS"
  2762. MHD_TLS_LIB_CFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CFLAGS"
  2763. MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS"
  2764. MHD_TLS_LIBDEPS="$GNUTLS_LIBS $LIBGCRYPT_LIBS"
  2765. AC_DEFINE([[MHD_HTTPS_REQUIRE_GCRYPT]], [[1]], [Define to `1' if HTTPS require initialisation of libgcrypt])
  2766. ],
  2767. [
  2768. MSG_HTTPS="yes (using libgnutls)"
  2769. AS_UNSET([LIBGCRYPT_CFLAGS])
  2770. AS_UNSET([LIBGCRYPT_LIBS])
  2771. MHD_TLS_LIB_CPPFLAGS="$GNUTLS_CPPFLAGS"
  2772. MHD_TLS_LIB_CFLAGS="$GNUTLS_CFLAGS"
  2773. MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS"
  2774. MHD_TLS_LIBDEPS="$GNUTLS_LIBS"
  2775. ]
  2776. )
  2777. AS_IF([[ test "x$have_gnutls_pkgcfg" = "xyes" ]],
  2778. [ # remove GnuTLS from private libs in .pc file as it defined in Requires.private
  2779. MHD_REQ_PRIVATE='gnutls'
  2780. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
  2781. [[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]]
  2782. )
  2783. ],
  2784. [
  2785. MHD_REQ_PRIVATE=''
  2786. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
  2787. [[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]]
  2788. )
  2789. MHD_LIBDEPS_PKGCFG="$GNUTLS_LIBS $MHD_LIBDEPS_PKGCFG"
  2790. ])
  2791. ]
  2792. )
  2793. ],
  2794. [
  2795. crypt_missing="libgnutls"
  2796. AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])])
  2797. enable_https=no
  2798. MSG_HTTPS="no (lacking $crypt_missing)"
  2799. AS_UNSET([LIBGCRYPT_CFLAGS])
  2800. AS_UNSET([LIBGCRYPT_LIBS])
  2801. AS_UNSET([GNUTLS_CPPFLAGS])
  2802. AS_UNSET([GNUTLS_CFLAGS])
  2803. AS_UNSET([GNUTLS_LDFLAGS])
  2804. AS_UNSET([GNUTLS_LIBS])
  2805. ]
  2806. )
  2807. ],[
  2808. MSG_HTTPS="no (disabled)"
  2809. ])
  2810. #
  2811. # End of large unindented block
  2812. #
  2813. AC_MSG_CHECKING(whether to support HTTPS)
  2814. AC_MSG_RESULT([$MSG_HTTPS])
  2815. AM_CONDITIONAL([HAVE_GNUTLS], [[test "x$have_gnutls" = "xyes"]])
  2816. AM_CONDITIONAL([HAVE_GNUTLS_SNI], [[test "x$have_gnutls_sni" = "xyes"]])
  2817. AM_CONDITIONAL([ENABLE_HTTPS], [test "x$enable_https" = "xyes"])
  2818. AM_CONDITIONAL([HTTPS_REQUIRE_GCRYPT], [[test "x$enable_https" = "xyes" && test "x$mhd_cv_gcrypt_required" = "xyes"]])
  2819. AC_SUBST([GNUTLS_CPPFLAGS])
  2820. AC_SUBST([GNUTLS_CFLAGS])
  2821. AC_SUBST([GNUTLS_LDFLAGS])
  2822. AC_SUBST([GNUTLS_LIBS])
  2823. AS_VAR_IF([have_gnutls], ["yes"],
  2824. [
  2825. AC_CACHE_CHECK([for GnuTLS quirks], [mhd_cv_gnutls_mthread_broken],
  2826. [
  2827. mhd_cv_gnutls_mthread_broken="no"
  2828. AS_IF([test -r /etc/redhat-release],
  2829. [
  2830. AS_IF([$FGREP ' release 6.' /etc/redhat-release >/dev/null || $FGREP '(Santiago)' /etc/redhat-release >/dev/null],
  2831. [mhd_cv_gnutls_mthread_broken="found"],
  2832. )
  2833. ]
  2834. )
  2835. AS_VAR_IF([mhd_cv_gnutls_mthread_broken], ["no"],
  2836. [
  2837. AS_IF([command -v rpm >/dev/null],
  2838. [
  2839. AS_IF([test "r`rpm -E '%{rhel}' 2>/dev/null`" = "r6"],
  2840. [mhd_cv_gnutls_mthread_broken="found"],
  2841. )
  2842. ]
  2843. )
  2844. ]
  2845. )
  2846. ]
  2847. )
  2848. AC_CACHE_CHECK([for gnutls-cli binary], [mhd_cv_gnutls_cli],
  2849. [
  2850. mhd_cv_gnutls_cli="no"
  2851. AS_IF([command -v gnutls-cli >/dev/null 2>&1],
  2852. [AS_IF([AC_RUN_LOG([gnutls-cli --version >&2])], [mhd_cv_gnutls_cli="yes"])]
  2853. )
  2854. ]
  2855. )
  2856. ]
  2857. )
  2858. AM_CONDITIONAL([HAVE_GNUTLS_MTHREAD_BROKEN], [[test "x${mhd_cv_gnutls_mthread_broken}" = "xfound"]])
  2859. AM_CONDITIONAL([USE_UPGRADE_TLS_TESTS], [[test "x${mhd_cv_gnutls_mthread_broken}" = "xno" || test "x${mhd_cv_gnutls_cli}" = "xyes"]])
  2860. # optional: HTTP Basic Auth support. Enabled by default
  2861. AC_MSG_CHECKING([[whether to support HTTP Basic authentication]])
  2862. AC_ARG_ENABLE([bauth],
  2863. [AS_HELP_STRING([--disable-bauth],[disable HTTP Basic Authentication support])],
  2864. [enable_bauth=${enableval}],
  2865. [enable_bauth=yes])
  2866. AS_IF([[test "x$enable_bauth" != "xno"]],
  2867. [ enable_bauth=yes
  2868. AC_DEFINE([BAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with Basic Auth support.]) ])
  2869. AM_CONDITIONAL([ENABLE_BAUTH], [test "x$enable_bauth" != "xno"])
  2870. AC_MSG_RESULT([[$enable_bauth]])
  2871. # optional: HTTP Digest Auth support. Enabled by default
  2872. AC_MSG_CHECKING([[whether to support HTTP Digest authentication]])
  2873. AC_ARG_ENABLE([dauth],
  2874. [AS_HELP_STRING([--disable-dauth], [disable HTTP Digest Authentication support])],
  2875. [enable_dauth=${enableval}],
  2876. [enable_dauth=yes])
  2877. AS_IF([[test "x$enable_dauth" != "xno"]],
  2878. [ enable_dauth=yes
  2879. AC_DEFINE([DAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with Digest Auth support.]) ])
  2880. AM_CONDITIONAL([ENABLE_DAUTH], [test "x$enable_dauth" != "xno"])
  2881. AC_MSG_RESULT([[$enable_dauth]])
  2882. # optional: HTTP "Upgrade" support. Enabled by default
  2883. AC_MSG_CHECKING([[whether to support HTTP "Upgrade"]])
  2884. AC_ARG_ENABLE([[httpupgrade]],
  2885. [AS_HELP_STRING([[--disable-httpupgrade]], [disable HTTP "Upgrade" support])],
  2886. [AS_VAR_IF([[enable_httpupgrade]],[["no"]],[],[[enable_httpupgrade='yes']])],
  2887. [[enable_httpupgrade='yes']])
  2888. AS_VAR_IF([[enable_httpupgrade]],[["yes"]],
  2889. [
  2890. AC_DEFINE([[UPGRADE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTP Upgrade support.]) ])
  2891. AM_CONDITIONAL([ENABLE_UPGRADE], [[test "x$enable_httpupgrade" = "xyes"]])
  2892. AC_MSG_RESULT([[$enable_httpupgrade]])
  2893. AC_CACHE_CHECK([[for calloc()]], [[mhd_cv_have_func_calloc]],
  2894. [
  2895. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  2896. #include <stdlib.h>
  2897. ]],[[void * ptr = calloc(1, 2); if (ptr) return 1;]])
  2898. ],
  2899. [[mhd_cv_have_func_calloc='yes']],
  2900. [[mhd_cv_have_func_calloc='no']]
  2901. )
  2902. ]
  2903. )
  2904. AS_VAR_IF([[mhd_cv_have_func_calloc]], [["yes"]],
  2905. [AC_DEFINE([[HAVE_CALLOC]], [[1]], [Define to 1 if you have the usable `calloc' function.])])
  2906. # Some systems have IPv6 disabled in kernel at run-time
  2907. AS_IF([[test "x${mhd_cv_have_inet6}" = "xyes" && test "x${cross_compiling}" = "xno"]],
  2908. [
  2909. AC_CACHE_CHECK([whether IPv6 could be used for testing],[mhd_cv_ipv6_for_testing],
  2910. [
  2911. AC_RUN_IFELSE(
  2912. [
  2913. AC_LANG_SOURCE([[
  2914. #ifdef HAVE_UNISTD_H
  2915. #include <unistd.h>
  2916. #endif
  2917. #ifdef HAVE_SYS_TYPES_H
  2918. #include <sys/types.h>
  2919. #endif
  2920. #ifdef HAVE_SYS_SOCKET_H
  2921. #include <sys/socket.h>
  2922. #endif
  2923. #ifdef HAVE_WINSOCK2_H
  2924. #include <winsock2.h>
  2925. #endif
  2926. #ifdef HAVE_WS2TCPIP_H
  2927. #include <ws2tcpip.h>
  2928. #endif
  2929. #ifdef HAVE_NETINET_IN_H
  2930. #include <netinet/in.h>
  2931. #endif
  2932. #ifdef HAVE_NETINET_IP_H
  2933. #include <netinet/ip.h>
  2934. #endif
  2935. #ifdef HAVE_ARPA_INET_H
  2936. #include <arpa/inet.h>
  2937. #endif
  2938. #ifdef HAVE_NETINET_TCP_H
  2939. #include <netinet/tcp.h>
  2940. #endif
  2941. static void zr_mem(void *ptr, socklen_t size)
  2942. { char *mem = ptr; while(size--) {mem[0] = 0; mem++;} }
  2943. int main(void)
  2944. {
  2945. int ret = 30;
  2946. struct sockaddr_in6 sa;
  2947. #if !defined(_WIN32) || defined(__CYGWIN__)
  2948. int sckt;
  2949. const int invld_sckt = -1;
  2950. #else
  2951. SOCKET sckt;
  2952. const SOCKET invld_sckt = INVALID_SOCKET;
  2953. WSADATA wsa_data;
  2954. WSAStartup(MAKEWORD(2, 2), &wsa_data);
  2955. #endif
  2956. zr_mem(&sa, sizeof(sa));
  2957. sa.sin6_family = AF_INET6;
  2958. sa.sin6_port = 0;
  2959. sa.sin6_addr = in6addr_loopback;
  2960. #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
  2961. sa.sin6_len = sizeof(sa);
  2962. #endif
  2963. sckt = socket (PF_INET6, SOCK_STREAM, 0);
  2964. if (invld_sckt != sckt)
  2965. {
  2966. if (0 == bind (sckt, (struct sockaddr *)&sa, sizeof(sa)))
  2967. {
  2968. if (0 == listen (sckt, 1))
  2969. ret = 0;
  2970. else
  2971. ret = 1; /* listen() failed */
  2972. } else ret = 2; /* bind() failed */
  2973. #if !defined(_WIN32) || defined(__CYGWIN__)
  2974. close (sckt);
  2975. #else
  2976. closesocket (sckt);
  2977. #endif
  2978. } else ret = 3; /* socket() failed */
  2979. #if defined(_WIN32) && !defined(__CYGWIN__)
  2980. WSACleanup();
  2981. #endif
  2982. return ret;
  2983. }
  2984. ]])
  2985. ], [[mhd_cv_ipv6_for_testing="yes"]], [[mhd_cv_ipv6_for_testing="no"]], [[mhd_cv_ipv6_for_testing="no"]]
  2986. )
  2987. ]
  2988. )
  2989. ]
  2990. )
  2991. AS_VAR_IF([mhd_cv_ipv6_for_testing],["yes"],
  2992. [AC_DEFINE([[USE_IPV6_TESTING]], [[1]], [Define to 1 if your kernel supports IPv6 and IPv6 is enabled and useful for testing.])]
  2993. )
  2994. # Check for fork() and waitpid(). They are used for tests.
  2995. AC_MSG_CHECKING([[for fork()]])
  2996. mhd_have_fork_waitpid='no'
  2997. AC_LINK_IFELSE(
  2998. [
  2999. AC_LANG_PROGRAM(
  3000. [[
  3001. #ifdef HAVE_SYS_TYPES_H
  3002. #include <sys/types.h>
  3003. #endif
  3004. #ifdef HAVE_UNISTD_H
  3005. #include <unistd.h>
  3006. #endif
  3007. ]], [[
  3008. pid_t p = fork ();
  3009. if (0 == p)
  3010. return 1;
  3011. ]])
  3012. ], [
  3013. AC_DEFINE([[HAVE_FORK]], [[1]], [Define to 1 if you have the usable `fork' function.])
  3014. AC_MSG_RESULT([[yes]])
  3015. AC_MSG_CHECKING([[for waitpid()]])
  3016. AC_LINK_IFELSE(
  3017. [
  3018. AC_LANG_PROGRAM(
  3019. [[
  3020. #ifdef HAVE_SYS_TYPES_H
  3021. #include <sys/types.h>
  3022. #endif
  3023. #ifdef HAVE_UNISTD_H
  3024. #include <unistd.h>
  3025. #endif
  3026. #include <sys/wait.h>
  3027. ]], [[
  3028. pid_t p = fork ();
  3029. if (0 == p)
  3030. return 1;
  3031. waitpid (p, (void*)0, 0)
  3032. ]])
  3033. ], [
  3034. AC_DEFINE([[HAVE_WAITPID]], [[1]], [Define to 1 if you have the usable `waitpid' function.])
  3035. AC_MSG_RESULT([[yes]])
  3036. mhd_have_fork_waitpid='yes'
  3037. ],[
  3038. AC_MSG_RESULT([[no]])
  3039. ])
  3040. ],[
  3041. AC_MSG_RESULT([[no]])
  3042. ])
  3043. AM_CONDITIONAL([HAVE_FORK_WAITPID], [test "x$mhd_have_fork_waitpid" = "xyes"])
  3044. # gcov compilation
  3045. AC_MSG_CHECKING(whether to compile with support for code coverage analysis)
  3046. AC_ARG_ENABLE([coverage],
  3047. AS_HELP_STRING([--enable-coverage],
  3048. [compile the library with code coverage support]),
  3049. [use_gcov=${enableval}],
  3050. [use_gcov=no])
  3051. AC_MSG_RESULT($use_gcov)
  3052. AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
  3053. AX_COUNT_CPUS
  3054. AC_MSG_CHECKING([for number of CPU cores to use in tests])
  3055. AS_VAR_IF([enable_heavy_tests], ["yes"],
  3056. [
  3057. # Enable usage of many core if heavy tests are enabled
  3058. AS_IF([[test "$CPU_COUNT" -gt "32"]], [[CPU_COUNT="32"]])dnl Limit resource usage
  3059. ],
  3060. [
  3061. # Limit usage to just a few cores if heavy tests are not enabled
  3062. AS_IF([[test "$CPU_COUNT" -gt "6"]], [[CPU_COUNT="6"]])
  3063. AS_IF([[test "$CPU_COUNT" -lt "2"]], [[CPU_COUNT="2"]])
  3064. ]
  3065. )
  3066. AC_MSG_RESULT([$CPU_COUNT])
  3067. AC_MSG_CHECKING([[whether to enable debug asserts]])
  3068. AC_ARG_ENABLE([[asserts]],
  3069. AS_HELP_STRING([[--enable-asserts]],
  3070. [enable test build with debug asserts]),
  3071. [], [[enable_asserts='no']])
  3072. AS_CASE([[$enable_asserts]], [[yes]], [[:]], [[no]], [[:]], [[enable_asserts='no']])
  3073. AC_MSG_RESULT([[$enable_asserts]])
  3074. AS_VAR_IF([[enable_asserts]], [["yes"]],
  3075. [
  3076. AC_DEFINE([[_DEBUG]], [[1]], [Define to use debug asserts.])
  3077. [mhd_assert_test_prg="#include <assert.h>
  3078. int pos_val(void) {return 5;}
  3079. int neg_val(void) {return -5;}
  3080. int main(void)
  3081. { int pos_var = pos_val(), neg_var = neg_val();
  3082. assert(neg_var > pos_var); /* Must trigger assert. */
  3083. (void)pos_var; (void)neg_var;
  3084. return 0; }
  3085. "]
  3086. AC_CACHE_CHECK([[whether system assert() is available]], [mhd_cv_sys_assert_avail],
  3087. [
  3088. AC_LINK_IFELSE([AC_LANG_SOURCE([[$mhd_assert_test_prg]])],
  3089. [[mhd_cv_sys_assert_avail='yes']],
  3090. [[mhd_cv_sys_assert_avail='no']])
  3091. ]
  3092. )
  3093. AS_VAR_IF([[mhd_cv_sys_assert_avail]], [["no"]], [],
  3094. [AC_DEFINE([[HAVE_ASSERT]], [[1]], [Define if you have usable assert() and assert.h])])
  3095. AS_UNSET([mhd_assert_test_prg])
  3096. ],
  3097. [AC_DEFINE([[NDEBUG]], [[1]], [Define to disable usage of debug asserts.])]
  3098. )
  3099. AS_UNSET([enabled_sanitizers])
  3100. AM_TESTS_ENVIRONMENT=""
  3101. AM_ASAN_OPTIONS=""
  3102. AM_UBSAN_OPTIONS=""
  3103. AM_LSAN_OPTIONS=""
  3104. AS_UNSET([ASAN_OPTIONS])
  3105. AS_UNSET([UBSAN_OPTIONS])
  3106. AS_UNSET([LSAN_OPTIONS])
  3107. AC_MSG_CHECKING([whether to enable run-time sanitizers])
  3108. AC_ARG_ENABLE([sanitizers],
  3109. [AS_HELP_STRING([[--enable-sanitizers[=address,undefined,leak,user-poison]]],
  3110. [enable run-time sanitizers, specify the list of types of sanitizers to enable or ]
  3111. [leave the list empty to enable all suppoted and availabe sanitizers])],
  3112. [], [enable_sanitizers=no])
  3113. AS_IF([test "x${enable_sanitizers}" = "x"], [enable_sanitizers="auto"])
  3114. AS_VAR_IF([enable_sanitizers], ["yes"], [enable_sanitizers="auto"])
  3115. AS_IF([test "x${enable_sanitizers}" = "xno"],
  3116. [
  3117. enable_sanitizers="no"
  3118. enable_san_address="no"
  3119. enable_san_undef="no"
  3120. enable_san_leak="no"
  3121. enable_san_upoison="no"
  3122. ],
  3123. [test "x${enable_sanitizers}" = "xauto"],
  3124. [
  3125. enable_san_address="auto"
  3126. enable_san_undef="auto"
  3127. enable_san_leak="auto"
  3128. enable_san_upoison="auto"
  3129. ],
  3130. [
  3131. AS_UNSET([san])
  3132. enable_san_address="no"
  3133. enable_san_undef="no"
  3134. enable_san_leak="no"
  3135. enable_san_upoison="no"
  3136. f][or san in `AS_ECHO([${enable_sanitizers}]) | tr ',' ' '`
  3137. do
  3138. AS_CASE([$san],
  3139. [address], [enable_san_address="yes"],
  3140. [undefined], [enable_san_undef="yes"],
  3141. [leak], [enable_san_leak="yes"],
  3142. [user-poison|user_poison], [enable_san_upoison="yes"],
  3143. [no|yes|auto], [AC_MSG_ERROR(["$san" cannot be used with other options for --enable-sanitizers=])],
  3144. [AC_MSG_ERROR([Unknown parameter "$san" for --enable-sanitizers=])]
  3145. )
  3146. done
  3147. AS_IF([test "x${enable_san_upoison}" = "xyes" && test "x${enable_san_address}" = "xno"],
  3148. [AC_MSG_ERROR([User memory poisoning cannot be used without address sanitizer])]
  3149. )
  3150. enable_sanitizers="selected"
  3151. ]
  3152. )
  3153. AS_CASE([${enable_sanitizers}],
  3154. [selected], [AC_MSG_RESULT([selected])],
  3155. [auto], [AC_MSG_RESULT([yes, detect and use supported sanitizers])],
  3156. [AC_MSG_RESULT([no])]
  3157. )
  3158. AS_VAR_IF([enable_sanitizers], ["no"], [:],
  3159. [
  3160. AS_UNSET([san_FLAGS]) # the sanitizer flags to be added to both CFLAGS and LDFLAGS
  3161. AS_UNSET([san_CFLAGS]) # the sanitizer flags to be added to CFLAGS
  3162. saved_CFLAGS="$CFLAGS"
  3163. AC_CACHE_CHECK([whether '-fsanitize=' works for $CC],
  3164. [mhd_cv_cc_sanitizer_works],
  3165. [
  3166. CFLAGS="${saved_CFLAGS} -fsanitize=wrongFeatureName"
  3167. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
  3168. [mhd_cv_cc_sanitizer_works=no], [mhd_cv_cc_sanitizer_works=yes])
  3169. ]
  3170. )
  3171. AS_VAR_IF([mhd_cv_cc_sanitizer_works], ["yes"],
  3172. [
  3173. AS_VAR_IF([enable_san_address], ["no"], [:],
  3174. [
  3175. AC_CACHE_CHECK([for address sanitizer], [mhd_cv_cc_sanitizer_address],
  3176. [
  3177. CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} -fsanitize=address"
  3178. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
  3179. [mhd_cv_cc_sanitizer_address=yes], [mhd_cv_cc_sanitizer_address=no])
  3180. ]
  3181. )
  3182. AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"],
  3183. [
  3184. AC_DEFINE([MHD_ASAN_ACTIVE], [1], [Define to '1' if you have address sanitizer enabled])
  3185. AX_APPEND_FLAG([-fsanitize=address], [san_FLAGS])
  3186. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }address"
  3187. AS_VAR_IF([enable_san_leak], ["no"], [:],
  3188. [
  3189. AC_CACHE_CHECK([whether leak detect is not rejected by address sanitizer], [mhd_cv_cc_sanitizer_address_leak],
  3190. [
  3191. CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS}"
  3192. ASAN_OPTIONS="exitcode=88:detect_leaks=1:halt_on_error=1"
  3193. export ASAN_OPTIONS
  3194. AC_RUN_IFELSE([AC_LANG_PROGRAM([],[])],
  3195. [mhd_cv_cc_sanitizer_address_leak=yes], [mhd_cv_cc_sanitizer_address_leak=no],
  3196. [
  3197. # Cross-compiling with sanitizers?
  3198. mhd_cv_cc_sanitizer_address_leak='assuming no'
  3199. ]
  3200. )
  3201. AS_UNSET([ASAN_OPTIONS])
  3202. ]
  3203. )
  3204. ]
  3205. )
  3206. AC_CACHE_CHECK([for pointer compare sanitizer], [mhd_cv_cc_sanitizer_pointer_compare],
  3207. [
  3208. CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-compare"
  3209. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
  3210. [mhd_cv_cc_sanitizer_pointer_compare=yes], [mhd_cv_cc_sanitizer_pointer_compare=no])
  3211. ]
  3212. )
  3213. AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_compare],["yes"],
  3214. [
  3215. AX_APPEND_FLAG([-fsanitize=pointer-compare], [san_FLAGS])
  3216. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer compare"
  3217. ]
  3218. )
  3219. AC_CACHE_CHECK([for pointer subtract sanitizer], [mhd_cv_cc_sanitizer_pointer_subtract],
  3220. [
  3221. CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-subtract"
  3222. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
  3223. [mhd_cv_cc_sanitizer_pointer_subtract=yes], [mhd_cv_cc_sanitizer_pointer_subtract=no])
  3224. ]
  3225. )
  3226. AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_subtract],["yes"],
  3227. [
  3228. AX_APPEND_FLAG([-fsanitize=pointer-subtract], [san_FLAGS])
  3229. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer subtract"
  3230. ]
  3231. )
  3232. AS_VAR_IF([enable_san_upoison], ["no"], [:],
  3233. [
  3234. AC_CHECK_HEADERS([sanitizer/asan_interface.h], [], [], [AC_INCLUDES_DEFAULT])
  3235. AS_IF([test "x${mhd_cv_cc_sanitizer_pointer_compare}" = "xyes" && test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes"],
  3236. [
  3237. AC_CACHE_CHECK([whether '__attribute__((no_sanitize("pointer-compare","pointer-subtract")))' works], [mhd_cv_func_attribute_nosanitize_ptr],
  3238. [
  3239. ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1"
  3240. export ASAN_OPTIONS
  3241. CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS}"
  3242. AC_RUN_IFELSE(
  3243. [
  3244. AC_LANG_PROGRAM(
  3245. [[
  3246. #include <stdlib.h>
  3247. __attribute__((no_sanitize("pointer-compare","pointer-subtract")))
  3248. int ptr_process(void *ptr1, void *ptr2)
  3249. {
  3250. if ((char*)ptr1 <= (char*)ptr2)
  3251. return (int) ((char*)ptr2 - (char*)ptr1);
  3252. return (int) ((char*)ptr1 - (char*)ptr2);
  3253. }
  3254. ]],
  3255. [[
  3256. int *a = (int*) malloc (sizeof(int)*4);
  3257. int *b = (int*) malloc (sizeof(long)*6);
  3258. int c = ptr_process(a, b);
  3259. if (c)
  3260. {
  3261. free (b);
  3262. free (a);
  3263. return 0;
  3264. }
  3265. free (a);
  3266. free (b);
  3267. ]]
  3268. )
  3269. ],
  3270. [mhd_cv_func_attribute_nosanitize_ptr=yes], [mhd_cv_func_attribute_nosanitize_ptr=no],
  3271. [
  3272. # Cross-compiling with sanitizers??
  3273. mhd_cv_func_attribute_nosanitize_ptr='assuming no'
  3274. ]
  3275. )
  3276. AS_UNSET([ASAN_OPTIONS])
  3277. ]
  3278. )
  3279. AS_VAR_IF([mhd_cv_func_attribute_nosanitize_ptr], ["yes"],
  3280. [AC_DEFINE([FUNC_ATTR_PTRCOMPARE_WOKRS],[1],[Define to '1' if '__attribute__((no_sanitize("pointer-compare","pointer-subtract")))' works])],
  3281. [
  3282. AC_CACHE_CHECK([whether '__attribute__((no_sanitize("address")))' works for pointers compare], [mhd_cv_func_attribute_nosanitize_addr],
  3283. [
  3284. ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1"
  3285. export ASAN_OPTIONS
  3286. CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS}"
  3287. AC_RUN_IFELSE(
  3288. [
  3289. AC_LANG_PROGRAM(
  3290. [[
  3291. #include <stdlib.h>
  3292. __attribute__((no_sanitize("address")))
  3293. int ptr_process(void *ptr1, void *ptr2)
  3294. {
  3295. if ((char*)ptr1 <= (char*)ptr2)
  3296. return (int) ((char*)ptr2 - (char*)ptr1);
  3297. return (int) ((char*)ptr1 - (char*)ptr2);
  3298. }
  3299. ]],
  3300. [[
  3301. int *a = (int*) malloc (sizeof(int)*4);
  3302. int *b = (int*) malloc (sizeof(long)*6);
  3303. int c = ptr_process(a, b);
  3304. if (c)
  3305. {
  3306. free (b);
  3307. free (a);
  3308. return 0;
  3309. }
  3310. free (a);
  3311. free (b);
  3312. ]]
  3313. )
  3314. ],
  3315. [mhd_cv_func_attribute_nosanitize_addr=yes], [mhd_cv_func_attribute_nosanitize_addr=no],
  3316. [
  3317. # Cross-compiling with sanitizers??
  3318. mhd_cv_func_attribute_nosanitize_addr='assuming no'
  3319. ]
  3320. )
  3321. AS_UNSET([ASAN_OPTIONS])
  3322. ]
  3323. )
  3324. AS_VAR_IF([mhd_cv_func_attribute_nosanitize_addr], ["yes"],
  3325. [AC_DEFINE([FUNC_ATTR_NOSANITIZE_WORKS],[1],[Define to '1' if '__attribute__((no_sanitize("address")))' works for pointers compare])]
  3326. )
  3327. ]
  3328. )
  3329. ]
  3330. )
  3331. ]
  3332. )
  3333. ]
  3334. )
  3335. AS_IF([test "x${enable_san_address}" = "xyes" && test "x${mhd_cv_cc_sanitizer_address}" != "xyes"],
  3336. [AC_MSG_ERROR([Address sanitizer cannot be enabled])]
  3337. )
  3338. enable_san_address="${mhd_cv_cc_sanitizer_address}"
  3339. ]
  3340. )
  3341. AS_VAR_IF([enable_san_undef], ["no"], [:],
  3342. [
  3343. dnl Ensure that '#' will be processed correctly
  3344. [
  3345. test_undf_prog='
  3346. #include <stdio.h>
  3347. static void func_out_b(char *arr)
  3348. {
  3349. arr[0] = 0;
  3350. arr[16] = 2;
  3351. }
  3352. static unsigned int int_deref(void *ptr)
  3353. {
  3354. return (*((unsigned int*)ptr)) + 2;
  3355. }
  3356. static int func1(void)
  3357. {
  3358. char chr[16];
  3359. func_out_b (chr);
  3360. return (int) (int_deref(chr + 1) + int_deref(chr + 2));
  3361. }
  3362. int main(void)
  3363. {
  3364. unsigned long ulvar;
  3365. signed char ch1;
  3366. ulvar = -1 * func1();
  3367. ch1 = ulvar * 6UL;
  3368. printf("%lu\n", ulvar + ch1);
  3369. return 0;
  3370. }
  3371. '
  3372. ]
  3373. AC_CACHE_CHECK([for undefined behavior sanitizer], [mhd_cv_cc_sanitizer_undefined],
  3374. [
  3375. CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined"
  3376. AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])],
  3377. [mhd_cv_cc_sanitizer_undefined=yes], [mhd_cv_cc_sanitizer_undefined=no])
  3378. ]
  3379. )
  3380. AS_VAR_IF([mhd_cv_cc_sanitizer_undefined],["yes"],
  3381. [
  3382. AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS])
  3383. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
  3384. ],
  3385. [
  3386. AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-undefined-trap-on-error'], [mhd_cv_cc_sanitizer_undefined_trap],
  3387. [
  3388. CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-undefined-trap-on-error"
  3389. AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])],
  3390. [mhd_cv_cc_sanitizer_undefined_trap=yes], [mhd_cv_cc_sanitizer_undefined_trap=no])
  3391. ]
  3392. )
  3393. AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap], ["yes"],
  3394. [
  3395. AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS])
  3396. AX_APPEND_FLAG([-fsanitize-undefined-trap-on-error], [san_FLAGS])
  3397. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
  3398. AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited])
  3399. ],
  3400. [
  3401. AS_IF([test -z "${enabled_sanitizers}"],
  3402. [
  3403. # Last resort
  3404. AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-trap=all'], [mhd_cv_cc_sanitizer_undefined_trap_all],
  3405. [
  3406. CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all"
  3407. AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])],
  3408. [mhd_cv_cc_sanitizer_undefined_trap_all=yes], [mhd_cv_cc_sanitizer_undefined_trap_all=no])
  3409. ]
  3410. )
  3411. AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap_all],["yes"],
  3412. [
  3413. AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS])
  3414. AX_APPEND_FLAG([-fsanitize-trap=all], [san_FLAGS])
  3415. CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all"
  3416. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
  3417. AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited])
  3418. ]
  3419. )
  3420. ]
  3421. )
  3422. ]
  3423. )
  3424. ]
  3425. )
  3426. AS_CASE(["$enabled_sanitizers"], [*undefined],
  3427. [
  3428. AS_VAR_IF([mhd_cv_cc_sanitizer_undefined], ["yes"],[],
  3429. [
  3430. # A workaround for broken clang which is trying to use UBSan lib
  3431. # even when instructed to not use it
  3432. CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS}"
  3433. AX_APPEND_LINK_FLAGS([-fsanitize-trap=implicit-conversion],
  3434. [san_FLAGS], [], [AC_LANG_SOURCE([${test_undf_prog}])])
  3435. ]
  3436. )
  3437. CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS}"
  3438. AX_APPEND_LINK_FLAGS([-fsanitize=bounds-strict -fsanitize=local-bounds -fsanitize=implicit-conversion -fsanitize=nullability-arg],
  3439. [san_CFLAGS], [], [AC_LANG_SOURCE([${test_undf_prog}])])
  3440. ]
  3441. )
  3442. AS_UNSET([test_undf_prog])
  3443. AS_CASE(["$enabled_sanitizers"],
  3444. [*undefined], [enable_san_undef="yes"],
  3445. [
  3446. AS_VAR_IF([enable_san_undef], [yes], [AC_MSG_ERROR([Undefined behavior sanitizer cannot be enabled])])
  3447. enable_san_undef="no"
  3448. ]
  3449. )
  3450. ]
  3451. )
  3452. AS_VAR_IF([enable_san_leak], ["no"], [:],
  3453. [
  3454. AC_CACHE_CHECK([for leak sanitizer], [mhd_cv_cc_sanitizer_leak],
  3455. [
  3456. CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS} -fsanitize=leak"
  3457. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
  3458. [mhd_cv_cc_sanitizer_leak=yes], [mhd_cv_cc_sanitizer_leak=no])
  3459. ]
  3460. )
  3461. AS_VAR_IF([mhd_cv_cc_sanitizer_leak],["yes"],
  3462. [
  3463. AX_APPEND_FLAG([-fsanitize=leak], [san_FLAGS])
  3464. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }leak"
  3465. ]
  3466. )
  3467. AS_IF([test "x${enable_san_leak}" = "xyes" && test "x${mhd_cv_cc_sanitizer_leak}" != "xyes"],
  3468. [AC_MSG_ERROR([User poison cannot be enabled])]
  3469. )
  3470. enable_san_leak="${mhd_cv_cc_sanitizer_leak}"
  3471. ]
  3472. )
  3473. AS_IF([test -z "${enabled_sanitizers}"],
  3474. [AC_MSG_ERROR([cannot find any sanitizer supported by $CC])])
  3475. AS_VAR_IF([enable_san_upoison], ["no"], [:],
  3476. [
  3477. AC_MSG_CHECKING([whether to enable user memory poisoning])
  3478. AS_IF([test "x${mhd_cv_cc_sanitizer_address}" = "xyes" && test "x${mhd_cv_cc_sanitizer_pointer_compare}" = "xyes" && \
  3479. test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes" && \
  3480. (test "x${mhd_cv_func_attribute_nosanitize_ptr}" = "xyes" || test "x${mhd_cv_func_attribute_nosanitize_addr}" = "xyes")],
  3481. [
  3482. AC_DEFINE([MHD_ASAN_POISON_ACTIVE], [1], [Define to '1' if user memory poison is used])
  3483. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }user-poison"
  3484. enable_san_upoison="yes"
  3485. AC_MSG_RESULT([yes])
  3486. ],
  3487. [
  3488. AC_MSG_RESULT([no])
  3489. AS_VAR_IF([enable_san_upoison], ["yes"],
  3490. [AC_MSG_ERROR([User memory poisoning cannot be enabled])])
  3491. enable_san_upoison="no"
  3492. ]
  3493. )
  3494. ]
  3495. )
  3496. AS_VAR_IF([enable_san_address], ["yes"],
  3497. [
  3498. AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"],
  3499. [
  3500. AX_APPEND_FLAG([-D_FORTIFY_SOURCE=0], [san_CFLAGS])
  3501. CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS}"
  3502. AX_APPEND_COMPILE_FLAGS([-Wp,-U_FORTIFY_SOURCE], [san_CFLAGS])
  3503. ],
  3504. [AC_MSG_WARN([$CC does not support address sanitizer])]
  3505. )
  3506. ]
  3507. )
  3508. CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS}"
  3509. # Always stop on sanitizer error
  3510. AX_APPEND_COMPILE_FLAGS([-fno-sanitize-recover=all], [san_CFLAGS])
  3511. # Get a better output for sanitizers error reporting
  3512. AX_APPEND_COMPILE_FLAGS([-fno-omit-frame-pointer -fno-optimize-sibling-calls],
  3513. [san_CFLAGS])
  3514. AS_VAR_IF([enable_san_address], ["yes"],
  3515. [
  3516. AM_ASAN_OPTIONS="exitcode=88:strict_string_checks=1:detect_stack_use_after_return=1"
  3517. AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:check_initialization_order=1:strict_init_order=1:redzone=64"
  3518. AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:max_free_fill_size=1024:detect_invalid_pointer_pairs=3"
  3519. AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:handle_ioctl=1:halt_on_error=1"
  3520. AS_VAR_IF([enable_san_upoison], ["yes"], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:allow_user_poisoning=1"])
  3521. AS_VAR_IF([enable_san_leak], ["yes"],
  3522. [AS_VAR_IF([mhd_cv_cc_sanitizer_address_leak], ["yes"],
  3523. [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=1"])
  3524. ], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=0"]
  3525. )
  3526. ]
  3527. )
  3528. AS_VAR_IF([enable_san_undef], [yes],
  3529. [AM_UBSAN_OPTIONS="exitcode=87:print_stacktrace=1:halt_on_error=1"])
  3530. AS_VAR_IF([enable_san_leak], ["yes"],
  3531. [AM_LSAN_OPTIONS="use_unaligned=1"]
  3532. )
  3533. AM_TESTS_ENVIRONMENT='\
  3534. ASAN_OPTIONS="$(AM_ASAN_OPTIONS)" ; export ASAN_OPTIONS ; \
  3535. UBSAN_OPTIONS="$(AM_UBSAN_OPTIONS)" ; export UBSAN_OPTIONS ; \
  3536. LSAN_OPTIONS="$(AM_LSAN_OPTIONS)" ; export LSAN_OPTIONS ;'
  3537. ]
  3538. )
  3539. CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS}"
  3540. AS_UNSET([saved_CFLAGS])
  3541. ]
  3542. )
  3543. AM_CONDITIONAL([USE_SANITIZERS],
  3544. [test -n "$enabled_sanitizers" && test "x$mhd_cv_cc_sanitizer_works" = "xyes"])
  3545. AC_SUBST([AM_ASAN_OPTIONS])
  3546. AC_SUBST([AM_UBSAN_OPTIONS])
  3547. AC_SUBST([AM_LSAN_OPTIONS])
  3548. AC_SUBST([AM_TESTS_ENVIRONMENT])
  3549. AM_CONDITIONAL([USE_BROKEN_TLS_TESTS],[false])
  3550. MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS -export-dynamic -no-undefined"
  3551. AC_SUBST([CPU_COUNT])
  3552. AC_SUBST([HEAVY_TESTS_NOTPARALLEL])
  3553. AC_SUBST(MHD_LIB_CPPFLAGS)
  3554. AC_SUBST(MHD_LIB_CFLAGS)
  3555. AC_SUBST(MHD_LIB_LDFLAGS)
  3556. AC_SUBST(MHD_LIBDEPS)
  3557. AC_SUBST(MHD_TLS_LIB_CPPFLAGS)
  3558. AC_SUBST(MHD_TLS_LIB_CFLAGS)
  3559. AC_SUBST(MHD_TLS_LIB_LDFLAGS)
  3560. AC_SUBST(MHD_TLS_LIBDEPS)
  3561. # for pkg-config
  3562. AC_SUBST([MHD_REQ_PRIVATE])
  3563. AC_SUBST([MHD_LIBDEPS_PKGCFG])
  3564. AC_SUBST(CPPFLAGS)
  3565. AC_SUBST(LIBS)
  3566. AC_SUBST(LDFLAGS)
  3567. # Used for 'po' directory staff
  3568. AC_SUBST([ac_configure_args])
  3569. AC_SUBST([EMPTY_VAR], [[]])
  3570. # We define the paths here, because MinGW/GCC expands paths
  3571. # passed through the command line ("-DDIR=..."). This would
  3572. # lead to hard-coded paths ("C:\mingw\mingw\bin...") that do
  3573. # not contain the actual installation.
  3574. AC_DEFINE_DIR([MHD_PLUGIN_INSTALL_PREFIX], [libdir/libmicrohttpd], [tls plugins])
  3575. # should experimental code be compiled (code that may not yet compile)?
  3576. AC_MSG_CHECKING(whether to compile experimental code)
  3577. AC_ARG_ENABLE([experimental],
  3578. [AS_HELP_STRING([--enable-experimental], [enable compiling experimental code])],
  3579. [enable_experimental=${enableval}],
  3580. [enable_experimental=no])
  3581. AC_MSG_RESULT($enable_experimental)
  3582. AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
  3583. AC_CONFIG_FILES([libmicrohttpd.pc
  3584. w32/common/microhttpd_dll_res_vc.rc
  3585. Makefile
  3586. contrib/Makefile
  3587. doc/Makefile
  3588. doc/doxygen/libmicrohttpd.doxy
  3589. doc/doxygen/Makefile
  3590. doc/examples/Makefile
  3591. m4/Makefile
  3592. src/Makefile
  3593. src/include/Makefile
  3594. src/lib/Makefile
  3595. src/microhttpd/Makefile
  3596. src/microhttpd_ws/Makefile
  3597. src/examples/Makefile
  3598. src/testcurl/Makefile
  3599. src/testcurl/https/Makefile
  3600. src/testzzuf/Makefile])
  3601. AC_OUTPUT
  3602. # Finally: summary
  3603. AS_IF([test "x$enable_curl" != "xyes"],
  3604. [MSG_CURL="no, many unit tests will not run"],
  3605. [MSG_CURL="yes"])
  3606. AS_VAR_IF([os_is_windows], ["yes"],
  3607. [os_ver_msg="
  3608. Target W32 ver: ${mhd_w32_ver_msg}"], [AS_UNSET([[os_ver_msg]])])
  3609. AC_MSG_NOTICE([GNU libmicrohttpd ${PACKAGE_VERSION} Configuration Summary:
  3610. Target directory: ${prefix}
  3611. Cross-compiling: ${cross_compiling}
  3612. Operating System: ${mhd_host_os}${os_ver_msg}
  3613. Shutdown of listening socket triggers select: ${mhd_cv_host_shtdwn_trgr_select}
  3614. Inter-thread comm: ${use_itc}
  3615. poll support: ${enable_poll=no}
  3616. epoll support: ${enable_epoll=no}
  3617. sendfile used: ${found_sendfile}
  3618. HTTPS support: ${MSG_HTTPS}
  3619. Threading lib: ${USE_THREADS}
  3620. Use thread names: ${enable_thread_names}
  3621. Use debug asserts: ${enable_asserts}
  3622. Use sanitizers: ${enabled_sanitizers:=no}
  3623. Messages: ${enable_messages}
  3624. Basic auth.: ${enable_bauth}
  3625. Digest auth.: ${enable_dauth}
  3626. HTTP "Upgrade": ${enable_httpupgrade}
  3627. Postproc: ${enable_postprocessor}
  3628. Build docs: ${enable_doc}
  3629. Build examples: ${enable_examples}
  3630. Test with libcurl: ${MSG_CURL}
  3631. ])
  3632. AS_IF([test "x$enable_https" = "xyes"],
  3633. [AC_MSG_NOTICE([HTTPS subsystem configuration:
  3634. License : LGPL version 2.1 or any later version
  3635. ])],
  3636. [AC_MSG_NOTICE([
  3637. License : LGPLv2.1+ or eCos
  3638. ])])
  3639. AS_IF([test "x$enable_bauth" != "xyes" || \
  3640. test "x$enable_dauth" != "xyes" || \
  3641. test "x$enable_httpupgrade" != "xyes" || \
  3642. test "x$enable_postprocessor" != "xyes"],
  3643. [AC_MSG_NOTICE([WARNING: This will be a custom build with missing symbols. Do NOT use this build in a distribution. Building with these kinds of configure options is only for custom builds for embedded systems.])])