# Template file for 'libdbus-c++'
pkgname=libdbus-c++
version=0.9.2pw
revision=1
build_style=gnu-configure
configure_args="--enable-glib --disable-ecore"
hostmakedepends="automake libtool pkg-config"
makedepends="dbus-devel glib-devel"
short_desc="C++ API for D-BUS"
maintainer="Duncaen <mail@duncano.de>"
license="LGPL-2.1-or-later"
homepage="http://dbus-cplusplus.sourceforge.net/"
distfiles="https://github.com/pkgw/dbus-cplusplus/releases/download/v${version}/libdbus-c---${version}.tar.gz"
checksum=4f140668f2529ecbdce99afbb89f8a977aa47a36248d5f4943b3660316752ee8

if [ -n "$CROSS_BUILD" ]; then
	hostmakedepends+=" libdbus-c++-devel dbus-devel glib-devel"
fi

pre_configure() {
	NOCONFIGURE=1 autoreconf -fi
}

post_install() {
	if [ -n "$CROSS_BUILD" ]; then
		# Re-build tools for the target architecture
		sed -i tools/Makefile \
			-e "s;^\(CXX =\).*;\1 $CXX;" \
			-e "s;^\(CFLAGS =\).*;\1 $CFLAGS;" \
			-e "s;^\(CXXFLAGS =\).*;\1 $CXXFLAGS;" \
			-e "s;^\(LDFLAGS =\).*;\1 $LDFLAGS;" \
			-e "/^libdbus_cxx_la/d" \
			-e "s;#\(libdbus_cxx_la = .*\);\1;"
		make -C tools clean
		make -C tools ${makejobs}
		vbin tools/dbusxx-xml2cpp
		vbin tools/dbusxx-introspect
	fi
}

libdbus-c++-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}-${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
		vmove usr/lib/pkgconfig
	}
}
