aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-09-02 14:15:46 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-21 11:47:16 +0200
commit84f9ce9150abfb5f4424d8e94fefa932af3172fa (patch)
tree5205a6d141793c190fe1e0cacda2b5f1bac6b06f
parent7e70aa043b7a2482590b0e5459284d2c848eb474 (diff)
Add infrastructure for oracle development testing and implement native test
-rw-r--r--INSTALL1
-rw-r--r--build/bootstrap.make2
-rwxr-xr-xbuild/configure3
-rw-r--r--build/import/libodb-oracle/LICENSE12
-rw-r--r--build/import/libodb-oracle/configuration-rules.make15
-rwxr-xr-xbuild/import/libodb-oracle/configure55
-rw-r--r--build/import/libodb-oracle/stub.make30
-rwxr-xr-xbuild/oracle/configure75
-rwxr-xr-xbuild/oracle/oracle73
-rw-r--r--libcommon/common/common.cxx14
-rw-r--r--libcommon/common/config.h.in1
-rw-r--r--libcommon/common/makefile3
-rw-r--r--makefile9
-rw-r--r--oracle/makefile35
-rw-r--r--oracle/native/driver.cxx78
-rw-r--r--oracle/native/makefile85
-rw-r--r--oracle/native/test.std0
-rw-r--r--oracle/template/driver.cxx44
-rw-r--r--oracle/template/makefile106
-rw-r--r--oracle/template/test.hxx27
-rw-r--r--oracle/template/test.std1
21 files changed, 666 insertions, 3 deletions
diff --git a/INSTALL b/INSTALL
index 719b6c1..7d87da3 100644
--- a/INSTALL
+++ b/INSTALL
@@ -4,6 +4,7 @@ system you would like to use. Valid values for <database> are:
'mysql' - The MySQL database system
'sqlite' - The SQLite database system
'pgsql' - The PostgreSQL database system
+ 'oracle' - The Oracle database system
Prerequisites
=============
diff --git a/build/bootstrap.make b/build/bootstrap.make
index 3c5ca1e..f59e809 100644
--- a/build/bootstrap.make
+++ b/build/bootstrap.make
@@ -62,7 +62,7 @@ ifeq ($(dist_prefix),)
$(error dist_prefix is not set)
endif
-databases := mysql sqlite pgsql
+databases := mysql sqlite pgsql oracle
$(dist): databases := $(databases)
# $1 project template without the -vcN.vc[x]proj suffix.
diff --git a/build/configure b/build/configure
index 70413fc..9aee64a 100755
--- a/build/configure
+++ b/build/configure
@@ -25,9 +25,10 @@ $echo
$echo "(1) MySQL"
$echo "(2) SQLite"
$echo "(3) PostgreSQL"
+$echo "(4) Oracle"
$echo
-db_id=`read_option "mysql sqlite pgsql"`
+db_id=`read_option "mysql sqlite pgsql oracle"`
echo "db_id := $db_id" >$1
diff --git a/build/import/libodb-oracle/LICENSE b/build/import/libodb-oracle/LICENSE
new file mode 100644
index 0000000..ed9c55c
--- /dev/null
+++ b/build/import/libodb-oracle/LICENSE
@@ -0,0 +1,12 @@
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2 as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
diff --git a/build/import/libodb-oracle/configuration-rules.make b/build/import/libodb-oracle/configuration-rules.make
new file mode 100644
index 0000000..a4a8c99
--- /dev/null
+++ b/build/import/libodb-oracle/configuration-rules.make
@@ -0,0 +1,15 @@
+# file : build/import/libodb-oracle/configuration-rules.make
+# author : Constantin Michael <constantin@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+$(dcf_root)/import/libodb-oracle/configuration-dynamic.make: | $(dcf_root)/import/libodb-oracle/.
+ $(call message,,$(scf_root)/import/libodb-oracle/configure $@)
+
+ifndef %foreign%
+
+$(dcf_root)/.disfigure::
+ $(call message,rm $(dcf_root)/import/libodb-oracle/configuration-dynamic.make,\
+rm -f $(dcf_root)/import/libodb-oracle/configuration-dynamic.make)
+
+endif
diff --git a/build/import/libodb-oracle/configure b/build/import/libodb-oracle/configure
new file mode 100755
index 0000000..9934d03
--- /dev/null
+++ b/build/import/libodb-oracle/configure
@@ -0,0 +1,55 @@
+#! /usr/bin/env bash
+
+# file : build/import/libodb-oracle/configure
+# author : Constantin Michael <constantin@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+
+# $1 - out file
+#
+# bld_root - build root
+# project_name - project name
+#
+
+source $bld_root/dialog.bash
+
+
+$echo
+$echo "Configuring external dependency on 'libodb-oracle' for '$project_name'."
+$echo
+
+$echo
+$echo "Would you like to configure dependency on the installed version"
+$echo "of 'libodb-oracle' as opposed to the development build?"
+$echo
+
+installed=`read_y_n y`
+
+path=
+
+if [ "$installed" = "n" ]; then
+
+$echo
+$echo "Please enter the src_root for 'libodb-oracle'."
+$echo
+
+src_root=`read_path --directory --exist`
+
+$echo
+$echo "Please enter the out_root for 'libodb-oracle'."
+$echo
+
+out_root=`read_path --directory $src_root`
+
+fi
+
+echo libodb_oracle_installed := $installed >$1
+
+if [ "$installed" = "n" ]; then
+
+echo src_root := $src_root >>$1
+echo scf_root := \$\(src_root\)/build >>$1
+echo out_root := $out_root >>$1
+
+fi
diff --git a/build/import/libodb-oracle/stub.make b/build/import/libodb-oracle/stub.make
new file mode 100644
index 0000000..2432246
--- /dev/null
+++ b/build/import/libodb-oracle/stub.make
@@ -0,0 +1,30 @@
+# file : build/import/libodb-oracle/stub.make
+# author : Constantin Michael <constantin@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+$(call include-once,$(scf_root)/import/libodb-oracle/configuration-rules.make,$(dcf_root))
+
+libodb_oracle_installed :=
+
+$(call -include,$(dcf_root)/import/libodb-oracle/configuration-dynamic.make)
+
+ifdef libodb_oracle_installed
+
+ifeq ($(libodb_oracle_installed),y)
+
+$(call export,l: -lodb-oracle -lodb -lclntsh,cpp-options: )
+
+else
+
+# Include export stub.
+#
+$(call include,$(scf_root)/export/libodb-oracle/stub.make)
+
+endif
+
+else
+
+.NOTPARALLEL:
+
+endif
diff --git a/build/oracle/configure b/build/oracle/configure
new file mode 100755
index 0000000..46e5061
--- /dev/null
+++ b/build/oracle/configure
@@ -0,0 +1,75 @@
+#! /usr/bin/env bash
+
+# file : build/oracle/configure
+# author : Constantin Michael <constantin@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+#
+# dcf_root - dynamic configuration root
+#
+
+$echo
+$echo "Please enter the Oracle client program path."
+$echo
+
+driver=`read_path --command sqlplus`
+
+$echo
+$echo "Please enter the Oracle database user."
+$echo
+
+user=`read_value "odb_test"`
+
+$echo
+$echo "Please enter the Oracle database password."
+$echo
+
+passwd=`read_value ""`
+
+$echo
+$echo "Please enter the Oracle listener host."
+$echo
+
+host=`read_value ""`
+
+$echo
+$echo "Please enter the Oracle listener port."
+$echo
+
+port=`read_value ""`
+
+$echo
+$echo "Please enter the Oracle service to use. Note that the associated"
+$echo "database WILL BE MODIFIED."
+$echo
+
+service=`read_value ""`
+
+opt=$dcf_root/db.options
+drv=$dcf_root/db-driver
+
+if [ -n "$user" ]; then
+echo "--user '$user'" >$opt
+fi
+
+if [ -n "$passwd" ]; then
+echo "--password '$passwd'" >>$opt
+fi
+
+if [ -n "$service" ]; then
+echo "--service '$service'" >>$opt
+fi
+
+if [ -n "$host" ]; then
+echo "--host '$host'" >>$opt
+fi
+
+if [ -n "$port" ]; then
+echo "--port '$port'" >>$opt
+fi
+
+echo "#!/bin/sh" >$drv
+echo "opt=\`cat $opt\`" >>$drv
+echo "eval $scf_root/oracle/oracle --driver $driver \$opt \$*" >>$drv
+chmod 755 $drv
diff --git a/build/oracle/oracle b/build/oracle/oracle
new file mode 100755
index 0000000..76badcb
--- /dev/null
+++ b/build/oracle/oracle
@@ -0,0 +1,73 @@
+#! /usr/bin/env bash
+
+# file : build/oracle/oracle
+# author : Constantin Michael <constantin@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+#
+# Oracle driver wrapper.
+#
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ --driver)
+ driver=$2
+ shift 2
+ ;;
+ --user)
+ user="$2"
+ shift 2
+ ;;
+ --password)
+ passwd="$2"
+ shift 2
+ ;;
+ --service)
+ service="$2"
+ shift 2
+ ;;
+ --host)
+ host="$2"
+ shift 2
+ ;;
+ --port)
+ port="$2"
+ shift 2
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+if [ -z "$driver" ]; then
+ driver=sqlplus
+fi
+
+opt="-L"
+conn=$user
+
+if [ -n "$passwd" ]; then
+ conn="$conn/$passwd"
+fi
+
+if [ -n "$host" ]; then
+ conn="$conn@//$host"
+
+ if [ -n "$port" ]; then
+ conn="$conn:$port"
+ fi
+
+ if [ -n "$service" ]; then
+ conn="$conn/$service"
+ fi
+elif [ -n "$service" ]; then
+ conn="$conn@$service"
+fi
+
+if [ -n "$1" ]; then
+ exec $driver $opt $conn <$1
+else
+ exec $driver $opt $conn
+fi
diff --git a/libcommon/common/common.cxx b/libcommon/common/common.cxx
index 384d945..d09c14b 100644
--- a/libcommon/common/common.cxx
+++ b/libcommon/common/common.cxx
@@ -22,6 +22,9 @@
#elif defined(DATABASE_PGSQL)
# include <odb/pgsql/database.hxx>
# include <odb/pgsql/connection-factory.hxx>
+#elif defined(DATABASE_ORACLE)
+# include <odb/oracle/database.hxx>
+# include <odb/oracle/connection-factory.hxx>
#else
# error unknown database
#endif
@@ -37,6 +40,8 @@ namespace mysql = odb::mysql;
namespace sqlite = odb::sqlite;
#elif defined(DATABASE_PGSQL)
namespace pgsql = odb::pgsql;
+#elif defined(DATABASE_ORACLE)
+namespace oracle = odb::oracle;
#endif
auto_ptr<database>
@@ -60,6 +65,8 @@ create_database (int& argc,
sqlite::database::print_usage (cerr);
#elif defined(DATABASE_PGSQL)
pgsql::database::print_usage (cerr);
+#elif defined(DATABASE_ORAClE)
+ oracle::database::print_usage (cerr);
#endif
exit (0);
@@ -107,6 +114,13 @@ create_database (int& argc,
f.reset (new pgsql::connection_pool_factory (max_connections));
db.reset (new pgsql::database (argc, argv, false, "", f));
+#elif defined(DATABASE_ORACLE)
+ auto_ptr<oracle::connection_factory> f;
+
+ if (max_connections != 0)
+ f.reset (new oracle::connection_pool_factory (max_connections));
+
+ db.reset (new oracle::database (argc, argv, false, 0, f));
#endif
return db;
diff --git a/libcommon/common/config.h.in b/libcommon/common/config.h.in
index dba0b12..b7cc545 100644
--- a/libcommon/common/config.h.in
+++ b/libcommon/common/config.h.in
@@ -12,6 +12,7 @@
#undef DATABASE_MYSQL
#undef DATABASE_SQLITE
#undef DATABASE_PGSQL
+#undef DATABASE_ORACLE
#undef HAVE_TR1_MEMORY
#undef LIBCOMMON_STATIC_LIB
diff --git a/libcommon/common/makefile b/libcommon/common/makefile
index 326f1f6..885b55d 100644
--- a/libcommon/common/makefile
+++ b/libcommon/common/makefile
@@ -58,6 +58,9 @@ endif
ifeq ($(db_id),pgsql)
@echo '#define DATABASE_PGSQL 1' >>$@
endif
+ifeq ($(db_id),oracle)
+ @echo '#define DATABASE_ORACLE 1' >>$@
+endif
@echo '#define HAVE_TR1_MEMORY 1' >>$@
@echo '' >>$@
@echo '#endif /* LIBCOMMON_COMMON_CONFIG_H */' >>$@
diff --git a/makefile b/makefile
index cbbfa78..9bb125d 100644
--- a/makefile
+++ b/makefile
@@ -5,7 +5,7 @@
include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make
-all_dirs := libcommon common tracer mysql sqlite pgsql boost qt
+all_dirs := libcommon common tracer mysql sqlite pgsql oracle boost qt
dirs := common tracer boost qt
ifeq ($(db_id),mysql)
@@ -20,6 +20,13 @@ ifeq ($(db_id),pgsql)
dirs += pgsql
endif
+# @@ Remove overrides when Oracle implementation is complete.
+#
+ifeq ($(db_id),oracle)
+all_dirs := libcommon oracle
+dirs := libcommon oracle
+endif
+
default := $(out_base)/
dist := $(out_base)/.dist
test := $(out_base)/.test
diff --git a/oracle/makefile b/oracle/makefile
new file mode 100644
index 0000000..7b7453b
--- /dev/null
+++ b/oracle/makefile
@@ -0,0 +1,35 @@
+# file : oracle/makefile
+# author : Constantin Michael <constantin@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make
+
+tests := \
+native
+
+default := $(out_base)/
+dist := $(out_base)/.dist
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests)))
+
+$(dist): name := oracle
+$(dist): export dirs := $(tests)
+$(dist): export extra_dist := $(name)-vc9.sln $(name)-vc10.sln test.bat
+$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(tests)))
+ $(call meta-automake)
+ $(call meta-vc9sln,$(name)-vc9.sln)
+ $(call meta-vc10sln,$(name)-vc10.sln)
+ $(call meta-vctest,$(name)-vc10.sln,test.bat)
+
+$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests)))
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests)))
+
+$(call include,$(bld_root)/meta/vc9sln.make)
+$(call include,$(bld_root)/meta/vc10sln.make)
+$(call include,$(bld_root)/meta/vctest.make)
+$(call include,$(bld_root)/meta/automake.make)
+
+$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile))
diff --git a/oracle/native/driver.cxx b/oracle/native/driver.cxx
new file mode 100644
index 0000000..ab1138a
--- /dev/null
+++ b/oracle/native/driver.cxx
@@ -0,0 +1,78 @@
+// file : oracle/native/driver.cxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+// Test native SQL execution.
+//
+
+#include <memory> // std::auto_ptr
+#include <cassert>
+#include <iostream>
+
+#include <odb/oracle/database.hxx>
+#include <odb/oracle/transaction.hxx>
+
+#include <common/common.hxx>
+
+using namespace std;
+using namespace odb::core;
+
+int
+main (int argc, char* argv[])
+{
+ try
+ {
+ auto_ptr<database> db (create_database (argc, argv, false));
+
+ // Create the database schema.
+ //
+ {
+ transaction t (db->begin ());
+
+ db->execute ("BEGIN "
+ " EXECUTE IMMEDIATE 'DROP TABLE oracle_native_test'; "
+ " EXCEPTION "
+ " WHEN OTHERS THEN "
+ " IF SQLCODE != -942 THEN RAISE; END IF; "
+ "END;");
+
+ db->execute ("CREATE TABLE oracle_native_test (n NUMERIC(10,0))");
+
+ t.commit ();
+ }
+
+ // Insert a few rows.
+ //
+ {
+ transaction t (db->begin ());
+
+ assert (
+ db->execute ("INSERT INTO oracle_native_test (n) VALUES (1)") == 1);
+
+ assert (
+ db->execute ("INSERT INTO oracle_native_test (n) VALUES (2)") == 1);
+
+ t.commit ();
+ }
+
+ // Select a few rows.
+ //
+ {
+ transaction t (db->begin ());
+
+ assert (
+ db->execute ("SELECT n FROM oracle_native_test WHERE n < 3") == 2);
+
+ assert (
+ db->execute ("SELECT n FROM oracle_native_test WHERE n > 3") == 0);
+
+ t.commit ();
+ }
+ }
+ catch (const odb::exception& e)
+ {
+ cerr << e.what () << endl;
+ return 1;
+ }
+}
diff --git a/oracle/native/makefile b/oracle/native/makefile
new file mode 100644
index 0000000..cea60ae
--- /dev/null
+++ b/oracle/native/makefile
@@ -0,0 +1,85 @@
+# file : oracle/native/makefile
+# author : Constantin Michael <constantin@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
+
+cxx_tun := driver.cxx
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o))
+cxx_od := $(cxx_obj:.o=.o.d)
+
+common.l := $(out_root)/libcommon/common/common.l
+common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+# Build.
+#
+$(driver): $(cxx_obj) $(common.l)
+$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
+$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
+
+$(call include-dep,$(cxx_od))
+
+# Alias for default target.
+#
+$(out_base)/: $(driver)
+
+# Dist
+#
+$(dist): sources := $(cxx_tun)
+$(dist): data_dist := test.std
+$(dist): export name := $(subst /,-,$(subst $(src_root)/oracle/,,$(src_base)))
+$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \
+$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters
+$(dist):
+ $(call dist-data,$(sources) $(data_dist))
+ $(call meta-automake,../template/Makefile.am)
+ $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj)
+ $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj)
+
+# Test.
+#
+$(test): $(driver) $(src_base)/test.std
+ $(call message,test $<,$< --options-file $(dcf_root)/db.options \
+>$(out_base)/test.out)
+ $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out)
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Clean.
+#
+$(clean): \
+ $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(cxx_obj)) \
+ $(addsuffix .cxx.clean,$(cxx_od))
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+# How to.
+#
+$(call include,$(bld_root)/dist.make)
+$(call include,$(bld_root)/meta/vc9proj.make)
+$(call include,$(bld_root)/meta/vc10proj.make)
+$(call include,$(bld_root)/meta/automake.make)
+
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/o-e.make)
+
+# Dependencies.
+#
+$(call import,$(src_root)/libcommon/makefile)
diff --git a/oracle/native/test.std b/oracle/native/test.std
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/oracle/native/test.std
diff --git a/oracle/template/driver.cxx b/oracle/template/driver.cxx
new file mode 100644
index 0000000..b5c9f71
--- /dev/null
+++ b/oracle/template/driver.cxx
@@ -0,0 +1,44 @@
+// file : oracle/template/driver.cxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+// PLACE TEST DESCRIPTION HERE
+//
+
+#include <memory> // std::auto_ptr
+#include <cassert>
+#include <iostream>
+
+#include <odb/oracle/database.hxx>
+#include <odb/oracle/transaction.hxx>
+
+#include <common/common.hxx>
+
+#include "test.hxx"
+#include "test-odb.hxx"
+
+using namespace std;
+using namespace odb::core;
+
+int
+main (int argc, char* argv[])
+{
+ try
+ {
+ auto_ptr<database> db (create_database (argc, argv));
+
+ //
+ //
+ cout << "test 001" << endl;
+ {
+ transaction t (db->begin ());
+ t.commit ();
+ }
+ }
+ catch (const odb::exception& e)
+ {
+ cerr << e.what () << endl;
+ return 1;
+ }
+}
diff --git a/oracle/template/makefile b/oracle/template/makefile
new file mode 100644
index 0000000..47315d9
--- /dev/null
+++ b/oracle/template/makefile
@@ -0,0 +1,106 @@
+# file : oracle/template/makefile
+# author : Constantin Michael <constantin@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
+
+cxx_tun := driver.cxx
+odb_hdr := test.hxx
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o))
+cxx_od := $(cxx_obj:.o=.o.d)
+
+common.l := $(out_root)/libcommon/common/common.l
+common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+# Import.
+#
+$(call import,\
+ $(scf_root)/import/odb/stub.make,\
+ odb: odb,odb-rules: odb_rules)
+
+# Build.
+#
+$(driver): $(cxx_obj) $(common.l)
+$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
+$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
+
+genf := $(addprefix $(odb_hdr:.hxx=-odb),.hxx .ixx .cxx) $(odb_hdr:.hxx=.sql)
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(odb)
+$(gen): odb := $(odb)
+$(gen) $(dist): export odb_options += --database oracle --generate-schema \
+--table-prefix oracle_template_ #@@ CHANGE THIS
+$(gen): cpp_options := -I$(src_base)
+$(gen): $(common.l.cpp-options)
+
+$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
+
+# Alias for default target.
+#
+$(out_base)/: $(driver)
+
+# Dist
+#
+$(dist): sources := $(cxx_tun)
+$(dist): headers := $(odb_hdr)
+$(dist): data_dist := test.std
+$(dist): export name := $(subst /,-,$(subst $(src_root)/oracle/,,$(src_base)))
+$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \
+$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters
+$(dist):
+ $(call dist-data,$(sources) $(headers) $(data_dist))
+ $(call meta-automake,../template/Makefile.am)
+ $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj)
+ $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj)
+
+# Test.
+#
+$(test): $(driver) $(src_base)/test.std
+ $(call schema)
+ $(call message,test $<,$< --options-file $(dcf_root)/db.options \
+>$(out_base)/test.out)
+ $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out)
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Clean.
+#
+$(clean): \
+ $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(cxx_obj)) \
+ $(addsuffix .cxx.clean,$(cxx_od)) \
+ $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean))
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+# How to.
+#
+$(call include,$(bld_root)/dist.make)
+$(call include,$(bld_root)/meta/vc9proj.make)
+$(call include,$(bld_root)/meta/vc10proj.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)
+$(call include,$(bld_root)/cxx/o-e.make)
+
+# Dependencies.
+#
+$(call import,$(src_root)/libcommon/makefile)
diff --git a/oracle/template/test.hxx b/oracle/template/test.hxx
new file mode 100644
index 0000000..7e8f699
--- /dev/null
+++ b/oracle/template/test.hxx
@@ -0,0 +1,27 @@
+// file : oracle/template/test.hxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+#ifndef TEST_HXX
+#define TEST_HXX
+
+#include <odb/core.hxx>
+
+#pragma db object
+struct object
+{
+ object (unsigned long id)
+ : id_ (id)
+ {
+ }
+
+ object ()
+ {
+ }
+
+ #pragma db id
+ unsigned long id_;
+};
+
+#endif // TEST_HXX
diff --git a/oracle/template/test.std b/oracle/template/test.std
new file mode 100644
index 0000000..af8d8e7
--- /dev/null
+++ b/oracle/template/test.std
@@ -0,0 +1 @@
+test 001