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