From f2803087b7e9ff704da16c37084ee8ad97478057 Mon Sep 17 00:00:00 2001
From: Helmut Pozimski <helmut@pozimski.eu>
Date: Thu, 5 Oct 2017 10:35:31 +0200
Subject: [PATCH] ghostscript: update to 9.22

the update includes fixes for the following security issues:
CVE-2017-9611, CVE-2017-9612, CVE-2017-9726, CVE-2017-9727, CVE-2017-9739,
CVE-2017-9835 and CVE-2017-11714
---
 srcpkgs/ghostscript/template | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/srcpkgs/ghostscript/template b/srcpkgs/ghostscript/template
index 86cf0f993b6..3fca3185783 100644
--- a/srcpkgs/ghostscript/template
+++ b/srcpkgs/ghostscript/template
@@ -1,13 +1,13 @@
 # Template file for 'ghostscript'
 pkgname=ghostscript
-version=9.20
+version=9.22
 revision=1
 short_desc="An interpreter for the PostScript language"
 maintainer="Juan RP <xtraeme@voidlinux.eu>"
 homepage="http://www.ghostscript.com/"
 license="AGPL-3, CPL-1.0"
 distfiles="https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs${version/./}/ghostscript-${version}.tar.xz"
-checksum=3c0f3dc5df6f784850fa4ce7dcc3d6c56ef543af1fbaedd1d9f8d9f8b66de0ab
+checksum=c1f862e6f40f997dbe3feba89355e8cb05d55818994e10f4932b0dd9b627d1bb
 
 hostmakedepends="automake libtool pkg-config"
 makedepends="
@@ -16,6 +16,10 @@ makedepends="
  cups-devel libpaper-devel"
 depends="gsfonts"
 
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" ${makedepends}"
+fi
+
 pre_configure() {
 	# force it to use system libs.
 	rm -rf zlib jpeg libpng jasper expat tiff lcms2 freetype cups/libs jbig2dec
@@ -30,6 +34,9 @@ pre_configure() {
 do_configure() {
 	cd ${wrksrc}
 	# configure ghostscript
+	if [ "$CROSS_BUILD" ]; then
+		export CCAUX=cc CFLAGSAUX=${XBPS_CFLAGS}
+	fi
 	./configure ${configure_args} --enable-dynamic --with-ijs \
 		--with-jbig2dec --with-omni --with-x --with-drivers=ALL \
 		--with-fontpath=/usr/share/fonts/Type1:/usr/share/fonts \
@@ -43,16 +50,6 @@ do_configure() {
 }
 
 do_build() {
-	if [ "$CROSS_BUILD" ]; then
-		# Build host utils.
-		cp -f Makefile Makefile.orig
-		sed "/GCFLAGS/s,${CFLAGS},,g" -i Makefile
-		make CC=cc CCLD=cc base/genarch base/genconf base/echogs
-		mv -f Makefile.orig Makefile
-		mkdir -p obj/aux soobj/aux
-		cp base/{echogs,genarch,genconf} obj/aux
-		cp base/{echogs,genarch,genconf} soobj/aux
-	fi
 	# build ghostscript
 	make ${makejobs}
 	make ${makejobs} so