NAME="avahi"
DESC="System which facilitates service discovery on a local network"
VERSION="0.8"
FILES=(
  "https://github.com/lathiat/avahi/releases/download/v$VERSION/avahi-$VERSION.tar.gz"
  "https://www.linuxfromscratch.org/patches/blfs/12.0/avahi-$VERSION-ipv6_race_condition_fix-1.patch"
)
HASHES=(
  "229c6aa30674fc43c202b22c5f8c2be7"
  "218c909581d0ca2c86c8145bb0797050d987a6b0ae3417949dbe2a6d55c49360"
)
DEPENDS=("glib" "gtk2" "gtk3" "libdaemon" "libglade" "qt5")

PACKAGE() {
  tar xf $NAME-$VERSION.tar.gz
  cd $NAME-$VERSION

  patch -Np1 -i ../avahi-$VERSION-ipv6_race_condition_fix-1.patch
  sed -i '426a if (events & AVAHI_WATCH_HUP) { \
client_free(c); \
return; \
}' avahi-daemon/simple-protocol.c

  ./configure \
    --prefix=/usr        \
    --sysconfdir=/etc    \
    --localstatedir=/var \
    --disable-static     \
    --disable-libevent   \
    --disable-mono       \
    --disable-monodoc    \
    --disable-python     \
    --disable-qt3        \
    --disable-qt4        \
    --enable-core-docs   \
    --with-distro=none   \
    --with-dbus-system-address='unix:path=/run/dbus/system_bus_socket'
  make && make DESTDIR="$ROOTDIR" install

  cd .. && rm -r $NAME-$VERSION
}
