2 # Process this file with autoconf to produce a configure script.
4 sinclude(acx_nlnetlabs.m4)
5 sinclude(ax_pthread.m4)
6 sinclude(acx_python.m4)
7 sinclude(ac_pkg_swig.m4)
9 # must be numbers. ac_defun because of later processing
10 m4_define([VERSION_MAJOR],[1])
11 m4_define([VERSION_MINOR],[4])
12 m4_define([VERSION_MICRO],[22])
13 AC_INIT(unbound, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), unbound-bugs@nlnetlabs.nl, unbound)
14 AC_SUBST(UNBOUND_VERSION_MAJOR, [VERSION_MAJOR])
15 AC_SUBST(UNBOUND_VERSION_MINOR, [VERSION_MINOR])
16 AC_SUBST(UNBOUND_VERSION_MICRO, [VERSION_MICRO])
28 # 1.3.0 had 1:0:0 # ub_cancel and -export-symbols.
33 # 1.4.0-snapshots had 1:5:0
34 # 1.4.0 had 1:5:0 (not 2:0:0) # ub_result.why_bogus
48 # and 1.4.13p1 and 1.4.13.p2
50 # 1.4.15 had 3:0:1 # adds ub_version()
55 # 1.4.20 had 4:0:2 # adds libunbound.ttl # but shipped 3:5:1
58 # Current -- the number of the binary API that we're implementing
59 # Revision -- which iteration of the implementation of the binary
60 # API are we supplying?
61 # Age -- How many previous binary API versions do we also
64 # If we release a new version that does not change the binary API,
67 # If we release a new version that changes the binary API, but does
68 # not break programs compiled against the old binary API, increment
69 # Current and Age. Set Revision to 0, since this is the first
70 # implementation of the new API.
72 # Otherwise, we're changing the binary API and breaking bakward
73 # compatibility with old binaries. Increment Current. Set Age to 0,
74 # since we're backward compatible with no previous APIs. Set Revision
76 AC_SUBST(LIBUNBOUND_CURRENT)
77 AC_SUBST(LIBUNBOUND_REVISION)
78 AC_SUBST(LIBUNBOUND_AGE)
82 if test "$ac_cv_header_minix_config_h" = "yes"; then
83 AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix])
87 dnl By default set prefix to /usr/local
96 if uname -s 2>&1 | grep MINGW32 >/dev/null; then on_mingw="yes"
98 if echo $target | grep mingw32 >/dev/null; then on_mingw="yes"
99 else on_mingw="no"; fi
103 # Determine configuration file
104 # the eval is to evaluate shell expansion twice
105 if test $on_mingw = "no"; then
106 ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"`
108 ub_conf_file="C:\\Program Files\\Unbound\\service.conf"
110 AC_ARG_WITH([conf_file],
111 AC_HELP_STRING([--with-conf-file=path],
112 [Pathname to the Unbound configuration file]),
113 [ub_conf_file="$withval"])
114 AC_SUBST(ub_conf_file)
115 ACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config)
116 AC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file])
118 # Determine run, chroot directory and pidfile locations
120 AC_HELP_STRING([--with-run-dir=path],
121 [set default directory to chdir to (by default dir part of cfg file)]),
122 UNBOUND_RUN_DIR="$withval",
123 if test $on_mingw = no; then
124 UNBOUND_RUN_DIR=`dirname "$ub_conf_file"`
129 AC_SUBST(UNBOUND_RUN_DIR)
130 ACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run)
131 AC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to])
133 AC_ARG_WITH(chroot-dir,
134 AC_HELP_STRING([--with-chroot-dir=path],
135 [set default directory to chroot to (by default same as run-dir)]),
136 UNBOUND_CHROOT_DIR="$withval",
137 if test $on_mingw = no; then
138 UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR"
140 UNBOUND_CHROOT_DIR=""
143 AC_SUBST(UNBOUND_CHROOT_DIR)
144 ACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot)
145 AC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to])
147 AC_ARG_WITH(share-dir,
148 AC_HELP_STRING([--with-share-dir=path],
149 [set default directory with shared data (by default same as share/unbound)]),
150 UNBOUND_SHARE_DIR="$withval",
151 UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR")
152 AC_SUBST(UNBOUND_SHARE_DIR)
153 AC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data])
156 AC_HELP_STRING([--with-pidfile=filename],
157 [set default pathname to unbound pidfile (default run-dir/unbound.pid)]),
158 UNBOUND_PIDFILE="$withval",
159 if test $on_mingw = no; then
160 UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid"
165 AC_SUBST(UNBOUND_PIDFILE)
166 ACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid)
167 AC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location])
169 AC_ARG_WITH(rootkey-file,
170 AC_HELP_STRING([--with-rootkey-file=filename],
171 [set default pathname to root key file (default run-dir/root.key). This file is read and written.]),
172 UNBOUND_ROOTKEY_FILE="$withval",
173 if test $on_mingw = no; then
174 UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key"
176 UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key"
179 AC_SUBST(UNBOUND_ROOTKEY_FILE)
180 ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey)
181 AC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location])
183 AC_ARG_WITH(rootcert-file,
184 AC_HELP_STRING([--with-rootcert-file=filename],
185 [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.]),
186 UNBOUND_ROOTCERT_FILE="$withval",
187 if test $on_mingw = no; then
188 UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem"
190 UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem"
193 AC_SUBST(UNBOUND_ROOTCERT_FILE)
194 ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem)
195 AC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location])
197 AC_ARG_WITH(username,
198 AC_HELP_STRING([--with-username=user],
199 [set default user that unbound changes to (default user is unbound)]),
200 UNBOUND_USERNAME="$withval",
201 UNBOUND_USERNAME="unbound")
202 AC_SUBST(UNBOUND_USERNAME)
203 AC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username])
205 AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
206 ACX_RSRC_VERSION(wnvs)
207 AC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files])
209 # Checks for typedefs, structures, and compiler characteristics.
212 # allow user to override the -g -O2 flags.
213 if test "x$CFLAGS" = "x" ; then
214 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"])
215 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"])
219 ACX_DETERMINE_EXT_FLAGS_UNBOUND
221 # debug mode flags warnings
222 AC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable warnings, asserts, makefile-dependencies]))
223 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [same as enable-checking]))
224 if test "$enable_debug" = "yes"; then debug_enabled="$enable_debug";
225 else debug_enabled="$enable_checking"; fi
226 AC_SUBST(debug_enabled)
227 case "$debug_enabled" in
229 ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"])
230 ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"])
231 ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"])
232 ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
233 AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.])
242 ACX_CHECK_FORMAT_ATTRIBUTE
243 ACX_CHECK_UNUSED_ATTRIBUTE
245 if test "$srcdir" != "."; then
246 CPPFLAGS="$CPPFLAGS -I$srcdir"
249 AC_DEFUN([ACX_YYLEX_DESTROY], [
250 AC_MSG_CHECKING([for yylex_destroy])
251 if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then
252 AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy])
254 else AC_MSG_RESULT(no); fi
260 AC_CHECK_PROG(doxygen, doxygen, doxygen)
261 AC_CHECK_TOOL(STRIP, strip)
264 # Checks for header files.
265 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])
268 # Using own tests for int64* because autoconf builtin only give 32bit.
269 AC_CHECK_TYPE(int8_t, signed char)
270 AC_CHECK_TYPE(int16_t, short)
271 AC_CHECK_TYPE(int32_t, int)
272 AC_CHECK_TYPE(int64_t, long long)
273 AC_CHECK_TYPE(uint8_t, unsigned char)
274 AC_CHECK_TYPE(uint16_t, unsigned short)
275 AC_CHECK_TYPE(uint32_t, unsigned int)
276 AC_CHECK_TYPE(uint64_t, unsigned long long)
278 AC_CHECK_TYPE(ssize_t, int)
287 ACX_CHECK_MEMCMP_SIGNED
289 AC_CHECK_SIZEOF(time_t,,[
291 #ifdef TIME_WITH_SYS_TIME
292 # include <sys/time.h>
295 # ifdef HAVE_SYS_TIME_H
296 # include <sys/time.h>
303 # add option to disable the evil rpath
305 AC_SUBST(RUNTIME_PATH)
307 # check to see if libraries are needed for these functions.
308 AC_SEARCH_LIBS([inet_pton], [nsl])
309 AC_SEARCH_LIBS([socket], [socket])
311 # check wether strptime also works
312 AC_DEFUN([AC_CHECK_STRPTIME_WORKS],
313 [AC_REQUIRE([AC_PROG_CC])
314 AC_MSG_CHECKING(whether strptime works)
315 if test c${cross_compiling} = cno; then
316 AC_RUN_IFELSE([AC_LANG_SOURCE([[
317 #define _XOPEN_SOURCE
319 int main(void) { struct tm tm; char *res;
320 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);
322 res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
323 if (!res) return 1; return 0; }
324 ]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"])
326 eval "ac_cv_c_strptime_works=maybe"
328 AC_MSG_RESULT($ac_cv_c_strptime_works)
329 if test $ac_cv_c_strptime_works = no; then
332 AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.])
336 # check some functions of the OS before linking libs (while still runnable).
342 ACX_CHECK_NONBLOCKING_BROKEN
344 AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])])
346 # set memory allocation checking if requested
347 AC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks],
348 [ enable to memory allocation statistics, for debug purposes ]),
350 AC_ARG_ENABLE(alloc-lite, AC_HELP_STRING([--enable-alloc-lite],
351 [ enable for lightweight alloc assertions, for debug purposes ]),
353 AC_ARG_ENABLE(alloc-nonregional, AC_HELP_STRING([--enable-alloc-nonregional],
354 [ enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes ]),
356 if test x_$enable_alloc_nonregional = x_yes; then
357 AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use])
359 if test x_$enable_alloc_checks = x_yes; then
360 AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use])
362 if test x_$enable_alloc_lite = x_yes; then
363 AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use])
365 ACX_FUNC_MALLOC([unbound])
369 # check windows threads (we use them, not pthreads, on windows).
370 if test "$on_mingw" = "yes"; then
371 # check windows threads
372 AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT])
373 AC_MSG_CHECKING([for CreateThread])
374 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
375 #ifdef HAVE_WINDOWS_H
379 HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL);
382 AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads])
388 # not on mingw, check thread libraries.
390 # check for thread library.
391 # check this first, so that the pthread lib does not get linked in via
392 # libssl or libpython, and thus distorts the tests, and we end up using
393 # the non-threadsafe C libraries.
394 AC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads],
395 [use pthreads library, or --without-pthreads to disable threading support.]),
396 [ ],[ withval="yes" ])
398 if test x_$withval != x_no; then
400 AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
401 LIBS="$PTHREAD_LIBS $LIBS"
402 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
405 AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>])
409 # check solaris thread library
410 AC_ARG_WITH(solaris-threads, AC_HELP_STRING([--with-solaris-threads],
411 [use solaris native thread library.]), [ ],[ withval="no" ])
412 ub_have_sol_threads=no
413 if test x_$withval != x_no; then
414 if test x_$ub_have_pthreads != x_no; then
415 AC_WARN([Have pthreads already, ignoring --with-solaris-threads])
417 AC_SEARCH_LIBS(thr_create, [thread],
419 AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads])
421 ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"],
422 [CFLAGS="$CFLAGS -D_REENTRANT"])
423 ub_have_sol_threads=yes
425 AC_ERROR([no solaris threads found.])
430 fi # end of non-mingw check of thread libraries
432 # Check for PyUnbound
433 AC_ARG_WITH(pyunbound,
434 AC_HELP_STRING([--with-pyunbound],
435 [build PyUnbound, or --without-pyunbound to skip it. (default=no)]),
436 [], [ withval="no" ])
440 if test x_$withval != x_no; then
441 ub_with_pyunbound=yes
445 # Check for Python module
446 AC_ARG_WITH(pythonmodule,
447 AC_HELP_STRING([--with-pythonmodule],
448 [build Python module, or --without-pythonmodule to disable script engine. (default=no)]),
449 [], [ withval="no" ])
452 if test x_$withval != x_no; then
453 ub_with_pythonmod=yes
457 # Check for Python & SWIG only on PyUnbound or PyModule
458 if test x_$ub_test_python != x_no; then
462 ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
464 if test ! -z "$PYTHON_VERSION"; then
465 if test `$PYTHON -c "print '$PYTHON_VERSION' >= '2.4.0'"` = "False"; then
466 AC_ERROR([Python version >= 2.4.0 is required])
470 AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
471 LIBS="$PYTHON_LDFLAGS $LIBS"
472 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
478 AC_MSG_CHECKING(SWIG)
479 if test ! -x "$SWIG"; then
480 AC_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound])
482 AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.])
483 AC_SUBST(swig, "$SWIG")
484 AC_MSG_RESULT(present)
486 # If have Python & SWIG
488 if test x_$ub_with_pythonmod != x_no; then
489 AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.])
490 WITH_PYTHONMODULE=yes
491 AC_SUBST(WITH_PYTHONMODULE)
492 PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo"
493 AC_SUBST(PYTHONMOD_OBJ)
494 PYTHONMOD_HEADER='$(srcdir)/pythonmod/pythonmod.h'
495 AC_SUBST(PYTHONMOD_HEADER)
496 PYTHONMOD_INSTALL=pythonmod-install
497 AC_SUBST(PYTHONMOD_INSTALL)
498 PYTHONMOD_UNINSTALL=pythonmod-uninstall
499 AC_SUBST(PYTHONMOD_UNINSTALL)
503 if test x_$ub_with_pyunbound != x_no; then
504 AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.])
506 AC_SUBST(WITH_PYUNBOUND)
507 PYUNBOUND_OBJ="libunbound_wrap.lo"
508 AC_SUBST(PYUNBOUND_OBJ)
509 PYUNBOUND_TARGET="_unbound.la"
510 AC_SUBST(PYUNBOUND_TARGET)
511 PYUNBOUND_INSTALL=pyunbound-install
512 AC_SUBST(PYUNBOUND_INSTALL)
513 PYUNBOUND_UNINSTALL=pyunbound-uninstall
514 AC_SUBST(PYUNBOUND_UNINSTALL)
518 AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***])
524 if test "`uname`" = "NetBSD"; then
525 NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_'
526 AC_SUBST(NETBSD_LINTFLAGS)
528 CONFIG_DATE=`date +%Y%m%d`
529 AC_SUBST(CONFIG_DATE)
531 # Checks for libraries.
535 AC_ARG_WITH([nss], AC_HELP_STRING([--with-nss=path],
536 [use libnss instead of openssl, installed at path.]),
539 AC_DEFINE(HAVE_NSS, 1, [Use libnss for crypto])
540 if test "$withval" != "" -a "$withval" != "yes"; then
541 CPPFLAGS="$CPPFLAGS -I$withval/include/nss3"
542 LDFLAGS="$LDFLAGS -L$withval/lib"
543 ACX_RUNTIME_PATH_ADD([$withval/lib])
544 CPPFLAGS="-I$withval/include/nspr4 $CPPFLAGS"
546 CPPFLAGS="$CPPFLAGS -I/usr/include/nss3"
547 CPPFLAGS="-I/usr/include/nspr4 $CPPFLAGS"
549 LIBS="$LIBS -lnss3 -lnspr4"
554 if test $USE_NSS = "no"; then
557 AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT])
558 AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT])
559 AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512 FIPS_mode])
560 AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free], [], [], [
562 #ifdef HAVE_OPENSSL_ERR_H
563 #include <openssl/err.h>
566 #ifdef HAVE_OPENSSL_RAND_H
567 #include <openssl/rand.h>
570 #ifdef HAVE_OPENSSL_CONF_H
571 #include <openssl/conf.h>
574 #ifdef HAVE_OPENSSL_ENGINE_H
575 #include <openssl/engine.h>
577 #include <openssl/ssl.h>
578 #include <openssl/evp.h>
583 AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
584 case "$enable_sha2" in
588 AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
592 # check wether gost also works
593 AC_DEFUN([AC_CHECK_GOST_WORKS],
594 [AC_REQUIRE([AC_PROG_CC])
595 AC_MSG_CHECKING([if GOST works])
596 if test c${cross_compiling} = cno; then
598 if test -n "$ssldir"; then
599 CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib"
601 AC_RUN_IFELSE([AC_LANG_SOURCE([[
603 #include <openssl/ssl.h>
604 #include <openssl/evp.h>
605 #include <openssl/engine.h>
606 #include <openssl/conf.h>
607 /* routine to load gost (from sldns) */
608 int load_gost_id(void)
610 static int gost_id = 0;
611 const EVP_PKEY_ASN1_METHOD* meth;
614 if(gost_id) return gost_id;
616 /* see if configuration loaded gost implementation from other engine*/
617 meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
619 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
623 /* see if engine can be loaded already */
624 e = ENGINE_by_id("gost");
626 /* load it ourself, in case statically linked */
627 ENGINE_load_builtin_engines();
628 ENGINE_load_dynamic();
629 e = ENGINE_by_id("gost");
632 /* no gost engine in openssl */
635 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
641 meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
648 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
654 unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */
655 const char* str = "Hello world";
656 const unsigned char check[] = {
657 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 ,
658 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 ,
659 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d ,
660 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d
662 OPENSSL_config(NULL);
663 (void)load_gost_id();
664 md = EVP_get_digestbyname("md_gost94");
666 memset(digest, 0, sizeof(digest));
667 ctx = EVP_MD_CTX_create();
669 if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3;
670 if(!EVP_DigestUpdate(ctx, str, 10)) return 4;
671 if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5;
672 /* uncomment to see the hash calculated.
675 printf(" %2.2x", (int)digest[i]);
678 if(memcmp(digest, check, sizeof(check)) != 0)
682 ]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"])
685 eval "ac_cv_c_gost_works=maybe"
687 AC_MSG_RESULT($ac_cv_c_gost_works)
690 AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
692 if test $USE_NSS = "no"; then
693 case "$enable_gost" in
697 AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])])
698 AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])])
700 if test "$ac_cv_c_gost_works" != no; then
702 AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
708 AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
710 case "$enable_ecdsa" in
714 if test $USE_NSS = "no"; then
715 AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])])
716 AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])])
717 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
718 #include <openssl/evp.h>
720 # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency)
721 AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP])
722 if grep OPENSSL_VERSION_NUMBER $ssldir/include/openssl/opensslv.h | grep 0x0 >/dev/null; then
724 AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl])
729 # we now know we have ECDSA and the required curves.
730 AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
735 AC_ARG_ENABLE(event-api, AC_HELP_STRING([--enable-event-api], [Enable (experimental) libevent-based libunbound API installed to unbound-event.h]))
736 use_unbound_event="no"
737 case "$enable_event_api" in
739 use_unbound_event="yes"
746 AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname],
747 [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.]),
748 [ ],[ withval="no" ])
749 if test x_$withval = x_yes -o x_$withval != x_no; then
750 AC_MSG_CHECKING(for libevent)
751 if test x_$withval = x_ -o x_$withval = x_yes; then
752 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
754 for dir in $withval; do
756 if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then
758 dnl assume /usr is in default path.
759 if test "$thedir" != "/usr"; then
760 CPPFLAGS="$CPPFLAGS -I$thedir/include"
765 if test x_$found_libevent != x_yes; then
766 if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
767 # libevent source directory
768 AC_MSG_RESULT(found in $thedir)
769 CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include"
771 BAK_LDFLAGS="$LDFLAGS"
772 # remove evdns from linking
773 mkdir build >/dev/null 2>&1
774 mkdir build/libevent >/dev/null 2>&1
775 mkdir build/libevent/.libs >/dev/null 2>&1
776 ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
777 ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo`
778 ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
779 cp $ev_files_o build/libevent
780 cp $ev_files_lo build/libevent
781 cp $ev_files_libso build/libevent/.libs
782 LATE_LDFLAGS="build/libevent/*.lo -lm"
783 LDFLAGS="build/libevent/*.o $LDFLAGS -lm"
785 AC_MSG_ERROR([Cannot find the libevent library in $withval
786 You can restart ./configure --with-libevent=no to use a builtin alternative.
787 Please note that this alternative is not as capable as libevent when using
788 large outgoing port ranges. ])
791 AC_MSG_RESULT(found in $thedir)
792 dnl if event2 exists and no event lib in dir itself, use subdir
793 if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then
794 LDFLAGS="$LDFLAGS -L$thedir/lib/event2"
795 ACX_RUNTIME_PATH_ADD([$thedir/lib/event2])
797 dnl assume /usr is in default path, do not add "".
798 if test "$thedir" != "/usr" -a "$thedir" != ""; then
799 LDFLAGS="$LDFLAGS -L$thedir/lib"
800 ACX_RUNTIME_PATH_ADD([$thedir/lib])
804 # check for library used by libevent after 1.3c
805 AC_SEARCH_LIBS([clock_gettime], [rt])
807 # is the event.h header libev or libevent?
808 AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT])
809 AC_CHECK_DECL(EV_VERSION_MAJOR, [
810 AC_SEARCH_LIBS(event_set, [ev])
812 AC_SEARCH_LIBS(event_set, [event])
813 ],[AC_INCLUDES_DEFAULT
816 AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later
817 AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later
818 AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later
819 AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later
820 AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51)
821 AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00)
822 if test -n "$BAK_LDFLAGS_SET"; then
823 LDFLAGS="$BAK_LDFLAGS"
825 if test "$use_unbound_event" = "yes"; then
826 AC_SUBST(UNBOUND_EVENT_INSTALL, [unbound-event-install])
827 AC_SUBST(UNBOUND_EVENT_UNINSTALL, [unbound-event-uninstall])
830 AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
834 AC_ARG_WITH(libexpat, AC_HELP_STRING([--with-libexpat=path],
835 [specify explicit path for libexpat.]),
836 [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ])
837 AC_MSG_CHECKING(for libexpat)
839 for dir in $withval ; do
840 if test -f "$dir/include/expat.h"; then
842 dnl assume /usr is in default path.
843 if test "$dir" != "/usr"; then
844 CPPFLAGS="$CPPFLAGS -I$dir/include"
845 LDFLAGS="$LDFLAGS -L$dir/lib"
847 AC_MSG_RESULT(found in $dir)
851 if test x_$found_libexpat != x_yes; then
852 AC_ERROR([Could not find libexpat, expat.h])
854 AC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT])
856 # set static linking if requested
859 AC_ARG_ENABLE(static-exe, AC_HELP_STRING([--enable-static-exe],
860 [ enable to compile executables statically against (event) libs, for debug purposes ]),
862 if test x_$enable_static_exe = x_yes; then
864 if test "$on_mingw" = yes; then
865 staticexe="-all-static"
866 # for static crosscompile, include gdi32 and zlib here.
867 if test "`uname`" = "Linux"; then
868 LIBS="$LIBS -lgdi32 -lz"
873 # set lock checking if requested
874 AC_ARG_ENABLE(lock_checks, AC_HELP_STRING([--enable-lock-checks],
875 [ enable to check lock and unlock calls, for debug purposes ]),
877 if test x_$enable_lock_checks = x_yes; then
878 AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).])
879 CHECKLOCK_OBJ="checklocks.lo"
880 AC_SUBST(CHECKLOCK_OBJ)
883 ACX_CHECK_GETADDRINFO_WITH_INCLUDES
884 if test "$USE_WINSOCK" = 1; then
885 AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API])
886 AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT
889 AC_CHECK_TOOL(WINDRES, windres)
890 LIBS="$LIBS -liphlpapi"
891 WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe"
893 WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c"
894 AC_SUBST(WIN_DAEMON_SRC)
895 WIN_DAEMON_OBJ="win_svc.lo w_inst.lo"
896 AC_SUBST(WIN_DAEMON_OBJ)
897 WIN_DAEMON_OBJ_LINK="rsrc_unbound.o"
898 AC_SUBST(WIN_DAEMON_OBJ_LINK)
899 WIN_HOST_OBJ_LINK="rsrc_unbound_host.o"
900 AC_SUBST(WIN_HOST_OBJ_LINK)
901 WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo"
902 AC_SUBST(WIN_UBANCHOR_OBJ_LINK)
903 WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o"
904 AC_SUBST(WIN_CONTROL_OBJ_LINK)
905 WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o"
906 AC_SUBST(WIN_CHECKCONF_OBJ_LINK)
908 if test $ac_cv_func_getaddrinfo = no; then
909 AC_LIBOBJ([fake-rfc2553])
911 # check after getaddrinfo for its libraries
914 # see if daemon(3) exists, and if it is deprecated.
915 AC_CHECK_FUNCS([daemon])
916 if test $ac_cv_func_daemon = yes; then
917 ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [
922 AC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[
925 #include <sys/param.h>
928 #ifdef HAVE_SYS_SOCKET_H
929 #include <sys/socket.h>
932 #ifdef HAVE_SYS_UIO_H
936 #ifdef HAVE_NETINET_IN_H
937 #include <netinet/in.h>
940 #ifdef HAVE_ARPA_INET_H
941 #include <arpa/inet.h>
944 #ifdef HAVE_WINSOCK2_H
945 #include <winsock2.h>
948 #ifdef HAVE_WS2TCPIP_H
949 #include <ws2tcpip.h>
952 AC_SEARCH_LIBS([setusercontext], [util])
953 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 endservent endprotoent])
954 AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
955 AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
957 # check if setreuid en setregid fail, on MacOSX10.4(darwin8).
958 if echo $build_os | grep darwin8 > /dev/null; then
959 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
961 AC_REPLACE_FUNCS(inet_aton)
962 AC_REPLACE_FUNCS(inet_pton)
963 AC_REPLACE_FUNCS(inet_ntop)
964 AC_REPLACE_FUNCS(snprintf)
965 AC_REPLACE_FUNCS(strlcat)
966 AC_REPLACE_FUNCS(strlcpy)
967 AC_REPLACE_FUNCS(memmove)
968 AC_REPLACE_FUNCS(gmtime_r)
969 LIBOBJ_WITHOUT_CTIME="$LIBOBJS"
970 AC_SUBST(LIBOBJ_WITHOUT_CTIME)
971 AC_REPLACE_FUNCS(ctime_r)
973 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]))
974 case "$enable_allsymbols" in
976 COMMON_OBJ_ALL_SYMBOLS=""
978 EXTRALINK="-L. -L.libs -lunbound"
979 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])
982 COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)'
983 UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def'
987 AC_SUBST(COMMON_OBJ_ALL_SYMBOLS)
990 if test x_$enable_lock_checks = x_yes; then
991 UBSYMS="-export-symbols clubsyms.def"
992 cp ${srcdir}/libunbound/ubsyms.def clubsyms.def
993 echo lock_protect >> clubsyms.def
994 echo lock_unprotect >> clubsyms.def
995 echo lock_get_mem >> clubsyms.def
996 echo checklock_start >> clubsyms.def
997 echo checklock_stop >> clubsyms.def
998 echo checklock_lock >> clubsyms.def
999 echo checklock_unlock >> clubsyms.def
1000 echo checklock_init >> clubsyms.def
1001 echo checklock_thrcreate >> clubsyms.def
1002 echo checklock_thrjoin >> clubsyms.def
1005 AC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope])
1006 # on openBSD, the implicit rule make $< work.
1007 # on Solaris, it does not work ($? is changed sources, $^ lists dependencies).
1009 cat >conftest.make <<EOF
1012 conftest.lo foo.lo bla.lo:
1013 if test -f "\$<"; then touch \$@; fi
1017 if test -f "\$<"; then touch \$@; fi
1019 conftest.lo: conftest.dir/conftest.c
1022 touch conftest.dir/conftest.c
1023 rm -f conftest.lo conftest.c
1024 ${MAKE:-make} -f conftest.make >/dev/null
1025 rm -f conftest.make conftest.c conftest.dir/conftest.c
1027 if test ! -f conftest.lo; then
1029 SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source'
1030 SOURCEFILE='`cat .source`'
1037 AC_SUBST(SOURCEDETERMINE)
1038 AC_SUBST(SOURCEFILE)
1040 # see if we want to build the library or everything
1041 ALLTARGET="alltargets"
1042 INSTALLTARGET="install-all"
1043 AC_ARG_WITH(libunbound-only, AC_HELP_STRING([--with-libunbound-only],
1044 [do not build daemon and tool programs]),
1046 if test "$withval" = "yes"; then
1048 INSTALLTARGET="install-lib"
1052 AC_SUBST(INSTALLTARGET)
1055 LDFLAGS="$LATE_LDFLAGS $LDFLAGS"
1057 AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.])
1060 dnl this must be first AH_CONFIG, to define the flags before any includes.
1061 AHX_CONFIG_EXT_FLAGS
1065 #ifndef UNBOUND_DEBUG
1069 /** Use small-ldns codebase */
1072 # define LDNS_BUILD_CONFIG_HAVE_SSL 1
1085 #ifdef HAVE_STDARG_H
1089 #ifdef HAVE_STDINT_H
1095 #if HAVE_SYS_PARAM_H
1096 #include <sys/param.h>
1099 #ifdef HAVE_SYS_SOCKET_H
1100 #include <sys/socket.h>
1103 #ifdef HAVE_SYS_UIO_H
1104 #include <sys/uio.h>
1107 #ifdef HAVE_NETINET_IN_H
1108 #include <netinet/in.h>
1111 #ifdef HAVE_ARPA_INET_H
1112 #include <arpa/inet.h>
1115 #ifdef HAVE_WINSOCK2_H
1116 #include <winsock2.h>
1119 #ifdef HAVE_WS2TCPIP_H
1120 #include <ws2tcpip.h>
1124 #define ARG_LL "%ll"
1126 #define ARG_LL "%I64"
1130 AHX_CONFIG_FORMAT_ATTRIBUTE
1131 AHX_CONFIG_UNUSED_ATTRIBUTE
1133 AHX_CONFIG_MAXHOSTNAMELEN
1134 AHX_CONFIG_SNPRINTF(unbound)
1135 AHX_CONFIG_INET_PTON(unbound)
1136 AHX_CONFIG_INET_NTOP(unbound)
1137 AHX_CONFIG_INET_ATON(unbound)
1138 AHX_CONFIG_MEMMOVE(unbound)
1139 AHX_CONFIG_STRLCAT(unbound)
1140 AHX_CONFIG_STRLCPY(unbound)
1141 AHX_CONFIG_GMTIME_R(unbound)
1142 AHX_CONFIG_W32_SLEEP
1143 AHX_CONFIG_W32_USLEEP
1144 AHX_CONFIG_W32_RANDOM
1145 AHX_CONFIG_W32_SRANDOM
1146 AHX_CONFIG_W32_FD_SET_T
1147 AHX_CONFIG_IPV6_MIN_MTU
1148 AHX_MEMCMP_BROKEN(unbound)
1151 #ifndef HAVE_CTIME_R
1152 #define ctime_r unbound_ctime_r
1153 char *ctime_r(const time_t *timep, char *buf);
1156 #if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
1157 #define strptime unbound_strptime
1159 char *strptime(const char *s, const char *format, struct tm *tm);
1162 #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))
1163 /* using version of libevent that is not threadsafe. */
1164 # define LIBEVENT_SIGNAL_PROBLEM 1
1167 #ifndef CHECKED_INET6
1168 # define CHECKED_INET6
1172 # define AF_INET6 28
1174 #endif /* CHECKED_INET6 */
1176 #ifndef HAVE_GETADDRINFO
1177 struct sockaddr_storage;
1178 #include "compat/fake-rfc2553.h"
1181 #ifdef UNBOUND_ALLOC_STATS
1182 # define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__)
1183 # define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__)
1184 # define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__)
1185 # define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__)
1186 void *unbound_stat_malloc(size_t size);
1187 void *unbound_stat_calloc(size_t nmemb, size_t size);
1188 void unbound_stat_free(void *ptr);
1189 void *unbound_stat_realloc(void *ptr, size_t size);
1190 void *unbound_stat_malloc_log(size_t size, const char* file, int line,
1192 void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file,
1193 int line, const char* func);
1194 void unbound_stat_free_log(void *ptr, const char* file, int line,
1196 void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file,
1197 int line, const char* func);
1198 #elif defined(UNBOUND_ALLOC_LITE)
1199 # include "util/alloc.h"
1200 #endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */
1202 /** default port for DNS traffic. */
1203 #define UNBOUND_DNS_PORT 53
1204 /** default port for unbound control traffic, registered port with IANA,
1205 ub-dns-control 8953/tcp unbound dns nameserver control */
1206 #define UNBOUND_CONTROL_PORT 8953
1207 /** the version of unbound-control that this software implements */
1208 #define UNBOUND_CONTROL_VERSION 1
1212 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 smallapp/unbound-control-setup.sh])
1213 AC_CONFIG_HEADER([config.h])