New Debian Policy
[yaz-moved-to-github.git] / yaz.m4
1 ## $Id: yaz.m4,v 1.6 2004-02-05 14:15:42 adam Exp $
2 ## 
3 # Use this m4 funciton for autoconf if you use YAZ in your own
4 # configure script.
5 # YAZ_INIT
6
7 AC_DEFUN([YAZ_INIT],
8 [
9         AC_SUBST(YAZLIB)
10         AC_SUBST(YAZLALIB)
11         AC_SUBST(YAZINC)
12         AC_SUBST(YAZVERSION)
13         yazconfig=NONE
14         yazpath=NONE
15         AC_ARG_WITH(yazconfig, [  --with-yazconfig=DIR    yaz-config in DIR (example /home/yaz-1.7)], [yazpath=$withval])
16         if test "x$yazpath" != "xNONE"; then
17                 yazconfig=$yazpath/yaz-config
18         else
19                 if test "x$srcdir" = "x"; then
20                         yazsrcdir=.
21                 else
22                         yazsrcdir=$srcdir
23                 fi
24                 for i in ${yazsrcdir}/../yaz* ${yazsrcdir}/../yaz ../yaz* ../yaz; do
25                         if test -d $i; then
26                                 if test -r $i/yaz-config; then
27                                         yazconfig=$i/yaz-config
28                                 fi
29                         fi
30                 done
31                 if test "x$yazconfig" = "xNONE"; then
32                         AC_PATH_PROG(yazconfig, yaz-config, NONE)
33                 fi
34         fi
35         AC_MSG_CHECKING(for YAZ)
36         if $yazconfig --version >/dev/null 2>&1; then
37                 YAZLIB=`$yazconfig --libs $1`
38                 # if this is empty, it's a simple version YAZ 1.6 script
39                 # so we have to source it instead...
40                 if test "X$YAZLIB" = "X"; then
41                         . $yazconfig
42                 else
43                         YAZLALIB=`$yazconfig --lalibs $1`
44                         YAZINC=`$yazconfig --cflags $1`
45                         YAZVERSION=`$yazconfig --version`
46                 fi
47                 AC_MSG_RESULT([$yazconfig])
48         else
49                 AC_MSG_RESULT(Not found)
50                 YAZVERSION=NONE
51         fi
52         if test "X$YAZVERSION" != "XNONE"; then
53                 AC_MSG_CHECKING([for YAZ version])
54                 AC_MSG_RESULT([$YAZVERSION])
55                 if test "$2"; then
56                         have_yaz_version=`echo "$YAZVERSION" | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
57                         req_yaz_version=`echo "$2" | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
58                         if test "$have_yaz_version" -lt "$req_yaz_version"; then
59                                 AC_MSG_ERROR([$YAZVERSION. Requires $2 or later])
60                         fi
61                 fi
62         fi
63 ])