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