configure.ac 49 KB

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