1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
8 # @BLURB: Support eclass for KDE 5-related packages.
10 # The kde5.eclass provides support for building KDE 5-related packages.
12 if [[ -z ${_KDE5_ECLASS} ]]; then
15 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
17 # For proper description see virtualx.eclass manpage.
18 # Here we redefine default value to be manual, if your package needs virtualx
19 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
20 : ${VIRTUALX_REQUIRED:=manual}
22 inherit kde5-functions fdo-mime flag-o-matic gnome2-utils versionator virtualx eutils cmake-utils
24 if [[ ${KDE_BUILD_TYPE} = live ]]; then
26 svn) inherit subversion ;;
27 git) inherit git-r3 ;;
31 EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm
33 # @ECLASS-VARIABLE: QT_MINIMAL
35 # Minimal Qt version to require for the package.
36 : ${QT_MINIMAL:=5.4.2}
38 # @ECLASS-VARIABLE: KDE_AUTODEPS
40 # If set to "false", do nothing.
41 # For any other value, add a dependency on dev-qt/qtcore:5 and kde-frameworks/extra-cmake-modules:5.
42 : ${KDE_AUTODEPS:=true}
44 # @ECLASS-VARIABLE: KDE_BLOCK_SLOT4
46 # This variable is used when KDE_AUTODEPS is set.
47 # If set to "true", add RDEPEND block on kde-{base,apps}/${PN}:4
48 : ${KDE_BLOCK_SLOT4:=true}
50 # @ECLASS-VARIABLE: KDE_DEBUG
52 # If set to "false", unconditionally build with -DNDEBUG.
53 # Otherwise, add debug to IUSE to control building with that flag.
56 # @ECLASS-VARIABLE: KDE_DOXYGEN
58 # If set to "false", do nothing.
59 # Otherwise, add "doc" to IUSE, add appropriate dependencies, and generate and
60 # install API documentation.
61 if [[ ${CATEGORY} = kde-frameworks ]]; then
62 : ${KDE_DOXYGEN:=true}
64 : ${KDE_DOXYGEN:=false}
67 # @ECLASS-VARIABLE: KDE_DOX_DIR
69 # Defaults to ".". Otherwise, use alternative KDE doxygen path.
72 # @ECLASS-VARIABLE: KDE_EXAMPLES
74 # If set to "false", unconditionally ignore a top-level examples subdirectory.
75 # Otherwise, add "examples" to IUSE to toggle adding that subdirectory.
76 : ${KDE_EXAMPLES:=false}
78 # @ECLASS-VARIABLE: KDE_HANDBOOK
80 # If set to "false", do nothing.
81 # Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and
82 # generate and install KDE handbook.
83 # If set to "forceoptional", remove a KF5DocTools dependency from the root
84 # CMakeLists.txt in addition to the above.
85 : ${KDE_HANDBOOK:=false}
87 # @ECLASS-VARIABLE: KDE_DOC_DIR
89 # Defaults to "doc". Otherwise, use alternative KDE handbook path.
92 # @ECLASS-VARIABLE: KDE_TEST
94 # If set to "false", do nothing.
95 # For any other value, add test to IUSE and add a dependency on dev-qt/qttest:5.
96 # If set to "forceoptional", remove a Qt5Test dependency from the root
97 # CMakeLists.txt in addition to the above.
98 if [[ ${CATEGORY} = kde-frameworks ]]; then
104 # @ECLASS-VARIABLE: KDE_PUNT_BOGUS_DEPS
106 # If set to "false", do nothing.
107 # For any other value, do black magic to make hardcoded-but-optional dependencies
108 # optional again. An upstream solution is preferable and this is a last resort.
109 : ${KDE_PUNT_BOGUS_DEPS:=false}
111 # @ECLASS-VARIABLE: KDE_SELINUX_MODULE
113 # If set to "none", do nothing.
114 # For any other value, add selinux to IUSE, and depending on that useflag
115 # add a dependency on sec-policy/selinux-${KDE_SELINUX_MODULE} to (R)DEPEND.
116 : ${KDE_SELINUX_MODULE:=none}
118 if [[ ${KDEBASE} = kdevelop ]]; then
119 HOMEPAGE="https://www.kdevelop.org/"
121 HOMEPAGE="https://www.kde.org/"
126 if [[ ${CATEGORY} = kde-frameworks ]]; then
127 SLOT=5/$(get_version_component_range 1-2)
132 case ${KDE_AUTODEPS} in
135 if [[ ${KDE_BUILD_TYPE} = live ]]; then
138 FRAMEWORKS_MINIMAL=9999
141 FRAMEWORKS_MINIMAL=9999
147 DEPEND+=" $(add_frameworks_dep extra-cmake-modules)"
148 RDEPEND+=" >=kde-frameworks/kf-env-3"
149 COMMONDEPEND+=" >=dev-qt/qtcore-${QT_MINIMAL}:5"
151 if [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma && ${PN} != polkit-kde-agent ]]; then
153 !kde-apps/kde4-l10n[-minimal(-)]
154 !<kde-apps/kde4-l10n-15.08.0-r1
158 if [[ ${KDE_BLOCK_SLOT4} = true && ${CATEGORY} = kde-apps ]]; then
159 RDEPEND+=" !kde-apps/${PN}:4"
164 case ${KDE_DOXYGEN} in
169 $(add_frameworks_dep kapidox)
182 case ${KDE_EXAMPLES} in
189 case ${KDE_HANDBOOK} in
193 DEPEND+=" handbook? ( $(add_frameworks_dep kdoctools) )"
201 DEPEND+=" test? ( >=dev-qt/qttest-${QT_MINIMAL}:5 )"
205 case ${KDE_SELINUX_MODULE} in
209 RDEPEND+=" selinux? ( sec-policy/selinux-${KDE_SELINUX_MODULE} )"
213 DEPEND+=" ${COMMONDEPEND} dev-util/desktop-file-utils"
214 RDEPEND+=" ${COMMONDEPEND}"
217 if [[ -n ${KMNAME} && ${KMNAME} != ${PN} && ${KDE_BUILD_TYPE} = release ]]; then
218 S=${WORKDIR}/${KMNAME}-${PV}
221 # Determine fetch location for released tarballs
222 _calculate_src_uri() {
223 debug-print-function ${FUNCNAME} "$@"
227 if [[ -n ${KMNAME} ]]; then
241 _kmname="portingAids/${_kmname}"
245 DEPEND+=" app-arch/xz-utils"
250 ??.?.[6-9]? | ??.??.[6-9]? )
251 SRC_URI="mirror://kde/unstable/applications/${PV}/src/${_kmname}-${PV}.tar.xz"
255 SRC_URI="mirror://kde/stable/applications/${PV}/src/${_kmname}-${PV}.tar.xz" ;;
259 SRC_URI="mirror://kde/stable/frameworks/${PV%.*}/${_kmname}-${PV}.tar.xz" ;;
261 local plasmapv=$(get_version_component_range 1-3)
265 # Plasma 5 beta releases
266 SRC_URI="mirror://kde/unstable/plasma/${plasmapv}/${_kmname}-${PV}.tar.xz"
270 # Plasma 5 stable releases
271 SRC_URI="mirror://kde/stable/plasma/${plasmapv}/${_kmname}-${PV}.tar.xz" ;;
277 # Determine fetch location for live sources
278 _calculate_live_repo() {
279 debug-print-function ${FUNCNAME} "$@"
285 # @ECLASS-VARIABLE: ESVN_MIRROR
287 # This variable allows easy overriding of default kde mirror service
288 # (anonsvn) with anything else you might want to use.
289 ESVN_MIRROR=${ESVN_MIRROR:=svn://anonsvn.kde.org/home/kde}
291 local branch_prefix="trunk/KDE"
293 if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
294 branch_prefix="branches/Applications/$(get_version_component_range 1-2)"
297 if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
298 branch_prefix="branches/plasma/$(get_version_component_range 1-2)"
303 if [[ -n ${KMNAME} ]]; then
309 ESVN_REPO_URI="${ESVN_MIRROR}/${branch_prefix}/${_kmname}"
312 # @ECLASS-VARIABLE: EGIT_MIRROR
314 # This variable allows easy overriding of default kde mirror service
315 # (anongit) with anything else you might want to use.
316 EGIT_MIRROR=${EGIT_MIRROR:=git://anongit.kde.org}
320 # @ECLASS-VARIABLE: EGIT_REPONAME
322 # This variable allows overriding of default repository
323 # name. Specify only if this differ from PN and KMNAME.
324 if [[ -n ${EGIT_REPONAME} ]]; then
325 # the repository and kmname different
326 _kmname=${EGIT_REPONAME}
327 elif [[ -n ${KMNAME} ]]; then
333 if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
334 EGIT_BRANCH="Applications/$(get_version_component_range 1-2)"
337 if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
338 EGIT_BRANCH="Plasma/$(get_version_component_range 1-2)"
341 EGIT_REPO_URI="${EGIT_MIRROR}/${_kmname}"
346 case ${KDE_BUILD_TYPE} in
347 live) _calculate_live_repo ;;
348 *) _calculate_src_uri ;;
351 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
353 # @FUNCTION: kde5_pkg_pretend
355 # Do some basic settings
357 debug-print-function ${FUNCNAME} "$@"
358 if [[ ${MERGE_TYPE} != binary ]]; then
363 # @FUNCTION: kde5_pkg_setup
365 # Do some basic settings
367 debug-print-function ${FUNCNAME} "$@"
368 if [[ ${MERGE_TYPE} != binary ]]; then
373 # @FUNCTION: kde5_src_unpack
375 # Function for unpacking KDE 5.
377 debug-print-function ${FUNCNAME} "$@"
379 if [[ ${KDE_BUILD_TYPE} = live ]]; then
382 subversion_src_unpack
393 # @FUNCTION: kde5_src_prepare
395 # Function for preparing the KDE 5 sources.
397 debug-print-function ${FUNCNAME} "$@"
399 cmake-utils_src_prepare
401 # only build examples when required
402 if ! use_if_iuse examples || ! use examples ; then
403 comment_add_subdirectory examples
406 # only enable handbook when required
407 if ! use_if_iuse handbook ; then
408 comment_add_subdirectory ${KDE_DOC_DIR}
410 if [[ ${KDE_HANDBOOK} = forceoptional ]] ; then
411 punt_bogus_dep KF5 DocTools
415 # enable only the requested translations
417 if [[ ${KDE_BUILD_TYPE} = release ]] ; then
418 if [[ -d po ]] ; then
419 pushd po > /dev/null || die
421 if ! has ${lang} ${LINGUAS} ; then
422 if [[ ${lang} != CMakeLists.txt ]] ; then
425 if [[ -e CMakeLists.txt ]] ; then
426 comment_add_subdirectory ${lang}
430 popd > /dev/null || die
433 if [[ ${KDE_HANDBOOK} != false && -d ${KDE_DOC_DIR} && ${CATEGORY} != kde-apps ]] ; then
434 pushd ${KDE_DOC_DIR} > /dev/null || die
436 if ! has ${lang} ${LINGUAS} ; then
437 comment_add_subdirectory ${lang}
440 popd > /dev/null || die
446 # in frameworks, tests = manual tests so never build them
447 if [[ ${CATEGORY} = kde-frameworks ]]; then
448 comment_add_subdirectory tests
451 case ${KDE_PUNT_BOGUS_DEPS} in
454 if ! use_if_iuse test ; then
455 punt_bogus_dep Qt5 Test
457 if ! use_if_iuse handbook ; then
458 punt_bogus_dep KF5 DocTools
463 # only build unit tests when required
464 if ! use_if_iuse test ; then
465 if [[ ${KDE_TEST} = forceoptional ]] ; then
466 punt_bogus_dep Qt5 Test
467 # if forceoptional, also cover non-kde categories
468 comment_add_subdirectory autotests
469 comment_add_subdirectory test
470 comment_add_subdirectory tests
471 elif [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma || ${CATEGORY} = kde-apps ]] ; then
472 comment_add_subdirectory autotests
473 comment_add_subdirectory test
474 comment_add_subdirectory tests
479 # @FUNCTION: kde5_src_configure
481 # Function for configuring the build of KDE 5.
482 kde5_src_configure() {
483 debug-print-function ${FUNCNAME} "$@"
485 # we rely on cmake-utils.eclass to append -DNDEBUG too
486 if ! use_if_iuse debug; then
487 append-cppflags -DQT_NO_DEBUG
492 if ! use_if_iuse test ; then
493 cmakeargs+=( -DBUILD_TESTING=OFF )
496 # install mkspecs in the same directory as qt stuff
497 cmakeargs+=(-DKDE_INSTALL_USE_QT_SYS_PATHS=ON)
499 # allow the ebuild to override what we set here
500 mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}")
502 cmake-utils_src_configure
505 # @FUNCTION: kde5_src_compile
507 # Function for compiling KDE 5.
509 debug-print-function ${FUNCNAME} "$@"
511 cmake-utils_src_compile "$@"
513 # Build doxygen documentation if applicable
514 if use_if_iuse doc ; then
515 kgenapidox ${KDE_DOX_DIR} || die
519 # @FUNCTION: kde5_src_test
521 # Function for testing KDE 5.
523 debug-print-function ${FUNCNAME} "$@"
526 if [[ -n "${VIRTUALDBUS_TEST}" ]]; then
527 export $(dbus-launch)
533 # When run as normal user during ebuild development with the ebuild command, the
534 # kde tests tend to access the session DBUS. This however is not possible in a real
535 # emerge or on the tinderbox.
536 # > make sure it does not happen, so bad tests can be recognized and disabled
537 unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
539 if [[ ${VIRTUALX_REQUIRED} = always || ${VIRTUALX_REQUIRED} = test ]]; then
540 VIRTUALX_COMMAND="_test_runner" virtualmake
545 if [[ -n "${DBUS_SESSION_BUS_PID}" ]] ; then
546 kill ${DBUS_SESSION_BUS_PID}
550 # @FUNCTION: kde5_src_install
552 # Function for installing KDE 5.
554 debug-print-function ${FUNCNAME} "$@"
556 # Install doxygen documentation if applicable
557 if use_if_iuse doc ; then
558 dodoc -r apidocs/html
561 cmake-utils_src_install
563 # We don't want ${PREFIX}/share/doc/HTML to be compressed,
564 # because then khelpcenter can't find the docs
565 if [[ -d ${ED}/${PREFIX}/share/doc/HTML ]]; then
566 docompress -x ${PREFIX}/share/doc/HTML
570 # @FUNCTION: kde5_pkg_preinst
572 # Function storing icon caches
574 debug-print-function ${FUNCNAME} "$@"
579 # @FUNCTION: kde5_pkg_postinst
581 # Function to rebuild the KDE System Configuration Cache after an application has been installed.
582 kde5_pkg_postinst() {
583 debug-print-function ${FUNCNAME} "$@"
585 gnome2_icon_cache_update
586 fdo-mime_desktop_database_update
589 # @FUNCTION: kde5_pkg_postrm
591 # Function to rebuild the KDE System Configuration Cache after an application has been removed.
593 debug-print-function ${FUNCNAME} "$@"
595 gnome2_icon_cache_update
596 fdo-mime_desktop_database_update