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

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.28 - (show annotations) (download)
Mon Mar 14 17:09:41 2011 UTC (3 years, 1 month ago) by flameeyes
Branch: MAIN
Changes since 1.27: +9 -6 lines
Make BASE_INDIVIDUAL_URI a tweakable value.

When setting it to an explicit empty string, it will signal the eclass
not to provide a SRC_URI at all. This is useful both for software
using the xorg interface but not the freedesktop source uri, and for
writing custom git-based ebuilds.

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.27 2011/03/08 11:31:42 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"
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: 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 : ${BASE_INDIVIDUAL_URI="http://xorg.freedesktop.org/releases/individual"}
66
67 # @ECLASS-VARIABLE: 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 ${MODULE} ]]; then
73 case ${CATEGORY} in
74 app-doc) MODULE=doc/ ;;
75 media-fonts) MODULE=font/ ;;
76 x11-apps|x11-wm) MODULE=app/ ;;
77 x11-misc|x11-themes) MODULE=util/ ;;
78 x11-base) MODULE=xserver/ ;;
79 x11-drivers) MODULE=driver/ ;;
80 x11-proto) MODULE=proto/ ;;
81 x11-libs) MODULE=lib/ ;;
82 *) MODULE= ;;
83 esac
84 fi
85
86 # @ECLASS-VARIABLE: 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 : ${PACKAGE_NAME:=${PN}}
91
92 if [[ -n ${GIT_ECLASS} ]]; then
93 EGIT_REPO_URI="git://anongit.freedesktop.org/git/xorg/${MODULE}${PACKAGE_NAME}"
94 elif [[ -n ${BASE_INDIVIDUAL_URI} ]]; then
95 SRC_URI="${BASE_INDIVIDUAL_URI}/${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.11.0"
113 # Required even by xorg-server
114 [[ ${PN} == "font-util" ]] || EAUTORECONF_DEPEND+=" >=media-fonts/font-util-1.1.1-r1"
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.1.1-r1"
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 # Check deps on drivers
181 if has dri ${IUSE//+}; then
182 COMMON_DEPEND+=" dri? (
183 x11-base/xorg-server[-minimal]
184 x11-libs/libdrm
185 )"
186 DEPEND+=" dri? (
187 x11-proto/xf86driproto
188 x11-proto/glproto
189 x11-proto/dri2proto
190 )"
191 fi
192 if [[ -n "${DRIVER}" ]]; then
193 COMMON_DEPEND+="
194 x11-base/xorg-server[xorg]
195 "
196 fi
197 if [[ -n "${DRIVER}" && ${PN} == xf86-video-* ]]; then
198 COMMON_DEPEND+="
199 x11-libs/libpciaccess
200 "
201 # we also needs some protos and libs in all cases
202 DEPEND+="
203 x11-proto/fontsproto
204 x11-proto/randrproto
205 x11-proto/renderproto
206 x11-proto/videoproto
207 x11-proto/xextproto
208 x11-proto/xineramaproto
209 x11-proto/xproto
210 "
211 fi
212
213 # Add deps on documentation
214 # Most docbooks use dtd version 4.2 and 4.3 add more when found
215 if has doc ${IUSE//+}; then
216 DEPEND+="
217 doc? (
218 app-text/xmlto
219 app-doc/doxygen
220 app-text/docbook-xml-dtd:4.1
221 app-text/docbook-xml-dtd:4.2
222 app-text/docbook-xml-dtd:4.3
223 )
224 "
225 fi
226
227 DEPEND+=" ${COMMON_DEPEND}"
228 RDEPEND+=" ${COMMON_DEPEND}"
229 unset COMMON_DEPEND
230
231 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND=${DEPEND}"
232 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: RDEPEND=${RDEPEND}"
233
234 # @FUNCTION: xorg-2_pkg_setup
235 # @DESCRIPTION:
236 # Setup prefix compat
237 xorg-2_pkg_setup() {
238 debug-print-function ${FUNCNAME} "$@"
239
240 [[ ${FONT} == yes ]] && font_pkg_setup "$@"
241 }
242
243 # @FUNCTION: xorg-2_src_unpack
244 # @DESCRIPTION:
245 # Simply unpack source code.
246 xorg-2_src_unpack() {
247 debug-print-function ${FUNCNAME} "$@"
248
249 if [[ -n ${GIT_ECLASS} ]]; then
250 git_src_unpack
251 else
252 unpack ${A}
253 fi
254
255 [[ -n ${FONT_OPTIONS} ]] && einfo "Detected font directory: ${FONT_DIR}"
256 }
257
258 # @FUNCTION: xorg-2_patch_source
259 # @DESCRIPTION:
260 # Apply all patches
261 xorg-2_patch_source() {
262 debug-print-function ${FUNCNAME} "$@"
263
264 # Use standardized names and locations with bulk patching
265 # Patch directory is ${WORKDIR}/patch
266 # See epatch() in eutils.eclass for more documentation
267 EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
268
269 [[ -d "${EPATCH_SOURCE}" ]] && epatch
270 autotools-utils_src_prepare "$@"
271 }
272
273 # @FUNCTION: xorg-2_reconf_source
274 # @DESCRIPTION:
275 # Run eautoreconf if necessary, and run elibtoolize.
276 xorg-2_reconf_source() {
277 debug-print-function ${FUNCNAME} "$@"
278
279 case ${CHOST} in
280 *-interix* | *-aix* | *-winnt*)
281 # some hosts need full eautoreconf
282 [[ -e "./configure.ac" || -e "./configure.in" ]] && eautoreconf || ewarn "Unable to autoreconf the configure script. Things may fail."
283 ;;
284 *)
285 # elibtoolize required for BSD
286 [[ ${XORG_EAUTORECONF} != no && ( -e "./configure.ac" || -e "./configure.in" ) ]] && eautoreconf || elibtoolize
287 ;;
288 esac
289 }
290
291 # @FUNCTION: xorg-2_src_prepare
292 # @DESCRIPTION:
293 # Prepare a package after unpacking, performing all X-related tasks.
294 xorg-2_src_prepare() {
295 debug-print-function ${FUNCNAME} "$@"
296
297 [[ -n ${GIT_ECLASS} ]] && git_src_prepare
298 xorg-2_patch_source
299 xorg-2_reconf_source
300 }
301
302 # @FUNCTION: xorg-2_font_configure
303 # @DESCRIPTION:
304 # If a font package, perform any necessary configuration steps
305 xorg-2_font_configure() {
306 debug-print-function ${FUNCNAME} "$@"
307
308 if has nls ${IUSE//+} && ! use nls; then
309 if grep -q -s "disable-all-encodings" ${ECONF_SOURCE:-.}/configure; then
310 FONT_OPTIONS+="
311 --disable-all-encodings"
312 else
313 FONT_OPTIONS+="
314 --disable-iso8859-2
315 --disable-iso8859-3
316 --disable-iso8859-4
317 --disable-iso8859-5
318 --disable-iso8859-6
319 --disable-iso8859-7
320 --disable-iso8859-8
321 --disable-iso8859-9
322 --disable-iso8859-10
323 --disable-iso8859-11
324 --disable-iso8859-12
325 --disable-iso8859-13
326 --disable-iso8859-14
327 --disable-iso8859-15
328 --disable-iso8859-16
329 --disable-jisx0201
330 --disable-koi8-r"
331 fi
332 fi
333 }
334
335 # @FUNCTION: xorg-2_flags_setup
336 # @DESCRIPTION:
337 # Set up CFLAGS for a debug build
338 xorg-2_flags_setup() {
339 debug-print-function ${FUNCNAME} "$@"
340
341 # Win32 require special define
342 [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__
343 # hardened ldflags
344 [[ ${PN} = xorg-server || -n ${DRIVER} ]] && append-ldflags -Wl,-z,lazy
345
346 # Quite few libraries fail on runtime without these:
347 if has static-libs ${IUSE//+}; then
348 filter-flags -Wl,-Bdirect
349 filter-ldflags -Bdirect
350 filter-ldflags -Wl,-Bdirect
351 fi
352 }
353
354 # @FUNCTION: xorg-2_src_configure
355 # @DESCRIPTION:
356 # Perform any necessary pre-configuration steps, then run configure
357 xorg-2_src_configure() {
358 debug-print-function ${FUNCNAME} "$@"
359
360 xorg-2_flags_setup
361
362 # @VARIABLE: CONFIGURE_OPTIONS
363 # @DESCRIPTION:
364 # Any options to pass to configure
365 # @DEFAULT_UNSET
366 CONFIGURE_OPTIONS=${CONFIGURE_OPTIONS:=""}
367
368 [[ -n "${FONT}" ]] && xorg-2_font_configure
369 local myeconfargs=(
370 --disable-dependency-tracking
371 ${CONFIGURE_OPTIONS}
372 ${FONT_OPTIONS}
373 )
374
375 autotools-utils_src_configure "$@"
376 }
377
378 # @FUNCTION: xorg-2_src_compile
379 # @DESCRIPTION:
380 # Compile a package, performing all X-related tasks.
381 xorg-2_src_compile() {
382 debug-print-function ${FUNCNAME} "$@"
383
384 autotools-utils_src_compile "$@"
385 }
386
387 # @FUNCTION: xorg-2_src_install
388 # @DESCRIPTION:
389 # Install a built package to ${D}, performing any necessary steps.
390 # Creates a ChangeLog from git if using live ebuilds.
391 xorg-2_src_install() {
392 debug-print-function ${FUNCNAME} "$@"
393
394 if [[ ${CATEGORY} == x11-proto ]]; then
395 autotools-utils_src_install \
396 ${PN/proto/}docdir="${EPREFIX}/usr/share/doc/${PF}" \
397 docdir="${EPREFIX}/usr/share/doc/${PF}"
398 else
399 autotools-utils_src_install \
400 docdir="${EPREFIX}/usr/share/doc/${PF}"
401 fi
402
403 if [[ -n ${GIT_ECLASS} ]]; then
404 pushd "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" > /dev/null
405 git log ${EGIT_COMMIT} > "${S}"/ChangeLog
406 popd > /dev/null
407 fi
408
409 if [[ -e "${S}"/ChangeLog ]]; then
410 dodoc "${S}"/ChangeLog || die "dodoc failed"
411 fi
412
413 # Don't install libtool archives (even with static-libs)
414 remove_libtool_files all
415
416 [[ -n ${FONT} ]] && remove_font_metadata
417 }
418
419 # @FUNCTION: xorg-2_pkg_postinst
420 # @DESCRIPTION:
421 # Run X-specific post-installation tasks on the live filesystem. The
422 # only task right now is some setup for font packages.
423 xorg-2_pkg_postinst() {
424 debug-print-function ${FUNCNAME} "$@"
425
426 [[ -n ${FONT} ]] && setup_fonts "$@"
427 }
428
429 # @FUNCTION: xorg-2_pkg_postrm
430 # @DESCRIPTION:
431 # Run X-specific post-removal tasks on the live filesystem. The only
432 # task right now is some cleanup for font packages.
433 xorg-2_pkg_postrm() {
434 debug-print-function ${FUNCNAME} "$@"
435
436 [[ -n ${FONT} ]] && font_pkg_postrm "$@"
437 }
438
439 # @FUNCTION: setup_fonts
440 # @DESCRIPTION:
441 # Generates needed files for fonts and fixes font permissions
442 setup_fonts() {
443 debug-print-function ${FUNCNAME} "$@"
444
445 create_fonts_scale
446 create_fonts_dir
447 font_pkg_postinst
448 }
449
450 # @FUNCTION: remove_font_metadata
451 # @DESCRIPTION:
452 # Don't let the package install generated font files that may overlap
453 # with other packages. Instead, they're generated in pkg_postinst().
454 remove_font_metadata() {
455 debug-print-function ${FUNCNAME} "$@"
456
457 if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
458 einfo "Removing font metadata"
459 rm -rf "${ED}"/usr/share/fonts/${FONT_DIR}/fonts.{scale,dir,cache-1}
460 fi
461 }
462
463 # @FUNCTION: create_fonts_scale
464 # @DESCRIPTION:
465 # Create fonts.scale file, used by the old server-side fonts subsystem.
466 create_fonts_scale() {
467 debug-print-function ${FUNCNAME} "$@"
468
469 if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
470 ebegin "Generating font.scale"
471 mkfontscale \
472 -a "${EROOT}/usr/share/fonts/encodings/encodings.dir" \
473 -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
474 eend $?
475 fi
476 }
477
478 # @FUNCTION: create_fonts_dir
479 # @DESCRIPTION:
480 # Create fonts.dir file, used by the old server-side fonts subsystem.
481 create_fonts_dir() {
482 debug-print-function ${FUNCNAME} "$@"
483
484 ebegin "Generating fonts.dir"
485 mkfontdir \
486 -e "${EROOT}"/usr/share/fonts/encodings \
487 -e "${EROOT}"/usr/share/fonts/encodings/large \
488 -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
489 eend $?
490 }

  ViewVC Help
Powered by ViewVC 1.1.20