/[gentoo-x86]/eclass/kde4-base.eclass
Gentoo

Contents of /eclass/kde4-base.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Sun Apr 6 21:36:53 2008 UTC (6 years ago) by zlin
Branch: MAIN
Changes since 1.8: +3 -3 lines
Use an array for PATCHES on the eclass level regardless if the ebuild explicitly specifies two or more patches or not.

1 # Copyright 2007-2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-base.eclass,v 1.8 2008/04/04 22:15:24 zlin Exp $
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 kde4-base_set_qt_dependencies() {
21 local qt qtcore qtgui qt3support qtsvg qttest qtopengl qtdepend qtopengldepend
22
23 # use dependencies
24 case "${EAPI}" in
25 kdebuild-1)
26 qt="[accessibility][dbus][debug?][gif][jpeg][png][qt3support][ssl][zlib]"
27 qtcore="[debug?][qt3support][ssl]"
28 qtgui="[accessibility][dbus][debug?]"
29 qt3support="[accessibility][debug?]"
30 qtsvg="[debug?]"
31 qttest="[debug?]"
32 qtopengl="[debug?]"
33 case "${OPENGL_REQUIRED}" in
34 always)
35 qt="${qt}[opengl]"
36 ;;
37 optional)
38 qt="${qt}[opengl?]"
39 ;;
40 esac
41 ;;
42 esac
43
44 # split qt
45 qtdepend="
46 x11-libs/qt-core:4${qtcore}
47 x11-libs/qt-gui:4${qtgui}
48 x11-libs/qt-qt3support:4${qt3support}
49 x11-libs/qt-svg:4${qtsvg}
50 x11-libs/qt-test:4${qttest}"
51 qtopengldepend="x11-libs/qt-opengl:4${qtopengl}"
52
53 # allow monolithic qt for PV < 4.1
54 case "${PV}" in
55 scm|9999.4|4.1*) : ;;
56 *)
57 qtdepend="|| ( ( ${qtdepend} ) >=x11-libs/qt-4.3.3:4${qt} )"
58 qtopengldepend="|| ( ${qtopengldepend} >=x11-libs/qt-4.3.3:4 )"
59 ;;
60 esac
61
62 # opengl dependencies
63 case "${OPENGL_REQUIRED}" in
64 always)
65 qtdepend="${qtdepend}
66 ${qtopengldepend}"
67 ;;
68 optional)
69 IUSE="${IUSE} opengl"
70 qtdepend="${qtdepend}
71 opengl? ( ${qtopengldepend} )"
72 ;;
73 *)
74 OPENGL_REQUIRED="never"
75 ;;
76 esac
77
78 COMMONDEPEND="${COMMONDEPEND} ${qtdepend}"
79 }
80 kde4-base_set_qt_dependencies
81
82 DEPEND="${DEPEND} ${COMMONDEPEND}
83 >=dev-util/cmake-2.4.7-r1
84 dev-util/pkgconfig
85 x11-libs/libXt
86 x11-proto/xf86vidmodeproto"
87 RDEPEND="${RDEPEND} ${COMMONDEPEND}"
88
89 # @ECLASS-VARIABLE: OPENGL_REQUIRED
90 # @DESCRIPTION:
91 # Is qt-opengl required? Possible values are 'always', 'optional' and 'never'.
92 # This variable must be set before inheriting any eclasses. Defaults to 'never'.
93 OPENGL_REQUIRED="${OPENGL_REQUIRED:-never}"
94
95 # @ECLASS-VARIABLE: CPPUNIT_REQUIRED
96 # @DESCRIPTION:
97 # Is cppunit required for tests? Possible values are 'always', 'optional' and 'never'.
98 # This variable must be set before inheriting any eclasses. Defaults to 'never'.
99 CPPUNIT_REQUIRED="${CPPUNIT_REQUIRED:-never}"
100
101 case "${CPPUNIT_REQUIRED}" in
102 always)
103 DEPEND="${DEPEND} dev-util/cppunit"
104 ;;
105 optional)
106 IUSE="${IUSE} test"
107 DEPEND="${DEPEND}
108 test? ( dev-util/cppunit )"
109 ;;
110 *)
111 CPPUNIT_REQUIRED="never"
112 ;;
113 esac
114
115 # @ECLASS-VARIABLE: NEED_KDE
116 # @DESCRIPTION:
117 # This variable sets the version of KDE4 which will be used by the eclass.
118 # This variable must be set by the ebuild, for all categories except for "kde-base".
119 # For kde-base packages, if it is not set by the ebuild,
120 # it's assumed that the required KDE4 version is the latest, non-live, available.
121 #
122 # @CODE
123 # Acceptable values are:
124 # - latest - Use latest version in the portage tree
125 # Default for kde-base ebuilds. Banned for ebuilds not part of kde or koffice.
126 # - svn - Use svn release (live ebuilds)
127 # - :SLOT - Use any version in the SLOT specified in the NEED_KDE value.
128 # - VERSION_NUMBER - Use the minimum KDE4 version specified in the NEED_KDE value.
129 # - VERSION_NUMBER:SLOT - Use the minimum KDE4 version and the SLOT specified in the NEED_KDE value.
130 # - none - Let the ebuild handle SLOT, kde dependencies, KDEDIR, ...
131 # @CODE
132 #
133 # Note: There is no default NEED_KDE for ebuilds not in kde-base or part of
134 # koffice, so you must set it explicitly in the ebuild, in all other cases.
135 if [[ -z ${NEED_KDE} ]]; then
136 if [[ -n ${KDEBASE} ]]; then
137 NEED_KDE="latest"
138 else
139 die "kde4-base.eclass inherited but NEED_KDE not defined - broken ebuild"
140 fi
141 fi
142 export NEED_KDE
143
144 case ${NEED_KDE} in
145 latest)
146 # Should only be used by 'kde-base'-ebuilds
147 if [[ "${KDEBASE}" == "kde-base" ]]; then
148 case ${PV} in
149 3.9*) _kdedir="3.9" ;;
150 4*) _kdedir="4.0" ;;
151 *) die "NEED_KDE=latest not supported for PV=${PV}" ;;
152 esac
153 _operator=">="
154 _pv="-${PV}:kde-4"
155 else
156 _kdedir="4.0"
157 _pv=":kde-4"
158 fi
159 ;;
160 scm|svn|9999*|:kde-svn)
161 _kdedir="svn"
162 _pv=":kde-svn"
163 export NEED_KDE="svn"
164 ;;
165 *:kde-svn)
166 _kdedir="svn"
167 _operator=">="
168 _pv="-${NEED_KDE}"
169 export NEED_KDE="svn"
170 ;;
171 # The ebuild handles dependencies, KDEDIR, SLOT.
172 none)
173 :
174 ;;
175 # NEED_KDE=":${SLOT}"
176 :kde-4)
177 _kdedir="4.0"
178 _pv="${NEED_KDE}"
179 ;;
180 # NEED_KDE="${PV}:${SLOT}"
181 *:kde-4)
182 _kdedir="4.0"
183 _operator=">="
184 _pv="-${NEED_KDE}"
185 ;;
186 3.9*)
187 _kdedir="3.9"
188 _operator=">="
189 _pv="-${NEED_KDE}:kde-4"
190 ;;
191 4*)
192 _kdedir="4.0"
193 _operator=">="
194 _pv="-${NEED_KDE}:kde-4"
195 ;;
196 *) die "NEED_KDE=${NEED_KDE} currently not supported."
197 ;;
198 esac
199
200 if [[ ${NEED_KDE} != none ]]; then
201 KDEDIR="/usr/kde/${_kdedir}"
202 KDEDIRS="/usr:/usr/local:${KDEDIR}"
203
204 if [[ -n ${KDEBASE} ]]; then
205 if [[ ${NEED_KDE} = svn ]]; then
206 SLOT="kde-svn"
207 else
208 SLOT="kde-4"
209 fi
210 fi
211
212 # We only need to add the dependencies if ${PN} is not "kdelibs" or "kdepimlibs"
213 if [[ ${PN} != "kdelibs" ]]; then
214 DEPEND="${DEPEND}
215 ${_operator}kde-base/kdelibs${_pv}"
216 RDEPEND="${RDEPEND}
217 ${_operator}kde-base/kdelibs${_pv}"
218 if [[ ${PN} != "kdepimlibs" ]]; then
219 DEPEND="${DEPEND}
220 ${_operator}kde-base/kdepimlibs${_pv}"
221 RDEPEND="${RDEPEND}
222 ${_operator}kde-base/kdepimlibs${_pv}"
223 fi
224 fi
225
226 unset _operator _pv _kdedir
227 fi
228
229 # Fetch section - If the ebuild's category is not 'kde-base' and if it is not a
230 # koffice ebuild, the URI should be set in the ebuild itself
231 if [[ -n ${KDEBASE} ]]; then
232 if [[ -n ${KMNAME} ]]; then
233 _kmname=${KMNAME}
234 else
235 _kmname=${PN}
236 fi
237 _kmname_pv="${_kmname}-${PV}"
238 if [[ ${NEED_KDE} != "svn" ]]; then
239 case ${KDEBASE} in
240 kde-base)
241 case ${PV} in
242 *) SRC_URI="mirror://kde/stable/${PV}/src/${_kmname_pv}.tar.bz2";;
243 esac
244 ;;
245 koffice)
246 SRC_URI="mirror://kde/unstable/${_kmname_pv}/src/${_kmname_pv}.tar.bz2"
247 ;;
248 esac
249 fi
250 unset _kmname _kmname_pv
251 fi
252
253 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
254 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND ${DEPEND} - before blockers"
255
256 # Monolithic ebuilds should add blockers for split ebuilds in the same slot.
257 # If KMNAME is not set then this is not a split package
258 if [[ -n ${KDEBASE} && -z ${KMNAME} ]]; then
259 for _x in $(get-child-packages ${CATEGORY}/${PN}); do
260 DEPEND="${DEPEND} !${_x}:${SLOT}"
261 RDEPEND="${RDEPEND} !${_x}:${SLOT}"
262 done
263 unset _x
264 fi
265
266 debug-print "${BASH_SOURCE} ${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND ${DEPEND} - after blockers"
267
268 # @ECLASS-VARIABLE: PREFIX
269 # @DESCRIPTION:
270 # Set the installation PREFIX. All kde-base ebuilds go into the KDE4 installation directory.
271 # Applications installed by the other ebuilds go into /usr/ by default, this value
272 # can be superseded by defining PREFIX before inheriting kde4-base.
273 if [[ -n ${KDEBASE} ]]; then
274 PREFIX=${KDEDIR}
275 else
276 # if PREFIX is not defined we set it to the default value of /usr
277 PREFIX="${PREFIX:-/usr}"
278 fi
279
280 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SLOT ${SLOT} - KDEDIR ${KDEDIR} - KDEDIRS ${KDEDIRS}- PREFIX ${PREFIX} - NEED_KDE ${NEED_KDE}"
281
282 # @FUNCTION: kde4-base_pkg_setup
283 # @DESCRIPTION:
284 # Adds flags needed by all of KDE 4 to $QT4_BUILT_WITH_USE_CHECK. Uses
285 # kde4-functions_check_use from kde4-functions.eclass to print appropriate
286 # errors and die if any required flags listed in $QT4_BUILT_WITH_USE_CHECK or
287 # $KDE4_BUILT_WITH_USE_CHECK are missing.
288 kde4-base_pkg_setup() {
289 debug-print-function $FUNCNAME "$@"
290
291 case "${EAPI}" in
292 kdebuild-1)
293 [[ -n ${QT4_BUILT_WITH_USE_CHECK} || -n ${KDE4_BUILT_WITH_USE_CHECK} ]] && \
294 die "built_with_use illegal in this EAPI!"
295 ;;
296 *)
297 # KDE4 applications require qt4 compiled with USE="accessibility dbus gif jpeg png qt3support ssl zlib".
298 if has_version '<x11-libs/qt-4.4_alpha:4'; then
299 QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK} accessibility dbus gif jpeg png qt3support ssl zlib"
300 else
301 KDE4_BUILT_WITH_USE_CHECK="${KDE4_BUILT_WITH_USE_CHECK}
302 x11-libs/qt-core qt3support ssl
303 x11-libs/qt-gui accessibility dbus
304 x11-libs/qt-qt3support accessibility"
305 fi
306
307 if has debug ${IUSE//+} && use debug; then
308 if has_version '<x11-libs/qt-4.4.0_alpha:4'; then
309 QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK} debug"
310 else
311 KDE4_BUILT_WITH_USE_CHECK="${KDE4_BUILT_WITH_USE_CHECK}
312 x11-libs/qt-core:4 debug
313 x11-libs/qt-gui:4 debug
314 x11-libs/qt-qt3support:4 debug
315 x11-libs/qt-svg:4 debug
316 x11-libs/qt-test:4 debug"
317 if has opengl ${IUSE//+} && use opengl || [[ ${OPENGL_REQUIRED} == always ]]; then
318 KDE4_BUILT_WITH_USE_CHECK="${KDE4_BUILT_WITH_USE_CHECK}
319 x11-libs/qt-opengl:4 debug"
320 fi
321 fi
322 fi
323
324 if has opengl ${IUSE//+} && use opengl || [[ ${OPENGL_REQUIRED} == always ]]; then
325 if has_version '<x11-libs/qt-4.4.0_alpha:4'; then
326 QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK} opengl"
327 fi
328 fi
329 kde4-functions_check_use
330 ;;
331 esac
332 }
333
334 # @FUNCTION: kde4-base_apply_patches
335 # @DESCRIPTION:
336 # This function applies patches.
337 #
338 # If the directory ${WORKDIR}/patches/ exists, we apply all patches in that
339 # directory, provided they follow this format:
340 # @CODE
341 # - Monolithic ebuilds, (from kde-base)
342 # - $CATEGORY=kde-base:
343 # Apply ${CHILD_EBUILD_NAME}-${SLOT}-*{diff,patch}
344 # - $CATEGORY=!kde-base:
345 # Apply ${CHILD_EBUILD_NAME}-${PV}-*{diff,patch}
346 # - Split ebuilds:
347 # - $CATEGORY=kde-base:
348 # Apply ${PN}-${SLOT}-*{diff,patch}
349 # - $CATEGORY!=kde-base:
350 # Apply ${PN}-${PV}-*{diff,patch}
351 # @CODE
352 #
353 # If ${PATCHES} is non-zero all patches in it get applied. If there is more
354 # than one patch please make ${PATCHES} an array for proper quoting.
355 kde4-base_apply_patches() {
356 local _patchdir _packages _p
357 _patchdir="${WORKDIR}/patches/"
358 if [[ -d "${_patchdir}" ]]; then
359 if is-parent-package ${CATEGORY}/${PN} ; then
360 _packages="$(get-child-packages ${CATEGORY}/${PN})"
361 _packages="${_packages//${CATEGORY}\//} ${PN}"
362 else
363 _packages="${PN}"
364 fi
365 if [[ ${#PATCHES[@]} -gt 1 ]]; then
366 for _p in ${_packages}; do
367 PATCHES=( "${PATCHES[@]}" $(ls ${_patchdir}/${_p}-${PV}-*{diff,patch} 2>/dev/null) )
368 if [[ -n "${KDEBASE}" ]]; then
369 PATCHES=( "${PATCHES[@]}" $(ls ${_patchdir}/${_p}-${SLOT}-*{diff,patch} 2>/dev/null) )
370 fi
371 done
372 else
373 for _p in ${_packages}; do
374 PATCHES=(${PATCHES} $(ls ${_patchdir}/${_p}-${PV}-*{diff,patch} 2>/dev/null))
375 if [[ -n "${KDEBASE}" ]]; then
376 PATCHES=(${PATCHES} $(ls ${_patchdir}/${_p}-${SLOT}-*{diff,patch} 2>/dev/null))
377 fi
378 done
379 fi
380 fi
381 [[ -n ${PATCHES[@]} ]] && base_src_unpack autopatch
382 }
383
384 # @FUNCTION: kde4-base_src_unpack
385 # @DESCRIPTION:
386 # This function unpacks the source tarballs for KDE4 applications.
387 #
388 # If no argument is passed to this function, then standard src_unpack is
389 # executed. Otherwise options are passed to base_src_unpack.
390 #
391 # In addition it calls kde4-base_apply_patches when no arguments are passed to
392 # this function.
393 #
394 # It also handles translations if KDE_LINGUAS is defined. See KDE_LINGUAS and
395 # enable_selected_linguas() in kde4-functions.eclass(5) for further details.
396 kde4-base_src_unpack() {
397 debug-print-function $FUNCNAME "$@"
398
399 [[ -z "${KDE_S}" ]] && KDE_S="${S}"
400
401 if [[ -z $* ]]; then
402 # Unpack first and deal with KDE patches after examing possible patch sets.
403 # To be picked up, patches need to conform to the guidelines stated before.
404 # Monolithic ebuilds will use the split ebuild patches.
405 [[ -d "${KDE_S}" ]] || unpack ${A}
406 kde4-base_apply_patches
407 else
408 # Call base_src_unpack, which unpacks and patches
409 # step by step transparently as defined in the ebuild.
410 base_src_unpack $*
411 fi
412
413 # Updated cmake dir
414 if [[ -d "${WORKDIR}/cmake" ]] && [[ -d "${KDE_S}/cmake" ]]; then
415 ebegin "Updating cmake/ directory..."
416 rm -rf "${KDE_S}/cmake" || die "Unable to remove old cmake/ directory"
417 ln -s "${WORKDIR}/cmake" "${KDE_S}/cmake" || die "Unable to symlink the new cmake/ directory"
418 eend 0
419 fi
420
421 # Only enable selected languages, used for KDE extragear apps.
422 if [[ -n ${KDE_LINGUAS} ]]; then
423 enable_selected_linguas
424 fi
425 }
426
427 # @FUNCTION: kde4-base_src_compile
428 # @DESCRIPTION:
429 # General function for compiling KDE4 applications.
430 kde4-base_src_compile() {
431 debug-print-function ${FUNCNAME} "$@"
432
433 kde4-base_src_configure
434 kde4-base_src_make
435 }
436
437 # @FUNCTION: kde4-base_src_configure
438 # @DESCRIPTION:
439 # Function for configuring the build of KDE4 applications.
440 kde4-base_src_configure() {
441 debug-print-function ${FUNCNAME} "$@"
442
443 # Final flag handling
444 if has kdeenablefinal ${IUSE//+} && use kdeenablefinal; then
445 echo "Activating enable-final flag"
446 mycmakeargs="${mycmakeargs} -DKDE4_ENABLE_FINAL=ON"
447 fi
448
449 # Enable generation of HTML handbook
450 if has htmlhandbook ${IUSE//+} && use htmlhandbook; then
451 echo "Enabling building of HTML handbook"
452 mycmakeargs="${mycmakeargs} -DKDE4_ENABLE_HTMLHANDBOOK=ON"
453 fi
454
455 # Build tests in src_test only, where we override this value
456 mycmakeargs="${mycmakeargs} -DKDE4_BUILD_TESTS=OFF"
457
458 # Set distribution name
459 [[ ${PN} == "kdelibs" ]] && mycmakeargs="${mycmakeargs} -DKDE_DISTRIBUTION_TEXT=Gentoo"
460
461 # runpath linking
462 mycmakeargs="${mycmakeargs} -DKDE4_USE_ALWAYS_FULL_RPATH=ON"
463
464 # Here we set the install prefix
465 mycmakeargs="${mycmakeargs} -DCMAKE_INSTALL_PREFIX=${PREFIX}"
466
467 # Set environment
468 QTEST_COLORED=1
469 QT_PLUGIN_PATH=${KDEDIR}/$(get_libdir)/kde4/plugins/
470
471 cmake-utils_src_configureout
472 }
473
474 # @FUNCTION: kde4-base_src_make
475 # @DESCRIPTION:
476 # Function for building KDE4 applications.
477 # Options are passed to cmake-utils_src_make.
478 kde4-base_src_make() {
479 debug-print-function ${FUNCNAME} "$@"
480
481 cmake-utils_src_make "$@"
482 }
483
484 # @FUNCTION: kde4-base_src_test
485 # @DESCRIPTION:
486 # Function for testing KDE4 applications.
487 kde4-base_src_test() {
488 debug-print-function ${FUNCNAME} "$@"
489
490 # Override this value, set in kde4-base_src_configure()
491 mycmakeargs="${mycmakeargs} -DKDE4_BUILD_TESTS=ON"
492 cmake-utils_src_compile
493
494 cmake-utils_src_test
495 }
496
497 # @FUNCTION: kde4-base_src_install
498 # @DESCRIPTION:
499 # Function for installing KDE4 applications.
500 kde4-base_src_install() {
501 debug-print-function ${FUNCNAME} "$@"
502
503 kde4-base_src_make_doc
504 cmake-utils_src_install
505 }
506
507 # @FUNCTION: kde4-base_src_make_doc
508 # @DESCRIPTION:
509 # Function for installing the documentation of KDE4 applications.
510 kde4-base_src_make_doc() {
511 debug-print-function ${FUNCNAME} "$@"
512
513 local doc
514 for doc in AUTHORS ChangeLog* README* NEWS TODO; do
515 [[ -s $doc ]] && dodoc ${doc}
516 done
517
518 if [[ -z ${KMNAME} ]]; then
519 for doc in {apps,runtime,workspace,.}/*/{AUTHORS,README*}; do
520 if [[ -s $doc ]]; then
521 local doc_complete=${doc}
522 doc="${doc#*/}"
523 newdoc "$doc_complete" "${doc%/*}.${doc##*/}"
524 fi
525 done
526 fi
527
528 if [[ -n ${KDEBASE} && -d "${D}"/usr/share/doc/${PF} ]]; then
529 # work around bug #97196
530 dodir /usr/share/doc/kde && \
531 mv "${D}"/usr/share/doc/${PF} "${D}"/usr/share/doc/kde/ || \
532 die "Failed to move docs to kde/ failed."
533 fi
534 }
535
536 # @FUNCTION: kde4-base_pkg_postinst
537 # @DESCRIPTION:
538 # Function to rebuild the KDE System Configuration Cache after an application has been installed.
539 kde4-base_pkg_postinst() {
540 buildsycoca
541 }
542
543 # @FUNCTION: kde4-base_pkg_postrm
544 # @DESCRIPTION:
545 # Function to rebuild the KDE System Configuration Cache after an application has been removed.
546 kde4-base_pkg_postrm() {
547 buildsycoca
548 }

  ViewVC Help
Powered by ViewVC 1.1.20