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