SUMMARY="X.Org X11 library"
DESCRIPTION="The X.Org project provides an open source implementation of the \
X Window System. \
The development work is being done in conjunction with the freedesktop.org \
community. \
The X.Org Foundation is the educational non-profit corporation whose \
Board serves this effort, and whose Members lead this work."
HOMEPAGE="https://www.x.org/"
# TODO: sort & merge
COPYRIGHT="2003-2006,2008 Jamey Sharp, Josh Triplett
	2009 Red Hat, Inc.
	1990-1992,1999,2000,2004,2009,2010 Oracle and/or its affiliates.
	1984-1994, 1998 The Open Group
	1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
	2000 The XFree86 Project, Inc.
	1985, 1986, 1987, 1988, 1989, 1990, 1991, 1993 Digital Equipment Corporation
	1990, 1991 by Tektronix, Inc.
	1999-2000  Free Software Foundation, Inc.
	1990, 1991 Tektronix, Inc.
	1990, 1991, 1992, 1993, 1994, 1995 FUJITSU LIMITED
	1992 by Oki Technosystems Laboratory, Inc.
	1992 by Fuji Xerox Co., Ltd.
	1995 David E. Wexelblat
	1990, 1991 by OMRON Corporation
	1993 Digital Equipment Corporation, Maynard, Massachusetts,
	1994 Sony Corporation
	1991 the Open Software Foundation
	1993, 1994 Sony Corporation
	1993, 1995 Silicon Graphics Computer Systems, Inc.
	1992, 1993 by FUJITSU LIMITED
	1993 Fujitsu Open Systems Solutions, Inc.
	1994 Sony Corporation
	1987, 1988, 1990, 1993 by Digital Equipment Corporation, Maynard, Massachusetts,
	1993 SunSoft, Inc.
	1999-2000 by Bruno Haible
	1991 the Open Software Foundation
	1993 the TOSHIBA Corp
	1988 Wyse Technology, Inc., San Jose, Ca.
	1991 the Open Software Foundation
	1993, 1994 the Sony Corporation
	1992, 1993 FUJITSU LIMITED
	1993 Fujitsu Open Systems Solutions, Inc.
	1993, 1994 Sony Corporation
	1986, 1998 The Open Group
	2000 The XFree86 Project, Inc.
	1990, 1991 OMRON Corporation, NTT Software Corporation, and Nippon Telegraph and Telephone Corporation
	1991 the Open Software Foundation
	1993 the FUJITSU LIMITED
	1988 Wyse Technology, Inc., San Jose, Ca,
	1987 Digital Equipment Corporation, Maynard, Massachusetts
	1991, 1992 Fuji Xerox Co., Ltd.
	1992, 1993, 1994 FUJITSU LIMITED
	2006 Josh Triplett
	1996 Sebastien Marineau and Holger Veit
	1990, 1991 OMRON Corporation, NTT Software Corporation, and Nippon Telegraph and Telephone Corporation
	1991 the Open Software Foundation
	1993 the TOSHIBA Corp.
	1993, 1994 Sony Corporation
	1993, 1994 the FUJITSU LIMITED
	2000 Bruno Haible
	2003 Keith Packard
	2007-2009 Troy D. Hanson
	1992, 1993 TOSHIBA Corp.
	1993 IBM Corporation
	1990, 1991 OMRON Corporation, NTT Software Corporation, and Nippon Telegraph and Telephone Corporation
	"
# TODO: check all the licenses in the COPYING file in the next century.
LICENSE="MIT"
REVISION="3"
SOURCE_URI="https://www.x.org/releases/individual/lib/libX11-$portVersion.tar.bz2"
CHECKSUM_SHA256="9cc7e8d000d6193fa5af580d50d689380b8287052270f5bb26a5fb6b58b2bed1"
SOURCE_DIR="libX11-$portVersion"
# TODO: fix the remaining xmlto conversions
PATCHES="libx11-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

# TODO: patch to detect libnetwork

# main lib: provides intentionally disabled, so this package is never
# used without explicit request, so xlibe is used by default instead.
PROVIDES="
	libx11$secondaryArchSuffix = $portVersion
#	lib:libX11$secondaryArchSuffix = 6.3.0 compat >= 6
#	lib:libX11_xcb$secondaryArchSuffix = 1.0.0 compat >= 1
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libXcb$secondaryArchSuffix
	"

PROVIDES_devel="
	libx11${secondaryArchSuffix}_devel = $portVersion
#	devel:libX11$secondaryArchSuffix = 6.3.0 compat >= 6
#	devel:libX11_xcb$secondaryArchSuffix = 1.0.0 compat >= 1
	"
REQUIRES_devel="
	libx11$secondaryArchSuffix == $portVersion base
	devel:libXcb$secondaryArchSuffix
	devel:kbproto
	devel:xproto
	"

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

defineDebugInfoPackage libx11$secondaryArchSuffix \
	"$libDir"/libX11.so.6.3.0 \
	"$libDir"/libX11-xcb.so.1.0.0

BUILD()
{
	export CPPFLAGS="-D_BSD_SOURCE"
	export LDFLAGS="-lnetwork"
	autoreconf -vfi
	# --disable-selective-werror else makekeys does not even reach main()
	runConfigure --omit-dirs docDir ./configure \
		--docdir=$developDocDir \
		--disable-selective-werror \
		--enable-static=no \
		--enable-unix-transport \
		--enable-loadable-i18n \
		--enable-xlocaledir
	make $jobArgs
}

INSTALL()
{
	make install-strip

	rm -f $libDir/lib*.la
	rm -f $libDir/X11/locale/common/*.la

	prepareInstalledDevelLibs \
		libX11 \
		libX11-xcb

	fixPkgconfig

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

	packageEntries devel \
		$developDir \
		$maybe_manDir_man3
}

TEST()
{
	make check
}
