net-wireless/hostapd: use #!/sbin/openrc-run instead of #!/sbin/runscript
[gentoo.git] / eclass / kde4-meta.eclass
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4 #
5 # @ECLASS: kde4-meta.eclass
6 # @MAINTAINER:
7 # kde@gentoo.org
8 # @BLURB: Eclass for writing "split" KDE packages.
9 # @DESCRIPTION:
10 # This eclass provides all necessary functions for writing split KDE ebuilds.
11 #
12 # You must define KMNAME to use this eclass, and do so before inheriting it. All other variables are optional.
13 # Do not include the same item in more than one of KMMODULE, KMMEXTRA, KMCOMPILEONLY, KMEXTRACTONLY.
14
15 if [[ -z ${_KDE4_META_ECLASS} ]]; then
16 _KDE4_META_ECLASS=1
17
18 [[ -z ${KMNAME} ]] && die "kde4-meta.eclass inherited but KMNAME not defined - broken ebuild"
19
20 inherit kde4-base
21
22 KDEMETA_EXPF="pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm"
23 EXPORT_FUNCTIONS ${KDEMETA_EXPF}
24
25 # Add dependencies that all packages in a certain module share.
26 case ${KMNAME} in
27         kdepim|kdepim-runtime)
28                 case ${PN} in
29                         akregator|kaddressbook|kjots|kmail|knode|knotes|korganizer|ktimetracker)
30                                 IUSE+=" +kontact"
31                                 RDEPEND+=" kontact? ( $(add_kdeapps_dep kontact '' ${PV}) )"
32                                 ;;
33                 esac
34                 ;;
35 esac
36
37 DEPEND+=" ${COMMONDEPEND}"
38 RDEPEND+=" ${COMMONDEPEND}"
39 unset COMMONDEPEND
40
41 debug-print "line ${LINENO} ${ECLASS}: DEPEND ${DEPEND} - after metapackage-specific dependencies"
42 debug-print "line ${LINENO} ${ECLASS}: RDEPEND ${RDEPEND} - after metapackage-specific dependencies"
43
44 # Useful to build kde4-meta style stuff from extragear/playground (plasmoids etc)
45 case ${KDE_BUILD_TYPE} in
46         live)
47                 if [[ ${KDE_SCM} == svn ]]; then
48                         case ${KMNAME} in
49                                 extragear*|playground*)
50                                         ESVN_REPO_URI="${ESVN_MIRROR}/trunk/${KMNAME}"
51                                         ESVN_PROJECT="${KMNAME}${ESVN_PROJECT_SUFFIX}"
52                                         ;;
53                         esac
54                 fi
55                 ;;
56 esac
57
58 # @ECLASS-VARIABLE: KMNAME
59 # @DESCRIPTION:
60 # Name of the parent-module (e.g. kdebase, kdepim, ...). You _must_ set it
61 # _before_ inheriting this eclass, (unlike the other parameters), since it's
62 # used to set $SRC_URI.
63
64 # @ECLASS-VARIABLE: KMMODULE
65 # @DESCRIPTION:
66 # Specify exactly one subdirectory of $KMNAME here. Defaults to $PN.
67 # The subdirectory listed here is treated exactly like items in $KMEXTRA.
68 #
69 # Example: The ebuild name of "kdebase/l10n" is kde-base/kdebase-l10n, because
70 # just 'l10n' would be too confusing. Hence it sets KMMODULE="l10n".
71
72 # @ECLASS-VARIABLE: KMNOMODULE
73 # @DESCRIPTION:
74 # If set to "true", $KMMODULE doesn't have to be defined.
75 #
76 # Example usage: If you're installing subdirectories of a package, like plugins,
77 # you mark the top subdirectory (containing the package) as $KMEXTRACTONLY, and
78 # set KMNOMODULE="true".
79 if [[ -z ${KMMODULE} ]] && [[ ${KMNOMODULE} != true ]]; then
80         KMMODULE=${PN}
81 fi
82
83 # @ECLASS-VARIABLE: KMEXTRA
84 # @DESCRIPTION:
85 # All subdirectories listed here will be extracted, compiled & installed.
86 # $KMMODULE is always added to $KMEXTRA.
87 # If KDE_HANDBOOK is 'always' or 'optional' and handbook USE-flag is set, and if this
88 # directory exists, then "doc/$KMMODULE" is added to $KMEXTRA. If there's additional
89 # documentation in different subdirectories, it should be added to KMEXTRA manually..
90
91 # @ECLASS-VARIABLE: KMCOMPILEONLY
92 # @DESCRIPTION:
93 # All subdirectories listed here will be extracted & compiled, but not installed.
94
95 # TODO: better formulation may be needed
96 # @ECLASS-VARIABLE: KMEXTRACTONLY
97 # @DESCRIPTION:
98 # All subdirectories listed here will be extracted, but neither compiled nor installed.
99 # This can be used to avoid compilation in a subdirectory of a directory in $KMMODULE or $KMEXTRA
100
101 # @ECLASS-VARIABLE: KMTARPARAMS
102 # @DESCRIPTION:
103 # Specify extra parameters to pass to tar, in kde4-meta_src_extract.
104 # '-xpf -j' are passed to tar by default.
105
106 # @FUNCTION: kde4-meta_pkg_setup
107 # @DESCRIPTION:
108 # Currently calls its equivalent in kde4-base.eclass(5) and checks the gcc version.
109 # Use this one in split ebuilds.
110 kde4-meta_pkg_setup() {
111         debug-print-function ${FUNCNAME} "$@"
112
113         kde4-base_pkg_setup
114 }
115
116 # @FUNCTION: kde4-meta_src_unpack
117 # @DESCRIPTION:
118 # This function unpacks the source for split ebuilds.
119 # Further more is processed in kde4-meta_src_extract
120 kde4-meta_src_unpack() {
121         debug-print-function ${FUNCNAME} "$@"
122
123         if [[ ${KDE_BUILD_TYPE} = live ]]; then
124                 case "${KDE_SCM}" in
125                         svn)
126                                 S="${WORKDIR}/${P}"
127                                 mkdir -p "${S}"
128                                 ESVN_RESTRICT="export" subversion_src_unpack
129                                 subversion_wc_info
130                                 subversion_bootstrap
131                                 ;;
132                         git)
133                                 git-r3_src_unpack
134                                 ;;
135                 esac
136         fi
137         kde4-meta_src_extract
138 }
139
140 # @FUNCTION: kde4-meta_src_extract
141 # @DESCRIPTION:
142 # A function to extract the source for a split KDE ebuild.
143 # Also see KMMODULE, KMNOMODULE, KMEXTRA, KMCOMPILEONLY, KMEXTRACTONLY and
144 # KMTARPARAMS.
145 kde4-meta_src_extract() {
146         debug-print-function ${FUNCNAME} "$@"
147
148         if [[ ${KDE_BUILD_TYPE} = live ]]; then
149                 # Export working copy to ${S}
150                 einfo "Exporting parts of working copy to ${S}"
151                 kde4-meta_create_extractlists
152
153                 case ${KDE_SCM} in
154                         svn)
155                                 local rsync_options subdir targetdir wc_path escm
156
157                                 rsync_options="--group --links --owner --perms --quiet --exclude=.svn/ --exclude=.git/"
158                                 wc_path="${ESVN_WC_PATH}"
159                                 escm="{ESVN}"
160
161                                 # Copy ${KMNAME} non-recursively (toplevel files)
162                                 rsync ${rsync_options} "${wc_path}"/* "${S}" \
163                                         || die "${escm}: can't export toplevel files to '${S}'."
164                                 # Copy cmake directory
165                                 if [[ -d "${wc_path}/cmake" ]]; then
166                                         rsync --recursive ${rsync_options} "${wc_path}/cmake" "${S}" \
167                                                 || die "${escm}: can't export cmake files to '${S}'."
168                                 fi
169                                 # Copy all subdirectories
170                                 for subdir in $(_list_needed_subdirectories); do
171                                         targetdir=""
172                                         if [[ $subdir = doc/* && ! -e "$wc_path/$subdir" ]]; then
173                                                 continue
174                                         fi
175
176                                         [[ ${subdir%/} = */* ]] && targetdir=${subdir%/} && targetdir=${targetdir%/*} && mkdir -p "${S}/${targetdir}"
177                                         rsync --recursive ${rsync_options} "${wc_path}/${subdir%/}" "${S}/${targetdir}" \
178                                                 || die "${escm}: can't export subdirectory '${subdir}' to '${S}/${targetdir}'."
179                                 done
180                                 ;;
181                 esac
182         else
183                 local abort tarball tarfile f extractlist postfix
184
185                 if [[ ${PV} =~ 4.4.11 ]]; then
186                         postfix="bz2"
187                         KMTARPARAMS+=" --bzip2"
188                 elif [[ ${PV} =~ _pre ]]; then
189                         postfix="gz"
190                         KMTARPARAMS+=" --gz"
191                 else
192                         postfix="xz"
193                         KMTARPARAMS+=" --xz"
194                 fi
195
196                 tarball="${KMNAME}-${PV}.tar.${postfix}"
197
198                 # Full path to source tarball
199                 tarfile="${DISTDIR}/${tarball}"
200
201                 # Detect real toplevel dir from tarball name - it will be used upon extraction
202                 # and in _list_needed_subdirectories
203                 topdir="${tarball%.tar.*}/"
204                 if [[ ${topdir} =~ _pre ]]; then
205                         topdir="${topdir%-$PV*}/"
206                 fi
207
208                 ebegin "Unpacking parts of ${tarball} to ${WORKDIR}"
209
210                 kde4-meta_create_extractlists
211
212                 for f in cmake/ CMakeLists.txt ConfigureChecks.cmake config.h.cmake
213                 do
214                         extractlist+=" ${topdir}${f}"
215                 done
216                 extractlist+=" $(_list_needed_subdirectories)"
217
218                 pushd "${WORKDIR}" > /dev/null || die
219
220                 # @ECLASS-VARIABLE: KDE4_STRICTER
221                 # @DESCRIPTION:
222                 # Print out all issues found executing tar / kmextract files
223                 # Set on if you want to find issues in kde-base ebuild unpack sequences
224                 [[ -n ${KDE4_STRICTER} ]] && echo 'tar -xpf "${tarfile}" ${KMTARPARAMS} ${extractlist}'
225                 tar -xpf "${tarfile}" ${KMTARPARAMS} ${extractlist} 2> /dev/null || echo "tar extract command failed at least partially - continuing anyway"
226
227                 # Default $S is based on $P; rename the extracted directory to match $S if necessary
228                 if [[ ${KMNAME} != ${PN} ]]; then
229                         mv ${topdir} ${P} || die "Died while moving \"${topdir}\" to \"${P}\""
230                 fi
231
232                 popd > /dev/null || die
233
234                 eend $?
235
236                 if [[ -n ${KDE4_STRICTER} ]]; then
237                         for f in $(_list_needed_subdirectories fatal); do
238                                 if [[ ! -e ${S}/${f#*/} ]]; then
239                                         eerror "'${f#*/}' is missing"
240                                         abort=true
241                                 fi
242                         done
243                         [[ -n ${abort} ]] && die "There were missing files."
244                 fi
245
246                 # We don't need it anymore
247                 unset topdir
248         fi
249 }
250
251 # @FUNCTION: kde4-meta_create_extractlists
252 # @DESCRIPTION:
253 # Create lists of files and subdirectories to extract.
254 # Also see descriptions of KMMODULE, KMNOMODULE, KMEXTRA, KMCOMPILEONLY,
255 # KMEXTRACTONLY and KMTARPARAMS.
256 kde4-meta_create_extractlists() {
257         debug-print-function ${FUNCNAME} "$@"
258
259         # Add default handbook locations
260         # FIXME - legacy code - remove when 4.4.5 is gone or preferrably port 4.4.5.
261         if [[ $(get_kde_version) < 4.5 ]] && use_if_iuse handbook && [[ -z ${KMNOMODULE} ]]; then
262                 # We use the basename of $KMMODULE because $KMMODULE can contain
263                 # the path to the module subdirectory.
264                 KMEXTRA_NONFATAL+="
265                         doc/${KMMODULE##*/}"
266         fi
267
268         # Add default handbook locations
269         if [[ -z ${KMNOMODULE} ]] && ( [[ ${KDE_HANDBOOK} == always ]] || ( [[ ${KDE_HANDBOOK} == optional ]] && use handbook ) ); then
270                 KMEXTRA_NONFATAL+=" doc/${KMMODULE##*/}"
271         fi
272
273         # Add some CMake-files to KMEXTRACTONLY.
274         # Note that this actually doesn't include KMEXTRA handling.
275         # In those cases you should care to add the relevant files to KMEXTRACTONLY
276         case ${KMNAME} in
277                 kde-baseapps)
278                         KMEXTRACTONLY+="
279                                 CTestConfig.cmake
280                                 config-apps.h.cmake
281                                 ConfigureChecks.cmake"
282                         ;;
283                 kde-runtime)
284                         KMEXTRACTONLY+="
285                                 cmake/modules/
286                                 CTestConfig.cmake
287                                 config-runtime.h.cmake"
288                         ;;
289                 kde-workspace)
290                         KMEXTRACTONLY+="
291                                 cmake/modules/
292                                 config-unix.h.cmake
293                                 ConfigureChecks.cmake
294                                 config-workspace.h.cmake
295                                 config-X11.h.cmake
296                                 startkde.cmake
297                                 KDE4WorkspaceConfig.cmake.in"
298                         ;;
299                 kdepim)
300                         if [[ ${PN} != libkdepim ]]; then
301                                 KMEXTRACTONLY+="
302                                         libkdepim/"
303                         fi
304                         KMEXTRACTONLY+="
305                                 config-enterprise.h.cmake
306                                 kleopatra/ConfigureChecks.cmake
307                                 CTestCustom.cmake
308                                 kdepim-version.h.cmake
309                                 kdepim-version.h"
310                         if use_if_iuse kontact; then
311                                 KMEXTRA+="
312                                         kontact/plugins/${PLUGINNAME:-${PN}}/"
313                         fi
314                         ;;
315         esac
316
317         debug-print "line ${LINENO} ${ECLASS} ${FUNCNAME}: KMEXTRACTONLY ${KMEXTRACTONLY}"
318 }
319
320 _list_needed_subdirectories() {
321         local i j kmextra kmextra_expanded kmmodule_expanded kmcompileonly_expanded extractlist
322
323         # We expand KMEXTRA by adding CMakeLists.txt files
324         kmextra="${KMEXTRA}"
325         [[ ${1} != fatal ]] && kmextra+=" ${KMEXTRA_NONFATAL}"
326         for i in ${kmextra}; do
327                 kmextra_expanded+=" ${i}"
328                 j=$(dirname ${i})
329                 while [[ ${j} != "." ]]; do
330                         kmextra_expanded+=" ${j}/CMakeLists.txt";
331                         j=$(dirname ${j})
332                 done
333         done
334
335         # Expand KMMODULE
336         if [[ -n ${KMMODULE} ]]; then
337                 kmmodule_expanded="${KMMODULE}"
338                 j=$(dirname ${KMMODULE})
339                 while [[ ${j} != "." ]]; do
340                         kmmodule_expanded+=" ${j}/CMakeLists.txt";
341                         j=$(dirname ${j})
342                 done
343         fi
344
345         # Expand KMCOMPILEONLY
346         for i in ${KMCOMPILEONLY}; do
347                 kmcompileonly_expanded+=" ${i}"
348                 j=$(dirname ${i})
349                 while [[ ${j} != "." ]]; do
350                         kmcompileonly_expanded+=" ${j}/CMakeLists.txt";
351                         j=$(dirname ${j})
352                 done
353         done
354
355         debug-print "line ${LINENO} ${ECLASS} ${FUNCNAME} - kmextra_expanded: ${kmextra_expanded}"
356         debug-print "line ${LINENO} ${ECLASS} ${FUNCNAME} - kmmodule_expanded:  ${kmmodule_expanded}"
357         debug-print "line ${LINENO} ${ECLASS} ${FUNCNAME} - kmcompileonly_expanded: ${kmcompileonly_expanded}"
358
359         # Create final list of stuff to extract
360         # We append topdir only when specified (usually for tarballs)
361         for i in ${kmmodule_expanded} ${kmextra_expanded} ${kmcompileonly_expanded} \
362                 ${KMEXTRACTONLY}
363         do
364                 extractlist+=" ${topdir}${i}"
365         done
366
367         echo ${extractlist}
368 }
369
370 # @FUNCTION: kde4-meta_src_prepare
371 # @DESCRIPTION:
372 # Meta-package build system configuration handling - commenting out targets, etc..
373 kde4-meta_src_prepare() {
374         debug-print-function ${FUNCNAME} "$@"
375
376         kde4-meta_change_cmakelists
377         kde4-base_src_prepare
378 }
379
380 # @FUNCTION: _change_cmakelists_parent_dirs
381 # @DESCRIPTION:
382 # Adjust CMakeLists.txt to shadow subdirectories
383 # that are not required for the build.
384 _change_cmakelists_parent_dirs() {
385         debug-print-function ${FUNCNAME} "$@"
386
387         local _olddir _dir
388         _dir="${S}"/${1}
389         until [[ ${_dir} == ${S} ]]; do
390                 _olddir=$(basename "${_dir}")
391                 _dir=$(dirname "${_dir}")
392                 debug-print "${LINENO}: processing ${_dir} CMakeLists.txt searching for ${_olddir}"
393                 if [[ -f ${_dir}/CMakeLists.txt ]]; then
394                         sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${_olddir}[[:space:]]*)/s/#DONOTCOMPILE //g" \
395                                 -e "/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${_olddir}[[:space:]]*)/s/#DONOTCOMPILE //g" \
396                                 -i ${_dir}/CMakeLists.txt || die "${LINENO}: died in ${FUNCNAME} while processing ${_dir}"
397                 fi
398         done
399 }
400
401 # @FUNCTION: kde4-meta_change_cmakelists
402 # @DESCRIPTION:
403 # Adjust CMakeLists.txt to comply to our splitting.
404 kde4-meta_change_cmakelists() {
405         debug-print-function ${FUNCNAME} "$@"
406
407         pushd "${S}" > /dev/null || die
408
409         comment_all_add_subdirectory ./
410
411         # Restore "add_subdirectory( cmake )" in ${S}/CMakeLists.txt
412         if [[ -f CMakeLists.txt ]]; then
413                 sed -e '/add_subdirectory[[:space:]]*([[:space:]]*cmake[[:space:]]*)/s/^#DONOTCOMPILE //' \
414                         -e '/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*cmake[[:space:]]*)/s/^#DONOTCOMPILE //' \
415                         -i CMakeLists.txt || die "${LINENO}: cmake sed died"
416         fi
417
418         # Restore "add_subdirectory( ${ ..." (this is done in kdesdk)
419         if [[ -f CMakeLists.txt ]]; then
420                 sed -e '/add_subdirectory[[:space:]]*([[:space:]]*\${/s/^#DONOTCOMPILE //' \
421                         -e '/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*\${/s/^#DONOTCOMPILE //' \
422                         -i CMakeLists.txt || die "${LINENO}: cmake sed died"
423         fi
424
425         if [[ -z ${KMNOMODULE} ]]; then
426                 # Restore "add_subdirectory" in $KMMODULE subdirectories
427                 find "${S}"/${KMMODULE} -name CMakeLists.txt -print0 | \
428                         xargs -0 sed -i -e 's/^#DONOTCOMPILE //g' || \
429                                 die "${LINENO}: died in KMMODULE section"
430                 _change_cmakelists_parent_dirs ${KMMODULE}
431         fi
432
433         local i
434
435         # KMEXTRACTONLY section - Some ebuilds need to comment out some subdirs in KMMODULE and they use KMEXTRACTONLY
436         for i in ${KMEXTRACTONLY}; do
437                 if [[ -d ${i} && -f ${i}/../CMakeLists.txt ]]; then
438                         sed -e "/([[:space:]]*$(basename $i)[[:space:]]*)/s/^/#DONOTCOMPILE /" \
439                                 -i ${i}/../CMakeLists.txt || \
440                                 die "${LINENO}: sed died while working in the KMEXTRACTONLY section while processing ${i}"
441                 fi
442         done
443
444         # KMCOMPILEONLY
445         for i in ${KMCOMPILEONLY}; do
446                 debug-print "${LINENO}: KMCOMPILEONLY, processing ${i}"
447                 # Uncomment "add_subdirectory" instructions inside $KMCOMPILEONLY, then comment "install" instructions.
448                 find "${S}"/${i} -name CMakeLists.txt -print0 | \
449                         xargs -0 sed -i \
450                                 -e 's/^#DONOTCOMPILE //g' \
451                                 -e '/install(.*)/I{s/^/#DONOTINSTALL /;}' \
452                                 -e '/^install(/,/)/I{s/^/#DONOTINSTALL /;}' \
453                                 -e '/kde4_install_icons(.*)/I{s/^/#DONOTINSTALL /;}' || \
454                                 die "${LINENO}: sed died in the KMCOMPILEONLY section while processing ${i}"
455                 _change_cmakelists_parent_dirs ${i}
456         done
457
458         # KMEXTRA section
459         for i in ${KMEXTRA}; do
460                 debug-print "${LINENO}: KMEXTRA section, processing ${i}"
461                 find "${S}"/${i} -name CMakeLists.txt -print0 | \
462                         xargs -0 sed -i -e 's/^#DONOTCOMPILE //g' || \
463                         die "${LINENO}: sed died uncommenting add_subdirectory instructions in KMEXTRA section while processing ${i}"
464                 _change_cmakelists_parent_dirs ${i}
465         done
466         # KMEXTRA_NONFATAL section
467         for i in ${KMEXTRA_NONFATAL}; do
468                 if [[ -d "${S}"/${i} ]]; then
469                         find "${S}"/${i} -name CMakeLists.txt -print0 | \
470                                 xargs -0 sed -i -e 's/^#DONOTCOMPILE //g' || \
471                                         die "${LINENO}: sed died uncommenting add_subdirectory instructions in KMEXTRA section while processing ${i}"
472                         _change_cmakelists_parent_dirs ${i}
473                 fi
474         done
475
476         case ${KMNAME} in
477                 kde-workspace)
478                         # COLLISION PROTECT section
479                         # Install the startkde script just once, as a part of kde-base/kdebase-startkde,
480                         # not as a part of every package.
481                         if [[ ${PN} != kdebase-startkde && -f CMakeLists.txt ]]; then
482                                 # The startkde script moved to kdebase-workspace for KDE4 versions > 3.93.0.
483                                 sed -e '/startkde/s/^/#DONOTINSTALL /' \
484                                         -i CMakeLists.txt || die "${LINENO}: sed died in the kdebase-startkde collision prevention section"
485                         fi
486                         # Remove workspace target prefix in order to get direct linking to workspace libs
487                         sed -e '/set(KDE4WORKSPACE_TARGET_PREFIX/s/^/#OVERRIDE /' \
488                                 -i CMakeLists.txt || die "${LINENO}: sed died in KDE4WORKSPACE_TARGET_PREFIX removal section"
489                         # Strip EXPORT feature section from workspace for KDE4 versions > 4.1.82
490                         if [[ ${PN} != libkworkspace ]]; then
491                                 sed -e '/install(FILES ${CMAKE_CURRENT_BINARY_DIR}\/KDE4WorkspaceConfig.cmake/,/^[[:space:]]*FILE KDE4WorkspaceLibraryTargets.cmake )[[:space:]]*^/d' \
492                                         -i CMakeLists.txt || die "${LINENO}: sed died in kde-workspace strip config install and fix EXPORT section"
493                         fi
494                         # <KDE/4.11
495                         if [[ ${PN} != plasma-workspace ]]; then
496                                 sed -e '/KActivities/s/REQUIRED//' \
497                                         -i CMakeLists.txt || die "${LINENO}: sed died in kde-workspace dep reduction section"
498                         fi
499                         sed -e '/QImageBlitz/s/REQUIRED//' \
500                                 -i CMakeLists.txt || die "${LINENO}: sed died in kde-workspace dep reduction section 2"
501
502                         # >=KDE/4.11
503                         sed -e 's/TYPE REQUIRED/TYPE OPTIONAL/' -e 's/XCB REQUIRED/XCB/' -e 's/X11 REQUIRED/X11/' \
504                                 -e 's/message(FATAL_ERROR/message(/' -i CMakeLists.txt \
505                                 || die "${LINENO}: sed died in kde-workspace dep reduction section"
506                         if [[ "${PN}" != "kwin" ]]; then
507                                 sed -i -e "/^    macro_log_feature(OPENGL_OR_ES_FOUND/s/TRUE/FALSE/" \
508                                         "${S}"/CMakeLists.txt || die "${LINENO}: sed died removing kde-workspace opengl dependency"
509                         fi
510                         ;;
511                 kde-runtime)
512                         sed -e 's/TYPE REQUIRED/TYPE OPTIONAL/' -e '/LibGcrypt/s/REQUIRED//' -i CMakeLists.txt \
513                                 || die "${LINENO}: sed died in kde-runtime dep reduction section"
514
515                         # COLLISION PROTECT section
516                         # Only install the kde4 script as part of kde-base/kdebase-data
517                         if [[ ${PN} != kdebase-data && -f CMakeLists.txt ]]; then
518                                 sed -e '/^install(PROGRAMS[[:space:]]*[^[:space:]]*\/kde4[[:space:]]/s/^/#DONOTINSTALL /' \
519                                         -i CMakeLists.txt || die "Sed to exclude bin/kde4 failed"
520                         fi
521                         ;;
522                 kdenetwork)
523                         # Disable hardcoded kdepimlibs check
524                         sed -e 's/find_package(KdepimLibs REQUIRED)/macro_optional_find_package(KdepimLibs)/' \
525                                 -i CMakeLists.txt || die "failed to disable hardcoded checks"
526                         ;;
527                 kdepim)
528                         # Disable hardcoded checks
529                         sed -r -e 's/TYPE REQUIRED/TYPE OPTIONAL/' -e '/find_package\(KdepimLibs/s/REQUIRED//' \
530                                 -e '/find_package\((KdepimLibs|Boost|QGpgme|Akonadi|ZLIB|Strigi|SharedDesktopOntologies|Soprano|Nepomuk)/{/macro_optional_/!s/find/macro_optional_&/}' \
531                                 -e '/macro_log_feature\((Boost|QGPGME|Akonadi|ZLIB|STRIGI|SHAREDDESKTOPONTOLOGIES|Soprano|Nepomuk)_FOUND/s/ TRUE / FALSE /' \
532                                 -e 's/if[[:space:]]*([[:space:]]*BUILD_.*)[[:space:]]*/if(1) # &/' \
533                                 -e 's/if[[:space:]]*([[:space:]]*[[:alnum:]]*_FOUND[[:space:]]*)[[:space:]]*$/if(1) # &/' \
534                                 -i CMakeLists.txt || die "failed to disable hardcoded checks"
535                         # Disable broken or redundant build logic
536                         if use_if_iuse kontact || [[ ${PN} = kontact ]]; then
537                                 sed -e 's/if[[:space:]]*([[:space:]]*BUILD_.*)[[:space:]]*$/if(1) # &/' \
538                                         -e 's/if[[:space:]]*([[:space:]]*[[:alnum:]]*_FOUND[[:space:]]*)[[:space:]]*$/if(1) # &/' \
539                                         -i kontact/plugins/CMakeLists.txt || die 'failed to override build logic'
540                         fi
541                         case ${PV} in
542                                 4.4*)
543                                         case ${PN} in
544                                                 kalarm|kmailcvt|kontact|korganizer|korn)
545                                                         sed -n -e '/qt4_generate_dbus_interface(.*org\.kde\.kmail\.\(kmail\|mailcomposer\)\.xml/p' \
546                                                                 -e '/add_custom_target(kmail_xml /,/)/p' \
547                                                                 -i kmail/CMakeLists.txt || die "uncommenting xml failed"
548                                                         _change_cmakelists_parent_dirs kmail
549                                                         ;;
550                                         esac
551                                         ;;
552                         esac
553                         ;;
554         esac
555
556         popd > /dev/null || die
557 }
558
559 # @FUNCTION: kde4-meta_src_configure
560 # @DESCRIPTION:
561 # Currently just calls its equivalent in kde4-base.eclass(5). Use this one in split
562 # ebuilds.
563 kde4-meta_src_configure() {
564         debug-print-function ${FUNCNAME} "$@"
565
566         kde4-base_src_configure
567 }
568
569 # @FUNCTION: kde4-meta_src_compile
570 # @DESCRIPTION:
571 # General function for compiling split KDE4 applications.
572 # Overrides kde4-base_src_compile.
573 kde4-meta_src_compile() {
574         debug-print-function ${FUNCNAME} "$@"
575
576         kde4-base_src_compile "$@"
577 }
578
579 # @FUNCTION: kde4-meta_src_test
580 # @DESCRIPTION:
581 # Currently just calls its equivalent in kde4-base.eclass(5) if
582 # I_KNOW_WHAT_I_AM_DOING is set. Use this in split ebuilds.
583 kde4-meta_src_test() {
584         debug-print-function ${FUNCNAME} "$@"
585
586         if [[ $I_KNOW_WHAT_I_AM_DOING ]]; then
587                 kde4-base_src_test
588         else
589                 einfo "Tests disabled"
590         fi
591 }
592
593 # @FUNCTION: kde4-meta_src_install
594 # @DESCRIPTION:
595 # Function for installing KDE4 split applications.
596 kde4-meta_src_install() {
597         debug-print-function ${FUNCNAME} "$@"
598
599         # Search ${S}/${KMMODULE} and install common documentation files found
600         local doc
601         for doc in "${S}/${KMMODULE}"/{AUTHORS,CHANGELOG,ChangeLog*,README*,NEWS,TODO,HACKING}; do
602                 [[ -f "${doc}" ]] && [[ -s "${doc}" ]] && dodoc "${doc}"
603         done
604
605         kde4-base_src_install
606 }
607
608 # @FUNCTION: kde4-meta_pkg_preinst
609 # @DESCRIPTION:
610 # Invoke its equivalent in kde4-base.eclass.
611 kde4-meta_pkg_preinst() {
612         debug-print-function ${FUNCNAME} "$@"
613
614         kde4-base_pkg_preinst
615 }
616
617 # @FUNCTION: kde4-meta_pkg_postinst
618 # @DESCRIPTION:
619 # Invoke kbuildsycoca4.
620 kde4-meta_pkg_postinst() {
621         debug-print-function ${FUNCNAME} "$@"
622
623         kde4-base_pkg_postinst
624 }
625
626 # @FUNCTION: kde4-meta_pkg_postrm
627 # @DESCRIPTION:
628 # Currently just calls its equivalent in kde4-base.eclass(5). Use this in split
629 # ebuilds.
630 kde4-meta_pkg_postrm() {
631         debug-print-function ${FUNCNAME} "$@"
632
633         kde4-base_pkg_postrm
634 }
635
636 fi