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