Browse Source

[1870] introduced separate m4 files for dependencies.

JINMEI Tatuya 12 years ago
parent
commit
0edff937af

+ 3 - 0
examples/Makefile.am

@@ -1 +1,4 @@
 SUBDIRS = host
+
+# Make sure macros under m4 will be included
+ACLOCAL_AMFLAGS = -I m4

+ 2 - 69
examples/configure.ac

@@ -11,79 +11,12 @@ AC_CONFIG_HEADERS([config.h])
 AC_PROG_CXX
 AC_LANG([C++])
 
-# Checks for libraries.
-
-# Check for BIND10 libdns++ headers
-AC_ARG_WITH(bind10-include,
-  AC_HELP_STRING([--with-bind10-include=PATH],
-  [specify a path to BIND 10 header files
-   (PATH, often needs to be in a BIND 10 source such as
-   <somewhere>/bind10/src/lib)]),
-    bind10_inc_path="$withval", bind10_inc_path="no")
-# If not specified, try some common paths.
-if test "$bind10_inc_path" = "no"; then
-	bind10dirs="/usr/local /usr/pkg /opt /opt/local"
-	for d in $bind10dirs
-	do
-		if test -f $d/dns/rrtype.h; then
-			bind10_inc_path=$d
-			break
-		fi
-	done
-fi
-CPPFLAGS_SAVES="$CPPFLAGS"
-if test "${bind10_inc_path}" ; then
-	BIND10_INCLUDES="-I${bind10_inc_path}"
-	CPPFLAGS="$CPPFLAGS $BIND10_INCLUDES"
-fi
-AC_CHECK_HEADERS([dns/rrtype.h],,
-  AC_MSG_ERROR([Missing required BIND 10 header files.]))
-CPPFLAGS="$CPPFLAGS_SAVES"
-AC_SUBST(BIND10_INCLUDES)
-
-# Check for BIND10 lib libraries
-AC_ARG_WITH(bind10-lib,
-  AC_HELP_STRING([--with-bind10-lib=PATH],
-  [specify a path to BIND 10 library files (PATH)]),
-    bind10_lib_path="$withval", bind10_lib_path="no")
-
-if test bind10_lib_path != "no"; then
-	BIND10_LDFLAGS="-L$bind10_lib_path"
-fi
-BIND10_LDADD="-lb10-dns++ -lb10-util -lb10-exceptions"
-
-CPPFLAGS_SAVED="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $BIND10_INCLUDES"
-LDFLAGS_SAVED="$LDFLAGS"
-LDFLAGS="$LDFLAGS $BIND10_LDFLAGS"
-LIBS_SAVED=$LIBS
-LIBS="$LIBS $BIND10_LDADD"
-
-AC_MSG_CHECKING([BIND 10 libraries])
-AC_TRY_LINK([
-#include <dns/rrtype.h>
-],[
-isc::dns::RRType rrtype(1);
-],
-[ AC_MSG_RESULT(yes)],
-[ AC_MSG_RESULT(no)
-  AC_MSG_ERROR(unable to find required BIND 10 libraries)])
-
-CPPFLAGS="$CPPFLAGS_SAVED"
-LDFLAGS="$LDFLAGS_SAVES"
-LIBS="$LIBS_SAVES"
-
-AC_SUBST(BIND10_LDFLAGS)
-AC_SUBST(BIND10_LDADD)
-
-# Checks for header files.
+# Checks for BIND 10 headers and libraries
+AX_ISC_BIND10
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDBOOL
 
-# Checks for library functions.
-AC_CHECK_FUNCS([gettimeofday memset socket])
-
 AC_CONFIG_FILES([Makefile
                  host/Makefile])
 

+ 2 - 2
examples/host/Makefile.am

@@ -1,6 +1,6 @@
-AM_CPPFLAGS = $(BOOST_INCLUDES) $(BIND10_INCLUDES)
+AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(BIND10_CPPFLAGS)
 
 bin_PROGRAMS = b10-host
 b10_host_SOURCES = host.cc
 b10_host_LDFLAGS = ${BIND10_LDFLAGS}
-b10_host_LDADD = ${BIND10_LDADD}
+b10_host_LDADD = ${BIND10_DNS_LIB}

+ 64 - 0
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 <boost/config.hpp>
+#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

+ 100 - 0
examples/m4/ax_isc_bind10.m4

@@ -0,0 +1,100 @@
+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_DNS_LIB)
+dnl
+
+
+AC_DEFUN([AX_ISC_BIND10], [
+AC_REQUIRE([AX_BOOST_INCLUDE])
+AC_LANG_SAVE
+AC_LANG([C++])
+
+AX_BOOST_INCLUDE
+
+# Check for BIND10 libdns++ 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/dns/rrtype.h; then
+	   bind10_inc_path=$d
+	   break
+	fi
+   done
+fi
+CPPFLAGS_SAVES="$CPPFLAGS"
+if test "${bind10_inc_path}" ; then
+   BIND10_CPPFLAGS="-I${bind10_inc_path}"
+   CPPFLAGS="$CPPFLAGS $BIND10_CPPFLAGS"
+fi
+AC_CHECK_HEADERS([dns/rrtype.h],,
+  AC_MSG_ERROR([Missing required 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([BIND 10 libraries])
+BIND10_DNS_LIB="-lb10-dns++ -lb10-util -lb10-exceptions"
+LDFLAGS="$LDFLAGS $BIND10_LDFLAGS"
+LIBS="$LIBS $BIND10_DNS_LIB"
+for d in $bind10_lib_dirs
+do
+  LDFLAGS_SAVED="$LDFLAGS"
+  LDFLAGS="$LDFLAGS -L$d"
+  AC_TRY_LINK([
+#include <dns/rrtype.h>
+],[
+isc::dns::RRType rrtype(1);
+], [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
+
+CPPFLAGS="$CPPFLAGS_SAVED"
+LDFLAGS="$LDFLAGS_SAVES"
+LIBS="$LIBS_SAVES"
+
+AC_SUBST(BIND10_LDFLAGS)
+AC_SUBST(BIND10_DNS_LIB)
+
+AC_LANG_RESTORE
+])dnl AX_ISC_BIND10