xref: /freebsd/contrib/ldns/configure.ac (revision 8d20be1e22095c27faf8fe8b2f0d089739cc742e)
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3AC_PREREQ(2.56)
4sinclude(acx_nlnetlabs.m4)
5
6# must be numbers. ac_defun because of later processing.
7m4_define([VERSION_MAJOR],[1])
8m4_define([VERSION_MINOR],[6])
9m4_define([VERSION_MICRO],[16])
10AC_INIT(ldns, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), libdns@nlnetlabs.nl, libdns)
11AC_CONFIG_SRCDIR([packet.c])
12# needed to build correct soname
13AC_SUBST(LIBTOOL_VERSION_INFO, VERSION_MAJOR:VERSION_MINOR:VERSION_MICRO)
14AC_SUBST(LDNS_VERSION_MAJOR, [VERSION_MAJOR])
15AC_SUBST(LDNS_VERSION_MINOR, [VERSION_MINOR])
16AC_SUBST(LDNS_VERSION_MICRO, [VERSION_MICRO])
17
18OURCPPFLAGS=''
19CPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}}
20CFLAGS="$CFLAGS"
21
22AC_AIX
23# Checks for programs.
24AC_PROG_CC
25ACX_DEPFLAG
26AC_PROG_MAKE_SET
27
28# Extra (sp)lint flags for NetBSD
29AC_CANONICAL_HOST
30case "$host_os" in
31	netbsd*) LINTFLAGS="'-D__RENAME(x)=' -D_NETINET_IN_H_ $LINTFLAGS"
32		 ;;
33	*)       LINTFLAGS="$LINTFLAGS"
34		 ;;
35esac
36AC_SUBST(LINTFLAGS)
37
38AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
39
40ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
41ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
42
43# routine to copy files
44# argument 1 is a list of files (relative to the source dir)
45# argument 2 is a destination directory (relative to the current
46# working directory
47AC_DEFUN([COPY_FILES],
48[
49for file in $1; do
50	sh $srcdir/install-sh -m 644 $file $2
51done
52])
53
54# copy all .h files in the dir at argument 1
55# (relative to source) to the dir at argument 2
56# (relative to current dir)
57AC_DEFUN([COPY_HEADER_FILES],
58[
59echo "copying header files"
60COPY_FILES($srcdir/$1/*.h, $2)
61])
62
63# Checks for typedefs, structures, and compiler characteristics.
64AC_C_CONST
65AC_LANG_C
66if test "x$CFLAGS" = "x" ; then
67ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="-g"])
68ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="-O2 $CFLAGS"])
69fi
70ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="-Wall $CFLAGS"])
71ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="-W $CFLAGS"])
72ACX_CHECK_COMPILER_FLAG(Wwrite-strings, [CFLAGS="-Wwrite-strings $CFLAGS"])
73
74
75AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
76
77# MinGW32 tests
78AC_CHECK_HEADERS([winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
79# end mingw32 tests
80
81ACX_DETERMINE_EXT_FLAGS_UNBOUND
82
83AC_C_INLINE
84AC_CHECK_TYPE(int8_t, char)
85AC_CHECK_TYPE(int16_t, short)
86AC_CHECK_TYPE(int32_t, int)
87AC_CHECK_TYPE(int64_t, long long)
88AC_CHECK_TYPE(uint8_t, unsigned char)
89AC_CHECK_TYPE(uint16_t, unsigned short)
90AC_CHECK_TYPE(uint32_t, unsigned int)
91AC_CHECK_TYPE(uint64_t, unsigned long long)
92
93# my own checks
94AC_CHECK_PROG(doxygen, doxygen, doxygen)
95
96# check to see if libraries are needed for these functions.
97AC_SEARCH_LIBS([socket], [socket])
98AC_SEARCH_LIBS([inet_pton], [nsl])
99
100
101AC_ARG_WITH(drill, AC_HELP_STRING([--with-drill],
102 [Also build drill.]),
103 [],[with_drill="no"])
104if test x_$with_drill != x_no ; then
105	AC_SUBST(DRILL,[drill])
106	AC_SUBST(INSTALL_DRILL,[install-drill])
107	AC_SUBST(UNINSTALL_DRILL,[uninstall-drill])
108	AC_SUBST(CLEAN_DRILL,[clean-drill])
109	AC_SUBST(LINT_DRILL,[lint-drill])
110	if test -e $srcdir/drill/config.h -o -e drill/config.h ; then
111		AC_MSG_ERROR([
112A config.h was detected in the drill subdirectory.
113This does not work with the --with-drill option.
114Please remove the config.h from the drill subdirectory
115or do not use the --with-drill option.])
116	fi
117	DRILL_CONFIG=" drill/drill.1"
118else
119	AC_SUBST(DRILL,[""])
120	AC_SUBST(INSTALL_DRILL,[""])
121	AC_SUBST(UNINSTALL_DRILL,[""])
122	AC_SUBST(CLEAN_DRILL,[""])
123	AC_SUBST(LINT_DRILL,[""])
124	DRILL_CONFIG=""
125fi
126
127
128AC_ARG_WITH(examples, AC_HELP_STRING([--with-examples],
129 [Also build examples.]),
130 [],[with_examples="no"])
131if test x_$with_examples != x_no ; then
132	AC_SUBST(EXAMPLES,[examples])
133	AC_SUBST(INSTALL_EXAMPLES,[install-examples])
134	AC_SUBST(UNINSTALL_EXAMPLES,[uninstall-examples])
135	AC_SUBST(CLEAN_EXAMPLES,[clean-examples])
136	AC_SUBST(LINT_EXAMPLES,[lint-examples])
137	if test -e $srcdir/examples/config.h -o -e examples/config.h ; then
138		AC_MSG_ERROR([
139A config.h was detected in the examples subdirectory.
140This does not work with the --with-examples option.
141Please remove the config.h from the examples subdirectory
142or do not use the --with-examples option.])
143	fi
144	EXAMPLES_CONFIG=" examples/ldns-dane.1 examples/ldns-verify-zone.1"
145else
146	AC_SUBST(EXAMPLES,[""])
147	AC_SUBST(INSTALL_EXAMPLES,[""])
148	AC_SUBST(UNINSTALL_EXAMPLES,[""])
149	AC_SUBST(CLEAN_EXAMPLES,[""])
150	AC_SUBST(LINT_EXAMPLES,[""])
151	EXAMPLES_CONFIG=""
152fi
153
154# add option to disable installation of ldns-config script
155AC_ARG_ENABLE(ldns-config, [ --disable-ldns-config	disable installation of ldns-config (default=enabled)],
156	enable_ldns_config=$enableval, enable_ldns_config=yes)
157if test "x$enable_ldns_config" = xyes; then
158	AC_SUBST(INSTALL_CONFIG, [install-config])
159	AC_SUBST(INSTALL_CONFIG_MANPAGE, [install-config-manpage])
160	AC_SUBST(UNINSTALL_CONFIG, [uninstall-config])
161	AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [uninstall-config-manpage])
162else
163	AC_SUBST(INSTALL_CONFIG, [""])
164	AC_SUBST(INSTALL_CONFIG_MANPAGE, [""])
165	AC_SUBST(UNINSTALL_CONFIG, [""])
166	AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [""])
167fi
168
169# check for python
170PYTHON_X_CFLAGS=""
171ldns_with_pyldns=no
172ldns_with_pyldnsx=no
173AC_ARG_WITH(pyldns, AC_HELP_STRING([--with-pyldns],
174 [generate python library, or --without-pyldns to disable Python support.]),
175 [],[ withval="no" ])
176ldns_have_python=no
177if test x_$withval != x_no; then
178   sinclude(ax_python_devel.m4)
179   ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
180
181   AX_PYTHON_DEVEL([>= '2.4.0'])
182   if test ! -z "$ac_python_version"; then
183	ldns_have_python=yes
184   fi
185
186   # pass additional Python 3 option to SWIG
187   if test `$PYTHON -c "import sys; \
188       ver = sys.version.split()[[0]]; \
189       print(ver >= '3')"` = "True"; then
190       AC_SUBST(SWIGPY3, ["-py3 -DPY3"])
191   fi
192
193   # check for SWIG
194   if test x_$ldns_have_python != x_no; then
195        sinclude(ax_pkg_swig.m4)
196
197        # check for >=SWIG-2.0.4 if Python 3.2 used
198        if test `$PYTHON -c "import sys; \
199            ver = sys.version.split()[[0]]; \
200            print(ver >= '3.2')"` = "True"; then
201            AX_PKG_SWIG(2.0.4, [], [AC_MSG_ERROR([SWIG-2.0.4 is required to build pyldns for Python 3.2 and greater.])])
202        else
203            AX_PKG_SWIG
204        fi
205
206	if test ! -x "$SWIG"; then
207		AC_MSG_ERROR([failed to find SWIG tool, install it, or do not build pyldns])
208	else
209		AC_DEFINE(HAVE_SWIG,1,[Define if you have SWIG libraries and header files.])
210		AC_SUBST(PYLDNS, "pyldns")
211		AC_SUBST(swig, "$SWIG")
212		ldns_with_pyldns=yes
213	fi
214   else
215	AC_MSG_RESULT([*** don't have Python, skipping SWIG, no pyldns ***]) # '
216   fi
217
218   # xtra cflags for pyldns
219   if test x_$ldns_have_python != x_no; then
220	ACX_CHECK_COMPILER_FLAG(fno-strict-aliasing, [PYTHON_X_CFLAGS="-fno-strict-aliasing"])
221	ACX_CHECK_COMPILER_FLAG(Wno-missing-field-initializers, [PYTHON_X_CFLAGS="-Wno-missing-field-initializers $PYTHON_X_CFLAGS"])
222	ACX_CHECK_COMPILER_FLAG(Wno-unused-parameter, [PYTHON_X_CFLAGS="-Wno-unused-parameter $PYTHON_X_CFLAGS"])
223	ACX_CHECK_COMPILER_FLAG(Wno-unused-variable, [PYTHON_X_CFLAGS="-Wno-unused-variable $PYTHON_X_CFLAGS"])
224   fi
225fi
226AC_SUBST(PYTHON_X_CFLAGS)
227
228# Check for pyldnsx
229AC_ARG_WITH(pyldnsx, AC_HELP_STRING([--without-pyldnsx],
230  [Do not install the ldnsx python module, or --with-pyldnsx to install it.]),
231  [],[ withval="with_pyldns" ])
232if test x_$withval != x_no; then
233  if test x_$ldns_with_pyldns != x_no; then
234    AC_SUBST(PYLDNSX, "pyldnsx")
235    ldns_with_pyldnsx=yes
236  else
237    if test x_$withval != x_with_pyldns; then
238      AC_MSG_ERROR([--with-pyldns is needed for the ldnsx python module])
239    fi
240  fi
241fi
242
243if test x_$ldns_with_pyldns != x_no; then
244  AC_SUBST(PYLDNSINST, "install-pyldns")dnl
245  AC_SUBST(PYLDNSUNINST, "uninstall-pyldns")
246else
247  AC_SUBST(PYLDNSINST, "")dnl
248  AC_SUBST(PYLDNSUNINST, "")
249fi
250if test x_$ldns_with_pyldnsx != x_no; then
251  AC_SUBST(PYLDNSXINST, "install-pyldnsx")dnl
252  AC_SUBST(PYLDNSXUNINST, "uninstall-pyldnsx")
253else
254  AC_SUBST(PYLDNSXINST, "")dnl
255  AC_SUBST(PYLDNSXUNINST, "")
256fi
257
258# Use libtool
259ACX_LIBTOOL_C_ONLY
260
261tmp_CPPFLAGS=$CPPFLAGS
262tmp_LDFLAGS=$LDFLAGS
263tmp_LIBS=$LIBS
264
265ACX_WITH_SSL_OPTIONAL
266
267AC_CHECK_FUNCS([EVP_sha256])
268
269# for macosx, see if glibtool exists and use that
270# BSD's need to know the version...
271#AC_CHECK_PROG(glibtool, glibtool, [glibtool], )
272#AC_CHECK_PROGS(libtool, [libtool15 libtool], [./libtool])
273
274AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
275case "$enable_sha2" in
276    no)
277        ;;
278    yes|*)
279        if test "x$HAVE_SSL" != "xyes"; then
280            AC_MSG_ERROR([SHA2 enabled, but no SSL support])
281        fi
282	AC_MSG_CHECKING(for SHA256 and SHA512)
283	AC_CHECK_FUNC(SHA256_Init, [], [
284		AC_MSG_ERROR([No SHA2 functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-sha2])
285		])
286	AC_DEFINE_UNQUOTED([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
287        ;;
288esac
289
290AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
291case "$enable_gost" in
292    no)
293        ;;
294    *)  dnl default
295        if test "x$HAVE_SSL" != "xyes"; then
296            AC_MSG_ERROR([GOST enabled, but no SSL support])
297        fi
298        AC_MSG_CHECKING(for GOST)
299        AC_CHECK_FUNC(EVP_PKEY_set_type_str, [],[AC_MSG_ERROR([OpenSSL >= 1.0.0 is needed for GOST support or rerun with --disable-gost])])
300        AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([No ECC functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-gost])])
301        AC_DEFINE_UNQUOTED([USE_GOST], [1], [Define this to enable GOST support.])
302        ;;
303esac
304
305AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
306case "$enable_ecdsa" in
307    no)
308      ;;
309    *) dnl default
310      if test "x$HAVE_SSL" != "xyes"; then
311        AC_MSG_ERROR([ECDSA enabled, but no SSL support])
312      fi
313      AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade OpenSSL or rerun with --disable-ecdsa])])
314      AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade OpenSSL or rerun with --disable-ecdsa])])
315      AC_CHECK_DECLS([NID_X9_62_prime256v1, NID_secp384r1], [], [AC_MSG_ERROR([OpenSSL does not support the ECDSA curves: please upgrade OpenSSL or rerun with --disable-ecdsa])], [AC_INCLUDES_DEFAULT
316#include <openssl/evp.h>
317      ])
318      # we now know we have ECDSA and the required curves.
319      AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
320      ;;
321esac
322
323AC_SUBST(LIBSSL_CPPFLAGS)
324AC_SUBST(LIBSSL_LDFLAGS)
325AC_SUBST(LIBSSL_LIBS)
326if test "x$HAVE_SSL" = "xyes"; then
327AC_SUBST(LIBSSL_SSL_LIBS, ["$LIBSSL_LIBS -lssl"])
328fi
329CPPFLAGS=$tmp_CPPFLAGS
330LDFLAGS=$tmp_LDFLAGS
331LIBS=$tmp_LIBS
332
333
334# add option to disable the evil rpath
335ACX_ARG_RPATH
336
337#AC_RUN_IFELSE([AC_LANG_SOURCE(
338#[
339#int main()
340#{
341#short one = 1;
342#char *cp = (char*)&one;
343#if ( *cp == 0 )
344#return(0);
345#else
346#return(1);
347#}
348#])], [],[
349#AC_DEFINE(CONFCHECK_LITTLE_ENDIAN, 1, [system appears to be little-endian])
350#],[])
351
352# should define WORDS_BIGENDIAN if the system is big-endian
353AC_C_BIGENDIAN
354
355# Checks for header files.
356AC_HEADER_STDC
357AC_HEADER_STDBOOL
358#AC_HEADER_SYS_WAIT
359#AC_CHECK_HEADERS([getopt.h fcntl.h stdlib.h string.h strings.h unistd.h])
360# do the very minimum - we can always extend this
361AC_CHECK_HEADERS([getopt.h stdarg.h openssl/ssl.h netinet/in.h time.h arpa/inet.h netdb.h],,, [AC_INCLUDES_DEFAULT])
362AC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
363[AC_INCLUDES_DEFAULT
364  [
365   #if HAVE_SYS_PARAM_H
366   # include <sys/param.h>
367   #endif
368  ]
369])
370AC_CHECK_HEADER(sys/socket.h,
371[
372include_sys_socket_h='#include <sys/socket.h>'
373AC_DEFINE(HAVE_SYS_SOCKET_H, 1, [define if you have sys/socket.h])
374],[
375include_sys_socket_h=''
376],[AC_INCLUDES_DEFAULT
377  [
378   #if HAVE_SYS_PARAM_H
379   # include <sys/param.h>
380   #endif
381  ]
382])
383AC_SUBST(include_sys_socket_h)
384AC_CHECK_HEADER(inttypes.h,
385[
386include_inttypes_h='#include <inttypes.h>'
387AC_DEFINE(HAVE_INTTYPES_H, 1, [define if you have inttypes.h])
388AC_SUBST(ldns_build_config_have_inttypes_h, 1)
389],[
390include_inttypes_h=''
391AC_SUBST(ldns_build_config_have_inttypes_h, 0)
392],[AC_INCLUDES_DEFAULT
393])
394AC_SUBST(include_inttypes_h)
395AC_CHECK_HEADER(sys/types.h,
396[
397include_systypes_h='#include <sys/types.h>'
398AC_DEFINE(HAVE_SYS_TYPES_H, 1, [define if you have sys/types.h])
399],[
400include_systypes_h=''
401],[AC_INCLUDES_DEFAULT
402])
403AC_SUBST(include_systypes_h)
404AC_CHECK_HEADER(unistd.h,
405[
406include_unistd_h='#include <unistd.h>'
407AC_DEFINE(HAVE_UNISTD_H, 1, [define if you have unistd.h])
408],[
409include_unistd_h=''
410],[AC_INCLUDES_DEFAULT
411])
412AC_SUBST(include_unistd_h)
413
414AC_CHECK_SIZEOF(time_t,,[
415AC_INCLUDES_DEFAULT
416#ifdef TIME_WITH_SYS_TIME
417# include <sys/time.h>
418# include <time.h>
419#else
420# ifdef HAVE_SYS_TIME_H
421#  include <sys/time.h>
422# else
423#  include <time.h>
424# endif
425#endif
426])
427
428if test x_$with_examples != x_no; then
429AC_CHECK_HEADERS([pcap.h],, [AC_INCLUDES_DEFAULT])
430AC_CHECK_LIB(pcap, pcap_open_offline, [
431	AC_DEFINE([HAVE_LIBPCAP], [1], [Define to 1 if you have the `pcap' library (-lpcap).])dnl`
432	AC_SUBST([LIBPCAP_LIBS], [-lpcap])
433    ], [
434	AC_MSG_WARN([Can't find pcap library (needed for ldns-dpa, will not build dpa now.)])dnl'
435	AC_SUBST([LIBPCAP_LIBS], [])
436    ]
437)
438AC_CHECK_HEADERS([netinet/in_systm.h net/if.h netinet/ip.h netinet/udp.h netinet/igmp.h netinet/if_ether.h netinet/ip6.h net/ethernet.h netinet/ip_compat.h],,, [
439AC_INCLUDES_DEFAULT
440#ifdef HAVE_NETINET_IN_SYSTM_H
441#include <netinet/in_systm.h>
442#endif
443#ifdef HAVE_NETINET_IN_H
444#include <netinet/in.h>
445#endif
446#ifdef HAVE_SYS_SOCKET_H
447#include <sys/socket.h>
448#endif
449#ifdef HAVE_NET_IF_H
450#include <net/if.h>
451#endif])
452fi
453
454ACX_TYPE_SOCKLEN_T
455if test "x$ac_cv_type_socklen_t" = xyes; then
456  AC_SUBST(ldns_build_config_have_socklen_t, 1)
457else
458  AC_SUBST(ldns_build_config_have_socklen_t, 0)
459fi
460AC_TYPE_SIZE_T
461AC_TYPE_SSIZE_T
462AC_TYPE_INTPTR_T
463AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
464#if HAVE_SYS_TYPES_H
465# include <sys/types.h>
466#endif
467#if HAVE_NETINET_IN_H
468# include <netinet/in.h>
469#endif])
470AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
471#if HAVE_SYS_TYPES_H
472# include <sys/types.h>
473#endif
474#if HAVE_NETINET_IN_H
475# include <netinet/in.h>
476#endif])
477ACX_CHECK_SS_FAMILY
478
479AC_FUNC_MALLOC
480AC_FUNC_REALLOC
481
482AC_REPLACE_FUNCS(b64_pton)
483AC_REPLACE_FUNCS(b64_ntop)
484AC_REPLACE_FUNCS(b32_pton)
485AC_REPLACE_FUNCS(b32_ntop)
486AC_REPLACE_FUNCS(calloc)
487AC_REPLACE_FUNCS(timegm)
488AC_REPLACE_FUNCS(gmtime_r)
489AC_REPLACE_FUNCS(ctime_r)
490AC_REPLACE_FUNCS(localtime_r)
491AC_REPLACE_FUNCS(isblank)
492AC_REPLACE_FUNCS(isascii)
493AC_REPLACE_FUNCS(inet_aton)
494AC_REPLACE_FUNCS(inet_pton)
495AC_REPLACE_FUNCS(inet_ntop)
496AC_REPLACE_FUNCS(snprintf)
497AC_REPLACE_FUNCS(strlcpy)
498AC_REPLACE_FUNCS(memmove)
499AC_FUNC_FORK
500AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul bzero memset])
501
502ACX_CHECK_GETADDRINFO_WITH_INCLUDES
503if test $ac_cv_func_getaddrinfo = no; then
504	AC_LIBOBJ([fake-rfc2553])
505fi
506if test "$USE_WINSOCK" = 1; then
507	AC_CHECK_TOOL(WINDRES, windres)
508fi
509ACX_FUNC_IOCTLSOCKET
510
511#AC_SEARCH_LIBS(RSA_new, [crypto])
512
513ACX_CHECK_FORMAT_ATTRIBUTE
514ACX_CHECK_UNUSED_ATTRIBUTE
515
516# check OSX deployment target which is needed
517if echo $build_os | grep darwin > /dev/null; then
518 	export MACOSX_DEPLOYMENT_TARGET="10.4"
519fi
520
521AC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir])
522
523AC_ARG_WITH(trust-anchor, AC_HELP_STRING([--with-trust-anchor=KEYFILE], [Default location of the trust anchor file for drill and ldns-dane. [default=SYSCONFDIR/unbound/root.key]]), [
524 LDNS_TRUST_ANCHOR_FILE="$withval"
525],[
526 if test "x$LDNS_TRUST_ANCHOR_FILE" = "x"; then
527  if test "x$sysconfdir" = 'x${prefix}/etc' ; then
528   if test "x$prefix" = 'xNONE' ; then
529    LDNS_TRUST_ANCHOR_FILE="/etc/unbound/root.key"
530   else
531    LDNS_TRUST_ANCHOR_FILE="${prefix}/etc/unbound/root.key"
532   fi
533  else
534    LDNS_TRUST_ANCHOR_FILE="${sysconfdir}/unbound/root.key"
535  fi
536 fi
537])
538AC_DEFINE_UNQUOTED([LDNS_TRUST_ANCHOR_FILE], ["$LDNS_TRUST_ANCHOR_FILE"], [Default trust anchor file])
539AC_SUBST(LDNS_TRUST_ANCHOR_FILE)
540AC_MSG_NOTICE([Default trust anchor: $LDNS_TRUST_ANCHOR_FILE])
541
542AC_ARG_WITH(ca-file, AC_HELP_STRING([--with-ca-file=CAFILE], [File containing CA certificates for ldns-dane]), [
543 AC_DEFINE([HAVE_DANE_CA_FILE], [1], [Is a CAFILE given at configure time])
544 AC_DEFINE_UNQUOTED([LDNS_DANE_CA_FILE], ["$withval"], [Is a CAFILE given at configure time])
545 AC_MSG_NOTICE([Using CAfile: $withval])
546 AC_SUBST(DEFAULT_CAFILE, ["Default is $withval"])
547],[
548 AC_DEFINE([HAVE_DANE_CA_FILE], [0], [Is a CAFILE given at configure time])
549 AC_SUBST(DEFAULT_CAFILE, [])
550])
551
552AC_ARG_WITH(ca-path, AC_HELP_STRING([--with-ca-path=CAPATH], [Directory containing CA certificate files for ldns-dane]), [
553 AC_DEFINE([HAVE_DANE_CA_PATH], [1], [Is a CAPATH given at configure time])
554 AC_DEFINE_UNQUOTED([LDNS_DANE_CA_PATH], ["$withval"], [Is a CAPATH given at configure time])
555 AC_MSG_NOTICE([Using CApath: $withval])
556 AC_SUBST(DEFAULT_CAPATH, ["Default is $withval"])
557],[
558 AC_DEFINE([HAVE_DANE_CA_PATH], [0], [Is a CAPATH given at configure time])
559 AC_SUBST(DEFAULT_CAPATH, [])
560])
561
562AH_BOTTOM([
563#include <stdio.h>
564#include <string.h>
565#include <unistd.h>
566#include <assert.h>
567
568#ifndef LITTLE_ENDIAN
569#define LITTLE_ENDIAN 1234
570#endif
571
572#ifndef BIG_ENDIAN
573#define BIG_ENDIAN 4321
574#endif
575
576#ifndef BYTE_ORDER
577#ifdef WORDS_BIGENDIAN
578#define BYTE_ORDER BIG_ENDIAN
579#else
580#define BYTE_ORDER LITTLE_ENDIAN
581#endif /* WORDS_BIGENDIAN */
582#endif /* BYTE_ORDER */
583
584#if STDC_HEADERS
585#include <stdlib.h>
586#include <stddef.h>
587#endif
588
589#ifdef HAVE_STDINT_H
590#include <stdint.h>
591#endif
592
593#ifdef HAVE_SYS_SOCKET_H
594#include <sys/socket.h>
595#endif
596
597#ifdef HAVE_NETINET_IN_H
598#include <netinet/in.h>
599#endif
600
601#ifdef HAVE_ARPA_INET_H
602#include <arpa/inet.h>
603#endif
604
605#ifdef HAVE_WINSOCK2_H
606#include <winsock2.h>
607#endif
608
609#ifdef HAVE_WS2TCPIP_H
610#include <ws2tcpip.h>
611#endif
612]
613AHX_CONFIG_W32_FD_SET_T
614)
615
616AH_BOTTOM([
617#ifdef __cplusplus
618extern "C" {
619#endif
620
621#ifndef B64_PTON
622int ldns_b64_ntop(uint8_t const *src, size_t srclength,
623	 	  char *target, size_t targsize);
624/**
625 * calculates the size needed to store the result of b64_ntop
626 */
627/*@unused@*/
628static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize)
629{
630	return ((((srcsize + 2) / 3) * 4) + 1);
631}
632#endif /* !B64_PTON */
633#ifndef B64_NTOP
634int ldns_b64_pton(char const *src, uint8_t *target, size_t targsize);
635/**
636 * calculates the size needed to store the result of ldns_b64_pton
637 */
638/*@unused@*/
639static inline size_t ldns_b64_pton_calculate_size(size_t srcsize)
640{
641	return (((((srcsize + 3) / 4) * 3)) + 1);
642}
643#endif /* !B64_NTOP */
644
645#ifndef HAVE_SLEEP
646/* use windows sleep, in millisecs, instead */
647#define sleep(x) Sleep((x)*1000)
648#endif
649
650#ifndef HAVE_RANDOM
651#define srandom(x) srand(x)
652#define random(x) rand(x)
653#endif
654
655#ifndef HAVE_TIMEGM
656#include <time.h>
657time_t timegm (struct tm *tm);
658#endif /* !TIMEGM */
659#ifndef HAVE_GMTIME_R
660struct tm *gmtime_r(const time_t *timep, struct tm *result);
661#endif
662#ifndef HAVE_LOCALTIME_R
663struct tm *localtime_r(const time_t *timep, struct tm *result);
664#endif
665#ifndef HAVE_ISBLANK
666int isblank(int c);
667#endif /* !HAVE_ISBLANK */
668#ifndef HAVE_ISASCII
669int isascii(int c);
670#endif /* !HAVE_ISASCII */
671#ifndef HAVE_SNPRINTF
672#include <stdarg.h>
673int snprintf (char *str, size_t count, const char *fmt, ...);
674int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
675#endif /* HAVE_SNPRINTF */
676#ifndef HAVE_INET_PTON
677int inet_pton(int af, const char* src, void* dst);
678#endif /* HAVE_INET_PTON */
679#ifndef HAVE_INET_NTOP
680const char *inet_ntop(int af, const void *src, char *dst, size_t size);
681#endif
682#ifndef HAVE_INET_ATON
683int inet_aton(const char *cp, struct in_addr *addr);
684#endif
685#ifndef HAVE_MEMMOVE
686void *memmove(void *dest, const void *src, size_t n);
687#endif
688#ifndef HAVE_STRLCPY
689size_t strlcpy(char *dst, const char *src, size_t siz);
690#endif
691#ifdef __cplusplus
692}
693#endif
694#ifndef HAVE_GETADDRINFO
695#include "compat/fake-rfc2553.h"
696#endif
697#ifndef HAVE_STRTOUL
698#define strtoul (unsigned long)strtol
699#endif
700])
701
702if test "x$HAVE_SSL" = "xyes"; then
703	AC_SUBST(ldns_build_config_have_ssl, 1)
704else
705	AC_SUBST(ldns_build_config_have_ssl, 0)
706fi
707if test "x$ac_cv_c_format_attribute" = "xyes"; then
708  AC_SUBST(ldns_build_config_have_attr_format, 1)
709else
710  AC_SUBST(ldns_build_config_have_attr_format, 0)
711fi
712if test "x$ac_cv_c_unused_attribute" = "xyes"; then
713  AC_SUBST(ldns_build_config_have_attr_unused, 1)
714else
715  AC_SUBST(ldns_build_config_have_attr_unused, 0)
716fi
717
718CONFIG_FILES="Makefile ldns/common.h ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config $DRILL_CONFIG $EXAMPLES_CONFIG"
719AC_SUBST(CONFIG_FILES)
720AC_CONFIG_FILES([$CONFIG_FILES])
721
722AC_CONFIG_HEADER([ldns/config.h])
723AC_OUTPUT
724COPY_HEADER_FILES(ldns/, ldns/)
725
726dnl AC_CONFIG_SUBDIRS([drill])
727
728
729