1 # This file is part of libmicrohttpd. 2 # (C) 2006-2015 Christian Grothoff (and other contributing authors) 3 # 4 # libmicrohttpd is free software; you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License as published 6 # by the Free Software Foundation; either version 3, or (at your 7 # option) any later version. 8 # 9 # libmicrohttpd is distributed in the hope that it will be useful, but 10 # WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 # General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License 15 # along with libmicrohttpd; see the file COPYING. If not, write to the 16 # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 # Boston, MA 02111-1307, USA. 18 # 19 # 20 # Process this file with autoconf to produce a configure script. 21 # 22 # 23 AC_PREREQ([2.60]) 24 LT_PREREQ([2.4.0]) 25 AC_INIT([libmicrohttpd],[0.9.42],[libmicrohttpd (a] gnu.org]) 26 AM_INIT_AUTOMAKE([silent-rules] [subdir-objects]) 27 AC_CONFIG_HEADERS([MHD_config.h]) 28 AC_CONFIG_MACRO_DIR([m4]) 29 AH_TOP([#define _GNU_SOURCE 1]) 30 31 LIB_VERSION_CURRENT=42 32 LIB_VERSION_REVISION=0 33 LIB_VERSION_AGE=32 34 AC_SUBST(LIB_VERSION_CURRENT) 35 AC_SUBST(LIB_VERSION_REVISION) 36 AC_SUBST(LIB_VERSION_AGE) 37 38 LIBSPDY_VERSION_CURRENT=0 39 LIBSPDY_VERSION_REVISION=0 40 LIBSPDY_VERSION_AGE=0 41 AC_SUBST(LIBSPDY_VERSION_CURRENT) 42 AC_SUBST(LIBSPDY_VERSION_REVISION) 43 AC_SUBST(LIBSPDY_VERSION_AGE) 44 45 46 if test `uname -s` = "OS/390" 47 then 48 # configure binaries for z/OS 49 if test -z "$CC" 50 then 51 CC=`pwd`"/contrib/xcc" 52 chmod +x $CC || true 53 fi 54 if test -z "$CPP" 55 then 56 CPP="c89 -E" 57 fi 58 if test -z "$CXXCPP" 59 then 60 CXXCPP="c++ -E -+" 61 fi 62 # _CCC_CCMODE=1 63 # _C89_CCMODE=1 64 fi 65 66 # Checks for programs. 67 AC_PROG_AWK 68 AC_PROG_INSTALL 69 AC_PROG_LN_S 70 AC_PROG_MAKE_SET 71 AC_CANONICAL_HOST 72 AM_PROG_CC_C_O 73 LT_INIT([win32-dll]) 74 LT_LANG([Windows Resource]) 75 76 PACKAGE_VERSION_MAJOR=${PACKAGE_VERSION%.*.*} 77 PACKAGE_VERSION_MINOR=${PACKAGE_VERSION%.*}; PACKAGE_VERSION_MINOR=${PACKAGE_VERSION_MINOR#*.} 78 PACKAGE_VERSION_SUBMINOR=${PACKAGE_VERSION#*.*.} 79 AC_SUBST([PACKAGE_VERSION_MAJOR]) 80 AC_SUBST([PACKAGE_VERSION_MINOR]) 81 AC_SUBST([PACKAGE_VERSION_SUBMINOR]) 82 AC_CONFIG_FILES([src/microhttpd/microhttpd_dll_res.rc]) 83 84 MHD_LIB_CPPFLAGS="" 85 MHD_LIB_CFLAGS="" 86 MHD_LIB_LDFLAGS="" 87 MHD_LIBDEPS="" 88 89 AC_ARG_WITH([threads], 90 [AC_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto) [auto]])], 91 [], [with_threads='auto']) 92 test "x$with_threads" = "xwin32" && with_threads='w32' 93 test "x$with_threads" = "xpthreads" && with_threads='posix' 94 95 # Check for posix threads support 96 AX_PTHREAD([HAVE_POSIX_THREADS='yes'],[HAVE_POSIX_THREADS='no']) 97 AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$HAVE_POSIX_THREADS" = "xyes"]) 98 # Simple check for W32 threads support 99 AC_CHECK_HEADER([windows.h], 100 [ 101 AC_MSG_CHECKING([for CreateThread()]) 102 AC_LINK_IFELSE( 103 [AC_LANG_PROGRAM([#include <windows.h>], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])], 104 [ 105 AC_MSG_RESULT([yes]) 106 HAVE_W32_THREADS='yes' 107 ], 108 [ 109 AC_MSG_RESULT([no]) 110 HAVE_W32_THREADS='no' 111 ]) 112 ], 113 [HAVE_W32_THREADS='no']) 114 115 # for pkg-config 116 MHD_LIBDEPS="" 117 MHD_REQ_PRIVATE='' 118 # Check system type 119 case "$host_os" in 120 *darwin* | *rhapsody* | *macosx*) 121 AC_DEFINE_UNQUOTED(OSX,1,[This is an OS X system]) 122 CFLAGS="-no-cpp-precomp -fno-common $CFLAGS" 123 ;; 124 freebsd*) 125 AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system]) 126 AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system]) 127 ;; 128 openbsd*) 129 AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system]) 130 AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system]) 131 ;; 132 netbsd*) 133 AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system]) 134 AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system]) 135 ;; 136 *solaris*) 137 AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system]) 138 AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno doesnt work]) 139 AC_SEARCH_LIBS(gethostbyname, nsl) 140 AC_SEARCH_LIBS(socket, socket) 141 ;; 142 *arm-linux*) 143 AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel]) 144 AC_DEFINE_UNQUOTED(HAVE_LISTEN_SHUTDOWN,1,[can use shutdown on listen sockets]) 145 CFLAGS="-fPIC -pipe $CFLAGS" 146 ;; 147 *linux*) 148 AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel]) 149 AC_DEFINE_UNQUOTED(HAVE_LISTEN_SHUTDOWN,1,[can use shutdown on listen sockets]) 150 ;; 151 *cygwin*) 152 AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system]) 153 os_is_windows=yes 154 ;; 155 *mingw*) 156 AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system]) 157 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system]) 158 LIBS="$LIBS -lws2_32" 159 AC_CHECK_HEADERS([winsock2.h ws2tcpip.h],, AC_MSG_ERROR([[Winsock2 headers are required for W32]])) 160 AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool], 161 [[mslibcheck=`lib 2>&1` 162 if [[ $mslibcheck = "Microsoft (R) Library Manager"* ]]; then 163 ac_cv_use_ms_lib_tool=yes 164 else 165 ac_cv_use_ms_lib_tool=no 166 fi 167 ]]) 168 if test "x$ac_cv_use_ms_lib_tool" = "xyes"; then 169 AC_SUBST([MS_LIB_TOOL], [[lib]]) 170 fi 171 AC_SUBST([lt_cv_objdir]) 172 os_is_windows=yes 173 os_is_native_w32=yes 174 ;; 175 *openedition*) 176 AC_DEFINE_UNQUOTED(OS390,1,[This is a OS/390 system]) 177 ;; 178 *) 179 AC_MSG_WARN([Unrecognised OS $host_os]) 180 AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS]) 181 # You might want to find out if your OS supports shutdown on listen sockets, 182 # and extend the switch statement; if we do not have 'HAVE_LISTEN_SHUTDOWN', 183 # pipes are used instead to signal 'select'. 184 # AC_DEFINE_UNQUOTED(HAVE_LISTEN_SHUTDOWN,1,[can use shutdown on listen sockets]) 185 ;; 186 esac 187 188 if test "x$with_threads" = "xposix"; then 189 # forced posix threads 190 if test "x$HAVE_POSIX_THREADS" = "xyes"; then 191 USE_THREADS='posix' 192 else 193 if test "x$HAVE_W32_THREADS" = "xyes"; then 194 AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]]) 195 else 196 AC_MSG_ERROR([[Posix threads are not available]]) 197 fi 198 fi 199 elif test "x$with_threads" = "xw32"; then 200 # forced w32 threads 201 if test "x$HAVE_W32_THREADS" = "xyes"; then 202 USE_THREADS='w32' 203 else 204 if test "x$HAVE_POSIX_THREADS" = "xyes"; then 205 AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]]) 206 else 207 AC_MSG_ERROR([[W32 threads are not available]]) 208 fi 209 fi 210 else 211 # automatic threads lib selection 212 if test "x$HAVE_POSIX_THREADS" = "xyes" && test "x$HAVE_W32_THREADS" = "xyes"; then 213 if test "x$os_is_native_w32" = "xyes"; then 214 USE_THREADS='w32' 215 else 216 USE_THREADS='posix' 217 fi 218 elif test "x$HAVE_POSIX_THREADS" = "xyes"; then 219 USE_THREADS='posix' 220 elif test "x$HAVE_W32_THREADS" = "xyes"; then 221 USE_THREADS='w32' 222 else 223 AC_MSG_ERROR([[No threading lib is available. Cosider installing pthreads]]) 224 fi 225 fi 226 227 if test "x$USE_THREADS" = "xposix"; then 228 CC="$PTHREAD_CC" 229 AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads]) 230 MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS" 231 MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS" 232 elif test "x$USE_THREADS" = "xw32"; then 233 AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads]) 234 fi 235 AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"]) 236 AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"]) 237 238 239 AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"]) 240 w32_shared_lib_exp=no 241 if test "x$enable_shared" = "xyes" && test "x$os_is_native_w32" = "xyes"; then 242 if test "x$ac_cv_use_ms_lib_tool" = "xyes" || test -n "$DLLTOOL"; then 243 w32_shared_lib_exp=yes 244 else 245 AC_MSG_WARN([[GNU dlltool or MS lib.exe is required for creating shared library export on W32]]) 246 AC_MSG_WARN([[Export library libmicrohttpd.lib will not be created]]) 247 fi 248 fi 249 AM_CONDITIONAL(W32_SHARED_LIB_EXP, [test "x$w32_shared_lib_exp" = "xyes"]) 250 AM_CONDITIONAL(USE_MS_LIB_TOOL, [test "x$ac_cv_use_ms_lib_tool" = "xyes"]) 251 252 # set GCC options 253 # use '-fno-strict-aliasing', but only if the compiler 254 # and linker can take it 255 AX_CHECK_LINK_FLAG([-fno-strict-aliasing], 256 [AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing])]) 257 258 AC_C_BIGENDIAN 259 260 AC_CHECK_PROG([HAVE_CURL_BINARY],[curl],[yes],[no]) 261 AM_CONDITIONAL([HAVE_CURL_BINARY],[test "x$HAVE_CURL_BINARY" = "xyes"]) 262 AC_CHECK_PROG([HAVE_MAKEINFO_BINARY],[makeinfo],[yes],[no]) 263 AM_CONDITIONAL([HAVE_MAKEINFO_BINARY],[test "x$HAVE_MAKEINFO_BINARY" = "xyes"]) 264 AM_CONDITIONAL(W32_STATIC_LIB, [test "x$os_is_native_w32" = "xyes" && test "x$enable_static" = "xyes"]) 265 266 267 AC_ARG_ENABLE([[doc]], 268 [AS_HELP_STRING([[--disable-doc]], [do not build any documentation])], , 269 [enable_doc=yes]) 270 test "x$enable_doc" = "xno" || enable_doc=yes 271 AM_CONDITIONAL([BUILD_DOC], [test "x$enable_doc" = "xyes"]) 272 273 AC_ARG_ENABLE([[examples]], 274 [AS_HELP_STRING([[--disable-examples]], [do not build any examples])], , 275 [enable_examples=yes]) 276 test "x$enable_examples" = "xno" || enable_examples=yes 277 AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" = "xyes"]) 278 279 AC_ARG_ENABLE([[poll]], 280 [AS_HELP_STRING([[--enable-poll[=ARG]]], [enable poll support (yes, no, auto) [auto]])], 281 [enable_poll=${enableval}], 282 [enable_poll='auto'] 283 ) 284 285 if test "$enable_poll" != "no"; then 286 if test "$os_is_native_w32" != "yes"; then 287 AC_CHECK_HEADERS([poll.h], 288 [ 289 AC_CHECK_FUNCS([poll], [have_poll='yes'], [have_poll='no']) 290 ]) 291 else 292 AC_MSG_CHECKING([for WSAPoll()]) 293 AC_LINK_IFELSE([ 294 AC_LANG_PROGRAM([[#include <winsock2.h>]], [[ 295 WSAPOLLFD fda[2]; 296 WSAPoll(fda, 2, 0);]])], 297 [ 298 have_poll='yes' 299 AC_DEFINE([HAVE_POLL],[1]) 300 ], [have_poll='no']) 301 AC_MSG_RESULT([$have_poll]) 302 fi 303 if test "$enable_poll" = "yes" && test "$have_poll" != "yes"; then 304 AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]]) 305 fi 306 enable_poll="$have_poll" 307 fi 308 309 AC_ARG_ENABLE([[epoll]], 310 [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])], 311 [enable_epoll=${enableval}], 312 [enable_epoll='auto'] 313 ) 314 315 if test "$enable_epoll" != "no"; then 316 AX_HAVE_EPOLL 317 if test "${ax_cv_have_epoll}" = "yes"; then 318 AC_DEFINE([EPOLL_SUPPORT],[1],[define to 1 to enable epoll support]) 319 enable_epoll='yes' 320 else 321 AC_DEFINE([EPOLL_SUPPORT],[0],[define to 0 to disable epoll support]) 322 if test "$enable_epoll" = "yes"; then 323 AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]]) 324 fi 325 enable_epoll='no' 326 fi 327 fi 328 329 if test "x$enable_epoll" = "xyes"; then 330 AC_CACHE_CHECK([for epoll_create1()], [mhd_cv_have_epoll_create1], [ 331 AC_LINK_IFELSE([ 332 AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[ 333 int fd; 334 fd = epoll_create1(EPOLL_CLOEXEC);]])], 335 [mhd_cv_have_epoll_create1=yes], 336 [mhd_cv_have_epoll_create1=no])]) 337 AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[ 338 AC_DEFINE([[HAVE_EPOLL_CREATE1]], [[1]], [Define if you have epoll_create1 function.])]) 339 fi 340 341 if test "x$HAVE_POSIX_THREADS" = "xyes"; then 342 # Check for pthread_setname_np() 343 SAVE_LIBS="$LIBS" 344 SAVE_CFLAGS="$CFLAGS" 345 LIBS="$PTHREAD_LIBS $LIBS" 346 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 347 AC_MSG_CHECKING([[for pthread_setname_np]]) 348 AC_LINK_IFELSE( 349 [AC_LANG_PROGRAM([[#include <pthread.h>]], [[ pthread_setname_np(pthread_self(), "name")]])], 350 [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP]], [[1]], [Define if you have pthread_setname_np function.]) 351 AC_MSG_RESULT([[yes]])], 352 [AC_MSG_RESULT([[no]])] ) 353 LIBS="$SAVE_LIBS" 354 CFLAGS="$SAVE_CFLAGS" 355 fi 356 357 # Check for headers that are ALWAYS required 358 AC_CHECK_HEADERS([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h sys/types.h pthread.h],,AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX headers files])) 359 360 # Check for optional headers 361 AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h netdb.h netinet/in.h netinet/tcp.h time.h sys/socket.h sys/mman.h arpa/inet.h sys/select.h search.h]) 362 AM_CONDITIONAL([HAVE_TSEARCH], [test "x$ac_cv_header_search_h" = "xyes"]) 363 364 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], 365 [ AC_DEFINE(HAVE_SOCKADDR_IN_SIN_LEN, 1, [Do we have sockaddr_in.sin_len?]) 366 ], 367 [], 368 [ 369 #ifdef HAVE_SYS_TYPES_H 370 #include <sys/types.h> 371 #endif 372 #ifdef HAVE_SYS_SOCKET_H 373 #include <sys/socket.h> 374 #endif 375 #ifdef HAVE_NETINET_IN_H 376 #include <netinet/in.h> 377 #endif 378 ]) 379 380 381 # Check for pipe/socketpair signaling 382 AC_MSG_CHECKING([[whether to enable signaling by socketpair]]) 383 384 AC_ARG_ENABLE([[socketpair]], 385 [AS_HELP_STRING([[--enable-socketpair[=ARG]]], [disable internal singalling by pipes and use socket pair instead (yes, no, try) [no]])], , 386 [AS_IF([[test "x$os_is_windows" = "xyes"]], [enable_socketpair=yes], [enable_socketpair=no])] 387 ) 388 389 AS_IF( 390 [[test "x$enable_socketpair" != "xno"]], 391 [AS_IF([[test "x$os_is_windows" = "xyes"]], 392 [ AC_MSG_RESULT([[yes, forced on W32]]) ], 393 [ AC_LINK_IFELSE( 394 [ AC_LANG_PROGRAM([[ 395 #ifdef HAVE_SYS_TYPES_H 396 #include <sys/types.h> 397 #endif 398 #ifdef HAVE_SYS_SOCKET_H 399 #include <sys/socket.h> 400 #endif 401 ]],[[ 402 int sv[2]; 403 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) != 0) return 1 404 ]]) 405 ], 406 [ AC_MSG_RESULT([[yes, socketpair in available]]) ], 407 [ AC_MSG_RESULT([[no, socketpair in not available]]) 408 AS_IF([[test "x$enable_socketpair" = "xyes"]], [ AC_MSG_ERROR([[socketpair signalling cannot be enabled.]]) ]) 409 ] 410 ) 411 ] 412 ) 413 ], 414 [ 415 AC_MSG_RESULT([[no]]) 416 AS_IF([[test "x$os_is_windows" = "xyes"]], [ AC_MSG_ERROR([[socketpair must be enabled on W32]]) ]) 417 ] 418 ) 419 if test "x$enable_socketpair" = "xyes"; then 420 AC_DEFINE([[MHD_DONT_USE_PIPES]], [[1]], [Define to use pair of sockets instead of pipes for signaling]) 421 fi 422 423 AC_CHECK_FUNCS_ONCE([memmem accept4]) 424 AC_MSG_CHECKING([[for gmtime_s]]) 425 AC_LINK_IFELSE( 426 [AC_LANG_PROGRAM( 427 [[ #include <time.h>]], [[struct tm now; time_t t; time (&t); gmtime_s (&now, &t)]]) 428 ], 429 [ 430 AC_DEFINE([HAVE_GMTIME_S], [1], [Define to 1 if you have `gmtime_s' function (only for W32).]) 431 AC_MSG_RESULT([[yes]]) 432 ], 433 [AC_MSG_RESULT([[no]]) 434 ]) 435 436 437 AC_CHECK_DECLS([SOCK_NONBLOCK], [AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBLOCK is defined in a socket header])], [], 438 [ 439 #if defined HAVE_SYS_TYPES_H 440 # include <sys/types.h> 441 #endif 442 #if defined HAVE_SYS_SOCKET_H 443 # include <sys/socket.h> 444 #elif defined HAVE_WINSOCK2_H 445 # include <winsock2.h> 446 #endif 447 ]) 448 449 450 AC_SEARCH_LIBS([clock_gettime], [rt], [ 451 AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Have clock_gettime]) 452 ]) 453 454 # IPv6 455 AC_MSG_CHECKING(for IPv6) 456 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 457 #include <stdio.h> 458 #if HAVE_NETINET_IN_H 459 #include <netinet/in.h> 460 #endif 461 #if HAVE_SYS_SOCKET_H 462 #include <sys/socket.h> 463 #endif 464 #if HAVE_WINSOCK2_H 465 #include <winsock2.h> 466 #endif 467 #if HAVE_WS2TCPIP_H 468 #include <ws2tcpip.h> 469 #endif 470 ]], [[ 471 int af=AF_INET6; 472 int pf=PF_INET6; 473 struct sockaddr_in6 sa; 474 printf("%d %d %p\n", af, pf, &sa); 475 ]])],[ 476 have_inet6=yes; 477 AC_DEFINE([HAVE_INET6], [1], [Provides IPv6 headers]) 478 ],[ 479 have_inet6=no 480 ]) 481 AC_MSG_RESULT($have_inet6) 482 483 # TCP_CORK and TCP_NOPUSH 484 AC_CHECK_DECLS([TCP_CORK, TCP_NOPUSH], [], [], [[#include <netinet/tcp.h>]]) 485 486 HIDDEN_VISIBILITY_CFLAGS="" 487 case "$host" in 488 *-*-mingw*) 489 dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport) 490 AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern], 491 [defines how to decorate public symbols while building]) 492 HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden" 493 ;; 494 *) 495 dnl on other compilers, check if we can do -fvisibility=hidden 496 AX_CHECK_LINK_FLAG([-fvisibility=hidden], 497 [AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], 498 [AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) extern], 499 [defines how to decorate public symbols while building]) 500 HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"])]) 501 ;; 502 esac 503 AC_SUBST(HIDDEN_VISIBILITY_CFLAGS) 504 505 # libcurl (required for testing) 506 AC_ARG_ENABLE([curl], 507 [AS_HELP_STRING([--disable-curl],[disable cURL based testcases])], 508 [enable_curl=${enableval}]) 509 curl=0 510 if test "$enable_curl" != "no" 511 then 512 LIBCURL_CHECK_CONFIG([yes],[7.16.4],[enable_curl=yes], 513 [ 514 if test "x$enable_curl" = "xyes"; then 515 AC_MSG_WARN([[cURL-based tests cannot be enabled because libcurl is missing]]) 516 fi 517 enable_curl=no 518 ]) 519 fi 520 if test "$enable_curl" != "no" 521 then 522 # Lib cURL & cURL - OpenSSL versions 523 AC_DEFINE([MHD_REQ_CURL_VERSION], ["7.16.4"], [required cURL version to run tests]) 524 AC_DEFINE([MHD_REQ_CURL_OPENSSL_VERSION], ["0.9.8"], [required cURL SSL version to run tests]) 525 AC_DEFINE([MHD_REQ_CURL_GNUTLS_VERSION], ["2.8.6"], [gnuTLS lib version - used in conjunction with cURL]) 526 AC_DEFINE([MHD_REQ_CURL_NSS_VERSION], ["3.12.0"], [NSS lib version - used in conjunction with cURL]) 527 fi 528 AM_CONDITIONAL([HAVE_CURL], [test "x$enable_curl" = "xyes"]) 529 530 AC_CHECK_LIB([[magic]], [[magic_open]], 531 [AC_CHECK_HEADERS([magic.h], 532 AM_CONDITIONAL(HAVE_MAGIC, true), 533 AM_CONDITIONAL(HAVE_MAGIC, false))], 534 AM_CONDITIONAL(HAVE_MAGIC, false)) 535 536 537 # optional: libmicrospdy support. Enabled by default if not on W32 538 AC_ARG_ENABLE([spdy], 539 AS_HELP_STRING([--enable-spdy], 540 [enable build libmicrospdy (yes, no, auto) [auto]]), 541 [enable_spdy=${enableval}], 542 [ AS_IF([[test "x$os_is_windows" = "xyes"]], [enable_spdy=no]) ]) 543 544 if test "$enable_spdy" != "no" 545 then 546 AX_CHECK_OPENSSL([ have_openssl=yes ],[ have_openssl=no ]) 547 if test "x$have_openssl" = "xyes" 548 then 549 # check OpenSSL headers 550 SAVE_CPP_FLAGS="$CPPFLAGS" 551 CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" 552 AC_CHECK_HEADERS([openssl/evp.h openssl/rsa.h openssl/rand.h openssl/err.h openssl/sha.h openssl/pem.h openssl/engine.h], [ have_openssl=yes ],[ have_openssl=no ]) 553 if test "x$have_openssl" = "xyes" 554 then 555 # check OpenSSL libs 556 SAVE_LIBS="$LIBS" 557 SAVE_LD_FLAGS="$LDFLAGS" 558 LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" 559 LIBS="$OPENSSL_LIBS $LIBS" 560 AC_CHECK_FUNC([SSL_CTX_set_next_protos_advertised_cb], 561 [ 562 AC_CHECK_FUNC([SSL_library_init], [ have_openssl=yes ],[ have_openssl=no ]) 563 ],[ have_openssl=no ]) 564 LIBS="$SAVE_LIBS" 565 LDFLAGS="$SAVE_LD_FLAGS" 566 fi 567 CPPFLAGS="$SAVE_CPP_FLAGS" 568 fi 569 if test "x$have_openssl" = "xyes" 570 then 571 enable_spdy=yes 572 else 573 AS_IF([[test "x$enable_spdy" = "xyes" ]], [AC_MSG_ERROR([[libmicrospdy cannot be enabled without OpenSSL.]])]) 574 have_openssl=no 575 enable_spdy=no 576 fi 577 else 578 # OpenSSL is used only for libmicrospdy 579 have_openssl=no 580 fi 581 AM_CONDITIONAL([HAVE_OPENSSL], [test "x$have_openssl" = "xyes"]) 582 583 if test "$enable_spdy" = "yes" 584 then 585 AC_DEFINE([SPDY_SUPPORT],[1],[include libmicrospdy support]) 586 else 587 AC_DEFINE([SPDY_SUPPORT],[0],[disable libmicrospdy support]) 588 fi 589 AM_CONDITIONAL(ENABLE_SPDY, [test "x$enable_spdy" != "xno"]) 590 AC_MSG_CHECKING(whether we have OpenSSL and thus can support libmicrospdy) 591 AC_MSG_RESULT($enable_spdy) 592 593 # for pkg-config 594 SPDY_LIBDEPS="$OPENSSL_LIBS" 595 596 SPDY_LIB_LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" 597 SPDY_LIB_CFLAGS="$CFLAGS" 598 SPDY_LIB_CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" 599 AC_SUBST(SPDY_LIB_LDFLAGS) 600 AC_SUBST(SPDY_LIB_CFLAGS) 601 AC_SUBST(SPDY_LIB_CPPFLAGS) 602 # for pkg-config 603 AC_SUBST(SPDY_LIBDEPS) 604 605 AC_CHECK_HEADERS([spdylay/spdylay.h], [ have_spdylay="yes" ], [have_spdylay="no"]) 606 AM_CONDITIONAL(HAVE_SPDYLAY, [test "x$have_spdylay" = "xyes"]) 607 608 # large file support (> 4 GB) 609 AC_SYS_LARGEFILE 610 AC_FUNC_FSEEKO 611 612 # optional: have error messages ? 613 AC_MSG_CHECKING(whether to generate error messages) 614 AC_ARG_ENABLE([messages], 615 [AS_HELP_STRING([--disable-messages], 616 [disable MHD error messages])], 617 [enable_messages=${enableval}], 618 [enable_messages=yes]) 619 AC_MSG_RESULT($enable_messages) 620 if test "$enable_messages" = "yes" 621 then 622 AC_DEFINE([HAVE_MESSAGES],[1],[Include error messages]) 623 else 624 AC_DEFINE([HAVE_MESSAGES],[0],[Disable error messages]) 625 fi 626 627 628 # optional: have postprocessor? 629 AC_MSG_CHECKING(whether to enable postprocessor) 630 AC_ARG_ENABLE([postprocessor], 631 [AS_HELP_STRING([--disable-postprocessor], 632 [disable MHD PostProcessor functionality])], 633 [enable_postprocessor=${enableval}], 634 [enable_postprocessor=yes]) 635 test "x$enable_postprocessor" = "xno" || enable_postprocessor=yes 636 AC_MSG_RESULT([[$enable_postprocessor]]) 637 AM_CONDITIONAL([HAVE_POSTPROCESSOR],test "x$enable_postprocessor" != "xno") 638 if test "x$enable_postprocessor" != "xno" 639 then 640 AC_DEFINE([HAVE_POSTPROCESSOR],[1],[define to 1 if MHD was build with postprocessor.c]) 641 fi 642 643 644 # optional: have zzuf, socat? 645 AC_CHECK_PROG([have_zzuf],[zzuf], [yes], [no]) 646 AC_CHECK_PROG([have_socat],[socat], [yes], [no]) 647 AM_CONDITIONAL([HAVE_ZZUF], [test "x$have_zzuf" = "xyes"]) 648 AM_CONDITIONAL([HAVE_SOCAT], [test "x$have_socat" = "xyes"]) 649 650 651 # libgcrypt linkage: required for HTTPS support 652 AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no]) 653 if test "x$have_gcrypt" = "xyes" 654 then 655 SAVE_CFLAGS="$CFLAGS" 656 CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS" 657 # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both 658 SAVE_CPPFLAGS="$CPPFLAGS" 659 CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS" 660 AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no]) 661 CFLAGS="$SAVE_CFLAGS" 662 CPPFLAGS="$SAVE_CPPFLAGS" 663 fi 664 665 # gnutls 666 GNUTLS_CPPFLAGS="" 667 GNUTLS_LDFLAGS="" 668 have_gnutls=no 669 have_gnutls_sni=no 670 have_gnutls_pkgcfg=no 671 AC_MSG_CHECKING([[how to find GnuTLS library]]) 672 AC_ARG_WITH([[gnutls]], 673 [AC_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)])], 674 [ 675 case $with_gnutls in 676 no) 677 AC_MSG_RESULT([[GnuTLS disabled]]) 678 ;; 679 yes) 680 AC_MSG_RESULT([[automatically, forced]]) 681 ;; 682 *) 683 AC_MSG_RESULT([[-I$with_gnutls/include -L$with_gnutls/lib -lgnutls]]) 684 SAVE_LDFLAGS="$LDFLAGS" 685 SAVE_CPPFLAGS="$CPPFLAGS" 686 LDFLAGS="-L$with_gnutls/lib $LDFLAGS" 687 CPPFLAGS="-I$with_gnutls/include $CPPFLAGS" 688 have_gnutls_pkgcfg=no 689 AC_CHECK_HEADERS([gnutls/gnutls.h], 690 [AC_CHECK_LIB([gnutls], [gnutls_priority_set], 691 [ 692 GNUTLS_CPPFLAGS="-I$with_gnutls/include" 693 GNUTLS_LDFLAGS="-L$with_gnutls/lib" 694 GNUTLS_LIBS="-lgnutls" 695 AC_CHECK_LIB([gnutls], [gnutls_load_file], [AC_CHECK_LIB([gnutls], [gnutls_privkey_import_x509_raw], [have_gnutls_sni=yes])]) 696 have_gnutls=yes 697 ])]) 698 AS_IF([test "x$have_gnutls" != "xyes"], [AC_MSG_ERROR([can't find usable libgnutls at specified prefix $with_gnutls])]) 699 LDFLAGS="$SAVE_LDFLAGS" 700 CPPFLAGS="$SAVE_CPPFLAGS" 701 ;; 702 esac 703 ], 704 [AC_MSG_RESULT([[automatically]]) 705 ]) 706 707 AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"], 708 [ 709 PKG_CHECK_MODULES(GNUTLS, [[gnutls]], 710 [ 711 have_gnutls_pkgcfg='yes' 712 SAVE_CPPFLAGS="$CPPFLAGS" 713 SAVE_CFLAGS="$CFLAGS" 714 SAVE_LDFLAGS="$LDFLAGS" 715 SAVE_LIBS="$LIBS" 716 CPPFLAGS="$GNUTLS_CFLAGS $CPPFLAGS" 717 CFLAGS="$GNUTLS_CFLAGS $CFLAGS" 718 LDFLAGS="$GNUTLS_LIBS $LDFLAGS" 719 LIBS="$LIBS $GNUTLS_LIBS" 720 AC_MSG_CHECKING([[whether GnuTLS is usable]]) 721 AC_LINK_IFELSE([ 722 AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], [[ 723 gnutls_session_t session; 724 gnutls_priority_t priorities; 725 gnutls_global_init(); 726 gnutls_priority_init(&priorities, "NORMAL", NULL); 727 gnutls_init(&session, GNUTLS_SERVER); 728 gnutls_priority_set(session, priorities); 729 ]])], 730 [ 731 AC_MSG_RESULT([[yes]]) 732 have_gnutls=yes 733 GNUTLS_CPPLAGS="$GNUTLS_CFLAGS" 734 GNUTLS_LDFLAGS="$GNUTLS_LIBS" 735 AC_MSG_CHECKING([[for gnutls_privkey_import_x509_raw()]]) 736 AC_LINK_IFELSE([ 737 AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], [[ 738 gnutls_datum_t data; 739 gnutls_privkey_t key; 740 gnutls_load_file("key.pem", &data); 741 gnutls_privkey_import_x509_raw(key, &data, GNUTLS_X509_FMT_PEM, NULL, 0); 742 gnutls_free(data.data); 743 ]])], [[have_gnutls_sni=yes]], [[have_gnutls_sni=no]]) 744 AC_MSG_RESULT([[$have_gnutls_sni]]) 745 ], 746 [ 747 AC_MSG_RESULT([[no]]) 748 have_gnutls=no 749 ]) 750 751 AS_IF([test "x$have_gnutls" != "xyes"], [AC_MSG_WARN([pkg-config reports that GnuTLS is present, but GnuTLS can't be used])]) 752 CPPFLAGS="$SAVE_CPPFLAGS" 753 CFLAGS="$SAVE_CFLAGS" 754 LDFLAGS="$SAVE_LDFLAGS" 755 LIBS="$SAVE_LIBS" 756 ], 757 [ 758 have_gnutls_pkgcfg='no' 759 AC_CHECK_HEADERS([gnutls/gnutls.h], 760 [AC_CHECK_LIB([gnutls], [gnutls_priority_set], 761 [ 762 GNUTLS_LIBS="-lgnutls" 763 AC_CHECK_LIB([gnutls], [gnutls_load_file], [AC_CHECK_LIB([gnutls], [gnutls_privkey_import_x509_raw], [have_gnutls_sni=yes])]) 764 have_gnutls=yes 765 ])]) 766 ]) 767 ]) 768 769 AS_IF([test "x$have_gnutls" != "xyes" && test "x$with_gnutls" = "xyes"], [AC_MSG_ERROR([[can't find usable libgnutls]])]) 770 771 AM_CONDITIONAL(HAVE_GNUTLS, test "x$have_gnutls" = "xyes") 772 AM_CONDITIONAL([HAVE_GNUTLS_SNI], [test "x$have_gnutls_sni" = "xyes"]) 773 774 AC_SUBST([GNUTLS_CPPFLAGS]) 775 AC_SUBST([GNUTLS_CFLAGS]) 776 AC_SUBST([GNUTLS_LDFLAGS]) 777 AC_SUBST([GNUTLS_LIBS]) 778 779 # optional: HTTPS support. Enabled by default 780 AC_MSG_CHECKING(whether to support HTTPS) 781 AC_ARG_ENABLE([https], 782 [AS_HELP_STRING([--enable-https], 783 [enable HTTPS support (yes, no, auto)[auto]])], 784 [enable_https=${enableval}]) 785 if test "x$enable_https" != "xno" 786 then 787 AS_IF([test "x$have_gnutls" = "xyes" && test "x$have_gcrypt" = "xyes"], [ 788 AC_DEFINE([HTTPS_SUPPORT],[1],[include HTTPS support]) 789 MHD_LIB_CPPFLAGS="$MHD_LIB_CPPFLAGS $LIBGCRYPT_CFLAGS $GNUTLS_CPPFLAGS" 790 MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $LIBGCRYPT_CFLAGS $GNUTLS_CFLAGS" 791 MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS $GNUTLS_LDFLAGS" 792 MHD_LIBDEPS="$GNUTLS_LIBS $LIBGCRYPT_LIBS $MHD_LIBDEPS" 793 enable_https=yes 794 MSG_HTTPS="yes (using libgnutls and libgcrypt)" 795 ], [ 796 AS_IF([test "x$have_gnutls" = "xyes"], [crypt_missing="libgrypt"], 797 [test "x$have_gcrypt" = "xyes"], [crypt_missing="libgnutls"], 798 [crypt_missing="libgrypt and libgnutls"]) 799 AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])]) 800 AC_DEFINE([HTTPS_SUPPORT],[0],[no libgcrypt or libgnutls]) 801 enable_https=no 802 MSG_HTTPS="no (lacking $crypt_missing)" 803 ]) 804 else 805 AC_DEFINE([HTTPS_SUPPORT],[0],[disable HTTPS support]) 806 MSG_HTTPS="no (disabled)" 807 fi 808 AC_MSG_RESULT([$MSG_HTTPS]) 809 810 AM_CONDITIONAL([ENABLE_HTTPS], [test "x$enable_https" = "xyes"]) 811 812 # optional: HTTP Basic Auth support. Enabled by default 813 AC_MSG_CHECKING(whether to support HTTP basic authentication) 814 AC_ARG_ENABLE([bauth], 815 AS_HELP_STRING([--disable-bauth], 816 [disable HTTP basic Auth support]), 817 [enable_bauth=${enableval}], 818 [enable_bauth=yes]) 819 if test "x$enable_bauth" != "xno" 820 then 821 enable_bauth=yes 822 AC_DEFINE([BAUTH_SUPPORT],[1],[include basic Auth support]) 823 else 824 AC_DEFINE([BAUTH_SUPPORT],[0],[disable basic Auth support]) 825 fi 826 AC_MSG_RESULT($enable_bauth) 827 AM_CONDITIONAL(ENABLE_BAUTH, [test "x$enable_bauth" != "xno"]) 828 829 # optional: HTTP Digest Auth support. Enabled by default 830 AC_MSG_CHECKING(whether to support HTTP digest authentication) 831 AC_ARG_ENABLE([dauth], 832 AS_HELP_STRING([--disable-dauth], 833 [disable HTTP basic and digest Auth support]), 834 [enable_dauth=${enableval}], 835 [enable_dauth=yes]) 836 if test "x$enable_dauth" != "xno" 837 then 838 enable_dauth=yes 839 AC_DEFINE([DAUTH_SUPPORT],[1],[include digest Auth support]) 840 else 841 AC_DEFINE([DAUTH_SUPPORT],[0],[disable digest Auth support]) 842 fi 843 AC_MSG_RESULT($enable_dauth) 844 AM_CONDITIONAL(ENABLE_DAUTH, [test "x$enable_dauth" != "xno"]) 845 846 847 848 MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS -export-dynamic -no-undefined" 849 850 # gcov compilation 851 AC_MSG_CHECKING(whether to compile with support for code coverage analysis) 852 AC_ARG_ENABLE([coverage], 853 AS_HELP_STRING([--enable-coverage], 854 [compile the library with code coverage support]), 855 [use_gcov=${enableval}], 856 [use_gcov=no]) 857 AC_MSG_RESULT($use_gcov) 858 AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"]) 859 860 AX_COUNT_CPUS 861 AC_SUBST([CPU_COUNT]) 862 863 AC_SUBST(MHD_LIB_CPPFLAGS) 864 AC_SUBST(MHD_LIB_CFLAGS) 865 AC_SUBST(MHD_LIB_LDFLAGS) 866 867 # for pkg-config 868 AS_IF([[test "x$enable_https" = "xyes" && test "x$have_gnutls_pkgcfg" = "xyes" ]], 869 [ # remove GnuTLS from private libs in .pc file as it defined in Requires.private 870 MHD_REQ_PRIVATE='gnutls' 871 MHD_LIBDEPS_PKGCFG="${MHD_LIBDEPS//$GNUTLS_LIBS/}" 872 ], 873 [ 874 MHD_REQ_PRIVATE='' 875 MHD_LIBDEPS_PKGCFG="$MHD_LIBDEPS" 876 ]) 877 AC_SUBST([MHD_REQ_PRIVATE]) 878 AC_SUBST([MHD_LIBDEPS_PKGCFG]) 879 AC_SUBST(MHD_LIBDEPS) 880 881 AC_SUBST(CPPFLAGS) 882 AC_SUBST(LIBS) 883 AC_SUBST(LDFLAGS) 884 885 AC_CONFIG_FILES([ 886 libmicrohttpd.pc 887 libmicrospdy.pc 888 w32/VS2013/microhttpd_dll_res_vc.rc 889 Makefile 890 contrib/Makefile 891 doc/Makefile 892 doc/doxygen/Makefile 893 doc/examples/Makefile 894 m4/Makefile 895 src/Makefile 896 src/include/Makefile 897 src/platform/Makefile 898 src/microhttpd/Makefile 899 src/microspdy/Makefile 900 src/spdy2http/Makefile 901 src/examples/Makefile 902 src/testcurl/Makefile 903 src/testcurl/https/Makefile 904 src/testspdy/Makefile 905 src/testzzuf/Makefile]) 906 AC_OUTPUT 907 908 # Finally: summary 909 if test "x$enable_curl" != "xyes"; then 910 MSG_CURL="no, many unit tests will not run" 911 else 912 MSG_CURL="yes" 913 fi 914 915 AC_MSG_NOTICE([Configuration Summary: 916 Operating System: ${host_os} 917 Threading lib: ${USE_THREADS} 918 libcurl (testing): ${MSG_CURL} 919 Target directory: ${prefix} 920 Messages: ${enable_messages} 921 Basic auth.: ${enable_bauth} 922 Digest auth.: ${enable_dauth} 923 Postproc: ${enable_postprocessor} 924 HTTPS support: ${MSG_HTTPS} 925 poll support: ${enable_poll=no} 926 epoll support: ${enable_epoll=no} 927 build docs: ${enable_doc} 928 build examples: ${enable_examples} 929 libmicrospdy: ${enable_spdy} 930 spdylay (testing): ${have_spdylay} 931 ]) 932 933 if test "x$enable_https" = "xyes" 934 then 935 AC_MSG_NOTICE([HTTPS subsystem configuration: 936 License : LGPL only 937 ]) 938 else 939 AC_MSG_NOTICE([ 940 License : LGPL or eCos 941 ]) 942 fi 943 944 if test "x$enable_bauth" != "xyes" -o \ 945 "x$enable_dauth" != "xyes" -o \ 946 "x$enable_postprocessor" != "xyes" 947 then 948 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.]) 949 fi 950