34b1191622060d961cb119c17185ea64d49a63ef
[m4-moved-to-github.git] / idzebra.m4
1 ## $Id: idzebra.m4,v 1.1 2006-03-30 18:00:51 adam Exp $
2 ## 
3 # Use this m4 function for autoconf if you use ID Zebra in your own
4 # configure script.
5
6 AC_DEFUN([IDZEBRA_INIT],
7 [
8         AC_SUBST(IDZEBRA_LIBS)
9         AC_SUBST(IDZEBRA_LALIBS)
10         AC_SUBST(IDZEBRA_CFLAGS)
11         AC_SUBST(IDZEBRA_VERSION)
12         idzebraconfig=NONE
13         idzebrapath=NONE
14         AC_ARG_WITH(idzebra, [  --with-idzebra=DIR      use idzebra-config in DIR (example /home/idzebra-1.4.0)], [idzebrapath=$withval])
15         if test "x$idzebrapath" != "xNONE"; then
16                 idzebraconfig=$idzebrapath/idzebra-config
17         else
18                 if test "x$srcdir" = "x"; then
19                         idzebrasrcdir=.
20                 else
21                         idzebrasrcdir=$srcdir
22                 fi
23                 for i in ${idzebrasrcdir}/../idzebra* ${idzebrasrcdir}/../idzebra ../idzebra* ../zebra; do
24                         if test -d $i; then
25                                 if test -r $i/idzebra-config; then
26                                         idzebraconfig=$i/idzebra-config
27                                 fi
28                         fi
29                 done
30                 if test "x$idzebraconfig" = "xNONE"; then
31                         AC_PATH_PROG(idzebraconfig, idzebra-config, NONE)
32                 fi
33         fi
34         AC_MSG_CHECKING(for idzebra)
35         if $idzebraconfig --version >/dev/null 2>&1; then
36                 IDZEBRA_LIBS=`$idzebraconfig --libs $1`
37                 IDZEBRA_LALIBS=`$idzebraconfig --lalibs $1`
38                 IDZEBRA_CFLAGS=`$idzebraconfig --cflags $1`
39                 IDZEBRA_VERSION=`$idzebraconfig --version`
40                 AC_MSG_RESULT([$idzebraconfig])
41         else
42                 AC_MSG_RESULT(Not found)
43                 IDZEBRA_VERSION=NONE
44         fi
45         if test "X$IDZEBRA_VERSION" != "XNONE"; then
46                 AC_MSG_CHECKING([for idzebra version])
47                 AC_MSG_RESULT([$IDZEBRA_VERSION])
48                 if test "$2"; then
49                         have_idzebra_version=`echo "$IDZEBRA_VERSION" | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
50                         req_idzebra_version=`echo "$2" | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
51                         if test "$have_idzebra_version" -lt "$req_idzebra_version"; then
52                                 AC_MSG_ERROR([$IDZEBRA_VERSION. Requires $2 or later])
53                         fi
54                 fi
55         fi
56 ]) 
57