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

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.37 - (show annotations) (download)
Fri Mar 18 18:31:23 2011 UTC (3 years, 4 months ago) by scarabeus
Branch: MAIN
Changes since 1.36: +2 -2 lines
Update ewarn to explicitly state what ebuild is broken

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

  ViewVC Help
Powered by ViewVC 1.1.20