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

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sun Mar 14 10:27:07 2010 UTC (4 years, 5 months ago) by scarabeus
Branch: MAIN
Add new xorg-2 eclass as replacement for x-modular eclass.

1 scarabeus 1.1 # Copyright 1999-2010 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3     # $Header: $
4     #
5     # @ECLASS: xorg-2.eclass
6     # @MAINTAINER:
7     # x11@gentoo.org
8    
9     # Author: Tomáš Chvátal <scarabeus@gentoo.org>
10     # Author: Donnie Berkholz <dberkholz@gentoo.org>
11     # @BLURB: Reduces code duplication in the modularized X11 ebuilds.
12     # @DESCRIPTION:
13     # This eclass makes trivial X ebuilds possible for apps, fonts, drivers,
14     # and more. Many things that would normally be done in various functions
15     # can be accessed by setting variables instead, such as patching,
16     # running eautoreconf, passing options to configure and installing docs.
17     #
18     # All you need to do in a basic ebuild is inherit this eclass and set
19     # DESCRIPTION, KEYWORDS and RDEPEND/DEPEND. If your package is hosted
20     # with the other X packages, you don't need to set SRC_URI. Pretty much
21     # everything else should be automatic.
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) EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare src_configure" ;;
47     *) DEPEND="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     MODULE=""
71     case ${CATEGORY} in
72     app-doc) MODULE="doc" ;;
73     media-fonts) MODULE="font" ;;
74     x11-apps|x11-wm) MODULE="app" ;;
75     x11-misc|x11-themes) MODULE="util" ;;
76     x11-drivers) MODULE="driver" ;;
77     x11-base) MODULE="xserver" ;;
78     x11-proto) MODULE="proto" ;;
79     x11-libs) MODULE="lib" ;;
80     esac
81     fi
82    
83     if [[ -n ${GIT_ECLASS} ]]; then
84     EGIT_REPO_URI="git://anongit.freedesktop.org/git/xorg/${MODULE}/${PN}"
85     else
86     SRC_URI+=" ${BASE_INDIVIDUAL_URI}/${MODULE}/${P}.tar.bz2"
87     fi
88    
89     : ${SLOT:=0}
90    
91     # Set the license for the package. This can be overridden by setting
92     # LICENSE after the inherit. Nearly all FreeDesktop-hosted X packages
93     # are under the MIT license. (This is what Red Hat does in their rpms)
94     : ${LICENSE=MIT}
95    
96     # Set up shared dependencies
97     if [[ ${XORG_EAUTORECONF} != no ]]; then
98     DEPEND+="
99     >=sys-devel/libtool-2.2.6a
100     sys-devel/m4"
101     # This MUST BE STABLE
102     if [[ ${PN} != util-macros ]] ; then
103     DEPEND+=" >=x11-misc/util-macros-1.5.0"
104     # Required even by xorg-server
105     [[ ${PN} == "font-util" ]] || DEPEND+=" >=media-fonts/font-util-1.1.1-r1"
106     fi
107     WANT_AUTOCONF="latest"
108     WANT_AUTOMAKE="latest"
109     fi
110    
111     if [[ ${FONT} == yes ]]; then
112     RDEPEND+=" media-fonts/encodings
113     x11-apps/mkfontscale
114     x11-apps/mkfontdir"
115     PDEPEND+=" media-fonts/font-alias"
116    
117     # @ECLASS-VARIABLE: FONT_DIR
118     # @DESCRIPTION:
119     # If you're creating a font package and the suffix of PN is not equal to
120     # the subdirectory of /usr/share/fonts/ it should install into, set
121     # FONT_DIR to that directory or directories. Set before inheriting this
122     # eclass.
123     [[ -z ${FONT_DIR} ]] && FONT_DIR=${PN##*-}
124    
125     # Fix case of font directories
126     FONT_DIR=${FONT_DIR/ttf/TTF}
127     FONT_DIR=${FONT_DIR/otf/OTF}
128     FONT_DIR=${FONT_DIR/type1/Type1}
129     FONT_DIR=${FONT_DIR/speedo/Speedo}
130    
131     # Set up configure options, wrapped so ebuilds can override if need be
132     [[ -z ${FONT_OPTIONS} ]] && FONT_OPTIONS="--with-fontdir=\"${EPREFIX}/usr/share/fonts/${FONT_DIR}\""
133    
134     [[ ${PN##*-} = misc || ${PN##*-} = 75dpi || ${PN##*-} = 100dpi || ${PN##*-} = cyrillic ]] && IUSE+=" nls"
135     fi
136    
137     # If we're a driver package, then enable DRIVER case
138     [[ ${PN} == xf86-video-* || ${PN} == xf86-input-* ]] && DRIVER="yes"
139    
140     # Add static-libs useflag where usefull.
141     if [[ ${FONT} != yes \
142     && ${CATEGORY} != app-doc \
143     && ${CATEGORY} != x11-proto \
144     && ${CATEGORY} != x11-drivers \
145     && ${CATEGORY} != media-fonts \
146     && ${PN} != util-macros \
147     && ${PN} != xbitmaps \
148     && ${PN} != xorg-cf-files \
149     && ${PN/xcursor} = ${PN} ]]; then
150     IUSE+=" static-libs"
151     fi
152    
153     DEPEND+=" >=dev-util/pkgconfig-0.23"
154    
155     # Check deps on xorg-server
156     has dri ${IUSE//+} && DEPEND+=" dri? ( >=x11-base/xorg-server-1.6.3.901-r2[-minimal] )"
157     [[ -n "${DRIVER}" ]] && DEPEND+=" x11-base/xorg-server[xorg]"
158    
159     # @FUNCTION: xorg-2_pkg_setup
160     # @USAGE:
161     # @DESCRIPTION:
162     # Setup prefix compat
163     xorg-2_pkg_setup() {
164     [[ ${FONT} == yes ]] && font_pkg_setup
165     }
166    
167     # @FUNCTION: xorg-2_src_unpack
168     # @USAGE:
169     # @DESCRIPTION:
170     # Simply unpack source code.
171     xorg-2_src_unpack() {
172     if [[ -n ${GIT_ECLASS} ]]; then
173     git_src_unpack
174     else
175     unpack ${A}
176     fi
177    
178     [[ -n ${FONT_OPTIONS} ]] && einfo "Detected font directory: ${FONT_DIR}"
179     }
180    
181     # @FUNCTION: xorg-2_patch_source
182     # @USAGE:
183     # @DESCRIPTION:
184     # Apply all patches
185     xorg-2_patch_source() {
186     # Use standardized names and locations with bulk patching
187     # Patch directory is ${WORKDIR}/patch
188     # See epatch() in eutils.eclass for more documentation
189     EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
190    
191     [[ -d "${EPATCH_SOURCE}" ]] && epatch
192     base_src_prepare
193     epatch_user
194     }
195    
196     # @FUNCTION: xorg-2_reconf_source
197     # @USAGE:
198     # @DESCRIPTION:
199     # Run eautoreconf if necessary, and run elibtoolize.
200     xorg-2_reconf_source() {
201     case ${CHOST} in
202     *-interix* | *-aix* | *-winnt*)
203     # some hosts need full eautoreconf
204     [[ -e "./configure.ac" ]] && eautoreconf || ewarn "Unable to autoreconf the configure script. Things may fail."
205     ;;
206     *)
207     # elibtoolize required for BSD
208     [[ ${XORG_EAUTORECONF} != no && -e "./configure.ac" ]] && eautoreconf || elibtoolize
209     ;;
210     esac
211     }
212    
213     # @FUNCTION: xorg-2_src_prepare
214     # @USAGE:
215     # @DESCRIPTION:
216     # Prepare a package after unpacking, performing all X-related tasks.
217     xorg-2_src_prepare() {
218     [[ -n ${GIT_ECLASS} ]] && git_src_prepare
219     xorg-2_patch_source
220     xorg-2_reconf_source
221     }
222    
223     # @FUNCTION: xorg-2_font_configure
224     # @USAGE:
225     # @DESCRIPTION:
226     # If a font package, perform any necessary configuration steps
227     xorg-2_font_configure() {
228     if has nls ${IUSE//+} && ! use nls; then
229     FONT_OPTIONS+="
230     --disable-iso8859-2
231     --disable-iso8859-3
232     --disable-iso8859-4
233     --disable-iso8859-5
234     --disable-iso8859-6
235     --disable-iso8859-7
236     --disable-iso8859-8
237     --disable-iso8859-9
238     --disable-iso8859-10
239     --disable-iso8859-11
240     --disable-iso8859-12
241     --disable-iso8859-13
242     --disable-iso8859-14
243     --disable-iso8859-15
244     --disable-iso8859-16
245     --disable-jisx0201
246     --disable-koi8-r"
247     fi
248     }
249    
250     # @FUNCTION: x-modular_flags_setup
251     # @USAGE:
252     # @DESCRIPTION:
253     # Set up CFLAGS for a debug build
254     xorg-2_flags_setup() {
255     # Win32 require special define
256     [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__
257     # hardened ldflags
258     [[ ${PN} = xorg-server || -n ${DRIVER} ]] && append-ldflags -Wl,-z,lazy
259     }
260    
261     # @FUNCTION: xorg-2_src_configure
262     # @USAGE:
263     # @DESCRIPTION:
264     # Perform any necessary pre-configuration steps, then run configure
265     xorg-2_src_configure() {
266     local myopts=""
267    
268     xorg-2_flags_setup
269     [[ -n "${FONT}" ]] && xorg-2_font_configure
270    
271     # @VARIABLE: CONFIGURE_OPTIONS
272     # @DESCRIPTION:
273     # Any options to pass to configure
274     CONFIGURE_OPTIONS=${CONFIGURE_OPTIONS:=""}
275     if [[ -x ${ECONF_SOURCE:-.}/configure ]]; then
276     if has static-libs ${IUSE//+}; then
277     myopts+=" $(use_enable static-libs static)"
278     fi
279     econf \
280     ${FONT_OPTIONS} \
281     ${CONFIGURE_OPTIONS} \
282     ${myopts}
283     fi
284     }
285    
286     # @FUNCTION: xorg-2_src_compile
287     # @USAGE:
288     # @DESCRIPTION:
289     # Compile a package, performing all X-related tasks.
290     xorg-2_src_compile() {
291     base_src_compile
292     }
293    
294     # @FUNCTION: xorg-2_src_install
295     # @USAGE:
296     # @DESCRIPTION:
297     # Install a built package to ${D}, performing any necessary steps.
298     # Creates a ChangeLog from git if using live ebuilds.
299     xorg-2_src_install() {
300     if [[ ${CATEGORY} == x11-proto ]]; then
301     emake \
302     ${PN/proto/}docdir=${EPREFIX}/usr/share/doc/${PF} \
303     DESTDIR="${D}" \
304     install || die "emake install failed"
305     else
306     emake \
307     docdir=${EPREFIX}/usr/share/doc/${PF} \
308     DESTDIR="${D}" \
309     install || die "emake install failed"
310     fi
311    
312     if [[ -n ${GIT_ECLASS} ]]; then
313     pushd "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" > /dev/null
314     git log ${GIT_TREE} > "${S}"/ChangeLog
315     popd > /dev/null
316     fi
317    
318     if [[ -e "${S}"/ChangeLog ]]; then
319     dodoc "${S}"/ChangeLog
320     fi
321     # @VARIABLE: DOCS
322     # @DESCRIPTION:
323     # Any documentation to install
324     if [[ -n ${DOCS} ]]; then
325     dodoc ${DOCS} || die "dodoc failed"
326     fi
327    
328     # Don't install libtool archives for server modules
329     if [[ -e "${D%/}${EPREFIX}/usr/$(get_libdir)/xorg/modules" ]]; then
330     find "${D%/}${EPREFIX}/usr/$(get_libdir)/xorg/modules" -name '*.la' \
331     -exec rm -f {} ';'
332     fi
333    
334     [[ -n ${FONT} ]] && remove_font_metadata
335     }
336    
337     # @FUNCTION: xorg-2_pkg_postinst
338     # @USAGE:
339     # @DESCRIPTION:
340     # Run X-specific post-installation tasks on the live filesystem. The
341     # only task right now is some setup for font packages.
342     xorg-2_pkg_postinst() {
343     [[ -n ${FONT} ]] && setup_fonts
344     }
345    
346     # @FUNCTION: xorg-2_pkg_postrm
347     # @USAGE:
348     # @DESCRIPTION:
349     # Run X-specific post-removal tasks on the live filesystem. The only
350     # task right now is some cleanup for font packages.
351     xorg-2_pkg_postrm() {
352     if [[ -n ${FONT} ]]; then
353     cleanup_fonts
354     font_pkg_postrm
355     fi
356     }
357    
358     # @FUNCTION: cleanup_fonts
359     # @USAGE:
360     # @DESCRIPTION:
361     # Get rid of font directories that only contain generated files
362     cleanup_fonts() {
363     local allowed_files="encodings.dir fonts.alias fonts.cache-1 fonts.dir fonts.scale"
364     local real_dir=${EROOT}usr/share/fonts/${FONT_DIR}
365     local fle allowed_file
366    
367     unset KEEP_FONTDIR
368    
369     einfo "Checking ${real_dir} for useless files"
370     pushd ${real_dir} &> /dev/null
371     for fle in *; do
372     unset MATCH
373     for allowed_file in ${allowed_files}; do
374     if [[ ${fle} = ${allowed_file} ]]; then
375     # If it's allowed, then move on to the next file
376     MATCH="yes"
377     break
378     fi
379     done
380     # If we found a match in allowed files, move on to the next file
381     [[ -n ${MATCH} ]] && continue
382     # If we get this far, there wasn't a match in the allowed files
383     KEEP_FONTDIR="yes"
384     # We don't need to check more files if we're already keeping it
385     break
386     done
387     popd &> /dev/null
388     # If there are no files worth keeping, then get rid of the dir
389     [[ -z "${KEEP_FONTDIR}" ]] && rm -rf ${real_dir}
390     }
391    
392     # @FUNCTION: setup_fonts
393     # @USAGE:
394     # @DESCRIPTION:
395     # Generates needed files for fonts and fixes font permissions
396     setup_fonts() {
397     create_fonts_scale
398     create_fonts_dir
399     font_pkg_postinst
400     }
401    
402     # @FUNCTION: remove_font_metadata
403     # @USAGE:
404     # @DESCRIPTION:
405     # Don't let the package install generated font files that may overlap
406     # with other packages. Instead, they're generated in pkg_postinst().
407     remove_font_metadata() {
408     if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
409     einfo "Removing font metadata"
410     rm -rf "${ED}"/usr/share/fonts/${FONT_DIR}/fonts.{scale,dir,cache-1}
411     fi
412     }
413    
414     # @FUNCTION: create_fonts_scale
415     # @USAGE:
416     # @DESCRIPTION:
417     # Create fonts.scale file, used by the old server-side fonts subsystem.
418     create_fonts_scale() {
419     if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
420     ebegin "Generating font.scale"
421     mkfontscale \
422     -a "${EROOT}/usr/share/fonts/encodings/encodings.dir" \
423     -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
424     eend $?
425     fi
426     }
427    
428     # @FUNCTION: create_fonts_dir
429     # @USAGE:
430     # @DESCRIPTION:
431     # Create fonts.dir file, used by the old server-side fonts subsystem.
432     create_fonts_dir() {
433     ebegin "Generating fonts.dir"
434     mkfontdir \
435     -e "${EROOT}"/usr/share/fonts/encodings \
436     -e "${EROOT}"/usr/share/fonts/encodings/large \
437     -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
438     eend $?
439     }

  ViewVC Help
Powered by ViewVC 1.1.20