# Description: Virtual Terminal Emulator widget for use with GTK2
# URL: https://wiki.gnome.org/Apps/Terminal/VTE
# Maintainer: Danny Rawlins, crux at romster dot me
# Depends on: gtk util-linux

name=vte
version=0.28.2
release=4
source=(https://download.gnome.org/sources/$name/${version%.*}/$name-$version.tar.xz
	$name-0.30.1-alt-meta.patch
	$name-0.28.2-interix.patch
	$name-0.28.2-limit-arguments.patch
	$name-0.28.2-repaint-after-change-scroll-region.patch)

build() {
	cd $name-$version

	# https://bugzilla.gnome.org/show_bug.cgi?id=663779
	patch -p1 -i $SRC/$name-0.30.1-alt-meta.patch

	# https://bugzilla.gnome.org/show_bug.cgi?id=652290
	patch -p1 -i $SRC/$name-0.28.2-interix.patch

	# Fix CVE-2012-2738, upstream bug #676090
	patch -p1 -i $SRC/$name-0.28.2-limit-arguments.patch

	# Fix https://bugzilla.gnome.org/show_bug.cgi?id=542087
	# Patch from https://github.com/pld-linux/vte0/commit/1e8dce16b239e5d378b02e4d04a60e823df36257
	patch -p1 -i $SRC/$name-0.28.2-repaint-after-change-scroll-region.patch

	export CFLAGS="$CFLAGS -Wno-deprecated-declarations"

	./configure \
		--prefix=/usr \
		--libexecdir=/usr/lib/$name \
		--disable-deprecation \
		--disable-debugging \
		--disable-python \
		--disable-gtk-doc \
		--with-xft2 \
		--with-pangox \
		--with-gtk=2.0

	sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool

	make
	make DESTDIR=$PKG install

	rm -r $PKG/usr/share/{gtk-doc,locale}
	rm $PKG/usr/lib/vte/gnome-pty-helper
}
