Do not use AC_CHECK_LIB anyway. Use AC_LINK_IFELSE instead.
[m4-moved-to-github.git] / yaz.m4
1 # Use this m4 function for autoconf if you use YAZ in your own
2 # configure script.
3
4 dnl ----- Setup Docbook documentation for YAZ
5 AC_DEFUN([YAZ_DOC],
6 [
7 dnl autoconf < 2.60 does not define docdir
8 if test -n "$docdir"; then
9         docdir="${datadir}/doc/${PACKAGE}"
10         AC_SUBST([docdir])
11 fi
12 AC_SUBST(XSLTPROC_COMPILE)
13 XSLTPROC_COMPILE='xsltproc -path ".:$(srcdir)"'
14 AC_SUBST(MAN_COMPILE)
15 MAN_COMPILE='$(XSLTPROC_COMPILE) $(srcdir)/common/id.man.xsl'
16 AC_SUBST(HTML_COMPILE)
17 HTML_COMPILE='$(XSLTPROC_COMPILE) $(srcdir)/common/id.htmlhelp.xsl'
18 AC_SUBST(TKL_COMPILE)
19 TKL_COMPILE='$(XSLTPROC_COMPILE) $(srcdir)/common/id.tkl.xsl'
20
21 AC_SUBST(DTD_DIR)       
22 AC_ARG_WITH(docbook-dtd,[[  --with-docbook-dtd=DIR  use docbookx.dtd in DIR]],
23 [
24         if test -f "$withval/docbookx.dtd"; then
25                 DTD_DIR=$withval
26         fi
27 ],[
28         AC_MSG_CHECKING(for docbookx.dtd)
29         DTD_DIR=""
30         for d in /usr/lib/sgml/dtd/docbook-xml \
31                  /usr/share/sgml/docbook/dtd/4.2 \
32                  /usr/share/sgml/docbook/dtd/xml/4.* \
33                  /usr/share/sgml/docbook/xml-dtd-4.* \
34                 /usr/local/share/xml/docbook/4.*
35         do
36                 if test -f $d/docbookx.dtd; then
37                         DTD_DIR=$d
38                 fi
39         done
40         if test -z "$DTD_DIR"; then
41                 AC_MSG_RESULT(Not found)
42         else
43                 AC_MSG_RESULT($d)
44         fi
45 ])
46 AC_SUBST(DSSSL_DIR)
47 AC_ARG_WITH(docbook-dsssl,[[  --with-docbook-dsssl=DIR use Docbook DSSSL in DIR/{html,print}/docbook.dsl]],
48 [
49         if test -f "$withval/html/docbook.dsl"; then
50                 DSSSL_DIR=$withval
51         fi
52 ],[
53         AC_MSG_CHECKING(for docbook.dsl)
54         DSSSL_DIR=""
55         for d in /usr/share/sgml/docbook/stylesheet/dsssl/modular \
56                 /usr/share/sgml/docbook/dsssl-stylesheets-1.* \
57                 /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh \
58                 /usr/local/share/sgml/docbook/dsssl/modular
59         do
60                 if test -f $d/html/docbook.dsl; then
61                         AC_MSG_RESULT($d)
62                         DSSSL_DIR=$d
63                         break
64                 fi
65         done
66         if test -z "$DSSSL_DIR"; then
67                 AC_MSG_RESULT(Not found)
68         fi
69 ])
70 AC_SUBST(XSL_DIR)
71 AC_ARG_WITH(docbook-xsl,[[  --with-docbook-xsl=DIR  use Docbook XSL in DIR/{htmlhelp,xhtml}]],
72 [
73         if test -f "$withval/htmlhelp/htmlhelp.xsl"; then
74                 XSL_DIR=$withval
75         fi
76 ],[
77         AC_MSG_CHECKING(for htmlhelp.xsl)
78         for d in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh \
79                 /usr/local/share/xsl/docbook \
80                 /usr/share/sgml/docbook/xsl-stylesheets-1.* 
81         do
82                 if test -f $d/htmlhelp/htmlhelp.xsl; then
83                         AC_MSG_RESULT($d)
84                         XSL_DIR=$d
85                         break
86                 fi
87         done
88         if test -z "$XSL_DIR"; then
89                 AC_MSG_RESULT(Not found)
90         fi
91 ])
92 ]) 
93
94 AC_DEFUN([YAZ_INIT],
95 [
96         AC_SUBST(YAZLIB)
97         AC_SUBST(YAZLALIB)
98         AC_SUBST(YAZINC)
99         AC_SUBST(YAZVERSION)
100         yazconfig=NONE
101         yazpath=NONE
102         AC_ARG_WITH(yaz, [  --with-yaz=DIR          use yaz-config in DIR (example /home/yaz-1.7)], [yazpath=$withval])
103         if test "x$yazpath" != "xNONE"; then
104                 yazconfig=$yazpath/yaz-config
105         else
106                 if test "x$srcdir" = "x"; then
107                         yazsrcdir=.
108                 else
109                         yazsrcdir=$srcdir
110                 fi
111                 for i in ${yazsrcdir}/../../yaz ${yazsrcdir}/../yaz-* ${yazsrcdir}/../yaz; do
112                         if test -d $i; then
113                                 if test -r $i/yaz-config; then
114                                         yazconfig=$i/yaz-config
115                                 fi
116                         fi
117                 done
118                 if test "x$yazconfig" = "xNONE"; then
119                         AC_PATH_PROG(yazconfig, yaz-config, NONE)
120                 fi
121         fi
122         AC_MSG_CHECKING(for YAZ)
123         if $yazconfig --version >/dev/null 2>&1; then
124                 YAZLIB=`$yazconfig --libs $1`
125                 # if this is empty, it's a simple version YAZ 1.6 script
126                 # so we have to source it instead...
127                 if test "X$YAZLIB" = "X"; then
128                         . $yazconfig
129                 else
130                         YAZLALIB=`$yazconfig --lalibs $1`
131                         YAZINC=`$yazconfig --cflags $1`
132                         YAZVERSION=`$yazconfig --version`
133                 fi
134                 AC_MSG_RESULT([$yazconfig])
135         else
136                 AC_MSG_RESULT(Not found)
137                 YAZVERSION=NONE
138         fi
139         if test "X$YAZVERSION" != "XNONE"; then
140                 AC_MSG_CHECKING([for YAZ version])
141                 AC_MSG_RESULT([$YAZVERSION])
142                 if test "$2"; then
143                         have_yaz_version=`echo "$YAZVERSION" | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
144                         req_yaz_version=`echo "$2" | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
145                         if test "$have_yaz_version" -lt "$req_yaz_version"; then
146                                 AC_MSG_ERROR([$YAZVERSION. Requires YAZ $2 or later])
147                         fi
148                         if test "$req_yaz_version" -gt "2000028"; then
149                                 YAZINC="$YAZINC -DYAZ_USE_NEW_LOG=1"
150                         fi
151                 fi
152         fi
153 ]) 
154