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

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.26 - (hide annotations) (download)
Wed Mar 2 15:40:38 2011 UTC (3 years, 7 months ago) by scarabeus
Branch: MAIN
Changes since 1.25: +6 -2 lines
Depend on proper xorg-server for all drivers.

1 scarabeus 1.1 # Copyright 1999-2010 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 scarabeus 1.26 # $Header: /var/cvsroot/gentoo-x86/eclass/xorg-2.eclass,v 1.25 2011/03/01 18:56:58 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 mgorny 1.24 inherit autotools-utils eutils libtool multilib toolchain-funcs flag-o-matic autotools \
42 scarabeus 1.1 ${FONT_ECLASS} ${GIT_ECLASS}
43    
44     EXPORTED_FUNCTIONS="src_unpack src_compile src_install pkg_postinst pkg_postrm"
45     case "${EAPI:-0}" in
46 scarabeus 1.21 3|4) 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     case ${CATEGORY} in
71 mgorny 1.24 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-base) MODULE=xserver/ ;;
76     x11-drivers) MODULE=driver/ ;;
77     x11-proto) MODULE=proto/ ;;
78     x11-libs) MODULE=lib/ ;;
79     *) MODULE= ;;
80 scarabeus 1.1 esac
81     fi
82    
83 scarabeus 1.20 # @ECLASS-VARIABLE: PACKAGE_NAME
84     # @DESCRIPTION:
85 mgorny 1.24 # For git checkout the git repository might differ from package name.
86 scarabeus 1.21 # This variable can be used for proper directory specification
87 scarabeus 1.20 : ${PACKAGE_NAME:=${PN}}
88    
89 scarabeus 1.1 if [[ -n ${GIT_ECLASS} ]]; then
90 mgorny 1.24 EGIT_REPO_URI="git://anongit.freedesktop.org/git/xorg/${MODULE}${PACKAGE_NAME}"
91 scarabeus 1.1 else
92 mgorny 1.24 SRC_URI+=" ${BASE_INDIVIDUAL_URI}/${MODULE}${P}.tar.bz2"
93 scarabeus 1.1 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 mgorny 1.24 # Check deps on drivers
178     if has dri ${IUSE//+}; then
179     COMMON_DEPEND+=" dri? (
180     x11-base/xorg-server[-minimal]
181     x11-libs/libdrm
182     )"
183     DEPEND+=" dri? (
184     x11-proto/xf86driproto
185     x11-proto/glproto
186     x11-proto/dri2proto
187     )"
188     fi
189 scarabeus 1.26 if [[ -n "${DRIVER}" ]]; then
190     COMMON_DEPEND+="
191     x11-base/xorg-server[xorg]
192     "
193     fi
194 scarabeus 1.25 if [[ -n "${DRIVER}" && ${PN} == xf86-video-* ]]; then
195 mgorny 1.24 COMMON_DEPEND+="
196     x11-libs/libpciaccess
197     "
198     # we also needs some protos and libs in all cases
199     DEPEND+="
200     x11-proto/fontsproto
201     x11-proto/randrproto
202     x11-proto/renderproto
203     x11-proto/videoproto
204     x11-proto/xextproto
205     x11-proto/xineramaproto
206     x11-proto/xproto
207     "
208     fi
209    
210     # Add deps on documentation
211     # Most docbooks use dtd version 4.2 and 4.3 add more when found
212     if has doc ${IUSE//+}; then
213     DEPEND+="
214     doc? (
215     app-text/xmlto
216     app-doc/doxygen
217     app-text/docbook-xml-dtd:4.2
218     app-text/docbook-xml-dtd:4.3
219     )
220     "
221     fi
222    
223     DEPEND+=" ${COMMON_DEPEND}"
224     RDEPEND+=" ${COMMON_DEPEND}"
225     unset COMMON_DEPEND
226    
227     debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND=${DEPEND}"
228     debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: RDEPEND=${RDEPEND}"
229 scarabeus 1.1
230     # @FUNCTION: xorg-2_pkg_setup
231     # @DESCRIPTION:
232     # Setup prefix compat
233     xorg-2_pkg_setup() {
234 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
235    
236     [[ ${FONT} == yes ]] && font_pkg_setup "$@"
237 scarabeus 1.1 }
238    
239     # @FUNCTION: xorg-2_src_unpack
240     # @DESCRIPTION:
241     # Simply unpack source code.
242     xorg-2_src_unpack() {
243 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
244    
245 scarabeus 1.1 if [[ -n ${GIT_ECLASS} ]]; then
246     git_src_unpack
247     else
248     unpack ${A}
249     fi
250    
251     [[ -n ${FONT_OPTIONS} ]] && einfo "Detected font directory: ${FONT_DIR}"
252     }
253    
254     # @FUNCTION: xorg-2_patch_source
255     # @DESCRIPTION:
256     # Apply all patches
257     xorg-2_patch_source() {
258 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
259    
260 scarabeus 1.1 # Use standardized names and locations with bulk patching
261     # Patch directory is ${WORKDIR}/patch
262     # See epatch() in eutils.eclass for more documentation
263     EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
264    
265     [[ -d "${EPATCH_SOURCE}" ]] && epatch
266 mgorny 1.24 autotools-utils_src_prepare "$@"
267 scarabeus 1.1 }
268    
269     # @FUNCTION: xorg-2_reconf_source
270     # @DESCRIPTION:
271     # Run eautoreconf if necessary, and run elibtoolize.
272     xorg-2_reconf_source() {
273 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
274    
275 scarabeus 1.1 case ${CHOST} in
276     *-interix* | *-aix* | *-winnt*)
277     # some hosts need full eautoreconf
278 scarabeus 1.6 [[ -e "./configure.ac" || -e "./configure.in" ]] && eautoreconf || ewarn "Unable to autoreconf the configure script. Things may fail."
279 scarabeus 1.1 ;;
280     *)
281     # elibtoolize required for BSD
282 scarabeus 1.8 [[ ${XORG_EAUTORECONF} != no && ( -e "./configure.ac" || -e "./configure.in" ) ]] && eautoreconf || elibtoolize
283 scarabeus 1.1 ;;
284     esac
285     }
286    
287     # @FUNCTION: xorg-2_src_prepare
288     # @DESCRIPTION:
289     # Prepare a package after unpacking, performing all X-related tasks.
290     xorg-2_src_prepare() {
291 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
292    
293 scarabeus 1.1 [[ -n ${GIT_ECLASS} ]] && git_src_prepare
294     xorg-2_patch_source
295     xorg-2_reconf_source
296     }
297    
298     # @FUNCTION: xorg-2_font_configure
299     # @DESCRIPTION:
300     # If a font package, perform any necessary configuration steps
301     xorg-2_font_configure() {
302 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
303    
304 scarabeus 1.1 if has nls ${IUSE//+} && ! use nls; then
305 mgorny 1.24 if grep -q -s "disable-all-encodings" ${ECONF_SOURCE:-.}/configure; then
306     FONT_OPTIONS+="
307     --disable-all-encodings"
308     else
309     FONT_OPTIONS+="
310     --disable-iso8859-2
311     --disable-iso8859-3
312     --disable-iso8859-4
313     --disable-iso8859-5
314     --disable-iso8859-6
315     --disable-iso8859-7
316     --disable-iso8859-8
317     --disable-iso8859-9
318     --disable-iso8859-10
319     --disable-iso8859-11
320     --disable-iso8859-12
321     --disable-iso8859-13
322     --disable-iso8859-14
323     --disable-iso8859-15
324     --disable-iso8859-16
325     --disable-jisx0201
326     --disable-koi8-r"
327     fi
328 scarabeus 1.1 fi
329     }
330    
331 scarabeus 1.11 # @FUNCTION: xorg-2_flags_setup
332 scarabeus 1.1 # @DESCRIPTION:
333     # Set up CFLAGS for a debug build
334     xorg-2_flags_setup() {
335 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
336    
337 scarabeus 1.1 # Win32 require special define
338     [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__
339     # hardened ldflags
340     [[ ${PN} = xorg-server || -n ${DRIVER} ]] && append-ldflags -Wl,-z,lazy
341 scarabeus 1.15
342 scarabeus 1.16 # Quite few libraries fail on runtime without these:
343     if has static-libs ${IUSE//+}; then
344     filter-flags -Wl,-Bdirect
345     filter-ldflags -Bdirect
346     filter-ldflags -Wl,-Bdirect
347     fi
348 scarabeus 1.1 }
349    
350     # @FUNCTION: xorg-2_src_configure
351     # @DESCRIPTION:
352     # Perform any necessary pre-configuration steps, then run configure
353     xorg-2_src_configure() {
354 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
355 scarabeus 1.1
356     xorg-2_flags_setup
357    
358 scarabeus 1.10 # @VARIABLE: CONFIGURE_OPTIONS
359     # @DESCRIPTION:
360     # Any options to pass to configure
361     # @DEFAULT_UNSET
362 scarabeus 1.1 CONFIGURE_OPTIONS=${CONFIGURE_OPTIONS:=""}
363 mgorny 1.24
364     [[ -n "${FONT}" ]] && xorg-2_font_configure
365     local myeconfargs=(
366     --disable-dependency-tracking
367     ${CONFIGURE_OPTIONS}
368     ${FONT_OPTIONS}
369     )
370    
371     autotools-utils_src_configure "$@"
372 scarabeus 1.1 }
373    
374     # @FUNCTION: xorg-2_src_compile
375     # @DESCRIPTION:
376     # Compile a package, performing all X-related tasks.
377     xorg-2_src_compile() {
378 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
379    
380 mgorny 1.24 autotools-utils_src_compile "$@"
381 scarabeus 1.1 }
382    
383     # @FUNCTION: xorg-2_src_install
384     # @DESCRIPTION:
385     # Install a built package to ${D}, performing any necessary steps.
386     # Creates a ChangeLog from git if using live ebuilds.
387     xorg-2_src_install() {
388 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
389    
390 scarabeus 1.1 if [[ ${CATEGORY} == x11-proto ]]; then
391 mgorny 1.24 autotools-utils_src_install \
392     ${PN/proto/}docdir="${EPREFIX}/usr/share/doc/${PF}" \
393     docdir="${EPREFIX}/usr/share/doc/${PF}"
394 scarabeus 1.1 else
395 mgorny 1.24 autotools-utils_src_install \
396     docdir="${EPREFIX}/usr/share/doc/${PF}"
397 scarabeus 1.1 fi
398    
399     if [[ -n ${GIT_ECLASS} ]]; then
400     pushd "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" > /dev/null
401 scarabeus 1.12 git log ${EGIT_COMMIT} > "${S}"/ChangeLog
402 scarabeus 1.1 popd > /dev/null
403     fi
404    
405     if [[ -e "${S}"/ChangeLog ]]; then
406 scarabeus 1.21 dodoc "${S}"/ChangeLog || die "dodoc failed"
407 scarabeus 1.1 fi
408    
409 mgorny 1.24 # Don't install libtool archives (even with static-libs)
410     remove_libtool_files all
411 scarabeus 1.1
412     [[ -n ${FONT} ]] && remove_font_metadata
413     }
414    
415     # @FUNCTION: xorg-2_pkg_postinst
416     # @DESCRIPTION:
417     # Run X-specific post-installation tasks on the live filesystem. The
418     # only task right now is some setup for font packages.
419     xorg-2_pkg_postinst() {
420 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
421    
422     [[ -n ${FONT} ]] && setup_fonts "$@"
423 scarabeus 1.1 }
424    
425     # @FUNCTION: xorg-2_pkg_postrm
426     # @DESCRIPTION:
427     # Run X-specific post-removal tasks on the live filesystem. The only
428     # task right now is some cleanup for font packages.
429     xorg-2_pkg_postrm() {
430 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
431    
432     [[ -n ${FONT} ]] && font_pkg_postrm "$@"
433 scarabeus 1.1 }
434    
435     # @FUNCTION: setup_fonts
436     # @DESCRIPTION:
437     # Generates needed files for fonts and fixes font permissions
438     setup_fonts() {
439 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
440    
441 scarabeus 1.1 create_fonts_scale
442     create_fonts_dir
443     font_pkg_postinst
444     }
445    
446     # @FUNCTION: remove_font_metadata
447     # @DESCRIPTION:
448     # Don't let the package install generated font files that may overlap
449     # with other packages. Instead, they're generated in pkg_postinst().
450     remove_font_metadata() {
451 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
452    
453 scarabeus 1.1 if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
454     einfo "Removing font metadata"
455     rm -rf "${ED}"/usr/share/fonts/${FONT_DIR}/fonts.{scale,dir,cache-1}
456     fi
457     }
458    
459     # @FUNCTION: create_fonts_scale
460     # @DESCRIPTION:
461     # Create fonts.scale file, used by the old server-side fonts subsystem.
462     create_fonts_scale() {
463 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
464    
465 scarabeus 1.1 if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then
466     ebegin "Generating font.scale"
467     mkfontscale \
468     -a "${EROOT}/usr/share/fonts/encodings/encodings.dir" \
469     -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
470     eend $?
471     fi
472     }
473    
474     # @FUNCTION: create_fonts_dir
475     # @DESCRIPTION:
476     # Create fonts.dir file, used by the old server-side fonts subsystem.
477     create_fonts_dir() {
478 scarabeus 1.21 debug-print-function ${FUNCNAME} "$@"
479    
480 scarabeus 1.1 ebegin "Generating fonts.dir"
481     mkfontdir \
482     -e "${EROOT}"/usr/share/fonts/encodings \
483     -e "${EROOT}"/usr/share/fonts/encodings/large \
484     -- "${EROOT}/usr/share/fonts/${FONT_DIR}"
485     eend $?
486     }

  ViewVC Help
Powered by ViewVC 1.1.20