# Description: A system which facilitates service discovery on a local network via the mDNS/DNS-SD protocol suite
# URL: https://www.avahi.org/
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: dbus gobject-introspection intltool libdaemon libevent

name=avahi
version=0.8
release=4
source=(https://github.com/lathiat/avahi/releases/download/v$version/$name-$version.tar.gz
  avahi-0.8-ipv6_race_condition_fix-1.patch
  0001-Fix-avahi-browse-Invalid-service-type.patch
  avahi-daemon.service)

build() {
  cd $name-$version
  patch -Np1 -i $SRC/0001-Fix-avahi-browse-Invalid-service-type.patch
  #patch -Np1 -i $SRC/282.patch
  patch -Np1 -i $SRC/avahi-0.8-ipv6_race_condition_fix-1.patch

  NOCONFIGURE=1 ./autogen.sh
  ./configure --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --runstatedir=/run \
    --with-distro=none \
    --with-autoipd-user=avahi \
    --with-autoipd-group=avahi \
    --with-avahi-priv-access-group=wheel \
    --enable-compat-libdns_sd \
    --disable-{gtk,gtk3,qt3,qt4,qt5,python,static} \
    --disable-{pygobject,python-dbus,mono,mono-doc,nls}
  make
  make DESTDIR=$PKG install

  ln -s avahi-compat-libdns_sd/dns_sd.h $PKG/usr/include/dns_sd.h
  install -D -m 0755 $SRC/avahi-daemon.service $PKG/etc/rc.d/avahi-daemon
}
