/[gentoo-x86]/eclass/x-modular.eclass
Gentoo

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.80 - (hide annotations) (download)
Mon Oct 30 18:40:58 2006 UTC (8 years, 1 month ago) by dberkholz
Branch: MAIN
Changes since 1.79: +6 -2 lines
Only inherit font.eclass on fonts so we don't get USE=X for everything. This requires the inherit line to move below the FONT setup. Idea from Diego Pettenó.

1 spyderous 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 dberkholz 1.77 # $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.76 2006/10/11 02:31:47 dberkholz Exp $
4 spyderous 1.1 #
5     # Author: Donnie Berkholz <spyderous@gentoo.org>
6     #
7     # This eclass is designed to reduce code duplication in the modularized X11
8     # ebuilds.
9 spyderous 1.32 #
10     # Using this eclass:
11     #
12     # Inherit it. If you need to run autoreconf for any reason (e.g., your patches
13     # apply to the autotools files rather than configure), set SNAPSHOT="yes". Set
14     # CONFIGURE_OPTIONS to everything you want to pass to the configure script.
15     #
16     # If you have any patches to apply, set PATCHES to their locations and epatch
17     # will apply them. It also handles epatch-style bulk patches, if you know how to
18     # use them and set the correct variables. If you don't, read eutils.eclass.
19     #
20     # If you're creating a font package and the suffix of PN is not equal to the
21     # subdirectory of /usr/share/fonts/ it should install into, set FONT_DIR to that
22     # directory or directories.
23     #
24 spyderous 1.33 # IMPORTANT: Both SNAPSHOT and FONT_DIR must be set _before_ the inherit.
25     #
26 spyderous 1.32 # Pretty much everything else should be automatic.
27 spyderous 1.1
28     # Directory prefix to use for everything
29     XDIR="/usr"
30    
31 joshuabaergen 1.29 # Set up default patchset version(s) if necessary
32     # x11-driver-patches
33     if [[ -z "${XDPVER}" ]]; then
34     XDPVER="1"
35     fi
36    
37 spyderous 1.1 IUSE=""
38     HOMEPAGE="http://xorg.freedesktop.org/"
39 spyderous 1.44
40     # Set up SRC_URI for individual modular releases
41     BASE_INDIVIDUAL_URI="http://xorg.freedesktop.org/releases/individual"
42 spyderous 1.57 if [[ ${CATEGORY} = x11-apps ]] || [[ ${CATEGORY} = x11-wm ]]; then
43 spyderous 1.44 SRC_URI="${SRC_URI}
44     ${BASE_INDIVIDUAL_URI}/app/${P}.tar.bz2"
45     elif [[ ${CATEGORY} = app-doc ]]; then
46     SRC_URI="${SRC_URI}
47     ${BASE_INDIVIDUAL_URI}/doc/${P}.tar.bz2"
48     # x11-misc contains data and util, x11-themes contains data
49     elif [[ ${CATEGORY} = x11-misc ]] || [[ ${CATEGORY} = x11-themes ]]; then
50     SRC_URI="${SRC_URI}
51     ${BASE_INDIVIDUAL_URI}/data/${P}.tar.bz2
52     ${BASE_INDIVIDUAL_URI}/util/${P}.tar.bz2"
53     elif [[ ${CATEGORY} = x11-drivers ]]; then
54     SRC_URI="${SRC_URI}
55     ${BASE_INDIVIDUAL_URI}/driver/${P}.tar.bz2"
56     elif [[ ${CATEGORY} = media-fonts ]]; then
57     SRC_URI="${SRC_URI}
58     ${BASE_INDIVIDUAL_URI}/font/${P}.tar.bz2"
59     elif [[ ${CATEGORY} = x11-libs ]]; then
60     SRC_URI="${SRC_URI}
61     ${BASE_INDIVIDUAL_URI}/lib/${P}.tar.bz2"
62     elif [[ ${CATEGORY} = x11-proto ]]; then
63     SRC_URI="${SRC_URI}
64     ${BASE_INDIVIDUAL_URI}/proto/${P}.tar.bz2"
65     elif [[ ${CATEGORY} = x11-base ]]; then
66     SRC_URI="${SRC_URI}
67     ${BASE_INDIVIDUAL_URI}/xserver/${P}.tar.bz2"
68     fi
69    
70 spyderous 1.1 SLOT="0"
71    
72 joshuabaergen 1.40 # Set the license for the package. This can be overridden by setting
73     # LICENSE after the inherit.
74     LICENSE=${PN}
75    
76 spyderous 1.1 # Set up shared dependencies
77 spyderous 1.28 if [[ -n "${SNAPSHOT}" ]]; then
78 spyderous 1.1 # FIXME: What's the minimal libtool version supporting arbitrary versioning?
79     DEPEND="${DEPEND}
80     >=sys-devel/autoconf-2.57
81     >=sys-devel/automake-1.7
82     >=sys-devel/libtool-1.5
83     >=sys-devel/m4-1.4"
84     fi
85    
86 spyderous 1.3 # If we're a font package, but not the font.alias one
87 dberkholz 1.80 FONT_ECLASS=""
88 spyderous 1.25 if [[ "${PN/#font-}" != "${PN}" ]] \
89 spyderous 1.49 && [[ "${CATEGORY}" = "media-fonts" ]] \
90 spyderous 1.25 && [[ "${PN}" != "font-alias" ]] \
91     && [[ "${PN}" != "font-util" ]]; then
92 spyderous 1.4 # Activate font code in the rest of the eclass
93     FONT="yes"
94    
95 dberkholz 1.80 # Whether to inherit the font eclass
96     FONT_ECLASS="font"
97    
98 spyderous 1.3 RDEPEND="${RDEPEND}
99 spyderous 1.36 media-fonts/encodings
100 spyderous 1.30 x11-apps/mkfontscale
101     x11-apps/mkfontdir"
102 spyderous 1.3 PDEPEND="${PDEPEND}
103     media-fonts/font-alias"
104 spyderous 1.25
105     # Starting with 7.0RC3, we can specify the font directory
106     # But oddly, we can't do the same for encodings or font-alias
107    
108     # Wrap in `if` so ebuilds can set it too
109     if [[ -z ${FONT_DIR} ]]; then
110     FONT_DIR=${PN##*-}
111    
112     fi
113    
114     # Fix case of font directories
115     FONT_DIR=${FONT_DIR/ttf/TTF}
116     FONT_DIR=${FONT_DIR/otf/OTF}
117     FONT_DIR=${FONT_DIR/type1/Type1}
118     FONT_DIR=${FONT_DIR/speedo/Speedo}
119    
120     # Set up configure option
121     FONT_OPTIONS="--with-fontdir=\"/usr/share/fonts/${FONT_DIR}\""
122    
123     if [[ -n "${FONT}" ]]; then
124     if [[ ${PN##*-} = misc ]] || [[ ${PN##*-} = 75dpi ]] || [[ ${PN##*-} = 100dpi ]]; then
125     IUSE="${IUSE} nls"
126     fi
127     fi
128 spyderous 1.3 fi
129    
130 spyderous 1.7 # If we're a driver package
131 spyderous 1.12 if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then
132 joshuabaergen 1.29 # Enable driver code in the rest of the eclass
133     DRIVER="yes"
134    
135 joshuabaergen 1.72 if [[ ${XDPVER} != -1 ]]; then
136     # Add driver patchset to SRC_URI
137     SRC_URI="${SRC_URI}
138     http://dev.gentoo.org/~joshuabaergen/distfiles/x11-driver-patches-${XDPVER}.tar.bz2"
139     fi
140 spyderous 1.7 fi
141    
142 spyderous 1.41 # Debugging -- ignore packages that can't be built with debugging
143     if [[ -z "${FONT}" ]] \
144     || [[ "${PN/app-doc}" != "${PN}" ]] \
145     || [[ "${PN/x11-proto}" != "${PN}" ]] \
146     || [[ "${PN/util-macros}" != "${PN}" ]] \
147     || [[ "${PN/xbitmaps}" != "${PN}" ]] \
148     || [[ "${PN/xkbdata}" != "${PN}" ]] \
149     || [[ "${PN/xorg-cf-files}" != "${PN}" ]] \
150     || [[ "${PN/xcursor}" != "${PN}" ]] \
151     ; then
152     DEBUGGABLE="yes"
153     IUSE="${IUSE} debug"
154     if use debug; then
155 spyderous 1.46 if ! has splitdebug ${FEATURES}; then
156     RESTRICT="${RESTRICT} nostrip"
157     fi
158 spyderous 1.41 fi
159     fi
160    
161 spyderous 1.1 DEPEND="${DEPEND}
162 spyderous 1.64 >=dev-util/pkgconfig-0.18"
163 spyderous 1.39
164 spyderous 1.43 if [[ "${PN/util-macros}" = "${PN}" ]]; then
165 spyderous 1.39 DEPEND="${DEPEND}
166 spyderous 1.68 >=x11-misc/util-macros-0.99.2
167 spyderous 1.71 >=sys-devel/binutils-2.16.1-r3"
168 spyderous 1.39 fi
169 spyderous 1.1
170 spyderous 1.13 RDEPEND="${RDEPEND}
171 dberkholz 1.76 || ( >=sys-apps/man-1.6b-r2 >=sys-apps/man-db-2.4.3-r1 )
172 exg 1.59 !<=x11-base/xorg-x11-6.9"
173 spyderous 1.13 # Provides virtual/x11 for temporary use until packages are ported
174 spyderous 1.1 # x11-base/x11-env"
175    
176 dberkholz 1.80 inherit eutils libtool multilib toolchain-funcs flag-o-matic autotools ${FONT_ECLASS}
177    
178 spyderous 1.54 x-modular_specs_check() {
179     if [[ ${PN:0:11} = "xorg-server" ]] || [[ -n "${DRIVER}" ]]; then
180 solar 1.62 append-ldflags -Wl,-z,lazy
181 spyderous 1.56 # (#116698) breaks loading
182     filter-ldflags -Wl,-z,now
183 spyderous 1.54 fi
184     }
185    
186 spyderous 1.55 x-modular_dri_check() {
187 spyderous 1.53 # (#120057) Enabling DRI in drivers requires that the server was built with
188     # support for it
189     if [[ -n "${DRIVER}" ]]; then
190     if has dri ${IUSE} && use dri; then
191     einfo "Checking for direct rendering capabilities ..."
192     if ! built_with_use x11-base/xorg-server dri; then
193     die "You must build x11-base/xorg-server with USE=dri."
194     fi
195     fi
196     fi
197 spyderous 1.55 }
198 spyderous 1.53
199 joshuabaergen 1.61 x-modular_server_supports_drivers_check() {
200     # (#135873) Only certain servers will actually use or be capable of
201     # building external drivers, including binary drivers.
202     if [[ -n "${DRIVER}" ]]; then
203 spyderous 1.67 if has_version '>=x11-base/xorg-server-1.1'; then
204 spyderous 1.66 if ! built_with_use x11-base/xorg-server xorg; then
205     eerror "x11-base/xorg-server is not built with support for external drivers."
206     die "You must build x11-base/xorg-server with USE=xorg."
207     fi
208 joshuabaergen 1.61 fi
209     fi
210     }
211    
212 spyderous 1.55 x-modular_unpack_source() {
213 spyderous 1.1 unpack ${A}
214     cd ${S}
215 joshuabaergen 1.16
216 spyderous 1.25 if [[ -n ${FONT_OPTIONS} ]]; then
217     einfo "Detected font directory: ${FONT_DIR}"
218     fi
219 spyderous 1.1 }
220    
221     x-modular_patch_source() {
222     # Use standardized names and locations with bulk patching
223     # Patch directory is ${WORKDIR}/patch
224     # See epatch() in eutils.eclass for more documentation
225 spyderous 1.28 if [[ -z "${EPATCH_SUFFIX}" ]] ; then
226 spyderous 1.1 EPATCH_SUFFIX="patch"
227     fi
228    
229 joshuabaergen 1.29 # If this is a driver package we need to fix man page install location.
230     # Running autoreconf will use the patched util-macros to make the
231     # change for us, so we only need to patch if it is not going to run.
232 joshuabaergen 1.72 if [[ -n "${DRIVER}" ]] && [[ "${SNAPSHOT}" != "yes" ]]\
233     && [[ ${XDPVER} != -1 ]]; then
234 joshuabaergen 1.29 PATCHES="${PATCHES} ${DISTDIR}/x11-driver-patches-${XDPVER}.tar.bz2"
235     fi
236    
237 spyderous 1.1 # For specific list of patches
238 spyderous 1.28 if [[ -n "${PATCHES}" ]] ; then
239 spyderous 1.1 for PATCH in ${PATCHES}
240     do
241     epatch ${PATCH}
242     done
243     # For non-default directory bulk patching
244 spyderous 1.28 elif [[ -n "${PATCH_LOC}" ]] ; then
245 spyderous 1.1 epatch ${PATCH_LOC}
246     # For standard bulk patching
247 spyderous 1.28 elif [[ -d "${EPATCH_SOURCE}" ]] ; then
248 spyderous 1.1 epatch
249     fi
250     }
251    
252     x-modular_reconf_source() {
253     # Run autoreconf for CVS snapshots only
254 spyderous 1.28 if [[ "${SNAPSHOT}" = "yes" ]]
255 spyderous 1.1 then
256     # If possible, generate configure if it doesn't exist
257 dberkholz 1.74 if [ -f "./configure.ac" ]
258 spyderous 1.1 then
259 spyderous 1.51 eautoreconf
260 spyderous 1.1 fi
261     fi
262    
263 spyderous 1.54 # Joshua Baergen - October 23, 2005
264     # Fix shared lib issues on MIPS, FBSD, etc etc
265     elibtoolize
266 spyderous 1.1 }
267    
268     x-modular_src_unpack() {
269 spyderous 1.54 x-modular_specs_check
270 joshuabaergen 1.61 x-modular_server_supports_drivers_check
271 spyderous 1.55 x-modular_dri_check
272 spyderous 1.1 x-modular_unpack_source
273     x-modular_patch_source
274     x-modular_reconf_source
275     }
276    
277 spyderous 1.25 x-modular_font_configure() {
278     if [[ -n "${FONT}" ]]; then
279     # Might be worth adding an option to configure your desired font
280     # and exclude all others. Also, should this USE be nls or minimal?
281     if ! use nls; then
282     FONT_OPTIONS="${FONT_OPTIONS}
283     --disable-iso8859-2
284     --disable-iso8859-3
285     --disable-iso8859-4
286     --disable-iso8859-5
287     --disable-iso8859-6
288     --disable-iso8859-7
289     --disable-iso8859-8
290     --disable-iso8859-9
291     --disable-iso8859-10
292     --disable-iso8859-11
293     --disable-iso8859-12
294     --disable-iso8859-13
295     --disable-iso8859-14
296     --disable-iso8859-15
297     --disable-iso8859-16
298     --disable-jisx0201
299     --disable-koi8-r"
300     fi
301     fi
302     }
303    
304 spyderous 1.41 x-modular_debug_setup() {
305     if [[ -n "${DEBUGGABLE}" ]]; then
306     if use debug; then
307     strip-flags
308 spyderous 1.42 append-flags -g
309 spyderous 1.41 fi
310     fi
311     }
312    
313 spyderous 1.6 x-modular_src_configure() {
314 spyderous 1.25 x-modular_font_configure
315 spyderous 1.41 x-modular_debug_setup
316 spyderous 1.25
317 spyderous 1.1 # If prefix isn't set here, .pc files cause problems
318 spyderous 1.28 if [[ -x ./configure ]]; then
319 spyderous 1.1 econf --prefix=${XDIR} \
320     --datadir=${XDIR}/share \
321 spyderous 1.25 ${FONT_OPTIONS} \
322 spyderous 1.7 ${DRIVER_OPTIONS} \
323 spyderous 1.1 ${CONFIGURE_OPTIONS}
324     fi
325 spyderous 1.6 }
326    
327     x-modular_src_make() {
328 spyderous 1.1 emake || die "emake failed"
329     }
330    
331 spyderous 1.6 x-modular_src_compile() {
332     x-modular_src_configure
333     x-modular_src_make
334     }
335    
336 spyderous 1.1 x-modular_src_install() {
337     # Install everything to ${XDIR}
338     make \
339     DESTDIR="${D}" \
340     install
341     # Shouldn't be necessary in XDIR=/usr
342     # einstall forces datadir, so we need to re-force it
343     # datadir=${XDIR}/share \
344     # mandir=${XDIR}/share/man \
345 spyderous 1.7
346 spyderous 1.60 if [[ -e ${S}/ChangeLog ]]; then
347     dodoc ${S}/ChangeLog
348     fi
349    
350 spyderous 1.52 # Make sure docs get compressed
351     prepalldocs
352    
353 spyderous 1.7 # Don't install libtool archives for server modules
354 spyderous 1.70 if [[ -e ${D}/usr/$(get_libdir)/xorg/modules ]]; then
355     find ${D}/usr/$(get_libdir)/xorg/modules -name '*.la' \
356 spyderous 1.7 | xargs rm -f
357     fi
358 spyderous 1.48
359     # Don't install overlapping fonts.* files
360     # Generate them instead when possible
361     if [[ -n "${FONT}" ]]; then
362     remove_font_metadata
363     fi
364 dberkholz 1.75
365     if [[ -n "${DRIVER}" ]]; then
366     install_driver_hwdata
367     fi
368 spyderous 1.1 }
369 spyderous 1.2
370 spyderous 1.4 x-modular_pkg_preinst() {
371 dberkholz 1.77 # We no longer do anything here, but we can't remove it from the API
372     :
373 spyderous 1.4 }
374    
375 spyderous 1.2 x-modular_pkg_postinst() {
376     if [[ -n "${FONT}" ]]; then
377     setup_fonts
378     fi
379     }
380    
381 spyderous 1.25 x-modular_pkg_postrm() {
382     if [[ -n "${FONT}" ]]; then
383     cleanup_fonts
384 dberkholz 1.78 font_pkg_postrm
385 spyderous 1.25 fi
386     }
387    
388     cleanup_fonts() {
389     local ALLOWED_FILES="encodings.dir fonts.cache-1 fonts.dir fonts.scale"
390     for DIR in ${FONT_DIR}; do
391     unset KEEP_FONTDIR
392     REAL_DIR=${ROOT}usr/share/fonts/${DIR}
393    
394     ebegin "Checking ${REAL_DIR} for useless files"
395     pushd ${REAL_DIR} &> /dev/null
396     for FILE in *; do
397     unset MATCH
398     for ALLOWED_FILE in ${ALLOWED_FILES}; do
399     if [[ ${FILE} = ${ALLOWED_FILE} ]]; then
400     # If it's allowed, then move on to the next file
401     MATCH="yes"
402     break
403     fi
404     done
405     # If we found a match in allowed files, move on to the next file
406     if [[ -n ${MATCH} ]]; then
407     continue
408     fi
409     # If we get this far, there wasn't a match in the allowed files
410     KEEP_FONTDIR="yes"
411     # We don't need to check more files if we're already keeping it
412     break
413     done
414     popd &> /dev/null
415     # If there are no files worth keeping, then get rid of the dir
416     if [[ -z "${KEEP_FONTDIR}" ]]; then
417     rm -rf ${REAL_DIR}
418     fi
419     eend 0
420     done
421     }
422    
423 spyderous 1.2 setup_fonts() {
424 dberkholz 1.77 if [[ ! -n "${FONT_DIR}" ]]; then
425     msg="FONT_DIR is empty. The ebuild should set it to at least one subdir of /usr/share/fonts."
426 spyderous 1.25 eerror "${msg}"
427     die "${msg}"
428 spyderous 1.2 fi
429    
430     create_fonts_scale
431     create_fonts_dir
432     fix_font_permissions
433     create_font_cache
434     }
435    
436 spyderous 1.48 remove_font_metadata() {
437     local DIR
438     for DIR in ${FONT_DIR}; do
439     if [[ "${DIR}" != "Speedo" ]] && \
440     [[ "${DIR}" != "CID" ]] ; then
441     # Delete font metadata files
442     # fonts.scale, fonts.dir, fonts.cache-1
443     rm -f ${D}/usr/share/fonts/${DIR}/fonts.{scale,dir,cache-1}
444     fi
445     done
446     }
447    
448 dberkholz 1.75 # Installs device-to-driver mappings for system-config-display
449     # and anything else that uses hwdata
450     install_driver_hwdata() {
451     insinto /usr/share/hwdata/videoaliases
452     for i in "${FILESDIR}"/*.xinf; do
453     # We need this for the case when none exist,
454     # so *.xinf doesn't expand
455     if [[ -e $i ]]; then
456     doins $i
457     fi
458     done
459     }
460    
461 spyderous 1.4 discover_font_dirs() {
462 dberkholz 1.77 FONT_DIRS="${FONT_DIR}"
463 spyderous 1.4 }
464    
465 spyderous 1.2 create_fonts_scale() {
466     ebegin "Creating fonts.scale files"
467     local x
468 dberkholz 1.77 for DIR in ${FONT_DIR}; do
469     x=${ROOT}/usr/share/fonts/${DIR}
470 spyderous 1.28 [[ -z "$(ls ${x}/)" ]] && continue
471     [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
472 spyderous 1.2
473     # Only generate .scale files if truetype, opentype or type1
474     # fonts are present ...
475    
476 dberkholz 1.79 # NOTE: There is no way to regenerate Speedo/CID fonts.scale
477 spyderous 1.2 # <spyderous@gentoo.org> 2 August 2004
478 spyderous 1.28 if [[ "${x/encodings}" = "${x}" ]] \
479 dberkholz 1.79 && [[ -n "$(find ${x} -iname '*.[pot][ft][abcf]' -print)" ]]; then
480     mkfontscale \
481 spyderous 1.2 -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
482     -- ${x}
483     fi
484     done
485     eend 0
486     }
487    
488     create_fonts_dir() {
489     ebegin "Generating fonts.dir files"
490 dberkholz 1.77 for DIR in ${FONT_DIR}; do
491     x=${ROOT}/usr/share/fonts/${DIR}
492 spyderous 1.28 [[ -z "$(ls ${x}/)" ]] && continue
493     [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
494 spyderous 1.2
495 spyderous 1.28 if [[ "${x/encodings}" = "${x}" ]]; then
496 dberkholz 1.79 mkfontdir \
497 spyderous 1.2 -e ${ROOT}/usr/share/fonts/encodings \
498     -e ${ROOT}/usr/share/fonts/encodings/large \
499     -- ${x}
500     fi
501     done
502     eend 0
503     }
504    
505     fix_font_permissions() {
506     ebegin "Fixing permissions"
507 dberkholz 1.77 for DIR in ${FONT_DIR}; do
508     find ${ROOT}/usr/share/fonts/${DIR} -type f -name 'font.*' \
509 spyderous 1.2 -exec chmod 0644 {} \;
510     done
511     eend 0
512     }
513    
514     create_font_cache() {
515 dberkholz 1.78 font_pkg_postinst
516 spyderous 1.2 }
517 dberkholz 1.78
518     EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm

  ViewVC Help
Powered by ViewVC 1.1.20