From f56d02199805d672c712e9964a4cd931b5775c00 Mon Sep 17 00:00:00 2001
From: Cameron Banta <cbanta@gmail.com>
Date: Sat, 6 Mar 2010 21:35:26 +0000
Subject: [PATCH 1/2] Update to version 8.71.
 Create dev package.
 Split build into separate build and package parts.
 Force libraries to use system libraries instead of bundled ones.

---
 main/ghostscript/APKBUILD                        |   55 ++++++++++++++++------
 main/ghostscript/ghostscript-system-jasper.patch |   26 ++++++++++
 main/ghostscript/libpng14.patch                  |   24 +++++++++
 3 files changed, 90 insertions(+), 15 deletions(-)
 create mode 100644 main/ghostscript/ghostscript-system-jasper.patch
 create mode 100644 main/ghostscript/libpng14.patch

diff --git a/main/ghostscript/APKBUILD b/main/ghostscript/APKBUILD
index 51c3701..ad414e5 100644
--- a/main/ghostscript/APKBUILD
+++ b/main/ghostscript/APKBUILD
@@ -1,45 +1,70 @@
 # Contributor: Cameron Banta <cbanta@gmail.com>
 # Maintainer: Cameron Banta <cbanta@gmail.com>
 pkgname=ghostscript
-pkgver=8.70
+pkgver=8.71
 pkgrel=0
 pkgdesc="An interpreter for the PostScript language and for PDF"
 url="http://ghostscript.com/"
 license="GPL"
-depends="uclibc"
-makedepends=""
-install=
-subpackages="$pkgname-doc"
-source="http://ghostscript.com/releases/$pkgname-$pkgver.tar.gz"
+makedepends="autoconf automake jpeg-dev libpng-dev jasper-dev expat-dev zlib-dev tiff-dev libiconv-dev"
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://ghostscript.com/releases/$pkgname-$pkgver.tar.gz
+	libpng14.patch
+	ghostscript-system-jasper.patch"
 
-build() {
+prepare() {
 	cd "$srcdir/$pkgname-$pkgver"
 
-	./configure --prefix=/usr \
+	# force it to use system-libs
+	rm -rf jpeg libpng jasper expat tiff
+
+	patch -Np1 -i "${srcdir}"/libpng14.patch || return 1
+
+	# fix build with systems jasper
+	patch -Np1 -i "${srcdir}"/ghostscript-system-jasper.patch || return 1
+	
+	./autogen.sh \
+		--prefix=/usr \
 		--sysconfdir=/etc \
 		--mandir=/usr/share/man \
 		--infodir=/usr/share/info \
+		--docdir=/usr/share/doc/"$pkgname" \
+		--enable-dynamic \
+		--with-system-libtiff \
+		--without-ijs --without-x \
+		--with-jbig2dec \
+		--without-omni \
 		--with-drivers=FILES \
+		--with-fontpath=/usr/share/fonts/Type1:/usr/share/fonts \
 		--disable-cups --disable-gtk --disable-cairo \
-		--docdir=/usr/share/doc/"$pkgname"
+		--disable-compile-inits # needed for linking with system-zlib
+}
+
+build(){
+	cd "$srcdir/$pkgname-$pkgver"
 	make || return 1
-	make DESTDIR="$pkgdir" install
+}
+
+package() {
+	cd "$srcdir/$pkgname-$pkgver"
+	make -j1 DESTDIR="${pkgdir}" install soinstall || return 1
+
+	#create empty dir for future fonts
+	mkdir -p "${pkgdir}"/usr/share/fonts/Type1
 
 	# license and copying
 	install -m644 -D "$srcdir/$pkgname-$pkgver/LICENSE" \
 		"$pkgdir/usr/share/licenses/$pkgname/LICENSE"
 	install -m644 -D "$srcdir/$pkgname-$pkgver/doc/COPYING" \
 		"$pkgdir/usr/share/licenses/$pkgname/COPYING"
-	
-
 
 	# make the doc and examples more alpine like 
 	#	(the --docdir above doesn't seem to work so good)
 	mkdir -p "$pkgdir/usr/share/doc/$pkgname"
 	mv "$pkgdir/usr/share/$pkgname/$pkgver/doc" "$pkgdir/usr/share/doc/$pkgname"
 	mv "$pkgdir/usr/share/$pkgname/$pkgver/examples" "$pkgdir/usr/share/doc/$pkgname"
-	
-
 }
 
-md5sums="be2581eb1ba9e4ab67c2eda95144d564  ghostscript-8.70.tar.gz"
+md5sums="51a522a5b4818bd3dc7c1c0e9dd22bad  ghostscript-8.71.tar.gz
+be94ee357986f7f63d1b470da5bdc99e  libpng14.patch
+03e27cd02471ab3b642c344fa06b623e  ghostscript-system-jasper.patch"
diff --git a/main/ghostscript/ghostscript-system-jasper.patch b/main/ghostscript/ghostscript-system-jasper.patch
new file mode 100644
index 0000000..444b760
--- /dev/null
+++ b/main/ghostscript/ghostscript-system-jasper.patch
@@ -0,0 +1,26 @@
+diff -up ghostscript-8.64/base/sjpx.c.system-jasper ghostscript-8.64/base/sjpx.c
+--- ghostscript-8.64/base/sjpx.c.system-jasper	2008-08-21 00:22:49.000000000 +0100
++++ ghostscript-8.64/base/sjpx.c	2009-02-04 11:35:56.000000000 +0000
+@@ -34,14 +34,6 @@ static void s_jpxd_set_defaults(stream_s
+ private_st_jpxd_state(); /* creates a gc object for our state,
+ 			    defined in sjpx.h */
+ 
+-/* error reporting callback for the jpx library */
+-static void
+-s_jpx_jas_error_cb(jas_error_t err, char *msg)
+-{
+-  dprintf2("jasper (code %d) %s", (int)err, msg);
+-}
+-
+-
+ /* initialize the steam.
+    this involves allocating the stream and image structures, and
+    initializing the decoder.
+@@ -59,7 +51,6 @@ s_jpxd_init(stream_state * ss)
+     }
+ 
+     status = jas_init();
+-    jas_set_error_cb(s_jpx_jas_error_cb);
+ #ifdef JPX_DEBUG
+     /* raise the error reporting threshold from the default (0) */
+     jas_setdbglevel(1);
diff --git a/main/ghostscript/libpng14.patch b/main/ghostscript/libpng14.patch
new file mode 100644
index 0000000..7ee08af
--- /dev/null
+++ b/main/ghostscript/libpng14.patch
@@ -0,0 +1,24 @@
+diff -Nur ghostscript-8.70.orig/base/configure.ac ghostscript-8.70/base/configure.ac
+--- ghostscript-8.70.orig/base/configure.ac	2009-07-27 19:59:50.000000000 +0300
++++ ghostscript-8.70/base/configure.ac	2010-01-17 02:20:52.000000000 +0200
+@@ -402,7 +402,7 @@
+ 	PNGDEVS="$PNGDEVS_ALL"
+ else
+ 	AC_MSG_RESULT([no])
+-	AC_CHECK_LIB(png, png_check_sig, [
++	AC_CHECK_LIB(png, png_sig_cmp, [
+ 	  AC_CHECK_HEADERS(png.h, [
+ 		SHARE_LIBPNG=1
+ 		PNGDEVS="$PNGDEVS_ALL"
+diff -Nur ghostscript-8.70.orig/jbig2dec/configure.ac ghostscript-8.70/jbig2dec/configure.ac
+--- ghostscript-8.70.orig/jbig2dec/configure.ac	2009-05-29 09:48:44.000000000 +0300
++++ ghostscript-8.70/jbig2dec/configure.ac	2010-01-17 02:21:25.000000000 +0200
+@@ -34,7 +34,7 @@
+   fi
+   dnl libpng requires pow() which may be in libm
+   AC_SEARCH_LIBS([pow], [m])
+-  AC_CHECK_LIB([png], [png_check_sig], [
++  AC_CHECK_LIB([png], [png_sig_cmp], [
+     AC_CHECK_LIB([z], [deflate], [
+       AC_DEFINE(HAVE_LIBPNG, 1, [Define if libpng is available (-lpng)])
+       LIBS="-lpng -lz $LIBS"
-- 
1.6.6.1


