configure.ac 67 KB

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