xref: /PHP-8.4/ext/odbc/config.m4 (revision dfdec2d5)
1dnl
2dnl PHP_ODBC_CHECK_HEADER(header)
3dnl
4dnl Check if required header file exists in the ODBC include directory.
5dnl
6AC_DEFUN([PHP_ODBC_CHECK_HEADER],
7[AS_IF([test ! -f "$ODBC_INCDIR/$1"],
8  [AC_MSG_ERROR([ODBC header file '$ODBC_INCDIR/$1' not found!])])])
9
10dnl
11dnl PHP_ODBC_FIND_SOLID_LIBS(libdir)
12dnl
13dnl Figure out which library file to link with for the Solid support.
14dnl
15AC_DEFUN([PHP_ODBC_FIND_SOLID_LIBS],[
16  AC_MSG_CHECKING([Solid library file])
17  ac_solid_uname_r=$(uname -r 2>/dev/null)
18  ac_solid_uname_s=$(uname -s 2>/dev/null)
19  case $ac_solid_uname_s in
20    AIX) ac_solid_os=a3x;;   # a4x for AIX4/ Solid 2.3/3.0 only
21    HP-UX) ac_solid_os=h9x;; # h1x for hpux11, h0x for hpux10
22    Linux)
23      if ldd -v /bin/sh | grep GLIBC > /dev/null; then
24        ac_solid_os=l2x
25      else
26        ac_solid_os=lux
27      fi
28      AC_DEFINE([SS_LINUX], [1],
29        [Define to 1 to be able to use the obsolete <sqlunix.h> header file on
30        some Linux systems.])
31      ;;
32    SunOS)
33      ac_solid_os=ssx;; # should we deal with SunOS 4?
34    FreeBSD)
35      if test $(expr $ac_solid_uname_r : '\(.\)') -gt "2"; then
36        ac_solid_os=fex
37      else
38        ac_solid_os=fbx
39      fi
40      AC_DEFINE([SS_FBX], [1],
41        [Define to 1 to be able to use the wchar defs in the obsolete
42        <sqlunix.h> header file on some FreeBSD systems.])
43      ;;
44  esac
45
46  if test -f $1/soc${ac_solid_os}35.a; then
47    ac_solid_version=35
48    ac_solid_prefix=soc
49  elif test -f $1/scl${ac_solid_os}30.a; then
50    ac_solid_version=30
51    ac_solid_prefix=scl
52  elif test -f $1/scl${ac_solid_os}23.a; then
53    ac_solid_version=23
54    ac_solid_prefix=scl
55  fi
56
57dnl Check for the library files, and setup the ODBC_LIBS path.
58if test ! -f $1/lib${ac_solid_prefix}${ac_solid_os}${ac_solid_version}.so && \
59  test ! -f $1/lib${ac_solid_prefix}${ac_solid_os}${ac_solid_version}.a; then
60  dnl we have an error and should bail out, as we can't find the libs!
61  echo ""
62  echo "*********************************************************************"
63  echo "* Unable to locate $1/lib${ac_solid_prefix}${ac_solid_os}${ac_solid_version}.so or $1/lib${ac_solid_prefix}${ac_solid_os}${ac_solid_version}.a"
64  echo "* Please correct this by creating the following links and reconfiguring:"
65  echo "* $1/lib${ac_solid_prefix}${ac_solid_os}${ac_solid_version}.a -> $1/lib${ac_solid_prefix}${ac_solid_os}${ac_solid_version}.a"
66  echo "* $1/${ac_solid_prefix}${ac_solid_os}${ac_solid_version}.so -> $1/lib${ac_solid_prefix}${ac_solid_os}${ac_solid_version}.so"
67  echo "*********************************************************************"
68else
69  ODBC_LFLAGS=-L$1
70  ODBC_LIBS=-l${ac_solid_prefix}${ac_solid_os}${ac_solid_version}
71fi
72
73  AC_MSG_RESULT([$(echo $ODBC_LIBS | $SED -e 's!.*/!!')])
74])
75
76dnl
77dnl PHP_ODBC_FIND_EMPRESS_LIBS(libdir)
78dnl
79dnl Figure out which library file to link with for the Empress support.
80dnl
81AC_DEFUN([PHP_ODBC_FIND_EMPRESS_LIBS],[
82  AC_MSG_CHECKING([Empress library file])
83  ODBC_LIBS=$(echo $1/libempodbccl.so | cut -d' ' -f1)
84  if test ! -f $ODBC_LIBS; then
85    ODBC_LIBS=$(echo $1/libempodbccl.so | cut -d' ' -f1)
86  fi
87  AC_MSG_RESULT([$(echo $ODBC_LIBS | $SED -e 's!.*/!!')])
88])
89
90dnl
91dnl PHP_ODBC_FIND_EMPRESS_BCS_LIBS(libdir)
92dnl
93dnl Figure out which library file to link with for the Empress local access
94dnl support.
95dnl
96AC_DEFUN([PHP_ODBC_FIND_EMPRESS_BCS_LIBS],[
97  AC_MSG_CHECKING([Empress local access library file])
98  ODBCBCS_LIBS=$(echo $1/libempodbcbcs.a | cut -d' ' -f1)
99  if test ! -f $ODBCBCS_LIBS; then
100    ODBCBCS_LIBS=$(echo $1/libempodbcbcs.a | cut -d' ' -f1)
101  fi
102  AC_MSG_RESULT([$(echo $ODBCBCS_LIBS | $SED -e 's!.*/!!')])
103])
104
105dnl
106dnl configure options
107dnl
108
109PHP_ARG_WITH([odbcver],,
110  [AS_HELP_STRING([[--with-odbcver[=HEX]]],
111    [Force support for the passed ODBC version. A hex number is expected,
112    default 0x0350. Use the special value of 0 to prevent an explicit ODBCVER to
113    be defined.])],
114  [0x0350])
115
116AS_VAR_IF([ODBC_TYPE],, [
117PHP_ARG_WITH([adabas],
118  [for Adabas support],
119  [AS_HELP_STRING([[--with-adabas[=DIR]]],
120    [Include Adabas D support [/usr/local]])])
121
122  AS_VAR_IF([PHP_ADABAS], [no], [], [
123    AS_VAR_IF([PHP_ADABAS], [yes], [PHP_ADABAS=/usr/local])
124    PHP_ADD_INCLUDE([$PHP_ADABAS/incl])
125    PHP_ADD_LIBPATH([$PHP_ADABAS/$PHP_LIBDIR])
126    ODBC_OBJS="$PHP_ADABAS/$PHP_LIBDIR/odbclib.a"
127    ODBC_LIB="$abs_builddir/ext/odbc/libodbc_adabas.a"
128    $srcdir/build/shtool mkdir -f -p ext/odbc
129    rm -f "$ODBC_LIB"
130    cp "$ODBC_OBJS" "$ODBC_LIB"
131    PHP_ADD_LIBRARY([sqlptc])
132    PHP_ADD_LIBRARY([sqlrte])
133    PHP_ADD_LIBRARY_WITH_PATH([odbc_adabas], [$abs_builddir/ext/odbc])
134    ODBC_TYPE=adabas
135    ODBC_INCDIR=$PHP_ADABAS/incl
136    PHP_ODBC_CHECK_HEADER([sqlext.h])
137    AC_DEFINE([HAVE_ADABAS], [1],
138      [Define to 1 if the odbc extension uses the Adabas D.])
139  ])
140])
141
142AS_VAR_IF([ODBC_TYPE],, [
143PHP_ARG_WITH([sapdb],
144  [for SAP DB support],
145  [AS_HELP_STRING([[--with-sapdb[=DIR]]],
146    [Include SAP DB support [/usr/local]])])
147
148  AS_VAR_IF([PHP_SAPDB], [no], [], [
149    AS_VAR_IF([PHP_SAPDB], [yes], [PHP_SAPDB=/usr/local])
150    PHP_ADD_INCLUDE([$PHP_SAPDB/incl])
151    PHP_ADD_LIBPATH([$PHP_SAPDB/$PHP_LIBDIR])
152    PHP_ADD_LIBRARY([sqlod])
153    ODBC_TYPE=sapdb
154    AC_DEFINE([HAVE_SAPDB], [1],
155      [Define to 1 if the odbc extension uses the SAP DB.])
156  ])
157])
158
159AS_VAR_IF([ODBC_TYPE],, [
160PHP_ARG_WITH([solid],
161  [for Solid support],
162  [AS_HELP_STRING([[--with-solid[=DIR]]],
163    [Include Solid support [/usr/local/solid]])])
164
165  AS_VAR_IF([PHP_SOLID], [no], [], [
166    AS_VAR_IF([PHP_SOLID], [yes], [PHP_SOLID=/usr/local/solid])
167    ODBC_INCDIR=$PHP_SOLID/include
168    ODBC_LIBDIR=$PHP_SOLID/$PHP_LIBDIR
169    ODBC_CFLAGS=-I$ODBC_INCDIR
170    ODBC_TYPE=solid
171    if test -f $ODBC_LIBDIR/soc*35.a; then
172      AC_DEFINE([HAVE_SOLID_35], [1], [Define to 1 if Solid DB 3.5 is used.])
173    elif test -f $ODBC_LIBDIR/scl*30.a; then
174      AC_DEFINE([HAVE_SOLID_30], [1], [Define to 1 if Solid DB 3.0 is used.])
175    elif test -f $ODBC_LIBDIR/scl*23.a; then
176      AC_DEFINE([HAVE_SOLID], [1],
177        [Define to 1 if the odbc extension uses the Solid DB.])
178    fi
179    PHP_ODBC_FIND_SOLID_LIBS([$ODBC_LIBDIR])
180  ])
181])
182
183AS_VAR_IF([ODBC_TYPE],, [
184PHP_ARG_WITH([ibm-db2],
185  [for IBM DB2 support],
186  [AS_HELP_STRING([[--with-ibm-db2[=DIR]]],
187    [Include IBM DB2 support [/home/db2inst1/sqllib]])])
188
189  AS_VAR_IF([PHP_IBM_DB2], [no], [], [
190    AS_VAR_IF([PHP_IBM_DB2], [yes], [
191      ODBC_INCDIR=/home/db2inst1/sqllib/include
192      ODBC_LIBDIR=/home/db2inst1/sqllib/lib
193    ], [
194      ODBC_INCDIR=$PHP_IBM_DB2/include
195      ODBC_LIBDIR=$PHP_IBM_DB2/$PHP_LIBDIR
196    ])
197
198    PHP_ODBC_CHECK_HEADER([sqlcli1.h])
199
200    ODBC_CFLAGS=-I$ODBC_INCDIR
201    ODBC_LFLAGS=-L$ODBC_LIBDIR
202    ODBC_TYPE=ibm-db2
203    ODBC_LIBS=-ldb2
204
205    dnl Sanity check.
206    old_LIBS=$LIBS
207    LIBS="$ODBC_LFLAGS $ODBC_LIBS $LIBS"
208    AC_CHECK_FUNC([SQLExecute],
209      [AC_DEFINE([HAVE_IBMDB2], [1],
210        [Define to 1 if the odbc extension uses the IBM DB2.])],
211      [AC_MSG_FAILURE([
212ODBC build test failed. You need to source your DB2 environment before running
213PHP configure:
214# . \$IBM_DB2/db2profile
215])])
216    LIBS=$old_LIBS
217  ])
218])
219
220AS_VAR_IF([ODBC_TYPE],, [
221PHP_ARG_WITH([empress],
222  [for Empress support],
223  [AS_HELP_STRING([[--with-empress[=DIR]]],
224    [Include Empress support $EMPRESSPATH (Empress Version >= 8.60
225    required)])])
226
227  AS_VAR_IF([PHP_EMPRESS], [no], [], [
228    AS_VAR_IF([PHP_EMPRESS], [yes], [
229      ODBC_INCDIR=$EMPRESSPATH/include/odbc
230      ODBC_LIBDIR=$EMPRESSPATH/shlib
231    ], [
232      ODBC_INCDIR=$PHP_EMPRESS/include/odbc
233      ODBC_LIBDIR=$PHP_EMPRESS/shlib
234    ])
235    ODBC_CFLAGS=-I$ODBC_INCDIR
236    ODBC_LFLAGS=-L$ODBC_LIBDIR
237    ODBC_TYPE=empress
238    AC_DEFINE([HAVE_EMPRESS], [1],
239      [Define to 1 if the odbc extension uses the Empress.])
240    PHP_ODBC_FIND_EMPRESS_LIBS([$ODBC_LIBDIR])
241  ])
242])
243
244AS_VAR_IF([ODBC_TYPE],, [
245PHP_ARG_WITH([empress-bcs],
246  [for Empress local access support],
247  [AS_HELP_STRING([[--with-empress-bcs[=DIR]]],
248    [Include Empress Local Access support $EMPRESSPATH (Empress Version >=
249    8.60 required)])])
250
251  AS_VAR_IF([PHP_EMPRESS_BCS], [no], [], [
252    AS_VAR_IF([PHP_EMPRESS_BCS], [yes], [
253      ODBC_INCDIR=$EMPRESSPATH/include/odbc
254      ODBC_LIBDIR=$EMPRESSPATH/shlib
255    ], [
256      ODBC_INCDIR=$PHP_EMPRESS_BCS/include/odbc
257      ODBC_LIBDIR=$PHP_EMPRESS_BCS/shlib
258    ])
259    CC="empocc -bcs";export CC;
260    LD="empocc -bcs";export LD;
261    ODBC_CFLAGS=-I$ODBC_INCDIR
262    ODBC_LFLAGS=-L$ODBC_LIBDIR
263    LIST=$(empocc -listlines -bcs -o a a.c)
264
265    NEWLIST=
266    for I in $LIST
267    do
268      case $I in
269        $EMPRESSPATH/odbccl/lib/* | \
270        $EMPRESSPATH/rdbms/lib/* | \
271        $EMPRESSPATH/common/lib/*)
272              NEWLIST="$NEWLIST $I"
273              ;;
274      esac
275    done
276    ODBC_LIBS="-lempphpbcs -lms -lmscfg -lbasic -lbasic_os -lnlscstab -lnlsmsgtab -lm -ldl -lcrypt"
277    ODBC_TYPE=empress-bcs
278    AC_DEFINE([HAVE_EMPRESS], [1],
279      [Define to 1 if the odbc extension uses the Empress.])
280    PHP_ODBC_FIND_EMPRESS_BCS_LIBS([$ODBC_LIBDIR])
281  ])
282])
283
284AS_VAR_IF([ODBC_TYPE],, [
285PHP_ARG_WITH([custom-odbc],
286  [for a custom ODBC support],
287  [AS_HELP_STRING([[--with-custom-odbc[=DIR]]],
288    [Include user defined ODBC support. DIR is ODBC install base directory
289    [/usr/local]. Make sure to define CUSTOM_ODBC_LIBS and have some odbc.h in
290    your include dirs. For example, you should define following for Sybase SQL
291    Anywhere 5.5.00 on QNX, prior to running this configure script:
292    CPPFLAGS="-DODBC_QNX -DSQLANY_BUG" LDFLAGS=-lunix
293    CUSTOM_ODBC_LIBS="-ldblib -lodbc"])])
294
295  AS_VAR_IF([PHP_CUSTOM_ODBC], [no], [], [
296    AS_VAR_IF([PHP_CUSTOM_ODBC], [yes], [PHP_CUSTOM_ODBC=/usr/local])
297    ODBC_INCDIR=$PHP_CUSTOM_ODBC/include
298    ODBC_LIBDIR=$PHP_CUSTOM_ODBC/$PHP_LIBDIR
299    ODBC_LFLAGS=-L$ODBC_LIBDIR
300    ODBC_CFLAGS=-I$ODBC_INCDIR
301    ODBC_LIBS=$CUSTOM_ODBC_LIBS
302    ODBC_TYPE=custom-odbc
303    AC_DEFINE([HAVE_CODBC], [1],
304      [Define to 1 if the odbc extension uses custom ODBC installation.])
305  ])
306])
307
308AS_VAR_IF([ODBC_TYPE],, [
309PHP_ARG_WITH([iodbc],
310  [whether to build with iODBC support],
311  [AS_HELP_STRING([--with-iodbc],
312    [Include iODBC support])])
313
314  AS_VAR_IF([PHP_IODBC], [no], [], [
315    PKG_CHECK_MODULES([ODBC], [libiodbc])
316    PHP_EVAL_INCLINE([$ODBC_CFLAGS])
317    ODBC_TYPE=iodbc
318    AC_DEFINE([HAVE_IODBC], [1],
319      [Define to 1 if the odbc extension uses the iODBC.])
320  ])
321])
322
323AS_VAR_IF([ODBC_TYPE],, [
324PHP_ARG_WITH([esoob],
325  [for Easysoft ODBC-ODBC Bridge support],
326  [AS_HELP_STRING([[--with-esoob[=DIR]]],
327    [Include Easysoft OOB support [/usr/local/easysoft/oob/client]])])
328
329  AS_VAR_IF([PHP_ESOOB], [no], [], [
330    AS_VAR_IF([PHP_ESOOB], [yes], [PHP_ESOOB=/usr/local/easysoft/oob/client])
331    ODBC_INCDIR=$PHP_ESOOB/include
332    ODBC_LIBDIR=$PHP_ESOOB/$PHP_LIBDIR
333    ODBC_LFLAGS=-L$ODBC_LIBDIR
334    ODBC_CFLAGS=-I$ODBC_INCDIR
335    ODBC_LIBS=-lesoobclient
336    ODBC_TYPE=esoob
337    AC_DEFINE([HAVE_ESOOB], [1],
338      [Define to 1 if the odbc extension uses the Easysoft OOB.])
339  ])
340])
341
342AS_VAR_IF([ODBC_TYPE],, [
343PHP_ARG_WITH([unixODBC],
344  [whether to build with unixODBC support],
345  [AS_HELP_STRING([[--with-unixODBC[=DIR]]],
346    [Include unixODBC support. Use PKG_CONFIG_PATH (or ODBC_CFLAGS and
347    ODBC_LIBS) environment variables, or alternatively the optional DIR argument
348    to customize where to look for the unixODBC library.])])
349
350  AS_VAR_IF([PHP_UNIXODBC], [no], [], [
351    AS_VAR_IF([PHP_UNIXODBC], [yes], [
352      PKG_CHECK_MODULES([ODBC], [odbc])
353      PHP_EVAL_INCLINE([$ODBC_CFLAGS])
354    ], [
355      dnl keep old DIR way for old version without libodbc.pc
356      ODBC_INCDIR=$PHP_UNIXODBC/include
357      ODBC_LIBDIR=$PHP_UNIXODBC/$PHP_LIBDIR
358      ODBC_LFLAGS=-L$ODBC_LIBDIR
359      ODBC_CFLAGS=-I$ODBC_INCDIR
360      ODBC_LIBS=-lodbc
361      PHP_ODBC_CHECK_HEADER([sqlext.h])
362      AC_MSG_NOTICE([Using unixODBC in $PHP_UNIXODBC])
363    ])
364    ODBC_TYPE=unixODBC
365    AC_DEFINE([HAVE_UNIXODBC], [1],
366      [Define to 1 if the odbc extension uses the unixODBC.])
367  ])
368])
369
370AS_VAR_IF([ODBC_TYPE],, [
371PHP_ARG_WITH([dbmaker],
372  [for DBMaker support],
373  [AS_HELP_STRING([[--with-dbmaker[=DIR]]],
374    [Include DBMaker support])])
375
376  AS_VAR_IF([PHP_DBMAKER], [no], [], [
377    AS_VAR_IF([PHP_DBMAKER], [yes], [
378      dnl Find dbmaker home directory
379      DBMAKER_HOME=$(grep "^dbmaker:" /etc/passwd | $AWK -F: '{print $6}')
380
381      dnl check DBMaker version (from 5.0 to 2.0)
382      DBMAKER_VERSION=5.0
383
384      while test ! -d $DBMAKER_HOME/$DBMAKER_VERSION && test "$DBMAKER_VERSION" != "2.9"; do
385        DM_VER=$(echo $DBMAKER_VERSION | $SED -e 's/\.//' | $AWK '{ print $1-1;}')
386        MAJOR_V=$(echo $DM_VER | $AWK '{ print $1/10; }'  | $AWK -F. '{ print $1; }')
387        MINOR_V=$(echo $DM_VER | $AWK '{ print $1%10; }')
388        DBMAKER_VERSION=$MAJOR_V.$MINOR_V
389      done
390
391      AS_VAR_IF([DBMAKER_VERSION], [2.9],
392        [PHP_DBMAKER=$DBMAKER_HOME],
393        [PHP_DBMAKER=$DBMAKER_HOME/$DBMAKER_VERSION])
394    ])
395
396    ODBC_INCDIR=$PHP_DBMAKER/include
397    ODBC_LIBDIR=$PHP_DBMAKER/$PHP_LIBDIR
398    ODBC_CFLAGS=-I$ODBC_INCDIR
399    ODBC_LFLAGS=-L$ODBC_LIBDIR
400    ODBC_LIBS="-ldmapic -lc"
401    ODBC_TYPE=dbmaker
402
403    AC_DEFINE([HAVE_DBMAKER], [1],
404      [Define to 1 if the odbc extension uses the DBMaker.])
405
406    AS_VAR_IF([ext_shared], [yes], [ODBC_LIBS="-ldmapic -lc -lm"], [
407      PHP_ADD_LIBRARY_WITH_PATH([dmapic], [$ODBC_LIBDIR])
408      PHP_ADD_INCLUDE([$ODBC_INCDIR])
409    ])
410  ])
411])
412
413AH_TEMPLATE([ODBCVER], [The highest supported ODBC version.])
414AS_VAR_IF([PHP_ODBCVER], [no],
415  [AC_DEFINE([ODBCVER], [0x0350])],
416  [AS_VAR_IF([PHP_ODBCVER], [0],,
417    [AC_DEFINE_UNQUOTED([ODBCVER], [$PHP_ODBCVER])])])
418
419dnl Extension setup
420if test -n "$ODBC_TYPE"; then
421  AS_VAR_IF([ODBC_TYPE], [dbmaker],, [
422    PHP_EVAL_LIBLINE([$ODBC_LFLAGS $ODBC_LIBS], [ODBC_SHARED_LIBADD])
423    AS_VAR_IF([ODBC_TYPE], [solid],,
424      [AC_DEFINE([HAVE_SQLDATASOURCES], [1],
425        [Define to 1 if ODBC library has 'SQLDataSources', as a function or
426        macro.])])
427  ])
428
429  AC_DEFINE([HAVE_UODBC], [1],
430    [Define to 1 if the PHP extension 'odbc' is available.])
431  PHP_SUBST([ODBC_SHARED_LIBADD])
432  AC_SUBST([ODBC_CFLAGS])
433  AC_SUBST([ODBC_LIBS])
434  AC_SUBST([ODBC_LFLAGS])
435  AC_SUBST([ODBC_TYPE])
436
437  PHP_NEW_EXTENSION([odbc],
438    [php_odbc.c odbc_utils.c],
439    [$ext_shared],,
440    [$ODBC_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
441else
442  AC_MSG_CHECKING([for any ODBC driver support])
443  AC_MSG_RESULT([no])
444fi
445