2 # Process this file with autoconf to produce a configure script.
4 sinclude(acx_nlnetlabs.m4)
5 sinclude(acx_pthread.m4)
6 sinclude(acx_python.m4)
7 sinclude(ac_pkg_swig.m4)
9 AC_INIT(unbound, 1.4.17, unbound-bugs@nlnetlabs.nl, unbound)
21 # 1.3.0 had 1:0:0 # ub_cancel and -export-symbols.
26 # 1.4.0-snapshots had 1:5:0
27 # 1.4.0 had 1:5:0 (not 2:0:0) # ub_result.why_bogus
41 # and 1.4.13p1 and 1.4.13.p2
43 # 1.4.15 had 3:0:1 # adds ub_version()
47 # Current -- the number of the binary API that we're implementing
48 # Revision -- which iteration of the implementation of the binary
49 # API are we supplying?
50 # Age -- How many previous binary API versions do we also
53 # If we release a new version that does not change the binary API,
56 # If we release a new version that changes the binary API, but does
57 # not break programs compiled against the old binary API, increment
58 # Current and Age. Set Revision to 0, since this is the first
59 # implementation of the new API.
61 # Otherwise, we're changing the binary API and breaking bakward
62 # compatibility with old binaries. Increment Current. Set Age to 0,
63 # since we're backward compatible with no previous APIs. Set Revision
65 AC_SUBST(LIBUNBOUND_CURRENT)
66 AC_SUBST(LIBUNBOUND_REVISION)
67 AC_SUBST(LIBUNBOUND_AGE)
71 while test -n "$1"; do
72 cmdline="$cmdline '"`echo $1 | sed -e 's/\\\\/\\\\\\\\/g' | sed -e 's/"/\\\\"/g' `"'"
77 AC_DEFINE_UNQUOTED(CONFIGURE_BUILD_WITH, ["$cmdline"], [configure flags])
79 AC_DEFINE_UNQUOTED(CONFIGURE_TARGET, ["$target"], [configure target system])
80 AC_DEFINE_UNQUOTED(CONFIGURE_DATE, ["`date`"], [configure date])
86 dnl By default set prefix to /usr/local
95 if uname -s 2>&1 | grep MINGW32 >/dev/null; then on_mingw="yes"
97 if echo $target | grep mingw32 >/dev/null; then on_mingw="yes"
98 else on_mingw="no"; fi
102 # Determine configuration file
103 # the eval is to evaluate shell expansion twice
104 if test $on_mingw = "no"; then
105 ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"`
107 ub_conf_file="C:\\Program Files\\Unbound\\service.conf"
109 AC_ARG_WITH([conf_file],
110 AC_HELP_STRING([--with-conf-file=path],
111 [Pathname to the Unbound configuration file]),
112 [ub_conf_file="$withval"])
113 AC_SUBST(ub_conf_file)
114 ACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config)
115 AC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file])
117 # Determine run, chroot directory and pidfile locations
119 AC_HELP_STRING([--with-run-dir=path],
120 [set default directory to chdir to (by default dir part of cfg file)]),
121 UNBOUND_RUN_DIR="$withval",
122 if test $on_mingw = no; then
123 UNBOUND_RUN_DIR=`dirname "$ub_conf_file"`
128 AC_SUBST(UNBOUND_RUN_DIR)
129 ACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run)
130 AC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to])
132 AC_ARG_WITH(chroot-dir,
133 AC_HELP_STRING([--with-chroot-dir=path],
134 [set default directory to chroot to (by default same as run-dir)]),
135 UNBOUND_CHROOT_DIR="$withval",
136 if test $on_mingw = no; then
137 UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR"
139 UNBOUND_CHROOT_DIR=""
142 AC_SUBST(UNBOUND_CHROOT_DIR)
143 ACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot)
144 AC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to])
146 AC_ARG_WITH(share-dir,
147 AC_HELP_STRING([--with-share-dir=path],
148 [set default directory with shared data (by default same as share/unbound)]),
149 UNBOUND_SHARE_DIR="$withval",
150 UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR")
151 AC_SUBST(UNBOUND_SHARE_DIR)
152 AC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data])
155 AC_HELP_STRING([--with-pidfile=filename],
156 [set default pathname to unbound pidfile (default run-dir/unbound.pid)]),
157 UNBOUND_PIDFILE="$withval",
158 if test $on_mingw = no; then
159 UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid"
164 AC_SUBST(UNBOUND_PIDFILE)
165 ACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid)
166 AC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location])
168 AC_ARG_WITH(rootkey-file,
169 AC_HELP_STRING([--with-rootkey-file=filename],
170 [set default pathname to root key file (default run-dir/root.key). This file is read and written.]),
171 UNBOUND_ROOTKEY_FILE="$withval",
172 if test $on_mingw = no; then
173 UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key"
175 UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key"
178 AC_SUBST(UNBOUND_ROOTKEY_FILE)
179 ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey)
180 AC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location])
182 AC_ARG_WITH(rootcert-file,
183 AC_HELP_STRING([--with-rootcert-file=filename],
184 [set default pathname to root update certificate file (default run-dir/icannbundle.pem). This file need not exist if you are content with the builtin.]),
185 UNBOUND_ROOTCERT_FILE="$withval",
186 if test $on_mingw = no; then
187 UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem"
189 UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem"
192 AC_SUBST(UNBOUND_ROOTCERT_FILE)
193 ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem)
194 AC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location])
196 AC_ARG_WITH(username,
197 AC_HELP_STRING([--with-username=user],
198 [set default user that unbound changes to (default user is unbound)]),
199 UNBOUND_USERNAME="$withval",
200 UNBOUND_USERNAME="unbound")
201 AC_SUBST(UNBOUND_USERNAME)
202 AC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username])
204 AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
205 ACX_RSRC_VERSION(wnvs)
206 AC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files])
208 # Checks for typedefs, structures, and compiler characteristics.
211 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"])
212 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"])
215 ACX_DETERMINE_EXT_FLAGS_UNBOUND
217 # debug mode flags warnings
218 AC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable warnings, asserts, makefile-dependencies]))
219 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [same as enable-checking]))
220 if test "$enable_debug" = "yes"; then debug_enabled="$enable_debug";
221 else debug_enabled="$enable_checking"; fi
222 AC_SUBST(debug_enabled)
223 case "$debug_enabled" in
225 ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"])
226 ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"])
227 ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"])
228 ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
229 AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.])
238 ACX_CHECK_FORMAT_ATTRIBUTE
239 ACX_CHECK_UNUSED_ATTRIBUTE
241 if test "$srcdir" != "."; then
242 CPPFLAGS="$CPPFLAGS -I$srcdir"
245 AC_DEFUN([ACX_YYLEX_DESTROY], [
246 AC_MSG_CHECKING([for yylex_destroy])
247 if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then
248 AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy])
250 else AC_MSG_RESULT(no); fi
256 AC_CHECK_PROG(doxygen, doxygen, doxygen)
257 AC_CHECK_TOOL(STRIP, strip)
260 # Checks for header files.
261 AC_CHECK_HEADERS([stdarg.h stdbool.h netinet/in.h sys/param.h sys/socket.h sys/uio.h sys/resource.h arpa/inet.h syslog.h netdb.h sys/wait.h pwd.h glob.h grp.h login_cap.h winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
264 # Using own tests for int64* because autoconf builtin only give 32bit.
265 AC_CHECK_TYPE(int8_t, signed char)
266 AC_CHECK_TYPE(int16_t, short)
267 AC_CHECK_TYPE(int32_t, int)
268 AC_CHECK_TYPE(int64_t, long long)
269 AC_CHECK_TYPE(uint8_t, unsigned char)
270 AC_CHECK_TYPE(uint16_t, unsigned short)
271 AC_CHECK_TYPE(uint32_t, unsigned int)
272 AC_CHECK_TYPE(uint64_t, unsigned long long)
274 AC_CHECK_TYPE(ssize_t, int)
283 ACX_CHECK_MEMCMP_SIGNED
285 # add option to disable the evil rpath
287 AC_SUBST(RUNTIME_PATH)
289 # check to see if libraries are needed for these functions.
290 AC_SEARCH_LIBS([inet_pton], [nsl])
291 AC_SEARCH_LIBS([socket], [socket])
293 # check wether strptime also works
294 AC_DEFUN([AC_CHECK_STRPTIME_WORKS],
295 [AC_REQUIRE([AC_PROG_CC])
296 AC_MSG_CHECKING(whether strptime works)
297 if test c${cross_compiling} = cno; then
298 AC_RUN_IFELSE([AC_LANG_SOURCE([[
299 #define _XOPEN_SOURCE
301 int main(void) { struct tm tm; char *res;
302 res = strptime("2010-07-15T00:00:00+00:00", "%t%Y%t-%t%m%t-%t%d%tT%t%H%t:%t%M%t:%t%S%t", &tm);
304 res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
305 if (!res) return 1; return 0; }
306 ]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"])
308 eval "ac_cv_c_strptime_works=maybe"
310 AC_MSG_RESULT($ac_cv_c_strptime_works)
311 if test $ac_cv_c_strptime_works = no; then
314 AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.])
318 # check some functions of the OS before linking libs (while still runnable).
324 ACX_CHECK_NONBLOCKING_BROKEN
326 AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])])
328 # set memory allocation checking if requested
329 AC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks],
330 [ enable to memory allocation statistics, for debug purposes ]),
332 AC_ARG_ENABLE(alloc-lite, AC_HELP_STRING([--enable-alloc-lite],
333 [ enable for lightweight alloc assertions, for debug purposes ]),
335 AC_ARG_ENABLE(alloc-nonregional, AC_HELP_STRING([--enable-alloc-nonregional],
336 [ enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes ]),
338 if test x_$enable_alloc_nonregional = x_yes; then
339 AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use])
341 if test x_$enable_alloc_checks = x_yes; then
342 AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use])
344 if test x_$enable_alloc_lite = x_yes; then
345 AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use])
347 ACX_FUNC_MALLOC([unbound])
351 # check windows threads (we use them, not pthreads, on windows).
352 if test "$on_mingw" = "yes"; then
353 # check windows threads
354 AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT])
355 AC_MSG_CHECKING([for CreateThread])
356 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
357 #ifdef HAVE_WINDOWS_H
361 HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL);
364 AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads])
370 # not on mingw, check thread libraries.
372 # check for thread library.
373 # check this first, so that the pthread lib does not get linked in via
374 # libssl or libpython, and thus distorts the tests, and we end up using
375 # the non-threadsafe C libraries.
376 AC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads],
377 [use pthreads library, or --without-pthreads to disable threading support.]),
378 [ ],[ withval="yes" ])
380 if test x_$withval != x_no; then
382 AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
383 LIBS="$PTHREAD_LIBS $LIBS"
384 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
387 AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>])
391 # check solaris thread library
392 AC_ARG_WITH(solaris-threads, AC_HELP_STRING([--with-solaris-threads],
393 [use solaris native thread library.]), [ ],[ withval="no" ])
394 ub_have_sol_threads=no
395 if test x_$withval != x_no; then
396 if test x_$ub_have_pthreads != x_no; then
397 AC_WARN([Have pthreads already, ignoring --with-solaris-threads])
399 AC_SEARCH_LIBS(thr_create, [thread],
401 AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads])
403 ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"],
404 [CFLAGS="$CFLAGS -D_REENTRANT"])
405 ub_have_sol_threads=yes
407 AC_ERROR([no solaris threads found.])
412 fi # end of non-mingw check of thread libraries
414 # Check for PyUnbound
415 AC_ARG_WITH(pyunbound,
416 AC_HELP_STRING([--with-pyunbound],
417 [build PyUnbound, or --without-pyunbound to skip it. (default=no)]),
418 [], [ withval="no" ])
422 if test x_$withval != x_no; then
423 ub_with_pyunbound=yes
427 # Check for Python module
428 AC_ARG_WITH(pythonmodule,
429 AC_HELP_STRING([--with-pythonmodule],
430 [build Python module, or --without-pythonmodule to disable script engine. (default=no)]),
431 [], [ withval="no" ])
434 if test x_$withval != x_no; then
435 ub_with_pythonmod=yes
439 # Check for Python & SWIG only on PyUnbound or PyModule
440 if test x_$ub_test_python != x_no; then
444 ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
446 if test ! -z "$PYTHON_VERSION"; then
447 if test `$PYTHON -c "print '$PYTHON_VERSION' >= '2.4.0'"` = "False"; then
448 AC_ERROR([Python version >= 2.4.0 is required])
452 AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
453 LIBS="$PYTHON_LDFLAGS $LIBS"
454 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
460 AC_MSG_CHECKING(SWIG)
461 if test ! -x "$SWIG"; then
462 AC_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound])
464 AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.])
465 AC_SUBST(swig, "$SWIG")
466 AC_MSG_RESULT(present)
468 # If have Python & SWIG
470 if test x_$ub_with_pythonmod != x_no; then
471 AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.])
472 WITH_PYTHONMODULE=yes
473 AC_SUBST(WITH_PYTHONMODULE)
474 PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo"
475 AC_SUBST(PYTHONMOD_OBJ)
476 PYTHONMOD_HEADER='$(srcdir)/pythonmod/pythonmod.h'
477 AC_SUBST(PYTHONMOD_HEADER)
478 PYTHONMOD_INSTALL=pythonmod-install
479 AC_SUBST(PYTHONMOD_INSTALL)
480 PYTHONMOD_UNINSTALL=pythonmod-uninstall
481 AC_SUBST(PYTHONMOD_UNINSTALL)
485 if test x_$ub_with_pyunbound != x_no; then
486 AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.])
488 AC_SUBST(WITH_PYUNBOUND)
489 PYUNBOUND_OBJ="libunbound_wrap.lo"
490 AC_SUBST(PYUNBOUND_OBJ)
491 PYUNBOUND_TARGET="_unbound.la"
492 AC_SUBST(PYUNBOUND_TARGET)
493 PYUNBOUND_INSTALL=pyunbound-install
494 AC_SUBST(PYUNBOUND_INSTALL)
495 PYUNBOUND_UNINSTALL=pyunbound-uninstall
496 AC_SUBST(PYUNBOUND_UNINSTALL)
500 AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***])
506 if test "`uname`" = "NetBSD"; then
507 NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_'
508 AC_SUBST(NETBSD_LINTFLAGS)
510 CONFIG_DATE=`date +%Y%m%d`
511 AC_SUBST(CONFIG_DATE)
513 # Checks for libraries.
516 AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT])
517 AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT])
518 AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512])
519 AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free], [], [], [
521 #ifdef HAVE_OPENSSL_ERR_H
522 #include <openssl/err.h>
525 #ifdef HAVE_OPENSSL_RAND_H
526 #include <openssl/rand.h>
529 #ifdef HAVE_OPENSSL_CONF_H
530 #include <openssl/conf.h>
533 #ifdef HAVE_OPENSSL_ENGINE_H
534 #include <openssl/engine.h>
536 #include <openssl/ssl.h>
537 #include <openssl/evp.h>
540 AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
541 case "$enable_sha2" in
545 AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
549 # check wether gost also works
550 AC_DEFUN([AC_CHECK_GOST_WORKS],
551 [AC_REQUIRE([AC_PROG_CC])
552 AC_MSG_CHECKING([if GOST works])
553 if test c${cross_compiling} = cno; then
555 if test -n "$ssldir"; then
556 CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib"
558 AC_RUN_IFELSE([AC_LANG_SOURCE([[
560 #include <openssl/ssl.h>
561 #include <openssl/evp.h>
562 #include <openssl/engine.h>
563 #include <openssl/conf.h>
564 /* routine to load gost from ldns */
565 int load_gost_id(void)
567 static int gost_id = 0;
568 const EVP_PKEY_ASN1_METHOD* meth;
571 if(gost_id) return gost_id;
573 /* see if configuration loaded gost implementation from other engine*/
574 meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
576 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
580 /* see if engine can be loaded already */
581 e = ENGINE_by_id("gost");
583 /* load it ourself, in case statically linked */
584 ENGINE_load_builtin_engines();
585 ENGINE_load_dynamic();
586 e = ENGINE_by_id("gost");
589 /* no gost engine in openssl */
592 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
598 meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
605 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
611 unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */
612 const char* str = "Hello world";
613 const unsigned char check[] = {
614 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 ,
615 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 ,
616 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d ,
617 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d
619 OPENSSL_config(NULL);
620 (void)load_gost_id();
621 md = EVP_get_digestbyname("md_gost94");
623 memset(digest, 0, sizeof(digest));
624 ctx = EVP_MD_CTX_create();
626 if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3;
627 if(!EVP_DigestUpdate(ctx, str, 10)) return 4;
628 if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5;
629 /* uncomment to see the hash calculated.
632 printf(" %2.2x", (int)digest[i]);
635 if(memcmp(digest, check, sizeof(check)) != 0)
639 ]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"])
642 eval "ac_cv_c_gost_works=maybe"
644 AC_MSG_RESULT($ac_cv_c_gost_works)
647 AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
649 case "$enable_gost" in
653 AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])])
654 AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])])
656 if test $ac_cv_c_gost_works != no; then
658 AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
663 AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
665 case "$enable_ecdsa" in
669 AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])])
670 AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])])
671 AC_CHECK_DECLS([NID_X9_62_prime256v1, NID_secp384r1], [], [AC_MSG_ERROR([OpenSSL does not support the ECDSA curves: please upgrade or rerun with --disable-ecdsa])], [AC_INCLUDES_DEFAULT
672 #include <openssl/evp.h>
674 # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency)
675 AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP])
676 if grep OPENSSL_VERSION_NUMBER $ssldir/include/openssl/opensslv.h | grep 0x0 >/dev/null; then
678 AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl])
682 # we now know we have ECDSA and the required curves.
683 AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
689 AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname],
690 [use libevent (will check /usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr or you can specify an explicit path). Slower, but allows use of large outgoing port ranges.]),
691 [ ],[ withval="no" ])
692 if test x_$withval = x_yes -o x_$withval != x_no; then
693 AC_MSG_CHECKING(for libevent)
694 if test x_$withval = x_ -o x_$withval = x_yes; then
695 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
697 for dir in $withval; do
699 if test -f "$dir/include/event.h"; then
701 dnl assume /usr is in default path.
702 if test "$thedir" != "/usr"; then
703 CPPFLAGS="$CPPFLAGS -I$thedir/include"
708 if test x_$found_libevent != x_yes; then
709 if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
710 # libevent source directory
711 AC_MSG_RESULT(found in $thedir)
712 CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include"
714 BAK_LDFLAGS="$LDFLAGS"
715 # remove evdns from linking
716 mkdir build >/dev/null 2>&1
717 mkdir build/libevent >/dev/null 2>&1
718 mkdir build/libevent/.libs >/dev/null 2>&1
719 ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
720 ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo`
721 ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
722 cp $ev_files_o build/libevent
723 cp $ev_files_lo build/libevent
724 cp $ev_files_libso build/libevent/.libs
725 LATE_LDFLAGS="build/libevent/*.lo -lm"
726 LDFLAGS="build/libevent/*.o $LDFLAGS -lm"
728 AC_MSG_ERROR([Cannot find the libevent library in $withval
729 You can restart ./configure --with-libevent=no to use a builtin alternative.
730 Please note that this alternative is not as capable as libevent when using
731 large outgoing port ranges. ])
734 AC_MSG_RESULT(found in $thedir)
735 dnl assume /usr is in default path, do not add "".
736 if test "$thedir" != "/usr" -a "$thedir" != ""; then
737 LDFLAGS="$LDFLAGS -L$thedir/lib"
738 ACX_RUNTIME_PATH_ADD([$thedir/lib])
741 # check for library used by libevent after 1.3c
742 AC_SEARCH_LIBS([clock_gettime], [rt])
744 # is the event.h header libev or libevent?
745 AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT])
746 AC_CHECK_DECL(EV_VERSION_MAJOR, [
747 AC_SEARCH_LIBS(event_set, [ev])
749 AC_SEARCH_LIBS(event_set, [event])
750 ],[AC_INCLUDES_DEFAULT
753 AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later
754 AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later
755 AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later
756 AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later
757 AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51)
758 AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00)
759 if test -n "$BAK_LDFLAGS_SET"; then
760 LDFLAGS="$BAK_LDFLAGS"
763 AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
767 AC_ARG_WITH(libexpat, AC_HELP_STRING([--with-libexpat=path],
768 [specify explicit path for libexpat.]),
769 [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ])
770 AC_MSG_CHECKING(for libexpat)
772 for dir in $withval ; do
773 if test -f "$dir/include/expat.h"; then
775 dnl assume /usr is in default path.
776 if test "$dir" != "/usr"; then
777 CPPFLAGS="$CPPFLAGS -I$dir/include"
778 LDFLAGS="$LDFLAGS -L$dir/lib"
780 AC_MSG_RESULT(found in $dir)
784 if test x_$found_libexpat != x_yes; then
785 AC_ERROR([Could not find libexpat, expat.h])
787 AC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT])
789 # set static linking if requested
792 AC_ARG_ENABLE(static-exe, AC_HELP_STRING([--enable-static-exe],
793 [ enable to compile executables statically against event, ldns libs, for debug purposes ]),
795 if test x_$enable_static_exe = x_yes; then
797 if test "$on_mingw" = yes; then
798 staticexe="-all-static"
799 # for static crosscompile, include gdi32 and zlib here.
800 if test "`uname`" = "Linux"; then
801 LIBS="$LIBS -lgdi32 -lz"
806 # set lock checking if requested
807 AC_ARG_ENABLE(lock_checks, AC_HELP_STRING([--enable-lock-checks],
808 [ enable to check lock and unlock calls, for debug purposes ]),
810 if test x_$enable_lock_checks = x_yes; then
811 AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).])
812 CHECKLOCK_OBJ="checklocks.lo"
813 AC_SUBST(CHECKLOCK_OBJ)
816 ACX_CHECK_GETADDRINFO_WITH_INCLUDES
817 if test "$USE_WINSOCK" = 1; then
818 AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API])
819 AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT
822 AC_CHECK_TOOL(WINDRES, windres)
823 LIBS="$LIBS -liphlpapi"
824 WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe"
826 WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c"
827 AC_SUBST(WIN_DAEMON_SRC)
828 WIN_DAEMON_OBJ="win_svc.lo w_inst.lo"
829 AC_SUBST(WIN_DAEMON_OBJ)
830 WIN_DAEMON_OBJ_LINK="rsrc_unbound.o"
831 AC_SUBST(WIN_DAEMON_OBJ_LINK)
832 WIN_HOST_OBJ_LINK="rsrc_unbound_host.o"
833 AC_SUBST(WIN_HOST_OBJ_LINK)
834 WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo"
835 AC_SUBST(WIN_UBANCHOR_OBJ_LINK)
836 WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o"
837 AC_SUBST(WIN_CONTROL_OBJ_LINK)
838 WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o"
839 AC_SUBST(WIN_CHECKCONF_OBJ_LINK)
841 if test $ac_cv_func_getaddrinfo = no; then
842 AC_LIBOBJ([fake-rfc2553])
844 # check after getaddrinfo for its libraries
847 # see if daemon(3) exists, and if it is deprecated.
848 AC_CHECK_FUNCS([daemon])
849 if test $ac_cv_func_daemon = yes; then
850 ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [
855 AC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[
858 #include <sys/param.h>
861 #ifdef HAVE_SYS_SOCKET_H
862 #include <sys/socket.h>
865 #ifdef HAVE_SYS_UIO_H
869 #ifdef HAVE_NETINET_IN_H
870 #include <netinet/in.h>
873 #ifdef HAVE_ARPA_INET_H
874 #include <arpa/inet.h>
877 #ifdef HAVE_WINSOCK2_H
878 #include <winsock2.h>
881 #ifdef HAVE_WS2TCPIP_H
882 #include <ws2tcpip.h>
885 AC_SEARCH_LIBS([setusercontext], [util])
886 AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex])
887 AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
888 AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
890 # check if setreuid en setregid fail, on MacOSX10.4(darwin8).
891 if echo $build_os | grep darwin8 > /dev/null; then
892 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
894 AC_REPLACE_FUNCS(inet_aton)
895 AC_REPLACE_FUNCS(inet_pton)
896 AC_REPLACE_FUNCS(inet_ntop)
897 AC_REPLACE_FUNCS(snprintf)
898 AC_REPLACE_FUNCS(strlcpy)
899 AC_REPLACE_FUNCS(memmove)
900 AC_REPLACE_FUNCS(gmtime_r)
901 LIBOBJ_WITHOUT_CTIME="$LIBOBJS"
902 AC_SUBST(LIBOBJ_WITHOUT_CTIME)
903 AC_REPLACE_FUNCS(ctime_r)
905 AC_ARG_ENABLE(allsymbols, AC_HELP_STRING([--enable-allsymbols], [export all symbols from libunbound and link binaries to it, smaller install size but libunbound export table is polluted by internal symbols]))
906 case "$enable_allsymbols" in
908 COMMON_OBJ_ALL_SYMBOLS=""
910 EXTRALINK="-L. -L.libs -lunbound"
911 AC_DEFINE(EXPORT_ALL_SYMBOLS, 1, [Define this if you enabled-allsymbols from libunbound to link binaries to it for smaller install size, but the libunbound export table is polluted by internal symbols])
914 COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)'
915 UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def'
919 AC_SUBST(COMMON_OBJ_ALL_SYMBOLS)
922 if test x_$enable_lock_checks = x_yes; then
923 UBSYMS="-export-symbols clubsyms.def"
924 cp ${srcdir}/libunbound/ubsyms.def clubsyms.def
925 echo lock_protect >> clubsyms.def
926 echo lock_unprotect >> clubsyms.def
927 echo lock_get_mem >> clubsyms.def
928 echo checklock_start >> clubsyms.def
929 echo checklock_stop >> clubsyms.def
930 echo checklock_lock >> clubsyms.def
931 echo checklock_unlock >> clubsyms.def
932 echo checklock_init >> clubsyms.def
933 echo checklock_thrcreate >> clubsyms.def
934 echo checklock_thrjoin >> clubsyms.def
937 AC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope])
938 # on openBSD, the implicit rule make $< work.
939 # on Solaris, it does not work ($? is changed sources, $^ lists dependencies).
941 cat >conftest.make <<EOF
944 conftest.lo foo.lo bla.lo:
945 if test -f "\$<"; then touch \$@; fi
949 if test -f "\$<"; then touch \$@; fi
951 conftest.lo: conftest.dir/conftest.c
954 touch conftest.dir/conftest.c
955 rm -f conftest.lo conftest.c
956 ${MAKE:-make} -f conftest.make >/dev/null
957 rm -f conftest.make conftest.c conftest.dir/conftest.c
959 if test ! -f conftest.lo; then
961 SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source'
962 SOURCEFILE='`cat .source`'
969 AC_SUBST(SOURCEDETERMINE)
972 # check this after all other compilation checks, since the linking of the lib
973 # may break checks after this.
974 AC_ARG_WITH(ldns, AC_HELP_STRING([--with-ldns=PATH],
975 [specify prefix of path of ldns library to use]),
977 if test "$withval" != "yes"; then
978 if test "$withval" != "/usr" -a "$withval" != ""; then
979 CPPFLAGS="-I$withval/include $CPPFLAGS"
980 LDFLAGS="-L$withval/lib $LDFLAGS"
981 ACX_RUNTIME_PATH_ADD([$withval/lib])
988 # check if ldns is good enough
989 AC_CHECK_LIB(ldns, ldns_rr_new,,[
990 AC_MSG_ERROR([No ldns library found, install the ldns library into system lib dir or use --with-ldns=path to other location. The --with-ldns can point to the make-dir of ldns. Install the package ldns or download source http://www.nlnetlabs.nl/projects/ldns])
992 AC_CHECK_FUNC(ldns_buffer_copy)
993 AC_CHECK_FUNC(ldns_key_buf2rsa_raw)
994 AC_CHECK_FUNC(ldns_get_random)
995 AC_CHECK_FUNC(ldns_b32_ntop_extended_hex)
996 if test x$use_gost = xyes; then
997 AC_CHECK_FUNC(ldns_key_EVP_load_gost_id)
998 AC_CHECK_FUNCS([ldns_key_EVP_unload_gost])
1000 ac_cv_func_ldns_key_EVP_load_gost_id="yes"
1002 if test x$use_ecdsa = xyes; then
1003 AC_CHECK_DECL([LDNS_ECDSAP384SHA384], [], [], [
1005 #ifdef HAVE_SYS_SOCKET_H
1006 # include <sys/socket.h>
1008 #ifdef HAVE_WS2TCPIP_H
1009 # include <ws2tcpip.h>
1011 #include <ldns/ldns.h>
1014 ac_cv_have_decl_LDNS_ECDSAP384SHA384="yes"
1016 AC_CHECK_HEADERS([ldns/ldns.h],,[
1017 AC_MSG_ERROR([No ldns include file found, install the ldns library development files. Install package ldns-dev or ldns-devel or download source http://www.nlnetlabs.nl/projects/ldns])
1018 ], [AC_INCLUDES_DEFAULT
1019 #ifdef HAVE_SYS_SOCKET_H
1020 #include <sys/socket.h>
1023 #ifdef HAVE_NETINET_IN_H
1024 #include <netinet/in.h>
1027 #ifdef HAVE_ARPA_INET_H
1028 #include <arpa/inet.h>
1031 #ifdef HAVE_WINSOCK2_H
1032 #include <winsock2.h>
1035 #ifdef HAVE_WS2TCPIP_H
1036 #include <ws2tcpip.h>
1039 if test $ac_cv_func_ldns_buffer_copy = yes \
1040 -a $ac_cv_func_ldns_key_buf2rsa_raw = yes \
1041 -a $ac_cv_func_ldns_get_random = yes \
1042 -a $ac_cv_header_ldns_ldns_h = yes \
1043 -a $ac_cv_func_ldns_b32_ntop_extended_hex = yes \
1044 -a $ac_cv_func_ldns_key_EVP_load_gost_id = yes \
1045 -a $ac_cv_have_decl_LDNS_ECDSAP384SHA384 = yes; then
1049 AC_MSG_ERROR([ldns library is not recent, update the ldns library, install it into system lib dir or use --with-ldns=path to other location. The --with-ldns can point to the make-dir of ldns. Package libldns or download source http://www.nlnetlabs.nl/projects/ldns])
1053 LDFLAGS="$LATE_LDFLAGS $LDFLAGS"
1055 AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.])
1058 dnl this must be first AH_CONFIG, to define the flags before any includes.
1059 AHX_CONFIG_EXT_FLAGS
1063 #ifndef UNBOUND_DEBUG
1077 #ifdef HAVE_STDINT_H
1083 #if HAVE_SYS_PARAM_H
1084 #include <sys/param.h>
1087 #ifdef HAVE_SYS_SOCKET_H
1088 #include <sys/socket.h>
1091 #ifdef HAVE_SYS_UIO_H
1092 #include <sys/uio.h>
1095 #ifdef HAVE_NETINET_IN_H
1096 #include <netinet/in.h>
1099 #ifdef HAVE_ARPA_INET_H
1100 #include <arpa/inet.h>
1103 #ifdef HAVE_WINSOCK2_H
1104 #include <winsock2.h>
1107 #ifdef HAVE_WS2TCPIP_H
1108 #include <ws2tcpip.h>
1112 AHX_CONFIG_FORMAT_ATTRIBUTE
1113 AHX_CONFIG_UNUSED_ATTRIBUTE
1115 AHX_CONFIG_MAXHOSTNAMELEN
1116 AHX_CONFIG_SNPRINTF(unbound)
1117 AHX_CONFIG_INET_PTON(unbound)
1118 AHX_CONFIG_INET_NTOP(unbound)
1119 AHX_CONFIG_INET_ATON(unbound)
1120 AHX_CONFIG_MEMMOVE(unbound)
1121 AHX_CONFIG_STRLCPY(unbound)
1122 AHX_CONFIG_GMTIME_R(unbound)
1123 AHX_CONFIG_W32_SLEEP
1124 AHX_CONFIG_W32_USLEEP
1125 AHX_CONFIG_W32_RANDOM
1126 AHX_CONFIG_W32_SRANDOM
1127 AHX_CONFIG_W32_FD_SET_T
1128 AHX_CONFIG_IPV6_MIN_MTU
1129 AHX_MEMCMP_BROKEN(unbound)
1132 #ifndef HAVE_CTIME_R
1133 #define ctime_r unbound_ctime_r
1134 char *ctime_r(const time_t *timep, char *buf);
1137 #if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
1138 #define strptime unbound_strptime
1140 char *strptime(const char *s, const char *format, struct tm *tm);
1143 #if defined(HAVE_EVENT_H) && !defined(HAVE_EVENT_BASE_ONCE) && !(defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)) && (defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS))
1144 /* using version of libevent that is not threadsafe. */
1145 # define LIBEVENT_SIGNAL_PROBLEM 1
1148 #ifndef CHECKED_INET6
1149 # define CHECKED_INET6
1153 # define AF_INET6 28
1155 #endif /* CHECKED_INET6 */
1157 /* maximum nesting of included files */
1158 #define MAXINCLUDES 10
1159 #ifndef HAVE_GETADDRINFO
1160 struct sockaddr_storage;
1161 #include "compat/fake-rfc2553.h"
1164 #ifdef UNBOUND_ALLOC_STATS
1165 # define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__)
1166 # define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__)
1167 # define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__)
1168 # define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__)
1169 void *unbound_stat_malloc(size_t size);
1170 void *unbound_stat_calloc(size_t nmemb, size_t size);
1171 void unbound_stat_free(void *ptr);
1172 void *unbound_stat_realloc(void *ptr, size_t size);
1173 void *unbound_stat_malloc_log(size_t size, const char* file, int line,
1175 void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file,
1176 int line, const char* func);
1177 void unbound_stat_free_log(void *ptr, const char* file, int line,
1179 void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file,
1180 int line, const char* func);
1181 #elif defined(UNBOUND_ALLOC_LITE)
1182 # include "util/alloc.h"
1183 #endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */
1185 /** default port for DNS traffic. */
1186 #define UNBOUND_DNS_PORT 53
1187 /** default port for unbound control traffic, registered port with IANA,
1188 ub-dns-control 8953/tcp unbound dns nameserver control */
1189 #define UNBOUND_CONTROL_PORT 8953
1190 /** the version of unbound-control that this software implements */
1191 #define UNBOUND_CONTROL_VERSION 1
1195 AC_CONFIG_FILES([Makefile doc/example.conf doc/libunbound.3 doc/unbound.8 doc/unbound-anchor.8 doc/unbound-checkconf.8 doc/unbound.conf.5 doc/unbound-control.8])
1196 AC_CONFIG_HEADER([config.h])