Check for xsltSaveResultToString presence.
[m4-moved-to-github.git] / yaz_libxml2.m4
1 AC_DEFUN([YAZ_LIBXML2],[
2 AC_PATH_PROG(pkgconfigpath, pkg-config, NONE)
3 xml2dir=default
4 XML2_VER=""
5 AC_ARG_WITH(xml2,[[  --with-xml2[=PREFIX]    use libxml2 in PREFIX]],xml2dir=$withval)
6 dnl -- if no PREFIX or not specified we just search in default locations
7 dnl -- try pkg-config. If not found, use xml2-config
8 if test "$xml2dir" = "yes" -o "$xml2dir" = "default"; then
9         if test "$pkgconfigpath" != "NONE"; then
10                 if $pkgconfigpath --exists libxml-2.0; then
11                         pkgmodule="libxml-2.0"
12                 fi
13         fi
14         if test -z "$pkgmodule"; then
15                 for d in /usr /usr/local; do
16                         if test -x $d/bin/xml2-config; then
17                                 xml2dir=$d
18                         fi
19                 done
20         fi
21 fi
22 dnl --- do the real check (pkg-config, xml2-config, not-found)
23 if test "$xml2dir" != "no"; then
24         AC_MSG_CHECKING(for libXML2)
25         if test "$pkgmodule"; then
26                 XML2_LIBS=`$pkgconfigpath --libs $pkgmodule`
27                 XML2_CFLAGS=`$pkgconfigpath --cflags $pkgmodule`
28                 XML2_VER=`$pkgconfigpath --modversion $pkgmodule`
29                 AC_MSG_RESULT($XML2_VER)
30                 AC_DEFINE(HAVE_XML2)
31         elif test -x $xml2dir/bin/xml2-config; then
32                 XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
33                 XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
34                 XML2_VER=`$xml2dir/bin/xml2-config --version`
35                 AC_MSG_RESULT($XML2_VER)
36                 AC_DEFINE(HAVE_XML2)
37         else
38                 AC_MSG_RESULT(Not found)
39
40                 if test "$xml2dir" = "default"; then
41                         AC_MSG_WARN([libxml2 development libraries not found.])
42                         AC_MSG_WARN([There will be no support for SRU.])
43                 else
44                         AC_MSG_ERROR([libxml2 development libraries not found.])
45                 fi
46         fi
47 fi
48 ])
49
50 AC_DEFUN([YAZ_LIBXSLT],[
51 xsltdir=default
52 pkgmodule=""
53 XSLT_VER=""
54 AC_ARG_WITH(xslt,[[  --with-xslt[=PREFIX]    use libXSLT in PREFIX]],xsltdir=$withval)
55
56 dnl -- if no PREFIX or not specified we just search in default locations
57 dnl -- try pkg-config. If not found, use xslt-config
58 if test "$xsltdir" = "yes" -o "$xsltdir" = "default"; then
59         if test "$pkgconfigpath" != "NONE"; then
60                 # pkg-config on woody reports bad CFLAGS which does 
61                 # not include libxml2 CFLAGS, so avoid it..
62                 if $pkgconfigpath --atleast-version 1.1.0 libxslt; then
63                         pkgmodule="libxslt"
64                 fi
65         fi
66         if test -z "$pkgmodule"; then
67                 for d in /usr /usr/local; do
68                         if test -x $d/bin/xslt-config; then
69                                 xsltdir=$d
70                         fi
71                 done
72         fi
73 fi
74 dnl --- do the real check (pkg-config, xslt-config, not-found)
75 if test "$xsltdir" != "no"; then
76         AC_MSG_CHECKING(for libXSLT)
77         if test "$pkgmodule"; then
78                 XML2_LIBS=`$pkgconfigpath --libs $pkgmodule`
79                 XML2_CFLAGS=`$pkgconfigpath --cflags $pkgmodule`
80                 XSLT_VER=`$pkgconfigpath --modversion $pkgmodule`
81                 AC_MSG_RESULT($XSLT_VER)
82                 AC_DEFINE(HAVE_XSLT)
83         elif test -x $xsltdir/bin/xslt-config; then
84                 XML2_LIBS=`$xsltdir/bin/xslt-config --libs`
85                 XML2_CFLAGS=`$xsltdir/bin/xslt-config --cflags`
86                 XSLT_VER=`$xsltdir/bin/xslt-config --version`
87                 AC_MSG_RESULT($XSLT_VER)
88                 AC_DEFINE(HAVE_XSLT)
89         else
90                 AC_MSG_RESULT(Not found)
91
92                 if test "$xsltdir" = "default"; then
93                         AC_MSG_WARN([libXSLT development libraries not found.])
94                 else
95                         AC_MSG_ERROR([libXSLT development libraries not found.])
96                 fi
97         fi
98 fi
99 ])
100
101 dnl -- get libEXSLT. xslt-config is no good. So use pkg-config only
102 AC_DEFUN([YAZ_LIBEXSLT],[
103 exsltdir=default
104 pkgmodule=""
105 EXSLT_VER=""
106 AC_ARG_WITH(exslt,[[  --with-exslt[=PREFIX]   use libEXSLT in PREFIX]],exsltdir=$withval)
107 if test "$exsltdir" = "yes" -o "$exsltdir" = "default"; then
108         if test "$pkgconfigpath" != "NONE"; then
109                 if $pkgconfigpath --exists libexslt; then
110                         pkgmodule="libexslt"
111                 fi
112         fi
113 fi
114 if test "$exsltdir" != "no"; then
115         AC_MSG_CHECKING(for libEXSLT)
116         if test "$pkgmodule"; then
117                 XML2_LIBS=`$pkgconfigpath --libs $pkgmodule`
118                 XML2_CFLAGS=`$pkgconfigpath --cflags $pkgmodule`
119                 EXSLT_VER=`$pkgconfigpath --modversion $pkgmodule`
120                 AC_MSG_RESULT($EXSLT_VER)
121                 AC_DEFINE(HAVE_EXSLT)
122         else
123                 AC_MSG_RESULT(Not found)
124         
125                 if test "$pkgconfigpath" = "NONE"; then
126                         extra="libEXSLT not enabled. pkg-config not found."
127                 else
128                         extra="libEXSLT development libraries not found."
129                 fi
130
131                 if test "$exsltdir" = "default"; then
132                         AC_MSG_WARN([$extra])
133                 else
134                         AC_MSG_ERROR([$extra])
135                 fi
136         fi
137 fi
138 OLIBS=$LIBS
139 LIBS="$LIBS $XML2_LIBS"
140 AC_CHECK_FUNCS([xsltSaveResultToString])
141 LIBS=$OLIBS
142 ])