SUMMARY="A library to work with the PDF file format"
DESCRIPTION="
PoDoFo is a library to work with the PDF file format and includes also a few \
tools. The name comes from the first two letters of PDF (Portable Document \
Format.
"
HOMEPAGE="http://sourceforge.net/projects/podofo"
COPYRIGHT="
	2005-2014 Dominik Seichter
	2008 Craig Ringer
	"
LICENSE="
GNU GPL v2
GNU LGPL v2.1
"
SOURCE_URI="http://sourceforge.net/projects/podofo/files/podofo/$portVersion/podofo-$portVersion.tar.gz"
CHECKSUM_SHA256="ec261e31e89dce45b1a31be61e9c6bb250532e631a02d68ec5bb849ef0a222d8"
REVISION="1"
ARCHITECTURES="x86 x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	# x86_gcc2 is fine as primary target architecture as long as we're building
	# for a different secondary architecture.
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

if [ $targetArchitecture != x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	podofo$secondaryArchSuffix = $portVersion compat >= 0.9
	lib:libpodofo$secondaryArchSuffix = $portVersion compat >= 0.9
	cmd:podofobox
	cmd:podofocolor
	cmd:podofocountpages
	cmd:podofocrop
	cmd:podofoencrypt
	cmd:podofogc
	cmd:podofoimg2pdf
	cmd:podofoimgextract
	cmd:podofoimpose
	cmd:podofoincrementalupdates
	cmd:podofomerge
	cmd:podofopages
	cmd:podofopdfinfo
	cmd:podofotxt2pdf
	cmd:podofotxtextract
	cmd:podofouncompress
	cmd:podofoxmp
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng15$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfontconfig$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng15$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:cmake
	cmd:make
	cmd:sed
	"

PATCH()
{
	freetypeDir=$portPackageLinksDir/devel~libfreetype/develop/headers/freetype2
	sed -i -e s:/usr/include/freetype2:$freetypeDir: cmake/modules/FindFREETYPE.cmake

}

BUILD()
{
	cmake -DCMAKE_INSTALL_PREFIX:PATH=$prefix .
	make $jobArgs
}

INSTALL()
{
	make install

	mkdir -p $(dirname $includeDir)
	mv $prefix/include $includeDir

	prepareInstalledDevelLibs libpodofo
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

# ----- devel package -------------------------------------------------------

PROVIDES_devel="
	podofo${secondaryArchSuffix}_devel = $portVersion compat >= 0.9
	devel:libpodofo$secondaryArchSuffix = $portVersion compat >= 0.9
	"
REQUIRES_devel="
	podofo$secondaryArchSuffix == $portVersion base
	"
