aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4')
-rw-r--r--m4/database.m45
-rw-r--r--m4/libodb-mssql.m484
-rw-r--r--m4/mssql.m4226
3 files changed, 315 insertions, 0 deletions
diff --git a/m4/database.m4 b/m4/database.m4
index a2d72eb..e334e91 100644
--- a/m4/database.m4
+++ b/m4/database.m4
@@ -35,6 +35,10 @@ AC_ARG_WITH(
database=oracle
AC_DEFINE([DATABASE_ORACLE], [1], [Using Oracle.])
;;
+ mssql)
+ database=mssql
+ AC_DEFINE([DATABASE_MSSQL], [1], [Using SQL Server.])
+ ;;
*)
AC_MSG_RESULT([])
AC_MSG_ERROR([unknown database $withval])
@@ -52,5 +56,6 @@ 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])
+AM_CONDITIONAL([DATABASE_MSSQL], [test x$database = xmssql])
])dnl
diff --git a/m4/libodb-mssql.m4 b/m4/libodb-mssql.m4
new file mode 100644
index 0000000..acddfd4
--- /dev/null
+++ b/m4/libodb-mssql.m4
@@ -0,0 +1,84 @@
+dnl file : m4/libodb-mssql.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_MSSQL([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl
+dnl
+AC_DEFUN([LIBODB_MSSQL], [
+libodb_mssql_found=no
+
+AC_ARG_WITH(
+ [libodb-mssql],
+ [AC_HELP_STRING([--with-libodb-mssql=DIR],[location of libodb-mssql build directory])],
+ [libodb_mssql_dir=${withval}],
+ [libodb_mssql_dir=])
+
+AC_MSG_CHECKING([for libodb-mssql])
+
+# If libodb_mssql_dir was given, add the necessary preprocessor and
+# linker flags.
+#
+if test x"$libodb_mssql_dir" != x; then
+ save_CPPFLAGS="$CPPFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+
+ AS_SET_CATFILE([abs_libodb_mssql_dir], [$ac_pwd], [$libodb_mssql_dir])
+
+ CPPFLAGS="$CPPFLAGS -I$abs_libodb_mssql_dir"
+ LDFLAGS="$LDFLAGS -L$abs_libodb_mssql_dir/odb/mssql"
+fi
+
+save_LIBS="$LIBS"
+LIBS="-lodb-mssql $LIBS"
+
+CXX_LIBTOOL_LINK_IFELSE(
+AC_LANG_SOURCE([[
+#include <odb/mssql/exceptions.hxx>
+
+void
+f ()
+{
+}
+
+const char*
+g ()
+{
+ try
+ {
+ f ();
+ }
+ catch (const odb::mssql::database_exception& e)
+ {
+ return e.what ();
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ const char* m (g ());
+ return m != 0;
+}
+]]),
+[libodb_mssql_found=yes])
+
+if test x"$libodb_mssql_found" = xno; then
+ LIBS="$save_LIBS"
+
+ if test x"$libodb_mssql_dir" != x; then
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ fi
+fi
+
+if test x"$libodb_mssql_found" = xyes; then
+ AC_MSG_RESULT([yes])
+ $1
+else
+ AC_MSG_RESULT([no])
+ $2
+fi
+])dnl
diff --git a/m4/mssql.m4 b/m4/mssql.m4
new file mode 100644
index 0000000..c446f31
--- /dev/null
+++ b/m4/mssql.m4
@@ -0,0 +1,226 @@
+dnl file : m4/mssql.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 MSSQL
+dnl
+AC_DEFUN([MSSQL], [
+
+# Client.
+#
+AC_MSG_CHECKING([for mssql client program])
+AC_ARG_WITH(
+ [mssql-client],
+ [AC_HELP_STRING([--with-mssql-client=PATH], [SQL Server client program path (sqlcmd by default)])],
+ [case $withval in
+ yes)
+ mssql_client=sqlcmd
+ ;;
+ no)
+ AC_MSG_RESULT([])
+ AC_MSG_ERROR([need mssql client to run the tests])
+ ;;
+ *)
+ mssql_client=$withval
+ ;;
+ esac],
+ [mssql_client=sqlcmd])
+
+$mssql_client -? 2>/dev/null 1>&2
+
+if test x"$?" = x0; then
+ AC_MSG_RESULT([$mssql_client])
+else
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([mssql client is not found; consider using --with-mssql-client=PATH])
+fi
+
+# User. If 'no' is specified, then use Windows authentication.
+#
+AC_MSG_CHECKING([for mssql database user])
+AC_ARG_WITH(
+ [mssql-user],
+ [AC_HELP_STRING([--with-mssql-user=NAME], [SQL Server database user (odb_test by default)])],
+ [case $withval in
+ yes)
+ mssql_user=odb_test
+ mssql_user_set=yes
+ ;;
+ no)
+ mssql_user_set=no
+ ;;
+ *)
+ mssql_user=$withval
+ mssql_user_set=yes
+ ;;
+ esac],
+ [mssql_user=odb_test
+ mssql_user_set=yes])
+
+if test x$mssql_user_set = xyes; then
+ AC_MSG_RESULT(['$mssql_user'])
+else
+ AC_MSG_RESULT([none])
+fi
+
+# Password. Can be left unspecified if using Windows authentication.
+#
+AC_MSG_CHECKING([for mssql database password])
+AC_ARG_WITH(
+ [mssql-password],
+ [AC_HELP_STRING([--with-mssql-password=PASS], [SQL Server database password (odb_test by default)])],
+ [case $withval in
+ yes)
+ mssql_password=odb_test
+ mssql_password_set=yes
+ ;;
+ no)
+ mssql_password_set=no
+ ;;
+ *)
+ mssql_password=$withval
+ mssql_password_set=yes
+ ;;
+ esac],
+ [mssql_password_set=no])
+
+if test x$mssql_password_set = xyes; then
+ AC_MSG_RESULT(['$mssql_password'])
+elif test x$mssql_user = xodb_test; then
+ mssql_password=odb_test
+ mssql_password_set=yes
+ AC_MSG_RESULT(['$mssql_password'])
+else
+ AC_MSG_RESULT([none])
+ if test x$mssql_user_set = xyes; then
+ AC_MSG_ERROR([password not specified; SQL Server requires a password (--with-mssql-password=PASS)])
+ fi
+fi
+
+# Database. If not specified, use the user's default.
+#
+AC_MSG_CHECKING([for mssql database name])
+AC_ARG_WITH(
+ [mssql-db],
+ [AC_HELP_STRING([--with-mssql-db=NAME], [SQL Server database name (odb_test by default). Note that all data in this database WILL BE LOST!])],
+ [case $withval in
+ yes)
+ mssql_db=odb_test
+ mssql_db_set=yes
+ ;;
+ no)
+ mssql_db_set=no
+ ;;
+ *)
+ mssql_db=$withval
+ mssql_db_set=yes
+ ;;
+ esac],
+ [mssql_db=odb_test
+ mssql_db_set=yes])
+
+if test x$mssql_db_set = xyes; then
+ AC_MSG_RESULT(['$mssql_db'])
+else
+ AC_MSG_RESULT([default])
+fi
+
+# Server.
+#
+AC_MSG_CHECKING([for mssql instance address])
+AC_ARG_WITH(
+ [mssql-server],
+ [AC_HELP_STRING([--with-mssql-server=ADDR], [SQL Server instance address])],
+ [case $withval in
+ yes | no)
+ mssql_server_set=no
+ ;;
+ *)
+ mssql_server=$withval
+ mssql_server_set=yes
+ ;;
+ esac],
+ [mssql_server_set=no])
+
+if test x$mssql_server_set = xyes; then
+ AC_MSG_RESULT(['$mssql_server'])
+else
+ AC_MSG_RESULT([none])
+ AC_MSG_ERROR([instance address not specified; SQL Server instance address is required (--with-mssql-server=ADDR)])
+fi
+
+# Driver.
+#
+AC_MSG_CHECKING([for mssql native client odbc driver])
+AC_ARG_WITH(
+ [mssql-driver],
+ [AC_HELP_STRING([--with-mssql-driver=NAME], [SQL Server Native Client ODBC driver (latest available by default)])],
+ [case $withval in
+ yes | no)
+ mssql_driver_set=no
+ ;;
+ *)
+ mssql_driver=$withval
+ mssql_driver_set=yes
+ ;;
+ esac],
+ [mssql_driver_set=no])
+
+if test x$mssql_driver_set = xyes; then
+ AC_MSG_RESULT(['$mssql_driver'])
+else
+ AC_MSG_RESULT([latest])
+fi
+
+# Create options file.
+#
+AC_CONFIG_COMMANDS([mssql.options],
+ [
+ rm -f db.options
+ echo '#! /bin/sh' >db-driver
+
+ echo 'opt=' >>db-driver
+
+ if test x$mssql_user_set = xyes; then
+ echo "--user '$mssql_user'" >>db.options
+ echo 'opt="$opt -U '"$mssql_user"'"' >>db-driver
+
+ echo "--password '$mssql_password'" >>db.options
+ echo 'opt="$opt -P '"$mssql_password"'"' >>db-driver
+ fi
+
+ if test x$mssql_db_set = xyes; then
+ echo "--database '$mssql_db'" >>db.options
+ echo 'opt="$opt -d '"$mssql_db"'"' >>db-driver
+ fi
+
+ echo "--server '$mssql_server'" >>db.options
+ echo 'opt="$opt -S '"$mssql_server"'"' >>db-driver
+
+ if test x$mssql_driver_set = xyes; then
+ echo "--driver '$mssql_driver'" >>db.options
+ fi
+
+ echo 'opt="$opt -x -r -b"' >>db-driver
+ echo 'if test x$[]1 != x; then' >>db-driver
+ echo " exec $mssql_client "'$opt -i $[]1' >>db-driver
+ echo "else" >>db-driver
+ echo " exec $mssql_client "'$opt' >>db-driver
+ echo "fi" >>db-driver
+
+ chmod +x db-driver
+ ],
+ [
+ mssql_client="$mssql_client"
+ mssql_user="$mssql_user"
+ mssql_user_set="$mssql_user_set"
+ mssql_password="$mssql_password"
+ mssql_db="$mssql_db"
+ mssql_db_set="$mssql_db_set"
+ mssql_server="$mssql_server"
+ mssql_driver="$mssql_driver"
+ mssql_driver_set="$mssql_driver_set"
+ ])
+
+])dnl