# Template file for 'rxvt-unicode'
pkgname=rxvt-unicode
version=9.31
revision=4
build_style=gnu-configure
configure_args="
 --with-terminfo=/usr/share/terminfo --enable-256-color
 --enable-font-styles --enable-xim --enable-keepscrolling
 --enable-selectionscrolling --enable-smart-resize --enable-transparency
 --enable-combining --with-term=rxvt-unicode-256color
 $(vopt_if gdk_pixbuf '--enable-pixbuf' '--disable-pixbuf')
 $(vopt_if perl '--enable-perl' '--disable-perl')
 $(vopt_if startup_notification '--enable-startup-notification' '--disable-startup-notification')
 $(vopt_if unicode3 '--enable-unicode3' '--disable-unicode3')"
hostmakedepends="pkg-config $(vopt_if perl 'perl')"
makedepends="xorgproto fontconfig-devel
 libXrender-devel libXft-devel libSM-devel libXt-devel libptytty-devel
 $(vopt_if gdk_pixbuf gdk-pixbuf-devel)
 $(vopt_if perl perl)
 $(vopt_if startup_notification startup-notification-devel)"
depends="ncurses rxvt-unicode-terminfo-${version}_${revision}"
short_desc="Terminal emulator supporting Xft fonts and Unicode"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="GPL-3.0-or-later"
homepage="http://software.schmorp.de/pkg/rxvt-unicode.html"
changelog="http://cvs.schmorp.de/rxvt-unicode/Changes"
distfiles="http://dist.schmorp.de/${pkgname}/${pkgname}-${version}.tar.bz2"
checksum=aaa13fcbc149fe0f3f391f933279580f74a96fd312d6ed06b8ff03c2d46672e8

# Package build options
build_options="gdk_pixbuf perl startup_notification unicode3"
desc_option_unicode3="Use 21 instead of 16 bits to represent unicode chars"

# Enable gdk_pixbuf & startup-notification by default.
build_options_default="gdk_pixbuf perl startup_notification unicode3"

_cross_perl() {
	if [ "$CROSS_BUILD" ]; then
		sed -e "s#/usr/lib#${XBPS_CROSS_BASE}\0#g" \
			-e "s#/usr/share#${XBPS_CROSS_BASE}\0#g" \
			-e "s# -m[^ ]*##g"
	else
		cat
	fi
}

do_configure() {
	if [ "$build_option_perl" ]; then
		./configure $configure_args \
			PERL=perl \
			PERL_O=rxvtperl.o \
			PERLFLAGS="$(perl -MExtUtils::Embed -e ccopts | _cross_perl)" \
			PERLLIB="$(perl -MExtUtils::Embed -e ldopts | _cross_perl)" \
			PERLPRIVLIBEXP="$(perl -MConfig -e 'print $Config{privlibexp}' | _cross_perl)"
	else
		./configure $configure_args
	fi
}

pre_configure() {
	if [ "$build_option_perl" ]; then
		sed -i 's/rxvt_perl_link=no/rxvt_perl_link=yes/' configure
		sed -i '/PERLFLAGS=/d' configure
	fi
}

pre_install() {
	export TERMINFO="${DESTDIR}/usr/share/terminfo"
	mkdir -p $TERMINFO
}

post_install() {
	vinstall ${FILESDIR}/${pkgname}.desktop 644 usr/share/applications
	vinstall ${FILESDIR}/${pkgname}.png 644 usr/share/pixmaps
}

rxvt-unicode-terminfo_package() {
	short_desc+=" - terminfo data"
	pkg_install() {
		vmove usr/share/terminfo
	}
}
