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

3
AC_PREREQ([2.60])
Jan Včelák's avatar
Jan Včelák committed
4
AC_INIT([knot], [1.6.0], [knot-dns@labs.nic.cz])
Ondřej Surý's avatar
Ondřej Surý committed
5
AM_INIT_AUTOMAKE([gnits subdir-objects dist-xz -Wall -Werror])
6
AM_SILENT_RULES([yes])
Lubos Slovak's avatar
Lubos Slovak committed
7
AC_CONFIG_SRCDIR([src/knot/main.c])
Ondřej Surý's avatar
Ondřej Surý committed
8 9
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_MACRO_DIR([m4])
10
AC_USE_SYSTEM_EXTENSIONS([_GNU_SOURCE])
11
AC_CANONICAL_HOST
12

13
# Automatically update release date based on configure.ac date
14 15 16 17 18 19 20 21 22
case "$host_os" in
linux*)
    release_date=`date +"%Y-%m-%d" -r configure.ac`
    ;;
*)
    tmstamp=`stat -f %m configure.ac`
    release_date=`date -r $tmstamp +"%Y-%m-%d"`
    ;;
esac
23 24
AC_SUBST([RELEASE_DATE], $release_date)

25 26 27 28
# 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
29

30
# Default compiler flags
31
CFLAGS="$CFLAGS -Wall -Werror=format-security -Werror=implicit"
32

33
# Checks for programs.
34
m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) # call AM_PROG_AR only if available
35

Ondřej Surý's avatar
Ondřej Surý committed
36
# Initialize libtool
37
AC_DISABLE_STATIC
Marek Vavrusa's avatar
Marek Vavrusa committed
38
AC_PROG_LIBTOOL
Ondřej Surý's avatar
Ondřej Surý committed
39 40
LT_INIT

41 42 43
# Use pkg-config
PKG_PROG_PKG_CONFIG

44 45 46
AC_CACHE_CHECK([for reentrant lex], [ac_cv_path_LEX],
  [AC_PATH_PROGS_FEATURE_CHECK([LEX], [$LEX flex gflex],
  [cat >conftest.l <<_ACEOF
47 48 49 50 51 52 53 54 55 56 57 58 59 60
%{
%}

%option reentrant
%option bison-bridge
%option noinput
%option nounput
%option noreject

BLANK [ \t\n]

%%
<<EOF>> return 0;
%%
61 62 63 64 65 66 67 68
_ACEOF
_AC_DO_VAR(ac_path_LEX conftest.l)
test $ac_status -eq 0 && ac_cv_path_LEX=$ac_path_LEX ac_path_LEX_found=true
rm -f conftest.l lexyy.c lex.yy.c
],
[AC_MSG_ERROR([could not find lex that supports reentrant parsers])])])
AC_SUBST([LEX], [$ac_cv_path_LEX])
AM_PROG_LEX
69

Ondřej Surý's avatar
Ondřej Surý committed
70
AC_PROG_YACC
71
YACC_BISON=`bison --version | awk '{print $1;exit}'`
72
AS_IF([test "x$YACC_BISON" != "xbison"],
73
    [AC_MSG_ERROR([GNU bison needed for reentrant parsers, set the \$YACC variable before running configure])])
Ondřej Surý's avatar
Ondřej Surý committed
74 75
AC_PROG_INSTALL

76
# Set zone parser type
77
AC_ARG_ENABLE([fastparser],
78 79 80
    AS_HELP_STRING([--disable-fastparser], [Use slower zone parser]),
    [], [enable_fastparser=yes])
AM_CONDITIONAL([FAST_PARSER], [test "$enable_fastparser" = yes])
81

82 83
# Systemd integration
AC_ARG_ENABLE([systemd],
84
    AS_HELP_STRING([--enable-systemd=auto|yes|no], [enable systemd integration [default=auto]]),
85 86 87
    [enable_systemd="$enableval"], [enable_systemd=auto])

case "$enable_systemd" in
88 89
    auto) PKG_CHECK_MODULES([systemd], [libsystemd-daemon libsystemd-journal], [enable_systemd=yes], [enable_systemd=no]) ;;
    yes)  PKG_CHECK_MODULES([systemd], [libsystemd-daemon libsystemd-journal]) ;;
90 91 92 93 94
    no)   ;;
    *)    AC_MSG_ERROR([Invalid value of --enable-systemd.]) ;;
esac

if test "$enable_systemd" = yes; then
95
    AC_DEFINE([ENABLE_SYSTEMD], [1], [Use systemd integration.])
96 97
fi

98 99
# Debug modules
AC_ARG_ENABLE([debug],
100
    AS_HELP_STRING([--enable-debug=server,zones,xfr,packet,rr,ns,loader,dnssec],
101
    [compile selected debug modules [default=none]]),
102
    [
103 104
    echo ${enableval}|tr "," "\n"|while read val; do
        case "${val}" in
105 106 107 108 109 110 111 112
            server) AC_DEFINE([KNOTD_SERVER_DEBUG], [1], [Server debug.]) ;;
            zones) AC_DEFINE([KNOT_ZONES_DEBUG], [1], [Zones debug.]) ;;
            xfr) AC_DEFINE([KNOT_XFR_DEBUG], [1], [XFR debug.]) ;;
            packet) AC_DEFINE([KNOT_PACKET_DEBUG], [1], [Packet debug.]) ;;
            rr) AC_DEFINE([KNOT_RR_DEBUG], [1], [RR debug.]) ;;
            ns) AC_DEFINE([KNOT_NS_DEBUG], [1], [Nameserver debug.]) ;;
            loader) AC_DEFINE([KNOT_LOADER_DEBUG], [1], [Zone loading debug.]) ;;
            dnssec) AC_DEFINE([KNOT_DNSSEC_DEBUG], [1], [DNSSEC debug.]) ;;
113 114
        esac
    done
115
    ], [])
Jan Kadlec's avatar
Jan Kadlec committed
116

117
# Debug level
118 119
AC_ARG_ENABLE([debuglevel],
    AS_HELP_STRING([--enable-debuglevel=brief|verbose|details], [enable given debug level [default=disabled]]),
120 121 122 123 124 125
    # Not all shells support fall-through with ;& so I have to duplicate
    [case "x${enableval}" in
      xdetails)
        AC_DEFINE([DEBUG_ENABLE_DETAILS], [1], [Enable details debugging messages.])
        AC_DEFINE([DEBUG_ENABLE_VERBOSE], [1], [Enable verbose debugging messages.])
        AC_DEFINE([DEBUG_ENABLE_BRIEF], [1], [Enable brief debugging messages.])
126
        ;;
127 128 129
      xverbose)
        AC_DEFINE([DEBUG_ENABLE_VERBOSE], [1], [Enable verbose debugging messages.])
        AC_DEFINE([DEBUG_ENABLE_BRIEF], [1], [Enable brief debugging messages.])
130
        ;;
131 132 133 134
      xbrief)
        AC_DEFINE([DEBUG_ENABLE_BRIEF], [1], [Enable brief debugging messages.])
        ;;
    esac], [])
135

136
# recvmmsg() (valgrind doesn't support it, so disable for debugging)
137
# The check for struct mmsghdr is required when libc doesn't have an API but the function links
138
AC_ARG_ENABLE([recvmmsg],
139
    AS_HELP_STRING([--enable-recvmmsg=yes|no], [enable recvmmsg() network API under Linux (kernel support required) (set to 'no' if you have trouble running server under valgrind) [default=yes]]),
140 141
    [case "${enableval}" in
      yes)
142 143 144
	  AC_CHECK_FUNCS([sendmmsg])
          AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]], [[struct mmsghdr v; recvmmsg(0,0,0,0,0);]])],
          [AC_DEFINE(HAVE_RECVMMSG, 1, [Define if struct mmsghdr and recvmmsg() exists.])])
145
          ;;
146
      no)
147
          ;;
148
      *)
149 150
          AC_MSG_ERROR([bad value ${enableval} for --enable-recvmmsg])
          ;;
151 152 153 154 155 156
    esac],
    [
      AC_CHECK_FUNCS([sendmmsg])
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]], [[struct mmsghdr v; recvmmsg(0,0,0,0,0);]])],
      [AC_DEFINE(HAVE_RECVMMSG, 1, [Define if struct mmsghdr and recvmmsg() exists.])])
    ])
157

158
# Check for link time optimizations support and predictive commoning
159
AC_ARG_ENABLE([lto],
160
    AS_HELP_STRING([--enable-lto=yes|no], [enable link-time optimizations, enable if not broken for some extra speed [default=no]]),
161
    [case "${enableval}" in
162
      yes) AX_CHECK_COMPILE_FLAG("-flto", [CFLAGS="$CFLAGS -flto"], []) ;;
163
      no) ;;
164
      *)  AC_MSG_ERROR([bad value ${enableval} for --enable-lto]) ;;
165
    esac])
166

167
AX_CHECK_COMPILE_FLAG("-fpredictive-commoning", [CFLAGS="$CFLAGS -fpredictive-commoning"], [], "-Werror")
168

169 170 171
# Default directories
run_dir="${localstatedir}/run/knot"
AC_ARG_WITH([rundir],
172
        AC_HELP_STRING([--with-rundir=path], [Path to run-time variable data (pid, sockets...). [default=LOCALSTATEDIR/run/knot]]),
173 174 175
        [run_dir=$withval])
AC_SUBST(run_dir)

Ondřej Surý's avatar
Ondřej Surý committed
176
storage_dir="${localstatedir}/lib/knot"
177
AC_ARG_WITH([storage],
178
        AC_HELP_STRING([--with-storage=path], [Default storage directory (slave zones, persistent data). [default=LOCALSTATEDIR/lib/knot]]),
179 180 181
        [storage_dir=$withval])
AC_SUBST(storage_dir)

182 183
config_dir="${sysconfdir}/knot"
AC_ARG_WITH([configdir],
184
        AC_HELP_STRING([--with-configdir=path], [Default directory for configuration. [default=SYSCONFDIR/knot]]),
185 186 187
        [config_dir=$withval])
AC_SUBST(config_dir)

Ondřej Surý's avatar
Ondřej Surý committed
188 189
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lm':
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219

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

AS_IF([test "$with_urcu" != "no"], [
  PKG_CHECK_MODULES([liburcu], liburcu, [
    CPPFLAGS="$CPPFLAGS $liburcu_CFLAGS"
    LIBS="$LIBS $liburcu_LIBS"
    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
	break
      ],[
Ondřej Surý's avatar
Ondřej Surý committed
220 221
        CPPFLAGS="$save_CPPFLAGS"
        LIBS="$save_LIBS"
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
        with_urcu=no
	# do not cache result of AC_SEARCH_LIBS test
	unset ac_cv_search_rcu_set_pointer_sym
      ])
    done

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

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

dnl Check for OpenSSL
AC_ARG_WITH(openssl,
[  --with-openssl=DIR        where to find openssl library])

AS_IF([test "$with_openssl" != "no"],[
  PKG_CHECK_MODULES([libcrypto], libcrypto, [
    CPPFLAGS="$CPPFLAGS $libcrypto_CFLAGS"
    LIBS="$LIBS $libcrypto_LIBS"
    with_openssl=yes
  ],[

    for try_openssl in "$with_openssl" "" "/usr/local"; do
      save_LIBS="$LIBS"
      save_CPPFLAGS="$CPPFLAGS"

      AS_IF([test -d "$try_openssl"], [
        libcrypto_CFLAGS="-I$try_openssl/include"
        libcrypto_LIBS="-L$try_openssl/lib"
      ],[
        libcrypto_CFLAGS=""
        libcrypto_LIBS=""
      ])

      CPPFLAGS="$CPPFLAGS $libcrypto_CFLAGS"
      LIBS="$LIBS $libcrypto_LIBS"

      AC_SEARCH_LIBS([OpenSSL_add_all_digests], [crypto], [
        with_openssl=yes
	break
      ],[
        with_openssl=no
	# do not cache result of AC_SEARCH_LIBS test
	unset ac_cv_search_OpenSSL_add_all_digests
      ])

      CPPFLAGS="$save_CPPFLAGS"
      LIBS="$save_LIBS"
    done

  ])
])

278 279 280 281 282 283
AS_IF([test "$with_openssl" = "no"],[
  AC_MSG_ERROR([OpenSSL library is required.])
])

AC_EGREP_CPP(openssl_version_ok,
  [#include <openssl/crypto.h>
284
   #if (OPENSSL_VERSION_NUMBER >= 0x10000000L)
285 286 287 288 289
   openssl_version_ok
   #endif
  ],[],[AC_MSG_ERROR([OpenSSL library version >= 1.0.0 is required.])]
)

290 291 292 293 294 295 296 297 298 299 300 301 302 303
dnl Check for libidn.
AC_ARG_WITH(libidn,
    AC_HELP_STRING([--with-libidn=[DIR]], [Support IDN (needs GNU Libidn)]),
    with_libidn=$withval,
    with_libidn=yes
)
if test "$with_libidn" != "no" ; then
    PKG_CHECK_MODULES([libidn], [libidn >= 0.0.0], [with_libidn=yes], [with_libidn=no])
    if test "$with_libidn" != "yes" ; then
        with_libidn=no
        AC_MSG_WARN([Libidn not found])
    else
        with_libidn=yes
        AC_DEFINE([LIBIDN], [1], [Define to 1 to enable IDN support])
Daniel Salzman's avatar
Daniel Salzman committed
304 305 306
    fi
fi

307 308 309 310 311 312 313 314
dnl Check for dnstap.
dt_DNSTAP([
    LIBS="$LIBS $DNSTAP_LIBS"
    CPPFLAGS="$CPPFLAGS $DNSTAP_CFLAGS"
    AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support])
])
AM_CONDITIONAL([HAVE_DNSTAP], test "$opt_dnstap" != "no")

Jan Včelák's avatar
Jan Včelák committed
315 316
dnl Check for LMDB
KNOT_CHECK_HEADER([lmdb], [LMDB], [auto], [lmdb.h], [], [-llmdb])
317
AS_IF([test "$enable_lmdb" = yes], [AC_DEFINE([HAVE_LMDB], [1], [Define to 1 to enable LMDB support])])
318

319 320
AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthreads not found])])
321
AC_SEARCH_LIBS([dlopen], [dl])
Marek Vavrusa's avatar
Marek Vavrusa committed
322
AC_SEARCH_LIBS([clock_gettime], [rt])
323
AC_SEARCH_LIBS([capng_apply], [cap-ng])
324
AC_SEARCH_LIBS([adler32], [z])
Ondřej Surý's avatar
Ondřej Surý committed
325 326 327

# Checks for header files.
AC_HEADER_RESOLV
328
AC_CHECK_HEADERS_ONCE([cap-ng.h netinet/in_systm.h pthread_np.h signal.h sys/select.h sys/time.h sys/wait.h sys/uio.h])
Ondřej Surý's avatar
Ondřej Surý committed
329 330 331 332 333 334 335 336

# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T

# Checks for library functions.
337
AC_CHECK_FUNCS([clock_gettime gettimeofday fgetln getline madvise malloc_trim poll posix_memalign pselect pthread_setaffinity_np regcomp select setgroups strlcat strlcpy initgroups])
Ondřej Surý's avatar
Ondřej Surý committed
338

339 340
# Check for be64toh function
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <endian.h>]], [[return be64toh(0);]])],
341
[AC_DEFINE(HAVE_BE64TOH, 1, [Define to 1 if you have the 'be64toh' function.])])
342

343 344 345 346 347 348 349 350
# 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.])])

351 352 353 354
# Use -fvisibility=hidden when linking.
# Let's leave it default now and use -export-symbols-regex in LDFLAGS
#gl_VISIBILITY()
#CFLAGS="$CFLAGS $CFLAG_VISIBILITY"
355

356 357 358
# Add code coverage macro
AX_CODE_COVERAGE

359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
AC_PATH_PROG([SPHINXBUILD], [sphinx-build], [false])
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.])])
  ])

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

Ondřej Surý's avatar
Ondřej Surý committed
374
AC_CONFIG_FILES([Makefile
375
		 doc/Makefile
376
		 man/Makefile
377
		 samples/Makefile
378
		 patches/Makefile
379 380 381
		 libtap/Makefile
		 src/Makefile
		 tests/Makefile
382
		 src/dnstap/Makefile
383
		 src/zscanner/Makefile
384
		 doc/conf.py
385 386 387 388 389 390
		 man/khost.1
		 man/knotc.8
		 man/knotd.8
		 man/kdig.1
		 man/knsupdate.1
		 man/knot.conf.5
391
		 man/knsec3hash.1
392
		 ])
393

Ondřej Surý's avatar
Ondřej Surý committed
394
AC_OUTPUT
Daniel Salzman's avatar
Daniel Salzman committed
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
AC_MSG_RESULT([
  $PACKAGE $VERSION

    Target:   $host_os $host_cpu
    Compiler: ${CC}
    CFlags:   ${CFLAGS} ${CPPFLAGS}
    LDFlags:  ${LDFLAGS}
    Libs:     ${LIBS}

    Prefix:      ${prefix}
    Run dir:     ${run_dir}
    Storage dir: ${storage_dir}
    Config dir:  ${config_dir}

    Fast zone parser:      ${enable_fastparser}
410
    Utilities with IDN:    ${with_libidn}
411
    Systemd integration:   ${enable_systemd}
412
    Dnstap support:        ${opt_dnstap}
Daniel Salzman's avatar
Daniel Salzman committed
413
    Code coverage:         ${enable_code_coverage}
Jan Včelák's avatar
Jan Včelák committed
414
    LMDB support:          ${enable_lmdb}
Daniel Salzman's avatar
Daniel Salzman committed
415 416 417

  Continue with 'make' command
])