xref: /PHP-8.0/ext/pdo_oci/config.m4 (revision 5d827c89)
1if test -z "$SED"; then
2  PHP_PDO_OCI_SED="sed";
3else
4  PHP_PDO_OCI_SED="$SED";
5fi
6
7PHP_PDO_OCI_TAIL1=`echo a | tail -n1 2>/dev/null`
8if test "$PHP_PDO_OCI_TAIL1" = "a"; then
9    PHP_PDO_OCI_TAIL1="tail -n1"
10else
11    PHP_PDO_OCI_TAIL1="tail -1"
12fi
13
14AC_DEFUN([AC_PDO_OCI_VERSION],[
15  AC_MSG_CHECKING([Oracle version])
16  PDO_OCI_LCS_BASE=$PDO_OCI_LIB_DIR/libclntsh.$SHLIB_SUFFIX_NAME
17  dnl Oracle 10g, 11g, 12c etc
18  PDO_OCI_LCS=`ls $PDO_OCI_LCS_BASE.*.1 2> /dev/null | $PHP_PDO_OCI_TAIL1`
19  if test -f "$PDO_OCI_LCS"; then
20    dnl Oracle 10g, 11g 12c etc. The x.2 version libraries are named x.1 for
21    dnl drop in compatibility
22    PDO_OCI_VERSION=`echo $PDO_OCI_LCS | $PHP_PDO_OCI_SED -e 's/.*\.\(.*\)\.1$/\1.1/'`
23  elif test -f $PDO_OCI_LCS_BASE.9.0; then
24    dnl There is no case for Oracle 9.2. Oracle 9.2 libraries have a 9.0 suffix
25    dnl for drop-in compatibility with Oracle 9.0
26    PDO_OCI_VERSION=9.0
27  else
28    AC_MSG_ERROR(Oracle libclntsh.$SHLIB_SUFFIX_NAME client library not found or its version is lower than 9)
29  fi
30  AC_MSG_RESULT($PDO_OCI_VERSION)
31])
32
33AC_DEFUN([AC_PDO_OCI_CHECK_LIB_DIR],[
34  AC_CHECK_SIZEOF([long])
35  AC_MSG_CHECKING([if we're at 64-bit platform])
36  AS_IF([test "$ac_cv_sizeof_long" -eq 4],[
37    AC_MSG_RESULT([no])
38    TMP_PDO_OCI_LIB_DIR="$PDO_OCI_DIR/lib32"
39  ],[
40    AC_MSG_RESULT([yes])
41    TMP_PDO_OCI_LIB_DIR="$PDO_OCI_DIR/lib"
42  ])
43
44  AC_MSG_CHECKING([OCI8 libraries dir])
45  if test -d "$PDO_OCI_DIR/lib" && test ! -d "$PDO_OCI_DIR/lib32"; then
46    PDO_OCI_LIB_DIR="$PDO_OCI_DIR/lib"
47  elif test ! -d "$PDO_OCI_DIR/lib" && test -d "$PDO_OCI_DIR/lib32"; then
48    PDO_OCI_LIB_DIR="$PDO_OCI_DIR/lib32"
49  elif test -d "$PDO_OCI_DIR/lib" && test -d "$PDO_OCI_DIR/lib32"; then
50    PDO_OCI_LIB_DIR=$TMP_PDO_OCI_LIB_DIR
51  else
52    AC_MSG_ERROR([Oracle required OCI8 libraries not found])
53  fi
54  AC_MSG_RESULT($PDO_OCI_LIB_DIR)
55])
56
57PHP_ARG_WITH([pdo-oci],
58  [Oracle OCI support for PDO],
59  [AS_HELP_STRING([[--with-pdo-oci[=DIR]]],
60    [PDO: Oracle OCI support. DIR defaults to $ORACLE_HOME. Use
61    --with-pdo-oci=instantclient,/path/to/instant/client/lib for an Oracle
62    Instant Client installation.])])
63
64if test "$PHP_PDO_OCI" != "no"; then
65
66  if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
67    AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
68  fi
69
70  AC_MSG_CHECKING([Oracle Install-Dir])
71  if test "$PHP_PDO_OCI" = "yes" || test -z "$PHP_PDO_OCI"; then
72    PDO_OCI_DIR=$ORACLE_HOME
73  else
74    PDO_OCI_DIR=$PHP_PDO_OCI
75  fi
76  AC_MSG_RESULT($PHP_PDO_OCI)
77
78  AC_MSG_CHECKING([if that is sane])
79  if test -z "$PDO_OCI_DIR"; then
80    AC_MSG_ERROR([You need to tell me where to find your Oracle Instant Client SDK, or set ORACLE_HOME.])
81  else
82    AC_MSG_RESULT([yes])
83  fi
84
85  if test "instantclient" = "`echo $PDO_OCI_DIR | cut -d, -f1`" ; then
86    AC_CHECK_SIZEOF([long])
87    AC_MSG_CHECKING([if we're at 64-bit platform])
88    AS_IF([test "$ac_cv_sizeof_long" -eq 4],[
89      AC_MSG_RESULT([no])
90      PDO_OCI_CLIENT_DIR="client"
91    ],[
92      AC_MSG_RESULT([yes])
93      PDO_OCI_CLIENT_DIR="client64"
94    ])
95
96    PDO_OCI_LIB_DIR="`echo $PDO_OCI_DIR | cut -d, -f2`"
97    AC_PDO_OCI_VERSION($PDO_OCI_LIB_DIR)
98
99    AC_MSG_CHECKING([for oci.h])
100    dnl Header directory for Instant Client SDK RPM install
101    OCISDKRPMINC=`echo "$PDO_OCI_LIB_DIR" | $PHP_PDO_OCI_SED -e 's!^\(.*\)/lib/oracle/\(.*\)/\('${PDO_OCI_CLIENT_DIR}'\)/lib[/]*$!\1/include/oracle/\2/\3!'`
102
103    dnl Header directory for manual installation
104    OCISDKMANINC=`echo "$PDO_OCI_LIB_DIR" | $PHP_PDO_OCI_SED -e 's!^\(.*\)/lib[/]*$!\1/include!'`
105
106    dnl Header directory for Instant Client SDK zip file install
107    OCISDKZIPINC=$PDO_OCI_LIB_DIR/sdk/include
108
109
110    if test -f "$OCISDKRPMINC/oci.h" ; then
111      PHP_ADD_INCLUDE($OCISDKRPMINC)
112      AC_MSG_RESULT($OCISDKRPMINC)
113    elif test -f "$OCISDKMANINC/oci.h" ; then
114      PHP_ADD_INCLUDE($OCISDKMANINC)
115      AC_MSG_RESULT($OCISDKMANINC)
116    elif test -f "$OCISDKZIPINC/oci.h" ; then
117      PHP_ADD_INCLUDE($OCISDKZIPINC)
118      AC_MSG_RESULT($OCISDKZIPINC)
119    else
120      AC_MSG_ERROR([I'm too dumb to figure out where the include dir is in your Instant Client install])
121    fi
122  else
123    AC_PDO_OCI_CHECK_LIB_DIR($PDO_OCI_DIR)
124
125    if test -d "$PDO_OCI_DIR/rdbms/public"; then
126      PHP_ADD_INCLUDE($PDO_OCI_DIR/rdbms/public)
127      PDO_OCI_INCLUDES="$PDO_OCI_INCLUDES -I$PDO_OCI_DIR/rdbms/public"
128    fi
129    if test -d "$PDO_OCI_DIR/rdbms/demo"; then
130      PHP_ADD_INCLUDE($PDO_OCI_DIR/rdbms/demo)
131      PDO_OCI_INCLUDES="$PDO_OCI_INCLUDES -I$PDO_OCI_DIR/rdbms/demo"
132    fi
133    if test -d "$PDO_OCI_DIR/network/public"; then
134      PHP_ADD_INCLUDE($PDO_OCI_DIR/network/public)
135      PDO_OCI_INCLUDES="$PDO_OCI_INCLUDES -I$PDO_OCI_DIR/network/public"
136    fi
137    if test -d "$PDO_OCI_DIR/plsql/public"; then
138      PHP_ADD_INCLUDE($PDO_OCI_DIR/plsql/public)
139      PDO_OCI_INCLUDES="$PDO_OCI_INCLUDES -I$PDO_OCI_DIR/plsql/public"
140    fi
141    if test -d "$PDO_OCI_DIR/include"; then
142      PHP_ADD_INCLUDE($PDO_OCI_DIR/include)
143      PDO_OCI_INCLUDES="$PDO_OCI_INCLUDES -I$PDO_OCI_DIR/include"
144    fi
145
146    if test -f "$PDO_OCI_LIB_DIR/sysliblist"; then
147      PHP_EVAL_LIBLINE(`cat $PDO_OCI_LIB_DIR/sysliblist`, PDO_OCI_SYSLIB)
148    elif test -f "$PDO_OCI_DIR/rdbms/lib/sysliblist"; then
149      PHP_EVAL_LIBLINE(`cat $PDO_OCI_DIR/rdbms/lib/sysliblist`, PDO_OCI_SYSLIB)
150    fi
151    AC_PDO_OCI_VERSION($PDO_OCI_LIB_DIR)
152  fi
153
154  case $PDO_OCI_VERSION in
155    7.3|8.0|8.1)
156      AC_MSG_ERROR([Oracle client libraries < 9 are not supported])
157      ;;
158  esac
159
160  PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
161  PHP_ADD_LIBPATH($PDO_OCI_LIB_DIR, PDO_OCI_SHARED_LIBADD)
162
163  PHP_CHECK_LIBRARY(clntsh, OCIEnvCreate,
164  [
165    AC_DEFINE(HAVE_OCIENVCREATE,1,[ ])
166  ], [], [
167    -L$PDO_OCI_LIB_DIR $PDO_OCI_SHARED_LIBADD
168  ])
169
170  PHP_CHECK_LIBRARY(clntsh, OCIEnvNlsCreate,
171  [
172    AC_DEFINE(HAVE_OCIENVNLSCREATE,1,[ ])
173  ], [], [
174    -L$PDO_OCI_LIB_DIR $PDO_OCI_SHARED_LIBADD
175  ])
176
177  dnl Scrollable cursors?
178  PHP_CHECK_LIBRARY(clntsh, OCIStmtFetch2,
179  [
180     AC_DEFINE(HAVE_OCISTMTFETCH2,1,[ ])
181  ], [], [
182    -L$PDO_OCI_LIB_DIR $PDO_OCI_SHARED_LIBADD
183  ])
184
185  PHP_CHECK_PDO_INCLUDES
186
187  PHP_NEW_EXTENSION(pdo_oci, pdo_oci.c oci_driver.c oci_statement.c, $ext_shared,,-I$pdo_cv_inc_path)
188
189  PHP_SUBST_OLD(PDO_OCI_SHARED_LIBADD)
190  PHP_SUBST_OLD(PDO_OCI_DIR)
191  PHP_SUBST_OLD(PDO_OCI_VERSION)
192
193  PHP_ADD_EXTENSION_DEP(pdo_oci, pdo)
194
195  AC_DEFINE_UNQUOTED(PHP_PDO_OCI_CLIENT_VERSION, "$PDO_OCI_VERSION", [ ])
196fi
197