xref: /PHP-5.5/ext/oci8/config.m4 (revision c6d977dd)
1dnl
2dnl $Id$
3dnl
4
5if test -z "$SED"; then
6  PHP_OCI8_SED="sed";
7else
8  PHP_OCI8_SED="$SED";
9fi
10
11PHP_OCI8_TAIL1=`echo a | tail -n1 2>/dev/null`
12if test "$PHP_OCI8_TAIL1" = "a"; then
13    PHP_OCI8_TAIL1="tail -n1"
14else
15    PHP_OCI8_TAIL1="tail -1"
16fi
17
18AC_DEFUN([PHP_OCI_IF_DEFINED],[
19  old_CPPFLAGS=$CPPFLAGS
20  CPPFLAGS=$3
21  AC_EGREP_CPP(yes,[
22#include <oci.h>
23#if defined($1)
24    yes
25#endif
26  ],[
27    CPPFLAGS=$old_CPPFLAGS
28    $2
29  ],[
30    CPPFLAGS=$old_CPPFLAGS
31  ])
32])
33
34AC_DEFUN([AC_OCI8_CHECK_LIB_DIR],[
35  AC_MSG_CHECKING([ORACLE_HOME library validity])
36  if test ! -d "$OCI8_DIR"; then
37    AC_MSG_ERROR([${OCI8_DIR} is not a directory])
38  fi
39  if test -d "$OCI8_DIR/lib" && test ! -d "$OCI8_DIR/lib32"; then
40    OCI8_LIB_DIR=lib
41  elif test ! -d "$OCI8_DIR/lib" && test -d "$OCI8_DIR/lib32"; then
42    OCI8_LIB_DIR=lib32
43  elif test -d "$OCI8_DIR/lib" && test -d "$OCI8_DIR/lib32"; then
44    OCI8_LIB_DIR=$PHP_OCI8_OH_LIBDIR
45  else
46    dnl This isn't an ORACLE_HOME.  Try heuristic examination of the dir to help the user
47    if test -f "$OCI8_DIR/libociei.$SHLIB_SUFFIX_NAME"; then
48      AC_MSG_ERROR([Expected an ORACLE_HOME top level directory but ${OCI8_DIR} appears to be an Instant Client directory. Try --with-oci8=instantclient,${OCI8_DIR}])
49    else
50      AC_MSG_ERROR([Oracle library directory not found in ${OCI8_DIR}])
51    fi
52  fi
53  AC_MSG_RESULT($OCI8_LIB_DIR)
54])
55
56AC_DEFUN([AC_OCI8IC_VERSION],[
57  AC_MSG_CHECKING([Oracle Instant Client library version compatibility])
58  OCI8_LCS_BASE=$PHP_OCI8_INSTANT_CLIENT/libclntsh.$SHLIB_SUFFIX_NAME
59  OCI8_LCS=`ls $OCI8_LCS_BASE.*.1 2> /dev/null | $PHP_OCI8_TAIL1`  # Oracle 10g, 11g etc
60  OCI8_NNZ=`ls $PHP_OCI8_INSTANT_CLIENT/libnnz*.$SHLIB_SUFFIX_NAME 2> /dev/null | $PHP_OCI8_TAIL1`
61  if test -f "$OCI8_NNZ" && test -f "$OCI8_LCS"; then
62    if test ! -f "$OCI8_LCS_BASE"; then
63      AC_MSG_ERROR([Link from $OCI8_LCS_BASE to $OCI8_LCS_BASE.*.1 not found])
64    fi
65    OCI8_ORACLE_VERSION=`echo $OCI8_LCS | $PHP_OCI8_SED -e 's/.*\.\(.*\)\.1$/\1.1/'`
66  else
67    AC_MSG_ERROR([Oracle Instant Client libraries libnnz.$SHLIB_SUFFIX_NAME and libclntsh.$SHLIB_SUFFIX_NAME not found])
68  fi
69  AC_MSG_RESULT([$OCI8_ORACLE_VERSION])
70])
71
72AC_DEFUN([AC_OCI8_ORACLE_VERSION],[
73  AC_MSG_CHECKING([Oracle library version compatibility])
74  OCI8_LCS_BASE=$OCI8_DIR/$OCI8_LIB_DIR/libclntsh.$SHLIB_SUFFIX_NAME
75  OCI8_LCS=`ls $OCI8_LCS_BASE.*.1 2> /dev/null | $PHP_OCI8_TAIL1`  # Oracle 10g, 11g etc
76  if test -s "$OCI8_DIR/orainst/unix.rgs"; then
77    OCI8_ORACLE_VERSION=`grep '"ocommon"' $OCI8_DIR/orainst/unix.rgs | $PHP_OCI8_SED 's/[ ][ ]*/:/g' | cut -d: -f 6 | cut -c 2-4`
78    test -z "$OCI8_ORACLE_VERSION" && OCI8_ORACLE_VERSION=7.3
79  elif test -f "$OCI8_LCS"; then
80    dnl Oracle 10g, 11g etc.  The x.2 version libraries are named x.1 for drop in compatibility
81    OCI8_ORACLE_VERSION=`echo $OCI8_LCS | $PHP_OCI8_SED -e 's/.*\.\(.*\)\.1$/\1.1/'`
82  elif test -f $OCI8_LCS_BASE.9.0; then
83    dnl There is no case for Oracle 9.2. Oracle 9.2 libraries have a 9.0 suffix for drop-in compatibility with Oracle 9.0
84    OCI8_ORACLE_VERSION=9.0
85  elif test -f $OCI8_LCS_BASE.8.0; then
86    OCI8_ORACLE_VERSION=8.1
87  elif test -f $OCI8_LCS_BASE.1.0; then
88    OCI8_ORACLE_VERSION=8.0
89  elif test -f $OCI8_DIR/$OCI8_LIB_DIR/libclntsh.a; then
90    if test -f $OCI8_DIR/$OCI8_LIB_DIR/libcore4.a; then
91      OCI8_ORACLE_VERSION=8.0
92    else
93      OCI8_ORACLE_VERSION=8.1
94    fi
95  else
96    AC_MSG_ERROR(Oracle libclntsh.$SHLIB_SUFFIX_NAME client library not found)
97  fi
98  AC_MSG_RESULT($OCI8_ORACLE_VERSION)
99])
100
101
102dnl --with-oci8=shared,instantclient,/path/to/client/dir/lib
103dnl or
104dnl --with-oci8=shared,/path/to/oracle/home
105PHP_ARG_WITH(oci8, for Oracle Database OCI8 support,
106[  --with-oci8[=DIR]         Include Oracle Database OCI8 support. DIR defaults to \$ORACLE_HOME.
107                          Use --with-oci8=instantclient,/path/to/instant/client/lib
108                          to use an Oracle Instant Client installation])
109
110if test "$PHP_OCI8" != "no"; then
111
112  if test -z "$PHP_OCI8"; then
113    dnl --with-oci8=$ORACLE_HOME where ORACLE_HOME isn't set (or is mistyped) will match this case
114    AC_MSG_ERROR([Empty parameter value passed to --with-oci8])
115  fi
116
117  dnl Check PHP version is compatible with this extension
118
119  AC_MSG_CHECKING([PHP version])
120
121  tmp_version=$PHP_VERSION
122  if test -z "$tmp_version"; then
123    if test -z "$PHP_CONFIG"; then
124      AC_MSG_ERROR([php-config not found])
125    fi
126    php_version=`$PHP_CONFIG --version 2>/dev/null|head -n 1|$PHP_OCI8_SED -e 's#\([0-9]\.[0-9]*\.[0-9]*\)\(.*\)#\1#'`
127  else
128    php_version=`echo "$tmp_version"|$PHP_OCI8_SED -e 's#\([0-9]\.[0-9]*\.[0-9]*\)\(.*\)#\1#'`
129  fi
130
131  if test -z "$php_version"; then
132    AC_MSG_ERROR([failed to detect PHP version, please report])
133  fi
134
135  ac_IFS=$IFS
136  IFS="."
137  set $php_version
138  IFS=$ac_IFS
139  oci8_php_version=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
140
141  if test "$oci8_php_version" -lt "4003009"; then
142    AC_MSG_ERROR([You need at least PHP 4.3.9 to be able to use this version of OCI8. PHP $php_version found])
143  elif test "$oci8_php_version" -ge "6000000"; then
144    AC_MSG_ERROR([This version of OCI8 is not compatible with PHP 6 or higher])
145  else
146    AC_MSG_RESULT([$php_version, ok])
147  fi
148
149  dnl Set some port specific directory components for use later
150
151  AC_CHECK_SIZEOF(long int, 4)
152  AC_MSG_CHECKING([checking if we're on a 64-bit platform])
153  if test "$ac_cv_sizeof_long_int" = "4"; then
154    AC_MSG_RESULT([no])
155    PHP_OCI8_OH_LIBDIR=lib32
156    PHP_OCI8_IC_LIBDIR_SUFFIX=""
157  else
158    AC_MSG_RESULT([yes])
159    PHP_OCI8_OH_LIBDIR=lib
160    PHP_OCI8_IC_LIBDIR_SUFFIX=64
161  fi
162
163  dnl Determine if the user wants to use Oracle Instant Client libraries
164
165  PHP_OCI8_INSTANT_CLIENT="no"
166
167  dnl PECL Bug 14268 (Allow "pecl install oci8" command to "autodetect"
168  dnl an Instant Client RPM install).  This also has a benefit for non
169  dnl "pecl install" builds: if the user does --with-oci8 or
170  dnl --with-oci8=shared but the ORACLE_HOME environment variable is not
171  dnl actually set, the install tries to locate the Instant Client RPM
172  if test "$PHP_OCI8" = "yes" && test -z "$ORACLE_HOME"; then
173    AC_MSG_WARN([OCI8 extension: ORACLE_HOME is not set, looking for default Oracle Instant Client instead])
174    PHP_OCI8=instantclient
175  fi
176
177  if test "`echo $PHP_OCI8`" = "instantclient"; then
178    PHP_OCI8_INSTANT_CLIENT="yes"
179  elif test "`echo $PHP_OCI8 | cut -d, -f2`" = "instantclient"; then
180    PHP_OCI8_INSTANT_CLIENT="`echo $PHP_OCI8 | cut -d, -f3`"
181    PHP_OCI8="`echo $PHP_OCI8 | cut -d, -f1,4`"
182    if test "$PHP_OCI8_INSTANT_CLIENT" = ""; then
183	PHP_OCI8_INSTANT_CLIENT="yes"
184    fi
185    if test -z "$PHP_OCI8"; then
186	PHP_OCI8=yes
187    fi
188  elif test "`echo $PHP_OCI8 | cut -d, -f1`" = "instantclient"; then
189    PHP_OCI8_INSTANT_CLIENT="`echo $PHP_OCI8 | cut -d, -f2`"
190    PHP_OCI8="`echo $PHP_OCI8 | cut -d, -f3,4`"
191    if test "$PHP_OCI8_INSTANT_CLIENT" = ""; then
192	PHP_OCI8_INSTANT_CLIENT="yes"
193    fi
194    if test -z "$PHP_OCI8"; then
195	PHP_OCI8=yes
196    fi
197  fi
198
199  if test "$PHP_OCI8_INSTANT_CLIENT" = "no"; then
200    dnl ***************************************
201    dnl Branch for using an ORACLE_HOME install
202    dnl ***************************************
203
204    AC_MSG_CHECKING([Oracle ORACLE_HOME install directory])
205
206    if test "$PHP_OCI8" = "yes"; then
207      OCI8_DIR=$ORACLE_HOME
208    else
209      OCI8_DIR=$PHP_OCI8
210    fi
211    AC_MSG_RESULT($OCI8_DIR)
212
213    AC_OCI8_CHECK_LIB_DIR($OCI8_DIR)
214
215    if test -d "$OCI8_DIR/rdbms/public"; then
216      PHP_ADD_INCLUDE($OCI8_DIR/rdbms/public)
217      OCI8_INCLUDES="$OCI8_INCLUDES -I$OCI8_DIR/rdbms/public"
218    fi
219    if test -d "$OCI8_DIR/rdbms/demo"; then
220      PHP_ADD_INCLUDE($OCI8_DIR/rdbms/demo)
221      OCI8_INCLUDES="$OCI8_INCLUDES -I$OCI8_DIR/rdbms/demo"
222    fi
223    if test -d "$OCI8_DIR/network/public"; then
224      PHP_ADD_INCLUDE($OCI8_DIR/network/public)
225      OCI8_INCLUDES="$OCI8_INCLUDES -I$OCI8_DIR/network/public"
226    fi
227    if test -d "$OCI8_DIR/plsql/public"; then
228      PHP_ADD_INCLUDE($OCI8_DIR/plsql/public)
229      OCI8_INCLUDES="$OCI8_INCLUDES -I$OCI8_DIR/plsql/public"
230    fi
231
232    if test -f "$OCI8_DIR/$OCI8_LIB_DIR/sysliblist"; then
233      PHP_EVAL_LIBLINE(`cat $OCI8_DIR/$OCI8_LIB_DIR/sysliblist`, OCI8_SYSLIB)
234    elif test -f "$OCI8_DIR/rdbms/$OCI8_LIB_DIR/sysliblist"; then
235      PHP_EVAL_LIBLINE(`cat $OCI8_DIR/rdbms/$OCI8_LIB_DIR/sysliblist`, OCI8_SYSLIB)
236    fi
237
238    AC_OCI8_ORACLE_VERSION($OCI8_DIR)
239
240    case $OCI8_ORACLE_VERSION in
241      7.3|8.0|8.1)
242	AC_MSG_ERROR([Oracle client libraries < 9.2 are not supported])
243	;;
244
245      9.0)
246	PHP_CHECK_LIBRARY(clntsh, OCIEnvNlsCreate,
247	[
248	  OCI8_ORACLE_VERSION=9.2
249	],
250	[
251	  AC_MSG_ERROR([Oracle client libraries < 9.2 are not supported])
252	], [
253	  -L$OCI8_DIR/$OCI8_LIB_DIR $OCI8_SHARED_LIBADD
254	])
255	;;
256
257      *)
258	AC_DEFINE(HAVE_OCI_LOB_READ2,1,[ ])
259	;;
260    esac
261
262    PHP_ADD_LIBRARY(clntsh, 1, OCI8_SHARED_LIBADD)
263    PHP_ADD_LIBPATH($OCI8_DIR/$OCI8_LIB_DIR, OCI8_SHARED_LIBADD)
264    PHP_NEW_EXTENSION(oci8, oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c, $ext_shared)
265    AC_DEFINE(HAVE_OCI8,1,[ ])
266
267    PHP_SUBST_OLD(OCI8_SHARED_LIBADD)
268    PHP_SUBST_OLD(OCI8_DIR)
269    PHP_SUBST_OLD(OCI8_ORACLE_VERSION)
270
271    dnl Fix Bug #46623
272    AC_DEFINE_UNQUOTED(PHP_OCI8_DEF_DIR, "$OCI8_DIR", [ ])
273    AC_DEFINE_UNQUOTED(PHP_OCI8_DEF_SHARED_LIBADD, "$OCI8_SHARED_LIBADD", [ ])
274
275  else
276    dnl ***************************************************
277    dnl Branch for using an Oracle Instant Client directory
278    dnl ***************************************************
279
280    AC_MSG_CHECKING([Oracle Instant Client directory])
281
282    if test "$PHP_OCI8_INSTANT_CLIENT" = "yes"; then
283      dnl Find the directory if user specified "instantclient" but did not
284      dnl give a dir. Generally the Instant Client can be anywhere so the
285      dnl user must pass in the library directory.  But on Linux we default
286      dnl to the most recent version in /usr/lib which is where the Oracle
287      dnl Instant Client RPM gets installed.
288      PHP_OCI8_INSTANT_CLIENT=`ls -d /usr/lib/oracle/*/client${PHP_OCI8_IC_LIBDIR_SUFFIX}/lib/libclntsh.* 2> /dev/null | $PHP_OCI8_TAIL1 | $PHP_OCI8_SED -e 's#/libclntsh[^/]*##'`
289      if test -z "$PHP_OCI8_INSTANT_CLIENT"; then
290	AC_MSG_ERROR([Oracle Instant Client directory /usr/lib/oracle/.../client${PHP_OCI8_IC_LIBDIR_SUFFIX}/lib libraries not found. Try --with-oci8=instantclient,DIR])
291      fi
292    fi
293    AC_MSG_RESULT($PHP_OCI8_INSTANT_CLIENT)
294
295    OCI8_DIR=$PHP_OCI8_INSTANT_CLIENT
296
297    AC_MSG_CHECKING([Oracle Instant Client SDK header directory])
298
299    dnl Header directory for Instant Client SDK RPM install
300    OCISDKRPMINC=`echo "$PHP_OCI8_INSTANT_CLIENT" | $PHP_OCI8_SED -e 's!^/usr/lib/oracle/\(.*\)/client\('${PHP_OCI8_IC_LIBDIR_SUFFIX}'\)*/lib[/]*$!/usr/include/oracle/\1/client\2!'`
301
302    dnl Header directory for Instant Client SDK zip file install
303    OCISDKZIPINC=$PHP_OCI8_INSTANT_CLIENT/sdk/include
304
305    dnl Header directory for manual installation
306    OCISDKMANINC=`echo "$PHP_OCI8_INSTANT_CLIENT" | $PHP_OCI8_SED -e 's!\(.*\)/lib[/]*$!\1/include!'`
307
308    if test -f "$OCISDKRPMINC/oci.h"; then
309      AC_MSG_RESULT($OCISDKRPMINC)
310      PHP_ADD_INCLUDE($OCISDKRPMINC)
311      OCI8INCDIR=$OCISDKRPMINC
312    elif test -f "$OCISDKZIPINC/oci.h"; then
313      AC_MSG_RESULT($OCISDKZIPINC)
314      PHP_ADD_INCLUDE($OCISDKZIPINC)
315      OCI8INCDIR=$OCISDKZIPINC
316    elif test -f "$OCISDKMANINC/oci.h"; then
317      AC_MSG_RESULT($OCISDKMANINC)
318      PHP_ADD_INCLUDE($OCISDKMANINC)
319      OCI8INCDIR=$OCISDKMANINC
320    else
321      AC_MSG_ERROR([Oracle Instant Client SDK header files not found])
322    fi
323
324    OCISYSLIBLIST=`echo "$OCI8INCDIR" | $PHP_OCI8_SED -e 's!\(.*\)/include$!\1/demo/sysliblist!'`
325    if test -f "$OCISYSLIBLIST"; then
326      PHP_EVAL_LIBLINE(`cat $OCISYSLIBLIST`, OCI8_SYSLIB)
327    fi
328
329    AC_OCI8IC_VERSION($PHP_OCI8_INSTANT_CLIENT)
330    PHP_ADD_LIBRARY(clntsh, 1, OCI8_SHARED_LIBADD)
331    PHP_ADD_LIBPATH($PHP_OCI8_INSTANT_CLIENT, OCI8_SHARED_LIBADD)
332
333    AC_DEFINE(HAVE_OCI_INSTANT_CLIENT,1,[ ])
334    AC_DEFINE(HAVE_OCI_LOB_READ2,1,[ ])
335
336    PHP_NEW_EXTENSION(oci8, oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c, $ext_shared)
337    AC_DEFINE(HAVE_OCI8,1,[ ])
338
339    PHP_SUBST_OLD(OCI8_SHARED_LIBADD)
340    PHP_SUBST_OLD(OCI8_DIR)
341    PHP_SUBST_OLD(OCI8_ORACLE_VERSION)
342
343  fi
344fi
345