aboutsummaryrefslogtreecommitdiff
path: root/m4
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 /m4
parent27a6fdf4b5295281853254cfdde8730128038dd2 (diff)
Autotools support for SQLite
Diffstat (limited to 'm4')
-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
4 files changed, 152 insertions, 2 deletions
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