SUMMARY="X.Org's C Bindings library"
DESCRIPTION="XCB provides application binary interface compatibility with \
both Xlib and XCB, providing an incremental porting path. XCB uses \
the protocol layer of Xlib, but replaces the Xlib transport layer with \
XCB, and provides access to the underlying XCB connection for direct use \
of XCB.
XCB allows an application to open a single connection to the Xdisplay server \
and use both XCB and Xlib, possibly through a mixture of libraries designed \
for one or the other."
HOMEPAGE="https://xcb.freedesktop.org/"
COPYRIGHT="2001-2006 Bart Massey, Jamey Sharp, and Josh Triplett"
LICENSE="MIT (no promotion)"
REVISION="1"
SOURCE_URI="https://xcb.freedesktop.org/dist/libxcb-$portVersion.tar.bz2"
CHECKSUM_SHA256="a89fb7af7a11f43d2ce84a844a4b38df688c092bf4b67683aef179cdf2a647c4"
PATCHES="libxcb-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

versionedXcbLibs="
	libxcb
	libxcb_randr
	libxcb_sync
	libxcb_xinput
	libxcb_xkb
	"
libVersion=0.0.0
libxcbVersion=1.1.0
libxcb_randrVersion=0.1.0
libxcb_syncVersion=1.0.0
libxcb_xinputVersion=0.1.0
libxcb_xkbVersion=1.0.0
for i in lib $versionedXcbLibs; do
	eval "${i}VersionCompat=\"\$${i}Version compat >= \${${i}Version%%.*}\""
done
otherXcbLibs="
	libxcb_composite
	libxcb_damage
	libxcb_dpms
	libxcb_dri2
	libxcb_dri3
	libxcb_glx
	libxcb_present
	libxcb_record
	libxcb_render
	libxcb_res
	libxcb_screensaver
	libxcb_shape
	libxcb_shm
	libxcb_xf86dri
	libxcb_xfixes
	libxcb_xinerama
	libxcb_xtest
	libxcb_xv
	libxcb_xvmc
	"

PROVIDES="
	libxcb$secondaryArchSuffix = $portVersion
	lib:libxcb$secondaryArchSuffix = $libxcbVersionCompat
	lib:libxcb_composite$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_damage$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_dpms$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_dri2$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_dri3$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_glx$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_present$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_randr$secondaryArchSuffix = $libxcb_randrVersionCompat
	lib:libxcb_record$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_render$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_res$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_screensaver$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_shape$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_shm$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_sync$secondaryArchSuffix = $libxcb_syncVersionCompat
	lib:libxcb_xf86dri$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_xfixes$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_xinerama$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_xinput$secondaryArchSuffix = $libxcb_xinputVersionCompat
	lib:libxcb_xkb$secondaryArchSuffix = $libxcb_xkbVersionCompat
	lib:libxcb_xtest$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_xv$secondaryArchSuffix = $libVersionCompat
	lib:libxcb_xvmc$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcheck$secondaryArchSuffix
	lib:libXau$secondaryArchSuffix
	lib:libXdmcp$secondaryArchSuffix
	"

PROVIDES_devel="
	libxcb${secondaryArchSuffix}_devel = $portVersion
	devel:libxcb$secondaryArchSuffix = $libxcbVersionCompat
	devel:libxcb_composite$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_damage$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_dpms$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_dri2$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_dri3$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_glx$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_present$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_randr$secondaryArchSuffix = $libxcb_randrVersionCompat
	devel:libxcb_record$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_render$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_res$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_screensaver$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_shape$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_shm$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_sync$secondaryArchSuffix = $libxcb_syncVersionCompat
	devel:libxcb_xf86dri$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_xfixes$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_xinerama$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_xinput$secondaryArchSuffix = $libxcb_xinputVersionCompat
	devel:libxcb_xkb$secondaryArchSuffix = $libxcb_xkbVersionCompat
	devel:libxcb_xtest$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_xv$secondaryArchSuffix = $libVersionCompat
	devel:libxcb_xvmc$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libxcb$secondaryArchSuffix == $portVersion base
	devel:libpthread_stubs
	devel:libXau$secondaryArchSuffix
	devel:libXdmcp$secondaryArchSuffix
	devel:xcb_proto
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcheck$secondaryArchSuffix
	devel:libpthread_stubs
	devel:libXau$secondaryArchSuffix
	devel:libXdmcp$secondaryArchSuffix
	devel:util_macros
	devel:xcb_proto
	devel:xproto
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
#	cmd:dot$secondaryArchSuffix
#	cmd:doxygen
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python
	cmd:xsltproc
	"

debugList=(
	"$libDir"/libxcb.so.$libxcbVersion
	"$libDir"/libxcb-randr.so.$libxcb_randrVersion
	"$libDir"/libxcb-sync.so.$libxcb_syncVersion
	"$libDir"/libxcb-xinput.so.$libxcb_xinputVersion
	"$libDir"/libxcb-xkb.so.$libxcb_xkbVersion
	)
for i in $otherXcbLibs; do
	debugList+=("$libDir"/${i/_/-}.so.$libVersion)
done
defineDebugInfoPackage libxcb$secondaryArchSuffix "${debugList[@]}"

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

INSTALL()
{
	make install
	install -d -m 755 "$developDocDir"
	install -m 644 -t "$developDocDir" README

	# remove libtool library files
	rm $libDir/libxcb*.la

	prepareInstalledDevelLibs ${versionedXcbLibs//_/-} ${otherXcbLibs//_/-}
	fixPkgconfig

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $manDir
		maybe_manDir_man3=
	else
		maybe_manDir_man3=$manDir/man3
	fi

	# devel package
	packageEntries devel \
		$developDir \
		$maybe_manDir_man3

#	remove the empty $documentationDir on primary architecture
	rm -fr $documentationDir
}

TEST()
{
	make check
}
