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