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

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.23 - (show annotations) (download)
Tue Feb 15 12:13:58 2011 UTC (3 years, 10 months ago) by scarabeus
Branch: MAIN
Changes since 1.22: +1 -2 lines
Revert disable-dependency-tracking and stick to eapi4 for this.

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.22 2011/01/15 17:55:21 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 ${FONT_OPTIONS} \
317 ${CONFIGURE_OPTIONS} \
318 ${myopts}
319 fi
320 }
321
322 # @FUNCTION: xorg-2_src_compile
323 # @DESCRIPTION:
324 # Compile a package, performing all X-related tasks.
325 xorg-2_src_compile() {
326 debug-print-function ${FUNCNAME} "$@"
327
328 base_src_compile "$@"
329 }
330
331 # @FUNCTION: xorg-2_src_install
332 # @DESCRIPTION:
333 # Install a built package to ${D}, performing any necessary steps.
334 # Creates a ChangeLog from git if using live ebuilds.
335 xorg-2_src_install() {
336 debug-print-function ${FUNCNAME} "$@"
337
338 if [[ ${CATEGORY} == x11-proto ]]; then
339 emake \
340 ${PN/proto/}docdir=${EPREFIX}/usr/share/doc/${PF} \
341 docdir=${EPREFIX}/usr/share/doc/${PF} \
342 DESTDIR="${D}" \
343 install || die "emake install failed"
344 else
345 emake \
346 docdir=${EPREFIX}/usr/share/doc/${PF} \
347 DESTDIR="${D}" \
348 install || die "emake install failed"
349 fi
350
351 if [[ -n ${GIT_ECLASS} ]]; then
352 pushd "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" > /dev/null
353 git log ${EGIT_COMMIT} > "${S}"/ChangeLog
354 popd > /dev/null
355 fi
356
357 if [[ -e "${S}"/ChangeLog ]]; then
358 dodoc "${S}"/ChangeLog || die "dodoc failed"
359 fi
360 # @VARIABLE: DOCS
361 # @DESCRIPTION:
362 # Any documentation to install
363 # @DEFAULT_UNSET
364 if [[ -n ${DOCS} ]]; then
365 dodoc ${DOCS} || die "dodoc failed"
366 fi
367
368 # Don't install libtool archives for server modules
369 if [[ -e "${D%/}${EPREFIX}/usr/$(get_libdir)/xorg/modules" ]]; then
370 find "${D%/}${EPREFIX}/usr/$(get_libdir)/xorg/modules" -name '*.la' \
371 -exec rm -f {} ';'
372 fi
373
374 [[ -n ${FONT} ]] && remove_font_metadata
375 }
376
377 # @FUNCTION: xorg-2_pkg_postinst
378 # @DESCRIPTION:
379 # Run X-specific post-installation tasks on the live filesystem. The
380 # only task right now is some setup for font packages.
381 xorg-2_pkg_postinst() {
382 debug-print-function ${FUNCNAME} "$@"
383
384 [[ -n ${FONT} ]] && setup_fonts "$@"
385 }
386
387 # @FUNCTION: xorg-2_pkg_postrm
388 # @DESCRIPTION:
389 # Run X-specific post-removal tasks on the live filesystem. The only
390 # task right now is some cleanup for font packages.
391 xorg-2_pkg_postrm() {
392 debug-print-function ${FUNCNAME} "$@"
393
394 [[ -n ${FONT} ]] && font_pkg_postrm "$@"
395 }
396
397 # @FUNCTION: setup_fonts
398 # @DESCRIPTION:
399 # Generates needed files for fonts and fixes font permissions
400 setup_fonts() {
401 debug-print-function ${FUNCNAME} "$@"
402
403 create_fonts_scale
404 create_fonts_dir
405 font_pkg_postinst
406 }
407
408 # @FUNCTION: remove_font_metadata
409 # @DESCRIPTION:
410 # Don't let the package install generated font files that may overlap
411 # with other packages. Instead, they're generated in pkg_postinst().
412 remove_font_metadata() {
413 debug-print-function ${FUNCNAME} "$@"
414
415 if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
416 einfo "Removing font metadata"
417 rm -rf "${ED}"/usr/share/fonts/${FONT_DIR}/fonts.{scale,dir,cache-1}
418 fi
419 }
420
421 # @FUNCTION: create_fonts_scale
422 # @DESCRIPTION:
423 # Create fonts.scale file, used by the old server-side fonts subsystem.
424 create_fonts_scale() {
425 debug-print-function ${FUNCNAME} "$@"
426
427 if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
428 ebegin "Generating font.scale"
429 mkfontscale \
430 -a "${EROOT}/usr/share/fonts/encodings/encodings.dir" \
431 -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
432 eend $?
433 fi
434 }
435
436 # @FUNCTION: create_fonts_dir
437 # @DESCRIPTION:
438 # Create fonts.dir file, used by the old server-side fonts subsystem.
439 create_fonts_dir() {
440 debug-print-function ${FUNCNAME} "$@"
441
442 ebegin "Generating fonts.dir"
443 mkfontdir \
444 -e "${EROOT}"/usr/share/fonts/encodings \
445 -e "${EROOT}"/usr/share/fonts/encodings/large \
446 -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
447 eend $?
448 }

  ViewVC Help
Powered by ViewVC 1.1.20