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

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.27 - (hide annotations) (download)
Tue Mar 8 11:31:42 2011 UTC (3 years, 9 months ago) by scarabeus
Branch: MAIN
Changes since 1.26: +2 -1 lines
Some docs are still in dtd:4.1.

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

  ViewVC Help
Powered by ViewVC 1.1.20