SUMMARY="X Resize, Rotate and Reflection extension library"
DESCRIPTION="libXrandr provides an X Window System client interface to \
the RandR extension to the X protocol. \
The RandR extension allows for run-time configuration of display attributes \
such as resolution, rotation, and reflection."
HOMEPAGE="https://www.x.org/releases/individual/lib/"
COPYRIGHT="2000, Compaq Computer Corporation.
	2002 Hewlett-Packard Company, Inc.
	2006 Intel Corporation
	2008 Red Hat, Inc.
	2011 Dave Airlie
	2006 Keith Packard"
LICENSE="MIT (no promotion)"
REVISION="2"
SOURCE_URI="https://www.x.org/releases/individual/lib/libXrandr-$portVersion.tar.bz2"
CHECKSUM_SHA256="8aea0ebe403d62330bb741ed595b53741acf45033d3bda1792f1d4cc3daee023"
SOURCE_DIR="libXrandr-$portVersion"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86"

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

# server-interfacing: needs libX11_xcb.

PROVIDES="
	libxrandr$secondaryArchSuffix = $portVersion
	lib:libXrandr$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libX11_xcb$secondaryArchSuffix
	lib:libXext$secondaryArchSuffix
	lib:libXrender$secondaryArchSuffix
	"

PROVIDES_devel="
	libxrandr${secondaryArchSuffix}_devel = $portVersion
	devel:libXrandr$secondaryArchSuffix = $libVersion
	"
REQUIRES_devel="
	libxrandr$secondaryArchSuffix == $portVersion base
	devel:libX11_xcb$secondaryArchSuffix
	devel:libXext$secondaryArchSuffix
	devel:libXrender$secondaryArchSuffix
	devel:randrproto
	devel:xproto
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libX11_xcb$secondaryArchSuffix
	devel:libXext$secondaryArchSuffix
	devel:libXrender$secondaryArchSuffix
	devel:util_macros
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libxrandr$secondaryArchSuffix \
	$libDir/libXrandr.so.$libVersion

BUILD()
{
	autoreconf -vfi
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

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

	rm -f $libDir/*.la

	prepareInstalledDevelLib libXrandr
	fixPkgconfig

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