summaryrefslogtreecommitdiff
path: root/ext/domxml/config.m4
blob: d2e874d059dc8530a94180deaff498808d88edfc (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
dnl $Id$
dnl config.m4 for extension domxml

AC_DEFUN(PHP_DOM_CHECK_VERSION,[
  old_CPPFLAGS=$CPPFLAGS
  CPPFLAGS="-I$DOMXML_DIR/include"
  AC_MSG_CHECKING(for libxml version)
  AC_EGREP_CPP(yes,[
  #include <libxml/xmlversion.h>
  #if LIBXML_VERSION >= 20207
  yes
  #endif
  ],[
    AC_MSG_RESULT(>= 2.2.7)
  ],[
    AC_MSG_ERROR(libxml version 2.2.7 or greater required.)
  ])
  CPPFLAGS=$old_CPPFLAGS
])

PHP_ARG_WITH(dom, for DOM support,
[  --with-dom[=DIR]        Include DOM support (requires libxml >= 2.2.7).
                          DIR is the libxml install directory,
                          defaults to /usr.])

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

  if test -r $PHP_DOM/include/libxml/tree.h; then
    DOMXML_DIR=$PHP_DOM
  else
    AC_MSG_CHECKING(for DOM in default path)
    for i in /usr/local /usr; do
      if test -r $i/include/libxml/tree.h; then
        DOMXML_DIR=$i
        AC_MSG_RESULT(found in $i)
      fi
    done
  fi

  if test -z "$DOMXML_DIR"; then
    AC_MSG_RESULT(not found)
    AC_MSG_ERROR(Please reinstall the libxml >= 2.2.7 distribution)
  fi

  PHP_DOM_CHECK_VERSION

  AC_ADD_INCLUDE($DOMXML_DIR/include)

  if test -f $DOMXML_DIR/lib/libxml2.a -o -f $DOMXML_DIR/lib/libxml2.s? ; then
    DOM_LIBNAME="xml2"
  else
    DOM_LIBNAME="xml"
  fi

  PHP_SUBST(DOMXML_SHARED_LIBADD)
  AC_ADD_LIBRARY_WITH_PATH($DOM_LIBNAME, $DOMXML_DIR/lib, DOMXML_SHARED_LIBADD)

  if test $HAVE_ZLIB; then
    AC_MSG_CHECKING([for zlib (needed by DOM support)])
    AC_ARG_WITH(zlib-dir,
    [  --with-zlib-dir[=DIR]   zlib dir for libxml or include zlib support],[
     AC_MSG_RESULT( )
     if test -z $withval; then
       withval="/usr/local"
     fi
     LIBS="$LIBS -L$withval/lib -lz"
     AC_CHECK_LIB(z,deflate, ,[AC_MSG_RESULT(no)],)
     AC_ADD_LIBRARY_WITH_PATH(z, $withval/lib)
    ],[
     AC_MSG_RESULT(no)
     AC_MSG_WARN(If configure fails try --with-zlib=<DIR>)
    ])
  else
    echo "checking for libz needed by libxml ... already zlib support"
    LIBS="$LIBS -lz"
  fi

  AC_DEFINE(HAVE_DOMXML,1,[ ])
  AC_ADD_LIBRARY(z)

  PHP_EXTENSION(domxml, $ext_shared)
fi