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

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.41 - (show annotations) (download)
Wed Apr 20 12:48:38 2011 UTC (3 years, 2 months ago) by mgorny
Branch: MAIN
Changes since 1.40: +13 -10 lines
Replace CONFIGURE_OPTIONS with XORG_CONFIGURE_OPTIONS array. Use git-2 eclass.

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

  ViewVC Help
Powered by ViewVC 1.1.20