"Fossies" - the Fresh Open Source Software Archive

Member "knot-2.9.2/configure.ac" (12 Dec 2019, 25778 Bytes) of package /linux/misc/dns/knot-2.9.2.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "configure.ac": 2.9.1_vs_2.9.2.

    1 AC_PREREQ([2.60])
    2 
    3 m4_define([knot_VERSION_MAJOR], 2)dnl
    4 m4_define([knot_VERSION_MINOR], 9)dnl
    5 m4_define([knot_VERSION_PATCH], 2)dnl Leave empty if the master branch!
    6 m4_include([m4/knot-version.m4])
    7 
    8 AC_INIT([knot], knot_PKG_VERSION, [knot-dns@labs.nic.cz])
    9 AM_INIT_AUTOMAKE([foreign std-options subdir-objects no-dist-gzip dist-xz -Wall -Werror])
   10 AM_SILENT_RULES([yes])
   11 AC_CONFIG_SRCDIR([src/knot])
   12 AC_CONFIG_HEADERS([src/config.h])
   13 AC_CONFIG_MACRO_DIR([m4])
   14 AC_USE_SYSTEM_EXTENSIONS
   15 AC_CANONICAL_HOST
   16 
   17 # Update library versions
   18 # https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
   19 KNOT_LIB_VERSION([libknot],    10, 0, 0)
   20 KNOT_LIB_VERSION([libdnssec],   7, 0, 0)
   21 KNOT_LIB_VERSION([libzscanner], 3, 0, 0)
   22 
   23 AC_SUBST([KNOT_VERSION_MAJOR], knot_VERSION_MAJOR)
   24 AC_SUBST([KNOT_VERSION_MINOR], knot_VERSION_MINOR)
   25 AC_SUBST([KNOT_VERSION_PATCH], knot_VERSION_PATCH)
   26 
   27 # Store ./configure parameters and CFLAGS
   28 AC_DEFINE_UNQUOTED([CONFIGURE_PARAMS],["$*"],[Params passed to configure])
   29 AC_DEFINE_UNQUOTED([CONFIGURE_CFLAGS],["$CFLAGS"],[Passed CFLAGS from environment])
   30 
   31 AC_CONFIG_FILES([src/libknot/version.h
   32                  src/libdnssec/version.h
   33                  src/libzscanner/version.h])
   34 
   35 # Automatically update release date based on NEWS
   36 AC_PROG_SED
   37 release_date=$($SED -n 's/^Knot DNS .* (\(.*\))/\1/p;q;' ${srcdir}/NEWS)
   38 AC_SUBST([RELEASE_DATE], $release_date)
   39 
   40 # Set compiler compatibility flags
   41 AC_PROG_CC_C99
   42 AM_PROG_CC_C_O
   43 AC_PROG_CPP_WERROR
   44 
   45 # Set default CFLAGS
   46 CFLAGS="$CFLAGS -Wall -Wshadow -Werror=format-security -Werror=implicit -Wstrict-prototypes"
   47 
   48 AX_CHECK_COMPILE_FLAG("-fpredictive-commoning", [CFLAGS="$CFLAGS -fpredictive-commoning"], [], "-Werror")
   49 AX_CHECK_LINK_FLAG(["-Wl,--exclude-libs,ALL"], [ldflag_exclude_libs="-Wl,--exclude-libs,ALL"], [ldflag_exclude_libs=""], "")
   50 AC_SUBST([LDFLAG_EXCLUDE_LIBS], $ldflag_exclude_libs)
   51 
   52 # Check if an archiver is available
   53 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
   54 
   55 AC_PROG_INSTALL
   56 
   57 # Initialize libtool
   58 LT_INIT
   59 
   60 # Use pkg-config
   61 PKG_PROG_PKG_CONFIG
   62 m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], [AC_SUBST([pkgconfigdir], ['${libdir}/pkgconfig'])])
   63 AC_CONFIG_FILES([src/knotd.pc
   64                  src/libknot.pc
   65                  src/libdnssec.pc
   66                  src/libzscanner.pc
   67                  ])
   68 
   69 # Default directories
   70 knot_prefix=$ac_default_prefix
   71 AS_IF([test "$prefix" != NONE], [knot_prefix=$prefix])
   72 
   73 run_dir="${localstatedir}/run/knot"
   74 AC_ARG_WITH([rundir],
   75         AC_HELP_STRING([--with-rundir=path], [Path to run-time variable data (pid, sockets...). [default=LOCALSTATEDIR/run/knot]]),
   76         [run_dir=$withval])
   77 AC_SUBST(run_dir)
   78 
   79 storage_dir="${localstatedir}/lib/knot"
   80 AC_ARG_WITH([storage],
   81         AC_HELP_STRING([--with-storage=path], [Default storage directory (slave zones, persistent data). [default=LOCALSTATEDIR/lib/knot]]),
   82         [storage_dir=$withval])
   83 AC_SUBST(storage_dir)
   84 
   85 config_dir="${sysconfdir}/knot"
   86 AC_ARG_WITH([configdir],
   87         AC_HELP_STRING([--with-configdir=path], [Default directory for configuration. [default=SYSCONFDIR/knot]]),
   88         [config_dir=$withval])
   89 AC_SUBST(config_dir)
   90 
   91 module_dir=
   92 module_instdir="${libdir}/knot/modules-${KNOT_VERSION_MAJOR}.${KNOT_VERSION_MINOR}"
   93 AC_ARG_WITH([moduledir],
   94         AC_HELP_STRING([--with-moduledir=path], [Path to auto-loaded dynamic modules. [default not set]]),
   95         [module_dir=$withval module_instdir=$module_dir])
   96 AC_SUBST(module_instdir)
   97 AC_SUBST(module_dir)
   98 
   99 # Build Knot DNS daemon
  100 AC_ARG_ENABLE([daemon],
  101     AS_HELP_STRING([--disable-daemon], [Don't build Knot DNS main daemon]), [], [enable_daemon=yes])
  102 AM_CONDITIONAL([HAVE_DAEMON], [test "$enable_daemon" = "yes"])
  103 
  104 # Build Knot DNS modules
  105 AC_ARG_ENABLE([modules],
  106     AS_HELP_STRING([--disable-modules], [Don't build Knot DNS modules]), [], [enable_modules=yes])
  107 
  108 # Build Knot DNS utilities
  109 AC_ARG_ENABLE([utilities],
  110     AS_HELP_STRING([--disable-utilities], [Don't build Knot DNS utilities]), [], [enable_utilities=yes])
  111 AM_CONDITIONAL([HAVE_UTILS], [test "$enable_utilities" = "yes"])
  112 
  113 # Build Knot DNS documentation
  114 AC_ARG_ENABLE([documentation],
  115     AS_HELP_STRING([--disable-documentation], [Don't build Knot DNS documentation]), [], [enable_documentation=yes])
  116 AM_CONDITIONAL([HAVE_DOCS], [test "$enable_documentation" = "yes"])
  117 
  118 AM_CONDITIONAL([HAVE_LIBUTILS], test "$enable_utilities" != "no" -o \
  119                                      "$enable_daemon" != "no")
  120 ######################
  121 # Generic dependencies
  122 ######################
  123 
  124 AC_ARG_ENABLE([fastparser],
  125     AS_HELP_STRING([--disable-fastparser], [Disable use of fastest zone parser]),[],[
  126     # Set zone parser type - fastest on release build, slowest on dev build
  127     AS_IF([test -d ".git" -o "$PATCH_VERSION" = "dev"],[
  128         enable_fastparser=no
  129         ],[
  130         enable_fastparser=yes
  131         ])
  132     ])
  133 
  134 AX_CC_CLANG
  135 AS_IF([test "$enable_fastparser" = "yes"],[
  136     AS_IF([test -n "$CC_CLANG_VERSION"],[
  137       enable_fastparser=no
  138       AC_MSG_WARN([Fast zone parser disabled due to possible compiler bug.])
  139       AC_MSG_WARN([See https://llvm.org/bugs/show_bug.cgi?id=23490 for details.])
  140       AC_MSG_WARN([Use --enable-fastparser=force if your know your clang is fixed.])
  141     ])
  142 ])
  143 
  144 AS_IF([test "$enable_fastparser" = "force"],[enable_fastparser=yes])
  145 
  146 AM_CONDITIONAL([FAST_PARSER], [test "$enable_fastparser" = "yes"])
  147 
  148 # GnuTLS crypto backend
  149 PKG_CHECK_MODULES([gnutls], [gnutls >= 3.3], [
  150     save_CFLAGS=$CFLAGS
  151     save_LIBS=$LIBS
  152     CFLAGS="$CFLAGS $gnutls_CFLAGS"
  153     LIBS="$LIBS $gnutls_LIBS"
  154 
  155     AC_CHECK_FUNC([gnutls_pkcs11_copy_pubkey], [enable_pkcs11=yes], [enable_pkcs11=no])
  156     AS_IF([test "$enable_pkcs11" = yes],
  157         [AC_DEFINE([ENABLE_PKCS11], [1], [PKCS #11 support available])])
  158 
  159     AC_CHECK_DECL([GNUTLS_PK_EDDSA_ED25519],
  160         [AC_DEFINE([HAVE_ED25519], [1], [GnuTLS ED25519 support available])
  161          enable_ed25519=yes],
  162         [enable_ed25519=no],
  163         [#include <gnutls/gnutls.h>])
  164 
  165     AC_CHECK_FUNC([gnutls_privkey_sign_data2],
  166         [AC_DEFINE([HAVE_SIGN_DATA2], [1], [gnutls_privkey_sign_data2 available])])
  167 
  168     AC_CHECK_FUNC([gnutls_memset],
  169         [AC_DEFINE([HAVE_GNUTLS_MEMSET], [1], [gnutls_memset available])
  170          gnutls_memset=yes], [gnutls_memset=no])
  171 
  172     CFLAGS=$save_CFLAGS
  173     LIBS=$save_LIBS
  174 ])
  175 AM_CONDITIONAL([ENABLE_PKCS11], [test "$enable_pkcs11" = "yes"])
  176 
  177 AC_ARG_ENABLE([recvmmsg],
  178    AS_HELP_STRING([--enable-recvmmsg=auto|yes|no], [enable recvmmsg() network API [default=auto]]),
  179    [], [enable_recvmmsg=auto])
  180 
  181 AS_CASE([$enable_recvmmsg],
  182    [auto|yes],[
  183       AC_CHECK_FUNC([recvmmsg],
  184                     [AC_CHECK_FUNC([sendmmsg],[enable_recvmmsg=yes],[enable_recvmmsg=no])],
  185                     [enable_recvmmsg=no])],
  186    [no],[],
  187    [*], [AC_MSG_ERROR([Invalid value of --enable-recvmmsg.]
  188  )])
  189 
  190 AS_IF([test "$enable_recvmmsg" = yes],[
  191    AC_DEFINE([ENABLE_RECVMMSG], [1], [Use recvmmsg().])])
  192 
  193 # Reuseport support
  194 AS_CASE([$host_os],
  195   [freebsd*], [reuseport_opt=SO_REUSEPORT_LB],
  196   [*], [reuseport_opt=SO_REUSEPORT],
  197 )
  198 
  199 AC_ARG_ENABLE([reuseport],
  200   AS_HELP_STRING([--enable-reuseport=auto|yes|no],
  201                  [enable SO_REUSEPORT(_LB) support [default=auto]]),
  202   [], [enable_reuseport=auto]
  203 )
  204 
  205 AS_CASE([$enable_reuseport],
  206   [auto], [
  207     AS_CASE([$host_os],
  208       [freebsd*|linux*], [AC_CHECK_DECL([$reuseport_opt],
  209                                         [enable_reuseport=yes],
  210                                         [enable_reuseport=no],
  211                                         [#include <sys/socket.h>
  212                                         ])],
  213       [*], [enable_reuseport=no]
  214     )],
  215   [yes], [AC_CHECK_DECL([$reuseport_opt], [],
  216                         [AC_MSG_ERROR([SO_REUSEPORT(_LB) not supported.])],
  217                         [#include <sys/socket.h>
  218                         ])],
  219   [no], [],
  220   [*], [AC_MSG_ERROR([Invalid value of --enable-reuseport.])]
  221 )
  222 
  223 AS_IF([test "$enable_reuseport" = yes],[
  224    AC_DEFINE([ENABLE_REUSEPORT], [1], [Use SO_REUSEPORT(_LB).])])
  225 
  226 #########################################
  227 # Dependencies needed for Knot DNS daemon
  228 #########################################
  229 
  230 # Systemd integration
  231 AC_ARG_ENABLE([systemd],
  232     AS_HELP_STRING([--enable-systemd=auto|yes|no], [enable systemd integration [default=auto]]),
  233     [enable_systemd="$enableval"], [enable_systemd=auto])
  234 
  235 AS_IF([test "$enable_daemon" = "yes"],[
  236 
  237 AS_IF([test "$enable_systemd" != "no"],[
  238   AS_CASE([$enable_systemd],
  239     [auto],[PKG_CHECK_MODULES([systemd], [libsystemd], [enable_systemd=yes], [
  240             PKG_CHECK_MODULES([systemd], [libsystemd-daemon libsystemd-journal], [enable_systemd=yes], [enable_systemd=no])])],
  241     [yes],[PKG_CHECK_MODULES([systemd], [libsystemd], [], [
  242             PKG_CHECK_MODULES([systemd], [libsystemd-daemon libsystemd-journal])])],
  243     [*],[AC_MSG_ERROR([Invalid value of --enable-systemd.])])
  244     ])
  245 
  246 AS_IF([test "$enable_systemd" = "yes"],[
  247   AC_DEFINE([ENABLE_SYSTEMD], [1], [Use systemd integration.])])
  248 
  249 ]) dnl enable_daemon
  250 
  251 # Alternative memory allocator
  252 malloc_LIBS=
  253 AC_ARG_WITH([memory-allocator],
  254   AS_HELP_STRING([--with-memory-allocator=auto|LIBRARY],
  255                  [Use specific memory allocator for the server (e.g. jemalloc) [default=auto]]),
  256   AS_CASE([$withval],
  257     [auto], [],
  258     [*],    [malloc_LIBS="-l$withval"]
  259   )
  260   with_memory_allocator=[$withval]
  261 )
  262 AS_IF([test "$with_memory_allocator" = ""], [with_memory_allocator="auto"])
  263 AC_SUBST([malloc_LIBS])
  264 
  265 dnl Check for userspace-rcu library
  266 AC_ARG_WITH(urcu,
  267 [  --with-urcu=DIR        where to find userspace-rcu library])
  268 
  269 AS_IF([test "$enable_daemon" = "yes"],[
  270 
  271 AS_IF([test "$with_urcu" != "no"], [
  272   PKG_CHECK_MODULES([liburcu], liburcu, [
  273     liburcu_PKGCONFIG="liburcu >= 0.4.0"
  274     AC_SUBST([liburcu_PKGCONFIG])
  275     with_urcu=yes
  276   ],[
  277     for try_urcu in "$with_urcu" "" "/usr/local"; do
  278       save_LIBS="$LIBS"
  279       save_CPPFLAGS="$CPPFLAGS"
  280 
  281       AS_IF([test -d "$try_urcu"], [
  282         liburcu_CFLAGS="-I$try_urcu/include"
  283         liburcu_LIBS="-L$try_urcu/lib"
  284       ],[
  285         liburcu_CFLAGS=""
  286         liburcu_LIBS=""
  287       ])
  288 
  289       CPPFLAGS="$CPPFLAGS $liburcu_CFLAGS"
  290       LIBS="$LIBS $liburcu_LIBS"
  291 
  292       AC_SEARCH_LIBS([rcu_set_pointer_sym], [urcu], [
  293         with_urcu=yes
  294         liburcu_LIBS="$liburcu_LIBS -lurcu"
  295         AC_SUBST([liburcu_CFLAGS])
  296         AC_SUBST([liburcu_LIBS])
  297         break
  298       ],[
  299         CPPFLAGS="$save_CPPFLAGS"
  300         LIBS="$save_LIBS"
  301         with_urcu=no
  302         # do not cache result of AC_SEARCH_LIBS test
  303         unset ac_cv_search_rcu_set_pointer_sym
  304       ])
  305     done
  306     CPPFLAGS="$save_CPPFLAGS"
  307     LIBS="$save_LIBS"
  308 
  309     AS_IF([test "$with_urcu" = "no"],[
  310       AC_MSG_ERROR([liburcu is required])
  311       ])
  312   ])
  313 ])
  314 
  315 ])
  316 
  317 static_modules=""
  318 shared_modules=""
  319 static_modules_declars=""
  320 static_modules_init=""
  321 doc_modules=""
  322 
  323 KNOT_MODULE([cookies],     "yes")
  324 KNOT_MODULE([dnsproxy],    "yes", "non-shareable")
  325 KNOT_MODULE([dnstap],      "no")
  326 KNOT_MODULE([geoip],       "yes")
  327 KNOT_MODULE([noudp],       "yes")
  328 KNOT_MODULE([onlinesign],  "yes", "non-shareable")
  329 KNOT_MODULE([queryacl],    "yes")
  330 KNOT_MODULE([rrl],         "yes")
  331 KNOT_MODULE([stats],       "yes")
  332 KNOT_MODULE([synthrecord], "yes")
  333 KNOT_MODULE([whoami],      "yes")
  334 
  335 AC_SUBST([STATIC_MODULES_DECLARS], [$(printf "$static_modules_declars")])
  336 AM_SUBST_NOTMAKE([STATIC_MODULES_DECLARS])
  337 AC_SUBST([STATIC_MODULES_INIT], [$(printf "$static_modules_init")])
  338 AM_SUBST_NOTMAKE([STATIC_MODULES_INIT])
  339 AC_SUBST([DOC_MODULES], [$(printf "$doc_modules")])
  340 AM_SUBST_NOTMAKE([DOC_MODULES])
  341 
  342 # Check for Dnstap
  343 AC_ARG_ENABLE([dnstap],
  344   AS_HELP_STRING([--enable-dnstap], [Enable dnstap support for kdig (requires fstrm, protobuf-c)]),
  345   [], [enable_dnstap=no])
  346 
  347 AS_IF([test "$enable_dnstap" != "no" -o "$STATIC_MODULE_dnstap" != "no" -o "$SHARED_MODULE_dnstap" != "no"],[
  348   AC_PATH_PROG([PROTOC_C], [protoc-c])
  349   AS_IF([test -z "$PROTOC_C"],[
  350     AC_MSG_ERROR([The protoc-c program was not found. Please install protobuf-c!])
  351   ])
  352   PKG_CHECK_MODULES([libfstrm], [libfstrm])
  353   PKG_CHECK_MODULES([libprotobuf_c], [libprotobuf-c >= 1.0.0])
  354   AC_SUBST([DNSTAP_CFLAGS], ["$libfstrm_CFLAGS $libprotobuf_c_CFLAGS"])
  355   AC_SUBST([DNSTAP_LIBS], ["$libfstrm_LIBS $libprotobuf_c_LIBS"])
  356 ])
  357 
  358 AS_IF([test "$enable_dnstap" != "no"],[
  359   AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support for kdig])
  360 ])
  361 AM_CONDITIONAL([HAVE_DNSTAP], test "$enable_dnstap" != "no")
  362 
  363 AM_CONDITIONAL([HAVE_LIBDNSTAP], test "$enable_dnstap" != "no" -o \
  364                                       "$STATIC_MODULE_dnstap" != "no" -o \
  365                                       "$SHARED_MODULE_dnstap" != "no")
  366 # MaxMind DB for the GeoIP module
  367 AC_ARG_ENABLE([maxminddb],
  368     AS_HELP_STRING([--enable-maxminddb=auto|yes|no], [enable MaxMind DB [default=auto]]),
  369     [enable_maxminddb="$enableval"], [enable_maxminddb=auto])
  370 
  371 AS_IF([test "$enable_daemon" = "no"],[enable_maxminddb=no])
  372 AS_CASE([$enable_maxminddb],
  373   [no],[],
  374   [auto],[PKG_CHECK_MODULES([libmaxminddb], [libmaxminddb], [enable_maxminddb=yes], [enable_maxminddb=no])],
  375   [yes], [PKG_CHECK_MODULES([libmaxminddb], [libmaxminddb])],
  376   [*],[
  377     save_CFLAGS="$CFLAGS"
  378     save_LIBS="$LIBS"
  379     AS_IF([test "$enable_maxminddb" != ""],[
  380       LIBS="$LIBS -L$enable_maxminddb"
  381       CFLAGS="$CFLAGS -I$enable_maxminddb/include"
  382       ])
  383     AC_SEARCH_LIBS([MMDB_open], [maxminddb], [
  384       AS_IF([test "$enable_maxminddb" != ""], [
  385         libmaxminddb_CFLAGS="-I$enable_maxminddb/include"
  386         libmaxminddb_LIBS="-L$enable_maxminddb -lmaxminddb"
  387   ],[
  388   libmaxminddb_CFLAGS=""
  389   libmaxminddb_LIBS="$ac_cv_search_MMDB_open"
  390         ])
  391       ],[AC_MSG_ERROR("not found in `$enable_maxminddb'")])
  392     CFLAGS="$save_CFLAGS"
  393     LIBS="$save_LIBS"
  394     AC_SUBST([libmaxminddb_CFLAGS])
  395     AC_SUBST([libmaxminddb_LIBS])
  396     enable_maxminddb=yes
  397     ])
  398 
  399 AS_IF([test "$enable_maxminddb" = yes], [AC_DEFINE([HAVE_MAXMINDDB], [1], [Define to 1 to enable MaxMind DB.])])
  400 AM_CONDITIONAL([HAVE_MAXMINDDB], [test "$enable_maxminddb" = yes])
  401 
  402 dnl Check for LMDB
  403 lmdb_MIN_VERSION_MAJOR=0
  404 lmdb_MIN_VERSION_MINOR=9
  405 lmdb_MIN_VERSION_PATCH=15
  406 lmdb_MIN_VERSION_STRING="$lmdb_MIN_VERSION_MAJOR.$lmdb_MIN_VERSION_MINOR.$lmdb_MIN_VERSION_PATCH"
  407 lmdb_MIN_VERSION_FULL="$((($lmdb_MIN_VERSION_MAJOR << 24) | ($lmdb_MIN_VERSION_MINOR << 16) | $lmdb_MIN_VERSION_PATCH))"
  408 AC_ARG_WITH([lmdb],
  409     AC_HELP_STRING([--with-lmdb=[DIR]], [Link with external LMDB (>= $lmdb_MIN_VERSION_STRING)]),[
  410     with_lmdb=$withval
  411     ],[
  412     with_lmdb=auto
  413     ])
  414 
  415 have_lmdb=no
  416 
  417 AS_IF([test "$with_lmdb" != "no"],[
  418     save_CPPFLAGS=$CPPFLAGS
  419     save_LIBS=$LIBS
  420 
  421     # Look for lmdb in given path and common locations
  422     for try_lmdb in "$with_lmdb" "" "/usr/local"; do
  423 
  424       AS_IF([test -d "$try_lmdb"], [
  425         lmdb_CFLAGS="-I$try_lmdb/include"
  426         lmdb_LIBS="-L$try_lmdb/lib"
  427         ],[
  428         lmdb_CFLAGS=""
  429         lmdb_LIBS=""
  430         ])
  431 
  432       CPPFLAGS="$save_CPPFLAGS $lmdb_CFLAGS"
  433       LIBS="$save_LIBS $lmdb_LIBS"
  434 
  435       AC_SEARCH_LIBS([mdb_env_open], [lmdb], [
  436           AC_CHECK_HEADERS([lmdb.h], [], [
  437               AC_MSG_ERROR([lmdb headers not found in `$try_lmdb', is your installation complete?])])
  438           AC_COMPUTE_INT(lmdb_VERSION_FULL, MDB_VERSION_FULL, [#include <lmdb.h>],
  439               AC_MSG_ERROR([Unable to determine lmdb version from MDB_VERSION_FULL]))
  440           AS_IF([test "$lmdb_VERSION_FULL" -ge "$lmdb_MIN_VERSION_FULL"],[
  441               lmdb_LIBS="$lmdb_LIBS -llmdb"
  442               have_lmdb=yes],[
  443               unset lmdb_CFLAGS
  444               unset lmdb_LIBS
  445               AC_MSG_WARN([lmdb version 0.9.15 and higher not found, using embedded version])
  446               ])
  447           break
  448           ])
  449 
  450       unset lmdb_CFLAGS
  451       unset lmdb_LIBS
  452       # do not cache result of AC_SEARCH_LIBS test
  453       unset ac_cv_search_mdb_env_open
  454     done
  455 
  456     CPPFLAGS="$save_CPPFLAGS"
  457     LIBS="$save_LIBS"
  458 
  459     # fail the configure if we haven't found lmdb library in the system
  460     AS_IF([test "$with_lmdb" != "auto" -a "$have_lmdb" = "no"],[
  461         AC_MSG_ERROR([shared lmdb library not found])
  462         ])
  463     ])
  464 
  465 AS_IF([test "$have_lmdb" != "no"],[
  466     AC_SUBST([lmdb_LIBS])
  467     enable_lmdb=shared
  468     external_lmdb_LIBS=$lmdb_LIBS
  469     ],[
  470     enable_lmdb=embedded
  471     lmdb_CFLAGS="-I\$(top_srcdir)/src/contrib/lmdb"
  472     ])
  473 AM_CONDITIONAL([HAVE_LMDB], test "$enable_lmdb" = "shared")
  474 AC_SUBST([lmdb_CFLAGS])
  475 AC_SUBST([external_lmdb_LIBS])
  476 
  477 # LMDB mapping sizes
  478 conf_mapsize_default=500
  479 AC_ARG_WITH([conf_mapsize],
  480     AC_HELP_STRING([--with-conf-mapsize=NUM], [Configuration DB mapsize in MiB [default=$conf_mapsize_default]]),
  481     [conf_mapsize=$withval],[conf_mapsize=$conf_mapsize_default])
  482 
  483 AS_CASE([$conf_mapsize],
  484     [yes],[conf_mapsize=$conf_mapsize_default],
  485     [no], [AC_MSG_ERROR([conf_mapsize must be a number])],
  486     [*],  [AS_IF([test $conf_mapsize != $(( $conf_mapsize + 0 ))],
  487                  [AC_ERROR([conf_mapsize must be an integer number])])])
  488 AC_DEFINE_UNQUOTED([CONF_MAPSIZE], [$conf_mapsize], [Configuration DB mapsize.])
  489 AC_SUBST(conf_mapsize)
  490 
  491 # libedit
  492 AS_IF([test "$enable_daemon" = "yes" -o "$enable_utilities" = "yes"], [
  493   PKG_CHECK_MODULES([libedit], [libedit], [with_libedit=yes], [
  494     with_libedit=no
  495     AC_CHECK_HEADER([histedit.h], [
  496       # workaround for OpenBSD
  497       AS_CASE([$host_os],
  498         [openbsd*], [libedit_deps=-lcurses],
  499         [libedit_deps=]
  500       )
  501       AC_CHECK_LIB([edit], [el_init], [
  502         with_libedit=yes
  503         libedit_CFLAGS=
  504         libedit_LIBS="-ledit $libedit_deps"
  505         ], [], [$libedit_deps]
  506       )
  507     ])
  508   ])
  509   AS_IF([test "$with_libedit" != "yes"], [
  510     AC_MSG_ERROR([libedit not found])
  511   ])
  512 ], [
  513   with_libedit=no
  514   libedit_CFLAGS=
  515   libedit_LIBS=
  516 ])
  517 
  518 ############################################
  519 # Dependencies needed for Knot DNS utilities
  520 ############################################
  521 
  522 dnl Check for libidn.
  523 AC_ARG_WITH(libidn,
  524   AC_HELP_STRING([--with-libidn=[DIR]], [Support IDN (needs GNU libidn2 or libidn)]),
  525   with_libidn=$withval,
  526   with_libidn=yes
  527 )
  528 
  529 AS_IF([test "$enable_utilities" = "yes"], [
  530   AS_IF([test "$with_libidn" != "no"], [
  531     PKG_CHECK_MODULES([libidn2], [libidn2 >= 2.0.0], [
  532       with_libidn=libidn2
  533       AC_DEFINE([LIBIDN], [1], [Define to 1 to enable IDN support])
  534       AC_DEFINE([LIBIDN_HEADER], [<idn2.h>], [Define to proper libidn header])
  535     ], [
  536       PKG_CHECK_MODULES([libidn], [libidn >= 0.0.0], [
  537         with_libidn=libidn
  538         AC_DEFINE([LIBIDN], [1], [Define to 1 to enable IDN support])
  539         AC_DEFINE([LIBIDN_HEADER], [<idna.h>], [Define to proper libidn header])
  540       ], [
  541         with_libidn=no
  542         AC_MSG_WARN([libidn2 or libidn not found])
  543       ])
  544     ])
  545   ])
  546 ]) # Knot DNS utilities dependencies
  547 
  548 AS_IF([test "$enable_daemon" = "yes"], [
  549   PKG_CHECK_MODULES([cap_ng], [cap-ng], [enable_cap_ng=yes], [
  550     enable_cap_ng=no
  551     AC_CHECK_HEADER([cap-ng.h], [
  552       save_LIBS="$LIBS"
  553       AC_SEARCH_LIBS([capng_apply], [cap-ng], [
  554         enable_cap_ng=yes
  555         cap_ng_LIBS="$ac_cv_search_capng_apply"
  556         AC_SUBST([cap_ng_LIBS])
  557       ])
  558       LIBS="$save_LIBS"
  559     ])
  560   ])
  561 ], [
  562   enable_cap_ng=no
  563   cap_ng_LIBS=
  564 ])
  565 
  566 AS_IF([test "$enable_cap_ng" = yes],
  567   [AC_DEFINE([ENABLE_CAP_NG], [1], [POSIX capabilities available])]
  568 )
  569 
  570 save_LIBS="$LIBS"
  571 AC_SEARCH_LIBS([pthread_create], [pthread], [
  572   pthread_LIBS="$ac_cv_search_pthread_create"
  573   AC_SUBST([pthread_LIBS])
  574 ],[
  575   AC_MSG_ERROR([pthreads not found])
  576 ])
  577 LIBS="$save_LIBS"
  578 
  579 save_LIBS="$LIBS"
  580 AC_SEARCH_LIBS([dlopen], [dl], [
  581   dlopen_LIBS="$ac_cv_search_dlopen"
  582   AC_SUBST([dlopen_LIBS])
  583 ],[
  584   AC_MSG_ERROR([dlopen not found])
  585 ])
  586 LIBS="$save_LIBS"
  587 
  588 save_LIBS="$LIBS"
  589 AC_SEARCH_LIBS([pow], [m], [
  590   math_LIBS="$ac_cv_search_pow"
  591   AC_SUBST([math_LIBS])
  592 ],[
  593   AC_MSG_ERROR([math not found])
  594 ])
  595 LIBS="$save_LIBS"
  596 
  597 save_LIBS="$LIBS"
  598 AC_SEARCH_LIBS([pthread_setaffinity_np], [pthread], [
  599   AC_DEFINE([HAVE_PTHREAD_SETAFFINITY_NP], [1],
  600   [Define to 1 if you have the pthread_setaffinity_np function.])
  601 ])
  602 LIBS="$save_LIBS"
  603 
  604 # Checks for header files.
  605 AC_HEADER_RESOLV
  606 AC_CHECK_HEADERS_ONCE([pthread_np.h sys/uio.h bsd/string.h])
  607 
  608 # Checks for optional library functions.
  609 AC_CHECK_FUNCS([accept4 clock_gettime fgetln getline initgroups malloc_trim \
  610                 setgroups strlcat strlcpy sysctlbyname])
  611 
  612 # Check for robust memory cleanup implementations.
  613 AC_CHECK_FUNC([explicit_bzero], [
  614   AC_DEFINE([HAVE_EXPLICIT_BZERO], [1], [explicit_bzero available])
  615   explicit_bzero=yes], [explicit_bzero=no]
  616 )
  617 AC_CHECK_FUNC([explicit_memset], [
  618   AC_DEFINE([HAVE_EXPLICIT_MEMSET], [1], [explicit_memset available])
  619   explicit_memset=yes], [explicit_memset=no]
  620 )
  621 AM_CONDITIONAL([USE_GNUTLS_MEMSET], [test "$explicit_bzero" = "no" -a "$explicit_memset" = "no" -a "$gnutls_memset" = "yes"])
  622 
  623 # Check for mandatory library functions.
  624 AC_CHECK_FUNC([vasprintf], [], [
  625   AC_MSG_ERROR([vasprintf support in the libc is required])])
  626 
  627 # Check for cpu_set_t/cpuset_t compatibility
  628 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[cpu_set_t set; CPU_ZERO(&set);]])],
  629 [AC_DEFINE(HAVE_CPUSET_LINUX, 1, [Define if Linux-like cpu_set_t exists.])])
  630 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread_np.h>]], [[cpuset_t set; CPU_ZERO(&set);]])],
  631 [AC_DEFINE(HAVE_CPUSET_BSD, 1, [Define if FreeBSD-like cpuset_t exists.])])
  632 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sched.h>]], [[cpuset_t* set = cpuset_create(); cpuset_destroy(set);]])],
  633 [AC_DEFINE(HAVE_CPUSET_NETBSD, 1, [Define if cpuset_t and cpuset(3) exists.])])
  634 
  635 # Check for '__atomic' compiler builtin atomic functions.
  636 AC_LINK_IFELSE(
  637   [AC_LANG_PROGRAM([[#include <stdint.h>]],
  638                    [[uint64_t val = 0; __atomic_add_fetch(&val, 1, __ATOMIC_RELAXED);]])],
  639   [AC_DEFINE(HAVE_ATOMIC, 1, [Define to 1 if you have '__atomic' functions.])]
  640 )
  641 
  642 # Check for '__sync' compiler builtin atomic functions.
  643 AC_LINK_IFELSE(
  644   [AC_LANG_PROGRAM([[#include <stdint.h>]],
  645                    [[int val = 0; __sync_add_and_fetch(&val, 1);]])],
  646   [AC_DEFINE(HAVE_SYNC_ATOMIC, 1, [Define to 1 if you have '__sync' functions.])]
  647 )
  648 
  649 # Prepare CFLAG_VISIBILITY to be used where needed
  650 gl_VISIBILITY()
  651 
  652 # Add code coverage macro
  653 AX_CODE_COVERAGE
  654 
  655 AX_SANITIZER
  656 AS_IF([test -n "$sanitizer_CFLAGS"], [CFLAGS="$CFLAGS $sanitizer_CFLAGS"])
  657 AM_CONDITIONAL([FUZZER], [test "$with_fuzzer" != "no"])
  658 AM_CONDITIONAL([OSS_FUZZ], [test "$with_oss_fuzz" != "no"])
  659 
  660 AS_IF([test "$enable_documentation" = "yes"],[
  661 
  662 AC_PATH_PROGS([SPHINXBUILD], [sphinx-build sphinx-build-3], [false])
  663 AS_IF([test "$SPHINXBUILD" = "false"],
  664   [AC_MSG_WARN([Could not find the 'sphinx-build' executable, you will be unable to regenerate documentation.])],
  665   [AC_PATH_PROG([PDFLATEX], [pdflatex], [false])
  666    AS_IF([test "$PDFLATEX" = ""],
  667      [AC_MSG_WARN([Could not find the 'pdflatex' executable, you will be unable to generate PDF documentation.])])
  668    AC_PATH_PROG([MAKEINFO], [makeinfo], [false])
  669    AS_IF([test "$MAKEINFO" = "false"],
  670      [AC_MSG_WARN([Could not find the 'makeinfo' executable, you will be unable to generate info documentation.])])
  671   ])
  672 
  673 ])
  674 
  675 AM_CONDITIONAL([HAVE_SPHINXBUILD], test "$SPHINXBUILD" != "false")
  676 AM_CONDITIONAL([HAVE_PDFLATEX], test "$PDFLATEX" != "false")
  677 AM_CONDITIONAL([HAVE_MAKEINFO], test "$MAKEINFO" != "false")
  678 
  679 filtered_cflags=$(echo -n "$CFLAGS" | sed 's/\W-f\S*-prefix-map=\S*\W/ /g')
  680 filtered_cppflags=$(echo -n "$CPPFLAGS" | sed 's/\W-f\S*-prefix-map=\S*\W/ /g')
  681 
  682 result_msg_base="  Knot DNS $VERSION
  683 
  684     Target:   $host_os $host_cpu
  685     Compiler: ${CC}
  686     CFLAGS:   ${filtered_cflags} ${filtered_cppflags}
  687     LIBS:     ${LIBS} ${LDFLAGS}
  688     LibURCU:  ${liburcu_LIBS} ${liburcu_CFLAGS}
  689     GnuTLS:   ${gnutls_LIBS} ${gnutls_CFLAGS}
  690     Libedit:  ${libedit_LIBS} ${libedit_CFLAGS}
  691     LMDB:     ${enable_lmdb} ${lmdb_LIBS} ${lmdb_CFLAGS}
  692     Config:   ${conf_mapsize} MiB default mapsize
  693 
  694     Prefix:      ${knot_prefix}
  695     Run dir:     ${run_dir}
  696     Storage dir: ${storage_dir}
  697     Config dir:  ${config_dir}
  698     Module dir:  ${module_dir}
  699 
  700     Static modules: ${static_modules}
  701     Shared modules: ${shared_modules}
  702 
  703     Knot DNS libraries:     yes
  704     Knot DNS daemon:        ${enable_daemon}
  705     Knot DNS utilities:     ${enable_utilities}
  706     Knot DNS documentation: ${enable_documentation}
  707 
  708     Use recvmmsg:           ${enable_recvmmsg}
  709     Use SO_REUSEPORT(_LB):  ${enable_reuseport}
  710     Memory allocator:       ${with_memory_allocator}
  711     Fast zone parser:       ${enable_fastparser}
  712     Utilities with IDN:     ${with_libidn}
  713     Utilities with Dnstap:  ${enable_dnstap}
  714     MaxMind DB support:     ${enable_maxminddb}
  715     Systemd integration:    ${enable_systemd}
  716     POSIX capabilities:     ${enable_cap_ng}
  717     PKCS #11 support:       ${enable_pkcs11}
  718     Ed25519 support:        ${enable_ed25519}
  719     Code coverage:          ${enable_code_coverage}
  720     Sanitizer:              ${with_sanitizer}
  721     LibFuzzer:              ${with_fuzzer}
  722     OSS-Fuzz:               ${with_oss_fuzz}"
  723 
  724 result_msg_esc=$(echo -n "$result_msg_base" | sed '$!s/$/\\n/' | tr -d '\n')
  725 
  726 AC_DEFINE_UNQUOTED([CONFIGURE_SUMMARY],["$result_msg_esc"],[Configure summary])
  727 
  728 AC_CONFIG_FILES([Makefile
  729                  Doxyfile
  730                  doc/Makefile
  731                  tests/Makefile
  732                  tests-fuzz/Makefile
  733                  samples/Makefile
  734                  distro/Makefile
  735                  python/Makefile
  736                  python/setup.py
  737                  python/libknot/__init__.py
  738                  src/Makefile
  739                  src/knot/modules/static_modules.h
  740                  ])
  741 
  742 AC_CONFIG_FILES([doc/modules.rst],
  743                 [cp doc/modules.rst ${srcdir}/doc/modules.rst 2>/dev/null;
  744                  ln -s -f $(readlink -f ${srcdir})/src/knot/modules ${srcdir}/doc 2>/dev/null])
  745 
  746 AC_OUTPUT
  747 AC_MSG_RESULT([
  748 $result_msg_base
  749 ])