SUMMARY="A user-friendly tool to ease the distribution of very large files"
DESCRIPTION="jigit aims to be a user-friendly wrapper for jigit-mkimage. \
jigit-mkimage is a simple but fast tool to reconstruct large image files from \
\".jigdo\" and \".template\" files. \
It doesn't have any logic to cope with downloading missing files, but will \
list the missing files that are needed. \
It is also convenient in case the user has a partially outdated optical media \
or ISO image containing at least some files which are not outdated."
HOMEPAGE="https://www.einval.com/~steve/software/JTE/"
COPYRIGHT="2004-2019 Steve McIntyre
	2000-2010 George Danchev, Thomas Schmitt"
LICENSE="GNU GPL v2
	GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="$HOMEPAGE/download/jigit-$portVersion.tar.xz"
CHECKSUM_SHA256="8a1da3fb7b817174c6c19d71ede19a4b8d0ae433fc5e967d33abf74b545f9954"
PATCHES="jigit-$portVersion.patchset"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="2.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	jigit$secondaryArchSuffix = $portVersion
	lib:libjte$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	jigit${secondaryArchSuffix}_devel = $portVersion
	devel:libjte$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	jigit$secondaryArchSuffix == $portVersion base
	"

PROVIDES_tools="
	jigit${secondaryArchSuffix}_tools = $portVersion
	cmd:extract_data$commandSuffix = $portVersion
	cmd:jigdump$commandSuffix = $portVersion
	cmd:jigit$commandSuffix = $portVersion
	cmd:jigsum$commandSuffix = $portVersion
	cmd:jigsum_sha256$commandSuffix = $portVersion
	cmd:jigit_mkimage$commandSuffix = $portVersion
	cmd:mkjigsnap$commandSuffix = $portVersion
	cmd:parallel_sums$commandSuffix = $portVersion
	cmd:rsyncsum$commandSuffix = $portVersion
	"
REQUIRES_tools="
	jigit$secondaryArchSuffix == $portVersion base
	haiku$secondaryArchSuffix
	cmd:awk
	cmd:bash
	cmd:wc
	cmd:wget
	cmd:xargs
	lib:libbz2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:touch
	"

BUILD()
{
	cd libjte
	touch NEWS README AUTHORS
	autoreconf -vfi
	runConfigure ./configure
	make $jobArgs
	make -C ../
}

INSTALL()
{
	install -m 755 -d "$commandBinDir" "$manDir"/man1 "$manDir"/man8
	install -m 755 -t "$commandBinDir" \
		extract-data jigdump jigit jigit-mkimage jigsum jigsum-sha256\
		mkjigsnap parallel-sums rsyncsum
	install -m 644 -t "$manDir"/man1 *.1
	install -m 644 -t "$manDir"/man8 *.8

	cd libjte && make install
	rm -f $libDir/*.la
	prepareInstalledDevelLib libjte
	fixPkgconfig

	packageEntries devel \
		$developDir
	packageEntries tools \
		$commandBinDir
}
