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.20, 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()
48 # 1.4.20 had 4:0:2 # adds libunbound.ttl
50 # Current -- the number of the binary API that we're implementing
51 # Revision -- which iteration of the implementation of the binary
52 # API are we supplying?
53 # Age -- How many previous binary API versions do we also
56 # If we release a new version that does not change the binary API,
59 # If we release a new version that changes the binary API, but does
60 # not break programs compiled against the old binary API, increment
61 # Current and Age. Set Revision to 0, since this is the first
62 # implementation of the new API.
64 # Otherwise, we're changing the binary API and breaking bakward
65 # compatibility with old binaries. Increment Current. Set Age to 0,
66 # since we're backward compatible with no previous APIs. Set Revision
68 AC_SUBST(LIBUNBOUND_CURRENT)
69 AC_SUBST(LIBUNBOUND_REVISION)
70 AC_SUBST(LIBUNBOUND_AGE)
74 while test -n "$1"; do
75 cmdline="$cmdline '"`echo $1 | sed -e 's/\\\\/\\\\\\\\/g' | sed -e 's/"/\\\\"/g' `"'"
80 AC_DEFINE_UNQUOTED(CONFIGURE_BUILD_WITH, ["$cmdline"], [configure flags])
82 AC_DEFINE_UNQUOTED(CONFIGURE_TARGET, ["$target"], [configure target system])
83 AC_DEFINE_UNQUOTED(CONFIGURE_DATE, ["`date`"], [configure date])
89 dnl By default set prefix to /usr/local
98 if uname -s 2>&1 | grep MINGW32 >/dev/null; then on_mingw="yes"
100 if echo $target | grep mingw32 >/dev/null; then on_mingw="yes"
101 else on_mingw="no"; fi
105 # Determine configuration file
106 # the eval is to evaluate shell expansion twice
107 if test $on_mingw = "no"; then
108 ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"`
110 ub_conf_file="C:\\Program Files\\Unbound\\service.conf"
112 AC_ARG_WITH([conf_file],
113 AC_HELP_STRING([--with-conf-file=path],
114 [Pathname to the Unbound configuration file]),
115 [ub_conf_file="$withval"])
116 AC_SUBST(ub_conf_file)
117 ACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config)
118 AC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file])
120 # Determine run, chroot directory and pidfile locations
122 AC_HELP_STRING([--with-run-dir=path],
123 [set default directory to chdir to (by default dir part of cfg file)]),
124 UNBOUND_RUN_DIR="$withval",
125 if test $on_mingw = no; then
126 UNBOUND_RUN_DIR=`dirname "$ub_conf_file"`
131 AC_SUBST(UNBOUND_RUN_DIR)
132 ACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run)
133 AC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to])
135 AC_ARG_WITH(chroot-dir,
136 AC_HELP_STRING([--with-chroot-dir=path],
137 [set default directory to chroot to (by default same as run-dir)]),
138 UNBOUND_CHROOT_DIR="$withval",
139 if test $on_mingw = no; then
140 UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR"
142 UNBOUND_CHROOT_DIR=""
145 AC_SUBST(UNBOUND_CHROOT_DIR)
146 ACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot)
147 AC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to])
149 AC_ARG_WITH(share-dir,
150 AC_HELP_STRING([--with-share-dir=path],
151 [set default directory with shared data (by default same as share/unbound)]),
152 UNBOUND_SHARE_DIR="$withval",
153 UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR")
154 AC_SUBST(UNBOUND_SHARE_DIR)
155 AC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data])
158 AC_HELP_STRING([--with-pidfile=filename],
159 [set default pathname to unbound pidfile (default run-dir/unbound.pid)]),
160 UNBOUND_PIDFILE="$withval",
161 if test $on_mingw = no; then
162 UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid"
167 AC_SUBST(UNBOUND_PIDFILE)
168 ACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid)
169 AC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location])
171 AC_ARG_WITH(rootkey-file,
172 AC_HELP_STRING([--with-rootkey-file=filename],
173 [set default pathname to root key file (default run-dir/root.key). This file is read and written.]),
174 UNBOUND_ROOTKEY_FILE="$withval",
175 if test $on_mingw = no; then
176 UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key"
178 UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key"
181 AC_SUBST(UNBOUND_ROOTKEY_FILE)
182 ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey)
183 AC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location])
185 AC_ARG_WITH(rootcert-file,
186 AC_HELP_STRING([--with-rootcert-file=filename],
187 [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.]),
188 UNBOUND_ROOTCERT_FILE="$withval",
189 if test $on_mingw = no; then
190 UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem"
192 UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem"
195 AC_SUBST(UNBOUND_ROOTCERT_FILE)
196 ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem)
197 AC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location])
199 AC_ARG_WITH(username,
200 AC_HELP_STRING([--with-username=user],
201 [set default user that unbound changes to (default user is unbound)]),
202 UNBOUND_USERNAME="$withval",
203 UNBOUND_USERNAME="unbound")
204 AC_SUBST(UNBOUND_USERNAME)
205 AC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username])
207 AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
208 ACX_RSRC_VERSION(wnvs)
209 AC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files])
211 # Checks for typedefs, structures, and compiler characteristics.
214 # allow user to override the -g -O2 flags.
215 if test "x$CFLAGS" = "x" ; then
216 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"])
217 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"])
221 ACX_DETERMINE_EXT_FLAGS_UNBOUND
223 # debug mode flags warnings
224 AC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable warnings, asserts, makefile-dependencies]))
225 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [same as enable-checking]))
226 if test "$enable_debug" = "yes"; then debug_enabled="$enable_debug";
227 else debug_enabled="$enable_checking"; fi
228 AC_SUBST(debug_enabled)
229 case "$debug_enabled" in
231 ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"])
232 ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"])
233 ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"])
234 ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
235 AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.])
244 ACX_CHECK_FORMAT_ATTRIBUTE
245 ACX_CHECK_UNUSED_ATTRIBUTE
247 if test "$srcdir" != "."; then
248 CPPFLAGS="$CPPFLAGS -I$srcdir"
251 AC_DEFUN([ACX_YYLEX_DESTROY], [
252 AC_MSG_CHECKING([for yylex_destroy])
253 if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then
254 AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy])
256 else AC_MSG_RESULT(no); fi
262 AC_CHECK_PROG(doxygen, doxygen, doxygen)
263 AC_CHECK_TOOL(STRIP, strip)
266 # Checks for header files.
267 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])
270 # Using own tests for int64* because autoconf builtin only give 32bit.
271 AC_CHECK_TYPE(int8_t, signed char)
272 AC_CHECK_TYPE(int16_t, short)
273 AC_CHECK_TYPE(int32_t, int)
274 AC_CHECK_TYPE(int64_t, long long)
275 AC_CHECK_TYPE(uint8_t, unsigned char)
276 AC_CHECK_TYPE(uint16_t, unsigned short)
277 AC_CHECK_TYPE(uint32_t, unsigned int)
278 AC_CHECK_TYPE(uint64_t, unsigned long long)
280 AC_CHECK_TYPE(ssize_t, int)
289 ACX_CHECK_MEMCMP_SIGNED
291 # add option to disable the evil rpath
293 AC_SUBST(RUNTIME_PATH)
295 # check to see if libraries are needed for these functions.
296 AC_SEARCH_LIBS([inet_pton], [nsl])
297 AC_SEARCH_LIBS([socket], [socket])
299 # check wether strptime also works
300 AC_DEFUN([AC_CHECK_STRPTIME_WORKS],
301 [AC_REQUIRE([AC_PROG_CC])
302 AC_MSG_CHECKING(whether strptime works)
303 if test c${cross_compiling} = cno; then
304 AC_RUN_IFELSE([AC_LANG_SOURCE([[
305 #define _XOPEN_SOURCE
307 int main(void) { struct tm tm; char *res;
308 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);
310 res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
311 if (!res) return 1; return 0; }
312 ]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"])
314 eval "ac_cv_c_strptime_works=maybe"
316 AC_MSG_RESULT($ac_cv_c_strptime_works)
317 if test $ac_cv_c_strptime_works = no; then
320 AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.])
324 # check some functions of the OS before linking libs (while still runnable).
330 ACX_CHECK_NONBLOCKING_BROKEN
332 AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])])
334 # set memory allocation checking if requested
335 AC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks],
336 [ enable to memory allocation statistics, for debug purposes ]),
338 AC_ARG_ENABLE(alloc-lite, AC_HELP_STRING([--enable-alloc-lite],
339 [ enable for lightweight alloc assertions, for debug purposes ]),
341 AC_ARG_ENABLE(alloc-nonregional, AC_HELP_STRING([--enable-alloc-nonregional],
342 [ enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes ]),
344 if test x_$enable_alloc_nonregional = x_yes; then
345 AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use])
347 if test x_$enable_alloc_checks = x_yes; then
348 AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use])
350 if test x_$enable_alloc_lite = x_yes; then
351 AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use])
353 ACX_FUNC_MALLOC([unbound])
357 # check windows threads (we use them, not pthreads, on windows).
358 if test "$on_mingw" = "yes"; then
359 # check windows threads
360 AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT])
361 AC_MSG_CHECKING([for CreateThread])
362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
363 #ifdef HAVE_WINDOWS_H
367 HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL);
370 AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads])
376 # not on mingw, check thread libraries.
378 # check for thread library.
379 # check this first, so that the pthread lib does not get linked in via
380 # libssl or libpython, and thus distorts the tests, and we end up using
381 # the non-threadsafe C libraries.
382 AC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads],
383 [use pthreads library, or --without-pthreads to disable threading support.]),
384 [ ],[ withval="yes" ])
386 if test x_$withval != x_no; then
388 AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
389 LIBS="$PTHREAD_LIBS $LIBS"
390 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
393 AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>])
397 # check solaris thread library
398 AC_ARG_WITH(solaris-threads, AC_HELP_STRING([--with-solaris-threads],
399 [use solaris native thread library.]), [ ],[ withval="no" ])
400 ub_have_sol_threads=no
401 if test x_$withval != x_no; then
402 if test x_$ub_have_pthreads != x_no; then
403 AC_WARN([Have pthreads already, ignoring --with-solaris-threads])
405 AC_SEARCH_LIBS(thr_create, [thread],
407 AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads])
409 ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"],
410 [CFLAGS="$CFLAGS -D_REENTRANT"])
411 ub_have_sol_threads=yes
413 AC_ERROR([no solaris threads found.])
418 fi # end of non-mingw check of thread libraries
420 # Check for PyUnbound
421 AC_ARG_WITH(pyunbound,
422 AC_HELP_STRING([--with-pyunbound],
423 [build PyUnbound, or --without-pyunbound to skip it. (default=no)]),
424 [], [ withval="no" ])
428 if test x_$withval != x_no; then
429 ub_with_pyunbound=yes
433 # Check for Python module
434 AC_ARG_WITH(pythonmodule,
435 AC_HELP_STRING([--with-pythonmodule],
436 [build Python module, or --without-pythonmodule to disable script engine. (default=no)]),
437 [], [ withval="no" ])
440 if test x_$withval != x_no; then
441 ub_with_pythonmod=yes
445 # Check for Python & SWIG only on PyUnbound or PyModule
446 if test x_$ub_test_python != x_no; then
450 ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
452 if test ! -z "$PYTHON_VERSION"; then
453 if test `$PYTHON -c "print '$PYTHON_VERSION' >= '2.4.0'"` = "False"; then
454 AC_ERROR([Python version >= 2.4.0 is required])
458 AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
459 LIBS="$PYTHON_LDFLAGS $LIBS"
460 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
466 AC_MSG_CHECKING(SWIG)
467 if test ! -x "$SWIG"; then
468 AC_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound])
470 AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.])
471 AC_SUBST(swig, "$SWIG")
472 AC_MSG_RESULT(present)
474 # If have Python & SWIG
476 if test x_$ub_with_pythonmod != x_no; then
477 AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.])
478 WITH_PYTHONMODULE=yes
479 AC_SUBST(WITH_PYTHONMODULE)
480 PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo"
481 AC_SUBST(PYTHONMOD_OBJ)
482 PYTHONMOD_HEADER='$(srcdir)/pythonmod/pythonmod.h'
483 AC_SUBST(PYTHONMOD_HEADER)
484 PYTHONMOD_INSTALL=pythonmod-install
485 AC_SUBST(PYTHONMOD_INSTALL)
486 PYTHONMOD_UNINSTALL=pythonmod-uninstall
487 AC_SUBST(PYTHONMOD_UNINSTALL)
491 if test x_$ub_with_pyunbound != x_no; then
492 AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.])
494 AC_SUBST(WITH_PYUNBOUND)
495 PYUNBOUND_OBJ="libunbound_wrap.lo"
496 AC_SUBST(PYUNBOUND_OBJ)
497 PYUNBOUND_TARGET="_unbound.la"
498 AC_SUBST(PYUNBOUND_TARGET)
499 PYUNBOUND_INSTALL=pyunbound-install
500 AC_SUBST(PYUNBOUND_INSTALL)
501 PYUNBOUND_UNINSTALL=pyunbound-uninstall
502 AC_SUBST(PYUNBOUND_UNINSTALL)
506 AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***])
512 if test "`uname`" = "NetBSD"; then
513 NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_'
514 AC_SUBST(NETBSD_LINTFLAGS)
516 CONFIG_DATE=`date +%Y%m%d`
517 AC_SUBST(CONFIG_DATE)
519 # Checks for libraries.
523 AC_ARG_WITH([nss], AC_HELP_STRING([--with-nss=path],
524 [use libnss instead of openssl, installed at path.]),
527 AC_DEFINE(HAVE_NSS, 1, [Use libnss for crypto])
528 if test "$withval" != "" -a "$withval" != "yes"; then
529 CPPFLAGS="$CPPFLAGS -I$withval/include/nss3"
530 LDFLAGS="$LDFLAGS -L$withval/lib"
531 ACX_RUNTIME_PATH_ADD([$withval/lib])
532 CPPFLAGS="-I$withval/include/nspr4 $CPPFLAGS"
534 CPPFLAGS="$CPPFLAGS -I/usr/include/nss3"
535 CPPFLAGS="-I/usr/include/nspr4 $CPPFLAGS"
537 LIBS="$LIBS -lnss3 -lnspr4"
542 if test $USE_NSS = "no"; then
545 AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT])
546 AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT])
547 AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512 FIPS_mode])
548 AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free], [], [], [
550 #ifdef HAVE_OPENSSL_ERR_H
551 #include <openssl/err.h>
554 #ifdef HAVE_OPENSSL_RAND_H
555 #include <openssl/rand.h>
558 #ifdef HAVE_OPENSSL_CONF_H
559 #include <openssl/conf.h>
562 #ifdef HAVE_OPENSSL_ENGINE_H
563 #include <openssl/engine.h>
565 #include <openssl/ssl.h>
566 #include <openssl/evp.h>
571 AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
572 case "$enable_sha2" in
576 AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
580 # check wether gost also works
581 AC_DEFUN([AC_CHECK_GOST_WORKS],
582 [AC_REQUIRE([AC_PROG_CC])
583 AC_MSG_CHECKING([if GOST works])
584 if test c${cross_compiling} = cno; then
586 if test -n "$ssldir"; then
587 CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib"
589 AC_RUN_IFELSE([AC_LANG_SOURCE([[
591 #include <openssl/ssl.h>
592 #include <openssl/evp.h>
593 #include <openssl/engine.h>
594 #include <openssl/conf.h>
595 /* routine to load gost from ldns */
596 int load_gost_id(void)
598 static int gost_id = 0;
599 const EVP_PKEY_ASN1_METHOD* meth;
602 if(gost_id) return gost_id;
604 /* see if configuration loaded gost implementation from other engine*/
605 meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
607 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
611 /* see if engine can be loaded already */
612 e = ENGINE_by_id("gost");
614 /* load it ourself, in case statically linked */
615 ENGINE_load_builtin_engines();
616 ENGINE_load_dynamic();
617 e = ENGINE_by_id("gost");
620 /* no gost engine in openssl */
623 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
629 meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
636 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
642 unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */
643 const char* str = "Hello world";
644 const unsigned char check[] = {
645 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 ,
646 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 ,
647 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d ,
648 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d
650 OPENSSL_config(NULL);
651 (void)load_gost_id();
652 md = EVP_get_digestbyname("md_gost94");
654 memset(digest, 0, sizeof(digest));
655 ctx = EVP_MD_CTX_create();
657 if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3;
658 if(!EVP_DigestUpdate(ctx, str, 10)) return 4;
659 if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5;
660 /* uncomment to see the hash calculated.
663 printf(" %2.2x", (int)digest[i]);
666 if(memcmp(digest, check, sizeof(check)) != 0)
670 ]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"])
673 eval "ac_cv_c_gost_works=maybe"
675 AC_MSG_RESULT($ac_cv_c_gost_works)
678 AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
680 if test $USE_NSS = "no"; then
681 case "$enable_gost" in
685 AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])])
686 AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])])
688 if test "$ac_cv_c_gost_works" != no; then
690 AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
696 AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
698 case "$enable_ecdsa" in
702 if test $USE_NSS = "no"; then
703 AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])])
704 AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])])
705 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
706 #include <openssl/evp.h>
708 # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency)
709 AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP])
710 if grep OPENSSL_VERSION_NUMBER $ssldir/include/openssl/opensslv.h | grep 0x0 >/dev/null; then
712 AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl])
717 # we now know we have ECDSA and the required curves.
718 AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
724 AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname],
725 [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.]),
726 [ ],[ withval="no" ])
727 if test x_$withval = x_yes -o x_$withval != x_no; then
728 AC_MSG_CHECKING(for libevent)
729 if test x_$withval = x_ -o x_$withval = x_yes; then
730 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
732 for dir in $withval; do
734 if test -f "$dir/include/event.h"; then
736 dnl assume /usr is in default path.
737 if test "$thedir" != "/usr"; then
738 CPPFLAGS="$CPPFLAGS -I$thedir/include"
743 if test x_$found_libevent != x_yes; then
744 if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
745 # libevent source directory
746 AC_MSG_RESULT(found in $thedir)
747 CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include"
749 BAK_LDFLAGS="$LDFLAGS"
750 # remove evdns from linking
751 mkdir build >/dev/null 2>&1
752 mkdir build/libevent >/dev/null 2>&1
753 mkdir build/libevent/.libs >/dev/null 2>&1
754 ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
755 ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo`
756 ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
757 cp $ev_files_o build/libevent
758 cp $ev_files_lo build/libevent
759 cp $ev_files_libso build/libevent/.libs
760 LATE_LDFLAGS="build/libevent/*.lo -lm"
761 LDFLAGS="build/libevent/*.o $LDFLAGS -lm"
763 AC_MSG_ERROR([Cannot find the libevent library in $withval
764 You can restart ./configure --with-libevent=no to use a builtin alternative.
765 Please note that this alternative is not as capable as libevent when using
766 large outgoing port ranges. ])
769 AC_MSG_RESULT(found in $thedir)
770 dnl assume /usr is in default path, do not add "".
771 if test "$thedir" != "/usr" -a "$thedir" != ""; then
772 LDFLAGS="$LDFLAGS -L$thedir/lib"
773 ACX_RUNTIME_PATH_ADD([$thedir/lib])
776 # check for library used by libevent after 1.3c
777 AC_SEARCH_LIBS([clock_gettime], [rt])
779 # is the event.h header libev or libevent?
780 AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT])
781 AC_CHECK_DECL(EV_VERSION_MAJOR, [
782 AC_SEARCH_LIBS(event_set, [ev])
784 AC_SEARCH_LIBS(event_set, [event])
785 ],[AC_INCLUDES_DEFAULT
788 AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later
789 AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later
790 AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later
791 AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later
792 AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51)
793 AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00)
794 if test -n "$BAK_LDFLAGS_SET"; then
795 LDFLAGS="$BAK_LDFLAGS"
798 AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
802 AC_ARG_WITH(libexpat, AC_HELP_STRING([--with-libexpat=path],
803 [specify explicit path for libexpat.]),
804 [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ])
805 AC_MSG_CHECKING(for libexpat)
807 for dir in $withval ; do
808 if test -f "$dir/include/expat.h"; then
810 dnl assume /usr is in default path.
811 if test "$dir" != "/usr"; then
812 CPPFLAGS="$CPPFLAGS -I$dir/include"
813 LDFLAGS="$LDFLAGS -L$dir/lib"
815 AC_MSG_RESULT(found in $dir)
819 if test x_$found_libexpat != x_yes; then
820 AC_ERROR([Could not find libexpat, expat.h])
822 AC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT])
824 # set static linking if requested
827 AC_ARG_ENABLE(static-exe, AC_HELP_STRING([--enable-static-exe],
828 [ enable to compile executables statically against event, ldns libs, for debug purposes ]),
830 if test x_$enable_static_exe = x_yes; then
832 if test "$on_mingw" = yes; then
833 staticexe="-all-static"
834 # for static crosscompile, include gdi32 and zlib here.
835 if test "`uname`" = "Linux"; then
836 LIBS="$LIBS -lgdi32 -lz"
841 # set lock checking if requested
842 AC_ARG_ENABLE(lock_checks, AC_HELP_STRING([--enable-lock-checks],
843 [ enable to check lock and unlock calls, for debug purposes ]),
845 if test x_$enable_lock_checks = x_yes; then
846 AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).])
847 CHECKLOCK_OBJ="checklocks.lo"
848 AC_SUBST(CHECKLOCK_OBJ)
851 ACX_CHECK_GETADDRINFO_WITH_INCLUDES
852 if test "$USE_WINSOCK" = 1; then
853 AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API])
854 AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT
857 AC_CHECK_TOOL(WINDRES, windres)
858 LIBS="$LIBS -liphlpapi"
859 WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe"
861 WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c"
862 AC_SUBST(WIN_DAEMON_SRC)
863 WIN_DAEMON_OBJ="win_svc.lo w_inst.lo"
864 AC_SUBST(WIN_DAEMON_OBJ)
865 WIN_DAEMON_OBJ_LINK="rsrc_unbound.o"
866 AC_SUBST(WIN_DAEMON_OBJ_LINK)
867 WIN_HOST_OBJ_LINK="rsrc_unbound_host.o"
868 AC_SUBST(WIN_HOST_OBJ_LINK)
869 WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo"
870 AC_SUBST(WIN_UBANCHOR_OBJ_LINK)
871 WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o"
872 AC_SUBST(WIN_CONTROL_OBJ_LINK)
873 WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o"
874 AC_SUBST(WIN_CHECKCONF_OBJ_LINK)
876 if test $ac_cv_func_getaddrinfo = no; then
877 AC_LIBOBJ([fake-rfc2553])
879 # check after getaddrinfo for its libraries
882 # see if daemon(3) exists, and if it is deprecated.
883 AC_CHECK_FUNCS([daemon])
884 if test $ac_cv_func_daemon = yes; then
885 ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [
890 AC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[
893 #include <sys/param.h>
896 #ifdef HAVE_SYS_SOCKET_H
897 #include <sys/socket.h>
900 #ifdef HAVE_SYS_UIO_H
904 #ifdef HAVE_NETINET_IN_H
905 #include <netinet/in.h>
908 #ifdef HAVE_ARPA_INET_H
909 #include <arpa/inet.h>
912 #ifdef HAVE_WINSOCK2_H
913 #include <winsock2.h>
916 #ifdef HAVE_WS2TCPIP_H
917 #include <ws2tcpip.h>
920 AC_SEARCH_LIBS([setusercontext], [util])
921 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])
922 AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
923 AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
925 # check if setreuid en setregid fail, on MacOSX10.4(darwin8).
926 if echo $build_os | grep darwin8 > /dev/null; then
927 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
929 AC_REPLACE_FUNCS(inet_aton)
930 AC_REPLACE_FUNCS(inet_pton)
931 AC_REPLACE_FUNCS(inet_ntop)
932 AC_REPLACE_FUNCS(snprintf)
933 AC_REPLACE_FUNCS(strlcpy)
934 AC_REPLACE_FUNCS(memmove)
935 AC_REPLACE_FUNCS(gmtime_r)
936 LIBOBJ_WITHOUT_CTIME="$LIBOBJS"
937 AC_SUBST(LIBOBJ_WITHOUT_CTIME)
938 AC_REPLACE_FUNCS(ctime_r)
940 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]))
941 case "$enable_allsymbols" in
943 COMMON_OBJ_ALL_SYMBOLS=""
945 EXTRALINK="-L. -L.libs -lunbound"
946 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])
949 COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)'
950 UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def'
954 AC_SUBST(COMMON_OBJ_ALL_SYMBOLS)
957 if test x_$enable_lock_checks = x_yes; then
958 UBSYMS="-export-symbols clubsyms.def"
959 cp ${srcdir}/libunbound/ubsyms.def clubsyms.def
960 echo lock_protect >> clubsyms.def
961 echo lock_unprotect >> clubsyms.def
962 echo lock_get_mem >> clubsyms.def
963 echo checklock_start >> clubsyms.def
964 echo checklock_stop >> clubsyms.def
965 echo checklock_lock >> clubsyms.def
966 echo checklock_unlock >> clubsyms.def
967 echo checklock_init >> clubsyms.def
968 echo checklock_thrcreate >> clubsyms.def
969 echo checklock_thrjoin >> clubsyms.def
972 AC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope])
973 # on openBSD, the implicit rule make $< work.
974 # on Solaris, it does not work ($? is changed sources, $^ lists dependencies).
976 cat >conftest.make <<EOF
979 conftest.lo foo.lo bla.lo:
980 if test -f "\$<"; then touch \$@; fi
984 if test -f "\$<"; then touch \$@; fi
986 conftest.lo: conftest.dir/conftest.c
989 touch conftest.dir/conftest.c
990 rm -f conftest.lo conftest.c
991 ${MAKE:-make} -f conftest.make >/dev/null
992 rm -f conftest.make conftest.c conftest.dir/conftest.c
994 if test ! -f conftest.lo; then
996 SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source'
997 SOURCEFILE='`cat .source`'
1004 AC_SUBST(SOURCEDETERMINE)
1005 AC_SUBST(SOURCEFILE)
1007 # see if we want to build the library or everything
1008 ALLTARGET="alltargets"
1009 AC_ARG_WITH(libunbound-only, AC_HELP_STRING([--with-libunbound-only],
1010 [do not build daemon and tool programs]),
1012 if test "$withval" = "yes"; then
1018 # check this after all other compilation checks, since the linking of the lib
1019 # may break checks after this.
1020 AC_ARG_WITH(ldns, AC_HELP_STRING([--with-ldns=PATH],
1021 [specify prefix of path of ldns library to use]),
1023 if test "$withval" != "yes"; then
1024 if test "$withval" != "/usr" -a "$withval" != ""; then
1025 CPPFLAGS="-I$withval/include $CPPFLAGS"
1026 LDFLAGS="-L$withval/lib $LDFLAGS"
1027 ACX_RUNTIME_PATH_ADD([$withval/lib])
1034 # check if ldns is good enough
1035 AC_CHECK_LIB(ldns, ldns_rr_new,,[
1036 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])
1038 AC_CHECK_FUNC(ldns_buffer_copy)
1039 if test $USE_NSS = "no"; then
1040 AC_CHECK_FUNC(ldns_key_buf2rsa_raw)
1043 ac_cv_func_ldns_key_buf2rsa_raw="yes"
1045 AC_CHECK_FUNC(ldns_get_random)
1046 AC_CHECK_FUNC(ldns_b32_ntop_extended_hex)
1047 if test x$use_gost = xyes -a x$USE_NSS = xno; then
1048 AC_CHECK_FUNC(ldns_key_EVP_load_gost_id)
1049 AC_CHECK_FUNCS([ldns_key_EVP_unload_gost])
1052 ac_cv_func_ldns_key_EVP_load_gost_id="yes"
1054 if test x$use_ecdsa = xyes; then
1055 AC_CHECK_DECL([LDNS_ECDSAP384SHA384], [], [], [
1057 #ifdef HAVE_SYS_SOCKET_H
1058 # include <sys/socket.h>
1060 #ifdef HAVE_WS2TCPIP_H
1061 # include <ws2tcpip.h>
1063 #include <ldns/ldns.h>
1066 ac_cv_have_decl_LDNS_ECDSAP384SHA384="yes"
1068 AC_CHECK_HEADERS([ldns/ldns.h],,[
1069 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])
1070 ], [AC_INCLUDES_DEFAULT
1071 #ifdef HAVE_SYS_SOCKET_H
1072 #include <sys/socket.h>
1075 #ifdef HAVE_NETINET_IN_H
1076 #include <netinet/in.h>
1079 #ifdef HAVE_ARPA_INET_H
1080 #include <arpa/inet.h>
1083 #ifdef HAVE_WINSOCK2_H
1084 #include <winsock2.h>
1087 #ifdef HAVE_WS2TCPIP_H
1088 #include <ws2tcpip.h>
1091 if test $ac_cv_func_ldns_buffer_copy = yes \
1092 -a $ac_cv_func_ldns_key_buf2rsa_raw = yes \
1093 -a $ac_cv_func_ldns_get_random = yes \
1094 -a $ac_cv_header_ldns_ldns_h = yes \
1095 -a $ac_cv_func_ldns_b32_ntop_extended_hex = yes \
1096 -a $ac_cv_func_ldns_key_EVP_load_gost_id = yes \
1097 -a $ac_cv_have_decl_LDNS_ECDSAP384SHA384 = yes; then
1101 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])
1105 LDFLAGS="$LATE_LDFLAGS $LDFLAGS"
1107 AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.])
1110 dnl this must be first AH_CONFIG, to define the flags before any includes.
1111 AHX_CONFIG_EXT_FLAGS
1115 #ifndef UNBOUND_DEBUG
1129 #ifdef HAVE_STDINT_H
1135 #if HAVE_SYS_PARAM_H
1136 #include <sys/param.h>
1139 #ifdef HAVE_SYS_SOCKET_H
1140 #include <sys/socket.h>
1143 #ifdef HAVE_SYS_UIO_H
1144 #include <sys/uio.h>
1147 #ifdef HAVE_NETINET_IN_H
1148 #include <netinet/in.h>
1151 #ifdef HAVE_ARPA_INET_H
1152 #include <arpa/inet.h>
1155 #ifdef HAVE_WINSOCK2_H
1156 #include <winsock2.h>
1159 #ifdef HAVE_WS2TCPIP_H
1160 #include <ws2tcpip.h>
1164 AHX_CONFIG_FORMAT_ATTRIBUTE
1165 AHX_CONFIG_UNUSED_ATTRIBUTE
1167 AHX_CONFIG_MAXHOSTNAMELEN
1168 AHX_CONFIG_SNPRINTF(unbound)
1169 AHX_CONFIG_INET_PTON(unbound)
1170 AHX_CONFIG_INET_NTOP(unbound)
1171 AHX_CONFIG_INET_ATON(unbound)
1172 AHX_CONFIG_MEMMOVE(unbound)
1173 AHX_CONFIG_STRLCPY(unbound)
1174 AHX_CONFIG_GMTIME_R(unbound)
1175 AHX_CONFIG_W32_SLEEP
1176 AHX_CONFIG_W32_USLEEP
1177 AHX_CONFIG_W32_RANDOM
1178 AHX_CONFIG_W32_SRANDOM
1179 AHX_CONFIG_W32_FD_SET_T
1180 AHX_CONFIG_IPV6_MIN_MTU
1181 AHX_MEMCMP_BROKEN(unbound)
1184 #ifndef HAVE_CTIME_R
1185 #define ctime_r unbound_ctime_r
1186 char *ctime_r(const time_t *timep, char *buf);
1189 #if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
1190 #define strptime unbound_strptime
1192 char *strptime(const char *s, const char *format, struct tm *tm);
1195 #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))
1196 /* using version of libevent that is not threadsafe. */
1197 # define LIBEVENT_SIGNAL_PROBLEM 1
1200 #ifndef CHECKED_INET6
1201 # define CHECKED_INET6
1205 # define AF_INET6 28
1207 #endif /* CHECKED_INET6 */
1209 /* maximum nesting of included files */
1210 #define MAXINCLUDES 10
1211 #ifndef HAVE_GETADDRINFO
1212 struct sockaddr_storage;
1213 #include "compat/fake-rfc2553.h"
1216 #ifdef UNBOUND_ALLOC_STATS
1217 # define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__)
1218 # define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__)
1219 # define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__)
1220 # define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__)
1221 void *unbound_stat_malloc(size_t size);
1222 void *unbound_stat_calloc(size_t nmemb, size_t size);
1223 void unbound_stat_free(void *ptr);
1224 void *unbound_stat_realloc(void *ptr, size_t size);
1225 void *unbound_stat_malloc_log(size_t size, const char* file, int line,
1227 void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file,
1228 int line, const char* func);
1229 void unbound_stat_free_log(void *ptr, const char* file, int line,
1231 void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file,
1232 int line, const char* func);
1233 #elif defined(UNBOUND_ALLOC_LITE)
1234 # include "util/alloc.h"
1235 #endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */
1237 /** default port for DNS traffic. */
1238 #define UNBOUND_DNS_PORT 53
1239 /** default port for unbound control traffic, registered port with IANA,
1240 ub-dns-control 8953/tcp unbound dns nameserver control */
1241 #define UNBOUND_CONTROL_PORT 8953
1242 /** the version of unbound-control that this software implements */
1243 #define UNBOUND_CONTROL_VERSION 1
1247 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])
1248 AC_CONFIG_HEADER([config.h])