configure.ac 77 KB

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