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