aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-03-30 13:10:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-03-30 13:10:42 +0200
commit18e0b8065af3b660a73af93dabb4767cbc64ec35 (patch)
tree54bb7540f6fb1db7b2ca9afe83f0690f8daffaca
parent27a6fdf4b5295281853254cfdde8730128038dd2 (diff)
Autotools support for SQLite
-rw-r--r--Makefile.am4
-rw-r--r--boost/Makefile.am5
-rw-r--r--boost/common/template/Makefile.am1
-rw-r--r--boost/mysql/template/Makefile.am1
-rw-r--r--common/query/makefile2
-rw-r--r--common/template/Makefile.am1
-rw-r--r--configure.ac4
-rw-r--r--libcommon/common/Makefile.am3
-rw-r--r--libcommon/common/config.h.in1
-rw-r--r--m4/database.m47
-rw-r--r--m4/libodb-sqlite.m484
-rw-r--r--m4/mysql.m42
-rw-r--r--m4/sqlite.m461
-rw-r--r--makefile2
-rw-r--r--mysql/template/Makefile.am1
-rw-r--r--sqlite/sqlite-vc10.sln (renamed from sqlite/mysql-vc10.sln)0
-rw-r--r--sqlite/sqlite-vc9.sln (renamed from sqlite/mysql-vc9.sln)0
-rw-r--r--sqlite/template/Makefile.am1
-rw-r--r--tracer/template/Makefile.am1
19 files changed, 176 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am
index b0070f3..0a15f76 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,5 +13,9 @@ if DATABASE_MYSQL
SUBDIRS += mysql
endif
+if DATABASE_SQLITE
+SUBDIRS += sqlite
+endif
+
EXTRA_DIST = __file__(extra_dist)
ACLOCAL_AMFLAGS = -I m4
diff --git a/boost/Makefile.am b/boost/Makefile.am
index 85915d2..9b08372 100644
--- a/boost/Makefile.am
+++ b/boost/Makefile.am
@@ -9,4 +9,9 @@ if DATABASE_MYSQL
SUBDIRS += mysql
endif
+if DATABASE_SQLITE
+# @@ enable
+#SUBDIRS += sqlite
+endif
+
EXTRA_DIST = __file__(extra_dist)
diff --git a/boost/common/template/Makefile.am b/boost/common/template/Makefile.am
index 4ab6efe..6cd68eb 100644
--- a/boost/common/template/Makefile.am
+++ b/boost/common/template/Makefile.am
@@ -9,6 +9,7 @@ noinst_PROGRAMS = driver
driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers)
LDADD = $(top_builddir)/libcommon/common/libcommon.la
AM_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon'
+AM_CPPFLAGS += -I'$(builddir)' -I'$(srcdir)'
TESTS=$(top_builddir)/tester
TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir;
diff --git a/boost/mysql/template/Makefile.am b/boost/mysql/template/Makefile.am
index 29017fa..6bab1d5 100644
--- a/boost/mysql/template/Makefile.am
+++ b/boost/mysql/template/Makefile.am
@@ -9,6 +9,7 @@ noinst_PROGRAMS = driver
driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers)
LDADD = $(top_builddir)/libcommon/common/libcommon.la
AM_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon'
+AM_CPPFLAGS += -I'$(builddir)' -I'$(srcdir)'
TESTS=$(top_builddir)/tester
TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir;
diff --git a/common/query/makefile b/common/query/makefile
index 5e98970..c41b1d5 100644
--- a/common/query/makefile
+++ b/common/query/makefile
@@ -53,7 +53,7 @@ name := $(subst /,-,$(subst $(src_root)/common/,,$(src_base)))
$(dist): db_id := @database@
$(dist): sources := $(cxx_tun)
$(dist): headers := $(odb_hdr)
-$(dist): export extra_headers := traits.hxx
+$(dist): export extra_headers := traits.hxx $(databases:%=traits-%.hxx)
$(dist): data_dist := test.std
$(dist): export name := $(name)
$(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \
diff --git a/common/template/Makefile.am b/common/template/Makefile.am
index 758d015..eb1ae97 100644
--- a/common/template/Makefile.am
+++ b/common/template/Makefile.am
@@ -9,6 +9,7 @@ noinst_PROGRAMS = driver
driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers)
LDADD = $(top_builddir)/libcommon/common/libcommon.la
AM_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon'
+AM_CPPFLAGS += -I'$(builddir)' -I'$(srcdir)'
TESTS=$(top_builddir)/tester
TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir;
diff --git a/configure.ac b/configure.ac
index 81d4a1a..cea2bd2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,6 +63,10 @@ case $database in
LIBODB_MYSQL([], [AC_MSG_ERROR([libodb-mysql is not found; consider using --with-libodb-mysql=DIR])])
MYSQL
;;
+ sqlite)
+ LIBODB_SQLITE([], [AC_MSG_ERROR([libodb-sqlite is not found; consider using --with-libodb-sqlite=DIR])])
+ SQLITE
+ ;;
esac
# Check for the ODB compiler.
diff --git a/libcommon/common/Makefile.am b/libcommon/common/Makefile.am
index f4886fe..405a2ed 100644
--- a/libcommon/common/Makefile.am
+++ b/libcommon/common/Makefile.am
@@ -8,5 +8,6 @@ libcommon_la_SOURCES = __path__(sources) __path__(headers)
EXTRA_DIST = __file__(extra_dist)
-AM_CPPFLAGS= -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon' -DLIBCOMMON_DYNAMIC_LIB
+AM_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon'
+AM_CPPFLAGS += -DLIBCOMMON_DYNAMIC_LIB
AM_LDFLAGS = -no-undefined -rpath '$(libdir)'
diff --git a/libcommon/common/config.h.in b/libcommon/common/config.h.in
index ad30893..8a504a0 100644
--- a/libcommon/common/config.h.in
+++ b/libcommon/common/config.h.in
@@ -10,6 +10,7 @@
#define LIBCOMMON_COMMON_CONFIG_H
#undef DATABASE_MYSQL
+#undef DATABASE_SQLITE
#undef HAVE_TR1_MEMORY
#undef LIBCOMMON_STATIC_LIB
diff --git a/m4/database.m4 b/m4/database.m4
index 6f75e27..9478016 100644
--- a/m4/database.m4
+++ b/m4/database.m4
@@ -13,7 +13,7 @@ AC_MSG_CHECKING([for database to use])
AC_ARG_WITH(
[database],
[AC_HELP_STRING([--with-database=db],
- [database to use for tests; valid values are: 'mysql'])],
+ [database to use for tests; valid values are: 'mysql', 'sqlite'])],
[case $withval in
no | yes)
AC_MSG_RESULT([])
@@ -23,6 +23,10 @@ AC_ARG_WITH(
database=mysql
AC_DEFINE([DATABASE_MYSQL], [1], [Using MySQL.])
;;
+ sqlite)
+ database=sqlite
+ AC_DEFINE([DATABASE_SQLITE], [1], [Using SQLite.])
+ ;;
*)
AC_MSG_RESULT([])
AC_MSG_ERROR([unknown database $withval])
@@ -37,5 +41,6 @@ AC_MSG_RESULT([$database])
AC_SUBST([database])
AM_CONDITIONAL([DATABASE_MYSQL], [test x$database = xmysql])
+AM_CONDITIONAL([DATABASE_SQLITE], [test x$database = xsqlite])
])dnl
diff --git a/m4/libodb-sqlite.m4 b/m4/libodb-sqlite.m4
new file mode 100644
index 0000000..b85614f
--- /dev/null
+++ b/m4/libodb-sqlite.m4
@@ -0,0 +1,84 @@
+dnl file : m4/libodb-sqlite.m4
+dnl author : Boris Kolpackov <boris@codesynthesis.com>
+dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+dnl license : GNU GPL v2; see accompanying LICENSE file
+dnl
+dnl LIBODB_SQLITE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl
+dnl
+AC_DEFUN([LIBODB_SQLITE], [
+libodb_sqlite_found=no
+
+AC_ARG_WITH(
+ [libodb-sqlite],
+ [AC_HELP_STRING([--with-libodb-sqlite=DIR],[location of libodb-sqlite build directory])],
+ [libodb_sqlite_dir=${withval}],
+ [libodb_sqlite_dir=])
+
+AC_MSG_CHECKING([for libodb-sqlite])
+
+# If libodb_sqlite_dir was given, add the necessary preprocessor and
+# linker flags.
+#
+if test x"$libodb_sqlite_dir" != x; then
+ save_CPPFLAGS="$CPPFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+
+ AS_SET_CATFILE([abs_libodb_sqlite_dir], [$ac_pwd], [$libodb_sqlite_dir])
+
+ CPPFLAGS="$CPPFLAGS -I$abs_libodb_sqlite_dir"
+ LDFLAGS="$LDFLAGS -L$abs_libodb_sqlite_dir/odb/sqlite"
+fi
+
+save_LIBS="$LIBS"
+LIBS="-lodb-sqlite $LIBS"
+
+CXX_LIBTOOL_LINK_IFELSE(
+AC_LANG_SOURCE([[
+#include <odb/sqlite/exceptions.hxx>
+
+void
+f ()
+{
+}
+
+const char*
+g ()
+{
+ try
+ {
+ f ();
+ }
+ catch (const odb::sqlite::database_exception& e)
+ {
+ return e.what ();
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ const char* m (g ());
+ return m != 0;
+}
+]]),
+[libodb_sqlite_found=yes])
+
+if test x"$libodb_sqlite_found" = xno; then
+ LIBS="$save_LIBS"
+
+ if test x"$libodb_sqlite_dir" != x; then
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ fi
+fi
+
+if test x"$libodb_sqlite_found" = xyes; then
+ AC_MSG_RESULT([yes])
+ $1
+else
+ AC_MSG_RESULT([no])
+ $2
+fi
+])dnl
diff --git a/m4/mysql.m4 b/m4/mysql.m4
index 5f35c91..102f150 100644
--- a/m4/mysql.m4
+++ b/m4/mysql.m4
@@ -202,7 +202,7 @@ fi
# Create options file.
#
-AC_CONFIG_COMMANDS([db.options],
+AC_CONFIG_COMMANDS([mysql.options],
[
rm -f db.options
echo '#! /bin/sh' >db-driver
diff --git a/m4/sqlite.m4 b/m4/sqlite.m4
new file mode 100644
index 0000000..de5503e
--- /dev/null
+++ b/m4/sqlite.m4
@@ -0,0 +1,61 @@
+dnl file : m4/sqlite.m4
+dnl author : Boris Kolpackov <boris@codesynthesis.com>
+dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+dnl license : GNU GPL v2; see accompanying LICENSE file
+dnl
+dnl SQLITE
+dnl
+AC_DEFUN([SQLITE], [
+
+# Database file.
+#
+AC_MSG_CHECKING([for sqlite database file])
+AC_ARG_WITH(
+ [sqlite-db],
+ [AC_HELP_STRING([--with-sqlite-db=file], [SQLite database file (odb_test.db by default). Note that all data in this database WILL BE LOST!])],
+ [case $withval in
+ yes)
+ sqlite_db=odb_test.db
+ sqlite_db_set=yes
+ ;;
+ no)
+ sqlite_db_set=no
+ ;;
+ *)
+ sqlite_db=$withval
+ sqlite_db_set=yes
+ ;;
+ esac],
+ [sqlite_db=odb_test.db
+ sqlite_db_set=yes])
+
+if test x$sqlite_db_set = xyes; then
+
+ # Make it an absolute path unless it is one of the special values.
+ #
+ if test x$sqlite_db != x -a x$sqlite_db != x:memory:; then
+ AS_SET_CATFILE([abs_sqlite_db], [$ac_pwd], [$sqlite_db])
+ sqlite_db=$abs_sqlite_db
+ fi
+
+ AC_MSG_RESULT(['$sqlite_db'])
+else
+ AC_MSG_RESULT([none])
+fi
+
+# Create options file.
+#
+AC_CONFIG_COMMANDS([sqlite.options],
+ [
+ rm -f db.options
+
+ if test x$sqlite_db_set = xyes; then
+ echo "--database '$sqlite_db'" >>db.options
+ fi
+ ],
+ [
+ sqlite_db="$sqlite_db"
+ sqlite_db_set="$sqlite_db_set"
+ ])
+
+])dnl
diff --git a/makefile b/makefile
index 0eaf04d..ad2f5b9 100644
--- a/makefile
+++ b/makefile
@@ -5,7 +5,7 @@
include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make
-all_dirs := libcommon common tracer mysql boost
+all_dirs := libcommon common tracer mysql sqlite boost
dirs := common tracer boost
ifeq ($(db_id),mysql)
diff --git a/mysql/template/Makefile.am b/mysql/template/Makefile.am
index 7571e28..af5895f 100644
--- a/mysql/template/Makefile.am
+++ b/mysql/template/Makefile.am
@@ -9,6 +9,7 @@ noinst_PROGRAMS = driver
driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers)
LDADD = $(top_builddir)/libcommon/common/libcommon.la
AM_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon'
+AM_CPPFLAGS += -I'$(builddir)' -I'$(srcdir)'
TESTS=$(top_builddir)/tester
TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir;
diff --git a/sqlite/mysql-vc10.sln b/sqlite/sqlite-vc10.sln
index 9a5dc32..9a5dc32 100644
--- a/sqlite/mysql-vc10.sln
+++ b/sqlite/sqlite-vc10.sln
diff --git a/sqlite/mysql-vc9.sln b/sqlite/sqlite-vc9.sln
index 2ec9432..2ec9432 100644
--- a/sqlite/mysql-vc9.sln
+++ b/sqlite/sqlite-vc9.sln
diff --git a/sqlite/template/Makefile.am b/sqlite/template/Makefile.am
index 5591b10..ba169b3 100644
--- a/sqlite/template/Makefile.am
+++ b/sqlite/template/Makefile.am
@@ -9,6 +9,7 @@ noinst_PROGRAMS = driver
driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers)
LDADD = $(top_builddir)/libcommon/common/libcommon.la
AM_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon'
+AM_CPPFLAGS += -I'$(builddir)' -I'$(srcdir)'
TESTS=$(top_builddir)/tester
TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir;
diff --git a/tracer/template/Makefile.am b/tracer/template/Makefile.am
index c6cbb16..4305788 100644
--- a/tracer/template/Makefile.am
+++ b/tracer/template/Makefile.am
@@ -8,6 +8,7 @@ EXTRA_DIST = __file__(extra_dist)
noinst_PROGRAMS = driver
driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers)
AM_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon'
+AM_CPPFLAGS += -I'$(builddir)' -I'$(srcdir)'
TESTS=$(top_builddir)/tester
TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir;