1 # Copyright 1999-2015 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" ;;
263 # Plasma 5 beta releases
264 SRC_URI="mirror://kde/unstable/plasma/${PV}/${_kmname}-${PV}.tar.xz"
268 # Plasma 5 stable releases
269 SRC_URI="mirror://kde/stable/plasma/${PV}/${_kmname}-${PV}.tar.xz" ;;
275 # Determine fetch location for live sources
276 _calculate_live_repo() {
277 debug-print-function ${FUNCNAME} "$@"
283 # @ECLASS-VARIABLE: ESVN_MIRROR
285 # This variable allows easy overriding of default kde mirror service
286 # (anonsvn) with anything else you might want to use.
287 ESVN_MIRROR=${ESVN_MIRROR:=svn://anonsvn.kde.org/home/kde}
289 local branch_prefix="trunk/KDE"
291 if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
292 branch_prefix="branches/Applications/$(get_version_component_range 1-2)"
295 if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
296 branch_prefix="branches/plasma/$(get_version_component_range 1-2)"
301 if [[ -n ${KMNAME} ]]; then
307 ESVN_REPO_URI="${ESVN_MIRROR}/${branch_prefix}/${_kmname}"
310 # @ECLASS-VARIABLE: EGIT_MIRROR
312 # This variable allows easy overriding of default kde mirror service
313 # (anongit) with anything else you might want to use.
314 EGIT_MIRROR=${EGIT_MIRROR:=git://anongit.kde.org}
318 # @ECLASS-VARIABLE: EGIT_REPONAME
320 # This variable allows overriding of default repository
321 # name. Specify only if this differ from PN and KMNAME.
322 if [[ -n ${EGIT_REPONAME} ]]; then
323 # the repository and kmname different
324 _kmname=${EGIT_REPONAME}
325 elif [[ -n ${KMNAME} ]]; then
331 if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
332 EGIT_BRANCH="Applications/$(get_version_component_range 1-2)"
335 if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
336 EGIT_BRANCH="Plasma/$(get_version_component_range 1-2)"
339 EGIT_REPO_URI="${EGIT_MIRROR}/${_kmname}"
344 case ${KDE_BUILD_TYPE} in
345 live) _calculate_live_repo ;;
346 *) _calculate_src_uri ;;
349 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
351 # @FUNCTION: kde5_pkg_pretend
353 # Do some basic settings
355 debug-print-function ${FUNCNAME} "$@"
356 if [[ ${MERGE_TYPE} != binary ]]; then
361 # @FUNCTION: kde5_pkg_setup
363 # Do some basic settings
365 debug-print-function ${FUNCNAME} "$@"
366 if [[ ${MERGE_TYPE} != binary ]]; then
371 # @FUNCTION: kde5_src_unpack
373 # Function for unpacking KDE 5.
375 debug-print-function ${FUNCNAME} "$@"
377 if [[ ${KDE_BUILD_TYPE} = live ]]; then
380 subversion_src_unpack
391 # @FUNCTION: kde5_src_prepare
393 # Function for preparing the KDE 5 sources.
395 debug-print-function ${FUNCNAME} "$@"
397 # only build examples when required
398 if ! use_if_iuse examples || ! use examples ; then
399 comment_add_subdirectory examples
402 # only enable handbook when required
403 if ! use_if_iuse handbook ; then
404 comment_add_subdirectory ${KDE_DOC_DIR}
407 # enable only the requested translations
409 if [[ ${KDE_BUILD_TYPE} = release ]] ; then
410 if [[ -d po ]] ; then
411 pushd po > /dev/null || die
413 if ! has ${lang} ${LINGUAS} ; then
414 if [[ ${lang} != CMakeLists.txt ]] ; then
417 if [[ -e CMakeLists.txt ]] ; then
418 comment_add_subdirectory ${lang}
422 popd > /dev/null || die
425 if [[ ${KDE_HANDBOOK} != false && -d ${KDE_DOC_DIR} && ${CATEGORY} != kde-apps ]] ; then
426 pushd ${KDE_DOC_DIR} > /dev/null || die
428 if ! has ${lang} ${LINGUAS} ; then
429 comment_add_subdirectory ${lang}
432 popd > /dev/null || die
438 # in frameworks, tests = manual tests so never
440 if [[ ${CATEGORY} = kde-frameworks ]]; then
441 comment_add_subdirectory tests
444 if [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma || ${CATEGORY} = kde-apps ]] ; then
445 # only build unit tests when required
446 if ! use_if_iuse test ; then
447 comment_add_subdirectory autotests
448 comment_add_subdirectory test
449 comment_add_subdirectory tests
453 case ${KDE_PUNT_BOGUS_DEPS} in
456 if ! use_if_iuse test ; then
457 punt_bogus_dep Qt5 Test
459 if ! use_if_iuse handbook ; then
460 punt_bogus_dep KF5 DocTools
465 if [[ ${KDE_HANDBOOK} = forceoptional ]] ; then
466 if ! use_if_iuse handbook ; then
467 punt_bogus_dep KF5 DocTools
471 if [[ ${KDE_TEST} = forceoptional ]] ; then
472 if ! use_if_iuse test ; then
473 punt_bogus_dep Qt5 Test
477 cmake-utils_src_prepare
480 # @FUNCTION: kde5_src_configure
482 # Function for configuring the build of KDE 5.
483 kde5_src_configure() {
484 debug-print-function ${FUNCNAME} "$@"
486 # we rely on cmake-utils.eclass to append -DNDEBUG too
487 if ! use_if_iuse debug; then
488 append-cppflags -DQT_NO_DEBUG
493 if ! use_if_iuse test ; then
494 cmakeargs+=( -DBUILD_TESTING=OFF )
497 # install mkspecs in the same directory as qt stuff
498 cmakeargs+=(-DKDE_INSTALL_USE_QT_SYS_PATHS=ON)
500 # allow the ebuild to override what we set here
501 mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}")
503 cmake-utils_src_configure
506 # @FUNCTION: kde5_src_compile
508 # Function for compiling KDE 5.
510 debug-print-function ${FUNCNAME} "$@"
512 cmake-utils_src_compile "$@"
514 # Build doxygen documentation if applicable
515 if use_if_iuse doc ; then
516 kgenapidox ${KDE_DOX_DIR} || die
520 # @FUNCTION: kde5_src_test
522 # Function for testing KDE 5.
524 debug-print-function ${FUNCNAME} "$@"
527 if [[ -n "${VIRTUALDBUS_TEST}" ]]; then
528 export $(dbus-launch)
534 # When run as normal user during ebuild development with the ebuild command, the
535 # kde tests tend to access the session DBUS. This however is not possible in a real
536 # emerge or on the tinderbox.
537 # > make sure it does not happen, so bad tests can be recognized and disabled
538 unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
540 if [[ ${VIRTUALX_REQUIRED} = always || ${VIRTUALX_REQUIRED} = test ]]; then
541 VIRTUALX_COMMAND="_test_runner" virtualmake
546 if [[ -n "${DBUS_SESSION_BUS_PID}" ]] ; then
547 kill ${DBUS_SESSION_BUS_PID}
551 # @FUNCTION: kde5_src_install
553 # Function for installing KDE 5.
555 debug-print-function ${FUNCNAME} "$@"
557 # Install doxygen documentation if applicable
558 if use_if_iuse doc ; then
559 dodoc -r apidocs/html
562 cmake-utils_src_install
564 # We don't want ${PREFIX}/share/doc/HTML to be compressed,
565 # because then khelpcenter can't find the docs
566 if [[ -d ${ED}/${PREFIX}/share/doc/HTML ]]; then
567 docompress -x ${PREFIX}/share/doc/HTML
571 # @FUNCTION: kde5_pkg_preinst
573 # Function storing icon caches
575 debug-print-function ${FUNCNAME} "$@"
580 # @FUNCTION: kde5_pkg_postinst
582 # Function to rebuild the KDE System Configuration Cache after an application has been installed.
583 kde5_pkg_postinst() {
584 debug-print-function ${FUNCNAME} "$@"
586 gnome2_icon_cache_update
587 fdo-mime_desktop_database_update
590 # @FUNCTION: kde5_pkg_postrm
592 # Function to rebuild the KDE System Configuration Cache after an application has been removed.
594 debug-print-function ${FUNCNAME} "$@"
596 gnome2_icon_cache_update
597 fdo-mime_desktop_database_update