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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.81 - (show annotations) (download)
Sun Dec 17 15:30:25 2006 UTC (7 years, 3 months ago) by joshuabaergen
Branch: MAIN
Changes since 1.80: +3 -3 lines
Set WANT_{AUTOMAKE,AUTOCONF} for snapshots (Matthias Schwarzott, bug #154657).

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.80 2006/10/30 18:40:58 dberkholz Exp $
4 #
5 # Author: Donnie Berkholz <spyderous@gentoo.org>
6 #
7 # This eclass is designed to reduce code duplication in the modularized X11
8 # ebuilds.
9 #
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 # IMPORTANT: Both SNAPSHOT and FONT_DIR must be set _before_ the inherit.
25 #
26 # Pretty much everything else should be automatic.
27
28 # Directory prefix to use for everything
29 XDIR="/usr"
30
31 # Set up default patchset version(s) if necessary
32 # x11-driver-patches
33 if [[ -z "${XDPVER}" ]]; then
34 XDPVER="1"
35 fi
36
37 IUSE=""
38 HOMEPAGE="http://xorg.freedesktop.org/"
39
40 # Set up SRC_URI for individual modular releases
41 BASE_INDIVIDUAL_URI="http://xorg.freedesktop.org/releases/individual"
42 if [[ ${CATEGORY} = x11-apps ]] || [[ ${CATEGORY} = x11-wm ]]; then
43 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 SLOT="0"
71
72 # Set the license for the package. This can be overridden by setting
73 # LICENSE after the inherit.
74 LICENSE=${PN}
75
76 # Set up shared dependencies
77 if [[ -n "${SNAPSHOT}" ]]; then
78 # FIXME: What's the minimal libtool version supporting arbitrary versioning?
79 DEPEND="${DEPEND}
80 >=sys-devel/libtool-1.5
81 >=sys-devel/m4-1.4"
82 WANT_AUTOCONF="latest"
83 WANT_AUTOMAKE="latest"
84 fi
85
86 # If we're a font package, but not the font.alias one
87 FONT_ECLASS=""
88 if [[ "${PN/#font-}" != "${PN}" ]] \
89 && [[ "${CATEGORY}" = "media-fonts" ]] \
90 && [[ "${PN}" != "font-alias" ]] \
91 && [[ "${PN}" != "font-util" ]]; then
92 # Activate font code in the rest of the eclass
93 FONT="yes"
94
95 # Whether to inherit the font eclass
96 FONT_ECLASS="font"
97
98 RDEPEND="${RDEPEND}
99 media-fonts/encodings
100 x11-apps/mkfontscale
101 x11-apps/mkfontdir"
102 PDEPEND="${PDEPEND}
103 media-fonts/font-alias"
104
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 fi
129
130 # If we're a driver package
131 if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then
132 # Enable driver code in the rest of the eclass
133 DRIVER="yes"
134
135 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 fi
141
142 # 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 if ! has splitdebug ${FEATURES}; then
156 RESTRICT="${RESTRICT} nostrip"
157 fi
158 fi
159 fi
160
161 DEPEND="${DEPEND}
162 >=dev-util/pkgconfig-0.18"
163
164 if [[ "${PN/util-macros}" = "${PN}" ]]; then
165 DEPEND="${DEPEND}
166 >=x11-misc/util-macros-0.99.2
167 >=sys-devel/binutils-2.16.1-r3"
168 fi
169
170 RDEPEND="${RDEPEND}
171 || ( >=sys-apps/man-1.6b-r2 >=sys-apps/man-db-2.4.3-r1 )
172 !<=x11-base/xorg-x11-6.9"
173 # Provides virtual/x11 for temporary use until packages are ported
174 # x11-base/x11-env"
175
176 inherit eutils libtool multilib toolchain-funcs flag-o-matic autotools ${FONT_ECLASS}
177
178 x-modular_specs_check() {
179 if [[ ${PN:0:11} = "xorg-server" ]] || [[ -n "${DRIVER}" ]]; then
180 append-ldflags -Wl,-z,lazy
181 # (#116698) breaks loading
182 filter-ldflags -Wl,-z,now
183 fi
184 }
185
186 x-modular_dri_check() {
187 # (#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 }
198
199 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 if has_version '>=x11-base/xorg-server-1.1'; then
204 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 fi
209 fi
210 }
211
212 x-modular_unpack_source() {
213 unpack ${A}
214 cd ${S}
215
216 if [[ -n ${FONT_OPTIONS} ]]; then
217 einfo "Detected font directory: ${FONT_DIR}"
218 fi
219 }
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 if [[ -z "${EPATCH_SUFFIX}" ]] ; then
226 EPATCH_SUFFIX="patch"
227 fi
228
229 # 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 if [[ -n "${DRIVER}" ]] && [[ "${SNAPSHOT}" != "yes" ]]\
233 && [[ ${XDPVER} != -1 ]]; then
234 PATCHES="${PATCHES} ${DISTDIR}/x11-driver-patches-${XDPVER}.tar.bz2"
235 fi
236
237 # For specific list of patches
238 if [[ -n "${PATCHES}" ]] ; then
239 for PATCH in ${PATCHES}
240 do
241 epatch ${PATCH}
242 done
243 # For non-default directory bulk patching
244 elif [[ -n "${PATCH_LOC}" ]] ; then
245 epatch ${PATCH_LOC}
246 # For standard bulk patching
247 elif [[ -d "${EPATCH_SOURCE}" ]] ; then
248 epatch
249 fi
250 }
251
252 x-modular_reconf_source() {
253 # Run autoreconf for CVS snapshots only
254 if [[ "${SNAPSHOT}" = "yes" ]]
255 then
256 # If possible, generate configure if it doesn't exist
257 if [ -f "./configure.ac" ]
258 then
259 eautoreconf
260 fi
261 fi
262
263 # Joshua Baergen - October 23, 2005
264 # Fix shared lib issues on MIPS, FBSD, etc etc
265 elibtoolize
266 }
267
268 x-modular_src_unpack() {
269 x-modular_specs_check
270 x-modular_server_supports_drivers_check
271 x-modular_dri_check
272 x-modular_unpack_source
273 x-modular_patch_source
274 x-modular_reconf_source
275 }
276
277 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 x-modular_debug_setup() {
305 if [[ -n "${DEBUGGABLE}" ]]; then
306 if use debug; then
307 strip-flags
308 append-flags -g
309 fi
310 fi
311 }
312
313 x-modular_src_configure() {
314 x-modular_font_configure
315 x-modular_debug_setup
316
317 # If prefix isn't set here, .pc files cause problems
318 if [[ -x ./configure ]]; then
319 econf --prefix=${XDIR} \
320 --datadir=${XDIR}/share \
321 ${FONT_OPTIONS} \
322 ${DRIVER_OPTIONS} \
323 ${CONFIGURE_OPTIONS}
324 fi
325 }
326
327 x-modular_src_make() {
328 emake || die "emake failed"
329 }
330
331 x-modular_src_compile() {
332 x-modular_src_configure
333 x-modular_src_make
334 }
335
336 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
346 if [[ -e ${S}/ChangeLog ]]; then
347 dodoc ${S}/ChangeLog
348 fi
349
350 # Make sure docs get compressed
351 prepalldocs
352
353 # Don't install libtool archives for server modules
354 if [[ -e ${D}/usr/$(get_libdir)/xorg/modules ]]; then
355 find ${D}/usr/$(get_libdir)/xorg/modules -name '*.la' \
356 | xargs rm -f
357 fi
358
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
365 if [[ -n "${DRIVER}" ]]; then
366 install_driver_hwdata
367 fi
368 }
369
370 x-modular_pkg_preinst() {
371 # We no longer do anything here, but we can't remove it from the API
372 :
373 }
374
375 x-modular_pkg_postinst() {
376 if [[ -n "${FONT}" ]]; then
377 setup_fonts
378 fi
379 }
380
381 x-modular_pkg_postrm() {
382 if [[ -n "${FONT}" ]]; then
383 cleanup_fonts
384 font_pkg_postrm
385 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 setup_fonts() {
424 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 eerror "${msg}"
427 die "${msg}"
428 fi
429
430 create_fonts_scale
431 create_fonts_dir
432 fix_font_permissions
433 create_font_cache
434 }
435
436 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 # 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 discover_font_dirs() {
462 FONT_DIRS="${FONT_DIR}"
463 }
464
465 create_fonts_scale() {
466 ebegin "Creating fonts.scale files"
467 local x
468 for DIR in ${FONT_DIR}; do
469 x=${ROOT}/usr/share/fonts/${DIR}
470 [[ -z "$(ls ${x}/)" ]] && continue
471 [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
472
473 # Only generate .scale files if truetype, opentype or type1
474 # fonts are present ...
475
476 # NOTE: There is no way to regenerate Speedo/CID fonts.scale
477 # <spyderous@gentoo.org> 2 August 2004
478 if [[ "${x/encodings}" = "${x}" ]] \
479 && [[ -n "$(find ${x} -iname '*.[pot][ft][abcf]' -print)" ]]; then
480 mkfontscale \
481 -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 for DIR in ${FONT_DIR}; do
491 x=${ROOT}/usr/share/fonts/${DIR}
492 [[ -z "$(ls ${x}/)" ]] && continue
493 [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
494
495 if [[ "${x/encodings}" = "${x}" ]]; then
496 mkfontdir \
497 -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 for DIR in ${FONT_DIR}; do
508 find ${ROOT}/usr/share/fonts/${DIR} -type f -name 'font.*' \
509 -exec chmod 0644 {} \;
510 done
511 eend 0
512 }
513
514 create_font_cache() {
515 font_pkg_postinst
516 }
517
518 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm

  ViewVC Help
Powered by ViewVC 1.1.20