configure.ac 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517
  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.54],[[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=54
  30. LIB_VERSION_REVISION=0
  31. LIB_VERSION_AGE=42
  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. PACKAGE_VERSION_MAJOR='m4_car(m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  69. PACKAGE_VERSION_MINOR='m4_argn(2, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  70. PACKAGE_VERSION_SUBMINOR='m4_argn(3, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  71. AC_SUBST([PACKAGE_VERSION_MAJOR])
  72. AC_SUBST([PACKAGE_VERSION_MINOR])
  73. AC_SUBST([PACKAGE_VERSION_SUBMINOR])
  74. AC_CONFIG_FILES([src/microhttpd/microhttpd_dll_res.rc])
  75. MHD_LIB_CPPFLAGS=""
  76. MHD_LIB_CFLAGS=""
  77. MHD_LIB_LDFLAGS=""
  78. MHD_LIBDEPS=""
  79. # for pkg-config
  80. MHD_REQ_PRIVATE=''
  81. MHD_LIBDEPS_PKGCFG=''
  82. AH_TEMPLATE([[HAVE_STDBOOL_H]], [Define to 1 if you have the <stdbool.h> header file and <stdbool.h> defines 'bool' type.])
  83. AH_TEMPLATE([[HAVE_REAL_BOOL]], [Define to 1 if you have the real boolean type.])
  84. AH_TEMPLATE([[bool]], [Define to type name which will be used as boolean type.])
  85. AC_CHECK_HEADER([stdbool.h],
  86. [
  87. AC_CHECK_TYPE([bool],
  88. [
  89. AC_DEFINE([[HAVE_STDBOOL_H]], [[1]])
  90. AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])
  91. ],
  92. [
  93. AC_MSG_WARN([[Header <stdbool.h> is present, but "bool" type cannot be detected. Check compiler flags.]])
  94. AC_DEFINE([[bool]], [[int]])
  95. ], [
  96. #include <stdbool.h>
  97. ]
  98. )
  99. ],
  100. [
  101. AC_CHECK_TYPE([bool],
  102. [AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])],
  103. [
  104. AC_CHECK_TYPE([_Bool],
  105. [
  106. AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])
  107. AC_DEFINE([[bool]], [[_Bool]])
  108. ],
  109. [
  110. AC_DEFINE([[bool]], [[int]])
  111. ], []
  112. )
  113. ], []
  114. )
  115. ],
  116. [AC_INCLUDES_DEFAULT]
  117. )
  118. AC_CACHE_CHECK([[whether "true" is defined or builtin]], [[mhd_cv_macro_true_defined]],
  119. [AC_COMPILE_IFELSE(
  120. [AC_LANG_PROGRAM(
  121. [[
  122. #ifdef HAVE_STDBOOL_H
  123. #include <stdbool.h>
  124. #endif
  125. ]], [[
  126. #if defined(true)
  127. /* dummy */
  128. #else
  129. (void)true;
  130. #endif
  131. ]])
  132. ], [[mhd_cv_macro_true_defined='yes']], [[mhd_cv_macro_true_defined='no']])
  133. ])
  134. AS_VAR_IF([[mhd_cv_macro_true_defined]], [["yes"]], [[:]],
  135. [AC_DEFINE([[true]],[[(!0)]], [Define to value interpreted by compiler as boolean "true", if "true" is not defined by system headers.])])
  136. AC_CACHE_CHECK([[whether "false" is defined or builtin]], [[mhd_cv_macro_false_defined]],
  137. [AC_COMPILE_IFELSE(
  138. [AC_LANG_PROGRAM(
  139. [[
  140. #ifdef HAVE_STDBOOL_H
  141. #include <stdbool.h>
  142. #endif
  143. ]], [[
  144. #if !defined(false)
  145. (void)false;
  146. #else
  147. /* dummy */
  148. #endif
  149. ]])
  150. ], [[mhd_cv_macro_false_defined='yes']], [[mhd_cv_macro_false_defined='no']])
  151. ])
  152. AS_VAR_IF([[mhd_cv_macro_false_defined]], [["yes"]], [[:]],
  153. [AC_DEFINE([[false]],[[0]], [Define to value interpreted by compiler as boolean "false", if "false" is not defined by system headers.])])
  154. AC_CACHE_CHECK([[whether "true" and "false" could be used]], [[mhd_cv_macro_true_false_valid]],
  155. [AC_COMPILE_IFELSE(
  156. [AC_LANG_PROGRAM(
  157. [[
  158. #ifdef HAVE_STDBOOL_H
  159. #include <stdbool.h>
  160. #endif
  161. ]], [[
  162. int var1[true ? 1 : -1] = { 1 };
  163. int var2[false ? -1 : 1] = { 2 };
  164. int var3[!true ? -1 : 1] = { 3 };
  165. int var4[!false ? 1 : -1] = { 4 };
  166. if (var1[0] == var2[0] || var3[0] == var4[0])
  167. return 1;
  168. ]])
  169. ], [[mhd_cv_macro_true_false_valid='yes']], [[mhd_cv_macro_true_false_valid='no']])
  170. ])
  171. AS_VAR_IF([[mhd_cv_macro_true_false_valid]], [["yes"]], [[:]],
  172. [AC_MSG_ERROR([[Value of "true" or value of "false" is not valid. Check config.log for details.]])])
  173. AX_CHECK_COMPILE_FLAG([[-Werror=attributes]],
  174. [
  175. save_CFLAGS="$CFLAGS"
  176. CFLAGS="$CFLAGS -Werror=attributes"
  177. AC_MSG_CHECKING([[whether -Werror=attributes actually works]])
  178. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  179. [[__attribute__((non_existing_attrb_dummy)) int SimpleFunc(void) {return 3;}]], [[int r = SimpleFunc(); if (r) return r;]])],
  180. [
  181. AC_MSG_RESULT([[no]])
  182. errattr_CFLAGS=""
  183. ], [
  184. AC_MSG_RESULT([[yes]])
  185. errattr_CFLAGS="-Werror=attributes"
  186. ])
  187. CFLAGS="$save_CFLAGS"
  188. ],
  189. [[errattr_CFLAGS=""]], [], [])
  190. AC_MSG_CHECKING([[for function inline keywords suppoted by $CC]])
  191. save_CFLAGS="$CFLAGS"
  192. CFLAGS="$CFLAGS $errattr_CFLAGS"
  193. inln_prfx="none"
  194. # Prefer always inline functions
  195. for inln_prfx_chk in InlineWithAttr __forceinline inline __inline__ __inline _inline _Inline; do
  196. # Try to link to avoid "symbol undefined" problems at build time
  197. AS_IF([[test "x$inln_prfx_chk" = "xInlineWithAttr"]],
  198. [
  199. AS_IF([[test "x$errattr_CFLAGS" = "x"]],
  200. [[ # Skip test with attribute as negative result can't be detected
  201. inln_prfx_chk="__forceinline" # use next value
  202. ]],[[inln_prfx_chk="inline __attribute__((always_inline))"]])
  203. ])
  204. AC_LINK_IFELSE(
  205. [
  206. AC_LANG_PROGRAM(
  207. [[
  208. #ifdef __cplusplus
  209. #error This test is only for C.
  210. choke me
  211. #endif
  212. #ifdef HAVE_STDBOOL_H
  213. #include <stdbool.h>
  214. #endif
  215. static $inln_prfx_chk bool cmpfn(int x, int y)
  216. { return x > y; }
  217. static $inln_prfx_chk int sumfn(int x, int y)
  218. { return x + y; }
  219. ]],[[
  220. int a = 1, b = 100, c;
  221. if (cmpfn(a, b))
  222. c = sumfn(a, b);
  223. else
  224. c = 0 - sumfn(a, b);
  225. ]])
  226. ],
  227. [[ inln_prfx="$inln_prfx_chk" ]])
  228. test "x$inln_prfx" != "xnone" && break
  229. done
  230. AS_IF([[test "x$inln_prfx" != "xnone"]],
  231. [
  232. AC_DEFINE([INLINE_FUNC],[1],[Define to 1 if your C compiler supports inline functions.])
  233. AC_DEFINE_UNQUOTED([_MHD_inline],[static $inln_prfx],[Define to prefix which will be used with MHD inline functions.])
  234. ])
  235. AC_MSG_RESULT([[$inln_prfx]])
  236. CFLAGS="$save_CFLAGS"
  237. # Check system type
  238. shutdown_trig_select='no'
  239. AC_MSG_CHECKING([[for target host OS]])
  240. case "$host_os" in
  241. *darwin* | *rhapsody* | *macosx*)
  242. AC_DEFINE_UNQUOTED(OSX,1,[This is an OS X system])
  243. CFLAGS="-no-cpp-precomp -fno-common $CFLAGS"
  244. mhd_host_os='Darwin'
  245. AC_MSG_RESULT([[$mhd_host_os]])
  246. ;;
  247. freebsd*)
  248. AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
  249. AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system])
  250. mhd_host_os='FreeBSD'
  251. AC_MSG_RESULT([[$mhd_host_os]])
  252. ;;
  253. openbsd*)
  254. AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
  255. AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system])
  256. mhd_host_os='OpenBSD'
  257. AC_MSG_RESULT([[$mhd_host_os]])
  258. ;;
  259. netbsd*)
  260. AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
  261. AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system])
  262. mhd_host_os='NetBSD'
  263. AC_MSG_RESULT([[$mhd_host_os]])
  264. ;;
  265. *solaris*)
  266. AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system])
  267. AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno doesnt work])
  268. mhd_host_os='Solaris'
  269. AC_MSG_RESULT([[$mhd_host_os]])
  270. AC_SEARCH_LIBS(gethostbyname, nsl)
  271. AC_SEARCH_LIBS(socket, socket)
  272. ;;
  273. *arm-linux*)
  274. AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel])
  275. mhd_host_os='ARM Linux'
  276. AC_MSG_RESULT([[$mhd_host_os]])
  277. CFLAGS="-fPIC -pipe $CFLAGS"
  278. ;;
  279. *linux*)
  280. AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel])
  281. mhd_host_os='Linux'
  282. AC_MSG_RESULT([[$mhd_host_os]])
  283. ;;
  284. *cygwin*)
  285. AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
  286. mhd_host_os='Windows (Cygwin)'
  287. AC_MSG_RESULT([[$mhd_host_os]])
  288. os_is_windows=yes
  289. ;;
  290. *mingw*)
  291. AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
  292. AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
  293. mhd_host_os='Windows (MinGW)'
  294. AC_MSG_RESULT([[$mhd_host_os]])
  295. LIBS="$LIBS -lws2_32"
  296. AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([[Winsock2 headers are required for W32]])], [AC_INCLUDES_DEFAULT])
  297. AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool],
  298. [[mslibcheck=`lib 2>&1`
  299. if [[ $mslibcheck = "Microsoft (R) Library Manager"* ]]; then
  300. ac_cv_use_ms_lib_tool=yes
  301. else
  302. ac_cv_use_ms_lib_tool=no
  303. fi
  304. ]])
  305. if test "x$ac_cv_use_ms_lib_tool" = "xyes"; then
  306. AC_SUBST([MS_LIB_TOOL], [[lib]])
  307. fi
  308. AC_SUBST([lt_cv_objdir])
  309. os_is_windows=yes
  310. os_is_native_w32=yes
  311. ;;
  312. *openedition*)
  313. AC_DEFINE_UNQUOTED(OS390,1,[This is a OS/390 system])
  314. mhd_host_os='OS/390'
  315. AC_MSG_RESULT([[$mhd_host_os]])
  316. ;;
  317. *)
  318. mhd_host_os='unrecognised OS'
  319. AC_MSG_RESULT([[$mhd_host_os]])
  320. AC_MSG_WARN([Unrecognised OS $host_os])
  321. AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
  322. # You might want to find out if your OS supports shutdown on listen sockets,
  323. # and extend the switch statement; if we do not have 'HAVE_LISTEN_SHUTDOWN',
  324. # pipes are used instead to signal 'select'.
  325. # AC_DEFINE_UNQUOTED(HAVE_LISTEN_SHUTDOWN,1,[can use shutdown on listen sockets])
  326. ;;
  327. esac
  328. AC_ARG_WITH([threads],
  329. [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto) [auto]])],
  330. [], [with_threads='auto'])
  331. AS_CASE([[$with_threads]],
  332. [[win32]], [[with_threads='w32']],
  333. [[pthreads]], [[with_threads='posix']],
  334. [[posix]], [[:]],
  335. [[w32]], [[:]],
  336. [[auto]], [[:]],
  337. [AC_MSG_ERROR([[incorrect parameter "$with_threads" specified for --with-threads]])]
  338. )
  339. # Check for posix threads support, regardless of configure parameters as
  340. # testsuite use only posix threads.
  341. AX_PTHREAD(
  342. [
  343. mhd_have_posix_threads='yes'
  344. AC_DEFINE([[HAVE_PTHREAD_H]],[[1]],[Define to 1 if you have the <pthread.h> header file.])
  345. ],[[mhd_have_posix_threads='no']])
  346. AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$mhd_have_posix_threads" = "xyes"])
  347. mhd_have_w32_threads='no'
  348. AS_IF([[test "x$with_threads" = "xauto"]],
  349. [
  350. AS_IF([[test "x$os_is_windows" = "xyes"]],
  351. [
  352. AC_MSG_CHECKING([[for W32 threads]])
  353. AC_LINK_IFELSE(
  354. [AC_LANG_PROGRAM([#include <windows.h>], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])]
  355. , [[mhd_have_w32_threads='yes']], [[mhd_have_w32_threads='no']]
  356. )
  357. AC_MSG_RESULT([[$mhd_have_w32_threads]])
  358. ])
  359. ]
  360. )
  361. AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd]])
  362. AS_IF([[test "x$with_threads" = "xposix"]],
  363. [ # forced posix threads
  364. AS_IF([[test "x$mhd_have_posix_threads" = "xyes"]], [[ USE_THREADS='posix' ]],
  365. [ AS_IF([[test "x$os_is_windows" = "xyes"]] ,
  366. [ AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]])],
  367. [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]])] )
  368. ])
  369. ] ,
  370. [[ test "x$with_threads" = "xw32" ]] ,
  371. [ # forced w32 threads
  372. AS_IF([[test "x$mhd_have_w32_threads" = "xyes"]],
  373. [[ USE_THREADS='w32' ]],
  374. [ AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]])])
  375. ] ,
  376. [ # automatic threads lib selection
  377. AS_IF([[test "x$os_is_native_w32" = "xyes" && test "x$mhd_have_w32_threads" = "xyes"]] ,
  378. [[ USE_THREADS='w32' ]] ,
  379. [[ test "x$mhd_have_posix_threads" = "xyes" ]], [[ USE_THREADS='posix' ]],
  380. [[ test "x$mhd_have_w32_threads" = "xyes" ]], [[ USE_THREADS='w32' ]],
  381. [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]]) ]
  382. )
  383. ]
  384. )
  385. if test "x$USE_THREADS" = "xposix"; then
  386. CC="$PTHREAD_CC"
  387. AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads])
  388. MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS"
  389. MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS"
  390. MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG"
  391. elif test "x$USE_THREADS" = "xw32"; then
  392. AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads])
  393. fi
  394. AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"])
  395. AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"])
  396. AC_MSG_RESULT([[$USE_THREADS]])
  397. AC_ARG_ENABLE([[thread-names]],
  398. [AS_HELP_STRING([--disable-thread-names [auto] ],[do not set names on MHD generated threads])],
  399. [], [enable_thread_names='auto'])
  400. if test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix"; then
  401. # Check for thread name function
  402. HAVE_THREAD_NAME_FUNC="no"
  403. SAVE_LIBS="$LIBS"
  404. SAVE_CFLAGS="$CFLAGS"
  405. LIBS="$PTHREAD_LIBS $LIBS"
  406. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  407. AC_CHECK_HEADERS([pthread_np.h],[],[],
  408. [
  409. AC_INCLUDES_DEFAULT
  410. [
  411. #include <pthread.h>
  412. ]
  413. ])
  414. # Try to find how to set thread name by thread attributes.
  415. # If pthread_attr_setname_np(3) is not declared, it's not possible to detect
  416. # form of pthread_attr_setname_np(3) due to C "feature" "implicit declaration".
  417. AC_CHECK_DECL([[pthread_attr_setname_np]],[],[],[[
  418. #include <pthread.h>
  419. #ifdef HAVE_PTHREAD_NP_H
  420. #include <pthread_np.h>
  421. #endif
  422. ]])
  423. AS_IF([[test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]],
  424. [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in NetBSD or OSF1 form]])
  425. AC_LINK_IFELSE(
  426. [AC_LANG_PROGRAM([[
  427. #include <pthread.h>
  428. #ifdef HAVE_PTHREAD_NP_H
  429. #include <pthread_np.h>
  430. #endif
  431. ]], [[
  432. pthread_attr_t thr_attr;
  433. pthread_attr_init(&thr_attr);
  434. pthread_attr_setname_np(&thr_attr, "name", 0);
  435. pthread_attr_destroy(&thr_attr);
  436. ]])],
  437. [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.])
  438. HAVE_THREAD_NAME_FUNC="yes"
  439. AC_MSG_RESULT([[yes]])],
  440. [AC_MSG_RESULT([[no]])]
  441. )
  442. ])
  443. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]],
  444. [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in IBM i form]])
  445. AC_LINK_IFELSE(
  446. [AC_LANG_PROGRAM([[
  447. #include <pthread.h>
  448. #ifdef HAVE_PTHREAD_NP_H
  449. #include <pthread_np.h>
  450. #endif
  451. ]], [[
  452. pthread_attr_t thr_attr;
  453. pthread_attr_init(&thr_attr);
  454. pthread_attr_setname_np(&thr_attr, "name");
  455. pthread_attr_destroy(&thr_attr);
  456. ]])],
  457. [AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI]], [[1]], [Define if you have IBM i form of pthread_attr_setname_np(3) function.])
  458. HAVE_THREAD_NAME_FUNC="yes"
  459. AC_MSG_RESULT([[yes]])],
  460. [AC_MSG_RESULT([[no]])]
  461. )
  462. ])
  463. # Try to find how to set thread name for started thread - less convinent
  464. # than setting name by attributes.
  465. # If pthread_setname_np(3) is not declared, it's not possible to detect
  466. # form of pthread_setname_np(3) due to C "feature" "implicit declaration".
  467. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]],
  468. [AC_CHECK_DECL([[pthread_setname_np]],[],[],[[
  469. #include <pthread.h>
  470. #ifdef HAVE_PTHREAD_NP_H
  471. #include <pthread_np.h>
  472. #endif
  473. ]])
  474. ])
  475. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  476. [AC_MSG_CHECKING([[for pthread_setname_np(3) in NetBSD or OSF1 form]])
  477. AC_LINK_IFELSE(
  478. [AC_LANG_PROGRAM([[
  479. #include <pthread.h>
  480. #ifdef HAVE_PTHREAD_NP_H
  481. #include <pthread_np.h>
  482. #endif
  483. ]], [[int res = pthread_setname_np(pthread_self(), "name", 0);]])],
  484. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_setname_np(3) function.])
  485. HAVE_THREAD_NAME_FUNC="yes"
  486. AC_MSG_RESULT([[yes]])],
  487. [AC_MSG_RESULT([[no]])]
  488. )
  489. ])
  490. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  491. [AC_MSG_CHECKING([[for pthread_setname_np(3) in GNU/Linux form]])
  492. AC_LINK_IFELSE(
  493. [AC_LANG_PROGRAM([[
  494. #include <pthread.h>
  495. #ifdef HAVE_PTHREAD_NP_H
  496. #include <pthread_np.h>
  497. #endif
  498. ]], [[int res = pthread_setname_np(pthread_self(), "name");]])],
  499. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_GNU]], [[1]], [Define if you have GNU/Linux form of pthread_setname_np(3) function.])
  500. HAVE_THREAD_NAME_FUNC="yes"
  501. AC_MSG_RESULT([[yes]])],
  502. [AC_MSG_RESULT([[no]])]
  503. )
  504. ])
  505. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  506. [AC_MSG_CHECKING([[for pthread_setname_np(3) in Darwin form]])
  507. AC_LINK_IFELSE(
  508. [AC_LANG_PROGRAM([[
  509. #include <pthread.h>
  510. #ifdef HAVE_PTHREAD_NP_H
  511. #include <pthread_np.h>
  512. #endif
  513. ]], [[int res = pthread_setname_np("name");]])],
  514. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_DARWIN]], [[1]], [Define if you have Darwin form of pthread_setname_np(3) function.])
  515. HAVE_THREAD_NAME_FUNC="yes"
  516. AC_MSG_RESULT([[yes]])],
  517. [AC_MSG_RESULT([[no]])]
  518. )
  519. ])
  520. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]],
  521. [
  522. AC_CHECK_DECL([[pthread_set_name_np]],
  523. [
  524. AC_MSG_CHECKING([[for pthread_set_name_np(3) in FreeBSD form]])
  525. AC_LINK_IFELSE(
  526. [AC_LANG_PROGRAM([[
  527. #include <pthread.h>
  528. #ifdef HAVE_PTHREAD_NP_H
  529. #include <pthread_np.h>
  530. #endif
  531. ]], [[pthread_set_name_np(pthread_self(), "name");]])],
  532. [AC_DEFINE([[HAVE_PTHREAD_SET_NAME_NP_FREEBSD]], [[1]], [Define if you have FreeBSD form of pthread_set_name_np(3) function.])
  533. HAVE_THREAD_NAME_FUNC="yes"
  534. AC_MSG_RESULT([[yes]])],
  535. [AC_MSG_RESULT([[no]])]
  536. )
  537. ],[],[[
  538. #include <pthread.h>
  539. #ifdef HAVE_PTHREAD_NP_H
  540. #include <pthread_np.h>
  541. #endif
  542. ]]
  543. )
  544. ])
  545. LIBS="$SAVE_LIBS"
  546. CFLAGS="$SAVE_CFLAGS"
  547. fi
  548. AS_IF(
  549. [[test "x$enable_thread_names" != "xno"]],
  550. [
  551. AC_MSG_CHECKING([[whether to enable thread names]])
  552. AC_COMPILE_IFELSE(
  553. [AC_LANG_PROGRAM([], [[
  554. #ifdef MHD_NO_THREAD_NAMES
  555. #error Thread names are disabled.
  556. choke me
  557. #endif
  558. /* Keep in sync with mhd_threads.h */
  559. #if defined(MHD_USE_POSIX_THREADS) && (defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) || \
  560. defined(HAVE_PTHREAD_SETNAME_NP_GNU) || defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || \
  561. defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) )
  562. int a = 1;
  563. #elif defined(MHD_USE_W32_THREADS) && defined(_MSC_FULL_VER)
  564. int b = 2;
  565. #else
  566. #error No thread name function is available.
  567. choke me
  568. #endif
  569. ]])
  570. ], [
  571. enable_thread_names='yes'
  572. ], [
  573. AS_IF([[test "x$enable_thread_names" = "xyes"]],
  574. [
  575. AC_MSG_RESULT([[no]])
  576. AC_MSG_ERROR([[thread names was explicitly requested, but thread name function is not available]])
  577. ])
  578. enable_thread_names='no'
  579. ])
  580. AC_MSG_RESULT([[$enable_thread_names]])
  581. ])
  582. AS_IF([[test "x$enable_thread_names" = "xno"]],
  583. [AC_DEFINE([[MHD_NO_THREAD_NAMES]], [[1]], [Define to 1 to disable setting name on generated threads])])
  584. AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"])
  585. w32_shared_lib_exp=no
  586. if test "x$enable_shared" = "xyes" && test "x$os_is_native_w32" = "xyes"; then
  587. if test "x$ac_cv_use_ms_lib_tool" = "xyes" || test -n "$DLLTOOL"; then
  588. w32_shared_lib_exp=yes
  589. else
  590. AC_MSG_WARN([[GNU dlltool or MS lib.exe is required for creating shared library export on W32]])
  591. AC_MSG_WARN([[Export library libmicrohttpd.lib will not be created]])
  592. fi
  593. fi
  594. AM_CONDITIONAL(W32_SHARED_LIB_EXP, [test "x$w32_shared_lib_exp" = "xyes"])
  595. AM_CONDITIONAL(USE_MS_LIB_TOOL, [test "x$ac_cv_use_ms_lib_tool" = "xyes"])
  596. MHD_CHECK_SOCKET_SHUTDOWN_TRIGGER([AC_DEFINE([HAVE_LISTEN_SHUTDOWN],[1],[can use shutdown on listen sockets])])
  597. AM_CONDITIONAL([HAVE_LISTEN_SHUTDOWN], [test "x$mhd_cv_host_shtdwn_trgr_select" = "xyes"])
  598. # set GCC options
  599. # use '-fno-strict-aliasing', but only if the compiler
  600. # and linker can take it
  601. AX_CHECK_LINK_FLAG([-fno-strict-aliasing],
  602. [AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing])])
  603. AC_C_BIGENDIAN
  604. AC_CHECK_PROG([HAVE_CURL_BINARY],[curl],[yes],[no])
  605. AM_CONDITIONAL([HAVE_CURL_BINARY],[test "x$HAVE_CURL_BINARY" = "xyes"])
  606. AC_CHECK_PROG([HAVE_MAKEINFO_BINARY],[makeinfo],[yes],[no])
  607. AM_CONDITIONAL([HAVE_MAKEINFO_BINARY],[test "x$HAVE_MAKEINFO_BINARY" = "xyes"])
  608. AM_CONDITIONAL(W32_STATIC_LIB, [test "x$os_is_native_w32" = "xyes" && test "x$enable_static" = "xyes"])
  609. AC_ARG_ENABLE([[doc]],
  610. [AS_HELP_STRING([[--disable-doc]], [do not build any documentation])], ,
  611. [enable_doc=yes])
  612. test "x$enable_doc" = "xno" || enable_doc=yes
  613. AM_CONDITIONAL([BUILD_DOC], [test "x$enable_doc" = "xyes"])
  614. AC_ARG_ENABLE([[examples]],
  615. [AS_HELP_STRING([[--disable-examples]], [do not build any examples])], ,
  616. [enable_examples=yes])
  617. test "x$enable_examples" = "xno" || enable_examples=yes
  618. AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" = "xyes"])
  619. AC_ARG_ENABLE([[poll]],
  620. [AS_HELP_STRING([[--enable-poll[=ARG]]], [enable poll support (yes, no, auto) [auto]])],
  621. [enable_poll=${enableval}],
  622. [enable_poll='auto']
  623. )
  624. if test "$enable_poll" != "no"; then
  625. if test "$os_is_native_w32" != "yes"; then
  626. AC_CHECK_HEADERS([poll.h],
  627. [
  628. AC_CHECK_FUNCS([poll], [have_poll='yes'], [have_poll='no'])
  629. ], [], [AC_INCLUDES_DEFAULT])
  630. else
  631. AC_MSG_CHECKING([for WSAPoll()])
  632. AC_LINK_IFELSE([
  633. AC_LANG_PROGRAM([[#include <winsock2.h>]], [[
  634. WSAPOLLFD fda[2];
  635. WSAPoll(fda, 2, 0);]])],
  636. [
  637. have_poll='yes'
  638. AC_DEFINE([HAVE_POLL],[1])
  639. ], [have_poll='no'])
  640. AC_MSG_RESULT([$have_poll])
  641. fi
  642. if test "$enable_poll" = "yes" && test "$have_poll" != "yes"; then
  643. AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]])
  644. fi
  645. enable_poll="$have_poll"
  646. fi
  647. AC_ARG_ENABLE([[epoll]],
  648. [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])],
  649. [enable_epoll=${enableval}],
  650. [enable_epoll='auto']
  651. )
  652. if test "$enable_epoll" != "no"; then
  653. AX_HAVE_EPOLL
  654. if test "${ax_cv_have_epoll}" = "yes"; then
  655. AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll support])
  656. enable_epoll='yes'
  657. else
  658. if test "$enable_epoll" = "yes"; then
  659. AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]])
  660. fi
  661. enable_epoll='no'
  662. fi
  663. fi
  664. if test "x$enable_epoll" = "xyes"; then
  665. AC_CACHE_CHECK([for epoll_create1()], [mhd_cv_have_epoll_create1], [
  666. AC_LINK_IFELSE([
  667. AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[
  668. int fd;
  669. fd = epoll_create1(EPOLL_CLOEXEC);]])],
  670. [mhd_cv_have_epoll_create1=yes],
  671. [mhd_cv_have_epoll_create1=no])])
  672. AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[
  673. AC_DEFINE([[HAVE_EPOLL_CREATE1]], [[1]], [Define if you have epoll_create1 function.])])
  674. fi
  675. # Check for headers that are ALWAYS required
  676. 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])
  677. # Check for optional headers
  678. AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h time.h sys/mman.h sys/ioctl.h \
  679. sys/socket.h sys/select.h netdb.h netinet/in.h netinet/ip.h netinet/tcp.h arpa/inet.h \
  680. endian.h machine/endian.h sys/endian.h sys/param.h sys/machine.h sys/byteorder.h machine/param.h sys/isa_defs.h \
  681. inttypes.h stddef.h unistd.h \
  682. sockLib.h inetLib.h net/if.h], [], [], [AC_INCLUDES_DEFAULT])
  683. AC_CHECK_HEADER([[search.h]],
  684. [
  685. gl_FUNC_TSEARCH
  686. AS_IF([[test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]],
  687. [AC_DEFINE([[HAVE_SEARCH_H]], [[1]],
  688. [Define to 1 if you have the <search.h> header file and your system have properly functioning tsearch(), tfind() and tdelete() functions])])
  689. ],
  690. [], [AC_INCLUDES_DEFAULT])
  691. AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]])
  692. # Check for generic functions
  693. AC_CHECK_FUNCS([rand random])
  694. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  695. [ AC_DEFINE(HAVE_SOCKADDR_IN_SIN_LEN, 1, [Do we have sockaddr_in.sin_len?])
  696. ],
  697. [],
  698. [
  699. #ifdef HAVE_SYS_TYPES_H
  700. #include <sys/types.h>
  701. #endif
  702. #ifdef HAVE_SYS_SOCKET_H
  703. #include <sys/socket.h>
  704. #endif
  705. #ifdef HAVE_NETINET_IN_H
  706. #include <netinet/in.h>
  707. #endif
  708. ])
  709. # Check for inter-thread signaling type
  710. AC_ARG_ENABLE([[itc]],
  711. [AS_HELP_STRING([[--enable-itc=TYPE]], [use TYPE of inter-thread communication (pipe, socketpair, eventfd) [auto]])], [],
  712. [[enable_itc='auto']]
  713. )
  714. AS_CASE([[$enable_itc]],
  715. [[pipe]], [[:]],
  716. [[socketpair]], [[:]],
  717. [[eventfd]], [[:]],
  718. [[auto]], [AS_VAR_IF([[os_is_windows]], [["yes"]], [[enable_itc='socketpair']])],
  719. [[eventFD]], [[enable_itc='eventfd']],
  720. [[socket]], [[enable_itc='socketpair']],
  721. [[no]], [AC_MSG_ERROR([[inter-thread communication cannot be disabled]])],
  722. [AC_MSG_ERROR([[unrecognized type "$enable_itc" of inter-thread communication specified by "--enable-itc=$enable_itc"]])]
  723. )
  724. # AS_UNSET([[use_itc]])
  725. AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]], [
  726. AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
  727. AC_CHECK_HEADERS([[sys/eventfd.h]], [], [], [AC_INCLUDES_DEFAULT])
  728. AS_VAR_IF([[ac_cv_header_sys_eventfd_h]], [["yes"]], [
  729. AC_CACHE_CHECK([whether eventfd(2) is usable], [[mhd_cv_eventfd_usable]], [
  730. AC_LINK_IFELSE([
  731. AC_LANG_PROGRAM([[
  732. #include <sys/eventfd.h>
  733. ]], [[int ef = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK)
  734. ]])
  735. ], [[mhd_cv_eventfd_usable='yes']], [[mhd_cv_eventfd_usable='no']])
  736. ])
  737. ])
  738. ])
  739. AS_VAR_IF([[mhd_cv_eventfd_usable]], [["yes"]], [
  740. use_itc='eventfd'
  741. enable_itc="$use_itc"
  742. AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for inter-thread communication])
  743. ], [
  744. AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not usable, consider using other type of inter-thread communication]])])
  745. ])
  746. ])
  747. AS_IF([[test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto"]], [
  748. AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
  749. AC_CACHE_CHECK([[whether pipe(3) is usable]], [[mhd_cv_pipe_usable]], [
  750. AC_LINK_IFELSE([
  751. AC_LANG_PROGRAM([
  752. AC_INCLUDES_DEFAULT
  753. #ifdef HAVE_UNISTD_H
  754. #include <unistd.h>
  755. #endif
  756. ], [[
  757. int arr[2];
  758. int res;
  759. res = pipe(arr)
  760. ]])
  761. ], [[mhd_cv_pipe_usable='yes']], [[mhd_cv_pipe_usable='no']])
  762. ])
  763. ])
  764. AS_VAR_IF([[mhd_cv_pipe_usable]], [["yes"]], [
  765. use_itc='pipe'
  766. enable_itc="$use_itc"
  767. AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread communication])
  768. AC_CACHE_CHECK([[whether pipe2(2) is usable]], [[mhd_cv_pipe2_usable]], [
  769. AC_LINK_IFELSE([
  770. AC_LANG_PROGRAM([
  771. AC_INCLUDES_DEFAULT
  772. #ifdef HAVE_FCNTL_H
  773. #include <fcntl.h>
  774. #endif
  775. #ifdef HAVE_UNISTD_H
  776. #include <unistd.h>
  777. #endif
  778. ], [[
  779. int arr[2];
  780. int res;
  781. res = pipe2(arr, O_CLOEXEC | O_NONBLOCK)
  782. ]])
  783. ], [[mhd_cv_pipe2_usable='yes']], [[mhd_cv_pipe2_usable='no']])
  784. ])
  785. AS_VAR_IF([[mhd_cv_pipe2_usable]], [["yes"]],
  786. [AC_DEFINE([[HAVE_PIPE2_FUNC]], [[1]], [Define if you have usable pipe2(2) function])])
  787. ], [
  788. AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not usable, consider using other type of inter-thread communication]])])
  789. ])
  790. ])
  791. AS_IF([[test "x$enable_itc" = "xsocketpair" || test "x$enable_itc" = "xauto"]], [
  792. AS_VAR_IF([[os_is_native_w32]], [["yes"]], [[mhd_cv_socketpair_usable='yes']], [
  793. AC_CACHE_CHECK([[whether socketpair(3) is usable]], [[mhd_cv_socketpair_usable]], [
  794. AC_LINK_IFELSE([
  795. AC_LANG_PROGRAM([
  796. AC_INCLUDES_DEFAULT
  797. #ifdef HAVE_SYS_TYPES_H
  798. #include <sys/types.h>
  799. #endif
  800. #ifdef HAVE_SYS_SOCKET_H
  801. #include <sys/socket.h>
  802. #endif
  803. ], [[
  804. int arr[2];
  805. int res;
  806. #if defined(AF_LOCAL)
  807. res = socketpair(AF_LOCAL, SOCK_STREAM, 0, arr);
  808. #elif defined(AF_UNIX)
  809. res = socketpair(AF_UNIX, SOCK_STREAM, 0, arr);
  810. #else
  811. #error AF_LOCAL and AF_UNIX are both undefined
  812. choke me now;
  813. #endif
  814. if (res != 0) return 1
  815. ]])
  816. ], [[mhd_cv_socketpair_usable='yes']], [[mhd_cv_socketpair_usable='no']])
  817. ])
  818. ])
  819. AS_VAR_IF([[mhd_cv_socketpair_usable]], [["yes"]], [
  820. use_itc='socketpair'
  821. enable_itc="$use_itc"
  822. AC_DEFINE([[_MHD_ITC_SOCKETPAIR]], [[1]], [Define to use socketpair for inter-thread communication])
  823. ], [
  824. AS_VAR_IF([[enable_itc]], [["socketpair"]], [AC_MSG_ERROR([[socketpair(3) is not usable, consider using other type of inter-thread communication]])])
  825. ])
  826. ])
  827. AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find useable type of inter-thread communication]])])
  828. AC_CHECK_FUNCS_ONCE([accept4 gmtime_r memmem snprintf])
  829. AC_CHECK_DECL([gmtime_s],
  830. [
  831. AC_MSG_CHECKING([[whether gmtime_s is in C11 form]])
  832. AC_LINK_IFELSE(
  833. [ AC_LANG_PROGRAM(
  834. [[
  835. #define __STDC_WANT_LIB_EXT1__ 1
  836. #include <time.h>
  837. #ifdef __cplusplus
  838. extern "C"
  839. #endif
  840. struct tm* gmtime_s(const time_t* time, struct tm* result);
  841. ]], [[
  842. struct tm res;
  843. time_t t;
  844. gmtime_s (&t, &res);
  845. ]])
  846. ],
  847. [
  848. AC_DEFINE([HAVE_C11_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in C11 form.])
  849. AC_MSG_RESULT([[yes]])
  850. ],
  851. [
  852. AC_MSG_RESULT([[no]])
  853. AC_MSG_CHECKING([[whether gmtime_s is in W32 form]])
  854. AC_LINK_IFELSE(
  855. [ AC_LANG_PROGRAM(
  856. [[
  857. #include <time.h>
  858. #ifdef __cplusplus
  859. extern "C"
  860. #endif
  861. errno_t gmtime_s(struct tm* _tm, const time_t* time);
  862. ]], [[
  863. struct tm res;
  864. time_t t;
  865. gmtime_s (&res, &t);
  866. ]])
  867. ],
  868. [
  869. AC_DEFINE([HAVE_W32_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in W32 form.])
  870. AC_MSG_RESULT([[yes]])
  871. ],
  872. [AC_MSG_RESULT([[no]])
  873. ])
  874. ])
  875. ], [],
  876. [[#define __STDC_WANT_LIB_EXT1__ 1
  877. #include <time.h>]])
  878. AC_CHECK_DECLS([SOCK_NONBLOCK], [AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBLOCK is defined in a socket header])], [],
  879. [
  880. #if defined(HAVE_SYS_TYPES_H)
  881. # include <sys/types.h>
  882. #endif
  883. #if defined(HAVE_SYS_SOCKET_H)
  884. # include <sys/socket.h>
  885. #elif defined(HAVE_WINSOCK2_H)
  886. # include <winsock2.h>
  887. #endif
  888. ])
  889. AC_CHECK_DECL([[clock_gettime]],
  890. [
  891. SAVE_LIBS="$LIBS"
  892. AC_SEARCH_LIBS([clock_gettime], [rt],
  893. [
  894. AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])
  895. AS_VAR_IF([[ac_cv_search_clock_gettime]],[["none required"]], [],
  896. [
  897. MHD_LIBDEPS="$ac_cv_search_clock_gettime $MHD_LIBDEPS"
  898. MHD_LIBDEPS_PKGCFG="$ac_cv_search_clock_gettime $MHD_LIBDEPS_PKGCFG"
  899. ])
  900. ], [], [$MHD_LIBDEPS])
  901. LIBS="$SAVE_LIBS"
  902. ], [], [[#include <time.h>]])
  903. AC_MSG_CHECKING([[for clock_get_time]])
  904. AC_LINK_IFELSE(
  905. [AC_LANG_PROGRAM(
  906. [[
  907. #include <mach/clock.h>
  908. #include <mach/mach.h>
  909. ]],
  910. [[
  911. clock_serv_t cs;
  912. mach_timespec_t mt;
  913. host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
  914. clock_get_time(cs, &mt);
  915. mach_port_deallocate(mach_task_self(), cs);
  916. ]])
  917. ],
  918. [
  919. 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.])
  920. AC_MSG_RESULT([[yes]])
  921. ],
  922. [AC_MSG_RESULT([[no]])
  923. ])
  924. AC_MSG_CHECKING([[for gethrtime]])
  925. AC_LINK_IFELSE(
  926. [AC_LANG_PROGRAM(
  927. [[
  928. #ifdef HAVE_SYS_TIME_H
  929. /* Solaris define gethrtime() in sys/time.h */
  930. #include <sys/time.h>
  931. #endif /* HAVE_SYS_TIME_H */
  932. #ifdef HAVE_TIME_H
  933. /* HP-UX define gethrtime() in time.h */
  934. #include <time.h>
  935. #endif /* HAVE_TIME_H */
  936. ]], [[hrtime_t hrt = gethrtime(); ]])
  937. ],
  938. [
  939. AC_DEFINE([HAVE_GETHRTIME], [1], [Define to 1 if you have `gethrtime' function.])
  940. AC_MSG_RESULT([[yes]])
  941. ],
  942. [AC_MSG_RESULT([[no]])
  943. ])
  944. # IPv6
  945. AC_MSG_CHECKING(for IPv6)
  946. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  947. #include <stdio.h>
  948. #if HAVE_NETINET_IN_H
  949. #include <netinet/in.h>
  950. #endif
  951. #if HAVE_SYS_SOCKET_H
  952. #include <sys/socket.h>
  953. #endif
  954. #if HAVE_WINSOCK2_H
  955. #include <winsock2.h>
  956. #endif
  957. #if HAVE_WS2TCPIP_H
  958. #include <ws2tcpip.h>
  959. #endif
  960. ]], [[
  961. int af=AF_INET6;
  962. int pf=PF_INET6;
  963. struct sockaddr_in6 sa;
  964. printf("%d %d %p\n", af, pf, &sa);
  965. ]])],[
  966. have_inet6=yes;
  967. AC_DEFINE([HAVE_INET6], [1], [Provides IPv6 headers])
  968. ],[
  969. have_inet6=no
  970. ])
  971. AC_MSG_RESULT($have_inet6)
  972. HIDDEN_VISIBILITY_CFLAGS=""
  973. case "$host" in
  974. *-*-mingw*)
  975. dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
  976. AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
  977. [defines how to decorate public symbols while building])
  978. HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
  979. ;;
  980. *)
  981. dnl on other compilers, check if we can do -fvisibility=hidden
  982. AX_CHECK_LINK_FLAG([-fvisibility=hidden],
  983. [AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],
  984. [AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) extern],
  985. [defines how to decorate public symbols while building])
  986. HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"])])
  987. ;;
  988. esac
  989. AC_SUBST(HIDDEN_VISIBILITY_CFLAGS)
  990. # libcurl (required for testing)
  991. AC_ARG_ENABLE([curl],
  992. [AS_HELP_STRING([--disable-curl],[disable cURL based testcases])],
  993. [enable_curl=${enableval}])
  994. curl=0
  995. if test "$enable_curl" != "no"
  996. then
  997. LIBCURL_CHECK_CONFIG([yes],[7.16.4],[enable_curl=yes],
  998. [
  999. if test "x$enable_curl" = "xyes"; then
  1000. AC_MSG_WARN([[cURL-based tests cannot be enabled because libcurl is missing]])
  1001. fi
  1002. enable_curl=no
  1003. ])
  1004. fi
  1005. if test "$enable_curl" != "no"
  1006. then
  1007. # Lib cURL & cURL - OpenSSL versions
  1008. AC_DEFINE([MHD_REQ_CURL_VERSION], ["7.16.4"], [required cURL version to run tests])
  1009. AC_DEFINE([MHD_REQ_CURL_OPENSSL_VERSION], ["0.9.8"], [required cURL SSL version to run tests])
  1010. AC_DEFINE([MHD_REQ_CURL_GNUTLS_VERSION], ["2.8.6"], [gnuTLS lib version - used in conjunction with cURL])
  1011. AC_DEFINE([MHD_REQ_CURL_NSS_VERSION], ["3.12.0"], [NSS lib version - used in conjunction with cURL])
  1012. fi
  1013. AM_CONDITIONAL([HAVE_CURL], [test "x$enable_curl" = "xyes"])
  1014. mhd_have_magic_open='no'
  1015. AC_CHECK_HEADERS([[magic.h]],
  1016. [ AC_CHECK_LIB([[magic]], [[magic_open]], [[mhd_have_magic_open='yes']]) ],[],
  1017. [AC_INCLUDES_DEFAULT])
  1018. AM_CONDITIONAL([HAVE_MAGIC], [[test "x$mhd_have_magic_open" = "xyes"]])
  1019. # large file support (> 4 GB)
  1020. AC_SYS_LARGEFILE
  1021. AC_FUNC_FSEEKO
  1022. AC_CHECK_FUNCS([lseek64 sendfile64 pread64 pread])
  1023. # optional: have error messages ?
  1024. AC_MSG_CHECKING([[whether to generate error messages]])
  1025. AC_ARG_ENABLE([messages],
  1026. [AS_HELP_STRING([--disable-messages],
  1027. [disable MHD error messages])],
  1028. [enable_messages=${enableval}],
  1029. [enable_messages=yes])
  1030. AS_IF([[test "x$enable_messages" = "xyes"]],
  1031. [ AC_DEFINE([HAVE_MESSAGES],[1],[Define to 1 to enable support for error messages.]) ],
  1032. [[ enable_messages=no ]])
  1033. AC_MSG_RESULT([[$enable_messages]])
  1034. # optional: have postprocessor?
  1035. AC_MSG_CHECKING([[whether to enable postprocessor]])
  1036. AC_ARG_ENABLE([postprocessor],
  1037. [AS_HELP_STRING([--disable-postprocessor],
  1038. [disable MHD PostProcessor functionality])],
  1039. [enable_postprocessor=${enableval}],
  1040. [enable_postprocessor=yes])
  1041. AS_IF([[test "x$enable_postprocessor" != "xno"]],
  1042. [ enable_postprocessor=yes
  1043. AC_DEFINE([HAVE_POSTPROCESSOR],[1],[Define to 1 if libmicrohttpd is compiled with postprocessor support.]) ])
  1044. AM_CONDITIONAL([HAVE_POSTPROCESSOR], [test "x$enable_postprocessor" != "xno"])
  1045. AC_MSG_RESULT([[$enable_postprocessor]])
  1046. # optional: have zzuf, socat?
  1047. AC_CHECK_PROG([have_zzuf],[zzuf], [yes], [no])
  1048. AC_CHECK_PROG([have_socat],[socat], [yes], [no])
  1049. AM_CONDITIONAL([HAVE_ZZUF], [test "x$have_zzuf" = "xyes"])
  1050. AM_CONDITIONAL([HAVE_SOCAT], [test "x$have_socat" = "xyes"])
  1051. GNUTLS_CPPFLAGS=""
  1052. GNUTLS_LDFLAGS=""
  1053. have_gnutls=no
  1054. have_gnutls_sni=no
  1055. have_gcrypt=no
  1056. # optional: HTTPS support. Enabled by default
  1057. AC_ARG_ENABLE([https],
  1058. [AS_HELP_STRING([--enable-https],
  1059. [enable HTTPS support (yes, no, auto)[auto]])],
  1060. [enable_https=${enableval}])
  1061. if test "x$enable_https" != "xno"
  1062. then
  1063. #
  1064. # Next block is large unindented block
  1065. #
  1066. # libgcrypt linkage: required for HTTPS support
  1067. AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no])
  1068. if test "x$have_gcrypt" = "xyes"
  1069. then
  1070. SAVE_CFLAGS="$CFLAGS"
  1071. CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
  1072. # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both
  1073. SAVE_CPPFLAGS="$CPPFLAGS"
  1074. CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS"
  1075. AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT])
  1076. CFLAGS="$SAVE_CFLAGS"
  1077. CPPFLAGS="$SAVE_CPPFLAGS"
  1078. fi
  1079. # gnutls
  1080. have_gnutls_pkgcfg=no
  1081. AC_MSG_CHECKING([[how to find GnuTLS library]])
  1082. AC_ARG_WITH([[gnutls]],
  1083. [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)])],
  1084. [
  1085. case $with_gnutls in
  1086. no)
  1087. AC_MSG_RESULT([[GnuTLS disabled]])
  1088. ;;
  1089. yes)
  1090. AC_MSG_RESULT([[automatically, forced]])
  1091. ;;
  1092. *)
  1093. AC_MSG_RESULT([[-I$with_gnutls/include -L$with_gnutls/lib -lgnutls]])
  1094. SAVE_LDFLAGS="$LDFLAGS"
  1095. SAVE_CPPFLAGS="$CPPFLAGS"
  1096. LDFLAGS="-L$with_gnutls/lib $LDFLAGS"
  1097. CPPFLAGS="-I$with_gnutls/include $CPPFLAGS"
  1098. have_gnutls_pkgcfg=no
  1099. AC_CHECK_HEADERS([gnutls/gnutls.h],
  1100. [AC_CHECK_LIB([gnutls], [gnutls_priority_set],
  1101. [
  1102. GNUTLS_CPPFLAGS="-I$with_gnutls/include"
  1103. GNUTLS_LDFLAGS="-L$with_gnutls/lib"
  1104. GNUTLS_LIBS="-lgnutls"
  1105. AC_CHECK_LIB([gnutls], [gnutls_load_file], [AC_CHECK_LIB([gnutls], [gnutls_privkey_import_x509_raw], [have_gnutls_sni=yes])])
  1106. have_gnutls=yes
  1107. ])], [], [AC_INCLUDES_DEFAULT])
  1108. AS_IF([test "x$have_gnutls" != "xyes"], [AC_MSG_ERROR([can't find usable libgnutls at specified prefix $with_gnutls])])
  1109. LDFLAGS="$SAVE_LDFLAGS"
  1110. CPPFLAGS="$SAVE_CPPFLAGS"
  1111. ;;
  1112. esac
  1113. ],
  1114. [AC_MSG_RESULT([[automatically]])
  1115. ])
  1116. AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"],
  1117. [
  1118. PKG_CHECK_MODULES(GNUTLS, [[gnutls]],
  1119. [
  1120. have_gnutls_pkgcfg='yes'
  1121. SAVE_CPPFLAGS="$CPPFLAGS"
  1122. SAVE_CFLAGS="$CFLAGS"
  1123. SAVE_LDFLAGS="$LDFLAGS"
  1124. SAVE_LIBS="$LIBS"
  1125. CPPFLAGS="$GNUTLS_CFLAGS $CPPFLAGS"
  1126. CFLAGS="$GNUTLS_CFLAGS $CFLAGS"
  1127. LDFLAGS="$GNUTLS_LIBS $LDFLAGS"
  1128. LIBS="$LIBS $GNUTLS_LIBS"
  1129. AC_MSG_CHECKING([[whether GnuTLS is usable]])
  1130. AC_LINK_IFELSE([
  1131. AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], [[
  1132. gnutls_session_t session;
  1133. gnutls_priority_t priorities;
  1134. gnutls_global_init();
  1135. gnutls_priority_init(&priorities, "NORMAL", NULL);
  1136. gnutls_init(&session, GNUTLS_SERVER);
  1137. gnutls_priority_set(session, priorities);
  1138. ]])],
  1139. [
  1140. AC_MSG_RESULT([[yes]])
  1141. have_gnutls=yes
  1142. GNUTLS_CPPFLAGS="$GNUTLS_CFLAGS"
  1143. GNUTLS_LDFLAGS="$GNUTLS_LIBS"
  1144. AC_MSG_CHECKING([[for gnutls_privkey_import_x509_raw()]])
  1145. AC_LINK_IFELSE([
  1146. AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], [[
  1147. gnutls_datum_t data;
  1148. gnutls_privkey_t key;
  1149. gnutls_load_file("key.pem", &data);
  1150. gnutls_privkey_import_x509_raw(key, &data, GNUTLS_X509_FMT_PEM, NULL, 0);
  1151. gnutls_free(data.data);
  1152. ]])], [[have_gnutls_sni=yes]], [[have_gnutls_sni=no]])
  1153. AC_MSG_RESULT([[$have_gnutls_sni]])
  1154. ],
  1155. [
  1156. AC_MSG_RESULT([[no]])
  1157. have_gnutls=no
  1158. ])
  1159. AS_IF([test "x$have_gnutls" != "xyes"], [AC_MSG_WARN([pkg-config reports that GnuTLS is present, but GnuTLS can't be used])])
  1160. CPPFLAGS="$SAVE_CPPFLAGS"
  1161. CFLAGS="$SAVE_CFLAGS"
  1162. LDFLAGS="$SAVE_LDFLAGS"
  1163. LIBS="$SAVE_LIBS"
  1164. ],
  1165. [
  1166. have_gnutls_pkgcfg='no'
  1167. SAVE_CPPFLAGS="$CPPFLAGS"
  1168. SAVE_CFLAGS="$CFLAGS"
  1169. SAVE_LDFLAGS="$LDFLAGS"
  1170. SAVE_LIBS="$LIBS"
  1171. # Try to use libgcrypt search path
  1172. # as libgcrypt flags will be used
  1173. # anyway for HTTPs builds
  1174. CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
  1175. CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS"
  1176. LDFLAGS="$LDFLAGS $LIBGCRYPT_LIBS"
  1177. AC_CHECK_HEADERS([gnutls/gnutls.h],
  1178. [AC_CHECK_LIB([gnutls], [gnutls_priority_set],
  1179. [
  1180. GNUTLS_CPPFLAGS="$LIBGCRYPT_CFLAGS"
  1181. GNUTLS_CFLAGS="$LIBGCRYPT_CFLAGS"
  1182. GNUTLS_LDFLAGS="$LIBGCRYPT_LIBS"
  1183. GNUTLS_LIBS="-lgnutls"
  1184. AC_CHECK_LIB([gnutls], [gnutls_load_file], [AC_CHECK_LIB([gnutls], [gnutls_privkey_import_x509_raw], [have_gnutls_sni=yes])])
  1185. have_gnutls=yes
  1186. ])], [], [AC_INCLUDES_DEFAULT])
  1187. CPPFLAGS="$SAVE_CPPFLAGS"
  1188. CFLAGS="$SAVE_CFLAGS"
  1189. LDFLAGS="$SAVE_LDFLAGS"
  1190. LIBS="$SAVE_LIBS"
  1191. ])
  1192. ])
  1193. AS_IF([test "x$have_gnutls" != "xyes" && test "x$with_gnutls" = "xyes"], [AC_MSG_ERROR([[can't find usable libgnutls]])])
  1194. AC_SUBST([GNUTLS_CPPFLAGS])
  1195. AC_SUBST([GNUTLS_CFLAGS])
  1196. AC_SUBST([GNUTLS_LDFLAGS])
  1197. AC_SUBST([GNUTLS_LIBS])
  1198. #
  1199. # End of large unindented block
  1200. #
  1201. AS_IF([test "x$have_gnutls" = "xyes" && test "x$have_gcrypt" = "xyes"], [
  1202. AC_DEFINE([[HTTPS_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTPS support.])
  1203. enable_https=yes
  1204. MSG_HTTPS="yes (using libgnutls and libgcrypt)"
  1205. MHD_LIB_CPPFLAGS="$MHD_LIB_CPPFLAGS $LIBGCRYPT_CFLAGS $GNUTLS_CPPFLAGS"
  1206. MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $LIBGCRYPT_CFLAGS $GNUTLS_CFLAGS"
  1207. MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS $GNUTLS_LDFLAGS"
  1208. MHD_LIBDEPS="$GNUTLS_LIBS $LIBGCRYPT_LIBS $MHD_LIBDEPS"
  1209. AS_IF([[ test "x$have_gnutls_pkgcfg" = "xyes" ]],
  1210. [ # remove GnuTLS from private libs in .pc file as it defined in Requires.private
  1211. MHD_REQ_PRIVATE='gnutls'
  1212. MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"
  1213. ],
  1214. [
  1215. MHD_REQ_PRIVATE=''
  1216. MHD_LIBDEPS_PKGCFG="$GNUTLS_LIBS $LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"
  1217. ])
  1218. ], [
  1219. AS_IF([test "x$have_gnutls" = "xyes"], [crypt_missing="libgcrypt"],
  1220. [test "x$have_gcrypt" = "xyes"], [crypt_missing="libgnutls"],
  1221. [crypt_missing="libgcrypt and libgnutls"])
  1222. AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])])
  1223. enable_https=no
  1224. MSG_HTTPS="no (lacking $crypt_missing)"
  1225. ])
  1226. else
  1227. MSG_HTTPS="no (disabled)"
  1228. fi
  1229. AC_MSG_CHECKING(whether to support HTTPS)
  1230. AC_MSG_RESULT([$MSG_HTTPS])
  1231. AM_CONDITIONAL([HAVE_GNUTLS], [[test "x$have_gnutls" = "xyes"]])
  1232. AM_CONDITIONAL([HAVE_GNUTLS_SNI], [[test "x$have_gnutls_sni" = "xyes"]])
  1233. AM_CONDITIONAL([ENABLE_HTTPS], [test "x$enable_https" = "xyes"])
  1234. # optional: HTTP Basic Auth support. Enabled by default
  1235. AC_MSG_CHECKING([[whether to support HTTP basic authentication]])
  1236. AC_ARG_ENABLE([bauth],
  1237. AS_HELP_STRING([--disable-bauth],
  1238. [disable HTTP basic Auth support]),
  1239. [enable_bauth=${enableval}],
  1240. [enable_bauth=yes])
  1241. AS_IF([[test "x$enable_bauth" != "xno"]],
  1242. [ enable_bauth=yes
  1243. AC_DEFINE([BAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with basic Auth support.]) ])
  1244. AM_CONDITIONAL([ENABLE_BAUTH], [test "x$enable_bauth" != "xno"])
  1245. AC_MSG_RESULT([[$enable_bauth]])
  1246. # optional: HTTP Digest Auth support. Enabled by default
  1247. AC_MSG_CHECKING([[whether to support HTTP digest authentication]])
  1248. AC_ARG_ENABLE([dauth],
  1249. AS_HELP_STRING([--disable-dauth],
  1250. [disable HTTP basic and digest Auth support]),
  1251. [enable_dauth=${enableval}],
  1252. [enable_dauth=yes])
  1253. AS_IF([[test "x$enable_dauth" != "xno"]],
  1254. [ enable_dauth=yes
  1255. AC_DEFINE([DAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with digest Auth support.]) ])
  1256. AM_CONDITIONAL([ENABLE_DAUTH], [test "x$enable_dauth" != "xno"])
  1257. AC_MSG_RESULT([[$enable_dauth]])
  1258. # optional: HTTP "Upgrade" support. Enabled by default
  1259. AC_MSG_CHECKING([[whether to support HTTP "Upgrade"]])
  1260. AC_ARG_ENABLE([[httpupgrade]],
  1261. AS_HELP_STRING([[--disable-httpupgrade]],
  1262. [disable HTTP "Upgrade" support]),
  1263. [AS_VAR_IF([[enable_httpupgrade]],[["no"]],[],[[enable_httpupgrade='yes']])],
  1264. [[enable_httpupgrade='yes']])
  1265. AS_VAR_IF([[enable_httpupgrade]],[["yes"]],
  1266. [
  1267. AC_DEFINE([[UPGRADE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTP Upgrade support.]) ])
  1268. AM_CONDITIONAL([ENABLE_UPGRADE], [[test "x$enable_httpupgrade" = "xyes"]])
  1269. AC_MSG_RESULT([[$enable_httpupgrade]])
  1270. AC_CACHE_CHECK([[for calloc()]], [[mhd_cv_have_func_calloc]],
  1271. [
  1272. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1273. #include <stdlib.h>
  1274. ]],[[void * ptr = calloc(1, 2)]])
  1275. ],
  1276. [[mhd_cv_have_func_calloc='yes']],
  1277. [[mhd_cv_have_func_calloc='no']]
  1278. )
  1279. ]
  1280. )
  1281. AS_VAR_IF([[mhd_cv_have_func_calloc]], [["yes"]],
  1282. [AC_DEFINE([[HAVE_CALLOC]], [[1]], [Define to 1 if you have the usable `calloc' function.])])
  1283. # Check for fork() and waitpid(). They are used for tests.
  1284. AC_MSG_CHECKING([[for fork()]])
  1285. mhd_have_fork_waitpid='no'
  1286. AC_LINK_IFELSE(
  1287. [
  1288. AC_LANG_PROGRAM(
  1289. [[
  1290. #ifdef HAVE_SYS_TYPES_H
  1291. #include <sys/types.h>
  1292. #endif
  1293. #ifdef HAVE_UNISTD_H
  1294. #include <unistd.h>
  1295. #endif
  1296. ]], [[
  1297. pid_t p = fork ();
  1298. if (0 == p)
  1299. return 1;
  1300. ]])
  1301. ], [
  1302. AC_DEFINE([[HAVE_FORK]], [[1]], [Define to 1 if you have the usable `fork' function.])
  1303. AC_MSG_RESULT([[yes]])
  1304. AC_MSG_CHECKING([[for waitpid()]])
  1305. AC_LINK_IFELSE(
  1306. [
  1307. AC_LANG_PROGRAM(
  1308. [[
  1309. #include <sys/wait.h>
  1310. ]], [[
  1311. pid_t p = fork ();
  1312. if (0 == p)
  1313. return 1;
  1314. waitpid (p, (void*)0, 0)
  1315. ]])
  1316. ], [
  1317. AC_DEFINE([[HAVE_WAITPID]], [[1]], [Define to 1 if you have the usable `waitpid' function.])
  1318. AC_MSG_RESULT([[yes]])
  1319. mhd_have_fork_waitpid='yes'
  1320. ],[
  1321. AC_MSG_RESULT([[no]])
  1322. ])
  1323. ],[
  1324. AC_MSG_RESULT([[no]])
  1325. ])
  1326. AM_CONDITIONAL([HAVE_FORK_WAITPID], [test "x$mhd_have_fork_waitpid" = "xyes"])
  1327. MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS -export-dynamic -no-undefined"
  1328. # gcov compilation
  1329. AC_MSG_CHECKING(whether to compile with support for code coverage analysis)
  1330. AC_ARG_ENABLE([coverage],
  1331. AS_HELP_STRING([--enable-coverage],
  1332. [compile the library with code coverage support]),
  1333. [use_gcov=${enableval}],
  1334. [use_gcov=no])
  1335. AC_MSG_RESULT($use_gcov)
  1336. AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
  1337. AX_COUNT_CPUS
  1338. AC_SUBST([CPU_COUNT])
  1339. AC_SUBST(MHD_LIB_CPPFLAGS)
  1340. AC_SUBST(MHD_LIB_CFLAGS)
  1341. AC_SUBST(MHD_LIB_LDFLAGS)
  1342. AC_SUBST(MHD_LIBDEPS)
  1343. # for pkg-config
  1344. AC_SUBST([MHD_REQ_PRIVATE])
  1345. AC_SUBST([MHD_LIBDEPS_PKGCFG])
  1346. AC_SUBST(CPPFLAGS)
  1347. AC_SUBST(LIBS)
  1348. AC_SUBST(LDFLAGS)
  1349. # Used for 'po' directory staff
  1350. AC_SUBST([ac_configure_args])
  1351. AC_SUBST([EMPTY_VAR], [[]])
  1352. AC_CONFIG_FILES([
  1353. libmicrohttpd.pc
  1354. w32/common/microhttpd_dll_res_vc.rc
  1355. po/configure.acT:po/configure.ac.in
  1356. Makefile
  1357. contrib/Makefile
  1358. doc/Makefile
  1359. doc/doxygen/Makefile
  1360. doc/examples/Makefile
  1361. m4/Makefile
  1362. src/Makefile
  1363. src/include/Makefile
  1364. src/microhttpd/Makefile
  1365. src/examples/Makefile
  1366. src/testcurl/Makefile
  1367. src/testcurl/https/Makefile
  1368. src/testzzuf/Makefile])
  1369. AC_OUTPUT
  1370. # Finally: summary
  1371. if test "x$enable_curl" != "xyes"; then
  1372. MSG_CURL="no, many unit tests will not run"
  1373. else
  1374. MSG_CURL="yes"
  1375. fi
  1376. AC_MSG_NOTICE([libmicrohttpd ${PACKAGE_VERSION} Configuration Summary:
  1377. Cross-compiling: ${cross_compiling}
  1378. Operating System: ${host_os}
  1379. Threading lib: ${USE_THREADS}
  1380. Use thread names: ${enable_thread_names}
  1381. Inter-thread comm: ${use_itc}
  1382. libcurl (testing): ${MSG_CURL}
  1383. Target directory: ${prefix}
  1384. Shutdown of listening socket
  1385. trigger select: ${mhd_cv_host_shtdwn_trgr_select}
  1386. Messages: ${enable_messages}
  1387. Basic auth.: ${enable_bauth}
  1388. Digest auth.: ${enable_dauth}
  1389. HTTP "Upgrade": ${enable_httpupgrade}
  1390. Postproc: ${enable_postprocessor}
  1391. HTTPS support: ${MSG_HTTPS}
  1392. poll support: ${enable_poll=no}
  1393. epoll support: ${enable_epoll=no}
  1394. build docs: ${enable_doc}
  1395. build examples: ${enable_examples}
  1396. ])
  1397. if test "x$enable_https" = "xyes"
  1398. then
  1399. AC_MSG_NOTICE([HTTPS subsystem configuration:
  1400. License : LGPL only
  1401. ])
  1402. else
  1403. AC_MSG_NOTICE([
  1404. License : LGPL or eCos
  1405. ])
  1406. fi
  1407. if test "x$enable_bauth" != "xyes" || \
  1408. test "x$enable_dauth" != "xyes" || \
  1409. test "x$enable_httpupgrade" != "xyes" || \
  1410. test "x$enable_postprocessor" != "xyes"
  1411. then
  1412. 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.])
  1413. fi