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.1}
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_EXAMPLES
69 # If set to "false", unconditionally ignore a top-level examples subdirectory.
70 # Otherwise, add "examples" to IUSE to toggle adding that subdirectory.
71 : ${KDE_EXAMPLES:=false}
73 # @ECLASS-VARIABLE: KDE_HANDBOOK
75 # If set to "false", do nothing.
76 # Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and
77 # generate and install KDE handbook.
78 : ${KDE_HANDBOOK:=false}
80 # @ECLASS-VARIABLE: KDE_DOC_DIR
82 # Defaults to "doc". Otherwise, use alternative KDE handbook path.
85 # @ECLASS-VARIABLE: KDE_TEST
87 # If set to "false", do nothing.
88 # For any other value, add test to IUSE and add a dependency on dev-qt/qttest:5.
89 if [[ ${CATEGORY} = kde-frameworks ]]; then
95 # @ECLASS-VARIABLE: KDE_PUNT_BOGUS_DEPS
97 # If set to "false", do nothing.
98 # For any other value, do black magic to make hardcoded-but-optional dependencies
99 # optional again. An upstream solution is preferable and this is a last resort.
100 : ${KDE_PUNT_BOGUS_DEPS:=false}
102 # @ECLASS-VARIABLE: KDE_SELINUX_MODULE
104 # If set to "none", do nothing.
105 # For any other value, add selinux to IUSE, and depending on that useflag
106 # add a dependency on sec-policy/selinux-${KDE_SELINUX_MODULE} to (R)DEPEND.
107 : ${KDE_SELINUX_MODULE:=none}
109 if [[ ${KDEBASE} = kdevelop ]]; then
110 HOMEPAGE="https://www.kdevelop.org/"
112 HOMEPAGE="https://www.kde.org/"
117 if [[ ${CATEGORY} = kde-frameworks ]]; then
118 SLOT=5/$(get_version_component_range 1-2)
123 case ${KDE_AUTODEPS} in
126 if [[ ${KDE_BUILD_TYPE} = live ]]; then
129 FRAMEWORKS_MINIMAL=9999
132 FRAMEWORKS_MINIMAL=9999
138 DEPEND+=" $(add_frameworks_dep extra-cmake-modules)"
139 RDEPEND+=" >=kde-frameworks/kf-env-3"
140 COMMONDEPEND+=" >=dev-qt/qtcore-${QT_MINIMAL}:5"
142 if [[ ${CATEGORY} = kde-plasma && ${PN} != polkit-kde-agent ]]; then
144 !kde-apps/kde4-l10n[-minimal(-)]
148 if [[ ${KDE_BLOCK_SLOT4} = true && ${CATEGORY} = kde-apps ]]; then
149 RDEPEND+=" !kde-apps/${PN}:4"
154 case ${KDE_DOXYGEN} in
159 $(add_frameworks_dep kapidox)
172 case ${KDE_EXAMPLES} in
179 case ${KDE_HANDBOOK} in
183 DEPEND+=" handbook? ( $(add_frameworks_dep kdoctools) )"
191 DEPEND+=" test? ( >=dev-qt/qttest-${QT_MINIMAL}:5 )"
195 case ${KDE_SELINUX_MODULE} in
199 RDEPEND+=" selinux? ( sec-policy/selinux-${KDE_SELINUX_MODULE} )"
203 DEPEND+=" ${COMMONDEPEND} dev-util/desktop-file-utils"
204 RDEPEND+=" ${COMMONDEPEND}"
207 if [[ -n ${KMNAME} && ${KMNAME} != ${PN} && ${KDE_BUILD_TYPE} = release ]]; then
208 S=${WORKDIR}/${KMNAME}-${PV}
211 # Determine fetch location for released tarballs
212 _calculate_src_uri() {
213 debug-print-function ${FUNCNAME} "$@"
217 if [[ -n ${KMNAME} ]]; then
231 _kmname="portingAids/${_kmname}"
235 DEPEND+=" app-arch/xz-utils"
240 ??.?.[6-9]? | ??.??.[6-9]? )
241 SRC_URI="mirror://kde/unstable/applications/${PV}/src/${_kmname}-${PV}.tar.xz"
245 SRC_URI="mirror://kde/stable/applications/${PV}/src/${_kmname}-${PV}.tar.xz" ;;
249 SRC_URI="mirror://kde/stable/frameworks/${PV%.*}/${_kmname}-${PV}.tar.xz" ;;
253 # Plasma 5 beta releases
254 SRC_URI="mirror://kde/unstable/plasma/${PV}/${_kmname}-${PV}.tar.xz"
258 # Plasma 5 stable releases
259 SRC_URI="mirror://kde/stable/plasma/${PV}/${_kmname}-${PV}.tar.xz" ;;
265 # Determine fetch location for live sources
266 _calculate_live_repo() {
267 debug-print-function ${FUNCNAME} "$@"
273 # @ECLASS-VARIABLE: ESVN_MIRROR
275 # This variable allows easy overriding of default kde mirror service
276 # (anonsvn) with anything else you might want to use.
277 ESVN_MIRROR=${ESVN_MIRROR:=svn://anonsvn.kde.org/home/kde}
279 local branch_prefix="trunk/KDE"
281 if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
282 branch_prefix="branches/Applications/$(get_version_component_range 1-2)"
285 if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
286 branch_prefix="branches/plasma/$(get_version_component_range 1-2)"
291 if [[ -n ${KMNAME} ]]; then
297 ESVN_REPO_URI="${ESVN_MIRROR}/${branch_prefix}/${_kmname}"
300 # @ECLASS-VARIABLE: EGIT_MIRROR
302 # This variable allows easy overriding of default kde mirror service
303 # (anongit) with anything else you might want to use.
304 EGIT_MIRROR=${EGIT_MIRROR:=git://anongit.kde.org}
308 # @ECLASS-VARIABLE: EGIT_REPONAME
310 # This variable allows overriding of default repository
311 # name. Specify only if this differ from PN and KMNAME.
312 if [[ -n ${EGIT_REPONAME} ]]; then
313 # the repository and kmname different
314 _kmname=${EGIT_REPONAME}
315 elif [[ -n ${KMNAME} ]]; then
321 if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
322 EGIT_BRANCH="Plasma/$(get_version_component_range 1-2)"
325 EGIT_REPO_URI="${EGIT_MIRROR}/${_kmname}"
330 case ${KDE_BUILD_TYPE} in
331 live) _calculate_live_repo ;;
332 *) _calculate_src_uri ;;
335 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
337 # @FUNCTION: kde5_pkg_pretend
339 # Do some basic settings
341 debug-print-function ${FUNCNAME} "$@"
345 # @FUNCTION: kde5_pkg_setup
347 # Do some basic settings
349 debug-print-function ${FUNCNAME} "$@"
353 # @FUNCTION: kde5_src_unpack
355 # Function for unpacking KDE 5.
357 debug-print-function ${FUNCNAME} "$@"
359 if [[ ${KDE_BUILD_TYPE} = live ]]; then
362 subversion_src_unpack
373 # @FUNCTION: kde5_src_prepare
375 # Function for preparing the KDE 5 sources.
377 debug-print-function ${FUNCNAME} "$@"
379 # only build examples when required
380 if ! use_if_iuse examples || ! use examples ; then
381 comment_add_subdirectory examples
384 # only enable handbook when required
385 if ! use_if_iuse handbook ; then
386 comment_add_subdirectory ${KDE_DOC_DIR}
389 # enable only the requested translations
391 if [[ ${KDE_BUILD_TYPE} = release ]] ; then
392 if [[ -d po ]] ; then
395 if ! has ${lang} ${LINGUAS} ; then
396 if [[ ${lang} != CMakeLists.txt ]] ; then
399 if [[ -e CMakeLists.txt ]] ; then
400 comment_add_subdirectory ${lang}
407 if [[ ${KDE_HANDBOOK} = true && -d ${KDE_DOC_DIR} && ${CATEGORY} != kde-apps ]] ; then
408 pushd ${KDE_DOC_DIR} > /dev/null
410 if ! has ${lang} ${LINGUAS} ; then
411 comment_add_subdirectory ${lang}
420 # in frameworks, tests = manual tests so never
422 if [[ ${CATEGORY} = kde-frameworks ]]; then
423 comment_add_subdirectory tests
426 if [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma || ${CATEGORY} = kde-apps ]] ; then
427 # only build unit tests when required
428 if ! use_if_iuse test ; then
429 comment_add_subdirectory autotests
430 comment_add_subdirectory test
431 comment_add_subdirectory tests
435 case ${KDE_PUNT_BOGUS_DEPS} in
438 if ! use_if_iuse test ; then
439 punt_bogus_dep Qt5 Test
441 if ! use_if_iuse handbook ; then
442 punt_bogus_dep KF5 DocTools
447 cmake-utils_src_prepare
450 # @FUNCTION: kde5_src_configure
452 # Function for configuring the build of KDE 5.
453 kde5_src_configure() {
454 debug-print-function ${FUNCNAME} "$@"
456 # we rely on cmake-utils.eclass to append -DNDEBUG too
457 if ! use_if_iuse debug; then
458 append-cppflags -DQT_NO_DEBUG
463 if ! use_if_iuse test ; then
464 cmakeargs+=( -DBUILD_TESTING=OFF )
467 # install mkspecs in the same directory as qt stuff
468 cmakeargs+=(-DKDE_INSTALL_USE_QT_SYS_PATHS=ON)
470 # allow the ebuild to override what we set here
471 mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}")
473 cmake-utils_src_configure
476 # @FUNCTION: kde5_src_compile
478 # Function for compiling KDE 5.
480 debug-print-function ${FUNCNAME} "$@"
482 cmake-utils_src_compile "$@"
484 # Build doxygen documentation if applicable
485 if use_if_iuse doc ; then
490 # @FUNCTION: kde5_src_test
492 # Function for testing KDE 5.
494 debug-print-function ${FUNCNAME} "$@"
497 if [[ -n "${VIRTUALDBUS_TEST}" ]]; then
498 export $(dbus-launch)
504 # When run as normal user during ebuild development with the ebuild command, the
505 # kde tests tend to access the session DBUS. This however is not possible in a real
506 # emerge or on the tinderbox.
507 # > make sure it does not happen, so bad tests can be recognized and disabled
508 unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
510 if [[ ${VIRTUALX_REQUIRED} = always || ${VIRTUALX_REQUIRED} = test ]]; then
511 VIRTUALX_COMMAND="_test_runner" virtualmake
516 if [[ -n "${DBUS_SESSION_BUS_PID}" ]] ; then
517 kill ${DBUS_SESSION_BUS_PID}
521 # @FUNCTION: kde5_src_install
523 # Function for installing KDE 5.
525 debug-print-function ${FUNCNAME} "$@"
527 # Install doxygen documentation if applicable
528 if use_if_iuse doc ; then
529 dodoc -r apidocs/html
532 cmake-utils_src_install
534 # We don't want ${PREFIX}/share/doc/HTML to be compressed,
535 # because then khelpcenter can't find the docs
536 if [[ -d ${ED}/${PREFIX}/share/doc/HTML ]]; then
537 docompress -x ${PREFIX}/share/doc/HTML
541 # @FUNCTION: kde5_pkg_preinst
543 # Function storing icon caches
545 debug-print-function ${FUNCNAME} "$@"
550 # @FUNCTION: kde5_pkg_postinst
552 # Function to rebuild the KDE System Configuration Cache after an application has been installed.
553 kde5_pkg_postinst() {
554 debug-print-function ${FUNCNAME} "$@"
556 gnome2_icon_cache_update
557 fdo-mime_desktop_database_update
560 # @FUNCTION: kde5_pkg_postrm
562 # Function to rebuild the KDE System Configuration Cache after an application has been removed.
564 debug-print-function ${FUNCNAME} "$@"
566 gnome2_icon_cache_update
567 fdo-mime_desktop_database_update