SUMMARY="A client library to multiplex connections from and to iOS devices"
DESCRIPTION="libusbmuxd is a client library to multiplex connections from and \
to iOS devices by connecting to a socket provided by a usbmuxd daemon."
HOMEPAGE="https://www.libimobiledevice.org/"
COPYRIGHT="2013-2014 Nikias Bassen
	2009-2014 Martin Szulecki"
LICENSE="GNU GPL v2
	GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://github.com/libimobiledevice/libusbmuxd/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="8ae3e1d9340177f8f3a785be276435869363de79f491d05d8a84a59efc8a8fdc"
SOURCE_FILENAME="libusbmuxd-$portVersion.tar.gz"
PATCHES="libusbmuxd-$portVersion.patchset"

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

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

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

PROVIDES="
	libusbmuxd$secondaryArchSuffix = $portVersion
	lib:libusbmuxd_2.0$secondaryArchSuffix = $libVersionCompat
	cmd:iproxy$commandSuffix
	cmd:inetcat$commandSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libplist_2.0$secondaryArchSuffix
	lib:libplist++_2.0$secondaryArchSuffix
	"

PROVIDES_devel="
	libusbmuxd${secondaryArchSuffix}_devel = $portVersion
	devel:libusbmuxd_2.0$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libusbmuxd$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libxml2$secondaryArchSuffix
	devel:libplist_2.0$secondaryArchSuffix
	devel:libplist++_2.0$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:automake
	cmd:autoreconf
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libusbmuxd$secondaryArchSuffix \
	"$commandBinDir"/iproxy \
	"$libDir"/libusbmuxd-2.0.so.$libVersion

BUILD()
{
	autoreconf -fi
	runConfigure --omit-dirs binDir ./configure --bindir=$commandBinDir
	make
}

INSTALL()
{
	make install

	# remove libtool file
	rm $libDir/libusbmuxd*.*a

	prepareInstalledDevelLib libusbmuxd-2.0
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
