/[gentoo-x86]/eclass/xorg-2.eclass
Gentoo

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.60 - (show annotations) (download)
Thu Jan 31 14:12:12 2013 UTC (18 months, 2 weeks ago) by chithanh
Branch: MAIN
Changes since 1.59: +24 -2 lines
Add EAPI 5 sub-slot dependency on x11-base/xorg-server for packages which require rebuilding when the server is upgraded.

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/xorg-2.eclass,v 1.59 2012/09/27 16:35:42 axs Exp $
4
5 # @ECLASS: xorg-2.eclass
6 # @MAINTAINER:
7 # x11@gentoo.org
8 # @AUTHOR:
9 # Author: Tomáš Chvátal <scarabeus@gentoo.org>
10 # Author: Donnie Berkholz <dberkholz@gentoo.org>
11 # @BLURB: Reduces code duplication in the modularized X11 ebuilds.
12 # @DESCRIPTION:
13 # This eclass makes trivial X ebuilds possible for apps, fonts, drivers,
14 # and more. Many things that would normally be done in various functions
15 # can be accessed by setting variables instead, such as patching,
16 # running eautoreconf, passing options to configure and installing docs.
17 #
18 # All you need to do in a basic ebuild is inherit this eclass and set
19 # DESCRIPTION, KEYWORDS and RDEPEND/DEPEND. If your package is hosted
20 # with the other X packages, you don't need to set SRC_URI. Pretty much
21 # everything else should be automatic.
22
23 GIT_ECLASS=""
24 if [[ ${PV} == *9999* ]]; then
25 GIT_ECLASS="git-2"
26 XORG_EAUTORECONF="yes"
27 fi
28
29 # If we're a font package, but not the font.alias one
30 FONT_ECLASS=""
31 if [[ ${PN} == font* \
32 && ${CATEGORY} = media-fonts \
33 && ${PN} != font-alias \
34 && ${PN} != font-util ]]; then
35 # Activate font code in the rest of the eclass
36 FONT="yes"
37 FONT_ECLASS="font"
38 fi
39
40 # we need to inherit autotools first to get the deps
41 inherit autotools autotools-utils eutils libtool multilib toolchain-funcs \
42 flag-o-matic ${FONT_ECLASS} ${GIT_ECLASS}
43
44 EXPORTED_FUNCTIONS="src_unpack src_compile src_install pkg_postinst pkg_postrm"
45 case "${EAPI:-0}" in
46 3|4|5) EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare src_configure" ;;
47 *) die "EAPI=${EAPI} is not supported" ;;
48 esac
49
50 # exports must be ALWAYS after inherit
51 EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
52
53 IUSE=""
54 HOMEPAGE="http://xorg.freedesktop.org/"
55
56 # @ECLASS-VARIABLE: XORG_EAUTORECONF
57 # @DESCRIPTION:
58 # If set to 'yes' and configure.ac exists, eautoreconf will run. Set
59 # before inheriting this eclass.
60 : ${XORG_EAUTORECONF:="no"}
61
62 # @ECLASS-VARIABLE: XORG_BASE_INDIVIDUAL_URI
63 # @DESCRIPTION:
64 # Set up SRC_URI for individual modular releases. If set to an empty
65 # string, no SRC_URI will be provided by the eclass.
66 : ${XORG_BASE_INDIVIDUAL_URI="http://xorg.freedesktop.org/releases/individual"}
67
68 # @ECLASS-VARIABLE: XORG_MODULE
69 # @DESCRIPTION:
70 # The subdirectory to download source from. Possible settings are app,
71 # doc, data, util, driver, font, lib, proto, xserver. Set above the
72 # inherit to override the default autoconfigured module.
73 if [[ -z ${XORG_MODULE} ]]; then
74 case ${CATEGORY} in
75 app-doc) XORG_MODULE=doc/ ;;
76 media-fonts) XORG_MODULE=font/ ;;
77 x11-apps|x11-wm) XORG_MODULE=app/ ;;
78 x11-misc|x11-themes) XORG_MODULE=util/ ;;
79 x11-base) XORG_MODULE=xserver/ ;;
80 x11-drivers) XORG_MODULE=driver/ ;;
81 x11-proto) XORG_MODULE=proto/ ;;
82 x11-libs) XORG_MODULE=lib/ ;;
83 *) XORG_MODULE= ;;
84 esac
85 fi
86
87 # @ECLASS-VARIABLE: XORG_PACKAGE_NAME
88 # @DESCRIPTION:
89 # For git checkout the git repository might differ from package name.
90 # This variable can be used for proper directory specification
91 : ${XORG_PACKAGE_NAME:=${PN}}
92
93 if [[ -n ${GIT_ECLASS} ]]; then
94 : ${EGIT_REPO_URI:="git://anongit.freedesktop.org/xorg/${XORG_MODULE}${XORG_PACKAGE_NAME} http://anongit.freedesktop.org/git/xorg/${XORG_MODULE}${XORG_PACKAGE_NAME}"}
95 elif [[ -n ${XORG_BASE_INDIVIDUAL_URI} ]]; then
96 SRC_URI="${XORG_BASE_INDIVIDUAL_URI}/${XORG_MODULE}${P}.tar.bz2"
97 fi
98
99 : ${SLOT:=0}
100
101 # Set the license for the package. This can be overridden by setting
102 # LICENSE after the inherit. Nearly all FreeDesktop-hosted X packages
103 # are under the MIT license. (This is what Red Hat does in their rpms)
104 : ${LICENSE:=MIT}
105
106 # Set up autotools shared dependencies
107 # Remember that all versions here MUST be stable
108 XORG_EAUTORECONF_ARCHES="x86-interix ppc-aix x86-winnt"
109 EAUTORECONF_DEPEND+="
110 >=sys-devel/libtool-2.2.6a
111 sys-devel/m4"
112 if [[ ${PN} != util-macros ]] ; then
113 EAUTORECONF_DEPEND+=" >=x11-misc/util-macros-1.17"
114 # Required even by xorg-server
115 [[ ${PN} == "font-util" ]] || EAUTORECONF_DEPEND+=" >=media-fonts/font-util-1.2.0"
116 fi
117 WANT_AUTOCONF="latest"
118 WANT_AUTOMAKE="latest"
119 for arch in ${XORG_EAUTORECONF_ARCHES}; do
120 EAUTORECONF_DEPENDS+=" ${arch}? ( ${EAUTORECONF_DEPEND} )"
121 done
122 DEPEND+=" ${EAUTORECONF_DEPENDS}"
123 [[ ${XORG_EAUTORECONF} != no ]] && DEPEND+=" ${EAUTORECONF_DEPEND}"
124 unset EAUTORECONF_DEPENDS
125 unset EAUTORECONF_DEPEND
126
127 if [[ ${FONT} == yes ]]; then
128 RDEPEND+=" media-fonts/encodings
129 x11-apps/mkfontscale
130 x11-apps/mkfontdir"
131 PDEPEND+=" media-fonts/font-alias"
132 DEPEND+=" >=media-fonts/font-util-1.2.0"
133
134 # @ECLASS-VARIABLE: FONT_DIR
135 # @DESCRIPTION:
136 # If you're creating a font package and the suffix of PN is not equal to
137 # the subdirectory of /usr/share/fonts/ it should install into, set
138 # FONT_DIR to that directory or directories. Set before inheriting this
139 # eclass.
140 [[ -z ${FONT_DIR} ]] && FONT_DIR=${PN##*-}
141
142 # Fix case of font directories
143 FONT_DIR=${FONT_DIR/ttf/TTF}
144 FONT_DIR=${FONT_DIR/otf/OTF}
145 FONT_DIR=${FONT_DIR/type1/Type1}
146 FONT_DIR=${FONT_DIR/speedo/Speedo}
147
148 # Set up configure options, wrapped so ebuilds can override if need be
149 [[ -z ${FONT_OPTIONS} ]] && FONT_OPTIONS="--with-fontdir=\"${EPREFIX}/usr/share/fonts/${FONT_DIR}\""
150
151 [[ ${PN##*-} = misc || ${PN##*-} = 75dpi || ${PN##*-} = 100dpi || ${PN##*-} = cyrillic ]] && IUSE+=" nls"
152 fi
153
154 # If we're a driver package, then enable DRIVER case
155 [[ ${PN} == xf86-video-* || ${PN} == xf86-input-* ]] && DRIVER="yes"
156
157 # @ECLASS-VARIABLE: XORG_STATIC
158 # @DESCRIPTION:
159 # Enables static-libs useflag. Set to no, if your package gets:
160 #
161 # QA: configure: WARNING: unrecognized options: --disable-static
162 : ${XORG_STATIC:="yes"}
163
164 # Add static-libs useflag where usefull.
165 if [[ ${XORG_STATIC} == yes \
166 && ${FONT} != yes \
167 && ${CATEGORY} != app-doc \
168 && ${CATEGORY} != x11-apps \
169 && ${CATEGORY} != x11-proto \
170 && ${CATEGORY} != x11-drivers \
171 && ${CATEGORY} != media-fonts \
172 && ${PN} != util-macros \
173 && ${PN} != xbitmaps \
174 && ${PN} != xorg-cf-files \
175 && ${PN/xcursor} = ${PN} ]]; then
176 IUSE+=" static-libs"
177 fi
178
179 DEPEND+=" virtual/pkgconfig"
180
181 # @ECLASS-VARIABLE: XORG_DRI
182 # @DESCRIPTION:
183 # Possible values are "always" or the value of the useflag DRI capabilities
184 # are required for. Default value is "no"
185 #
186 # Eg. XORG_DRI="opengl" will pull all dri dependant deps for opengl useflag
187 : ${XORG_DRI:="no"}
188
189 DRI_COMMON_DEPEND="
190 x11-base/xorg-server[-minimal]
191 x11-libs/libdrm
192 "
193 DRI_DEPEND="
194 x11-proto/xf86driproto
195 x11-proto/glproto
196 x11-proto/dri2proto
197 "
198 case ${XORG_DRI} in
199 no)
200 ;;
201 always)
202 COMMON_DEPEND+=" ${DRI_COMMON_DEPEND}"
203 DEPEND+=" ${DRI_DEPEND}"
204 ;;
205 *)
206 COMMON_DEPEND+=" ${XORG_DRI}? ( ${DRI_COMMON_DEPEND} )"
207 DEPEND+=" ${XORG_DRI}? ( ${DRI_DEPEND} )"
208 IUSE+=" ${XORG_DRI}"
209 ;;
210 esac
211 unset DRI_DEPEND
212 unset DRI_COMMONDEPEND
213
214 if [[ -n "${DRIVER}" ]]; then
215 COMMON_DEPEND+="
216 x11-base/xorg-server[xorg]
217 "
218 fi
219 if [[ -n "${DRIVER}" && ${PN} == xf86-input-* ]]; then
220 DEPEND+="
221 x11-proto/inputproto
222 x11-proto/kbproto
223 x11-proto/xproto
224 "
225 fi
226 if [[ -n "${DRIVER}" && ${PN} == xf86-video-* ]]; then
227 COMMON_DEPEND+="
228 x11-libs/libpciaccess
229 "
230 # we also needs some protos and libs in all cases
231 DEPEND+="
232 x11-proto/fontsproto
233 x11-proto/randrproto
234 x11-proto/renderproto
235 x11-proto/videoproto
236 x11-proto/xextproto
237 x11-proto/xineramaproto
238 x11-proto/xproto
239 "
240 fi
241
242 # @ECLASS-VARIABLE: XORG_DOC
243 # @DESCRIPTION:
244 # Possible values are "always" or the value of the useflag doc packages
245 # are required for. Default value is "no"
246 #
247 # Eg. XORG_DOC="manual" will pull all doc dependant deps for manual useflag
248 : ${XORG_DOC:="no"}
249
250 DOC_DEPEND="
251 doc? (
252 app-text/asciidoc
253 app-text/xmlto
254 app-doc/doxygen
255 app-text/docbook-xml-dtd:4.1.2
256 app-text/docbook-xml-dtd:4.2
257 app-text/docbook-xml-dtd:4.3
258 )
259 "
260 case ${XORG_DOC} in
261 no)
262 ;;
263 always)
264 DEPEND+=" ${DOC_DEPEND}"
265 ;;
266 *)
267 DEPEND+=" ${XORG_DOC}? ( ${DOC_DEPEND} )"
268 IUSE+=" ${XORG_DOC}"
269 ;;
270 esac
271 unset DOC_DEPEND
272
273 # @ECLASS-VARIABLE: XORG_MODULE_REBUILD
274 # @DESCRIPTION:
275 # Describes whether a package contains modules that need to be rebuilt on
276 # xorg-server upgrade. This has an effect only since EAPI=5.
277 # Possible values are "yes" or "no". Default value is "yes" for packages which
278 # are recognized as DRIVER by this eclass and "no" for all other packages.
279 if [[ "${DRIVER}" == yes ]]; then
280 : ${XORG_MODULE_REBUILD:="yes"}
281 else
282 : ${XORG_MODULE_REBUILD:="no"}
283 fi
284
285 if [[ ${XORG_MODULE_REBUILD} == yes ]]; then
286 case ${EAPI} in
287 3|4)
288 ;;
289 *)
290 RDEPEND+=" x11-base/xorg-server:="
291 ;;
292 esac
293 fi
294
295 DEPEND+=" ${COMMON_DEPEND}"
296 RDEPEND+=" ${COMMON_DEPEND}"
297 unset COMMON_DEPEND
298
299 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND=${DEPEND}"
300 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: RDEPEND=${RDEPEND}"
301 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: PDEPEND=${PDEPEND}"
302
303 # @FUNCTION: xorg-2_pkg_setup
304 # @DESCRIPTION:
305 # Setup prefix compat
306 xorg-2_pkg_setup() {
307 debug-print-function ${FUNCNAME} "$@"
308
309 [[ ${FONT} == yes ]] && font_pkg_setup "$@"
310 }
311
312 # @FUNCTION: xorg-2_src_unpack
313 # @DESCRIPTION:
314 # Simply unpack source code.
315 xorg-2_src_unpack() {
316 debug-print-function ${FUNCNAME} "$@"
317
318 if [[ -n ${GIT_ECLASS} ]]; then
319 git-2_src_unpack
320 else
321 unpack ${A}
322 fi
323
324 [[ -n ${FONT_OPTIONS} ]] && einfo "Detected font directory: ${FONT_DIR}"
325 }
326
327 # @FUNCTION: xorg-2_patch_source
328 # @DESCRIPTION:
329 # Apply all patches
330 xorg-2_patch_source() {
331 debug-print-function ${FUNCNAME} "$@"
332
333 # Use standardized names and locations with bulk patching
334 # Patch directory is ${WORKDIR}/patch
335 # See epatch() in eutils.eclass for more documentation
336 EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
337
338 [[ -d "${EPATCH_SOURCE}" ]] && epatch
339 }
340
341 # @FUNCTION: xorg-2_reconf_source
342 # @DESCRIPTION:
343 # Run eautoreconf if necessary, and run elibtoolize.
344 xorg-2_reconf_source() {
345 debug-print-function ${FUNCNAME} "$@"
346
347 case ${CHOST} in
348 *-interix* | *-aix* | *-winnt*)
349 # some hosts need full eautoreconf
350 [[ -e "./configure.ac" || -e "./configure.in" ]] \
351 && AUTOTOOLS_AUTORECONF=1
352 ;;
353 *)
354 # elibtoolize required for BSD
355 [[ ${XORG_EAUTORECONF} != no && ( -e "./configure.ac" || -e "./configure.in" ) ]] \
356 && AUTOTOOLS_AUTORECONF=1
357 ;;
358 esac
359 }
360
361 # @FUNCTION: xorg-2_src_prepare
362 # @DESCRIPTION:
363 # Prepare a package after unpacking, performing all X-related tasks.
364 xorg-2_src_prepare() {
365 debug-print-function ${FUNCNAME} "$@"
366
367 xorg-2_patch_source
368 xorg-2_reconf_source
369 autotools-utils_src_prepare "$@"
370 }
371
372 # @FUNCTION: xorg-2_font_configure
373 # @DESCRIPTION:
374 # If a font package, perform any necessary configuration steps
375 xorg-2_font_configure() {
376 debug-print-function ${FUNCNAME} "$@"
377
378 if has nls ${IUSE//+} && ! use nls; then
379 if grep -q -s "disable-all-encodings" ${ECONF_SOURCE:-.}/configure; then
380 FONT_OPTIONS+="
381 --disable-all-encodings"
382 else
383 FONT_OPTIONS+="
384 --disable-iso8859-2
385 --disable-iso8859-3
386 --disable-iso8859-4
387 --disable-iso8859-5
388 --disable-iso8859-6
389 --disable-iso8859-7
390 --disable-iso8859-8
391 --disable-iso8859-9
392 --disable-iso8859-10
393 --disable-iso8859-11
394 --disable-iso8859-12
395 --disable-iso8859-13
396 --disable-iso8859-14
397 --disable-iso8859-15
398 --disable-iso8859-16
399 --disable-jisx0201
400 --disable-koi8-r"
401 fi
402 fi
403 }
404
405 # @FUNCTION: xorg-2_flags_setup
406 # @DESCRIPTION:
407 # Set up CFLAGS for a debug build
408 xorg-2_flags_setup() {
409 debug-print-function ${FUNCNAME} "$@"
410
411 # Win32 require special define
412 [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__
413 # hardened ldflags
414 [[ ${PN} = xorg-server || -n ${DRIVER} ]] && append-ldflags -Wl,-z,lazy
415
416 # Quite few libraries fail on runtime without these:
417 if has static-libs ${IUSE//+}; then
418 filter-flags -Wl,-Bdirect
419 filter-ldflags -Bdirect
420 filter-ldflags -Wl,-Bdirect
421 fi
422 }
423
424 # @FUNCTION: xorg-2_src_configure
425 # @DESCRIPTION:
426 # Perform any necessary pre-configuration steps, then run configure
427 xorg-2_src_configure() {
428 debug-print-function ${FUNCNAME} "$@"
429
430 xorg-2_flags_setup
431
432 # @VARIABLE: XORG_CONFIGURE_OPTIONS
433 # @DESCRIPTION:
434 # Array of an additional options to pass to configure.
435 # @DEFAULT_UNSET
436 if [[ $(declare -p XORG_CONFIGURE_OPTIONS 2>&-) != "declare -a"* ]]; then
437 # fallback to CONFIGURE_OPTIONS, deprecated.
438 if [[ -n "${CONFIGURE_OPTIONS}" ]]; then
439 eqawarn "CONFIGURE_OPTIONS are deprecated. Please migrate to XORG_CONFIGURE_OPTIONS"
440 eqawarn "to preserve namespace."
441 fi
442
443 local xorgconfadd=(${CONFIGURE_OPTIONS} ${XORG_CONFIGURE_OPTIONS})
444 else
445 local xorgconfadd=("${XORG_CONFIGURE_OPTIONS[@]}")
446 fi
447
448 [[ -n "${FONT}" ]] && xorg-2_font_configure
449
450 # Check if package supports disabling of dep tracking
451 # Fixes warnings like:
452 # WARNING: unrecognized options: --disable-dependency-tracking
453 if grep -q -s "disable-depencency-tracking" ${ECONF_SOURCE:-.}/configure; then
454 local dep_track="--disable-dependency-tracking"
455 fi
456
457 local myeconfargs=(
458 ${dep_track}
459 ${FONT_OPTIONS}
460 "${xorgconfadd[@]}"
461 )
462
463 autotools-utils_src_configure "$@"
464 }
465
466 # @FUNCTION: xorg-2_src_compile
467 # @DESCRIPTION:
468 # Compile a package, performing all X-related tasks.
469 xorg-2_src_compile() {
470 debug-print-function ${FUNCNAME} "$@"
471
472 autotools-utils_src_compile "$@"
473 }
474
475 # @FUNCTION: xorg-2_src_install
476 # @DESCRIPTION:
477 # Install a built package to ${D}, performing any necessary steps.
478 # Creates a ChangeLog from git if using live ebuilds.
479 xorg-2_src_install() {
480 debug-print-function ${FUNCNAME} "$@"
481
482 if [[ ${CATEGORY} == x11-proto ]]; then
483 autotools-utils_src_install \
484 ${PN/proto/}docdir="${EPREFIX}/usr/share/doc/${PF}" \
485 docdir="${EPREFIX}/usr/share/doc/${PF}"
486 else
487 autotools-utils_src_install \
488 docdir="${EPREFIX}/usr/share/doc/${PF}"
489 fi
490
491 if [[ -n ${GIT_ECLASS} ]]; then
492 pushd "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" > /dev/null
493 git log ${EGIT_COMMIT} > "${S}"/ChangeLog
494 popd > /dev/null
495 fi
496
497 if [[ -e "${S}"/ChangeLog ]]; then
498 dodoc "${S}"/ChangeLog || die "dodoc failed"
499 fi
500
501 # Don't install libtool archives (even for modules)
502 prune_libtool_files --all
503
504 [[ -n ${FONT} ]] && remove_font_metadata
505 }
506
507 # @FUNCTION: xorg-2_pkg_postinst
508 # @DESCRIPTION:
509 # Run X-specific post-installation tasks on the live filesystem. The
510 # only task right now is some setup for font packages.
511 xorg-2_pkg_postinst() {
512 debug-print-function ${FUNCNAME} "$@"
513
514 if [[ -n ${FONT} ]]; then
515 create_fonts_scale
516 create_fonts_dir
517 font_pkg_postinst "$@"
518 fi
519 }
520
521 # @FUNCTION: xorg-2_pkg_postrm
522 # @DESCRIPTION:
523 # Run X-specific post-removal tasks on the live filesystem. The only
524 # task right now is some cleanup for font packages.
525 xorg-2_pkg_postrm() {
526 debug-print-function ${FUNCNAME} "$@"
527
528 if [[ -n ${FONT} ]]; then
529 # if we're doing an upgrade, postinst will do
530 if [[ ${EAPI} -lt 4 || -z ${REPLACED_BY_VERSION} ]]; then
531 create_fonts_scale
532 create_fonts_dir
533 font_pkg_postrm "$@"
534 fi
535 fi
536 }
537
538 # @FUNCTION: remove_font_metadata
539 # @DESCRIPTION:
540 # Don't let the package install generated font files that may overlap
541 # with other packages. Instead, they're generated in pkg_postinst().
542 remove_font_metadata() {
543 debug-print-function ${FUNCNAME} "$@"
544
545 if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
546 einfo "Removing font metadata"
547 rm -rf "${ED}"/usr/share/fonts/${FONT_DIR}/fonts.{scale,dir,cache-1}
548 fi
549 }
550
551 # @FUNCTION: create_fonts_scale
552 # @DESCRIPTION:
553 # Create fonts.scale file, used by the old server-side fonts subsystem.
554 create_fonts_scale() {
555 debug-print-function ${FUNCNAME} "$@"
556
557 if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
558 ebegin "Generating fonts.scale"
559 mkfontscale \
560 -a "${EROOT}/usr/share/fonts/encodings/encodings.dir" \
561 -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
562 eend $?
563 fi
564 }
565
566 # @FUNCTION: create_fonts_dir
567 # @DESCRIPTION:
568 # Create fonts.dir file, used by the old server-side fonts subsystem.
569 create_fonts_dir() {
570 debug-print-function ${FUNCNAME} "$@"
571
572 ebegin "Generating fonts.dir"
573 mkfontdir \
574 -e "${EROOT}"/usr/share/fonts/encodings \
575 -e "${EROOT}"/usr/share/fonts/encodings/large \
576 -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
577 eend $?
578 }

  ViewVC Help
Powered by ViewVC 1.1.20