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