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