configure.ac 68 KB

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