xref: /PHP-5.4/ext/pdo_oci/config.m4 (revision 423b132a)
1dnl $Id$
2dnl config.m4 for extension pdo_oci
3dnl vim:et:sw=2:ts=2:
4
5SUPPORTED_LIB_VERS="9.0 10.1 11.1 12.1"  # The lib vers are not bumped when the DB version is bumped
6AC_DEFUN([AC_PDO_OCI_VERSION],[
7  AC_MSG_CHECKING([Oracle version])
8  for OCI_VER in $SUPPORTED_LIB_VERS; do
9    if test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.$OCI_VER; then
10      PDO_OCI_VERSION="$OCI_VER"
11    fi
12  done
13  if test -z "$PDO_OCI_VERSION"; then
14    AC_MSG_ERROR([Oracle required OCI8 libraries not found under $PDO_OCI_DIR])
15  fi
16  AC_MSG_RESULT($PDO_OCI_VERSION)
17])
18
19AC_DEFUN([AC_PDO_OCI_CHECK_LIB_DIR],[
20  AC_CHECK_SIZEOF(long int, 4)
21  AC_MSG_CHECKING([if we're on a 64-bit platform])
22  if test "$ac_cv_sizeof_long_int" = "4" ; then
23    AC_MSG_RESULT([no])
24    TMP_PDO_OCI_LIB_DIR="$PDO_OCI_DIR/lib32"
25  else
26    AC_MSG_RESULT([yes])
27    TMP_PDO_OCI_LIB_DIR="$PDO_OCI_DIR/lib"
28  fi
29
30  AC_MSG_CHECKING([OCI8 libraries dir])
31  if test -d "$PDO_OCI_DIR/lib" && test ! -d "$PDO_OCI_DIR/lib32"; then
32    PDO_OCI_LIB_DIR="$PDO_OCI_DIR/lib"
33  elif test ! -d "$PDO_OCI_DIR/lib" && test -d "$PDO_OCI_DIR/lib32"; then
34    PDO_OCI_LIB_DIR="$PDO_OCI_DIR/lib32"
35  elif test -d "$PDO_OCI_DIR/lib" && test -d "$PDO_OCI_DIR/lib32"; then
36    PDO_OCI_LIB_DIR=$TMP_PDO_OCI_LIB_DIR
37  else
38    AC_MSG_ERROR([Oracle required OCI8 libraries not found])
39  fi
40  AC_MSG_RESULT($PDO_OCI_LIB_DIR)
41])
42
43PHP_ARG_WITH(pdo-oci, Oracle OCI support for PDO,
44[  --with-pdo-oci[=DIR]      PDO: Oracle OCI support. DIR defaults to \$ORACLE_HOME.
45                            Use --with-pdo-oci=instantclient,prefix,version
46                            for an Oracle Instant Client SDK.
47                            For example on Linux with 11.2 RPMs use:
48                            --with-pdo-oci=instantclient,/usr,11.2
49                            With 10.2 RPMs use:
50                            --with-pdo-oci=instantclient,/usr,10.2.0.4])
51
52if test "$PHP_PDO_OCI" != "no"; then
53
54  if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
55    AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
56  fi
57
58  AC_MSG_CHECKING([Oracle Install-Dir])
59  if test "$PHP_PDO_OCI" = "yes" || test -z "$PHP_PDO_OCI"; then
60    PDO_OCI_DIR=$ORACLE_HOME
61  else
62    PDO_OCI_DIR=$PHP_PDO_OCI
63  fi
64  AC_MSG_RESULT($PHP_PDO_OCI)
65
66  AC_MSG_CHECKING([if that is sane])
67  if test -z "$PDO_OCI_DIR"; then
68    AC_MSG_ERROR([
69You need to tell me where to find your Oracle Instant Client SDK, or set ORACLE_HOME.
70])
71  else
72    AC_MSG_RESULT([yes])
73  fi
74
75  if test "instantclient" = "`echo $PDO_OCI_DIR | cut -d, -f1`" ; then
76    AC_CHECK_SIZEOF(long int, 4)
77    if test "$ac_cv_sizeof_long_int" = "4" ; then
78      PDO_OCI_CLIENT_DIR="client"
79    else
80      PDO_OCI_CLIENT_DIR="client64"
81    fi
82    PDO_OCI_IC_PREFIX="`echo $PDO_OCI_DIR | cut -d, -f2`"
83    PDO_OCI_IC_VERS="`echo $PDO_OCI_DIR | cut -d, -f3`"
84    if test -n "$PDO_OCI_IC_VERS"; then
85      PDO_OCI_IC_MAJ_VER="`echo $PDO_OCI_IC_VERS | cut -d. -f1`"
86      if test "$PDO_OCI_IC_MAJ_VER" -ge 11; then
87        # From 11.1.0.7 the RPM path only has an X.Y component
88        PDO_OCI_IC_VERS="`echo $PDO_OCI_IC_VERS | cut -d. -f1-2`"
89      fi
90    fi
91    AC_MSG_CHECKING([for oci.h])
92    if test -f $PDO_OCI_IC_PREFIX/include/oracle/$PDO_OCI_IC_VERS/$PDO_OCI_CLIENT_DIR/oci.h ; then
93      PHP_ADD_INCLUDE($PDO_OCI_IC_PREFIX/include/oracle/$PDO_OCI_IC_VERS/$PDO_OCI_CLIENT_DIR)
94      AC_MSG_RESULT($PDO_OCI_IC_PREFIX/include/oracle/$PDO_OCI_IC_VERS/$PDO_OCI_CLIENT_DIR)
95    elif test -f $PDO_OCI_IC_PREFIX/lib/oracle/$PDO_OCI_IC_VERS/$PDO_OCI_CLIENT_DIR/include/oci.h ; then
96      PHP_ADD_INCLUDE($PDO_OCI_IC_PREFIX/lib/oracle/$PDO_OCI_IC_VERS/$PDO_OCI_CLIENT_DIR/include)
97      AC_MSG_RESULT($PDO_OCI_IC_PREFIX/lib/oracle/$PDO_OCI_IC_VERS/$PDO_OCI_CLIENT_DIR/include)
98    elif test -f $PDO_OCI_IC_PREFIX/sdk/include/oci.h ; then
99      PHP_ADD_INCLUDE($PDO_OCI_IC_PREFIX/sdk/include)
100      AC_MSG_RESULT($PDO_OCI_IC_PREFIX/sdk/include)
101    elif test -f $PDO_OCI_IC_PREFIX/$PDO_OCI_CLIENT_DIR/include/oci.h ; then
102      PHP_ADD_INCLUDE($PDO_OCI_IC_PREFIX/$PDO_OCI_CLIENT_DIR/include)
103      AC_MSG_RESULT($PDO_OCI_IC_PREFIX/$PDO_OCI_CLIENT_DIR/include)
104    else
105      AC_MSG_ERROR([I'm too dumb to figure out where the include dir is in your Instant Client install])
106    fi
107    if test -f "$PDO_OCI_IC_PREFIX/lib/oracle/$PDO_OCI_IC_VERS/$PDO_OCI_CLIENT_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME" ; then
108    PDO_OCI_LIB_DIR="$PDO_OCI_IC_PREFIX/lib/oracle/$PDO_OCI_IC_VERS/$PDO_OCI_CLIENT_DIR/lib"
109    elif test -f "$PDO_OCI_IC_PREFIX/$PDO_OCI_CLIENT_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME" ; then
110      PDO_OCI_LIB_DIR="$PDO_OCI_IC_PREFIX/$PDO_OCI_CLIENT_DIR/lib"
111    elif test -f "$PDO_OCI_IC_PREFIX/libclntsh.$SHLIB_SUFFIX_NAME" ; then
112      PDO_OCI_LIB_DIR="$PDO_OCI_IC_PREFIX"
113    else
114      AC_MSG_ERROR([I'm too dumb to figure out where the libraries are in your Instant Client install])
115    fi
116    PDO_OCI_VERSION="`echo $PDO_OCI_IC_VERS | cut -d. -f1-2`"
117  else
118    AC_PDO_OCI_CHECK_LIB_DIR($PDO_OCI_DIR)
119
120    if test -d "$PDO_OCI_DIR/rdbms/public"; then
121      PHP_ADD_INCLUDE($PDO_OCI_DIR/rdbms/public)
122      PDO_OCI_INCLUDES="$PDO_OCI_INCLUDES -I$PDO_OCI_DIR/rdbms/public"
123    fi
124    if test -d "$PDO_OCI_DIR/rdbms/demo"; then
125      PHP_ADD_INCLUDE($PDO_OCI_DIR/rdbms/demo)
126      PDO_OCI_INCLUDES="$PDO_OCI_INCLUDES -I$PDO_OCI_DIR/rdbms/demo"
127    fi
128    if test -d "$PDO_OCI_DIR/network/public"; then
129      PHP_ADD_INCLUDE($PDO_OCI_DIR/network/public)
130      PDO_OCI_INCLUDES="$PDO_OCI_INCLUDES -I$PDO_OCI_DIR/network/public"
131    fi
132    if test -d "$PDO_OCI_DIR/plsql/public"; then
133      PHP_ADD_INCLUDE($PDO_OCI_DIR/plsql/public)
134      PDO_OCI_INCLUDES="$PDO_OCI_INCLUDES -I$PDO_OCI_DIR/plsql/public"
135    fi
136    if test -d "$PDO_OCI_DIR/include"; then
137      PHP_ADD_INCLUDE($PDO_OCI_DIR/include)
138      PDO_OCI_INCLUDES="$PDO_OCI_INCLUDES -I$PDO_OCI_DIR/include"
139    fi
140
141    if test -f "$PDO_OCI_LIB_DIR/sysliblist"; then
142      PHP_EVAL_LIBLINE(`cat $PDO_OCI_LIB_DIR/sysliblist`, PDO_OCI_SYSLIB)
143    elif test -f "$PDO_OCI_DIR/rdbms/lib/sysliblist"; then
144      PHP_EVAL_LIBLINE(`cat $PDO_OCI_DIR/rdbms/lib/sysliblist`, PDO_OCI_SYSLIB)
145    fi
146    AC_PDO_OCI_VERSION($PDO_OCI_DIR)
147  fi
148
149  case $PDO_OCI_VERSION in
150    9.0|10.1|10.2|11.1|11.2|12.1)
151      PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
152      ;;
153
154    *)
155      AC_MSG_ERROR(Unsupported Oracle version $PDO_OCI_VERSION)
156      ;;
157  esac
158
159  PHP_ADD_LIBPATH($PDO_OCI_LIB_DIR, PDO_OCI_SHARED_LIBADD)
160
161  PHP_CHECK_LIBRARY(clntsh, OCIEnvCreate,
162  [
163    AC_DEFINE(HAVE_OCIENVCREATE,1,[ ])
164  ], [], [
165    -L$PDO_OCI_LIB_DIR $PDO_OCI_SHARED_LIBADD
166  ])
167
168  PHP_CHECK_LIBRARY(clntsh, OCIEnvNlsCreate,
169  [
170    AC_DEFINE(HAVE_OCIENVNLSCREATE,1,[ ])
171  ], [], [
172    -L$PDO_OCI_LIB_DIR $PDO_OCI_SHARED_LIBADD
173  ])
174
175  dnl
176  dnl Check if we need to add -locijdbc8
177  dnl
178  PHP_CHECK_LIBRARY(clntsh, OCILobIsTemporary,
179  [
180    AC_DEFINE(HAVE_OCILOBISTEMPORARY,1,[ ])
181  ], [
182    PHP_CHECK_LIBRARY(ocijdbc8, OCILobIsTemporary,
183    [
184      PHP_ADD_LIBRARY(ocijdbc8, 1, PDO_OCI_SHARED_LIBADD)
185      AC_DEFINE(HAVE_OCILOBISTEMPORARY,1,[ ])
186    ], [], [
187      -L$PDO_OCI_LIB_DIR $PDO_OCI_SHARED_LIBADD
188    ])
189  ], [
190    -L$PDO_OCI_LIB_DIR $PDO_OCI_SHARED_LIBADD
191  ])
192
193  dnl
194  dnl Check if we have collections
195  dnl
196  PHP_CHECK_LIBRARY(clntsh, OCICollAssign,
197  [
198    AC_DEFINE(HAVE_OCICOLLASSIGN,1,[ ])
199  ], [], [
200    -L$PDO_OCI_LIB_DIR $PDO_OCI_SHARED_LIBADD
201  ])
202
203  dnl Scrollable cursors?
204  PHP_CHECK_LIBRARY(clntsh, OCIStmtFetch2,
205  [
206     AC_DEFINE(HAVE_OCISTMTFETCH2,1,[ ])
207  ], [], [
208    -L$PDO_OCI_LIB_DIR $PDO_OCI_SHARED_LIBADD
209  ])
210
211  ifdef([PHP_CHECK_PDO_INCLUDES],
212  [
213    PHP_CHECK_PDO_INCLUDES
214  ],[
215    AC_MSG_CHECKING([for PDO includes])
216    if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
217      pdo_cv_inc_path=$abs_srcdir/ext
218    elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
219      pdo_cv_inc_path=$abs_srcdir/ext
220    elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
221      pdo_cv_inc_path=$prefix/include/php/ext
222    else
223      AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
224    fi
225    AC_MSG_RESULT($pdo_cv_inc_path)
226  ])
227
228  PHP_NEW_EXTENSION(pdo_oci, pdo_oci.c oci_driver.c oci_statement.c, $ext_shared,,-I$pdo_cv_inc_path)
229
230  PHP_SUBST_OLD(PDO_OCI_SHARED_LIBADD)
231  PHP_SUBST_OLD(PDO_OCI_DIR)
232  PHP_SUBST_OLD(PDO_OCI_VERSION)
233
234  ifdef([PHP_ADD_EXTENSION_DEP],
235  [
236    PHP_ADD_EXTENSION_DEP(pdo_oci, pdo)
237  ])
238
239  AC_DEFINE_UNQUOTED(PHP_PDO_OCI_CLIENT_VERSION, "$PDO_OCI_VERSION", [ ])
240fi
241
242