SUMMARY="X Session Management Library"
DESCRIPTION="The Session Management Library (SMlib) is a low-level \"C\" \
language interface to XSMP. It is expected that higher level toolkits, \
such as Xt, will hide many of the details of session management from \
clients. Higher level toolkits might also be developed for session managers \
to use, but no such effort is currently under way."
HOMEPAGE="https://www.x.org/releases/individual/lib/"
COPYRIGHT="1989, 1998 The Open Group
	2002 Oracle and/or its affiliates"
LICENSE="MIT (no promotion)"
REVISION="2"
SOURCE_URI="https://www.x.org/releases/individual/lib/libSM-$portVersion.tar.bz2"
CHECKSUM_SHA256="2d264499dcb05f56438dee12a1b4b71d76736ce7ba7aa6efbf15ebb113769cbb"
SOURCE_DIR="libSM-$portVersion"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86"

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

PROVIDES="
	libsm$secondaryArchSuffix = $portVersion
	lib:libSM$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libICE$secondaryArchSuffix
	"

PROVIDES_devel="
	libsm${secondaryArchSuffix}_devel = $portVersion
	devel:libSM$secondaryArchSuffix = $libVersion
	"
REQUIRES_devel="
	libsm$secondaryArchSuffix == $portVersion base
	devel:libICE$secondaryArchSuffix
	devel:xproto
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	docbook_xml_dtd
	docbook_xsl_stylesheets
	devel:libICE$secondaryArchSuffix
	devel:util_macros
	devel:xorg_sgml_doctools
	devel:xtrans
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:xmlto
	cmd:xsltproc
	"

defineDebugInfoPackage libsm$secondaryArchSuffix \
	$libDir/libSM.so.$libVersion

BUILD()
{
	export LDFLAGS="-lnetwork"
	autoreconf -vfi
	runConfigure --omit-dirs docDir ./configure \
		--docdir=$developDocDir \
		--enable-tcp-transport
	make $jobArgs
}

INSTALL()
{
	make install

	if [ -z "$secondaryArchSuffix" ]; then
		install -m 0644 -t "$developDocDir" README
	else
		rm -rf "$developDir/documentation"
	fi

	rm -f $libDir/*.la

	prepareInstalledDevelLib libSM
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
