SUMMARY="An atomic memory update operations portable implementation"
DESCRIPTION="Semi-portable access to hardware-provided atomic memory update \
operations on a number architectures."
HOMEPAGE="https://github.com/ivmai/libatomic_ops"
COPYRIGHT="2008-2021 Ivan Maidanski
	1991-1994 Xerox Corporation
	1996-1999 Silicon Graphics
	1999-2011 Hewlett-Packard Development Company, L.P.
	2005, 2007 Thiemo Seufer
	2007 NEC LE-IT
	2009 Bradley Smith
	2009 Takashi YOSHII"
LICENSE="MIT
	Boehm
	GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/ivmai/libatomic_ops/releases/download/v$portVersion/libatomic_ops-$portVersion.tar.gz"
CHECKSUM_SHA256="f0ab566e25fce08b560e1feab6a3db01db4a38e5bc687804334ef3920c549f3e"

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

libVersion="1.1.1"
libGplVersion="1.1.2"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
libGplVersionCompat="$libGplVersion compat >= ${libGplVersion%%.*}"

PROVIDES="
	libatomic_ops$secondaryArchSuffix = $portVersion
	lib:libatomic_ops$secondaryArchSuffix = $libVersionCompat
	lib:libatomic_ops_gpl$secondaryArchSuffix = $libGplVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libatomic_ops${secondaryArchSuffix}_devel = $portVersion
	devel:libatomic_ops$secondaryArchSuffix = $libVersionCompat
	devel:libatomic_ops_gpl$secondaryArchSuffix = $libGplVersionCompat
	"
REQUIRES_devel="
	libatomic_ops$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:find
	cmd:gawk
	cmd:gcc$secondaryArchSuffix
	cmd:grep
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:sed
	"

defineDebugInfoPackage libatomic_ops$secondaryArchSuffix \
	"$libDir"/libatomic_ops.so.$libVersion \
	"$libDir"/libatomic_ops_gpl.so.$libGplVersion

BUILD()
{
	runConfigure ./configure --disable-dependency-tracking \
		--enable-shared \
		--with-gnu-ld

	make $jobArgs
}

INSTALL()
{
	make install

	mkdir -p $developDocDir
	mv $docDir/README* $developDocDir

	# remove libtool files
	rm -f $libDir/libatomic_ops*.la

	prepareInstalledDevelLibs \
		libatomic_ops \
		libatomic_ops_gpl
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
