diff --git a/configure.ac b/configure.ac index c6a2f01ffb..c54161e15e 100644 --- a/configure.ac +++ b/configure.ac @@ -1099,7 +1099,6 @@ AC_CONFIG_FILES([Makefile src/bin/dbutil/Makefile src/bin/dbutil/tests/Makefile src/bin/dbutil/tests/testdata/Makefile - src/bin/host/Makefile src/bin/loadzone/Makefile src/bin/loadzone/tests/correct/Makefile src/bin/loadzone/tests/error/Makefile diff --git a/examples/AUTHORS b/examples/AUTHORS new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/COPYING b/examples/COPYING new file mode 100644 index 0000000000..f3febbe839 --- /dev/null +++ b/examples/COPYING @@ -0,0 +1,13 @@ +Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC") + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/examples/ChangeLog b/examples/ChangeLog new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/INSTALL b/examples/INSTALL new file mode 100644 index 0000000000..43436c2eef --- /dev/null +++ b/examples/INSTALL @@ -0,0 +1,9 @@ +If using git (not the tarball), build the "configure" file: + autoreconf --install + +To then build from source: + ./configure + make + +You may have to specify the location of BIND 10 header files and +library objects. See configure options by ./configure --help. diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 0000000000..ef437ebf31 --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,4 @@ +SUBDIRS = host + +# Make sure macros under m4 will be included +ACLOCAL_AMFLAGS = -I m4 diff --git a/examples/NEWS b/examples/NEWS new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/README b/examples/README new file mode 100644 index 0000000000..12dbbbaaff --- /dev/null +++ b/examples/README @@ -0,0 +1,32 @@ +This is the top directory for sample programs that can be developed +using public BIND 10 libraries outside of the BIND 10 project. It's +intended to be built with installed BIND 10 header files and library +objects, so it's not a target of the main build tree, and does not +refer to any other part of the BIND 10 source tree that contains +this directory. + +On the top (sub) directory (where this README file is stored), we +provide a sample configure.ac and Makefile.am files for GNU automake +environments with helper autoconf macros to detect the available and +location of BIND 10 header files and library objects. + +You can use the configure.ac and Makefile.am files with macros under +the "m4" subdirectory as a template for your own project. The key is +to call the AX_ISC_BIND10 function (as the sample configure.ac does) +from your configure.ac. Then it will check the availability of +necessary stuff and set some corresponding AC variables. You can then +use the resulting variables in your Makefile.in or Makefile.ac. + +If you use automake, don't forget adding the following line to the top +level Makefile.am: + +ACLOCAL_AMFLAGS = -I m4 + +This is necessary to incorporate the helper macro definitions. + +If you don't use automake but autoconf, make sure to add the following +to the configure.ac file: + +sinclude(m4/ax_boost_include.m4) +sinclude(m4/ax_isc_bind10.m4) +(and same for other m4 files as they are added under m4/) diff --git a/examples/configure.ac b/examples/configure.ac new file mode 100644 index 0000000000..937968760d --- /dev/null +++ b/examples/configure.ac @@ -0,0 +1,28 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.59]) +AC_INIT(bind10-examples, 20120817, bind10-dev@isc.org) +AC_CONFIG_SRCDIR([README]) +AM_INIT_AUTOMAKE +AC_CONFIG_HEADERS([config.h]) + +# Checks for programs. +AC_PROG_CXX +AC_LANG([C++]) + +# Checks for BIND 10 headers and libraries +AX_ISC_BIND10 + +# For the example host program, we require the BIND 10 DNS library +if test "x$BIND10_DNS_LIB" = "x"; then + AC_MSG_ERROR([unable to find BIND 10 DNS library needed to build 'host']) +fi + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL + +AC_CONFIG_FILES([Makefile + host/Makefile]) + +AC_OUTPUT diff --git a/src/bin/host/.gitignore b/examples/host/.gitignore similarity index 100% rename from src/bin/host/.gitignore rename to examples/host/.gitignore diff --git a/examples/host/Makefile.am b/examples/host/Makefile.am new file mode 100644 index 0000000000..dbd57a2821 --- /dev/null +++ b/examples/host/Makefile.am @@ -0,0 +1,6 @@ +AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(BIND10_CPPFLAGS) + +bin_PROGRAMS = b10-host +b10_host_SOURCES = host.cc +b10_host_LDFLAGS = ${BIND10_LDFLAGS} +b10_host_LDADD = ${BIND10_DNS_LIB} diff --git a/src/bin/host/README b/examples/host/README similarity index 100% rename from src/bin/host/README rename to examples/host/README diff --git a/src/bin/host/b10-host.xml b/examples/host/b10-host.xml similarity index 100% rename from src/bin/host/b10-host.xml rename to examples/host/b10-host.xml diff --git a/src/bin/host/host.cc b/examples/host/host.cc similarity index 100% rename from src/bin/host/host.cc rename to examples/host/host.cc diff --git a/examples/m4/ax_boost_include.m4 b/examples/m4/ax_boost_include.m4 new file mode 100644 index 0000000000..e41614d884 --- /dev/null +++ b/examples/m4/ax_boost_include.m4 @@ -0,0 +1,64 @@ +dnl @synopsis AX_BOOST_INCLUDE +dnl +dnl Test for the Boost C++ header files +dnl +dnl If no path to the installed boost header files is given via the +dnl --with-boost-include option, the macro searchs under +dnl /usr/local /usr/pkg /opt /opt/local directories. +dnl +dnl This macro calls: +dnl +dnl AC_SUBST(BOOST_CPPFLAGS) +dnl + +AC_DEFUN([AX_BOOST_INCLUDE], [ +AC_LANG_SAVE +AC_LANG([C++]) + +# +# Configure Boost header path +# +# If explicitly specified, use it. +AC_ARG_WITH([boost-include], + AS_HELP_STRING([--with-boost-include=PATH], + [specify exact directory for Boost headers]), + [boost_include_path="$withval"]) +# If not specified, try some common paths. +if test -z "$with_boost_include"; then + boostdirs="/usr/local /usr/pkg /opt /opt/local" + for d in $boostdirs + do + if test -f $d/include/boost/shared_ptr.hpp; then + boost_include_path=$d/include + break + fi + done +fi +CPPFLAGS_SAVES="$CPPFLAGS" +if test "${boost_include_path}" ; then + BOOST_CPPFLAGS="-I${boost_include_path}" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" +fi +# Make sure some commonly used headers are available +AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/bind.hpp boost/function.hpp],, + AC_MSG_ERROR([Missing required Boost header files.])) + +# Detect whether Boost tries to use threads by default, and, if not, +# make it sure explicitly. In some systems the automatic detection +# may depend on preceding header files, and if inconsistency happens +# it could lead to a critical disruption. +AC_MSG_CHECKING([whether Boost tries to use threads]) +AC_TRY_COMPILE([ +#include +#ifdef BOOST_HAS_THREADS +#error "boost will use threads" +#endif],, +[AC_MSG_RESULT(no) + CPPFLAGS_BOOST_THREADCONF="-DBOOST_DISABLE_THREADS=1"], +[AC_MSG_RESULT(yes)]) + +CPPFLAGS="$CPPFLAGS_SAVES $CPPFLAGS_BOOST_THREADCONF" +AC_SUBST(BOOST_CPPFLAGS) + +AC_LANG_RESTORE +])dnl AX_BOOST_INCLUDE diff --git a/examples/m4/ax_isc_bind10.m4 b/examples/m4/ax_isc_bind10.m4 new file mode 100644 index 0000000000..63e028c407 --- /dev/null +++ b/examples/m4/ax_isc_bind10.m4 @@ -0,0 +1,122 @@ +dnl @synopsis AX_BIND10 +dnl +dnl @summary figure out how to build C++ programs using ISC BIND 10 libraries +dnl +dnl If no path to the installed BIND 10 header files or libraries is given +dnl via the --with-bind10-include or --with-bind10-lib option, the macro +dnl searchs under /usr/local/{include, lib}, /usr/pkg/{include, lib}, +dnl /opt/{include, lib}, /opt/local/{include, lib} directories, respectively. +dnl +dnl This macro calls: +dnl +dnl AC_SUBST(BIND10_CPPFLAGS) +dnl AC_SUBST(BIND10_LDFLAGS) +dnl AC_SUBST(BIND10_COMMON_LIB) +dnl AC_SUBST(BIND10_DNS_LIB) +dnl +dnl If this macro finds CPPFLAGS, LDFLAGS or COMMON_LIB unavailable, it treats +dnl that as a fatal error. +dnl Checks for other BIND 10 module libraries are option, as not all +dnl applications need all libraries. The main configure.ac can handle any +dnl missing library as fatal by checking whether the corresponding +dnl BIND10_xxx_LIB is defined. + +AC_DEFUN([AX_ISC_BIND10], [ +AC_REQUIRE([AX_BOOST_INCLUDE]) +AC_LANG_SAVE +AC_LANG([C++]) + +# Check for BIND10 common headers + +AC_ARG_WITH(bind10-include, + AS_HELP_STRING([--with-bind10-include=PATH], + [specify a path to BIND 10 header files]), + bind10_inc_path="$withval", bind10_inc_path="no") +# If not specified, try some common paths. +if test "$bind10_inc_path" = "no"; then + for d in /usr/local /usr/pkg /opt /opt/local + do + if test -f $d/include/util/buffer.h; then + bind10_inc_path=$d + break + fi + done +fi +CPPFLAGS_SAVES="$CPPFLAGS" +if test "${bind10_inc_path}" != "no"; then + BIND10_CPPFLAGS="-I${bind10_inc_path}" + CPPFLAGS="$CPPFLAGS $BIND10_CPPFLAGS" +fi +AC_CHECK_HEADERS([util/buffer.h],, + AC_MSG_ERROR([Missing a commonly used BIND 10 header files])) +CPPFLAGS="$CPPFLAGS_SAVES" +AC_SUBST(BIND10_CPPFLAGS) + +# Check for BIND10 libraries +CPPFLAGS_SAVED="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $BIND10_CPPFLAGS" + +AC_ARG_WITH(bind10-lib, + AS_HELP_STRING([--with-bind10-lib=PATH], + [specify a path to BIND 10 library files]), + bind10_lib_path="$withval", bind10_lib_path="no") +if test $bind10_lib_path != "no"; then + bind10_lib_dirs=$bind10_lib_path +else + # If not specified, try some common paths. + bind10_lib_dirs="/usr/local/lib /usr/pkg/lib /opt/lib /opt/local/lib" +fi + +# make sure we have buildable libraries +AC_MSG_CHECKING([for BIND 10 common library]) +BIND10_COMMON_LIB="-lb10-util -lb10-exceptions" +LDFLAGS="$LDFLAGS $BIND10_LDFLAGS" +LIBS="$LIBS $BIND10_COMMON_LIB" +for d in $bind10_lib_dirs +do + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS -L$d" + AC_TRY_LINK([ +#include +],[ +isc::util::OutputBuffer buffer(0); +], [BIND10_LDFLAGS="-L${d}"]) + if test "x$BIND10_LDFLAGS" != "x"; then + break + fi + LDFLAGS="$LDFLAGS_SAVED" +done +if test "x$BIND10_LDFLAGS" != "x"; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) + AC_MSG_ERROR([unable to find required BIND 10 libraries]) +fi + +# restore LIBS once at this point +LIBS="$LIBS_SAVES" + +AC_SUBST(BIND10_LDFLAGS) +AC_SUBST(BIND10_COMMON_LIB) + +# Check per-module BIND 10 libraries + +# DNS library +AC_MSG_CHECKING([for BIND 10 DNS library]) +LIBS="$LIBS $BIND10_COMMON_LIB -lb10-dns++" +AC_TRY_LINK([ +#include +],[ +isc::dns::RRType rrtype(1); +], [BIND10_DNS_LIB="-lb10-dns++" + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)]) +LIBS="$LIBS_SAVES" +AC_SUBST(BIND10_DNS_LIB) + +# Restore other flags +CPPFLAGS="$CPPFLAGS_SAVED" +LDFLAGS="$LDFLAGS_SAVES" + +AC_LANG_RESTORE +])dnl AX_ISC_BIND10 diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 7af44f9b8f..0b4c1ae796 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = bind10 bindctl cfgmgr ddns loadzone msgq host cmdctl auth xfrin \ +SUBDIRS = bind10 bindctl cfgmgr ddns loadzone msgq cmdctl auth xfrin \ xfrout usermgr zonemgr stats tests resolver sockcreator dhcp4 dhcp6 \ dbutil sysinfo diff --git a/src/bin/host/Makefile.am b/src/bin/host/Makefile.am deleted file mode 100644 index 42ef954ce1..0000000000 --- a/src/bin/host/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib -AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns -AM_CPPFLAGS += $(BOOST_INCLUDES) - -AM_CXXFLAGS = $(B10_CXXFLAGS) - -if USE_STATIC_LINK -AM_LDFLAGS = -static -endif - -CLEANFILES = *.gcno *.gcda - -bin_PROGRAMS = b10-host -b10_host_SOURCES = host.cc -b10_host_LDADD = $(top_builddir)/src/lib/dns/libb10-dns++.la -b10_host_LDADD += $(top_builddir)/src/lib/util/libb10-util.la -b10_host_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la - -man_MANS = b10-host.1 -DISTCLEANFILES = $(man_MANS) -EXTRA_DIST = $(man_MANS) b10-host.xml - -.PHONY: man -if GENERATE_DOCS - -man: b10-host.1 - -b10-host.1: b10-host.xml - @XSLTPROC@ --novalid --xinclude --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $(srcdir)/b10-host.xml - -else - -$(man_MANS): - @echo Man generation disabled. Creating dummy $@. Configure with --enable-generate-docs to enable it. - @echo Man generation disabled. Remove this file, configure with --enable-generate-docs, and rebuild BIND 10 > $@ - -endif diff --git a/src/lib/dns/Makefile.am b/src/lib/dns/Makefile.am index 38809e0921..40cb943412 100644 --- a/src/lib/dns/Makefile.am +++ b/src/lib/dns/Makefile.am @@ -149,11 +149,11 @@ libdns___include_HEADERS = \ messagerenderer.h \ name.h \ question.h \ + opcode.h \ rcode.h \ rdata.h \ rrparamregistry.h \ rrset.h \ - rrsetlist.h \ rrttl.h \ tsigkey.h # Purposely not installing these headers: diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am index fe1b3274a0..13f8f7b595 100644 --- a/src/lib/util/Makefile.am +++ b/src/lib/util/Makefile.am @@ -33,3 +33,6 @@ EXTRA_DIST = python/pycppwrapper_util.h libb10_util_la_LIBADD = $(top_builddir)/src/lib/exceptions/libb10-exceptions.la CLEANFILES = *.gcno *.gcda + +libb10_util_includedir = $(includedir)/$(PACKAGE_NAME)/util +libb10_util_include_HEADERS = buffer.h