configure.ac 66 KB

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