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

Contents of /eclass/kde4-base.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Thu Apr 3 18:12:48 2008 UTC (6 years, 4 months ago) by philantrop
Branch: MAIN
Changes since 1.6: +102 -58 lines
Added support for EAPI=kdebuild-1. Hard depend on qt-4.4.x when PV >= 4.1.

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.6 2008/03/26 20:39:05 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 gets applied.
354 kde4-base_apply_patches() {
355 local _patchdir _packages _p
356 _patchdir="${WORKDIR}/patches/"
357 if [[ -d "${_patchdir}" ]]; then
358 if is-parent-package ${CATEGORY}/${PN} ; then
359 _packages="$(get-child-packages ${CATEGORY}/${PN})"
360 _packages="${_packages//${CATEGORY}\//} ${PN}"
361 else
362 _packages="${PN}"
363 fi
364 for _p in ${_packages}; do
365 PATCHES="${PATCHES} $(ls ${_patchdir}/${_p}-${PV}-*{diff,patch} 2>/dev/null)"
366 if [[ -n "${KDEBASE}" ]]; then
367 PATCHES="${PATCHES} $(ls ${_patchdir}/${_p}-${SLOT}-*{diff,patch} 2>/dev/null)"
368 fi
369 done
370 fi
371 [[ -n ${PATCHES} ]] && base_src_unpack autopatch
372 }
373
374 # @FUNCTION: kde4-base_src_unpack
375 # @DESCRIPTION:
376 # This function unpacks the source tarballs for KDE4 applications.
377 #
378 # If no argument is passed to this function, then standard src_unpack is
379 # executed. Otherwise options are passed to base_src_unpack.
380 #
381 # In addition it calls kde4-base_apply_patches when no arguments are passed to
382 # this function.
383 kde4-base_src_unpack() {
384 debug-print-function $FUNCNAME "$@"
385
386 [[ -z "${KDE_S}" ]] && KDE_S="${S}"
387
388 if [[ -z $* ]]; then
389 # Unpack first and deal with KDE patches after examing possible patch sets.
390 # To be picked up, patches need to conform to the guidelines stated before.
391 # Monolithic ebuilds will use the split ebuild patches.
392 [[ -d "${KDE_S}" ]] || unpack ${A}
393 kde4-base_apply_patches
394 else
395 # Call base_src_unpack, which unpacks and patches
396 # step by step transparently as defined in the ebuild.
397 base_src_unpack $*
398 fi
399
400 # Updated cmake dir
401 if [[ -d "${WORKDIR}/cmake" ]] && [[ -d "${KDE_S}/cmake" ]]; then
402 ebegin "Updating cmake/ directory..."
403 rm -rf "${KDE_S}/cmake" || die "Unable to remove old cmake/ directory"
404 ln -s "${WORKDIR}/cmake" "${KDE_S}/cmake" || die "Unable to symlink the new cmake/ directory"
405 eend 0
406 fi
407 }
408
409 # @FUNCTION: kde4-base_src_compile
410 # @DESCRIPTION:
411 # General function for compiling KDE4 applications.
412 kde4-base_src_compile() {
413 debug-print-function ${FUNCNAME} "$@"
414
415 kde4-base_src_configure
416 kde4-base_src_make
417 }
418
419 # @FUNCTION: kde4-base_src_configure
420 # @DESCRIPTION:
421 # Function for configuring the build of KDE4 applications.
422 kde4-base_src_configure() {
423 debug-print-function ${FUNCNAME} "$@"
424
425 # Final flag handling
426 if has kdeenablefinal ${IUSE//+} && use kdeenablefinal; then
427 echo "Activating enable-final flag"
428 mycmakeargs="${mycmakeargs} -DKDE4_ENABLE_FINAL=ON"
429 fi
430
431 # Enable generation of HTML handbook
432 if has htmlhandbook ${IUSE//+} && use htmlhandbook; then
433 echo "Enabling building of HTML handbook"
434 mycmakeargs="${mycmakeargs} -DKDE4_ENABLE_HTMLHANDBOOK=ON"
435 fi
436
437 # Build tests in src_test only, where we override this value
438 mycmakeargs="${mycmakeargs} -DKDE4_BUILD_TESTS=OFF"
439
440 # Set distribution name
441 [[ ${PN} == "kdelibs" ]] && mycmakeargs="${mycmakeargs} -DKDE_DISTRIBUTION_TEXT=Gentoo"
442
443 # runpath linking
444 mycmakeargs="${mycmakeargs} -DKDE4_USE_ALWAYS_FULL_RPATH=ON"
445
446 # Here we set the install prefix
447 mycmakeargs="${mycmakeargs} -DCMAKE_INSTALL_PREFIX=${PREFIX}"
448
449 # Set environment
450 QTEST_COLORED=1
451 QT_PLUGIN_PATH=${KDEDIR}/$(get_libdir)/kde4/plugins/
452
453 cmake-utils_src_configureout
454 }
455
456 # @FUNCTION: kde4-base_src_make
457 # @DESCRIPTION:
458 # Function for building KDE4 applications.
459 # Options are passed to cmake-utils_src_make.
460 kde4-base_src_make() {
461 debug-print-function ${FUNCNAME} "$@"
462
463 cmake-utils_src_make "$@"
464 }
465
466 # @FUNCTION: kde4-base_src_test
467 # @DESCRIPTION:
468 # Function for testing KDE4 applications.
469 kde4-base_src_test() {
470 debug-print-function ${FUNCNAME} "$@"
471
472 # Override this value, set in kde4-base_src_configure()
473 mycmakeargs="${mycmakeargs} -DKDE4_BUILD_TESTS=ON"
474 cmake-utils_src_compile
475
476 cmake-utils_src_test
477 }
478
479 # @FUNCTION: kde4-base_src_install
480 # @DESCRIPTION:
481 # Function for installing KDE4 applications.
482 kde4-base_src_install() {
483 debug-print-function ${FUNCNAME} "$@"
484
485 kde4-base_src_make_doc
486 cmake-utils_src_install
487 }
488
489 # @FUNCTION: kde4-base_src_make_doc
490 # @DESCRIPTION:
491 # Function for installing the documentation of KDE4 applications.
492 kde4-base_src_make_doc() {
493 debug-print-function ${FUNCNAME} "$@"
494
495 local doc
496 for doc in AUTHORS ChangeLog* README* NEWS TODO; do
497 [[ -s $doc ]] && dodoc ${doc}
498 done
499
500 if [[ -z ${KMNAME} ]]; then
501 for doc in {apps,runtime,workspace,.}/*/{AUTHORS,README*}; do
502 if [[ -s $doc ]]; then
503 local doc_complete=${doc}
504 doc="${doc#*/}"
505 newdoc "$doc_complete" "${doc%/*}.${doc##*/}"
506 fi
507 done
508 fi
509
510 if [[ -n ${KDEBASE} && -d "${D}"/usr/share/doc/${PF} ]]; then
511 # work around bug #97196
512 dodir /usr/share/doc/kde && \
513 mv "${D}"/usr/share/doc/${PF} "${D}"/usr/share/doc/kde/ || \
514 die "Failed to move docs to kde/ failed."
515 fi
516 }
517
518 # @FUNCTION: kde4-base_pkg_postinst
519 # @DESCRIPTION:
520 # Function to rebuild the KDE System Configuration Cache after an application has been installed.
521 kde4-base_pkg_postinst() {
522 buildsycoca
523 }
524
525 # @FUNCTION: kde4-base_pkg_postrm
526 # @DESCRIPTION:
527 # Function to rebuild the KDE System Configuration Cache after an application has been removed.
528 kde4-base_pkg_postrm() {
529 buildsycoca
530 }

  ViewVC Help
Powered by ViewVC 1.1.20