# $Id: PKGBUILD 94183 2010-10-05 07:08:54Z bisson $
# Contributor: Douglas Soares de Andrade <douglas@archlinux.org>

pkgname=avahi
pkgver=0.6.27
pkgrel=8
pkgdesc='A multicast/unicast DNS-SD framework'
arch=('i686' 'x86_64')
url='http://www.avahi.org/'
license=('LGPL')
depends=('expat' 'libdaemon' 'glib2' 'dbus' 'libcap' 'gdbm')
optdepends=('gtk2: avahi-discover-standalone'
            'qt3: qt3 bindings'
            'qt: qt bindings'
            'pygtk: avahi-bookmarks, avahi-discover'
            'twisted: avahi-bookmarks'
            'mono: mono bindings'
            'dbus-python: avahi-discover'
            'nss-mdns: NSS support for mDNS')
makedepends=('qt' 'pygtk' 'mono' 'intltool' 'dbus-python' 'gtk-sharp-2' 'gobject-introspection>=0.9.10')
backup=(etc/avahi/avahi-daemon.conf etc/avahi/services/{sftp-,}ssh.service)
install=avahi.install
conflicts=('howl' 'mdnsresponder')
provides=('howl' 'mdnsresponder')
replaces=('howl' 'mdnsresponder')
options=('!libtool')
source=(http://www.avahi.org/download/avahi-${pkgver}.tar.gz
        avahi-daemon-dbus.patch
        gnome-nettool.png
        introspection.patch)
sha1sums=('e763bbeba92fd5b3ba3e2af5fc85aaf99b406c8b'
          '41e9f23efa0b5a5f7b0f14a86cfb0677ece84c61'
          'cf56387c88aed246b9f435efc182ef44de4d52f3'
          '999d71add829ab9bb55262855dfe04126ac7975c')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  sed -i 's/netdev/network/g' avahi-daemon/avahi-dbus.conf
  patch -Np0 -i "${srcdir}/avahi-daemon-dbus.patch"
  patch -Np1 -i "${srcdir}/introspection.patch"

  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --disable-gtk3 \
    --disable-qt3 \
    --disable-monodoc \
    --disable-doxygen-doc \
    --disable-xmltoman \
    --enable-compat-libdns_sd \
    --enable-compat-howl \
    --with-distro=archlinux \
    --with-avahi-priv-access-group=network \
    --with-autoipd-user=avahi \
    --with-autoipd-group=avahi \
    --with-systemdsystemunitdir=/lib/systemd/system # See FS#20999

  make || return 1
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  make DESTDIR="${pkgdir}" install || return 1

  # howl and mdnsresponder compatability
  cd "${pkgdir}"/usr/include
  ln -s avahi-compat-libdns_sd/dns_sd.h dns_sd.h
  ln -s avahi-compat-howl howl
  cd "${pkgdir}"/usr/lib/pkgconfig
  ln -s avahi-compat-howl.pc howl.pc

  sed -i '1c #!/usr/bin/python2' "$pkgdir"/usr/bin/avahi-{bookmarks,discover}

  install -D -m 644 "${srcdir}"/gnome-nettool.png "${pkgdir}"/usr/share/pixmaps/gnome-nettool.png
}