1 |
# Copyright 2007-2008 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: $ |
4 |
|
5 |
# @ECLASS: kde4-base.eclass |
6 |
# @MAINTAINER: |
7 |
# kde@gentoo.org |
8 |
# @BLURB: This eclass provides functions for kde 4.0 ebuilds |
9 |
# @DESCRIPTION: |
10 |
# The kde4-base.eclass provides support for building KDE4 monolithic ebuilds |
11 |
# and KDE4 applications. |
12 |
# |
13 |
# NOTE: This eclass uses the SLOT dependencies from EAPI="1" or compatible, |
14 |
# hence you must define EAPI="1" in the ebuild, before inheriting any eclasses. |
15 |
|
16 |
inherit base eutils multilib cmake-utils kde4-functions |
17 |
|
18 |
EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_postinst pkg_postrm |
19 |
|
20 |
COMMONDEPEND=">=x11-libs/qt-4.3.3:4" |
21 |
DEPEND="${DEPEND} ${COMMONDEPEND} |
22 |
>=dev-util/cmake-2.4.7-r1 |
23 |
dev-util/pkgconfig |
24 |
x11-libs/libXt |
25 |
x11-proto/xf86vidmodeproto" |
26 |
RDEPEND="${RDEPEND} ${COMMONDEPEND}" |
27 |
|
28 |
if has test ${IUSE//+}; then |
29 |
DEPEND="${DEPEND} |
30 |
test? ( dev-util/cppunit )" |
31 |
fi |
32 |
|
33 |
# @ECLASS-VARIABLE: NEED_KDE |
34 |
# @DESCRIPTION: |
35 |
# This variable sets the version of KDE4 which will be used by the eclass. |
36 |
# This variable must be set by the ebuild, for all categories except for "kde-base". |
37 |
# For kde-base packages, if it is not set by the ebuild, |
38 |
# it's assumed that the required KDE4 version is the latest, non-live, available. |
39 |
# |
40 |
# @CODE |
41 |
# Acceptable values are: |
42 |
# - latest - Use latest version in the portage tree |
43 |
# Default for kde-base ebuilds. Banned for ebuilds not part of kde or koffice. |
44 |
# - svn - Use svn release (live ebuilds) |
45 |
# - :SLOT - Use any version in the SLOT specified in the NEED_KDE value. |
46 |
# - VERSION_NUMBER - Use the minimum KDE4 version specified in the NEED_KDE value. |
47 |
# - VERSION_NUMBER:SLOT - Use the minimum KDE4 version and the SLOT specified in the NEED_KDE value. |
48 |
# - none - Let the ebuild handle SLOT, kde dependencies, KDEDIR, ... |
49 |
# @CODE |
50 |
# |
51 |
# Note: There is no default NEED_KDE for ebuilds not in kde-base or part of |
52 |
# koffice, so you must set it explicitly in the ebuild, in all other cases. |
53 |
if [[ -z ${NEED_KDE} ]]; then |
54 |
if [[ -n ${KDEBASE} ]]; then |
55 |
NEED_KDE="latest" |
56 |
else |
57 |
die "kde4-base.eclass inherited but NEED_KDE not defined - broken ebuild" |
58 |
fi |
59 |
fi |
60 |
export NEED_KDE |
61 |
|
62 |
case ${NEED_KDE} in |
63 |
latest) |
64 |
# Should only be used by 'kde-base'-ebuilds |
65 |
if [[ "${KDEBASE}" == "kde-base" ]]; then |
66 |
case ${PV} in |
67 |
3.9*) _kdedir="3.9" ;; |
68 |
4*) _kdedir="4.0" ;; |
69 |
*) die "NEED_KDE=latest not supported for PV=${PV}" ;; |
70 |
esac |
71 |
_operator=">=" |
72 |
_pv="-${PV}:kde-4" |
73 |
else |
74 |
_kdedir="4.0" |
75 |
_pv=":kde-4" |
76 |
fi |
77 |
;; |
78 |
svn|9999*|:kde-svn) |
79 |
_kdedir="svn" |
80 |
_pv=":kde-svn" |
81 |
export NEED_KDE="svn" |
82 |
;; |
83 |
*:kde-svn) |
84 |
_kdedir="svn" |
85 |
_operator=">=" |
86 |
_pv="-${NEED_KDE}" |
87 |
export NEED_KDE="svn" |
88 |
;; |
89 |
# The ebuild handles dependencies, KDEDIR, SLOT. |
90 |
none) |
91 |
# This shouldn't be used for kde-base ebuilds. |
92 |
if [[ -n ${KDEBASE} ]]; then |
93 |
die 'Ebuilds part of kde-base ebuilds should not use NEED_KDE="none".' |
94 |
fi |
95 |
;; |
96 |
# NEED_KDE=":${SLOT}" |
97 |
:kde-4) |
98 |
_kdedir="4.0" |
99 |
_pv="${NEED_KDE}" |
100 |
;; |
101 |
# NEED_KDE="${PV}:${SLOT}" |
102 |
*:kde-4) |
103 |
_kdedir="4.0" |
104 |
_operator=">=" |
105 |
_pv="-${NEED_KDE}" |
106 |
;; |
107 |
3.9*) |
108 |
_kdedir="3.9" |
109 |
_operator=">=" |
110 |
_pv="-${NEED_KDE}:kde-4" |
111 |
;; |
112 |
4*) |
113 |
_kdedir="4.0" |
114 |
_operator=">=" |
115 |
_pv="-${NEED_KDE}:kde-4" |
116 |
;; |
117 |
*) die "NEED_KDE=${NEED_KDE} currently not supported." |
118 |
;; |
119 |
esac |
120 |
|
121 |
if [[ ${NEED_KDE} != none ]]; then |
122 |
KDEDIR="/usr/kde/${_kdedir}" |
123 |
KDEDIRS="/usr:/usr/local:${KDEDIR}" |
124 |
|
125 |
if [[ -n ${KDEBASE} ]]; then |
126 |
if [[ ${NEED_KDE} = svn ]]; then |
127 |
SLOT="kde-svn" |
128 |
else |
129 |
SLOT="kde-4" |
130 |
fi |
131 |
fi |
132 |
|
133 |
# We only need to add the dependencies if ${PN} is not "kdelibs" or "kdepimlibs" |
134 |
if [[ ${PN} != "kdelibs" ]]; then |
135 |
DEPEND="${DEPEND} |
136 |
${_operator}kde-base/kdelibs${_pv}" |
137 |
RDEPEND="${RDEPEND} |
138 |
${_operator}kde-base/kdelibs${_pv}" |
139 |
if [[ ${PN} != "kdepimlibs" ]]; then |
140 |
DEPEND="${DEPEND} |
141 |
${_operator}kde-base/kdepimlibs${_pv}" |
142 |
RDEPEND="${RDEPEND} |
143 |
${_operator}kde-base/kdepimlibs${_pv}" |
144 |
fi |
145 |
fi |
146 |
|
147 |
unset _operator _pv _kdedir |
148 |
fi |
149 |
|
150 |
# Fetch section - If the ebuild's category is not 'kde-base' and if it is not a |
151 |
# koffice ebuild, the URI should be set in the ebuild itself |
152 |
if [[ -n ${KDEBASE} ]]; then |
153 |
if [[ -n ${KMNAME} ]]; then |
154 |
_kmname=${KMNAME} |
155 |
else |
156 |
_kmname=${PN} |
157 |
fi |
158 |
_kmname_pv="${_kmname}-${PV}" |
159 |
if [[ ${NEED_KDE} != "svn" ]]; then |
160 |
case ${KDEBASE} in |
161 |
kde-base) |
162 |
case ${PV} in |
163 |
*) SRC_URI="mirror://kde/stable/${PV}/src/${_kmname_pv}.tar.bz2";; |
164 |
esac |
165 |
;; |
166 |
koffice) |
167 |
SRC_URI="mirror://kde/unstable/${_kmname_pv}/src/${_kmname_pv}.tar.bz2" |
168 |
;; |
169 |
esac |
170 |
fi |
171 |
unset _kmname _kmname_pv |
172 |
fi |
173 |
|
174 |
debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}" |
175 |
debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND ${DEPEND} - before blockers" |
176 |
|
177 |
# Monolithic ebuilds should add blockers for split ebuilds in the same slot. |
178 |
# If KMNAME is not set then this is not a split package |
179 |
if [[ -n ${KDEBASE} && -z ${KMNAME} ]]; then |
180 |
for _x in $(get-child-packages ${CATEGORY}/${PN}); do |
181 |
DEPEND="${DEPEND} !${_x}:${SLOT}" |
182 |
RDEPEND="${RDEPEND} !${_x}:${SLOT}" |
183 |
done |
184 |
unset _x |
185 |
fi |
186 |
|
187 |
debug-print "${BASH_SOURCE} ${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND ${DEPEND} - after blockers" |
188 |
|
189 |
# @ECLASS-VARIABLE: PREFIX |
190 |
# @DESCRIPTION: |
191 |
# Set the installation PREFIX. All kde-base ebuilds go into the KDE4 installation directory. |
192 |
# Applications installed by the other ebuilds go into /usr/ by default, this value |
193 |
# can be superseded by defining PREFIX before inheriting kde4-base. |
194 |
if [[ -n ${KDEBASE} ]]; then |
195 |
PREFIX=${KDEDIR} |
196 |
else |
197 |
# if PREFIX is not defined we set it to the default value of /usr |
198 |
PREFIX="${PREFIX:-/usr}" |
199 |
fi |
200 |
|
201 |
debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SLOT ${SLOT} - KDEDIR ${KDEDIR} - KDEDIRS ${KDEDIRS}- PREFIX ${PREFIX} - NEED_KDE ${NEED_KDE}" |
202 |
|
203 |
# @FUNCTION: kde4-base_pkg_setup |
204 |
# @DESCRIPTION: |
205 |
# Adds flags needed by all of KDE 4 to $QT4_BUILT_WITH_USE_CHECK. Uses |
206 |
# kde4-functions_check_use from kde4-functions.eclass to print appropriate |
207 |
# errors and die if any required flags listed in $QT4_BUILT_WITH_USE_CHECK or |
208 |
# $KDE4_BUILT_WITH_USE_CHECK are missing. |
209 |
kde4-base_pkg_setup() { |
210 |
debug-print-function $FUNCNAME "$@" |
211 |
|
212 |
# KDE4 applications require qt4 compiled with USE="accessibility dbus jpeg png qt3support ssl zlib". |
213 |
QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK} accessibility dbus jpeg png qt3support ssl zlib" |
214 |
|
215 |
if has debug ${IUSE//+} && use debug; then |
216 |
QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK} debug" |
217 |
fi |
218 |
|
219 |
if has opengl ${IUSE//+} && use opengl; then |
220 |
QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK} opengl" |
221 |
fi |
222 |
|
223 |
kde4-functions_check_use |
224 |
} |
225 |
|
226 |
# @FUNCTION: kde4-base_src_unpack |
227 |
# @DESCRIPTION: |
228 |
# This function unpacks the source tarballs for KDE4 applications. |
229 |
# |
230 |
# If no argument is passed to this function, then standard src_unpack is |
231 |
# executed. Otherwise options are passed to base_src_unpack. |
232 |
# |
233 |
# If the directory ${WORKDIR}/patches/ exists, we apply all patches in that |
234 |
# directory, provided they follow this format: |
235 |
# @CODE |
236 |
# - Monolithic ebuilds, (from kde-base) |
237 |
# - $CATEGORY=kde-base: |
238 |
# Apply ${CHILD_EBUILD_NAME}-${SLOT}-*{diff,patch} |
239 |
# - $CATEGORY=!kde-base: |
240 |
# Apply ${CHILD_EBUILD_NAME}-${PV}-*{diff,patch} |
241 |
# - Split ebuilds: |
242 |
# - $CATEGORY=kde-base: |
243 |
# Apply ${PN}-${SLOT}-*{diff,patch} |
244 |
# - $CATEGORY!=kde-base: |
245 |
# Apply ${PN}-${PV}-*{diff,patch} |
246 |
# @CODE |
247 |
# |
248 |
# If ${PATCHES} is non-zero all patches in it gets applied. |
249 |
kde4-base_src_unpack() { |
250 |
debug-print-function $FUNCNAME "$@" |
251 |
|
252 |
[[ -z "${KDE_S}" ]] && KDE_S="${S}" |
253 |
|
254 |
local _patchdir _packages _p |
255 |
_patchdir="${WORKDIR}/patches/" |
256 |
if [[ -z $* ]]; then |
257 |
# Unpack first and deal with KDE patches after examing possible patch sets. |
258 |
# To be picked up, patches need to conform to the guidelines stated before. |
259 |
# Monolithic ebuilds will use the split ebuild patches. |
260 |
[[ -d "${KDE_S}" ]] || unpack ${A} |
261 |
if [[ -d "${_patchdir}" ]]; then |
262 |
if is-parent-package ${CATEGORY}/${PN} ; then |
263 |
_packages="$(get-child-packages ${CATEGORY}/${PN})" |
264 |
_packages="${_packages//${CATEGORY}\//} ${PN}" |
265 |
else |
266 |
_packages="${PN}" |
267 |
fi |
268 |
for _p in ${_packages}; do |
269 |
PATCHES="${PATCHES} $(ls ${_patchdir}/${_p}-${PV}-*{diff,patch} 2>/dev/null)" |
270 |
if [[ -n "${KDEBASE}" ]]; then |
271 |
PATCHES="${PATCHES} $(ls ${_patchdir}/${_p}-${SLOT}-*{diff,patch} 2>/dev/null)" |
272 |
fi |
273 |
done |
274 |
fi |
275 |
[[ -n ${PATCHES} ]] && base_src_unpack autopatch |
276 |
else |
277 |
# Call base_src_unpack, which unpacks and patches |
278 |
# step by step transparently as defined in the ebuild. |
279 |
base_src_unpack $* |
280 |
fi |
281 |
|
282 |
# Updated cmake dir |
283 |
if [[ -d "${WORKDIR}/cmake" ]] && [[ -d "${KDE_S}/cmake" ]]; then |
284 |
ebegin "Updating cmake/ directory..." |
285 |
rm -rf "${KDE_S}/cmake" || die "Unable to remove old cmake/ directory" |
286 |
ln -s "${WORKDIR}/cmake" "${KDE_S}/cmake" || die "Unable to symlink the new cmake/ directory" |
287 |
eend 0 |
288 |
fi |
289 |
} |
290 |
|
291 |
# @FUNCTION: kde4-base_src_compile |
292 |
# @DESCRIPTION: |
293 |
# General function for compiling KDE4 applications. |
294 |
kde4-base_src_compile() { |
295 |
debug-print-function ${FUNCNAME} "$@" |
296 |
|
297 |
kde4-base_src_configure |
298 |
kde4-base_src_make |
299 |
} |
300 |
|
301 |
# @FUNCTION: kde4-base_src_configure |
302 |
# @DESCRIPTION: |
303 |
# Function for configuring the build of KDE4 applications. |
304 |
kde4-base_src_configure() { |
305 |
debug-print-function ${FUNCNAME} "$@" |
306 |
|
307 |
# Final flag handling |
308 |
if has kdeenablefinal ${IUSE//+} && use kdeenablefinal; then |
309 |
einfo "Activating enable-final flag" |
310 |
mycmakeargs="${mycmakeargs} -DKDE4_ENABLE_FINAL=ON" |
311 |
fi |
312 |
|
313 |
# Enable generation of HTML handbook |
314 |
if has htmlhandbook ${IUSE//+} && use htmlhandbook; then |
315 |
einfo "Enabling building of HTML handbook" |
316 |
mycmakeargs="${mycmakeargs} -DKDE4_ENABLE_HTMLHANDBOOK=ON" |
317 |
fi |
318 |
|
319 |
# Build tests in src_test only, where we override this value |
320 |
mycmakeargs="${mycmakeargs} -DKDE4_BUILD_TESTS=OFF" |
321 |
|
322 |
# Set distribution name |
323 |
[[ ${PN} == "kdelibs" ]] && mycmakeargs="${mycmakeargs} -DKDE_DISTRIBUTION_TEXT=Gentoo" |
324 |
|
325 |
# runpath linking |
326 |
mycmakeargs="${mycmakeargs} -DKDE4_USE_ALWAYS_FULL_RPATH=ON" |
327 |
|
328 |
# Here we set the install prefix |
329 |
mycmakeargs="${mycmakeargs} -DCMAKE_INSTALL_PREFIX=${PREFIX}" |
330 |
|
331 |
# Set environment |
332 |
QTEST_COLORED=1 |
333 |
QT_PLUGIN_PATH=${KDEDIR}/$(get_libdir)/kde4/plugins/ |
334 |
|
335 |
cmake-utils_src_configureout |
336 |
} |
337 |
|
338 |
# @FUNCTION: kde4-base_src_make |
339 |
# @DESCRIPTION: |
340 |
# Function for building KDE4 applications. |
341 |
# Options are passed to cmake-utils_src_make. |
342 |
kde4-base_src_make() { |
343 |
debug-print-function ${FUNCNAME} "$@" |
344 |
|
345 |
cmake-utils_src_make "$@" |
346 |
} |
347 |
|
348 |
# @FUNCTION: kde4-base_src_test |
349 |
# @DESCRIPTION: |
350 |
# Function for testing KDE4 applications. |
351 |
kde4-base_src_test() { |
352 |
debug-print-function ${FUNCNAME} "$@" |
353 |
|
354 |
# Override this value, set in kde4-base_src_configure() |
355 |
mycmakeargs="${mycmakeargs} -DKDE4_BUILD_TESTS=ON" |
356 |
cmake-utils_src_compile |
357 |
|
358 |
cmake-utils_src_test |
359 |
} |
360 |
|
361 |
# @FUNCTION: kde4-base_src_install |
362 |
# @DESCRIPTION: |
363 |
# Function for installing KDE4 applications. |
364 |
kde4-base_src_install() { |
365 |
debug-print-function ${FUNCNAME} "$@" |
366 |
|
367 |
kde4-base_src_make_doc |
368 |
cmake-utils_src_install |
369 |
} |
370 |
|
371 |
# @FUNCTION: kde4-base_src_make_doc |
372 |
# @DESCRIPTION: |
373 |
# Function for installing the documentation of KDE4 applications. |
374 |
kde4-base_src_make_doc() { |
375 |
debug-print-function ${FUNCNAME} "$@" |
376 |
|
377 |
local doc |
378 |
for doc in AUTHORS ChangeLog* README* NEWS TODO; do |
379 |
[[ -s $doc ]] && dodoc ${doc} |
380 |
done |
381 |
|
382 |
if [[ -z ${KMNAME} ]]; then |
383 |
for doc in {apps,runtime,workspace,.}/*/{AUTHORS,README*}; do |
384 |
if [[ -s $doc ]]; then |
385 |
local doc_complete=${doc} |
386 |
doc="${doc#*/}" |
387 |
newdoc "$doc_complete" "${doc%/*}.${doc##*/}" |
388 |
fi |
389 |
done |
390 |
fi |
391 |
|
392 |
if [[ -n ${KDEBASE} && -d "${D}"/usr/share/doc/${PF} ]]; then |
393 |
# work around bug #97196 |
394 |
dodir /usr/share/doc/kde && \ |
395 |
mv "${D}"/usr/share/doc/${PF} "${D}"/usr/share/doc/kde/ || \ |
396 |
die "Failed to move docs to kde/ failed." |
397 |
fi |
398 |
} |
399 |
|
400 |
# @FUNCTION: kde4-base_pkg_postinst |
401 |
# @DESCRIPTION: |
402 |
# Function to rebuild the KDE System Configuration Cache after an application has been installed. |
403 |
kde4-base_pkg_postinst() { |
404 |
buildsycoca |
405 |
} |
406 |
|
407 |
# @FUNCTION: kde4-base_pkg_postrm |
408 |
# @DESCRIPTION: |
409 |
# Function to rebuild the KDE System Configuration Cache after an application has been removed. |
410 |
kde4-base_pkg_postrm() { |
411 |
buildsycoca |
412 |
} |