configure.ac 64 KB

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