SUMMARY="A minimalist implementation of a client library for SMB using C"
DESCRIPTION="lib Defective SMb (libDSM) is a SMB protocol client \
implementation in pure old C, with a lot less features than Samba but with a \
much simpler, and a more permissive license (currently LGPL + proprietary).

The initial goal of this project is to have a library that can access most \
SMB shares to read files and that has a license compatible with the \
iOS/Android/WinRT appstores in order to integrate it into VLC for iOS and VLC \
for Android."
HOMEPAGE="https://github.com/videolabs/libdsm"
COPYRIGHT="2003-2020 The Music Player Daemon Project"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://github.com/videolabs/libdsm/releases/download/v${portVersion}/libdsm-${portVersion}.tar.gz"
CHECKSUM_SHA256="6a91269d5756e9648b2453d9234a8010bb3c479b7fb81c809540000b35633d75"

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

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

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

PROVIDES="
	libdsm$secondaryArchSuffix = $portVersion
	cmd:dsm
	cmd:dsm_discover
	cmd:dsm_inverse
	cmd:dsm_lookup
	lib:libdsm$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libtasn1$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libtasn1$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libdsm$secondaryArchSuffix \
	$libDir/libdsm.so.$libVersion

BUILD()
{
	LIBS="-lnetwork" runConfigure --omit-dirs "binDir" ./configure \
		--bindir=$commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libdsm.la

	prepareInstalledDevelLib libdsm
	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
