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)
76 dnl By default set prefix to /usr/local
85 if uname -s 2>&1 | grep MINGW32 >/dev/null; then on_mingw="yes"
87 if echo $target | grep mingw32 >/dev/null; then on_mingw="yes"
88 else on_mingw="no"; fi
92 # Determine configuration file
93 # the eval is to evaluate shell expansion twice
94 if test $on_mingw = "no"; then
95 ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"`
97 ub_conf_file="C:\\Program Files\\Unbound\\service.conf"
99 AC_ARG_WITH([conf_file],
100 AC_HELP_STRING([--with-conf-file=path],
101 [Pathname to the Unbound configuration file]),
102 [ub_conf_file="$withval"])
103 AC_SUBST(ub_conf_file)
104 ACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config)
105 AC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file])
107 # Determine run, chroot directory and pidfile locations
109 AC_HELP_STRING([--with-run-dir=path],
110 [set default directory to chdir to (by default dir part of cfg file)]),
111 UNBOUND_RUN_DIR="$withval",
112 if test $on_mingw = no; then
113 UNBOUND_RUN_DIR=`dirname "$ub_conf_file"`
118 AC_SUBST(UNBOUND_RUN_DIR)
119 ACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run)
120 AC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to])
122 AC_ARG_WITH(chroot-dir,
123 AC_HELP_STRING([--with-chroot-dir=path],
124 [set default directory to chroot to (by default same as run-dir)]),
125 UNBOUND_CHROOT_DIR="$withval",
126 if test $on_mingw = no; then
127 UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR"
129 UNBOUND_CHROOT_DIR=""
132 AC_SUBST(UNBOUND_CHROOT_DIR)
133 ACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot)
134 AC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to])
136 AC_ARG_WITH(share-dir,
137 AC_HELP_STRING([--with-share-dir=path],
138 [set default directory with shared data (by default same as share/unbound)]),
139 UNBOUND_SHARE_DIR="$withval",
140 UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR")
141 AC_SUBST(UNBOUND_SHARE_DIR)
142 AC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data])
145 AC_HELP_STRING([--with-pidfile=filename],
146 [set default pathname to unbound pidfile (default run-dir/unbound.pid)]),
147 UNBOUND_PIDFILE="$withval",
148 if test $on_mingw = no; then
149 UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid"
154 AC_SUBST(UNBOUND_PIDFILE)
155 ACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid)
156 AC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location])
158 AC_ARG_WITH(rootkey-file,
159 AC_HELP_STRING([--with-rootkey-file=filename],
160 [set default pathname to root key file (default run-dir/root.key). This file is read and written.]),
161 UNBOUND_ROOTKEY_FILE="$withval",
162 if test $on_mingw = no; then
163 UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key"
165 UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key"
168 AC_SUBST(UNBOUND_ROOTKEY_FILE)
169 ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey)
170 AC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location])
172 AC_ARG_WITH(rootcert-file,
173 AC_HELP_STRING([--with-rootcert-file=filename],
174 [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.]),
175 UNBOUND_ROOTCERT_FILE="$withval",
176 if test $on_mingw = no; then
177 UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem"
179 UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem"
182 AC_SUBST(UNBOUND_ROOTCERT_FILE)
183 ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem)
184 AC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location])
186 AC_ARG_WITH(username,
187 AC_HELP_STRING([--with-username=user],
188 [set default user that unbound changes to (default user is unbound)]),
189 UNBOUND_USERNAME="$withval",
190 UNBOUND_USERNAME="unbound")
191 AC_SUBST(UNBOUND_USERNAME)
192 AC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username])
194 AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
195 ACX_RSRC_VERSION(wnvs)
196 AC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files])
198 # Checks for typedefs, structures, and compiler characteristics.
201 # allow user to override the -g -O2 flags.
202 if test "x$CFLAGS" = "x" ; then
203 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"])
204 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"])
208 ACX_DETERMINE_EXT_FLAGS_UNBOUND
210 # debug mode flags warnings
211 AC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable warnings, asserts, makefile-dependencies]))
212 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [same as enable-checking]))
213 if test "$enable_debug" = "yes"; then debug_enabled="$enable_debug";
214 else debug_enabled="$enable_checking"; fi
215 AC_SUBST(debug_enabled)
216 case "$debug_enabled" in
218 ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"])
219 ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"])
220 ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"])
221 ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
222 AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.])
231 ACX_CHECK_FORMAT_ATTRIBUTE
232 ACX_CHECK_UNUSED_ATTRIBUTE
234 if test "$srcdir" != "."; then
235 CPPFLAGS="$CPPFLAGS -I$srcdir"
238 AC_DEFUN([ACX_YYLEX_DESTROY], [
239 AC_MSG_CHECKING([for yylex_destroy])
240 if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then
241 AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy])
243 else AC_MSG_RESULT(no); fi
249 AC_CHECK_PROG(doxygen, doxygen, doxygen)
250 AC_CHECK_TOOL(STRIP, strip)
253 # Checks for header files.
254 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])
257 # Using own tests for int64* because autoconf builtin only give 32bit.
258 AC_CHECK_TYPE(int8_t, signed char)
259 AC_CHECK_TYPE(int16_t, short)
260 AC_CHECK_TYPE(int32_t, int)
261 AC_CHECK_TYPE(int64_t, long long)
262 AC_CHECK_TYPE(uint8_t, unsigned char)
263 AC_CHECK_TYPE(uint16_t, unsigned short)
264 AC_CHECK_TYPE(uint32_t, unsigned int)
265 AC_CHECK_TYPE(uint64_t, unsigned long long)
267 AC_CHECK_TYPE(ssize_t, int)
276 ACX_CHECK_MEMCMP_SIGNED
278 # add option to disable the evil rpath
280 AC_SUBST(RUNTIME_PATH)
282 # check to see if libraries are needed for these functions.
283 AC_SEARCH_LIBS([inet_pton], [nsl])
284 AC_SEARCH_LIBS([socket], [socket])
286 # check wether strptime also works
287 AC_DEFUN([AC_CHECK_STRPTIME_WORKS],
288 [AC_REQUIRE([AC_PROG_CC])
289 AC_MSG_CHECKING(whether strptime works)
290 if test c${cross_compiling} = cno; then
291 AC_RUN_IFELSE([AC_LANG_SOURCE([[
292 #define _XOPEN_SOURCE
294 int main(void) { struct tm tm; char *res;
295 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);
297 res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
298 if (!res) return 1; return 0; }
299 ]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"])
301 eval "ac_cv_c_strptime_works=maybe"
303 AC_MSG_RESULT($ac_cv_c_strptime_works)
304 if test $ac_cv_c_strptime_works = no; then
307 AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.])
311 # check some functions of the OS before linking libs (while still runnable).
317 ACX_CHECK_NONBLOCKING_BROKEN
319 AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])])
321 # set memory allocation checking if requested
322 AC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks],
323 [ enable to memory allocation statistics, for debug purposes ]),
325 AC_ARG_ENABLE(alloc-lite, AC_HELP_STRING([--enable-alloc-lite],
326 [ enable for lightweight alloc assertions, for debug purposes ]),
328 AC_ARG_ENABLE(alloc-nonregional, AC_HELP_STRING([--enable-alloc-nonregional],
329 [ enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes ]),
331 if test x_$enable_alloc_nonregional = x_yes; then
332 AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use])
334 if test x_$enable_alloc_checks = x_yes; then
335 AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use])
337 if test x_$enable_alloc_lite = x_yes; then
338 AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use])
340 ACX_FUNC_MALLOC([unbound])
344 # check windows threads (we use them, not pthreads, on windows).
345 if test "$on_mingw" = "yes"; then
346 # check windows threads
347 AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT])
348 AC_MSG_CHECKING([for CreateThread])
349 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
350 #ifdef HAVE_WINDOWS_H
354 HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL);
357 AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads])
363 # not on mingw, check thread libraries.
365 # check for thread library.
366 # check this first, so that the pthread lib does not get linked in via
367 # libssl or libpython, and thus distorts the tests, and we end up using
368 # the non-threadsafe C libraries.
369 AC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads],
370 [use pthreads library, or --without-pthreads to disable threading support.]),
371 [ ],[ withval="yes" ])
373 if test x_$withval != x_no; then
375 AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
376 LIBS="$PTHREAD_LIBS $LIBS"
377 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
380 AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>])
384 # check solaris thread library
385 AC_ARG_WITH(solaris-threads, AC_HELP_STRING([--with-solaris-threads],
386 [use solaris native thread library.]), [ ],[ withval="no" ])
387 ub_have_sol_threads=no
388 if test x_$withval != x_no; then
389 if test x_$ub_have_pthreads != x_no; then
390 AC_WARN([Have pthreads already, ignoring --with-solaris-threads])
392 AC_SEARCH_LIBS(thr_create, [thread],
394 AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads])
396 ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"],
397 [CFLAGS="$CFLAGS -D_REENTRANT"])
398 ub_have_sol_threads=yes
400 AC_ERROR([no solaris threads found.])
405 fi # end of non-mingw check of thread libraries
407 # Check for PyUnbound
408 AC_ARG_WITH(pyunbound,
409 AC_HELP_STRING([--with-pyunbound],
410 [build PyUnbound, or --without-pyunbound to skip it. (default=no)]),
411 [], [ withval="no" ])
415 if test x_$withval != x_no; then
416 ub_with_pyunbound=yes
420 # Check for Python module
421 AC_ARG_WITH(pythonmodule,
422 AC_HELP_STRING([--with-pythonmodule],
423 [build Python module, or --without-pythonmodule to disable script engine. (default=no)]),
424 [], [ withval="no" ])
427 if test x_$withval != x_no; then
428 ub_with_pythonmod=yes
432 # Check for Python & SWIG only on PyUnbound or PyModule
433 if test x_$ub_test_python != x_no; then
437 ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
439 if test ! -z "$PYTHON_VERSION"; then
440 if test `$PYTHON -c "print '$PYTHON_VERSION' >= '2.4.0'"` = "False"; then
441 AC_ERROR([Python version >= 2.4.0 is required])
445 AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
446 LIBS="$PYTHON_LDFLAGS $LIBS"
447 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
453 AC_MSG_CHECKING(SWIG)
454 if test ! -x "$SWIG"; then
455 AC_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound])
457 AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.])
458 AC_SUBST(swig, "$SWIG")
459 AC_MSG_RESULT(present)
461 # If have Python & SWIG
463 if test x_$ub_with_pythonmod != x_no; then
464 AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.])
465 WITH_PYTHONMODULE=yes
466 AC_SUBST(WITH_PYTHONMODULE)
467 PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo"
468 AC_SUBST(PYTHONMOD_OBJ)
469 PYTHONMOD_HEADER='$(srcdir)/pythonmod/pythonmod.h'
470 AC_SUBST(PYTHONMOD_HEADER)
471 PYTHONMOD_INSTALL=pythonmod-install
472 AC_SUBST(PYTHONMOD_INSTALL)
473 PYTHONMOD_UNINSTALL=pythonmod-uninstall
474 AC_SUBST(PYTHONMOD_UNINSTALL)
478 if test x_$ub_with_pyunbound != x_no; then
479 AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.])
481 AC_SUBST(WITH_PYUNBOUND)
482 PYUNBOUND_OBJ="libunbound_wrap.lo"
483 AC_SUBST(PYUNBOUND_OBJ)
484 PYUNBOUND_TARGET="_unbound.la"
485 AC_SUBST(PYUNBOUND_TARGET)
486 PYUNBOUND_INSTALL=pyunbound-install
487 AC_SUBST(PYUNBOUND_INSTALL)
488 PYUNBOUND_UNINSTALL=pyunbound-uninstall
489 AC_SUBST(PYUNBOUND_UNINSTALL)
493 AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***])
499 if test "`uname`" = "NetBSD"; then
500 NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_'
501 AC_SUBST(NETBSD_LINTFLAGS)
503 CONFIG_DATE=`date +%Y%m%d`
504 AC_SUBST(CONFIG_DATE)
506 # Checks for libraries.
510 AC_ARG_WITH([nss], AC_HELP_STRING([--with-nss=path],
511 [use libnss instead of openssl, installed at path.]),
514 AC_DEFINE(HAVE_NSS, 1, [Use libnss for crypto])
515 if test "$withval" != "" -a "$withval" != "yes"; then
516 CPPFLAGS="$CPPFLAGS -I$withval/include/nss3"
517 LDFLAGS="$LDFLAGS -L$withval/lib"
518 ACX_RUNTIME_PATH_ADD([$withval/lib])
519 CPPFLAGS="-I$withval/include/nspr4 $CPPFLAGS"
521 CPPFLAGS="$CPPFLAGS -I/usr/include/nss3"
522 CPPFLAGS="-I/usr/include/nspr4 $CPPFLAGS"
524 LIBS="$LIBS -lnss3 -lnspr4"
529 if test $USE_NSS = "no"; then
532 AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT])
533 AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT])
534 AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512 FIPS_mode])
535 AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free], [], [], [
537 #ifdef HAVE_OPENSSL_ERR_H
538 #include <openssl/err.h>
541 #ifdef HAVE_OPENSSL_RAND_H
542 #include <openssl/rand.h>
545 #ifdef HAVE_OPENSSL_CONF_H
546 #include <openssl/conf.h>
549 #ifdef HAVE_OPENSSL_ENGINE_H
550 #include <openssl/engine.h>
552 #include <openssl/ssl.h>
553 #include <openssl/evp.h>
558 AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
559 case "$enable_sha2" in
563 AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
567 # check wether gost also works
568 AC_DEFUN([AC_CHECK_GOST_WORKS],
569 [AC_REQUIRE([AC_PROG_CC])
570 AC_MSG_CHECKING([if GOST works])
571 if test c${cross_compiling} = cno; then
573 if test -n "$ssldir"; then
574 CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib"
576 AC_RUN_IFELSE([AC_LANG_SOURCE([[
578 #include <openssl/ssl.h>
579 #include <openssl/evp.h>
580 #include <openssl/engine.h>
581 #include <openssl/conf.h>
582 /* routine to load gost from ldns */
583 int load_gost_id(void)
585 static int gost_id = 0;
586 const EVP_PKEY_ASN1_METHOD* meth;
589 if(gost_id) return gost_id;
591 /* see if configuration loaded gost implementation from other engine*/
592 meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
594 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
598 /* see if engine can be loaded already */
599 e = ENGINE_by_id("gost");
601 /* load it ourself, in case statically linked */
602 ENGINE_load_builtin_engines();
603 ENGINE_load_dynamic();
604 e = ENGINE_by_id("gost");
607 /* no gost engine in openssl */
610 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
616 meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
623 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
629 unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */
630 const char* str = "Hello world";
631 const unsigned char check[] = {
632 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 ,
633 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 ,
634 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d ,
635 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d
637 OPENSSL_config(NULL);
638 (void)load_gost_id();
639 md = EVP_get_digestbyname("md_gost94");
641 memset(digest, 0, sizeof(digest));
642 ctx = EVP_MD_CTX_create();
644 if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3;
645 if(!EVP_DigestUpdate(ctx, str, 10)) return 4;
646 if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5;
647 /* uncomment to see the hash calculated.
650 printf(" %2.2x", (int)digest[i]);
653 if(memcmp(digest, check, sizeof(check)) != 0)
657 ]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"])
660 eval "ac_cv_c_gost_works=maybe"
662 AC_MSG_RESULT($ac_cv_c_gost_works)
665 AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
667 if test $USE_NSS = "no"; then
668 case "$enable_gost" in
672 AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])])
673 AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])])
675 if test "$ac_cv_c_gost_works" != no; then
677 AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
683 AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
685 case "$enable_ecdsa" in
689 if test $USE_NSS = "no"; then
690 AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])])
691 AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])])
692 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
693 #include <openssl/evp.h>
695 # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency)
696 AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP])
697 if grep OPENSSL_VERSION_NUMBER $ssldir/include/openssl/opensslv.h | grep 0x0 >/dev/null; then
699 AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl])
704 # we now know we have ECDSA and the required curves.
705 AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
711 AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname],
712 [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.]),
713 [ ],[ withval="no" ])
714 if test x_$withval = x_yes -o x_$withval != x_no; then
715 AC_MSG_CHECKING(for libevent)
716 if test x_$withval = x_ -o x_$withval = x_yes; then
717 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
719 for dir in $withval; do
721 if test -f "$dir/include/event.h"; then
723 dnl assume /usr is in default path.
724 if test "$thedir" != "/usr"; then
725 CPPFLAGS="$CPPFLAGS -I$thedir/include"
730 if test x_$found_libevent != x_yes; then
731 if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
732 # libevent source directory
733 AC_MSG_RESULT(found in $thedir)
734 CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include"
736 BAK_LDFLAGS="$LDFLAGS"
737 # remove evdns from linking
738 mkdir build >/dev/null 2>&1
739 mkdir build/libevent >/dev/null 2>&1
740 mkdir build/libevent/.libs >/dev/null 2>&1
741 ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
742 ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo`
743 ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
744 cp $ev_files_o build/libevent
745 cp $ev_files_lo build/libevent
746 cp $ev_files_libso build/libevent/.libs
747 LATE_LDFLAGS="build/libevent/*.lo -lm"
748 LDFLAGS="build/libevent/*.o $LDFLAGS -lm"
750 AC_MSG_ERROR([Cannot find the libevent library in $withval
751 You can restart ./configure --with-libevent=no to use a builtin alternative.
752 Please note that this alternative is not as capable as libevent when using
753 large outgoing port ranges. ])
756 AC_MSG_RESULT(found in $thedir)
757 dnl assume /usr is in default path, do not add "".
758 if test "$thedir" != "/usr" -a "$thedir" != ""; then
759 LDFLAGS="$LDFLAGS -L$thedir/lib"
760 ACX_RUNTIME_PATH_ADD([$thedir/lib])
763 # check for library used by libevent after 1.3c
764 AC_SEARCH_LIBS([clock_gettime], [rt])
766 # is the event.h header libev or libevent?
767 AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT])
768 AC_CHECK_DECL(EV_VERSION_MAJOR, [
769 AC_SEARCH_LIBS(event_set, [ev])
771 AC_SEARCH_LIBS(event_set, [event])
772 ],[AC_INCLUDES_DEFAULT
775 AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later
776 AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later
777 AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later
778 AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later
779 AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51)
780 AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00)
781 if test -n "$BAK_LDFLAGS_SET"; then
782 LDFLAGS="$BAK_LDFLAGS"
785 AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
789 AC_ARG_WITH(libexpat, AC_HELP_STRING([--with-libexpat=path],
790 [specify explicit path for libexpat.]),
791 [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ])
792 AC_MSG_CHECKING(for libexpat)
794 for dir in $withval ; do
795 if test -f "$dir/include/expat.h"; then
797 dnl assume /usr is in default path.
798 if test "$dir" != "/usr"; then
799 CPPFLAGS="$CPPFLAGS -I$dir/include"
800 LDFLAGS="$LDFLAGS -L$dir/lib"
802 AC_MSG_RESULT(found in $dir)
806 if test x_$found_libexpat != x_yes; then
807 AC_ERROR([Could not find libexpat, expat.h])
809 AC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT])
811 # set static linking if requested
814 AC_ARG_ENABLE(static-exe, AC_HELP_STRING([--enable-static-exe],
815 [ enable to compile executables statically against event, ldns libs, for debug purposes ]),
817 if test x_$enable_static_exe = x_yes; then
819 if test "$on_mingw" = yes; then
820 staticexe="-all-static"
821 # for static crosscompile, include gdi32 and zlib here.
822 if test "`uname`" = "Linux"; then
823 LIBS="$LIBS -lgdi32 -lz"
828 # set lock checking if requested
829 AC_ARG_ENABLE(lock_checks, AC_HELP_STRING([--enable-lock-checks],
830 [ enable to check lock and unlock calls, for debug purposes ]),
832 if test x_$enable_lock_checks = x_yes; then
833 AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).])
834 CHECKLOCK_OBJ="checklocks.lo"
835 AC_SUBST(CHECKLOCK_OBJ)
838 ACX_CHECK_GETADDRINFO_WITH_INCLUDES
839 if test "$USE_WINSOCK" = 1; then
840 AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API])
841 AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT
844 AC_CHECK_TOOL(WINDRES, windres)
845 LIBS="$LIBS -liphlpapi"
846 WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe"
848 WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c"
849 AC_SUBST(WIN_DAEMON_SRC)
850 WIN_DAEMON_OBJ="win_svc.lo w_inst.lo"
851 AC_SUBST(WIN_DAEMON_OBJ)
852 WIN_DAEMON_OBJ_LINK="rsrc_unbound.o"
853 AC_SUBST(WIN_DAEMON_OBJ_LINK)
854 WIN_HOST_OBJ_LINK="rsrc_unbound_host.o"
855 AC_SUBST(WIN_HOST_OBJ_LINK)
856 WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo"
857 AC_SUBST(WIN_UBANCHOR_OBJ_LINK)
858 WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o"
859 AC_SUBST(WIN_CONTROL_OBJ_LINK)
860 WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o"
861 AC_SUBST(WIN_CHECKCONF_OBJ_LINK)
863 if test $ac_cv_func_getaddrinfo = no; then
864 AC_LIBOBJ([fake-rfc2553])
866 # check after getaddrinfo for its libraries
869 # see if daemon(3) exists, and if it is deprecated.
870 AC_CHECK_FUNCS([daemon])
871 if test $ac_cv_func_daemon = yes; then
872 ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [
877 AC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[
880 #include <sys/param.h>
883 #ifdef HAVE_SYS_SOCKET_H
884 #include <sys/socket.h>
887 #ifdef HAVE_SYS_UIO_H
891 #ifdef HAVE_NETINET_IN_H
892 #include <netinet/in.h>
895 #ifdef HAVE_ARPA_INET_H
896 #include <arpa/inet.h>
899 #ifdef HAVE_WINSOCK2_H
900 #include <winsock2.h>
903 #ifdef HAVE_WS2TCPIP_H
904 #include <ws2tcpip.h>
907 AC_SEARCH_LIBS([setusercontext], [util])
908 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])
909 AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
910 AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
912 # check if setreuid en setregid fail, on MacOSX10.4(darwin8).
913 if echo $build_os | grep darwin8 > /dev/null; then
914 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
916 AC_REPLACE_FUNCS(inet_aton)
917 AC_REPLACE_FUNCS(inet_pton)
918 AC_REPLACE_FUNCS(inet_ntop)
919 AC_REPLACE_FUNCS(snprintf)
920 AC_REPLACE_FUNCS(strlcpy)
921 AC_REPLACE_FUNCS(memmove)
922 AC_REPLACE_FUNCS(gmtime_r)
923 LIBOBJ_WITHOUT_CTIME="$LIBOBJS"
924 AC_SUBST(LIBOBJ_WITHOUT_CTIME)
925 AC_REPLACE_FUNCS(ctime_r)
927 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]))
928 case "$enable_allsymbols" in
930 COMMON_OBJ_ALL_SYMBOLS=""
932 EXTRALINK="-L. -L.libs -lunbound"
933 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])
936 COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)'
937 UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def'
941 AC_SUBST(COMMON_OBJ_ALL_SYMBOLS)
944 if test x_$enable_lock_checks = x_yes; then
945 UBSYMS="-export-symbols clubsyms.def"
946 cp ${srcdir}/libunbound/ubsyms.def clubsyms.def
947 echo lock_protect >> clubsyms.def
948 echo lock_unprotect >> clubsyms.def
949 echo lock_get_mem >> clubsyms.def
950 echo checklock_start >> clubsyms.def
951 echo checklock_stop >> clubsyms.def
952 echo checklock_lock >> clubsyms.def
953 echo checklock_unlock >> clubsyms.def
954 echo checklock_init >> clubsyms.def
955 echo checklock_thrcreate >> clubsyms.def
956 echo checklock_thrjoin >> clubsyms.def
959 AC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope])
960 # on openBSD, the implicit rule make $< work.
961 # on Solaris, it does not work ($? is changed sources, $^ lists dependencies).
963 cat >conftest.make <<EOF
966 conftest.lo foo.lo bla.lo:
967 if test -f "\$<"; then touch \$@; fi
971 if test -f "\$<"; then touch \$@; fi
973 conftest.lo: conftest.dir/conftest.c
976 touch conftest.dir/conftest.c
977 rm -f conftest.lo conftest.c
978 ${MAKE:-make} -f conftest.make >/dev/null
979 rm -f conftest.make conftest.c conftest.dir/conftest.c
981 if test ! -f conftest.lo; then
983 SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source'
984 SOURCEFILE='`cat .source`'
991 AC_SUBST(SOURCEDETERMINE)
994 # see if we want to build the library or everything
995 ALLTARGET="alltargets"
996 AC_ARG_WITH(libunbound-only, AC_HELP_STRING([--with-libunbound-only],
997 [do not build daemon and tool programs]),
999 if test "$withval" = "yes"; then
1005 # check this after all other compilation checks, since the linking of the lib
1006 # may break checks after this.
1007 AC_ARG_WITH(ldns, AC_HELP_STRING([--with-ldns=PATH],
1008 [specify prefix of path of ldns library to use]),
1010 if test "$withval" != "yes"; then
1011 if test "$withval" != "/usr" -a "$withval" != ""; then
1012 CPPFLAGS="-I$withval/include $CPPFLAGS"
1013 LDFLAGS="-L$withval/lib $LDFLAGS"
1014 ACX_RUNTIME_PATH_ADD([$withval/lib])
1021 # check if ldns is good enough
1022 AC_CHECK_LIB(ldns, ldns_rr_new,,[
1023 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])
1025 AC_CHECK_FUNC(ldns_buffer_copy)
1026 if test $USE_NSS = "no"; then
1027 AC_CHECK_FUNC(ldns_key_buf2rsa_raw)
1030 ac_cv_func_ldns_key_buf2rsa_raw="yes"
1032 AC_CHECK_FUNC(ldns_get_random)
1033 AC_CHECK_FUNC(ldns_b32_ntop_extended_hex)
1034 if test x$use_gost = xyes -a x$USE_NSS = xno; then
1035 AC_CHECK_FUNC(ldns_key_EVP_load_gost_id)
1036 AC_CHECK_FUNCS([ldns_key_EVP_unload_gost])
1039 ac_cv_func_ldns_key_EVP_load_gost_id="yes"
1041 if test x$use_ecdsa = xyes; then
1042 AC_CHECK_DECL([LDNS_ECDSAP384SHA384], [], [], [
1044 #ifdef HAVE_SYS_SOCKET_H
1045 # include <sys/socket.h>
1047 #ifdef HAVE_WS2TCPIP_H
1048 # include <ws2tcpip.h>
1050 #include <ldns/ldns.h>
1053 ac_cv_have_decl_LDNS_ECDSAP384SHA384="yes"
1055 AC_CHECK_HEADERS([ldns/ldns.h],,[
1056 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])
1057 ], [AC_INCLUDES_DEFAULT
1058 #ifdef HAVE_SYS_SOCKET_H
1059 #include <sys/socket.h>
1062 #ifdef HAVE_NETINET_IN_H
1063 #include <netinet/in.h>
1066 #ifdef HAVE_ARPA_INET_H
1067 #include <arpa/inet.h>
1070 #ifdef HAVE_WINSOCK2_H
1071 #include <winsock2.h>
1074 #ifdef HAVE_WS2TCPIP_H
1075 #include <ws2tcpip.h>
1078 if test $ac_cv_func_ldns_buffer_copy = yes \
1079 -a $ac_cv_func_ldns_key_buf2rsa_raw = yes \
1080 -a $ac_cv_func_ldns_get_random = yes \
1081 -a $ac_cv_header_ldns_ldns_h = yes \
1082 -a $ac_cv_func_ldns_b32_ntop_extended_hex = yes \
1083 -a $ac_cv_func_ldns_key_EVP_load_gost_id = yes \
1084 -a $ac_cv_have_decl_LDNS_ECDSAP384SHA384 = yes; then
1088 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])
1092 LDFLAGS="$LATE_LDFLAGS $LDFLAGS"
1094 AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.])
1097 dnl this must be first AH_CONFIG, to define the flags before any includes.
1098 AHX_CONFIG_EXT_FLAGS
1102 #ifndef UNBOUND_DEBUG
1116 #ifdef HAVE_STDINT_H
1122 #if HAVE_SYS_PARAM_H
1123 #include <sys/param.h>
1126 #ifdef HAVE_SYS_SOCKET_H
1127 #include <sys/socket.h>
1130 #ifdef HAVE_SYS_UIO_H
1131 #include <sys/uio.h>
1134 #ifdef HAVE_NETINET_IN_H
1135 #include <netinet/in.h>
1138 #ifdef HAVE_ARPA_INET_H
1139 #include <arpa/inet.h>
1142 #ifdef HAVE_WINSOCK2_H
1143 #include <winsock2.h>
1146 #ifdef HAVE_WS2TCPIP_H
1147 #include <ws2tcpip.h>
1151 AHX_CONFIG_FORMAT_ATTRIBUTE
1152 AHX_CONFIG_UNUSED_ATTRIBUTE
1154 AHX_CONFIG_MAXHOSTNAMELEN
1155 AHX_CONFIG_SNPRINTF(unbound)
1156 AHX_CONFIG_INET_PTON(unbound)
1157 AHX_CONFIG_INET_NTOP(unbound)
1158 AHX_CONFIG_INET_ATON(unbound)
1159 AHX_CONFIG_MEMMOVE(unbound)
1160 AHX_CONFIG_STRLCPY(unbound)
1161 AHX_CONFIG_GMTIME_R(unbound)
1162 AHX_CONFIG_W32_SLEEP
1163 AHX_CONFIG_W32_USLEEP
1164 AHX_CONFIG_W32_RANDOM
1165 AHX_CONFIG_W32_SRANDOM
1166 AHX_CONFIG_W32_FD_SET_T
1167 AHX_CONFIG_IPV6_MIN_MTU
1168 AHX_MEMCMP_BROKEN(unbound)
1171 #ifndef HAVE_CTIME_R
1172 #define ctime_r unbound_ctime_r
1173 char *ctime_r(const time_t *timep, char *buf);
1176 #if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
1177 #define strptime unbound_strptime
1179 char *strptime(const char *s, const char *format, struct tm *tm);
1182 #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))
1183 /* using version of libevent that is not threadsafe. */
1184 # define LIBEVENT_SIGNAL_PROBLEM 1
1187 #ifndef CHECKED_INET6
1188 # define CHECKED_INET6
1192 # define AF_INET6 28
1194 #endif /* CHECKED_INET6 */
1196 /* maximum nesting of included files */
1197 #define MAXINCLUDES 10
1198 #ifndef HAVE_GETADDRINFO
1199 struct sockaddr_storage;
1200 #include "compat/fake-rfc2553.h"
1203 #ifdef UNBOUND_ALLOC_STATS
1204 # define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__)
1205 # define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__)
1206 # define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__)
1207 # define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__)
1208 void *unbound_stat_malloc(size_t size);
1209 void *unbound_stat_calloc(size_t nmemb, size_t size);
1210 void unbound_stat_free(void *ptr);
1211 void *unbound_stat_realloc(void *ptr, size_t size);
1212 void *unbound_stat_malloc_log(size_t size, const char* file, int line,
1214 void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file,
1215 int line, const char* func);
1216 void unbound_stat_free_log(void *ptr, const char* file, int line,
1218 void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file,
1219 int line, const char* func);
1220 #elif defined(UNBOUND_ALLOC_LITE)
1221 # include "util/alloc.h"
1222 #endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */
1224 /** default port for DNS traffic. */
1225 #define UNBOUND_DNS_PORT 53
1226 /** default port for unbound control traffic, registered port with IANA,
1227 ub-dns-control 8953/tcp unbound dns nameserver control */
1228 #define UNBOUND_CONTROL_PORT 8953
1229 /** the version of unbound-control that this software implements */
1230 #define UNBOUND_CONTROL_VERSION 1
1234 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])
1235 AC_CONFIG_HEADER([config.h])