# Copyright 2007-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-base.eclass,v 1.12 2008/05/17 14:09:03 zlin Exp $ # @ECLASS: kde4-base.eclass # @MAINTAINER: # kde@gentoo.org # @BLURB: This eclass provides functions for kde 4.0 ebuilds # @DESCRIPTION: # The kde4-base.eclass provides support for building KDE4 monolithic ebuilds # and KDE4 applications. # # NOTE: This eclass uses the SLOT dependencies from EAPI="1" or compatible, # hence you must define EAPI="1" in the ebuild, before inheriting any eclasses. inherit base eutils multilib cmake-utils kde4-functions EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_postinst pkg_postrm kde4-base_set_qt_dependencies() { local qt qtcore qtgui qt3support qtdepend qtopengldepend # use dependencies case "${EAPI}" in kdebuild-1) qt="[accessibility][dbus][gif][jpeg][png][qt3support][ssl][zlib]" qtcore="[qt3support][ssl]" qtgui="[accessibility][dbus]" qt3support="[accessibility]" case "${OPENGL_REQUIRED}" in always) qt="${qt}[opengl]" ;; optional) qt="${qt}[opengl?]" ;; esac ;; esac # split qt qtdepend=" x11-libs/qt-core:4${qtcore} x11-libs/qt-gui:4${qtgui} x11-libs/qt-qt3support:4${qt3support} x11-libs/qt-script:4 x11-libs/qt-svg:4 x11-libs/qt-test:4" qtopengldepend="x11-libs/qt-opengl:4" # allow monolithic qt for PV < 4.1 case "${PV}" in scm|9999.4|4.1*) : ;; *) qtdepend="|| ( ( ${qtdepend} ) >=x11-libs/qt-4.3.3:4${qt} )" qtopengldepend="|| ( ${qtopengldepend} >=x11-libs/qt-4.3.3:4 )" ;; esac # opengl dependencies case "${OPENGL_REQUIRED}" in always) qtdepend="${qtdepend} ${qtopengldepend}" ;; optional) IUSE="${IUSE} opengl" qtdepend="${qtdepend} opengl? ( ${qtopengldepend} )" ;; *) OPENGL_REQUIRED="never" ;; esac COMMONDEPEND="${COMMONDEPEND} ${qtdepend}" } kde4-base_set_qt_dependencies DEPEND="${DEPEND} ${COMMONDEPEND} >=dev-util/cmake-2.4.7-r1 dev-util/pkgconfig x11-libs/libXt x11-proto/xf86vidmodeproto" RDEPEND="${RDEPEND} ${COMMONDEPEND}" # @ECLASS-VARIABLE: OPENGL_REQUIRED # @DESCRIPTION: # Is qt-opengl required? Possible values are 'always', 'optional' and 'never'. # This variable must be set before inheriting any eclasses. Defaults to 'never'. OPENGL_REQUIRED="${OPENGL_REQUIRED:-never}" # @ECLASS-VARIABLE: CPPUNIT_REQUIRED # @DESCRIPTION: # Is cppunit required for tests? Possible values are 'always', 'optional' and 'never'. # This variable must be set before inheriting any eclasses. Defaults to 'never'. CPPUNIT_REQUIRED="${CPPUNIT_REQUIRED:-never}" case "${CPPUNIT_REQUIRED}" in always) DEPEND="${DEPEND} dev-util/cppunit" ;; optional) IUSE="${IUSE} test" DEPEND="${DEPEND} test? ( dev-util/cppunit )" ;; *) CPPUNIT_REQUIRED="never" ;; esac # @ECLASS-VARIABLE: NEED_KDE # @DESCRIPTION: # This variable sets the version of KDE4 which will be used by the eclass. # This variable must be set by the ebuild, for all categories except for "kde-base". # For kde-base packages, if it is not set by the ebuild, # it's assumed that the required KDE4 version is the latest, non-live, available. # # @CODE # Acceptable values are: # - latest - Use latest version in the portage tree # Default for kde-base ebuilds. Banned for ebuilds not part of kde or koffice. # - svn - Use svn release (live ebuilds) # - :SLOT - Use any version in the SLOT specified in the NEED_KDE value. # - VERSION_NUMBER - Use the minimum KDE4 version specified in the NEED_KDE value. # - VERSION_NUMBER:SLOT - Use the minimum KDE4 version and the SLOT specified in the NEED_KDE value. # - none - Let the ebuild handle SLOT, kde dependencies, KDEDIR, ... # @CODE # # Note: There is no default NEED_KDE for ebuilds not in kde-base or part of # koffice, so you must set it explicitly in the ebuild, in all other cases. if [[ -z ${NEED_KDE} ]]; then if [[ -n ${KDEBASE} ]]; then NEED_KDE="latest" else die "kde4-base.eclass inherited but NEED_KDE not defined - broken ebuild" fi fi export NEED_KDE case ${NEED_KDE} in latest) # Should only be used by 'kde-base'-ebuilds if [[ "${KDEBASE}" == "kde-base" ]]; then case ${PV} in 3.9*) _kdedir="3.9" ;; 4*) _kdedir="4.0" ;; *) die "NEED_KDE=latest not supported for PV=${PV}" ;; esac _operator=">=" _pv="-${PV}:kde-4" else _kdedir="4.0" _pv=":kde-4" fi ;; scm|svn|9999*|:kde-svn) _kdedir="svn" _pv=":kde-svn" export NEED_KDE="svn" ;; *:kde-svn) _kdedir="svn" _operator=">=" _pv="-${NEED_KDE}" export NEED_KDE="svn" ;; # The ebuild handles dependencies, KDEDIR, SLOT. none) : ;; # NEED_KDE=":${SLOT}" :kde-4) _kdedir="4.0" _pv="${NEED_KDE}" ;; # NEED_KDE="${PV}:${SLOT}" *:kde-4) _kdedir="4.0" _operator=">=" _pv="-${NEED_KDE}" ;; 3.9*) _kdedir="3.9" _operator=">=" _pv="-${NEED_KDE}:kde-4" ;; 4*) _kdedir="4.0" _operator=">=" _pv="-${NEED_KDE}:kde-4" ;; *) die "NEED_KDE=${NEED_KDE} currently not supported." ;; esac if [[ ${NEED_KDE} != none ]]; then KDEDIR="/usr/kde/${_kdedir}" KDEDIRS="/usr:/usr/local:${KDEDIR}" if [[ -n ${KDEBASE} ]]; then if [[ ${NEED_KDE} = svn ]]; then SLOT="kde-svn" else SLOT="kde-4" fi fi # We only need to add the dependencies if ${PN} is not "kdelibs" or "kdepimlibs" if [[ ${PN} != "kdelibs" ]]; then DEPEND="${DEPEND} ${_operator}kde-base/kdelibs${_pv}" RDEPEND="${RDEPEND} ${_operator}kde-base/kdelibs${_pv}" if [[ ${PN} != "kdepimlibs" ]]; then DEPEND="${DEPEND} ${_operator}kde-base/kdepimlibs${_pv}" RDEPEND="${RDEPEND} ${_operator}kde-base/kdepimlibs${_pv}" fi fi unset _operator _pv _kdedir fi # Fetch section - If the ebuild's category is not 'kde-base' and if it is not a # koffice ebuild, the URI should be set in the ebuild itself if [[ -n ${KDEBASE} ]]; then if [[ -n ${KMNAME} ]]; then _kmname=${KMNAME} else _kmname=${PN} fi _kmname_pv="${_kmname}-${PV}" if [[ ${NEED_KDE} != "svn" ]]; then case ${KDEBASE} in kde-base) case ${PV} in *) SRC_URI="mirror://kde/stable/${PV}/src/${_kmname_pv}.tar.bz2";; esac ;; koffice) SRC_URI="mirror://kde/unstable/${_kmname_pv}/src/${_kmname_pv}.tar.bz2" ;; esac fi unset _kmname _kmname_pv fi debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}" debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND ${DEPEND} - before blockers" # Monolithic ebuilds should add blockers for split ebuilds in the same slot. # If KMNAME is not set then this is not a split package if [[ -n ${KDEBASE} && -z ${KMNAME} ]]; then for _x in $(get-child-packages ${CATEGORY}/${PN}); do DEPEND="${DEPEND} !${_x}:${SLOT}" RDEPEND="${RDEPEND} !${_x}:${SLOT}" done unset _x fi debug-print "${BASH_SOURCE} ${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND ${DEPEND} - after blockers" # @ECLASS-VARIABLE: PREFIX # @DESCRIPTION: # Set the installation PREFIX. All kde-base ebuilds go into the KDE4 installation directory. # Applications installed by the other ebuilds go into /usr/ by default, this value # can be superseded by defining PREFIX before inheriting kde4-base. if [[ -n ${KDEBASE} ]]; then PREFIX=${KDEDIR} else # if PREFIX is not defined we set it to the default value of /usr PREFIX="${PREFIX:-/usr}" fi debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SLOT ${SLOT} - KDEDIR ${KDEDIR} - KDEDIRS ${KDEDIRS}- PREFIX ${PREFIX} - NEED_KDE ${NEED_KDE}" # @FUNCTION: kde4-base_pkg_setup # @DESCRIPTION: # Adds flags needed by all of KDE 4 to $QT4_BUILT_WITH_USE_CHECK. Uses # kde4-functions_check_use from kde4-functions.eclass to print appropriate # errors and die if any required flags listed in $QT4_BUILT_WITH_USE_CHECK or # $KDE4_BUILT_WITH_USE_CHECK are missing. kde4-base_pkg_setup() { debug-print-function $FUNCNAME "$@" case "${EAPI}" in kdebuild-1) [[ -n ${QT4_BUILT_WITH_USE_CHECK} || -n ${KDE4_BUILT_WITH_USE_CHECK[@]} ]] && \ die "built_with_use illegal in this EAPI!" ;; *) # Make KDE4_BUILT_WITH_USE_CHECK an array if it isn't already local line kde4_built_with_use_check=() if [[ -n ${KDE4_BUILT_WITH_USE_CHECK[@]} && $(declare -p KDE4_BUILT_WITH_USE_CHECK) != 'declare -a '* ]]; then while read line; do [[ -z ${line} ]] && continue kde4_built_with_use_check+=("${line}") done <<< "${KDE4_BUILT_WITH_USE_CHECK}" KDE4_BUILT_WITH_USE_CHECK=("${kde4_built_with_use_check[@]}") fi # KDE4 applications require qt4 compiled with USE="accessibility dbus gif jpeg png qt3support ssl zlib". if has_version '