SUMMARY="A library for generating PDF files"
DESCRIPTION="PDFlib is a development tool for PDF-enabling your software, or \
generating PDF on your server. PDFlib saves you the intricate details of PDF \
generation by offering a simple-to-use API for programmatically creating PDF \
files from within your own server- or client-side software. PDFlib doesn't \
make use of third-party software for generating PDF, nor does it require any \
other tools.

This is the \"Lite\" version of PDFlib, which may only be used in open-source \
software."
HOMEPAGE="https://www.pdflib.com/"
COPYRIGHT="PDFlib GmbH"
LICENSE="PDFlib 5"
REVISION="4"
SOURCE_URI="http://download.nust.na/pub2/openpkg1/sources/DST/pdflib/PDFlib-Lite-$portVersion-Unix-src.tar.gz"
CHECKSUM_SHA256="4908d84c7836cd11677c48df8d9a0bdf0021a358853804621663458fc0c94077"
SOURCE_DIR="PDFlib-Lite-$portVersion-Unix-src"

ARCHITECTURES="all ?x86"

# no devel package, due to licensing
PROVIDES="
	pdflib = $portVersion
	cmd:pdflib_config = $portVersion
	devel:libpdf = $portVersion
	lib:libpdf = $portVersion
	"
REQUIRES="
	haiku
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc
	cmd:ld
	cmd:libtool
	cmd:libtoolize
	cmd:make
	"

PATCH()
{
	if [ "$effectiveTargetArchitecture" == x86_gcc2 ]; then
		sed -i "s/-lstdc++/-lstdc++.r4/g" configure
	fi
}

BUILD()
{
	/bin/libtoolize -fci
	cp /bin/libtool config/ltmain.sh
	runConfigure --omit-dirs "docDir dataRootDir" ./configure \
		--enable-shared --with-libm=-lroot --with-pic --without-PSP \
		--without-perl --disable-debug
	make $jobArgs
}

INSTALL()
{
	# libtool install rule is semi-busted
	mkdir -p $binDir
	make install || true

	mkdir -p $libDir
	cp "./libs/pdflib/.libs/libpdf.so" $libDir/libpdf.so.2
	ln -srf $libDir/libpdf.so.2 $libDir/libpdf.so

	# documentation & examples -- we must include these due to licensing
	mkdir -p $docDir/
	cp -R doc/* $docDir/
	mkdir -p $developDir/sample-code/
	cp -R bind/pdflib/ $developDir/sample-code/

	prepareInstalledDevelLibs \
		libpdf
}
