perl-functions.eclass: should 'just work' in EAPI=6
[gentoo.git] / eclass / kde4-base.eclass
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: kde4-base.eclass
6 # @MAINTAINER:
7 # kde@gentoo.org
8 # @BLURB: This eclass provides functions for kde 4.X ebuilds
9 # @DESCRIPTION:
10 # The kde4-base.eclass provides support for building KDE4 based ebuilds
11 # and KDE4 applications.
12 #
13 # NOTE: KDE 4 ebuilds currently support EAPI 5. This will be
14 # reviewed over time as new EAPI versions are approved.
15
16 if [[ -z ${_KDE4_BASE_ECLASS} ]]; then
17 _KDE4_BASE_ECLASS=1
18
19 # @ECLASS-VARIABLE: KDE_SELINUX_MODULE
20 # @DESCRIPTION:
21 # If set to "none", do nothing.
22 # For any other value, add selinux to IUSE, and depending on that useflag
23 # add a dependency on sec-policy/selinux-${KDE_SELINUX_MODULE} to (R)DEPEND
24 : ${KDE_SELINUX_MODULE:=none}
25
26 # @ECLASS-VARIABLE: VIRTUALDBUS_TEST
27 # @DESCRIPTION:
28 # If defined, launch and use a private dbus session during src_test.
29
30 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
31 # @DESCRIPTION:
32 # For proper description see virtualx.eclass manpage.
33 # Here we redefine default value to be manual, if your package needs virtualx
34 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
35 : ${VIRTUALX_REQUIRED:=manual}
36
37 inherit kde4-functions toolchain-funcs fdo-mime flag-o-matic gnome2-utils virtualx versionator eutils multilib
38
39 if [[ ${KDE_BUILD_TYPE} = live ]]; then
40         case ${KDE_SCM} in
41                 svn) inherit subversion ;;
42                 git) inherit git-r3 ;;
43         esac
44 fi
45
46 # @ECLASS-VARIABLE: CMAKE_REQUIRED
47 # @DESCRIPTION:
48 # Specify if cmake buildsystem is being used. Possible values are 'always' and 'never'.
49 # Please note that if it's set to 'never' you need to explicitly override following phases:
50 # src_configure, src_compile, src_test and src_install.
51 # Defaults to 'always'.
52 : ${CMAKE_REQUIRED:=always}
53 if [[ ${CMAKE_REQUIRED} = always ]]; then
54         buildsystem_eclass="cmake-utils"
55         export_fns="src_configure src_compile src_test src_install"
56 fi
57
58 # @ECLASS-VARIABLE: KDE_MINIMAL
59 # @DESCRIPTION:
60 # This variable is used when KDE_REQUIRED is set, to specify required KDE minimal
61 # version for apps to work. Currently defaults to 4.4
62 # One may override this variable to raise version requirements.
63 # Note that it is fixed to ${PV} for kde-base packages.
64 KDE_MINIMAL="${KDE_MINIMAL:-4.4}"
65
66 # Set slot for KDEBASE known packages
67 case ${KDEBASE} in
68         kde-base)
69                 SLOT=4/$(get_version_component_range 1-2)
70                 KDE_MINIMAL="${PV}"
71                 ;;
72         kdevelop)
73                 if [[ ${KDE_BUILD_TYPE} = live ]]; then
74                         # @ECLASS-VARIABLE: KDEVELOP_VERSION
75                         # @DESCRIPTION:
76                         # Specifies KDevelop version. Default is 4.0.0 for tagged packages and 9999 for live packages.
77                         # Applies to KDEBASE=kdevelop only.
78                         KDEVELOP_VERSION="${KDEVELOP_VERSION:-4.9999}"
79                         # @ECLASS-VARIABLE: KDEVPLATFORM_VERSION
80                         # @DESCRIPTION:
81                         # Specifies KDevplatform version. Default is 1.0.0 for tagged packages and 9999 for live packages.
82                         # Applies to KDEBASE=kdevelop only.
83                         KDEVPLATFORM_VERSION="${KDEVPLATFORM_VERSION:-4.9999}"
84                 else
85                         case ${PN} in
86                                 kdevelop)
87                                         KDEVELOP_VERSION=${PV}
88                                         KDEVPLATFORM_VERSION="$(($(get_major_version)-3)).$(get_after_major_version)"
89                                         ;;
90                                 kdevplatform|kdevelop-php*|kdevelop-python)
91                                         KDEVELOP_VERSION="$(($(get_major_version)+3)).$(get_after_major_version)"
92                                         KDEVPLATFORM_VERSION=${PV}
93                                         ;;
94                                 *)
95                                         KDEVELOP_VERSION="${KDEVELOP_VERSION:-4.0.0}"
96                                         KDEVPLATFORM_VERSION="${KDEVPLATFORM_VERSION:-1.0.0}"
97                         esac
98                 fi
99                 SLOT="4"
100                 ;;
101 esac
102
103 inherit ${buildsystem_eclass}
104
105 EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare ${export_fns} pkg_preinst pkg_postinst pkg_postrm
106
107 unset buildsystem_eclass
108 unset export_fns
109
110 # @ECLASS-VARIABLE: DECLARATIVE_REQUIRED
111 # @DESCRIPTION:
112 # Is qtdeclarative required? Possible values are 'always', 'optional' and 'never'.
113 # This variable must be set before inheriting any eclasses. Defaults to 'never'.
114 DECLARATIVE_REQUIRED="${DECLARATIVE_REQUIRED:-never}"
115
116 # @ECLASS-VARIABLE: QTHELP_REQUIRED
117 # @DESCRIPTION:
118 # Is qthelp required? Possible values are 'always', 'optional' and 'never'.
119 # This variable must be set before inheriting any eclasses. Defaults to 'never'.
120 QTHELP_REQUIRED="${QTHELP_REQUIRED:-never}"
121
122 # @ECLASS-VARIABLE: OPENGL_REQUIRED
123 # @DESCRIPTION:
124 # Is qtopengl required? Possible values are 'always', 'optional' and 'never'.
125 # This variable must be set before inheriting any eclasses. Defaults to 'never'.
126 OPENGL_REQUIRED="${OPENGL_REQUIRED:-never}"
127
128 # @ECLASS-VARIABLE: MULTIMEDIA_REQUIRED
129 # @DESCRIPTION:
130 # Is qtmultimedia required? Possible values are 'always', 'optional' and 'never'.
131 # This variable must be set before inheriting any eclasses. Defaults to 'never'.
132 MULTIMEDIA_REQUIRED="${MULTIMEDIA_REQUIRED:-never}"
133
134 # @ECLASS-VARIABLE: CPPUNIT_REQUIRED
135 # @DESCRIPTION:
136 # Is cppunit required for tests? Possible values are 'always', 'optional' and 'never'.
137 # This variable must be set before inheriting any eclasses. Defaults to 'never'.
138 CPPUNIT_REQUIRED="${CPPUNIT_REQUIRED:-never}"
139
140 # @ECLASS-VARIABLE: KDE_REQUIRED
141 # @DESCRIPTION:
142 # Is kde required? Possible values are 'always', 'optional' and 'never'.
143 # This variable must be set before inheriting any eclasses. Defaults to 'always'
144 # If set to 'always' or 'optional', KDE_MINIMAL may be overriden as well.
145 # Note that for kde-base packages this variable is fixed to 'always'.
146 KDE_REQUIRED="${KDE_REQUIRED:-always}"
147
148 # @ECLASS-VARIABLE: KDE_HANDBOOK
149 # @DESCRIPTION:
150 # Set to enable handbook in application. Possible values are 'always', 'optional'
151 # (handbook USE flag) and 'never'.
152 # This variable must be set before inheriting any eclasses. Defaults to 'never'.
153 # It adds default handbook dirs for kde-base packages to KMEXTRA and in any case it
154 # ensures buildtime and runtime dependencies.
155 KDE_HANDBOOK="${KDE_HANDBOOK:-never}"
156
157 # @ECLASS-VARIABLE: KDE_LINGUAS_LIVE_OVERRIDE
158 # @DESCRIPTION:
159 # Set this varible if you want your live package to manage its
160 # translations. (Mostly all kde ebuilds does not ship documentation
161 # and translations in live ebuilds)
162 if [[ ${KDE_BUILD_TYPE} == live && -z ${KDE_LINGUAS_LIVE_OVERRIDE} ]]; then
163         # Kdebase actualy provides the handbooks even for live stuff
164         [[ ${KDEBASE} == kde-base ]] || KDE_HANDBOOK=never
165         KDE_LINGUAS=""
166 fi
167
168 # Setup packages inheriting this eclass
169 case ${KDEBASE} in
170         kde-base)
171                 HOMEPAGE="https://www.kde.org/"
172                 LICENSE="GPL-2"
173                 if [[ ${KDE_BUILD_TYPE} = live && -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then
174                         # Disable tests for live ebuilds by default
175                         RESTRICT+=" test"
176                 fi
177
178                 # This code is to prevent portage from searching GENTOO_MIRRORS for
179                 # packages that will never be mirrored. (As they only will ever be in
180                 # the overlay).
181                 case ${PV} in
182                         *9999* | 4.?.[6-9]? | 4.??.[6-9]? | ??.?.[6-9]? | ??.??.[6-9]?)
183                                 RESTRICT+=" mirror"
184                                 ;;
185                 esac
186                 ;;
187         kdevelop)
188                 HOMEPAGE="https://www.kdevelop.org/"
189                 LICENSE="GPL-2"
190                 ;;
191 esac
192
193 # @ECLASS-VARIABLE: QT_MINIMAL
194 # @DESCRIPTION:
195 # Determine version of qt we enforce as minimal for the package.
196 QT_MINIMAL="${QT_MINIMAL:-4.8.5}"
197
198 # Declarative dependencies
199 qtdeclarativedepend="
200         >=dev-qt/qtdeclarative-${QT_MINIMAL}:4
201 "
202 case ${DECLARATIVE_REQUIRED} in
203         always)
204                 COMMONDEPEND+=" ${qtdeclarativedepend}"
205                 ;;
206         optional)
207                 IUSE+=" declarative"
208                 COMMONDEPEND+=" declarative? ( ${qtdeclarativedepend} )"
209                 ;;
210         *) ;;
211 esac
212 unset qtdeclarativedepend
213
214 # QtHelp dependencies
215 qthelpdepend="
216         >=dev-qt/qthelp-${QT_MINIMAL}:4
217 "
218 case ${QTHELP_REQUIRED} in
219         always)
220                 COMMONDEPEND+=" ${qthelpdepend}"
221                 ;;
222         optional)
223                 IUSE+=" qthelp"
224                 COMMONDEPEND+=" qthelp? ( ${qthelpdepend} )"
225                 ;;
226 esac
227 unset qthelpdepend
228
229 # OpenGL dependencies
230 qtopengldepend="
231         >=dev-qt/qtopengl-${QT_MINIMAL}:4
232 "
233 case ${OPENGL_REQUIRED} in
234         always)
235                 COMMONDEPEND+=" ${qtopengldepend}"
236                 ;;
237         optional)
238                 IUSE+=" opengl"
239                 COMMONDEPEND+=" opengl? ( ${qtopengldepend} )"
240                 ;;
241         *) ;;
242 esac
243 unset qtopengldepend
244
245 # MultiMedia dependencies
246 qtmultimediadepend="
247         >=dev-qt/qtmultimedia-${QT_MINIMAL}:4
248 "
249 case ${MULTIMEDIA_REQUIRED} in
250         always)
251                 COMMONDEPEND+=" ${qtmultimediadepend}"
252                 ;;
253         optional)
254                 IUSE+=" multimedia"
255                 COMMONDEPEND+=" multimedia? ( ${qtmultimediadepend} )"
256                 ;;
257         *) ;;
258 esac
259 unset qtmultimediadepend
260
261 # CppUnit dependencies
262 cppuintdepend="
263         dev-util/cppunit
264 "
265 case ${CPPUNIT_REQUIRED} in
266         always)
267                 DEPEND+=" ${cppuintdepend}"
268                 ;;
269         optional)
270                 IUSE+=" test"
271                 DEPEND+=" test? ( ${cppuintdepend} )"
272                 ;;
273         *) ;;
274 esac
275 unset cppuintdepend
276
277 # KDE dependencies
278 # Qt accessibility classes are needed in various places, bug 325461
279 kdecommondepend="
280         dev-lang/perl
281         >=dev-qt/qt3support-${QT_MINIMAL}:4[accessibility]
282         >=dev-qt/qtcore-${QT_MINIMAL}:4[qt3support,ssl]
283         >=dev-qt/qtdbus-${QT_MINIMAL}:4
284         >=dev-qt/designer-${QT_MINIMAL}:4
285         >=dev-qt/qtgui-${QT_MINIMAL}:4[accessibility,dbus(+)]
286         >=dev-qt/qtscript-${QT_MINIMAL}:4
287         >=dev-qt/qtsql-${QT_MINIMAL}:4[qt3support]
288         >=dev-qt/qtsvg-${QT_MINIMAL}:4
289         >=dev-qt/qttest-${QT_MINIMAL}:4
290         >=dev-qt/qtwebkit-${QT_MINIMAL}:4
291 "
292
293 if [[ ${PN} != kdelibs ]]; then
294         kdecommondepend+=" $(add_kdebase_dep kdelibs)"
295         if [[ ${KDEBASE} = kdevelop ]]; then
296                 if [[ ${PN} != kdevplatform ]]; then
297                         # @ECLASS-VARIABLE: KDEVPLATFORM_REQUIRED
298                         # @DESCRIPTION:
299                         # Specifies whether kdevplatform is required. Possible values are 'always' (default) and 'never'.
300                         # Applies to KDEBASE=kdevelop only.
301                         KDEVPLATFORM_REQUIRED="${KDEVPLATFORM_REQUIRED:-always}"
302                         case ${KDEVPLATFORM_REQUIRED} in
303                                 always)
304                                         kdecommondepend+="
305                                                 >=dev-util/kdevplatform-${KDEVPLATFORM_VERSION}:4
306                                         "
307                                         ;;
308                                 *) ;;
309                         esac
310                 fi
311         fi
312 fi
313
314 kdedepend="
315         dev-util/automoc
316         virtual/pkgconfig
317         !aqua? (
318                 >=x11-libs/libXtst-1.1.0
319                 x11-proto/xf86vidmodeproto
320         )
321 "
322
323 kderdepend=""
324
325 if [[ ${CATEGORY} == kde-apps ]]; then
326         kderdepend+=" !kde-base/${PN}:4"
327 fi
328
329 # all packages needs oxygen icons for basic iconset
330 if [[ ${PN} != oxygen-icons ]]; then
331         kderdepend+=" kde-frameworks/oxygen-icons"
332 fi
333
334 # add a dependency over kde4-l10n
335 if [[ ${KDEBASE} != "kde-base" && -n ${KDE_LINGUAS} ]]; then
336         for _lingua in ${KDE_LINGUAS}; do
337                 # if our package has linguas, pull in kde4-l10n with selected lingua enabled,
338                 # but only for selected ones.
339                 # this can't be done on one line because if user doesn't use any localisation
340                 # then he is probably not interested in kde4-l10n at all.
341                 kderdepend+="
342                 linguas_${_lingua}? ( $(add_kdeapps_dep kde4-l10n "linguas_${_lingua}(+)") )
343                 "
344         done
345         unset _lingua
346 fi
347
348 kdehandbookdepend="
349         app-text/docbook-xml-dtd:4.2
350         app-text/docbook-xsl-stylesheets
351 "
352 kdehandbookrdepend="
353         $(add_kdebase_dep kdelibs 'handbook')
354 "
355 case ${KDE_HANDBOOK} in
356         always)
357                 kdedepend+=" ${kdehandbookdepend}"
358                 [[ ${PN} != kdelibs ]] && kderdepend+=" ${kdehandbookrdepend}"
359                 ;;
360         optional)
361                 IUSE+=" +handbook"
362                 kdedepend+=" handbook? ( ${kdehandbookdepend} )"
363                 [[ ${PN} != kdelibs ]] && kderdepend+=" handbook? ( ${kdehandbookrdepend} )"
364                 ;;
365         *) ;;
366 esac
367 unset kdehandbookdepend kdehandbookrdepend
368
369 case ${KDE_SELINUX_MODULE} in
370         none)   ;;
371         *)
372                 IUSE+=" selinux"
373                 kderdepend+=" selinux? ( sec-policy/selinux-${KDE_SELINUX_MODULE} )"
374                 ;;
375 esac
376
377 # We always need the aqua useflag because otherwise we cannot = refer to it inside
378 # add_kdebase_dep. This was always kind of a bug, but came to light with EAPI=5
379 # (where referring to a use flag not in IUSE masks the ebuild).
380 # The only alternative would be to prohibit using add_kdebase_dep if KDE_REQUIRED=never
381 IUSE+=" aqua"
382
383 case ${KDE_REQUIRED} in
384         always)
385                 [[ -n ${kdecommondepend} ]] && COMMONDEPEND+=" ${kdecommondepend}"
386                 [[ -n ${kdedepend} ]] && DEPEND+=" ${kdedepend}"
387                 [[ -n ${kderdepend} ]] && RDEPEND+=" ${kderdepend}"
388                 ;;
389         optional)
390                 IUSE+=" kde"
391                 [[ -n ${kdecommondepend} ]] && COMMONDEPEND+=" kde? ( ${kdecommondepend} )"
392                 [[ -n ${kdedepend} ]] && DEPEND+=" kde? ( ${kdedepend} )"
393                 [[ -n ${kderdepend} ]] && RDEPEND+=" kde? ( ${kderdepend} )"
394                 ;;
395         *) ;;
396 esac
397
398 unset kdecommondepend kdedepend kderdepend
399
400 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: COMMONDEPEND is ${COMMONDEPEND}"
401 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND (only) is ${DEPEND}"
402 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: RDEPEND (only) is ${RDEPEND}"
403
404 # Accumulate dependencies set by this eclass
405 DEPEND+=" ${COMMONDEPEND}"
406 RDEPEND+=" ${COMMONDEPEND}"
407 unset COMMONDEPEND
408
409 # Fetch section - If the ebuild's category is not 'kde-base' and if it is not a
410 # kdevelop ebuild, the URI should be set in the ebuild itself
411 _calculate_src_uri() {
412         debug-print-function ${FUNCNAME} "$@"
413
414         local _kmname _kmname_pv
415
416         # we calculate URI only for known KDEBASE modules
417         [[ -n ${KDEBASE} ]] || return
418
419         # calculate tarball module name
420         if [[ -n ${KMNAME} ]]; then
421                 _kmname="${KMNAME}"
422         else
423                 _kmname=${PN}
424         fi
425         _kmname_pv="${_kmname}-${PV}"
426         case ${KDEBASE} in
427                 kde-base)
428                         case ${PV} in
429                                 4.4.11.1)
430                                         # KDEPIM 4.4, special case
431                                         # TODO: Remove this part when KDEPIM 4.4 gets out of the tree
432                                         SRC_URI="mirror://kde/stable/kdepim-${PV}/src/${_kmname_pv}.tar.bz2" ;;
433                                 4.4.20*)
434                                         # KDEPIM 4.4 no-akonadi branch, special case
435                                         # TODO: Remove this part when KDEPIM 4.4 gets out of the tree
436                                         SRC_URI="https://dev.gentoo.org/~dilfridge/distfiles/${_kmname_pv}.tar.xz" ;;
437                                 4.?.[6-9]? | 4.??.[6-9]?)
438                                         # Unstable KDE SC releases
439                                         SRC_URI="mirror://kde/unstable/${PV}/src/${_kmname_pv}.tar.xz" ;;
440                                 4.11.19)
441                                         # Part of 15.04.1 actually, sigh. Not stable for next release!
442                                         SRC_URI="mirror://kde/stable/applications/15.04.1/src/${_kmname_pv}.tar.xz" ;;
443                                 4.11.22)
444                                         # Part of 15.08.0 actually, sigh. Not stable for next release!
445                                         SRC_URI="mirror://kde/stable/applications/15.08.0/src/${_kmname_pv}.tar.xz" ;;
446                                 4.14.3)
447                                         # Last SC release
448                                         SRC_URI="mirror://kde/stable/${PV}/src/${_kmname_pv}.tar.xz" ;;
449                                 4.14.8)
450                                         # Part of 15.04.1 actually, sigh. Not stable for next release!
451                                         SRC_URI="mirror://kde/stable/applications/15.04.1/src/${_kmname_pv}.tar.xz" ;;
452                                 4.14.10)
453                                         # Part of 15.04.3 actually, sigh. Not stable for next release!
454                                         SRC_URI="mirror://kde/stable/applications/15.04.3/src/${_kmname_pv}.tar.xz" ;;
455                                 4.14.13)
456                                         # Part of 15.08.2 actually, sigh. Not stable for next release!
457                                         SRC_URI="mirror://kde/stable/applications/15.08.2/src/${_kmname_pv}.tar.xz" ;;
458                                 4.14.14)
459                                         # Part of 15.08.3 actually, sigh. Not stable for next release!
460                                         SRC_URI="mirror://kde/stable/applications/15.08.3/src/${_kmname_pv}.tar.xz" ;;
461                                 ??.?.[6-9]? | ??.??.[4-9]?)
462                                         # Unstable KDE Applications releases
463                                         SRC_URI="mirror://kde/unstable/applications/${PV}/src/${_kmname}-${PV}.tar.xz" ;;
464                                 *)
465                                         # Stable KDE Applications releases
466                                         SRC_URI="mirror://kde/stable/applications/${PV}/src/${_kmname}-${PV}.tar.xz"
467                                 ;;
468                         esac
469                         ;;
470                 kdevelop|kdevelop-php*|kdevplatform)
471                         case ${KDEVELOP_VERSION} in
472                                 4.[123].[6-9]*) SRC_URI="mirror://kde/unstable/kdevelop/${KDEVELOP_VERSION}/src/${P}.tar.xz" ;;
473                                 *) SRC_URI="mirror://kde/stable/kdevelop/${KDEVELOP_VERSION}/src/${P}.tar.xz" ;;
474                         esac
475                         ;;
476         esac
477 }
478
479 _calculate_live_repo() {
480         debug-print-function ${FUNCNAME} "$@"
481
482         SRC_URI=""
483         case ${KDE_SCM} in
484                 svn)
485                         # Determine branch URL based on live type
486                         local branch_prefix
487                         case ${PV} in
488                                 9999*)
489                                         # trunk
490                                         branch_prefix="trunk/KDE"
491                                         ;;
492                                 *)
493                                         # branch
494                                         branch_prefix="branches/KDE/$(get_kde_version)"
495
496                                         if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
497                                                 branch_prefix="branches/Applications/$(get_kde_version)"
498                                         fi
499
500                                         # @ECLASS-VARIABLE: ESVN_PROJECT_SUFFIX
501                                         # @DESCRIPTION
502                                         # Suffix appended to ESVN_PROJECT depending on fetched branch.
503                                         # Defaults is empty (for -9999 = trunk), and "-${PV}" otherwise.
504                                         ESVN_PROJECT_SUFFIX="-${PV}"
505                                         ;;
506                         esac
507                         # @ECLASS-VARIABLE: ESVN_MIRROR
508                         # @DESCRIPTION:
509                         # This variable allows easy overriding of default kde mirror service
510                         # (anonsvn) with anything else you might want to use.
511                         ESVN_MIRROR=${ESVN_MIRROR:=svn://anonsvn.kde.org/home/kde}
512                         # Split ebuild, or extragear stuff
513                         if [[ -n ${KMNAME} ]]; then
514                                 ESVN_PROJECT="${KMNAME}${ESVN_PROJECT_SUFFIX}"
515                                 if [[ -z ${KMNOMODULE} ]] && [[ -z ${KMMODULE} ]]; then
516                                         KMMODULE="${PN}"
517                                 fi
518                                 # Split kde-base/ ebuilds: (they reside in trunk/KDE)
519                                 case ${KMNAME} in
520                                         kdebase-*)
521                                                 ESVN_REPO_URI="${ESVN_MIRROR}/${branch_prefix}/kdebase/${KMNAME#kdebase-}"
522                                                 ;;
523                                         kdelibs-*)
524                                                 ESVN_REPO_URI="${ESVN_MIRROR}/${branch_prefix}/kdelibs/${KMNAME#kdelibs-}"
525                                                 ;;
526                                         kdereview*)
527                                                 ESVN_REPO_URI="${ESVN_MIRROR}/trunk/${KMNAME}/${KMMODULE}"
528                                                 ;;
529                                         kdesupport)
530                                                 ESVN_REPO_URI="${ESVN_MIRROR}/trunk/${KMNAME}/${KMMODULE}"
531                                                 ESVN_PROJECT="${PN}${ESVN_PROJECT_SUFFIX}"
532                                                 ;;
533                                         kde*)
534                                                 ESVN_REPO_URI="${ESVN_MIRROR}/${branch_prefix}/${KMNAME}"
535                                                 ;;
536                                         extragear*|playground*)
537                                                 # Unpack them in toplevel dir, so that they won't conflict with kde4-meta
538                                                 # build packages from same svn location.
539                                                 ESVN_REPO_URI="${ESVN_MIRROR}/trunk/${KMNAME}/${KMMODULE}"
540                                                 ESVN_PROJECT="${PN}${ESVN_PROJECT_SUFFIX}"
541                                                 ;;
542                                         *)
543                                                 ESVN_REPO_URI="${ESVN_MIRROR}/trunk/${KMNAME}/${KMMODULE}"
544                                                 ;;
545                                 esac
546                         else
547                                 # kdelibs, kdepimlibs
548                                 ESVN_REPO_URI="${ESVN_MIRROR}/${branch_prefix}/${PN}"
549                                 ESVN_PROJECT="${PN}${ESVN_PROJECT_SUFFIX}"
550                         fi
551                         # @ECLASS-VARIABLE: ESVN_UP_FREQ
552                         # @DESCRIPTION:
553                         # This variable is used for specifying the timeout between svn synces
554                         # for kde-base modules. Does not affect misc apps.
555                         # Default value is 1 hour.
556                         [[ ${KDEBASE} = kde-base ]] && ESVN_UP_FREQ=${ESVN_UP_FREQ:-1}
557                         ;;
558                 git)
559                         local _kmname
560                         # @ECLASS-VARIABLE: EGIT_MIRROR
561                         # @DESCRIPTION:
562                         # This variable allows easy overriding of default kde mirror service
563                         # (anongit) with anything else you might want to use.
564                         EGIT_MIRROR=${EGIT_MIRROR:=git://anongit.kde.org}
565
566                         # @ECLASS-VARIABLE: EGIT_REPONAME
567                         # @DESCRIPTION:
568                         # This variable allows overriding of default repository
569                         # name. Specify only if this differ from PN and KMNAME.
570                         if [[ -n ${EGIT_REPONAME} ]]; then
571                                 # the repository and kmname different
572                                 _kmname=${EGIT_REPONAME}
573                         elif [[ -n ${KMNAME} ]]; then
574                                 _kmname=${KMNAME}
575                         else
576                                 _kmname=${PN}
577                         fi
578
579                         # default branching
580                         [[ ${PV} != 4.9999* && ${PV} != 9999 && ${KDEBASE} == kde-base ]] && \
581                                 EGIT_BRANCH="KDE/$(get_kde_version)"
582
583                         # Applications branching
584                         [[ ${PV} == ??.??.49.9999 && ${KDEBASE} == kde-base ]] && \
585                                 EGIT_BRANCH="Applications/$(get_kde_version)"
586
587                         # default repo uri
588                         EGIT_REPO_URI+=( "${EGIT_MIRROR}/${_kmname}" )
589
590                         debug-print "${FUNCNAME}: Repository: ${EGIT_REPO_URI}"
591                         debug-print "${FUNCNAME}: Branch: ${EGIT_BRANCH}"
592                         ;;
593         esac
594 }
595
596 case ${KDE_BUILD_TYPE} in
597         live) _calculate_live_repo ;;
598         *) _calculate_src_uri ;;
599 esac
600
601 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
602
603 # @ECLASS-VARIABLE: PREFIX
604 # @DESCRIPTION:
605 # Set the installation PREFIX for non kde-base applications. It defaults to /usr.
606 # kde-base packages go into KDE4 installation directory (/usr).
607 # No matter the PREFIX, package will be built against KDE installed in /usr.
608
609 # @FUNCTION: kde4-base_pkg_setup
610 # @DESCRIPTION:
611 # Do some basic settings
612 kde4-base_pkg_setup() {
613         debug-print-function ${FUNCNAME} "$@"
614
615         if has handbook ${IUSE} || has "+handbook" ${IUSE} && [ "${KDE_HANDBOOK}" != optional ] ; then
616                 eqawarn "Handbook support is enabled via KDE_HANDBOOK=optional in the ebuild."
617                 eqawarn "Please do not just set IUSE=handbook, as this leads to dependency errors."
618         fi
619
620         # Don't set KDEHOME during compilation, it will cause access violations
621         unset KDEHOME
622
623         # Check if gcc compiler is fresh enough.
624         # In theory should be in pkg_pretend but we check it only for kdelibs there
625         # and for others we do just quick scan in pkg_setup because pkg_pretend
626         # executions consume quite some time (ie. when merging 300 packages at once will cause 300 checks)
627         if [[ ${MERGE_TYPE} != binary ]]; then
628                 [[ $(gcc-major-version) -lt 4 ]] || \
629                                 ( [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -le 6 ]] ) \
630                         && die "Sorry, but gcc-4.6 and earlier wont work for some KDE packages."
631         fi
632
633         KDEDIR=/usr
634         : ${PREFIX:=/usr}
635         EKDEDIR=${EPREFIX}/usr
636
637         # Point to correct QT plugins path
638         QT_PLUGIN_PATH="${EPREFIX}/usr/$(get_libdir)/kde4/plugins/"
639
640         # Fix XDG collision with sandbox
641         export XDG_CONFIG_HOME="${T}"
642 }
643
644 # @FUNCTION: kde4-base_src_unpack
645 # @DESCRIPTION:
646 # This function unpacks the source tarballs for KDE4 applications.
647 kde4-base_src_unpack() {
648         debug-print-function ${FUNCNAME} "$@"
649
650         if [[ ${KDE_BUILD_TYPE} = live ]]; then
651                 case ${KDE_SCM} in
652                         svn)
653                                 subversion_src_unpack
654                                 ;;
655                         git)
656                                 git-r3_src_unpack
657                                 ;;
658                 esac
659         else
660                 unpack ${A}
661         fi
662 }
663
664 # @FUNCTION: kde4-base_src_prepare
665 # @DESCRIPTION:
666 # General pre-configure and pre-compile function for KDE4 applications.
667 # It also handles translations if KDE_LINGUAS is defined. See KDE_LINGUAS and
668 # enable_selected_linguas() and enable_selected_doc_linguas()
669 # in kde4-functions.eclass(5) for further details.
670 kde4-base_src_prepare() {
671         debug-print-function ${FUNCNAME} "$@"
672
673         # enable handbook and linguas only when not using live ebuild
674
675         # Only enable selected languages, used for KDE extragear apps.
676         if [[ -n ${KDE_LINGUAS} ]]; then
677                 enable_selected_linguas
678         fi
679
680         # Enable/disable handbooks for kde4-base packages
681         # kde4-l10n inherits kde4-base but is metapackage, so no check for doc
682         # kdelibs inherits kde4-base but handle installing the handbook itself
683         if ! has kde4-meta ${INHERITED} && in_iuse handbook; then
684                 if [[ ${KDEBASE} == kde-base ]]; then
685                         if [[ ${PN} != kde4-l10n && ${PN} != kdepim-l10n && ${PN} != kdelibs ]] && use !handbook; then
686                                 # documentation in kde4-functions
687                                 : ${KDE_DOC_DIRS:=doc}
688                                 local dir
689                                 for dir in ${KDE_DOC_DIRS}; do
690                                         sed -e "\!^[[:space:]]*add_subdirectory[[:space:]]*([[:space:]]*${dir}[[:space:]]*)!s/^/#DONOTCOMPILE /" \
691                                                 -e "\!^[[:space:]]*ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${dir}[[:space:]]*)!s/^/#DONOTCOMPILE /" \
692                                                 -e "\!^[[:space:]]*macro_optional_add_subdirectory[[:space:]]*([[:space:]]*${dir}[[:space:]]*)!s/^/#DONOTCOMPILE /" \
693                                                 -e "\!^[[:space:]]*MACRO_OPTIONAL_ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${dir}[[:space:]]*)!s/^/#DONOTCOMPILE /" \
694                                                 -i CMakeLists.txt || die "failed to comment out handbook"
695                                 done
696                         fi
697                 else
698                         enable_selected_doc_linguas
699                 fi
700         fi
701
702         # SCM bootstrap
703         if [[ ${KDE_BUILD_TYPE} = live ]]; then
704                 case ${KDE_SCM} in
705                         svn) subversion_src_prepare ;;
706                 esac
707         fi
708
709         # Apply patches, cmake-utils does the job already
710         cmake-utils_src_prepare
711
712         # Save library dependencies
713         if [[ -n ${KMSAVELIBS} ]] ; then
714                 save_library_dependencies
715         fi
716
717         # Inject library dependencies
718         if [[ -n ${KMLOADLIBS} ]] ; then
719                 load_library_dependencies
720         fi
721
722         # Hack for manuals relying on outdated DTD, only outside kde-base/...
723         if [[ -z ${KDEBASE} ]]; then
724                 find "${S}" -name "*.docbook" \
725                         -exec sed -i -r \
726                                 -e 's:-//KDE//DTD DocBook XML V4\.1(\..)?-Based Variant V1\.[01]//EN:-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN:g' {} + \
727                         || die 'failed to fix DocBook variant version'
728         fi
729 }
730
731 # @FUNCTION: kde4-base_src_configure
732 # @DESCRIPTION:
733 # Function for configuring the build of KDE4 applications.
734 kde4-base_src_configure() {
735         debug-print-function ${FUNCNAME} "$@"
736
737         # Build tests in src_test only, where we override this value
738         local cmakeargs=(-DKDE4_BUILD_TESTS=OFF)
739
740         if use_if_iuse debug; then
741                 # Set "real" debug mode
742                 CMAKE_KDE_BUILD_TYPE="Debugfull"
743         else
744                 # Handle common release builds
745                 append-cppflags -DQT_NO_DEBUG
746         fi
747
748         # Set distribution name
749         [[ ${PN} = kdelibs ]] && cmakeargs+=(-DKDE_DISTRIBUTION_TEXT=Gentoo)
750
751         # Here we set the install prefix
752         tc-is-cross-compiler || cmakeargs+=(-DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX}")
753
754         # Use colors
755         QTEST_COLORED=1
756
757         # Shadow existing installations
758         unset KDEDIRS
759
760         #qmake -query QT_INSTALL_LIBS unavailable when cross-compiling
761         tc-is-cross-compiler && cmakeargs+=(-DQT_LIBRARY_DIR=${ROOT}/usr/$(get_libdir)/qt4)
762         #kde-config -path data unavailable when cross-compiling
763         tc-is-cross-compiler && cmakeargs+=(-DKDE4_DATA_DIR=${ROOT}/usr/share/apps/)
764
765         # sysconf needs to be /etc, not /usr/etc
766         cmakeargs+=(-DSYSCONF_INSTALL_DIR="${EPREFIX}"/etc)
767
768         if [[ $(declare -p mycmakeargs 2>&-) != "declare -a mycmakeargs="* ]]; then
769                 if [[ ${mycmakeargs} ]]; then
770                         eqawarn "mycmakeargs should always be declared as an array, not a string"
771                 fi
772                 mycmakeargs=(${mycmakeargs})
773         fi
774
775         mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}")
776
777         cmake-utils_src_configure
778 }
779
780 # @FUNCTION: kde4-base_src_compile
781 # @DESCRIPTION:
782 # General function for compiling KDE4 applications.
783 kde4-base_src_compile() {
784         debug-print-function ${FUNCNAME} "$@"
785
786         cmake-utils_src_compile "$@"
787 }
788
789 # @FUNCTION: kde4-base_src_test
790 # @DESCRIPTION:
791 # Function for testing KDE4 applications.
792 kde4-base_src_test() {
793         debug-print-function ${FUNCNAME} "$@"
794
795         local kded4_pid
796
797         _test_runner() {
798                 if [[ -n "${VIRTUALDBUS_TEST}" ]]; then
799                         export $(dbus-launch)
800                         kded4 2>&1 > /dev/null &
801                         kded4_pid=$!
802                 fi
803
804                 cmake-utils_src_test
805         }
806
807         # When run as normal user during ebuild development with the ebuild command, the
808         # kde tests tend to access the session DBUS. This however is not possible in a real
809         # emerge or on the tinderbox.
810         # > make sure it does not happen, so bad tests can be recognized and disabled
811         unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
812
813         # Override this value, set in kde4-base_src_configure()
814         mycmakeargs+=(-DKDE4_BUILD_TESTS=ON)
815         cmake-utils_src_configure
816         kde4-base_src_compile
817
818         if [[ ${VIRTUALX_REQUIRED} == always || ${VIRTUALX_REQUIRED} == test ]]; then
819                 # check for sanity if anyone already redefined VIRTUALX_COMMAND from the default
820                 if [[ ${VIRTUALX_COMMAND} != emake ]]; then
821                         # surprise- we are already INSIDE virtualmake!!!
822                         debug-print "QA Notice: This version of kde4-base.eclass includes the virtualx functionality."
823                         debug-print "           You may NOT set VIRTUALX_COMMAND or call virtualmake from the ebuild."
824                         debug-print "           Setting VIRTUALX_REQUIRED is completely sufficient. See the"
825                         debug-print "           kde4-base.eclass docs for details... Applying workaround."
826                         _test_runner
827                 else
828                         VIRTUALX_COMMAND="_test_runner" virtualmake
829                 fi
830         else
831                 _test_runner
832         fi
833
834         if [ -n "${kded4_pid}" ] ; then
835                 kill ${kded4_pid}
836         fi
837
838         if [ -n "${DBUS_SESSION_BUS_PID}" ] ; then
839                 kill ${DBUS_SESSION_BUS_PID}
840         fi
841 }
842
843 # @FUNCTION: kde4-base_src_install
844 # @DESCRIPTION:
845 # Function for installing KDE4 applications.
846 kde4-base_src_install() {
847         debug-print-function ${FUNCNAME} "$@"
848
849         if [[ -n ${KMSAVELIBS} ]] ; then
850                 install_library_dependencies
851         fi
852
853         # Install common documentation of KDE4 applications
854         local doc
855         if ! has kde4-meta ${INHERITED}; then
856                 for doc in "${S}"/{AUTHORS,CHANGELOG,ChangeLog*,README*,NEWS,TODO,HACKING}; do
857                         [[ -f ${doc} && -s ${doc} ]] && dodoc "${doc}"
858                 done
859                 for doc in "${S}"/*/{AUTHORS,CHANGELOG,ChangeLog*,README*,NEWS,TODO,HACKING}; do
860                         [[ -f ${doc} && -s ${doc} ]] && newdoc "${doc}" "$(basename $(dirname ${doc})).$(basename ${doc})"
861                 done
862         fi
863
864         cmake-utils_src_install
865
866         # We don't want ${PREFIX}/share/doc/HTML to be compressed,
867         # because then khelpcenter can't find the docs
868         [[ -d ${ED}/${PREFIX}/share/doc/HTML ]] &&
869                 docompress -x ${PREFIX}/share/doc/HTML
870 }
871
872 # @FUNCTION: kde4-base_pkg_preinst
873 # @DESCRIPTION:
874 # Function storing icon caches
875 kde4-base_pkg_preinst() {
876         debug-print-function ${FUNCNAME} "$@"
877
878         gnome2_icon_savelist
879         if [[ ${KDE_BUILD_TYPE} == live && ${KDE_SCM} == svn ]]; then
880                 subversion_pkg_preinst
881         fi
882 }
883
884 # @FUNCTION: kde4-base_pkg_postinst
885 # @DESCRIPTION:
886 # Function to rebuild the KDE System Configuration Cache after an application has been installed.
887 kde4-base_pkg_postinst() {
888         debug-print-function ${FUNCNAME} "$@"
889
890         gnome2_icon_cache_update
891         fdo-mime_desktop_database_update
892         fdo-mime_mime_database_update
893         buildsycoca
894
895         if [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then
896                 if [[ ${KDE_BUILD_TYPE} = live ]]; then
897                         echo
898                         einfo "WARNING! This is an experimental live ebuild of ${CATEGORY}/${PN}"
899                         einfo "Use it at your own risk."
900                         einfo "Do _NOT_ file bugs at bugs.gentoo.org because of this ebuild!"
901                         echo
902                 fi
903                 # for all 3rd party soft tell user that he SHOULD install kdebase-startkde or kdebase-runtime-meta
904                 if [[ ${KDEBASE} != kde-base ]] && \
905                                 ! has_version 'kde-apps/kdebase-runtime-meta'; then
906                         if [[ ${KDE_REQUIRED} == always ]] || ( [[ ${KDE_REQUIRED} == optional ]] && use kde ); then
907                                 echo
908                                 ewarn "WARNING! Your system configuration does not contain \"kde-apps/kdebase-runtime-meta\"."
909                                 ewarn "With this setting you are unsupported by KDE team."
910                                 ewarn "All missing features you report for misc packages will be probably ignored or closed as INVALID."
911                         fi
912                 fi
913         fi
914 }
915
916 # @FUNCTION: kde4-base_pkg_postrm
917 # @DESCRIPTION:
918 # Function to rebuild the KDE System Configuration Cache after an application has been removed.
919 kde4-base_pkg_postrm() {
920         debug-print-function ${FUNCNAME} "$@"
921
922         gnome2_icon_cache_update
923         fdo-mime_desktop_database_update
924         fdo-mime_mime_database_update
925         buildsycoca
926 }
927
928 fi