configure.ac 69 KB

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