# Template file for 'evolution-data-server'
pkgname=evolution-data-server
version=3.24.6
revision=1
build_style=cmake
configure_args="-DENABLE_GOOGLE_AUTH=OFF -DENABLE_UOA=OFF"
hostmakedepends="pkg-config intltool flex glib-devel gperf $(vopt_if gir gobject-introspection)"
makedepends="db-devel sqlite-devel mit-krb5-devel nss-devel libical-devel
 libsecret-devel libsoup-gnome-devel gcr-devel libldap-devel
 libgdata-devel $(vopt_if gir vala-devel) libgweather-devel icu-devel"
depends="libsoup-gnome>=2.46 libgweather>=3.12"
short_desc="Centralized access to appointments and contacts"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="GPL-2"
homepage="https://wiki.gnome.org/Apps/Evolution"
distfiles="${GNOME_SITE}/$pkgname/${version%.*}/$pkgname-$version.tar.xz"
checksum=058040214c9362e5e0f7592455418813da28b533b9ff2d6e2d868c39e580189e
nocross=yes

build_options="gir"
if [ -z "$CROSS_BUILD" ]; then
	build_options_default="gir"
fi

if [ ! -z "$build_option_gir" ]; then
	configure_args+=" -DENABLE_INTROSPECTION=ON -DENABLE_VALA_BINDINGS=ON"
fi

pre_configure() {
	if [ ! -d "build" ]; then
		mkdir build
	fi
	echo '/* This is an auto-generated header, DO NOT EDIT! */' > build/iconv-detect.h
	echo  >> build/iconv-detect.h
	echo '#define ICONV_ISO_D_FORMAT "iso-%d-%d"' >> build/iconv-detect.h
	echo '#define ICONV_ISO_S_FORMAT "iso-%d-%s"' >> build/iconv-detect.h
	echo '#define ICONV_10646 "iso-10646"' >> build/iconv-detect.h
}
post_install() {
	# Fix broken pkg-config
	sed -i "s|^Requires: gio-2.0, , |Requires: gio-2.0, mozilla-nspr, mozilla-nss|" \
		$DESTDIR/usr/lib/pkgconfig/evolution-data-server-1.2.pc
}

evolution-data-server-devel_package() {
	depends="sqlite-devel mit-krb5-devel nss-devel libical-devel
		libldap-devel libgdata-devel>=0.15 libsecret-devel libglib-devel
		${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0
			vmove usr/share/vala
		fi
	}
}
