SUMMARY="7-zip file compression program"
DESCRIPTION="
p7zip is a port of 7za.exe for POSIX systems like Unix (Linux, Solaris, \
OpenBSD, FreeBSD, Cygwin, AIX, ...), MacOS X and also for BeOS and Amiga."
HOMEPAGE="http://p7zip.sourceforge.net"
COPYRIGHT="1999-2011 7-Zip Igor Pavlov."
LICENSE="GNU LGPL v2.1"
REVISION="2"
SOURCE_URI="https://github.com/jinfeihan57/p7zip/archive/v$portVersion/p7zip-$portVersion.tar.gz"
CHECKSUM_SHA256="ea029a2e21d2d6ad0a156f6679bd66836204aa78148a4c5e498fe682e77127ef"
PATCHES="p7zip-$portVersion.patchset"
ADDITIONAL_FILES="p7zip-expander-rules"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	p7zip$secondaryArchSuffix = $portVersion
	cmd:7z = $portVersion compat >= 17
	cmd:7za = $portVersion compat >= 9
	cmd:7zr = $portVersion compat >= 17
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	"
if [ "$targetArchitecture" = x86_gcc2 ]; then
	REPLACES="
		p7zip
		"
fi

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	cp makefile.haiku makefile.machine
	make $jobArgs 7z 7zr 7za
}

INSTALL()
{
	make install DEST_DIR="" DEST_HOME=$prefix DEST_SHARE_DOC=$docDir \
		DEST_MAN=$manDir

	expanderRulesDir=$dataDir/expander/rules
	mkdir -p $expanderRulesDir
	cp "$portDir/additional-files/p7zip-expander-rules" \
		"$expanderRulesDir/p7zip"
}
