1# 2# This file is part of nzbget. See <http://nzbget.net>. 3# 4# Copyright (C) 2008-2021 Andrey Prygunkov <hugbug@users.sourceforge.net> 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <http://www.gnu.org/licenses/>. 18# 19 20# -*- Autoconf -*- 21# Process this file with autoconf to produce a configure script. 22 23AC_PREREQ(2.65) 24AC_INIT(nzbget, 21.1, hugbug@users.sourceforge.net) 25AC_CONFIG_AUX_DIR(posix) 26AC_CANONICAL_TARGET 27AM_INIT_AUTOMAKE([foreign subdir-objects]) 28AC_CONFIG_SRCDIR([daemon/main/nzbget.cpp]) 29AC_CONFIG_HEADERS([config.h]) 30AM_MAINTAINER_MODE 31 32m4_include([posix/ax_cxx_compile_stdcxx.m4]) 33 34 35dnl 36dnl Check for programs. 37dnl 38AC_PROG_CXX 39AC_PATH_PROG(TAR, tar, $FALSE) 40AC_PATH_PROG(MAKE, gmake, $FALSE) 41AC_PROG_INSTALL 42 43 44dnl 45dnl Do all tests with c++ compiler. 46dnl 47AC_LANG(C++) 48 49dnl 50dnl Determine compiler switches to support C++14 standard. 51dnl 52AC_MSG_CHECKING(whether to test compiler features) 53AC_ARG_ENABLE(cpp-check, 54 [AS_HELP_STRING([--disable-cpp-check], [disable check for C++14 compiler features])], 55 [ ENABLECPPCHECK=$enableval ], 56 [ ENABLECPPCHECK=yes] ) 57AC_MSG_RESULT($ENABLECPPCHECK) 58if test "$ENABLECPPCHECK" = "yes"; then 59 AX_CXX_COMPILE_STDCXX(14,,[optional]) 60 if test "$HAVE_CXX14" != "1"; then 61 AC_MSG_ERROR("A compiler with support for C++14 language features is required. For details visit http://nzbget.net/cpp14") 62 fi 63fi 64 65dnl 66dnl Checks for header files. 67dnl 68AC_CHECK_HEADERS(sys/prctl.h regex.h endian.h getopt.h) 69 70 71dnl 72dnl Check for libs 73dnl 74AC_SEARCH_LIBS([pthread_create], [pthread]) 75AC_SEARCH_LIBS([socket], [socket]) 76AC_SEARCH_LIBS([inet_addr], [nsl]) 77AC_SEARCH_LIBS([hstrerror], [resolv]) 78 79 80dnl 81dnl Android NDK restrictions 82dnl 83AC_CHECK_FUNC(lockf, 84 [AC_CHECK_DECL(lockf, 85 [AC_DEFINE([HAVE_LOCKF], 1, [Define to 1 if lockf is supported])],, 86 [#include <unistd.h>])]) 87AC_CHECK_FUNC(pthread_cancel, 88 [AC_CHECK_DECL(pthread_cancel, 89 [AC_DEFINE([HAVE_PTHREAD_CANCEL], 1, [Define to 1 if pthread_cancel is supported])],, 90 [#include <pthread.h>])]) 91 92 93dnl 94dnl Getopt 95dnl 96AC_CHECK_FUNC(getopt_long, 97 [AC_DEFINE([HAVE_GETOPT_LONG], 1, [Define to 1 if getopt_long is supported])],) 98 99 100dnl 101dnl fsync 102dnl 103AC_CHECK_FUNC(fdatasync, 104 [AC_DEFINE([HAVE_FDATASYNC], 1, [Define to 1 if fdatasync is supported])],) 105AC_CHECK_DECL(F_FULLFSYNC, 106 [AC_DEFINE([HAVE_FULLFSYNC], 1, [Define to 1 if F_FULLFSYNC is supported])],,[#include <fcntl.h>]) 107 108dnl 109dnl use 64-Bits for file sizes 110dnl 111AC_SYS_LARGEFILE 112 113 114dnl 115dnl check ctime_r 116dnl 117AC_MSG_CHECKING(for ctime_r) 118AC_TRY_COMPILE( 119 [#include <time.h>], 120 [ time_t clock; char buf[26]; ctime_r(&clock, buf, 26); ], 121 AC_MSG_RESULT([[yes, and it takes 3 arguments]]) 122 FOUND="yes" 123 AC_DEFINE([HAVE_CTIME_R_3], 1, [Define to 1 if ctime_r takes 3 arguments]), 124 FOUND="no") 125if test "$FOUND" = "no"; then 126AC_TRY_COMPILE( 127 [#include <time.h>], 128 [ time_t clock; char buf[26]; ctime_r(&clock, buf); ], 129 AC_MSG_RESULT([[yes, and it takes 2 arguments]]) 130 FOUND="yes" 131 AC_DEFINE([HAVE_CTIME_R_2], 1, [Define to 1 if ctime_r takes 2 arguments]), 132 FOUND="no") 133fi 134if test "$FOUND" = "no"; then 135 AC_MSG_RESULT([no]) 136 AC_MSG_ERROR("function ctime_r not found") 137fi 138 139 140dnl 141dnl check getaddrinfo 142dnl 143AC_CHECK_FUNC(getaddrinfo, 144 FOUND="yes" 145 [AC_DEFINE([HAVE_GETADDRINFO], 1, [Define to 1 if getaddrinfo is supported])] 146 AC_SEARCH_LIBS([getaddrinfo], [nsl]), 147 FOUND="no") 148 149 150dnl 151dnl check gethostbyname_r, if getaddrinfo is not available 152dnl 153if test "$FOUND" = "no"; then 154 AC_MSG_CHECKING(for gethostbyname_r) 155 156 AC_TRY_COMPILE( 157 [#include <netdb.h>], 158 [ char* szHost; struct hostent hinfobuf; char* strbuf; int h_errnop; 159 struct hostent* hinfo = gethostbyname_r(szHost, &hinfobuf, strbuf, 1024, &h_errnop); ], 160 AC_MSG_RESULT([[yes, and it takes 5 arguments]]) 161 FOUND="yes" 162 AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if gethostbyname_r takes 5 arguments]), 163 FOUND="no") 164 165 if test "$FOUND" = "no"; then 166 AC_TRY_COMPILE( 167 [#include <netdb.h>], 168 [ char* szHost; struct hostent* hinfo; struct hostent hinfobuf; char* strbuf; int h_errnop; 169 int err = gethostbyname_r(szHost, &hinfobuf, strbuf, 1024, &hinfo, &h_errnop); ], 170 AC_MSG_RESULT([[yes, and it takes 6 arguments]]) 171 FOUND="yes" 172 AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if gethostbyname_r takes 6 arguments]), 173 FOUND="no") 174 fi 175 176 if test "$FOUND" = "no"; then 177 AC_TRY_COMPILE( 178 [#include <netdb.h>], 179 [ char* szHost; struct hostent hinfo; struct hostent_data hinfobuf; 180 int err = gethostbyname_r(szHost, &hinfo, &hinfobuf); ], 181 AC_MSG_RESULT([[yes, and it takes 3 arguments]]) 182 FOUND="yes" 183 AC_DEFINE([HAVE_GETHOSTBYNAME_R_3], 1, [Define to 1 if gethostbyname_r takes 3 arguments]), 184 AC_MSG_RESULT([[no]]) 185 FOUND="no") 186 fi 187 188 if test "$FOUND" = "yes"; then 189 AC_DEFINE([HAVE_GETHOSTBYNAME_R], 1, [Define to 1 if gethostbyname_r is supported]) 190 AC_SEARCH_LIBS([gethostbyname_r], [nsl]) 191 fi 192fi 193 194 195dnl 196dnl Determine what socket length (socklen_t) data type is 197dnl 198AC_MSG_CHECKING([for type of socket length (socklen_t)]) 199AC_TRY_COMPILE([ 200#include <stddef.h> 201#include <sys/types.h> 202#include <sys/socket.h>],[ 203(void)getsockopt (1, 1, 1, NULL, (socklen_t*)NULL)],[ 204 AC_MSG_RESULT(socklen_t) 205 SOCKLEN_T=socklen_t],[ 206 AC_TRY_COMPILE([ 207#include <stddef.h> 208#include <sys/types.h> 209#include <sys/socket.h>],[ 210(void)getsockopt (1, 1, 1, NULL, (size_t*)NULL)],[ 211 AC_MSG_RESULT(size_t) 212 SOCKLEN_T=size_t],[ 213 AC_TRY_COMPILE([ 214#include <stddef.h> 215#include <sys/types.h> 216#include <sys/socket.h>],[ 217(void)getsockopt (1, 1, 1, NULL, (int*)NULL)],[ 218 AC_MSG_RESULT(int) 219 SOCKLEN_T=int],[ 220 AC_MSG_WARN(could not determine) 221 SOCKLEN_T=int])])]) 222AC_DEFINE_UNQUOTED(SOCKLEN_T, $SOCKLEN_T, [Determine what socket length (socklen_t) data type is]) 223 224 225dnl 226dnl check cpu cores via sysconf 227dnl 228AC_MSG_CHECKING(for cpu cores via sysconf) 229AC_TRY_COMPILE( 230 [#include <unistd.h>], 231 [ int a = _SC_NPROCESSORS_ONLN; ], 232 FOUND="yes" 233 AC_MSG_RESULT([[yes]]) 234 AC_DEFINE([HAVE_SC_NPROCESSORS_ONLN], 1, [Define to 1 if _SC_NPROCESSORS_ONLN is present in unistd.h]), 235 FOUND="no") 236 237 238dnl 239dnl checks for libxml2 includes and libraries. 240dnl 241AC_MSG_CHECKING(whether to use libxml2) 242AC_ARG_ENABLE(libxml2, 243 [AS_HELP_STRING([--disable-libxml2], [do not use libxml2 (removes dependency from libxml2-library, only for development purposes)])], 244 [USELIBXML2=$enableval], 245 [USELIBXML2=yes] ) 246AC_MSG_RESULT($USELIBXML2) 247if test "$USELIBXML2" = "yes"; then 248 AC_ARG_WITH(libxml2_includes, 249 [AS_HELP_STRING([--with-libxml2-includes=DIR], [libxml2 include directory])], 250 [CPPFLAGS="${CPPFLAGS} -I${withval}"] 251 [INCVAL="yes"], 252 [INCVAL="no"]) 253 AC_ARG_WITH(libxml2_libraries, 254 [AS_HELP_STRING([--with-libxml2-libraries=DIR], [libxml2 library directory])], 255 [LDFLAGS="${LDFLAGS} -L${withval}"] 256 [LIBVAL="yes"], 257 [LIBVAL="no"]) 258 if test "$INCVAL" = "no" -o "$LIBVAL" = "no"; then 259 PKG_CHECK_MODULES(libxml2, libxml-2.0, 260 [LIBS="${LIBS} $libxml2_LIBS"] 261 [CPPFLAGS="${CPPFLAGS} $libxml2_CFLAGS"], 262 AC_MSG_ERROR("libxml2 library not found")) 263 fi 264 AC_CHECK_HEADER(libxml/tree.h,, 265 AC_MSG_ERROR("libxml2 header files not found")) 266 AC_SEARCH_LIBS([xmlNewNode], [xml2], , 267 AC_MSG_ERROR("libxml2 library not found")) 268else 269 AC_DEFINE([DISABLE_LIBXML2],1,[Define to 1 to not use libxml2, only for development purposes]) 270fi 271 272 273dnl 274dnl Use curses. Deafult: yes 275dnl 276AC_MSG_CHECKING(whether to use curses) 277AC_ARG_ENABLE(curses, 278 [AS_HELP_STRING([--disable-curses], [do not use curses (removes dependency from curses-library)])], 279 [USECURSES=$enableval], 280 [USECURSES=yes] ) 281AC_MSG_RESULT($USECURSES) 282if test "$USECURSES" = "yes"; then 283 AC_ARG_WITH(libcurses_includes, 284 [AS_HELP_STRING([--with-libcurses-includes=DIR], [libcurses include directory])], 285 [CPPFLAGS="${CPPFLAGS} -I${withval}"] 286 [INCVAL="yes"], 287 [INCVAL="no"]) 288 AC_ARG_WITH(libcurses_libraries, 289 [AS_HELP_STRING([--with-libcurses-libraries=DIR], [libcurses library directory])], 290 [LDFLAGS="${LDFLAGS} -L${withval}"] 291 [LIBVAL="yes"], 292 [LIBVAL="no"]) 293 if test "$INCVAL" = "no" -o "$LIBVAL" = "no"; then 294 PKG_CHECK_MODULES(ncurses, ncurses, 295 [LIBS="${LIBS} $ncurses_LIBS"] 296 [CPPFLAGS="${CPPFLAGS} $ncurses_CFLAGS"], 297 AC_MSG_ERROR("ncurses library not found")) 298 fi 299 300 AC_CHECK_HEADER(ncurses.h, 301 FOUND=yes 302 AC_DEFINE([HAVE_NCURSES_H],1,[Define to 1 if you have the <ncurses.h> header file.]), 303 FOUND=no) 304 if test "$FOUND" = "no"; then 305 AC_CHECK_HEADER(ncurses/ncurses.h, 306 FOUND=yes 307 AC_DEFINE([HAVE_NCURSES_NCURSES_H],1,[Define to 1 if you have the <ncurses/ncurses.h> header file.]), 308 FOUND=no) 309 fi 310 if test "$FOUND" = "no"; then 311 AC_CHECK_HEADER(curses.h, 312 FOUND=yes 313 AC_DEFINE([HAVE_CURSES_H],1,[Define to 1 if you have the <curses.h> header file.]), 314 FOUND=no) 315 fi 316 if test "$FOUND" = "no"; then 317 AC_MSG_ERROR([Couldn't find curses headers (ncurses.h or curses.h)]) 318 fi 319 AC_SEARCH_LIBS([refresh], [ncurses curses],, 320 AC_ERROR([Couldn't find curses library])) 321 AC_SEARCH_LIBS([nodelay], [ncurses curses tinfo],, 322 AC_ERROR([Couldn't find curses library])) 323else 324 AC_DEFINE([DISABLE_CURSES],1,[Define to 1 to not use curses]) 325fi 326 327 328dnl 329dnl Use par-checking. Deafult: yes. 330dnl 331AC_MSG_CHECKING(whether to include code for par-checking) 332AC_ARG_ENABLE(parcheck, 333 [AS_HELP_STRING([--disable-parcheck], [do not include par-check/-repair-support])], 334 [ ENABLEPARCHECK=$enableval ], 335 [ ENABLEPARCHECK=yes] ) 336AC_MSG_RESULT($ENABLEPARCHECK) 337if test "$ENABLEPARCHECK" = "yes"; then 338 dnl PAR2 checks. 339 dnl 340 dnl Checks for typedefs, structures, and compiler characteristics. 341 AC_TYPE_SIZE_T 342 AC_FUNC_FSEEKO 343 dnl Checks for library functions. 344 AC_CHECK_FUNCS([stricmp]) 345 AC_CHECK_FUNCS([getopt]) 346 AM_CONDITIONAL(WITH_PAR2, true) 347else 348 AC_DEFINE([DISABLE_PARCHECK],1,[Define to 1 to disable par-verification and repair]) 349 AM_CONDITIONAL(WITH_PAR2, false) 350fi 351 352 353dnl 354dnl Use TLS/SSL. Deafult: yes 355dnl 356AC_MSG_CHECKING(whether to use TLS/SSL) 357AC_ARG_ENABLE(tls, 358 [AS_HELP_STRING([--disable-tls], [do not use TLS/SSL (removes dependency from TLS/SSL-libraries)])], 359 [ USETLS=$enableval ], 360 [ USETLS=yes] ) 361AC_MSG_RESULT($USETLS) 362if test "$USETLS" = "yes"; then 363 AC_ARG_WITH(tlslib, 364 [AS_HELP_STRING([--with-tlslib=(OpenSSL, GnuTLS)], [TLS/SSL library to use])], 365 [TLSLIB="$withval"]) 366 if test "$TLSLIB" != "GnuTLS" -a "$TLSLIB" != "OpenSSL" -a "$TLSLIB" != ""; then 367 AC_MSG_ERROR([Invalid argument for option --with-tlslib]) 368 fi 369 370 if test "$TLSLIB" = "OpenSSL" -o "$TLSLIB" = ""; then 371 AC_ARG_WITH(openssl_includes, 372 [AS_HELP_STRING([--with-openssl-includes=DIR], [OpenSSL include directory])], 373 [CPPFLAGS="${CPPFLAGS} -I${withval}"] 374 [INCVAL="yes"], 375 [INCVAL="no"]) 376 AC_ARG_WITH(openssl_libraries, 377 [AS_HELP_STRING([--with-openssl-libraries=DIR], [OpenSSL library directory])], 378 [LDFLAGS="${LDFLAGS} -L${withval}"] 379 [LIBVAL="yes"], 380 [LIBVAL="no"]) 381 if test "$INCVAL" = "no" -o "$LIBVAL" = "no"; then 382 PKG_CHECK_MODULES([openssl], [openssl], 383 [LIBS="${LIBS} $openssl_LIBS"] 384 [CPPFLAGS="${CPPFLAGS} $openssl_CFLAGS"]) 385 fi 386 387 AC_CHECK_HEADER(openssl/ssl.h, 388 FOUND=yes 389 TLSHEADERS=yes, 390 FOUND=no) 391 if test "$FOUND" = "no" -a "$TLSLIB" = "OpenSSL"; then 392 AC_MSG_ERROR([Couldn't find OpenSSL headers (ssl.h)]) 393 fi 394 if test "$FOUND" = "yes"; then 395 AC_SEARCH_LIBS([ASN1_OBJECT_free], [crypto], 396 AC_SEARCH_LIBS([SSL_CTX_new], [ssl], 397 FOUND=yes, 398 FOUND=no), 399 FOUND=no) 400 if test "$FOUND" = "no" -a "$TLSLIB" = "OpenSSL"; then 401 AC_MSG_ERROR([Couldn't find OpenSSL library]) 402 fi 403 if test "$FOUND" = "yes"; then 404 TLSLIB="OpenSSL" 405 AC_DEFINE([HAVE_OPENSSL],1,[Define to 1 to use OpenSSL library for TLS/SSL-support and decryption.]) 406 AC_SEARCH_LIBS([X509_check_host], [crypto], 407 AC_DEFINE([HAVE_X509_CHECK_HOST],1,[Define to 1 if OpenSSL supports function "X509_check_host".])) 408 fi 409 fi 410 fi 411 412 if test "$TLSLIB" = "GnuTLS" -o "$TLSLIB" = ""; then 413 AC_ARG_WITH(libgnutls_includes, 414 [AS_HELP_STRING([--with-libgnutls-includes=DIR], [GnuTLS include directory])], 415 [CPPFLAGS="${CPPFLAGS} -I${withval}"] 416 [INCVAL="yes"], 417 [INCVAL="no"]) 418 AC_ARG_WITH(libgnutls_libraries, 419 [AS_HELP_STRING([--with-libgnutls-libraries=DIR], [GnuTLS library directory])], 420 [LDFLAGS="${LDFLAGS} -L${withval}"] 421 [LIBVAL="yes"], 422 [LIBVAL="no"]) 423 if test "$INCVAL" = "no" -o "$LIBVAL" = "no"; then 424 PKG_CHECK_MODULES([gnutls], [gnutls], 425 [LIBS="${LIBS} $gnutls_LIBS"] 426 [CPPFLAGS="${CPPFLAGS} $gnutls_CFLAGS"]) 427 fi 428 429 AC_CHECK_HEADER(gnutls/gnutls.h, 430 FOUND=yes 431 TLSHEADERS=yes, 432 FOUND=no) 433 if test "$FOUND" = "no" -a "$TLSLIB" = "GnuTLS"; then 434 AC_MSG_ERROR([Couldn't find GnuTLS headers (gnutls.h)]) 435 fi 436 if test "$FOUND" = "yes"; then 437 AC_SEARCH_LIBS([gnutls_global_init], [gnutls], 438 FOUND=yes, 439 FOUND=no) 440 if test "$FOUND" = "yes"; then 441 dnl gcrypt is optional 442 AC_MSG_CHECKING([whether gcrypt is needed]) 443 AC_TRY_COMPILE( 444 [#include <gnutls/gnutls.h>] 445 [#if GNUTLS_VERSION_NUMBER <= 0x020b00] 446 [compile error] 447 [#endif], 448 [int a;], 449 AC_MSG_RESULT([no]) 450 GCRYPT=no, 451 AC_MSG_RESULT([yes]) 452 GCRYPT=yes) 453 if test "$GCRYPT" = "yes"; then 454 AC_CHECK_HEADER([gcrypt.h], 455 AC_SEARCH_LIBS([gcry_control], [gnutls gcrypt], 456 FOUND=yes, 457 FOUND=no), 458 FOUND=yes) 459 fi 460 fi 461 if test "$FOUND" = "no" -a "$TLSLIB" = "GnuTLS"; then 462 AC_MSG_ERROR([Couldn't find GnuTLS library]) 463 fi 464 if test "$FOUND" = "yes"; then 465 TLSLIB="GnuTLS" 466 AC_DEFINE([HAVE_LIBGNUTLS],1,[Define to 1 to use GnuTLS library for TLS/SSL-support.]) 467 fi 468 fi 469 470 if test "$TLSLIB" = "GnuTLS"; then 471 AC_ARG_WITH(libnettle_includes, 472 [AS_HELP_STRING([--with-libnettle-includes=DIR], [Nettle include directory])], 473 [CPPFLAGS="${CPPFLAGS} -I${withval}"] 474 [INCVAL="yes"], 475 [INCVAL="no"]) 476 AC_ARG_WITH(libnettle_libraries, 477 [AS_HELP_STRING([--with-libnettle-libraries=DIR], [Nettle library directory])], 478 [LDFLAGS="${LDFLAGS} -L${withval}"] 479 [LIBVAL="yes"], 480 [LIBVAL="no"]) 481 if test "$INCVAL" = "no" -o "$LIBVAL" = "no"; then 482 PKG_CHECK_MODULES([nettle], [nettle], 483 [LIBS="${LIBS} $nettle_LIBS"] 484 [CPPFLAGS="${CPPFLAGS} $nettle_CFLAGS"]) 485 fi 486 AC_CHECK_HEADER(nettle/sha.h, 487 FOUND=yes, 488 FOUND=no) 489 if test "$FOUND" = "no"; then 490 AC_MSG_ERROR([Couldn't find Nettle headers (sha.h)]) 491 fi 492 AC_SEARCH_LIBS([nettle_pbkdf2_hmac_sha256], [nettle], 493 FOUND=yes, 494 FOUND=no) 495 if test "$FOUND" = "no"; then 496 AC_MSG_ERROR([Couldn't find Nettle library, required when using GnuTLS]) 497 fi 498 if test "$FOUND" = "yes"; then 499 AC_DEFINE([HAVE_NETTLE],1,[Define to 1 to use Nettle library for decryption.]) 500 fi 501 fi 502 fi 503 504 if test "$TLSLIB" = ""; then 505 if test "$TLSHEADERS" = ""; then 506 AC_MSG_ERROR([Couldn't find neither OpenSSL nor GnuTLS headers (ssl.h or gnutls.h)]) 507 else 508 AC_MSG_ERROR([Couldn't find neither OpenSSL nor GnuTLS library]) 509 fi 510 fi 511else 512 AC_DEFINE([DISABLE_TLS],1,[Define to 1 to not use TLS/SSL]) 513fi 514 515 516dnl 517dnl checks for zlib includes and libraries. 518dnl 519AC_MSG_CHECKING(whether to use gzip) 520AC_ARG_ENABLE(gzip, 521 [AS_HELP_STRING([--disable-gzip], [disable gzip-compression/decompression (removes dependency from zlib-library)])], 522 [USEZLIB=$enableval], 523 [USEZLIB=yes] ) 524AC_MSG_RESULT($USEZLIB) 525if test "$USEZLIB" = "yes"; then 526 AC_ARG_WITH(zlib_includes, 527 [AS_HELP_STRING([--with-zlib-includes=DIR], [zlib include directory])], 528 [CPPFLAGS="${CPPFLAGS} -I${withval}"] 529 [INCVAL="yes"], 530 [INCVAL="no"]) 531 AC_ARG_WITH(zlib_libraries, 532 [AS_HELP_STRING([--with-zlib-libraries=DIR], [zlib library directory])], 533 [LDFLAGS="${LDFLAGS} -L${withval}"] 534 [LIBVAL="yes"], 535 [LIBVAL="no"]) 536 if test "$INCVAL" = "no" -o "$LIBVAL" = "no"; then 537 PKG_CHECK_MODULES([zlib], [zlib], 538 [LIBS="${LIBS} $zlib_LIBS"] 539 [CPPFLAGS="${CPPFLAGS} $zlib_CFLAGS"]) 540 fi 541 542 AC_CHECK_HEADER(zlib.h,, 543 AC_MSG_ERROR("zlib header files not found")) 544 AC_SEARCH_LIBS([deflateBound], [z], , 545 AC_MSG_ERROR("zlib library not found")) 546else 547 AC_DEFINE([DISABLE_GZIP],1,[Define to 1 to disable gzip-support]) 548fi 549 550 551dnl 552dnl Determine if CPU supports SIMD instructions 553dnl 554AC_MSG_CHECKING(whether to use SIMD-optimized routines) 555USE_SIMD=no 556case $host_cpu in 557 i?86|x86_64|amd64) 558 SSE2_CXXFLAGS="-msse2" 559 SSSE3_CXXFLAGS="-mssse3" 560 PCLMUL_CXXFLAGS="-msse4.1 -mpclmul" 561 USE_SIMD=yes 562 ;; 563 arm*) 564 NEON_CXXFLAGS="-mfpu=neon" 565 ACLECRC_CXXFLAGS="-march=armv8-a+crc -fpermissive" 566 USE_SIMD=yes 567 ;; 568 aarch64) 569 ACLECRC_CXXFLAGS="-march=armv8-a+crc -fpermissive" 570 USE_SIMD=yes 571 ;; 572esac 573USE_SIMD=no 574AC_MSG_RESULT($USE_SIMD) 575 576 577dnl 578dnl Some Linux systems require an empty signal handler for SIGCHLD 579dnl in order for exit codes to be correctly delivered to parent process. 580dnl Some 32-Bit BSD systems however may not function properly if the handler is installed. 581dnl The default behavior is to install the handler. 582dnl 583AC_MSG_CHECKING(whether to use an empty SIGCHLD handler) 584AC_ARG_ENABLE(sigchld-handler, 585 [AS_HELP_STRING([--disable-sigchld-handler], [do not use sigchld-handler (the disabling may be neccessary on 32-Bit BSD)])], 586 [SIGCHLDHANDLER=$enableval], 587 [SIGCHLDHANDLER=yes]) 588AC_MSG_RESULT($SIGCHLDHANDLER) 589if test "$SIGCHLDHANDLER" = "yes"; then 590 AC_DEFINE([SIGCHLD_HANDLER], 1, [Define to 1 to install an empty signal handler for SIGCHLD]) 591fi 592 593 594dnl 595dnl Debugging. Default: no 596dnl 597AC_MSG_CHECKING(whether to include all debugging code) 598AC_ARG_ENABLE(debug, 599 [AS_HELP_STRING([--enable-debug], [enable debugging])], 600 [ ENABLEDEBUG=$enableval ], 601 [ ENABLEDEBUG=no] ) 602AC_MSG_RESULT($ENABLEDEBUG) 603 604 605if test "$ENABLEDEBUG" = "yes"; then 606 607dnl 608dnl Begin of debugging code 609dnl 610 611AC_DEFINE([DEBUG],1,Define to 1 to include debug-code) 612 613 614dnl 615dnl check for __FUNCTION__ or __func__ macro 616dnl 617AC_MSG_CHECKING(for macro returning current function name) 618AC_TRY_COMPILE( 619 [#include <stdio.h>], [printf("%s\n", __FUNCTION__);], 620 AC_MSG_RESULT(__FUNCTION__) 621 FUNCTION_MACRO_NAME=__FUNCTION__, 622AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);], 623 AC_MSG_RESULT(__func__) 624 FUNCTION_MACRO_NAME=__func__, 625 AC_MSG_RESULT(none))) 626if test "$FUNCTION_MACRO_NAME" != ""; then 627 AC_DEFINE_UNQUOTED(FUNCTION_MACRO_NAME, $FUNCTION_MACRO_NAME, [Define to the name of macro which returns the name of function being compiled]) 628fi 629 630 631dnl 632dnl variadic macros 633dnl 634AC_MSG_CHECKING(for variadic macros) 635AC_TRY_COMPILE( 636 [ #define macro(...) macrofunc(__VA_ARGS__) ] 637 [ int macrofunc(int a, int b) { return a + b; } ], 638 [ int a=macro(1, 2); ], 639 AC_MSG_RESULT([yes]) 640 AC_DEFINE([HAVE_VARIADIC_MACROS], 1, Define to 1 if variadic macros are supported), 641 AC_MSG_RESULT([no])) 642 643 644dnl 645dnl Backtracing on segmentation faults 646dnl 647AC_MSG_CHECKING(for backtrace) 648AC_TRY_COMPILE( 649 [#include <execinfo.h>] 650 [#include <stdio.h>] 651 [#include <stdlib.h>], 652 [ void *array[100]; size_t size; char **strings; ] 653 [ size = backtrace(array, 100); ] 654 [ strings = backtrace_symbols(array, size); ], 655 FOUND=yes 656 AC_MSG_RESULT([[yes]]) 657 AC_DEFINE([HAVE_BACKTRACE], 1, [Define to 1 to create stacktrace on segmentation faults]), 658 FOUND=no 659 AC_MSG_RESULT([[no]])) 660 661 662dnl 663dnl "rdynamic" linker flag 664dnl 665AC_MSG_CHECKING(for rdynamic linker flag) 666 old_LDFLAGS="$LDFLAGS" 667 LDFLAGS="$LDFLAGS -rdynamic" 668 AC_TRY_LINK([], [], 669 AC_MSG_RESULT([[yes]]), 670 AC_MSG_RESULT([[no]]) 671 [LDFLAGS="$old_LDFLAGS"]) 672 673dnl 674dnl End of debugging code 675dnl 676else 677AC_DEFINE([NDEBUG],1,Define to 1 to exclude debug-code) 678fi 679 680 681dnl 682dnl Enable test suite. Deafult: no. 683dnl 684AC_MSG_CHECKING(whether to enable unit and integration tests) 685AC_ARG_ENABLE(tests, 686 [AS_HELP_STRING([--enable-tests], [enable unit and integration tests])], 687 [ ENABLETESTS=$enableval ], 688 [ ENABLETESTS=no] ) 689AC_MSG_RESULT($ENABLETESTS) 690if test "$ENABLETESTS" = "yes"; then 691 AC_DEFINE([ENABLE_TESTS],1,[Define to 1 to enable unit and integration tests]) 692 AM_CONDITIONAL(WITH_TESTS, true) 693else 694 AM_CONDITIONAL(WITH_TESTS, false) 695fi 696 697AC_CONFIG_FILES([Makefile]) 698AC_OUTPUT 699