1 |
# Copyright 1999-2010 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/xorg-2.eclass,v 1.18 2010/11/01 12:37:58 scarabeus Exp $ |
4 |
# |
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 |
# Author: Tomáš Chvátal <scarabeus@gentoo.org> |
21 |
# Author: Donnie Berkholz <dberkholz@gentoo.org> |
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 |
*) die "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 autotools shared dependencies |
97 |
# Remember that all versions here MUST be stable |
98 |
XORG_EAUTORECONF_ARCHES="x86-interix ppc-aix x86-winnt" |
99 |
EAUTORECONF_DEPEND+=" |
100 |
>=sys-devel/libtool-2.2.6a |
101 |
sys-devel/m4" |
102 |
if [[ ${PN} != util-macros ]] ; then |
103 |
EAUTORECONF_DEPEND+=" >=x11-misc/util-macros-1.11.0" |
104 |
# Required even by xorg-server |
105 |
[[ ${PN} == "font-util" ]] || EAUTORECONF_DEPEND+=" >=media-fonts/font-util-1.1.1-r1" |
106 |
fi |
107 |
WANT_AUTOCONF="latest" |
108 |
WANT_AUTOMAKE="latest" |
109 |
for arch in ${XORG_EAUTORECONF_ARCHES}; do |
110 |
EAUTORECONF_DEPENDS+=" ${arch}? ( ${EAUTORECONF_DEPEND} )" |
111 |
done |
112 |
DEPEND+=" ${EAUTORECONF_DEPENDS}" |
113 |
[[ ${XORG_EAUTORECONF} != no ]] && DEPEND+=" ${EAUTORECONF_DEPEND}" |
114 |
unset EAUTORECONF_DEPENDS |
115 |
unset EAUTORECONF_DEPEND |
116 |
|
117 |
if [[ ${FONT} == yes ]]; then |
118 |
RDEPEND+=" media-fonts/encodings |
119 |
x11-apps/mkfontscale |
120 |
x11-apps/mkfontdir" |
121 |
PDEPEND+=" media-fonts/font-alias" |
122 |
DEPEND+=" >=media-fonts/font-util-1.1.1-r1" |
123 |
|
124 |
# @ECLASS-VARIABLE: FONT_DIR |
125 |
# @DESCRIPTION: |
126 |
# If you're creating a font package and the suffix of PN is not equal to |
127 |
# the subdirectory of /usr/share/fonts/ it should install into, set |
128 |
# FONT_DIR to that directory or directories. Set before inheriting this |
129 |
# eclass. |
130 |
[[ -z ${FONT_DIR} ]] && FONT_DIR=${PN##*-} |
131 |
|
132 |
# Fix case of font directories |
133 |
FONT_DIR=${FONT_DIR/ttf/TTF} |
134 |
FONT_DIR=${FONT_DIR/otf/OTF} |
135 |
FONT_DIR=${FONT_DIR/type1/Type1} |
136 |
FONT_DIR=${FONT_DIR/speedo/Speedo} |
137 |
|
138 |
# Set up configure options, wrapped so ebuilds can override if need be |
139 |
[[ -z ${FONT_OPTIONS} ]] && FONT_OPTIONS="--with-fontdir=\"${EPREFIX}/usr/share/fonts/${FONT_DIR}\"" |
140 |
|
141 |
[[ ${PN##*-} = misc || ${PN##*-} = 75dpi || ${PN##*-} = 100dpi || ${PN##*-} = cyrillic ]] && IUSE+=" nls" |
142 |
fi |
143 |
|
144 |
# If we're a driver package, then enable DRIVER case |
145 |
[[ ${PN} == xf86-video-* || ${PN} == xf86-input-* ]] && DRIVER="yes" |
146 |
|
147 |
# @ECLASS-VARIABLE: XORG_STATIC |
148 |
# @DESCRIPTION: |
149 |
# Enables static-libs useflag. Set to no, if your package gets: |
150 |
# |
151 |
# QA: configure: WARNING: unrecognized options: --disable-static |
152 |
: ${XORG_STATIC:="yes"} |
153 |
|
154 |
# Add static-libs useflag where usefull. |
155 |
if [[ ${XORG_STATIC} == yes \ |
156 |
&& ${FONT} != yes \ |
157 |
&& ${CATEGORY} != app-doc \ |
158 |
&& ${CATEGORY} != x11-apps \ |
159 |
&& ${CATEGORY} != x11-proto \ |
160 |
&& ${CATEGORY} != x11-drivers \ |
161 |
&& ${CATEGORY} != media-fonts \ |
162 |
&& ${PN} != util-macros \ |
163 |
&& ${PN} != xbitmaps \ |
164 |
&& ${PN} != xorg-cf-files \ |
165 |
&& ${PN/xcursor} = ${PN} ]]; then |
166 |
IUSE+=" static-libs" |
167 |
fi |
168 |
|
169 |
DEPEND+=" >=dev-util/pkgconfig-0.23" |
170 |
|
171 |
# Check deps on xorg-server |
172 |
has dri ${IUSE//+} && DEPEND+=" dri? ( >=x11-base/xorg-server-1.6.3.901-r2[-minimal] )" |
173 |
[[ -n "${DRIVER}" ]] && DEPEND+=" x11-base/xorg-server[xorg]" |
174 |
|
175 |
# @FUNCTION: xorg-2_pkg_setup |
176 |
# @DESCRIPTION: |
177 |
# Setup prefix compat |
178 |
xorg-2_pkg_setup() { |
179 |
[[ ${FONT} == yes ]] && font_pkg_setup |
180 |
} |
181 |
|
182 |
# @FUNCTION: xorg-2_src_unpack |
183 |
# @DESCRIPTION: |
184 |
# Simply unpack source code. |
185 |
xorg-2_src_unpack() { |
186 |
if [[ -n ${GIT_ECLASS} ]]; then |
187 |
git_src_unpack |
188 |
else |
189 |
unpack ${A} |
190 |
fi |
191 |
|
192 |
[[ -n ${FONT_OPTIONS} ]] && einfo "Detected font directory: ${FONT_DIR}" |
193 |
} |
194 |
|
195 |
# @FUNCTION: xorg-2_patch_source |
196 |
# @DESCRIPTION: |
197 |
# Apply all patches |
198 |
xorg-2_patch_source() { |
199 |
# Use standardized names and locations with bulk patching |
200 |
# Patch directory is ${WORKDIR}/patch |
201 |
# See epatch() in eutils.eclass for more documentation |
202 |
EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch} |
203 |
|
204 |
[[ -d "${EPATCH_SOURCE}" ]] && epatch |
205 |
base_src_prepare |
206 |
} |
207 |
|
208 |
# @FUNCTION: xorg-2_reconf_source |
209 |
# @DESCRIPTION: |
210 |
# Run eautoreconf if necessary, and run elibtoolize. |
211 |
xorg-2_reconf_source() { |
212 |
case ${CHOST} in |
213 |
*-interix* | *-aix* | *-winnt*) |
214 |
# some hosts need full eautoreconf |
215 |
[[ -e "./configure.ac" || -e "./configure.in" ]] && eautoreconf || ewarn "Unable to autoreconf the configure script. Things may fail." |
216 |
;; |
217 |
*) |
218 |
# elibtoolize required for BSD |
219 |
[[ ${XORG_EAUTORECONF} != no && ( -e "./configure.ac" || -e "./configure.in" ) ]] && eautoreconf || elibtoolize |
220 |
;; |
221 |
esac |
222 |
} |
223 |
|
224 |
# @FUNCTION: xorg-2_src_prepare |
225 |
# @DESCRIPTION: |
226 |
# Prepare a package after unpacking, performing all X-related tasks. |
227 |
xorg-2_src_prepare() { |
228 |
[[ -n ${GIT_ECLASS} ]] && git_src_prepare |
229 |
xorg-2_patch_source |
230 |
xorg-2_reconf_source |
231 |
} |
232 |
|
233 |
# @FUNCTION: xorg-2_font_configure |
234 |
# @DESCRIPTION: |
235 |
# If a font package, perform any necessary configuration steps |
236 |
xorg-2_font_configure() { |
237 |
if has nls ${IUSE//+} && ! use nls; then |
238 |
FONT_OPTIONS+=" |
239 |
--disable-iso8859-2 |
240 |
--disable-iso8859-3 |
241 |
--disable-iso8859-4 |
242 |
--disable-iso8859-5 |
243 |
--disable-iso8859-6 |
244 |
--disable-iso8859-7 |
245 |
--disable-iso8859-8 |
246 |
--disable-iso8859-9 |
247 |
--disable-iso8859-10 |
248 |
--disable-iso8859-11 |
249 |
--disable-iso8859-12 |
250 |
--disable-iso8859-13 |
251 |
--disable-iso8859-14 |
252 |
--disable-iso8859-15 |
253 |
--disable-iso8859-16 |
254 |
--disable-jisx0201 |
255 |
--disable-koi8-r" |
256 |
fi |
257 |
} |
258 |
|
259 |
# @FUNCTION: xorg-2_flags_setup |
260 |
# @DESCRIPTION: |
261 |
# Set up CFLAGS for a debug build |
262 |
xorg-2_flags_setup() { |
263 |
# Win32 require special define |
264 |
[[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__ |
265 |
# hardened ldflags |
266 |
[[ ${PN} = xorg-server || -n ${DRIVER} ]] && append-ldflags -Wl,-z,lazy |
267 |
|
268 |
# Quite few libraries fail on runtime without these: |
269 |
if has static-libs ${IUSE//+}; then |
270 |
filter-flags -Wl,-Bdirect |
271 |
filter-ldflags -Bdirect |
272 |
filter-ldflags -Wl,-Bdirect |
273 |
fi |
274 |
} |
275 |
|
276 |
# @FUNCTION: xorg-2_src_configure |
277 |
# @DESCRIPTION: |
278 |
# Perform any necessary pre-configuration steps, then run configure |
279 |
xorg-2_src_configure() { |
280 |
local myopts="" |
281 |
|
282 |
xorg-2_flags_setup |
283 |
[[ -n "${FONT}" ]] && xorg-2_font_configure |
284 |
|
285 |
# @VARIABLE: CONFIGURE_OPTIONS |
286 |
# @DESCRIPTION: |
287 |
# Any options to pass to configure |
288 |
# @DEFAULT_UNSET |
289 |
CONFIGURE_OPTIONS=${CONFIGURE_OPTIONS:=""} |
290 |
if [[ -x ${ECONF_SOURCE:-.}/configure ]]; then |
291 |
if has static-libs ${IUSE//+}; then |
292 |
myopts+=" $(use_enable static-libs static)" |
293 |
fi |
294 |
econf \ |
295 |
${FONT_OPTIONS} \ |
296 |
${CONFIGURE_OPTIONS} \ |
297 |
${myopts} |
298 |
fi |
299 |
} |
300 |
|
301 |
# @FUNCTION: xorg-2_src_compile |
302 |
# @DESCRIPTION: |
303 |
# Compile a package, performing all X-related tasks. |
304 |
xorg-2_src_compile() { |
305 |
base_src_compile |
306 |
} |
307 |
|
308 |
# @FUNCTION: xorg-2_src_install |
309 |
# @DESCRIPTION: |
310 |
# Install a built package to ${D}, performing any necessary steps. |
311 |
# Creates a ChangeLog from git if using live ebuilds. |
312 |
xorg-2_src_install() { |
313 |
if [[ ${CATEGORY} == x11-proto ]]; then |
314 |
emake \ |
315 |
${PN/proto/}docdir=${EPREFIX}/usr/share/doc/${PF} \ |
316 |
docdir=${EPREFIX}/usr/share/doc/${PF} \ |
317 |
DESTDIR="${D}" \ |
318 |
install || die "emake install failed" |
319 |
else |
320 |
emake \ |
321 |
docdir=${EPREFIX}/usr/share/doc/${PF} \ |
322 |
DESTDIR="${D}" \ |
323 |
install || die "emake install failed" |
324 |
fi |
325 |
|
326 |
if [[ -n ${GIT_ECLASS} ]]; then |
327 |
pushd "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" > /dev/null |
328 |
git log ${EGIT_COMMIT} > "${S}"/ChangeLog |
329 |
popd > /dev/null |
330 |
fi |
331 |
|
332 |
if [[ -e "${S}"/ChangeLog ]]; then |
333 |
dodoc "${S}"/ChangeLog |
334 |
fi |
335 |
# @VARIABLE: DOCS |
336 |
# @DESCRIPTION: |
337 |
# Any documentation to install |
338 |
# @DEFAULT_UNSET |
339 |
if [[ -n ${DOCS} ]]; then |
340 |
dodoc ${DOCS} || die "dodoc failed" |
341 |
fi |
342 |
|
343 |
# Don't install libtool archives for server modules |
344 |
if [[ -e "${D%/}${EPREFIX}/usr/$(get_libdir)/xorg/modules" ]]; then |
345 |
find "${D%/}${EPREFIX}/usr/$(get_libdir)/xorg/modules" -name '*.la' \ |
346 |
-exec rm -f {} ';' |
347 |
fi |
348 |
|
349 |
[[ -n ${FONT} ]] && remove_font_metadata |
350 |
} |
351 |
|
352 |
# @FUNCTION: xorg-2_pkg_postinst |
353 |
# @DESCRIPTION: |
354 |
# Run X-specific post-installation tasks on the live filesystem. The |
355 |
# only task right now is some setup for font packages. |
356 |
xorg-2_pkg_postinst() { |
357 |
[[ -n ${FONT} ]] && setup_fonts |
358 |
} |
359 |
|
360 |
# @FUNCTION: xorg-2_pkg_postrm |
361 |
# @DESCRIPTION: |
362 |
# Run X-specific post-removal tasks on the live filesystem. The only |
363 |
# task right now is some cleanup for font packages. |
364 |
xorg-2_pkg_postrm() { |
365 |
if [[ -n ${FONT} ]]; then |
366 |
font_pkg_postrm |
367 |
fi |
368 |
} |
369 |
|
370 |
# @FUNCTION: setup_fonts |
371 |
# @DESCRIPTION: |
372 |
# Generates needed files for fonts and fixes font permissions |
373 |
setup_fonts() { |
374 |
create_fonts_scale |
375 |
create_fonts_dir |
376 |
font_pkg_postinst |
377 |
} |
378 |
|
379 |
# @FUNCTION: remove_font_metadata |
380 |
# @DESCRIPTION: |
381 |
# Don't let the package install generated font files that may overlap |
382 |
# with other packages. Instead, they're generated in pkg_postinst(). |
383 |
remove_font_metadata() { |
384 |
if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then |
385 |
einfo "Removing font metadata" |
386 |
rm -rf "${ED}"/usr/share/fonts/${FONT_DIR}/fonts.{scale,dir,cache-1} |
387 |
fi |
388 |
} |
389 |
|
390 |
# @FUNCTION: create_fonts_scale |
391 |
# @DESCRIPTION: |
392 |
# Create fonts.scale file, used by the old server-side fonts subsystem. |
393 |
create_fonts_scale() { |
394 |
if [[ ${FONT_DIR} != Speedo && ${FONT_DIR} != CID ]]; then |
395 |
ebegin "Generating font.scale" |
396 |
mkfontscale \ |
397 |
-a "${EROOT}/usr/share/fonts/encodings/encodings.dir" \ |
398 |
-- "${EROOT}/usr/share/fonts/${FONT_DIR}" |
399 |
eend $? |
400 |
fi |
401 |
} |
402 |
|
403 |
# @FUNCTION: create_fonts_dir |
404 |
# @DESCRIPTION: |
405 |
# Create fonts.dir file, used by the old server-side fonts subsystem. |
406 |
create_fonts_dir() { |
407 |
ebegin "Generating fonts.dir" |
408 |
mkfontdir \ |
409 |
-e "${EROOT}"/usr/share/fonts/encodings \ |
410 |
-e "${EROOT}"/usr/share/fonts/encodings/large \ |
411 |
-- "${EROOT}/usr/share/fonts/${FONT_DIR}" |
412 |
eend $? |
413 |
} |