SUMMARY="X Input extension library"
DESCRIPTION="libxi is an extension to the X11 protocol to support input \
devices other than the core X keyboard and pointer. It allows client programs \
to select input from these devices independently from each other and \
independently from the core devices."
HOMEPAGE="http://xorg.freedesktop.org/releases/individual/lib/"
COPYRIGHT="1989, 1998 The Open Group"
LICENSE="MIT (no promotion)"
REVISION="2"
SOURCE_URI="https://www.x.org/archive/individual/lib/libXi-$portVersion.tar.bz2"
CHECKSUM_SHA256="36a30d8f6383a72e7ce060298b4b181fd298bc3a135c8e201b7ca847f5f81061"
SOURCE_DIR="libXi-$portVersion"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86"

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

# server-interfacing: needs libX11_xcb.

PROVIDES="
	libxi$secondaryArchSuffix = $portVersion
	lib:libXi$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libX11_xcb$secondaryArchSuffix
	lib:libXext$secondaryArchSuffix
	lib:libXfixes$secondaryArchSuffix
	"

PROVIDES_devel="
	libxi${secondaryArchSuffix}_devel = $portVersion
	devel:libXi$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libxi$secondaryArchSuffix == $portVersion base
	devel:inputproto
	devel:libX11_xcb$secondaryArchSuffix
	devel:libXext$secondaryArchSuffix
	devel:libXfixes$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	docbook_xml_dtd
	docbook_xsl_stylesheets
	devel:libX11_xcb$secondaryArchSuffix
	devel:libXext$secondaryArchSuffix
	devel:libXfixes$secondaryArchSuffix
	devel:util_macros
	devel:xorg_sgml_doctools
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	#cmd:asciidoc
	cmd:autoconf
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:xmlto
	cmd:xsltproc
	"

defineDebugInfoPackage libxi$secondaryArchSuffix \
	$libDir/libXi.so.$libVersion

BUILD()
{
	autoreconf -vfi
	runConfigure --omit-dirs docDir ./configure --docdir=$developDocDir
	make $jobArgs
}

INSTALL()
{
	make install

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

	rm -rf $libDir/libXi.la

	fixPkgconfig
	prepareInstalledDevelLib libXi

	# devel package
	packageEntries devel \
		$developDir \
		${maybe_manDir:+"$maybe_manDir"}
}
