1# JABBER_CHECK_CONFIG ([DEFAULT-ACTION])
2# ----------------------------------------------------------
3#    Eugene Grigorjev <eugene@zabbix.com>   Feb-02-2007
4#
5# Checks for iksemel.  DEFAULT-ACTION is the string yes or no to
6# specify whether to default to --with-jabber or --without-jabber.
7# If not supplied, DEFAULT-ACTION is no.
8#
9# This macro #defines HAVE_JABBER and HAVE_IKSEMEL if a required header files is
10# found, and sets @JABBER_LDFLAGS@ and @JABBER_CPPFLAGS@ to the necessary
11# values.
12#
13# Users may override the detected values by doing something like:
14# JABBER_LDFLAGS="-liksemel" JABBER_CPPFLAGS="-I/usr/myinclude" ./configure
15#
16# This macro is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20AC_DEFUN([JABBER_CHECK_CONFIG],
21[
22  AC_ARG_WITH(jabber,
23[
24If you want to use Jabber protocol for messaging:
25AC_HELP_STRING([--with-jabber@<:@=DIR@:>@],[Include Jabber support @<:@default=no@:>@. DIR is the iksemel library install directory.])],[
26	if test "$withval" = "no"; then
27            want_jabber="no"
28            _libiksemel_with="no"
29        elif test "$withval" = "yes"; then
30            want_jabber="yes"
31            _libiksemel_with="yes"
32        else
33            want_jabber="yes"
34            _libiksemel_with=$withval
35        fi
36     ],[_libiksemel_with=ifelse([$1],,[no],[$1])])
37
38  if test "x$_libiksemel_with" != x"no"; then
39       if test "$_libiksemel_with" = "yes"; then
40		PKG_CHECK_MODULES(IKSEMEL,iksemel,
41			[
42			 JABBER_INCDIR="$IKSEMEL_CPPFLAGS"
43			 JABBER_LIBDIR="$IKSEMEL_LDFLAGS"
44			 JABBER_LIBS="-liksemel"
45			],[
46			 found_iksemel="no"
47			 found_jabber="no"
48			])
49       else
50	       AC_MSG_CHECKING(for iksemel support)
51
52               if test -f $_libiksemel_with/include/iksemel.h; then
53                       JABBER_INCDIR="-I$_libiksemel_with/include"
54                       JABBER_LIBDIR="-L$_libiksemel_with/lib"
55                       JABBER_LIBS="-liksemel"
56		       AC_MSG_RESULT(yes)
57               else
58                       found_iksemel="no"
59                       found_jabber="no"
60                       AC_MSG_RESULT(no)
61               fi
62       fi
63
64       if test "x$found_iksemel" != "xno" ; then
65
66               AC_CHECK_FUNCS(getaddrinfo)
67
68               JABBER_CPPFLAGS=$JABBER_INCDIR
69               JABBER_LDFLAGS="$JABBER_LIBDIR"
70
71		if test "x$enable_static" = "xyes"; then
72			for i in -liksemel -lgnutls -ltasn1 -lgcrypt -lgpg-error; do
73				case $i in
74					-liksemel)
75				;;
76					-l*)
77						_lib_name=`echo "$i" | cut -b3-`
78						AC_CHECK_LIB($_lib_name , main,[
79							JABBER_LIBS="$JABBER_LIBS $i"
80						],[
81							AC_MSG_ERROR([Not found $_lib_name library])
82						])
83				;;
84				esac
85			done
86		fi
87
88               found_iksemel="yes"
89               found_jabber="yes"
90               AC_DEFINE(HAVE_IKSEMEL,1,[Define to 1 if Iksemel library should be enabled.])
91               AC_DEFINE(HAVE_JABBER,1,[Define to 1 if Jabber should be enabled.])
92       fi
93  fi
94
95  AC_SUBST(JABBER_CPPFLAGS)
96  AC_SUBST(JABBER_LDFLAGS)
97  AC_SUBST(JABBER_LIBS)
98
99  unset _libiksemel_with
100])dnl
101