################################################################################
#
# xorg.cygclass - functions for building X.Org components
#
# Part of cygport - Cygwin packaging application
# Copyright (C) 2006-2020 Cygport authors
# Provided by the Cygwin project <https://cygwin.com/>
#
# cygport is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cygport is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cygport.  If not, see <https://www.gnu.org/licenses/>.
#
################################################################################

#****h* Cygclasses/xorg.cygclass
#  SYNOPSIS
#  inherit xorg
#  DESCRIPTION
#  X.Org provides the reference implementation of the X11 protocol. Since
#  X11R7.0, packages have been released in a "modular" format, with the server
#  and each library, application, set of headers, and font shipping in it's
#  own autotools-based tarball.
#
#  This cygclass defines the variables necessary to download X.Org packages,
#  either as tarballs (default) or from Git (if git.cygclass is inherit()ed
#  afterwards).
#  HISTORY
#  Previous versions of Cygwin and X11 required some additional build steps:
#  * Cygwin 1.5 did not have proper locale support, so -DX_LOCALE was added to
#    CPPFLAGS to force usage of X11's own locale implementation instead.
#  * Each font package had to be told where to install its fonts during configure.
#  As of X11R7.5 for Cygwin 1.7, neither of these are necessary, so xorg.cygclass
#  relies solely on the build functions provided by autotools.cygclass.
#  INHERITS
#  autotools.cygclass
#****

case ${PN} in
	font-*-dpi*)  ORIG_PN=${PN/-dpi/-}dpi ;;
	font-encodings)  ORIG_PN="encodings" ;;
	xorg-scripts|xorg-util-macros)  ORIG_PN=${PN/xorg-/} ;;
	*)  ORIG_PN=${ORIG_PN:-${PN}} ;;
esac

case ${ORIG_PN} in
	xbitmaps)
		xorg_cat="data"
		xorg_git="xorg/data/bitmaps"
		;;
	xcursor-themes)
		xorg_cat="data"
		xorg_git="xorg/data/cursors"
		;;
	xkeyboard-config)
		xorg_cat="data"
		xorg_git="xkeyboard-config"
		;;

	xf86-*)
		xorg_cat="driver"
		xorg_git="xorg/driver/${ORIG_PN}"
		;;

	xorg-docs|xorg-sgml-doctools)
		xorg_cat="doc"
		xorg_git=xorg/doc/${ORIG_PN}
		;;

	font-*|encodings)
		xorg_cat="font"
		xorg_git=xorg/font/${ORIG_PN#font-}
		;;

	lib*)
		xorg_cat="lib"
		xorg_git=xorg/lib/${ORIG_PN}
		;;
	pixman)
		xorg_cat="lib"
		xorg_git="pixman"
		;;
	xtrans)
		xorg_cat="lib"
		xorg_git="xorg/lib/libxtrans"
		;;

	xproxymanagementprotocol)
		xorg_cat="proto"
		xorg_git="xorg/proto/pmproto"
		;;
	*proto)
		xorg_cat="proto"
		xorg_git=xorg/proto/${ORIG_PN}
		;;

	gccmakedep|imake|lndir|makedepend)
		xorg_cat="util"
		xorg_git=xorg/util/${ORIG_PN}
		;;
	xorg-cf-files)
		xorg_cat="util"
		xorg_git="xorg/util/cf"
		;;
	util-macros)
		xorg_cat="util"
		xorg_git="xorg/util/macros"
		;;

	xts)
		xorg_cat="test"
		xorg_git="xorg/test/xts"
		;;

	rendercheck)
		xorg_cat="test"
		xorg_git="xorg/test/rendercheck"
		;;

	xorg-server)
		xorg_cat="xserver"
		xorg_git="xorg/xserver"
		;;

	*)
		xorg_cat="app"
		xorg_git=xorg/app/${ORIG_PN}
		;;
esac

#****o* xorg.cygclass/CATEGORY (xorg)
#  DEFINITION
CATEGORY="X11"
#****
#****o* xorg.cygclass/SUMMARY (xorg)
#  DEFINITION
SUMMARY="X.Org ${ORIG_PN} component"
#****
#****o* xorg.cygclass/HOMEPAGE (xorg)
#  DEFINITION
HOMEPAGE="https://www.x.org/"
#****
#****o* xorg.cygclass/LICENSE (xorg)
#  DEFINITION
LICENSE="MIT"
#****

#****o* xorg.cygclass/XORG_SRC_COMPRESSION
#  DESCRIPTION
#  The compression extension used in the default SRC_URI, set by the xorg
#  cygclass.  For backwards compatibility, this defaults to 'bz2', but a
#  different value may be needed for X.Org packages which no longer provide
#  tarballs using that compression.
#  DEFINITION
XORG_SRC_COMPRESSION="${XORG_SRC_COMPRESSION:-bz2}"
#****

#****o* xorg.cygclass/SRC_URI (xorg)
#  DESCRIPTION
#  Download location of the release tarball.
#****
SRC_URI="https://www.x.org/releases/individual/${xorg_cat}/${ORIG_PN}-${PV}.tar.${XORG_SRC_COMPRESSION}"

#****o* xorg.cygclass/GIT_URI (xorg)
#  DESCRIPTION
#  Git repository for the package.
#  NOTE
#  git.cygclass should be inherit()ed last for this to be of use.
#****
GIT_URI="git://anongit.freedesktop.org/git/${xorg_git}"

unset xorg_cat xorg_git
