### this file is sourced not run
PKGVER=9.23
PKGBUILD=1
PKGARCH=x86_64

# source: james - based on BLFS recipe for ghostscript 9.23
TARBALL=ghostpdl-$PKGVER.tar.gz
MD5SUM=2a3b246869bf19baeaaef264e7f99de4
SRC_URL=https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs923/$TARBALL
BUNDLE=

#SLACKREQ='expat freetype2 libjpeg-turbo libpng libtiff lcms2 cairo fontconfig cups libjasper'
SLACKDESC="ghostpdl: ghostpdl $PKGVER (Postscript/PCL/XPS renderer)
ghostpdl: 
ghostpdl: GhostPDL is a versatile printer-description-language (PDL) 
ghostpdl: interpreter with ability to render them into many different targets. 
ghostpdl: The following PDL are supported: Postscript, PCL, and XPS.
ghostpdl: 
ghostpdl: https://www.ghostscript.com/download/gpcldnld.html
ghostpdl: 
ghostpdl: Note: this package includes ghostscript functionality. If you install
ghostpdl: this package you don't need to install ghostscript.
ghostpdl:
"
SLACKCONF=ghostscript # this package includes ghostscript

### default pkg_download
### default pkg_prepare
### package
pkg_package() {
	# add our extra stuff: pdf-writer (cups-pdf) backend and its ppd
	mkdir -p usr/$LIBDIR/cups/backend &&
	install -m500 $CHROOT_DIR/tmp/pkg/pdf-writer usr/$LIBDIR/cups/backend &&
	mkdir -p etc/cups/ppd &&
	install -m644 $CHROOT_DIR/tmp/pkg/CUPS-PDF.ppd etc/cups/ppd
}

### build
pkg_build() {
	cd /tmp/ghostpdl* 

	# this will prevent installation to complete, so clean it out first
	rm -rf /usr/share/ghostscript &&
	
	# delete obsolete library
	rm -rf expat freetype lcms2 jpeg libpng zlib tiff jasper lcms &&

	# start build
	./configure --prefix=/usr --libdir=/usr/$LIBDIR --disable-compile-inits \
	--enable-dynamic --with-system-libtiff  &&

	{ make $MAKEFLAGS    || make ;    } && 
	{ make $MAKEFLAGS so || make so ; } &&

	make install &&
	rm -f /usr/share/ghostscript/$PKGVER/doc && # avoid stall
	make soinstall &&
	
	install -v -m644 base/*.h /usr/include/ghostscript &&
	ln -v -s ghostscript /usr/include/ps &&
	ln -sfvn ../ghostscript/$PKGVER/doc /usr/share/doc/ghostscript-$PKGVER &&
	cp -a examples/ /usr/share/ghostscript/$PKGVER &&
	pkg_build_slackdesc	
}
 

