configure.ac 41 KB

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