SUMMARY="A library to access multiple forms of archives"
DESCRIPTION="Physfs is short for PhysicsFS. It's a C library that provides \
abstract access to various archives. It is intended for use in video games, \
and the design was somewhat inspired by Quake 3's file subsystem.

The programmer defines a \"write directory\" on the physical filesystem to \
which all writing through the PhysicsFS is restricted for security reasons.
PhysicsFS gives you platform-abstracted means to determine if CD-ROMs are \
available, the user's home directory (where in the real filesystem your \
game is running), etc."
HOMEPAGE="https://icculus.org/physfs"
COPYRIGHT="2001-2017 Ryan C. Gordon"
LICENSE="PHYSFS"
REVISION="1"
SOURCE_URI="http://icculus.org/physfs/downloads/physfs-$portVersion.tar.bz2"
CHECKSUM_SHA256="304df76206d633df5360e738b138c94e82ccf086e50ba84f456d3f8432f9f863"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	physfs$secondaryArchSuffix = $portVersion compat >= 3.0
	cmd:test_physfs$secondaryArchSuffix = $portVersion compat >= 3.0
	lib:libphysfs$secondaryArchSuffix = $portVersion compat >= 3.0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	physfs${secondaryArchSuffix}_devel = $portVersion compat >= 3.0
	devel:libphysfs$secondaryArchSuffix = $portVersion compat >= 3.0
	"
REQUIRES_devel="
	physfs$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

PATCH()
{
	sed -i "s,DESTINATION include,DESTINATION $relativeIncludeDir," CMakeLists.txt
	sed -i "s,DESTINATION bin,DESTINATION $relativeBinDir," CMakeLists.txt
}

BUILD()
{
	cmake . -DCMAKE_INSTALL_PREFIX=$prefix \
		-DLIB_SUFFIX="/${secondaryArchSuffix/_/}"
	make $jobArgs
}

INSTALL()
{
	make install

	prepareInstalledDevelLib libphysfs
	fixPkgconfig

	# devel package
	packageEntries devel \
			$developDir
}
