# Template file for 'avahi-discover'
#
# WARNING: THIS TEMPLATE MUST BE SYNCHRONIZED WITH AVAHI. IT IS SPLITTED TO DROP
# ADDITIONAL DEPENDENCIES LIKE GTK3 AND PYGTK.
#
pkgname=avahi-discover
version=0.6.31
wrksrc="avahi-${version}"
revision=12
build_style=gnu-configure
configure_args="--disable-qt3 --disable-qt4 --disable-mono --disable-monodoc
 --disable-doxygen-doc --enable-compat-libdns_sd --enable-compat-howl
 --with-xml=expat --with-avahi-user=avahi --with-avahi-group=avahi
 --with-avahi-priv-access-group=network --with-autoipd-user=avahi
 --with-autoipd-group=avahi --with-distro=none --disable-xmltoman
 --disable-dbm --with-systemdsystemunitdir=/usr/lib/systemd/system
 --disable-static ssp_cv_lib=no --enable-python --enable-pygtk
 --enable-glib --enable-gobject --enable-gtk --enable-gtk3
 --enable-introspection"
short_desc="Multicast DNS Service Discovery"
maintainer="Juan RP <xtraeme@gmail.com>"
license="LGPL-2.1"
homepage="http://www.avahi.org"
distfiles="$homepage/download/avahi-$version.tar.gz"
checksum=8372719b24e2dd75de6f59bb1315e600db4fd092805bd1201ed0cb651a2dab48

hostmakedepends="pkg-config intltool"
makedepends="dbus-devel libcap-devel libdaemon-devel gdbm-devel
 pygtk-devel dbus-python gtk+3-devel gobject-introspection"

if [ "$CROSS_BUILD" ]; then
	msg_error "$pkgver: this package is not cross buildable currently.\n"
fi

pre_configure() {
	# Disable GTK deprecations and -Werror to let this build with gtk+>=3.10.
	sed -e 's,-DG_DISABLE_DEPRECATED=1,,' \
		-e 's,-DGDK_DISABLE_DEPRECATED=1,,' \
		-e 's,-DGTK_DISABLE_DEPRECATED=1,,' \
		-i avahi-ui/Makefile.in
	sed -e 's,-Werror,,g' -i configure
}

avahi-python-utils_package() {
	noarch=yes
	depends="avahi-python>=$version"
	short_desc="Avahi python utilities"
	pkg_install() {
		vmove usr/bin/avahi-bookmarks
		vmove "usr/share/man/man1/avahi-bookmarks*"
	}
}

avahi-python_package() {
	depends="python dbus-python"
	short_desc="Python utility package for Avahi"
	noarch=yes
	pycompile_module="avahi"
	pkg_install() {
		vmove usr/lib/python2.7/site-packages/avahi
	}
}

avahi-glib-libs-devel_package() {
	depends="avahi-libs-devel-${version}_${revision} avahi-glib-libs-${version}_${revision}"
	short_desc="Avahi glib libraries - development files"
	pkg_install() {
		vmove "usr/include/avahi-g*"
		vmove "usr/lib/pkgconfig/avahi-g*"
		vmove "usr/share/gir-*"
		vmove usr/lib/libavahi-glib.so
		vmove usr/lib/libavahi-gobject.so
	}
}

avahi-glib-libs_package() {
	short_desc="Avahi glib shared libraries"
	pkg_install() {
		vmove "usr/lib/libavahi-glib.so.*"
		vmove "usr/lib/libavahi-gobject.so.*"
		vmove "usr/lib/girepository*"
	}
}

avahi-ui-libs-devel_package() {
	depends="gtk+-devel gtk+3-devel avahi-libs-devel-${version}_${revision}
		avahi-ui-libs-${version}_${revision} avahi-ui-libs-gtk3-${version}_${revision}"
	short_desc="Avahi UI libraries - development files"
	pkg_install() {
		vmove usr/include/avahi-ui/avahi-ui.h
		vmove usr/lib/pkgconfig/avahi-ui.pc
		vmove usr/lib/pkgconfig/avahi-ui-gtk3.pc
		vmove usr/lib/libavahi-ui-gtk3.so
		vmove usr/lib/libavahi-ui.so
	}
}

avahi-ui-libs-gtk3_package() {
	short_desc="Avahi UI GTK+3 shared libraries"
	pkg_install() {
		vmove "usr/lib/libavahi-ui-gtk3.so.*"
	}
}

avahi-ui-libs_package() {
	short_desc="Avahi UI shared libraries"
	pkg_install() {
		vmove "usr/lib/libavahi-ui.so.*"
	}
}

avahi-ui-utils_package() {
	depends="desktop-file-utils avahi>=$version"
	short_desc="Avahi GTK+ utilities"
	pkg_install() {
		vmove usr/share/applications/bvnc.desktop
		vmove usr/share/applications/bssh.desktop
		vmove usr/share/man/man1/bssh.1
		vmove usr/bin/avahi-discover-standalone
		vmove usr/bin/bssh
		vmove usr/share/man/man1/bvnc.1
		vmove usr/bin/bvnc
		vmove usr/bin/bshell
	}
}

avahi-discover_package() {
	depends="avahi>=$version python avahi-python>=$version dbus-python pygtk desktop-file-utils"
	short_desc="Service discover user interface for avahi"
	noarch=yes
	pycompile_module="avahi_discover"
	pkg_install() {
		vmove usr/lib/python2.7/site-packages/avahi_discover
		vmove usr/share/applications/avahi-discover.desktop
		vmove usr/share/man/man1/avahi-discover.1
		vmove usr/share/avahi/interfaces/avahi-discover.ui
		vmove usr/bin/avahi-discover
	}
}