2 # Process this file with autoconf to produce a configure script.
4 sinclude(acx_nlnetlabs.m4)
6 # must be numbers. ac_defun because of later processing.
7 m4_define([VERSION_MAJOR],[1])
8 m4_define([VERSION_MINOR],[8])
9 m4_define([VERSION_MICRO],[3])
10 AC_INIT(ldns, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), libdns@nlnetlabs.nl, libdns)
11 AC_CONFIG_SRCDIR([packet.c])
12 # needed to build correct soname
13 AC_SUBST(LDNS_VERSION_MAJOR, [VERSION_MAJOR])
14 AC_SUBST(LDNS_VERSION_MINOR, [VERSION_MINOR])
15 AC_SUBST(LDNS_VERSION_MICRO, [VERSION_MICRO])
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
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
37 AC_SUBST(VERSION_INFO, [8:0:5])
40 if test "$ac_cv_header_minix_config_h" = "yes"; then
41 AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix])
44 AC_CONFIG_MACRO_DIR([m4])
47 CPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}}
50 # Checks for programs.
55 # Extra (sp)lint flags for NetBSD
58 netbsd*) LINTFLAGS="'-D__RENAME(x)=' -D_NETINET_IN_H_ $LINTFLAGS"
60 *) LINTFLAGS="$LINTFLAGS"
65 AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
67 ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
68 ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
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
74 AC_DEFUN([COPY_FILES],
77 sh $srcdir/install-sh -m 644 $file $2
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)
84 AC_DEFUN([COPY_HEADER_FILES],
86 echo "copying header files"
87 COPY_FILES($srcdir/$1/*.h, $2)
90 # Checks for typedefs, structures, and compiler characteristics.
93 if test "x$CFLAGS" = "x" ; then
94 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="-g"])
95 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="-O2 $CFLAGS"])
97 ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="-Wall $CFLAGS"])
98 ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="-W $CFLAGS"])
99 ACX_CHECK_COMPILER_FLAG(Wwrite-strings, [CFLAGS="-Wwrite-strings $CFLAGS"])
100 ACX_CHECK_COMPILER_FLAG(Wstrict-prototypes, [CFLAGS="-Wstrict-prototypes $CFLAGS"])
101 #ACX_CHECK_COMPILER_FLAG(Wshadow, [CFLAGS="-Wshadow $CFLAGS"])
102 ACX_CHECK_COMPILER_FLAG(Wunused-function, [CFLAGS="-Wunused-function $CFLAGS"])
103 ACX_CHECK_COMPILER_FLAG(Wmissing-prototypes, [CFLAGS="-Wmissing-prototypes $CFLAGS"])
104 ACX_CHECK_COMPILER_FLAG(fno-strict-aliasing, [CFLAGS="-fno-strict-aliasing $CFLAGS"])
106 AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
109 AC_CHECK_HEADERS([winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
112 # Check for Apple header. This uncovers TARGET_OS_IPHONE, TARGET_OS_TV or TARGET_OS_WATCH
113 AC_CHECK_HEADERS([TargetConditionals.h])
115 ACX_DETERMINE_EXT_FLAGS_UNBOUND
118 AC_CHECK_TYPE(int8_t, char)
119 AC_CHECK_TYPE(int16_t, short)
120 AC_CHECK_TYPE(int32_t, int)
121 AC_CHECK_TYPE(int64_t, long long)
122 AC_CHECK_TYPE(uint8_t, unsigned char)
123 AC_CHECK_TYPE(uint16_t, unsigned short)
124 AC_CHECK_TYPE(uint32_t, unsigned int)
125 AC_CHECK_TYPE(uint64_t, unsigned long long)
128 AC_CHECK_PROG(doxygen, doxygen, doxygen)
130 # check to see if libraries are needed for these functions.
131 AC_CHECK_FUNC([socket],
133 [AC_SEARCH_LIBS([socket], [socket])
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.
140 AC_CHECK_FUNC([inet_ntop],
142 [AC_SEARCH_LIBS([inet_ntop], [socket c nsl resolv], [ac_cv_func_inet_ntop=yes])
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.
149 AC_CHECK_FUNC([inet_pton],
151 [AC_SEARCH_LIBS([inet_pton], [socket c nsl resolv], [ac_cv_func_inet_pton=yes])
155 AC_ARG_WITH(drill, AC_HELP_STRING([--with-drill],
156 [Also build drill.]),
157 [],[with_drill="no"])
158 if 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
166 A config.h was detected in the drill subdirectory.
167 This does not work with the --with-drill option.
168 Please remove the config.h from the drill subdirectory
169 or do not use the --with-drill option.])
173 AC_SUBST(INSTALL_DRILL,[""])
174 AC_SUBST(UNINSTALL_DRILL,[""])
175 AC_SUBST(CLEAN_DRILL,[""])
176 AC_SUBST(LINT_DRILL,[""])
180 AC_ARG_WITH(examples, AC_HELP_STRING([--with-examples],
181 [Also build examples.]),
182 [],[with_examples="no"])
183 if 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
191 A config.h was detected in the examples subdirectory.
192 This does not work with the --with-examples option.
193 Please remove the config.h from the examples subdirectory
194 or do not use the --with-examples option.])
197 AC_SUBST(EXAMPLES,[""])
198 AC_SUBST(INSTALL_EXAMPLES,[""])
199 AC_SUBST(UNINSTALL_EXAMPLES,[""])
200 AC_SUBST(CLEAN_EXAMPLES,[""])
201 AC_SUBST(LINT_EXAMPLES,[""])
204 # add option to disable installation of ldns-config script
205 AC_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)
207 if 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])
213 AC_SUBST(INSTALL_CONFIG, [""])
214 AC_SUBST(INSTALL_CONFIG_MANPAGE, [""])
215 AC_SUBST(UNINSTALL_CONFIG, [""])
216 AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [""])
219 # add option to disable library printing to stderr
220 AC_ARG_ENABLE(stderr-msgs, AC_HELP_STRING([--enable-stderr-msgs], [Enable printing to stderr (default=disabled)]), enable_stderr_msgs=$enableval, enable_stderr_msgs=no)
221 case "$enable_stderr_msgs" in
225 AC_DEFINE_UNQUOTED([STDERR_MSGS], [1], [Define this to enable messages to stderr.])
230 [AX_CONFIG_FEATURE_ENABLE(poll)],
231 [AX_CONFIG_FEATURE_DISABLE(poll)])
233 [poll], [This platform supports poll(7)],
234 [HAVE_POLL], [This platform supports poll(7).])
240 AC_ARG_WITH(pyldns, AC_HELP_STRING([--with-pyldns],
241 [generate python library, or --without-pyldns to disable Python support.]),
244 if test x_$withval != x_no; then
245 sinclude(ax_python_devel.m4)
246 ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
248 AX_PYTHON_DEVEL([>= '2.4.0'])
249 if test ! -z "$ac_python_version"; then
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"])
261 if test x_$ldns_have_python != x_no; then
262 sinclude(ax_pkg_swig.m4)
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.])])
273 if test ! -x "$SWIG"; then
274 AC_MSG_ERROR([failed to find SWIG tool, install it, or do not build pyldns])
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")
282 AC_MSG_RESULT([*** don't have Python, skipping SWIG, no pyldns ***]) # '
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"])
293 AC_SUBST(PYTHON_X_CFLAGS)
296 AC_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" ])
299 if 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
304 if test x_$withval != x_with_pyldns; then
305 AC_MSG_ERROR([--with-pyldns is needed for the ldnsx python module])
310 if test x_$ldns_with_pyldns != x_no; then
311 AC_SUBST(PYLDNSINST, "install-pyldns")dnl
312 AC_SUBST(PYLDNSUNINST, "uninstall-pyldns")
314 AC_SUBST(PYLDNSINST, "")dnl
315 AC_SUBST(PYLDNSUNINST, "")
317 if test x_$ldns_with_pyldnsx != x_no; then
318 AC_SUBST(PYLDNSXINST, "install-pyldnsx")dnl
319 AC_SUBST(PYLDNSXUNINST, "uninstall-pyldnsx")
321 AC_SUBST(PYLDNSXINST, "")dnl
322 AC_SUBST(PYLDNSXUNINST, "")
326 ldns_with_p5_dns_ldns=no
327 AC_ARG_WITH(p5-dns-ldns, AC_HELP_STRING([--with-p5-dns-ldns],
328 [generate DNS::LDNS perl bindings]),
331 if 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])
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")
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, "")
352 tmp_CPPFLAGS=$CPPFLAGS
356 ACX_WITH_SSL_OPTIONAL
357 AC_MSG_CHECKING([for LibreSSL])
358 if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then
360 AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL])
364 AC_CHECK_HEADERS([openssl/ssl.h openssl/evp.h openssl/engine.h openssl/conf.h])
365 AC_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])
366 AC_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>
371 AC_MSG_CHECKING([Checking for OpenSSL >= 3.0.0])
372 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
373 #include <openssl/ssl.h>
374 #if OPENSSL_VERSION_MAJOR >= 3
377 This fails compiling.
378 So either no OpenSSL at all (the include already failed), or the version < 3.0.0
383 CFLAGS="-DOPENSSL_API_COMPAT=10100 $CFLAGS"
384 ], [ AC_MSG_RESULT(no)
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])
393 AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
394 case "$enable_sha2" in
398 if test "x$HAVE_SSL" != "xyes"; then
399 AC_MSG_ERROR([SHA2 enabled, but no SSL support])
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])
405 AC_DEFINE_UNQUOTED([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
409 # check whether gost also works
410 AC_DEFUN([AC_CHECK_GOST_WORKS],
411 [AC_REQUIRE([AC_PROG_CC])
412 AC_MSG_CHECKING([if GOST works])
413 if test c${cross_compiling} = cno; then
415 if test -n "$ssldir"; then
416 if test ! -d "$ssldir/lib" -a -d "$ssldir/lib64"; then
417 CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib64"
419 CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib"
422 AC_RUN_IFELSE([AC_LANG_SOURCE([[
424 #ifdef HAVE_OPENSSL_SSL_H
425 #include <openssl/ssl.h>
427 #ifdef HAVE_OPENSSL_EVP_H
428 #include <openssl/evp.h>
430 #ifdef HAVE_OPENSSL_ENGINE_H
431 #include <openssl/engine.h>
433 #ifdef HAVE_OPENSSL_CONF_H
434 #include <openssl/conf.h>
436 /* routine to load gost (from sldns) */
437 int load_gost_id(void)
439 static int gost_id = 0;
440 const EVP_PKEY_ASN1_METHOD* meth;
443 if(gost_id) return gost_id;
445 /* see if configuration loaded gost implementation from other engine*/
446 meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
448 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
452 /* see if engine can be loaded already */
453 e = ENGINE_by_id("gost");
455 /* load it ourself, in case statically linked */
456 ENGINE_load_builtin_engines();
457 ENGINE_load_dynamic();
458 e = ENGINE_by_id("gost");
461 /* no gost engine in openssl */
464 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
470 meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
477 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
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
491 OPENSSL_config(NULL);
492 (void)load_gost_id();
493 md = EVP_get_digestbyname("md_gost94");
495 memset(digest, 0, sizeof(digest));
496 ctx = EVP_MD_CTX_create();
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.
504 printf(" %2.2x", (int)digest[i]);
507 if(memcmp(digest, check, sizeof(check)) != 0)
511 ]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"])
514 eval "ac_cv_c_gost_works=maybe"
518 AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
519 case "$enable_gost" in
523 if test "x$HAVE_SSL" != "xyes"; then
524 AC_MSG_ERROR([GOST enabled, but no SSL support])
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])])
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])
538 AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
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])
548 AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
549 case "$enable_ecdsa" in
553 if test "x$HAVE_SSL" != "xyes"; then
554 AC_MSG_ERROR([ECDSA enabled, but no SSL support])
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>
561 # we now know we have ECDSA and the required curves.
562 AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
566 AC_ARG_ENABLE(dsa, AC_HELP_STRING([--disable-dsa], [Disable DSA support]))
567 case "$enable_dsa" in
569 AC_SUBST(ldns_build_config_use_dsa, 0)
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.])
578 AC_SUBST(ldns_build_config_use_dsa, 0)])
582 AC_ARG_ENABLE(ed25519, AC_HELP_STRING([--disable-ed25519], [Disable (experimental) ED25519 support. Default is detect]))
583 case "$enable_ed25519" in
585 AC_SUBST(ldns_build_config_use_ed25519, 0)
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.])
593 AC_SUBST(ldns_build_config_use_ed25519, 0)], [AC_INCLUDES_DEFAULT
594 #include <openssl/evp.h>
599 AC_ARG_ENABLE(ed448, AC_HELP_STRING([--disable-ed448], [Disable (experimental) ED448 support. Default is detect]))
600 case "$enable_ed448" in
602 AC_SUBST(ldns_build_config_use_ed448, 0)
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.])
610 AC_SUBST(ldns_build_config_use_ed448, 0)], [AC_INCLUDES_DEFAULT
611 #include <openssl/evp.h>
616 AC_ARG_ENABLE(dane, AC_HELP_STRING([--disable-dane], [Disable DANE support]))
617 AC_ARG_ENABLE(dane-verify, AC_HELP_STRING([--disable-dane-verify], [Disable DANE verify support]))
618 AC_ARG_ENABLE(dane-ta-usage, AC_HELP_STRING([--disable-dane-ta-usage], [Disable DANE-TA usage type support]))
620 AC_ARG_ENABLE(full-dane,, [
621 enable_dane_ta_usage=yes
622 enable_dane_verify=yes
625 AC_ARG_ENABLE(no-dane-ta-usage,, [
626 enable_dane_ta_usage=no
627 enable_dane_verify=yes
630 AC_ARG_ENABLE(no-dane-verify,, [
631 enable_dane_ta_usage=no
632 enable_dane_verify=no
635 case "$enable_dane" in
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)
642 if test "x$HAVE_SSL" != "xyes"; then
643 AC_MSG_ERROR([DANE enabled, but no SSL support])
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
650 AC_SUBST(ldns_build_config_use_dane_verify, 0)
651 AC_SUBST(ldns_build_config_use_dane_ta_usage, 0)
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
658 AC_SUBST(ldns_build_config_use_dane_ta_usage, 0)
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"
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.])
674 AC_ARG_ENABLE(rrtype-ninfo, AC_HELP_STRING([--enable-rrtype-ninfo], [Enable draft RR type ninfo.]))
675 case "$enable_rrtype_ninfo" in
677 AC_DEFINE_UNQUOTED([RRTYPE_NINFO], [], [Define this to enable RR type NINFO.])
682 AC_ARG_ENABLE(rrtype-rkey, AC_HELP_STRING([--enable-rrtype-rkey], [Enable draft RR type rkey.]))
683 case "$enable_rrtype_rkey" in
685 AC_DEFINE_UNQUOTED([RRTYPE_RKEY], [], [Define this to enable RR type RKEY.])
690 AC_ARG_ENABLE(rrtype-openpgpkey, AC_HELP_STRING([--disable-rrtype-openpgpkey], [Disable openpgpkey RR type.]))
691 case "$enable_rrtype_openpgpkey" in
695 AC_DEFINE_UNQUOTED([RRTYPE_OPENPGPKEY], [], [Define this to enable RR type OPENPGPKEY.])
698 AC_ARG_ENABLE(rrtype-ta, AC_HELP_STRING([--enable-rrtype-ta], [Enable draft RR type ta.]))
699 case "$enable_rrtype_ta" in
701 AC_DEFINE_UNQUOTED([RRTYPE_TA], [], [Define this to enable RR type TA.])
706 AC_ARG_ENABLE(rrtype-avc, AC_HELP_STRING([--enable-rrtype-avc], [Enable draft RR type avc.]))
707 case "$enable_rrtype_avc" in
709 AC_DEFINE_UNQUOTED([RRTYPE_AVC], [], [Define this to enable RR type AVC.])
714 AC_ARG_ENABLE(rrtype-doa, AC_HELP_STRING([--enable-rrtype-doa], [Enable draft RR type DOA.]))
715 case "$enable_rrtype_doa" in
717 AC_DEFINE_UNQUOTED([RRTYPE_DOA], [], [Define this to enable RR type DOA.])
722 AC_ARG_ENABLE(rrtype-amtrelay, AC_HELP_STRING([--enable-rrtype-amtrelay], [Enable draft RR type AMTRELAY.]))
723 case "$enable_rrtype_amtrelay" in
725 AC_DEFINE_UNQUOTED([RRTYPE_AMTRELAY], [], [Define this to enable RR type AMTRELAY.])
730 AC_ARG_ENABLE(rrtype-svcb-https, AC_HELP_STRING([--disable-rrtype-svcb-https], [Disable RR types SVCB and HTTPS.]))
731 case "$enable_rrtype_svcb_https" in
735 AC_DEFINE_UNQUOTED([RRTYPE_SVCB_HTTPS], [], [Define this to enable RR types SVCB and HTTPS.])
741 AC_SUBST(LIBSSL_CPPFLAGS)
742 AC_SUBST(LIBSSL_LDFLAGS)
743 AC_SUBST(LIBSSL_LIBS)
744 if test "x$HAVE_SSL" = "xyes"; then
745 if echo "$LIBSSL_LIBS" | grep -- "-lssl" >/dev/null 2>&1; then
746 LIBSSL_SSL_LIBS="$LIBSSL_LIBS"
748 LIBSSL_SSL_LIBS="-lssl $LIBSSL_LIBS"
750 AC_SUBST(LIBSSL_SSL_LIBS, "$LIBSSL_SSL_LIBS")
752 CPPFLAGS=$tmp_CPPFLAGS
757 # add option to disable the evil rpath
760 #AC_RUN_IFELSE([AC_LANG_SOURCE(
765 #char *cp = (char*)&one;
772 #AC_DEFINE(CONFCHECK_LITTLE_ENDIAN, 1, [system appears to be little-endian])
775 # should define WORDS_BIGENDIAN if the system is big-endian
778 # Checks for header files.
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
784 AC_CHECK_HEADERS([getopt.h stdarg.h openssl/ssl.h netinet/in.h time.h arpa/inet.h netdb.h],,, [AC_INCLUDES_DEFAULT])
785 AC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
789 # include <sys/param.h>
793 AC_CHECK_HEADER(sys/socket.h,
795 include_sys_socket_h='#include <sys/socket.h>'
796 AC_DEFINE(HAVE_SYS_SOCKET_H, 1, [define if you have sys/socket.h])
798 include_sys_socket_h=''
799 ],[AC_INCLUDES_DEFAULT
802 # include <sys/param.h>
806 AC_SUBST(include_sys_socket_h)
807 AC_CHECK_HEADER(inttypes.h,
809 include_inttypes_h='#include <inttypes.h>'
810 AC_DEFINE(HAVE_INTTYPES_H, 1, [define if you have inttypes.h])
811 AC_SUBST(ldns_build_config_have_inttypes_h, 1)
813 include_inttypes_h=''
814 AC_SUBST(ldns_build_config_have_inttypes_h, 0)
815 ],[AC_INCLUDES_DEFAULT
817 AC_SUBST(include_inttypes_h)
818 AC_CHECK_HEADER(sys/types.h,
820 include_systypes_h='#include <sys/types.h>'
821 AC_DEFINE(HAVE_SYS_TYPES_H, 1, [define if you have sys/types.h])
823 include_systypes_h=''
824 ],[AC_INCLUDES_DEFAULT
826 AC_SUBST(include_systypes_h)
827 AC_CHECK_HEADER(unistd.h,
829 include_unistd_h='#include <unistd.h>'
830 AC_DEFINE(HAVE_UNISTD_H, 1, [define if you have unistd.h])
833 ],[AC_INCLUDES_DEFAULT
835 AC_SUBST(include_unistd_h)
837 AC_CHECK_SIZEOF(time_t,,[
839 #ifdef TIME_WITH_SYS_TIME
840 # include <sys/time.h>
843 # ifdef HAVE_SYS_TIME_H
844 # include <sys/time.h>
851 if test x_$with_examples != x_no; then
852 AC_CHECK_HEADERS([pcap.h],,, [AC_INCLUDES_DEFAULT])
853 AC_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])
857 AC_MSG_WARN([Can't find pcap library (needed for ldns-dpa, will not build dpa now.)])dnl'
858 AC_SUBST([LIBPCAP_LIBS], [])
861 AC_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],,, [
863 #ifdef HAVE_NETINET_IN_SYSTM_H
864 #include <netinet/in_systm.h>
866 #ifdef HAVE_NETINET_IN_H
867 #include <netinet/in.h>
869 #ifdef HAVE_SYS_SOCKET_H
870 #include <sys/socket.h>
878 if test "x$ac_cv_type_socklen_t" = xyes; then
879 AC_SUBST(ldns_build_config_have_socklen_t, 1)
881 AC_SUBST(ldns_build_config_have_socklen_t, 0)
884 AC_CHECK_TYPE(ssize_t, int)
885 dnl AC_TYPE_INTPTR_T does not work on all platforms (autoconf)
886 AC_CHECK_TYPE(intptr_t, size_t)
887 AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
889 # include <sys/types.h>
891 #if HAVE_NETINET_IN_H
892 # include <netinet/in.h>
894 AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
896 # include <sys/types.h>
898 #if HAVE_NETINET_IN_H
899 # include <netinet/in.h>
903 # AC_FUNC_MALLOC suffers false failures and causes Asan failures.
907 AC_REPLACE_FUNCS(b64_pton)
908 AC_REPLACE_FUNCS(b64_ntop)
909 AC_REPLACE_FUNCS(calloc)
910 AC_REPLACE_FUNCS(timegm)
911 AC_REPLACE_FUNCS(gmtime_r)
912 AC_REPLACE_FUNCS(ctime_r)
913 AC_REPLACE_FUNCS(localtime_r)
914 AC_REPLACE_FUNCS(isblank)
915 AC_REPLACE_FUNCS(isascii)
916 AC_REPLACE_FUNCS(inet_aton)
917 AC_REPLACE_FUNCS(inet_pton)
918 AC_REPLACE_FUNCS(inet_ntop)
919 AC_REPLACE_FUNCS(snprintf)
920 AC_REPLACE_FUNCS(strlcpy)
921 AC_REPLACE_FUNCS(memmove)
923 AC_MSG_CHECKING([compile of fork])
924 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
930 AC_DEFINE([HAVE_FORK_AVAILABLE], 1, [if fork is available for compile])
931 ], [ AC_MSG_RESULT(no)
933 AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul bzero memset b32_ntop b32_pton])
934 if test "x$HAVE_B32_NTOP" = "xyes"; then
935 AC_SUBST(ldns_build_config_have_b32_ntop, 1)
937 AC_SUBST(ldns_build_config_have_b32_ntop, 0)
939 if test "x$HAVE_B32_PTON" = "xyes"; then
940 AC_SUBST(ldns_build_config_have_b32_pton, 1)
942 AC_SUBST(ldns_build_config_have_b32_pton, 0)
945 ACX_CHECK_GETADDRINFO_WITH_INCLUDES
946 if test $ac_cv_func_getaddrinfo = no; then
947 AC_LIBOBJ([fake-rfc2553])
949 if test "$USE_WINSOCK" = 1; then
950 AC_CHECK_TOOL(WINDRES, windres)
954 #AC_SEARCH_LIBS(RSA_new, [crypto])
956 ACX_CHECK_FORMAT_ATTRIBUTE
957 ACX_CHECK_UNUSED_ATTRIBUTE
959 AC_ARG_WITH(xcode-sdk, AC_HELP_STRING([--with-xcode-sdk],
960 [Set xcode SDK version. Default is autodetect]),
961 [],[with_xcode_sdk="yes"])
962 if 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 )"
969 sdk_v="$with_xcode_sdk"
971 # xcrun only got that option in 10.7
972 if test -z "$sdk_v" ; then
976 SYSROOT="$( find ${sdk_p} -name MacOSX${sdk_v}.sdk )"
978 10.9|10.8) sdk_c="10.7";;
979 10.11|10.10|*) sdk_c="10.10";;
981 export MACOSX_DEPLOYMENT_TARGET="${sdk_c}";
982 export CFLAGS="$CFLAGS -mmacosx-version-min=${sdk_c} -isysroot ${SYSROOT}"
986 AC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir])
988 AC_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])
992 AC_SUBST([LDNS_TRUST_ANCHOR_FILE], ["\$(sysconfdir)/unbound/root.key"])
995 AC_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"])
1001 AC_DEFINE([HAVE_DANE_CA_FILE], [0], [Is a CAFILE given at configure time])
1002 AC_SUBST(DEFAULT_CAFILE, [])
1005 AC_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"])
1011 AC_DEFINE([HAVE_DANE_CA_PATH], [0], [Is a CAPATH given at configure time])
1012 AC_SUBST(DEFAULT_CAPATH, [])
1021 #ifndef LITTLE_ENDIAN
1022 #define LITTLE_ENDIAN 1234
1026 #define BIG_ENDIAN 4321
1030 #ifdef WORDS_BIGENDIAN
1031 #define BYTE_ORDER BIG_ENDIAN
1033 #define BYTE_ORDER LITTLE_ENDIAN
1034 #endif /* WORDS_BIGENDIAN */
1035 #endif /* BYTE_ORDER */
1042 #ifdef HAVE_STDINT_H
1046 #ifdef HAVE_SYS_SOCKET_H
1047 #include <sys/socket.h>
1050 #ifdef HAVE_NETINET_IN_H
1051 #include <netinet/in.h>
1054 #ifdef HAVE_ARPA_INET_H
1055 #include <arpa/inet.h>
1058 #ifdef HAVE_WINSOCK2_H
1059 #include <winsock2.h>
1062 #ifdef HAVE_WS2TCPIP_H
1063 #include <ws2tcpip.h>
1066 AHX_CONFIG_W32_FD_SET_T
1074 int ldns_b64_ntop(uint8_t const *src, size_t srclength,
1075 char *target, size_t targsize);
1077 * calculates the size needed to store the result of b64_ntop
1080 static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize)
1082 return ((((srcsize + 2) / 3) * 4) + 1);
1084 int ldns_b64_pton(char const *src, uint8_t *target, size_t targsize);
1086 * calculates the size needed to store the result of ldns_b64_pton
1089 static inline size_t ldns_b64_pton_calculate_size(size_t srcsize)
1091 return (((((srcsize + 3) / 4) * 3)) + 1);
1095 * Given in dnssec_zone.c, also used in dnssec_sign.c:w
1098 int ldns_dname_compare_v(const void *a, const void *b);
1101 /* use windows sleep, in millisecs, instead */
1102 #define sleep(x) Sleep((x)*1000)
1106 #define srandom(x) srand(x)
1107 #define random(x) rand(x)
1112 time_t timegm (struct tm *tm);
1113 #endif /* !TIMEGM */
1114 #ifndef HAVE_GMTIME_R
1115 struct tm *gmtime_r(const time_t *timep, struct tm *result);
1117 #ifndef HAVE_LOCALTIME_R
1118 struct tm *localtime_r(const time_t *timep, struct tm *result);
1120 #ifndef HAVE_ISBLANK
1122 #endif /* !HAVE_ISBLANK */
1123 #ifndef HAVE_ISASCII
1125 #endif /* !HAVE_ISASCII */
1126 #ifndef HAVE_SNPRINTF
1128 int snprintf (char *str, size_t count, const char *fmt, ...);
1129 int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
1130 #endif /* HAVE_SNPRINTF */
1131 #ifndef HAVE_INET_PTON
1132 int inet_pton(int af, const char* src, void* dst);
1133 #endif /* HAVE_INET_PTON */
1134 #ifndef HAVE_INET_NTOP
1135 const char *inet_ntop(int af, const void *src, char *dst, size_t size);
1137 #ifndef HAVE_INET_ATON
1138 int inet_aton(const char *cp, struct in_addr *addr);
1140 #ifndef HAVE_MEMMOVE
1141 void *memmove(void *dest, const void *src, size_t n);
1143 #ifndef HAVE_STRLCPY
1144 size_t strlcpy(char *dst, const char *src, size_t siz);
1148 #define SOCK_INVALID INVALID_SOCKET
1149 #define close_socket(_s) do { if (_s != SOCK_INVALID) {closesocket(_s); _s = -1;} } while(0)
1151 #define SOCK_INVALID -1
1152 #define close_socket(_s) do { if (_s != SOCK_INVALID) {close(_s); _s = -1;} } while(0)
1158 #ifndef HAVE_GETADDRINFO
1159 #include "compat/fake-rfc2553.h"
1161 #ifndef HAVE_STRTOUL
1162 #define strtoul (unsigned long)strtol
1166 if test "x$HAVE_SSL" = "xyes"; then
1167 AC_SUBST(ldns_build_config_have_ssl, 1)
1169 AC_SUBST(ldns_build_config_have_ssl, 0)
1171 if test "x$ac_cv_c_format_attribute" = "xyes"; then
1172 AC_SUBST(ldns_build_config_have_attr_format, 1)
1174 AC_SUBST(ldns_build_config_have_attr_format, 0)
1176 if test "x$ac_cv_c_unused_attribute" = "xyes"; then
1177 AC_SUBST(ldns_build_config_have_attr_unused, 1)
1179 AC_SUBST(ldns_build_config_have_attr_unused, 0)
1182 CONFIG_FILES="Makefile libdns.doxygen ldns/common.h ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config"
1183 AC_SUBST(CONFIG_FILES)
1184 AC_CONFIG_FILES([$CONFIG_FILES])
1186 AC_CONFIG_HEADER([ldns/config.h])
1188 COPY_HEADER_FILES(ldns/, ldns/)
1190 dnl AC_CONFIG_SUBDIRS([drill])