xref: /freebsd/contrib/ldns/configure.ac (revision fe75646a0234a261c0013bf1840fdac4acaf0cec)
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],[8])
9m4_define([VERSION_MICRO],[3])
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(LDNS_VERSION_MAJOR, [VERSION_MAJOR])
14AC_SUBST(LDNS_VERSION_MINOR, [VERSION_MINOR])
15AC_SUBST(LDNS_VERSION_MICRO, [VERSION_MICRO])
16
17# Library version
18# ---------------
19# current:revision:age
20# (binary-api-number):(which-binary-api-version):(how-many-nrs-backwardscompat)
21# if source code changes increment revision
22# if any interfaces have been added/removed/changed since last update then
23#   increment current and set revision to 0
24# if any interfaces have been added since the last public release then increment age
25# if any interfaces have been removed or changed since the last public release then
26#   set age to 0
27#
28# ldns-1.6.17 and before had a .so with version same as VERSION_INFO
29# ldns-1.7.0 had libversion 2:0:0
30# ldns-1.7.1 had libversion 3:0:0 (though it should have had 3:0:1)
31# ldns-1.8.0 had libversion 4:0:2 (though it should have had 4:0:1)
32# ldns-1.8.1 had libversion 5:0:2
33# ldns-1.8.1 had libversion 6:0:3
34# ldns-1.8.2 had libversion 7:0:4
35# ldns-1.8.3 has libversion 8:0:5
36#
37AC_SUBST(VERSION_INFO, [8:0:5])
38
39AC_AIX
40if test "$ac_cv_header_minix_config_h" = "yes"; then
41	AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix])
42fi
43LT_INIT
44AC_CONFIG_MACRO_DIR([m4])
45
46OURCPPFLAGS=''
47CPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}}
48CFLAGS="$CFLAGS"
49
50# Checks for programs.
51AC_PROG_CC
52ACX_DEPFLAG
53AC_PROG_MAKE_SET
54
55# Extra (sp)lint flags for NetBSD
56AC_CANONICAL_HOST
57case "$host_os" in
58	netbsd*) LINTFLAGS="'-D__RENAME(x)=' -D_NETINET_IN_H_ $LINTFLAGS"
59		 ;;
60	*)       LINTFLAGS="$LINTFLAGS"
61		 ;;
62esac
63AC_SUBST(LINTFLAGS)
64
65AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
66
67ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
68ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
69
70# routine to copy files
71# argument 1 is a list of files (relative to the source dir)
72# argument 2 is a destination directory (relative to the current
73# working directory
74AC_DEFUN([COPY_FILES],
75[
76for file in $1; do
77	sh $srcdir/install-sh -m 644 $file $2
78done
79])
80
81# copy all .h files in the dir at argument 1
82# (relative to source) to the dir at argument 2
83# (relative to current dir)
84AC_DEFUN([COPY_HEADER_FILES],
85[
86echo "copying header files"
87COPY_FILES($srcdir/$1/*.h, $2)
88])
89
90# Checks for typedefs, structures, and compiler characteristics.
91AC_C_CONST
92AC_LANG_C
93if test "x$CFLAGS" = "x" ; then
94ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="-g"])
95ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="-O2 $CFLAGS"])
96fi
97ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="-Wall $CFLAGS"])
98ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="-W $CFLAGS"])
99ACX_CHECK_COMPILER_FLAG(Wwrite-strings, [CFLAGS="-Wwrite-strings $CFLAGS"])
100ACX_CHECK_COMPILER_FLAG(Wstrict-prototypes, [CFLAGS="-Wstrict-prototypes $CFLAGS"])
101#ACX_CHECK_COMPILER_FLAG(Wshadow, [CFLAGS="-Wshadow $CFLAGS"])
102ACX_CHECK_COMPILER_FLAG(Wunused-function, [CFLAGS="-Wunused-function $CFLAGS"])
103ACX_CHECK_COMPILER_FLAG(Wmissing-prototypes, [CFLAGS="-Wmissing-prototypes $CFLAGS"])
104ACX_CHECK_COMPILER_FLAG(fno-strict-aliasing, [CFLAGS="-fno-strict-aliasing $CFLAGS"])
105
106AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
107
108# MinGW32 tests
109AC_CHECK_HEADERS([winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
110# end mingw32 tests
111
112# Check for Apple header. This uncovers TARGET_OS_IPHONE, TARGET_OS_TV or TARGET_OS_WATCH
113AC_CHECK_HEADERS([TargetConditionals.h])
114
115ACX_DETERMINE_EXT_FLAGS_UNBOUND
116
117AC_C_INLINE
118AC_CHECK_TYPE(int8_t, char)
119AC_CHECK_TYPE(int16_t, short)
120AC_CHECK_TYPE(int32_t, int)
121AC_CHECK_TYPE(int64_t, long long)
122AC_CHECK_TYPE(uint8_t, unsigned char)
123AC_CHECK_TYPE(uint16_t, unsigned short)
124AC_CHECK_TYPE(uint32_t, unsigned int)
125AC_CHECK_TYPE(uint64_t, unsigned long long)
126
127# my own checks
128AC_CHECK_PROG(doxygen, doxygen, doxygen)
129
130# check to see if libraries are needed for these functions.
131AC_CHECK_FUNC([socket],
132    [],
133    [AC_SEARCH_LIBS([socket], [socket])
134])
135
136# modern Linux provides inet_ntop in -lsocket.
137# modern OS X provides inet_ntop in -lc.
138# modern Solaris provides inet_ntop in -lsocket -lnsl.
139# older Solaris provides inet_ntop in -lresolv.
140AC_CHECK_FUNC([inet_ntop],
141    [],
142    [AC_SEARCH_LIBS([inet_ntop], [socket c nsl resolv], [ac_cv_func_inet_ntop=yes])
143])
144
145# modern Linux provides inet_pton in -lsocket.
146# modern OS X provides inet_pton in -lc.
147# modern Solaris provides inet_pton in -lsocket -lnsl.
148# older Solaris provides inet_pton in -lresolv.
149AC_CHECK_FUNC([inet_pton],
150    [],
151    [AC_SEARCH_LIBS([inet_pton], [socket c nsl resolv], [ac_cv_func_inet_pton=yes])
152])
153
154
155AC_ARG_WITH(drill, AC_HELP_STRING([--with-drill],
156 [Also build drill.]),
157 [],[with_drill="no"])
158if test x_$with_drill != x_no ; then
159	AC_SUBST(DRILL,[drill])
160	AC_SUBST(INSTALL_DRILL,[install-drill])
161	AC_SUBST(UNINSTALL_DRILL,[uninstall-drill])
162	AC_SUBST(CLEAN_DRILL,[clean-drill])
163	AC_SUBST(LINT_DRILL,[lint-drill])
164	if test -e $srcdir/drill/config.h -o -e drill/config.h ; then
165		AC_MSG_ERROR([
166A config.h was detected in the drill subdirectory.
167This does not work with the --with-drill option.
168Please remove the config.h from the drill subdirectory
169or do not use the --with-drill option.])
170	fi
171else
172	AC_SUBST(DRILL,[""])
173	AC_SUBST(INSTALL_DRILL,[""])
174	AC_SUBST(UNINSTALL_DRILL,[""])
175	AC_SUBST(CLEAN_DRILL,[""])
176	AC_SUBST(LINT_DRILL,[""])
177fi
178
179
180AC_ARG_WITH(examples, AC_HELP_STRING([--with-examples],
181 [Also build examples.]),
182 [],[with_examples="no"])
183if test x_$with_examples != x_no ; then
184	AC_SUBST(EXAMPLES,[examples])
185	AC_SUBST(INSTALL_EXAMPLES,[install-examples])
186	AC_SUBST(UNINSTALL_EXAMPLES,[uninstall-examples])
187	AC_SUBST(CLEAN_EXAMPLES,[clean-examples])
188	AC_SUBST(LINT_EXAMPLES,[lint-examples])
189	if test -e $srcdir/examples/config.h -o -e examples/config.h ; then
190		AC_MSG_ERROR([
191A config.h was detected in the examples subdirectory.
192This does not work with the --with-examples option.
193Please remove the config.h from the examples subdirectory
194or do not use the --with-examples option.])
195	fi
196else
197	AC_SUBST(EXAMPLES,[""])
198	AC_SUBST(INSTALL_EXAMPLES,[""])
199	AC_SUBST(UNINSTALL_EXAMPLES,[""])
200	AC_SUBST(CLEAN_EXAMPLES,[""])
201	AC_SUBST(LINT_EXAMPLES,[""])
202fi
203
204# add option to disable installation of ldns-config script
205AC_ARG_ENABLE(ldns-config, AC_HELP_STRING([--disable-ldns-config], [disable installation of ldns-config (default=enabled)]),
206	enable_ldns_config=$enableval, enable_ldns_config=yes)
207if test "x$enable_ldns_config" = xyes; then
208	AC_SUBST(INSTALL_CONFIG, [install-config])
209	AC_SUBST(INSTALL_CONFIG_MANPAGE, [install-config-manpage])
210	AC_SUBST(UNINSTALL_CONFIG, [uninstall-config])
211	AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [uninstall-config-manpage])
212else
213	AC_SUBST(INSTALL_CONFIG, [""])
214	AC_SUBST(INSTALL_CONFIG_MANPAGE, [""])
215	AC_SUBST(UNINSTALL_CONFIG, [""])
216	AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [""])
217fi
218
219# add option to disable library printing to stderr
220AC_ARG_ENABLE(stderr-msgs, AC_HELP_STRING([--enable-stderr-msgs], [Enable printing to stderr (default=disabled)]), enable_stderr_msgs=$enableval, enable_stderr_msgs=no)
221case "$enable_stderr_msgs" in
222    no) dnl default
223        ;;
224    *)
225        AC_DEFINE_UNQUOTED([STDERR_MSGS], [1], [Define this to enable messages to stderr.])
226        ;;
227esac
228
229AX_HAVE_POLL(
230  [AX_CONFIG_FEATURE_ENABLE(poll)],
231  [AX_CONFIG_FEATURE_DISABLE(poll)])
232AX_CONFIG_FEATURE(
233  [poll], [This platform supports poll(7)],
234  [HAVE_POLL], [This platform supports poll(7).])
235
236# check for python
237PYTHON_X_CFLAGS=""
238ldns_with_pyldns=no
239ldns_with_pyldnsx=no
240AC_ARG_WITH(pyldns, AC_HELP_STRING([--with-pyldns],
241 [generate python library, or --without-pyldns to disable Python support.]),
242 [],[ withval="no" ])
243ldns_have_python=no
244if test x_$withval != x_no; then
245   sinclude(ax_python_devel.m4)
246   ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
247
248   AX_PYTHON_DEVEL([>= '2.4.0'])
249   if test ! -z "$ac_python_version"; then
250	ldns_have_python=yes
251   fi
252
253   # pass additional Python 3 option to SWIG
254   if test `$PYTHON -c "import sys; \
255       ver = sys.version.split()[[0]]; \
256       print(ver >= '3')"` = "True"; then
257       AC_SUBST(SWIGPY3, ["-py3 -DPY3"])
258   fi
259
260   # check for SWIG
261   if test x_$ldns_have_python != x_no; then
262        sinclude(ax_pkg_swig.m4)
263
264        # check for >=SWIG-2.0.4 if Python 3.2 used
265        if test `$PYTHON -c "import sys; \
266            ver = sys.version.split()[[0]]; \
267            print(ver >= '3.2')"` = "True"; then
268            AX_PKG_SWIG(2.0.4, [], [AC_MSG_ERROR([SWIG-2.0.4 is required to build pyldns for Python 3.2 and greater.])])
269        else
270            AX_PKG_SWIG
271        fi
272
273	if test ! -x "$SWIG"; then
274		AC_MSG_ERROR([failed to find SWIG tool, install it, or do not build pyldns])
275	else
276		AC_DEFINE(HAVE_SWIG,1,[Define if you have SWIG libraries and header files.])
277		AC_SUBST(PYLDNS, "pyldns")
278		AC_SUBST(swig, "$SWIG")
279		ldns_with_pyldns=yes
280	fi
281   else
282	AC_MSG_RESULT([*** don't have Python, skipping SWIG, no pyldns ***]) # '
283   fi
284
285   # xtra cflags for pyldns
286   if test x_$ldns_have_python != x_no; then
287	ACX_CHECK_COMPILER_FLAG(fno-strict-aliasing, [PYTHON_X_CFLAGS="-fno-strict-aliasing"])
288	ACX_CHECK_COMPILER_FLAG(Wno-missing-field-initializers, [PYTHON_X_CFLAGS="-Wno-missing-field-initializers $PYTHON_X_CFLAGS"])
289	ACX_CHECK_COMPILER_FLAG(Wno-unused-parameter, [PYTHON_X_CFLAGS="-Wno-unused-parameter $PYTHON_X_CFLAGS"])
290	ACX_CHECK_COMPILER_FLAG(Wno-unused-variable, [PYTHON_X_CFLAGS="-Wno-unused-variable $PYTHON_X_CFLAGS"])
291   fi
292fi
293AC_SUBST(PYTHON_X_CFLAGS)
294
295# Check for pyldnsx
296AC_ARG_WITH(pyldnsx, AC_HELP_STRING([--without-pyldnsx],
297  [Do not install the ldnsx python module, or --with-pyldnsx to install it.]),
298  [],[ withval="with_pyldns" ])
299if test x_$withval != x_no; then
300  if test x_$ldns_with_pyldns != x_no; then
301    AC_SUBST(PYLDNSX, "pyldnsx")
302    ldns_with_pyldnsx=yes
303  else
304    if test x_$withval != x_with_pyldns; then
305      AC_MSG_ERROR([--with-pyldns is needed for the ldnsx python module])
306    fi
307  fi
308fi
309
310if test x_$ldns_with_pyldns != x_no; then
311  AC_SUBST(PYLDNSINST, "install-pyldns")dnl
312  AC_SUBST(PYLDNSUNINST, "uninstall-pyldns")
313else
314  AC_SUBST(PYLDNSINST, "")dnl
315  AC_SUBST(PYLDNSUNINST, "")
316fi
317if test x_$ldns_with_pyldnsx != x_no; then
318  AC_SUBST(PYLDNSXINST, "install-pyldnsx")dnl
319  AC_SUBST(PYLDNSXUNINST, "uninstall-pyldnsx")
320else
321  AC_SUBST(PYLDNSXINST, "")dnl
322  AC_SUBST(PYLDNSXUNINST, "")
323fi
324
325# check for perl
326ldns_with_p5_dns_ldns=no
327AC_ARG_WITH(p5-dns-ldns, AC_HELP_STRING([--with-p5-dns-ldns],
328 [generate DNS::LDNS perl bindings]),
329 [],[ withval="no" ])
330ldns_have_perl=no
331if test x_$withval != x_no; then
332   AC_PATH_PROG([PERL], [perl])
333   if test -z "$PERL"; then
334      AC_MSG_ERROR([Cannot find perl in your system path])
335   fi
336   AC_SUBST(P5_DNS_LDNS, "p5-dns-ldns")dnl
337   AC_SUBST(TEST_P5_DNS_LDNS, "test-p5-dns-ldns")dnl
338   AC_SUBST(INSTALL_P5_DNS_LDNS, "install-p5-dns-ldns")dnl
339   AC_SUBST(UNINSTALL_P5_DNS_LDNS, "uninstall-p5-dns-ldns")dnl
340   AC_SUBST(CLEAN_P5_DNS_LDNS, "clean-p5-dns-ldns")
341else
342   AC_SUBST(P5_DNS_LDNS, "")dnl
343   AC_SUBST(TEST_P5_DNS_LDNS, "")dnl
344   AC_SUBST(INSTALL_P5_DNS_LDNS, "")dnl
345   AC_SUBST(UNINSTALL_P5_DNS_LDNS, "")dnl
346   AC_SUBST(CLEAN_P5_DNS_LDNS, "")
347fi
348
349# Use libtool
350ACX_LIBTOOL_C_ONLY
351
352tmp_CPPFLAGS=$CPPFLAGS
353tmp_LDFLAGS=$LDFLAGS
354tmp_LIBS=$LIBS
355
356ACX_WITH_SSL_OPTIONAL
357AC_MSG_CHECKING([for LibreSSL])
358if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then
359	AC_MSG_RESULT([yes])
360	AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL])
361else
362	AC_MSG_RESULT([no])
363fi
364AC_CHECK_HEADERS([openssl/ssl.h openssl/evp.h openssl/engine.h openssl/conf.h])
365AC_CHECK_FUNCS([EVP_sha256 EVP_sha384 EVP_sha512 EVP_PKEY_keygen ECDSA_SIG_get0 EVP_MD_CTX_new DSA_SIG_set0 DSA_SIG_get0 EVP_dss1 DSA_get0_pqg DSA_get0_key EVP_cleanup ENGINE_cleanup ENGINE_free CRYPTO_cleanup_all_ex_data ERR_free_strings CONF_modules_unload OPENSSL_init_ssl OPENSSL_init_crypto ERR_load_crypto_strings CRYPTO_memcmp EVP_PKEY_get_base_id])
366AC_CHECK_DECLS([EVP_PKEY_base_id], [
367	AC_DEFINE_UNQUOTED([HAVE_EVP_PKEY_BASE_ID], [1], [Define to 1 if you have the EVP_PKEY_base_id function or macro.])
368], [], [AC_INCLUDES_DEFAULT
369#include <openssl/evp.h>
370])
371AC_MSG_CHECKING([Checking for OpenSSL >= 3.0.0])
372AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
373#include <openssl/ssl.h>
374#if OPENSSL_VERSION_MAJOR >= 3
375#define SOMETHING
376#else
377This fails compiling.
378So either no OpenSSL at all (the include already failed), or the version < 3.0.0
379#endif
380], [
381])], [
382	AC_MSG_RESULT(yes)
383	CFLAGS="-DOPENSSL_API_COMPAT=10100 $CFLAGS"
384], [	AC_MSG_RESULT(no)
385])
386
387
388# for macosx, see if glibtool exists and use that
389# BSD's need to know the version...
390#AC_CHECK_PROG(glibtool, glibtool, [glibtool], )
391#AC_CHECK_PROGS(libtool, [libtool15 libtool], [./libtool])
392
393AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
394case "$enable_sha2" in
395    no)
396        ;;
397    yes|*)
398        if test "x$HAVE_SSL" != "xyes"; then
399            AC_MSG_ERROR([SHA2 enabled, but no SSL support])
400        fi
401	AC_MSG_CHECKING(for SHA256 and SHA512)
402	AC_CHECK_FUNC(SHA256_Init, [], [
403		AC_MSG_ERROR([No SHA2 functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-sha2])
404		])
405	AC_DEFINE_UNQUOTED([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
406        ;;
407esac
408
409# check whether gost also works
410AC_DEFUN([AC_CHECK_GOST_WORKS],
411[AC_REQUIRE([AC_PROG_CC])
412AC_MSG_CHECKING([if GOST works])
413if test c${cross_compiling} = cno; then
414BAKCFLAGS="$CFLAGS"
415if test -n "$ssldir"; then
416    if test ! -d "$ssldir/lib" -a -d "$ssldir/lib64"; then
417	CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib64"
418    else
419	CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib"
420    fi
421fi
422AC_RUN_IFELSE([AC_LANG_SOURCE([[
423#include <string.h>
424#ifdef HAVE_OPENSSL_SSL_H
425#include <openssl/ssl.h>
426#endif
427#ifdef HAVE_OPENSSL_EVP_H
428#include <openssl/evp.h>
429#endif
430#ifdef HAVE_OPENSSL_ENGINE_H
431#include <openssl/engine.h>
432#endif
433#ifdef HAVE_OPENSSL_CONF_H
434#include <openssl/conf.h>
435#endif
436/* routine to load gost (from sldns) */
437int load_gost_id(void)
438{
439	static int gost_id = 0;
440	const EVP_PKEY_ASN1_METHOD* meth;
441	ENGINE* e;
442
443	if(gost_id) return gost_id;
444
445	/* see if configuration loaded gost implementation from other engine*/
446	meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
447	if(meth) {
448		EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
449		return gost_id;
450	}
451
452	/* see if engine can be loaded already */
453	e = ENGINE_by_id("gost");
454	if(!e) {
455		/* load it ourself, in case statically linked */
456		ENGINE_load_builtin_engines();
457		ENGINE_load_dynamic();
458		e = ENGINE_by_id("gost");
459	}
460	if(!e) {
461		/* no gost engine in openssl */
462		return 0;
463	}
464	if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
465		ENGINE_finish(e);
466		ENGINE_free(e);
467		return 0;
468	}
469
470	meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
471	if(!meth) {
472		/* algo not found */
473		ENGINE_finish(e);
474		ENGINE_free(e);
475		return 0;
476	}
477	EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
478	return gost_id;
479}
480int main(void) {
481	EVP_MD_CTX* ctx;
482	const EVP_MD* md;
483	unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */
484	const char* str = "Hello world";
485	const unsigned char check[] = {
486		0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 ,
487		0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 ,
488		0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d ,
489		0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d
490	};
491	OPENSSL_config(NULL);
492	(void)load_gost_id();
493	md = EVP_get_digestbyname("md_gost94");
494	if(!md) return 1;
495	memset(digest, 0, sizeof(digest));
496	ctx = EVP_MD_CTX_create();
497	if(!ctx) return 2;
498	if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3;
499	if(!EVP_DigestUpdate(ctx, str, 10)) return 4;
500	if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5;
501	/* uncomment to see the hash calculated.
502		{int i;
503		for(i=0; i<32; i++)
504			printf(" %2.2x", (int)digest[i]);
505		printf("\n");}
506	*/
507	if(memcmp(digest, check, sizeof(check)) != 0)
508		return 6;
509	return 0;
510}
511]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"])
512CFLAGS="$BAKCFLAGS"
513else
514eval "ac_cv_c_gost_works=maybe"
515fi
516])dnl
517
518AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
519case "$enable_gost" in
520    no)
521        ;;
522    *)  dnl default
523        if test "x$HAVE_SSL" != "xyes"; then
524            AC_MSG_ERROR([GOST enabled, but no SSL support])
525        fi
526        AC_MSG_CHECKING(for GOST)
527        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])])
528        AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([No ECC functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-gost])])
529	AC_CHECK_GOST_WORKS
530	AC_ARG_ENABLE(gost-anyway, AC_HELP_STRING([--enable-gost-anyway], [Enable GOST even without a GOST engine installed]))
531	if test "$ac_cv_c_gost_works" != "no" -o "$enable_gost_anyway" = "yes"; then
532		if test "$ac_cv_c_gost_works" = "no"; then
533			AC_MSG_RESULT([no, but compiling with GOST support anyway])
534		else
535			AC_MSG_RESULT([yes])
536		fi
537		use_gost="yes"
538		AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
539	else
540		AC_MSG_RESULT([no])
541		AC_MSG_WARN([Gost support does not work because the engine is missing.])
542		AC_MSG_WARN([Install gost-engine first or use the --enable-gost-anyway to compile with GOST support anyway])
543		AC_MSG_WARN([See also https://github.com/gost-engine/engine/wiki for information about gost-engine])
544	fi
545        ;;
546esac
547
548AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
549case "$enable_ecdsa" in
550    no)
551      ;;
552    *) dnl default
553      if test "x$HAVE_SSL" != "xyes"; then
554        AC_MSG_ERROR([ECDSA enabled, but no SSL support])
555      fi
556      AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade OpenSSL or rerun with --disable-ecdsa])])
557      AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade OpenSSL or rerun with --disable-ecdsa])])
558      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
559#include <openssl/evp.h>
560      ])
561      # we now know we have ECDSA and the required curves.
562      AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
563      ;;
564esac
565
566AC_ARG_ENABLE(dsa, AC_HELP_STRING([--disable-dsa], [Disable DSA support]))
567case "$enable_dsa" in
568    no)
569      AC_SUBST(ldns_build_config_use_dsa, 0)
570      ;;
571    *) dnl default
572      # detect if DSA is supported, and turn it off if not.
573      AC_CHECK_FUNC(DSA_SIG_new, [
574	AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.])
575	AC_SUBST(ldns_build_config_use_dsa, 1)
576      ], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.])
577	  fi
578	  AC_SUBST(ldns_build_config_use_dsa, 0)])
579      ;;
580esac
581
582AC_ARG_ENABLE(ed25519, AC_HELP_STRING([--disable-ed25519], [Disable (experimental) ED25519 support. Default is detect]))
583case "$enable_ed25519" in
584    no)
585      AC_SUBST(ldns_build_config_use_ed25519, 0)
586      ;;
587    *) dnl default
588      AC_CHECK_DECLS([NID_ED25519], [
589      	AC_DEFINE_UNQUOTED([USE_ED25519], [1], [Define this to enable ED25519 support.])
590        AC_SUBST(ldns_build_config_use_ed25519, 1)
591      ], [if test "x$enable_ed25519" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED25519 and you used --enable-ed25519.])
592          fi
593	  AC_SUBST(ldns_build_config_use_ed25519, 0)], [AC_INCLUDES_DEFAULT
594#include <openssl/evp.h>
595      ])
596      ;;
597esac
598
599AC_ARG_ENABLE(ed448, AC_HELP_STRING([--disable-ed448], [Disable (experimental) ED448 support. Default is detect]))
600case "$enable_ed448" in
601    no)
602      AC_SUBST(ldns_build_config_use_ed448, 0)
603      ;;
604    *) dnl default
605      AC_CHECK_DECLS([NID_ED448], [
606      	AC_DEFINE_UNQUOTED([USE_ED448], [1], [Define this to enable ED448 support.])
607        AC_SUBST(ldns_build_config_use_ed448, 1)
608      ], [if test "x$enable_ed448" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED448 and you used --enable-ed448.])
609          fi
610          AC_SUBST(ldns_build_config_use_ed448, 0)], [AC_INCLUDES_DEFAULT
611#include <openssl/evp.h>
612      ])
613      ;;
614esac
615
616AC_ARG_ENABLE(dane, AC_HELP_STRING([--disable-dane], [Disable DANE support]))
617AC_ARG_ENABLE(dane-verify, AC_HELP_STRING([--disable-dane-verify], [Disable DANE verify support]))
618AC_ARG_ENABLE(dane-ta-usage, AC_HELP_STRING([--disable-dane-ta-usage], [Disable DANE-TA usage type support]))
619
620AC_ARG_ENABLE(full-dane,, [
621	enable_dane_ta_usage=yes
622	enable_dane_verify=yes
623	enable_dane=yes
624])
625AC_ARG_ENABLE(no-dane-ta-usage,, [
626	enable_dane_ta_usage=no
627	enable_dane_verify=yes
628	enable_dane=yes
629])
630AC_ARG_ENABLE(no-dane-verify,, [
631	enable_dane_ta_usage=no
632	enable_dane_verify=no
633	enable_dane=yes
634])
635case "$enable_dane" in
636    no)
637      AC_SUBST(ldns_build_config_use_dane, 0)
638      AC_SUBST(ldns_build_config_use_dane_verify, 0)
639      AC_SUBST(ldns_build_config_use_dane_ta_usage, 0)
640      ;;
641    *) dnl default
642      if test "x$HAVE_SSL" != "xyes"; then
643        AC_MSG_ERROR([DANE enabled, but no SSL support])
644      fi
645      AC_CHECK_FUNC(X509_check_ca, [], [AC_MSG_ERROR([OpenSSL does not support DANE: please upgrade OpenSSL or rerun with --disable-dane])])
646      AC_SUBST(ldns_build_config_use_dane, 1)
647      AC_DEFINE_UNQUOTED([USE_DANE], [1], [Define this to enable DANE support.])
648      case "$enable_dane_verify" in
649          no)
650            AC_SUBST(ldns_build_config_use_dane_verify, 0)
651            AC_SUBST(ldns_build_config_use_dane_ta_usage, 0)
652	    ;;
653	  *)
654	    AC_SUBST(ldns_build_config_use_dane_verify, 1)
655	    AC_DEFINE_UNQUOTED([USE_DANE_VERIFY], [1], [Define this to enable DANE verify support.])
656            case "$enable_dane_ta_usage" in
657                no)
658                  AC_SUBST(ldns_build_config_use_dane_ta_usage, 0)
659                  ;;
660                *) dnl default
661		  danetmpLIBS="$LIBS"
662                  LIBS="-lssl -lcrypto $LIBS"
663                  AC_CHECK_FUNC(SSL_get0_dane, [], [AC_MSG_ERROR([OpenSSL does not support offline DANE verification (Needed for the DANE-TA usage type).  Please upgrade OpenSSL to version >= 1.1.0 or rerun with --disable-dane-verify or --disable-dane-ta-usage])])
664                  LIBSSL_LIBS="-lssl $LIBSSL_LIBS"
665		  LIBS="$danetmpLIBS"
666                  AC_SUBST(ldns_build_config_use_dane_ta_usage, 1)
667                  AC_DEFINE_UNQUOTED([USE_DANE_TA_USAGE], [1], [Define this to enable DANE-TA usage type support.])
668                  ;;
669            esac
670      esac
671      ;;
672esac
673
674AC_ARG_ENABLE(rrtype-ninfo, AC_HELP_STRING([--enable-rrtype-ninfo], [Enable draft RR type ninfo.]))
675case "$enable_rrtype_ninfo" in
676	yes)
677		AC_DEFINE_UNQUOTED([RRTYPE_NINFO], [], [Define this to enable RR type NINFO.])
678		;;
679	no|*)
680		;;
681esac
682AC_ARG_ENABLE(rrtype-rkey, AC_HELP_STRING([--enable-rrtype-rkey], [Enable draft RR type rkey.]))
683case "$enable_rrtype_rkey" in
684	yes)
685		AC_DEFINE_UNQUOTED([RRTYPE_RKEY], [], [Define this to enable RR type RKEY.])
686		;;
687	no|*)
688		;;
689esac
690AC_ARG_ENABLE(rrtype-openpgpkey, AC_HELP_STRING([--disable-rrtype-openpgpkey], [Disable openpgpkey RR type.]))
691case "$enable_rrtype_openpgpkey" in
692	no)
693		;;
694	yes|*)
695		AC_DEFINE_UNQUOTED([RRTYPE_OPENPGPKEY], [], [Define this to enable RR type OPENPGPKEY.])
696		;;
697esac
698AC_ARG_ENABLE(rrtype-ta, AC_HELP_STRING([--enable-rrtype-ta], [Enable draft RR type ta.]))
699case "$enable_rrtype_ta" in
700	yes)
701		AC_DEFINE_UNQUOTED([RRTYPE_TA], [], [Define this to enable RR type TA.])
702		;;
703	no|*)
704		;;
705esac
706AC_ARG_ENABLE(rrtype-avc, AC_HELP_STRING([--enable-rrtype-avc], [Enable draft RR type avc.]))
707case "$enable_rrtype_avc" in
708	yes)
709		AC_DEFINE_UNQUOTED([RRTYPE_AVC], [], [Define this to enable RR type AVC.])
710		;;
711	no|*)
712		;;
713esac
714AC_ARG_ENABLE(rrtype-doa, AC_HELP_STRING([--enable-rrtype-doa], [Enable draft RR type DOA.]))
715case "$enable_rrtype_doa" in
716	yes)
717		AC_DEFINE_UNQUOTED([RRTYPE_DOA], [], [Define this to enable RR type DOA.])
718		;;
719	no|*)
720		;;
721esac
722AC_ARG_ENABLE(rrtype-amtrelay, AC_HELP_STRING([--enable-rrtype-amtrelay], [Enable draft RR type AMTRELAY.]))
723case "$enable_rrtype_amtrelay" in
724	yes)
725		AC_DEFINE_UNQUOTED([RRTYPE_AMTRELAY], [], [Define this to enable RR type AMTRELAY.])
726		;;
727	no|*)
728		;;
729esac
730AC_ARG_ENABLE(rrtype-svcb-https, AC_HELP_STRING([--disable-rrtype-svcb-https], [Disable RR types SVCB and HTTPS.]))
731case "$enable_rrtype_svcb_https" in
732	no)
733		;;
734	yes|*)
735		AC_DEFINE_UNQUOTED([RRTYPE_SVCB_HTTPS], [], [Define this to enable RR types SVCB and HTTPS.])
736		;;
737esac
738
739
740
741AC_SUBST(LIBSSL_CPPFLAGS)
742AC_SUBST(LIBSSL_LDFLAGS)
743AC_SUBST(LIBSSL_LIBS)
744if test "x$HAVE_SSL" = "xyes"; then
745    if echo "$LIBSSL_LIBS" | grep -- "-lssl" >/dev/null 2>&1; then
746	LIBSSL_SSL_LIBS="$LIBSSL_LIBS"
747    else
748	LIBSSL_SSL_LIBS="-lssl $LIBSSL_LIBS"
749    fi
750    AC_SUBST(LIBSSL_SSL_LIBS, "$LIBSSL_SSL_LIBS")
751fi
752CPPFLAGS=$tmp_CPPFLAGS
753LDFLAGS=$tmp_LDFLAGS
754LIBS=$tmp_LIBS
755
756
757# add option to disable the evil rpath
758ACX_ARG_RPATH
759
760#AC_RUN_IFELSE([AC_LANG_SOURCE(
761#[
762#int main()
763#{
764#short one = 1;
765#char *cp = (char*)&one;
766#if ( *cp == 0 )
767#return(0);
768#else
769#return(1);
770#}
771#])], [],[
772#AC_DEFINE(CONFCHECK_LITTLE_ENDIAN, 1, [system appears to be little-endian])
773#],[])
774
775# should define WORDS_BIGENDIAN if the system is big-endian
776AC_C_BIGENDIAN
777
778# Checks for header files.
779AC_HEADER_STDC
780AC_HEADER_STDBOOL
781#AC_HEADER_SYS_WAIT
782#AC_CHECK_HEADERS([getopt.h fcntl.h stdlib.h string.h strings.h unistd.h])
783# do the very minimum - we can always extend this
784AC_CHECK_HEADERS([getopt.h stdarg.h openssl/ssl.h netinet/in.h time.h arpa/inet.h netdb.h],,, [AC_INCLUDES_DEFAULT])
785AC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
786[AC_INCLUDES_DEFAULT
787  [
788   #if HAVE_SYS_PARAM_H
789   # include <sys/param.h>
790   #endif
791  ]
792])
793AC_CHECK_HEADER(sys/socket.h,
794[
795include_sys_socket_h='#include <sys/socket.h>'
796AC_DEFINE(HAVE_SYS_SOCKET_H, 1, [define if you have sys/socket.h])
797],[
798include_sys_socket_h=''
799],[AC_INCLUDES_DEFAULT
800  [
801   #if HAVE_SYS_PARAM_H
802   # include <sys/param.h>
803   #endif
804  ]
805])
806AC_SUBST(include_sys_socket_h)
807AC_CHECK_HEADER(inttypes.h,
808[
809include_inttypes_h='#include <inttypes.h>'
810AC_DEFINE(HAVE_INTTYPES_H, 1, [define if you have inttypes.h])
811AC_SUBST(ldns_build_config_have_inttypes_h, 1)
812],[
813include_inttypes_h=''
814AC_SUBST(ldns_build_config_have_inttypes_h, 0)
815],[AC_INCLUDES_DEFAULT
816])
817AC_SUBST(include_inttypes_h)
818AC_CHECK_HEADER(sys/types.h,
819[
820include_systypes_h='#include <sys/types.h>'
821AC_DEFINE(HAVE_SYS_TYPES_H, 1, [define if you have sys/types.h])
822],[
823include_systypes_h=''
824],[AC_INCLUDES_DEFAULT
825])
826AC_SUBST(include_systypes_h)
827AC_CHECK_HEADER(unistd.h,
828[
829include_unistd_h='#include <unistd.h>'
830AC_DEFINE(HAVE_UNISTD_H, 1, [define if you have unistd.h])
831],[
832include_unistd_h=''
833],[AC_INCLUDES_DEFAULT
834])
835AC_SUBST(include_unistd_h)
836
837AC_CHECK_SIZEOF(time_t,,[
838AC_INCLUDES_DEFAULT
839#ifdef TIME_WITH_SYS_TIME
840# include <sys/time.h>
841# include <time.h>
842#else
843# ifdef HAVE_SYS_TIME_H
844#  include <sys/time.h>
845# else
846#  include <time.h>
847# endif
848#endif
849])
850
851if test x_$with_examples != x_no; then
852AC_CHECK_HEADERS([pcap.h],,, [AC_INCLUDES_DEFAULT])
853AC_CHECK_LIB(pcap, pcap_open_offline, [
854	AC_DEFINE([HAVE_LIBPCAP], [1], [Define to 1 if you have the `pcap' library (-lpcap).])dnl`
855	AC_SUBST([LIBPCAP_LIBS], [-lpcap])
856    ], [
857	AC_MSG_WARN([Can't find pcap library (needed for ldns-dpa, will not build dpa now.)])dnl'
858	AC_SUBST([LIBPCAP_LIBS], [])
859    ]
860)
861AC_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],,, [
862AC_INCLUDES_DEFAULT
863#ifdef HAVE_NETINET_IN_SYSTM_H
864#include <netinet/in_systm.h>
865#endif
866#ifdef HAVE_NETINET_IN_H
867#include <netinet/in.h>
868#endif
869#ifdef HAVE_SYS_SOCKET_H
870#include <sys/socket.h>
871#endif
872#ifdef HAVE_NET_IF_H
873#include <net/if.h>
874#endif])
875fi
876
877ACX_TYPE_SOCKLEN_T
878if test "x$ac_cv_type_socklen_t" = xyes; then
879  AC_SUBST(ldns_build_config_have_socklen_t, 1)
880else
881  AC_SUBST(ldns_build_config_have_socklen_t, 0)
882fi
883AC_TYPE_SIZE_T
884AC_CHECK_TYPE(ssize_t, int)
885dnl AC_TYPE_INTPTR_T does not work on all platforms (autoconf)
886AC_CHECK_TYPE(intptr_t, size_t)
887AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
888#if HAVE_SYS_TYPES_H
889# include <sys/types.h>
890#endif
891#if HAVE_NETINET_IN_H
892# include <netinet/in.h>
893#endif])
894AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
895#if HAVE_SYS_TYPES_H
896# include <sys/types.h>
897#endif
898#if HAVE_NETINET_IN_H
899# include <netinet/in.h>
900#endif])
901ACX_CHECK_SS_FAMILY
902
903# AC_FUNC_MALLOC suffers false failures and causes Asan failures.
904# AC_FUNC_MALLOC
905# AC_FUNC_REALLOC
906
907AC_REPLACE_FUNCS(b64_pton)
908AC_REPLACE_FUNCS(b64_ntop)
909AC_REPLACE_FUNCS(calloc)
910AC_REPLACE_FUNCS(timegm)
911AC_REPLACE_FUNCS(gmtime_r)
912AC_REPLACE_FUNCS(ctime_r)
913AC_REPLACE_FUNCS(localtime_r)
914AC_REPLACE_FUNCS(isblank)
915AC_REPLACE_FUNCS(isascii)
916AC_REPLACE_FUNCS(inet_aton)
917AC_REPLACE_FUNCS(inet_pton)
918AC_REPLACE_FUNCS(inet_ntop)
919AC_REPLACE_FUNCS(snprintf)
920AC_REPLACE_FUNCS(strlcpy)
921AC_REPLACE_FUNCS(memmove)
922AC_FUNC_FORK
923AC_MSG_CHECKING([compile of fork])
924AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
925#include <unistd.h>
926], [
927	(void)fork();
928])], [
929	AC_MSG_RESULT(yes)
930	AC_DEFINE([HAVE_FORK_AVAILABLE], 1, [if fork is available for compile])
931], [	AC_MSG_RESULT(no)
932])
933AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul bzero memset b32_ntop b32_pton])
934if test "x$HAVE_B32_NTOP" = "xyes"; then
935	AC_SUBST(ldns_build_config_have_b32_ntop, 1)
936else
937	AC_SUBST(ldns_build_config_have_b32_ntop, 0)
938fi
939if test "x$HAVE_B32_PTON" = "xyes"; then
940	AC_SUBST(ldns_build_config_have_b32_pton, 1)
941else
942	AC_SUBST(ldns_build_config_have_b32_pton, 0)
943fi
944
945ACX_CHECK_GETADDRINFO_WITH_INCLUDES
946if test $ac_cv_func_getaddrinfo = no; then
947	AC_LIBOBJ([fake-rfc2553])
948fi
949if test "$USE_WINSOCK" = 1; then
950	AC_CHECK_TOOL(WINDRES, windres)
951fi
952ACX_FUNC_IOCTLSOCKET
953
954#AC_SEARCH_LIBS(RSA_new, [crypto])
955
956ACX_CHECK_FORMAT_ATTRIBUTE
957ACX_CHECK_UNUSED_ATTRIBUTE
958
959AC_ARG_WITH(xcode-sdk, AC_HELP_STRING([--with-xcode-sdk],
960 [Set xcode SDK version. Default is autodetect]),
961 [],[with_xcode_sdk="yes"])
962if test "x_$with_xcode_sdk" != "x_no" ; then
963   # check OSX deployment target, if needed
964   if echo $target_os | grep darwin > /dev/null; then
965     sdk_p=`xcode-select -print-path`;
966     if test "x_$with_xcode_sdk" = "x_yes" ; then
967        sdk_v="$( /usr/bin/xcrun --show-sdk-version 2>/dev/null )"
968     else
969        sdk_v="$with_xcode_sdk"
970     fi
971     # xcrun only got that option in 10.7
972     if test -z "$sdk_v" ; then
973        sdk_c="10.6"
974        sdk_v="10.6"
975     fi
976     SYSROOT="$( find ${sdk_p} -name MacOSX${sdk_v}.sdk )"
977     case $sdk_v in
978          10.9|10.8)   sdk_c="10.7";;
979          10.11|10.10|*) sdk_c="10.10";;
980     esac
981     export MACOSX_DEPLOYMENT_TARGET="${sdk_c}";
982     export CFLAGS="$CFLAGS -mmacosx-version-min=${sdk_c} -isysroot ${SYSROOT}"
983   fi
984fi
985
986AC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir])
987
988AC_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]]), [
989 AC_SUBST([LDNS_TRUST_ANCHOR_FILE], ["$withval"])
990 AC_MSG_NOTICE([Default trust anchor: $withval])
991],[
992 AC_SUBST([LDNS_TRUST_ANCHOR_FILE], ["\$(sysconfdir)/unbound/root.key"])
993])
994
995AC_ARG_WITH(ca-file, AC_HELP_STRING([--with-ca-file=CAFILE], [File containing CA certificates for ldns-dane]), [
996 AC_DEFINE([HAVE_DANE_CA_FILE], [1], [Is a CAFILE given at configure time])
997 AC_DEFINE_UNQUOTED([LDNS_DANE_CA_FILE], ["$withval"], [Is a CAFILE given at configure time])
998 AC_MSG_NOTICE([Using CAfile: $withval])
999 AC_SUBST(DEFAULT_CAFILE, ["Default is $withval"])
1000],[
1001 AC_DEFINE([HAVE_DANE_CA_FILE], [0], [Is a CAFILE given at configure time])
1002 AC_SUBST(DEFAULT_CAFILE, [])
1003])
1004
1005AC_ARG_WITH(ca-path, AC_HELP_STRING([--with-ca-path=CAPATH], [Directory containing CA certificate files for ldns-dane]), [
1006 AC_DEFINE([HAVE_DANE_CA_PATH], [1], [Is a CAPATH given at configure time])
1007 AC_DEFINE_UNQUOTED([LDNS_DANE_CA_PATH], ["$withval"], [Is a CAPATH given at configure time])
1008 AC_MSG_NOTICE([Using CApath: $withval])
1009 AC_SUBST(DEFAULT_CAPATH, ["Default is $withval"])
1010],[
1011 AC_DEFINE([HAVE_DANE_CA_PATH], [0], [Is a CAPATH given at configure time])
1012 AC_SUBST(DEFAULT_CAPATH, [])
1013])
1014
1015AH_BOTTOM([
1016#include <stdio.h>
1017#include <string.h>
1018#include <unistd.h>
1019#include <assert.h>
1020
1021#ifndef LITTLE_ENDIAN
1022#define LITTLE_ENDIAN 1234
1023#endif
1024
1025#ifndef BIG_ENDIAN
1026#define BIG_ENDIAN 4321
1027#endif
1028
1029#ifndef BYTE_ORDER
1030#ifdef WORDS_BIGENDIAN
1031#define BYTE_ORDER BIG_ENDIAN
1032#else
1033#define BYTE_ORDER LITTLE_ENDIAN
1034#endif /* WORDS_BIGENDIAN */
1035#endif /* BYTE_ORDER */
1036
1037#if STDC_HEADERS
1038#include <stdlib.h>
1039#include <stddef.h>
1040#endif
1041
1042#ifdef HAVE_STDINT_H
1043#include <stdint.h>
1044#endif
1045
1046#ifdef HAVE_SYS_SOCKET_H
1047#include <sys/socket.h>
1048#endif
1049
1050#ifdef HAVE_NETINET_IN_H
1051#include <netinet/in.h>
1052#endif
1053
1054#ifdef HAVE_ARPA_INET_H
1055#include <arpa/inet.h>
1056#endif
1057
1058#ifdef HAVE_WINSOCK2_H
1059#include <winsock2.h>
1060#endif
1061
1062#ifdef HAVE_WS2TCPIP_H
1063#include <ws2tcpip.h>
1064#endif
1065]
1066AHX_CONFIG_W32_FD_SET_T
1067)
1068
1069AH_BOTTOM([
1070#ifdef __cplusplus
1071extern "C" {
1072#endif
1073
1074int ldns_b64_ntop(uint8_t const *src, size_t srclength,
1075	 	  char *target, size_t targsize);
1076/**
1077 * calculates the size needed to store the result of b64_ntop
1078 */
1079/*@unused@*/
1080static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize)
1081{
1082	return ((((srcsize + 2) / 3) * 4) + 1);
1083}
1084int ldns_b64_pton(char const *src, uint8_t *target, size_t targsize);
1085/**
1086 * calculates the size needed to store the result of ldns_b64_pton
1087 */
1088/*@unused@*/
1089static inline size_t ldns_b64_pton_calculate_size(size_t srcsize)
1090{
1091	return (((((srcsize + 3) / 4) * 3)) + 1);
1092}
1093
1094/**
1095 * Given in dnssec_zone.c, also used in dnssec_sign.c:w
1096
1097 */
1098int ldns_dname_compare_v(const void *a, const void *b);
1099
1100#ifndef HAVE_SLEEP
1101/* use windows sleep, in millisecs, instead */
1102#define sleep(x) Sleep((x)*1000)
1103#endif
1104
1105#ifndef HAVE_RANDOM
1106#define srandom(x) srand(x)
1107#define random(x) rand(x)
1108#endif
1109
1110#ifndef HAVE_TIMEGM
1111#include <time.h>
1112time_t timegm (struct tm *tm);
1113#endif /* !TIMEGM */
1114#ifndef HAVE_GMTIME_R
1115struct tm *gmtime_r(const time_t *timep, struct tm *result);
1116#endif
1117#ifndef HAVE_LOCALTIME_R
1118struct tm *localtime_r(const time_t *timep, struct tm *result);
1119#endif
1120#ifndef HAVE_ISBLANK
1121int isblank(int c);
1122#endif /* !HAVE_ISBLANK */
1123#ifndef HAVE_ISASCII
1124int isascii(int c);
1125#endif /* !HAVE_ISASCII */
1126#ifndef HAVE_SNPRINTF
1127#include <stdarg.h>
1128int snprintf (char *str, size_t count, const char *fmt, ...);
1129int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
1130#endif /* HAVE_SNPRINTF */
1131#ifndef HAVE_INET_PTON
1132int inet_pton(int af, const char* src, void* dst);
1133#endif /* HAVE_INET_PTON */
1134#ifndef HAVE_INET_NTOP
1135const char *inet_ntop(int af, const void *src, char *dst, size_t size);
1136#endif
1137#ifndef HAVE_INET_ATON
1138int inet_aton(const char *cp, struct in_addr *addr);
1139#endif
1140#ifndef HAVE_MEMMOVE
1141void *memmove(void *dest, const void *src, size_t n);
1142#endif
1143#ifndef HAVE_STRLCPY
1144size_t strlcpy(char *dst, const char *src, size_t siz);
1145#endif
1146
1147#ifdef USE_WINSOCK
1148#define SOCK_INVALID INVALID_SOCKET
1149#define close_socket(_s) do { if (_s != SOCK_INVALID) {closesocket(_s); _s = -1;} } while(0)
1150#else
1151#define SOCK_INVALID -1
1152#define close_socket(_s) do { if (_s != SOCK_INVALID) {close(_s); _s = -1;} } while(0)
1153#endif
1154
1155#ifdef __cplusplus
1156}
1157#endif
1158#ifndef HAVE_GETADDRINFO
1159#include "compat/fake-rfc2553.h"
1160#endif
1161#ifndef HAVE_STRTOUL
1162#define strtoul (unsigned long)strtol
1163#endif
1164])
1165
1166if test "x$HAVE_SSL" = "xyes"; then
1167	AC_SUBST(ldns_build_config_have_ssl, 1)
1168else
1169	AC_SUBST(ldns_build_config_have_ssl, 0)
1170fi
1171if test "x$ac_cv_c_format_attribute" = "xyes"; then
1172  AC_SUBST(ldns_build_config_have_attr_format, 1)
1173else
1174  AC_SUBST(ldns_build_config_have_attr_format, 0)
1175fi
1176if test "x$ac_cv_c_unused_attribute" = "xyes"; then
1177  AC_SUBST(ldns_build_config_have_attr_unused, 1)
1178else
1179  AC_SUBST(ldns_build_config_have_attr_unused, 0)
1180fi
1181
1182CONFIG_FILES="Makefile libdns.doxygen ldns/common.h ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config"
1183AC_SUBST(CONFIG_FILES)
1184AC_CONFIG_FILES([$CONFIG_FILES])
1185
1186AC_CONFIG_HEADER([ldns/config.h])
1187AC_OUTPUT
1188COPY_HEADER_FILES(ldns/, ldns/)
1189
1190dnl AC_CONFIG_SUBDIRS([drill])
1191