1dnl Check for optional Zeroconf support
2
3AC_DEFUN([NETATALK_ZEROCONF], [
4	ZEROCONF_LIBS=""
5	ZEROCONF_CFLAGS=""
6	found_zeroconf=no
7	zeroconf_dir=""
8
9	AC_ARG_ENABLE(zeroconf,
10		[  --enable-zeroconf[[=DIR]]   enable Zeroconf support [[auto]]],
11		[zeroconf=$enableval],
12		[zeroconf=try]
13	)
14
15    dnl make sure atalk_libname is defined beforehand
16    [[ -n "$atalk_libname" ]] || AC_MSG_ERROR([internal error, atalk_libname undefined])
17
18	if test "x$zeroconf" != "xno"; then
19		savedcppflags="$CPPFLAGS"
20		savedldflags="$LDFLAGS"
21
22		if test "x$zeroconf" = "xyes" -o "x$zeroconf" = "xtry"; then
23			zeroconf_dir="/usr"
24		else
25			zeroconf_dir="$zeroconf"
26		fi
27
28    # mDNS support using Avahi
29    AC_CHECK_HEADER(
30        avahi-client/client.h,
31        AC_CHECK_LIB(
32           avahi-client,
33           avahi_client_new,
34           AC_DEFINE(USE_ZEROCONF, 1, [Use DNS-SD registration]))
35    )
36
37    case "$ac_cv_lib_avahi_client_avahi_client_new" in
38      yes)
39      PKG_CHECK_MODULES(AVAHI, [ avahi-client >= 0.6 ])
40      PKG_CHECK_MODULES(AVAHI_TPOLL, [ avahi-client >= 0.6.4 ],
41        [AC_DEFINE(HAVE_AVAHI_THREADED_POLL, 1, [Uses Avahis threaded poll implementation])],
42        [AC_MSG_WARN(This Avahi implementation is not supporting threaded poll objects. Maybe this is not what you want.)])
43      ZEROCONF_LIBS="$AVAHI_LIBS"
44      ZEROCONF_CFLAGS="$AVAHI_CFLAGS"
45      AC_DEFINE(HAVE_AVAHI, 1, [Use Avahi/DNS-SD registration])
46      found_zeroconf=yes
47      ;;
48    esac
49
50		CPPFLAGS="$savedcppflags"
51		LDFLAGS="$savedldflags"
52	fi
53	
54	netatalk_cv_zeroconf=no
55	AC_MSG_CHECKING([whether to enable Zerconf support])
56	if test "x$found_zeroconf" = "xyes"; then
57		AC_MSG_RESULT([yes])
58		AC_DEFINE(USE_ZEROCONF, 1, [Define to enable Zeroconf support])
59		netatalk_cv_zeroconf=yes
60	else
61		AC_MSG_RESULT([no])
62		if test "x$zeroconf" != "xno" -a "x$zeroconf" != "xtry"; then
63			AC_MSG_ERROR([Zeroconf installation not found])
64		fi
65	fi
66
67	LIB_REMOVE_USR_LIB(ZEROCONF_LIBS)
68	CFLAGS_REMOVE_USR_INCLUDE(ZEROCONF_CFLAGS)
69	AC_SUBST(ZEROCONF_LIBS)
70	AC_SUBST(ZEROCONF_CFLAGS)
71])
72