# Copyright 1999-2016 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ # @ECLASS: kde5.eclass # @MAINTAINER: # kde@gentoo.org # @BLURB: Support eclass for KDE 5-related packages. # @DESCRIPTION: # The kde5.eclass provides support for building KDE 5-related packages. if [[ -z ${_KDE5_ECLASS} ]]; then _KDE5_ECLASS=1 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED # @DESCRIPTION: # For proper description see virtualx.eclass manpage. # Here we redefine default value to be manual, if your package needs virtualx # for tests you should proceed with setting VIRTUALX_REQUIRED=test. : ${VIRTUALX_REQUIRED:=manual} inherit kde5-functions fdo-mime flag-o-matic gnome2-utils versionator virtualx eutils cmake-utils if [[ ${KDE_BUILD_TYPE} = live ]]; then case ${KDE_SCM} in svn) inherit subversion ;; git) inherit git-r3 ;; esac fi EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm # @ECLASS-VARIABLE: QT_MINIMAL # @DESCRIPTION: # Minimal Qt version to require for the package. : ${QT_MINIMAL:=5.4.2} # @ECLASS-VARIABLE: KDE_AUTODEPS # @DESCRIPTION: # If set to "false", do nothing. # For any other value, add a dependency on dev-qt/qtcore:5 and kde-frameworks/extra-cmake-modules:5. : ${KDE_AUTODEPS:=true} # @ECLASS-VARIABLE: KDE_BLOCK_SLOT4 # @DESCRIPTION: # This variable is used when KDE_AUTODEPS is set. # If set to "true", add RDEPEND block on kde-{base,apps}/${PN}:4 : ${KDE_BLOCK_SLOT4:=true} # @ECLASS-VARIABLE: KDE_DEBUG # @DESCRIPTION: # If set to "false", unconditionally build with -DNDEBUG. # Otherwise, add debug to IUSE to control building with that flag. : ${KDE_DEBUG:=true} # @ECLASS-VARIABLE: KDE_DOXYGEN # @DESCRIPTION: # If set to "false", do nothing. # Otherwise, add "doc" to IUSE, add appropriate dependencies, and generate and # install API documentation. if [[ ${CATEGORY} = kde-frameworks ]]; then : ${KDE_DOXYGEN:=true} else : ${KDE_DOXYGEN:=false} fi # @ECLASS-VARIABLE: KDE_DOX_DIR # @DESCRIPTION: # Defaults to ".". Otherwise, use alternative KDE doxygen path. : ${KDE_DOX_DIR:=.} # @ECLASS-VARIABLE: KDE_EXAMPLES # @DESCRIPTION: # If set to "false", unconditionally ignore a top-level examples subdirectory. # Otherwise, add "examples" to IUSE to toggle adding that subdirectory. : ${KDE_EXAMPLES:=false} # @ECLASS-VARIABLE: KDE_HANDBOOK # @DESCRIPTION: # If set to "false", do nothing. # Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and # generate and install KDE handbook. # If set to "forceoptional", remove a KF5DocTools dependency from the root # CMakeLists.txt in addition to the above. : ${KDE_HANDBOOK:=false} # @ECLASS-VARIABLE: KDE_DOC_DIR # @DESCRIPTION: # Defaults to "doc". Otherwise, use alternative KDE handbook path. : ${KDE_DOC_DIR:=doc} # @ECLASS-VARIABLE: KDE_TEST # @DESCRIPTION: # If set to "false", do nothing. # For any other value, add test to IUSE and add a dependency on dev-qt/qttest:5. # If set to "forceoptional", remove a Qt5Test dependency from the root # CMakeLists.txt in addition to the above. if [[ ${CATEGORY} = kde-frameworks ]]; then : ${KDE_TEST:=true} else : ${KDE_TEST:=false} fi # @ECLASS-VARIABLE: KDE_PUNT_BOGUS_DEPS # @DESCRIPTION: # If set to "false", do nothing. # For any other value, do black magic to make hardcoded-but-optional dependencies # optional again. An upstream solution is preferable and this is a last resort. : ${KDE_PUNT_BOGUS_DEPS:=false} # @ECLASS-VARIABLE: KDE_SELINUX_MODULE # @DESCRIPTION: # If set to "none", do nothing. # For any other value, add selinux to IUSE, and depending on that useflag # add a dependency on sec-policy/selinux-${KDE_SELINUX_MODULE} to (R)DEPEND. : ${KDE_SELINUX_MODULE:=none} if [[ ${KDEBASE} = kdevelop ]]; then HOMEPAGE="https://www.kdevelop.org/" else HOMEPAGE="https://www.kde.org/" fi LICENSE="GPL-2" if [[ ${CATEGORY} = kde-frameworks ]]; then SLOT=5/$(get_version_component_range 1-2) else SLOT=5 fi case ${KDE_AUTODEPS} in false) ;; *) if [[ ${KDE_BUILD_TYPE} = live ]]; then case ${CATEGORY} in kde-frameworks) FRAMEWORKS_MINIMAL=9999 ;; kde-plasma) FRAMEWORKS_MINIMAL=9999 ;; *) ;; esac fi DEPEND+=" $(add_frameworks_dep extra-cmake-modules)" RDEPEND+=" >=kde-frameworks/kf-env-3" COMMONDEPEND+=" >=dev-qt/qtcore-${QT_MINIMAL}:5" if [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma && ${PN} != polkit-kde-agent ]]; then RDEPEND+=" !kde-apps/kde4-l10n[-minimal(-)] ! /dev/null || die for lang in *; do if ! has ${lang} ${LINGUAS} ; then if [[ ${lang} != CMakeLists.txt ]] ; then rm -rf ${lang} fi if [[ -e CMakeLists.txt ]] ; then cmake_comment_add_subdirectory ${lang} fi fi done popd > /dev/null || die fi if [[ ${KDE_HANDBOOK} != false && -d ${KDE_DOC_DIR} && ${CATEGORY} != kde-apps ]] ; then pushd ${KDE_DOC_DIR} > /dev/null || die for lang in *; do if ! has ${lang} ${LINGUAS} ; then cmake_comment_add_subdirectory ${lang} fi done popd > /dev/null || die fi else rm -rf po fi # in frameworks, tests = manual tests so never build them if [[ ${CATEGORY} = kde-frameworks ]]; then cmake_comment_add_subdirectory tests fi case ${KDE_PUNT_BOGUS_DEPS} in false) ;; *) if ! use_if_iuse test ; then punt_bogus_dep Qt5 Test fi if ! use_if_iuse handbook ; then punt_bogus_dep KF5 DocTools fi ;; esac # only build unit tests when required if ! use_if_iuse test ; then if [[ ${KDE_TEST} = forceoptional ]] ; then punt_bogus_dep Qt5 Test # if forceoptional, also cover non-kde categories cmake_comment_add_subdirectory autotests cmake_comment_add_subdirectory test cmake_comment_add_subdirectory tests elif [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma || ${CATEGORY} = kde-apps ]] ; then cmake_comment_add_subdirectory autotests cmake_comment_add_subdirectory test cmake_comment_add_subdirectory tests fi fi } # @FUNCTION: kde5_src_configure # @DESCRIPTION: # Function for configuring the build of KDE 5. kde5_src_configure() { debug-print-function ${FUNCNAME} "$@" # we rely on cmake-utils.eclass to append -DNDEBUG too if ! use_if_iuse debug; then append-cppflags -DQT_NO_DEBUG fi local cmakeargs if ! use_if_iuse test ; then cmakeargs+=( -DBUILD_TESTING=OFF ) fi # install mkspecs in the same directory as qt stuff cmakeargs+=(-DKDE_INSTALL_USE_QT_SYS_PATHS=ON) # allow the ebuild to override what we set here mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}") cmake-utils_src_configure } # @FUNCTION: kde5_src_compile # @DESCRIPTION: # Function for compiling KDE 5. kde5_src_compile() { debug-print-function ${FUNCNAME} "$@" cmake-utils_src_compile "$@" # Build doxygen documentation if applicable if use_if_iuse doc ; then kgenapidox ${KDE_DOX_DIR} || die fi } # @FUNCTION: kde5_src_test # @DESCRIPTION: # Function for testing KDE 5. kde5_src_test() { debug-print-function ${FUNCNAME} "$@" _test_runner() { if [[ -n "${VIRTUALDBUS_TEST}" ]]; then export $(dbus-launch) fi cmake-utils_src_test } # When run as normal user during ebuild development with the ebuild command, the # kde tests tend to access the session DBUS. This however is not possible in a real # emerge or on the tinderbox. # > make sure it does not happen, so bad tests can be recognized and disabled unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID if [[ ${VIRTUALX_REQUIRED} = always || ${VIRTUALX_REQUIRED} = test ]]; then VIRTUALX_COMMAND="_test_runner" virtualmake else _test_runner fi if [[ -n "${DBUS_SESSION_BUS_PID}" ]] ; then kill ${DBUS_SESSION_BUS_PID} fi } # @FUNCTION: kde5_src_install # @DESCRIPTION: # Function for installing KDE 5. kde5_src_install() { debug-print-function ${FUNCNAME} "$@" # Install doxygen documentation if applicable if use_if_iuse doc ; then dodoc -r apidocs/html fi cmake-utils_src_install # We don't want ${PREFIX}/share/doc/HTML to be compressed, # because then khelpcenter can't find the docs if [[ -d ${ED}/${PREFIX}/share/doc/HTML ]]; then docompress -x ${PREFIX}/share/doc/HTML fi } # @FUNCTION: kde5_pkg_preinst # @DESCRIPTION: # Function storing icon caches kde5_pkg_preinst() { debug-print-function ${FUNCNAME} "$@" gnome2_icon_savelist } # @FUNCTION: kde5_pkg_postinst # @DESCRIPTION: # Function to rebuild the KDE System Configuration Cache after an application has been installed. kde5_pkg_postinst() { debug-print-function ${FUNCNAME} "$@" gnome2_icon_cache_update fdo-mime_desktop_database_update } # @FUNCTION: kde5_pkg_postrm # @DESCRIPTION: # Function to rebuild the KDE System Configuration Cache after an application has been removed. kde5_pkg_postrm() { debug-print-function ${FUNCNAME} "$@" gnome2_icon_cache_update fdo-mime_desktop_database_update } fi