SUMMARY="X.Org's C Bindings protocol headers"
DESCRIPTION="The X C Bindings protocol headers."
HOMEPAGE="https://xcb.freedesktop.org/"
COPYRIGHT="2001-2018 Bart Massey, Jamey Sharp, and Josh Triplett."
LICENSE="MIT (no promotion)"
REVISION="2"
SOURCE_URI="https://xcb.freedesktop.org/dist/xcb-proto-$portVersion.tar.bz2"
CHECKSUM_SHA256="7b98721e669be80284e9bbfeab02d2d0d54cd11172b72271e47a2fe875e2bde1"
SOURCE_DIR="xcb-proto-$portVersion"

ARCHITECTURES="any"

PROVIDES="
	xcb_proto = $portVersion
	devel:xcb_proto = $portVersion
	"
REQUIRES="
	haiku
	lib:libxml2
	"

BUILD_REQUIRES="
	haiku_devel
	devel:libxml2
	devel:util_macros
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:gcc
	cmd:make
	cmd:pkg_config
	cmd:python
	"

BUILD()
{
	autoreconf -vfi
	runConfigure --omit-dirs libDir ./configure --libdir=$dataDir
	# force python dirs as the autodected one is the non-packaged one.
	export PATH="$portPackageLinksDir/cmd~python/bin:$PATH"
	pythonVersion=$(python --version 2>&1 | sed 's/Python //' | head -c3)
	export pyexecdir=$prefix/lib/python$pythonVersion/vendor-packages
	export pythondir=$prefix/lib/python$pythonVersion/vendor-packages
	make pyexecdir=$pyexecdir pythondir=$pythondir
}

INSTALL()
{
	# force python dirs as the autodected one is the non-packaged one.
	export PATH="$portPackageLinksDir/cmd~python/bin:$PATH"
	pythonVersion=$(python --version 2>&1 | sed 's/Python //' | head -c3)
	export pyexecdir=$prefix/lib/python$pythonVersion/vendor-packages
	export pythondir=$prefix/lib/python$pythonVersion/vendor-packages
	# the .pc file doesn't get it anyway, force it
	sed -i "s,pythondir=.*/site-packages,pythondir=\${prefix}/lib/python$pythonVersion/vendor-packages," \
		xcb-proto.pc
	make install DESTDIR=/ pyexecdir=$pyexecdir pythondir=$pythondir
	fixPkgconfig
}

TEST()
{
	make check
}
