From 921c4c14c2999a03b9e649b5c9adec73b5cae0de Mon Sep 17 00:00:00 2001
From: Boris Kolpackov <boris@codesynthesis.com>
Date: Mon, 6 Sep 2010 14:26:25 +0200
Subject: Add automake build support

---
 mysql/Makefile.am          |  6 ++++++
 mysql/makefile             | 12 ++++++++++--
 mysql/template/Makefile.am | 27 +++++++++++++++++++++++++++
 mysql/template/makefile    | 13 ++++++++++++-
 mysql/truncation/makefile  | 13 ++++++++++++-
 mysql/types/makefile       | 17 +++++++++++++++--
 mysql/types/test.mk        |  4 ++++
 7 files changed, 86 insertions(+), 6 deletions(-)
 create mode 100644 mysql/Makefile.am
 create mode 100644 mysql/template/Makefile.am
 create mode 100644 mysql/types/test.mk

(limited to 'mysql')

diff --git a/mysql/Makefile.am b/mysql/Makefile.am
new file mode 100644
index 0000000..1e8c1c0
--- /dev/null
+++ b/mysql/Makefile.am
@@ -0,0 +1,6 @@
+# file      : mysql/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)
diff --git a/mysql/makefile b/mysql/makefile
index ae1b83f..53dd049 100644
--- a/mysql/makefile
+++ b/mysql/makefile
@@ -6,16 +6,24 @@
 include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make
 
 tests :=      \
+template      \
 truncation    \
-types         \
-template
+types
 
 default   := $(out_base)/
+dist      := $(out_base)/.dist
 test      := $(out_base)/.test
 clean     := $(out_base)/.clean
 
 $(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests)))
+
+$(dist): export dirs := $(tests)
+$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(tests)))
+	$(call meta-automake)
+
 $(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests)))
 $(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests)))
 
+$(call include,$(bld_root)/meta/automake.make)
+
 $(foreach t,$(tests),$(call import,$(src_base)/$t/makefile))
diff --git a/mysql/template/Makefile.am b/mysql/template/Makefile.am
new file mode 100644
index 0000000..46c3bae
--- /dev/null
+++ b/mysql/template/Makefile.am
@@ -0,0 +1,27 @@
+# file      : mysql/template/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
+
+noinst_PROGRAMS = driver
+driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers)
+driver_LDADD = $(top_builddir)/libcommon/libcommon.la
+driver_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon'
+
+TESTS=$(top_builddir)/tester
+TESTS_ENVIRONMENT=top_builddir=$(top_builddir);
+
+m4_ifelse(__value__(odb_options),,,
+
+# ODB compilation.
+#
+driver_SOURCES += test.hxx test-odb.cxx
+BUILT_SOURCES = test-odb.hxx
+CLEANFILES = test-odb.hxx test-odb.ixx test-odb.cxx
+
+ODB = @ODB@
+ODBFLAGS = @ODBFLAGS@
+
+test-odb.hxx: test.hxx
+	$(ODB) $(ODBCPPFLAGS) $(CPPFLAGS) $(ODBFLAGS) __value__(odb_options) $<
+)
diff --git a/mysql/template/makefile b/mysql/template/makefile
index a614597..28146f4 100644
--- a/mysql/template/makefile
+++ b/mysql/template/makefile
@@ -14,6 +14,7 @@ common.l             := $(out_root)/libcommon/common.l
 common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options
 
 driver  := $(out_base)/driver
+dist    := $(out_base)/.dist
 test    := $(out_base)/.test
 clean   := $(out_base)/.clean
 
@@ -40,7 +41,7 @@ gen  := $(addprefix $(out_base)/,$(genf))
 
 $(gen): $(odb)
 $(gen): odb := $(odb)
-$(gen): odb_options += --database $(db_id) --generate-schema
+$(gen) $(dist): export odb_options += --database mysql --generate-schema
 $(gen): cpp_options := -I$(out_base)
 $(gen): $(common.l.cpp-options)
 
@@ -50,6 +51,13 @@ $(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
 #
 $(out_base)/: $(driver)
 
+# Dist
+#
+$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std
+$(dist):
+	$(call dist-data,$(data_dist))
+	$(call meta-automake)
+
 # Test.
 #
 $(test): $(driver) $(src_base)/test.std
@@ -78,6 +86,9 @@ endif
 
 # How to.
 #
+$(call include,$(bld_root)/dist.make)
+$(call include,$(bld_root)/meta/automake.make)
+
 $(call include,$(odb_rules))
 $(call include,$(bld_root)/cxx/cxx-d.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
diff --git a/mysql/truncation/makefile b/mysql/truncation/makefile
index 84eb4f3..f0d475d 100644
--- a/mysql/truncation/makefile
+++ b/mysql/truncation/makefile
@@ -14,6 +14,7 @@ common.l             := $(out_root)/libcommon/common.l
 common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options
 
 driver  := $(out_base)/driver
+dist    := $(out_base)/.dist
 test    := $(out_base)/.test
 clean   := $(out_base)/.clean
 
@@ -40,7 +41,7 @@ gen  := $(addprefix $(out_base)/,$(genf))
 
 $(gen): $(odb)
 $(gen): odb := $(odb)
-$(gen): odb_options += --database $(db_id) --generate-schema
+$(gen) $(dist): export odb_options += --database mysql --generate-schema
 $(gen): cpp_options := -I$(out_base)
 $(gen): $(common.l.cpp-options)
 
@@ -50,6 +51,13 @@ $(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
 #
 $(out_base)/: $(driver)
 
+# Dist
+#
+$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std
+$(dist):
+	$(call dist-data,$(data_dist))
+	$(call meta-automake,$(src_root)/mysql/template/Makefile.am)
+
 # Test.
 #
 $(test): $(driver) $(src_base)/test.std
@@ -78,6 +86,9 @@ endif
 
 # How to.
 #
+$(call include,$(bld_root)/dist.make)
+$(call include,$(bld_root)/meta/automake.make)
+
 $(call include,$(odb_rules))
 $(call include,$(bld_root)/cxx/cxx-d.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
diff --git a/mysql/types/makefile b/mysql/types/makefile
index c7c8742..859ef29 100644
--- a/mysql/types/makefile
+++ b/mysql/types/makefile
@@ -14,6 +14,7 @@ common.l             := $(out_root)/libcommon/common.l
 common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options
 
 driver  := $(out_base)/driver
+dist    := $(out_base)/.dist
 test    := $(out_base)/.test
 clean   := $(out_base)/.clean
 
@@ -40,8 +41,9 @@ gen  := $(addprefix $(out_base)/,$(genf))
 
 $(gen): $(odb)
 $(gen): odb := $(odb)
-$(gen): odb_options += --database $(db_id) --generate-schema \
---generate-query --cxx-prologue '\\\#include "traits.hxx"'
+$(gen) $(dist): export odb_options += --database mysql --generate-schema \
+--generate-query --cxx-prologue '\#include "traits.hxx"'
+
 $(gen): cpp_options := -I$(out_base)
 $(gen): $(common.l.cpp-options)
 
@@ -51,6 +53,14 @@ $(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
 #
 $(out_base)/: $(driver)
 
+# Dist
+#
+$(dist): data_dist := $(cxx_tun) $(odb_hdr) traits.hxx test.std
+$(dist): export extra_headers := traits.hxx
+$(dist):
+	$(call dist-data,$(data_dist))
+	$(call meta-automake,$(src_root)/mysql/template/Makefile.am)
+
 # Test.
 #
 $(test): $(driver) $(src_base)/test.std
@@ -79,6 +89,9 @@ endif
 
 # How to.
 #
+$(call include,$(bld_root)/dist.make)
+$(call include,$(bld_root)/meta/automake.make)
+
 $(call include,$(odb_rules))
 $(call include,$(bld_root)/cxx/cxx-d.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
diff --git a/mysql/types/test.mk b/mysql/types/test.mk
new file mode 100644
index 0000000..693fc71
--- /dev/null
+++ b/mysql/types/test.mk
@@ -0,0 +1,4 @@
+v = '\#include "foo.hxx"'
+
+all:
+	echo $v
-- 
cgit v1.1