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