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