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