1 # Copyright 1999-2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/kde.eclass,v 1.223 2009/05/12 12:55:46 tampakrap Exp $
9 # original author Dan Armak <danarmak@gentoo.org>
11 # Revisions Caleb Tennis <caleb@gentoo.org>
12 # @BLURB: The kde eclass is inherited by all kde-* eclasses.
14 # This eclass is inherited by all kde-* eclasses. Few ebuilds inherit straight from here.
16 [[ -z ${WANT_AUTOMAKE} ]] && WANT_AUTOMAKE
="1.9"
18 inherit base eutils kde-functions flag-o-matic libtool autotools
20 DESCRIPTION
="Based on the $ECLASS eclass"
21 HOMEPAGE
="http://www.kde.org/"
22 IUSE
="debug elibc_FreeBSD"
25 if [[ ${CATEGORY} == "kde-base" ]]; then
26 if [[ ${PV##*.} -lt 10 ]] ; then
27 # Keep old ebuilds as is
28 IUSE
="${IUSE} kdeenablefinal"
30 # Don't use --enable-final anymore. Does only cause problems for users and
31 # as an unwelcome extra invalid bug reports, without any reasonable benefit.
33 # Get the aRts dependencies right - finally.
35 blinken|juk|kalarm|kanagram|kbounce|kcontrol|konq-plugins|kscd|kscreensaver|kttsd|kwifimanager|kdelibs
) ARTS_REQUIRED
="" ;;
36 artsplugin-
*|kaboodle|kasteroids|kdemultimedia-arts|kolf|krec|ksayit|noatun
*) ARTS_REQUIRED
="yes" ;;
37 *) ARTS_REQUIRED
="never" ;;
42 if [[ ${ARTS_REQUIRED} != "yes" && ${ARTS_REQUIRED} != "never" && ${PN} != "arts" ]]; then
46 # @ECLASS-VARIABLE: KDE_S
48 # Like the 'normal' ${S} this variable takes the path to the temporary build
49 # directory. If unset ${S} will be used.
51 # @ECLASS-VARIABLE: USE_KEG_PACKAGING
53 # Set USE_KEG_PACKAGING=1 before inheriting if the package use extragear-like
54 # packaging and then supports ${LANGS} and ${LANGS_DOC} variables. By default
55 # translations are found in the po subdirectory of ${S}. Set KEG_PO_DIR to
56 # override this default.
57 if [[ -n ${USE_KEG_PACKAGING} && -n "${LANGS}${LANGS_DOC}" ]]; then
58 for lang in ${LANGS} ${LANGS_DOC}; do
59 IUSE="${IUSE} linguas_
${lang}"
63 DEPEND="sys-devel
/make
67 if [[ ${CATEGORY} != "kde-base" ]] || [[ ${CATEGORY} == "kde-base" && ${PV##*.} -lt 10 ]] ; then
70 x11-proto
/xf86vidmodeproto
71 xinerama?
( x11-proto
/xineramaproto
)"
72 RDEPEND="xinerama?
( x11-libs
/libXinerama
)"
73 IUSE="${IUSE} xinerama
"
78 if [[ ${ARTS_REQUIRED} == "yes" ]]; then
79 DEPEND="${DEPEND} kde-base
/arts
"
80 RDEPEND="${RDEPEND} kde-base
/arts
"
81 elif [[ ${ARTS_REQUIRED} != "never
" && ${PN} != "arts
" ]]; then
82 DEPEND="${DEPEND} arts?
( kde-base
/arts
)"
83 RDEPEND="${RDEPEND} arts?
( kde-base
/arts
)"
86 # overridden in other places like kde-dist, kde-source and some individual ebuilds
89 # @ECLASS-VARIABLE: ARTS_REQUIRED
91 # Is aRTs-support required or not? Possible values are 'yes', 'never'. Otherwise
92 # leave this variable unset. This results in an arts USE flag.
94 # @FUNCTION: kde_pkg_setup
96 # Some basic test about arts-support. It also filters some compiler flags
98 if [[ ${PN} != "arts
" ]] && [[ ${PN} != "kdelibs
" ]] ; then
99 if [[ ${ARTS_REQUIRED} == 'yes' ]] || \
100 ( [[ ${ARTS_REQUIRED} != "never
" ]] && use arts ) ; then
101 if ! built_with_use =kde-base/kdelibs-3.5* arts ; then
102 if has arts ${IUSE} && use arts; then
103 eerror "You are trying to compile
${CATEGORY}/${PF} with the
\"arts
\" USE flag enabled.
"
105 eerror "The package
${CATEGORY}/${PF} you
're trying to merge requires aRTs."
107 eerror "However, $(best_version =kde-base/kdelibs-3.5*) was compiled with the arts USE flag disabled."
109 if has arts ${IUSE} && use arts; then
110 eerror "You must either disable this USE flag, or recompile"
112 eerror "To build this package you have to recompile"
114 eerror "$(best_version =kde-base/kdelibs-3.5*) with the arts USE flag enabled."
115 die "kdelibs missing arts"
120 if [[ "${PN}" = "kdelibs" ]]; then
121 use doc && if ! built_with_use =x11-libs/qt-meta-3* doc ; then
122 eerror "Building kdelibs with the doc USE flag requires qt to be built with the doc USE flag."
123 eerror "Please re-emerge qt-3 with this USE flag enabled."
127 # Let filter visibility flags that will *really* hurt your KDE
128 # _experimental_ support for this is enabled by kdehiddenvisibility useflag
129 filter-flags -fvisibility=hidden -fvisibility-inlines-hidden
132 # @FUNCTION: kde_src_unpack
134 # This function unpacks the sources.
135 # For EAPI 0 and 1 it allso runs kde_src_prepare.
137 debug-print-function $FUNCNAME "$@"
138 [[ -z "$*" ]] || die "$FUNCNAME no longer supports stages."
139 [[ -z "${KDE_S}" ]] && KDE_S="${S}"
140 # Don't use base_src_unpack
, as that will call base_src_prepare
142 [[ -d "${KDE_S}" ]] || unpack
${A}
144 0|
1) kde_src_prepare
;;
148 # @FUNCTION: kde_src_prepare
150 # This function patches the sources. The patches need to be named
151 # $PN-$PV-*{diff,patch}
153 # This function also handles the linguas if extragear-like packaging is enabled.
154 # (See USE_KEG_PACKAGING)
156 debug-print-function
$FUNCNAME "$@"
157 local PATCHDIR
="${WORKDIR}/patches/"
159 # Unpack first and deal with KDE patches after examing possible patch sets.
160 # To be picked up, patches need to be named $PN-$PV-*{diff,patch} and be
161 # placed in $PATCHDIR. Monolithic ebuilds will use the split ebuild patches.
162 if [[ -d "${PATCHDIR}" ]] ; then
164 if is-parent-package
${CATEGORY}/${PN} ; then
165 packages
="$(get-child-packages ${CATEGORY}/${PN})"
166 packages
="${packages//${CATEGORY}\//} ${PN}"
170 if [[ -n ${PATCHES[@]} && $
(declare -p PATCHES
) != 'declare -a '* ]]; then
173 for p
in ${packages}; do
174 for f
in "${PATCHDIR}"/${p}-${PV}-*{diff,patch}; do
175 [[ -e ${f} ]] && PATCHES+=("${f}")
177 if [[ -n "${KDEBASE}" ]]; then
178 for f in "${PATCHDIR}"/${p}-${SLOT}-*{diff,patch}; do
179 [[ -e ${f} ]] && PATCHES
+=("${f}")
187 # if extragear-like packaging is enabled, set the translations and the
188 # documentation depending on LINGUAS settings
189 if [[ -n ${USE_KEG_PACKAGING} ]]; then
190 if [[ -z ${LINGUAS} ]]; then
191 einfo
"You can drop some of the translations of the interface and"
192 einfo
"documentation by setting the \${LINGUAS} variable to the"
193 einfo
"languages you want installed."
195 einfo
"Enabling all languages"
197 # we sanitise LINGUAS to avoid issues when a user specifies the same
198 # linguas twice. bug #215016.
199 local sanitised_linguas
=$
(echo "${LINGUAS}" |
tr '[[:space:]]' '\n' |
sort |
uniq)
200 if [[ -n ${LANGS} ]]; then
201 MAKE_PO
=$
(echo "${sanitised_linguas} ${LANGS}" |
tr '[[:space:]]' '\n' |
sort |
uniq -d |
tr '\n' ' ')
202 einfo
"Enabling translations for: ${MAKE_PO}"
203 sed -i -e "s:^SUBDIRS[ \t]*=.*:SUBDIRS = ${MAKE_PO}:" "${KDE_S}/${KEG_PO_DIR:-po}/Makefile.am" \
204 || die
"sed for locale failed"
205 rm -f "${KDE_S}/configure"
208 if [[ -n ${LANGS_DOC} ]]; then
209 MAKE_DOC
=$
(echo "${sanitised_linguas} ${LANGS_DOC}" |
tr '[[:space:]]' '\n' |
sort |
uniq -d |
tr '\n' ' ')
210 einfo
"Enabling documentation for: ${MAKE_DOC}"
211 [[ -n ${MAKE_DOC} ]] && [[ -n ${DOC_DIR_SUFFIX} ]] && MAKE_DOC=$(echo "${MAKE_DOC}" | tr '\n' ' ') && MAKE_DOC="${MAKE_DOC// /${DOC_DIR_SUFFIX} }"
212 sed -i -e "s
:^SUBDIRS
[ \t]*=.
*:SUBDIRS
= ${MAKE_DOC} ${PN}:" \
213 "${KDE_S}/doc
/Makefile.am
" || die "sed for locale failed
"
214 rm -f "${KDE_S}/configure
"
219 # fix the 'languageChange undeclared' bug group: touch all .ui files, so that the
220 # makefile regenerate any .cpp and .h files depending on them.
222 debug-print "$FUNCNAME: Searching
for .ui files
in ${PWD}"
223 UIFILES="$
(find .
-name '*.ui' -print)"
224 debug-print "$FUNCNAME: .ui files found
:"
225 debug-print "$UIFILES"
226 # done in two stages, because touch doens't have a silent/force mode
227 if [[ -n "$UIFILES" ]]; then
228 debug-print "$FUNCNAME: touching .ui files...
"
232 if [[ -d "${WORKDIR}/admin
" ]] && [[ -d "${KDE_S}/admin
" ]]; then
233 ebegin "Updating admin
/ directory...
"
234 rm -rf "${KDE_S}/admin
" "${KDE_S}/configure
" || die "Unable to remove old admin
/ directory
"
235 ln -s "${WORKDIR}/admin
" "${KDE_S}/admin
" || die "Unable to symlink the new admin
/ directory
"
240 # @FUNCTION: kde_src_configure
241 # @USAGE: [ myconf ] [ configure ] [ all ]
243 # This function compiles the sources. It takes care of "cannot
write to .kde
244 # or .qt"-problem due to sandbox and some other sandbox issues.
246 # If no argument is given, all is assumed.
247 kde_src_configure
() {
248 debug-print-function
$FUNCNAME "$@"
250 [[ -z "$1" ]] && kde_src_configure all
252 [[ -z "${KDE_S}" ]] && KDE_S
="${S}"
255 export kde_widgetdir
="$KDEDIR/$(get_libdir)/kde3/plugins/designer"
257 # fix the sandbox errors "can't writ to .kde or .qt" problems.
258 # this is a fake homedir that is writeable under the sandbox, so that the build process
259 # can do anything it wants with it.
261 mkdir
-p "${T}"/fakehome
/.kde
262 mkdir
-p "${T}"/fakehome
/.qt
263 export HOME
="${T}"/fakehome
264 addwrite
"${QTDIR}/etc/settings"
266 # Fix bug 96177: if KDEROOTHOME is defined, the ebuild accesses the real homedir via it, and not our exported $HOME
270 # things that should access the real homedir
271 [[ -d "$REALHOME/.ccache" ]] && ln -sf "$REALHOME/.ccache" "$HOME/"
277 debug-print-section myconf
278 if [[ ${CATEGORY} != "kde-base" ]] || [[ ${CATEGORY} == "kde-base" && ${PV##*.} -lt 10 ]] ; then
279 myconf
+=" --with-x --enable-mitshm $(use_with xinerama) --with-qt-dir=${QTDIR} --enable-mt --with-qt-libraries=${QTDIR}/$(get_libdir)"
281 myconf
+=" --with-qt-dir=${QTDIR} --enable-mt --with-qt-libraries=${QTDIR}/$(get_libdir)"
283 # calculate dependencies separately from compiling, enables ccache to work on kde compiles
284 myconf
="$myconf --disable-dependency-tracking"
286 myconf
="$myconf --enable-debug=full --with-debug"
288 myconf
="$myconf --disable-debug --without-debug"
290 if hasq kdeenablefinal
${IUSE}; then
291 myconf
="$myconf $(use_enable kdeenablefinal final)"
293 if [[ ${ARTS_REQUIRED} == "never" ]]; then
294 myconf
="$myconf --without-arts"
295 elif [[ ${ARTS_REQUIRED} != 'yes' && ${PN} != "arts" ]]; then
296 # This might break some external package until
297 # ARTS_REQUIRED="yes" is set on them, KDE 3.2 is no more
299 myconf
="$myconf $(use_with arts)"
301 debug-print
"$FUNCNAME: myconf: set to ${myconf}"
304 debug-print-section configure
305 debug-print
"$FUNCNAME::configure: myconf=$myconf"
309 # rebuild configure script, etc
310 # This can happen with e.g. a cvs snapshot
311 if [[ ! -f "./configure" ]]; then
312 # This is needed to fix building with autoconf 2.60.
313 # Many thanks to who preferred such a stupid check rather
314 # than a working arithmetic comparison.
315 if [[ -f admin
/cvs.sh
]]; then
316 sed -i -e '/case $AUTO\(CONF\|HEADER\)_VERSION in/,+1 s/2\.5/2.[56]/g' \
320 # Replace the detection script with a dummy, let our wrappers do the work
321 if [[ -f admin
/detect-autoconf.sh
]]; then
322 cat - > admin
/detect-autoconf.sh
<<EOF
324 export AUTOCONF="autoconf"
325 export AUTOHEADER="autoheader"
326 export AUTOM4TE="autom4te"
327 export AUTOMAKE="automake"
328 export ACLOCAL="aclocal"
333 # Make build succeed with >=autoconf-2.65, see http://tinyurl.com/yc4nbhq
334 if [[ -f admin
/acinclude.
m4.
in ]] && \
335 [[ ! -f ${T}/acinclude.
m4.
in ]]; then
336 cp admin
/acinclude.
m4.
in "${T}"
337 einfo
"Patching admin/acinclude.m4.in"
338 patch -f --ignore-whitespace admin
/acinclude.
m4.
in <<'EOF'
339 --- admin/acinclude.m4.in
340 +++ admin/acinclude.m4.in
341 @@ -3081,6 +3081,13 @@
345 +AC_DEFUN([GENTOO_DUMMY_CFLAGS],
347 + dnl this prevents stupid AC_PROG_CC to add "-g" to the default CFLAGS
350 +AC_BEFORE([GENTOO_DUMMY_CFLAGS],[AC_PROG_CC])
352 AC_DEFUN([AC_CHECK_COMPILERS],
355 @@ -3141,12 +3148,10 @@
356 [kde_use_profiling="no"]
359 - dnl this prevents stupid AC_PROG_CC to add "-g" to the default CFLAGS
363 + AC_REQUIRE([GENTOO_DUMMY_CFLAGS])
364 + AC_REQUIRE([AC_PROG_CC])
367 + AC_REQUIRE([AC_PROG_CPP])
369 if test "$GCC" = "yes"; then
370 if test "$kde_use_debug_code" != "no"; then
371 @@ -3176,7 +3181,7 @@
373 CXXFLAGS=" $CXXFLAGS"
376 + AC_REQUIRE([AC_PROG_CXX])
378 KDE_CHECK_FOR_BAD_COMPILER
381 if [[ $?
!= 0 ]]; then
382 ewarn
"Failed to patch admin/acinclude.m4.in"
383 cp "${T}/acinclude.m4.in" admin
/acinclude.
m4.
in
386 for x
in Makefile.cvs admin
/Makefile.common
; do
387 if [[ -f "$x" && -z "$makefile" ]]; then makefile
="$x"; fi
389 if [[ -f "$makefile" ]]; then
390 debug-print
"$FUNCNAME: configure: generating configure script, running make -f $makefile"
393 [[ -f "./configure" ]] || die
"no configure script found, generation unsuccessful"
396 export PATH
="${KDEDIR}/bin:${PATH}"
398 # configure doesn't need to know about the other KDEs installed.
399 # in fact, if it does, it sometimes tries to use the wrong dcopidl, etc.
400 # due to the messed up way configure searches for things
401 export KDEDIRS
="${PREFIX}:${KDEDIR}"
403 # Visiblity stuff is broken. Just disable it when it's present.
404 export kde_cv_prog_cxx_fvisibility_hidden
=no
406 if hasq kdehiddenvisibility
${IUSE} && use kdehiddenvisibility
; then
407 if [[ $
(gcc-major-version
)$
(gcc-minor-version
) -ge 41 ]]; then
408 if [[ ${PN} != "kdelibs" && ${PN} != "arts" ]] && \
409 ! fgrep
-q "#define __KDE_HAVE_GCC_VISIBILITY" "${KDEDIR}/include/kdemacros.h"; then
411 eerror
"You asked to enable hidden visibility, but your kdelibs was"
412 eerror
"built without its support. Please rebuild kdelibs with the"
413 eerror
"kdehiddenvisibility useflag enabled."
414 die
"kdelibs without hidden visibility"
416 unset kde_cv_prog_cxx_fvisibility_hidden
417 myconf
="$myconf $(use_enable kdehiddenvisibility gcc-hidden-visibility)"
420 eerror
"You're trying to enable hidden visibility, but"
421 eerror
"you are using an old GCC version. Hidden visibility"
422 eerror
"can be enabled only with GCC 4.1 and later."
426 # If we're in a kde-base ebuild, set the prefixed directories to
427 # override the ones set by econf.
428 if [[ -n ${PREFIX} && ${PREFIX} != "/usr" ]]; then
429 myconf
="${myconf} --prefix=${PREFIX}
430 --mandir=${PREFIX}/share/man
431 --infodir=${PREFIX}/share/info
432 --datadir=${PREFIX}/share
433 --sysconfdir=${PREFIX}/etc"
436 # Use libsuffix to keep KDE happy, the --libdir parameter get
438 if [[ $
(get_libdir
) != "lib" ]] ; then
439 myconf
="${myconf} --enable-libsuffix=$(get_libdir | sed s/lib//)"
442 export PATH
="${KDEDIR}/bin:${PATH}"
444 # The configure checks for kconfig_compiler do not respect PATH
445 export KCONFIG_COMPILER
="${KDEDIR}/bin/kconfig_compiler"
447 # Sometimes it doesn't get the include and library paths right,
449 if [[ -z ${PREFIX} || ${PREFIX} != ${KDEDIR} ]]; then
450 myconf
="${myconf} --with-extra-includes=${KDEDIR}/include
451 --with-extra-libs=${KDEDIR}/$(get_libdir)"
454 if grep "cope with newer libtools" "${KDE_S}/admin/ltconfig" &> /dev
/null
; then
455 einfo
"Removing the dummy ltconfig file."
456 rm "${KDE_S}/admin/ltconfig"
459 use elibc_FreeBSD
&& myconf
="${myconf} --disable-pie"
464 # Seems ./configure add -O2 by default but hppa don't want that but we need -ffunction-sections
465 if [[ "${ARCH}" = "hppa" ]]
467 einfo
"Fixing Makefiles"
468 find "${KDE_S}" -name Makefile
-print0 |
xargs -0 sed -i -e \
469 's:-O2:-ffunction-sections:g'
473 debug-print-section all
474 kde_src_configure myconf configure
482 # @FUNCTION: kde_src_compile
483 # @USAGE: [ myconf ] [ configure ] [ make ] [ all ]
485 # This function compiles the sources. It takes care of "cannot write to .kde
486 # or .qt"-problem due to sandbox and some other sandbox issues.
488 # If no argument is given, all is assumed.
490 debug-print-function
$FUNCNAME "$@"
492 [[ -z "$1" ]] && kde_src_compile all
494 [[ -z "${KDE_S}" ]] && KDE_S
="${S}"
499 debug-print-section
make
500 emake || die
"died running emake, $FUNCNAME:make"
504 0|
1) kde_src_configure all
;;
510 0|
1) kde_src_configure
$1 ;;
519 # @FUNCTION: kde_src_install
520 # @USAGE: [ make ] [ dodoc ] [ all ]
522 # This installs the software, including the right handling of the
523 # "/usr/share/doc/kde"-dir, but it only installs AUTHORS, ChangeLog*, README*,
524 # NEWS, and TODO (if available) as docs.
526 # If no argument is given, all is assumed
528 debug-print-function
$FUNCNAME "$@"
530 [[ -z "$1" ]] && kde_src_install all
532 [[ -z ${KDE_S} ]] && KDE_S
="${S}"
535 # Ensure that KDE binaries take precedence
536 export PATH
="${KDEDIR}/bin:${PATH}"
542 debug-print-section
make
543 emake
install DESTDIR
="${D}" destdir
="${D}" || die
"died running make install, $FUNCNAME:make"
546 debug-print-section dodoc
547 for doc
in AUTHORS ChangeLog
* README
* NEWS TODO
; do
548 [[ -s "$doc" ]] && dodoc
$doc
552 debug-print-section all
553 kde_src_install
make dodoc
560 if [[ -n ${KDEBASE} && "${PN}" != "arts" && -d "${D}"/usr/share/doc/${PF} ]]; then
561 # work around bug #97196
562 dodir
/usr
/share
/doc
/kde
&& \
563 mv "${D}"/usr/share/doc/${PF} "${D}"/usr
/share
/doc
/kde
/ || \
564 die
"Failed to move docs to kde/ failed."
568 # @FUNCTION: slot_rebuild
569 # @USAGE: [ list_of_packages_to_check ]
570 # @RETURN: False, if no rebuild is required
572 # Unneeded and therefore deprecated for a long, long time now. Ebuilds are still
573 # referencing it, so replacing with a stub.
574 # Looks for packages in the supplied list of packages which have not been linked
575 # against this kde SLOT. It does this by looking for lib*.la files that doesn't
576 # contain the current ${KDEDIR}. If it finds any thus broken packages it prints
577 # eerrors and return True.
579 # Thanks to Carsten Lohrke in bug 98425.
584 # @FUNCTION: kde_pkg_preinst
586 # Calls postprocess_desktop_entries
588 postprocess_desktop_entries
591 # @FUNCTION: kde_pkg_postinst
598 # @FUNCTION: kde_pkg_postrm
606 0|
1) EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_postrm pkg_preinst
;;
607 2) EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_postinst pkg_postrm pkg_preinst
;;