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