aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac32
-rw-r--r--cutl/Makefile.am4
-rw-r--r--cutl/details/config.h.in1
-rw-r--r--cutl/makefile17
-rw-r--r--cutl/re/re.cxx6
-rw-r--r--m4/libboost.m4144
6 files changed, 195 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac
index 5691eb1..9b71e7f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,6 +24,38 @@ AC_LANG(C++)
#
LT_OUTPUT
+# Check if we need to use external Boost.
+#
+AC_MSG_CHECKING([if we should use external boost])
+
+AC_ARG_WITH(
+ [external-boost],
+ [AC_HELP_STRING([--with-external-boost],[use external boost instead of the internal subset])],
+ [external_boost=${withval}],
+ [external_boost=no])
+
+if test x"$external_boost" != xno; then
+ AC_MSG_RESULT([yes])
+
+ # Check if we have Boost.
+ #
+ boost_found=yes
+ LIBBOOST([],[boost_found=no])
+ LIBBOOST_REGEX([],[boost_found=no])
+ LIBBOOST_SYSTEM
+
+ if test x"$boost_found" == xno; then
+ AC_MSG_ERROR([boost regex is not found; consider using CPPFLAGS/LDFLAGS or --with-boost=DIR to specify its location])
+ fi
+
+ AC_DEFINE([LIBCUTL_EXTERNAL_BOOST], [1], [Use external boost.])
+else
+ AC_MSG_RESULT([no])
+fi
+
+AM_CONDITIONAL([LIBCUTL_EXTERNAL_BOOST], [test x"$external_boost" != xno])
+
+
# Define LIBODB_STATIC_LIB if we are build static library on certain platforms.
#
STATIC_LIB([LIBCUTL_STATIC_LIB], [Static library interface.])
diff --git a/cutl/Makefile.am b/cutl/Makefile.am
index 345fcd5..ca5adc5 100644
--- a/cutl/Makefile.am
+++ b/cutl/Makefile.am
@@ -8,6 +8,10 @@ EXTRA_DIST = __file__(extra_dist)
lib_LTLIBRARIES = libcutl.la
libcutl_la_SOURCES = __path__(sources)
+if !LIBCUTL_EXTERNAL_BOOST
+libcutl_la_SOURCES += __path__(boost_sources)
+endif
+
cutlincludedir = $(includedir)/cutl
nobase_cutlinclude_HEADERS = __path__(headers)
nobase_nodist_cutlinclude_HEADERS = details/config.h
diff --git a/cutl/details/config.h.in b/cutl/details/config.h.in
index 5049b74..a3f0c51 100644
--- a/cutl/details/config.h.in
+++ b/cutl/details/config.h.in
@@ -10,5 +10,6 @@
#define CUTL_DETAILS_CONFIG_H
#undef LIBCUTL_STATIC_LIB
+#undef LIBCUTL_EXTERNAL_BOOST
#endif /* CUTL_DETAILS_CONFIG_H */
diff --git a/cutl/makefile b/cutl/makefile
index c1c3b37..505bb41 100644
--- a/cutl/makefile
+++ b/cutl/makefile
@@ -5,18 +5,18 @@
include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make
-cxx_tun := exception.cxx shared-ptr/base.cxx
+sources := exception.cxx shared-ptr/base.cxx
-cxx_tun += fs/exception.cxx fs/path.cxx fs/auto-remove.cxx
+sources += fs/exception.cxx fs/path.cxx fs/auto-remove.cxx
-cxx_tun += re/re.cxx
+sources += re/re.cxx
-cxx_tun += \
+sources += \
compiler/context.cxx \
compiler/type-info.cxx \
compiler/cxx-indenter.cxx
-cxx_tun += \
+boost_sources := \
details/boost/regex/src/regex.cxx \
details/boost/regex/src/usinstances.cxx \
details/boost/regex/src/regex_raw_buffer.cxx \
@@ -35,7 +35,7 @@ details/boost/regex/src/static_mutex.cxx \
details/boost/regex/src/icu.cxx \
details/boost/regex/src/winstances.cxx
-
+cxx_tun := $(sources) $(boost_sources)
cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o))
cxx_od := $(cxx_obj:.o=.o.d)
@@ -74,7 +74,8 @@ $(out_base)/: $(cutl.l)
# Dist.
#
-$(dist): export sources := $(cxx_tun)
+$(dist): export sources := $(sources)
+$(dist): export boost_sources := $(boost_sources)
$(dist): export headers := $(subst $(src_base)/,,$(shell find $(src_base) \
-name '*.hxx' -o -name '*.ixx' -o -name '*.txx'))
$(dist): data_dist := details/config-vc.h $(subst $(src_base)/,,$(shell find \
@@ -86,7 +87,7 @@ $(dist): export interface_version = $(shell sed -e \
's/^\([0-9]*\.[0-9]*\).*/\1/' $(src_root)/version)
$(dist):
- $(call dist-data,$(sources) $(headers) $(data_dist) details/config.h.in)
+ $(call dist-data,$(sources) $(boost_sources) $(headers) $(data_dist) details/config.h.in)
$(call meta-vc9proj,libcutl-vc9.vcproj)
$(call meta-vc10proj,libcutl-vc10.vcxproj)
$(call meta-automake)
diff --git a/cutl/re/re.cxx b/cutl/re/re.cxx
index 9cd2f2e..96d5651 100644
--- a/cutl/re/re.cxx
+++ b/cutl/re/re.cxx
@@ -7,7 +7,11 @@
#include <cutl/re.hxx>
-#include <cutl/details/boost/tr1/regex.hpp>
+#ifndef LIBCUTL_EXTERNAL_BOOST
+# include <cutl/details/boost/tr1/regex.hpp>
+#else
+# include <boost/tr1/regex.hpp>
+#endif
using namespace std;
diff --git a/m4/libboost.m4 b/m4/libboost.m4
new file mode 100644
index 0000000..64d34d3
--- /dev/null
+++ b/m4/libboost.m4
@@ -0,0 +1,144 @@
+dnl file : m4/libboost.m4
+dnl author : Boris Kolpackov <boris@codesynthesis.com>
+dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+dnl license : MIT; see accompanying LICENSE file
+dnl
+dnl LIBBOOST([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl
+dnl
+AC_DEFUN([LIBBOOST], [
+libboost_found=no
+
+AC_MSG_CHECKING([for boost base headers])
+
+AC_ARG_WITH(
+ [boost],
+ [AC_HELP_STRING([--with-boost=DIR],[location of boost build directory])],
+ [libboost_dir=${withval}],
+ [libboost_dir=])
+
+# If libboost_dir was given, add the necessary preprocessor and linker flags.
+#
+if test x"$libboost_dir" != x; then
+ save_CPPFLAGS="$CPPFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+
+ AS_SET_CATFILE([abs_libboost_dir], [$ac_pwd], [$libboost_dir])
+
+ CPPFLAGS="$CPPFLAGS -I$abs_libboost_dir"
+ LDFLAGS="$LDFLAGS -L$abs_libboost_dir/stage/lib"
+fi
+
+CXX_LIBTOOL_LINK_IFELSE(
+AC_LANG_SOURCE([[
+#include <boost/version.hpp>
+
+#ifndef BOOST_VERSION
+# error BOOST_VERSION not defined
+#endif
+
+int
+main ()
+{
+}
+]]),
+[
+libboost_found=yes
+])
+
+if test x"$libboost_found" = xno; then
+ if test x"$libboost_dir" != x; then
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ fi
+fi
+
+if test x"$libboost_found" = xyes; then
+ AC_MSG_RESULT([yes])
+ $1
+else
+ AC_MSG_RESULT([no])
+ $2
+fi
+])dnl
+dnl
+dnl LIBBOOST_HEADER_LIB(NAME, SOURCE, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
+dnl
+AC_DEFUN([LIBBOOST_HEADER_LIB], [
+libboost_$1_found=no
+
+AC_MSG_CHECKING([for boost $1 library])
+CXX_LIBTOOL_LINK_IFELSE([$2],[libboost_$1_found=yes])
+
+if test x"$libboost_$1_found" = xyes; then
+ AC_MSG_RESULT([yes])
+ [$3]
+else
+ AC_MSG_RESULT([no])
+ [$4]
+fi
+])dnl
+dnl
+dnl LIBBOOST_LIB(NAME, SOURCE, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
+dnl
+AC_DEFUN([LIBBOOST_LIB], [
+libboost_$1_found=no
+
+AC_MSG_CHECKING([for boost $1 library])
+
+save_LIBS="$LIBS"
+LIBS="-lboost_$1 $LIBS"
+
+CXX_LIBTOOL_LINK_IFELSE([$2],[libboost_$1_found=yes])
+
+# Try to fall back on the -mt version for backwards-compatibility.
+#
+if test x"$libboost_$1_found" = xno; then
+ LIBS="-lboost_$1-mt $save_LIBS"
+ CXX_LIBTOOL_LINK_IFELSE([$2],[libboost_$1_found=yes])
+fi
+
+if test x"$libboost_$1_found" = xno; then
+ LIBS="$save_LIBS"
+fi
+
+if test x"$libboost_$1_found" = xyes; then
+ AC_MSG_RESULT([yes])
+ [$3]
+else
+ AC_MSG_RESULT([no])
+ [$4]
+fi
+])dnl
+dnl
+dnl LIBBOOST_SYSTEM([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl
+AC_DEFUN([LIBBOOST_SYSTEM], [
+LIBBOOST_LIB([system],
+AC_LANG_SOURCE([[
+int
+main ()
+{
+}
+]]),
+[$1],
+[$2])
+])dnl
+dnl
+dnl LIBBOOST_REGEX([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl
+AC_DEFUN([LIBBOOST_REGEX], [
+LIBBOOST_LIB([regex],
+AC_LANG_SOURCE([[
+#include <boost/tr1/regex.hpp>
+
+int
+main ()
+{
+ std::tr1::regex r ("te.t", std::tr1::regex_constants::ECMAScript);
+ return std::tr1::regex_match ("test", r) ? 0 : 1;
+}
+]]),
+[$1],
+[$2])
+])dnl