SUMMARY="Manage floppy disk image formats"
DESCRIPTION="The HxC floppy emulator is a device that replaces a floppy drive \
and allows to use an SD card or USB drive instead of old floppies. This library \
allows to manage floppy image in the HFE format used by the emulator, as well \
as several other common floppy image formats."
HOMEPAGE="https://sourceforge.net/projects/hxcfloppyemu/"
COPYRIGHT="2006-2016 Jean-François Del Nero"
LICENSE="GNU GPL v3"
REVISION="2"
SOURCE_URI="https://github.com/jfdelnero/libhxcfe/archive/libhxcfe_V2_4_6_0.tar.gz"
CHECKSUM_SHA256="af37d7fb7cd7634af287b8795bf22d6511097cb8666b82baaa05cf6c646f7b7e"
SOURCE_DIR="libhxcfe-libhxcfe_V2_4_6_0"
SOURCE_URI_2="https://github.com/jfdelnero/libhxcadaptor/archive/libhxcadaptor_V2_0_0_5.tar.gz"
CHECKSUM_SHA256_2="2777d2d86a93113dfc3502e3fb7f2f179aa84a94712947c68374c379336185ad"
SOURCE_DIR_2="libhxcadaptor-libhxcadaptor_V2_0_0_5"
SOURCE_URI_3="https://github.com/jfdelnero/libusbhxcfe/archive/libusbhxcfe_V2_0_0_4.tar.gz"
CHECKSUM_SHA256_3="41c16f6539ec6cd6da6c76c94945092d440be4870ff81f308e946e6dfe10e866"
SOURCE_DIR_3="libusbhxcfe-libusbhxcfe_V2_0_0_4"
PATCHES="libhxcfe-$portVersion.patchset"
PATCHES_2="libhxcadaptor-$portVersion.patchset"

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

PROVIDES="
	libhxcfe$secondaryArchSuffix = $portVersion
	lib:libhxcfe$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libhxcfe${secondaryArchSuffix}_devel = $portVersion
	devel:libhxcadaptor$secondaryArchSuffix
	devel:libhxcfe$secondaryArchSuffix
	"
REQUIRES_devel="
	haiku${secondaryArchSuffix}_devel
	libhxcfe$secondaryArchSuffix == $portVersion base
	"

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

BUILD()
{
	# Prepare directories so the sub-projects can see each other…
	mkdir -p ../../libhxcadaptor
	ln -sf ../sources-2/libhxcadaptor-libhxcadaptor_V2_0_0_5 ../../libhxcadaptor/trunk

	mkdir -p ../../libusbhxcfe
	ln -sf ../sources-3/libusbhxcfe-libusbhxcfe_V2_0_0_4 ../../libusbhxcfe/trunk

	mkdir -p ../../libhxcfe
	ln -sf ../sources/libhxcfe-libhxcfe_V2_4_6_0 ../../libhxcfe/trunk

	# Prepare the output dir where all .a files will be put…
	mkdir -p ../../build

	# Build platform abstraction layer…
	pushd ../../sources-2/libhxcadaptor-libhxcadaptor_V2_0_0_5/build
	make $jobArgs
	popd

	# Build floppy image management library…
	cd build
	make $jobArgs
}

INSTALL()
{
	mkdir -p $libDir $includeDir $includeDir/tracks

	cp ../../build/*.* $libDir
	cp ../../sources-2/*/sources/*.h $includeDir
	cp sources/*.h $includeDir
	cp sources/tracks/*.h $includeDir/tracks/

	prepareInstalledDevelLibs \
		libhxcfe libhxcadaptor
	packageEntries devel \
		$developDir
}
