summaryrefslogtreecommitdiff
path: root/ext/mssql/config.m4
blob: 4231bb360a7556c303f622211abae869bf216700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
dnl
dnl $Id$
dnl

PHP_ARG_WITH(mssql,for MSSQL support via FreeTDS,
[  --with-mssql[=DIR]      Include MSSQL-DB support.  DIR is the FreeTDS home
                          directory [/usr/local/freetds]])

if test "$PHP_MSSQL" != "no"; then

  if test "$PHP_MSSQL" = "yes"; then
    for i in /usr/local /usr; do
      if test -f $i/include/sybdb.h; then
        FREETDS_INSTALLATION_DIR=$i
        FREETDS_INCLUDE_DIR=$i/include
        break
      elif test -f $i/include/freetds/sybdb.h; then
        FREETDS_INSTALLATION_DIR=$i
        FREETDS_INCLUDE_DIR=$i/include/freetds
        break
      fi
    done

    if test -z "$FREETDS_INSTALLATION_DIR"; then
      AC_MSG_ERROR(Cannot find FreeTDS in known installation directories)
    fi

  elif test "$PHP_MSSQL" != "no"; then

    if test -f $PHP_MSSQL/include/sybdb.h; then
      FREETDS_INSTALLATION_DIR=$PHP_MSSQL
      FREETDS_INCLUDE_DIR=$PHP_MSSQL/include
    elif test -f $PHP_MSSQL/include/freetds/sybdb.h; then
      FREETDS_INSTALLATION_DIR=$PHP_MSSQL
      FREETDS_INCLUDE_DIR=$PHP_MSSQL/include/freetds
    else
      AC_MSG_ERROR(Directory $PHP_MSSQL is not a FreeTDS installation directory)
    fi
  fi  

  if test ! -r "$FREETDS_INSTALLATION_DIR/$PHP_LIBDIR/libsybdb.a" && test ! -r "$FREETDS_INSTALLATION_DIR/$PHP_LIBDIR/libsybdb.so"; then
     AC_MSG_ERROR(Could not find $FREETDS_INSTALLATION_DIR/$PHP_LIBDIR/libsybdb.[a|so])
  fi

  PHP_ADD_INCLUDE($FREETDS_INCLUDE_DIR)
  PHP_ADD_LIBRARY_WITH_PATH(sybdb, $FREETDS_INSTALLATION_DIR/$PHP_LIBDIR, MSSQL_SHARED_LIBADD)

  PHP_NEW_EXTENSION(mssql, php_mssql.c, $ext_shared)
  AC_CHECK_LIB(dnet_stub, dnet_addr,
     [ PHP_ADD_LIBRARY_WITH_PATH(dnet_stub,,MSSQL_SHARED_LIBADD)
        AC_DEFINE(HAVE_LIBDNET_STUB,1,[ ])
     ])
  AC_DEFINE(HAVE_MSSQL,1,[ ])
  AC_DEFINE(HAVE_FREETDS,1,[ ])
  PHP_SUBST(MSSQL_SHARED_LIBADD)
fi