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

3
AC_PREREQ([2.65])
Lubos Slovak's avatar
Lubos Slovak committed
4
AC_INIT([knot], [1.0.5], [knot-dns@labs.nic.cz])
5
AM_INIT_AUTOMAKE([gnu -Wall -Werror])
6
AC_CONFIG_SRCDIR([src/knot/main.c])
Ondřej Surý's avatar
Ondřej Surý committed
7 8
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_MACRO_DIR([m4])
9
AC_USE_SYSTEM_EXTENSIONS([_GNU_SOURCE])
10
AX_EXT
Ondřej Surý's avatar
Ondřej Surý committed
11

12 13 14
# Checks for programs.
AC_PROG_CC

15 16 17
# Enable maintainer mode by default for development
AM_MAINTAINER_MODE([enable])

Ondřej Surý's avatar
Ondřej Surý committed
18
# Initialize libtool
19
AC_PROG_LIBTOOL
Ondřej Surý's avatar
Ondřej Surý committed
20 21
LT_INIT

22 23 24
AC_CACHE_CHECK([for reentrant lex], [ac_cv_path_LEX],
  [AC_PATH_PROGS_FEATURE_CHECK([LEX], [$LEX flex gflex],
  [cat >conftest.l <<_ACEOF
25 26 27 28 29 30 31 32 33 34 35 36 37 38
%{
%}

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

BLANK [ \t\n]

%%
<<EOF>> return 0;
%%
39 40 41 42 43 44 45 46
_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
47

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
# Check for tools needed to compile used documentation
AC_ARG_VAR([XMLTO], [path to xmlto processor to generate a HTML documentation])
#AC_ARG_VAR([DBLATEX], [path to dblatex process to generate a PDF documentation])
AC_ARG_WITH([documentation],
    [AS_HELP_STRING([--with-documentation @<:@default=no@:>@],
	[enable building of the user documentation])],
    [],
    [with_documentation=no])

XMLTO=
AS_IF([test "x$with_documentation" != "xno"],
    [AC_CHECK_PROG([XMLTO], [xmlto], [xmlto],
        [AC_MSG_ERROR([xmlto needed for building the documentation])])
#     AC_PATH_PROG([DBLATEX], [dblatex],
#        [AC_MSG_ERROR([dblatex needed for building the documentation])])
     AC_SUBST([DOC], [doc])
    ])

Ondřej Surý's avatar
Ondřej Surý committed
66
AC_PROG_YACC
67 68 69 70
YACC_BISON=`bison --version | awk '{print $1;exit}'`
if test "$YACC_BISON" != "bison"; then
    AC_MSG_ERROR([GNU bison needed for reentrant parsers, set the \$YACC variable before running configure])
fi
Ondřej Surý's avatar
Ondřej Surý committed
71 72
AC_PROG_INSTALL

73 74 75 76
# Set compiler compatibility flags
AC_PROG_CPP_WERROR
AC_PROG_CC_C99

Jan Kadlec's avatar
Jan Kadlec committed
77
AC_ARG_ENABLE([ldns],
78
     AC_HELP_STRING([--enable-ldns=yes|no], [Enable tests with ldns [default=no]]),
Jan Kadlec's avatar
Jan Kadlec committed
79
     [case "${enableval}" in
80 81
       yes) AC_SEARCH_LIBS([ldns_rr_list_pop_rrset], [ldns], [AC_DEFINE([HAVE_LDNS], [1], [ldns present])],
       AC_MSG_ERROR([ldns not found])) ;;
Jan Kadlec's avatar
Jan Kadlec committed
82 83 84
       no)  ldns=false ;;
       *) AC_MSG_ERROR([bad value ${enableval} for --enable-ldns]) ;;
     esac],[ldns=false])
85 86 87
     
# Debug modules
AC_ARG_ENABLE([debug],
88 89
    AS_HELP_STRING([--enable-debug=server,zones,xfr,packet,dname,rr,ns,hash,compiler],
    [compile selected debug modules [default=none]]),
90
    [
91 92 93 94 95 96 97 98 99 100 101 102 103
    echo ${enableval}|tr "," "\n"|while read val; do
        case "${val}" in
          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.]) ;;
          dname) AC_DEFINE([KNOT_DNAME_DEBUG], [1], [Domain names debug.]) ;;
          rr) AC_DEFINE([KNOT_RR_DEBUG], [1], [RR debug.]) ;;
          ns) AC_DEFINE([KNOT_NS_DEBUG], [1], [Nameserver debug.]) ;;
          hash) AC_DEFINE([KNOT_HASH_DEBUG], [1], [Hashtable debug.]) ;;
          compiler) AC_DEFINE([KNOT_COMPILER_DEBUG], [1], [Zone compiler debug.]) ;;
        esac
    done
104
    ], [])
Jan Kadlec's avatar
Jan Kadlec committed
105

106
# Debug level
107 108
AC_ARG_ENABLE([debuglevel],
    AS_HELP_STRING([--enable-debuglevel=brief|verbose|details], [enable given debug level [default=disabled]]),
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
    # 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.])
	;;
      xverbose)
        AC_DEFINE([DEBUG_ENABLE_VERBOSE], [1], [Enable verbose debugging messages.])
        AC_DEFINE([DEBUG_ENABLE_BRIEF], [1], [Enable brief debugging messages.])
	;;
      xbrief)
        AC_DEFINE([DEBUG_ENABLE_BRIEF], [1], [Enable brief debugging messages.])
        ;;
    esac], [])
124 125 126
    
# recvmmsg() (valgrind doesn't support it, so disable for debugging)
AC_ARG_ENABLE([recvmmsg],
127
    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]]),
128 129 130 131 132 133 134 135 136 137 138 139 140 141
    [case "${enableval}" in
      yes)
         AC_DEFINE([ENABLE_RECVMMSG], [1], [recvmmsg enabled])
         ;;
      no)
         recvmmsg=false
         ;;
      *) 
         AC_MSG_ERROR([bad value ${enableval} for --enable-recvmmsg])
         ;;
    esac], [
    AC_DEFINE([ENABLE_RECVMMSG], [1], [recvmmsg enabled])
    recvmmsg=true
    ])
142

143
# Check for link time optimizations support and predictive commoning
144 145 146 147 148 149 150 151 152 153
AC_ARG_ENABLE([lto],
    AS_HELP_STRING([--enable-lto=yes|no], [enable link-time optimizations, disable if broken (f.e. clang on FreeBSD) [default=yes]]),
    [case "${enableval}" in
      yes) AX_CHECK_COMPILER_FLAGS("-flto", [CFLAGS="$CFLAGS -flto"], []) ;;
      no) ;;
      *)  AC_MSG_ERROR([bad value ${enableval} for --enable-recvmmsg]) ;;
    esac], [
    AX_CHECK_COMPILER_FLAGS("-flto", [CFLAGS="$CFLAGS -flto"], [])
    ])

154 155
AX_CHECK_COMPILER_FLAGS("-fpredictive-commoning", [CFLAGS="$CFLAGS -fpredictive-commoning"], [])

Ondřej Surý's avatar
Ondřej Surý committed
156 157
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lm':
158
# TODO: check if paths exist before appending
159
CFLAGS="$CFLAGS -I/usr/local/include $SIMD_FLAGS"
160 161 162
LDFLAGS="$LDFLAGS -L/usr/local/lib"
AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthreads not found])])
163
AC_SEARCH_LIBS([rcu_set_pointer_sym], [urcu], [], [AC_MSG_ERROR([liburcu not found])])
164
AC_SEARCH_LIBS([urcu_init], [urcu], [AC_MSG_ERROR([liburcu is too old (< 0.4.0), urcu_init symbol found])], [])
165
AC_SEARCH_LIBS([dlopen], [dl])
Marek Vavrusa's avatar
Marek Vavrusa committed
166
AC_SEARCH_LIBS([clock_gettime], [rt])
167
AC_SEARCH_LIBS([OpenSSL_add_all_digests], [crypto],[], [AC_MSG_ERROR([libcrypto not found])])
168
AC_SEARCH_LIBS([capng_apply], [cap-ng])
169
AC_SEARCH_LIBS([crc32], [z])
170
#AC_SEARCH_LIBS([ldns_rr_list_pop_rrset], [ldns], [], [AC_MSG_ERROR([libldns not found])])
Ondřej Surý's avatar
Ondřej Surý committed
171 172 173

# Checks for header files.
AC_HEADER_RESOLV
174
AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h malloc.h netdb.h netinet/in_systm.h netinet/in.h stdint.h stdlib.h string.h strings.h sys/socket.h sys/time.h cap-ng.h syslog.h unistd.h urcu.h ev.h pthread_np.h])
Ondřej Surý's avatar
Ondřej Surý committed
175 176 177 178 179 180 181 182 183 184 185 186 187

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT64_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T

188 189 190
# Set PRNG parameters
AC_DEFINE([DSFMT_MEXP], [521], [DSFMT parameters.])

Ondřej Surý's avatar
Ondřej Surý committed
191 192 193
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MMAP
194
AC_CHECK_FUNCS([gethostbyname gettimeofday clock_gettime memalign memmove memset munmap regcomp pselect select socket sqrt strcasecmp strchr strdup strerror strncasecmp strtol strtoul poll epoll_wait kqueue setgroups sendmmsg madvise pthread_setaffinity_np])
Ondřej Surý's avatar
Ondřej Surý committed
195

196 197 198 199 200 201 202 203
# 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.])])

Ondřej Surý's avatar
Ondřej Surý committed
204
AC_CONFIG_FILES([Makefile
205
		 samples/Makefile
Ondřej Surý's avatar
Ondřej Surý committed
206 207
                 src/Makefile])
AC_OUTPUT