configure.ac 20.8 KB
Newer Older
Ondřej Surý's avatar
Ondřej Surý committed
1 2
#                                               -*- Autoconf -*-

3
AC_PREREQ([2.60])
4

5
m4_define([knot_VERSION_MAJOR],2)dnl
6 7
m4_define([knot_VERSION_MINOR],6)dnl
m4_define([knot_VERSION_PATCH],0)dnl
8
m4_define([knot_VERSION_EXTRA],)dnl
9
m4_define([knot_PKG_VERSION],[knot_VERSION_MAJOR.knot_VERSION_MINOR.knot_VERSION_PATCH]knot_VERSION_EXTRA)dnl
10 11

AC_INIT([knot], knot_PKG_VERSION, [knot-dns@labs.nic.cz])
12
configure_params="$*"
13
AM_INIT_AUTOMAKE([gnits subdir-objects no-dist-gzip dist-xz -Wall -Werror])
14
AM_SILENT_RULES([yes])
15
AC_CONFIG_SRCDIR([src/knot])
Ondřej Surý's avatar
Ondřej Surý committed
16 17
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_MACRO_DIR([m4])
18
AC_USE_SYSTEM_EXTENSIONS
19
AC_CANONICAL_HOST
20

21 22 23 24 25
AC_SUBST([KNOT_VERSION_MAJOR], knot_VERSION_MAJOR)
AC_SUBST([KNOT_VERSION_MINOR], knot_VERSION_MINOR)
AC_SUBST([KNOT_VERSION_PATCH], knot_VERSION_PATCH)
AC_SUBST([KNOT_VERSION_EXTRA], knot_VERSION_EXTRA)

26
AC_CONFIG_FILES([src/libknot/version.h
27 28
                 src/zscanner/version.h
                 src/dnssec/lib/dnssec/version.h])
29

30 31 32 33
# Store ./configure parameters into macro
AC_DEFINE_UNQUOTED([CONFIGURE_PARAMS],["$configure_params"],[Params passed to configure])
AC_DEFINE_UNQUOTED([CONFIGURE_CFLAGS],["$CFLAGS"],[Passed CFLAGS from environment])

Jan Včelák's avatar
Jan Včelák committed
34 35
# Updating version info
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
36 37
AC_SUBST([libknot_VERSION_INFO],["-version-info 7:0:0"])
AC_SUBST([libdnssec_VERSION_INFO],["-version-info 5:0:0"])
38
AC_SUBST([libzscanner_VERSION_INFO],["-version-info 1:0:0"])
39

40
# Automatically update release date based on configure.ac date
41 42
AC_PROG_SED
release_date=$($SED -n 's/^Knot DNS .* (\(.*\))/\1/p;q;' ${srcdir}/NEWS)
43 44
AC_SUBST([RELEASE_DATE], $release_date)

45 46 47 48
# Set compiler compatibility flags
AC_PROG_CC_C99
AM_PROG_CC_C_O
AC_PROG_CPP_WERROR
Ondřej Surý's avatar
Ondřej Surý committed
49

50
# Default compiler flags
51
CFLAGS="$CFLAGS -Wall -Werror=format-security -Werror=implicit -Wstrict-prototypes"
52

53
# Checks for programs.
54
m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) # call AM_PROG_AR only if available
55

Ondřej Surý's avatar
Ondřej Surý committed
56 57 58
# Initialize libtool
LT_INIT

59
# Use pkg-config
60
PKG_PROG_PKG_CONFIG
61
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], [AC_SUBST([pkgconfigdir], ['${libdir}/pkgconfig'])])
62 63
AC_CONFIG_FILES([src/knotd.pc
                 src/libknot.pc
64 65 66
                 src/dnssec/libdnssec.pc
                 src/zscanner/libzscanner.pc
                 ])
67

68 69 70 71
# Build Knot DNS daemon
AC_ARG_ENABLE([daemon],
    AS_HELP_STRING([--disable-daemon], [Don't build Knot DNS main daemon]), [], [enable_daemon=yes])
AM_CONDITIONAL([HAVE_DAEMON], [test "$enable_daemon" = "yes"])
72

73 74 75 76
# Build Knot DNS utilities
AC_ARG_ENABLE([utilities],
    AS_HELP_STRING([--disable-utilities], [Don't build Knot DNS utilities]), [], [enable_utilities=yes])
AM_CONDITIONAL([HAVE_UTILS], [test "$enable_utilities" = "yes"])
77

78 79 80 81
# Build Knot DNS documentation
AC_ARG_ENABLE([documentation],
    AS_HELP_STRING([--disable-documentation], [Don't build Knot DNS documentation]), [], [enable_documentation=yes])
AM_CONDITIONAL([HAVE_DOCS], [test "$enable_documentation" = "yes"])
82

83 84 85
######################
# Generic dependencies
######################
86

Ondřej Surý's avatar
Ondřej Surý committed
87 88
AC_PROG_INSTALL

89
AC_ARG_ENABLE([fastparser],
90 91 92 93
    AS_HELP_STRING([--disable-fastparser], [Disable use of fastest zone parser]),[],[
    # Set zone parser type - fastest on release build, slowest on dev build
    AS_IF([test -d ".git" -o "$PATCH_VERSION" = "dev"],[
        enable_fastparser=no
94 95 96
        ],[
        enable_fastparser=yes
        ])
97
    ])
98

99
AX_CC_CLANG
100
AS_IF([test "$enable_fastparser" = "yes"],[
101
    AS_IF([test -n "$CC_CLANG_VERSION"],[
102 103 104 105
      enable_fastparser=no
      AC_MSG_WARN([Fast zone parser disabled due to possible compiler bug.])
      AC_MSG_WARN([See https://llvm.org/bugs/show_bug.cgi?id=23490 for details.])
      AC_MSG_WARN([Use --enable-fastparser=force if your know your clang is fixed.])
106
    ])
107 108 109
])

AS_IF([test "$enable_fastparser" = "force"],[enable_fastparser=yes])
110

111
AM_CONDITIONAL([FAST_PARSER], [test "$enable_fastparser" = "yes"])
112 113

# GnuTLS crypto backend
114
PKG_CHECK_MODULES([gnutls], [gnutls >= 3.3 nettle], [
115
    save_CFLAGS=$CFLAGS
116
    save_LIBS=$LIBS
117
    CFLAGS="$CFLAGS $gnutls_CFLAGS"
118
    LIBS="$LIBS $gnutls_LIBS"
119
    AC_CHECK_HEADERS([nettle/version.h])
120

121
    AC_CHECK_FUNC([gnutls_pkcs11_copy_pubkey], [enable_pkcs11=yes], [enable_pkcs11=no])
122
    AS_IF([test "$enable_pkcs11" = yes],
Jan Včelák's avatar
Jan Včelák committed
123
        [AC_DEFINE([ENABLE_PKCS11], [1], [PKCS #11 support available])])
124

125 126 127 128 129 130 131 132
    AC_CHECK_DECL([GNUTLS_PK_EDDSA_ED25519],
        [AC_DEFINE([HAVE_ED25519], [1], [GnuTLS ED25519 support available])
	 enable_ed25519=yes],
        [enable_ed25519=no],
	[#include <gnutls/gnutls.h>])

    AC_CHECK_FUNC([gnutls_privkey_sign_data2],
        [AC_DEFINE([HAVE_SIGN_DATA2], [1], [gnutls_privkey_sign_data2 available])])
133

134
    CFLAGS=$save_CFLAGS
135
    LIBS=$save_LIBS
136
])
137

138
AC_ARG_ENABLE([recvmmsg],
139 140 141 142 143 144 145 146 147 148 149 150 151 152
   AS_HELP_STRING([--enable-recvmmsg=auto|yes|no], [enable recvmmsg() network API [default=auto]]),
   [], [enable_recvmmsg=auto])

AS_CASE([$enable_recvmmsg],
   [auto|yes],[
      AC_CHECK_FUNC([recvmmsg],
                    [AC_CHECK_FUNC([sendmmsg],[enable_recvmmsg=yes],[enable_recvmmsg=no])],
                    [enable_recvmmsg=no])],
   [no],[],
   [*], [AC_MSG_ERROR([Invalid value of --enable-recvmmsg.]
 )])

AS_IF([test "$enable_recvmmsg" = yes],[
   AC_DEFINE([ENABLE_RECVMMSG], [1], [Use recvmmsg().])])
153

154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
AC_ARG_ENABLE([reuseport],
    AS_HELP_STRING([--enable-reuseport=auto|yes|no], [enable Linux SO_REUSEPORT support [default=auto]]),
    [enable_reuseport="$enableval"], [enable_reuseport=auto])

AC_DEFUN([CHECK_REUSEPORT], [
  AC_CHECK_DECL(
    [SO_REUSEPORT],
    [$1],
    [$2],
    [
    #include <sys/socket.h>
    ]
  )])

AS_IF([test "$enable_reuseport" != no], [
  AS_CASE([$enable_reuseport],
    [auto],[
      AS_CASE([$host_os],
        [linux*], [CHECK_REUSEPORT([enable_reuseport=yes], [enable_reuseport=no])],
        [*], [enable_reuseport=no]
      )],
    [yes],[
      AS_CASE([$host_os],
        [linux*], [CHECK_REUSEPORT([enable_reuseport=yes], [AC_MSG_ERROR([SO_REUSEPORT support not detected.])])],
        [*], [AC_MSG_ERROR(["SO_REUSEPORT not supported on $host_os."])]
      )],
    [*], [AC_MSG_ERROR([Invalid value of --enable-reuseport.])]
  )])

AS_IF([test "$enable_reuseport" = yes],[
   AC_DEFINE([ENABLE_REUSEPORT], [1], [Use SO_REUSEPORT.])])

186
AX_CHECK_COMPILE_FLAG("-fpredictive-commoning", [CFLAGS="$CFLAGS -fpredictive-commoning"], [], "-Werror")
187 188
AX_CHECK_LINK_FLAG(["-Wl,--exclude-libs,ALL"], [ldflag_exclude_libs="-Wl,--exclude-libs,ALL"], [ldflag_exclude_libs=""], "")
AC_SUBST([LDFLAG_EXCLUDE_LIBS], $ldflag_exclude_libs)
189

190 191 192
# Default directories
run_dir="${localstatedir}/run/knot"
AC_ARG_WITH([rundir],
193
        AC_HELP_STRING([--with-rundir=path], [Path to run-time variable data (pid, sockets...). [default=LOCALSTATEDIR/run/knot]]),
194 195 196
        [run_dir=$withval])
AC_SUBST(run_dir)

Ondřej Surý's avatar
Ondřej Surý committed
197
storage_dir="${localstatedir}/lib/knot"
198
AC_ARG_WITH([storage],
199
        AC_HELP_STRING([--with-storage=path], [Default storage directory (slave zones, persistent data). [default=LOCALSTATEDIR/lib/knot]]),
200 201 202
        [storage_dir=$withval])
AC_SUBST(storage_dir)

203 204
config_dir="${sysconfdir}/knot"
AC_ARG_WITH([configdir],
205
        AC_HELP_STRING([--with-configdir=path], [Default directory for configuration. [default=SYSCONFDIR/knot]]),
206 207 208
        [config_dir=$withval])
AC_SUBST(config_dir)

209 210 211 212 213 214 215 216
module_dir=
module_instdir="${libdir}/knot/modules-${KNOT_VERSION_MAJOR}.${KNOT_VERSION_MINOR}"
AC_ARG_WITH([moduledir],
        AC_HELP_STRING([--with-moduledir=path], [Path to auto-loaded dynamic modules. [default not set]]),
        [module_dir=$withval module_instdir=$module_dir])
AC_SUBST(module_instdir)
AC_SUBST(module_dir)

217 218 219 220 221 222 223 224 225 226 227
#########################################
# Dependencies needed for Knot DNS daemon
#########################################

# Systemd integration
AC_ARG_ENABLE([systemd],
    AS_HELP_STRING([--enable-systemd=auto|yes|no], [enable systemd integration [default=auto]]),
    [enable_systemd="$enableval"], [enable_systemd=auto])

AS_IF([test "$enable_daemon" = "yes"],[

228
AS_IF([test "$enable_systemd" != "no"],[
229
  AS_CASE([$enable_systemd],
230 231 232
    [auto],[PKG_CHECK_MODULES([systemd], [libsystemd], [enable_systemd=yes], [
            PKG_CHECK_MODULES([systemd], [libsystemd-daemon libsystemd-journal], [enable_systemd=yes], [enable_systemd=no])])],
    [yes],[PKG_CHECK_MODULES([systemd], [libsystemd], [], [
233
            PKG_CHECK_MODULES([systemd], [libsystemd-daemon libsystemd-journal])])],
234 235 236 237 238
    [*],[AC_MSG_ERROR([Invalid value of --enable-systemd.])])
    ])

AS_IF([test "$enable_systemd" = "yes"],[
  AC_DEFINE([ENABLE_SYSTEMD], [1], [Use systemd integration.])])
239

240 241
]) dnl enable_daemon

242 243 244 245 246

dnl Check for userspace-rcu library
AC_ARG_WITH(urcu,
[  --with-urcu=DIR        where to find userspace-rcu library])

247 248
AS_IF([test "$enable_daemon" = "yes"],[

249 250
AS_IF([test "$with_urcu" != "no"], [
  PKG_CHECK_MODULES([liburcu], liburcu, [
251
    liburcu_PKGCONFIG="liburcu >= 0.4.0"
252
    AC_SUBST([liburcu_PKGCONFIG])
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
    with_urcu=yes
  ],[
    for try_urcu in "$with_urcu" "" "/usr/local"; do
      save_LIBS="$LIBS"
      save_CPPFLAGS="$CPPFLAGS"

      AS_IF([test -d "$try_urcu"], [
        liburcu_CFLAGS="-I$try_urcu/include"
        liburcu_LIBS="-L$try_urcu/lib"
      ],[
        liburcu_CFLAGS=""
        liburcu_LIBS=""
      ])

      CPPFLAGS="$CPPFLAGS $liburcu_CFLAGS"
      LIBS="$LIBS $liburcu_LIBS"

      AC_SEARCH_LIBS([rcu_set_pointer_sym], [urcu], [
        with_urcu=yes
272 273 274 275
        liburcu_LIBS="$liburcu_LIBS -lurcu"
        AC_SUBST([liburcu_CFLAGS])
        AC_SUBST([liburcu_LIBS])
        break
276
      ],[
277 278
        CPPFLAGS="$save_CPPFLAGS"
        LIBS="$save_LIBS"
279
        with_urcu=no
280 281
        # do not cache result of AC_SEARCH_LIBS test
        unset ac_cv_search_rcu_set_pointer_sym
282 283
      ])
    done
284 285
    CPPFLAGS="$save_CPPFLAGS"
    LIBS="$save_LIBS"
286 287 288

    AS_IF([test "$with_urcu" = "no"],[
      AC_MSG_ERROR([liburcu is required])
289
      ])
290 291 292
  ])
])

293
AC_SEARCH_LIBS([urcu_init], [urcu], [AC_MSG_ERROR([liburcu is too old (< 0.4.0), urcu_init symbol found])])
294
])
295

296 297
static_modules=""
shared_modules=""
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
static_modules_declars=""
static_modules_init=""
doc_modules=""

KNOT_MODULE([dnsproxy],    "yes", "non-shareable")
KNOT_MODULE([dnstap],      "no")
KNOT_MODULE([noudp],       "yes")
KNOT_MODULE([onlinesign],  "yes", "non-shareable")
KNOT_MODULE([rosedb],      "no")
KNOT_MODULE([rrl],         "yes")
KNOT_MODULE([stats],       "yes")
KNOT_MODULE([synthrecord], "yes")
KNOT_MODULE([whoami],      "yes")

AC_SUBST([STATIC_MODULES_DECLARS], [$(printf "$static_modules_declars")])
AM_SUBST_NOTMAKE([STATIC_MODULES_DECLARS])
AC_SUBST([STATIC_MODULES_INIT], [$(printf "$static_modules_init")])
AM_SUBST_NOTMAKE([STATIC_MODULES_INIT])
AC_SUBST([DOC_MODULES], [$(printf "$doc_modules")])
AM_SUBST_NOTMAKE([DOC_MODULES])
318

319
opt_dnstap=no
320
AS_IF([test "$enable_daemon" = "yes" -o "$enable_utilities" = "yes"],[
321 322
dnl Check for dnstap.
dt_DNSTAP([
323
    AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support for kdig])
324 325
    AC_SUBST(DNSTAP_CFLAGS)
    AC_SUBST(DNSTAP_LIBS)
326
    ])
327
])
328

329 330
AM_CONDITIONAL([HAVE_DNSTAP], test "$opt_dnstap" != "no")

Jan Včelák's avatar
Jan Včelák committed
331
dnl Check for LMDB
332 333 334 335 336
lmdb_MIN_VERSION_MAJOR=0
lmdb_MIN_VERSION_MINOR=9
lmdb_MIN_VERSION_PATCH=15
lmdb_MIN_VERSION_STRING="$lmdb_MIN_VERSION_MAJOR.$lmdb_MIN_VERSION_MINOR.$lmdb_MIN_VERSION_PATCH"
lmdb_MIN_VERSION_FULL="$((($lmdb_MIN_VERSION_MAJOR << 24) | ($lmdb_MIN_VERSION_MINOR << 16) | $lmdb_MIN_VERSION_PATCH))"
337
AC_ARG_WITH([lmdb],
338
    AC_HELP_STRING([--with-lmdb=[DIR]], [Link with external LMDB (>= $lmdb_MIN_VERSION_STRING)]),[
339 340
    with_lmdb=$withval
    ],[
341
    with_lmdb=auto
342 343 344
    ])

have_lmdb=no
345

346 347 348
AS_IF([test "$with_lmdb" != "no"],[
    save_CPPFLAGS=$CPPFLAGS
    save_LIBS=$LIBS
349 350

    # Look for lmdb in given path and common locations
351 352
    for try_lmdb in "$with_lmdb" "" "/usr/local"; do

353 354 355
      AS_IF([test -d "$try_lmdb"], [
        lmdb_CFLAGS="-I$try_lmdb/include"
        lmdb_LIBS="-L$try_lmdb/lib"
356 357 358
        ],[
        lmdb_CFLAGS=""
        lmdb_LIBS=""
359
        ])
360

361 362
      CPPFLAGS="$save_CPPFLAGS $lmdb_CFLAGS"
      LIBS="$save_LIBS $lmdb_LIBS"
363 364 365

      AC_SEARCH_LIBS([mdb_env_open], [lmdb], [
          AC_CHECK_HEADERS([lmdb.h], [], [
366 367
              AC_MSG_ERROR([lmdb headers not found in `$try_lmdb', is your installation complete?])])
          AC_COMPUTE_INT(lmdb_VERSION_FULL, MDB_VERSION_FULL, [#include <lmdb.h>],
368 369
              AC_MSG_ERROR([Unable to determine lmdb version from MDB_VERSION_FULL]))
          AS_IF([test "$lmdb_VERSION_FULL" -ge "$lmdb_MIN_VERSION_FULL"],[
370 371
              lmdb_LIBS="$lmdb_LIBS -llmdb"
              have_lmdb=yes],[
372 373 374 375 376
              unset lmdb_CFLAGS
              unset lmdb_LIBS
              AC_MSG_WARN([lmdb version 0.9.15 and higher not found, using embedded version])
              ])
          break
377
          ])
378

379 380 381 382
      unset lmdb_CFLAGS
      unset lmdb_LIBS
      # do not cache result of AC_SEARCH_LIBS test
      unset ac_cv_search_mdb_env_open
383
    done
384

385 386
    CPPFLAGS="$save_CPPFLAGS"
    LIBS="$save_LIBS"
387 388

    # fail the configure if we haven't found lmdb library in the system
389
    AS_IF([test "$with_lmdb" != "auto" -a "$have_lmdb" = "no"],[
390
        AC_MSG_ERROR([shared lmdb library not found])
391
        ])
392 393 394
    ])

AS_IF([test "$have_lmdb" != "no"],[
395 396
    AC_SUBST([lmdb_LIBS])
    enable_lmdb=shared
397 398
    ],[
    enable_lmdb=embedded
399
    CFLAGS="$CFLAGS -I\$(top_srcdir)/src/contrib/lmdb"
400
    ])
401
AM_CONDITIONAL([HAVE_LMDB], test "$enable_lmdb" = "shared")
402
AC_SUBST([lmdb_CFLAGS])
403

404
# LMDB mapping sizes
405
conf_mapsize_default=500
406
AC_ARG_WITH([conf_mapsize],
407 408 409 410 411 412 413 414
    AC_HELP_STRING([--with-conf-mapsize=NUM], [Configuration DB mapsize in MiB [default=$conf_mapsize_default]]),
    [conf_mapsize=$withval],[conf_mapsize=$conf_mapsize_default])

AS_CASE([$conf_mapsize],
    [yes],[conf_mapsize=$conf_mapsize_default],
    [no], [AC_MSG_ERROR([conf_mapsize must be a number])],
    [*],  [AS_IF([test $conf_mapsize != $(( $conf_mapsize + 0 ))],
                 [AC_ERROR([conf_mapsize must be an integer number])])])
415 416
AC_DEFINE_UNQUOTED([CONF_MAPSIZE], [$conf_mapsize], [Configuration DB mapsize.])

417
# libedit
418
AS_IF([test "$enable_daemon" = "yes" -o "$enable_utilities" = "yes"], [
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
  PKG_CHECK_MODULES([libedit], [libedit], [with_libedit=yes], [
    with_libedit=no
    AC_CHECK_HEADER([histedit.h], [
      # workaround for OpenBSD
      AS_CASE([$host_os],
        [openbsd*], [libedit_deps=-lcurses],
        [libedit_deps=]
      )
      AC_CHECK_LIB([edit], [el_init], [
        with_libedit=yes
        libedit_CFLAGS=
        libedit_LIBS="-ledit $libedit_deps"
        ], [], [$libedit_deps]
      )
    ])
  ])
  AS_IF([test "$with_libedit" != "yes"], [
    AC_MSG_ERROR([libedit not found])
  ])
438
], [
439 440 441 442 443
  with_libedit=no
  libedit_CFLAGS=
  libedit_LIBS=
])

444 445 446 447 448 449
############################################
# Dependencies needed for Knot DNS utilities
############################################

dnl Check for libidn.
AC_ARG_WITH(libidn,
450 451 452 453 454 455 456
  AC_HELP_STRING([--with-libidn=[DIR]], [Support IDN (needs GNU libidn2 or libidn)]),
  with_libidn=$withval,
  with_libidn=yes
)

AS_IF([test "$enable_utilities" = "yes"], [
  AS_IF([test "$with_libidn" != "no"], [
457
    PKG_CHECK_MODULES([libidn2], [libidn2 >= 2.0.0], [
458 459 460 461 462
      with_libidn=yes
      AC_DEFINE([LIBIDN], [1], [Define to 1 to enable IDN support])
      AC_DEFINE([LIBIDN_HEADER], [<idn2.h>], [Define to proper libidn header])
    ], [
      PKG_CHECK_MODULES([libidn], [libidn >= 0.0.0], [
463 464
        with_libidn=yes
        AC_DEFINE([LIBIDN], [1], [Define to 1 to enable IDN support])
465 466
        AC_DEFINE([LIBIDN_HEADER], [<idna.h>], [Define to proper libidn header])
      ], [
467
        with_libidn=no
468 469 470 471
        AC_MSG_WARN([libidn2 or libidn not found])
      ])
    ])
  ])
472
]) # Knot DNS utilities dependencies
473

474 475
AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthreads not found])])
476
AC_SEARCH_LIBS([dlopen], [dl])
Marek Vavrusa's avatar
Marek Vavrusa committed
477
AC_SEARCH_LIBS([clock_gettime], [rt])
478
AC_SEARCH_LIBS([capng_apply], [cap-ng])
Ondřej Surý's avatar
Ondřej Surý committed
479 480 481

# Checks for header files.
AC_HEADER_RESOLV
482
AC_CHECK_HEADERS_ONCE([cap-ng.h netinet/in_systm.h pthread_np.h signal.h sys/time.h sys/wait.h sys/uio.h])
Ondřej Surý's avatar
Ondřej Surý committed
483 484

# Checks for library functions.
485 486 487 488 489 490
AC_CHECK_FUNCS([clock_gettime gettimeofday fgetln getline madvise malloc_trim poll \
                posix_memalign pthread_setaffinity_np regcomp setgroups strlcat strlcpy \
                initgroups accept4])

AC_CHECK_FUNC([vasprintf], [], [
  AC_MSG_ERROR([vasprintf support in the libc is required])])
Ondřej Surý's avatar
Ondřej Surý committed
491

492 493
# Check for be64toh function
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <endian.h>]], [[return be64toh(0);]])],
494
[AC_DEFINE(HAVE_BE64TOH, 1, [Define to 1 if you have the 'be64toh' function.])])
495

496 497 498 499 500 501 502 503
# Check for cpu_set_t/cpuset_t compatibility
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[cpu_set_t set; CPU_ZERO(&set);]])],
[AC_DEFINE(HAVE_CPUSET_LINUX, 1, [Define if Linux-like cpu_set_t exists.])])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread_np.h>]], [[cpuset_t set; CPU_ZERO(&set);]])],
[AC_DEFINE(HAVE_CPUSET_BSD, 1, [Define if FreeBSD-like cpuset_t exists.])])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sched.h>]], [[cpuset_t* set = cpuset_create(); cpuset_destroy(set);]])],
[AC_DEFINE(HAVE_CPUSET_NETBSD, 1, [Define if cpuset_t and cpuset(3) exists.])])

504 505 506
AC_COMPILE_IFELSE(
  [AC_LANG_PROGRAM([[#include <stdint.h>]],
                   [[uint64_t val = 0; __atomic_add_fetch(&val, 1, __ATOMIC_RELAXED);]])],
507 508 509 510 511 512 513 514
  [AC_DEFINE(HAVE_ATOMIC, 1, [Define to 1 if you have '__atomic' functions.])
    AC_LINK_IFELSE(
     [AC_LANG_PROGRAM([[#include <stdint.h>]],
                      [[uint64_t val = 0; __atomic_add_fetch(&val, 1, __ATOMIC_RELAXED);]])],
     [atomic_LIBS=""],
     [atomic_LIBS="-latomic"]
  )],
  [atomic_LIBS=""]
515
)
516
AC_SUBST([atomic_LIBS])
517

518
# Prepare CFLAG_VISIBILITY to be used where needed
519
gl_VISIBILITY()
520

521 522 523
# Add code coverage macro
AX_CODE_COVERAGE

524 525
AX_SANITIZER
AS_IF([test -n "$sanitize_CFLAGS"], [CFLAGS="$CFLAGS $sanitize_CFLAGS"])
526
AM_CONDITIONAL([SANITIZE_FUZZER], [test "$with_sanitize_fuzzer" != "no"])
527

528 529
AS_IF([test "$enable_documentation" = "yes"],[

530
AC_PATH_PROGS([SPHINXBUILD], [sphinx-build sphinx-build-3], [false])
531 532 533 534 535 536 537 538 539 540
AS_IF([test "$SPHINXBUILD" = "false"],
  [AC_MSG_WARN([Could not find the 'sphinx-build' executable, you will be unable to regenerate documentation.])],
  [AC_PATH_PROG([PDFLATEX], [pdflatex], [false])
   AS_IF([test "$PDFLATEX" = ""],
     [AC_MSG_WARN([Could not find the 'pdflatex' executable, you will be unable to generate PDF documentation.])])
   AC_PATH_PROG([MAKEINFO], [makeinfo], [false])
   AS_IF([test "$MAKEINFO" = "false"],
     [AC_MSG_WARN([Could not find the 'makeinfo' executable, you will be unable to generate info documentation.])])
  ])

541 542
])

543 544 545 546
AM_CONDITIONAL([HAVE_SPHINXBUILD], test "$SPHINXBUILD" != "false")
AM_CONDITIONAL([HAVE_PDFLATEX], test "$PDFLATEX" != "false")
AM_CONDITIONAL([HAVE_MAKEINFO], test "$MAKEINFO" != "false")

547
result_msg_base="  $PACKAGE $VERSION
548 549 550

    Target:   $host_os $host_cpu
    Compiler: ${CC}
551
    CFLAGS:   ${CFLAGS} ${CPPFLAGS}
552 553 554
    LIBS:     ${LIBS} ${LDFLAGS}
    LibURCU:  ${liburcu_LIBS} ${liburcu_CFLAGS}
    GnuTLS:   ${gnutls_LIBS} ${gnutls_CFLAGS}
555
    Libedit:  ${libedit_LIBS} ${libedit_CFLAGS}
556
    LMDB:     ${enable_lmdb} ${lmdb_LIBS} ${lmdb_CFLAGS}
557
    Config:   ${conf_mapsize} MiB mapsize
558

559 560 561 562
    Prefix:      ${prefix}
    Run dir:     ${run_dir}
    Storage dir: ${storage_dir}
    Config dir:  ${config_dir}
563
    Module dir:  ${module_dir}
564

565 566
    Static modules: ${static_modules}
    Shared modules: ${shared_modules}
567

568 569
    Knot DNS libraries:     yes
    Knot DNS daemon:        ${enable_daemon}
570
    Knot DNS utilities:     ${enable_utilities}
571 572
    Knot DNS documentation: ${enable_documentation}

573 574 575 576 577 578 579
    Use recvmmsg:           ${enable_recvmmsg}
    Use SO_REUSEPORT:       ${enable_reuseport}
    Fast zone parser:       ${enable_fastparser}
    Utilities with IDN:     ${with_libidn}
    Utilities with Dnstap:  ${opt_dnstap}
    Systemd integration:    ${enable_systemd}
    PKCS #11 support:       ${enable_pkcs11}
580
    Ed25519 support:        ${enable_ed25519}
581 582
    Code coverage:          ${enable_code_coverage}
    Sanitizer:              ${with_sanitize}
583 584 585
    Sanitizer coverage:     ${with_sanitize_coverage}
    LibFuzzer:              ${with_sanitize_fuzzer}
"
586 587 588 589

result_msg_esc=$(echo -n "$result_msg_base" | sed '$!s/$/\\n/' | tr -d '\n')
result_msg_add="
$result_msg_base
590 591

  Continue with 'make' command
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
"

AC_DEFINE_UNQUOTED([CONFIGURE_SUMMARY],["$result_msg_esc"],[Configure summary])

AC_CONFIG_FILES([Makefile
                 doc/Makefile
                 libtap/Makefile
                 tests/Makefile
                 tests-fuzz/Makefile
                 samples/Makefile
                 python/Makefile
                 src/Makefile
                 src/contrib/dnstap/Makefile
                 src/dnssec/Makefile
                 src/dnssec/tests/Makefile
607
                 src/knot/modules/static_modules.h
608 609 610
                 src/zscanner/Makefile
                 ])

611
AC_CONFIG_FILES([src/utils/pykeymgr/pykeymgr], [chmod +x src/utils/pykeymgr/pykeymgr])
612 613
AC_CONFIG_FILES([doc/modules.rst],
                [cp doc/modules.rst ${srcdir}/doc/modules.rst 2>/dev/null;
614
                 ln -s -f -t ${srcdir}/doc/ $(readlink -f ${srcdir})/src/knot/modules 2>/dev/null])
615

616 617 618
AC_OUTPUT

AC_MSG_RESULT([$result_msg_add])