configure.ac 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468
  1. # This file is part of libmicrohttpd.
  2. # (C) 2006-2020 Christian Grothoff (and other contributing authors)
  3. #
  4. # libmicrohttpd is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published
  6. # by the Free Software Foundation; either version 3, or (at your
  7. # option) any later version.
  8. #
  9. # libmicrohttpd is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with libmicrohttpd; see the file COPYING. If not, write to the
  16. # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. # Boston, MA 02110-1301, USA.
  18. #
  19. #
  20. # Process this file with autoconf to produce a configure script.
  21. #
  22. #
  23. AC_PREREQ([2.64])
  24. LT_PREREQ([2.4.0])
  25. AC_INIT([GNU Libmicrohttpd],[0.9.73],[[email protected]])
  26. AC_CONFIG_AUX_DIR([build-aux])
  27. AM_INIT_AUTOMAKE([silent-rules] [subdir-objects])
  28. AC_CONFIG_HEADERS([MHD_config.h])
  29. AC_CONFIG_MACRO_DIR([m4])
  30. LIB_VERSION_CURRENT=70
  31. LIB_VERSION_REVISION=0
  32. LIB_VERSION_AGE=58
  33. AC_SUBST(LIB_VERSION_CURRENT)
  34. AC_SUBST(LIB_VERSION_REVISION)
  35. AC_SUBST(LIB_VERSION_AGE)
  36. AC_MSG_CHECKING([[whether z/OS special settings are required]])
  37. AS_IF([test `uname -s` = "OS/390"],
  38. [
  39. # configure binaries for z/OS
  40. AS_IF([test -z "$CC"],
  41. [CC=`pwd`"/contrib/xcc"
  42. chmod +x $CC || true])
  43. AS_IF([test -z "$CPP"],
  44. CPP="c89 -E")
  45. AS_IF([test -z "$CXXCPP"],
  46. CXXCPP="c++ -E -+")
  47. AC_MSG_RESULT([[yes]])
  48. # _CCC_CCMODE=1
  49. # _C89_CCMODE=1
  50. ],
  51. AC_MSG_RESULT([[no]])
  52. )
  53. # Checks for programs.
  54. AC_PROG_AWK
  55. AC_PROG_GREP
  56. AC_PROG_INSTALL
  57. AC_PROG_LN_S
  58. AC_PROG_MAKE_SET
  59. AC_CANONICAL_HOST
  60. m4_version_prereq([2.70],
  61. [
  62. # Find C compiler and compiler options to support
  63. # the latest C standard (C11). Fallback to C99 and C89
  64. # if later C versions are not supported.
  65. AC_PROG_CC
  66. ],
  67. [
  68. # Find C compiler and compiler options to support
  69. # the latest C standard (C99). Fallback to C89
  70. # if later C versions are not supported.
  71. AC_PROG_CC_STDC
  72. ]
  73. )
  74. MHD_SYS_EXT
  75. LT_INIT([win32-dll])
  76. LT_LANG([Windows Resource])
  77. # Checks for gettext.
  78. m4_ifdef([AM_GNU_GETTEXT], [
  79. AS_VAR_SET_IF([enable_nls], [], [[enable_nls=no]])
  80. AM_GNU_GETTEXT([external],[need-ngettext])
  81. AC_CONFIG_FILES([po/Makefile.in])
  82. have_po=yes
  83. ], [
  84. have_po=no
  85. ])
  86. m4_ifdef([AM_GNU_GETTEXT_VERSION], [
  87. #do not indent here
  88. AM_GNU_GETTEXT_VERSION([0.20.2])
  89. ])
  90. AM_CONDITIONAL([HAVE_PO], [ test "$have_po" = yes ])
  91. # Adam shostack suggests the following for Windows:
  92. # -D_FORTIFY_SOURCE=2 -fstack-protector-all
  93. AC_ARG_ENABLE([gcc-hardening],
  94. [AS_HELP_STRING([--enable-gcc-hardening], [enable compiler security checks])],
  95. [AS_IF([test x$enableval = xyes],[
  96. CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all"
  97. CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector"
  98. CFLAGS="$CFLAGS --param ssp-buffer-size=1"
  99. LDFLAGS="$LDFLAGS -pie"
  100. ])])
  101. # Linker hardening options
  102. # Currently these options are ELF specific - you can't use this with MacOSX
  103. AC_ARG_ENABLE([linker-hardening],
  104. [AS_HELP_STRING([--enable-linker-hardening], [enable linker security fixups])],
  105. [AS_IF([test x$enableval = xyes],
  106. [LDFLAGS="$LDFLAGS -z relro -z now"])])
  107. AC_ARG_ENABLE([sanitizer],
  108. [AS_HELP_STRING([--enable-sanitizer], [enable Address Sanitizer and Undefined Behavior Sanitizer])],
  109. [AS_IF([test x$enableval = xyes],[
  110. CFLAGS="$CFLAGS -fsanitize=address,undefined -fno-omit-frame-pointer"
  111. ])])
  112. # Workaround for libgcrypt
  113. AS_IF([[test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x"]], [[SYSROOT="$lt_sysroot"]])
  114. PACKAGE_VERSION_MAJOR='m4_car(m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  115. PACKAGE_VERSION_MINOR='m4_argn(2, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  116. PACKAGE_VERSION_SUBMINOR='m4_argn(3, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  117. AS_VAR_ARITH([MHD_W32_DLL_SUFF],[[$LIB_VERSION_CURRENT - $LIB_VERSION_AGE]])
  118. AC_SUBST([PACKAGE_VERSION_MAJOR])
  119. AC_SUBST([PACKAGE_VERSION_MINOR])
  120. AC_SUBST([PACKAGE_VERSION_SUBMINOR])
  121. AC_SUBST([MHD_W32_DLL_SUFF])
  122. AC_CONFIG_FILES([src/microhttpd/microhttpd_dll_res.rc])
  123. MHD_LIB_CPPFLAGS=""
  124. MHD_LIB_CFLAGS=""
  125. MHD_LIB_LDFLAGS=""
  126. MHD_LIBDEPS=""
  127. # for pkg-config
  128. MHD_REQ_PRIVATE=''
  129. MHD_LIBDEPS_PKGCFG=''
  130. AH_TEMPLATE([[HAVE_STDBOOL_H]], [Define to 1 if you have the <stdbool.h> header file and <stdbool.h> defines 'bool' type.])
  131. AH_TEMPLATE([[HAVE_REAL_BOOL]], [Define to 1 if you have the real boolean type.])
  132. AH_TEMPLATE([[bool]], [Define to type name which will be used as boolean type.])
  133. AC_CHECK_HEADER([stdbool.h],
  134. [
  135. AC_CHECK_TYPE([bool],
  136. [
  137. AC_DEFINE([[HAVE_STDBOOL_H]], [[1]])
  138. AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])
  139. ],
  140. [
  141. AC_MSG_WARN([[Header <stdbool.h> is present, but "bool" type cannot be detected. Check compiler flags.]])
  142. AC_DEFINE([[bool]], [[int]])
  143. ], [
  144. #include <stdbool.h>
  145. ]
  146. )
  147. ],
  148. [
  149. AC_CHECK_TYPE([bool],
  150. [AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])],
  151. [
  152. AC_CHECK_TYPE([_Bool],
  153. [
  154. AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])
  155. AC_DEFINE([[bool]], [[_Bool]])
  156. ],
  157. [
  158. AC_DEFINE([[bool]], [[int]])
  159. ], []
  160. )
  161. ], []
  162. )
  163. ],
  164. [AC_INCLUDES_DEFAULT]
  165. )
  166. AC_CACHE_CHECK([[whether "true" is defined or builtin]], [[mhd_cv_macro_true_defined]],
  167. [AC_COMPILE_IFELSE(
  168. [AC_LANG_PROGRAM(
  169. [[
  170. #ifdef HAVE_STDBOOL_H
  171. #include <stdbool.h>
  172. #endif
  173. ]], [[
  174. #if defined(true)
  175. /* dummy */
  176. #else
  177. (void)true;
  178. #endif
  179. ]])
  180. ], [[mhd_cv_macro_true_defined='yes']], [[mhd_cv_macro_true_defined='no']])
  181. ])
  182. AS_VAR_IF([[mhd_cv_macro_true_defined]], [["yes"]], [[:]],
  183. [AC_DEFINE([[true]],[[(!0)]], [Define to value interpreted by compiler as boolean "true", if "true" is not defined by system headers.])])
  184. AC_CACHE_CHECK([[whether "false" is defined or builtin]], [[mhd_cv_macro_false_defined]],
  185. [AC_COMPILE_IFELSE(
  186. [AC_LANG_PROGRAM(
  187. [[
  188. #ifdef HAVE_STDBOOL_H
  189. #include <stdbool.h>
  190. #endif
  191. ]], [[
  192. #if !defined(false)
  193. (void)false;
  194. #else
  195. /* dummy */
  196. #endif
  197. ]])
  198. ], [[mhd_cv_macro_false_defined='yes']], [[mhd_cv_macro_false_defined='no']])
  199. ])
  200. AS_VAR_IF([[mhd_cv_macro_false_defined]], [["yes"]], [[:]],
  201. [AC_DEFINE([[false]],[[0]], [Define to value interpreted by compiler as boolean "false", if "false" is not defined by system headers.])])
  202. AC_CACHE_CHECK([[whether "true" and "false" could be used]], [[mhd_cv_macro_true_false_valid]],
  203. [AC_COMPILE_IFELSE(
  204. [AC_LANG_PROGRAM(
  205. [[
  206. #ifdef HAVE_STDBOOL_H
  207. #include <stdbool.h>
  208. #endif
  209. ]], [[
  210. int var1[true ? 1 : -1] = { 1 };
  211. int var2[false ? -1 : 1] = { 2 };
  212. int var3[!true ? -1 : 1] = { 3 };
  213. int var4[!false ? 1 : -1] = { 4 };
  214. if (var1[0] == var2[0] || var3[0] == var4[0])
  215. return 1;
  216. ]])
  217. ], [[mhd_cv_macro_true_false_valid='yes']], [[mhd_cv_macro_true_false_valid='no']])
  218. ])
  219. AS_VAR_IF([[mhd_cv_macro_true_false_valid]], [["yes"]], [[:]],
  220. [AC_MSG_ERROR([[Value of "true" or value of "false" is not valid. Check config.log for details.]])])
  221. AX_CHECK_COMPILE_FLAG([[-Werror=attributes]],
  222. [
  223. save_CFLAGS="$CFLAGS"
  224. CFLAGS="$CFLAGS -Werror=attributes"
  225. AC_MSG_CHECKING([[whether -Werror=attributes actually works]])
  226. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  227. [[__attribute__((non_existing_attrb_dummy)) int SimpleFunc(void) {return 3;}]], [[int r = SimpleFunc(); if (r) return r;]])],
  228. [
  229. AC_MSG_RESULT([[no]])
  230. errattr_CFLAGS=""
  231. ], [
  232. AC_MSG_RESULT([[yes]])
  233. errattr_CFLAGS="-Werror=attributes"
  234. ])
  235. CFLAGS="$save_CFLAGS"
  236. ],
  237. [[errattr_CFLAGS=""]], [], [])
  238. AC_MSG_CHECKING([[for function inline keywords supported by $CC]])
  239. save_CFLAGS="$CFLAGS"
  240. CFLAGS="$CFLAGS $errattr_CFLAGS"
  241. inln_prfx="none"
  242. # Prefer always inline functions
  243. for inln_prfx_chk in InlineWithAttr __forceinline inline __inline__ __inline _inline _Inline; do
  244. # Try to link to avoid "symbol undefined" problems at build time
  245. AS_IF([[test "x$inln_prfx_chk" = "xInlineWithAttr"]],
  246. [
  247. AS_IF([[test "x$errattr_CFLAGS" = "x"]],
  248. [[ # Skip test with attribute as negative result can't be detected
  249. inln_prfx_chk="__forceinline" # use next value
  250. ]],[[inln_prfx_chk="inline __attribute__((always_inline))"]])
  251. ])
  252. AC_LINK_IFELSE(
  253. [
  254. AC_LANG_PROGRAM(
  255. [[
  256. #ifdef __cplusplus
  257. #error This test is only for C.
  258. choke me
  259. #endif
  260. #ifdef HAVE_STDBOOL_H
  261. #include <stdbool.h>
  262. #endif
  263. static $inln_prfx_chk bool cmpfn(int x, int y)
  264. { return x > y; }
  265. static $inln_prfx_chk int sumfn(int x, int y)
  266. { return x + y; }
  267. ]],[[
  268. int a = 1, b = 100, c;
  269. if (cmpfn(a, b))
  270. c = sumfn(a, b);
  271. else
  272. c = 0 - sumfn(a, b);
  273. ]])
  274. ],
  275. [[ inln_prfx="$inln_prfx_chk" ]])
  276. test "x$inln_prfx" != "xnone" && break
  277. done
  278. AS_IF([[test "x$inln_prfx" != "xnone"]],
  279. [
  280. AC_DEFINE([INLINE_FUNC],[1],[Define to 1 if your C compiler supports inline functions.])
  281. AC_DEFINE_UNQUOTED([_MHD_static_inline],[static $inln_prfx],[Define to prefix which will be used with MHD static inline functions.])
  282. ], [
  283. AC_DEFINE([_MHD_static_inline],[static],[Define to prefix which will be used with MHD static inline functions.])
  284. ])
  285. AC_MSG_RESULT([[$inln_prfx]])
  286. CFLAGS="$save_CFLAGS"
  287. # Check system type
  288. shutdown_trig_select='no'
  289. AC_MSG_CHECKING([[for target host OS]])
  290. AS_CASE(["$host_os"],
  291. [*darwin* | *rhapsody* | *macosx*],
  292. [AC_DEFINE_UNQUOTED(OSX,1,[This is an OS X system])
  293. CFLAGS="-no-cpp-precomp -fno-common $CFLAGS"
  294. mhd_host_os='Darwin'
  295. AC_MSG_RESULT([[$mhd_host_os]])],
  296. [freebsd*],
  297. [AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
  298. AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system])
  299. mhd_host_os='FreeBSD'
  300. AC_MSG_RESULT([[$mhd_host_os]])],
  301. [openbsd*],
  302. [AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
  303. AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system])
  304. mhd_host_os='OpenBSD'
  305. AC_MSG_RESULT([[$mhd_host_os]])],
  306. [netbsd*],
  307. [AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
  308. AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system])
  309. mhd_host_os='NetBSD'
  310. AC_MSG_RESULT([[$mhd_host_os]])],
  311. [*solaris*],
  312. [AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system])
  313. AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno does not work])
  314. mhd_host_os='Solaris'
  315. AC_MSG_RESULT([[$mhd_host_os]])
  316. AC_SEARCH_LIBS(gethostbyname, nsl)
  317. AC_SEARCH_LIBS(socket, socket)],
  318. [*arm-linux*],
  319. [AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel])
  320. mhd_host_os='ARM Linux'
  321. AC_MSG_RESULT([[$mhd_host_os]])
  322. CFLAGS="-fPIC -pipe $CFLAGS"],
  323. [*linux*],
  324. [AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel])
  325. mhd_host_os='Linux'
  326. AC_MSG_RESULT([[$mhd_host_os]])],
  327. [*cygwin*],
  328. [AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
  329. mhd_host_os='Windows (Cygwin)'
  330. AC_MSG_RESULT([[$mhd_host_os]])
  331. os_is_windows=yes],
  332. [*mingw*],
  333. [AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
  334. AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
  335. mhd_host_os='Windows (MinGW)'
  336. AC_MSG_RESULT([[$mhd_host_os]])
  337. LIBS="$LIBS -lws2_32"
  338. AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([[Winsock2 headers are required for W32]])], [AC_INCLUDES_DEFAULT])
  339. AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool],
  340. [mslibcheck=`lib 2>&1`
  341. AS_IF([echo "$mslibcheck" | $GREP -e '^Microsoft (R) Library Manager' - >/dev/null],
  342. [ac_cv_use_ms_lib_tool=yes],
  343. [ac_cv_use_ms_lib_tool=no])
  344. ])
  345. AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes"],
  346. [AC_SUBST([MS_LIB_TOOL], [[lib]])])
  347. AC_SUBST([lt_cv_objdir])
  348. os_is_windows=yes
  349. os_is_native_w32=yes
  350. ],
  351. [*openedition*],
  352. [AC_DEFINE_UNQUOTED(OS390,1,[This is a OS/390 system])
  353. mhd_host_os='OS/390'
  354. AC_MSG_RESULT([[$mhd_host_os]])],
  355. [gnu*],
  356. [AC_DEFINE([[GNU_HURD]], [[1]], [Define to `1' if host machine runs on GNU Hurd.])
  357. mhd_host_os='GNU Hurd'
  358. AC_MSG_RESULT([[$mhd_host_os]])
  359. ],
  360. [
  361. mhd_host_os='unrecognised OS'
  362. AC_MSG_RESULT([[$mhd_host_os]])
  363. AC_MSG_WARN([Unrecognised OS $host_os])
  364. AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
  365. ])
  366. AM_CONDITIONAL([CYGWIN_TARGET], [[test "x$os_is_windows" = "xyes" && \
  367. test "x${os_is_native_w32}" != "xyes"]])
  368. AS_VAR_IF([os_is_windows], ["yes"],
  369. [
  370. AC_MSG_CHECKING([[whether target W32 version is specified by precomiler defines]])
  371. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  372. /* Note: check logic is reversed for easy log reading */
  373. #ifdef WINVER
  374. #error WINVER is defined
  375. choke me now;
  376. #endif
  377. #ifdef _WIN32_WINNT
  378. #error _WIN32_WINNT is defined
  379. choke me now;
  380. #endif
  381. #ifdef NTDDI
  382. #error NTDDI is defined
  383. choke me now;
  384. #endif
  385. ]],[[(void)0]])
  386. ], [[mhd_w32_ver_preselect=no]], [[mhd_w32_ver_preselect=yes]]
  387. )
  388. AC_MSG_RESULT([[${mhd_w32_ver_preselect}]])
  389. AC_CHECK_HEADERS([windows.h sdkddkver.h], [], [], [AC_INCLUDES_DEFAULT])
  390. AS_VAR_IF([mhd_w32_ver_preselect],["yes"],
  391. [
  392. AC_MSG_CHECKING([[for specified target W32 version]])
  393. AS_UNSET([[mhd_w32_ver]])
  394. AS_UNSET([[mhd_w32_ver_msg]])
  395. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  396. #if _WIN32_WINNT+0 < 0x0501
  397. /* Check before headers inclusion */
  398. #error _WIN32_WINNT is less than 0x0501
  399. choke me now;
  400. #endif
  401. #ifdef HAVE_SDKDDKVER_H
  402. #include <sdkddkver.h>
  403. #endif
  404. #ifdef HAVE_WINDOWS_H
  405. #include <windows.h>
  406. #endif
  407. #if _WIN32_WINNT+0 < 0x0501
  408. #error _WIN32_WINNT is less than 0x0501
  409. choke me now;
  410. #endif
  411. ]],[[(void)0]])
  412. ], [], [
  413. AC_MSG_RESULT([[pre-WinXP]])
  414. AC_MSG_ERROR([[libmicrohttpd cannot be compiled for Windows version before Windows XP]])
  415. ]
  416. )
  417. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  418. #ifdef HAVE_SDKDDKVER_H
  419. #include <sdkddkver.h>
  420. #endif
  421. #ifdef HAVE_WINDOWS_H
  422. #include <windows.h>
  423. #endif
  424. #if _WIN32_WINNT+0 == 0x0501
  425. #error _WIN32_WINNT is 0x0501
  426. choke me now;
  427. #endif
  428. #if _WIN32_WINNT+0 == 0x0502
  429. #error _WIN32_WINNT is 0x0502
  430. choke me now;
  431. #endif
  432. ]],[[(void)0]])
  433. ], [], [
  434. mhd_w32_ver="WinXP"
  435. mhd_w32_ver_msg="WinXP (selected by precompiler flags)"
  436. ]
  437. )
  438. AS_VAR_SET_IF([mhd_w32_ver], [],
  439. [
  440. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  441. #ifdef HAVE_SDKDDKVER_H
  442. #include <sdkddkver.h>
  443. #endif
  444. #ifdef HAVE_WINDOWS_H
  445. #include <windows.h>
  446. #endif
  447. #if _WIN32_WINNT+0 < 0x0600
  448. #error _WIN32_WINNT is less than 0x0600 but greater than 0x0502
  449. choke me now;
  450. #endif
  451. ]],[[(void)0]])
  452. ], [], [
  453. AC_MSG_ERROR([[_WIN32_WINNT value is wrong (less than 0x0600 but greater than 0x0502)]])
  454. ]
  455. )
  456. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  457. #ifdef HAVE_SDKDDKVER_H
  458. #include <sdkddkver.h>
  459. #endif
  460. #ifdef HAVE_WINDOWS_H
  461. #include <windows.h>
  462. #endif
  463. #if _WIN32_WINNT+0 == 0x0600
  464. #error _WIN32_WINNT is 0x0600
  465. choke me now;
  466. #endif
  467. ]],[[(void)0]])
  468. ], [], [
  469. mhd_w32_ver="Vista"
  470. mhd_w32_ver_msg="Vista (selected by precompiler flags)"
  471. ]
  472. )
  473. ]
  474. )
  475. AS_VAR_SET_IF([mhd_w32_ver], [],
  476. [
  477. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  478. #ifdef HAVE_SDKDDKVER_H
  479. #include <sdkddkver.h>
  480. #endif
  481. #ifdef HAVE_WINDOWS_H
  482. #include <windows.h>
  483. #endif
  484. #if _WIN32_WINNT+0 > 0x0600
  485. #error _WIN32_WINNT is greater than 0x0600
  486. choke me now;
  487. #endif
  488. ]],[[(void)0]])
  489. ], [
  490. mhd_w32_ver="unknown"
  491. mhd_w32_ver_msg="unknown (cannot be detected)"
  492. ], [
  493. mhd_w32_ver="newer than Vista"
  494. mhd_w32_ver_msg="newer than Vista (selected by precompiler flags)"
  495. ]
  496. )
  497. ]
  498. )
  499. AC_MSG_RESULT([[${mhd_w32_ver}]])
  500. ], [
  501. mhd_w32_ver="Vista"
  502. mhd_w32_ver_msg="Vista (default, override by CPPFLAGS=-D_WIN32_WINNT=0xNNNN)"
  503. CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600"
  504. AC_MSG_CHECKING([[whether headers accept _WIN32_WINNT=0x0600]])
  505. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  506. #ifdef HAVE_SDKDDKVER_H
  507. #include <sdkddkver.h>
  508. #endif
  509. #ifdef HAVE_WINDOWS_H
  510. #include <windows.h>
  511. #endif
  512. #include <stdio.h>
  513. ]],[[(void)0]])
  514. ], [
  515. AC_MSG_RESULT([[yes]])
  516. ], [
  517. AC_MSG_RESULT([[no]])
  518. AC_MSG_ERROR([Headers do not accept _WIN32_WINNT=0x0600. Consider override target W32 version by CPPFLAGS=-D_WIN32_WINNT=0xNNNN])
  519. ]
  520. )
  521. ]
  522. )
  523. ]
  524. )
  525. AC_ARG_WITH([threads],
  526. [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto, none) [auto]])],
  527. [], [with_threads='auto'])
  528. AS_CASE([[$with_threads]],
  529. [[win32]], [[with_threads='w32']],
  530. [[pthreads]], [[with_threads='posix']],
  531. [[posix]], [[:]],
  532. [[w32]], [[:]],
  533. [[none]], [[with_threads='none']],
  534. [[no]], [[with_threads='none']],
  535. [[auto]], [[:]],
  536. [AC_MSG_ERROR([[incorrect parameter "$with_threads" specified for --with-threads]])]
  537. )
  538. # Check for posix threads support, regardless of configure parameters as
  539. # testsuite uses only posix threads.
  540. AX_PTHREAD(
  541. [
  542. mhd_have_posix_threads='yes'
  543. AC_DEFINE([[HAVE_PTHREAD_H]],[[1]],[Define to 1 if you have the <pthread.h> header file.])
  544. AC_CACHE_CHECK([[whether pthread_sigmask(3) is available]],
  545. [[mhd_cv_func_pthread_sigmask]], [dnl
  546. save_LIBS="$LIBS"
  547. save_CFLAGS="$CFLAGS"
  548. LIBS="$PTHREAD_LIBS $LIBS"
  549. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  550. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]],
  551. [[
  552. sigset_t nset, oset;
  553. sigemptyset (&nset);
  554. sigaddset (&nset, SIGPIPE);
  555. if (0 != pthread_sigmask(SIG_BLOCK, &nset, &oset)) return 1;
  556. ]])],
  557. [[mhd_cv_func_pthread_sigmask="yes"]],[[mhd_cv_func_pthread_sigmask="no"]])
  558. LIBS="${save_LIBS}"
  559. CFLAGS="${save_CFLAGS}"
  560. ])
  561. AS_VAR_IF([mhd_cv_func_pthread_sigmask],["yes"],
  562. [AC_DEFINE([[HAVE_PTHREAD_SIGMASK]],[[1]],[Define to 1 if you have the pthread_sigmask(3) function.])])
  563. ],[[mhd_have_posix_threads='no']])
  564. AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$mhd_have_posix_threads" = "xyes"])
  565. mhd_have_w32_threads='no'
  566. AS_IF([[test "x$with_threads" = "xauto"]],
  567. [
  568. AS_IF([[test "x$os_is_windows" = "xyes"]],
  569. [
  570. AC_MSG_CHECKING([[for W32 threads]])
  571. AC_LINK_IFELSE(
  572. [AC_LANG_PROGRAM([[
  573. #include <windows.h>
  574. ]], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])]
  575. , [[mhd_have_w32_threads='yes']], [[mhd_have_w32_threads='no']]
  576. )
  577. AC_MSG_RESULT([[$mhd_have_w32_threads]])
  578. ])
  579. ]
  580. )
  581. AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd ($with_threads)]])
  582. AS_IF([test "x$with_threads" = "xposix"],
  583. [ # forced posix threads
  584. AS_IF([test "x$mhd_have_posix_threads" = "xyes"], [USE_THREADS='posix'],
  585. [ AS_IF([[test "x$os_is_windows" = "xyes"]] ,
  586. [ AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]])],
  587. [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]])] )
  588. ])
  589. ])
  590. AS_IF([test "x$with_threads" = "xw32"],
  591. [ # forced w32 threads
  592. AS_IF([[test "x$mhd_have_w32_threads" = "xyes"]],
  593. [[ USE_THREADS='w32' ]],
  594. [ AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]])])
  595. ])
  596. AS_IF([test "x$with_threads" = "xauto"],
  597. [# automatic threads lib selection
  598. AS_IF([[test "x$os_is_native_w32" = "xyes" && test "x$mhd_have_w32_threads" = "xyes"]] ,
  599. [[ USE_THREADS='w32' ]] ,
  600. [[ test "x$mhd_have_posix_threads" = "xyes" ]], [[ USE_THREADS='posix' ]],
  601. [[ test "x$mhd_have_w32_threads" = "xyes" ]], [[ USE_THREADS='w32' ]],
  602. [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]]) ]
  603. )])
  604. AS_IF([test "x$with_threads" = "xnone"],
  605. [USE_THREADS='none'])
  606. AS_IF([test "x$USE_THREADS" = "xposix"],
  607. [CC="$PTHREAD_CC"
  608. AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads])
  609. MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS"
  610. MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS"
  611. MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG"],
  612. [AS_IF([test "x$USE_THREADS" = "xw32"],
  613. [AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads])])])
  614. AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"])
  615. AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"])
  616. AM_CONDITIONAL([DISABLE_THREADS], [test "x$USE_THREADS" = "xnone"])
  617. AC_MSG_RESULT([$USE_THREADS])
  618. AC_ARG_ENABLE([[thread-names]],
  619. [AS_HELP_STRING([--disable-thread-names],[do not set names on MHD generated threads [auto]])],
  620. [], [enable_thread_names='auto'])
  621. AS_IF([test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix"],[
  622. # Check for thread name function
  623. HAVE_THREAD_NAME_FUNC="no"
  624. SAVE_LIBS="$LIBS"
  625. SAVE_CFLAGS="$CFLAGS"
  626. LIBS="$PTHREAD_LIBS $LIBS"
  627. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  628. AC_CHECK_HEADERS([pthread_np.h],[],[],
  629. [
  630. AC_INCLUDES_DEFAULT
  631. [
  632. #include <pthread.h>
  633. ]
  634. ])
  635. # Try to find how to set thread name by thread attributes.
  636. # If pthread_attr_setname_np(3) is not declared, it's not possible to detect
  637. # form of pthread_attr_setname_np(3) due to C "feature" "implicit declaration".
  638. AC_CHECK_DECL([[pthread_attr_setname_np]],[],[],[[
  639. #include <pthread.h>
  640. #ifdef HAVE_PTHREAD_NP_H
  641. #include <pthread_np.h>
  642. #endif
  643. ]])
  644. AS_IF([[test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]],
  645. [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in NetBSD or OSF1 form]])
  646. AC_LINK_IFELSE(
  647. [AC_LANG_PROGRAM([[
  648. #include <pthread.h>
  649. #ifdef HAVE_PTHREAD_NP_H
  650. #include <pthread_np.h>
  651. #endif
  652. ]], [[
  653. pthread_attr_t thr_attr;
  654. pthread_attr_init(&thr_attr);
  655. pthread_attr_setname_np(&thr_attr, "name", 0);
  656. pthread_attr_destroy(&thr_attr);
  657. ]])],
  658. [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.])
  659. HAVE_THREAD_NAME_FUNC="yes"
  660. AC_MSG_RESULT([[yes]])],
  661. [AC_MSG_RESULT([[no]])]
  662. )
  663. ])
  664. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]],
  665. [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in IBM i form]])
  666. AC_LINK_IFELSE(
  667. [AC_LANG_PROGRAM([[
  668. #include <pthread.h>
  669. #ifdef HAVE_PTHREAD_NP_H
  670. #include <pthread_np.h>
  671. #endif
  672. ]], [[
  673. pthread_attr_t thr_attr;
  674. pthread_attr_init(&thr_attr);
  675. pthread_attr_setname_np(&thr_attr, "name");
  676. pthread_attr_destroy(&thr_attr);
  677. ]])],
  678. [AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI]], [[1]], [Define if you have IBM i form of pthread_attr_setname_np(3) function.])
  679. HAVE_THREAD_NAME_FUNC="yes"
  680. AC_MSG_RESULT([[yes]])],
  681. [AC_MSG_RESULT([[no]])]
  682. )
  683. ])
  684. # Try to find how to set thread name for started thread - less convenient
  685. # than setting name by attributes.
  686. # If pthread_setname_np(3) is not declared, it's not possible to detect
  687. # form of pthread_setname_np(3) due to C "feature" "implicit declaration".
  688. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]],
  689. [AC_CHECK_DECL([[pthread_setname_np]],[],[],[[
  690. #include <pthread.h>
  691. #ifdef HAVE_PTHREAD_NP_H
  692. #include <pthread_np.h>
  693. #endif
  694. ]])
  695. ])
  696. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  697. [AC_MSG_CHECKING([[for pthread_setname_np(3) in NetBSD or OSF1 form]])
  698. AC_LINK_IFELSE(
  699. [AC_LANG_PROGRAM([[
  700. #include <pthread.h>
  701. #ifdef HAVE_PTHREAD_NP_H
  702. #include <pthread_np.h>
  703. #endif
  704. ]], [[int res = pthread_setname_np(pthread_self(), "name", 0);]])],
  705. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_setname_np(3) function.])
  706. HAVE_THREAD_NAME_FUNC="yes"
  707. AC_MSG_RESULT([[yes]])],
  708. [AC_MSG_RESULT([[no]])]
  709. )
  710. ])
  711. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  712. [AC_MSG_CHECKING([[for pthread_setname_np(3) in GNU/Linux form]])
  713. AC_LINK_IFELSE(
  714. [AC_LANG_PROGRAM([[
  715. #include <pthread.h>
  716. #ifdef HAVE_PTHREAD_NP_H
  717. #include <pthread_np.h>
  718. #endif
  719. ]], [[int res = pthread_setname_np(pthread_self(), "name");]])],
  720. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_GNU]], [[1]], [Define if you have GNU/Linux form of pthread_setname_np(3) function.])
  721. HAVE_THREAD_NAME_FUNC="yes"
  722. AC_MSG_RESULT([[yes]])],
  723. [AC_MSG_RESULT([[no]])]
  724. )
  725. ])
  726. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  727. [AC_MSG_CHECKING([[for pthread_setname_np(3) in Darwin form]])
  728. AC_LINK_IFELSE(
  729. [AC_LANG_PROGRAM([[
  730. #include <pthread.h>
  731. #ifdef HAVE_PTHREAD_NP_H
  732. #include <pthread_np.h>
  733. #endif
  734. ]], [[int res = pthread_setname_np("name");]])],
  735. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_DARWIN]], [[1]], [Define if you have Darwin form of pthread_setname_np(3) function.])
  736. HAVE_THREAD_NAME_FUNC="yes"
  737. AC_MSG_RESULT([[yes]])],
  738. [AC_MSG_RESULT([[no]])]
  739. )
  740. ])
  741. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]],
  742. [
  743. AC_CHECK_DECL([[pthread_set_name_np]],
  744. [
  745. AC_MSG_CHECKING([[for pthread_set_name_np(3) in FreeBSD form]])
  746. AC_LINK_IFELSE(
  747. [AC_LANG_PROGRAM([[
  748. #include <pthread.h>
  749. #ifdef HAVE_PTHREAD_NP_H
  750. #include <pthread_np.h>
  751. #endif
  752. ]], [[pthread_set_name_np(pthread_self(), "name");]])],
  753. [AC_DEFINE([[HAVE_PTHREAD_SET_NAME_NP_FREEBSD]], [[1]], [Define if you have FreeBSD form of pthread_set_name_np(3) function.])
  754. HAVE_THREAD_NAME_FUNC="yes"
  755. AC_MSG_RESULT([[yes]])],
  756. [AC_MSG_RESULT([[no]])]
  757. )
  758. ],[],[[
  759. #include <pthread.h>
  760. #ifdef HAVE_PTHREAD_NP_H
  761. #include <pthread_np.h>
  762. #endif
  763. ]]
  764. )
  765. ])
  766. LIBS="$SAVE_LIBS"
  767. CFLAGS="$SAVE_CFLAGS"
  768. ])
  769. AS_IF([[test "x$enable_thread_names" != "xno"]],
  770. [
  771. AC_MSG_CHECKING([[whether to enable thread names]])
  772. AC_COMPILE_IFELSE(
  773. [AC_LANG_PROGRAM([], [[
  774. #ifdef MHD_NO_THREAD_NAMES
  775. #error Thread names are disabled.
  776. choke me
  777. #endif
  778. /* Keep in sync with mhd_threads.h */
  779. #if defined(MHD_USE_POSIX_THREADS) && (defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) || \
  780. defined(HAVE_PTHREAD_SETNAME_NP_GNU) || defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || \
  781. defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) )
  782. int a = 1;
  783. #elif defined(MHD_USE_W32_THREADS) && defined(_MSC_FULL_VER)
  784. int b = 2;
  785. #else
  786. #error No thread name function is available.
  787. choke me
  788. #endif
  789. ]])
  790. ], [
  791. enable_thread_names='yes'
  792. ], [
  793. AS_IF([[test "x$enable_thread_names" = "xyes"]],
  794. [
  795. AC_MSG_RESULT([[no]])
  796. AC_MSG_ERROR([[thread names was explicitly requested, but thread name function is not available]])
  797. ])
  798. enable_thread_names='no'
  799. ])
  800. AC_MSG_RESULT([[$enable_thread_names]])
  801. ])
  802. AS_IF([[test "x$enable_thread_names" = "xno"]],
  803. [AC_DEFINE([[MHD_NO_THREAD_NAMES]], [[1]], [Define to 1 to disable setting name on generated threads])])
  804. AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"])
  805. w32_shared_lib_exp=no
  806. if test "x$enable_shared" = "xyes" && test "x$os_is_native_w32" = "xyes"; then
  807. if test "x$ac_cv_use_ms_lib_tool" = "xyes" || test -n "$DLLTOOL"; then
  808. w32_shared_lib_exp=yes
  809. else
  810. AC_MSG_WARN([[GNU dlltool or MS lib.exe is required for creating shared library export on W32]])
  811. AC_MSG_WARN([[Export library libmicrohttpd.lib will not be created]])
  812. fi
  813. fi
  814. AM_CONDITIONAL(W32_SHARED_LIB_EXP, [test "x$w32_shared_lib_exp" = "xyes"])
  815. AM_CONDITIONAL(USE_MS_LIB_TOOL, [test "x$ac_cv_use_ms_lib_tool" = "xyes"])
  816. MHD_CHECK_SOCKET_SHUTDOWN_TRIGGER([AC_DEFINE([HAVE_LISTEN_SHUTDOWN],[1],[can use shutdown on listen sockets])])
  817. AM_CONDITIONAL([HAVE_LISTEN_SHUTDOWN], [test "x$mhd_cv_host_shtdwn_trgr_select" = "xyes"])
  818. # SENDMSG. Should we check for SCM_RIGHTS instead?
  819. # https://lists.x.org/archives/xorg-devel/2013-November/038687.html
  820. AC_SEARCH_LIBS([sendmsg], [socket], [AC_DEFINE([HAVE_SENDMSG],[1],[Define if your platform supports sendmsg])])
  821. AC_CHECK_FUNCS([writev])
  822. # set GCC options
  823. # use '-fno-strict-aliasing', but only if the compiler
  824. # and linker can take it
  825. AX_CHECK_LINK_FLAG([-fno-strict-aliasing],
  826. [AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing])])
  827. AC_C_BIGENDIAN
  828. AC_C_VARARRAYS
  829. AC_CACHE_CHECK([[whether __func__ magic-macro is available]],
  830. [[mhd_cv_macro___func___avail]], [dnl
  831. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]],[[const char *funcname = __func__ ; if (NULL == funcname) return 1;]])],
  832. [[mhd_cv_macro___func___avail="yes"]],[[mhd_cv_macro___func___avail="no"]])
  833. ])
  834. AS_VAR_IF([mhd_cv_macro___func___avail], ["yes"],
  835. [AC_DEFINE([HAVE___FUNC__], [1], [Define to 1 if your compiler supports __func__ magic-macro.])],
  836. [
  837. AC_CACHE_CHECK([[whether __FUNCTION__ magic-macro is available]],
  838. [[mhd_cv_macro___function___avail]], [dnl
  839. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]],[[const char *funcname = __FUNCTION__ ; if (NULL == funcname) return 1;]])],
  840. [[mhd_cv_macro___function___avail="yes"]],[[mhd_cv_macro___function___avail="no"]])
  841. ])
  842. AC_DEFINE([HAVE___FUNCTION__], [1], [Define to 1 if your compiler supports __FUNCTION__ magic-macro.])
  843. ]
  844. )
  845. AC_CACHE_CHECK([[whether __builtin_bswap32() is available]],
  846. [[mhd_cv_func___builtin_bswap32_avail]], [dnl
  847. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint32_t a = 1; uint32_t b = __builtin_bswap32(a); a = b;]])],
  848. [[mhd_cv_func___builtin_bswap32_avail="yes"]],[[mhd_cv_func___builtin_bswap32_avail="no"]])
  849. ])
  850. AS_IF([[test "x$mhd_cv_func___builtin_bswap32_avail" = "xyes"]],
  851. [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP32]], [[1]], [Define to 1 if you have __builtin_bswap32() builtin function])])
  852. AC_CACHE_CHECK([[whether __builtin_bswap64() is available]],
  853. [[mhd_cv_func___builtin_bswap64_avail]], [dnl
  854. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint64_t a = 1; uint32_t b = __builtin_bswap64(a); a = b;]])],
  855. [[mhd_cv_func___builtin_bswap64_avail="yes"]], [[mhd_cv_func___builtin_bswap64_avail="no"]])
  856. ])
  857. AS_IF([[test "x$mhd_cv_func___builtin_bswap64_avail" = "xyes"]],
  858. [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP64]], [[1]], [Define to 1 if you have __builtin_bswap64() builtin function])])
  859. AC_CHECK_PROG([HAVE_CURL_BINARY],[curl],[yes],[no])
  860. AM_CONDITIONAL([HAVE_CURL_BINARY],[test "x$HAVE_CURL_BINARY" = "xyes"])
  861. AC_CHECK_PROG([HAVE_MAKEINFO_BINARY],[makeinfo],[yes],[no])
  862. AM_CONDITIONAL([HAVE_MAKEINFO_BINARY],[test "x$HAVE_MAKEINFO_BINARY" = "xyes"])
  863. AM_CONDITIONAL(W32_STATIC_LIB, [test "x$os_is_native_w32" = "xyes" && test "x$enable_static" = "xyes"])
  864. AC_ARG_ENABLE([[doc]],
  865. [AS_HELP_STRING([[--disable-doc]], [do not build any documentation])], ,
  866. [enable_doc=yes])
  867. test "x$enable_doc" = "xno" || enable_doc=yes
  868. AM_CONDITIONAL([BUILD_DOC], [test "x$enable_doc" = "xyes"])
  869. AC_ARG_ENABLE([[examples]],
  870. [AS_HELP_STRING([[--disable-examples]], [do not build any examples])], ,
  871. [enable_examples=yes])
  872. test "x$enable_examples" = "xno" || enable_examples=yes
  873. AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" = "xyes"])
  874. AC_ARG_ENABLE([[heavy-tests]],
  875. [AS_HELP_STRING([[--enable-heavy-tests]], [use heavy tests in test-suite. WARNING:]
  876. [a dedicated host with minimal number of background processes and no network]
  877. [activity is recommended to enable.])], [],
  878. [enable_heavy_tests=no])
  879. AS_VAR_IF([enable_heavy_tests], ["yes"], [], [enable_heavy_tests=no])
  880. AM_CONDITIONAL([HEAVY_TESTS],[test "x$enable_heavy_tests" = "xyes"])
  881. AC_ARG_ENABLE([[poll]],
  882. [AS_HELP_STRING([[--enable-poll[=ARG]]], [enable poll support (yes, no, auto) [auto]])],
  883. [enable_poll=${enableval}],
  884. [enable_poll='auto']
  885. )
  886. AS_IF([test "$enable_poll" != "no"],
  887. [AS_IF([test "$os_is_native_w32" != "yes"],
  888. AC_CHECK_HEADERS([poll.h],
  889. [AC_CHECK_FUNCS([poll], [have_poll='yes'], [have_poll='no'])],
  890. [],
  891. [AC_INCLUDES_DEFAULT]),
  892. [AC_MSG_CHECKING([for WSAPoll()])
  893. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  894. #include <winsock2.h>
  895. ]],[[
  896. WSAPOLLFD fda[2];
  897. WSAPoll(fda, 2, 0);]])],
  898. [have_poll='yes'
  899. AC_DEFINE([HAVE_POLL],[1])
  900. ],[have_poll='no'])
  901. AC_MSG_RESULT([$have_poll])])
  902. AS_IF([test "$enable_poll" = "yes" && test "$have_poll" != "yes"],
  903. AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]]))
  904. enable_poll="$have_poll"])
  905. AC_ARG_ENABLE([[epoll]],
  906. [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])],
  907. [enable_epoll=${enableval}],
  908. [enable_epoll='auto']
  909. )
  910. AS_IF([test "$enable_epoll" != "no"],
  911. [AX_HAVE_EPOLL
  912. AS_IF([test "${ax_cv_have_epoll}" = "yes"],
  913. [AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll support])
  914. enable_epoll='yes'],
  915. [AS_IF([test "$enable_epoll" = "yes"],
  916. AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]]))
  917. enable_epoll='no'])])
  918. AM_CONDITIONAL([MHD_HAVE_EPOLL], [[test "x$enable_epoll" = xyes]])
  919. AS_IF([test "x$enable_epoll" = "xyes"],
  920. AC_CACHE_CHECK([for epoll_create1()],
  921. [mhd_cv_have_epoll_create1], [
  922. AC_LINK_IFELSE([
  923. AC_LANG_PROGRAM([[
  924. #include <sys/epoll.h>
  925. ]], [[
  926. int fd;
  927. fd = epoll_create1(EPOLL_CLOEXEC);]])],
  928. [mhd_cv_have_epoll_create1=yes],
  929. [mhd_cv_have_epoll_create1=no])])
  930. AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[
  931. AC_DEFINE([[HAVE_EPOLL_CREATE1]], [[1]], [Define if you have epoll_create1 function.])]))
  932. # Check for headers that are ALWAYS required
  933. AC_CHECK_HEADERS_ONCE([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h sys/types.h], [], [AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX headers files])], [AC_INCLUDES_DEFAULT])
  934. # Check for optional headers
  935. AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h time.h sys/mman.h sys/ioctl.h \
  936. sys/socket.h sys/select.h netdb.h netinet/in.h netinet/ip.h netinet/tcp.h arpa/inet.h \
  937. endian.h machine/endian.h sys/endian.h sys/param.h sys/machine.h sys/byteorder.h machine/param.h sys/isa_defs.h \
  938. signal.h \
  939. inttypes.h stddef.h unistd.h \
  940. sockLib.h inetLib.h net/if.h], [], [], [AC_INCLUDES_DEFAULT])
  941. AC_CHECK_HEADER([[search.h]],
  942. [
  943. gl_FUNC_TSEARCH
  944. AS_IF([[test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]],
  945. [AC_DEFINE([[HAVE_SEARCH_H]], [[1]],
  946. [Define to 1 if you have the <search.h> header file and your system have properly functioning tsearch(), tfind() and tdelete() functions])])
  947. ],
  948. [], [AC_INCLUDES_DEFAULT])
  949. AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]])
  950. AC_CHECK_HEADERS([dlfcn.h],[have_tlsplugin=yes],[have_tlsplugin=no], [AC_INCLUDES_DEFAULT])
  951. AM_CONDITIONAL([MHD_HAVE_TLS_PLUGIN], [[test "x$have_tlsplugin" = xyes]])
  952. AC_CHECK_HEADERS([zlib.h],[have_zlib=yes],[have_zlib=no], [AC_INCLUDES_DEFAULT])
  953. AM_CONDITIONAL([HAVE_ZLIB], [[test "x$have_zlib" = xyes]])
  954. # Check for generic functions
  955. MHD_CHECK_FUNC([random],
  956. [
  957. AC_INCLUDES_DEFAULT
  958. [#include <stdlib.h>
  959. ]],
  960. [[long int r = random(); (void)r;]],
  961. [],
  962. [
  963. MHD_CHECK_FUNC([rand],
  964. [
  965. AC_INCLUDES_DEFAULT
  966. [#include <stdlib.h>
  967. ]],
  968. [[int r = rand(); (void)r;]],
  969. )
  970. ]
  971. )
  972. AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len,
  973. struct sockaddr_storage.ss_len],
  974. [], [],
  975. [
  976. #ifdef HAVE_SYS_TYPES_H
  977. #include <sys/types.h>
  978. #endif
  979. #ifdef HAVE_SYS_SOCKET_H
  980. #include <sys/socket.h>
  981. #endif
  982. #ifdef HAVE_NETINET_IN_H
  983. #include <netinet/in.h>
  984. #endif
  985. ])
  986. MHD_CHECK_FUNC([getsockname],
  987. [[
  988. #ifdef HAVE_SYS_TYPES_H
  989. #include <sys/types.h>
  990. #endif
  991. #ifdef HAVE_SYS_SOCKET_H
  992. #include <sys/socket.h>
  993. #endif
  994. #ifdef HAVE_WINSOCK2_H
  995. #include <winsock2.h>
  996. #endif
  997. ]],
  998. [
  999. struct sockaddr_storage ss;
  1000. (void)getsockname(socket(0,0,0),(struct sockaddr *)&ss,(void*)0);
  1001. ],
  1002. [
  1003. AC_CACHE_CHECK([[whether getsockname() is usable]], [[mhc_cv_getsockname_usable]],
  1004. [
  1005. AC_RUN_IFELSE(
  1006. [
  1007. AC_LANG_SOURCE(
  1008. [[
  1009. #ifdef HAVE_SYS_TYPES_H
  1010. #include <sys/types.h>
  1011. #endif
  1012. #ifdef HAVE_SYS_SOCKET_H
  1013. #include <sys/socket.h>
  1014. #endif
  1015. #ifdef HAVE_UNISTD_H
  1016. #include <unistd.h>
  1017. #endif
  1018. #ifdef HAVE_WINSOCK2_H
  1019. #include <winsock2.h>
  1020. #endif
  1021. #ifdef HAVE_WS2TCPIP_H
  1022. #include <ws2tcpip.h>
  1023. #endif
  1024. #ifdef HAVE_NETINET_IN_H
  1025. #include <netinet/in.h>
  1026. #endif
  1027. #ifdef HAVE_NETINET_IP_H
  1028. #include <netinet/ip.h>
  1029. #endif
  1030. #ifdef HAVE_ARPA_INET_H
  1031. #include <arpa/inet.h>
  1032. #endif
  1033. static void zr_mem(void *ptr, socklen_t size)
  1034. { char *mem = ptr; while(size--) {mem[0] = 0; mem++;} }
  1035. int main(void)
  1036. {
  1037. const socklen_t c_addr_size = (socklen_t)sizeof(struct sockaddr_in);
  1038. struct sockaddr_in sa;
  1039. socklen_t addr_size;
  1040. int ret = 1;
  1041. #if !defined(_WIN32) || defined(__CYGWIN__)
  1042. int sckt;
  1043. const int invld_sckt = -1;
  1044. #else
  1045. SOCKET sckt;
  1046. const SOCKET invld_sckt = INVALID_SOCKET;
  1047. WSADATA wsa_data;
  1048. if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data) || MAKEWORD(2, 2) != wsa_data.wVersion)
  1049. return 20;
  1050. #endif
  1051. sckt = socket (PF_INET, SOCK_STREAM, 0);
  1052. if (invld_sckt != sckt)
  1053. {
  1054. zr_mem(&sa, c_addr_size);
  1055. sa.sin_family = AF_INET;
  1056. #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
  1057. sa.sin_len = c_addr_size;
  1058. #endif
  1059. if (0 == bind (sckt, (struct sockaddr *)&sa, c_addr_size))
  1060. {
  1061. if (0 == listen (sckt, 1))
  1062. {
  1063. addr_size = c_addr_size;
  1064. if (0 == getsockname (sckt, (struct sockaddr *)&sa, &addr_size))
  1065. {
  1066. if (c_addr_size >= addr_size)
  1067. {
  1068. if (0 != ntohs(sa.sin_port))
  1069. { ret = 0;
  1070. } else ret = 7;
  1071. } else ret = 6;
  1072. } else ret = 5;
  1073. } else ret = 4;
  1074. } else ret = 3;
  1075. } else ret = 2;
  1076. #if !defined(_WIN32) || defined(__CYGWIN__)
  1077. close (sckt);
  1078. #else
  1079. closesocket (sckt);
  1080. WSACleanup();
  1081. #endif
  1082. return ret;
  1083. }
  1084. ]]
  1085. )
  1086. ],
  1087. [[mhc_cv_getsockname_usable='yes']],
  1088. [[mhc_cv_getsockname_usable='no']],
  1089. [[mhc_cv_getsockname_usable='assuming yes']]
  1090. )
  1091. ]
  1092. )
  1093. AS_VAR_IF([[mhc_cv_getsockname_usable]], [["no"]], [:],
  1094. [AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable `getsockname' function.])])
  1095. ]
  1096. )
  1097. # Check for inter-thread signaling type
  1098. AC_ARG_ENABLE([[itc]],
  1099. [AS_HELP_STRING([[--enable-itc=TYPE]], [use TYPE of inter-thread communication (pipe, socketpair, eventfd) [auto]])], [],
  1100. [[enable_itc='auto']]
  1101. )
  1102. AS_CASE([[$enable_itc]],
  1103. [[pipe]], [[:]],
  1104. [[socketpair]], [[:]],
  1105. [[eventfd]], [[:]],
  1106. [[auto]], [AS_VAR_IF([[os_is_windows]], [["yes"]], [[enable_itc='socketpair']])],
  1107. [[eventFD]], [[enable_itc='eventfd']],
  1108. [[socket]], [[enable_itc='socketpair']],
  1109. [[no]], [AC_MSG_ERROR([[inter-thread communication cannot be disabled]])],
  1110. [AC_MSG_ERROR([[unrecognized type "$enable_itc" of inter-thread communication specified by "--enable-itc=$enable_itc"]])]
  1111. )
  1112. # AS_UNSET([[use_itc]])
  1113. AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]], [
  1114. AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
  1115. AC_CHECK_HEADERS([sys/eventfd.h], [], [], [AC_INCLUDES_DEFAULT])
  1116. AS_VAR_IF([[ac_cv_header_sys_eventfd_h]], [["yes"]], [
  1117. AC_CACHE_CHECK([whether eventfd(2) is usable], [[mhd_cv_eventfd_usable]], [
  1118. AC_LINK_IFELSE([
  1119. AC_LANG_PROGRAM([[
  1120. #include <sys/eventfd.h>
  1121. ]], [[int ef = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK)
  1122. ]])
  1123. ], [[mhd_cv_eventfd_usable='yes']], [[mhd_cv_eventfd_usable='no']])
  1124. ])
  1125. ])
  1126. ])
  1127. AS_VAR_IF([[mhd_cv_eventfd_usable]], [["yes"]], [
  1128. use_itc='eventfd'
  1129. enable_itc="$use_itc"
  1130. AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for inter-thread communication])
  1131. ], [
  1132. AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not usable, consider using other type of inter-thread communication]])])
  1133. ])
  1134. ])
  1135. AS_IF([[test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto"]], [
  1136. AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
  1137. AC_CACHE_CHECK([[whether pipe(3) is usable]], [[mhd_cv_pipe_usable]], [
  1138. AC_LINK_IFELSE([
  1139. AC_LANG_PROGRAM([
  1140. AC_INCLUDES_DEFAULT
  1141. #ifdef HAVE_UNISTD_H
  1142. #include <unistd.h>
  1143. #endif
  1144. ], [[
  1145. int arr[2];
  1146. int res;
  1147. res = pipe(arr)
  1148. ]])
  1149. ], [[mhd_cv_pipe_usable='yes']], [[mhd_cv_pipe_usable='no']])
  1150. ])
  1151. ])
  1152. AS_VAR_IF([[mhd_cv_pipe_usable]], [["yes"]], [
  1153. use_itc='pipe'
  1154. enable_itc="$use_itc"
  1155. AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread communication])
  1156. AC_CACHE_CHECK([[whether pipe2(2) is usable]], [[mhd_cv_pipe2_usable]], [
  1157. AC_LINK_IFELSE([
  1158. AC_LANG_PROGRAM([
  1159. AC_INCLUDES_DEFAULT
  1160. #ifdef HAVE_FCNTL_H
  1161. #include <fcntl.h>
  1162. #endif
  1163. #ifdef HAVE_UNISTD_H
  1164. #include <unistd.h>
  1165. #endif
  1166. ], [[
  1167. int arr[2];
  1168. int res;
  1169. res = pipe2(arr, O_CLOEXEC | O_NONBLOCK)
  1170. ]])
  1171. ], [[mhd_cv_pipe2_usable='yes']], [[mhd_cv_pipe2_usable='no']])
  1172. ])
  1173. AS_VAR_IF([[mhd_cv_pipe2_usable]], [["yes"]],
  1174. [AC_DEFINE([[HAVE_PIPE2_FUNC]], [[1]], [Define if you have usable pipe2(2) function])])
  1175. ], [
  1176. AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not usable, consider using other type of inter-thread communication]])])
  1177. ])
  1178. ])
  1179. AS_IF([[test "x$enable_itc" = "xsocketpair" || test "x$enable_itc" = "xauto"]], [
  1180. AS_VAR_IF([[os_is_native_w32]], [["yes"]], [[mhd_cv_socketpair_usable='yes']], [
  1181. AC_CACHE_CHECK([[whether socketpair(3) is usable]], [[mhd_cv_socketpair_usable]], [
  1182. AC_LINK_IFELSE([
  1183. AC_LANG_PROGRAM([
  1184. AC_INCLUDES_DEFAULT
  1185. #ifdef HAVE_SYS_TYPES_H
  1186. #include <sys/types.h>
  1187. #endif
  1188. #ifdef HAVE_SYS_SOCKET_H
  1189. #include <sys/socket.h>
  1190. #endif
  1191. ], [[
  1192. int arr[2];
  1193. int res;
  1194. #if defined(AF_LOCAL)
  1195. res = socketpair(AF_LOCAL, SOCK_STREAM, 0, arr);
  1196. #elif defined(AF_UNIX)
  1197. res = socketpair(AF_UNIX, SOCK_STREAM, 0, arr);
  1198. #else
  1199. #error AF_LOCAL and AF_UNIX are both undefined
  1200. choke me now;
  1201. #endif
  1202. if (res != 0) return 1
  1203. ]])
  1204. ], [[mhd_cv_socketpair_usable='yes']], [[mhd_cv_socketpair_usable='no']])
  1205. ])
  1206. ])
  1207. AS_VAR_IF([[mhd_cv_socketpair_usable]], [["yes"]], [
  1208. use_itc='socketpair'
  1209. enable_itc="$use_itc"
  1210. AC_DEFINE([[_MHD_ITC_SOCKETPAIR]], [[1]], [Define to use socketpair for inter-thread communication])
  1211. ], [
  1212. AS_VAR_IF([[enable_itc]], [["socketpair"]], [AC_MSG_ERROR([[socketpair(3) is not usable, consider using other type of inter-thread communication]])])
  1213. ])
  1214. ])
  1215. AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find usable type of inter-thread communication]])])
  1216. AC_CHECK_FUNCS_ONCE([accept4 gmtime_r memmem snprintf])
  1217. AC_CHECK_DECL([gmtime_s],
  1218. [
  1219. AC_MSG_CHECKING([[whether gmtime_s is in C11 form]])
  1220. AC_LINK_IFELSE(
  1221. [ AC_LANG_PROGRAM(
  1222. [[
  1223. #define __STDC_WANT_LIB_EXT1__ 1
  1224. #include <time.h>
  1225. #ifdef __cplusplus
  1226. extern "C"
  1227. #endif
  1228. struct tm* gmtime_s(const time_t* time, struct tm* result);
  1229. ]], [[
  1230. struct tm res;
  1231. time_t t;
  1232. gmtime_s (&t, &res);
  1233. ]])
  1234. ],
  1235. [
  1236. AC_DEFINE([HAVE_C11_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in C11 form.])
  1237. AC_MSG_RESULT([[yes]])
  1238. ],
  1239. [
  1240. AC_MSG_RESULT([[no]])
  1241. AC_MSG_CHECKING([[whether gmtime_s is in W32 form]])
  1242. AC_LINK_IFELSE(
  1243. [ AC_LANG_PROGRAM(
  1244. [[
  1245. #include <time.h>
  1246. #ifdef __cplusplus
  1247. extern "C"
  1248. #endif
  1249. errno_t gmtime_s(struct tm* _tm, const time_t* time);
  1250. ]], [[
  1251. struct tm res;
  1252. time_t t;
  1253. gmtime_s (&res, &t);
  1254. ]])
  1255. ],
  1256. [
  1257. AC_DEFINE([HAVE_W32_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in W32 form.])
  1258. AC_MSG_RESULT([[yes]])
  1259. ],
  1260. [AC_MSG_RESULT([[no]])
  1261. ])
  1262. ])
  1263. ], [],
  1264. [[#define __STDC_WANT_LIB_EXT1__ 1
  1265. #include <time.h>]])
  1266. AC_CHECK_DECLS([SOCK_NONBLOCK], [AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBLOCK is defined in a socket header])], [],
  1267. [
  1268. #if defined(HAVE_SYS_TYPES_H)
  1269. # include <sys/types.h>
  1270. #endif
  1271. #if defined(HAVE_SYS_SOCKET_H)
  1272. # include <sys/socket.h>
  1273. #elif defined(HAVE_WINSOCK2_H)
  1274. # include <winsock2.h>
  1275. #endif
  1276. ])
  1277. AC_CHECK_DECL([[clock_gettime]],
  1278. [
  1279. SAVE_LIBS="$LIBS"
  1280. AC_SEARCH_LIBS([clock_gettime], [rt],
  1281. [
  1282. AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])
  1283. AS_VAR_IF([[ac_cv_search_clock_gettime]],[["none required"]], [],
  1284. [
  1285. MHD_LIBDEPS="$ac_cv_search_clock_gettime $MHD_LIBDEPS"
  1286. MHD_LIBDEPS_PKGCFG="$ac_cv_search_clock_gettime $MHD_LIBDEPS_PKGCFG"
  1287. ])
  1288. ], [], [$MHD_LIBDEPS])
  1289. LIBS="$SAVE_LIBS"
  1290. ], [], [[
  1291. #include <time.h>
  1292. ]])
  1293. AC_MSG_CHECKING([[for clock_get_time]])
  1294. AC_LINK_IFELSE(
  1295. [AC_LANG_PROGRAM(
  1296. [[
  1297. #include <mach/clock.h>
  1298. #include <mach/mach.h>
  1299. ]],
  1300. [[
  1301. clock_serv_t cs;
  1302. mach_timespec_t mt;
  1303. host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
  1304. clock_get_time(cs, &mt);
  1305. mach_port_deallocate(mach_task_self(), cs);
  1306. ]])
  1307. ],
  1308. [
  1309. AC_DEFINE([HAVE_CLOCK_GET_TIME], [1], [Define to 1 if you have `clock_get_time', `host_get_clock_service' and `mach_port_deallocate' functions.])
  1310. AC_MSG_RESULT([[yes]])
  1311. ],
  1312. [AC_MSG_RESULT([[no]])
  1313. ])
  1314. AC_MSG_CHECKING([[for gethrtime]])
  1315. AC_LINK_IFELSE(
  1316. [AC_LANG_PROGRAM(
  1317. [[
  1318. #ifdef HAVE_SYS_TIME_H
  1319. /* Solaris define gethrtime() in sys/time.h */
  1320. #include <sys/time.h>
  1321. #endif /* HAVE_SYS_TIME_H */
  1322. #ifdef HAVE_TIME_H
  1323. /* HP-UX define gethrtime() in time.h */
  1324. #include <time.h>
  1325. #endif /* HAVE_TIME_H */
  1326. ]], [[hrtime_t hrt = gethrtime(); ]])
  1327. ],
  1328. [
  1329. AC_DEFINE([HAVE_GETHRTIME], [1], [Define to 1 if you have `gethrtime' function.])
  1330. AC_MSG_RESULT([[yes]])
  1331. ],
  1332. [AC_MSG_RESULT([[no]])
  1333. ])
  1334. # IPv6
  1335. AC_MSG_CHECKING(for IPv6)
  1336. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1337. #include <stdio.h>
  1338. #if HAVE_NETINET_IN_H
  1339. #include <netinet/in.h>
  1340. #endif
  1341. #if HAVE_SYS_SOCKET_H
  1342. #include <sys/socket.h>
  1343. #endif
  1344. #if HAVE_WINSOCK2_H
  1345. #include <winsock2.h>
  1346. #endif
  1347. #if HAVE_WS2TCPIP_H
  1348. #include <ws2tcpip.h>
  1349. #endif
  1350. ]], [[
  1351. int af=AF_INET6;
  1352. int pf=PF_INET6;
  1353. struct sockaddr_in6 sa;
  1354. printf("%d %d %p\n", af, pf, &sa);
  1355. ]])],[
  1356. have_inet6=yes;
  1357. AC_DEFINE([HAVE_INET6], [1], [Provides IPv6 headers])
  1358. ],[
  1359. have_inet6=no
  1360. ])
  1361. AC_MSG_RESULT($have_inet6)
  1362. MHD_CHECK_FUNC([[sysconf]], [[#include <unistd.h>]], [[long a = sysconf(0); if (a) return 1;]])
  1363. HIDDEN_VISIBILITY_CFLAGS=""
  1364. AS_CASE(["$host"],
  1365. [*-*-mingw*],[
  1366. dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
  1367. AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
  1368. [defines how to decorate public symbols while building])
  1369. HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
  1370. ],[
  1371. dnl on other compilers, check if we can do -fvisibility=hidden
  1372. AX_CHECK_LINK_FLAG([-fvisibility=hidden],
  1373. [AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],
  1374. [AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) extern],
  1375. [defines how to decorate public symbols while building])
  1376. HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"])])
  1377. ])
  1378. AC_SUBST(HIDDEN_VISIBILITY_CFLAGS)
  1379. # libcurl (required for testing)
  1380. AC_ARG_ENABLE([curl],
  1381. [AS_HELP_STRING([--disable-curl],[disable cURL based testcases])],
  1382. [enable_curl=${enableval}])
  1383. curl=0
  1384. AS_IF([test "$enable_curl" != "no"],
  1385. [LIBCURL_CHECK_CONFIG([yes],[7.16.4],[enable_curl=yes],
  1386. [
  1387. AS_IF([test "x$enable_curl" = "xyes"],
  1388. [AC_MSG_WARN([[cURL-based tests cannot be enabled because libcurl is missing]])])
  1389. enable_curl=no
  1390. ])
  1391. ])
  1392. AS_IF([test "$enable_curl" != "no"],
  1393. [
  1394. # Lib cURL & cURL - OpenSSL versions
  1395. AC_DEFINE([MHD_REQ_CURL_VERSION], ["7.16.4"], [required cURL version to run tests])
  1396. AC_DEFINE([MHD_REQ_CURL_OPENSSL_VERSION], ["0.9.8"], [required cURL SSL version to run tests])
  1397. AC_DEFINE([MHD_REQ_CURL_GNUTLS_VERSION], ["2.8.6"], [gnuTLS lib version - used in conjunction with cURL])
  1398. AC_DEFINE([MHD_REQ_CURL_NSS_VERSION], ["3.12.0"], [NSS lib version - used in conjunction with cURL])
  1399. ])
  1400. AM_CONDITIONAL([HAVE_CURL], [test "x$enable_curl" = "xyes"])
  1401. mhd_have_libmagic="no"
  1402. SAVE_LIBS="$LIBS"
  1403. LIBS="$LIBS -lmagic"
  1404. AC_MSG_CHECKING([[for suitable libmagic]])
  1405. AC_LINK_IFELSE(
  1406. [AC_LANG_PROGRAM(
  1407. [[
  1408. #include <magic.h>
  1409. ]],
  1410. [[
  1411. char var_data[256];
  1412. const char *var_mime;
  1413. magic_t var_magic = magic_open (MAGIC_MIME_TYPE);
  1414. (void)magic_load (var_magic, NULL);
  1415. var_data[0] = 0;
  1416. var_mime = magic_buffer (var_magic, var_data, 1);
  1417. magic_close (var_magic);
  1418. ]]
  1419. )
  1420. ],
  1421. [
  1422. AC_DEFINE([HAVE_LIBMAGIC], [1], [Define to 1 if you have suitable libmagic.])
  1423. mhd_have_libmagic="yes"
  1424. AC_MSG_RESULT([[yes]])
  1425. ],
  1426. [AC_MSG_RESULT([[no]])
  1427. ]
  1428. )
  1429. LIBS="$SAVE_LIBS"
  1430. AM_CONDITIONAL([HAVE_LIBMAGIC], [[test "x$mhd_have_libmagic" = "xyes"]])
  1431. # large file support (> 4 GB)
  1432. AC_SYS_LARGEFILE
  1433. AC_FUNC_FSEEKO
  1434. AC_CHECK_FUNCS([lseek64 pread64 pread])
  1435. # check for various sendfile functions
  1436. AC_ARG_ENABLE([sendfile],
  1437. [AS_HELP_STRING([--disable-sendfile],
  1438. [disable usage of sendfile() for HTTP connections [auto]])],
  1439. [],
  1440. [enable_sendfile="auto"])
  1441. AS_CASE([$enable_sendfile],
  1442. [[auto | yes]],[[found_sendfile="no"]],
  1443. [[no]],[[found_sendfile="disabled"]],
  1444. [AC_MSG_ERROR([[unknown value specified: --enable-sendfile=$enable_sendfile]])]
  1445. )
  1446. AS_VAR_IF([[found_sendfile]], [["no"]],
  1447. [
  1448. AC_MSG_CHECKING([[for Linux-style sendfile(2)]])
  1449. AC_LINK_IFELSE(
  1450. [AC_LANG_PROGRAM(
  1451. [[
  1452. #include <sys/sendfile.h>
  1453. static void empty_func(void)
  1454. {
  1455. /* Check for declaration */
  1456. (void)sendfile;
  1457. }
  1458. /* Declare again to check form match */
  1459. ssize_t sendfile(int, int, off_t*, size_t);
  1460. ]],
  1461. [[
  1462. int fd1=0, fd2=2;
  1463. off_t o = 0;
  1464. size_t s = 5;
  1465. ssize_t r;
  1466. r = sendfile (fd1, fd2, &o, s);
  1467. if (r)
  1468. empty_func();
  1469. ]]
  1470. )
  1471. ],
  1472. [
  1473. AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).])
  1474. found_sendfile="yes, Linux-style"
  1475. AC_MSG_RESULT([[yes]])
  1476. AC_CHECK_FUNCS([sendfile64])
  1477. ],
  1478. [AC_MSG_RESULT([[no]])
  1479. ]
  1480. )
  1481. ]
  1482. )
  1483. AS_VAR_IF([[found_sendfile]], [["no"]],
  1484. [
  1485. AC_MSG_CHECKING([[for FreeBSD-style sendfile(2)]])
  1486. AC_LINK_IFELSE(
  1487. [AC_LANG_PROGRAM(
  1488. [[
  1489. #include <sys/types.h>
  1490. #include <sys/socket.h>
  1491. #include <sys/uio.h>
  1492. static void empty_func(void)
  1493. {
  1494. /* Check for declaration */
  1495. (void)sendfile;
  1496. }
  1497. /* Declare again to check form match */
  1498. int sendfile(int, int, off_t, size_t,
  1499. struct sf_hdtr*, off_t*, int);
  1500. ]],
  1501. [[
  1502. int fd1=0, fd2=1;
  1503. off_t o = 0;
  1504. size_t s = 5;
  1505. off_t r1;
  1506. int r2;
  1507. r2 = sendfile (fd1, fd2, o, s, (void*)0, &r1, 0);
  1508. if (r2)
  1509. empty_func();
  1510. ]]
  1511. )
  1512. ],
  1513. [
  1514. AC_DEFINE([HAVE_FREEBSD_SENDFILE], [1], [Define to 1 if you have FreeBSD-style sendfile(2).])
  1515. found_sendfile="yes, FreeBSD-style"
  1516. AC_MSG_RESULT([[yes]])
  1517. ],
  1518. [AC_MSG_RESULT([[no]])
  1519. ]
  1520. )
  1521. ]
  1522. )
  1523. AS_VAR_IF([[found_sendfile]], [["no"]],
  1524. [
  1525. AC_MSG_CHECKING([[for Darwin-style sendfile(2)]])
  1526. AC_LINK_IFELSE(
  1527. [AC_LANG_PROGRAM(
  1528. [[
  1529. #include <sys/types.h>
  1530. #include <sys/socket.h>
  1531. #include <sys/uio.h>
  1532. static void empty_func(void)
  1533. {
  1534. /* Check for declaration */
  1535. (void)sendfile;
  1536. }
  1537. /* Declare again to check form match */
  1538. int sendfile(int, int, off_t, off_t*,
  1539. struct sf_hdtr *, int);
  1540. ]],
  1541. [[
  1542. int fd=0, s=1;
  1543. off_t o = 0;
  1544. off_t l = 5;
  1545. int r;
  1546. r = sendfile (fd, s, o, &l, (void*)0, 0);
  1547. if (r)
  1548. empty_func();
  1549. ]]
  1550. )
  1551. ],
  1552. [
  1553. AC_DEFINE([HAVE_DARWIN_SENDFILE], [1], [Define to 1 if you have Darwin-style sendfile(2).])
  1554. found_sendfile="yes, Darwin-style"
  1555. AC_MSG_RESULT([[yes]])
  1556. ],
  1557. [AC_MSG_RESULT([[no]])
  1558. ]
  1559. )
  1560. ]
  1561. )
  1562. AS_VAR_IF([[found_sendfile]], [["no"]],
  1563. [
  1564. AC_MSG_CHECKING([[for Solaris-style sendfile(3)]])
  1565. SAVE_LIBS="$LIBS"
  1566. LIBS="$LIBS -lsendfile"
  1567. AC_LINK_IFELSE(
  1568. [AC_LANG_PROGRAM(
  1569. [[
  1570. #include <sys/types.h>
  1571. #include <sys/socket.h>
  1572. #include <sys/sendfile.h>
  1573. static void empty_func(void)
  1574. {
  1575. /* Check for declaration */
  1576. (void)sendfile;
  1577. }
  1578. /* Declare again to check form match */
  1579. ssize_t sendfile(int out_fd, int in_fd,
  1580. off_t *off, size_t len);
  1581. ]],
  1582. [[
  1583. int fd1=0, fd2=1;
  1584. off_t o = 0;
  1585. size_t l = 5;
  1586. ssize_t r;
  1587. r = sendfile (fd1, fd2, &o, l);
  1588. if (r)
  1589. empty_func();
  1590. ]]
  1591. )
  1592. ],
  1593. [
  1594. AC_DEFINE([HAVE_SOLARIS_SENDFILE], [1], [Define to 1 if you have Solaris-style sendfile(3).])
  1595. found_sendfile="yes, Solaris-style"
  1596. MHD_LIBDEPS="-lsendfile $MHD_LIBDEPS"
  1597. MHD_LIBDEPS_PKGCFG="-lsendfile $MHD_LIBDEPS_PKGCFG"
  1598. AC_MSG_RESULT([[yes]])
  1599. AC_CHECK_FUNCS([sendfile64])
  1600. ],
  1601. [AC_MSG_RESULT([[no]])
  1602. ]
  1603. )
  1604. LIBS="$SAVE_LIBS"
  1605. ]
  1606. )
  1607. AS_IF([[test "x$found_sendfile" = "xno" && test "x$enable_sendfile" = "xyes"]],
  1608. [AC_MSG_ERROR([[sendfile() usage was requested by configure parameter, but no usable sendfile() function is detected]])]
  1609. )
  1610. # optional: have error messages ?
  1611. AC_MSG_CHECKING([[whether to generate error messages]])
  1612. AC_ARG_ENABLE([messages],
  1613. [AS_HELP_STRING([--disable-messages],
  1614. [disable MHD error messages])],
  1615. [enable_messages=${enableval}],
  1616. [enable_messages=yes])
  1617. AS_IF([[test "x$enable_messages" = "xyes"]],
  1618. [ AC_DEFINE([HAVE_MESSAGES],[1],[Define to 1 to enable support for error messages.]) ],
  1619. [[ enable_messages=no ]])
  1620. AC_MSG_RESULT([[$enable_messages]])
  1621. # optional: have postprocessor?
  1622. AC_MSG_CHECKING([[whether to enable postprocessor]])
  1623. AC_ARG_ENABLE([postprocessor],
  1624. [AS_HELP_STRING([--disable-postprocessor],
  1625. [disable MHD PostProcessor functionality])],
  1626. [enable_postprocessor=${enableval}],
  1627. [enable_postprocessor=yes])
  1628. AS_IF([[test "x$enable_postprocessor" != "xno"]],
  1629. [ enable_postprocessor=yes
  1630. AC_DEFINE([HAVE_POSTPROCESSOR],[1],[Define to 1 if libmicrohttpd is compiled with postprocessor support.]) ])
  1631. AM_CONDITIONAL([HAVE_POSTPROCESSOR], [test "x$enable_postprocessor" != "xno"])
  1632. AC_MSG_RESULT([[$enable_postprocessor]])
  1633. # optional: have zzuf, socat?
  1634. AC_CHECK_PROG([have_zzuf],[zzuf], [yes], [no])
  1635. AC_CHECK_PROG([have_socat],[socat], [yes], [no])
  1636. AM_CONDITIONAL([HAVE_ZZUF], [test "x$have_zzuf" = "xyes"])
  1637. AM_CONDITIONAL([HAVE_SOCAT], [test "x$have_socat" = "xyes"])
  1638. have_gnutls=no
  1639. have_gnutls_sni=no
  1640. have_gcrypt=no
  1641. AS_UNSET([GNUTLS_CPPFLAGS])
  1642. AS_UNSET([GNUTLS_LDFLAGS])
  1643. # optional: HTTPS support. Enabled by default
  1644. AC_ARG_ENABLE([https],
  1645. [AS_HELP_STRING([--enable-https],
  1646. [enable HTTPS support (yes, no, auto)[auto]])],
  1647. [enable_https=${enableval}])
  1648. AS_IF([test "x$enable_https" != "xno"],[
  1649. #
  1650. # Next block is large unindented block
  1651. #
  1652. # gnutls
  1653. have_gnutls_pkgcfg=no
  1654. AC_MSG_CHECKING([[how to find GnuTLS library]])
  1655. AC_ARG_WITH([[gnutls]],
  1656. [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)])],
  1657. [
  1658. AS_CASE([$with_gnutls],
  1659. [no],[
  1660. AC_MSG_RESULT([[GnuTLS disabled]])
  1661. AS_UNSET([GNUTLS_CPPFLAGS])
  1662. AS_UNSET([GNUTLS_CFLAGS])
  1663. AS_UNSET([GNUTLS_LDFLAGS])
  1664. AS_UNSET([GNUTLS_LIBS])
  1665. ],
  1666. [yes],[
  1667. AC_MSG_RESULT([[automatically, forced]])
  1668. ],
  1669. [
  1670. AC_MSG_RESULT([[-I$with_gnutls/include -L$with_gnutls/lib -lgnutls]])
  1671. SAVE_LDFLAGS="$LDFLAGS"
  1672. SAVE_CPPFLAGS="$CPPFLAGS"
  1673. SAVE_CFLAGS="$CFLAGS"
  1674. SAVE_LIBS="$LIBS"
  1675. LDFLAGS="-L$with_gnutls/lib $LDFLAGS"
  1676. CPPFLAGS="-I$with_gnutls/include $CPPFLAGS"
  1677. have_gnutls_pkgcfg=no
  1678. AC_CHECK_HEADERS([gnutls/gnutls.h],
  1679. [AC_CHECK_LIB([gnutls], [gnutls_priority_set],
  1680. [
  1681. GNUTLS_CPPFLAGS="-I$with_gnutls/include"
  1682. GNUTLS_LDFLAGS="-L$with_gnutls/lib"
  1683. GNUTLS_LIBS="-lgnutls"
  1684. have_gnutls=yes
  1685. ])], [], [AC_INCLUDES_DEFAULT])
  1686. AS_IF([test "x$have_gnutls" != "xyes"], [AC_MSG_ERROR([can't find usable libgnutls at specified prefix $with_gnutls])])
  1687. CPPFLAGS="$SAVE_CPPFLAGS"
  1688. CFLAGS="$SAVE_CFLAGS"
  1689. LDFLAGS="$SAVE_LDFLAGS"
  1690. LIBS="$SAVE_LIBS"
  1691. ])
  1692. ],
  1693. [AC_MSG_RESULT([[automatically]])
  1694. ])
  1695. AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"],
  1696. [
  1697. AC_CACHE_CHECK([[whether to add pkg-config special search directories]], [mhd_cv_pkgconf_add_dirs],
  1698. [
  1699. AS_IF([[test "x$host_os" = "xsolaris2.11" && test "x$cross_compiling" = "xno"]],
  1700. [
  1701. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1702. char size_chk[7-sizeof(char*)];
  1703. #if defined(_LP64) || defined(__LP64__) || defined(__x86_64) || defined(__x86_64__)
  1704. #error This is 64-bit target.
  1705. choke me now
  1706. #endif
  1707. #if defined(__amd64) || defined(__amd64__) || defined(__sparcv9) || defined(__sparc_v9__)
  1708. #error This is 64-bit target.
  1709. choke me now
  1710. #endif
  1711. ]], [[]]
  1712. )
  1713. ],
  1714. [
  1715. mhd_cv_pkgconf_add_dirs='/usr/lib/pkgconfig/gnutls-3'
  1716. ],
  1717. [
  1718. AS_IF([[test "x$host_cpu" = "xx86_64" || test "x$host_cpu" = "xi386"]],
  1719. [[mhd_cv_pkgconf_add_dirs='/usr/lib/amd64/pkgconfig/gnutls-3:/usr/lib/amd64/pkgconfig']],
  1720. [[test "x$host_cpu" = "xsparc"]],
  1721. [[mhd_cv_pkgconf_add_dirs='/usr/lib/sparkv9/pkgconfig/gnutls-3:/usr/lib/sparkv9/pkgconfig']],
  1722. [[mhd_cv_pkgconf_add_dirs='/usr/lib/64/pkgconfig/gnutls-3:/usr/lib/64/pkgconfig']]
  1723. )
  1724. ]
  1725. )
  1726. ],
  1727. [[ mhd_cv_pkgconf_add_dirs='no' ]]
  1728. )
  1729. ]
  1730. )
  1731. AS_IF([[test "x$mhd_cv_pkgconf_add_dirs" != "xno"]],
  1732. [
  1733. test "x$PKG_CONFIG_PATH" = "x" || PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${PATH_SEPARATOR}"
  1734. PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${mhd_cv_pkgconf_add_dirs}"
  1735. export PKG_CONFIG_PATH
  1736. ]
  1737. )
  1738. PKG_CHECK_MODULES(GNUTLS, [[gnutls]],
  1739. [
  1740. have_gnutls_pkgcfg='yes'
  1741. SAVE_CPPFLAGS="$CPPFLAGS"
  1742. SAVE_CFLAGS="$CFLAGS"
  1743. SAVE_LDFLAGS="$LDFLAGS"
  1744. SAVE_LIBS="$LIBS"
  1745. CFLAGS="$GNUTLS_CFLAGS $CFLAGS"
  1746. LIBS="$LIBS $GNUTLS_LIBS"
  1747. AC_MSG_CHECKING([[whether GnuTLS is usable]])
  1748. AC_LINK_IFELSE([
  1749. AC_LANG_PROGRAM([[
  1750. #include <gnutls/gnutls.h>
  1751. ]], [[
  1752. gnutls_session_t session;
  1753. gnutls_priority_t priorities;
  1754. gnutls_global_init();
  1755. gnutls_priority_init(&priorities, "NORMAL", NULL);
  1756. gnutls_init(&session, GNUTLS_SERVER);
  1757. gnutls_priority_set(session, priorities);
  1758. ]])],
  1759. [
  1760. AC_MSG_RESULT([[yes]])
  1761. have_gnutls=yes
  1762. # GNUTLS_CFLAGS is actually CPPFLAGS
  1763. GNUTLS_CPPFLAGS="$GNUTLS_CFLAGS"
  1764. # GNUTLS_CFLAGS is combination of LDFLAGS and LIBS
  1765. GNUTLS_LDFLAGS="$GNUTLS_LIBS"
  1766. ],
  1767. [
  1768. AC_MSG_RESULT([[no]])
  1769. have_gnutls=no
  1770. ])
  1771. AS_IF([test "x$have_gnutls" != "xyes"],
  1772. [
  1773. AC_MSG_WARN([pkg-config reports that GnuTLS is present, but GnuTLS can't be used])
  1774. AS_UNSET([GNUTLS_CPPFLAGS])
  1775. AS_UNSET([GNUTLS_CFLAGS])
  1776. AS_UNSET([GNUTLS_LDFLAGS])
  1777. AS_UNSET([GNUTLS_LIBS])
  1778. ]
  1779. )
  1780. CPPFLAGS="$SAVE_CPPFLAGS"
  1781. CFLAGS="$SAVE_CFLAGS"
  1782. LDFLAGS="$SAVE_LDFLAGS"
  1783. LIBS="$SAVE_LIBS"
  1784. ],
  1785. [
  1786. # check for GnuTLS at default paths
  1787. have_gnutls_pkgcfg='no'
  1788. AC_CHECK_HEADERS([gnutls/gnutls.h],
  1789. [AC_CHECK_LIB([gnutls], [gnutls_priority_set],
  1790. [
  1791. GNUTLS_LIBS="-lgnutls"
  1792. have_gnutls=yes
  1793. ])], [], [AC_INCLUDES_DEFAULT])
  1794. ])
  1795. ])
  1796. have_gcrypt='unknown'
  1797. AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"],
  1798. [
  1799. AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no])
  1800. AS_IF([[test "x$have_gcrypt" = "xyes"]],
  1801. [
  1802. SAVE_CPPFLAGS="$CPPFLAGS"
  1803. SAVE_CFLAGS="$CFLAGS"
  1804. SAVE_LIBS="$LIBS"
  1805. SAVE_LDFLAGS="$LDFLAGS"
  1806. CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
  1807. # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both
  1808. CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS"
  1809. AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT])
  1810. # Check for GnuTLS with gcrypt flags
  1811. LDFLAGS="$LDFLAGS $LIBGCRYPT_LIBS"
  1812. # A bit of hack: unset cache variable to force recheck
  1813. AS_UNSET([ac_cv_header_gnutls_gnutls_h])
  1814. AC_CHECK_HEADERS([gnutls/gnutls.h],
  1815. [AS_UNSET([ac_cv_lib_gnutls_gnutls_priority_set]) # A bit of hack: unset cache variable to force recheck
  1816. AC_CHECK_LIB([gnutls], [gnutls_priority_set],
  1817. [
  1818. GNUTLS_CPPFLAGS="$LIBGCRYPT_CFLAGS"
  1819. GNUTLS_CFLAGS="$LIBGCRYPT_CFLAGS"
  1820. GNUTLS_LDFLAGS="$LIBGCRYPT_LIBS"
  1821. GNUTLS_LIBS="-lgnutls"
  1822. have_gnutls=yes
  1823. ])], [], [AC_INCLUDES_DEFAULT])
  1824. CPPFLAGS="$SAVE_CPPFLAGS"
  1825. CFLAGS="$SAVE_CFLAGS"
  1826. LDFLAGS="$SAVE_LDFLAGS"
  1827. LIBS="$SAVE_LIBS"
  1828. ]
  1829. )
  1830. ]
  1831. )
  1832. AS_IF([test "x$have_gnutls" != "xyes" && test "x$with_gnutls" = "xyes"],
  1833. [AC_MSG_ERROR([[can't find usable libgnutls]])])
  1834. AS_IF([test "x$have_gnutls" = "xyes"],
  1835. [
  1836. SAVE_CPPFLAGS="$CPPFLAGS"
  1837. SAVE_CFLAGS="$CFLAGS"
  1838. SAVE_LDFLAGS="$LDFLAGS"
  1839. SAVE_LIBS="$LIBS"
  1840. CPPFLAGS="$GNUTLS_CPPFLAGS $CPPFLAGS"
  1841. CFLAGS="$GNUTLS_CFLAGS $CFLAGS"
  1842. LDFLAGS="$GNUTLS_LDFLAGS $LDFLAGS"
  1843. LIBS="$LIBS $GNUTLS_LIBS"
  1844. AC_MSG_CHECKING([[for gnutls_privkey_import_x509_raw()]])
  1845. AC_LINK_IFELSE([
  1846. AC_LANG_PROGRAM([[
  1847. #include <gnutls/gnutls.h>
  1848. #include <gnutls/abstract.h>
  1849. ]], [[
  1850. gnutls_datum_t data;
  1851. gnutls_privkey_t key = 0;
  1852. #ifndef gnutls_load_file
  1853. (void)gnutls_load_file; /* Check for declaration. */
  1854. #endif
  1855. #ifndef gnutls_privkey_import_x509_raw
  1856. (void)gnutls_privkey_import_x509_raw; /* Check for declaration. */
  1857. #endif
  1858. gnutls_load_file("key.pem", &data);
  1859. gnutls_privkey_import_x509_raw(key, &data, GNUTLS_X509_FMT_PEM, NULL, 0);
  1860. gnutls_free(data.data);
  1861. ]])], [[have_gnutls_sni=yes]], [[have_gnutls_sni=no]])
  1862. AC_MSG_RESULT([[$have_gnutls_sni]])
  1863. AC_CACHE_CHECK([[whether GnuTLS require libgcrypt initialisaion]], [mhd_cv_gcrypt_required],
  1864. [
  1865. AC_COMPILE_IFELSE(
  1866. [
  1867. AC_LANG_PROGRAM(
  1868. [
  1869. #include <gnutls/gnutls.h>
  1870. ],
  1871. [
  1872. #if !defined(GNUTLS_VERSION_NUMBER) || GNUTLS_VERSION_NUMBER+0 <= 0x020c14
  1873. #error Old versions of GnuTLS require libgcript initialisaion
  1874. choke me now
  1875. #endif
  1876. ]
  1877. )
  1878. ],
  1879. [[mhd_cv_gcrypt_required='no']], [[mhd_cv_gcrypt_required='yes']]
  1880. )
  1881. ]
  1882. )
  1883. CPPFLAGS="$SAVE_CPPFLAGS"
  1884. CFLAGS="$SAVE_CFLAGS"
  1885. LDFLAGS="$SAVE_LDFLAGS"
  1886. LIBS="$SAVE_LIBS"
  1887. ],
  1888. [
  1889. AS_UNSET([GNUTLS_CPPFLAGS])
  1890. AS_UNSET([GNUTLS_LDFLAGS])
  1891. ]
  1892. )
  1893. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" = "xunknown"]],
  1894. [
  1895. AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no])
  1896. AS_IF([[test "x$have_gcrypt" = "xyes"]],
  1897. [
  1898. SAVE_CPPFLAGS="$CPPFLAGS"
  1899. SAVE_CFLAGS="$CFLAGS"
  1900. CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
  1901. # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both
  1902. CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS"
  1903. AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT])
  1904. CPPFLAGS="$SAVE_CPPFLAGS"
  1905. CFLAGS="$SAVE_CFLAGS"
  1906. ]
  1907. )
  1908. ]
  1909. )
  1910. AS_UNSET([[crypt_missing]])
  1911. AS_IF([[test "x$have_gnutls" = "xyes"]],
  1912. [
  1913. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" != "xyes"]],
  1914. [
  1915. crypt_missing="required libgcrypt"
  1916. AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])])
  1917. enable_https=no
  1918. MSG_HTTPS="no (lacking $crypt_missing)"
  1919. AS_UNSET([LIBGCRYPT_CFLAGS])
  1920. AS_UNSET([LIBGCRYPT_LIBS])
  1921. AS_UNSET([GNUTLS_CPPFLAGS])
  1922. AS_UNSET([GNUTLS_CFLAGS])
  1923. AS_UNSET([GNUTLS_LDFLAGS])
  1924. AS_UNSET([GNUTLS_LIBS])
  1925. ],
  1926. [
  1927. AC_DEFINE([[HTTPS_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTPS support.])
  1928. enable_https=yes
  1929. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
  1930. [
  1931. MSG_HTTPS="yes (using libgnutls and libgcrypt)"
  1932. MHD_TLS_LIB_CPPFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CPPFLAGS"
  1933. MHD_TLS_LIB_CFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CFLAGS"
  1934. MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS"
  1935. MHD_TLS_LIBDEPS="$GNUTLS_LIBS $LIBGCRYPT_LIBS"
  1936. AC_DEFINE([[MHD_HTTPS_REQUIRE_GCRYPT]], [[1]], [Define to `1' if HTTPS require initialisation of libgcrypt])
  1937. ],
  1938. [
  1939. MSG_HTTPS="yes (using libgnutls)"
  1940. AS_UNSET([LIBGCRYPT_CFLAGS])
  1941. AS_UNSET([LIBGCRYPT_LIBS])
  1942. MHD_TLS_LIB_CPPFLAGS="$GNUTLS_CPPFLAGS"
  1943. MHD_TLS_LIB_CFLAGS="$GNUTLS_CFLAGS"
  1944. MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS"
  1945. MHD_TLS_LIBDEPS="$GNUTLS_LIBS"
  1946. ]
  1947. )
  1948. AS_IF([[ test "x$have_gnutls_pkgcfg" = "xyes" ]],
  1949. [ # remove GnuTLS from private libs in .pc file as it defined in Requires.private
  1950. MHD_REQ_PRIVATE='gnutls'
  1951. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
  1952. [[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]]
  1953. )
  1954. ],
  1955. [
  1956. MHD_REQ_PRIVATE=''
  1957. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
  1958. [[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]]
  1959. )
  1960. MHD_LIBDEPS_PKGCFG="$GNUTLS_LIBS $MHD_LIBDEPS_PKGCFG"
  1961. ])
  1962. ]
  1963. )
  1964. ],
  1965. [
  1966. crypt_missing="libgnutls"
  1967. AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])])
  1968. enable_https=no
  1969. MSG_HTTPS="no (lacking $crypt_missing)"
  1970. AS_UNSET([LIBGCRYPT_CFLAGS])
  1971. AS_UNSET([LIBGCRYPT_LIBS])
  1972. AS_UNSET([GNUTLS_CPPFLAGS])
  1973. AS_UNSET([GNUTLS_CFLAGS])
  1974. AS_UNSET([GNUTLS_LDFLAGS])
  1975. AS_UNSET([GNUTLS_LIBS])
  1976. ]
  1977. )
  1978. ],[
  1979. MSG_HTTPS="no (disabled)"
  1980. ])
  1981. #
  1982. # End of large unindented block
  1983. #
  1984. AC_MSG_CHECKING(whether to support HTTPS)
  1985. AC_MSG_RESULT([$MSG_HTTPS])
  1986. AM_CONDITIONAL([HAVE_GNUTLS], [[test "x$have_gnutls" = "xyes"]])
  1987. AM_CONDITIONAL([HAVE_GNUTLS_SNI], [[test "x$have_gnutls_sni" = "xyes"]])
  1988. AM_CONDITIONAL([ENABLE_HTTPS], [test "x$enable_https" = "xyes"])
  1989. AM_CONDITIONAL([HTTPS_REQUIRE_GCRYPT], [[test "x$enable_https" = "xyes" && test "x$mhd_cv_gcrypt_required" = "xyes"]])
  1990. AC_SUBST([GNUTLS_CPPFLAGS])
  1991. AC_SUBST([GNUTLS_CFLAGS])
  1992. AC_SUBST([GNUTLS_LDFLAGS])
  1993. AC_SUBST([GNUTLS_LIBS])
  1994. # optional: HTTP Basic Auth support. Enabled by default
  1995. AC_MSG_CHECKING([[whether to support HTTP basic authentication]])
  1996. AC_ARG_ENABLE([bauth],
  1997. AS_HELP_STRING([--disable-bauth],
  1998. [disable HTTP basic Auth support]),
  1999. [enable_bauth=${enableval}],
  2000. [enable_bauth=yes])
  2001. AS_IF([[test "x$enable_bauth" != "xno"]],
  2002. [ enable_bauth=yes
  2003. AC_DEFINE([BAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with basic Auth support.]) ])
  2004. AM_CONDITIONAL([ENABLE_BAUTH], [test "x$enable_bauth" != "xno"])
  2005. AC_MSG_RESULT([[$enable_bauth]])
  2006. # optional: HTTP Digest Auth support. Enabled by default
  2007. AC_MSG_CHECKING([[whether to support HTTP digest authentication]])
  2008. AC_ARG_ENABLE([dauth],
  2009. AS_HELP_STRING([--disable-dauth],
  2010. [disable HTTP basic and digest Auth support]),
  2011. [enable_dauth=${enableval}],
  2012. [enable_dauth=yes])
  2013. AS_IF([[test "x$enable_dauth" != "xno"]],
  2014. [ enable_dauth=yes
  2015. AC_DEFINE([DAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with digest Auth support.]) ])
  2016. AM_CONDITIONAL([ENABLE_DAUTH], [test "x$enable_dauth" != "xno"])
  2017. AC_MSG_RESULT([[$enable_dauth]])
  2018. # optional: HTTP "Upgrade" support. Enabled by default
  2019. AC_MSG_CHECKING([[whether to support HTTP "Upgrade"]])
  2020. AC_ARG_ENABLE([[httpupgrade]],
  2021. AS_HELP_STRING([[--disable-httpupgrade]],
  2022. [disable HTTP "Upgrade" support]),
  2023. [AS_VAR_IF([[enable_httpupgrade]],[["no"]],[],[[enable_httpupgrade='yes']])],
  2024. [[enable_httpupgrade='yes']])
  2025. AS_VAR_IF([[enable_httpupgrade]],[["yes"]],
  2026. [
  2027. AC_DEFINE([[UPGRADE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTP Upgrade support.]) ])
  2028. AM_CONDITIONAL([ENABLE_UPGRADE], [[test "x$enable_httpupgrade" = "xyes"]])
  2029. AC_MSG_RESULT([[$enable_httpupgrade]])
  2030. AC_CACHE_CHECK([[for calloc()]], [[mhd_cv_have_func_calloc]],
  2031. [
  2032. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  2033. #include <stdlib.h>
  2034. ]],[[void * ptr = calloc(1, 2)]])
  2035. ],
  2036. [[mhd_cv_have_func_calloc='yes']],
  2037. [[mhd_cv_have_func_calloc='no']]
  2038. )
  2039. ]
  2040. )
  2041. AS_VAR_IF([[mhd_cv_have_func_calloc]], [["yes"]],
  2042. [AC_DEFINE([[HAVE_CALLOC]], [[1]], [Define to 1 if you have the usable `calloc' function.])])
  2043. # Some systems have IPv6 disabled in kernel at run-time
  2044. AS_IF([[test "x${have_inet6}" = "xyes" && test "x${cross_compiling}" = "xno"]],
  2045. [
  2046. AC_CACHE_CHECK([whether IPv6 could be used for testing],[mhd_cv_ipv6_for_testing],
  2047. [
  2048. AC_RUN_IFELSE(
  2049. [
  2050. AC_LANG_SOURCE([[
  2051. #ifdef HAVE_UNISTD_H
  2052. #include <unistd.h>
  2053. #endif
  2054. #ifdef HAVE_SYS_TYPES_H
  2055. #include <sys/types.h>
  2056. #endif
  2057. #ifdef HAVE_SYS_SOCKET_H
  2058. #include <sys/socket.h>
  2059. #endif
  2060. #ifdef HAVE_WINSOCK2_H
  2061. #include <winsock2.h>
  2062. #endif
  2063. #ifdef HAVE_WS2TCPIP_H
  2064. #include <ws2tcpip.h>
  2065. #endif
  2066. #ifdef HAVE_NETINET_IN_H
  2067. #include <netinet/in.h>
  2068. #endif
  2069. #ifdef HAVE_NETINET_IP_H
  2070. #include <netinet/ip.h>
  2071. #endif
  2072. #ifdef HAVE_ARPA_INET_H
  2073. #include <arpa/inet.h>
  2074. #endif
  2075. #ifdef HAVE_NETINET_TCP_H
  2076. #include <netinet/tcp.h>
  2077. #endif
  2078. static void zr_mem(void *ptr, socklen_t size)
  2079. { char *mem = ptr; while(size--) {mem[0] = 0; mem++;} }
  2080. int main(void)
  2081. {
  2082. int ret = 30;
  2083. struct sockaddr_in6 sa;
  2084. #if !defined(_WIN32) || defined(__CYGWIN__)
  2085. int sckt;
  2086. const int invld_sckt = -1;
  2087. #else
  2088. SOCKET sckt;
  2089. const SOCKET invld_sckt = INVALID_SOCKET;
  2090. WSADATA wsa_data;
  2091. WSAStartup(MAKEWORD(2, 2), &wsa_data);
  2092. #endif
  2093. zr_mem(&sa, sizeof(sa));
  2094. sa.sin6_family = AF_INET6;
  2095. sa.sin6_port = 0;
  2096. sa.sin6_addr = in6addr_loopback;
  2097. #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
  2098. sa.sin6_len = sizeof(sa);
  2099. #endif
  2100. sckt = socket (PF_INET6, SOCK_STREAM, 0);
  2101. if (invld_sckt != sckt)
  2102. {
  2103. if (0 == bind (sckt, (struct sockaddr *)&sa, sizeof(sa)))
  2104. {
  2105. if (0 == listen (sckt, 1))
  2106. ret = 0;
  2107. else
  2108. ret = 1; /* listen() failed */
  2109. } else ret = 2; /* bind() failed */
  2110. #if !defined(_WIN32) || defined(__CYGWIN__)
  2111. close (sckt);
  2112. #else
  2113. closesocket (sckt);
  2114. #endif
  2115. } else ret = 3; /* socket() failed */
  2116. #if defined(_WIN32) && !defined(__CYGWIN__)
  2117. WSACleanup();
  2118. #endif
  2119. return ret;
  2120. }
  2121. ]])
  2122. ], [[mhd_cv_ipv6_for_testing="yes"]], [[mhd_cv_ipv6_for_testing="no"]], [[mhd_cv_ipv6_for_testing="no"]]
  2123. )
  2124. ]
  2125. )
  2126. ]
  2127. )
  2128. AS_VAR_IF([mhd_cv_ipv6_for_testing],["yes"],
  2129. [AC_DEFINE([[USE_IPV6_TESTING]], [[1]], [Define to 1 if your kernel supports IPv6 and IPv6 is enabled and useful for testing.])]
  2130. )
  2131. # Check for fork() and waitpid(). They are used for tests.
  2132. AC_MSG_CHECKING([[for fork()]])
  2133. mhd_have_fork_waitpid='no'
  2134. AC_LINK_IFELSE(
  2135. [
  2136. AC_LANG_PROGRAM(
  2137. [[
  2138. #ifdef HAVE_SYS_TYPES_H
  2139. #include <sys/types.h>
  2140. #endif
  2141. #ifdef HAVE_UNISTD_H
  2142. #include <unistd.h>
  2143. #endif
  2144. ]], [[
  2145. pid_t p = fork ();
  2146. if (0 == p)
  2147. return 1;
  2148. ]])
  2149. ], [
  2150. AC_DEFINE([[HAVE_FORK]], [[1]], [Define to 1 if you have the usable `fork' function.])
  2151. AC_MSG_RESULT([[yes]])
  2152. AC_MSG_CHECKING([[for waitpid()]])
  2153. AC_LINK_IFELSE(
  2154. [
  2155. AC_LANG_PROGRAM(
  2156. [[
  2157. #include <sys/wait.h>
  2158. ]], [[
  2159. pid_t p = fork ();
  2160. if (0 == p)
  2161. return 1;
  2162. waitpid (p, (void*)0, 0)
  2163. ]])
  2164. ], [
  2165. AC_DEFINE([[HAVE_WAITPID]], [[1]], [Define to 1 if you have the usable `waitpid' function.])
  2166. AC_MSG_RESULT([[yes]])
  2167. mhd_have_fork_waitpid='yes'
  2168. ],[
  2169. AC_MSG_RESULT([[no]])
  2170. ])
  2171. ],[
  2172. AC_MSG_RESULT([[no]])
  2173. ])
  2174. AM_CONDITIONAL([HAVE_FORK_WAITPID], [test "x$mhd_have_fork_waitpid" = "xyes"])
  2175. # gcov compilation
  2176. AC_MSG_CHECKING(whether to compile with support for code coverage analysis)
  2177. AC_ARG_ENABLE([coverage],
  2178. AS_HELP_STRING([--enable-coverage],
  2179. [compile the library with code coverage support]),
  2180. [use_gcov=${enableval}],
  2181. [use_gcov=no])
  2182. AC_MSG_RESULT($use_gcov)
  2183. AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
  2184. AX_COUNT_CPUS
  2185. AS_IF([[test "$CPU_COUNT" -gt "32"]], [[CPU_COUNT="32"]])dnl Limit resource usage
  2186. AC_SUBST([CPU_COUNT])
  2187. AC_MSG_CHECKING([[whether to enable debug asserts]])
  2188. AC_ARG_ENABLE([[asserts]],
  2189. AS_HELP_STRING([[--enable-asserts]],
  2190. [enable test build with debug asserts]),
  2191. [], [[enable_asserts='no']])
  2192. AS_CASE([[$enable_asserts]], [[yes]], [[:]], [[no]], [[:]], [[enable_asserts='no']])
  2193. AC_MSG_RESULT([[$enable_asserts]])
  2194. AS_VAR_IF([[enable_asserts]], [["yes"]],
  2195. [
  2196. AC_DEFINE([[_DEBUG]], [[1]], [Define to use debug asserts.])
  2197. [mhd_assert_test_prg="#include <assert.h>
  2198. int pos_val(void) {return 5;}
  2199. int neg_val(void) {return -5;}
  2200. int main(void)
  2201. { int pos_var = pos_val(), neg_var = neg_val();
  2202. assert(neg_var > pos_var); /* Must trigger assert. */
  2203. (void)pos_var; (void)neg_var;
  2204. return 0; }
  2205. "]
  2206. AC_CACHE_CHECK([[whether system assert() is available]], [mhd_cv_sys_assert_avail],
  2207. [
  2208. AC_LINK_IFELSE([AC_LANG_SOURCE([[$mhd_assert_test_prg]])],
  2209. [[mhd_cv_sys_assert_avail='yes']],
  2210. [[mhd_cv_sys_assert_avail='no']])
  2211. ]
  2212. )
  2213. AS_VAR_IF([[mhd_cv_sys_assert_avail]], [["no"]], [],
  2214. [AC_DEFINE([[HAVE_ASSERT]], [[1]], [Define if you have usable assert() and assert.h])])
  2215. AS_UNSET([mhd_assert_test_prg])
  2216. ],
  2217. [AC_DEFINE([[NDEBUG]], [[1]], [Define to disable usage of debug asserts.])]
  2218. )
  2219. MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS -export-dynamic -no-undefined"
  2220. AC_SUBST(MHD_LIB_CPPFLAGS)
  2221. AC_SUBST(MHD_LIB_CFLAGS)
  2222. AC_SUBST(MHD_LIB_LDFLAGS)
  2223. AC_SUBST(MHD_LIBDEPS)
  2224. AC_SUBST(MHD_TLS_LIB_CPPFLAGS)
  2225. AC_SUBST(MHD_TLS_LIB_CFLAGS)
  2226. AC_SUBST(MHD_TLS_LIB_LDFLAGS)
  2227. AC_SUBST(MHD_TLS_LIBDEPS)
  2228. # for pkg-config
  2229. AC_SUBST([MHD_REQ_PRIVATE])
  2230. AC_SUBST([MHD_LIBDEPS_PKGCFG])
  2231. AC_SUBST(CPPFLAGS)
  2232. AC_SUBST(LIBS)
  2233. AC_SUBST(LDFLAGS)
  2234. # Used for 'po' directory staff
  2235. AC_SUBST([ac_configure_args])
  2236. AC_SUBST([EMPTY_VAR], [[]])
  2237. # We define the paths here, because MinGW/GCC expands paths
  2238. # passed through the command line ("-DDIR=..."). This would
  2239. # lead to hard-coded paths ("C:\mingw\mingw\bin...") that do
  2240. # not contain the actual installation.
  2241. AC_DEFINE_DIR([MHD_PLUGIN_INSTALL_PREFIX], [libdir/libmicrohttpd], [tls plugins])
  2242. # should experimental code be compiled (code that may not yet compile)?
  2243. AC_MSG_CHECKING(whether to compile experimental code)
  2244. AC_ARG_ENABLE([experimental],
  2245. [AS_HELP_STRING([--enable-experimental], [enable compiling experimental code])],
  2246. [enable_experimental=${enableval}],
  2247. [enable_experimental=no])
  2248. AC_MSG_RESULT($enable_experimental)
  2249. AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
  2250. AC_CONFIG_FILES([libmicrohttpd.pc
  2251. w32/common/microhttpd_dll_res_vc.rc
  2252. Makefile
  2253. contrib/Makefile
  2254. doc/Makefile
  2255. doc/doxygen/libmicrohttpd.doxy
  2256. doc/doxygen/Makefile
  2257. doc/examples/Makefile
  2258. m4/Makefile
  2259. src/Makefile
  2260. src/include/Makefile
  2261. src/lib/Makefile
  2262. src/microhttpd/Makefile
  2263. src/examples/Makefile
  2264. src/testcurl/Makefile
  2265. src/testcurl/https/Makefile
  2266. src/testzzuf/Makefile])
  2267. AC_OUTPUT
  2268. # Finally: summary
  2269. AS_IF([test "x$enable_curl" != "xyes"],
  2270. [MSG_CURL="no, many unit tests will not run"],
  2271. [MSG_CURL="yes"])
  2272. AS_VAR_IF([os_is_windows], ["yes"],
  2273. [os_ver_msg="
  2274. Target W32 ver: ${mhd_w32_ver_msg}"], [AS_UNSET([[os_ver_msg]])])
  2275. AC_MSG_NOTICE([GNU libmicrohttpd ${PACKAGE_VERSION} Configuration Summary:
  2276. Target directory: ${prefix}
  2277. Cross-compiling: ${cross_compiling}
  2278. Operating System: ${host_os}${os_ver_msg}
  2279. Shutdown of listening socket triggers select: ${mhd_cv_host_shtdwn_trgr_select}
  2280. Inter-thread comm: ${use_itc}
  2281. poll support: ${enable_poll=no}
  2282. epoll support: ${enable_epoll=no}
  2283. sendfile used: ${found_sendfile}
  2284. HTTPS support: ${MSG_HTTPS}
  2285. Threading lib: ${USE_THREADS}
  2286. Use thread names: ${enable_thread_names}
  2287. Use debug asserts: ${enable_asserts}
  2288. Messages: ${enable_messages}
  2289. Gettext: ${have_po}
  2290. Basic auth.: ${enable_bauth}
  2291. Digest auth.: ${enable_dauth}
  2292. HTTP "Upgrade": ${enable_httpupgrade}
  2293. Postproc: ${enable_postprocessor}
  2294. Build docs: ${enable_doc}
  2295. Build examples: ${enable_examples}
  2296. Test with libcurl: ${MSG_CURL}
  2297. ])
  2298. AS_IF([test "x$enable_https" = "xyes"],
  2299. [AC_MSG_NOTICE([HTTPS subsystem configuration:
  2300. License : LGPLv2.1+ only
  2301. ])],
  2302. [AC_MSG_NOTICE([
  2303. License : LGPLv2.1+ or eCos
  2304. ])])
  2305. AS_IF([test "x$enable_bauth" != "xyes" || \
  2306. test "x$enable_dauth" != "xyes" || \
  2307. test "x$enable_httpupgrade" != "xyes" || \
  2308. test "x$enable_postprocessor" != "xyes"],
  2309. [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.])])