summaryrefslogtreecommitdiff
path: root/ext/pgsql/config.m4
blob: 4e9aafbf35573e2e846993b73a5d746b2b6fc748 (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
57
58
59
60
61
dnl $Id$

AC_MSG_CHECKING(for PostgresSQL support)
AC_ARG_WITH(pgsql,
[  --with-pgsql[=DIR]      Include PostgresSQL support.  DIR is the PostgresSQL
                          base install directory, defaults to /usr/local/pgsql.
			  Set DIR to "shared" to build as a dl, or "shared,DIR" 
                          to build as a dl and still specify DIR.],
[
  case $withval in
    shared)
      shared=yes
      withval=yes
      ;;
    shared,*)
      shared=yes
      withval=`echo $withval | sed -e 's/^shared,//'`      
      ;;
    *)
      shared=no
      ;;
  esac
  if test "$withval" != "no"; then
    if test "$withval" = "yes"; then
      PGSQL_INCDIR=/usr/local/pgsql/include
      PGSQL_LIBDIR=/usr/local/pgsql/lib
    else
      PGSQL_INCDIR=$withval/include
      test -d $withval/include/pgsql && PGSQL_INCDIR=$withval/include/pgsql
      test -d $withval/include/postgresql && PGSQL_INCDIR=$withval/include/postgresql
      PGSQL_LIBDIR=$withval/lib
      test -d $withval/lib/pgsql && PGSQL_LIBDIR=$withval/lib/pgsql
    fi
    PGSQL_INCLUDE=-I$PGSQL_INCDIR
    PGSQL_LFLAGS=-L$PGSQL_LIBDIR
    PGSQL_LIBS=-lpq

    old_CFLAGS=$CFLAGS
    CFLAGS="$CFLAGS $PGSQL_INCLUDE"
    AC_DEFINE(HAVE_PGSQL)
    if test "$shared" = "yes"; then
      AC_MSG_RESULT(yes (shared))
      PGSQL_SHARED="pgsql.la"
    else 
      AC_MSG_RESULT(yes (static))
      AC_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR)
      AC_ADD_INCLUDE($PGSQL_INCDIR)
      PGSQL_STATIC="libphpext_pgsql.la"
    fi
    AC_CHECK_FUNC(PQcmdTuples,AC_DEFINE(HAVE_PQCMDTUPLES))
    CFLAGS=$old_CFLAGS
    PHP_EXTENSION(pgsql,$shared)
  else
    AC_MSG_RESULT(no)
  fi
],[
  AC_MSG_RESULT(no)
])
PHP_SUBST(PGSQL_LIBS)
PHP_SUBST(PGSQL_LFLAGS)
PHP_SUBST(PGSQL_INCLUDE)