configure.ac 68 KB

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