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

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (hide annotations) (download)
Tue Nov 9 18:25:00 2010 UTC (4 years ago) by scarabeus
Branch: MAIN
Changes since 1.19: +8 -2 lines
Add PACKAGE_NAME variable that allows specification of git checkout folder, so we dont have to respecify complete EGIT_REPO_URI.

1 scarabeus 1.1 # Copyright 1999-2010 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 scarabeus 1.20 # $Header: /var/cvsroot/gentoo-x86/eclass/xorg-2.eclass,v 1.19 2010/11/05 12:11:55 scarabeus Exp $
4 scarabeus 1.1 #
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 scarabeus 1.2 # Author: Tomáš Chvátal <scarabeus@gentoo.org>
21     # Author: Donnie Berkholz <dberkholz@gentoo.org>
22    
23 scarabeus 1.1 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 scarabeus 1.13 *) die "EAPI-UNSUPPORTED" ;;
48 scarabeus 1.1 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 scarabeus 1.20 # @ECLASS-VARIABLE: PACKAGE_NAME
84     # @DESCRIPTION:
85     # For git checkout git repository migth differ from package name
86     # so it can be overriden via this variable.
87     : ${PACKAGE_NAME:=${PN}}
88    
89 scarabeus 1.1 if [[ -n ${GIT_ECLASS} ]]; then
90 scarabeus 1.20 EGIT_REPO_URI="git://anongit.freedesktop.org/git/xorg/${MODULE}/${PACKAGE_NAME}"
91 scarabeus 1.1 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 scarabeus 1.2 : ${LICENSE:=MIT}
101 scarabeus 1.1
102 scarabeus 1.19 # 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 scarabeus 1.1 fi
113 scarabeus 1.19 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 scarabeus 1.1
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 mgorny 1.14 DEPEND+=" >=media-fonts/font-util-1.1.1-r1"
129 scarabeus 1.1
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 scarabeus 1.2 # @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 scarabeus 1.1 # Add static-libs useflag where usefull.
161 scarabeus 1.2 if [[ ${XORG_STATIC} == yes \
162     && ${FONT} != yes \
163 scarabeus 1.1 && ${CATEGORY} != app-doc \
164 scarabeus 1.18 && ${CATEGORY} != x11-apps \
165 scarabeus 1.1 && ${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     [[ ${FONT} == yes ]] && font_pkg_setup
186     }
187    
188     # @FUNCTION: xorg-2_src_unpack
189     # @DESCRIPTION:
190     # Simply unpack source code.
191     xorg-2_src_unpack() {
192     if [[ -n ${GIT_ECLASS} ]]; then
193     git_src_unpack
194     else
195     unpack ${A}
196     fi
197    
198     [[ -n ${FONT_OPTIONS} ]] && einfo "Detected font directory: ${FONT_DIR}"
199     }
200    
201     # @FUNCTION: xorg-2_patch_source
202     # @DESCRIPTION:
203     # Apply all patches
204     xorg-2_patch_source() {
205     # Use standardized names and locations with bulk patching
206     # Patch directory is ${WORKDIR}/patch
207     # See epatch() in eutils.eclass for more documentation
208     EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
209    
210     [[ -d "${EPATCH_SOURCE}" ]] && epatch
211     base_src_prepare
212     }
213    
214     # @FUNCTION: xorg-2_reconf_source
215     # @DESCRIPTION:
216     # Run eautoreconf if necessary, and run elibtoolize.
217     xorg-2_reconf_source() {
218     case ${CHOST} in
219     *-interix* | *-aix* | *-winnt*)
220     # some hosts need full eautoreconf
221 scarabeus 1.6 [[ -e "./configure.ac" || -e "./configure.in" ]] && eautoreconf || ewarn "Unable to autoreconf the configure script. Things may fail."
222 scarabeus 1.1 ;;
223     *)
224     # elibtoolize required for BSD
225 scarabeus 1.8 [[ ${XORG_EAUTORECONF} != no && ( -e "./configure.ac" || -e "./configure.in" ) ]] && eautoreconf || elibtoolize
226 scarabeus 1.1 ;;
227     esac
228     }
229    
230     # @FUNCTION: xorg-2_src_prepare
231     # @DESCRIPTION:
232     # Prepare a package after unpacking, performing all X-related tasks.
233     xorg-2_src_prepare() {
234     [[ -n ${GIT_ECLASS} ]] && git_src_prepare
235     xorg-2_patch_source
236     xorg-2_reconf_source
237     }
238    
239     # @FUNCTION: xorg-2_font_configure
240     # @DESCRIPTION:
241     # If a font package, perform any necessary configuration steps
242     xorg-2_font_configure() {
243     if has nls ${IUSE//+} && ! use nls; then
244     FONT_OPTIONS+="
245     --disable-iso8859-2
246     --disable-iso8859-3
247     --disable-iso8859-4
248     --disable-iso8859-5
249     --disable-iso8859-6
250     --disable-iso8859-7
251     --disable-iso8859-8
252     --disable-iso8859-9
253     --disable-iso8859-10
254     --disable-iso8859-11
255     --disable-iso8859-12
256     --disable-iso8859-13
257     --disable-iso8859-14
258     --disable-iso8859-15
259     --disable-iso8859-16
260     --disable-jisx0201
261     --disable-koi8-r"
262     fi
263     }
264    
265 scarabeus 1.11 # @FUNCTION: xorg-2_flags_setup
266 scarabeus 1.1 # @DESCRIPTION:
267     # Set up CFLAGS for a debug build
268     xorg-2_flags_setup() {
269     # Win32 require special define
270     [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__
271     # hardened ldflags
272     [[ ${PN} = xorg-server || -n ${DRIVER} ]] && append-ldflags -Wl,-z,lazy
273 scarabeus 1.15
274 scarabeus 1.16 # Quite few libraries fail on runtime without these:
275     if has static-libs ${IUSE//+}; then
276     filter-flags -Wl,-Bdirect
277     filter-ldflags -Bdirect
278     filter-ldflags -Wl,-Bdirect
279     fi
280 scarabeus 1.1 }
281    
282     # @FUNCTION: xorg-2_src_configure
283     # @DESCRIPTION:
284     # Perform any necessary pre-configuration steps, then run configure
285     xorg-2_src_configure() {
286     local myopts=""
287    
288     xorg-2_flags_setup
289     [[ -n "${FONT}" ]] && xorg-2_font_configure
290    
291 scarabeus 1.10 # @VARIABLE: CONFIGURE_OPTIONS
292     # @DESCRIPTION:
293     # Any options to pass to configure
294     # @DEFAULT_UNSET
295 scarabeus 1.1 CONFIGURE_OPTIONS=${CONFIGURE_OPTIONS:=""}
296     if [[ -x ${ECONF_SOURCE:-.}/configure ]]; then
297     if has static-libs ${IUSE//+}; then
298     myopts+=" $(use_enable static-libs static)"
299     fi
300     econf \
301     ${FONT_OPTIONS} \
302     ${CONFIGURE_OPTIONS} \
303     ${myopts}
304     fi
305     }
306    
307     # @FUNCTION: xorg-2_src_compile
308     # @DESCRIPTION:
309     # Compile a package, performing all X-related tasks.
310     xorg-2_src_compile() {
311     base_src_compile
312     }
313    
314     # @FUNCTION: xorg-2_src_install
315     # @DESCRIPTION:
316     # Install a built package to ${D}, performing any necessary steps.
317     # Creates a ChangeLog from git if using live ebuilds.
318     xorg-2_src_install() {
319     if [[ ${CATEGORY} == x11-proto ]]; then
320     emake \
321     ${PN/proto/}docdir=${EPREFIX}/usr/share/doc/${PF} \
322 scarabeus 1.9 docdir=${EPREFIX}/usr/share/doc/${PF} \
323 scarabeus 1.1 DESTDIR="${D}" \
324     install || die "emake install failed"
325     else
326     emake \
327     docdir=${EPREFIX}/usr/share/doc/${PF} \
328     DESTDIR="${D}" \
329     install || die "emake install failed"
330     fi
331    
332     if [[ -n ${GIT_ECLASS} ]]; then
333     pushd "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" > /dev/null
334 scarabeus 1.12 git log ${EGIT_COMMIT} > "${S}"/ChangeLog
335 scarabeus 1.1 popd > /dev/null
336     fi
337    
338     if [[ -e "${S}"/ChangeLog ]]; then
339     dodoc "${S}"/ChangeLog
340     fi
341 scarabeus 1.10 # @VARIABLE: DOCS
342     # @DESCRIPTION:
343     # Any documentation to install
344     # @DEFAULT_UNSET
345 scarabeus 1.1 if [[ -n ${DOCS} ]]; then
346     dodoc ${DOCS} || die "dodoc failed"
347     fi
348    
349     # Don't install libtool archives for server modules
350     if [[ -e "${D%/}${EPREFIX}/usr/$(get_libdir)/xorg/modules" ]]; then
351     find "${D%/}${EPREFIX}/usr/$(get_libdir)/xorg/modules" -name '*.la' \
352     -exec rm -f {} ';'
353     fi
354    
355     [[ -n ${FONT} ]] && remove_font_metadata
356     }
357    
358     # @FUNCTION: xorg-2_pkg_postinst
359     # @DESCRIPTION:
360     # Run X-specific post-installation tasks on the live filesystem. The
361     # only task right now is some setup for font packages.
362     xorg-2_pkg_postinst() {
363     [[ -n ${FONT} ]] && setup_fonts
364     }
365    
366     # @FUNCTION: xorg-2_pkg_postrm
367     # @DESCRIPTION:
368     # Run X-specific post-removal tasks on the live filesystem. The only
369     # task right now is some cleanup for font packages.
370     xorg-2_pkg_postrm() {
371     if [[ -n ${FONT} ]]; then
372     font_pkg_postrm
373     fi
374     }
375    
376     # @FUNCTION: setup_fonts
377     # @DESCRIPTION:
378     # Generates needed files for fonts and fixes font permissions
379     setup_fonts() {
380     create_fonts_scale
381     create_fonts_dir
382     font_pkg_postinst
383     }
384    
385     # @FUNCTION: remove_font_metadata
386     # @DESCRIPTION:
387     # Don't let the package install generated font files that may overlap
388     # with other packages. Instead, they're generated in pkg_postinst().
389     remove_font_metadata() {
390     if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
391     einfo "Removing font metadata"
392     rm -rf "${ED}"/usr/share/fonts/${FONT_DIR}/fonts.{scale,dir,cache-1}
393     fi
394     }
395    
396     # @FUNCTION: create_fonts_scale
397     # @DESCRIPTION:
398     # Create fonts.scale file, used by the old server-side fonts subsystem.
399     create_fonts_scale() {
400     if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
401     ebegin "Generating font.scale"
402     mkfontscale \
403     -a "${EROOT}/usr/share/fonts/encodings/encodings.dir" \
404     -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
405     eend $?
406     fi
407     }
408    
409     # @FUNCTION: create_fonts_dir
410     # @DESCRIPTION:
411     # Create fonts.dir file, used by the old server-side fonts subsystem.
412     create_fonts_dir() {
413     ebegin "Generating fonts.dir"
414     mkfontdir \
415     -e "${EROOT}"/usr/share/fonts/encodings \
416     -e "${EROOT}"/usr/share/fonts/encodings/large \
417     -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
418     eend $?
419     }

  ViewVC Help
Powered by ViewVC 1.1.20