configure.ac 37 KB

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