1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: xorg-3.eclass
8 # Author: Tomáš Chvátal <scarabeus@gentoo.org>
9 # Author: Donnie Berkholz <dberkholz@gentoo.org>
10 # Author: Matt Turner <mattst88@gentoo.org>
12 # @BLURB: Reduces code duplication in the modularized X11 ebuilds.
14 # This eclass makes trivial X ebuilds possible for apps, drivers,
15 # and more. Many things that would normally be done in various functions
16 # can be accessed by setting variables instead, such as patching,
17 # running eautoreconf, passing options to configure and installing docs.
19 # All you need to do in a basic ebuild is inherit this eclass and set
20 # DESCRIPTION, KEYWORDS and RDEPEND/DEPEND. If your package is hosted
21 # with the other X packages, you don't need to set SRC_URI. Pretty much
22 # everything else should be automatic.
25 if [[ ${PV} == *9999* ]]; then
27 XORG_EAUTORECONF="yes"
30 # @ECLASS-VARIABLE: XORG_MULTILIB
32 # If set to 'yes', the multilib support for package will be enabled. Set
33 # before inheriting this eclass.
34 : ${XORG_MULTILIB:="no"}
36 # we need to inherit autotools first to get the deps
37 inherit autotools libtool multilib toolchain-funcs flag-o-matic ${GIT_ECLASS}
39 if [[ ${XORG_MULTILIB} == yes ]]; then
40 inherit multilib-minimal
43 EXPORTED_FUNCTIONS="src_prepare src_configure src_unpack src_compile src_install"
46 *) die "EAPI=${EAPI} is not supported" ;;
49 # exports must be ALWAYS after inherit
50 EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
54 # @ECLASS-VARIABLE: XORG_EAUTORECONF
56 # If set to 'yes' and configure.ac exists, eautoreconf will run. Set
57 # before inheriting this eclass.
58 : ${XORG_EAUTORECONF:="no"}
60 # @ECLASS-VARIABLE: XORG_BASE_INDIVIDUAL_URI
62 # Set up SRC_URI for individual modular releases. If set to an empty
63 # string, no SRC_URI will be provided by the eclass.
64 : ${XORG_BASE_INDIVIDUAL_URI="https://www.x.org/releases/individual"}
66 # @ECLASS-VARIABLE: XORG_MODULE
68 # The subdirectory to download source from. Possible settings are app,
69 # doc, data, util, driver, lib, proto, xserver. Set above the
70 # inherit to override the default autoconfigured module.
71 : ${XORG_MODULE:="auto"}
72 if [[ ${XORG_MODULE} == auto ]]; then
74 app-doc) XORG_MODULE=doc/ ;;
75 x11-apps|x11-wm) XORG_MODULE=app/ ;;
76 x11-misc|x11-themes) XORG_MODULE=util/ ;;
77 x11-base) XORG_MODULE=xserver/ ;;
78 x11-drivers) XORG_MODULE=driver/ ;;
79 x11-libs) XORG_MODULE=lib/ ;;
84 # @ECLASS-VARIABLE: XORG_PACKAGE_NAME
86 # For git checkout the git repository might differ from package name.
87 # This variable can be used for proper directory specification
88 : ${XORG_PACKAGE_NAME:=${PN}}
90 HOMEPAGE="https://www.x.org/wiki/ https://gitlab.freedesktop.org/xorg/${XORG_MODULE}${XORG_PACKAGE_NAME}"
92 if [[ -n ${GIT_ECLASS} ]]; then
93 : ${EGIT_REPO_URI:="https://gitlab.freedesktop.org/xorg/${XORG_MODULE}${XORG_PACKAGE_NAME}.git"}
94 elif [[ -n ${XORG_BASE_INDIVIDUAL_URI} ]]; then
95 SRC_URI="${XORG_BASE_INDIVIDUAL_URI}/${XORG_MODULE}${P}.tar.bz2"
100 # Set the license for the package. This can be overridden by setting
101 # LICENSE after the inherit. Nearly all FreeDesktop-hosted X packages
102 # are under the MIT license. (This is what Red Hat does in their rpms)
105 # Set up autotools shared dependencies
106 # Remember that all versions here MUST be stable
107 XORG_EAUTORECONF_ARCHES="ppc-aix x86-winnt"
108 EAUTORECONF_DEPEND+="
109 >=sys-devel/libtool-2.2.6a
111 if [[ ${PN} != util-macros ]] ; then
112 EAUTORECONF_DEPEND+=" >=x11-misc/util-macros-1.18 >=media-fonts/font-util-1.2.0"
114 WANT_AUTOCONF="latest"
115 WANT_AUTOMAKE="latest"
116 for arch in ${XORG_EAUTORECONF_ARCHES}; do
117 EAUTORECONF_DEPENDS+=" ${arch}? ( ${EAUTORECONF_DEPEND} )"
119 DEPEND+=" ${EAUTORECONF_DEPENDS}"
120 [[ ${XORG_EAUTORECONF} != no ]] && BDEPEND+=" ${EAUTORECONF_DEPEND}"
121 unset EAUTORECONF_DEPENDS
122 unset EAUTORECONF_DEPEND
124 # @ECLASS-VARIABLE: XORG_STATIC
126 # Enables static-libs useflag. Set to no, if your package gets:
128 # QA: configure: WARNING: unrecognized options: --disable-static
129 : ${XORG_STATIC:="yes"}
131 # Add static-libs useflag where useful.
132 if [[ ${XORG_STATIC} == yes \
133 && ${CATEGORY} != app-doc \
134 && ${CATEGORY} != x11-apps \
135 && ${CATEGORY} != x11-drivers \
136 && ${PN} != util-macros \
137 && ${PN} != xbitmaps \
138 && ${PN} != xorg-cf-files \
139 && ${PN/xcursor} = ${PN} ]]; then
143 if [[ ${XORG_MULTILIB} == yes ]]; then
144 BDEPEND+=" virtual/pkgconfig[${MULTILIB_USEDEP}]"
146 BDEPEND+=" virtual/pkgconfig"
149 # @ECLASS-VARIABLE: XORG_DRI
151 # Possible values are "always" or the value of the useflag DRI capabilities
152 # are required for. Default value is "no"
154 # Eg. XORG_DRI="opengl" will pull all dri dependent deps for opengl useflag
158 x11-base/xorg-server[-minimal]
165 COMMON_DEPEND+=" ${DRI_COMMON_DEPEND}"
168 COMMON_DEPEND+=" ${XORG_DRI}? ( ${DRI_COMMON_DEPEND} )"
172 unset DRI_COMMON_DEPEND
174 if [[ ${PN} == xf86-video-* || ${PN} == xf86-input-* ]]; then
175 DEPEND+=" x11-base/xorg-proto"
176 RDEPEND+=" x11-base/xorg-server:="
177 COMMON_DEPEND+=" >=x11-base/xorg-server-1.20[xorg]"
178 [[ ${PN} == xf86-video-* ]] && COMMON_DEPEND+=" >=x11-libs/libpciaccess-0.14"
182 # @ECLASS-VARIABLE: XORG_DOC
184 # Possible values are "always" or the value of the useflag doc packages
185 # are required for. Default value is "no"
187 # Eg. XORG_DOC="manual" will pull all doc dependent deps for manual useflag
192 || ( app-text/asciidoc dev-ruby/asciidoctor )
195 app-text/docbook-xml-dtd:4.1.2
196 app-text/docbook-xml-dtd:4.2
197 app-text/docbook-xml-dtd:4.3
204 BDEPEND+=" ${DOC_DEPEND}"
207 BDEPEND+=" ${XORG_DOC}? ( ${DOC_DEPEND} )"
213 DEPEND+=" ${COMMON_DEPEND}"
214 RDEPEND+=" ${COMMON_DEPEND}"
217 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND=${DEPEND}"
218 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: RDEPEND=${RDEPEND}"
219 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: PDEPEND=${PDEPEND}"
220 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: BDEPEND=${BDEPEND}"
222 # @FUNCTION: xorg-3_src_unpack
224 # Simply unpack source code.
225 xorg-3_src_unpack() {
226 debug-print-function ${FUNCNAME} "$@"
228 if [[ -n ${GIT_ECLASS} ]]; then
235 # @FUNCTION: xorg-3_reconf_source
237 # Run eautoreconf if necessary, and run elibtoolize.
238 xorg-3_reconf_source() {
239 debug-print-function ${FUNCNAME} "$@"
243 # some hosts need full eautoreconf
244 [[ -e "./configure.ac" || -e "./configure.in" ]] \
245 && XORG_EAUTORECONF=yes
248 # elibtoolize required for BSD
249 [[ ${XORG_EAUTORECONF} != no && ( -e "./configure.ac" || -e "./configure.in" ) ]] \
250 && XORG_EAUTORECONF=yes
254 [[ ${XORG_EAUTORECONF} != no ]] && eautoreconf
255 elibtoolize --patch-only
258 # @FUNCTION: xorg-3_src_prepare
260 # Prepare a package after unpacking, performing all X-related tasks.
261 xorg-3_src_prepare() {
262 debug-print-function ${FUNCNAME} "$@"
268 # @FUNCTION: xorg-3_flags_setup
270 # Set up CFLAGS for a debug build
271 xorg-3_flags_setup() {
272 debug-print-function ${FUNCNAME} "$@"
274 # Win32 require special define
275 [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__
277 [[ ${PN} == xorg-server || ${PN} == xf86-video-* || ${PN} == xf86-input-* ]] \
278 && append-ldflags -Wl,-z,lazy
280 # Quite few libraries fail on runtime without these:
281 if has static-libs ${IUSE//+}; then
282 filter-flags -Wl,-Bdirect
283 filter-ldflags -Bdirect
284 filter-ldflags -Wl,-Bdirect
288 multilib_src_configure() {
289 ECONF_SOURCE="${S}" econf "${econfargs[@]}"
292 # @FUNCTION: xorg-3_src_configure
294 # Perform any necessary pre-configuration steps, then run configure
295 xorg-3_src_configure() {
296 debug-print-function ${FUNCNAME} "$@"
300 # @VARIABLE: XORG_CONFIGURE_OPTIONS
302 # Array of an additional options to pass to configure.
304 local xorgconfadd=("${XORG_CONFIGURE_OPTIONS[@]}")
306 # Check if package supports disabling of dep tracking
307 # Fixes warnings like:
308 # WARNING: unrecognized options: --disable-dependency-tracking
309 if grep -q -s "disable-depencency-tracking" ${ECONF_SOURCE:-.}/configure; then
310 local dep_track="--disable-dependency-tracking"
313 # Check if package supports disabling of selective -Werror=...
314 if grep -q -s "disable-selective-werror" ${ECONF_SOURCE:-.}/configure; then
315 local selective_werror="--disable-selective-werror"
324 # Handle static-libs found in IUSE, disable them by default
325 if in_iuse static-libs; then
328 $(use_enable static-libs static)
332 if [[ ${XORG_MULTILIB} == yes ]]; then
333 multilib-minimal_src_configure "$@"
335 econf "${econfargs[@]}" "$@"
339 multilib_src_compile() {
340 emake "$@" || die 'emake failed'
343 # @FUNCTION: xorg-3_src_compile
345 # Compile a package, performing all X-related tasks.
346 xorg-3_src_compile() {
347 debug-print-function ${FUNCNAME} "$@"
349 if [[ ${XORG_MULTILIB} == yes ]]; then
350 multilib-minimal_src_compile "$@"
352 emake "$@" || die 'emake failed'
356 multilib_src_install() {
357 emake DESTDIR="${D}" "${install_args[@]}" "$@" install || die "emake install failed"
360 # @FUNCTION: xorg-3_src_install
362 # Install a built package to ${D}, performing any necessary steps.
363 xorg-3_src_install() {
364 debug-print-function ${FUNCNAME} "$@"
366 local install_args=( docdir="${EPREFIX}/usr/share/doc/${PF}" )
368 if [[ ${XORG_MULTILIB} == yes ]]; then
369 multilib-minimal_src_install "$@"
371 emake DESTDIR="${D}" "${install_args[@]}" "$@" install || die "emake install failed"
374 # Many X11 libraries unconditionally install developer documentation
375 if [[ -d "${D}"/usr/share/man/man3 ]]; then
376 ! in_iuse doc && eqawarn "ebuild should set XORG_DOC=doc since package installs library documentation"
379 if in_iuse doc && ! use doc; then
380 rm -rf "${D}"/usr/share/man/man3
381 rmdir "${D}"/usr{/share{/man,},} 2>/dev/null
384 # Don't install libtool archives (even for modules)
385 find "${D}" -type f -name '*.la' -delete || die