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