aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-11-24 09:47:29 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-11-24 09:48:38 +0200
commit0cbf7216a6455525e67d6cbca462d568471e5c26 (patch)
tree5cfa33fc7ffdc1183bc3ae7f77493f9191a368e7 /m4
parentb2778d6818ffa7fcbf68e3f7bbfd1a342dac98e4 (diff)
Add Oracle to automake and Visual Studio build
Diffstat (limited to 'm4')
-rw-r--r--m4/database.m47
-rw-r--r--m4/libodb-oracle.m484
-rw-r--r--m4/oracle.m4245
3 files changed, 335 insertions, 1 deletions
diff --git a/m4/database.m4 b/m4/database.m4
index 968f764..5f5a03e 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', 'sqlite', and 'pgsql'])],
+ [database to use for tests; valid values are: 'mysql', 'sqlite', 'pgsql', and 'oracle'])],
[case $withval in
no | yes)
AC_MSG_RESULT([])
@@ -31,6 +31,10 @@ AC_ARG_WITH(
database=pgsql
AC_DEFINE([DATABASE_PGSQL], [1], [Using PostgreSQL.])
;;
+ oracle)
+ database=oracle
+ AC_DEFINE([DATABASE_ORACLE], [1], [Using Oracle.])
+ ;;
*)
AC_MSG_RESULT([])
AC_MSG_ERROR([unknown database $withval])
@@ -47,5 +51,6 @@ AC_SUBST([database])
AM_CONDITIONAL([DATABASE_MYSQL], [test x$database = xmysql])
AM_CONDITIONAL([DATABASE_SQLITE], [test x$database = xsqlite])
AM_CONDITIONAL([DATABASE_PGSQL], [test x$database = xpgsql])
+AM_CONDITIONAL([DATABASE_ORACLE], [test x$database = xoracle])
])dnl
diff --git a/m4/libodb-oracle.m4 b/m4/libodb-oracle.m4
new file mode 100644
index 0000000..319377f
--- /dev/null
+++ b/m4/libodb-oracle.m4
@@ -0,0 +1,84 @@
+dnl file : m4/libodb-oracle.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_ORACLE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl
+dnl
+AC_DEFUN([LIBODB_ORACLE], [
+libodb_oracle_found=no
+
+AC_ARG_WITH(
+ [libodb-oracle],
+ [AC_HELP_STRING([--with-libodb-oracle=DIR],[location of libodb-oracle build directory])],
+ [libodb_oracle_dir=${withval}],
+ [libodb_oracle_dir=])
+
+AC_MSG_CHECKING([for libodb-oracle])
+
+# If libodb_oracle_dir was given, add the necessary preprocessor and
+# linker flags.
+#
+if test x"$libodb_oracle_dir" != x; then
+ save_CPPFLAGS="$CPPFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+
+ AS_SET_CATFILE([abs_libodb_oracle_dir], [$ac_pwd], [$libodb_oracle_dir])
+
+ CPPFLAGS="$CPPFLAGS -I$abs_libodb_oracle_dir"
+ LDFLAGS="$LDFLAGS -L$abs_libodb_oracle_dir/odb/oracle"
+fi
+
+save_LIBS="$LIBS"
+LIBS="-lodb-oracle $LIBS"
+
+CXX_LIBTOOL_LINK_IFELSE(
+AC_LANG_SOURCE([[
+#include <odb/oracle/exceptions.hxx>
+
+void
+f ()
+{
+}
+
+const char*
+g ()
+{
+ try
+ {
+ f ();
+ }
+ catch (const odb::oracle::database_exception& e)
+ {
+ return e.what ();
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ const char* m (g ());
+ return m != 0;
+}
+]]),
+[libodb_oracle_found=yes])
+libodb_oracle_found=yes
+if test x"$libodb_oracle_found" = xno; then
+ LIBS="$save_LIBS"
+
+ if test x"$libodb_oracle_dir" != x; then
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ fi
+fi
+
+if test x"$libodb_oracle_found" = xyes; then
+ AC_MSG_RESULT([yes])
+ $1
+else
+ AC_MSG_RESULT([no])
+ $2
+fi
+])dnl
diff --git a/m4/oracle.m4 b/m4/oracle.m4
new file mode 100644
index 0000000..321b50d
--- /dev/null
+++ b/m4/oracle.m4
@@ -0,0 +1,245 @@
+dnl file : m4/oracle.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 ORACLE
+dnl
+AC_DEFUN([ORACLE], [
+
+# Client.
+#
+AC_MSG_CHECKING([for oracle client program])
+AC_ARG_WITH(
+ [oracle-client],
+ [AC_HELP_STRING([--with-oracle-client=path], [Oracle client program path (sqlplus by default)])],
+ [case $withval in
+ yes)
+ oracle_client=sqlplus
+ ;;
+ no)
+ AC_MSG_RESULT([])
+ AC_MSG_ERROR([need oracle client to run the tests])
+ ;;
+ *)
+ oracle_client=$withval
+ ;;
+ esac],
+ [oracle_client=sqlplus])
+
+$oracle_client -V 2>/dev/null 1>&2
+
+if test x"$?" = x0; then
+ AC_MSG_RESULT([$oracle_client])
+else
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([oracle client is not found; consider using --with-oracle-client=PATH])
+fi
+
+# User.
+#
+AC_MSG_CHECKING([for oracle database user])
+AC_ARG_WITH(
+ [oracle-user],
+ [AC_HELP_STRING([--with-oracle-user=login], [Oracle database user (odb_test by default)])],
+ [case $withval in
+ yes)
+ oracle_user=odb_test
+ oracle_user_set=yes
+ ;;
+ no)
+ oracle_user_set=no
+ ;;
+ *)
+ oracle_user=$withval
+ oracle_user_set=yes
+ ;;
+ esac],
+ [oracle_user=odb_test
+ oracle_user_set=yes])
+
+if test x$oracle_user_set = xyes; then
+ AC_MSG_RESULT(['$oracle_user'])
+else
+ AC_MSG_RESULT([none])
+fi
+
+# Password.
+#
+AC_MSG_CHECKING([for oracle database password])
+AC_ARG_WITH(
+ [oracle-password],
+ [AC_HELP_STRING([--with-oracle-password=login], [Oracle database password])],
+ [case $withval in
+ yes)
+ oracle_password=
+ oracle_password_set=yes
+ ;;
+ no)
+ oracle_password_set=no
+ ;;
+ *)
+ oracle_password=$withval
+ oracle_password_set=yes
+ ;;
+ esac],
+ [oracle_password_set=no])
+
+if test x$oracle_password_set = xyes; then
+ AC_MSG_RESULT(['$oracle_password'])
+elif test x$oracle_user = xodb_test; then
+ oracle_password=odb_test
+ oracle_password_set=yes
+ AC_MSG_RESULT(['$oracle_password'])
+else
+ AC_MSG_RESULT([none])
+ AC_MSG_ERROR([password not specfied; Oracle requires a password])
+fi
+
+# Service name.
+#
+AC_MSG_CHECKING([for oracle service name])
+AC_ARG_WITH(
+ [oracle-service],
+ [AC_HELP_STRING([--with-oracle-service=name], [Oracle service name (default service if left empty). Note that all data in the database associated with the test user on this service WILL BE LOST!])],
+ [case $withval in
+ yes)
+ oracle_service=
+ oracle_service_set=yes
+ ;;
+ no)
+ oracle_service_set=no
+ ;;
+ *)
+ oracle_service=$withval
+ oracle_service_set=yes
+ ;;
+ esac],
+ [oracle_service=
+ oracle_service_set=yes])
+
+if test x$oracle_service_set = xyes; then
+ AC_MSG_RESULT(['$oracle_service'])
+else
+ AC_MSG_RESULT([none])
+fi
+
+# Host.
+#
+AC_MSG_CHECKING([for oracle database host])
+AC_ARG_WITH(
+ [oracle-host],
+ [AC_HELP_STRING([--with-oracle-host=host], [Oracle database host (localhost by default)])],
+ [case $withval in
+ yes)
+ oracle_host=
+ oracle_host_set=yes
+ ;;
+ no)
+ oracle_host_set=no
+ ;;
+ *)
+ oracle_host=$withval
+ oracle_host_set=yes
+ ;;
+ esac],
+ [oracle_host=localhost
+ oracle_host_set=yes])
+
+if test x$oracle_host_set = xyes; then
+ AC_MSG_RESULT(['$oracle_host'])
+else
+ AC_MSG_RESULT([localhost])
+fi
+
+# Port.
+#
+AC_MSG_CHECKING([for oracle database port])
+AC_ARG_WITH(
+ [oracle-port],
+ [AC_HELP_STRING([--with-oracle-port=port], [Oracle database port (standard Oracle port by default)])],
+ [case $withval in
+ yes)
+ oracle_port=0
+ oracle_port_set=yes
+ ;;
+ no)
+ oracle_port_set=no
+ ;;
+ *)
+ oracle_port=$withval
+ oracle_port_set=yes
+ ;;
+ esac],
+ [oracle_port_set=no])
+
+if test x$oracle_port_set = xyes; then
+ AC_MSG_RESULT(['$oracle_port'])
+else
+ AC_MSG_RESULT([default])
+fi
+
+# Create options file.
+#
+AC_CONFIG_COMMANDS([oracle.options],
+ [
+ rm -f db.options
+ echo '#! /bin/sh' >db-driver
+
+ if test x$oracle_user_set = xyes; then
+ echo "--user '$oracle_user'" >>db.options
+ echo 'conn_str="'"$oracle_user"'"' >>db-driver
+ fi
+
+ if test x$oracle_password_set = xyes; then
+ echo "--password '$oracle_password'" >>db.options
+ echo 'conn_str="$conn_str/'"$oracle_password"'"' >>db-driver
+ fi
+
+ if test x$oracle_host_set = xyes; then
+ echo "--host '$oracle_host'" >>db.options
+ echo 'conn_str="$conn_str@//'"$oracle_host"'"' >>db-driver
+
+ if test x$oracle_port_set = xyes; then
+ echo "--port '$oracle_port'" >>db.options
+ echo 'conn_str="$conn_str:'"$oracle_port"'"' >>db-driver
+ fi
+ fi
+
+ if test x$oracle_service != x; then
+ if test x$oracle_host_set = xno; then
+ echo 'conn_str="$conn_str@"' >>db-driver
+ fi
+
+ echo "--service '$oracle_service'" >>db.options
+ echo 'conn_str="$conn_str/'"$oracle_service"'"' >>db-driver
+ fi
+
+ echo 'if test x$[]1 != x; then' >>db-driver
+ echo " exec $oracle_client -L -S "'$conn_str <$[]1' >>db-driver
+ echo "else" >>db-driver
+ echo " exec $oracle_client -L -S "'$conn_str' >>db-driver
+ echo "fi" >>db-driver
+
+ chmod +x db-driver
+ ],
+ [
+ oracle_client="$oracle_client"
+
+ oracle_user="$oracle_user"
+ oracle_user_set="$oracle_user_set"
+
+ oracle_password="$oracle_password"
+ oracle_password_set="$oracle_password_set"
+
+ oracle_service="$oracle_service"
+ oracle_service_set="$oracle_service_set"
+
+ oracle_host="$oracle_host"
+ oracle_host_set="$oracle_host_set"
+
+ oracle_port="$oracle_port"
+ oracle_port_set="$oracle_port_set"
+ ])
+
+])dnl