]> granicus.if.org Git - php/commitdiff
Add configure support for ODBCRouter and generic ODBC libs.
authorWez Furlong <wez@php.net>
Wed, 12 Jan 2005 02:19:30 +0000 (02:19 +0000)
committerWez Furlong <wez@php.net>
Wed, 12 Jan 2005 02:19:30 +0000 (02:19 +0000)
Note that ODBCRouter doesn't directly implement ODBC 3.0, so
using it here won't really work.

Expand the ODBC 3 check to better explain what happened and
how to make progress (e.g.: use an ODBC manager library like
unixODBC).

ext/pdo_odbc/config.m4
ext/pdo_odbc/php_pdo_odbc_int.h

index e69a8a6bc73c4970ae81c97b2abfa60ea72e3bd9..afa47f866fc35a1b7d5ab59938547484401380b8 100755 (executable)
@@ -1,18 +1,23 @@
 dnl $Id$
 dnl config.m4 for extension pdo_odbc
+dnl vim:et:sw=2:ts=2:
 
 AC_DEFUN(PDO_ODBC_HELP_TEXT, [[
  --with-pdo-odbc=flavour,dir  Add support for "flavour" ODBC drivers,
                               looking for include and lib dirs under "dir"
          
         flavour can be one of:
-           ibm-db2, unixODBC
+           ibm-db2, unixODBC, ODBCRouter, generic
 
         You may omit the ,dir part to use a reasonable default for
         the flavour you have selected. e.g.:
             --with-pdo-odbc=unixODBC
         will check for unixODBC under /usr/local
 
+        You may attempt to use an otherwise unsupported driver using
+        the generic flavour.  The syntax for generic ODBC support is:
+            --with-pdo-odbc=generic,dir,ldflags,cflags
+
         This extension will always be created as a shared extension
         named pdo_odbc.so
 ]])
@@ -47,6 +52,18 @@ if test "$PHP_PDO_ODBC" != "no" && test "$PHP_PDO_ODBC" != "yes" ; then
         pdo_odbc_def_lib=-lodbc
         ;;
 
+    ODBCRouter)
+        pdo_odbc_def_libdir=/usr/lib
+        pdo_odbc_def_incdir=/usr/include
+        pdo_odbc_def_lib=-lodbcsdk
+        ;;
+
+    generic)
+        pdo_odbc_def_lib="`echo $withval | cut -d, -f3`"
+        pdo_odbc_def_cflags="`echo $withval | cut -d, -f4`"
+        pdo_odbc_flavour="$pdo_odbc_flavour ($pdo_odbc_def_lib)"
+        ;;
+
       *)
         AC_MSG_ERROR(Unknown ODBC flavour $pdo_odbc_flavour
 PDO_ODBC_HELP_TEXT      
@@ -72,6 +89,7 @@ PDO_ODBC_HELP_TEXT
 
   dnl yick time
   PDO_ODBC_CHECK_HEADER(odbc.h)
+  PDO_ODBC_CHECK_HEADER(odbcsdk.h)
   PDO_ODBC_CHECK_HEADER(iodbc.h)
   PDO_ODBC_CHECK_HEADER(sqlunix.h)
   PDO_ODBC_CHECK_HEADER(sqltypes.h)
@@ -89,13 +107,24 @@ PDO_ODBC_HELP_TEXT
   PDO_ODBC_CHECK_HEADER(cli0defs.h)
   PDO_ODBC_CHECK_HEADER(cli0env.h)
 
-  PDO_ODBC_INCLUDE="-I$PDO_ODBC_INCDIR -DPDO_ODBC_TYPE=\\\"$pdo_odbc_flavour\\\""
+  PDO_ODBC_INCLUDE="$pdo_odbc_def_cflags -I$PDO_ODBC_INCDIR -DPDO_ODBC_TYPE=\\\"$pdo_odbc_flavour\\\""
   PDO_ODBC_LFLAGS="-L$PDO_ODBC_LIBDIR"
   PDO_ODBC_LIBS="$pdo_odbc_def_lib"
 
   LDFLAGS="$PDO_ODBC_LFLAGS $PDO_ODBC_LIBS -lm -ldl"
+  dnl Check for an ODBC 1.0 function to assert that the libraries work
+  AC_TRY_LINK_FUNC([SQLBindCol],[],[
+    AC_MSG_ERROR([[Your ODBC library does not exist]])
+  ])
+  dnl And now check for an ODBC 3.0 function to assert that they're
+  dnl *good* libraries.
   AC_TRY_LINK_FUNC([SQLAllocHandle],[],[
-    AC_MSG_ERROR([[Your ODBC libraries either do not exist, or do not appear to be ODBC3 compatible]])
+    AC_MSG_ERROR([[
+Your ODBC library does not appear to be ODBC 3 compatible.
+You should consider using unixODBC instead, and loading your
+libraries as a driver in that environment; it will emulate the
+functions required for PDO support.
+]])
   ])
   LDFLAGS=$save_old_LDFLAGS
   PHP_EVAL_LIBLINE($PDO_ODBC_LIBS $PDO_ODBC_LFLAGS, [PDO_ODBC_SHARED_LIBADD])
index e249be56872f94f7a56565bb118b41394edd4851..a4d473e3b874749e0713f75affd7c8529b8b4a19 100755 (executable)
 # include <cli0env.h>
 #endif
 
+#if HAVE_ODBCSDK_H
+# include <odbcsdk.h>
+#endif
+
 /* }}} */
 
 /* {{{ Figure out the type for handles */