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