aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am10
-rw-r--r--README0
-rwxr-xr-xbootstrap18
-rw-r--r--build/bootstrap.make33
-rw-r--r--configure.ac77
-rw-r--r--m4/disable-rpath.m426
-rw-r--r--m4/gcc-plugin.m428
-rw-r--r--m4/libcutl.m483
-rw-r--r--m4/libtool-link.m431
-rw-r--r--makefile39
-rw-r--r--odb/Makefile.am31
-rw-r--r--odb/makefile25
12 files changed, 358 insertions, 43 deletions
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..0188df6
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,10 @@
+# file : Makefile.am
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+SUBDIRS = __path__(dirs)
+dist_doc_DATA = __file__(docs)
+EXTRA_DIST = __file__(extra_dist)
+ACLOCAL_AMFLAGS = -I m4
+
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..ceb2ea7
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+# file : bootstrap
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+#
+# Bootstrap the automake build system.
+#
+
+rm -f config.cache
+
+if test ! -d m4; then
+ mkdir m4
+fi
+
+autoreconf --install
diff --git a/build/bootstrap.make b/build/bootstrap.make
index 3078be4..733abef 100644
--- a/build/bootstrap.make
+++ b/build/bootstrap.make
@@ -27,22 +27,28 @@ $(call include,$(bld_root)/cxx/configuration.make)
# Aliases
#
.PHONY: $(out_base)/ \
- $(out_base)/.test \
- $(out_base)/.install \
+ $(out_base)/.dist \
$(out_base)/.clean \
$(out_base)/.cleandoc
ifdef %interactive%
-.PHONY: test install clean cleandoc
+.PHONY: dist clean cleandoc
-test: $(out_base)/.test
-install: $(out_base)/.install
-clean: $(out_base)/.clean
+dist: $(out_base)/.dist
+clean: $(out_base)/.clean
cleandoc: $(out_base)/.cleandoc
endif
+# Make sure the distribution prefix is set if the goal is dist.
+#
+ifneq ($(filter $(MAKECMDGOALS),dist),)
+ifeq ($(dist_prefix),)
+$(error dist_prefix is not set)
+endif
+endif
+
ifdef cxx_id
# It would be better to do these checks in the script once instead
@@ -69,25 +75,10 @@ endef
endif
-
# Don't include dependency info for certain targets.
#
ifneq ($(filter $(MAKECMDGOALS),clean cleandoc disfigure),)
include-dep =
endif
-# For install, don't include dependecies in examples, and tests.
-#
-ifneq ($(filter $(MAKECMDGOALS),install),)
-
-ifneq ($(subst $(src_root)/tests/,,$(src_base)),$(src_base))
-include-dep =
-endif
-
-ifneq ($(subst $(src_root)/examples/,,$(src_base)),$(src_base))
-include-dep =
-endif
-
-endif
-
.DEFAULT_GOAL := $(def_goal)
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..a0b8744
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,77 @@
+# file : configure.ac
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+AC_PREREQ(2.60)
+AC_INIT([odb], [__value__(version)], [odb-users@codesynthesis.com])
+AC_CONFIG_AUX_DIR([config])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_SRCDIR([odb/version.hxx])
+
+AM_INIT_AUTOMAKE([-Wall -Werror foreign nostdinc subdir-objects dist-bzip2 dist-zip tar-ustar])
+
+LT_INIT([disable-static])
+
+AC_CANONICAL_HOST
+
+# Check for C++ compiler and use it to compile the tests.
+#
+AC_PROG_CXX
+AC_LANG(C++)
+
+# See if we are building static plugin.
+#
+static_plugin="$enable_static"
+
+AS_IF([test x$static_plugin = xyes],
+ AC_DEFINE([STATIC_PLUGIN], [1], [Building static plugin.]))
+
+# Check for plugin support in GCC unless we are building a static plugin.
+#
+AS_IF([test x$static_plugin = xno], GCC_PLUGIN)
+
+#
+#
+AC_ARG_WITH(
+ [gxx-name],
+ [AC_HELP_STRING([--with-gxx-name=NAME], [g++ binary to embed in the driver])],
+ [case $withval in
+ no)
+ gxx_name=
+ ;;
+ yes)
+ gxx_name=$CXX
+ ;;
+ *)
+ gxx_name="$withval"
+ ;;
+ esac],
+ [gxx_name=$CXX])
+
+AS_IF(
+ [test x$gxx_name != x],
+ [AC_DEFINE_UNQUOTED([GXX_NAME], ["$gxx_name"], [g++ binary.])])
+
+
+# Create the libtool executable so that we can use it in further tests.
+#
+LT_OUTPUT
+
+
+# Check for libcutl.
+#
+LIBCUTL([],[AC_MSG_ERROR([libcutl is not found; consider using --with-libcutl=DIR])])
+
+
+# Check if we should disable rpath.
+#
+DISABLE_RPATH
+
+# Output.
+#
+AC_CONFIG_HEADERS([odb/config.h])
+AC_CONFIG_FILES([
+ __path__(config_files)
+])
+AC_OUTPUT
diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4
new file mode 100644
index 0000000..da77bbe
--- /dev/null
+++ b/m4/disable-rpath.m4
@@ -0,0 +1,26 @@
+dnl file : m4/disable-rpath.m4
+dnl author : Boris Kolpackov <boris@codesynthesis.com>
+dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+dnl license : GNU GPL v2; see accompanying LICENSE file
+dnl
+AC_DEFUN([DISABLE_RPATH],[
+
+AC_MSG_CHECKING([whether to use rpath])
+AC_ARG_ENABLE(
+ [rpath],
+ [AC_HELP_STRING([--disable-rpath], [patch libtool to not use rpath])],
+ [libtool_rpath="$enable_rpath"],
+ [libtool_rpath="yes"])
+AC_MSG_RESULT($libtool_rpath)
+
+# Patch libtool to not use rpath if requested.
+#
+AC_CONFIG_COMMANDS(
+ [libtool-rpath-patch],
+ [if test "$libtool_use_rpath" = "no"; then
+ sed < libtool > libtool-2 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_NO_RPATH__ "/'
+ mv libtool-2 libtool
+ chmod 755 libtool
+ fi],
+ [libtool_use_rpath=$libtool_rpath])
+])dnl
diff --git a/m4/gcc-plugin.m4 b/m4/gcc-plugin.m4
new file mode 100644
index 0000000..d270ce0
--- /dev/null
+++ b/m4/gcc-plugin.m4
@@ -0,0 +1,28 @@
+dnl file : m4/gcc-plugin.m4
+dnl author : Boris Kolpackov <boris@codesynthesis.com>
+dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+dnl license : GNU GPL v2; see accompanying LICENSE file
+dnl
+dnl GCC_PLUGIN
+dnl
+AC_DEFUN([GCC_PLUGIN], [
+gcc_plugin_support=no
+
+if test x"$GXX" != xyes; then
+ AC_MSG_ERROR([$CXX is not a GNU C++ compiler])
+fi
+
+AC_MSG_CHECKING([whether $CXX supports plugins])
+
+gcc_plugin_base=`$CXX -print-file-name=plugin 2>/dev/null`
+
+if test x"$gcc_plugin_base" = xplugin; then
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([$CXX does not support plugins; reconfigure GCC with --enable-plugin])
+else
+ AC_MSG_RESULT([yes])
+ gcc_plugin_support=yes
+fi
+
+CPPFLAGS="$CPPFLAGS -I$gcc_plugin_base/include"
+])dnl
diff --git a/m4/libcutl.m4 b/m4/libcutl.m4
new file mode 100644
index 0000000..f51aee5
--- /dev/null
+++ b/m4/libcutl.m4
@@ -0,0 +1,83 @@
+dnl file : m4/libcutl.m4
+dnl author : Boris Kolpackov <boris@codesynthesis.com>
+dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+dnl license : MIT; see accompanying LICENSE file
+dnl
+dnl LIBCUTL([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl
+dnl
+AC_DEFUN([LIBCUTL], [
+libcutl_found=no
+
+AC_ARG_WITH(
+ [libcutl],
+ [AC_HELP_STRING([--with-libcutl=DIR],[location of libcutl build directory])],
+ [libcutl_dir=${withval}],
+ [libcutl_dir=])
+
+AC_MSG_CHECKING([for libcutl])
+
+# If libcutl_dir was given, add the necessary preprocessor and linker flags.
+#
+if test x"$libcutl_dir" != x; then
+ save_CPPFLAGS="$CPPFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+
+ AS_SET_CATFILE([abs_libcutl_dir], [$ac_pwd], [$libcutl_dir])
+
+ CPPFLAGS="$CPPFLAGS -I$abs_libcutl_dir"
+ LDFLAGS="$LDFLAGS -L$abs_libcutl_dir/cutl"
+fi
+
+save_LIBS="$LIBS"
+LIBS="-lcutl $LIBS"
+
+CXX_LIBTOOL_LINK_IFELSE(
+AC_LANG_SOURCE([[
+#include <cutl/exception.hxx>
+
+void
+f ()
+{
+}
+
+const char*
+g ()
+{
+ try
+ {
+ f ();
+ }
+ catch (const cutl::exception& e)
+ {
+ return e.what ();
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ const char* m (g ());
+ return m != 0;
+}
+]]),
+[libcutl_found=yes])
+
+if test x"$libcutl_found" = xno; then
+ LIBS="$save_LIBS"
+
+ if test x"$libcutl_dir" != x; then
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ fi
+fi
+
+if test x"$libcutl_found" = xyes; then
+ AC_MSG_RESULT([yes])
+ $1
+else
+ AC_MSG_RESULT([no])
+ $2
+fi
+])dnl
diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4
new file mode 100644
index 0000000..229b270
--- /dev/null
+++ b/m4/libtool-link.m4
@@ -0,0 +1,31 @@
+dnl file : m4/libtool-link.m4
+dnl author : Boris Kolpackov <boris@codesynthesis.com>
+dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+dnl license : GNU GPL v2; see accompanying LICENSE file
+dnl
+dnl
+dnl CXX_LIBTOOL_LINK_IFELSE (input, [action-if-true], [action-if-false])
+dnl
+dnl Similar to AC_LINK_IFELSE except it uses libtool to perform the
+dnl linking and it does this using the C++ compiler.
+dnl
+AC_DEFUN([CXX_LIBTOOL_LINK_IFELSE],[
+AC_LANG_SAVE
+save_CXX="$CXX"
+CXX="./libtool --tag=CXX --mode=link $CXX -no-install"
+AC_LANG(C++)
+
+if test -d .libs; then
+ delete_libs_dir=no
+else
+ delete_libs_dir=yes
+fi
+
+AC_LINK_IFELSE([$1], [$2], [$3])
+
+if test x"$delete_libs_dir" != xyes; then
+ rm -rf .libs
+fi
+
+CXX="$save_CXX"
+AC_LANG_RESTORE])dnl
diff --git a/makefile b/makefile
index 00a6adb..14fe2c0 100644
--- a/makefile
+++ b/makefile
@@ -5,31 +5,34 @@
include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make
+dirs := odb
+
default := $(out_base)/
-test := $(out_base)/.test
-install := $(out_base)/.install
+dist := $(out_base)/.dist
clean := $(out_base)/.clean
cleandoc := $(out_base)/.cleandoc
-$(default): $(out_base)/odb/
-
-
-# Test.
-#
-$(test): $(out_base)/tests/.test
-
-
-# Install.
-#
-$(install): $(out_base)/odb/.install
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs)))
+$(dist): export dirs := $(dirs)
+$(dist): export docs := GPLv2 LICENSE README version
+$(dist): data_dist :=
+$(dist): exec_dist := bootstrap
+$(dist): export extra_dist := $(data_dist) $(exec_dist)
+$(dist): export version = $(shell cat $(src_root)/version)
-# Clean.
-#
-$(clean): $(out_base)/odb/.clean
+$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(dirs)))
+ $(call dist-data,$(docs) $(data_dist))
+ $(call dist-exec,$(exec_dist))
+ $(call dist-dir,m4)
+ $(call meta-automake)
+ $(call meta-autoconf)
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(dirs)))
$(cleandoc): $(out_base)/doc/.cleandoc
-$(call include,$(bld_root)/install.make)
+$(call include,$(bld_root)/dist.make)
+$(call include,$(bld_root)/meta/automake.make)
+$(call include,$(bld_root)/meta/autoconf.make)
-$(call import,$(src_base)/odb/makefile)
+$(foreach d,$(dirs),$(call import,$(src_base)/$d/makefile))
diff --git a/odb/Makefile.am b/odb/Makefile.am
new file mode 100644
index 0000000..e8f2b40
--- /dev/null
+++ b/odb/Makefile.am
@@ -0,0 +1,31 @@
+# file : odb/Makefile.am
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+plugindir = $(bindir)
+
+bin_PROGRAMS = odb
+plugin_LTLIBRARIES = odb.la
+
+AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)
+
+EXTRA_DIST = __path__(headers) __path__(extra_dist)
+
+# Plugin.
+#
+odb_la_SOURCES = __path__(plugin_sources) __path__(common_sources)
+odb_la_LDFLAGS = -module -shrext .so -avoid-version
+
+# Remove the .la file from the final install.
+#
+install-data-hook:
+ rm -f $(bindir)/odb.la
+
+# Driver.
+#
+odb_SOURCES = __path__(driver_sources) __path__(common_sources)
+
+# Make sure common sources are compiled differently.
+#
+odb_CXXFLAGS = $(AM_CXXFLAGS)
diff --git a/odb/makefile b/odb/makefile
index 5eb23a1..d8592e4 100644
--- a/odb/makefile
+++ b/odb/makefile
@@ -84,10 +84,9 @@ odb_so := $(out_base)/odb.so
# Dummy library to force driver timestamp update when the plugin DSO
# changes.
#
-odb.l := $(out_base)/odb.l
-
-clean := $(out_base)/.clean
-install := $(out_base)/.install
+odb.l := $(out_base)/odb.l
+clean := $(out_base)/.clean
+dist := $(out_base)/.dist
# Import.
#
@@ -133,6 +132,21 @@ $(install): $(odb)
$(call install-exec,$<,$(install_bin_dir)/odb)
$(call install-exec,$<.so,$(install_bin_dir)/odb.so)
+# Dist.
+#
+$(dist): export plugin_sources := $(cxx_ptun)
+$(dist): export driver_sources := $(cxx_dtun)
+$(dist): export common_sources := $(cxx_ctun) $(cli_tun:.cli=.cxx)
+$(dist): export headers = $(subst $(src_base)/,,$(shell find $(src_base) \
+-name '*.hxx' -o -name '*.ixx' -o -name '*.txx'))
+$(dist): data_dist := $(cli_tun)
+$(dist): export extra_dist := $(data_dist)
+
+$(dist): $(gen)
+ $(call dist-data,$(plugin_sources) $(driver_sources) \
+$(common_sources) $(headers) $(data_dist))
+ $(call meta-automake)
+
# Clean.
#
$(clean): \
@@ -159,7 +173,10 @@ endif
# Rules.
#
+$(call include,$(bld_root)/dist.make)
+$(call include,$(bld_root)/meta/automake.make)
$(call include,$(bld_root)/install.make)
+
$(call include,$(cli_rules))
$(call include,$(bld_root)/cxx/cxx-d.make)
$(call include,$(bld_root)/cxx/cxx-o.make)