1# This file is part of libmicrohttpd. 2# (C) 2006-2021 Christian Grothoff (and other contributing authors) 3# (C) 2014-2021 Evgeny Grin (Karlson2k) 4# 5# libmicrohttpd is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published 7# by the Free Software Foundation; either version 3, or (at your 8# option) any later version. 9# 10# libmicrohttpd is distributed in the hope that it will be useful, but 11# WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13# General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with libmicrohttpd; see the file COPYING. If not, write to the 17# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18# Boston, MA 02110-1301, USA. 19# 20# 21# Process this file with autoconf to produce a configure script. 22# 23# 24AC_PREREQ([2.64]) 25LT_PREREQ([2.4.0]) 26AC_INIT([GNU Libmicrohttpd],[0.9.74],[libmicrohttpd@gnu.org]) 27AC_CONFIG_AUX_DIR([build-aux]) 28AM_INIT_AUTOMAKE([silent-rules] [subdir-objects]) 29AC_CONFIG_HEADERS([MHD_config.h]) 30AC_CONFIG_MACRO_DIR([m4]) 31 32LIB_VERSION_CURRENT=71 33LIB_VERSION_REVISION=0 34LIB_VERSION_AGE=59 35AC_SUBST(LIB_VERSION_CURRENT) 36AC_SUBST(LIB_VERSION_REVISION) 37AC_SUBST(LIB_VERSION_AGE) 38 39AC_MSG_CHECKING([[whether z/OS special settings are required]]) 40AS_IF([test `uname -s` = "OS/390"], 41[ 42# configure binaries for z/OS 43 AS_IF([test -z "$CC"], 44 [CC=`pwd`"/contrib/xcc" 45 chmod +x $CC || true]) 46 AS_IF([test -z "$CPP"], 47 CPP="c89 -E") 48 AS_IF([test -z "$CXXCPP"], 49 CXXCPP="c++ -E -+") 50 AC_MSG_RESULT([[yes]]) 51# _CCC_CCMODE=1 52# _C89_CCMODE=1 53], 54 AC_MSG_RESULT([[no]]) 55) 56 57# Checks for programs. 58AC_PROG_AWK 59AC_PROG_GREP 60AC_PROG_FGREP 61AC_PROG_INSTALL 62AC_PROG_LN_S 63AC_PROG_MAKE_SET 64AC_CANONICAL_HOST 65m4_version_prereq([2.70], 66 [ 67# Find C compiler and compiler options to support 68# the latest C standard (C11). Fallback to C99 and C89 69# if later C versions are not supported. 70AC_PROG_CC 71 ], 72 [ 73# Find C compiler and compiler options to support 74# the latest C standard (C99). Fallback to C89 75# if later C versions are not supported. 76AC_PROG_CC_STDC 77 ] 78) 79MHD_SYS_EXT 80LT_INIT([win32-dll]) 81LT_LANG([Windows Resource]) 82 83# Check for headers that are ALWAYS required 84AC_CHECK_HEADERS_ONCE([stdio.h string.h stdint.h errno.h limits.h fcntl.h], [], 85 [AC_MSG_ERROR([Compiling libmicrohttpd requires standard POSIX headers files])], [AC_INCLUDES_DEFAULT]) 86 87# Check for basic optional headers 88AC_CHECK_HEADERS([stddef.h stdlib.h inttypes.h sys/types.h sys/stat.h unistd.h], [], [], [AC_INCLUDES_DEFAULT]) 89 90# Check for clock-specific optional headers 91AC_CHECK_HEADERS([sys/time.h time.h], [], [], [AC_INCLUDES_DEFAULT]) 92 93# Check for system information and parameters optional headers 94AC_CHECK_HEADERS([endian.h machine/endian.h sys/endian.h sys/byteorder.h \ 95 sys/machine.h machine/param.h sys/param.h sys/isa_defs.h \ 96 sys/ioctl.h], [], [], [AC_INCLUDES_DEFAULT]) 97 98# Check for network and sockets optional headers 99AC_CHECK_HEADERS([sys/socket.h sys/select.h netinet/in.h arpa/inet.h \ 100 netinet/ip.h netinet/tcp.h net/if.h \ 101 netdb.h sockLib.h inetLib.h], [], [], 102 [AC_INCLUDES_DEFAULT 103 [ 104#ifdef HAVE_SYS_TYPES_H 105#include <sys/types.h> 106#endif /* HAVE_SYS_TYPES_H */ 107#ifdef HAVE_INTTYPES_H 108#include <inttypes.h> 109#endif /* HAVE_INTTYPES_H */ 110#ifdef HAVE_SYS_SOCKET_H 111#include <sys/socket.h> 112#endif /* HAVE_SYS_SOCKET_H */ 113#ifdef HAVE_NETINET_IN_H 114#include <netinet/in.h> 115#endif /* HAVE_NETINET_IN_H */ 116#ifdef HAVE_NETINET_IP_H 117#include <netinet/ip.h> 118#endif /* HAVE_NETINET_IP_H */ 119#ifdef HAVE_NETINET_TCP_H 120#include <netinet/tcp.h> 121#endif /* HAVE_NETINET_TCP_H */ 122 ]] 123) 124 125# Check for other optional headers 126AC_CHECK_HEADERS([sys/msg.h sys/mman.h signal.h], [], [], [AC_INCLUDES_DEFAULT]) 127 128AC_CHECK_HEADER([[search.h]], 129 [ 130 gl_FUNC_TSEARCH 131 AS_IF([[test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]], 132 [AC_DEFINE([[HAVE_SEARCH_H]], [[1]], 133 [Define to 1 if you have the <search.h> header file and your system have properly functioning tsearch(), tfind() and tdelete() functions])]) 134 ], 135 [], [AC_INCLUDES_DEFAULT]) 136 137AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]]) 138 139# Optional headers used for tests 140AC_CHECK_HEADERS([sys/sysctl.h netinet/ip_icmp.h netinet/icmp_var.h], [], [], 141 [[ 142#ifdef HAVE_SYS_TYPES_H 143#include <sys/types.h> 144#endif /* HAVE_SYS_TYPES_H */ 145#ifdef HAVE_SYS_SYSCTL_H 146#include <sys/sysctl.h> 147#endif /* HAVE_SYS_SYSCTL_H */ 148#ifdef HAVE_SYS_SOCKET_H 149#include <sys/socket.h> 150#endif /* HAVE_SYS_SOCKET_H */ 151#ifdef HAVE_NETINET_IN_H 152#include <netinet/in.h> 153#endif /* HAVE_NETINET_IN_H */ 154#ifdef HAVE_NETINET_IP_H 155#include <netinet/ip.h> 156#endif /* HAVE_NETINET_IP_H */ 157#ifdef HAVE_NETINET_IP_ICMP_H 158#include <netinet/ip_icmp.h> 159#endif /* HAVE_NETINET_IP_ICMP_H */ 160 ]] 161) 162 163# Checks for gettext. 164m4_ifdef([AM_GNU_GETTEXT], [ 165 AS_VAR_SET_IF([enable_nls], [], [[enable_nls=no]]) 166 AM_GNU_GETTEXT([external],[need-ngettext]) 167 AC_CONFIG_FILES([po/Makefile.in]) 168 have_po=yes 169], [ 170 have_po=no 171]) 172m4_ifdef([AM_GNU_GETTEXT_VERSION], [ 173#do not indent here 174AM_GNU_GETTEXT_VERSION([0.20.2]) 175]) 176AM_CONDITIONAL([HAVE_PO], [ test "$have_po" = yes ]) 177 178 179 180 181# Adam shostack suggests the following for Windows: 182# -D_FORTIFY_SOURCE=2 -fstack-protector-all 183AC_ARG_ENABLE([gcc-hardening], 184 [AS_HELP_STRING([--enable-gcc-hardening], [enable compiler security checks])], 185[AS_IF([test x$enableval = xyes],[ 186 CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all" 187 CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector" 188 CFLAGS="$CFLAGS --param ssp-buffer-size=1" 189 LDFLAGS="$LDFLAGS -pie" 190 ])]) 191 192# Linker hardening options 193# Currently these options are ELF specific - you can't use this with MacOSX 194AC_ARG_ENABLE([linker-hardening], 195 [AS_HELP_STRING([--enable-linker-hardening], [enable linker security fixups])], 196[AS_IF([test x$enableval = xyes], 197 [LDFLAGS="$LDFLAGS -z relro -z now"])]) 198 199 200# Workaround for libgcrypt 201AS_IF([[test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x"]], [[SYSROOT="$lt_sysroot"]]) 202 203PACKAGE_VERSION_MAJOR='m4_car(m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))' 204PACKAGE_VERSION_MINOR='m4_argn(2, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))' 205PACKAGE_VERSION_SUBMINOR='m4_argn(3, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))' 206AS_VAR_ARITH([MHD_W32_DLL_SUFF],[[$LIB_VERSION_CURRENT - $LIB_VERSION_AGE]]) 207AC_SUBST([PACKAGE_VERSION_MAJOR]) 208AC_SUBST([PACKAGE_VERSION_MINOR]) 209AC_SUBST([PACKAGE_VERSION_SUBMINOR]) 210AC_SUBST([MHD_W32_DLL_SUFF]) 211AC_CONFIG_FILES([src/microhttpd/microhttpd_dll_res.rc]) 212 213MHD_LIB_CPPFLAGS="" 214MHD_LIB_CFLAGS="" 215MHD_LIB_LDFLAGS="" 216MHD_LIBDEPS="" 217# for pkg-config 218MHD_REQ_PRIVATE='' 219MHD_LIBDEPS_PKGCFG='' 220 221AH_TEMPLATE([[HAVE_STDBOOL_H]], [Define to 1 if you have the <stdbool.h> header file and <stdbool.h> defines 'bool' type.]) 222AH_TEMPLATE([[HAVE_REAL_BOOL]], [Define to 1 if you have the real boolean type.]) 223AH_TEMPLATE([[bool]], [Define to type name which will be used as boolean type.]) 224AC_CHECK_HEADER([stdbool.h], 225 [ 226 AC_CHECK_TYPE([bool], 227 [ 228 AC_DEFINE([[HAVE_STDBOOL_H]], [[1]]) 229 AC_DEFINE([[HAVE_REAL_BOOL]], [[1]]) 230 ], 231 [ 232 AC_MSG_WARN([[Header <stdbool.h> is present, but "bool" type cannot be detected. Check compiler flags.]]) 233 AC_DEFINE([[bool]], [[int]]) 234 ], [ 235#include <stdbool.h> 236 ] 237 ) 238 ], 239 [ 240 AC_CHECK_TYPE([bool], 241 [AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])], 242 [ 243 AC_CHECK_TYPE([_Bool], 244 [ 245 AC_DEFINE([[HAVE_REAL_BOOL]], [[1]]) 246 AC_DEFINE([[bool]], [[_Bool]]) 247 ], 248 [ 249 AC_DEFINE([[bool]], [[int]]) 250 ], [] 251 ) 252 ], [] 253 ) 254 ], 255 [AC_INCLUDES_DEFAULT] 256) 257 258AC_CACHE_CHECK([[whether "true" is defined or builtin]], [[mhd_cv_macro_true_defined]], 259 [AC_COMPILE_IFELSE( 260 [AC_LANG_PROGRAM( 261 [[ 262#ifdef HAVE_STDBOOL_H 263#include <stdbool.h> 264#endif 265 ]], [[ 266#if defined(true) 267 /* dummy */ 268#else 269 (void)true; 270#endif 271 ]]) 272 ], [[mhd_cv_macro_true_defined='yes']], [[mhd_cv_macro_true_defined='no']]) 273 ]) 274AS_VAR_IF([[mhd_cv_macro_true_defined]], [["yes"]], [[:]], 275 [AC_DEFINE([[true]],[[(!0)]], [Define to value interpreted by compiler as boolean "true", if "true" is not defined by system headers.])]) 276 277AC_CACHE_CHECK([[whether "false" is defined or builtin]], [[mhd_cv_macro_false_defined]], 278 [AC_COMPILE_IFELSE( 279 [AC_LANG_PROGRAM( 280 [[ 281#ifdef HAVE_STDBOOL_H 282#include <stdbool.h> 283#endif 284 ]], [[ 285#if !defined(false) 286 (void)false; 287#else 288 /* dummy */ 289#endif 290 ]]) 291 ], [[mhd_cv_macro_false_defined='yes']], [[mhd_cv_macro_false_defined='no']]) 292 ]) 293AS_VAR_IF([[mhd_cv_macro_false_defined]], [["yes"]], [[:]], 294 [AC_DEFINE([[false]],[[0]], [Define to value interpreted by compiler as boolean "false", if "false" is not defined by system headers.])]) 295 296AC_CACHE_CHECK([[whether "true" and "false" could be used]], [[mhd_cv_macro_true_false_valid]], 297 [AC_COMPILE_IFELSE( 298 [AC_LANG_PROGRAM( 299 [[ 300#ifdef HAVE_STDBOOL_H 301#include <stdbool.h> 302#endif 303 ]], [[ 304 int var1[true ? 1 : -1] = { 1 }; 305 int var2[false ? -1 : 1] = { 2 }; 306 int var3[!true ? -1 : 1] = { 3 }; 307 int var4[!false ? 1 : -1] = { 4 }; 308 if (var1[0] == var2[0] || var3[0] == var4[0]) 309 return 1; 310 ]]) 311 ], [[mhd_cv_macro_true_false_valid='yes']], [[mhd_cv_macro_true_false_valid='no']]) 312 ]) 313AS_VAR_IF([[mhd_cv_macro_true_false_valid]], [["yes"]], [[:]], 314 [AC_MSG_ERROR([[Value of "true" or value of "false" is not valid. Check config.log for details.]])]) 315 316 317AX_CHECK_COMPILE_FLAG([[-Werror=attributes]], 318 [ 319 save_CFLAGS="$CFLAGS" 320 CFLAGS="$CFLAGS -Werror=attributes" 321 AC_MSG_CHECKING([[whether -Werror=attributes actually works]]) 322 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 323 [[__attribute__((non_existing_attrb_dummy)) int SimpleFunc(void) {return 3;}]], [[int r = SimpleFunc(); if (r) return r;]])], 324 [ 325 AC_MSG_RESULT([[no]]) 326 errattr_CFLAGS="" 327 ], [ 328 AC_MSG_RESULT([[yes]]) 329 errattr_CFLAGS="-Werror=attributes" 330 ]) 331 CFLAGS="$save_CFLAGS" 332 ], 333 [[errattr_CFLAGS=""]], [], []) 334AC_MSG_CHECKING([[for function inline keywords supported by $CC]]) 335save_CFLAGS="$CFLAGS" 336CFLAGS="$CFLAGS $errattr_CFLAGS" 337inln_prfx="none" 338# Prefer always inline functions 339for inln_prfx_chk in InlineWithAttr __forceinline inline __inline__ __inline _inline _Inline 340do 341 # Try to link to avoid "symbol undefined" problems at build time 342 AS_IF([[test "x$inln_prfx_chk" = "xInlineWithAttr"]], 343 [ 344 AS_IF([[test "x$errattr_CFLAGS" = "x"]], 345 [[ # Skip test with attribute as negative result can't be detected 346 inln_prfx_chk="__forceinline" # use next value 347 ]],[[inln_prfx_chk="inline __attribute__((always_inline))"]]) 348 ]) 349 AC_LINK_IFELSE( 350 [ 351 AC_LANG_PROGRAM( 352 [[ 353#ifdef __cplusplus 354#error This test is only for C. 355choke me 356#endif 357#ifdef HAVE_STDBOOL_H 358#include <stdbool.h> 359#endif 360 static $inln_prfx_chk bool cmpfn(int x, int y) 361 { return x > y; } 362 static $inln_prfx_chk int sumfn(int x, int y) 363 { return x + y; } 364 ]],[[ 365 int a = 1, b = 100, c; 366 if (cmpfn(a, b)) 367 c = sumfn(a, b); 368 else 369 c = 0 - sumfn(a, b); 370 if (c) 371 return 0; 372 ]]) 373 ], 374 [[ inln_prfx="$inln_prfx_chk" ]]) 375 test "x$inln_prfx" != "xnone" && break 376done 377AS_IF([[test "x$inln_prfx" != "xnone"]], 378 [ 379 AC_DEFINE([INLINE_FUNC],[1],[Define to 1 if your C compiler supports inline functions.]) 380 AC_DEFINE_UNQUOTED([_MHD_static_inline],[static $inln_prfx],[Define to prefix which will be used with MHD static inline functions.]) 381 ], [ 382 AC_DEFINE([_MHD_static_inline],[static],[Define to prefix which will be used with MHD static inline functions.]) 383 ]) 384AC_MSG_RESULT([[$inln_prfx]]) 385CFLAGS="$save_CFLAGS" 386 387AC_CHECK_HEADERS([stdalign.h], [], [], [AC_INCLUDES_DEFAULT]) 388AC_CACHE_CHECK([[for C11 'alignof()' support]], [[mhd_cv_c_alignof]], 389 [AC_COMPILE_IFELSE( 390 [AC_LANG_PROGRAM( 391 [[ 392#ifdef HAVE_STDALIGN_H 393#include <stdalign.h> 394#endif 395 ]], [[ 396 int var1[(alignof(int) >= 2) ? 1 : -1]; 397 int var2[alignof(unsigned int) - 1]; 398 int var3[(alignof(char) > 0) ? 1 : -1]; 399 int var4[(alignof(long) >= 4) ? 1 : -1]; 400 401 /* Mute compiler warnings */ 402 var1[0] = var2[0] = var3[0] = 0; 403 var4[0] = 1; 404 if (var1[0] + var2[0] + var3[0] == var4[0]) 405 return 1; 406 ]]) 407 ], [ 408 AC_COMPILE_IFELSE( 409 [AC_LANG_PROGRAM( 410 [[ 411#ifdef HAVE_STDALIGN_H 412#include <stdalign.h> 413#endif 414 ]], [[ 415 /* Should fail if 'alignof()' works */ 416 int var1[alignof(nonexisting_type) - 1]; 417 418 /* Mute compiler warnings */ 419 var1[0] = 1; 420 if (var1[0] + 1 == 1) 421 return 1; 422 ]]) 423 ], [[mhd_cv_c_alignof='no']], [[mhd_cv_c_alignof='yes']]) 424 ], [[mhd_cv_c_alignof='no']]) 425 ]) 426AS_VAR_IF([mhd_cv_c_alignof], ["yes"], 427 [AC_DEFINE([[HAVE_C_ALIGNOF]], [1], [Define to 1 if your compiler supports 'alignof()'])]) 428 429 430# Check system type 431shutdown_trig_select='no' 432AC_MSG_CHECKING([[for target host OS]]) 433AS_CASE(["$host_os"], 434 [*darwin* | *rhapsody* | *macosx*], 435 [AC_DEFINE_UNQUOTED(OSX,1,[This is an OS X system]) 436 CFLAGS="-no-cpp-precomp -fno-common $CFLAGS" 437 mhd_host_os='Darwin' 438 AC_MSG_RESULT([[$mhd_host_os]])], 439 [freebsd*], 440 [AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system]) 441 AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system]) 442 mhd_host_os='FreeBSD' 443 AC_MSG_RESULT([[$mhd_host_os]])], 444 [openbsd*], 445 [AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system]) 446 AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system]) 447 mhd_host_os='OpenBSD' 448 AC_MSG_RESULT([[$mhd_host_os]])], 449 [netbsd*], 450 [AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system]) 451 AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system]) 452 mhd_host_os='NetBSD' 453 AC_MSG_RESULT([[$mhd_host_os]])], 454 [*solaris*], 455 [AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system]) 456 AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno does not work]) 457 mhd_host_os='Solaris' 458 AC_MSG_RESULT([[$mhd_host_os]]) 459 AC_SEARCH_LIBS(gethostbyname, nsl) 460 AC_SEARCH_LIBS(socket, socket)], 461 [*arm-linux*], 462 [AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel]) 463 mhd_host_os='ARM Linux' 464 AC_MSG_RESULT([[$mhd_host_os]]) 465 CFLAGS="-fPIC -pipe $CFLAGS"], 466 [*linux*], 467 [AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel]) 468 mhd_host_os='Linux' 469 AC_MSG_RESULT([[$mhd_host_os]])], 470 [*cygwin*], 471 [AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system]) 472 mhd_host_os='Windows/Cygwin' 473 AC_MSG_RESULT([[$mhd_host_os]]) 474 os_is_windows=yes], 475 [*mingw*], 476 [ 477 AC_DEFINE([MINGW],[1],[This is a MinGW system]) 478 AC_DEFINE([WINDOWS],[1],[This is a Windows system]) 479 mhd_host_os='Windows/MinGW' 480 AC_MSG_RESULT([[$mhd_host_os]]) 481 LIBS="$LIBS -lws2_32" 482 AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([[Winsock2 headers are required for W32]])], [AC_INCLUDES_DEFAULT]) 483 AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool], 484 [mslibcheck=`lib 2>&1` 485 AS_IF([echo "$mslibcheck" | $GREP -e '^Microsoft (R) Library Manager' - >/dev/null], 486 [ac_cv_use_ms_lib_tool=yes], 487 [ac_cv_use_ms_lib_tool=no]) 488 ]) 489 AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes"], 490 [AC_SUBST([MS_LIB_TOOL], [[lib]])]) 491 AC_SUBST([lt_cv_objdir]) 492 os_is_windows=yes 493 os_is_native_w32=yes 494 ], 495 [*openedition*], 496 [AC_DEFINE_UNQUOTED(OS390,1,[This is a OS/390 system]) 497 mhd_host_os='OS/390' 498 AC_MSG_RESULT([[$mhd_host_os]])], 499 [gnu*], 500 [AC_DEFINE([[GNU_HURD]], [[1]], [Define to `1' if host machine runs on GNU Hurd.]) 501 mhd_host_os='GNU Hurd' 502 AC_MSG_RESULT([[$mhd_host_os]]) 503 ], 504 [ 505 AC_MSG_RESULT([unrecognised OS]) 506 mhd_host_os="${host_os}" 507 AC_MSG_WARN([Unrecognised OS $host_os]) 508 AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS]) 509 ]) 510 511AM_CONDITIONAL([CYGWIN_TARGET], [[test "x$os_is_windows" = "xyes" && \ 512 test "x${os_is_native_w32}" != "xyes"]]) 513 514AS_VAR_IF([os_is_windows], ["yes"], 515 [ 516 AC_MSG_CHECKING([[whether target W32 version is specified by precompiler defines]]) 517 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 518/* Note: check logic is reversed for easy log reading */ 519#ifdef WINVER 520#error WINVER is defined 521choke me now; 522#endif 523#ifdef _WIN32_WINNT 524#error _WIN32_WINNT is defined 525choke me now; 526#endif 527#ifdef NTDDI 528#error NTDDI is defined 529choke me now; 530#endif 531 ]],[[(void)0]]) 532 ], [[mhd_w32_ver_preselect=no]], [[mhd_w32_ver_preselect=yes]] 533 ) 534 AC_MSG_RESULT([[${mhd_w32_ver_preselect}]]) 535 AC_CHECK_HEADERS([windows.h sdkddkver.h], [], [], [AC_INCLUDES_DEFAULT]) 536 AS_VAR_IF([mhd_w32_ver_preselect],["yes"], 537 [ 538 AC_MSG_CHECKING([[for specified target W32 version]]) 539 AS_UNSET([[mhd_w32_ver]]) 540 AS_UNSET([[mhd_w32_ver_msg]]) 541 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 542#if _WIN32_WINNT+0 < 0x0501 543/* Check before headers inclusion */ 544#error _WIN32_WINNT is less than 0x0501 545choke me now; 546#endif 547 548#ifdef HAVE_SDKDDKVER_H 549#include <sdkddkver.h> 550#endif 551#ifdef HAVE_WINDOWS_H 552#include <windows.h> 553#endif 554 555#if _WIN32_WINNT+0 < 0x0501 556#error _WIN32_WINNT is less than 0x0501 557choke me now; 558#endif 559 ]],[[(void)0]]) 560 ], [], [ 561 AC_MSG_RESULT([[pre-WinXP]]) 562 AC_MSG_ERROR([[libmicrohttpd cannot be compiled for Windows version before Windows XP]]) 563 ] 564 ) 565 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 566#ifdef HAVE_SDKDDKVER_H 567#include <sdkddkver.h> 568#endif 569#ifdef HAVE_WINDOWS_H 570#include <windows.h> 571#endif 572 573#if _WIN32_WINNT+0 == 0x0501 574#error _WIN32_WINNT is 0x0501 575choke me now; 576#endif 577#if _WIN32_WINNT+0 == 0x0502 578#error _WIN32_WINNT is 0x0502 579choke me now; 580#endif 581 ]],[[(void)0]]) 582 ], [], [ 583 mhd_w32_ver="WinXP" 584 mhd_w32_ver_msg="WinXP (selected by precompiler flags)" 585 ] 586 ) 587 AS_VAR_SET_IF([mhd_w32_ver], [], 588 [ 589 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 590#ifdef HAVE_SDKDDKVER_H 591#include <sdkddkver.h> 592#endif 593#ifdef HAVE_WINDOWS_H 594#include <windows.h> 595#endif 596 597#if _WIN32_WINNT+0 < 0x0600 598#error _WIN32_WINNT is less than 0x0600 but greater than 0x0502 599choke me now; 600#endif 601 ]],[[(void)0]]) 602 ], [], [ 603 AC_MSG_ERROR([[_WIN32_WINNT value is wrong (less than 0x0600 but greater than 0x0502)]]) 604 ] 605 ) 606 607 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 608#ifdef HAVE_SDKDDKVER_H 609#include <sdkddkver.h> 610#endif 611#ifdef HAVE_WINDOWS_H 612#include <windows.h> 613#endif 614 615#if _WIN32_WINNT+0 == 0x0600 616#error _WIN32_WINNT is 0x0600 617choke me now; 618#endif 619 ]],[[(void)0]]) 620 ], [], [ 621 mhd_w32_ver="Vista" 622 mhd_w32_ver_msg="Vista (selected by precompiler flags)" 623 ] 624 ) 625 ] 626 ) 627 628 AS_VAR_SET_IF([mhd_w32_ver], [], 629 [ 630 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 631#ifdef HAVE_SDKDDKVER_H 632#include <sdkddkver.h> 633#endif 634#ifdef HAVE_WINDOWS_H 635#include <windows.h> 636#endif 637 638#if _WIN32_WINNT+0 > 0x0600 639#error _WIN32_WINNT is greater than 0x0600 640choke me now; 641#endif 642 ]],[[(void)0]]) 643 ], [ 644 mhd_w32_ver="unknown" 645 mhd_w32_ver_msg="unknown (cannot be detected)" 646 ], [ 647 mhd_w32_ver="newer than Vista" 648 mhd_w32_ver_msg="newer than Vista (selected by precompiler flags)" 649 ] 650 ) 651 ] 652 ) 653 AC_MSG_RESULT([[${mhd_w32_ver}]]) 654 ], [ 655 mhd_w32_ver="Vista" 656 mhd_w32_ver_msg="Vista (default, override by CPPFLAGS=-D_WIN32_WINNT=0xNNNN)" 657 CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600" 658 AC_MSG_CHECKING([[whether headers accept _WIN32_WINNT=0x0600]]) 659 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 660#ifdef HAVE_SDKDDKVER_H 661#include <sdkddkver.h> 662#endif 663#ifdef HAVE_WINDOWS_H 664#include <windows.h> 665#endif 666#include <stdio.h> 667 ]],[[(void)0]]) 668 ], [ 669 AC_MSG_RESULT([[yes]]) 670 ], [ 671 AC_MSG_RESULT([[no]]) 672 AC_MSG_ERROR([Headers do not accept _WIN32_WINNT=0x0600. Consider override target W32 version by CPPFLAGS=-D_WIN32_WINNT=0xNNNN]) 673 ] 674 ) 675 ] 676 ) 677 ] 678) 679 680AS_IF([test "x${os_is_windows}" = "xyes" && test "x${os_is_native_w32}" = "xyes"], 681 [ 682 AC_CACHE_CHECK([W32 run-time library type], [mhd_cv_wctr_type], 683 [ 684 AC_EGREP_CPP([MHDMARKER: UCRT run-time library in use!], [ 685#include <stdio.h> 686#if defined(_UCRT) 687#define CRT_STR "MHDMARKER: UCRT run-time library in use!" 688#endif 689#if defined(__MSVCRT_VERSION__) 690#if (__MSVCRT_VERSION__ >= 0xE00) && (__MSVCRT_VERSION__ < 0x1000) 691#define CRT_STR "MHDMARKER: UCRT run-time library in use!" 692#endif 693#if (__MSVCRT_VERSION__ > 0x1400) 694#define CRT_STR "MHDMARKER: UCRT run-time library in use!" 695#endif 696#endif 697 698#ifndef CRT_STR 699#define CRT_STR "MHDMARKER: MSVCRT run-time library in use!" 700#endif 701 702int main(void) 703{ 704 printf ("%\n", CRT_STR); 705 return 0; 706} 707 ], 708 [mhd_cv_wctr_type="ucrt"], [mhd_cv_wctr_type="msvcrt"]) 709 ] 710 ) 711 mhd_host_os="${mhd_host_os}-${mhd_cv_wctr_type}" 712 AS_VAR_IF([mhd_cv_wctr_type], ["msvcrt"], 713 [ 714 AX_APPEND_COMPILE_FLAGS([-D__USE_MINGW_ANSI_STDIO=0], [CPPFLAGS]) 715 AC_SUBST([W32CRT], [MSVCRT]) 716 ], [AC_SUBST([W32CRT], [UCRT])] 717 ) 718 ] 719) 720 721 722 723AC_ARG_WITH([threads], 724 [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto, none) [auto]])], 725 [], [with_threads='auto']) 726AS_CASE([[$with_threads]], 727 [[win32]], [[with_threads='w32']], 728 [[pthreads]], [[with_threads='posix']], 729 [[posix]], [[:]], 730 [[w32]], [[:]], 731 [[none]], [[with_threads='none']], 732 [[no]], [[with_threads='none']], 733 [[auto]], [[:]], 734 [AC_MSG_ERROR([[incorrect parameter "$with_threads" specified for --with-threads]])] 735) 736 737# Check for posix threads support, regardless of configure parameters as 738# testsuite uses only posix threads. 739AX_PTHREAD( 740 [ 741 mhd_have_posix_threads='yes' 742 AC_DEFINE([[HAVE_PTHREAD_H]],[[1]],[Define to 1 if you have the <pthread.h> header file.]) 743 AC_CACHE_CHECK([[whether pthread_sigmask(3) is available]], 744 [[mhd_cv_func_pthread_sigmask]], [dnl 745 save_LIBS="$LIBS" 746 save_CFLAGS="$CFLAGS" 747 LIBS="$PTHREAD_LIBS $LIBS" 748 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 749 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], 750 [[ 751 sigset_t nset, oset; 752 sigemptyset (&nset); 753 sigaddset (&nset, SIGPIPE); 754 if (0 != pthread_sigmask(SIG_BLOCK, &nset, &oset)) return 1; 755 ]])], 756 [[mhd_cv_func_pthread_sigmask="yes"]],[[mhd_cv_func_pthread_sigmask="no"]]) 757 LIBS="${save_LIBS}" 758 CFLAGS="${save_CFLAGS}" 759 ]) 760 AS_VAR_IF([mhd_cv_func_pthread_sigmask],["yes"], 761 [AC_DEFINE([[HAVE_PTHREAD_SIGMASK]],[[1]],[Define to 1 if you have the pthread_sigmask(3) function.])]) 762 ],[[mhd_have_posix_threads='no']]) 763AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$mhd_have_posix_threads" = "xyes"]) 764 765mhd_have_w32_threads='no' 766AS_IF([[test "x$with_threads" = "xauto"]], 767 [ 768 AS_IF([[test "x$os_is_windows" = "xyes"]], 769 [ 770 AC_MSG_CHECKING([[for W32 threads]]) 771 AC_LINK_IFELSE( 772 [AC_LANG_PROGRAM([[ 773#include <windows.h> 774 ]], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])] 775 , [[mhd_have_w32_threads='yes']], [[mhd_have_w32_threads='no']] 776 ) 777 AC_MSG_RESULT([[$mhd_have_w32_threads]]) 778 ]) 779 ] 780) 781 782AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd ($with_threads)]]) 783AS_IF([test "x$with_threads" = "xposix"], 784 [ # forced posix threads 785 AS_IF([test "x$mhd_have_posix_threads" = "xyes"], [USE_THREADS='posix'], 786 [ AS_IF([[test "x$os_is_windows" = "xyes"]] , 787 [ AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]])], 788 [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]])] ) 789 ]) 790 ]) 791AS_IF([test "x$with_threads" = "xw32"], 792 [ # forced w32 threads 793 AS_IF([[test "x$mhd_have_w32_threads" = "xyes"]], 794 [[ USE_THREADS='w32' ]], 795 [ AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]])]) 796 ]) 797AS_IF([test "x$with_threads" = "xauto"], 798 [# automatic threads lib selection 799 AS_IF([[test "x$os_is_native_w32" = "xyes" && test "x$mhd_have_w32_threads" = "xyes"]] , 800 [[ USE_THREADS='w32' ]] , 801 [[ test "x$mhd_have_posix_threads" = "xyes" ]], [[ USE_THREADS='posix' ]], 802 [[ test "x$mhd_have_w32_threads" = "xyes" ]], [[ USE_THREADS='w32' ]], 803 [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]]) ] 804 )]) 805AS_IF([test "x$with_threads" = "xnone"], 806 [USE_THREADS='none']) 807 808AS_IF([test "x$USE_THREADS" = "xposix"], 809 [CC="$PTHREAD_CC" 810 AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads]) 811 MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS" 812 MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS" 813 MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG"], 814 [AS_IF([test "x$USE_THREADS" = "xw32"], 815 [AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads])])]) 816AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"]) 817AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"]) 818AM_CONDITIONAL([USE_THREADS], [test "x$USE_THREADS" != "xnone"]) 819AM_CONDITIONAL([DISABLE_THREADS], [test "x$USE_THREADS" = "xnone"]) 820AC_MSG_RESULT([$USE_THREADS]) 821 822AC_ARG_ENABLE([[thread-names]], 823 [AS_HELP_STRING([--disable-thread-names],[do not set names on MHD generated threads [auto]])], 824 [], [enable_thread_names='auto']) 825 826AS_IF([test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix"],[ 827 # Check for thread name function 828 HAVE_THREAD_NAME_FUNC="no" 829 SAVE_LIBS="$LIBS" 830 SAVE_CFLAGS="$CFLAGS" 831 LIBS="$PTHREAD_LIBS $LIBS" 832 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 833 AC_CHECK_HEADERS([pthread_np.h],[],[], 834 [ 835AC_INCLUDES_DEFAULT 836 [ 837#include <pthread.h> 838 ] 839 ]) 840 841 # Try to find how to set thread name by thread attributes. 842 # If pthread_attr_setname_np(3) is not declared, it's not possible to detect 843 # form of pthread_attr_setname_np(3) due to C "feature" "implicit declaration". 844 AC_CHECK_DECL([[pthread_attr_setname_np]],[],[],[[ 845#include <pthread.h> 846#ifdef HAVE_PTHREAD_NP_H 847#include <pthread_np.h> 848#endif 849]]) 850 851 AS_IF([[test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]], 852 [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in NetBSD or OSF1 form]]) 853 AC_LINK_IFELSE( 854 [AC_LANG_PROGRAM([[ 855#include <pthread.h> 856#ifdef HAVE_PTHREAD_NP_H 857#include <pthread_np.h> 858#endif 859]], [[ 860 pthread_attr_t thr_attr; 861 pthread_attr_init(&thr_attr); 862 pthread_attr_setname_np(&thr_attr, "name", 0); 863 pthread_attr_destroy(&thr_attr); 864 ]])], 865 [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.]) 866 HAVE_THREAD_NAME_FUNC="yes" 867 AC_MSG_RESULT([[yes]])], 868 [AC_MSG_RESULT([[no]])] 869 ) 870 ]) 871 872 AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]], 873 [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in IBM i or Solaris form]]) 874 AC_LINK_IFELSE( 875 [AC_LANG_PROGRAM([[ 876#include <pthread.h> 877#ifdef HAVE_PTHREAD_NP_H 878#include <pthread_np.h> 879#endif 880]], [[ 881 pthread_attr_t thr_attr; 882 pthread_attr_init(&thr_attr); 883 pthread_attr_setname_np(&thr_attr, "name"); 884 pthread_attr_destroy(&thr_attr); 885 ]])], 886 [AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI]], [[1]], [Define if you have IBM i form (or Solaris form) of pthread_attr_setname_np(3) function.]) 887 HAVE_THREAD_NAME_FUNC="yes" 888 AC_MSG_RESULT([[yes]])], 889 [AC_MSG_RESULT([[no]])] 890 ) 891 ]) 892 893 # Try to find how to set thread name for started thread - less convenient 894 # than setting name by attributes. 895 # If pthread_setname_np(3) is not declared, it's not possible to detect 896 # form of pthread_setname_np(3) due to C "feature" "implicit declaration". 897 AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]], 898 [AC_CHECK_DECL([[pthread_setname_np]],[],[],[[ 899#include <pthread.h> 900#ifdef HAVE_PTHREAD_NP_H 901#include <pthread_np.h> 902#endif 903 ]]) 904 ]) 905 906 AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]], 907 [AC_MSG_CHECKING([[for pthread_setname_np(3) in NetBSD or OSF1 form]]) 908 AC_LINK_IFELSE( 909 [AC_LANG_PROGRAM([[ 910#include <pthread.h> 911#ifdef HAVE_PTHREAD_NP_H 912#include <pthread_np.h> 913#endif 914]], [[int res = pthread_setname_np(pthread_self(), "name", 0); if (res) return res;]])], 915 [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_setname_np(3) function.]) 916 HAVE_THREAD_NAME_FUNC="yes" 917 AC_MSG_RESULT([[yes]])], 918 [AC_MSG_RESULT([[no]])] 919 ) 920 ]) 921 922 AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]], 923 [AC_MSG_CHECKING([[for pthread_setname_np(3) in GNU/Linux form]]) 924 AC_LINK_IFELSE( 925 [AC_LANG_PROGRAM([[ 926#include <pthread.h> 927#ifdef HAVE_PTHREAD_NP_H 928#include <pthread_np.h> 929#endif 930]], [[int res = pthread_setname_np(pthread_self(), "name"); if (res) return res;]])], 931 [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_GNU]], [[1]], [Define if you have GNU/Linux form of pthread_setname_np(3) function.]) 932 HAVE_THREAD_NAME_FUNC="yes" 933 AC_MSG_RESULT([[yes]])], 934 [AC_MSG_RESULT([[no]])] 935 ) 936 ]) 937 938 AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]], 939 [AC_MSG_CHECKING([[for pthread_setname_np(3) in Darwin form]]) 940 AC_LINK_IFELSE( 941 [AC_LANG_PROGRAM([[ 942#include <pthread.h> 943#ifdef HAVE_PTHREAD_NP_H 944#include <pthread_np.h> 945#endif 946]], [[int res = pthread_setname_np("name"); if (res) return res;]])], 947 [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_DARWIN]], [[1]], [Define if you have Darwin form of pthread_setname_np(3) function.]) 948 HAVE_THREAD_NAME_FUNC="yes" 949 AC_MSG_RESULT([[yes]])], 950 [AC_MSG_RESULT([[no]])] 951 ) 952 ]) 953 954 AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]], 955 [ 956 AC_CHECK_DECL([[pthread_set_name_np]], 957 [ 958 AC_MSG_CHECKING([[for pthread_set_name_np(3) in FreeBSD form]]) 959 AC_LINK_IFELSE( 960 [AC_LANG_PROGRAM([[ 961#include <pthread.h> 962#ifdef HAVE_PTHREAD_NP_H 963#include <pthread_np.h> 964#endif 965]], [[pthread_set_name_np(pthread_self(), "name");]])], 966 [AC_DEFINE([[HAVE_PTHREAD_SET_NAME_NP_FREEBSD]], [[1]], [Define if you have FreeBSD form of pthread_set_name_np(3) function.]) 967 HAVE_THREAD_NAME_FUNC="yes" 968 AC_MSG_RESULT([[yes]])], 969 [AC_MSG_RESULT([[no]])] 970 ) 971 ],[],[[ 972#include <pthread.h> 973#ifdef HAVE_PTHREAD_NP_H 974#include <pthread_np.h> 975#endif 976 ]] 977 ) 978 ]) 979 980 LIBS="$SAVE_LIBS" 981 CFLAGS="$SAVE_CFLAGS" 982]) 983 984AS_IF([[test "x$enable_thread_names" != "xno"]], 985 [ 986 AC_MSG_CHECKING([[whether to enable thread names]]) 987 AC_COMPILE_IFELSE( 988 [AC_LANG_PROGRAM([], [[ 989#ifdef MHD_NO_THREAD_NAMES 990#error Thread names are disabled. 991choke me 992#endif 993 994/* Keep in sync with mhd_threads.h */ 995#if defined(MHD_USE_POSIX_THREADS) && (defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) || \ 996 defined(HAVE_PTHREAD_SETNAME_NP_GNU) || defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || \ 997 defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) ) 998(void) 0; /* no-op */ 999#elif defined(MHD_USE_W32_THREADS) && defined(_MSC_FULL_VER) 1000(void) 0; /* no-op */ 1001#else 1002#error No thread name function is available. 1003choke me 1004#endif 1005 ]]) 1006 ], [ 1007 enable_thread_names='yes' 1008 ], [ 1009 AS_IF([[test "x$enable_thread_names" = "xyes"]], 1010 [ 1011 AC_MSG_RESULT([[no]]) 1012 AC_MSG_ERROR([[thread names was explicitly requested, but thread name function is not available]]) 1013 ]) 1014 enable_thread_names='no' 1015 ]) 1016 AC_MSG_RESULT([[$enable_thread_names]]) 1017 ]) 1018 1019AS_IF([[test "x$enable_thread_names" = "xno"]], 1020 [AC_DEFINE([[MHD_NO_THREAD_NAMES]], [[1]], [Define to 1 to disable setting name on generated threads])]) 1021 1022AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"]) 1023w32_shared_lib_exp=no 1024AS_IF([test "x$enable_shared" = "xyes" && test "x$os_is_native_w32" = "xyes"], 1025 [ 1026 AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes" || test -n "$DLLTOOL"], 1027 [ 1028 w32_shared_lib_exp=yes 1029 use_expfile="no" 1030 AS_VAR_IF([ac_cv_use_ms_lib_tool], ["yes"], [use_expfile="yes"], 1031 [ 1032 AC_CACHE_CHECK([whether $DLLTOOL supports export file generation], [mhd_cv_dlltool_expfile], 1033 [ 1034 AS_IF([AC_RUN_LOG([$DLLTOOL -e conftest.exp >&2 ])], 1035 [ 1036 AS_IF([test -f conftest.exp], [mhd_cv_dlltool_expfile="yes"], [mhd_cv_dlltool_expfile="no"]) 1037 ], [mhd_cv_dlltool_expfile="no"] 1038 ) 1039 rm -f conftest.exp 1040 ] 1041 ) 1042 use_expfile="${mhd_cv_dlltool_expfile}" 1043 ] 1044 ) 1045 ], 1046 [ 1047 AC_MSG_WARN([[GNU dlltool or MS lib.exe is required for creating shared library export on W32]]) 1048 AC_MSG_WARN([[Export library libmicrohttpd.lib will not be created]]) 1049 ] 1050 ) 1051 ] 1052) 1053AM_CONDITIONAL([W32_SHARED_LIB_EXP], [test "x$w32_shared_lib_exp" = "xyes"]) 1054AM_CONDITIONAL([USE_MS_LIB_TOOL], [test "x$ac_cv_use_ms_lib_tool" = "xyes"]) 1055AM_CONDITIONAL([USE_EXPORT_FILE], [test "x$use_expfile" = "xyes"]) 1056 1057MHD_CHECK_SOCKET_SHUTDOWN_TRIGGER([AC_DEFINE([HAVE_LISTEN_SHUTDOWN],[1],[can use shutdown on listen sockets])]) 1058AM_CONDITIONAL([HAVE_LISTEN_SHUTDOWN], [test "x$mhd_cv_host_shtdwn_trgr_select" = "xyes"]) 1059 1060# SENDMSG. Should we check for SCM_RIGHTS instead? 1061# https://lists.x.org/archives/xorg-devel/2013-November/038687.html 1062AC_SEARCH_LIBS([sendmsg], [socket], [AC_DEFINE([HAVE_SENDMSG],[1],[Define if your platform supports sendmsg])]) 1063AC_CHECK_FUNCS([writev]) 1064 1065# set GCC options 1066# use '-fno-strict-aliasing', but only if the compiler 1067# and linker can take it 1068AX_CHECK_LINK_FLAG([-fno-strict-aliasing], 1069 [AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing])]) 1070 1071AC_C_BIGENDIAN 1072AC_C_VARARRAYS 1073 1074AC_CACHE_CHECK([[whether __func__ magic-macro is available]], 1075 [[mhd_cv_macro___func___avail]], [dnl 1076 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]],[[const char *funcname = __func__ ; if (NULL == funcname) return 1;]])], 1077 [[mhd_cv_macro___func___avail="yes"]],[[mhd_cv_macro___func___avail="no"]]) 1078]) 1079AS_VAR_IF([mhd_cv_macro___func___avail], ["yes"], 1080 [AC_DEFINE([HAVE___FUNC__], [1], [Define to 1 if your compiler supports __func__ magic-macro.])], 1081 [ 1082 AC_CACHE_CHECK([[whether __FUNCTION__ magic-macro is available]], 1083 [[mhd_cv_macro___function___avail]], [dnl 1084 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]],[[const char *funcname = __FUNCTION__ ; if (NULL == funcname) return 1;]])], 1085 [[mhd_cv_macro___function___avail="yes"]],[[mhd_cv_macro___function___avail="no"]]) 1086 ]) 1087 AC_DEFINE([HAVE___FUNCTION__], [1], [Define to 1 if your compiler supports __FUNCTION__ magic-macro.]) 1088 ] 1089) 1090AC_CACHE_CHECK([[whether __builtin_bswap32() is available]], 1091 [[mhd_cv_func___builtin_bswap32_avail]], [dnl 1092 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint32_t a = 1; uint32_t b = __builtin_bswap32(a); a = b;]])], 1093 [[mhd_cv_func___builtin_bswap32_avail="yes"]],[[mhd_cv_func___builtin_bswap32_avail="no"]]) 1094]) 1095AS_IF([[test "x$mhd_cv_func___builtin_bswap32_avail" = "xyes"]], 1096 [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP32]], [[1]], [Define to 1 if you have __builtin_bswap32() builtin function])]) 1097AC_CACHE_CHECK([[whether __builtin_bswap64() is available]], 1098 [[mhd_cv_func___builtin_bswap64_avail]], [dnl 1099 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint64_t a = 1; uint32_t b = __builtin_bswap64(a); a = b;]])], 1100 [[mhd_cv_func___builtin_bswap64_avail="yes"]], [[mhd_cv_func___builtin_bswap64_avail="no"]]) 1101]) 1102AS_IF([[test "x$mhd_cv_func___builtin_bswap64_avail" = "xyes"]], 1103 [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP64]], [[1]], [Define to 1 if you have __builtin_bswap64() builtin function])]) 1104 1105AC_CHECK_PROG([HAVE_CURL_BINARY],[curl],[yes],[no]) 1106AM_CONDITIONAL([HAVE_CURL_BINARY],[test "x$HAVE_CURL_BINARY" = "xyes"]) 1107AC_CHECK_PROG([HAVE_MAKEINFO_BINARY],[makeinfo],[yes],[no]) 1108AM_CONDITIONAL([HAVE_MAKEINFO_BINARY],[test "x$HAVE_MAKEINFO_BINARY" = "xyes"]) 1109AM_CONDITIONAL(W32_STATIC_LIB, [test "x$os_is_native_w32" = "xyes" && test "x$enable_static" = "xyes"]) 1110 1111 1112AC_ARG_ENABLE([[doc]], 1113 [AS_HELP_STRING([[--disable-doc]], [do not build any documentation])], , 1114 [enable_doc=yes]) 1115test "x$enable_doc" = "xno" || enable_doc=yes 1116AM_CONDITIONAL([BUILD_DOC], [test "x$enable_doc" = "xyes"]) 1117 1118AC_ARG_ENABLE([[examples]], 1119 [AS_HELP_STRING([[--disable-examples]], [do not build any examples])], , 1120 [enable_examples=yes]) 1121test "x$enable_examples" = "xno" || enable_examples=yes 1122AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" = "xyes"]) 1123 1124AC_ARG_ENABLE([[heavy-tests]], 1125 [AS_HELP_STRING([[--enable-heavy-tests]], [use heavy tests in test-suite. WARNING:] 1126 [a dedicated host with minimal number of background processes and no network] 1127 [activity is recommended to enable.])], [], 1128 [enable_heavy_tests=no]) 1129AS_VAR_IF([enable_heavy_tests], ["yes"], 1130 [ 1131 HEAVY_TESTS_NOTPARALLEL='.NOTPARALLEL:' 1132 AC_DEFINE([_MHD_HEAVY_TESTS], [1], [Define to 1 to enable "heavy" test paths.]) 1133 ], 1134 [ 1135 enable_heavy_tests=no 1136 HEAVY_TESTS_NOTPARALLEL=" " 1137 ] 1138) 1139AM_CONDITIONAL([HEAVY_TESTS],[test "x$enable_heavy_tests" = "xyes"]) 1140 1141AC_ARG_ENABLE([[poll]], 1142 [AS_HELP_STRING([[--enable-poll[=ARG]]], [enable poll support (yes, no, auto) [auto]])], 1143 [enable_poll=${enableval}], 1144 [enable_poll='auto'] 1145 ) 1146 1147AS_IF([test "$enable_poll" != "no"], 1148 [AS_IF([test "$os_is_native_w32" != "yes"], 1149 AC_CHECK_HEADERS([poll.h], 1150 [AC_CHECK_FUNCS([poll], [have_poll='yes'], [have_poll='no'])], 1151 [], 1152 [AC_INCLUDES_DEFAULT]), 1153 [AC_MSG_CHECKING([for WSAPoll()]) 1154 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 1155#include <winsock2.h> 1156 ]],[[ 1157WSAPOLLFD fda[2]; 1158WSAPoll(fda, 2, 0);]])], 1159 [have_poll='yes' 1160 AC_DEFINE([HAVE_POLL],[1]) 1161 ],[have_poll='no']) 1162 AC_MSG_RESULT([$have_poll])]) 1163 AS_IF([test "$enable_poll" = "yes" && test "$have_poll" != "yes"], 1164 [AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]])]) 1165 enable_poll="$have_poll"]) 1166 1167AC_ARG_ENABLE([[epoll]], 1168 [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])], 1169 [enable_epoll=${enableval}], 1170 [enable_epoll='auto'] 1171 ) 1172 1173AS_IF([test "$enable_epoll" != "no"], 1174 [ 1175 AX_HAVE_EPOLL 1176 AS_IF([test "${ax_cv_have_epoll}" = "yes"], 1177 [ 1178 AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll support]) 1179 enable_epoll='yes' 1180 ], 1181 [ 1182 AS_IF([test "$enable_epoll" = "yes"], 1183 [AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]])] 1184 ) 1185 enable_epoll='no' 1186 ] 1187 ) 1188 ] 1189) 1190 1191AM_CONDITIONAL([MHD_HAVE_EPOLL], [[test "x$enable_epoll" = xyes]]) 1192 1193AS_IF([test "x$enable_epoll" = "xyes"], 1194 AC_CACHE_CHECK([for epoll_create1()], 1195 [mhd_cv_have_epoll_create1], [ 1196 AC_LINK_IFELSE([ 1197 AC_LANG_PROGRAM([[ 1198#include <sys/epoll.h> 1199 ]], [[ 1200int fd; 1201fd = epoll_create1(EPOLL_CLOEXEC);]])], 1202 [mhd_cv_have_epoll_create1=yes], 1203 [mhd_cv_have_epoll_create1=no])]) 1204 AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[ 1205 AC_DEFINE([[HAVE_EPOLL_CREATE1]], [[1]], [Define if you have epoll_create1 function.])])) 1206 1207AC_CACHE_CHECK([for suported 'noreturn' keyword], [mhd_cv_decl_noreturn], 1208 [ 1209 mhd_cv_decl_noreturn="none" 1210 save_CFLAGS="${CFLAGS}" 1211 CFLAGS="${CFLAGS} ${errattr_CFLAGS}" 1212 for decl_noret in '_Noreturn' '__attribute__((__noreturn__))' '__declspec(noreturn)' 1213 do 1214 AC_LINK_IFELSE([AC_LANG_SOURCE( 1215 [[ 1216#ifdef HAVE_STDLIB_H 1217#include <stdlib.h> 1218#endif 1219 1220${decl_noret} void myexitfunc(int code) 1221{ 1222#ifdef HAVE_STDLIB_H 1223 exit (code); 1224#else 1225 (void)code; 1226#endif 1227} 1228 1229int main (int argc, char *const *argv) 1230{ 1231 (void) argv; 1232 if (argc > 2) 1233 myexitfunc (2); 1234 return 0; 1235} 1236 ]] 1237 )], [mhd_cv_decl_noreturn="${decl_noret}"] 1238 ) 1239 AS_IF([test "x${mhd_cv_decl_noreturn}" != "xnone"], [break]) 1240 done 1241 CFLAGS="${save_CFLAGS}" 1242 ] 1243) 1244AS_VAR_IF([mhd_cv_decl_noreturn], ["none"], 1245 [AC_DEFINE([_MHD_NORETURN], [], [Define to supported 'noreturn' function declaration])], 1246 [AC_DEFINE_UNQUOTED([_MHD_NORETURN], [${mhd_cv_decl_noreturn}], [Define to supported 'noreturn' function declaration])] 1247) 1248 1249# Check for types sizes 1250# Types sizes are used as an indirect indication of maximum allowed values for types 1251# which is used to exclude by preprocessor some compiler checks for values clips 1252# Assuming no staffing or uniform staffing for integer types 1253AC_CACHE_CHECK([size of tv_sec member of struct timeval], [mhd_cv_size_timeval_tv_sec], 1254 [ 1255 AC_COMPUTE_INT([mhd_cv_size_timeval_tv_sec], [((long int)sizeof(test_var.tv_sec))], 1256 [[ 1257#ifdef HAVE_SYS_TIME_H 1258#include <sys/time.h> 1259#endif /* HAVE_SYS_TIME_H */ 1260#ifdef HAVE_TIME_H 1261#include <time.h> 1262#endif /* HAVE_TIME_H */ 1263#if HAVE_SYS_TYPES_H 1264#include <sys/types.h> 1265#endif /* HAVE_SYS_TYPES_H */ 1266struct timeval test_var; 1267 ]], 1268 [ 1269 # The size is used only to exclude additional checks/comparison in code 1270 # to avoid compiler warnings. With larger size MHD code will use 1271 # additional checks which ensure that value will fit but it may produce 1272 # a harmless compiler warning. 1273 AC_MSG_WARN([The size cannot be determined, assuming 8.]) 1274 mhd_cv_size_timeval_tv_sec=8 1275 ] 1276 ) 1277 ] 1278) 1279AC_DEFINE_UNQUOTED([SIZEOF_STRUCT_TIMEVAL_TV_SEC], [$mhd_cv_size_timeval_tv_sec], 1280 [The size of `tv_sec' member of `struct timeval', as computed by sizeof]) 1281AC_CHECK_SIZEOF([uint64_t], [], [[#include <stdint.h>]]) 1282AC_CHECK_SIZEOF([unsigned int], [], [[#include <stdint.h>]]) 1283AC_CHECK_SIZEOF([size_t], [], 1284 [[ 1285#ifdef HAVE_STDLIB_H 1286#include <stdlib.h> 1287#endif /* HAVE_STDLIB_H */ 1288#ifdef HAVE_STDDEF_H 1289#include <stddef.h> 1290#endif /* HAVE_STDDEF_H */ 1291#include <stdio.h> 1292 ]] 1293) 1294AC_CHECK_SIZEOF([unsigned long long], [], [[#include <stdint.h>]]) 1295 1296AC_CHECK_HEADERS([dlfcn.h],[have_tlsplugin=yes],[have_tlsplugin=no], [AC_INCLUDES_DEFAULT]) 1297AM_CONDITIONAL([MHD_HAVE_TLS_PLUGIN], [[test "x$have_tlsplugin" = xyes]]) 1298 1299AC_CHECK_HEADERS([zlib.h],[have_zlib=yes],[have_zlib=no], [AC_INCLUDES_DEFAULT]) 1300AM_CONDITIONAL([HAVE_ZLIB], [[test "x$have_zlib" = xyes]]) 1301 1302# Check for generic functions 1303MHD_CHECK_FUNC([random], 1304 [ 1305AC_INCLUDES_DEFAULT 1306[#include <stdlib.h> 1307 ]], 1308 [[long int r = random(); (void)r;]], 1309 [], 1310 [ 1311 MHD_CHECK_FUNC([rand], 1312 [ 1313AC_INCLUDES_DEFAULT 1314[#include <stdlib.h> 1315 ]], 1316 [[int r = rand(); (void)r;]], 1317 ) 1318 ] 1319) 1320 1321AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len, 1322 struct sockaddr_storage.ss_len], 1323 [], [], 1324 [ 1325#ifdef HAVE_SYS_TYPES_H 1326#include <sys/types.h> 1327#endif 1328#ifdef HAVE_SYS_SOCKET_H 1329#include <sys/socket.h> 1330#endif 1331#ifdef HAVE_NETINET_IN_H 1332#include <netinet/in.h> 1333#endif 1334 ]) 1335 1336MHD_CHECK_FUNC([getsockname], 1337 [[ 1338#ifdef HAVE_SYS_TYPES_H 1339#include <sys/types.h> 1340#endif 1341#ifdef HAVE_SYS_SOCKET_H 1342#include <sys/socket.h> 1343#endif 1344#ifdef HAVE_WINSOCK2_H 1345#include <winsock2.h> 1346#endif 1347 ]], 1348 [ 1349 struct sockaddr_storage ss; 1350 (void)getsockname(socket(0,0,0),(struct sockaddr *)&ss,(void*)0); 1351 ], 1352 [ 1353 AC_CACHE_CHECK([[whether getsockname() is usable]], [[mhd_cv_getsockname_usable]], 1354 [ 1355 AC_RUN_IFELSE( 1356 [ 1357 AC_LANG_SOURCE( 1358 [[ 1359#ifdef HAVE_SYS_TYPES_H 1360#include <sys/types.h> 1361#endif 1362#ifdef HAVE_SYS_SOCKET_H 1363#include <sys/socket.h> 1364#endif 1365#ifdef HAVE_UNISTD_H 1366#include <unistd.h> 1367#endif 1368#ifdef HAVE_WINSOCK2_H 1369#include <winsock2.h> 1370#endif 1371#ifdef HAVE_WS2TCPIP_H 1372#include <ws2tcpip.h> 1373#endif 1374#ifdef HAVE_NETINET_IN_H 1375#include <netinet/in.h> 1376#endif 1377#ifdef HAVE_NETINET_IP_H 1378#include <netinet/ip.h> 1379#endif 1380#ifdef HAVE_ARPA_INET_H 1381#include <arpa/inet.h> 1382#endif 1383 1384 1385static void zr_mem(void *ptr, socklen_t size) 1386{ char *mem = ptr; while(size--) {mem[0] = 0; mem++;} } 1387 1388int main(void) 1389{ 1390 const socklen_t c_addr_size = (socklen_t)sizeof(struct sockaddr_in); 1391 struct sockaddr_in sa; 1392 socklen_t addr_size; 1393 int ret = 1; 1394#if !defined(_WIN32) || defined(__CYGWIN__) 1395 int sckt; 1396 const int invld_sckt = -1; 1397#else 1398 SOCKET sckt; 1399 const SOCKET invld_sckt = INVALID_SOCKET; 1400 WSADATA wsa_data; 1401 1402 if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data) || MAKEWORD(2, 2) != wsa_data.wVersion) 1403 return 20; 1404#endif 1405 1406 sckt = socket (PF_INET, SOCK_STREAM, 0); 1407 if (invld_sckt != sckt) 1408 { 1409 zr_mem(&sa, c_addr_size); 1410 sa.sin_family = AF_INET; 1411#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1412 sa.sin_len = c_addr_size; 1413#endif 1414 if (0 == bind (sckt, (struct sockaddr *)&sa, c_addr_size)) 1415 { 1416 if (0 == listen (sckt, 1)) 1417 { 1418 addr_size = c_addr_size; 1419 if (0 == getsockname (sckt, (struct sockaddr *)&sa, &addr_size)) 1420 { 1421 if (c_addr_size >= addr_size) 1422 { 1423 if (0 != ntohs(sa.sin_port)) 1424 { ret = 0; 1425 } else ret = 7; 1426 } else ret = 6; 1427 } else ret = 5; 1428 } else ret = 4; 1429 } else ret = 3; 1430 } else ret = 2; 1431#if !defined(_WIN32) || defined(__CYGWIN__) 1432 close (sckt); 1433#else 1434 closesocket (sckt); 1435 WSACleanup(); 1436#endif 1437 return ret; 1438} 1439 ]] 1440 ) 1441 ], 1442 [[mhd_cv_getsockname_usable='yes']], 1443 [[mhd_cv_getsockname_usable='no']], 1444 [[mhd_cv_getsockname_usable='assuming yes']] 1445 ) 1446 ] 1447 ) 1448 AS_VAR_IF([[mhd_cv_getsockname_usable]], [["no"]], [:], 1449 [AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable `getsockname' function.])]) 1450 ] 1451) 1452 1453AC_CACHE_CHECK([for usable PAGESIZE macro], [mhd_cv_macro_pagesize_usable], 1454 [ 1455 AC_LINK_IFELSE( 1456 [ 1457 AC_LANG_PROGRAM( 1458 [[ 1459#ifdef HAVE_UNISTD_H 1460#include <unistd.h> 1461#endif 1462#ifdef HAVE_LIMITS_H 1463#include <limits.h> 1464#endif 1465#ifdef HAVE_SYS_PARAM_H 1466#include <sys/param.h> 1467#endif 1468#ifndef PAGESIZE 1469#error No PAGESIZE macro defined 1470choke me now 1471#endif 1472 ]], 1473 [[ 1474 long pgsz = PAGESIZE + 0; 1475 if (1 > pgsz) return 1; 1476 ]] 1477 ) 1478 ], 1479 [[mhd_cv_macro_pagesize_usable="yes"]], [[mhd_cv_macro_pagesize_usable="no"]] 1480 ) 1481 ] 1482) 1483AS_VAR_IF([[mhd_cv_macro_pagesize_usable]], [["yes"]], 1484 [ 1485 AC_DEFINE([[MHD_USE_PAGESIZE_MACRO]],[[1]],[Define if you have usable PAGESIZE macro]) 1486 AC_CACHE_CHECK([whether PAGESIZE macro could be used for static init], [mhd_cv_macro_pagesize_usable_static], 1487 [ 1488 AC_LINK_IFELSE( 1489 [ 1490 AC_LANG_PROGRAM( 1491 [[ 1492#ifdef HAVE_UNISTD_H 1493#include <unistd.h> 1494#endif 1495#ifdef HAVE_LIMITS_H 1496#include <limits.h> 1497#endif 1498#ifdef HAVE_SYS_PARAM_H 1499#include <sys/param.h> 1500#endif 1501#ifndef PAGESIZE 1502#error No PAGESIZE macro defined 1503choke me now 1504#endif 1505static long ac_pgsz = PAGESIZE + 0; 1506 ]], 1507 [[ 1508 if (1 > ac_pgsz) return 1; 1509 ]] 1510 ) 1511 ], 1512 [[mhd_cv_macro_pagesize_usable_static="yes"]], [[mhd_cv_macro_pagesize_usable_static="no"]] 1513 ) 1514 ] 1515 ) 1516 AS_VAR_IF([[mhd_cv_macro_pagesize_usable_static]], [["yes"]], 1517 [AC_DEFINE([[MHD_USE_PAGESIZE_MACRO_STATIC]],[[1]],[Define if you have PAGESIZE macro usable for static init])] 1518 ) 1519 ], 1520 [ 1521 AC_CACHE_CHECK([for usable PAGE_SIZE macro], [mhd_cv_macro_page_size_usable], 1522 [ 1523 AC_LINK_IFELSE( 1524 [ 1525 AC_LANG_PROGRAM( 1526 [[ 1527#ifdef HAVE_UNISTD_H 1528#include <unistd.h> 1529#endif 1530#ifdef HAVE_LIMITS_H 1531#include <limits.h> 1532#endif 1533#ifdef HAVE_SYS_PARAM_H 1534#include <sys/param.h> 1535#endif 1536#ifndef PAGE_SIZE 1537#error No PAGE_SIZE macro defined 1538choke me now 1539#endif 1540 ]], 1541 [[ 1542 long pgsz = PAGE_SIZE + 0; 1543 if (1 > pgsz) return 1; 1544 ]] 1545 ) 1546 ], 1547 [[mhd_cv_macro_page_size_usable="yes"]], [[mhd_cv_macro_page_size_usable="no"]] 1548 ) 1549 ] 1550 ) 1551 AS_VAR_IF([[mhd_cv_macro_page_size_usable]], [["yes"]], 1552 [ 1553 AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO]],[[1]],[Define if you have usable PAGE_SIZE macro]) 1554 AC_CACHE_CHECK([whether PAGE_SIZE macro could be used for static init], [mhd_cv_macro_page_size_usable_static], 1555 [ 1556 AC_LINK_IFELSE( 1557 [ 1558 AC_LANG_PROGRAM( 1559 [[ 1560#ifdef HAVE_UNISTD_H 1561#include <unistd.h> 1562#endif 1563#ifdef HAVE_LIMITS_H 1564#include <limits.h> 1565#endif 1566#ifdef HAVE_SYS_PARAM_H 1567#include <sys/param.h> 1568#endif 1569#ifndef PAGE_SIZE 1570#error No PAGE_SIZE macro defined 1571choke me now 1572#endif 1573static long ac_pgsz = PAGE_SIZE + 0; 1574 ]], 1575 [[ 1576 if (1 > ac_pgsz) return 1; 1577 ]] 1578 ) 1579 ], 1580 [[mhd_cv_macro_page_size_usable_static="yes"]], [[mhd_cv_macro_page_size_usable_static="no"]] 1581 ) 1582 ] 1583 ) 1584 AS_VAR_IF([[mhd_cv_macro_page_size_usable_static]], [["yes"]], 1585 [AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO_STATIC]],[[1]],[Define if you have PAGE_SIZE macro usable for static init])] 1586 ) 1587 ] 1588 ) 1589 ] 1590) 1591 1592# Check for inter-thread signaling type 1593AC_ARG_ENABLE([[itc]], 1594 [AS_HELP_STRING([[--enable-itc=TYPE]], [use TYPE of inter-thread communication (pipe, socketpair, eventfd) [auto]])], [], 1595 [[enable_itc='auto']] 1596) 1597 1598AS_CASE([[$enable_itc]], 1599 [[pipe]], [[:]], 1600 [[socketpair]], [[:]], 1601 [[eventfd]], [[:]], 1602 [[auto]], [AS_VAR_IF([[os_is_windows]], [["yes"]], [[enable_itc='socketpair']])], 1603 [[eventFD]], [[enable_itc='eventfd']], 1604 [[socket]], [[enable_itc='socketpair']], 1605 [[no]], [AC_MSG_ERROR([[inter-thread communication cannot be disabled]])], 1606 [AC_MSG_ERROR([[unrecognized type "$enable_itc" of inter-thread communication specified by "--enable-itc=$enable_itc"]])] 1607) 1608# AS_UNSET([[use_itc]]) 1609 1610AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]], [ 1611 AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [ 1612 AC_CHECK_HEADERS([sys/eventfd.h], [], [], [AC_INCLUDES_DEFAULT]) 1613 AS_VAR_IF([[ac_cv_header_sys_eventfd_h]], [["yes"]], [ 1614 AC_CACHE_CHECK([whether eventfd(2) is usable], [[mhd_cv_eventfd_usable]], [ 1615 AC_LINK_IFELSE([ 1616 AC_LANG_PROGRAM([[ 1617#include <sys/eventfd.h> 1618 ]], [[ 1619 int ef = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); 1620 if (ef) return ef - 1; 1621 ]]) 1622 ], [[mhd_cv_eventfd_usable='yes']], [[mhd_cv_eventfd_usable='no']]) 1623 ]) 1624 ]) 1625 ]) 1626 AS_VAR_IF([[mhd_cv_eventfd_usable]], [["yes"]], [ 1627 use_itc='eventfd' 1628 enable_itc="$use_itc" 1629 AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for inter-thread communication]) 1630 ], [ 1631 AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not usable, consider using other type of inter-thread communication]])]) 1632 ]) 1633]) 1634 1635AS_IF([[test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto"]], [ 1636 AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [ 1637 AC_CACHE_CHECK([[whether pipe(3) is usable]], [[mhd_cv_pipe_usable]], [ 1638 AC_LINK_IFELSE([ 1639 AC_LANG_PROGRAM([ 1640AC_INCLUDES_DEFAULT 1641#ifdef HAVE_UNISTD_H 1642#include <unistd.h> 1643#endif 1644 ], [[ 1645 int arr[2]; 1646 int res; 1647 res = pipe(arr) 1648 ]]) 1649 ], [[mhd_cv_pipe_usable='yes']], [[mhd_cv_pipe_usable='no']]) 1650 ]) 1651 ]) 1652 AS_VAR_IF([[mhd_cv_pipe_usable]], [["yes"]], [ 1653 use_itc='pipe' 1654 enable_itc="$use_itc" 1655 AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread communication]) 1656 AC_CACHE_CHECK([[whether pipe2(2) is usable]], [[mhd_cv_pipe2_usable]], [ 1657 AC_LINK_IFELSE([ 1658 AC_LANG_PROGRAM([ 1659AC_INCLUDES_DEFAULT 1660#ifdef HAVE_FCNTL_H 1661#include <fcntl.h> 1662#endif 1663#ifdef HAVE_UNISTD_H 1664#include <unistd.h> 1665#endif 1666 ], [[ 1667 int arr[2]; 1668 int res; 1669 res = pipe2(arr, O_CLOEXEC | O_NONBLOCK) 1670 ]]) 1671 ], [[mhd_cv_pipe2_usable='yes']], [[mhd_cv_pipe2_usable='no']]) 1672 ]) 1673 AS_VAR_IF([[mhd_cv_pipe2_usable]], [["yes"]], 1674 [AC_DEFINE([[HAVE_PIPE2_FUNC]], [[1]], [Define if you have usable pipe2(2) function])]) 1675 ], [ 1676 AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not usable, consider using other type of inter-thread communication]])]) 1677 ]) 1678]) 1679 1680AS_IF([[test "x$enable_itc" = "xsocketpair" || test "x$enable_itc" = "xauto"]], [ 1681 AS_VAR_IF([[os_is_native_w32]], [["yes"]], [[mhd_cv_socketpair_usable='yes']], [ 1682 AC_CACHE_CHECK([[whether socketpair(3) is usable]], [[mhd_cv_socketpair_usable]], [ 1683 AC_LINK_IFELSE([ 1684 AC_LANG_PROGRAM([ 1685AC_INCLUDES_DEFAULT 1686#ifdef HAVE_SYS_TYPES_H 1687#include <sys/types.h> 1688#endif 1689#ifdef HAVE_SYS_SOCKET_H 1690#include <sys/socket.h> 1691#endif 1692 ], [[ 1693 int arr[2]; 1694 int res; 1695#if defined(AF_LOCAL) 1696 res = socketpair(AF_LOCAL, SOCK_STREAM, 0, arr); 1697#elif defined(AF_UNIX) 1698 res = socketpair(AF_UNIX, SOCK_STREAM, 0, arr); 1699#else 1700#error AF_LOCAL and AF_UNIX are both undefined 1701 choke me now; 1702#endif 1703 if (res != 0) return 1 1704 ]]) 1705 ], [[mhd_cv_socketpair_usable='yes']], [[mhd_cv_socketpair_usable='no']]) 1706 ]) 1707 ]) 1708 AS_VAR_IF([[mhd_cv_socketpair_usable]], [["yes"]], [ 1709 use_itc='socketpair' 1710 enable_itc="$use_itc" 1711 AC_DEFINE([[_MHD_ITC_SOCKETPAIR]], [[1]], [Define to use socketpair for inter-thread communication]) 1712 ], [ 1713 AS_VAR_IF([[enable_itc]], [["socketpair"]], [AC_MSG_ERROR([[socketpair(3) is not usable, consider using other type of inter-thread communication]])]) 1714 ]) 1715]) 1716 1717AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find usable type of inter-thread communication]])]) 1718 1719 1720AC_CHECK_FUNCS_ONCE([accept4 gmtime_r memmem snprintf]) 1721AC_CHECK_DECL([gmtime_s], 1722 [ 1723 AC_MSG_CHECKING([[whether gmtime_s is in C11 form]]) 1724 AC_LINK_IFELSE( 1725 [ AC_LANG_PROGRAM( 1726 [[ 1727#define __STDC_WANT_LIB_EXT1__ 1 1728#include <time.h> 1729#ifdef __cplusplus 1730extern "C" 1731#endif 1732 struct tm* gmtime_s(const time_t* time, struct tm* result); 1733 ]], [[ 1734 struct tm res; 1735 time_t t; 1736 gmtime_s (&t, &res); 1737 ]]) 1738 ], 1739 [ 1740 AC_DEFINE([HAVE_C11_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in C11 form.]) 1741 AC_MSG_RESULT([[yes]]) 1742 ], 1743 [ 1744 AC_MSG_RESULT([[no]]) 1745 AC_MSG_CHECKING([[whether gmtime_s is in W32 form]]) 1746 AC_LINK_IFELSE( 1747 [ AC_LANG_PROGRAM( 1748 [[ 1749#include <time.h> 1750#ifdef __cplusplus 1751extern "C" 1752#endif 1753errno_t gmtime_s(struct tm* _tm, const time_t* time); 1754 ]], [[ 1755 struct tm res; 1756 time_t t; 1757 gmtime_s (&res, &t); 1758 ]]) 1759 ], 1760 [ 1761 AC_DEFINE([HAVE_W32_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in W32 form.]) 1762 AC_MSG_RESULT([[yes]]) 1763 ], 1764 [AC_MSG_RESULT([[no]]) 1765 ]) 1766 ]) 1767 ], [], 1768 [[#define __STDC_WANT_LIB_EXT1__ 1 1769#include <time.h>]]) 1770 1771 1772AC_CHECK_DECL([SOCK_NONBLOCK], [AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBLOCK is defined in a socket header])], [], 1773 [[ 1774#if defined(HAVE_SYS_TYPES_H) 1775# include <sys/types.h> 1776#endif 1777#if defined(HAVE_SYS_SOCKET_H) 1778# include <sys/socket.h> 1779#elif defined(HAVE_WINSOCK2_H) 1780# include <winsock2.h> 1781#endif 1782 ]] 1783) 1784 1785 1786AC_CHECK_DECL([[clock_gettime]], 1787 [ 1788 SAVE_LIBS="$LIBS" 1789 AC_SEARCH_LIBS([clock_gettime], [rt], 1790 [ 1791 AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime]) 1792 AS_VAR_IF([[ac_cv_search_clock_gettime]],[["none required"]], [], 1793 [ 1794 MHD_LIBDEPS="$ac_cv_search_clock_gettime $MHD_LIBDEPS" 1795 MHD_LIBDEPS_PKGCFG="$ac_cv_search_clock_gettime $MHD_LIBDEPS_PKGCFG" 1796 ]) 1797 ], [], [$MHD_LIBDEPS]) 1798 LIBS="$SAVE_LIBS" 1799 ], [], [[ 1800#include <time.h> 1801 ]]) 1802 1803AC_MSG_CHECKING([[for clock_get_time]]) 1804AC_LINK_IFELSE( 1805 [AC_LANG_PROGRAM( 1806 [[ 1807#include <mach/clock.h> 1808#include <mach/mach.h> 1809 ]], 1810 [[ 1811 clock_serv_t cs; 1812 mach_timespec_t mt; 1813 host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs); 1814 clock_get_time(cs, &mt); 1815 mach_port_deallocate(mach_task_self(), cs); 1816 ]]) 1817 ], 1818 [ 1819 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.]) 1820 AC_MSG_RESULT([[yes]]) 1821 ], 1822 [AC_MSG_RESULT([[no]]) 1823 ]) 1824 1825AC_MSG_CHECKING([[for gethrtime]]) 1826AC_LINK_IFELSE( 1827 [AC_LANG_PROGRAM( 1828 [[ 1829#ifdef HAVE_SYS_TIME_H 1830/* Solaris define gethrtime() in sys/time.h */ 1831#include <sys/time.h> 1832#endif /* HAVE_SYS_TIME_H */ 1833#ifdef HAVE_TIME_H 1834/* HP-UX define gethrtime() in time.h */ 1835#include <time.h> 1836#endif /* HAVE_TIME_H */ 1837 ]], [[hrtime_t hrt = gethrtime(); ]]) 1838 ], 1839 [ 1840 AC_DEFINE([HAVE_GETHRTIME], [1], [Define to 1 if you have `gethrtime' function.]) 1841 AC_MSG_RESULT([[yes]]) 1842 ], 1843 [AC_MSG_RESULT([[no]]) 1844 ]) 1845 1846AS_VAR_IF([ac_cv_header_time_h], ["yes"], 1847 [ 1848 AC_CACHE_CHECK([[for C11 timespec_get()]], [mhd_cv_func_timespec_get], 1849 [ 1850 AC_LINK_IFELSE( 1851 [ 1852 AC_LANG_PROGRAM( 1853 [[ 1854#include <time.h> 1855 1856#ifndef TIME_UTC 1857#error TIME_UTC must be defined to use timespec_get() 1858choke me now 1859#endif 1860 ]], 1861 [[ 1862 struct timespec ts; 1863 if (TIME_UTC != timespec_get (&ts, TIME_UTC)) 1864 return 1; 1865 ]] 1866 ) 1867 ], [[mhd_cv_func_timespec_get="yes"]], [[mhd_cv_func_timespec_get="no"]] 1868 ) 1869 ] 1870 ) 1871 AS_VAR_IF([mhd_cv_func_timespec_get], ["yes"], 1872 [AC_DEFINE([HAVE_TIMESPEC_GET], [1], [Define to 1 if you have C11 `mhd_cv_func_timespec_get' function and TIME_UTC macro.])] 1873 ) 1874 ] 1875) 1876 1877AS_VAR_SET_IF([ac_cv_func_gettimeofday], [mhd_cv_func_gettimeofday="${ac_cv_func_gettimeofday}"]) 1878AC_CACHE_CHECK([[for gettimeofday(2)]], [mhd_cv_func_gettimeofday], [ 1879 AC_LINK_IFELSE( 1880 [ 1881 AC_LANG_PROGRAM( 1882 [[ 1883#ifdef HAVE_SYS_TIME_H 1884#include <sys/time.h> 1885#endif /* HAVE_SYS_TIME_H */ 1886#ifdef HAVE_TIME_H 1887#include <time.h> 1888#endif /* HAVE_TIME_H */ 1889 ]], 1890 [[ 1891 struct timeval tv; 1892 if (0 != gettimeofday (&tv, (void*) 0)) 1893 return 1; 1894 ]] 1895 ) 1896 ], [[mhd_cv_func_gettimeofday="yes"]], [[mhd_cv_func_gettimeofday="no"]] 1897 ) 1898]) 1899AS_VAR_IF([mhd_cv_func_gettimeofday], ["yes"], 1900 [AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [Define to 1 if you have `gettimeofday' function.])] 1901) 1902 1903# IPv6 1904AC_MSG_CHECKING(for IPv6) 1905AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1906#include <stdio.h> 1907#if HAVE_NETINET_IN_H 1908#include <netinet/in.h> 1909#endif 1910#if HAVE_SYS_SOCKET_H 1911#include <sys/socket.h> 1912#endif 1913#if HAVE_WINSOCK2_H 1914#include <winsock2.h> 1915#endif 1916#if HAVE_WS2TCPIP_H 1917#include <ws2tcpip.h> 1918#endif 1919]], [[ 1920int af=AF_INET6; 1921int pf=PF_INET6; 1922struct sockaddr_in6 sa; 1923printf("%d %d %p\n", af, pf, &sa); 1924]])],[ 1925have_inet6=yes; 1926AC_DEFINE([HAVE_INET6], [1], [Provides IPv6 headers]) 1927],[ 1928have_inet6=no 1929]) 1930AC_MSG_RESULT($have_inet6) 1931 1932MHD_CHECK_FUNC([[sysconf]], [[#include <unistd.h>]], [[long a = sysconf(0); if (a) return 1;]]) 1933 1934MHD_CHECK_FUNC([[sysctl]], [[ 1935#ifdef HAVE_SYS_TYPES_H 1936#include <sys/types.h> 1937#endif 1938#ifdef HAVE_SYS_SYSCTL_H 1939#include <sys/sysctl.h> 1940#endif 1941#ifdef HAVE_STDDEF_H 1942#include <stddef.h> 1943#endif 1944 ]], [[int mib[2] = {CTL_KERN, KERN_MAXPROC}; if (sysctl(mib, 2, NULL, NULL, NULL, 0)) return 1;]] 1945) 1946 1947MHD_CHECK_FUNC([[sysctlbyname]], [[ 1948#ifdef HAVE_SYS_TYPES_H 1949#include <sys/types.h> 1950#endif 1951#ifdef HAVE_SYS_SYSCTL_H 1952#include <sys/sysctl.h> 1953#endif 1954#ifdef HAVE_STDDEF_H 1955#include <stddef.h> 1956#endif 1957 ]], [[sysctlbyname("test", NULL, NULL, NULL, 0);]] 1958) 1959 1960MHD_CHECK_FUNC([[usleep]], [[#include <unistd.h>]], [[usleep(100000);]]) 1961MHD_CHECK_FUNC([[nanosleep]], [[#include <time.h>]], [[struct timespec ts2, ts1 = {0, 0}; nanosleep(&ts1, &ts2);]]) 1962 1963HIDDEN_VISIBILITY_CFLAGS="" 1964AS_CASE(["$host"], 1965 [*-*-mingw*],[ 1966 dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport) 1967 AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern], 1968 [defines how to decorate public symbols while building]) 1969 HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden" 1970 ],[ 1971 dnl on other compilers, check if we can do -fvisibility=hidden 1972 AX_CHECK_LINK_FLAG([-fvisibility=hidden], 1973 [AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], 1974 [AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) extern], 1975 [defines how to decorate public symbols while building]) 1976 HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"])]) 1977 ]) 1978AC_SUBST(HIDDEN_VISIBILITY_CFLAGS) 1979 1980# libcurl (required for testing) 1981AC_ARG_ENABLE([curl], 1982 [AS_HELP_STRING([--disable-curl],[disable cURL based testcases])], 1983 [enable_curl=${enableval}]) 1984curl=0 1985AS_IF([test "$enable_curl" != "no"], 1986 [LIBCURL_CHECK_CONFIG([yes],[7.16.4],[enable_curl=yes], 1987 [ 1988 AS_IF([test "x$enable_curl" = "xyes"], 1989 [AC_MSG_WARN([[cURL-based tests cannot be enabled because libcurl is missing]])]) 1990 enable_curl=no 1991 ]) 1992]) 1993AS_IF([test "$enable_curl" != "no"], 1994 [ 1995# Lib cURL & cURL - OpenSSL versions 1996 AC_DEFINE([MHD_REQ_CURL_VERSION], ["7.16.4"], [required cURL version to run tests]) 1997 AC_DEFINE([MHD_REQ_CURL_OPENSSL_VERSION], ["0.9.8"], [required cURL SSL version to run tests]) 1998 AC_DEFINE([MHD_REQ_CURL_GNUTLS_VERSION], ["2.8.6"], [gnuTLS lib version - used in conjunction with cURL]) 1999 AC_DEFINE([MHD_REQ_CURL_NSS_VERSION], ["3.12.0"], [NSS lib version - used in conjunction with cURL]) 2000 ]) 2001AM_CONDITIONAL([HAVE_CURL], [test "x$enable_curl" = "xyes"]) 2002 2003mhd_have_libmagic="no" 2004SAVE_LIBS="$LIBS" 2005LIBS="$LIBS -lmagic" 2006AC_MSG_CHECKING([[for suitable libmagic]]) 2007AC_LINK_IFELSE( 2008 [AC_LANG_PROGRAM( 2009 [AC_INCLUDES_DEFAULT 2010 [ 2011#include <magic.h> 2012 ]], 2013 [[ 2014 char var_data[256]; 2015 const char *var_mime; 2016 magic_t var_magic = magic_open (MAGIC_MIME_TYPE); 2017 (void)magic_load (var_magic, NULL); 2018 var_data[0] = 0; 2019 var_mime = magic_buffer (var_magic, var_data, 1); 2020 magic_close (var_magic); 2021 ]] 2022 ) 2023 ], 2024 [ 2025 AC_DEFINE([MHD_HAVE_LIBMAGIC], [1], [Define to 1 if you have suitable libmagic.]) 2026 mhd_have_libmagic="yes" 2027 AC_MSG_RESULT([[yes]]) 2028 ], 2029 [AC_MSG_RESULT([[no]]) 2030 ] 2031) 2032LIBS="$SAVE_LIBS" 2033AM_CONDITIONAL([MHD_HAVE_LIBMAGIC], [[test "x$mhd_have_libmagic" = "xyes"]]) 2034 2035# large file support (> 4 GB) 2036AC_SYS_LARGEFILE 2037AC_FUNC_FSEEKO 2038AC_CHECK_FUNCS([lseek64 pread64 pread]) 2039 2040# check for various sendfile functions 2041AC_ARG_ENABLE([sendfile], 2042 [AS_HELP_STRING([--disable-sendfile], 2043 [disable usage of sendfile() for HTTP connections [auto]])], 2044 [], 2045 [enable_sendfile="auto"]) 2046AS_CASE([$enable_sendfile], 2047 [[auto | yes]],[[found_sendfile="no"]], 2048 [[no]],[[found_sendfile="disabled"]], 2049 [AC_MSG_ERROR([[unknown value specified: --enable-sendfile=$enable_sendfile]])] 2050) 2051AS_VAR_IF([[found_sendfile]], [["no"]], 2052 [ 2053 AC_MSG_CHECKING([[for Linux-style sendfile(2)]]) 2054 AC_LINK_IFELSE( 2055 [AC_LANG_PROGRAM( 2056 [[ 2057#include <sys/sendfile.h> 2058 2059static void empty_func(void) 2060{ 2061/* Check for declaration */ 2062 (void)sendfile; 2063} 2064/* Declare again to check form match */ 2065ssize_t sendfile(int, int, off_t*, size_t); 2066 ]], 2067 [[ 2068 int fd1=0, fd2=2; 2069 off_t o = 0; 2070 size_t s = 5; 2071 ssize_t r; 2072 r = sendfile (fd1, fd2, &o, s); 2073 if (r) 2074 empty_func(); 2075 ]] 2076 ) 2077 ], 2078 [ 2079 AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).]) 2080 found_sendfile="yes, Linux-style" 2081 AC_MSG_RESULT([[yes]]) 2082 AC_CHECK_FUNCS([sendfile64]) 2083 ], 2084 [AC_MSG_RESULT([[no]]) 2085 ] 2086 ) 2087 ] 2088) 2089AS_VAR_IF([[found_sendfile]], [["no"]], 2090 [ 2091 AC_MSG_CHECKING([[for FreeBSD-style sendfile(2)]]) 2092 AC_LINK_IFELSE( 2093 [AC_LANG_PROGRAM( 2094 [[ 2095#include <sys/types.h> 2096#include <sys/socket.h> 2097#include <sys/uio.h> 2098 2099static void empty_func(void) 2100{ 2101/* Check for declaration */ 2102 (void)sendfile; 2103} 2104/* Declare again to check form match */ 2105int sendfile(int, int, off_t, size_t, 2106 struct sf_hdtr*, off_t*, int); 2107 ]], 2108 [[ 2109 int fd1=0, fd2=1; 2110 off_t o = 0; 2111 size_t s = 5; 2112 off_t r1; 2113 int r2; 2114 r2 = sendfile (fd1, fd2, o, s, (void*)0, &r1, 0); 2115 if (r2) 2116 empty_func(); 2117 ]] 2118 ) 2119 ], 2120 [ 2121 AC_DEFINE([HAVE_FREEBSD_SENDFILE], [1], [Define to 1 if you have FreeBSD-style sendfile(2).]) 2122 found_sendfile="yes, FreeBSD-style" 2123 AC_MSG_RESULT([[yes]]) 2124 ], 2125 [AC_MSG_RESULT([[no]]) 2126 ] 2127 ) 2128 ] 2129) 2130AS_VAR_IF([[found_sendfile]], [["no"]], 2131 [ 2132 AC_MSG_CHECKING([[for Darwin-style sendfile(2)]]) 2133 AC_LINK_IFELSE( 2134 [AC_LANG_PROGRAM( 2135 [[ 2136#include <sys/types.h> 2137#include <sys/socket.h> 2138#include <sys/uio.h> 2139 2140static void empty_func(void) 2141{ 2142/* Check for declaration */ 2143 (void)sendfile; 2144} 2145/* Declare again to check form match */ 2146int sendfile(int, int, off_t, off_t*, 2147 struct sf_hdtr *, int); 2148 ]], 2149 [[ 2150 int fd=0, s=1; 2151 off_t o = 0; 2152 off_t l = 5; 2153 int r; 2154 r = sendfile (fd, s, o, &l, (void*)0, 0); 2155 if (r) 2156 empty_func(); 2157 ]] 2158 ) 2159 ], 2160 [ 2161 AC_DEFINE([HAVE_DARWIN_SENDFILE], [1], [Define to 1 if you have Darwin-style sendfile(2).]) 2162 found_sendfile="yes, Darwin-style" 2163 AC_MSG_RESULT([[yes]]) 2164 ], 2165 [AC_MSG_RESULT([[no]]) 2166 ] 2167 ) 2168 ] 2169) 2170 2171AS_VAR_IF([[found_sendfile]], [["no"]], 2172 [ 2173 AC_MSG_CHECKING([[for Solaris-style sendfile(3)]]) 2174 SAVE_LIBS="$LIBS" 2175 LIBS="$LIBS -lsendfile" 2176 AC_LINK_IFELSE( 2177 [AC_LANG_PROGRAM( 2178 [[ 2179#include <sys/types.h> 2180#include <sys/socket.h> 2181#include <sys/sendfile.h> 2182 2183static void empty_func(void) 2184{ 2185/* Check for declaration */ 2186 (void)sendfile; 2187} 2188/* Declare again to check form match */ 2189ssize_t sendfile(int out_fd, int in_fd, 2190 off_t *off, size_t len); 2191 ]], 2192 [[ 2193 int fd1=0, fd2=1; 2194 off_t o = 0; 2195 size_t l = 5; 2196 ssize_t r; 2197 r = sendfile (fd1, fd2, &o, l); 2198 if (r) 2199 empty_func(); 2200 ]] 2201 ) 2202 ], 2203 [ 2204 AC_DEFINE([HAVE_SOLARIS_SENDFILE], [1], [Define to 1 if you have Solaris-style sendfile(3).]) 2205 found_sendfile="yes, Solaris-style" 2206 MHD_LIBDEPS="-lsendfile $MHD_LIBDEPS" 2207 MHD_LIBDEPS_PKGCFG="-lsendfile $MHD_LIBDEPS_PKGCFG" 2208 AC_MSG_RESULT([[yes]]) 2209 AC_CHECK_FUNCS([sendfile64]) 2210 ], 2211 [AC_MSG_RESULT([[no]]) 2212 ] 2213 ) 2214 LIBS="$SAVE_LIBS" 2215 ] 2216) 2217AS_IF([[test "x$found_sendfile" = "xno" && test "x$enable_sendfile" = "xyes"]], 2218 [AC_MSG_ERROR([[sendfile() usage was requested by configure parameter, but no usable sendfile() function is detected]])] 2219) 2220 2221# optional: have error messages ? 2222AC_MSG_CHECKING([[whether to generate error messages]]) 2223AC_ARG_ENABLE([messages], 2224 [AS_HELP_STRING([--disable-messages], 2225 [disable MHD error messages])], 2226 [enable_messages=${enableval}], 2227 [enable_messages=yes]) 2228AS_IF([[test "x$enable_messages" = "xyes"]], 2229 [ AC_DEFINE([HAVE_MESSAGES],[1],[Define to 1 to enable support for error messages.]) ], 2230 [[ enable_messages=no ]]) 2231AC_MSG_RESULT([[$enable_messages]]) 2232 2233 2234# optional: have postprocessor? 2235AC_MSG_CHECKING([[whether to enable postprocessor]]) 2236AC_ARG_ENABLE([postprocessor], 2237 [AS_HELP_STRING([--disable-postprocessor], 2238 [disable MHD PostProcessor functionality])], 2239 [enable_postprocessor=${enableval}], 2240 [enable_postprocessor=yes]) 2241AS_IF([[test "x$enable_postprocessor" != "xno"]], 2242 [ enable_postprocessor=yes 2243 AC_DEFINE([HAVE_POSTPROCESSOR],[1],[Define to 1 if libmicrohttpd is compiled with postprocessor support.]) ]) 2244AM_CONDITIONAL([HAVE_POSTPROCESSOR], [test "x$enable_postprocessor" != "xno"]) 2245AC_MSG_RESULT([[$enable_postprocessor]]) 2246 2247 2248# optional: have zzuf, socat? 2249AC_CHECK_PROG([have_zzuf],[zzuf], [yes], [no]) 2250AC_CHECK_PROG([have_socat],[socat], [yes], [no]) 2251AM_CONDITIONAL([HAVE_ZZUF], [test "x$have_zzuf" = "xyes"]) 2252AM_CONDITIONAL([HAVE_SOCAT], [test "x$have_socat" = "xyes"]) 2253 2254have_gnutls=no 2255have_gnutls_sni=no 2256have_gcrypt=no 2257AS_UNSET([GNUTLS_CPPFLAGS]) 2258AS_UNSET([GNUTLS_LDFLAGS]) 2259 2260# optional: HTTPS support. Enabled by default 2261AC_ARG_ENABLE([https], 2262 [AS_HELP_STRING([--enable-https], 2263 [enable HTTPS support (yes, no, auto)[auto]])], 2264 [enable_https=${enableval}]) 2265AS_IF([test "x$enable_https" != "xno"],[ 2266# 2267# Next block is large unindented block 2268# 2269 2270# gnutls 2271have_gnutls_pkgcfg=no 2272AC_MSG_CHECKING([[how to find GnuTLS library]]) 2273AC_ARG_WITH([[gnutls]], 2274 [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)])], 2275 [ 2276 AS_CASE([$with_gnutls], 2277 [no],[ 2278 AC_MSG_RESULT([[GnuTLS disabled]]) 2279 AS_UNSET([GNUTLS_CPPFLAGS]) 2280 AS_UNSET([GNUTLS_CFLAGS]) 2281 AS_UNSET([GNUTLS_LDFLAGS]) 2282 AS_UNSET([GNUTLS_LIBS]) 2283 ], 2284 [yes],[ 2285 AC_MSG_RESULT([[automatically, forced]]) 2286 ], 2287 [ 2288 AC_MSG_RESULT([[-I$with_gnutls/include -L$with_gnutls/lib -lgnutls]]) 2289 SAVE_LDFLAGS="$LDFLAGS" 2290 SAVE_CPPFLAGS="$CPPFLAGS" 2291 SAVE_CFLAGS="$CFLAGS" 2292 SAVE_LIBS="$LIBS" 2293 LDFLAGS="-L$with_gnutls/lib $LDFLAGS" 2294 CPPFLAGS="-I$with_gnutls/include $CPPFLAGS" 2295 have_gnutls_pkgcfg=no 2296 AC_CHECK_HEADERS([gnutls/gnutls.h], 2297 [AC_CHECK_LIB([gnutls], [gnutls_priority_set], 2298 [ 2299 GNUTLS_CPPFLAGS="-I$with_gnutls/include" 2300 GNUTLS_LDFLAGS="-L$with_gnutls/lib" 2301 GNUTLS_LIBS="-lgnutls" 2302 have_gnutls=yes 2303 ])], [], [AC_INCLUDES_DEFAULT]) 2304 AS_IF([test "x$have_gnutls" != "xyes"], [AC_MSG_ERROR([can't find usable libgnutls at specified prefix $with_gnutls])]) 2305 CPPFLAGS="$SAVE_CPPFLAGS" 2306 CFLAGS="$SAVE_CFLAGS" 2307 LDFLAGS="$SAVE_LDFLAGS" 2308 LIBS="$SAVE_LIBS" 2309 ]) 2310 ], 2311 [AC_MSG_RESULT([[automatically]]) 2312 ]) 2313 2314AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"], 2315 [ 2316 AC_CACHE_CHECK([[whether to add pkg-config special search directories]], [mhd_cv_pkgconf_add_dirs], 2317 [ 2318 AS_IF([[test "x$host_os" = "xsolaris2.11" && test "x$cross_compiling" = "xno"]], 2319 [ 2320 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2321char size_chk[7-sizeof(char*)]; 2322#if defined(_LP64) || defined(__LP64__) || defined(__x86_64) || defined(__x86_64__) 2323#error This is 64-bit target. 2324choke me now 2325#endif 2326#if defined(__amd64) || defined(__amd64__) || defined(__sparcv9) || defined(__sparc_v9__) 2327#error This is 64-bit target. 2328choke me now 2329#endif 2330 ]], [[]] 2331 ) 2332 ], 2333 [ 2334 mhd_cv_pkgconf_add_dirs='/usr/lib/pkgconfig/gnutls-3' 2335 ], 2336 [ 2337 AS_IF([[test "x$host_cpu" = "xx86_64" || test "x$host_cpu" = "xi386"]], 2338 [[mhd_cv_pkgconf_add_dirs='/usr/lib/amd64/pkgconfig/gnutls-3:/usr/lib/amd64/pkgconfig']], 2339 [[test "x$host_cpu" = "xsparc"]], 2340 [[mhd_cv_pkgconf_add_dirs='/usr/lib/sparkv9/pkgconfig/gnutls-3:/usr/lib/sparkv9/pkgconfig']], 2341 [[mhd_cv_pkgconf_add_dirs='/usr/lib/64/pkgconfig/gnutls-3:/usr/lib/64/pkgconfig']] 2342 ) 2343 ] 2344 ) 2345 ], 2346 [[ mhd_cv_pkgconf_add_dirs='no' ]] 2347 ) 2348 ] 2349 ) 2350 AS_IF([[test "x$mhd_cv_pkgconf_add_dirs" != "xno"]], 2351 [ 2352 test "x$PKG_CONFIG_PATH" = "x" || PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${PATH_SEPARATOR}" 2353 PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${mhd_cv_pkgconf_add_dirs}" 2354 export PKG_CONFIG_PATH 2355 ] 2356 ) 2357 PKG_CHECK_MODULES(GNUTLS, [[gnutls]], 2358 [ 2359 have_gnutls_pkgcfg='yes' 2360 SAVE_CPPFLAGS="$CPPFLAGS" 2361 SAVE_CFLAGS="$CFLAGS" 2362 SAVE_LDFLAGS="$LDFLAGS" 2363 SAVE_LIBS="$LIBS" 2364 CFLAGS="$GNUTLS_CFLAGS $CFLAGS" 2365 LIBS="$LIBS $GNUTLS_LIBS" 2366 AC_MSG_CHECKING([[whether GnuTLS is usable]]) 2367 AC_LINK_IFELSE([ 2368 AC_LANG_PROGRAM([[ 2369#include <gnutls/gnutls.h> 2370 ]], [[ 2371 gnutls_session_t session; 2372 gnutls_priority_t priorities; 2373 gnutls_global_init(); 2374 gnutls_priority_init(&priorities, "NORMAL", NULL); 2375 gnutls_init(&session, GNUTLS_SERVER); 2376 gnutls_priority_set(session, priorities); 2377 ]])], 2378 [ 2379 AC_MSG_RESULT([[yes]]) 2380 have_gnutls=yes 2381 # GNUTLS_CFLAGS is actually CPPFLAGS 2382 GNUTLS_CPPFLAGS="$GNUTLS_CFLAGS" 2383 # GNUTLS_CFLAGS is combination of LDFLAGS and LIBS 2384 GNUTLS_LDFLAGS="$GNUTLS_LIBS" 2385 ], 2386 [ 2387 AC_MSG_RESULT([[no]]) 2388 have_gnutls=no 2389 ]) 2390 2391 AS_IF([test "x$have_gnutls" != "xyes"], 2392 [ 2393 AC_MSG_WARN([pkg-config reports that GnuTLS is present, but GnuTLS can't be used]) 2394 AS_UNSET([GNUTLS_CPPFLAGS]) 2395 AS_UNSET([GNUTLS_CFLAGS]) 2396 AS_UNSET([GNUTLS_LDFLAGS]) 2397 AS_UNSET([GNUTLS_LIBS]) 2398 ] 2399 ) 2400 CPPFLAGS="$SAVE_CPPFLAGS" 2401 CFLAGS="$SAVE_CFLAGS" 2402 LDFLAGS="$SAVE_LDFLAGS" 2403 LIBS="$SAVE_LIBS" 2404 ], 2405 [ 2406 # check for GnuTLS at default paths 2407 have_gnutls_pkgcfg='no' 2408 AC_CHECK_HEADERS([gnutls/gnutls.h], 2409 [AC_CHECK_LIB([gnutls], [gnutls_priority_set], 2410 [ 2411 GNUTLS_LIBS="-lgnutls" 2412 have_gnutls=yes 2413 ])], [], [AC_INCLUDES_DEFAULT]) 2414 ]) 2415 ]) 2416 2417have_gcrypt='unknown' 2418AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"], 2419 [ 2420 AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no]) 2421 AS_IF([[test "x$have_gcrypt" = "xyes"]], 2422 [ 2423 SAVE_CPPFLAGS="$CPPFLAGS" 2424 SAVE_CFLAGS="$CFLAGS" 2425 SAVE_LIBS="$LIBS" 2426 SAVE_LDFLAGS="$LDFLAGS" 2427 CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS" 2428 # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both 2429 CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS" 2430 AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT]) 2431 # Check for GnuTLS with gcrypt flags 2432 LDFLAGS="$LDFLAGS $LIBGCRYPT_LIBS" 2433 # A bit of hack: unset cache variable to force recheck 2434 AS_UNSET([ac_cv_header_gnutls_gnutls_h]) 2435 AC_CHECK_HEADERS([gnutls/gnutls.h], 2436 [AS_UNSET([ac_cv_lib_gnutls_gnutls_priority_set]) # A bit of hack: unset cache variable to force recheck 2437 AC_CHECK_LIB([gnutls], [gnutls_priority_set], 2438 [ 2439 GNUTLS_CPPFLAGS="$LIBGCRYPT_CFLAGS" 2440 GNUTLS_CFLAGS="$LIBGCRYPT_CFLAGS" 2441 GNUTLS_LDFLAGS="$LIBGCRYPT_LIBS" 2442 GNUTLS_LIBS="-lgnutls" 2443 have_gnutls=yes 2444 ])], [], [AC_INCLUDES_DEFAULT]) 2445 CPPFLAGS="$SAVE_CPPFLAGS" 2446 CFLAGS="$SAVE_CFLAGS" 2447 LDFLAGS="$SAVE_LDFLAGS" 2448 LIBS="$SAVE_LIBS" 2449 ] 2450 ) 2451 ] 2452) 2453AS_IF([test "x$have_gnutls" != "xyes" && test "x$with_gnutls" = "xyes"], 2454 [AC_MSG_ERROR([[can't find usable libgnutls]])]) 2455 2456 AS_IF([test "x$have_gnutls" = "xyes"], 2457 [ 2458 SAVE_CPPFLAGS="$CPPFLAGS" 2459 SAVE_CFLAGS="$CFLAGS" 2460 SAVE_LDFLAGS="$LDFLAGS" 2461 SAVE_LIBS="$LIBS" 2462 CPPFLAGS="$GNUTLS_CPPFLAGS $CPPFLAGS" 2463 CFLAGS="$GNUTLS_CFLAGS $CFLAGS" 2464 LDFLAGS="$GNUTLS_LDFLAGS $LDFLAGS" 2465 LIBS="$LIBS $GNUTLS_LIBS" 2466 AC_MSG_CHECKING([[for gnutls_privkey_import_x509_raw()]]) 2467 AC_LINK_IFELSE([ 2468 AC_LANG_PROGRAM([[ 2469#include <gnutls/gnutls.h> 2470#include <gnutls/abstract.h> 2471 ]], [[ 2472 gnutls_datum_t data; 2473 gnutls_privkey_t key = 0; 2474#ifndef gnutls_load_file 2475 (void)gnutls_load_file; /* Check for declaration. */ 2476#endif 2477#ifndef gnutls_privkey_import_x509_raw 2478 (void)gnutls_privkey_import_x509_raw; /* Check for declaration. */ 2479#endif 2480 gnutls_load_file("key.pem", &data); 2481 gnutls_privkey_import_x509_raw(key, &data, GNUTLS_X509_FMT_PEM, NULL, 0); 2482 gnutls_free(data.data); 2483 ]])], [[have_gnutls_sni=yes]], [[have_gnutls_sni=no]]) 2484 AC_MSG_RESULT([[$have_gnutls_sni]]) 2485 AC_CACHE_CHECK([[whether GnuTLS require libgcrypt initialisaion]], [mhd_cv_gcrypt_required], 2486 [ 2487 AC_COMPILE_IFELSE( 2488 [ 2489 AC_LANG_PROGRAM( 2490 [ 2491#include <gnutls/gnutls.h> 2492 ], 2493 [ 2494#if !defined(GNUTLS_VERSION_NUMBER) || GNUTLS_VERSION_NUMBER+0 <= 0x020c14 2495#error Old versions of GnuTLS require libgcript initialisaion 2496choke me now 2497#endif 2498 ] 2499 ) 2500 ], 2501 [[mhd_cv_gcrypt_required='no']], [[mhd_cv_gcrypt_required='yes']] 2502 ) 2503 ] 2504 ) 2505 CPPFLAGS="$SAVE_CPPFLAGS" 2506 CFLAGS="$SAVE_CFLAGS" 2507 LDFLAGS="$SAVE_LDFLAGS" 2508 LIBS="$SAVE_LIBS" 2509 ], 2510 [ 2511 AS_UNSET([GNUTLS_CPPFLAGS]) 2512 AS_UNSET([GNUTLS_LDFLAGS]) 2513 ] 2514 ) 2515 2516 AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" = "xunknown"]], 2517 [ 2518 AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no]) 2519 AS_IF([[test "x$have_gcrypt" = "xyes"]], 2520 [ 2521 SAVE_CPPFLAGS="$CPPFLAGS" 2522 SAVE_CFLAGS="$CFLAGS" 2523 CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS" 2524 # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both 2525 CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS" 2526 AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT]) 2527 CPPFLAGS="$SAVE_CPPFLAGS" 2528 CFLAGS="$SAVE_CFLAGS" 2529 ] 2530 ) 2531 ] 2532 ) 2533 2534 AS_UNSET([[crypt_missing]]) 2535 AS_IF([[test "x$have_gnutls" = "xyes"]], 2536 [ 2537 AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" != "xyes"]], 2538 [ 2539 crypt_missing="required libgcrypt" 2540 AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])]) 2541 enable_https=no 2542 MSG_HTTPS="no (lacking $crypt_missing)" 2543 AS_UNSET([LIBGCRYPT_CFLAGS]) 2544 AS_UNSET([LIBGCRYPT_LIBS]) 2545 AS_UNSET([GNUTLS_CPPFLAGS]) 2546 AS_UNSET([GNUTLS_CFLAGS]) 2547 AS_UNSET([GNUTLS_LDFLAGS]) 2548 AS_UNSET([GNUTLS_LIBS]) 2549 ], 2550 [ 2551 AC_DEFINE([[HTTPS_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTPS support.]) 2552 enable_https=yes 2553 AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]], 2554 [ 2555 MSG_HTTPS="yes (using libgnutls and libgcrypt)" 2556 MHD_TLS_LIB_CPPFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CPPFLAGS" 2557 MHD_TLS_LIB_CFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CFLAGS" 2558 MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS" 2559 MHD_TLS_LIBDEPS="$GNUTLS_LIBS $LIBGCRYPT_LIBS" 2560 AC_DEFINE([[MHD_HTTPS_REQUIRE_GCRYPT]], [[1]], [Define to `1' if HTTPS require initialisation of libgcrypt]) 2561 ], 2562 [ 2563 MSG_HTTPS="yes (using libgnutls)" 2564 AS_UNSET([LIBGCRYPT_CFLAGS]) 2565 AS_UNSET([LIBGCRYPT_LIBS]) 2566 MHD_TLS_LIB_CPPFLAGS="$GNUTLS_CPPFLAGS" 2567 MHD_TLS_LIB_CFLAGS="$GNUTLS_CFLAGS" 2568 MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS" 2569 MHD_TLS_LIBDEPS="$GNUTLS_LIBS" 2570 ] 2571 ) 2572 AS_IF([[ test "x$have_gnutls_pkgcfg" = "xyes" ]], 2573 [ # remove GnuTLS from private libs in .pc file as it defined in Requires.private 2574 MHD_REQ_PRIVATE='gnutls' 2575 AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]], 2576 [[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]] 2577 ) 2578 ], 2579 [ 2580 MHD_REQ_PRIVATE='' 2581 AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]], 2582 [[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]] 2583 ) 2584 MHD_LIBDEPS_PKGCFG="$GNUTLS_LIBS $MHD_LIBDEPS_PKGCFG" 2585 ]) 2586 ] 2587 ) 2588 ], 2589 [ 2590 crypt_missing="libgnutls" 2591 AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])]) 2592 enable_https=no 2593 MSG_HTTPS="no (lacking $crypt_missing)" 2594 AS_UNSET([LIBGCRYPT_CFLAGS]) 2595 AS_UNSET([LIBGCRYPT_LIBS]) 2596 AS_UNSET([GNUTLS_CPPFLAGS]) 2597 AS_UNSET([GNUTLS_CFLAGS]) 2598 AS_UNSET([GNUTLS_LDFLAGS]) 2599 AS_UNSET([GNUTLS_LIBS]) 2600 ] 2601 ) 2602],[ 2603 MSG_HTTPS="no (disabled)" 2604]) 2605 2606# 2607# End of large unindented block 2608# 2609 2610 2611AC_MSG_CHECKING(whether to support HTTPS) 2612AC_MSG_RESULT([$MSG_HTTPS]) 2613 2614AM_CONDITIONAL([HAVE_GNUTLS], [[test "x$have_gnutls" = "xyes"]]) 2615AM_CONDITIONAL([HAVE_GNUTLS_SNI], [[test "x$have_gnutls_sni" = "xyes"]]) 2616AM_CONDITIONAL([ENABLE_HTTPS], [test "x$enable_https" = "xyes"]) 2617AM_CONDITIONAL([HTTPS_REQUIRE_GCRYPT], [[test "x$enable_https" = "xyes" && test "x$mhd_cv_gcrypt_required" = "xyes"]]) 2618AC_SUBST([GNUTLS_CPPFLAGS]) 2619AC_SUBST([GNUTLS_CFLAGS]) 2620AC_SUBST([GNUTLS_LDFLAGS]) 2621AC_SUBST([GNUTLS_LIBS]) 2622 2623AS_VAR_IF([have_gnutls], ["yes"], 2624 [ 2625 AC_CACHE_CHECK([for GnuTLS quirks], [mhd_cv_gnutls_mthread_broken], 2626 [ 2627 mhd_cv_gnutls_mthread_broken="no" 2628 AS_IF([test -r /etc/redhat-release], 2629 [ 2630 AS_IF([$FGREP ' release 6.' /etc/redhat-release >/dev/null || $FGREP '(Santiago)' /etc/redhat-release >/dev/null], 2631 [mhd_cv_gnutls_mthread_broken="found"], 2632 ) 2633 ] 2634 ) 2635 AS_VAR_IF([mhd_cv_gnutls_mthread_broken], ["no"], 2636 [ 2637 AS_IF([command -v rpm >/dev/null], 2638 [ 2639 AS_IF([test r`rpm -E '%{rhel} 2>/dev/null'` = "r6"], 2640 [mhd_cv_gnutls_mthread_broken="found"], 2641 ) 2642 ] 2643 ) 2644 ] 2645 ) 2646 ] 2647 ) 2648 AC_CACHE_CHECK([for gnutls-cli binary], [mhd_cv_gnutls_cli], 2649 [ 2650 mhd_cv_gnutls_cli="no" 2651 AS_IF([command -v gnutls-cli >/dev/null 2>&1], 2652 [AS_IF([AC_RUN_LOG([gnutls-cli --version >&2])], [mhd_cv_gnutls_cli="yes"])] 2653 ) 2654 ] 2655 ) 2656 ] 2657) 2658AM_CONDITIONAL([HAVE_GNUTLS_MTHREAD_BROKEN], [[test "x${mhd_cv_gnutls_mthread_broken}" = "xfound"]]) 2659AM_CONDITIONAL([USE_UPGRADE_TLS_TESTS], [[test "x${mhd_cv_gnutls_mthread_broken}" = "xno" || test "x${mhd_cv_gnutls_cli}" == "xyes"]]) 2660 2661# optional: HTTP Basic Auth support. Enabled by default 2662AC_MSG_CHECKING([[whether to support HTTP basic authentication]]) 2663AC_ARG_ENABLE([bauth], 2664 AS_HELP_STRING([--disable-bauth], 2665 [disable HTTP basic Auth support]), 2666 [enable_bauth=${enableval}], 2667 [enable_bauth=yes]) 2668AS_IF([[test "x$enable_bauth" != "xno"]], 2669 [ enable_bauth=yes 2670 AC_DEFINE([BAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with basic Auth support.]) ]) 2671AM_CONDITIONAL([ENABLE_BAUTH], [test "x$enable_bauth" != "xno"]) 2672AC_MSG_RESULT([[$enable_bauth]]) 2673 2674# optional: HTTP Digest Auth support. Enabled by default 2675AC_MSG_CHECKING([[whether to support HTTP digest authentication]]) 2676AC_ARG_ENABLE([dauth], 2677 AS_HELP_STRING([--disable-dauth], 2678 [disable HTTP basic and digest Auth support]), 2679 [enable_dauth=${enableval}], 2680 [enable_dauth=yes]) 2681AS_IF([[test "x$enable_dauth" != "xno"]], 2682 [ enable_dauth=yes 2683 AC_DEFINE([DAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with digest Auth support.]) ]) 2684AM_CONDITIONAL([ENABLE_DAUTH], [test "x$enable_dauth" != "xno"]) 2685AC_MSG_RESULT([[$enable_dauth]]) 2686 2687# optional: HTTP "Upgrade" support. Enabled by default 2688AC_MSG_CHECKING([[whether to support HTTP "Upgrade"]]) 2689AC_ARG_ENABLE([[httpupgrade]], 2690 AS_HELP_STRING([[--disable-httpupgrade]], 2691 [disable HTTP "Upgrade" support]), 2692 [AS_VAR_IF([[enable_httpupgrade]],[["no"]],[],[[enable_httpupgrade='yes']])], 2693 [[enable_httpupgrade='yes']]) 2694AS_VAR_IF([[enable_httpupgrade]],[["yes"]], 2695 [ 2696 AC_DEFINE([[UPGRADE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTP Upgrade support.]) ]) 2697AM_CONDITIONAL([ENABLE_UPGRADE], [[test "x$enable_httpupgrade" = "xyes"]]) 2698AC_MSG_RESULT([[$enable_httpupgrade]]) 2699 2700AC_CACHE_CHECK([[for calloc()]], [[mhd_cv_have_func_calloc]], 2701 [ 2702 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2703#include <stdlib.h> 2704 ]],[[void * ptr = calloc(1, 2); if (ptr) return 1;]]) 2705 ], 2706 [[mhd_cv_have_func_calloc='yes']], 2707 [[mhd_cv_have_func_calloc='no']] 2708 ) 2709 ] 2710) 2711AS_VAR_IF([[mhd_cv_have_func_calloc]], [["yes"]], 2712 [AC_DEFINE([[HAVE_CALLOC]], [[1]], [Define to 1 if you have the usable `calloc' function.])]) 2713 2714# Some systems have IPv6 disabled in kernel at run-time 2715AS_IF([[test "x${have_inet6}" = "xyes" && test "x${cross_compiling}" = "xno"]], 2716 [ 2717 AC_CACHE_CHECK([whether IPv6 could be used for testing],[mhd_cv_ipv6_for_testing], 2718 [ 2719 AC_RUN_IFELSE( 2720 [ 2721 AC_LANG_SOURCE([[ 2722#ifdef HAVE_UNISTD_H 2723#include <unistd.h> 2724#endif 2725#ifdef HAVE_SYS_TYPES_H 2726#include <sys/types.h> 2727#endif 2728#ifdef HAVE_SYS_SOCKET_H 2729#include <sys/socket.h> 2730#endif 2731#ifdef HAVE_WINSOCK2_H 2732#include <winsock2.h> 2733#endif 2734#ifdef HAVE_WS2TCPIP_H 2735#include <ws2tcpip.h> 2736#endif 2737#ifdef HAVE_NETINET_IN_H 2738#include <netinet/in.h> 2739#endif 2740#ifdef HAVE_NETINET_IP_H 2741#include <netinet/ip.h> 2742#endif 2743#ifdef HAVE_ARPA_INET_H 2744#include <arpa/inet.h> 2745#endif 2746#ifdef HAVE_NETINET_TCP_H 2747#include <netinet/tcp.h> 2748#endif 2749 2750static void zr_mem(void *ptr, socklen_t size) 2751{ char *mem = ptr; while(size--) {mem[0] = 0; mem++;} } 2752 2753int main(void) 2754{ 2755 int ret = 30; 2756 struct sockaddr_in6 sa; 2757#if !defined(_WIN32) || defined(__CYGWIN__) 2758 int sckt; 2759 const int invld_sckt = -1; 2760#else 2761 SOCKET sckt; 2762 const SOCKET invld_sckt = INVALID_SOCKET; 2763 WSADATA wsa_data; 2764 2765 WSAStartup(MAKEWORD(2, 2), &wsa_data); 2766#endif 2767 zr_mem(&sa, sizeof(sa)); 2768 sa.sin6_family = AF_INET6; 2769 sa.sin6_port = 0; 2770 sa.sin6_addr = in6addr_loopback; 2771#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN 2772 sa.sin6_len = sizeof(sa); 2773#endif 2774 sckt = socket (PF_INET6, SOCK_STREAM, 0); 2775 if (invld_sckt != sckt) 2776 { 2777 if (0 == bind (sckt, (struct sockaddr *)&sa, sizeof(sa))) 2778 { 2779 if (0 == listen (sckt, 1)) 2780 ret = 0; 2781 else 2782 ret = 1; /* listen() failed */ 2783 } else ret = 2; /* bind() failed */ 2784#if !defined(_WIN32) || defined(__CYGWIN__) 2785 close (sckt); 2786#else 2787 closesocket (sckt); 2788#endif 2789 } else ret = 3; /* socket() failed */ 2790#if defined(_WIN32) && !defined(__CYGWIN__) 2791 WSACleanup(); 2792#endif 2793 return ret; 2794} 2795 ]]) 2796 ], [[mhd_cv_ipv6_for_testing="yes"]], [[mhd_cv_ipv6_for_testing="no"]], [[mhd_cv_ipv6_for_testing="no"]] 2797 ) 2798 ] 2799 ) 2800 ] 2801) 2802AS_VAR_IF([mhd_cv_ipv6_for_testing],["yes"], 2803 [AC_DEFINE([[USE_IPV6_TESTING]], [[1]], [Define to 1 if your kernel supports IPv6 and IPv6 is enabled and useful for testing.])] 2804) 2805 2806 2807# Check for fork() and waitpid(). They are used for tests. 2808AC_MSG_CHECKING([[for fork()]]) 2809mhd_have_fork_waitpid='no' 2810AC_LINK_IFELSE( 2811 [ 2812 AC_LANG_PROGRAM( 2813 [[ 2814#ifdef HAVE_SYS_TYPES_H 2815#include <sys/types.h> 2816#endif 2817#ifdef HAVE_UNISTD_H 2818#include <unistd.h> 2819#endif 2820 ]], [[ 2821 pid_t p = fork (); 2822 if (0 == p) 2823 return 1; 2824 ]]) 2825 ], [ 2826 AC_DEFINE([[HAVE_FORK]], [[1]], [Define to 1 if you have the usable `fork' function.]) 2827 AC_MSG_RESULT([[yes]]) 2828 2829 AC_MSG_CHECKING([[for waitpid()]]) 2830 AC_LINK_IFELSE( 2831 [ 2832 AC_LANG_PROGRAM( 2833 [[ 2834#include <sys/wait.h> 2835 ]], [[ 2836 pid_t p = fork (); 2837 if (0 == p) 2838 return 1; 2839 waitpid (p, (void*)0, 0) 2840 ]]) 2841 ], [ 2842 AC_DEFINE([[HAVE_WAITPID]], [[1]], [Define to 1 if you have the usable `waitpid' function.]) 2843 AC_MSG_RESULT([[yes]]) 2844 mhd_have_fork_waitpid='yes' 2845 ],[ 2846 AC_MSG_RESULT([[no]]) 2847 ]) 2848],[ 2849 AC_MSG_RESULT([[no]]) 2850]) 2851 2852AM_CONDITIONAL([HAVE_FORK_WAITPID], [test "x$mhd_have_fork_waitpid" = "xyes"]) 2853 2854# gcov compilation 2855AC_MSG_CHECKING(whether to compile with support for code coverage analysis) 2856AC_ARG_ENABLE([coverage], 2857 AS_HELP_STRING([--enable-coverage], 2858 [compile the library with code coverage support]), 2859 [use_gcov=${enableval}], 2860 [use_gcov=no]) 2861AC_MSG_RESULT($use_gcov) 2862AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"]) 2863 2864AX_COUNT_CPUS 2865AC_MSG_CHECKING([for number of CPU cores to use in tests]) 2866AS_VAR_IF([enable_heavy_tests], ["yes"], 2867 [ 2868 # Enable usage of many core if heavy tests are enabled 2869 AS_IF([[test "$CPU_COUNT" -gt "32"]], [[CPU_COUNT="32"]])dnl Limit resource usage 2870 ], 2871 [ 2872 # Limit usage to just a few cores if heavy tests are not enabled 2873 AS_IF([[test "$CPU_COUNT" -gt "6"]], [[CPU_COUNT="6"]]) 2874 AS_IF([[test "$CPU_COUNT" -lt "2"]], [[CPU_COUNT="2"]]) 2875 ] 2876) 2877AC_MSG_RESULT([$CPU_COUNT]) 2878 2879 2880AC_MSG_CHECKING([[whether to enable debug asserts]]) 2881AC_ARG_ENABLE([[asserts]], 2882 AS_HELP_STRING([[--enable-asserts]], 2883 [enable test build with debug asserts]), 2884 [], [[enable_asserts='no']]) 2885AS_CASE([[$enable_asserts]], [[yes]], [[:]], [[no]], [[:]], [[enable_asserts='no']]) 2886AC_MSG_RESULT([[$enable_asserts]]) 2887 2888AS_VAR_IF([[enable_asserts]], [["yes"]], 2889 [ 2890 AC_DEFINE([[_DEBUG]], [[1]], [Define to use debug asserts.]) 2891 [mhd_assert_test_prg="#include <assert.h> 2892 int pos_val(void) {return 5;} 2893 int neg_val(void) {return -5;} 2894 int main(void) 2895 { int pos_var = pos_val(), neg_var = neg_val(); 2896 assert(neg_var > pos_var); /* Must trigger assert. */ 2897 (void)pos_var; (void)neg_var; 2898 return 0; } 2899 "] 2900 AC_CACHE_CHECK([[whether system assert() is available]], [mhd_cv_sys_assert_avail], 2901 [ 2902 AC_LINK_IFELSE([AC_LANG_SOURCE([[$mhd_assert_test_prg]])], 2903 [[mhd_cv_sys_assert_avail='yes']], 2904 [[mhd_cv_sys_assert_avail='no']]) 2905 ] 2906 ) 2907 AS_VAR_IF([[mhd_cv_sys_assert_avail]], [["no"]], [], 2908 [AC_DEFINE([[HAVE_ASSERT]], [[1]], [Define if you have usable assert() and assert.h])]) 2909 AS_UNSET([mhd_assert_test_prg]) 2910 ], 2911 [AC_DEFINE([[NDEBUG]], [[1]], [Define to disable usage of debug asserts.])] 2912) 2913 2914AS_UNSET([enabled_sanitizers]) 2915AM_TESTS_ENVIRONMENT="" 2916AM_ASAN_OPTIONS="" 2917AM_UBSAN_OPTIONS="" 2918AM_LSAN_OPTIONS="" 2919AS_UNSET([ASAN_OPTIONS]) 2920AS_UNSET([UBSAN_OPTIONS]) 2921AS_UNSET([LSAN_OPTIONS]) 2922 2923AC_MSG_CHECKING([whether to enable run-time sanitizers]) 2924AC_ARG_ENABLE([sanitizers], 2925 [AS_HELP_STRING([[--enable-sanitizers[=address,undefined,leak,user-poison]]], 2926 [enable run-time sanitizers, specify the list of types of sanitizers to enable or ] 2927 [leave the list empty to enable all suppoted and availabe sanitizers])], 2928 [], [enable_sanitizers=no]) 2929AS_IF([test "x${enable_sanitizers}" = "x"], [enable_sanitizers="auto"]) 2930AS_VAR_IF([enable_sanitizers], ["yes"], [enable_sanitizers="auto"]) 2931AS_IF([test "x${enable_sanitizers}" = "xno"], 2932 [ 2933 enable_sanitizers="no" 2934 enable_san_address="no" 2935 enable_san_undef="no" 2936 enable_san_leak="no" 2937 enable_san_upoison="no" 2938 ], 2939 [test "x${enable_sanitizers}" = "xauto"], 2940 [ 2941 enable_san_address="auto" 2942 enable_san_undef="auto" 2943 enable_san_leak="auto" 2944 enable_san_upoison="auto" 2945 ], 2946 [ 2947 AS_UNSET([san]) 2948 enable_san_address="no" 2949 enable_san_undef="no" 2950 enable_san_leak="no" 2951 enable_san_upoison="no" 2952 for san in `AS_ECHO([${enable_sanitizers}]) | tr ',' ' '` 2953 do 2954 AS_CASE([$san], 2955 [address], [enable_san_address="yes"], 2956 [undefined], [enable_san_undef="yes"], 2957 [leak], [enable_san_leak="yes"], 2958 [user-poison|user_poison], [enable_san_upoison="yes"], 2959 [no|yes|auto], [AC_MSG_ERROR(["$san" cannot be used with other options for --enable-sanitizers=])], 2960 [AC_MSG_ERROR([Unknown parameter "$san" for --enable-sanitizers=])] 2961 ) 2962 done 2963 AS_IF([test "x${enable_san_upoison}" = "xyes" && test "x${enable_san_address}" = "xno"], 2964 [AC_MSG_ERROR([User memory poisoning cannot be used without address sanitizer])] 2965 ) 2966 enable_sanitizers="selected" 2967 ] 2968) 2969AS_CASE([${enable_sanitizers}], 2970 [selected], [AC_MSG_RESULT([selected])], 2971 [auto], [AC_MSG_RESULT([yes, detect and use supported sanitizers])], 2972 [AC_MSG_RESULT([no])] 2973) 2974AS_VAR_IF([enable_sanitizers], ["no"], [:], 2975 [ 2976 AS_UNSET([san_FLAGS]) # the sanitizer flags to be added to both CFLAGS and LDFLAGS 2977 AS_UNSET([san_CFLAGS]) # the sanitizer flags to be added to CFLAGS 2978 saved_CFLAGS="$CFLAGS" 2979 AC_CACHE_CHECK([whether '-fsanitize=' works for $CC], 2980 [mhd_cv_cc_sanitizer_works], 2981 [ 2982 CFLAGS="${saved_CFLAGS} -fsanitize=wrongFeatureName" 2983 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], 2984 [mhd_cv_cc_sanitizer_works=no], [mhd_cv_cc_sanitizer_works=yes]) 2985 ] 2986 ) 2987 AS_VAR_IF([mhd_cv_cc_sanitizer_works], ["yes"], 2988 [ 2989 AS_VAR_IF([enable_san_address], ["no"], [:], 2990 [ 2991 AC_CACHE_CHECK([for address sanitizer], [mhd_cv_cc_sanitizer_address], 2992 [ 2993 CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} -fsanitize=address" 2994 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], 2995 [mhd_cv_cc_sanitizer_address=yes], [mhd_cv_cc_sanitizer_address=no]) 2996 ] 2997 ) 2998 AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"], 2999 [ 3000 AC_DEFINE([MHD_ASAN_ACTIVE], [1], [Define to '1' if you have address sanitizer enabled]) 3001 AX_APPEND_FLAG([-fsanitize=address], [san_FLAGS]) 3002 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }address" 3003 AS_VAR_IF([enable_san_leak], ["no"], [:], 3004 [ 3005 AC_CACHE_CHECK([whether leak detect is not rejected by address sanitizer], [mhd_cv_cc_sanitizer_address_leak], 3006 [ 3007 CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS}" 3008 ASAN_OPTIONS="exitcode=88:detect_leaks=1:halt_on_error=1" 3009 export ASAN_OPTIONS 3010 AC_RUN_IFELSE([AC_LANG_PROGRAM([],[])], 3011 [mhd_cv_cc_sanitizer_address_leak=yes], [mhd_cv_cc_sanitizer_address_leak=no], 3012 [ 3013 # Cross-compiling with sanitizers? 3014 mhd_cv_cc_sanitizer_address_leak='assuming no' 3015 ] 3016 ) 3017 AS_UNSET([ASAN_OPTIONS]) 3018 ] 3019 ) 3020 ] 3021 ) 3022 AC_CACHE_CHECK([for pointer compare sanitizer], [mhd_cv_cc_sanitizer_pointer_compare], 3023 [ 3024 CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-compare" 3025 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], 3026 [mhd_cv_cc_sanitizer_pointer_compare=yes], [mhd_cv_cc_sanitizer_pointer_compare=no]) 3027 ] 3028 ) 3029 AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_compare],["yes"], 3030 [ 3031 AX_APPEND_FLAG([-fsanitize=pointer-compare], [san_FLAGS]) 3032 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer compare" 3033 ] 3034 ) 3035 AC_CACHE_CHECK([for pointer subtract sanitizer], [mhd_cv_cc_sanitizer_pointer_subtract], 3036 [ 3037 CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-subtract" 3038 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], 3039 [mhd_cv_cc_sanitizer_pointer_subtract=yes], [mhd_cv_cc_sanitizer_pointer_subtract=no]) 3040 ] 3041 ) 3042 AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_subtract],["yes"], 3043 [ 3044 AX_APPEND_FLAG([-fsanitize=pointer-subtract], [san_FLAGS]) 3045 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer subtract" 3046 ] 3047 ) 3048 AS_VAR_IF([enable_san_upoison], ["no"], [:], 3049 [ 3050 AC_CHECK_HEADERS([sanitizer/asan_interface.h], [], [], [AC_INCLUDES_DEFAULT]) 3051 AS_IF([test "x${mhd_cv_cc_sanitizer_pointer_compare}" = "xyes" && test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes"], 3052 [ 3053 AC_CACHE_CHECK([whether '__attribute__((no_sanitize("pointer-compare","pointer-subtract")))' works], [mhd_cv_func_attribute_nosanitize_ptr], 3054 [ 3055 ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1" 3056 export ASAN_OPTIONS 3057 CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS}" 3058 AC_RUN_IFELSE( 3059 [ 3060 AC_LANG_PROGRAM( 3061 [[ 3062#include <stdlib.h> 3063 3064__attribute__((no_sanitize("pointer-compare","pointer-subtract"))) 3065int ptr_process(void *ptr1, void *ptr2) 3066{ 3067 if ((char*)ptr1 <= (char*)ptr2) 3068 return (int) ((char*)ptr2 - (char*)ptr1); 3069 return (int) ((char*)ptr1 - (char*)ptr2); 3070} 3071 ]], 3072 [[ 3073 int *a = (int*) malloc (sizeof(int)*4); 3074 int *b = (int*) malloc (sizeof(long)*6); 3075 int c = ptr_process(a, b); 3076 if (c) 3077 { 3078 free (b); 3079 free (a); 3080 return 0; 3081 } 3082 free (a); 3083 free (b); 3084 ]] 3085 ) 3086 ], 3087 [mhd_cv_func_attribute_nosanitize_ptr=yes], [mhd_cv_func_attribute_nosanitize_ptr=no], 3088 [ 3089 # Cross-compiling with sanitizers?? 3090 mhd_cv_func_attribute_nosanitize_ptr='assuming no' 3091 ] 3092 ) 3093 AS_UNSET([ASAN_OPTIONS]) 3094 ] 3095 ) 3096 AS_VAR_IF([mhd_cv_func_attribute_nosanitize_ptr], ["yes"], 3097 [AC_DEFINE([FUNC_ATTR_PTRCOMPARE_WOKRS],[1],[Define to '1' if '__attribute__((no_sanitize("pointer-compare","pointer-subtract")))' works])], 3098 [ 3099 AC_CACHE_CHECK([whether '__attribute__((no_sanitize("address")))' works for pointers compare], [mhd_cv_func_attribute_nosanitize_addr], 3100 [ 3101 ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1" 3102 export ASAN_OPTIONS 3103 CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS}" 3104 AC_RUN_IFELSE( 3105 [ 3106 AC_LANG_PROGRAM( 3107 [[ 3108#include <stdlib.h> 3109 3110__attribute__((no_sanitize("address"))) 3111int ptr_process(void *ptr1, void *ptr2) 3112{ 3113 if ((char*)ptr1 <= (char*)ptr2) 3114 return (int) ((char*)ptr2 - (char*)ptr1); 3115 return (int) ((char*)ptr1 - (char*)ptr2); 3116} 3117 ]], 3118 [[ 3119 int *a = (int*) malloc (sizeof(int)*4); 3120 int *b = (int*) malloc (sizeof(long)*6); 3121 int c = ptr_process(a, b); 3122 if (c) 3123 { 3124 free (b); 3125 free (a); 3126 return 0; 3127 } 3128 free (a); 3129 free (b); 3130 ]] 3131 ) 3132 ], 3133 [mhd_cv_func_attribute_nosanitize_addr=yes], [mhd_cv_func_attribute_nosanitize_addr=no], 3134 [ 3135 # Cross-compiling with sanitizers?? 3136 mhd_cv_func_attribute_nosanitize_addr='assuming no' 3137 ] 3138 ) 3139 AS_UNSET([ASAN_OPTIONS]) 3140 ] 3141 ) 3142 AS_VAR_IF([mhd_cv_func_attribute_nosanitize_addr], ["yes"], 3143 [AC_DEFINE([FUNC_ATTR_NOSANITIZE_WORKS],[1],[Define to '1' if '__attribute__((no_sanitize("address")))' works for pointers compare])] 3144 ) 3145 ] 3146 ) 3147 ] 3148 ) 3149 ] 3150 ) 3151 ] 3152 ) 3153 AS_IF([test "x${enable_san_address}" = "xyes" && test "x${mhd_cv_cc_sanitizer_address}" != "xyes"], 3154 [AC_MSG_ERROR([Address sanitizer cannot be enabled])] 3155 ) 3156 enable_san_address="${mhd_cv_cc_sanitizer_address}" 3157 ] 3158 ) 3159 AS_VAR_IF([enable_san_undef], ["no"], [:], 3160 [ 3161 dnl Ensure that '#' will be processed correctly 3162 [ 3163 test_undf_prog=' 3164#include <stdio.h> 3165 3166void func_out_b(char *arr) 3167{ 3168 arr[0] = 0; 3169 arr[16] = 2; 3170} 3171 3172unsigned int int_deref(void *ptr) 3173{ 3174 return (*((int*)ptr)) + 2; 3175} 3176 3177int func1(void) 3178{ 3179 char chr[16]; 3180 func_out_b (chr); 3181 return int_deref(chr + 1) + int_deref(chr + 2); 3182} 3183 3184int main(void) 3185{ 3186 unsigned long ulvar; 3187 signed char ch1; 3188 ulvar = -1 * func1(); 3189 ch1 = ulvar * 6UL; 3190 printf("%lu\n", ulvar + ch1); 3191 return 0; 3192} 3193 ' 3194 ] 3195 AC_CACHE_CHECK([for undefined behavior sanitizer], [mhd_cv_cc_sanitizer_undefined], 3196 [ 3197 CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined" 3198 AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])], 3199 [mhd_cv_cc_sanitizer_undefined=yes], [mhd_cv_cc_sanitizer_undefined=no]) 3200 ] 3201 ) 3202 AS_VAR_IF([mhd_cv_cc_sanitizer_undefined],["yes"], 3203 [ 3204 AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS]) 3205 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined" 3206 ], 3207 [ 3208 AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-undefined-trap-on-error'], [mhd_cv_cc_sanitizer_undefined_trap], 3209 [ 3210 CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-undefined-trap-on-error" 3211 AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])], 3212 [mhd_cv_cc_sanitizer_undefined_trap=yes], [mhd_cv_cc_sanitizer_undefined_trap=no]) 3213 ] 3214 ) 3215 AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap], ["yes"], 3216 [ 3217 AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS]) 3218 AX_APPEND_FLAG([-fsanitize-undefined-trap-on-error], [san_FLAGS]) 3219 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined" 3220 AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited]) 3221 ], 3222 [ 3223 AS_IF([test -z "${enabled_sanitizers}"], 3224 [ 3225 # Last resort 3226 AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-trap=all'], [mhd_cv_cc_sanitizer_undefined_trap_all], 3227 [ 3228 CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all" 3229 AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])], 3230 [mhd_cv_cc_sanitizer_undefined_trap_all=yes], [mhd_cv_cc_sanitizer_undefined_trap_all=no]) 3231 ] 3232 ) 3233 AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap_all],["yes"], 3234 [ 3235 AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS]) 3236 AX_APPEND_FLAG([-fsanitize-trap=all], [san_FLAGS]) 3237 CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all" 3238 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined" 3239 AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited]) 3240 ] 3241 ) 3242 ] 3243 ) 3244 ] 3245 ) 3246 ] 3247 ) 3248 AS_CASE(["$enabled_sanitizers"], [*undefined], 3249 [ 3250 AS_VAR_IF([mhd_cv_cc_sanitizer_undefined], ["yes"],[], 3251 [ 3252 # A workaround for broken clang which is trying to use UBSan lib 3253 # even when instructed to not use it 3254 CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS}" 3255 AX_APPEND_LINK_FLAGS([-fsanitize-trap=implicit-conversion], 3256 [san_FLAGS], [], [AC_LANG_SOURCE([${test_undf_prog}])]) 3257 ] 3258 ) 3259 CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS}" 3260 AX_APPEND_LINK_FLAGS([-fsanitize=bounds-strict -fsanitize=local-bounds -fsanitize=implicit-conversion -fsanitize=nullability-arg], 3261 [san_CFLAGS], [], [AC_LANG_SOURCE([${test_undf_prog}])]) 3262 ] 3263 ) 3264 AS_UNSET([test_undf_prog]) 3265 AS_CASE(["$enabled_sanitizers"], 3266 [*undefined], [enable_san_undef="yes"], 3267 [ 3268 AS_VAR_IF([enable_san_undef], [yes], [AC_MSG_ERROR([Undefined behavior sanitizer cannot be enabled])]) 3269 enable_san_undef="no" 3270 ] 3271 ) 3272 ] 3273 ) 3274 AS_VAR_IF([enable_san_leak], ["no"], [:], 3275 [ 3276 AC_CACHE_CHECK([for leak sanitizer], [mhd_cv_cc_sanitizer_leak], 3277 [ 3278 CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS} -fsanitize=leak" 3279 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], 3280 [mhd_cv_cc_sanitizer_leak=yes], [mhd_cv_cc_sanitizer_leak=no]) 3281 ] 3282 ) 3283 AS_VAR_IF([mhd_cv_cc_sanitizer_leak],["yes"], 3284 [ 3285 AX_APPEND_FLAG([-fsanitize=leak], [san_FLAGS]) 3286 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }leak" 3287 ] 3288 ) 3289 AS_IF([test "x${enable_san_leak}" = "xyes" && test "x${mhd_cv_cc_sanitizer_leak}" != "xyes"], 3290 [AC_MSG_ERROR([User poison cannot be enabled])] 3291 ) 3292 enable_san_leak="${mhd_cv_cc_sanitizer_leak}" 3293 ] 3294 ) 3295 AS_IF([test -z "${enabled_sanitizers}"], 3296 [AC_MSG_ERROR([cannot find any sanitizer supported by $CC])]) 3297 AS_VAR_IF([enable_san_upoison], ["no"], [:], 3298 [ 3299 AC_MSG_CHECKING([whether to enable user memory poisoning]) 3300 AS_IF([test "x${mhd_cv_cc_sanitizer_address}" = "xyes" && test "x${mhd_cv_cc_sanitizer_pointer_compare}" = "xyes" && \ 3301 test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes" && \ 3302 (test "x${mhd_cv_func_attribute_nosanitize_ptr}" = "xyes" || test "x${mhd_cv_func_attribute_nosanitize_addr}" = "xyes")], 3303 [ 3304 AC_DEFINE([MHD_ASAN_POISON_ACTIVE], [1], [Define to '1' if user memory poison is used]) 3305 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }user-poison" 3306 enable_san_upoison="yes" 3307 AC_MSG_RESULT([yes]) 3308 ], 3309 [ 3310 AC_MSG_RESULT([no]) 3311 AS_VAR_IF([enable_san_upoison], ["yes"], 3312 [AC_MSG_ERROR([User memory poisoning cannot be enabled])]) 3313 enable_san_upoison="no" 3314 ] 3315 ) 3316 ] 3317 ) 3318 AS_VAR_IF([enable_san_address], ["yes"], 3319 [ 3320 AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"], 3321 [ 3322 AX_APPEND_FLAG([-D_FORTIFY_SOURCE=0], [san_CFLAGS]) 3323 CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS}" 3324 AX_APPEND_COMPILE_FLAGS([-Wp,-U_FORTIFY_SOURCE], [san_CFLAGS]) 3325 ], 3326 [AC_MSG_WARN([$CC does not support address sanitizer])] 3327 ) 3328 ] 3329 ) 3330 CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS}" 3331 # Always stop on sanitizer error 3332 AX_APPEND_COMPILE_FLAGS([-fno-sanitize-recover=all], [san_CFLAGS]) 3333 # Get a better output for sanitizers error reporting 3334 AX_APPEND_COMPILE_FLAGS([-fno-omit-frame-pointer -fno-optimize-sibling-calls], 3335 [san_CFLAGS]) 3336 AS_VAR_IF([enable_san_address], ["yes"], 3337 [ 3338 AM_ASAN_OPTIONS="exitcode=88:strict_string_checks=1:detect_stack_use_after_return=1" 3339 AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:check_initialization_order=1:strict_init_order=1:redzone=64" 3340 AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:max_free_fill_size=1024:detect_invalid_pointer_pairs=3" 3341 AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:handle_ioctl=1:halt_on_error=1" 3342 AS_VAR_IF([enable_san_upoison], ["yes"], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:allow_user_poisoning=1"]) 3343 AS_VAR_IF([enable_san_leak], ["yes"], 3344 [AS_VAR_IF([mhd_cv_cc_sanitizer_address_leak], ["yes"], 3345 [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=1"]) 3346 ], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=0"] 3347 ) 3348 ] 3349 ) 3350 AS_VAR_IF([enable_san_undef], [yes], 3351 [AM_UBSAN_OPTIONS="exitcode=87:print_stacktrace=1:halt_on_error=1"]) 3352 AS_VAR_IF([enable_san_leak], ["yes"], 3353 [AM_LSAN_OPTIONS="use_unaligned=1"] 3354 ) 3355 AM_TESTS_ENVIRONMENT='\ 3356ASAN_OPTIONS="$(AM_ASAN_OPTIONS)" ; export ASAN_OPTIONS ; \ 3357UBSAN_OPTIONS="$(AM_UBSAN_OPTIONS)" ; export UBSAN_OPTIONS ; \ 3358LSAN_OPTIONS="$(AM_LSAN_OPTIONS)" ; export LSAN_OPTIONS ;' 3359 ] 3360 ) 3361 CFLAGS="${saved_CFLAGS} ${san_FLAGS} ${san_CFLAGS}" 3362 AS_UNSET([saved_CFLAGS]) 3363 ] 3364) 3365AM_CONDITIONAL([USE_SANITIZERS], 3366 [test -n "$enabled_sanitizers" && test "x$mhd_cv_cc_sanitizer_works" = "xyes"]) 3367AC_SUBST([AM_ASAN_OPTIONS]) 3368AC_SUBST([AM_UBSAN_OPTIONS]) 3369AC_SUBST([AM_LSAN_OPTIONS]) 3370AC_SUBST([AM_TESTS_ENVIRONMENT]) 3371 3372MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS -export-dynamic -no-undefined" 3373 3374AC_SUBST([CPU_COUNT]) 3375AC_SUBST([HEAVY_TESTS_NOTPARALLEL]) 3376AC_SUBST(MHD_LIB_CPPFLAGS) 3377AC_SUBST(MHD_LIB_CFLAGS) 3378AC_SUBST(MHD_LIB_LDFLAGS) 3379AC_SUBST(MHD_LIBDEPS) 3380AC_SUBST(MHD_TLS_LIB_CPPFLAGS) 3381AC_SUBST(MHD_TLS_LIB_CFLAGS) 3382AC_SUBST(MHD_TLS_LIB_LDFLAGS) 3383AC_SUBST(MHD_TLS_LIBDEPS) 3384 3385# for pkg-config 3386AC_SUBST([MHD_REQ_PRIVATE]) 3387AC_SUBST([MHD_LIBDEPS_PKGCFG]) 3388 3389AC_SUBST(CPPFLAGS) 3390AC_SUBST(LIBS) 3391AC_SUBST(LDFLAGS) 3392 3393# Used for 'po' directory staff 3394AC_SUBST([ac_configure_args]) 3395AC_SUBST([EMPTY_VAR], [[]]) 3396 3397# We define the paths here, because MinGW/GCC expands paths 3398# passed through the command line ("-DDIR=..."). This would 3399# lead to hard-coded paths ("C:\mingw\mingw\bin...") that do 3400# not contain the actual installation. 3401AC_DEFINE_DIR([MHD_PLUGIN_INSTALL_PREFIX], [libdir/libmicrohttpd], [tls plugins]) 3402 3403 3404# should experimental code be compiled (code that may not yet compile)? 3405AC_MSG_CHECKING(whether to compile experimental code) 3406AC_ARG_ENABLE([experimental], 3407 [AS_HELP_STRING([--enable-experimental], [enable compiling experimental code])], 3408 [enable_experimental=${enableval}], 3409 [enable_experimental=no]) 3410AC_MSG_RESULT($enable_experimental) 3411AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"]) 3412 3413 3414AC_CONFIG_FILES([libmicrohttpd.pc 3415w32/common/microhttpd_dll_res_vc.rc 3416Makefile 3417contrib/Makefile 3418doc/Makefile 3419doc/doxygen/libmicrohttpd.doxy 3420doc/doxygen/Makefile 3421doc/examples/Makefile 3422m4/Makefile 3423src/Makefile 3424src/include/Makefile 3425src/lib/Makefile 3426src/microhttpd/Makefile 3427src/microhttpd_ws/Makefile 3428src/examples/Makefile 3429src/testcurl/Makefile 3430src/testcurl/https/Makefile 3431src/testzzuf/Makefile]) 3432AC_OUTPUT 3433 3434# Finally: summary 3435AS_IF([test "x$enable_curl" != "xyes"], 3436 [MSG_CURL="no, many unit tests will not run"], 3437 [MSG_CURL="yes"]) 3438 3439AS_VAR_IF([os_is_windows], ["yes"], 3440 [os_ver_msg=" 3441 Target W32 ver: ${mhd_w32_ver_msg}"], [AS_UNSET([[os_ver_msg]])]) 3442 3443 3444AC_MSG_NOTICE([GNU libmicrohttpd ${PACKAGE_VERSION} Configuration Summary: 3445 Target directory: ${prefix} 3446 Cross-compiling: ${cross_compiling} 3447 Operating System: ${mhd_host_os}${os_ver_msg} 3448 Shutdown of listening socket triggers select: ${mhd_cv_host_shtdwn_trgr_select} 3449 Inter-thread comm: ${use_itc} 3450 poll support: ${enable_poll=no} 3451 epoll support: ${enable_epoll=no} 3452 sendfile used: ${found_sendfile} 3453 HTTPS support: ${MSG_HTTPS} 3454 Threading lib: ${USE_THREADS} 3455 Use thread names: ${enable_thread_names} 3456 Use debug asserts: ${enable_asserts} 3457 Use sanitizers: ${enabled_sanitizers:=no} 3458 Messages: ${enable_messages} 3459 Gettext: ${have_po} 3460 Basic auth.: ${enable_bauth} 3461 Digest auth.: ${enable_dauth} 3462 HTTP "Upgrade": ${enable_httpupgrade} 3463 Postproc: ${enable_postprocessor} 3464 Build docs: ${enable_doc} 3465 Build examples: ${enable_examples} 3466 Test with libcurl: ${MSG_CURL} 3467]) 3468 3469AS_IF([test "x$enable_https" = "xyes"], 3470 [AC_MSG_NOTICE([HTTPS subsystem configuration: 3471 License : LGPLv2.1+ only 3472 ])], 3473 [AC_MSG_NOTICE([ 3474 License : LGPLv2.1+ or eCos 3475 ])]) 3476 3477AS_IF([test "x$enable_bauth" != "xyes" || \ 3478 test "x$enable_dauth" != "xyes" || \ 3479 test "x$enable_httpupgrade" != "xyes" || \ 3480 test "x$enable_postprocessor" != "xyes"], 3481 [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.])]) 3482