configure.ac 66 KB

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