1238106Sdes#                                               -*- Autoconf -*-
2238106Sdes# Process this file with autoconf to produce a configure script.
3238106SdesAC_PREREQ(2.56)
4238106Sdessinclude(acx_nlnetlabs.m4)
5238106Sdessinclude(acx_pthread.m4)
6238106Sdessinclude(acx_python.m4)
7238106Sdessinclude(ac_pkg_swig.m4)
8238106Sdes
9249141SdesAC_INIT(unbound, 1.4.20, unbound-bugs@nlnetlabs.nl, unbound)
10238106Sdes
11238106SdesLIBUNBOUND_CURRENT=3
12249141SdesLIBUNBOUND_REVISION=5
13238106SdesLIBUNBOUND_AGE=1
14238106Sdes# 1.0.0 had 0:12:0
15238106Sdes# 1.0.1 had 0:13:0
16238106Sdes# 1.0.2 had 0:14:0
17238106Sdes# 1.1.0 had 0:15:0
18238106Sdes# 1.1.1 had 0:16:0
19238106Sdes# 1.2.0 had 0:17:0
20238106Sdes# 1.2.1 had 0:18:0
21238106Sdes# 1.3.0 had 1:0:0   # ub_cancel and -export-symbols.
22238106Sdes# 1.3.1 had 1:1:0
23238106Sdes# 1.3.2 had 1:2:0
24238106Sdes# 1.3.3 had 1:3:0
25238106Sdes# 1.3.4 had 1:4:0
26238106Sdes# 1.4.0-snapshots had 1:5:0
27238106Sdes# 1.4.0 had 1:5:0 (not 2:0:0)   # ub_result.why_bogus
28238106Sdes# 1.4.1 had 2:1:0
29238106Sdes# 1.4.2 had 2:2:0
30238106Sdes# 1.4.3 had 2:3:0
31238106Sdes# 1.4.4 had 2:4:0
32238106Sdes# 1.4.5 had 2:5:0
33238106Sdes# 1.4.6 had 2:6:0
34238106Sdes# 1.4.7 had 2:7:0
35238106Sdes# 1.4.8 had 2:8:0
36238106Sdes# 1.4.9 had 2:9:0
37238106Sdes# 1.4.10 had 2:10:0
38238106Sdes# 1.4.11 had 2:11:0
39238106Sdes# 1.4.12 had 2:12:0
40238106Sdes# 1.4.13 had 2:13:0
41238106Sdes# and 1.4.13p1 and 1.4.13.p2
42238106Sdes# 1.4.14 had 2:14:0
43238106Sdes# 1.4.15 had 3:0:1 # adds ub_version()
44238106Sdes# 1.4.16 had 3:1:1
45238106Sdes# 1.4.17 had 3:2:1
46249141Sdes# 1.4.18 had 3:3:1
47249141Sdes# 1.4.19 had 3:4:1
48249141Sdes# 1.4.20 had 4:0:2 # adds libunbound.ttl
49238106Sdes
50238106Sdes#   Current  -- the number of the binary API that we're implementing
51238106Sdes#   Revision -- which iteration of the implementation of the binary
52238106Sdes#               API are we supplying?
53238106Sdes#   Age      -- How many previous binary API versions do we also
54238106Sdes#               support?
55238106Sdes#
56238106Sdes# If we release a new version that does not change the binary API,
57238106Sdes# increment Revision.
58238106Sdes#
59238106Sdes# If we release a new version that changes the binary API, but does
60238106Sdes# not break programs compiled against the old binary API, increment
61238106Sdes# Current and Age.  Set Revision to 0, since this is the first
62238106Sdes# implementation of the new API.
63238106Sdes#
64238106Sdes# Otherwise, we're changing the binary API and breaking bakward
65238106Sdes# compatibility with old binaries.  Increment Current.  Set Age to 0,
66238106Sdes# since we're backward compatible with no previous APIs.  Set Revision
67238106Sdes# to 0 too.
68238106SdesAC_SUBST(LIBUNBOUND_CURRENT)
69238106SdesAC_SUBST(LIBUNBOUND_REVISION)
70238106SdesAC_SUBST(LIBUNBOUND_AGE)
71238106Sdes
72238106SdesCFLAGS="$CFLAGS"
73238106SdesAC_AIX
74238106Sdes
75238106Sdesdnl
76238106Sdesdnl By default set prefix to /usr/local
77238106Sdesdnl
78238106Sdescase "$prefix" in
79238106Sdes        NONE)
80238106Sdes		prefix="/usr/local"
81238106Sdes        ;;
82238106Sdesesac
83238106Sdes
84238106Sdes# are we on MinGW?
85238106Sdesif uname -s 2>&1 | grep MINGW32 >/dev/null; then on_mingw="yes"
86238106Sdeselse 
87238106Sdes	if echo $target | grep mingw32 >/dev/null; then on_mingw="yes"
88238106Sdes	else on_mingw="no"; fi
89238106Sdesfi
90238106Sdes
91238106Sdes#
92238106Sdes# Determine configuration file
93238106Sdes# the eval is to evaluate shell expansion twice
94238106Sdesif test $on_mingw = "no"; then
95238106Sdes  ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"`
96238106Sdeselse
97238106Sdes  ub_conf_file="C:\\Program Files\\Unbound\\service.conf"
98238106Sdesfi
99238106SdesAC_ARG_WITH([conf_file],
100238106Sdes        AC_HELP_STRING([--with-conf-file=path], 
101238106Sdes	[Pathname to the Unbound configuration file]),
102238106Sdes	[ub_conf_file="$withval"])
103238106SdesAC_SUBST(ub_conf_file)
104238106SdesACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config)
105238106SdesAC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file])
106238106Sdes
107238106Sdes# Determine run, chroot directory and pidfile locations
108238106SdesAC_ARG_WITH(run-dir, 
109238106Sdes    AC_HELP_STRING([--with-run-dir=path], 
110238106Sdes    [set default directory to chdir to (by default dir part of cfg file)]), 
111238106Sdes    UNBOUND_RUN_DIR="$withval", 
112238106Sdesif test $on_mingw = no; then
113238106Sdes    UNBOUND_RUN_DIR=`dirname "$ub_conf_file"`
114238106Sdeselse
115238106Sdes    UNBOUND_RUN_DIR=""
116238106Sdesfi
117238106Sdes)
118238106SdesAC_SUBST(UNBOUND_RUN_DIR)
119238106SdesACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run)
120238106SdesAC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to])
121238106Sdes
122238106SdesAC_ARG_WITH(chroot-dir, 
123238106Sdes    AC_HELP_STRING([--with-chroot-dir=path], 
124238106Sdes    [set default directory to chroot to (by default same as run-dir)]), 
125238106Sdes    UNBOUND_CHROOT_DIR="$withval", 
126238106Sdesif test $on_mingw = no; then
127238106Sdes    UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR"
128238106Sdeselse
129238106Sdes    UNBOUND_CHROOT_DIR=""
130238106Sdesfi
131238106Sdes)
132238106SdesAC_SUBST(UNBOUND_CHROOT_DIR)
133238106SdesACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot)
134238106SdesAC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to])
135238106Sdes
136238106SdesAC_ARG_WITH(share-dir,
137238106Sdes    AC_HELP_STRING([--with-share-dir=path],
138238106Sdes    [set default directory with shared data (by default same as share/unbound)]),
139238106Sdes    UNBOUND_SHARE_DIR="$withval",
140238106Sdes    UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR")
141238106SdesAC_SUBST(UNBOUND_SHARE_DIR)
142238106SdesAC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data])
143238106Sdes
144238106SdesAC_ARG_WITH(pidfile, 
145238106Sdes    AC_HELP_STRING([--with-pidfile=filename], 
146238106Sdes    [set default pathname to unbound pidfile (default run-dir/unbound.pid)]), 
147238106Sdes    UNBOUND_PIDFILE="$withval", 
148238106Sdesif test $on_mingw = no; then
149238106Sdes    UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid"
150238106Sdeselse
151238106Sdes    UNBOUND_PIDFILE=""
152238106Sdesfi
153238106Sdes)
154238106SdesAC_SUBST(UNBOUND_PIDFILE)
155238106SdesACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid)
156238106SdesAC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location])
157238106Sdes
158238106SdesAC_ARG_WITH(rootkey-file, 
159238106Sdes    AC_HELP_STRING([--with-rootkey-file=filename], 
160238106Sdes    [set default pathname to root key file (default run-dir/root.key). This file is read and written.]), 
161238106Sdes    UNBOUND_ROOTKEY_FILE="$withval", 
162238106Sdesif test $on_mingw = no; then
163238106Sdes    UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key"
164238106Sdeselse
165238106Sdes    UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key"
166238106Sdesfi
167238106Sdes)
168238106SdesAC_SUBST(UNBOUND_ROOTKEY_FILE)
169238106SdesACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey)
170238106SdesAC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location])
171238106Sdes
172238106SdesAC_ARG_WITH(rootcert-file, 
173238106Sdes    AC_HELP_STRING([--with-rootcert-file=filename], 
174238106Sdes    [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.]), 
175238106Sdes    UNBOUND_ROOTCERT_FILE="$withval", 
176238106Sdesif test $on_mingw = no; then
177238106Sdes    UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem"
178238106Sdeselse
179238106Sdes    UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem"
180238106Sdesfi
181238106Sdes)
182238106SdesAC_SUBST(UNBOUND_ROOTCERT_FILE)
183238106SdesACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem)
184238106SdesAC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location])
185238106Sdes
186238106SdesAC_ARG_WITH(username, 
187238106Sdes    AC_HELP_STRING([--with-username=user], 
188238106Sdes    [set default user that unbound changes to (default user is unbound)]), 
189238106Sdes    UNBOUND_USERNAME="$withval", 
190238106Sdes    UNBOUND_USERNAME="unbound")
191238106SdesAC_SUBST(UNBOUND_USERNAME)
192238106SdesAC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username])
193238106Sdes
194238106SdesAC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
195238106SdesACX_RSRC_VERSION(wnvs)
196238106SdesAC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files])
197238106Sdes
198238106Sdes# Checks for typedefs, structures, and compiler characteristics.
199238106SdesAC_C_CONST
200238106SdesAC_LANG_C
201249141Sdes# allow user to override the -g -O2 flags.
202249141Sdesif test "x$CFLAGS" = "x" ; then
203238106SdesACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"])
204238106SdesACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"])
205249141Sdesfi
206238106SdesAC_PROG_CC
207238106SdesACX_DEPFLAG
208238106SdesACX_DETERMINE_EXT_FLAGS_UNBOUND
209238106Sdes
210238106Sdes# debug mode flags warnings
211238106SdesAC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable warnings, asserts, makefile-dependencies]))
212238106SdesAC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [same as enable-checking]))
213238106Sdesif test "$enable_debug" = "yes"; then debug_enabled="$enable_debug"; 
214238106Sdeselse debug_enabled="$enable_checking"; fi
215238106SdesAC_SUBST(debug_enabled)
216238106Sdescase "$debug_enabled" in
217238106Sdes        yes)
218238106Sdes		ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"])
219238106Sdes		ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"])
220238106Sdes		ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"])
221238106Sdes		ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
222238106Sdes		AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.])
223238106Sdes		;;
224238106Sdes	no|*)
225238106Sdes		# nothing to do.
226238106Sdes		;;
227238106Sdesesac
228238106SdesACX_CHECK_FLTO
229238106Sdes
230238106SdesAC_C_INLINE
231238106SdesACX_CHECK_FORMAT_ATTRIBUTE
232238106SdesACX_CHECK_UNUSED_ATTRIBUTE
233238106Sdes
234238106Sdesif test "$srcdir" != "."; then
235238106Sdes	CPPFLAGS="$CPPFLAGS -I$srcdir"
236238106Sdesfi
237238106Sdes
238238106SdesAC_DEFUN([ACX_YYLEX_DESTROY], [
239238106Sdes	AC_MSG_CHECKING([for yylex_destroy])
240238106Sdes	if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then
241238106Sdes		AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy])
242238106Sdes		AC_MSG_RESULT(yes)
243238106Sdes	else AC_MSG_RESULT(no); fi
244238106Sdes])
245238106Sdes
246238106SdesAC_PROG_LEX
247238106SdesACX_YYLEX_DESTROY
248238106SdesAC_PROG_YACC
249238106SdesAC_CHECK_PROG(doxygen, doxygen, doxygen)
250238106SdesAC_CHECK_TOOL(STRIP, strip)
251238106SdesACX_LIBTOOL_C_ONLY
252238106Sdes
253238106Sdes# Checks for header files.
254238106SdesAC_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])
255238106Sdes
256238106Sdes# check for types.  
257238106Sdes# Using own tests for int64* because autoconf builtin only give 32bit.
258238106SdesAC_CHECK_TYPE(int8_t, signed char)
259238106SdesAC_CHECK_TYPE(int16_t, short)
260238106SdesAC_CHECK_TYPE(int32_t, int)
261238106SdesAC_CHECK_TYPE(int64_t, long long)
262238106SdesAC_CHECK_TYPE(uint8_t, unsigned char)
263238106SdesAC_CHECK_TYPE(uint16_t, unsigned short)
264238106SdesAC_CHECK_TYPE(uint32_t, unsigned int)
265238106SdesAC_CHECK_TYPE(uint64_t, unsigned long long)
266238106SdesAC_TYPE_SIZE_T
267238106SdesAC_CHECK_TYPE(ssize_t, int)
268238106SdesAC_TYPE_UID_T
269238106SdesAC_TYPE_PID_T
270238106SdesAC_TYPE_OFF_T
271238106SdesACX_TYPE_U_CHAR
272238106SdesACX_TYPE_RLIM_T
273238106SdesACX_TYPE_SOCKLEN_T
274238106SdesACX_TYPE_IN_ADDR_T
275238106SdesACX_TYPE_IN_PORT_T
276238106SdesACX_CHECK_MEMCMP_SIGNED
277238106Sdes
278238106Sdes# add option to disable the evil rpath
279238106SdesACX_ARG_RPATH
280238106SdesAC_SUBST(RUNTIME_PATH)
281238106Sdes
282238106Sdes# check to see if libraries are needed for these functions.
283238106SdesAC_SEARCH_LIBS([inet_pton], [nsl])
284238106SdesAC_SEARCH_LIBS([socket], [socket])
285238106Sdes
286238106Sdes# check wether strptime also works
287238106SdesAC_DEFUN([AC_CHECK_STRPTIME_WORKS],
288238106Sdes[AC_REQUIRE([AC_PROG_CC])
289238106SdesAC_MSG_CHECKING(whether strptime works)
290238106Sdesif test c${cross_compiling} = cno; then
291238106SdesAC_RUN_IFELSE([AC_LANG_SOURCE([[
292238106Sdes#define _XOPEN_SOURCE
293238106Sdes#include <time.h>
294238106Sdesint main(void) { struct tm tm; char *res;
295238106Sdesres = 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);
296238106Sdesif (!res) return 2;
297238106Sdesres = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
298238106Sdesif (!res) return 1; return 0; }
299238106Sdes]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"])
300238106Sdeselse
301238106Sdeseval "ac_cv_c_strptime_works=maybe"
302238106Sdesfi
303238106SdesAC_MSG_RESULT($ac_cv_c_strptime_works)
304238106Sdesif test $ac_cv_c_strptime_works = no; then
305238106SdesAC_LIBOBJ(strptime)
306238106Sdeselse
307238106SdesAC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.])
308238106Sdesfi
309238106Sdes])dnl
310238106Sdes
311238106Sdes# check some functions of the OS before linking libs (while still runnable).
312238106SdesAC_FUNC_CHOWN
313238106SdesAC_FUNC_FORK
314238106SdesAC_TYPE_SIGNAL
315238106SdesAC_FUNC_FSEEKO
316238106SdesACX_SYS_LARGEFILE
317238106SdesACX_CHECK_NONBLOCKING_BROKEN
318238106SdesACX_MKDIR_ONE_ARG
319238106SdesAC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])])
320238106Sdes
321238106Sdes# set memory allocation checking if requested
322238106SdesAC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks],
323238106Sdes	[ enable to memory allocation statistics, for debug purposes ]), 
324238106Sdes	, )
325238106SdesAC_ARG_ENABLE(alloc-lite, AC_HELP_STRING([--enable-alloc-lite],
326238106Sdes	[ enable for lightweight alloc assertions, for debug purposes ]), 
327238106Sdes	, )
328238106SdesAC_ARG_ENABLE(alloc-nonregional, AC_HELP_STRING([--enable-alloc-nonregional],
329238106Sdes	[ enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes ]), 
330238106Sdes	, )
331238106Sdesif test x_$enable_alloc_nonregional = x_yes; then
332238106Sdes	AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use])
333238106Sdesfi
334238106Sdesif test x_$enable_alloc_checks = x_yes; then
335238106Sdes	AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use])
336238106Sdeselse
337238106Sdes	if test x_$enable_alloc_lite = x_yes; then
338238106Sdes		AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use])
339238106Sdes	else
340238106Sdes		ACX_FUNC_MALLOC([unbound])
341238106Sdes	fi
342238106Sdesfi
343238106Sdes
344238106Sdes# check windows threads (we use them, not pthreads, on windows).
345238106Sdesif test "$on_mingw" = "yes"; then
346238106Sdes# check windows threads
347238106Sdes	AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT])
348238106Sdes	AC_MSG_CHECKING([for CreateThread])
349238106Sdes	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
350238106Sdes#ifdef HAVE_WINDOWS_H
351238106Sdes#include <windows.h>
352238106Sdes#endif
353238106Sdes], [
354238106Sdes	HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL);
355238106Sdes])],
356238106Sdes	AC_MSG_RESULT(yes)
357238106Sdes	AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads])
358238106Sdes,	
359238106Sdes	AC_MSG_RESULT(no)
360238106Sdes)
361238106Sdes
362238106Sdeselse
363238106Sdes# not on mingw, check thread libraries.
364238106Sdes
365238106Sdes# check for thread library.
366238106Sdes# check this first, so that the pthread lib does not get linked in via
367238106Sdes# libssl or libpython, and thus distorts the tests, and we end up using
368238106Sdes# the non-threadsafe C libraries.
369238106SdesAC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads], 
370238106Sdes [use pthreads library, or --without-pthreads to disable threading support.]), 
371238106Sdes [ ],[ withval="yes" ])
372238106Sdesub_have_pthreads=no
373238106Sdesif test x_$withval != x_no; then
374238106Sdes	ACX_PTHREAD([
375238106Sdes		AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
376238106Sdes		LIBS="$PTHREAD_LIBS $LIBS"
377238106Sdes		CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
378238106Sdes		CC="$PTHREAD_CC"
379238106Sdes		ub_have_pthreads=yes
380238106Sdes		AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>])
381238106Sdes		])
382238106Sdesfi
383238106Sdes
384238106Sdes# check solaris thread library 
385238106SdesAC_ARG_WITH(solaris-threads, AC_HELP_STRING([--with-solaris-threads], 
386238106Sdes	[use solaris native thread library.]), [ ],[ withval="no" ])
387238106Sdesub_have_sol_threads=no
388238106Sdesif test x_$withval != x_no; then
389238106Sdes	if test x_$ub_have_pthreads != x_no; then
390238106Sdes	    AC_WARN([Have pthreads already, ignoring --with-solaris-threads])
391238106Sdes	else
392238106Sdes	AC_SEARCH_LIBS(thr_create, [thread],
393238106Sdes	[
394238106Sdes    		AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads])
395238106Sdes
396238106Sdes		ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"],
397238106Sdes			[CFLAGS="$CFLAGS -D_REENTRANT"])
398238106Sdes		ub_have_sol_threads=yes
399238106Sdes	] , [ 
400238106Sdes		AC_ERROR([no solaris threads found.]) 
401238106Sdes	])
402238106Sdes	fi
403238106Sdesfi
404238106Sdes
405238106Sdesfi # end of non-mingw check of thread libraries
406238106Sdes
407238106Sdes# Check for PyUnbound
408238106SdesAC_ARG_WITH(pyunbound,
409238106Sdes   AC_HELP_STRING([--with-pyunbound],
410238106Sdes   [build PyUnbound, or --without-pyunbound to skip it. (default=no)]),
411238106Sdes   [], [ withval="no" ])
412238106Sdes
413238106Sdesub_test_python=no
414238106Sdesub_with_pyunbound=no
415238106Sdesif test x_$withval != x_no; then
416238106Sdes   ub_with_pyunbound=yes
417238106Sdes   ub_test_python=yes
418238106Sdesfi
419238106Sdes
420238106Sdes# Check for Python module
421238106SdesAC_ARG_WITH(pythonmodule,
422238106Sdes   AC_HELP_STRING([--with-pythonmodule],
423238106Sdes   [build Python module, or --without-pythonmodule to disable script engine. (default=no)]),
424238106Sdes   [], [ withval="no" ])
425238106Sdes
426238106Sdesub_with_pythonmod=no
427238106Sdesif test x_$withval != x_no; then
428238106Sdes   ub_with_pythonmod=yes
429238106Sdes   ub_test_python=yes
430238106Sdesfi
431238106Sdes
432238106Sdes# Check for Python & SWIG only on PyUnbound or PyModule
433238106Sdesif test x_$ub_test_python != x_no; then
434238106Sdes
435238106Sdes   # Check for Python
436238106Sdes   ub_have_python=no
437238106Sdes   ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
438238106Sdes   AC_PYTHON_DEVEL
439238106Sdes   if test ! -z "$PYTHON_VERSION"; then
440238106Sdes	if test `$PYTHON -c "print '$PYTHON_VERSION' >= '2.4.0'"` = "False"; then
441238106Sdes		AC_ERROR([Python version >= 2.4.0 is required])
442238106Sdes	fi
443238106Sdes
444238106Sdes      # Have Python
445238106Sdes      AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
446238106Sdes      LIBS="$PYTHON_LDFLAGS $LIBS"
447238106Sdes      CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
448238106Sdes      ub_have_python=yes
449238106Sdes
450238106Sdes      # Check for SWIG
451238106Sdes      ub_have_swig=no
452238106Sdes      AC_PROG_SWIG
453238106Sdes      AC_MSG_CHECKING(SWIG)
454238106Sdes      if test ! -x "$SWIG"; then
455238106Sdes         AC_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound])
456238106Sdes      else
457238106Sdes         AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.])
458238106Sdes         AC_SUBST(swig, "$SWIG")
459238106Sdes         AC_MSG_RESULT(present)
460238106Sdes
461238106Sdes         # If have Python & SWIG
462238106Sdes         # Declare PythonMod
463238106Sdes         if test x_$ub_with_pythonmod != x_no; then
464238106Sdes            AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.])
465238106Sdes            WITH_PYTHONMODULE=yes
466238106Sdes            AC_SUBST(WITH_PYTHONMODULE)
467238106Sdes	    PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo"
468238106Sdes	    AC_SUBST(PYTHONMOD_OBJ)
469238106Sdes	    PYTHONMOD_HEADER='$(srcdir)/pythonmod/pythonmod.h'
470238106Sdes	    AC_SUBST(PYTHONMOD_HEADER)
471238106Sdes	    PYTHONMOD_INSTALL=pythonmod-install
472238106Sdes	    AC_SUBST(PYTHONMOD_INSTALL)
473238106Sdes	    PYTHONMOD_UNINSTALL=pythonmod-uninstall
474238106Sdes	    AC_SUBST(PYTHONMOD_UNINSTALL)
475238106Sdes         fi
476238106Sdes
477238106Sdes         # Declare PyUnbound
478238106Sdes         if test x_$ub_with_pyunbound != x_no; then
479238106Sdes            AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.])
480238106Sdes            WITH_PYUNBOUND=yes
481238106Sdes            AC_SUBST(WITH_PYUNBOUND)
482238106Sdes	    PYUNBOUND_OBJ="libunbound_wrap.lo"
483238106Sdes	    AC_SUBST(PYUNBOUND_OBJ)
484238106Sdes	    PYUNBOUND_TARGET="_unbound.la"
485238106Sdes	    AC_SUBST(PYUNBOUND_TARGET)
486238106Sdes	    PYUNBOUND_INSTALL=pyunbound-install
487238106Sdes	    AC_SUBST(PYUNBOUND_INSTALL)
488238106Sdes	    PYUNBOUND_UNINSTALL=pyunbound-uninstall
489238106Sdes	    AC_SUBST(PYUNBOUND_UNINSTALL)
490238106Sdes         fi
491238106Sdes      fi
492238106Sdes   else
493238106Sdes      AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***])
494238106Sdes      ub_with_pyunbound=no
495238106Sdes      ub_with_pythonmod=no
496238106Sdes   fi
497238106Sdesfi
498238106Sdes
499238106Sdesif test "`uname`" = "NetBSD"; then
500238106Sdes	NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_'
501238106Sdes	AC_SUBST(NETBSD_LINTFLAGS)
502238106Sdesfi
503238106SdesCONFIG_DATE=`date +%Y%m%d`
504238106SdesAC_SUBST(CONFIG_DATE)
505238106Sdes
506238106Sdes# Checks for libraries.
507249141Sdes
508249141Sdes# libnss
509249141SdesUSE_NSS="no"
510249141SdesAC_ARG_WITH([nss], AC_HELP_STRING([--with-nss=path],
511249141Sdes	[use libnss instead of openssl, installed at path.]),
512249141Sdes	[
513249141Sdes	USE_NSS="yes"
514249141Sdes	AC_DEFINE(HAVE_NSS, 1, [Use libnss for crypto])
515249141Sdes	if test "$withval" != "" -a "$withval" != "yes"; then
516249141Sdes		CPPFLAGS="$CPPFLAGS -I$withval/include/nss3"
517249141Sdes		LDFLAGS="$LDFLAGS -L$withval/lib"
518249141Sdes		ACX_RUNTIME_PATH_ADD([$withval/lib])
519249141Sdes		CPPFLAGS="-I$withval/include/nspr4 $CPPFLAGS"
520249141Sdes	else
521249141Sdes		CPPFLAGS="$CPPFLAGS -I/usr/include/nss3"
522249141Sdes		CPPFLAGS="-I/usr/include/nspr4 $CPPFLAGS"
523249141Sdes	fi
524249141Sdes        LIBS="$LIBS -lnss3 -lnspr4"
525249141Sdes	]
526249141Sdes)
527249141Sdes
528249141Sdes# openssl
529249141Sdesif test $USE_NSS = "no"; then
530238106SdesACX_WITH_SSL
531238106SdesACX_LIB_SSL
532238106SdesAC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT])
533238106SdesAC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT])
534249141SdesAC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512 FIPS_mode])
535238106SdesAC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free], [], [], [
536238106SdesAC_INCLUDES_DEFAULT
537238106Sdes#ifdef HAVE_OPENSSL_ERR_H
538238106Sdes#include <openssl/err.h>
539238106Sdes#endif
540238106Sdes
541238106Sdes#ifdef HAVE_OPENSSL_RAND_H
542238106Sdes#include <openssl/rand.h>
543238106Sdes#endif
544238106Sdes
545238106Sdes#ifdef HAVE_OPENSSL_CONF_H
546238106Sdes#include <openssl/conf.h>
547238106Sdes#endif
548238106Sdes
549238106Sdes#ifdef HAVE_OPENSSL_ENGINE_H
550238106Sdes#include <openssl/engine.h>
551238106Sdes#endif
552238106Sdes#include <openssl/ssl.h>
553238106Sdes#include <openssl/evp.h>
554238106Sdes])
555249141Sdesfi
556238106Sdes
557249141Sdes
558238106SdesAC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
559238106Sdescase "$enable_sha2" in
560238106Sdes	no)
561238106Sdes	;;
562238106Sdes	yes|*)
563238106Sdes	AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
564238106Sdes	;;
565238106Sdesesac
566238106Sdes
567238106Sdes# check wether gost also works
568238106SdesAC_DEFUN([AC_CHECK_GOST_WORKS],
569238106Sdes[AC_REQUIRE([AC_PROG_CC])
570238106SdesAC_MSG_CHECKING([if GOST works])
571238106Sdesif test c${cross_compiling} = cno; then
572238106SdesBAKCFLAGS="$CFLAGS"
573238106Sdesif test -n "$ssldir"; then
574238106Sdes	CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib"
575238106Sdesfi
576238106SdesAC_RUN_IFELSE([AC_LANG_SOURCE([[
577238106Sdes#include <string.h>
578238106Sdes#include <openssl/ssl.h>
579238106Sdes#include <openssl/evp.h>
580238106Sdes#include <openssl/engine.h>
581238106Sdes#include <openssl/conf.h>
582238106Sdes/* routine to load gost from ldns */
583238106Sdesint load_gost_id(void)
584238106Sdes{
585238106Sdes	static int gost_id = 0;
586238106Sdes	const EVP_PKEY_ASN1_METHOD* meth;
587238106Sdes	ENGINE* e;
588238106Sdes
589238106Sdes	if(gost_id) return gost_id;
590238106Sdes
591238106Sdes	/* see if configuration loaded gost implementation from other engine*/
592238106Sdes	meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
593238106Sdes	if(meth) {
594238106Sdes		EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
595238106Sdes		return gost_id;
596238106Sdes	}
597238106Sdes
598238106Sdes	/* see if engine can be loaded already */
599238106Sdes	e = ENGINE_by_id("gost");
600238106Sdes	if(!e) {
601238106Sdes		/* load it ourself, in case statically linked */
602238106Sdes		ENGINE_load_builtin_engines();
603238106Sdes		ENGINE_load_dynamic();
604238106Sdes		e = ENGINE_by_id("gost");
605238106Sdes	}
606238106Sdes	if(!e) {
607238106Sdes		/* no gost engine in openssl */
608238106Sdes		return 0;
609238106Sdes	}
610238106Sdes	if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
611238106Sdes		ENGINE_finish(e);
612238106Sdes		ENGINE_free(e);
613238106Sdes		return 0;
614238106Sdes	}
615238106Sdes
616238106Sdes	meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
617238106Sdes	if(!meth) {
618238106Sdes		/* algo not found */
619238106Sdes		ENGINE_finish(e);
620238106Sdes		ENGINE_free(e);
621238106Sdes		return 0;
622238106Sdes	}
623238106Sdes	EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
624238106Sdes	return gost_id;
625238106Sdes}
626238106Sdesint main(void) { 
627238106Sdes	EVP_MD_CTX* ctx;
628238106Sdes	const EVP_MD* md;
629238106Sdes	unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */
630238106Sdes	const char* str = "Hello world";
631238106Sdes	const unsigned char check[] = {
632238106Sdes		0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 ,
633238106Sdes		0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 ,
634238106Sdes		0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d ,
635238106Sdes		0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d
636238106Sdes	};
637238106Sdes	OPENSSL_config(NULL);
638238106Sdes	(void)load_gost_id();
639238106Sdes	md = EVP_get_digestbyname("md_gost94");
640238106Sdes	if(!md) return 1;
641238106Sdes	memset(digest, 0, sizeof(digest));
642238106Sdes	ctx = EVP_MD_CTX_create();
643238106Sdes	if(!ctx) return 2;
644238106Sdes	if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3;
645238106Sdes	if(!EVP_DigestUpdate(ctx, str, 10)) return 4;
646238106Sdes	if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5;
647238106Sdes	/* uncomment to see the hash calculated.
648238106Sdes		{int i;
649238106Sdes		for(i=0; i<32; i++)
650238106Sdes			printf(" %2.2x", (int)digest[i]);
651238106Sdes		printf("\n");}
652238106Sdes	*/
653238106Sdes	if(memcmp(digest, check, sizeof(check)) != 0)
654238106Sdes		return 6;
655238106Sdes	return 0;
656238106Sdes}
657238106Sdes]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"])
658238106SdesCFLAGS="$BAKCFLAGS"
659238106Sdeselse
660238106Sdeseval "ac_cv_c_gost_works=maybe"
661238106Sdesfi
662238106SdesAC_MSG_RESULT($ac_cv_c_gost_works)
663238106Sdes])dnl
664238106Sdes
665238106SdesAC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
666238106Sdesuse_gost="no"
667249141Sdesif test $USE_NSS = "no"; then
668238106Sdescase "$enable_gost" in
669238106Sdes	no)
670238106Sdes	;;
671238106Sdes	*)
672238106Sdes	AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])])
673249141Sdes	AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])])
674238106Sdes	AC_CHECK_GOST_WORKS
675249141Sdes	if test "$ac_cv_c_gost_works" != no; then
676238106Sdes		use_gost="yes"
677238106Sdes		AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
678238106Sdes	fi
679238106Sdes	;;
680238106Sdesesac
681249141Sdesfi dnl !USE_NSS
682238106Sdes
683238106SdesAC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
684238106Sdesuse_ecdsa="no"
685238106Sdescase "$enable_ecdsa" in
686238106Sdes    no)
687238106Sdes      ;;
688238106Sdes    *)
689249141Sdes      if test $USE_NSS = "no"; then
690249141Sdes	      AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])])
691249141Sdes	      AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])])
692249141Sdes	      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
693238106Sdes#include <openssl/evp.h>
694249141Sdes	      ])
695249141Sdes	      # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency)
696249141Sdes	      AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP])
697249141Sdes	      if grep OPENSSL_VERSION_NUMBER $ssldir/include/openssl/opensslv.h | grep 0x0 >/dev/null; then
698249141Sdes		AC_MSG_RESULT([no])
699249141Sdes		AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl])
700249141Sdes	      else
701249141Sdes		AC_MSG_RESULT([yes])
702249141Sdes	      fi
703238106Sdes      fi
704238106Sdes      # we now know we have ECDSA and the required curves.
705238106Sdes      AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
706238106Sdes      use_ecdsa="yes"
707238106Sdes      ;;
708238106Sdesesac
709238106Sdes
710238106Sdes# check for libevent
711238106SdesAC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname],
712238106Sdes    [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.]),
713238106Sdes    [ ],[ withval="no" ])
714238106Sdesif test x_$withval = x_yes -o x_$withval != x_no; then
715238106Sdes        AC_MSG_CHECKING(for libevent)
716238106Sdes        if test x_$withval = x_ -o x_$withval = x_yes; then
717238106Sdes            withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
718238106Sdes        fi
719238106Sdes        for dir in $withval; do
720238106Sdes            thedir="$dir"
721238106Sdes            if test -f "$dir/include/event.h"; then
722238106Sdes                found_libevent="yes"
723238106Sdes		dnl assume /usr is in default path.
724238106Sdes		if test "$thedir" != "/usr"; then
725238106Sdes                    CPPFLAGS="$CPPFLAGS -I$thedir/include"
726238106Sdes		fi
727238106Sdes                break;
728238106Sdes            fi
729238106Sdes        done
730238106Sdes        if test x_$found_libevent != x_yes; then
731238106Sdes		if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
732238106Sdes			# libevent source directory
733238106Sdes            		AC_MSG_RESULT(found in $thedir)
734238106Sdes                	CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include"
735238106Sdes			BAK_LDFLAGS_SET="1"
736238106Sdes			BAK_LDFLAGS="$LDFLAGS"
737238106Sdes			# remove evdns from linking
738238106Sdes			mkdir build >/dev/null 2>&1
739238106Sdes			mkdir build/libevent >/dev/null 2>&1
740238106Sdes			mkdir build/libevent/.libs >/dev/null 2>&1
741238106Sdes			ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
742238106Sdes			ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo`
743238106Sdes			ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
744238106Sdes			cp $ev_files_o build/libevent
745238106Sdes			cp $ev_files_lo build/libevent
746238106Sdes			cp $ev_files_libso build/libevent/.libs
747238106Sdes            		LATE_LDFLAGS="build/libevent/*.lo -lm"
748238106Sdes			LDFLAGS="build/libevent/*.o $LDFLAGS -lm"
749238106Sdes		else
750238106Sdes            		AC_MSG_ERROR([Cannot find the libevent library in $withval
751238106SdesYou can restart ./configure --with-libevent=no to use a builtin alternative.
752238106SdesPlease note that this alternative is not as capable as libevent when using
753238106Sdeslarge outgoing port ranges.  ])
754238106Sdes		fi
755238106Sdes        else
756238106Sdes            AC_MSG_RESULT(found in $thedir)
757238106Sdes	    dnl assume /usr is in default path, do not add "".
758238106Sdes	    if test "$thedir" != "/usr" -a "$thedir" != ""; then
759238106Sdes                LDFLAGS="$LDFLAGS -L$thedir/lib"
760238106Sdes		ACX_RUNTIME_PATH_ADD([$thedir/lib])
761238106Sdes	    fi
762238106Sdes        fi
763238106Sdes	# check for library used by libevent after 1.3c
764238106Sdes	AC_SEARCH_LIBS([clock_gettime], [rt])
765238106Sdes
766238106Sdes	# is the event.h header libev or libevent?
767238106Sdes	AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT])
768238106Sdes	AC_CHECK_DECL(EV_VERSION_MAJOR, [
769238106Sdes		AC_SEARCH_LIBS(event_set, [ev])
770238106Sdes	],[
771238106Sdes		AC_SEARCH_LIBS(event_set, [event])
772238106Sdes	],[AC_INCLUDES_DEFAULT
773238106Sdes#include <event.h>
774238106Sdes	])
775238106Sdes	AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later
776238106Sdes	AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later
777238106Sdes	AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later
778238106Sdes	AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later
779238106Sdes	AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51)
780238106Sdes	AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00)
781238106Sdes	if test -n "$BAK_LDFLAGS_SET"; then
782238106Sdes		LDFLAGS="$BAK_LDFLAGS"
783238106Sdes	fi
784238106Sdeselse
785238106Sdes	AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
786238106Sdesfi
787238106Sdes
788238106Sdes# check for libexpat
789238106SdesAC_ARG_WITH(libexpat, AC_HELP_STRING([--with-libexpat=path],
790238106Sdes    [specify explicit path for libexpat.]),
791238106Sdes    [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ])
792238106SdesAC_MSG_CHECKING(for libexpat)
793238106Sdesfound_libexpat="no"
794238106Sdesfor dir in $withval ; do
795238106Sdes            if test -f "$dir/include/expat.h"; then
796238106Sdes		found_libexpat="yes"
797238106Sdes		dnl assume /usr is in default path.
798238106Sdes		if test "$dir" != "/usr"; then
799238106Sdes                    CPPFLAGS="$CPPFLAGS -I$dir/include"
800238106Sdes		    LDFLAGS="$LDFLAGS -L$dir/lib"
801238106Sdes		fi
802238106Sdes            	AC_MSG_RESULT(found in $dir)
803238106Sdes                break;
804238106Sdes            fi
805238106Sdesdone
806238106Sdesif test x_$found_libexpat != x_yes; then
807238106Sdes	AC_ERROR([Could not find libexpat, expat.h])
808238106Sdesfi
809238106SdesAC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT])
810238106Sdes
811238106Sdes# set static linking if requested
812238106SdesAC_SUBST(staticexe)
813238106Sdesstaticexe=""
814238106SdesAC_ARG_ENABLE(static-exe, AC_HELP_STRING([--enable-static-exe],
815238106Sdes	[ enable to compile executables statically against event, ldns libs, for debug purposes ]), 
816238106Sdes	, )
817238106Sdesif test x_$enable_static_exe = x_yes; then
818238106Sdes	staticexe="-static"
819238106Sdes	if test "$on_mingw" = yes; then
820238106Sdes		staticexe="-all-static"
821238106Sdes		# for static crosscompile, include gdi32 and zlib here.
822238106Sdes		if test "`uname`" = "Linux"; then
823238106Sdes			LIBS="$LIBS -lgdi32 -lz"
824238106Sdes		fi
825238106Sdes	fi
826238106Sdesfi
827238106Sdes
828238106Sdes# set lock checking if requested
829238106SdesAC_ARG_ENABLE(lock_checks, AC_HELP_STRING([--enable-lock-checks],
830238106Sdes	[ enable to check lock and unlock calls, for debug purposes ]), 
831238106Sdes	, )
832238106Sdesif test x_$enable_lock_checks = x_yes; then
833238106Sdes	AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).])
834238106Sdes	CHECKLOCK_OBJ="checklocks.lo"
835238106Sdes	AC_SUBST(CHECKLOCK_OBJ)
836238106Sdesfi
837238106Sdes
838238106SdesACX_CHECK_GETADDRINFO_WITH_INCLUDES
839238106Sdesif test "$USE_WINSOCK" = 1; then
840238106Sdes	AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API])
841238106Sdes	AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT
842238106Sdes#include <windows.h>
843238106Sdes	])
844238106Sdes	AC_CHECK_TOOL(WINDRES, windres)
845238106Sdes	LIBS="$LIBS -liphlpapi"
846238106Sdes	WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe"
847238106Sdes	AC_SUBST(WINAPPS)
848238106Sdes	WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c"
849238106Sdes	AC_SUBST(WIN_DAEMON_SRC)
850238106Sdes	WIN_DAEMON_OBJ="win_svc.lo w_inst.lo"
851238106Sdes	AC_SUBST(WIN_DAEMON_OBJ)
852238106Sdes	WIN_DAEMON_OBJ_LINK="rsrc_unbound.o"
853238106Sdes	AC_SUBST(WIN_DAEMON_OBJ_LINK)
854238106Sdes	WIN_HOST_OBJ_LINK="rsrc_unbound_host.o"
855238106Sdes	AC_SUBST(WIN_HOST_OBJ_LINK)
856238106Sdes	WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo"
857238106Sdes	AC_SUBST(WIN_UBANCHOR_OBJ_LINK)
858238106Sdes	WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o"
859238106Sdes	AC_SUBST(WIN_CONTROL_OBJ_LINK)
860238106Sdes	WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o"
861238106Sdes	AC_SUBST(WIN_CHECKCONF_OBJ_LINK)
862238106Sdesfi
863238106Sdesif test $ac_cv_func_getaddrinfo = no; then
864238106Sdes	AC_LIBOBJ([fake-rfc2553])
865238106Sdesfi
866238106Sdes# check after getaddrinfo for its libraries
867238106SdesACX_FUNC_IOCTLSOCKET
868238106Sdes
869238106Sdes# see if daemon(3) exists, and if it is deprecated.
870238106SdesAC_CHECK_FUNCS([daemon])
871238106Sdesif test $ac_cv_func_daemon = yes; then
872238106Sdes	ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [
873238106Sdes#include <stdlib.h>
874238106Sdes])
875238106Sdesfi
876238106Sdes
877238106SdesAC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[
878238106SdesAC_INCLUDES_DEFAULT
879238106Sdes#if HAVE_SYS_PARAM_H
880238106Sdes#include <sys/param.h>
881238106Sdes#endif
882238106Sdes
883238106Sdes#ifdef HAVE_SYS_SOCKET_H
884238106Sdes#include <sys/socket.h>
885238106Sdes#endif
886238106Sdes
887238106Sdes#ifdef HAVE_SYS_UIO_H
888238106Sdes#include <sys/uio.h>
889238106Sdes#endif
890238106Sdes
891238106Sdes#ifdef HAVE_NETINET_IN_H
892238106Sdes#include <netinet/in.h>
893238106Sdes#endif
894238106Sdes
895238106Sdes#ifdef HAVE_ARPA_INET_H
896238106Sdes#include <arpa/inet.h>
897238106Sdes#endif
898238106Sdes
899238106Sdes#ifdef HAVE_WINSOCK2_H
900238106Sdes#include <winsock2.h>
901238106Sdes#endif
902238106Sdes
903238106Sdes#ifdef HAVE_WS2TCPIP_H
904238106Sdes#include <ws2tcpip.h>
905238106Sdes#endif
906238106Sdes])
907238106SdesAC_SEARCH_LIBS([setusercontext], [util])
908238106SdesAC_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])
909238106SdesAC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
910238106SdesAC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
911238106Sdes
912238106Sdes# check if setreuid en setregid fail, on MacOSX10.4(darwin8).
913238106Sdesif echo $build_os | grep darwin8 > /dev/null; then
914238106Sdes	AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
915238106Sdesfi
916238106SdesAC_REPLACE_FUNCS(inet_aton)
917238106SdesAC_REPLACE_FUNCS(inet_pton)
918238106SdesAC_REPLACE_FUNCS(inet_ntop)
919238106SdesAC_REPLACE_FUNCS(snprintf)
920238106SdesAC_REPLACE_FUNCS(strlcpy)
921238106SdesAC_REPLACE_FUNCS(memmove)
922238106SdesAC_REPLACE_FUNCS(gmtime_r)
923238106SdesLIBOBJ_WITHOUT_CTIME="$LIBOBJS"
924238106SdesAC_SUBST(LIBOBJ_WITHOUT_CTIME)
925238106SdesAC_REPLACE_FUNCS(ctime_r)
926238106Sdes
927238106SdesAC_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]))
928238106Sdescase "$enable_allsymbols" in
929238106Sdes	yes)
930238106Sdes	COMMON_OBJ_ALL_SYMBOLS=""
931238106Sdes	UBSYMS=""
932238106Sdes	EXTRALINK="-L. -L.libs -lunbound"
933238106Sdes	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])
934238106Sdes	;;
935238106Sdes	no|*)
936238106Sdes	COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)'
937238106Sdes	UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def'
938238106Sdes	EXTRALINK=""
939238106Sdes	;;
940238106Sdesesac
941238106SdesAC_SUBST(COMMON_OBJ_ALL_SYMBOLS)
942238106SdesAC_SUBST(EXTRALINK)
943238106SdesAC_SUBST(UBSYMS)
944238106Sdesif test x_$enable_lock_checks = x_yes; then
945238106Sdes	UBSYMS="-export-symbols clubsyms.def"
946238106Sdes	cp ${srcdir}/libunbound/ubsyms.def clubsyms.def
947238106Sdes	echo lock_protect >> clubsyms.def
948238106Sdes	echo lock_unprotect >> clubsyms.def
949238106Sdes	echo lock_get_mem >> clubsyms.def
950238106Sdes	echo checklock_start >> clubsyms.def
951238106Sdes	echo checklock_stop >> clubsyms.def
952238106Sdes	echo checklock_lock >> clubsyms.def
953238106Sdes	echo checklock_unlock >> clubsyms.def
954238106Sdes	echo checklock_init >> clubsyms.def
955238106Sdes	echo checklock_thrcreate >> clubsyms.def
956238106Sdes	echo checklock_thrjoin >> clubsyms.def
957238106Sdesfi
958238106Sdes
959238106SdesAC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope])
960238106Sdes# on openBSD, the implicit rule make $< work.
961238106Sdes# on Solaris, it does not work ($? is changed sources, $^ lists dependencies).
962238106Sdes# gmake works.
963238106Sdescat >conftest.make <<EOF
964238106Sdesall:	conftest.lo
965238106Sdes
966238106Sdesconftest.lo foo.lo bla.lo:
967238106Sdes	if test -f "\$<"; then touch \$@; fi
968238106Sdes
969238106Sdes.SUFFIXES: .lo
970238106Sdes.c.lo:
971238106Sdes	if test -f "\$<"; then touch \$@; fi
972238106Sdes
973238106Sdesconftest.lo:        conftest.dir/conftest.c
974238106SdesEOF
975238106Sdesmkdir conftest.dir
976238106Sdestouch conftest.dir/conftest.c
977238106Sdesrm -f conftest.lo conftest.c
978238106Sdes${MAKE:-make} -f conftest.make >/dev/null
979238106Sdesrm -f conftest.make conftest.c conftest.dir/conftest.c
980238106Sdesrm -rf conftest.dir
981238106Sdesif test ! -f conftest.lo; then
982238106Sdes	AC_MSG_RESULT(no)
983238106Sdes	SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source'
984238106Sdes	SOURCEFILE='`cat .source`'
985238106Sdeselse
986238106Sdes	AC_MSG_RESULT(yes)
987238106Sdes	SOURCEDETERMINE=':'
988238106Sdes	SOURCEFILE='$<'
989238106Sdesfi
990238106Sdesrm -f conftest.lo
991238106SdesAC_SUBST(SOURCEDETERMINE)
992238106SdesAC_SUBST(SOURCEFILE)
993238106Sdes
994249141Sdes# see if we want to build the library or everything
995249141SdesALLTARGET="alltargets"
996249141SdesAC_ARG_WITH(libunbound-only, AC_HELP_STRING([--with-libunbound-only],
997249141Sdes	[do not build daemon and tool programs]),
998249141Sdes	[
999249141Sdes	if test "$withval" = "yes"; then
1000249141Sdes		ALLTARGET="lib"
1001249141Sdes	fi
1002249141Sdes])
1003249141SdesAC_SUBST(ALLTARGET)
1004249141Sdes
1005238106Sdes# check this after all other compilation checks, since the linking of the lib
1006238106Sdes# may break checks after this.
1007238106SdesAC_ARG_WITH(ldns, AC_HELP_STRING([--with-ldns=PATH], 
1008238106Sdes	[specify prefix of path of ldns library to use]), 
1009238106Sdes	[
1010238106Sdes	if test "$withval" != "yes"; then
1011238106Sdes		if test "$withval" != "/usr" -a "$withval" != ""; then
1012238106Sdes			CPPFLAGS="-I$withval/include $CPPFLAGS"
1013238106Sdes			LDFLAGS="-L$withval/lib $LDFLAGS"
1014238106Sdes			ACX_RUNTIME_PATH_ADD([$withval/lib])
1015238106Sdes		fi
1016238106Sdes		ldnsdir="$withval"
1017238106Sdes		AC_SUBST(ldnsdir)
1018238106Sdes	fi
1019238106Sdes])
1020238106Sdes
1021238106Sdes# check if ldns is good enough
1022238106SdesAC_CHECK_LIB(ldns, ldns_rr_new,,[
1023238106Sdes	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])
1024238106Sdes])
1025238106SdesAC_CHECK_FUNC(ldns_buffer_copy)
1026249141Sdesif test $USE_NSS = "no"; then
1027249141Sdes    AC_CHECK_FUNC(ldns_key_buf2rsa_raw)
1028249141Sdeselse
1029249141Sdes    dnl ignore test
1030249141Sdes    ac_cv_func_ldns_key_buf2rsa_raw="yes"
1031249141Sdesfi
1032238106SdesAC_CHECK_FUNC(ldns_get_random)
1033238106SdesAC_CHECK_FUNC(ldns_b32_ntop_extended_hex)
1034249141Sdesif test x$use_gost = xyes -a x$USE_NSS = xno; then
1035238106Sdes    AC_CHECK_FUNC(ldns_key_EVP_load_gost_id)
1036238106Sdes    AC_CHECK_FUNCS([ldns_key_EVP_unload_gost])
1037238106Sdeselse
1038249141Sdes    dnl ignore test
1039238106Sdes    ac_cv_func_ldns_key_EVP_load_gost_id="yes"
1040238106Sdesfi
1041238106Sdesif test x$use_ecdsa = xyes; then
1042238106Sdes    AC_CHECK_DECL([LDNS_ECDSAP384SHA384], [], [], [
1043238106SdesAC_INCLUDES_DEFAULT
1044238106Sdes#ifdef HAVE_SYS_SOCKET_H
1045238106Sdes#  include <sys/socket.h>
1046238106Sdes#endif
1047238106Sdes#ifdef HAVE_WS2TCPIP_H
1048238106Sdes#  include <ws2tcpip.h>
1049238106Sdes#endif
1050238106Sdes#include <ldns/ldns.h>
1051238106Sdes    ])
1052238106Sdeselse
1053238106Sdes    ac_cv_have_decl_LDNS_ECDSAP384SHA384="yes"
1054238106Sdesfi
1055238106SdesAC_CHECK_HEADERS([ldns/ldns.h],,[
1056238106Sdes	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])
1057238106Sdes	], [AC_INCLUDES_DEFAULT
1058238106Sdes#ifdef HAVE_SYS_SOCKET_H
1059238106Sdes#include <sys/socket.h>
1060238106Sdes#endif
1061238106Sdes
1062238106Sdes#ifdef HAVE_NETINET_IN_H
1063238106Sdes#include <netinet/in.h>
1064238106Sdes#endif
1065238106Sdes
1066238106Sdes#ifdef HAVE_ARPA_INET_H
1067238106Sdes#include <arpa/inet.h>
1068238106Sdes#endif
1069238106Sdes
1070238106Sdes#ifdef HAVE_WINSOCK2_H
1071238106Sdes#include <winsock2.h>
1072238106Sdes#endif
1073238106Sdes
1074238106Sdes#ifdef HAVE_WS2TCPIP_H
1075238106Sdes#include <ws2tcpip.h>
1076238106Sdes#endif
1077238106Sdes])
1078238106Sdesif test $ac_cv_func_ldns_buffer_copy = yes \
1079238106Sdes    -a $ac_cv_func_ldns_key_buf2rsa_raw = yes \
1080238106Sdes    -a $ac_cv_func_ldns_get_random = yes \
1081238106Sdes    -a $ac_cv_header_ldns_ldns_h = yes \
1082238106Sdes    -a $ac_cv_func_ldns_b32_ntop_extended_hex = yes \
1083238106Sdes    -a $ac_cv_func_ldns_key_EVP_load_gost_id = yes \
1084238106Sdes    -a $ac_cv_have_decl_LDNS_ECDSAP384SHA384 = yes; then
1085238106Sdes    dnl ldns was found
1086238106Sdes    :
1087238106Sdeselse
1088238106Sdes    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])
1089238106Sdesfi
1090238106Sdes
1091238106SdesACX_STRIP_EXT_FLAGS
1092238106SdesLDFLAGS="$LATE_LDFLAGS $LDFLAGS"
1093238106Sdes
1094238106SdesAC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.])
1095238106Sdes
1096238106SdesAH_BOTTOM(
1097238106Sdesdnl this must be first AH_CONFIG, to define the flags before any includes.
1098238106SdesAHX_CONFIG_EXT_FLAGS
1099238106Sdes
1100238106Sdesdnl includes
1101238106Sdes[
1102238106Sdes#ifndef UNBOUND_DEBUG
1103238106Sdes#  define NDEBUG
1104238106Sdes#endif
1105238106Sdes
1106238106Sdes#include <stdio.h>
1107238106Sdes#include <string.h>
1108238106Sdes#include <unistd.h>
1109238106Sdes#include <assert.h>
1110238106Sdes
1111238106Sdes#if STDC_HEADERS
1112238106Sdes#include <stdlib.h>
1113238106Sdes#include <stddef.h>
1114238106Sdes#endif
1115238106Sdes
1116238106Sdes#ifdef HAVE_STDINT_H
1117238106Sdes#include <stdint.h>
1118238106Sdes#endif
1119238106Sdes
1120238106Sdes#include <errno.h>
1121238106Sdes
1122238106Sdes#if HAVE_SYS_PARAM_H
1123238106Sdes#include <sys/param.h>
1124238106Sdes#endif
1125238106Sdes
1126238106Sdes#ifdef HAVE_SYS_SOCKET_H
1127238106Sdes#include <sys/socket.h>
1128238106Sdes#endif
1129238106Sdes
1130238106Sdes#ifdef HAVE_SYS_UIO_H
1131238106Sdes#include <sys/uio.h>
1132238106Sdes#endif
1133238106Sdes
1134238106Sdes#ifdef HAVE_NETINET_IN_H
1135238106Sdes#include <netinet/in.h>
1136238106Sdes#endif
1137238106Sdes
1138238106Sdes#ifdef HAVE_ARPA_INET_H
1139238106Sdes#include <arpa/inet.h>
1140238106Sdes#endif
1141238106Sdes
1142238106Sdes#ifdef HAVE_WINSOCK2_H
1143238106Sdes#include <winsock2.h>
1144238106Sdes#endif
1145238106Sdes
1146238106Sdes#ifdef HAVE_WS2TCPIP_H
1147238106Sdes#include <ws2tcpip.h>
1148238106Sdes#endif
1149238106Sdes]
1150238106Sdes
1151238106SdesAHX_CONFIG_FORMAT_ATTRIBUTE
1152238106SdesAHX_CONFIG_UNUSED_ATTRIBUTE
1153238106SdesAHX_CONFIG_FSEEKO
1154238106SdesAHX_CONFIG_MAXHOSTNAMELEN
1155238106SdesAHX_CONFIG_SNPRINTF(unbound)
1156238106SdesAHX_CONFIG_INET_PTON(unbound)
1157238106SdesAHX_CONFIG_INET_NTOP(unbound)
1158238106SdesAHX_CONFIG_INET_ATON(unbound)
1159238106SdesAHX_CONFIG_MEMMOVE(unbound)
1160238106SdesAHX_CONFIG_STRLCPY(unbound)
1161238106SdesAHX_CONFIG_GMTIME_R(unbound)
1162238106SdesAHX_CONFIG_W32_SLEEP
1163238106SdesAHX_CONFIG_W32_USLEEP
1164238106SdesAHX_CONFIG_W32_RANDOM
1165238106SdesAHX_CONFIG_W32_SRANDOM
1166238106SdesAHX_CONFIG_W32_FD_SET_T
1167238106SdesAHX_CONFIG_IPV6_MIN_MTU
1168238106SdesAHX_MEMCMP_BROKEN(unbound)
1169238106Sdes
1170238106Sdes[
1171238106Sdes#ifndef HAVE_CTIME_R
1172238106Sdes#define ctime_r unbound_ctime_r
1173238106Sdeschar *ctime_r(const time_t *timep, char *buf);
1174238106Sdes#endif
1175238106Sdes
1176238106Sdes#if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
1177238106Sdes#define strptime unbound_strptime
1178238106Sdesstruct tm;
1179238106Sdeschar *strptime(const char *s, const char *format, struct tm *tm);
1180238106Sdes#endif
1181238106Sdes
1182238106Sdes#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))
1183238106Sdes   /* using version of libevent that is not threadsafe. */
1184238106Sdes#  define LIBEVENT_SIGNAL_PROBLEM 1
1185238106Sdes#endif
1186238106Sdes
1187238106Sdes#ifndef CHECKED_INET6
1188238106Sdes#  define CHECKED_INET6
1189238106Sdes#  ifdef AF_INET6
1190238106Sdes#    define INET6
1191238106Sdes#  else
1192238106Sdes#    define AF_INET6        28
1193238106Sdes#  endif
1194238106Sdes#endif /* CHECKED_INET6 */
1195238106Sdes
1196238106Sdes/* maximum nesting of included files */
1197238106Sdes#define MAXINCLUDES 10
1198238106Sdes#ifndef HAVE_GETADDRINFO
1199238106Sdesstruct sockaddr_storage;
1200238106Sdes#include "compat/fake-rfc2553.h"
1201238106Sdes#endif
1202238106Sdes
1203238106Sdes#ifdef UNBOUND_ALLOC_STATS
1204238106Sdes#  define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__)
1205238106Sdes#  define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__)
1206238106Sdes#  define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__)
1207238106Sdes#  define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__)
1208238106Sdesvoid *unbound_stat_malloc(size_t size);
1209238106Sdesvoid *unbound_stat_calloc(size_t nmemb, size_t size);
1210238106Sdesvoid unbound_stat_free(void *ptr);
1211238106Sdesvoid *unbound_stat_realloc(void *ptr, size_t size);
1212238106Sdesvoid *unbound_stat_malloc_log(size_t size, const char* file, int line,
1213238106Sdes	const char* func);
1214238106Sdesvoid *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file,
1215238106Sdes	int line, const char* func);
1216238106Sdesvoid unbound_stat_free_log(void *ptr, const char* file, int line,
1217238106Sdes	const char* func);
1218238106Sdesvoid *unbound_stat_realloc_log(void *ptr, size_t size, const char* file,
1219238106Sdes	int line, const char* func);
1220238106Sdes#elif defined(UNBOUND_ALLOC_LITE)
1221238106Sdes#  include "util/alloc.h"
1222238106Sdes#endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */
1223238106Sdes
1224238106Sdes/** default port for DNS traffic. */
1225238106Sdes#define UNBOUND_DNS_PORT 53
1226238106Sdes/** default port for unbound control traffic, registered port with IANA,
1227238106Sdes    ub-dns-control  8953/tcp    unbound dns nameserver control */
1228238106Sdes#define UNBOUND_CONTROL_PORT 8953
1229238106Sdes/** the version of unbound-control that this software implements */
1230238106Sdes#define UNBOUND_CONTROL_VERSION 1
1231238106Sdes
1232238106Sdes])
1233238106Sdes
1234255592SdesAC_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])
1235238106SdesAC_CONFIG_HEADER([config.h])
1236238106SdesAC_OUTPUT
1237