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

Contents of /eclass/xorg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (hide annotations) (download)
Mon Feb 28 18:16:40 2011 UTC (3 years, 7 months ago) by mgorny
Branch: MAIN
Changes since 1.23: +102 -68 lines
Sync eclass from the x11 overlay.

Changes:
- use of autotools-utils, with out of tree builds by default;
- complete .la file removal,
- common doc and video driver dependency handling,
- simplified font encoding disable calls (with new enough util-macros).

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

  ViewVC Help
Powered by ViewVC 1.1.20