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 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/ ;;
85 # @ECLASS-VARIABLE: XORG_PACKAGE_NAME
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}}
91 HOMEPAGE="https://www.x.org/wiki/ https://gitlab.freedesktop.org/xorg/${XORG_MODULE}${XORG_PACKAGE_NAME}"
93 # @ECLASS-VARIABLE: XORG_TARBALL_SUFFIX
95 # Most X11 projects provide tarballs as tar.bz2 or tar.xz. This eclass defaults
97 : ${XORG_TARBALL_SUFFIX:="bz2"}
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}"
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)
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
118 if [[ ${PN} != util-macros ]] ; then
119 EAUTORECONF_DEPEND+=" >=x11-misc/util-macros-1.18 >=media-fonts/font-util-1.2.0"
121 WANT_AUTOCONF="latest"
122 WANT_AUTOMAKE="latest"
123 for arch in ${XORG_EAUTORECONF_ARCHES}; do
124 EAUTORECONF_DEPENDS+=" ${arch}? ( ${EAUTORECONF_DEPEND} )"
127 BDEPEND+=" ${EAUTORECONF_DEPENDS}"
128 [[ ${XORG_EAUTORECONF} != no ]] && BDEPEND+=" ${EAUTORECONF_DEPEND}"
129 unset EAUTORECONF_DEPENDS
130 unset EAUTORECONF_DEPEND
132 # @ECLASS-VARIABLE: XORG_STATIC
134 # Enables static-libs useflag. Set to no, if your package gets:
136 # QA: configure: WARNING: unrecognized options: --disable-static
137 : ${XORG_STATIC:="yes"}
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
152 if [[ ${XORG_MULTILIB} == yes ]]; then
153 BDEPEND+=" virtual/pkgconfig[${MULTILIB_USEDEP}]"
155 BDEPEND+=" virtual/pkgconfig"
158 # @ECLASS-VARIABLE: XORG_DRI
160 # Possible values are "always" or the value of the useflag DRI capabilities
161 # are required for. Default value is "no"
163 # Eg. XORG_DRI="opengl" will pull all dri dependent deps for opengl useflag
167 x11-base/xorg-server[-minimal]
174 COMMON_DEPEND+=" ${DRI_COMMON_DEPEND}"
177 COMMON_DEPEND+=" ${XORG_DRI}? ( ${DRI_COMMON_DEPEND} )"
181 unset DRI_COMMON_DEPEND
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"
191 # @ECLASS-VARIABLE: XORG_DOC
193 # Possible values are "always" or the value of the useflag doc packages
194 # are required for. Default value is "no"
196 # Eg. XORG_DOC="manual" will pull all doc dependent deps for manual useflag
201 || ( app-text/asciidoc dev-ruby/asciidoctor )
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
213 BDEPEND+=" ${DOC_DEPEND}"
216 BDEPEND+=" ${XORG_DOC}? ( ${DOC_DEPEND} )"
222 DEPEND+=" ${COMMON_DEPEND}"
223 RDEPEND+=" ${COMMON_DEPEND}"
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}"
231 # @FUNCTION: xorg-3_src_unpack
233 # Simply unpack source code.
234 xorg-3_src_unpack() {
235 debug-print-function ${FUNCNAME} "$@"
237 if [[ -n ${GIT_ECLASS} ]]; then
244 # @FUNCTION: xorg-3_reconf_source
246 # Run eautoreconf if necessary, and run elibtoolize.
247 xorg-3_reconf_source() {
248 debug-print-function ${FUNCNAME} "$@"
252 # some hosts need full eautoreconf
253 [[ -e "./configure.ac" || -e "./configure.in" ]] \
254 && XORG_EAUTORECONF=yes
257 # elibtoolize required for BSD
258 [[ ${XORG_EAUTORECONF} != no && ( -e "./configure.ac" || -e "./configure.in" ) ]] \
259 && XORG_EAUTORECONF=yes
263 [[ ${XORG_EAUTORECONF} != no ]] && eautoreconf
264 elibtoolize --patch-only
267 # @FUNCTION: xorg-3_src_prepare
269 # Prepare a package after unpacking, performing all X-related tasks.
270 xorg-3_src_prepare() {
271 debug-print-function ${FUNCNAME} "$@"
277 # @FUNCTION: xorg-3_flags_setup
279 # Set up CFLAGS for a debug build
280 xorg-3_flags_setup() {
281 debug-print-function ${FUNCNAME} "$@"
283 # Win32 require special define
284 [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__
286 [[ ${PN} == xorg-server || ${PN} == xf86-video-* || ${PN} == xf86-input-* ]] \
287 && append-ldflags -Wl,-z,lazy
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
297 multilib_src_configure() {
298 ECONF_SOURCE="${S}" econf "${econfargs[@]}"
301 # @FUNCTION: xorg-3_src_configure
303 # Perform any necessary pre-configuration steps, then run configure
304 xorg-3_src_configure() {
305 debug-print-function ${FUNCNAME} "$@"
309 # @VARIABLE: XORG_CONFIGURE_OPTIONS
311 # Array of an additional options to pass to configure.
313 local xorgconfadd=("${XORG_CONFIGURE_OPTIONS[@]}")
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"
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"
333 # Handle static-libs found in IUSE, disable them by default
334 if in_iuse static-libs; then
337 $(use_enable static-libs static)
341 if [[ ${XORG_MULTILIB} == yes ]]; then
342 multilib-minimal_src_configure "$@"
344 econf "${econfargs[@]}" "$@"
348 multilib_src_compile() {
349 emake "$@" || die 'emake failed'
352 # @FUNCTION: xorg-3_src_compile
354 # Compile a package, performing all X-related tasks.
355 xorg-3_src_compile() {
356 debug-print-function ${FUNCNAME} "$@"
358 if [[ ${XORG_MULTILIB} == yes ]]; then
359 multilib-minimal_src_compile "$@"
361 emake "$@" || die 'emake failed'
365 multilib_src_install() {
366 emake DESTDIR="${D}" "${install_args[@]}" "$@" install || die "emake install failed"
369 # @FUNCTION: xorg-3_src_install
371 # Install a built package to ${D}, performing any necessary steps.
372 xorg-3_src_install() {
373 debug-print-function ${FUNCNAME} "$@"
375 local install_args=( docdir="${EPREFIX}/usr/share/doc/${PF}" )
377 if [[ ${XORG_MULTILIB} == yes ]]; then
378 multilib-minimal_src_install "$@"
380 emake DESTDIR="${D}" "${install_args[@]}" "$@" install || die "emake install failed"
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"
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
393 # Don't install libtool archives (even for modules)
394 find "${D}" -type f -name '*.la' -delete || die