sys-process/glances: 3.1.4.1-r1 amd64 stable, bug #720368
[gentoo.git] / eclass / xorg-3.eclass
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: xorg-3.eclass
5 # @MAINTAINER:
6 # x11@gentoo.org
7 # @AUTHOR:
8 # Author: Tomáš Chvátal <scarabeus@gentoo.org>
9 # Author: Donnie Berkholz <dberkholz@gentoo.org>
10 # Author: Matt Turner <mattst88@gentoo.org>
11 # @SUPPORTED_EAPIS: 7
12 # @BLURB: Reduces code duplication in the modularized X11 ebuilds.
13 # @DESCRIPTION:
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.
18 #
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.
23
24 GIT_ECLASS=""
25 if [[ ${PV} == *9999* ]]; then
26         GIT_ECLASS="git-r3"
27         XORG_EAUTORECONF="yes"
28 fi
29
30 # @ECLASS-VARIABLE: XORG_MULTILIB
31 # @DESCRIPTION:
32 # If set to 'yes', the multilib support for package will be enabled. Set
33 # before inheriting this eclass.
34 : ${XORG_MULTILIB:="no"}
35
36 # we need to inherit autotools first to get the deps
37 inherit autotools libtool multilib toolchain-funcs flag-o-matic ${GIT_ECLASS}
38
39 if [[ ${XORG_MULTILIB} == yes ]]; then
40         inherit multilib-minimal
41 fi
42
43 EXPORTED_FUNCTIONS="src_prepare src_configure src_unpack src_compile src_install"
44 case "${EAPI:-0}" in
45         7) ;;
46         *) die "EAPI=${EAPI} is not supported" ;;
47 esac
48
49 # exports must be ALWAYS after inherit
50 EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
51
52 IUSE=""
53
54 # @ECLASS-VARIABLE: XORG_EAUTORECONF
55 # @DESCRIPTION:
56 # If set to 'yes' and configure.ac exists, eautoreconf will run. Set
57 # before inheriting this eclass.
58 : ${XORG_EAUTORECONF:="no"}
59
60 # @ECLASS-VARIABLE: XORG_BASE_INDIVIDUAL_URI
61 # @DESCRIPTION:
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"}
65
66 # @ECLASS-VARIABLE: XORG_MODULE
67 # @DESCRIPTION:
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
73         case ${CATEGORY} in
74                 app-doc)             XORG_MODULE=doc/     ;;
75                 media-fonts)         XORG_MODULE=font/    ;;
76                 x11-apps|x11-wm)     XORG_MODULE=app/     ;;
77                 x11-misc|x11-themes) XORG_MODULE=util/    ;;
78                 x11-base)            XORG_MODULE=xserver/ ;;
79                 x11-drivers)         XORG_MODULE=driver/  ;;
80                 x11-libs)            XORG_MODULE=lib/     ;;
81                 *)                   XORG_MODULE=         ;;
82         esac
83 fi
84
85 # @ECLASS-VARIABLE: XORG_PACKAGE_NAME
86 # @DESCRIPTION:
87 # For git checkout the git repository might differ from package name.
88 # This variable can be used for proper directory specification
89 : ${XORG_PACKAGE_NAME:=${PN}}
90
91 HOMEPAGE="https://www.x.org/wiki/ https://gitlab.freedesktop.org/xorg/${XORG_MODULE}${XORG_PACKAGE_NAME}"
92
93 # @ECLASS-VARIABLE: XORG_TARBALL_SUFFIX
94 # @DESCRIPTION:
95 # Most X11 projects provide tarballs as tar.bz2 or tar.xz. This eclass defaults
96 # to bz2.
97 : ${XORG_TARBALL_SUFFIX:="bz2"}
98
99 if [[ -n ${GIT_ECLASS} ]]; then
100         : ${EGIT_REPO_URI:="https://gitlab.freedesktop.org/xorg/${XORG_MODULE}${XORG_PACKAGE_NAME}.git"}
101 elif [[ -n ${XORG_BASE_INDIVIDUAL_URI} ]]; then
102         SRC_URI="${XORG_BASE_INDIVIDUAL_URI}/${XORG_MODULE}${P}.tar.${XORG_TARBALL_SUFFIX}"
103 fi
104
105 : ${SLOT:=0}
106
107 # Set the license for the package. This can be overridden by setting
108 # LICENSE after the inherit. Nearly all FreeDesktop-hosted X packages
109 # are under the MIT license. (This is what Red Hat does in their rpms)
110 : ${LICENSE:=MIT}
111
112 # Set up autotools shared dependencies
113 # Remember that all versions here MUST be stable
114 XORG_EAUTORECONF_ARCHES="ppc-aix x86-winnt"
115 EAUTORECONF_DEPEND+="
116         >=sys-devel/libtool-2.2.6a
117         sys-devel/m4"
118 if [[ ${PN} != util-macros ]] ; then
119         EAUTORECONF_DEPEND+=" >=x11-misc/util-macros-1.18 >=media-fonts/font-util-1.2.0"
120 fi
121 WANT_AUTOCONF="latest"
122 WANT_AUTOMAKE="latest"
123 for arch in ${XORG_EAUTORECONF_ARCHES}; do
124         EAUTORECONF_DEPENDS+=" ${arch}? ( ${EAUTORECONF_DEPEND} )"
125 done
126 unset arch
127 BDEPEND+=" ${EAUTORECONF_DEPENDS}"
128 [[ ${XORG_EAUTORECONF} != no ]] && BDEPEND+=" ${EAUTORECONF_DEPEND}"
129 unset EAUTORECONF_DEPENDS
130 unset EAUTORECONF_DEPEND
131
132 # @ECLASS-VARIABLE: XORG_STATIC
133 # @DESCRIPTION:
134 # Enables static-libs useflag. Set to no, if your package gets:
135 #
136 # QA: configure: WARNING: unrecognized options: --disable-static
137 : ${XORG_STATIC:="yes"}
138
139 # Add static-libs useflag where useful.
140 if [[ ${XORG_STATIC} == yes \
141                 && ${CATEGORY} != app-doc \
142                 && ${CATEGORY} != x11-apps \
143                 && ${CATEGORY} != x11-drivers \
144                 && ${CATEGORY} != media-fonts \
145                 && ${PN} != util-macros \
146                 && ${PN} != xbitmaps \
147                 && ${PN} != xorg-cf-files \
148                 && ${PN/xcursor} = ${PN} ]]; then
149         IUSE+=" static-libs"
150 fi
151
152 if [[ ${XORG_MULTILIB} == yes ]]; then
153         BDEPEND+=" virtual/pkgconfig[${MULTILIB_USEDEP}]"
154 else
155         BDEPEND+=" virtual/pkgconfig"
156 fi
157
158 # @ECLASS-VARIABLE: XORG_DRI
159 # @DESCRIPTION:
160 # Possible values are "always" or the value of the useflag DRI capabilities
161 # are required for. Default value is "no"
162 #
163 # Eg. XORG_DRI="opengl" will pull all dri dependent deps for opengl useflag
164 : ${XORG_DRI:="no"}
165
166 DRI_COMMON_DEPEND="
167         x11-base/xorg-server[-minimal]
168         x11-libs/libdrm
169 "
170 case ${XORG_DRI} in
171         no)
172                 ;;
173         always)
174                 COMMON_DEPEND+=" ${DRI_COMMON_DEPEND}"
175                 ;;
176         *)
177                 COMMON_DEPEND+=" ${XORG_DRI}? ( ${DRI_COMMON_DEPEND} )"
178                 IUSE+=" ${XORG_DRI}"
179                 ;;
180 esac
181 unset DRI_COMMON_DEPEND
182
183 if [[ ${PN} == xf86-video-* || ${PN} == xf86-input-* ]]; then
184         DEPEND+="  x11-base/xorg-proto"
185         RDEPEND+=" x11-base/xorg-server:="
186         COMMON_DEPEND+=" >=x11-base/xorg-server-1.20[xorg]"
187         [[ ${PN} == xf86-video-* ]] && COMMON_DEPEND+=" >=x11-libs/libpciaccess-0.14"
188 fi
189
190
191 # @ECLASS-VARIABLE: XORG_DOC
192 # @DESCRIPTION:
193 # Possible values are "always" or the value of the useflag doc packages
194 # are required for. Default value is "no"
195 #
196 # Eg. XORG_DOC="manual" will pull all doc dependent deps for manual useflag
197 : ${XORG_DOC:="no"}
198
199 DOC_DEPEND="
200         doc? (
201                 || ( app-text/asciidoc dev-ruby/asciidoctor )
202                 app-text/xmlto
203                 app-doc/doxygen
204                 app-text/docbook-xml-dtd:4.1.2
205                 app-text/docbook-xml-dtd:4.2
206                 app-text/docbook-xml-dtd:4.3
207         )
208 "
209 case ${XORG_DOC} in
210         no)
211                 ;;
212         always)
213                 BDEPEND+=" ${DOC_DEPEND}"
214                 ;;
215         *)
216                 BDEPEND+=" ${XORG_DOC}? ( ${DOC_DEPEND} )"
217                 IUSE+=" ${XORG_DOC}"
218                 ;;
219 esac
220 unset DOC_DEPEND
221
222 DEPEND+=" ${COMMON_DEPEND}"
223 RDEPEND+=" ${COMMON_DEPEND}"
224 unset COMMON_DEPEND
225
226 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND=${DEPEND}"
227 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: RDEPEND=${RDEPEND}"
228 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: PDEPEND=${PDEPEND}"
229 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: BDEPEND=${BDEPEND}"
230
231 # @FUNCTION: xorg-3_src_unpack
232 # @DESCRIPTION:
233 # Simply unpack source code.
234 xorg-3_src_unpack() {
235         debug-print-function ${FUNCNAME} "$@"
236
237         if [[ -n ${GIT_ECLASS} ]]; then
238                 git-r3_src_unpack
239         else
240                 unpack ${A}
241         fi
242 }
243
244 # @FUNCTION: xorg-3_reconf_source
245 # @DESCRIPTION:
246 # Run eautoreconf if necessary, and run elibtoolize.
247 xorg-3_reconf_source() {
248         debug-print-function ${FUNCNAME} "$@"
249
250         case ${CHOST} in
251                 *-aix* | *-winnt*)
252                         # some hosts need full eautoreconf
253                         [[ -e "./configure.ac" || -e "./configure.in" ]] \
254                                 && XORG_EAUTORECONF=yes
255                         ;;
256                 *)
257                         # elibtoolize required for BSD
258                         [[ ${XORG_EAUTORECONF} != no && ( -e "./configure.ac" || -e "./configure.in" ) ]] \
259                                 && XORG_EAUTORECONF=yes
260                         ;;
261         esac
262
263         [[ ${XORG_EAUTORECONF} != no ]] && eautoreconf
264         elibtoolize --patch-only
265 }
266
267 # @FUNCTION: xorg-3_src_prepare
268 # @DESCRIPTION:
269 # Prepare a package after unpacking, performing all X-related tasks.
270 xorg-3_src_prepare() {
271         debug-print-function ${FUNCNAME} "$@"
272
273         default
274         xorg-3_reconf_source
275 }
276
277 # @FUNCTION: xorg-3_flags_setup
278 # @DESCRIPTION:
279 # Set up CFLAGS for a debug build
280 xorg-3_flags_setup() {
281         debug-print-function ${FUNCNAME} "$@"
282
283         # Win32 require special define
284         [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__
285         # hardened ldflags
286         [[ ${PN} == xorg-server || ${PN} == xf86-video-* || ${PN} == xf86-input-* ]] \
287                 && append-ldflags -Wl,-z,lazy
288
289         # Quite few libraries fail on runtime without these:
290         if has static-libs ${IUSE//+}; then
291                 filter-flags -Wl,-Bdirect
292                 filter-ldflags -Bdirect
293                 filter-ldflags -Wl,-Bdirect
294         fi
295 }
296
297 multilib_src_configure() {
298         ECONF_SOURCE="${S}" econf "${econfargs[@]}"
299 }
300
301 # @FUNCTION: xorg-3_src_configure
302 # @DESCRIPTION:
303 # Perform any necessary pre-configuration steps, then run configure
304 xorg-3_src_configure() {
305         debug-print-function ${FUNCNAME} "$@"
306
307         xorg-3_flags_setup
308
309         # @VARIABLE: XORG_CONFIGURE_OPTIONS
310         # @DESCRIPTION:
311         # Array of an additional options to pass to configure.
312         # @DEFAULT_UNSET
313         local xorgconfadd=("${XORG_CONFIGURE_OPTIONS[@]}")
314
315         # Check if package supports disabling of dep tracking
316         # Fixes warnings like:
317         #    WARNING: unrecognized options: --disable-dependency-tracking
318         if grep -q -s "disable-depencency-tracking" ${ECONF_SOURCE:-.}/configure; then
319                 local dep_track="--disable-dependency-tracking"
320         fi
321
322         # Check if package supports disabling of selective -Werror=...
323         if grep -q -s "disable-selective-werror" ${ECONF_SOURCE:-.}/configure; then
324                 local selective_werror="--disable-selective-werror"
325         fi
326
327         local econfargs=(
328                 ${dep_track}
329                 ${selective_werror}
330                 "${xorgconfadd[@]}"
331         )
332
333         # Handle static-libs found in IUSE, disable them by default
334         if in_iuse static-libs; then
335                 econfargs+=(
336                         --enable-shared
337                         $(use_enable static-libs static)
338                 )
339         fi
340
341         if [[ ${XORG_MULTILIB} == yes ]]; then
342                 multilib-minimal_src_configure "$@"
343         else
344                 econf "${econfargs[@]}" "$@"
345         fi
346 }
347
348 multilib_src_compile() {
349         emake "$@" || die 'emake failed'
350 }
351
352 # @FUNCTION: xorg-3_src_compile
353 # @DESCRIPTION:
354 # Compile a package, performing all X-related tasks.
355 xorg-3_src_compile() {
356         debug-print-function ${FUNCNAME} "$@"
357
358         if [[ ${XORG_MULTILIB} == yes ]]; then
359                 multilib-minimal_src_compile "$@"
360         else
361                 emake "$@" || die 'emake failed'
362         fi
363 }
364
365 multilib_src_install() {
366         emake DESTDIR="${D}" "${install_args[@]}" "$@" install || die "emake install failed"
367 }
368
369 # @FUNCTION: xorg-3_src_install
370 # @DESCRIPTION:
371 # Install a built package to ${D}, performing any necessary steps.
372 xorg-3_src_install() {
373         debug-print-function ${FUNCNAME} "$@"
374
375         local install_args=( docdir="${EPREFIX}/usr/share/doc/${PF}" )
376
377         if [[ ${XORG_MULTILIB} == yes ]]; then
378                 multilib-minimal_src_install "$@"
379         else
380                 emake DESTDIR="${D}" "${install_args[@]}" "$@" install || die "emake install failed"
381         fi
382
383         # Many X11 libraries unconditionally install developer documentation
384         if [[ -d "${D}"/usr/share/man/man3 ]]; then
385                 ! in_iuse doc && eqawarn "ebuild should set XORG_DOC=doc since package installs library documentation"
386         fi
387
388         if in_iuse doc && ! use doc; then
389                 rm -rf "${D}"/usr/share/man/man3
390                 rmdir "${D}"/usr{/share{/man,},} 2>/dev/null
391         fi
392
393         # Don't install libtool archives (even for modules)
394         find "${D}" -type f -name '*.la' -delete || die
395 }