php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31084 OCI8: Suggested config.m4 changes to compile with Oracle OCI8 Instant Client
Submitted: 2004-12-14 09:16 UTC Modified: 2004-12-27 09:59 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: cjbj at hotmail dot com Assigned: tony2001 (profile)
Status: Closed Package: Feature/Change Request
PHP Version: 4.3.9 OS: Linux
Private report: No CVE-ID: None
 [2004-12-14 09:16 UTC] cjbj at hotmail dot com
Description:
------------
This is a suggested enhancement for PHP's ext/oci8/config.m4 to enable
PHP to be built with the Oracle Instant Client 10.1 libraries and SDK.
This allows PHP to connect to an existing, remote Oracle DB without
needing a full install of Oracle.

The diff adds a new configuration parameter
   --with-oci8-instant-client[=DIR]
that takes the directory of the Oracle Instant Client libraries.  It
is the solution previously discussed with Antony.

The new "--with-oci8-instant-client" and existing "--with-oci8"
options are mutually exclusive.

Instructions:

  Install the Instant Client "basic" and "SDK" packages from Oracle:
    http://www.oracle.com/technology/tech/oci/instantclient/instantclient.html

  Make sure a symbolic link exists from libclntsh.so pointing to
  libclntsh.so.10.1.  If the Linux RPMs were installed then this is
  automatically created.

  Backup and apply the diff listed below to ext/oci8/config.m4

  cd php-4.3.9
  rm -rf autom4te.cache config.cache
  ./buildconf --force

  Run configure.  These are the options I needed to use to install PHP 4.3.9 on
  my local Apache under Redhat 3:

   ./configure \
      --with-oci8-instant-client=/usr/lib/oracle/10.1.0.3/client/lib \
      --prefix=$HOME/php --with-apxs=$HOME/apache/bin/apxs \
      --enable-sigchild --with-config-file-path=$HOME/apache/conf

  (Since I was on linux I could have used --with-oci8-instant-client
  without giving a directory)

  make install

  You might need to set LD_LIBRARY_PATH to
  /usr/lib/oracle/10.1.0.3/client/lib before starting Apache.  If a
  connection string is needed, also set TNS_ADMIN.  For
  Oracle-standard connection information see section 1.3 of
  http://www.oracle.com/technology/docs/tech/sql_plus/10103/readme_ic.htm

  Note: these changes have only been tested on Linux using the Oracle
  Instant Client 10.1.0.3 release and PHP 4.3.9.



--- ext/oci8/config.m4.orig	2004-02-04 01:22:34.000000000 +1100
+++ ext/oci8/config.m4	2004-12-14 18:36:21.000000000 +1100
@@ -38,16 +38,46 @@
       OCI8_VERSION=8.1
     fi
   else
-    AC_MSG_ERROR(Oracle-OCI8 needed libraries not found)
+    AC_MSG_ERROR([Oracle (OCI8) required libraries not found])
   fi
   AC_MSG_RESULT($OCI8_VERSION)
 ])                                                                                                                                                                
 
-PHP_ARG_WITH(oci8, for Oracle-OCI8 support,
-[  --with-oci8[=DIR]       Include Oracle-oci8 support. Default DIR is ORACLE_HOME.])
+AC_DEFUN(AC_OCI8IC_VERSION,[
+  AC_MSG_CHECKING([Oracle Instant Client version])
+  if test -f $PHP_OCI8_INSTANT_CLIENT/libociei.$SHLIB_SUFFIX_NAME; then
+    if test -f $PHP_OCI8_INSTANT_CLIENT/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then
+      if test ! -f $PHP_OCI8_INSTANT_CLIENT/libclntsh.$SHLIB_SUFFIX_NAME; then
+        AC_MSG_ERROR([Link from $PHP_OCI8_INSTANT_CLIENT/libclntsh.$SHLIB_SUFFIX_NAME to libclntsh.$SHLIB_SUFFIX_NAME.10.1 not found])
+      fi
+      OCI8_VERSION=10.1
+    else
+      AC_MSG_ERROR([Oracle Instant Client library version not supported])
+    fi
+  else
+    AC_MSG_ERROR([Oracle Instant Client libraries not found])
+  fi
+  AC_MSG_RESULT([$OCI8_VERSION])
+])
+
+PHP_ARG_WITH(oci8, for Oracle (OCI8) support using ORACLE_HOME installation,
+[  --with-oci8[[=DIR]]     Include Oracle (OCI8) support using an ORACLE_HOME
+                        install. The default DIR is ORACLE_HOME])
+
+PHP_ARG_WITH(oci8-instant-client, for Oracle (OCI8) support using Oracle Instant Client,
+[  --with-oci8-instant-client[[=DIR]]    Include Oracle (OCI8) support using
+                        Oracle Instant Client. DIR is the directory with the
+                        Instant Client libraries. On Linux it will default to
+                        /usr/lib/oracle/<most_recent_version>/client/lib
+                        Other platforms will need to have it explicitly specified.])
 
 if test "$PHP_OCI8" != "no"; then
-  AC_MSG_CHECKING([Oracle Install-Dir])
+
+  if test "$PHP_OCI8_INSTANT_CLIENT" != "no"; then
+    AC_MSG_ERROR([--with-oci8 and --with-oci8-instant-client are mutually exclusive])
+  fi
+
+  AC_MSG_CHECKING([Oracle Install Directory])
   if test "$PHP_OCI8" = "yes"; then
     OCI8_DIR=$ORACLE_HOME
   else
@@ -116,14 +146,18 @@
         -L$OCI8_DIR/lib $OCI8_SHARED_LIBADD
       ])
       ;;
+
     10.1)
       PHP_ADD_LIBRARY(clntsh, 1, OCI8_SHARED_LIBADD)
       PHP_ADD_LIBPATH($OCI8_DIR/lib, OCI8_SHARED_LIBADD)
       AC_DEFINE(HAVE_OCI8_ATTR_STATEMENT,1,[ ])
       AC_DEFINE(HAVE_OCI_9_2,1,[ ])
+      AC_DEFINE(HAVE_OCI8_TEMP_LOB,1,[ ])
+      AC_DEFINE(PHP_OCI8_HAVE_COLLECTIONS,1,[ ])
       ;;
+
     *)
-      AC_MSG_ERROR(Unsupported Oracle version!)
+      AC_MSG_ERROR([Unsupported Oracle version])
       ;;
   esac
 
@@ -145,10 +179,88 @@
     -L$OCI8_DIR/lib $OCI8_SHARED_LIBADD
   ])
 
+  dnl
+  dnl Check if we have collections
+  dnl
+  PHP_CHECK_LIBRARY(clntsh, OCICollAssign,
+  [
+    AC_DEFINE(PHP_OCI8_HAVE_COLLECTIONS,1,[ ])
+  ], [], [
+    -L$OCI8_DIR/lib $OCI8_SHARED_LIBADD
+  ])
+
+
   PHP_NEW_EXTENSION(oci8, oci8.c, $ext_shared)
   AC_DEFINE(HAVE_OCI8,1,[ ])
 
   PHP_SUBST_OLD(OCI8_SHARED_LIBADD)
   PHP_SUBST_OLD(OCI8_DIR)
   PHP_SUBST_OLD(OCI8_VERSION)
+
+elif test "$PHP_OCI8_INSTANT_CLIENT" != "no"; then
+
+  AC_MSG_CHECKING([Oracle Instant Client directory])
+  if test "$PHP_OCI8_INSTANT_CLIENT" = "yes"; then

+dnl Generally the Instant Client can be anywhere so the user must pass in the
+dnl directory to the libraries.  But on Linux we default to the most recent
+dnl version in /usr/lib
+    PHP_OCI8_INSTANT_CLIENT=`ls -d /usr/lib/oracle/*/client/lib  2> /dev/null | tail -1`
+    if test -z "$PHP_OCI8_INSTANT_CLIENT"; then
+      AC_MSG_ERROR([Oracle Instant Client directory not found. Try --with-oci8-instant-client=DIR])
+    fi
+  fi
+  AC_MSG_RESULT($PHP_OCI8_INSTANT_CLIENT)
+
+  OCI8_DIR=$PHP_OCI8_INSTANT_CLIENT
+
+  AC_MSG_CHECKING([Oracle Instant Client SDK header directory])
+
+dnl Header directory for Instant Client SDK RPM install
+  OCISDKRPMINC=`echo "$PHP_OCI8_INSTANT_CLIENT" | sed -e 's!^/usr/lib/oracle/\(.*\)/client/lib[[/]]*$!/usr/include/oracle/\1/client!'`
+
+dnl Header directory for Instant Client SDK zip file install
+  OCISDKZIPINC=$PHP_OCI8_INSTANT_CLIENT/sdk/include
+
+  if test -f "$OCISDKRPMINC/oci.h"; then
+    AC_MSG_RESULT($OCISDKRPMINC)
+    PHP_ADD_INCLUDE($OCISDKRPMINC)
+    OCI8INCDIR=$OCISDKRPMINC
+  elif test -f "$OCISDKZIPINC/oci.h"; then
+    AC_MSG_RESULT($OCISDKZIPINC)
+    PHP_ADD_INCLUDE($OCISDKZIPINC)
+    OCI8INCDIR=$OCISDKZIPINC
+  else
+    AC_MSG_ERROR([Oracle Instant Client SDK header files not found])
+  fi
+
+  OCISYSLIBLIST=`echo "$OCI8INCDIR" | sed -e 's!\(.*\)/include$!\1/demo/sysliblist!'`
+  if test -f "$OCISYSLIBLIST"; then
+    PHP_EVAL_LIBLINE(`cat $OCISYSLIBLIST`, OCI8_SYSLIB)
+  fi
+
+  AC_OCI8IC_VERSION($PHP_OCI8_INSTANT_CLIENT)
+  case $OCI8_VERSION in
+    10.1)
+      PHP_ADD_LIBRARY(clntsh, 1, OCI8_SHARED_LIBADD)
+      PHP_ADD_LIBPATH($PHP_OCI8_INSTANT_CLIENT, OCI8_SHARED_LIBADD)
+      ;;
+
+    *)
+      AC_MSG_ERROR([Unsupported Oracle Instant Client version])
+      ;;
+  esac
+
+  AC_DEFINE(HAVE_OCI8_ATTR_STATEMENT,1,[ ])
+  AC_DEFINE(HAVE_OCI_9_2,1,[ ])
+  AC_DEFINE(HAVE_OCI8_TEMP_LOB,1,[ ])
+  AC_DEFINE(PHP_OCI8_HAVE_COLLECTIONS,1,[ ])
+  AC_DEFINE(HAVE_OCI_INSTANT_CLIENT,1,[ ])
+
+  PHP_NEW_EXTENSION(oci8, oci8.c, $ext_shared)
+  AC_DEFINE(HAVE_OCI8,1,[ ])
+
+  PHP_SUBST_OLD(OCI8_SHARED_LIBADD)
+  PHP_SUBST_OLD(OCI8_DIR)
+  PHP_SUBST_OLD(OCI8_VERSION)
+
 fi



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-14 09:28 UTC] cjbj at hotmail dot com
To see an unmunged copy of the diff, go to 
http://forums.oracle.com/forums/thread.jsp?nav=false&forum=178&thread=279365
 [2004-12-27 09:59 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Jul 23 01:01:25 2018 UTC