xref: /PHP-7.3/ext/pdo_dblib/config.m4 (revision 902d39a3)
1dnl config.m4 for extension pdo_dblib
2
3PHP_ARG_WITH(pdo-dblib, for PDO_DBLIB support via FreeTDS,
4[  --with-pdo-dblib[=DIR]    PDO: DBLIB-DB support.  DIR is the FreeTDS home directory])
5
6if test "$PHP_PDO_DBLIB" != "no"; then
7
8  if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
9    AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
10  fi
11
12  if test "$PHP_PDO_DBLIB" = "yes"; then
13
14    for i in /usr/local /usr; do
15      if test -f $i/include/sybdb.h; then
16        PDO_FREETDS_INSTALLATION_DIR=$i
17        PDO_FREETDS_INCLUDE_DIR=$i/include
18        break
19      elif test -f $i/include/freetds/sybdb.h; then
20        PDO_FREETDS_INSTALLATION_DIR=$i
21        PDO_FREETDS_INCLUDE_DIR=$i/include/freetds
22        break;
23      fi
24    done
25
26    if test -z "$PDO_FREETDS_INSTALLATION_DIR"; then
27      AC_MSG_ERROR(Cannot find FreeTDS in known installation directories)
28    fi
29
30  elif test "$PHP_PDO_DBLIB" != "no"; then
31
32    if test -f $PHP_PDO_DBLIB/include/sybdb.h; then
33      PDO_FREETDS_INSTALLATION_DIR=$PHP_PDO_DBLIB
34      PDO_FREETDS_INCLUDE_DIR=$PHP_PDO_DBLIB/include
35    elif test -f $PHP_PDO_DBLIB/include/freetds/sybdb.h; then
36      PDO_FREETDS_INSTALLATION_DIR=$PHP_PDO_DBLIB
37      PDO_FREETDS_INCLUDE_DIR=$PHP_PDO_DBLIB/include/freetds
38    else
39      AC_MSG_ERROR(Directory $PHP_PDO_DBLIB is not a FreeTDS installation directory)
40    fi
41  fi
42
43  if test "x$PHP_LIBDIR" = "x" ; then
44    PHP_LIBDIR=lib
45  fi
46
47  if test ! -r "$PDO_FREETDS_INSTALLATION_DIR/$PHP_LIBDIR/libsybdb.a" && test ! -r "$PDO_FREETDS_INSTALLATION_DIR/$PHP_LIBDIR/libsybdb.so"; then
48     AC_MSG_ERROR(Could not find $PDO_FREETDS_INSTALLATION_DIR/$PHP_LIBDIR/libsybdb.[a|so])
49  fi
50
51  PHP_ADD_INCLUDE($PDO_FREETDS_INCLUDE_DIR)
52  PHP_ADD_LIBRARY_WITH_PATH(sybdb, $PDO_FREETDS_INSTALLATION_DIR/$PHP_LIBDIR, PDO_DBLIB_SHARED_LIBADD)
53
54  ifdef([PHP_CHECK_PDO_INCLUDES],
55  [
56    PHP_CHECK_PDO_INCLUDES
57  ],[
58    AC_MSG_CHECKING([for PDO includes])
59    if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
60      pdo_cv_inc_path=$abs_srcdir/ext
61    elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
62      pdo_cv_inc_path=$abs_srcdir/ext
63    elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then
64      pdo_cv_inc_path=$phpincludedir/ext
65    else
66      AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
67    fi
68    AC_MSG_RESULT($pdo_cv_inc_path)
69  ])
70
71  PDO_DBLIB_DEFS="-DPDO_DBLIB_FLAVOUR=\\\"freetds\\\""
72  PHP_NEW_EXTENSION(pdo_dblib, pdo_dblib.c dblib_driver.c dblib_stmt.c, $ext_shared,,-I$pdo_cv_inc_path $PDO_DBLIB_DEFS)
73  AC_CHECK_LIB(dnet_stub, dnet_addr,
74     [ PHP_ADD_LIBRARY_WITH_PATH(dnet_stub,,PDO_DBLIB_SHARED_LIBADD)
75        AC_DEFINE(HAVE_LIBDNET_STUB,1,[ ])
76     ])
77  AC_DEFINE(HAVE_PDO_DBLIB,1,[ ])
78  AC_DEFINE(HAVE_FREETDS,1,[ ])
79  PHP_SUBST(PDO_DBLIB_SHARED_LIBADD)
80
81  ifdef([PHP_ADD_EXTENSION_DEP],
82  [
83    PHP_ADD_EXTENSION_DEP(pdo_dblib, pdo)
84  ])
85fi
86