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

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (show annotations) (download)
Sat Jan 15 17:55:21 2011 UTC (3 years, 6 months ago) by scarabeus
Branch: MAIN
Changes since 1.21: +2 -1 lines
By default disable dependency tracking, all x11 packages support this one.

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.21 2011/01/06 11:01:59 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 SRC_URI=""
28 fi
29
30 # If we're a font package, but not the font.alias one
31 FONT_ECLASS=""
32 if [[ ${PN} == font* \
33 && ${CATEGORY} = media-fonts \
34 && ${PN} != font-alias \
35 && ${PN} != font-util ]]; then
36 # Activate font code in the rest of the eclass
37 FONT="yes"
38 FONT_ECLASS="font"
39 fi
40
41 inherit eutils base libtool multilib toolchain-funcs flag-o-matic autotools \
42 ${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) EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare src_configure" ;;
47 *) die "EAPI-UNSUPPORTED" ;;
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 # Set up SRC_URI for individual modular releases
63 BASE_INDIVIDUAL_URI="http://xorg.freedesktop.org/releases/individual"
64 # @ECLASS-VARIABLE: MODULE
65 # @DESCRIPTION:
66 # The subdirectory to download source from. Possible settings are app,
67 # doc, data, util, driver, font, lib, proto, xserver. Set above the
68 # inherit to override the default autoconfigured module.
69 if [[ -z ${MODULE} ]]; then
70 case ${CATEGORY} in
71 app-doc) MODULE="doc" ;;
72 media-fonts) MODULE="font" ;;
73 x11-apps|x11-wm) MODULE="app" ;;
74 x11-misc|x11-themes) MODULE="util" ;;
75 x11-drivers) MODULE="driver" ;;
76 x11-base) MODULE="xserver" ;;
77 x11-proto) MODULE="proto" ;;
78 x11-libs) MODULE="lib" ;;
79 *) MODULE="" ;;
80 esac
81 fi
82
83 # @ECLASS-VARIABLE: PACKAGE_NAME
84 # @DESCRIPTION:
85 # For git checkout the git repository migth differ from package name.
86 # This variable can be used for proper directory specification
87 : ${PACKAGE_NAME:=${PN}}
88
89 if [[ -n ${GIT_ECLASS} ]]; then
90 EGIT_REPO_URI="git://anongit.freedesktop.org/git/xorg/${MODULE}/${PACKAGE_NAME}"
91 else
92 SRC_URI+=" ${BASE_INDIVIDUAL_URI}/${MODULE}/${P}.tar.bz2"
93 fi
94
95 : ${SLOT:=0}
96
97 # Set the license for the package. This can be overridden by setting
98 # LICENSE after the inherit. Nearly all FreeDesktop-hosted X packages
99 # are under the MIT license. (This is what Red Hat does in their rpms)
100 : ${LICENSE:=MIT}
101
102 # Set up autotools shared dependencies
103 # Remember that all versions here MUST be stable
104 XORG_EAUTORECONF_ARCHES="x86-interix ppc-aix x86-winnt"
105 EAUTORECONF_DEPEND+="
106 >=sys-devel/libtool-2.2.6a
107 sys-devel/m4"
108 if [[ ${PN} != util-macros ]] ; then
109 EAUTORECONF_DEPEND+=" >=x11-misc/util-macros-1.11.0"
110 # Required even by xorg-server
111 [[ ${PN} == "font-util" ]] || EAUTORECONF_DEPEND+=" >=media-fonts/font-util-1.1.1-r1"
112 fi
113 WANT_AUTOCONF="latest"
114 WANT_AUTOMAKE="latest"
115 for arch in ${XORG_EAUTORECONF_ARCHES}; do
116 EAUTORECONF_DEPENDS+=" ${arch}? ( ${EAUTORECONF_DEPEND} )"
117 done
118 DEPEND+=" ${EAUTORECONF_DEPENDS}"
119 [[ ${XORG_EAUTORECONF} != no ]] && DEPEND+=" ${EAUTORECONF_DEPEND}"
120 unset EAUTORECONF_DEPENDS
121 unset EAUTORECONF_DEPEND
122
123 if [[ ${FONT} == yes ]]; then
124 RDEPEND+=" media-fonts/encodings
125 x11-apps/mkfontscale
126 x11-apps/mkfontdir"
127 PDEPEND+=" media-fonts/font-alias"
128 DEPEND+=" >=media-fonts/font-util-1.1.1-r1"
129
130 # @ECLASS-VARIABLE: FONT_DIR
131 # @DESCRIPTION:
132 # If you're creating a font package and the suffix of PN is not equal to
133 # the subdirectory of /usr/share/fonts/ it should install into, set
134 # FONT_DIR to that directory or directories. Set before inheriting this
135 # eclass.
136 [[ -z ${FONT_DIR} ]] && FONT_DIR=${PN##*-}
137
138 # Fix case of font directories
139 FONT_DIR=${FONT_DIR/ttf/TTF}
140 FONT_DIR=${FONT_DIR/otf/OTF}
141 FONT_DIR=${FONT_DIR/type1/Type1}
142 FONT_DIR=${FONT_DIR/speedo/Speedo}
143
144 # Set up configure options, wrapped so ebuilds can override if need be
145 [[ -z ${FONT_OPTIONS} ]] && FONT_OPTIONS="--with-fontdir=\"${EPREFIX}/usr/share/fonts/${FONT_DIR}\""
146
147 [[ ${PN##*-} = misc || ${PN##*-} = 75dpi || ${PN##*-} = 100dpi || ${PN##*-} = cyrillic ]] && IUSE+=" nls"
148 fi
149
150 # If we're a driver package, then enable DRIVER case
151 [[ ${PN} == xf86-video-* || ${PN} == xf86-input-* ]] && DRIVER="yes"
152
153 # @ECLASS-VARIABLE: XORG_STATIC
154 # @DESCRIPTION:
155 # Enables static-libs useflag. Set to no, if your package gets:
156 #
157 # QA: configure: WARNING: unrecognized options: --disable-static
158 : ${XORG_STATIC:="yes"}
159
160 # Add static-libs useflag where usefull.
161 if [[ ${XORG_STATIC} == yes \
162 && ${FONT} != yes \
163 && ${CATEGORY} != app-doc \
164 && ${CATEGORY} != x11-apps \
165 && ${CATEGORY} != x11-proto \
166 && ${CATEGORY} != x11-drivers \
167 && ${CATEGORY} != media-fonts \
168 && ${PN} != util-macros \
169 && ${PN} != xbitmaps \
170 && ${PN} != xorg-cf-files \
171 && ${PN/xcursor} = ${PN} ]]; then
172 IUSE+=" static-libs"
173 fi
174
175 DEPEND+=" >=dev-util/pkgconfig-0.23"
176
177 # Check deps on xorg-server
178 has dri ${IUSE//+} && DEPEND+=" dri? ( >=x11-base/xorg-server-1.6.3.901-r2[-minimal] )"
179 [[ -n "${DRIVER}" ]] && DEPEND+=" x11-base/xorg-server[xorg]"
180
181 # @FUNCTION: xorg-2_pkg_setup
182 # @DESCRIPTION:
183 # Setup prefix compat
184 xorg-2_pkg_setup() {
185 debug-print-function ${FUNCNAME} "$@"
186
187 [[ ${FONT} == yes ]] && font_pkg_setup "$@"
188 }
189
190 # @FUNCTION: xorg-2_src_unpack
191 # @DESCRIPTION:
192 # Simply unpack source code.
193 xorg-2_src_unpack() {
194 debug-print-function ${FUNCNAME} "$@"
195
196 if [[ -n ${GIT_ECLASS} ]]; then
197 git_src_unpack
198 else
199 unpack ${A}
200 fi
201
202 [[ -n ${FONT_OPTIONS} ]] && einfo "Detected font directory: ${FONT_DIR}"
203 }
204
205 # @FUNCTION: xorg-2_patch_source
206 # @DESCRIPTION:
207 # Apply all patches
208 xorg-2_patch_source() {
209 debug-print-function ${FUNCNAME} "$@"
210
211 # Use standardized names and locations with bulk patching
212 # Patch directory is ${WORKDIR}/patch
213 # See epatch() in eutils.eclass for more documentation
214 EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
215
216 [[ -d "${EPATCH_SOURCE}" ]] && epatch
217 base_src_prepare "$@"
218 }
219
220 # @FUNCTION: xorg-2_reconf_source
221 # @DESCRIPTION:
222 # Run eautoreconf if necessary, and run elibtoolize.
223 xorg-2_reconf_source() {
224 debug-print-function ${FUNCNAME} "$@"
225
226 case ${CHOST} in
227 *-interix* | *-aix* | *-winnt*)
228 # some hosts need full eautoreconf
229 [[ -e "./configure.ac" || -e "./configure.in" ]] && eautoreconf || ewarn "Unable to autoreconf the configure script. Things may fail."
230 ;;
231 *)
232 # elibtoolize required for BSD
233 [[ ${XORG_EAUTORECONF} != no && ( -e "./configure.ac" || -e "./configure.in" ) ]] && eautoreconf || elibtoolize
234 ;;
235 esac
236 }
237
238 # @FUNCTION: xorg-2_src_prepare
239 # @DESCRIPTION:
240 # Prepare a package after unpacking, performing all X-related tasks.
241 xorg-2_src_prepare() {
242 debug-print-function ${FUNCNAME} "$@"
243
244 [[ -n ${GIT_ECLASS} ]] && git_src_prepare
245 xorg-2_patch_source
246 xorg-2_reconf_source
247 }
248
249 # @FUNCTION: xorg-2_font_configure
250 # @DESCRIPTION:
251 # If a font package, perform any necessary configuration steps
252 xorg-2_font_configure() {
253 debug-print-function ${FUNCNAME} "$@"
254
255 if has nls ${IUSE//+} && ! use nls; then
256 FONT_OPTIONS+="
257 --disable-iso8859-2
258 --disable-iso8859-3
259 --disable-iso8859-4
260 --disable-iso8859-5
261 --disable-iso8859-6
262 --disable-iso8859-7
263 --disable-iso8859-8
264 --disable-iso8859-9
265 --disable-iso8859-10
266 --disable-iso8859-11
267 --disable-iso8859-12
268 --disable-iso8859-13
269 --disable-iso8859-14
270 --disable-iso8859-15
271 --disable-iso8859-16
272 --disable-jisx0201
273 --disable-koi8-r"
274 fi
275 }
276
277 # @FUNCTION: xorg-2_flags_setup
278 # @DESCRIPTION:
279 # Set up CFLAGS for a debug build
280 xorg-2_flags_setup() {
281 debug-print-function ${FUNCNAME} "$@"
282
283 # Win32 require special define
284 [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__
285 # hardened ldflags
286 [[ ${PN} = xorg-server || -n ${DRIVER} ]] && append-ldflags -Wl,-z,lazy
287
288 # Quite few libraries fail on runtime without these:
289 if has static-libs ${IUSE//+}; then
290 filter-flags -Wl,-Bdirect
291 filter-ldflags -Bdirect
292 filter-ldflags -Wl,-Bdirect
293 fi
294 }
295
296 # @FUNCTION: xorg-2_src_configure
297 # @DESCRIPTION:
298 # Perform any necessary pre-configuration steps, then run configure
299 xorg-2_src_configure() {
300 debug-print-function ${FUNCNAME} "$@"
301 local myopts=""
302
303 xorg-2_flags_setup
304 [[ -n "${FONT}" ]] && xorg-2_font_configure
305
306 # @VARIABLE: CONFIGURE_OPTIONS
307 # @DESCRIPTION:
308 # Any options to pass to configure
309 # @DEFAULT_UNSET
310 CONFIGURE_OPTIONS=${CONFIGURE_OPTIONS:=""}
311 if [[ -x ${ECONF_SOURCE:-.}/configure ]]; then
312 if has static-libs ${IUSE//+}; then
313 myopts+=" $(use_enable static-libs static)"
314 fi
315 econf \
316 --disable-dependency-tracking \
317 ${FONT_OPTIONS} \
318 ${CONFIGURE_OPTIONS} \
319 ${myopts}
320 fi
321 }
322
323 # @FUNCTION: xorg-2_src_compile
324 # @DESCRIPTION:
325 # Compile a package, performing all X-related tasks.
326 xorg-2_src_compile() {
327 debug-print-function ${FUNCNAME} "$@"
328
329 base_src_compile "$@"
330 }
331
332 # @FUNCTION: xorg-2_src_install
333 # @DESCRIPTION:
334 # Install a built package to ${D}, performing any necessary steps.
335 # Creates a ChangeLog from git if using live ebuilds.
336 xorg-2_src_install() {
337 debug-print-function ${FUNCNAME} "$@"
338
339 if [[ ${CATEGORY} == x11-proto ]]; then
340 emake \
341 ${PN/proto/}docdir=${EPREFIX}/usr/share/doc/${PF} \
342 docdir=${EPREFIX}/usr/share/doc/${PF} \
343 DESTDIR="${D}" \
344 install || die "emake install failed"
345 else
346 emake \
347 docdir=${EPREFIX}/usr/share/doc/${PF} \
348 DESTDIR="${D}" \
349 install || die "emake install failed"
350 fi
351
352 if [[ -n ${GIT_ECLASS} ]]; then
353 pushd "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" > /dev/null
354 git log ${EGIT_COMMIT} > "${S}"/ChangeLog
355 popd > /dev/null
356 fi
357
358 if [[ -e "${S}"/ChangeLog ]]; then
359 dodoc "${S}"/ChangeLog || die "dodoc failed"
360 fi
361 # @VARIABLE: DOCS
362 # @DESCRIPTION:
363 # Any documentation to install
364 # @DEFAULT_UNSET
365 if [[ -n ${DOCS} ]]; then
366 dodoc ${DOCS} || die "dodoc failed"
367 fi
368
369 # Don't install libtool archives for server modules
370 if [[ -e "${D%/}${EPREFIX}/usr/$(get_libdir)/xorg/modules" ]]; then
371 find "${D%/}${EPREFIX}/usr/$(get_libdir)/xorg/modules" -name '*.la' \
372 -exec rm -f {} ';'
373 fi
374
375 [[ -n ${FONT} ]] && remove_font_metadata
376 }
377
378 # @FUNCTION: xorg-2_pkg_postinst
379 # @DESCRIPTION:
380 # Run X-specific post-installation tasks on the live filesystem. The
381 # only task right now is some setup for font packages.
382 xorg-2_pkg_postinst() {
383 debug-print-function ${FUNCNAME} "$@"
384
385 [[ -n ${FONT} ]] && setup_fonts "$@"
386 }
387
388 # @FUNCTION: xorg-2_pkg_postrm
389 # @DESCRIPTION:
390 # Run X-specific post-removal tasks on the live filesystem. The only
391 # task right now is some cleanup for font packages.
392 xorg-2_pkg_postrm() {
393 debug-print-function ${FUNCNAME} "$@"
394
395 [[ -n ${FONT} ]] && font_pkg_postrm "$@"
396 }
397
398 # @FUNCTION: setup_fonts
399 # @DESCRIPTION:
400 # Generates needed files for fonts and fixes font permissions
401 setup_fonts() {
402 debug-print-function ${FUNCNAME} "$@"
403
404 create_fonts_scale
405 create_fonts_dir
406 font_pkg_postinst
407 }
408
409 # @FUNCTION: remove_font_metadata
410 # @DESCRIPTION:
411 # Don't let the package install generated font files that may overlap
412 # with other packages. Instead, they're generated in pkg_postinst().
413 remove_font_metadata() {
414 debug-print-function ${FUNCNAME} "$@"
415
416 if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
417 einfo "Removing font metadata"
418 rm -rf "${ED}"/usr/share/fonts/${FONT_DIR}/fonts.{scale,dir,cache-1}
419 fi
420 }
421
422 # @FUNCTION: create_fonts_scale
423 # @DESCRIPTION:
424 # Create fonts.scale file, used by the old server-side fonts subsystem.
425 create_fonts_scale() {
426 debug-print-function ${FUNCNAME} "$@"
427
428 if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
429 ebegin "Generating font.scale"
430 mkfontscale \
431 -a "${EROOT}/usr/share/fonts/encodings/encodings.dir" \
432 -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
433 eend $?
434 fi
435 }
436
437 # @FUNCTION: create_fonts_dir
438 # @DESCRIPTION:
439 # Create fonts.dir file, used by the old server-side fonts subsystem.
440 create_fonts_dir() {
441 debug-print-function ${FUNCNAME} "$@"
442
443 ebegin "Generating fonts.dir"
444 mkfontdir \
445 -e "${EROOT}"/usr/share/fonts/encodings \
446 -e "${EROOT}"/usr/share/fonts/encodings/large \
447 -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
448 eend $?
449 }

  ViewVC Help
Powered by ViewVC 1.1.20