configure.ac 65 KB

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