Where possible, those are replaced by build configuration defines (that won't conflict with another autoconf environment)
sha1.c sha2.c
LIBDNS_HEADERS = $(srcdir)/ldns/error.h \
$(srcdir)/ldns/packet.h \
- $(srcdir)/ldns/common.h \
$(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h \
$(srcdir)/ldns/wire2host.h \
LINK = $(CC) $(strip $(CFLAGS) $(LDFLAGS) $(LIBS))
LINK_LIB = $(LIBTOOL) --mode=link $(CC) $(strip $(CFLAGS) $(LDFLAGS) $(LIBS) -version-number $(version_info) -no-undefined)
-%.o: $(srcdir)/%.c $(LIBDNS_HEADERS) ldns/net.h ldns/util.h ldns/config.h
+%.o: $(srcdir)/%.c $(LIBDNS_HEADERS) ldns/common.h ldns/net.h ldns/util.h ldns/config.h
$(COMP_LIB) $(LIBSSL_CPPFLAGS) -c $<
.PHONY: clean realclean docclean manpages doc lint all lib pyldns test
all: copy-headers lib linktest manpages @PYLDNS@
-linktest: $(srcdir)/linktest.c $(LIBDNS_HEADERS) ldns/net.h ldns/util.h ldns/config.h libldns.la
+linktest: $(srcdir)/linktest.c $(LIBDNS_HEADERS) ldns/common.h ldns/net.h ldns/util.h ldns/config.h libldns.la
$(LIBTOOL) --mode=link $(CC) $(srcdir)/linktest.c $(CPPFLAGS) $(LIBSSL_CPPFLAGS) $(CFLAGS) -lldns $(LIBS) -o linktest
lib: libldns.la
@if [ ! -d include/ldns ] ; then (cd include; ln -s ../ldns ./ldns || echo "include/ldns exists") ; fi ;
$(INSTALL) -c -m 644 $< ./include/ldns/
-include/ldns/util.h include/ldns/net.h include/ldns/config.h: include/ldns/%.h: ./ldns/%.h
+include/ldns/util.h include/ldns/common.h include/ldns/net.h include/ldns/config.h: include/ldns/%.h: ./ldns/%.h
@if [ ! -d include ] ; then ($(INSTALL) -d include || echo "include exists") ; fi ;
@if [ ! -d include/ldns ] ; then (cd include; ln -s ../ldns ./ldns || echo "include/ldns exists") ; fi ;
$(INSTALL) -c -m 644 $< ./include/ldns/
-copy-headers: $(addprefix include/ldns/, $(notdir $(LIBDNS_HEADERS))) include/ldns/util.h include/ldns/net.h include/ldns/config.h
+copy-headers: $(addprefix include/ldns/, $(notdir $(LIBDNS_HEADERS))) include/ldns/common.h include/ldns/util.h include/ldns/net.h include/ldns/config.h
mancheck:
sh -c 'find . -name \*.\[13\] -exec troff -z {} \;' 2>&1 | sed "s/^\.\///" | sed "s/\(:[0\-9]\+:\)/\1 warning:/g"
pyldns: _ldns.la
-$(pywrapdir)/ldns_wrapper.c: $(pywrapdir)/ldns.i $(wildcard $(pywrapdir)/*.i) $(LIBDNS_HEADERS) ldns/util.h ldns/config.h
+$(pywrapdir)/ldns_wrapper.c: $(pywrapdir)/ldns.i $(wildcard $(pywrapdir)/*.i) $(LIBDNS_HEADERS) ldns/common.h ldns/util.h ldns/config.h
$(swig) -python -o $@ $(CPPFLAGS) $(PYTHON_CPPFLAGS) $<
-ldns_wrapper.lo: $(pywrapdir)/ldns_wrapper.c $(LIBDNS_HEADERS) ldns/util.h ldns/config.h
+ldns_wrapper.lo: $(pywrapdir)/ldns_wrapper.c $(LIBDNS_HEADERS) ldns/common.h ldns/util.h ldns/config.h
$(COMP_LIB) -I./include/ldns $(PYTHON_CPPFLAGS) -c $< -o $@
_ldns.la: ldns_wrapper.lo libldns.la
install: install-h install-lib install-config install-manpages $(pyldns_inst)
-uninstall: uninstall-manpages uninstall-h uninstall-lib $(pyldns_uninst)
+uninstall: uninstall-manpages uninstall-config uninstall-h uninstall-lib $(pyldns_uninst)
destclean: uninstall
$(INSTALL) -c -m 755 packaging/ldns-config $(DESTDIR)$(bindir)/; \
fi
+uninstall-config:
+ if [ $(INSTALL_LDNS_CONFIG) = "yes" ] ; then \
+ rm -f $(DESTDIR)$(bindir)/ldns-config; \
+ [ ! -d $(DESTDIR)$(bindir) ] || rmdir -p $(DESTDIR)$(bindir) || echo "ok, dir already gone"; \
+ fi
+
install-manpages: manpages
${INSTALL} -d $(DESTDIR)$(mandir)/man3
for f in doc/man/man3/*; do \
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)/ldns
for i in $(LIBDNS_HEADERS); do \
$(INSTALL) -c -m 644 $$i $(DESTDIR)$(includedir)/ldns/; done
+ $(INSTALL) -c -m 644 include/ldns/common.h $(DESTDIR)$(includedir)/ldns/
$(INSTALL) -c -m 644 include/ldns/util.h $(DESTDIR)$(includedir)/ldns/
$(INSTALL) -c -m 644 include/ldns/net.h $(DESTDIR)$(includedir)/ldns/
uninstall-h:
for i in $(LIBDNS_HEADERS); do \
rm -f $(DESTDIR)$(includedir)/$$i; done
+ rm -f $(DESTDIR)$(includedir)/ldns/net.h
+ rm -f $(DESTDIR)$(includedir)/ldns/util.h
+ rm -f $(DESTDIR)$(includedir)/ldns/common.h
[ ! -d $(DESTDIR)$(includedir)/ldns ] || rmdir -p $(DESTDI)$(includedir)/ldns || echo "ok, dir already gone"
exit 0
rm -f ldns/config.h.in
rm -f ldns/config.h
rm -f ldns/util.h
+ rm -f ldns/common.h
rm -f config.h.in
rm -f configure
rm -f config.sub
$(LIBTOOL) --mode clean rm -f libldns.so
$(LIBTOOL) --mode clean rm -f libldns.so.*
$(LIBTOOL) --mode clean rm -f _ldns.la
- rm -rf ldns/net.h ldns/util.h ldns/config.h
+ rm -rf ldns/net.h ldns/util.h ldns/config.h ldns/common.h
rm -rf *.lo
rm -rf .libs
rm -rf libtool
AC_MSG_RESULT($ac_cv_c_format_attribute)
if test $ac_cv_c_format_attribute = yes; then
AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute])
+ AC_SUBST(ldns_build_config_have_attr_format, 1)
+else
+ AC_SUBST(ldns_build_config_have_attr_format, 0)
fi
])dnl End of ACX_CHECK_FORMAT_ATTRIBUTE
AC_MSG_RESULT($ac_cv_c_unused_attribute)
if test $ac_cv_c_unused_attribute = yes; then
AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute])
+ AC_SUBST(ldns_build_config_have_attr_unused, 1)
+else
+ AC_SUBST(ldns_build_config_have_attr_unused, 0)
fi
])dnl
])
# we now know we have ECDSA and the required curves.
AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
+ AC_SUBST(ldns_build_config_use_ecdsa, 1)
AC_WARN([
*****************************************************************
*** YOU HAVE ENABLED ECDSA WHICH IS EXPERIMENTAL AT THIS TIME ***
*****************************************************************])
;;
no)
+ AC_SUBST(ldns_build_config_use_ecdsa, 0)
;;
*)
+ AC_SUBST(ldns_build_config_use_ecdsa, 0)
;;
esac
[
include_inttypes_h='#include <inttypes.h>'
AC_DEFINE(HAVE_INTTYPES_H, 1, [define if you have inttypes.h])
+AC_SUBST(ldns_build_config_have_inttypes_h, 1)
],[
include_inttypes_h=''
+AC_SUBST(ldns_build_config_have_inttypes_h, 0)
],[AC_INCLUDES_DEFAULT
])
AC_SUBST(include_inttypes_h)
#endif
])
-AC_CONFIG_FILES([Makefile ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config])
+if test "x$HAVE_SSL" = "xyes"; then
+ AC_SUBST(ldns_build_config_have_ssl, 1)
+else
+ AC_SUBST(ldns_build_config_have_ssl, 0)
+fi
+
+AC_CONFIG_FILES([Makefile ldns/common.h ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config])
AC_CONFIG_HEADER([ldns/config.h])
AC_OUTPUT
+++ /dev/null
-/**
- * \file common.h
- *
- * Common definitions for LDNS
- */
-
-/**
- * a Net::DNS like library for C
- *
- * (c) NLnet Labs, 2004-2006
- *
- * See the file LICENSE for the license
- */
-
-#ifndef LDNS_COMMON_H
-#define LDNS_COMMON_H
-
-/*@ignore@*/
-/* splint barfs on this construct */
-#ifdef HAVE_STDBOOL_H
-# include <stdbool.h>
-#else
-# ifndef HAVE__BOOL
-# ifdef __cplusplus
-typedef bool _Bool;
-# else
-# define _Bool signed char
-# endif
-# endif
-# define bool _Bool
-# define false 0
-# define true 1
-# define __bool_true_false_are_defined 1
-#endif
-/*@end@*/
-
-#ifdef HAVE_ATTR_FORMAT
-#define ATTR_FORMAT(archetype, string_index, first_to_check) \
- __attribute__ ((format (archetype, string_index, first_to_check)))
-#else /* !HAVE_ATTR_FORMAT */
-#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
-#endif /* !HAVE_ATTR_FORMAT */
-
-#if defined(__cplusplus)
-#define ATTR_UNUSED(x)
-#elif defined(HAVE_ATTR_UNUSED)
-#define ATTR_UNUSED(x) x __attribute__((unused))
-#else /* !HAVE_ATTR_UNUSED */
-#define ATTR_UNUSED(x) x
-#endif /* !HAVE_ATTR_UNUSED */
-
-#endif /* LDNS_COMMON_H */
--- /dev/null
+/**
+ * \file common.h
+ *
+ * Common definitions for LDNS
+ */
+
+/**
+ * a Net::DNS like library for C
+ *
+ * (c) NLnet Labs, 2004-2006
+ *
+ * See the file LICENSE for the license
+ */
+
+#ifndef LDNS_COMMON_H
+#define LDNS_COMMON_H
+
+/*
+ * The build configuration that is used in the distributed headers,
+ * as detected and determined by the auto configure script.
+ */
+#define LDNS_BUILD_CONFIG_HAVE_SSL @ldns_build_config_have_ssl@
+#define LDNS_BUILD_CONFIG_USE_ECDSA @ldns_build_config_use_ecdsa@
+#define LDNS_BUILD_CONFIG_HAVE_INTTYPES_H @ldns_build_config_have_inttypes_h@
+#define LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT @ldns_build_config_have_attr_format@
+#define LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED @ldns_build_config_have_attr_unused@
+
+/*
+ * HAVE_STDBOOL_H is not available when distributed as a library, but no build
+ * configuration variables may be used (like those above) because the header
+ * is sometimes only available when using special compiler flags to enable the
+ * c99 environment. Because we cannot force the usage of this flag, we have to
+ * provide a default type. Below what is suggested by the autoconf manual.
+ */
+/*@ignore@*/
+/* splint barfs on this construct */
+#ifdef HAVE_STDBOOL_H
+# include <stdbool.h>
+#else
+# ifndef HAVE__BOOL
+# ifdef __cplusplus
+typedef bool _Bool;
+# else
+# define _Bool signed char
+# endif
+# endif
+# define bool _Bool
+# define false 0
+# define true 1
+# define __bool_true_false_are_defined 1
+#endif
+/*@end@*/
+
+#if LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT
+#define ATTR_FORMAT(archetype, string_index, first_to_check) \
+ __attribute__ ((format (archetype, string_index, first_to_check)))
+#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
+#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
+#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
+
+#if defined(__cplusplus)
+#define ATTR_UNUSED(x)
+#elif LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED
+#define ATTR_UNUSED(x) x __attribute__((unused))
+#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
+#define ATTR_UNUSED(x) x
+#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
+
+#endif /* LDNS_COMMON_H */
#ifndef LDNS_DNSSEC_H
#define LDNS_DNSSEC_H
-#ifdef HAVE_SSL
+#include <ldns/common.h>
+#if LDNS_BUILD_CONFIG_HAVE_SSL
#include <openssl/ssl.h>
#include <openssl/evp.h>
-#endif /* HAVE_SSL */
-#include <ldns/common.h>
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
#include <ldns/packet.h>
#include <ldns/keys.h>
#include <ldns/zone.h>
*/
uint16_t ldns_calc_keytag_raw(uint8_t* key, size_t keysize);
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* converts a buffer holding key material to a DSA key in openssl.
*
*/
EVP_PKEY* ldns_ecdsa2pkey_raw(unsigned char* key, size_t keylen, uint8_t algo);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* converts a buffer holding key material to a RSA key in openssl.
*
* \return a RSA * structure with the key material
*/
RSA *ldns_key_buf2rsa_raw(unsigned char* key, size_t len);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
/**
* returns a new DS rr that represents the given key rr.
*/
bool ldns_nsec_covers_name(const ldns_rr *nsec, const ldns_rdf *name);
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* verify a packet
* \param[in] p the packet
*/
int ldns_dnssec_default_replace_signatures(ldns_rr *sig, void *n);
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* Converts the DSA signature from ASN1 representation (RFC2459, as
* used by OpenSSL) to raw signature data as used in DNS (rfc2536)
ldns_convert_ecdsa_rrsig_rdf2asn1(ldns_buffer *target_buffer,
const ldns_rdf *sig_rdf);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
#ifdef __cplusplus
}
*/
ldns_rr_list *ldns_sign_public(ldns_rr_list *rrset, ldns_key_list *keys);
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* Sign a buffer with the DSA key (hash with SHA1)
* \param[in] to_sign buffer with the data
* \return a ldns_rdf with the signed data
*/
ldns_rdf *ldns_sign_public_rsamd5(ldns_buffer *to_sign, RSA *key);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
/**
* Marks the names in the zone that are occluded. Those names will be skipped
* \param[in] key the EVP key structure
* \param[in] digest_type The digest type of the signature
*/
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
ldns_status ldns_verify_rrsig_evp(ldns_buffer *sig,
ldns_buffer *rrset,
EVP_PKEY *key,
* \param[in] key the EVP key structure
* \param[in] digest_type The digest type of the signature
*/
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
ldns_status ldns_verify_rrsig_evp_raw(unsigned char *sig,
size_t siglen,
ldns_buffer *rrset,
#ifndef LDNS_KEYS_H
#define LDNS_KEYS_H
-#ifdef HAVE_SSL
+#include <ldns/common.h>
+#if LDNS_BUILD_CONFIG_HAVE_SSL
#include <openssl/ssl.h>
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
#include <ldns/dnssec.h>
#include <ldns/util.h>
#include <errno.h>
LDNS_RSASHA256 = 8, /* RFC 5702 */
LDNS_RSASHA512 = 10, /* RFC 5702 */
LDNS_ECC_GOST = 12, /* RFC 5933 */
-#ifdef USE_ECDSA
+#if LDNS_BUILD_CONFIG_USE_ECDSA
/* this ifdef has to be removed once it is no longer experimental,
* to be able to use these values outside of the ldns library itself */
LDNS_ECDSAP256SHA256 = 13, /* draft-hoffman-dnssec-ecdsa */
LDNS_SHA1 = 1, /* RFC 4034 */
LDNS_SHA256 = 2, /* RFC 4509 */
LDNS_HASH_GOST = 3 /* RFC 5933 */
-#ifdef USE_ECDSA
+#if LDNS_BUILD_CONFIG_USE_ECDSA
/* this ifdef has to be removed once it is no longer experimental,
* to be able to use these values outside of the ldns library itself */
,LDNS_SHA384 = 4 /* draft-hoffman-dnssec-ecdsa EXPERIMENTAL */
LDNS_SIGN_RSASHA512 = LDNS_RSASHA512,
LDNS_SIGN_DSA_NSEC3 = LDNS_DSA_NSEC3,
LDNS_SIGN_ECC_GOST = LDNS_ECC_GOST,
-#ifdef USE_ECDSA
+#if LDNS_BUILD_CONFIG_USE_ECDSA
/* this ifdef has to be removed once it is no longer experimental,
* to be able to use these values outside of the ldns library itself */
LDNS_SIGN_ECDSAP256SHA256 = LDNS_ECDSAP256SHA256,
/** Storage pointers for the types of keys supported */
/* TODO remove unions? */
struct {
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
#ifndef S_SPLINT_S
/* The key can be an OpenSSL EVP Key
*/
EVP_PKEY *key;
#endif
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
/**
* The key can be an HMAC key
*/
*/
ldns_status ldns_key_new_frm_fp_l(ldns_key **k, FILE *fp, int *line_nr);
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* Read the key with the given id from the given engine and store it
* in the given ldns_key structure. The algorithm type is set
* \return NULL on failure otherwise a RSA structure
*/
RSA *ldns_key_new_frm_fp_rsa(FILE *fp);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* frm_fp helper function. This function parses the
* remainder of the (RSA) priv. key file generated from bind9
* \return NULL on failure otherwise a RSA structure
*/
RSA *ldns_key_new_frm_fp_rsa_l(FILE *fp, int *line_nr);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* frm_fp helper function. This function parses the
* remainder of the (DSA) priv. key file
* \return NULL on failure otherwise a RSA structure
*/
DSA *ldns_key_new_frm_fp_dsa(FILE *fp);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* frm_fp helper function. This function parses the
* remainder of the (DSA) priv. key file
* \return NULL on failure otherwise a RSA structure
*/
DSA *ldns_key_new_frm_fp_dsa_l(FILE *fp, int *line_nr);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* frm_fp helper function. This function parses the
* remainder of the (HMAC-MD5) key file
unsigned char *ldns_key_new_frm_fp_hmac(FILE *fp, size_t *hmac_size);
#endif
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* frm_fp helper function. This function parses the
* remainder of the (HMAC-MD5) key file
* \return NULL on failure otherwise a newly allocated char buffer
*/
unsigned char *ldns_key_new_frm_fp_hmac_l(FILE *fp, int *line_nr, size_t *hmac_size);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
/* acces write functions */
/**
* \param[in] l the algorithm
*/
void ldns_key_set_algorithm(ldns_key *k, ldns_signing_algorithm l);
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* Set the key's evp key
* \param[in] k the key
/** Release the engine reference held for the GOST engine. */
void ldns_key_EVP_unload_gost(void);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
/**
* Set the key's hmac data
*/
ldns_key *ldns_key_list_key(const ldns_key_list *key, size_t nr);
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
/**
* returns the (openssl) RSA struct contained in the key
* \param[in] k the key to look in
* \return the RSA * structure in the key
*/
EVP_PKEY *ldns_key_evp_key(const ldns_key *k);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
/**
* returns the (openssl) DSA struct contained in the key
*/
-#ifdef HAVE_SSL
+#if LDNS_BUILD_CONFIG_HAVE_SSL
DSA *ldns_key_dsa_key(const ldns_key *k);
-#endif /* HAVE_SSL */
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
/**
* return the signing alg of the key
* Import u_intXX_t size_t type definitions from system headers. You
* may need to change this, or define these things yourself in this
* file.
- *
- * (include ldns/config.h so HAVE_INTTYPES is defined (or not, depending
- * on the system))
*/
#include <sys/types.h>
-#ifdef HAVE_INTTYPES_H
+#if LDNS_BUILD_CONFIG_HAVE_INTTYPES_H
#include <inttypes.h>
-#endif /* HAVE_INTTYPES_H */
+#endif /* LDNS_BUILD_CONFIG_HAVE_INTTYPES_H */
/*** SHA-256/384/512 Various Length Definitions ***********************/