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

# source: james - based on BLFS recipe for ghostscript 9.23 updated to 9.50
TARBALL=ghostpdl-$PKGVER.tar.xz
MD5SUM=6ffebf1763970f5c47ec2186379bb7e1
SRC_URL=https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs950/$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  --enable-gpdl &&

	{ 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 &&

	# install ghostpcl fonts & make sure ghostpcl knows where to find them
	cp -a pcl/urwfonts /usr/share/ghostscript &&
	mkdir -p /etc/profile.d &&
	cat > /etc/profile.d/ghostpdl.sh << "EOF" &&
# make sure gpcl6 knows where to find its fonts
export PCLFONTSOURCE=/usr/share/ghostscript/urwfonts
EOF
	chmod +x /etc/profile.d/ghostpdl.sh &&

	# install ghostpcl tools
	install -m755 pcl/tools/pcl2pdf{,wr} /usr/bin &&
	
	# install ghostpcl examples
	cp -a pcl/examples /usr/share/ghostscript/$PKGVER/examples/pcl &&
	
	pkg_build_slackdesc	
}
  

