xref: /openbsd/usr.sbin/unbound/configure.ac (revision cca36db2)
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3AC_PREREQ(2.56)
4sinclude(acx_nlnetlabs.m4)
5sinclude(acx_pthread.m4)
6sinclude(acx_python.m4)
7sinclude(ac_pkg_swig.m4)
8
9AC_INIT(unbound, 1.4.16, unbound-bugs@nlnetlabs.nl, unbound)
10
11LIBUNBOUND_CURRENT=3
12LIBUNBOUND_REVISION=1
13LIBUNBOUND_AGE=1
14# 1.0.0 had 0:12:0
15# 1.0.1 had 0:13:0
16# 1.0.2 had 0:14:0
17# 1.1.0 had 0:15:0
18# 1.1.1 had 0:16:0
19# 1.2.0 had 0:17:0
20# 1.2.1 had 0:18:0
21# 1.3.0 had 1:0:0   # ub_cancel and -export-symbols.
22# 1.3.1 had 1:1:0
23# 1.3.2 had 1:2:0
24# 1.3.3 had 1:3:0
25# 1.3.4 had 1:4:0
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
28# 1.4.1 had 2:1:0
29# 1.4.2 had 2:2:0
30# 1.4.3 had 2:3:0
31# 1.4.4 had 2:4:0
32# 1.4.5 had 2:5:0
33# 1.4.6 had 2:6:0
34# 1.4.7 had 2:7:0
35# 1.4.8 had 2:8:0
36# 1.4.9 had 2:9:0
37# 1.4.10 had 2:10:0
38# 1.4.11 had 2:11:0
39# 1.4.12 had 2:12:0
40# 1.4.13 had 2:13:0
41# and 1.4.13p1 and 1.4.13.p2
42# 1.4.14 had 2:14:0
43# 1.4.15 had 3:0:1 # adds ub_version()
44# 1.4.16 had 3:1:1
45
46#   Current  -- the number of the binary API that we're implementing
47#   Revision -- which iteration of the implementation of the binary
48#               API are we supplying?
49#   Age      -- How many previous binary API versions do we also
50#               support?
51#
52# If we release a new version that does not change the binary API,
53# increment Revision.
54#
55# If we release a new version that changes the binary API, but does
56# not break programs compiled against the old binary API, increment
57# Current and Age.  Set Revision to 0, since this is the first
58# implementation of the new API.
59#
60# Otherwise, we're changing the binary API and breaking bakward
61# compatibility with old binaries.  Increment Current.  Set Age to 0,
62# since we're backward compatible with no previous APIs.  Set Revision
63# to 0 too.
64AC_SUBST(LIBUNBOUND_CURRENT)
65AC_SUBST(LIBUNBOUND_REVISION)
66AC_SUBST(LIBUNBOUND_AGE)
67
68pretty_cmdline() {
69	cmdline=""
70	while test -n "$1"; do
71		cmdline="$cmdline '"`echo $1 | sed -e 's/\\\\/\\\\\\\\/g' | sed -e 's/"/\\\\"/g' `"'"
72		shift
73	done
74}
75pretty_cmdline $@
76AC_DEFINE_UNQUOTED(CONFIGURE_BUILD_WITH, ["$cmdline"], [configure flags])
77AC_CANONICAL_TARGET
78AC_DEFINE_UNQUOTED(CONFIGURE_TARGET, ["$target"], [configure target system])
79AC_DEFINE_UNQUOTED(CONFIGURE_DATE, ["`date`"], [configure date])
80
81CFLAGS="$CFLAGS"
82AC_AIX
83
84dnl
85dnl By default set prefix to /usr/local
86dnl
87case "$prefix" in
88        NONE)
89		prefix="/usr/local"
90        ;;
91esac
92
93# are we on MinGW?
94if uname -s 2>&1 | grep MINGW32 >/dev/null; then on_mingw="yes"
95else
96	if echo $target | grep mingw32 >/dev/null; then on_mingw="yes"
97	else on_mingw="no"; fi
98fi
99
100#
101# Determine configuration file
102# the eval is to evaluate shell expansion twice
103if test $on_mingw = "no"; then
104  ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"`
105else
106  ub_conf_file="C:\\Program Files\\Unbound\\service.conf"
107fi
108AC_ARG_WITH([conf_file],
109        AC_HELP_STRING([--with-conf-file=path],
110	[Pathname to the Unbound configuration file]),
111	[ub_conf_file="$withval"])
112AC_SUBST(ub_conf_file)
113ACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config)
114AC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file])
115
116# Determine run, chroot directory and pidfile locations
117AC_ARG_WITH(run-dir,
118    AC_HELP_STRING([--with-run-dir=path],
119    [set default directory to chdir to (by default dir part of cfg file)]),
120    UNBOUND_RUN_DIR="$withval",
121if test $on_mingw = no; then
122    UNBOUND_RUN_DIR=`dirname "$ub_conf_file"`
123else
124    UNBOUND_RUN_DIR=""
125fi
126)
127AC_SUBST(UNBOUND_RUN_DIR)
128ACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run)
129AC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to])
130
131AC_ARG_WITH(chroot-dir,
132    AC_HELP_STRING([--with-chroot-dir=path],
133    [set default directory to chroot to (by default same as run-dir)]),
134    UNBOUND_CHROOT_DIR="$withval",
135if test $on_mingw = no; then
136    UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR"
137else
138    UNBOUND_CHROOT_DIR=""
139fi
140)
141AC_SUBST(UNBOUND_CHROOT_DIR)
142ACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot)
143AC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to])
144
145AC_ARG_WITH(share-dir,
146    AC_HELP_STRING([--with-share-dir=path],
147    [set default directory with shared data (by default same as share/unbound)]),
148    UNBOUND_SHARE_DIR="$withval",
149    UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR")
150AC_SUBST(UNBOUND_SHARE_DIR)
151AC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data])
152
153AC_ARG_WITH(pidfile,
154    AC_HELP_STRING([--with-pidfile=filename],
155    [set default pathname to unbound pidfile (default run-dir/unbound.pid)]),
156    UNBOUND_PIDFILE="$withval",
157if test $on_mingw = no; then
158    UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid"
159else
160    UNBOUND_PIDFILE=""
161fi
162)
163AC_SUBST(UNBOUND_PIDFILE)
164ACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid)
165AC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location])
166
167AC_ARG_WITH(rootkey-file,
168    AC_HELP_STRING([--with-rootkey-file=filename],
169    [set default pathname to root key file (default run-dir/root.key). This file is read and written.]),
170    UNBOUND_ROOTKEY_FILE="$withval",
171if test $on_mingw = no; then
172    UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key"
173else
174    UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key"
175fi
176)
177AC_SUBST(UNBOUND_ROOTKEY_FILE)
178ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey)
179AC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location])
180
181AC_ARG_WITH(rootcert-file,
182    AC_HELP_STRING([--with-rootcert-file=filename],
183    [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.]),
184    UNBOUND_ROOTCERT_FILE="$withval",
185if test $on_mingw = no; then
186    UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem"
187else
188    UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem"
189fi
190)
191AC_SUBST(UNBOUND_ROOTCERT_FILE)
192ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem)
193AC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location])
194
195AC_ARG_WITH(username,
196    AC_HELP_STRING([--with-username=user],
197    [set default user that unbound changes to (default user is unbound)]),
198    UNBOUND_USERNAME="$withval",
199    UNBOUND_USERNAME="unbound")
200AC_SUBST(UNBOUND_USERNAME)
201AC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username])
202
203AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
204ACX_RSRC_VERSION(wnvs)
205AC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files])
206
207# Checks for typedefs, structures, and compiler characteristics.
208AC_C_CONST
209AC_LANG_C
210AC_PROG_CC
211ACX_DEPFLAG
212ACX_DETERMINE_EXT_FLAGS_UNBOUND
213
214# debug mode flags warnings
215AC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable warnings, asserts, makefile-dependencies]))
216AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [same as enable-checking]))
217if test "$enable_debug" = "yes"; then debug_enabled="$enable_debug";
218else debug_enabled="$enable_checking"; fi
219AC_SUBST(debug_enabled)
220case "$debug_enabled" in
221        yes)
222		ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"])
223		ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"])
224		ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"])
225		ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
226		AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.])
227		;;
228	no|*)
229		# nothing to do.
230		;;
231esac
232ACX_CHECK_FLTO
233
234AC_C_INLINE
235ACX_CHECK_FORMAT_ATTRIBUTE
236ACX_CHECK_UNUSED_ATTRIBUTE
237
238if test "$srcdir" != "."; then
239	CPPFLAGS="$CPPFLAGS -I$srcdir"
240fi
241
242AC_DEFUN([ACX_YYLEX_DESTROY], [
243	AC_MSG_CHECKING([for yylex_destroy])
244	if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then
245		AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy])
246		AC_MSG_RESULT(yes)
247	else AC_MSG_RESULT(no); fi
248])
249
250AC_PROG_LEX
251ACX_YYLEX_DESTROY
252AC_PROG_YACC
253AC_CHECK_PROG(doxygen, doxygen, doxygen)
254AC_CHECK_TOOL(STRIP, strip)
255ACX_LIBTOOL_C_ONLY
256
257# Checks for header files.
258AC_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])
259
260# check for types.
261# Using own tests for int64* because autoconf builtin only give 32bit.
262AC_CHECK_TYPE(int8_t, signed char)
263AC_CHECK_TYPE(int16_t, short)
264AC_CHECK_TYPE(int32_t, int)
265AC_CHECK_TYPE(int64_t, long long)
266AC_CHECK_TYPE(uint8_t, unsigned char)
267AC_CHECK_TYPE(uint16_t, unsigned short)
268AC_CHECK_TYPE(uint32_t, unsigned int)
269AC_CHECK_TYPE(uint64_t, unsigned long long)
270AC_TYPE_SIZE_T
271AC_CHECK_TYPE(ssize_t, int)
272AC_TYPE_UID_T
273AC_TYPE_PID_T
274AC_TYPE_OFF_T
275ACX_TYPE_U_CHAR
276ACX_TYPE_RLIM_T
277ACX_TYPE_SOCKLEN_T
278ACX_TYPE_IN_ADDR_T
279ACX_TYPE_IN_PORT_T
280ACX_CHECK_MEMCMP_SIGNED
281
282# add option to disable the evil rpath
283ACX_ARG_RPATH
284AC_SUBST(RUNTIME_PATH)
285
286# check to see if libraries are needed for these functions.
287AC_SEARCH_LIBS([inet_pton], [nsl])
288AC_SEARCH_LIBS([socket], [socket])
289
290# check wether strptime also works
291AC_DEFUN([AC_CHECK_STRPTIME_WORKS],
292[AC_REQUIRE([AC_PROG_CC])
293AC_MSG_CHECKING(whether strptime works)
294if test c${cross_compiling} = cno; then
295AC_RUN_IFELSE([AC_LANG_SOURCE([[
296#define _XOPEN_SOURCE
297#include <time.h>
298int main(void) { struct tm tm; char *res;
299res = 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);
300if (!res) return 2;
301res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
302if (!res) return 1; return 0; }
303]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"])
304else
305eval "ac_cv_c_strptime_works=maybe"
306fi
307AC_MSG_RESULT($ac_cv_c_strptime_works)
308if test $ac_cv_c_strptime_works = no; then
309AC_LIBOBJ(strptime)
310else
311AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.])
312fi
313])dnl
314
315# check some functions of the OS before linking libs (while still runnable).
316AC_FUNC_CHOWN
317AC_FUNC_FORK
318AC_TYPE_SIGNAL
319AC_FUNC_FSEEKO
320ACX_SYS_LARGEFILE
321ACX_CHECK_NONBLOCKING_BROKEN
322ACX_MKDIR_ONE_ARG
323AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])])
324
325# set memory allocation checking if requested
326AC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks],
327	[ enable to memory allocation statistics, for debug purposes ]),
328	, )
329AC_ARG_ENABLE(alloc-lite, AC_HELP_STRING([--enable-alloc-lite],
330	[ enable for lightweight alloc assertions, for debug purposes ]),
331	, )
332AC_ARG_ENABLE(alloc-nonregional, AC_HELP_STRING([--enable-alloc-nonregional],
333	[ enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes ]),
334	, )
335if test x_$enable_alloc_nonregional = x_yes; then
336	AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use])
337fi
338if test x_$enable_alloc_checks = x_yes; then
339	AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use])
340else
341	if test x_$enable_alloc_lite = x_yes; then
342		AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use])
343	else
344		ACX_FUNC_MALLOC([unbound])
345	fi
346fi
347
348# check windows threads (we use them, not pthreads, on windows).
349if test "$on_mingw" = "yes"; then
350# check windows threads
351	AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT])
352	AC_MSG_CHECKING([for CreateThread])
353	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
354#ifdef HAVE_WINDOWS_H
355#include <windows.h>
356#endif
357], [
358	HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL);
359])],
360	AC_MSG_RESULT(yes)
361	AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads])
362,
363	AC_MSG_RESULT(no)
364)
365
366else
367# not on mingw, check thread libraries.
368
369# check for thread library.
370# check this first, so that the pthread lib does not get linked in via
371# libssl or libpython, and thus distorts the tests, and we end up using
372# the non-threadsafe C libraries.
373AC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads],
374 [use pthreads library, or --without-pthreads to disable threading support.]),
375 [ ],[ withval="yes" ])
376ub_have_pthreads=no
377if test x_$withval != x_no; then
378	ACX_PTHREAD([
379		AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
380		LIBS="$PTHREAD_LIBS $LIBS"
381		CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
382		CC="$PTHREAD_CC"
383		ub_have_pthreads=yes
384		AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>])
385		])
386fi
387
388# check solaris thread library
389AC_ARG_WITH(solaris-threads, AC_HELP_STRING([--with-solaris-threads],
390	[use solaris native thread library.]), [ ],[ withval="no" ])
391ub_have_sol_threads=no
392if test x_$withval != x_no; then
393	if test x_$ub_have_pthreads != x_no; then
394	    AC_WARN([Have pthreads already, ignoring --with-solaris-threads])
395	else
396	AC_SEARCH_LIBS(thr_create, [thread],
397	[
398    		AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads])
399
400		ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"],
401			[CFLAGS="$CFLAGS -D_REENTRANT"])
402		ub_have_sol_threads=yes
403	] , [
404		AC_ERROR([no solaris threads found.])
405	])
406	fi
407fi
408
409fi # end of non-mingw check of thread libraries
410
411# Check for PyUnbound
412AC_ARG_WITH(pyunbound,
413   AC_HELP_STRING([--with-pyunbound],
414   [build PyUnbound, or --without-pyunbound to skip it. (default=no)]),
415   [], [ withval="no" ])
416
417ub_test_python=no
418ub_with_pyunbound=no
419if test x_$withval != x_no; then
420   ub_with_pyunbound=yes
421   ub_test_python=yes
422fi
423
424# Check for Python module
425AC_ARG_WITH(pythonmodule,
426   AC_HELP_STRING([--with-pythonmodule],
427   [build Python module, or --without-pythonmodule to disable script engine. (default=no)]),
428   [], [ withval="no" ])
429
430ub_with_pythonmod=no
431if test x_$withval != x_no; then
432   ub_with_pythonmod=yes
433   ub_test_python=yes
434fi
435
436# Check for Python & SWIG only on PyUnbound or PyModule
437if test x_$ub_test_python != x_no; then
438
439   # Check for Python
440   ub_have_python=no
441   ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
442   AC_PYTHON_DEVEL
443   if test ! -z "$PYTHON_VERSION"; then
444	if test `$PYTHON -c "print '$PYTHON_VERSION' >= '2.4.0'"` = "False"; then
445		AC_ERROR([Python version >= 2.4.0 is required])
446	fi
447
448      # Have Python
449      AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
450      LIBS="$PYTHON_LDFLAGS $LIBS"
451      CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
452      ub_have_python=yes
453
454      # Check for SWIG
455      ub_have_swig=no
456      AC_PROG_SWIG
457      AC_MSG_CHECKING(SWIG)
458      if test ! -x "$SWIG"; then
459         AC_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound])
460      else
461         AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.])
462         AC_SUBST(swig, "$SWIG")
463         AC_MSG_RESULT(present)
464
465         # If have Python & SWIG
466         # Declare PythonMod
467         if test x_$ub_with_pythonmod != x_no; then
468            AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.])
469            WITH_PYTHONMODULE=yes
470            AC_SUBST(WITH_PYTHONMODULE)
471	    PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo"
472	    AC_SUBST(PYTHONMOD_OBJ)
473	    PYTHONMOD_HEADER="$(srcdir)/pythonmod/pythonmod.h"
474	    AC_SUBST(PYTHONMOD_HEADER)
475	    PYTHONMOD_INSTALL=pythonmod-install
476	    AC_SUBST(PYTHONMOD_INSTALL)
477	    PYTHONMOD_UNINSTALL=pythonmod-uninstall
478	    AC_SUBST(PYTHONMOD_UNINSTALL)
479         fi
480
481         # Declare PyUnbound
482         if test x_$ub_with_pyunbound != x_no; then
483            AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.])
484            WITH_PYUNBOUND=yes
485            AC_SUBST(WITH_PYUNBOUND)
486	    PYUNBOUND_OBJ="libunbound_wrap.lo"
487	    AC_SUBST(PYUNBOUND_OBJ)
488	    PYUNBOUND_TARGET="_unbound.la"
489	    AC_SUBST(PYUNBOUND_TARGET)
490	    PYUNBOUND_INSTALL=pyunbound-install
491	    AC_SUBST(PYUNBOUND_INSTALL)
492	    PYUNBOUND_UNINSTALL=pyunbound-uninstall
493	    AC_SUBST(PYUNBOUND_UNINSTALL)
494         fi
495      fi
496   else
497      AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***])
498      ub_with_pyunbound=no
499      ub_with_pythonmod=no
500   fi
501fi
502
503if test "`uname`" = "NetBSD"; then
504	NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_'
505	AC_SUBST(NETBSD_LINTFLAGS)
506fi
507CONFIG_DATE=`date +%Y%m%d`
508AC_SUBST(CONFIG_DATE)
509
510# Checks for libraries.
511ACX_WITH_SSL
512ACX_LIB_SSL
513AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT])
514AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT])
515AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512])
516AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free], [], [], [
517AC_INCLUDES_DEFAULT
518#ifdef HAVE_OPENSSL_ERR_H
519#include <openssl/err.h>
520#endif
521
522#ifdef HAVE_OPENSSL_RAND_H
523#include <openssl/rand.h>
524#endif
525
526#ifdef HAVE_OPENSSL_CONF_H
527#include <openssl/conf.h>
528#endif
529
530#ifdef HAVE_OPENSSL_ENGINE_H
531#include <openssl/engine.h>
532#endif
533#include <openssl/ssl.h>
534#include <openssl/evp.h>
535])
536
537AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
538case "$enable_sha2" in
539	no)
540	;;
541	yes|*)
542	AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
543	;;
544esac
545
546# check wether gost also works
547AC_DEFUN([AC_CHECK_GOST_WORKS],
548[AC_REQUIRE([AC_PROG_CC])
549AC_MSG_CHECKING([if GOST works])
550if test c${cross_compiling} = cno; then
551BAKCFLAGS="$CFLAGS"
552if test -n "$ssldir"; then
553	CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib"
554fi
555AC_RUN_IFELSE([AC_LANG_SOURCE([[
556#include <string.h>
557#include <openssl/ssl.h>
558#include <openssl/evp.h>
559#include <openssl/engine.h>
560#include <openssl/conf.h>
561/* routine to load gost from ldns */
562int load_gost_id(void)
563{
564	static int gost_id = 0;
565	const EVP_PKEY_ASN1_METHOD* meth;
566	ENGINE* e;
567
568	if(gost_id) return gost_id;
569
570	/* see if configuration loaded gost implementation from other engine*/
571	meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
572	if(meth) {
573		EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
574		return gost_id;
575	}
576
577	/* see if engine can be loaded already */
578	e = ENGINE_by_id("gost");
579	if(!e) {
580		/* load it ourself, in case statically linked */
581		ENGINE_load_builtin_engines();
582		ENGINE_load_dynamic();
583		e = ENGINE_by_id("gost");
584	}
585	if(!e) {
586		/* no gost engine in openssl */
587		return 0;
588	}
589	if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
590		ENGINE_finish(e);
591		ENGINE_free(e);
592		return 0;
593	}
594
595	meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
596	if(!meth) {
597		/* algo not found */
598		ENGINE_finish(e);
599		ENGINE_free(e);
600		return 0;
601	}
602	EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
603	return gost_id;
604}
605int main(void) {
606	EVP_MD_CTX* ctx;
607	const EVP_MD* md;
608	unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */
609	const char* str = "Hello world";
610	const unsigned char check[] = {
611		0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 ,
612		0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 ,
613		0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d ,
614		0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d
615	};
616	OPENSSL_config(NULL);
617	(void)load_gost_id();
618	md = EVP_get_digestbyname("md_gost94");
619	if(!md) return 1;
620	memset(digest, 0, sizeof(digest));
621	ctx = EVP_MD_CTX_create();
622	if(!ctx) return 2;
623	if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3;
624	if(!EVP_DigestUpdate(ctx, str, 10)) return 4;
625	if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5;
626	/* uncomment to see the hash calculated.
627		{int i;
628		for(i=0; i<32; i++)
629			printf(" %2.2x", (int)digest[i]);
630		printf("\n");}
631	*/
632	if(memcmp(digest, check, sizeof(check)) != 0)
633		return 6;
634	return 0;
635}
636]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"])
637CFLAGS="$BAKCFLAGS"
638else
639eval "ac_cv_c_gost_works=maybe"
640fi
641AC_MSG_RESULT($ac_cv_c_gost_works)
642])dnl
643
644AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
645use_gost="no"
646case "$enable_gost" in
647	no)
648	;;
649	*)
650	AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])])
651        AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])])
652	AC_CHECK_GOST_WORKS
653	if test $ac_cv_c_gost_works != no; then
654		use_gost="yes"
655		AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
656	fi
657	;;
658esac
659
660# check for libevent
661AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname],
662    [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.]),
663    [ ],[ withval="no" ])
664if test x_$withval = x_yes -o x_$withval != x_no; then
665        AC_MSG_CHECKING(for libevent)
666        if test x_$withval = x_ -o x_$withval = x_yes; then
667            withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
668        fi
669        for dir in $withval; do
670            thedir="$dir"
671            if test -f "$dir/include/event.h"; then
672                found_libevent="yes"
673		dnl assume /usr is in default path.
674		if test "$thedir" != "/usr"; then
675                    CPPFLAGS="$CPPFLAGS -I$thedir/include"
676		fi
677                break;
678            fi
679        done
680        if test x_$found_libevent != x_yes; then
681		if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
682			# libevent source directory
683            		AC_MSG_RESULT(found in $thedir)
684                	CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include"
685			BAK_LDFLAGS_SET="1"
686			BAK_LDFLAGS="$LDFLAGS"
687			# remove evdns from linking
688			mkdir build >/dev/null 2>&1
689			mkdir build/libevent >/dev/null 2>&1
690			mkdir build/libevent/.libs >/dev/null 2>&1
691			ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
692			ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo`
693			ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
694			cp $ev_files_o build/libevent
695			cp $ev_files_lo build/libevent
696			cp $ev_files_libso build/libevent/.libs
697            		LATE_LDFLAGS="build/libevent/*.lo -lm"
698			LDFLAGS="build/libevent/*.o $LDFLAGS -lm"
699		else
700            		AC_MSG_ERROR([Cannot find the libevent library in $withval
701You can restart ./configure --with-libevent=no to use a builtin alternative.
702Please note that this alternative is not as capable as libevent when using
703large outgoing port ranges.  ])
704		fi
705        else
706            AC_MSG_RESULT(found in $thedir)
707	    dnl assume /usr is in default path, do not add "".
708	    if test "$thedir" != "/usr" -a "$thedir" != ""; then
709                LDFLAGS="$LDFLAGS -L$thedir/lib"
710		ACX_RUNTIME_PATH_ADD([$thedir/lib])
711	    fi
712        fi
713	# check for library used by libevent after 1.3c
714	AC_SEARCH_LIBS([clock_gettime], [rt])
715
716	# is the event.h header libev or libevent?
717	AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT])
718	AC_CHECK_DECL(EV_VERSION_MAJOR, [
719		AC_SEARCH_LIBS(event_set, [ev])
720	],[
721		AC_SEARCH_LIBS(event_set, [event])
722	],[AC_INCLUDES_DEFAULT
723#include <event.h>
724	])
725	AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later
726	AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later
727	AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later
728	AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later
729	AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51)
730	AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00)
731	if test -n "$BAK_LDFLAGS_SET"; then
732		LDFLAGS="$BAK_LDFLAGS"
733	fi
734else
735	AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
736fi
737
738# check for libexpat
739AC_ARG_WITH(libexpat, AC_HELP_STRING([--with-libexpat=path],
740    [specify explicit path for libexpat.]),
741    [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ])
742AC_MSG_CHECKING(for libexpat)
743found_libexpat="no"
744for dir in $withval ; do
745            if test -f "$dir/include/expat.h"; then
746		found_libexpat="yes"
747		dnl assume /usr is in default path.
748		if test "$dir" != "/usr"; then
749                    CPPFLAGS="$CPPFLAGS -I$dir/include"
750		    LDFLAGS="$LDFLAGS -L$dir/lib"
751		fi
752            	AC_MSG_RESULT(found in $dir)
753                break;
754            fi
755done
756if test x_$found_libexpat != x_yes; then
757	AC_ERROR([Could not find libexpat, expat.h])
758fi
759AC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT])
760
761# set static linking if requested
762AC_SUBST(staticexe)
763staticexe=""
764AC_ARG_ENABLE(static-exe, AC_HELP_STRING([--enable-static-exe],
765	[ enable to compile executables statically against event, ldns libs, for debug purposes ]),
766	, )
767if test x_$enable_static_exe = x_yes; then
768	staticexe="-static"
769	if test "$on_mingw" = yes; then
770		staticexe="-all-static"
771		# for static crosscompile, include gdi32 and zlib here.
772		if test "`uname`" = "Linux"; then
773			LIBS="$LIBS -lgdi32 -lz"
774		fi
775	fi
776fi
777
778# set lock checking if requested
779AC_ARG_ENABLE(lock_checks, AC_HELP_STRING([--enable-lock-checks],
780	[ enable to check lock and unlock calls, for debug purposes ]),
781	, )
782if test x_$enable_lock_checks = x_yes; then
783	AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).])
784	CHECKLOCK_OBJ="checklocks.lo"
785	AC_SUBST(CHECKLOCK_OBJ)
786fi
787
788ACX_CHECK_GETADDRINFO_WITH_INCLUDES
789if test "$USE_WINSOCK" = 1; then
790	AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API])
791	AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT
792#include <windows.h>
793	])
794	AC_CHECK_TOOL(WINDRES, windres)
795	LIBS="$LIBS -liphlpapi"
796	WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe"
797	AC_SUBST(WINAPPS)
798	WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c"
799	AC_SUBST(WIN_DAEMON_SRC)
800	WIN_DAEMON_OBJ="win_svc.lo w_inst.lo"
801	AC_SUBST(WIN_DAEMON_OBJ)
802	WIN_DAEMON_OBJ_LINK="rsrc_unbound.o"
803	AC_SUBST(WIN_DAEMON_OBJ_LINK)
804	WIN_HOST_OBJ_LINK="rsrc_unbound_host.o"
805	AC_SUBST(WIN_HOST_OBJ_LINK)
806	WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo"
807	AC_SUBST(WIN_UBANCHOR_OBJ_LINK)
808	WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o"
809	AC_SUBST(WIN_CONTROL_OBJ_LINK)
810	WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o"
811	AC_SUBST(WIN_CHECKCONF_OBJ_LINK)
812fi
813if test $ac_cv_func_getaddrinfo = no; then
814	AC_LIBOBJ([fake-rfc2553])
815fi
816# check after getaddrinfo for its libraries
817ACX_FUNC_IOCTLSOCKET
818
819# see if daemon(3) exists, and if it is deprecated.
820AC_CHECK_FUNCS([daemon])
821if test $ac_cv_func_daemon = yes; then
822	ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [
823#include <stdlib.h>
824])
825fi
826
827AC_SEARCH_LIBS([setusercontext], [util])
828AC_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])
829AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
830AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
831
832# check if setreuid en setregid fail, on MacOSX10.4(darwin8).
833if echo $build_os | grep darwin8 > /dev/null; then
834	AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
835fi
836AC_REPLACE_FUNCS(inet_aton)
837AC_REPLACE_FUNCS(inet_pton)
838AC_REPLACE_FUNCS(inet_ntop)
839AC_REPLACE_FUNCS(snprintf)
840AC_REPLACE_FUNCS(strlcpy)
841AC_REPLACE_FUNCS(memmove)
842AC_REPLACE_FUNCS(gmtime_r)
843LIBOBJ_WITHOUT_CTIME="$LIBOBJS"
844AC_SUBST(LIBOBJ_WITHOUT_CTIME)
845AC_REPLACE_FUNCS(ctime_r)
846
847AC_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]))
848case "$enable_allsymbols" in
849	yes)
850	COMMON_OBJ_ALL_SYMBOLS=""
851	UBSYMS=""
852	EXTRALINK="-L. -L.libs -lunbound"
853	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])
854	;;
855	no|*)
856	COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)'
857	UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def'
858	EXTRALINK=""
859	;;
860esac
861AC_SUBST(COMMON_OBJ_ALL_SYMBOLS)
862AC_SUBST(EXTRALINK)
863AC_SUBST(UBSYMS)
864if test x_$enable_lock_checks = x_yes; then
865	UBSYMS="-export-symbols clubsyms.def"
866	cp ${srcdir}/libunbound/ubsyms.def clubsyms.def
867	echo lock_protect >> clubsyms.def
868	echo lock_unprotect >> clubsyms.def
869	echo lock_get_mem >> clubsyms.def
870	echo checklock_start >> clubsyms.def
871	echo checklock_stop >> clubsyms.def
872	echo checklock_lock >> clubsyms.def
873	echo checklock_unlock >> clubsyms.def
874	echo checklock_init >> clubsyms.def
875	echo checklock_thrcreate >> clubsyms.def
876	echo checklock_thrjoin >> clubsyms.def
877fi
878
879AC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope])
880# on openBSD, the implicit rule make $< work.
881# on Solaris, it does not work ($? is changed sources, $^ lists dependencies).
882# gmake works.
883cat >conftest.make <<EOF
884all:	conftest.lo
885
886conftest.lo foo.lo bla.lo:
887	if test -f "\$<"; then touch \$@; fi
888
889.SUFFIXES: .lo
890.c.lo:
891	if test -f "\$<"; then touch \$@; fi
892
893conftest.lo:        conftest.dir/conftest.c
894EOF
895mkdir conftest.dir
896touch conftest.dir/conftest.c
897rm -f conftest.lo conftest.c
898${MAKE:-make} -f conftest.make >/dev/null
899rm -f conftest.make conftest.c conftest.dir/conftest.c
900rm -rf conftest.dir
901if test ! -f conftest.lo; then
902	AC_MSG_RESULT(no)
903	SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source'
904	SOURCEFILE='`cat .source`'
905else
906	AC_MSG_RESULT(yes)
907	SOURCEDETERMINE=':'
908	SOURCEFILE='$<'
909fi
910rm -f conftest.lo
911AC_SUBST(SOURCEDETERMINE)
912AC_SUBST(SOURCEFILE)
913
914# check this after all other compilation checks, since the linking of the lib
915# may break checks after this.
916AC_ARG_WITH(ldns, AC_HELP_STRING([--with-ldns=PATH],
917	[specify prefix of path of ldns library to use]),
918	[
919	if test "$withval" != "yes"; then
920		if test "$withval" != "/usr" -a "$withval" != ""; then
921			CPPFLAGS="-I$withval/include $CPPFLAGS"
922			LDFLAGS="-L$withval/lib $LDFLAGS"
923			ACX_RUNTIME_PATH_ADD([$withval/lib])
924		fi
925		ldnsdir="$withval"
926		AC_SUBST(ldnsdir)
927	fi
928])
929
930# check if ldns is good enough
931AC_CHECK_LIB(ldns, ldns_rr_new,,[
932	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])
933])
934AC_CHECK_FUNC(ldns_buffer_copy)
935AC_CHECK_FUNC(ldns_key_buf2rsa_raw)
936AC_CHECK_FUNC(ldns_get_random)
937AC_CHECK_FUNC(ldns_b32_ntop_extended_hex)
938if test x$use_gost = xyes; then
939    AC_CHECK_FUNC(ldns_key_EVP_load_gost_id)
940    AC_CHECK_FUNCS([ldns_key_EVP_unload_gost])
941else
942    ac_cv_func_ldns_key_EVP_load_gost_id="yes"
943fi
944AC_CHECK_HEADERS([ldns/ldns.h],,[
945	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])
946	], [AC_INCLUDES_DEFAULT
947#ifdef HAVE_SYS_SOCKET_H
948#include <sys/socket.h>
949#endif
950
951#ifdef HAVE_NETINET_IN_H
952#include <netinet/in.h>
953#endif
954
955#ifdef HAVE_ARPA_INET_H
956#include <arpa/inet.h>
957#endif
958
959#ifdef HAVE_WINSOCK2_H
960#include <winsock2.h>
961#endif
962
963#ifdef HAVE_WS2TCPIP_H
964#include <ws2tcpip.h>
965#endif
966])
967if test $ac_cv_func_ldns_buffer_copy = yes \
968    -a $ac_cv_func_ldns_key_buf2rsa_raw = yes \
969    -a $ac_cv_func_ldns_get_random = yes \
970    -a $ac_cv_header_ldns_ldns_h = yes \
971    -a $ac_cv_func_ldns_b32_ntop_extended_hex = yes \
972    -a $ac_cv_func_ldns_key_EVP_load_gost_id = yes; then
973    dnl ldns was found
974    :
975else
976    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])
977fi
978
979ACX_STRIP_EXT_FLAGS
980LDFLAGS="$LATE_LDFLAGS $LDFLAGS"
981
982AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.])
983
984AH_BOTTOM(
985dnl this must be first AH_CONFIG, to define the flags before any includes.
986AHX_CONFIG_EXT_FLAGS
987
988dnl includes
989[
990#ifndef UNBOUND_DEBUG
991#  define NDEBUG
992#endif
993
994#include <stdio.h>
995#include <string.h>
996#include <unistd.h>
997#include <assert.h>
998
999#if STDC_HEADERS
1000#include <stdlib.h>
1001#include <stddef.h>
1002#endif
1003
1004#ifdef HAVE_STDINT_H
1005#include <stdint.h>
1006#endif
1007
1008#include <errno.h>
1009
1010#if HAVE_SYS_PARAM_H
1011#include <sys/param.h>
1012#endif
1013
1014#ifdef HAVE_SYS_SOCKET_H
1015#include <sys/socket.h>
1016#endif
1017
1018#ifdef HAVE_SYS_UIO_H
1019#include <sys/uio.h>
1020#endif
1021
1022#ifdef HAVE_NETINET_IN_H
1023#include <netinet/in.h>
1024#endif
1025
1026#ifdef HAVE_ARPA_INET_H
1027#include <arpa/inet.h>
1028#endif
1029
1030#ifdef HAVE_WINSOCK2_H
1031#include <winsock2.h>
1032#endif
1033
1034#ifdef HAVE_WS2TCPIP_H
1035#include <ws2tcpip.h>
1036#endif
1037]
1038
1039AHX_CONFIG_FORMAT_ATTRIBUTE
1040AHX_CONFIG_UNUSED_ATTRIBUTE
1041AHX_CONFIG_FSEEKO
1042AHX_CONFIG_MAXHOSTNAMELEN
1043AHX_CONFIG_SNPRINTF(unbound)
1044AHX_CONFIG_INET_PTON(unbound)
1045AHX_CONFIG_INET_NTOP(unbound)
1046AHX_CONFIG_INET_ATON(unbound)
1047AHX_CONFIG_MEMMOVE(unbound)
1048AHX_CONFIG_STRLCPY(unbound)
1049AHX_CONFIG_GMTIME_R(unbound)
1050AHX_CONFIG_W32_SLEEP
1051AHX_CONFIG_W32_USLEEP
1052AHX_CONFIG_W32_RANDOM
1053AHX_CONFIG_W32_SRANDOM
1054AHX_CONFIG_W32_FD_SET_T
1055AHX_CONFIG_IPV6_MIN_MTU
1056AHX_MEMCMP_BROKEN(unbound)
1057
1058[
1059#ifndef HAVE_CTIME_R
1060#define ctime_r unbound_ctime_r
1061char *ctime_r(const time_t *timep, char *buf);
1062#endif
1063
1064#if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
1065#define strptime unbound_strptime
1066struct tm;
1067char *strptime(const char *s, const char *format, struct tm *tm);
1068#endif
1069
1070#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))
1071   /* using version of libevent that is not threadsafe. */
1072#  define LIBEVENT_SIGNAL_PROBLEM 1
1073#endif
1074
1075#ifndef CHECKED_INET6
1076#  define CHECKED_INET6
1077#  ifdef AF_INET6
1078#    define INET6
1079#  else
1080#    define AF_INET6        28
1081#  endif
1082#endif /* CHECKED_INET6 */
1083
1084/* maximum nesting of included files */
1085#define MAXINCLUDES 10
1086#ifndef HAVE_GETADDRINFO
1087struct sockaddr_storage;
1088#include "compat/fake-rfc2553.h"
1089#endif
1090
1091#ifdef UNBOUND_ALLOC_STATS
1092#  define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__)
1093#  define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__)
1094#  define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__)
1095#  define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__)
1096void *unbound_stat_malloc(size_t size);
1097void *unbound_stat_calloc(size_t nmemb, size_t size);
1098void unbound_stat_free(void *ptr);
1099void *unbound_stat_realloc(void *ptr, size_t size);
1100void *unbound_stat_malloc_log(size_t size, const char* file, int line,
1101	const char* func);
1102void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file,
1103	int line, const char* func);
1104void unbound_stat_free_log(void *ptr, const char* file, int line,
1105	const char* func);
1106void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file,
1107	int line, const char* func);
1108#elif defined(UNBOUND_ALLOC_LITE)
1109#  include "util/alloc.h"
1110#endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */
1111
1112/** default port for DNS traffic. */
1113#define UNBOUND_DNS_PORT 53
1114/** default port for unbound control traffic, registered port with IANA,
1115    ub-dns-control  8953/tcp    unbound dns nameserver control */
1116#define UNBOUND_CONTROL_PORT 8953
1117/** the version of unbound-control that this software implements */
1118#define UNBOUND_CONTROL_VERSION 1
1119
1120])
1121
1122AC_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])
1123AC_CONFIG_HEADER([config.h])
1124AC_OUTPUT
1125