configure.ac 66 KB

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