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