]> arthur.barton.de Git - netatalk.git/blob - macros/zeroconf.m4
6916c9905dca7541fe91f50678994695b3674ed3
[netatalk.git] / macros / zeroconf.m4
1 dnl Check for optional Zeroconf support
2
3 AC_DEFUN([AC_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 mDNSResponder
29         AC_CHECK_HEADER(
30             dns_sd.h,
31             AC_CHECK_LIB(
32                 dns_sd,
33                 DNSServiceRegister,
34                 AC_DEFINE(USE_ZEROCONF, 1, [Use DNS-SD registration]))
35         )
36
37         if test "$ac_cv_lib_dns_sd_DNSServiceRegister" = yes; then
38             ZEROCONF_LIBS="-ldns_sd"
39             AC_DEFINE(HAVE_MDNS, 1, [Use mDNSRespnder/DNS-SD registration])
40             found_zeroconf=yes
41         fi
42
43         # mDNS support using Avahi
44         if test x"$found_zeroconf" != x"yes" ; then
45             AC_CHECK_HEADER(
46                 avahi-client/client.h,
47                 AC_CHECK_LIB(
48                     avahi-client,
49                     avahi_client_new,
50                     AC_DEFINE(USE_ZEROCONF, 1, [Use DNS-SD registration]))
51             )
52
53             case "$ac_cv_lib_avahi_client_avahi_client_new" in
54             yes)
55                 PKG_CHECK_MODULES(AVAHI, [ avahi-client >= 0.6 ])
56                 PKG_CHECK_MODULES(AVAHI_TPOLL, [ avahi-client >= 0.6.4 ],
57                     [AC_DEFINE(HAVE_AVAHI_THREADED_POLL, 1, [Uses Avahis threaded poll implementation])],
58                     [AC_MSG_WARN(This Avahi implementation is not supporting threaded poll objects. Maybe this is not what you want.)])
59                 ZEROCONF_LIBS="$AVAHI_LIBS"
60                 ZEROCONF_CFLAGS="$AVAHI_CFLAGS"
61                 AC_DEFINE(HAVE_AVAHI, 1, [Use Avahi/DNS-SD registration])
62                 found_zeroconf=yes
63                 ;;
64             esac
65                 CPPFLAGS="$savedcppflags"
66                     LDFLAGS="$savedldflags"
67         fi
68         fi
69
70         netatalk_cv_zeroconf=no
71         AC_MSG_CHECKING([whether to enable Zerconf support])
72         if test "x$found_zeroconf" = "xyes"; then
73                 AC_MSG_RESULT([yes])
74                 AC_DEFINE(USE_ZEROCONF, 1, [Define to enable Zeroconf support])
75                 netatalk_cv_zeroconf=yes
76         else
77                 AC_MSG_RESULT([no])
78                 if test "x$zeroconf" != "xno" -a "x$zeroconf" != "xtry"; then
79                         AC_MSG_ERROR([Zeroconf installation not found])
80                 fi
81         fi
82
83         LIB_REMOVE_USR_LIB(ZEROCONF_LIBS)
84         CFLAGS_REMOVE_USR_INCLUDE(ZEROCONF_CFLAGS)
85         AC_SUBST(ZEROCONF_LIBS)
86         AC_SUBST(ZEROCONF_CFLAGS)
87 ])