/[gentoo-x86]/eclass/kde4-base.eclass
Gentoo

Contents of /eclass/kde4-base.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Mon Mar 10 21:41:56 2008 UTC (6 years, 5 months ago) by zlin
Branch: MAIN
Changes since 1.3: +107 -30 lines
Add support for split qt-4.4. Add {CPPUNIT,OPENGL}_REQUIRED. Split out kde4-base_apply_patches().

1 ingmar 1.1 # Copyright 2007-2008 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 zlin 1.4 # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-base.eclass,v 1.3 2008/02/18 17:00:32 ingmar Exp $
4 ingmar 1.1
5     # @ECLASS: kde4-base.eclass
6     # @MAINTAINER:
7     # kde@gentoo.org
8     # @BLURB: This eclass provides functions for kde 4.0 ebuilds
9     # @DESCRIPTION:
10     # The kde4-base.eclass provides support for building KDE4 monolithic ebuilds
11     # and KDE4 applications.
12     #
13     # NOTE: This eclass uses the SLOT dependencies from EAPI="1" or compatible,
14     # hence you must define EAPI="1" in the ebuild, before inheriting any eclasses.
15    
16     inherit base eutils multilib cmake-utils kde4-functions
17    
18     EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_postinst pkg_postrm
19    
20 zlin 1.4 COMMONDEPEND="|| ( (
21     x11-libs/qt-core:4
22     x11-libs/qt-gui:4
23     x11-libs/qt-qt3support:4
24     x11-libs/qt-svg:4
25     x11-libs/qt-test:4 )
26     >=x11-libs/qt-4.3.3:4 )"
27    
28     # @ECLASS-VARIABLE: OPENGL_REQUIRED
29     # @DESCRIPTION:
30     # Is qt-opengl required? Possible values are 'always', 'optional' and 'never'.
31     # This variable must be set before inheriting any eclasses. Defaults to 'never'.
32     OPENGL_REQUIRED="${OPENGL_REQUIRED:-never}"
33    
34     OPENGLDEPEND="|| ( x11-libs/qt-opengl:4
35     >=x11-libs/qt-4.3.3:4 )"
36     case "${OPENGL_REQUIRED}" in
37     always)
38     COMMONDEPEND="${COMMONDEPEND}
39     ${OPENGLDEPEND}"
40     ;;
41     optional)
42     IUSE="${IUSE} opengl"
43     COMMONDEPEND="${COMMONDEPEND}
44     opengl? ( ${OPENGLDEPEND} )"
45     ;;
46     *)
47     OPENGL_REQUIRED="never"
48     ;;
49     esac
50    
51 ingmar 1.1 DEPEND="${DEPEND} ${COMMONDEPEND}
52     >=dev-util/cmake-2.4.7-r1
53     dev-util/pkgconfig
54     x11-libs/libXt
55     x11-proto/xf86vidmodeproto"
56     RDEPEND="${RDEPEND} ${COMMONDEPEND}"
57    
58 zlin 1.4 # @ECLASS-VARIABLE: CPPUNIT_REQUIRED
59     # @DESCRIPTION:
60     # Is cppunit required for tests? Possible values are 'always', 'optional' and 'never'.
61     # This variable must be set before inheriting any eclasses. Defaults to 'never'.
62     CPPUNIT_REQUIRED="${CPPUNIT_REQUIRED:-never}"
63    
64     case "${CPPUNIT_REQUIRED}" in
65     always)
66     DEPEND="${DEPEND} dev-util/cppunit"
67     ;;
68     optional)
69     IUSE="${IUSE} test"
70 ingmar 1.1 DEPEND="${DEPEND}
71     test? ( dev-util/cppunit )"
72 zlin 1.4 ;;
73     *)
74     CPPUNIT_REQUIRED="never"
75     ;;
76     esac
77 ingmar 1.1
78     # @ECLASS-VARIABLE: NEED_KDE
79     # @DESCRIPTION:
80     # This variable sets the version of KDE4 which will be used by the eclass.
81     # This variable must be set by the ebuild, for all categories except for "kde-base".
82     # For kde-base packages, if it is not set by the ebuild,
83     # it's assumed that the required KDE4 version is the latest, non-live, available.
84     #
85     # @CODE
86     # Acceptable values are:
87     # - latest - Use latest version in the portage tree
88     # Default for kde-base ebuilds. Banned for ebuilds not part of kde or koffice.
89     # - svn - Use svn release (live ebuilds)
90     # - :SLOT - Use any version in the SLOT specified in the NEED_KDE value.
91     # - VERSION_NUMBER - Use the minimum KDE4 version specified in the NEED_KDE value.
92     # - VERSION_NUMBER:SLOT - Use the minimum KDE4 version and the SLOT specified in the NEED_KDE value.
93     # - none - Let the ebuild handle SLOT, kde dependencies, KDEDIR, ...
94     # @CODE
95     #
96     # Note: There is no default NEED_KDE for ebuilds not in kde-base or part of
97     # koffice, so you must set it explicitly in the ebuild, in all other cases.
98     if [[ -z ${NEED_KDE} ]]; then
99     if [[ -n ${KDEBASE} ]]; then
100     NEED_KDE="latest"
101     else
102     die "kde4-base.eclass inherited but NEED_KDE not defined - broken ebuild"
103     fi
104     fi
105     export NEED_KDE
106    
107     case ${NEED_KDE} in
108     latest)
109     # Should only be used by 'kde-base'-ebuilds
110     if [[ "${KDEBASE}" == "kde-base" ]]; then
111     case ${PV} in
112     3.9*) _kdedir="3.9" ;;
113     4*) _kdedir="4.0" ;;
114     *) die "NEED_KDE=latest not supported for PV=${PV}" ;;
115     esac
116     _operator=">="
117     _pv="-${PV}:kde-4"
118     else
119     _kdedir="4.0"
120     _pv=":kde-4"
121     fi
122     ;;
123     svn|9999*|:kde-svn)
124     _kdedir="svn"
125     _pv=":kde-svn"
126     export NEED_KDE="svn"
127     ;;
128     *:kde-svn)
129     _kdedir="svn"
130     _operator=">="
131     _pv="-${NEED_KDE}"
132     export NEED_KDE="svn"
133     ;;
134     # The ebuild handles dependencies, KDEDIR, SLOT.
135     none)
136 ingmar 1.3 :
137 ingmar 1.1 ;;
138     # NEED_KDE=":${SLOT}"
139     :kde-4)
140     _kdedir="4.0"
141     _pv="${NEED_KDE}"
142     ;;
143     # NEED_KDE="${PV}:${SLOT}"
144     *:kde-4)
145     _kdedir="4.0"
146     _operator=">="
147     _pv="-${NEED_KDE}"
148     ;;
149     3.9*)
150     _kdedir="3.9"
151     _operator=">="
152     _pv="-${NEED_KDE}:kde-4"
153     ;;
154     4*)
155     _kdedir="4.0"
156     _operator=">="
157     _pv="-${NEED_KDE}:kde-4"
158     ;;
159     *) die "NEED_KDE=${NEED_KDE} currently not supported."
160     ;;
161     esac
162    
163     if [[ ${NEED_KDE} != none ]]; then
164     KDEDIR="/usr/kde/${_kdedir}"
165     KDEDIRS="/usr:/usr/local:${KDEDIR}"
166    
167     if [[ -n ${KDEBASE} ]]; then
168     if [[ ${NEED_KDE} = svn ]]; then
169     SLOT="kde-svn"
170     else
171     SLOT="kde-4"
172     fi
173     fi
174    
175     # We only need to add the dependencies if ${PN} is not "kdelibs" or "kdepimlibs"
176     if [[ ${PN} != "kdelibs" ]]; then
177     DEPEND="${DEPEND}
178     ${_operator}kde-base/kdelibs${_pv}"
179     RDEPEND="${RDEPEND}
180     ${_operator}kde-base/kdelibs${_pv}"
181     if [[ ${PN} != "kdepimlibs" ]]; then
182     DEPEND="${DEPEND}
183     ${_operator}kde-base/kdepimlibs${_pv}"
184     RDEPEND="${RDEPEND}
185     ${_operator}kde-base/kdepimlibs${_pv}"
186     fi
187     fi
188    
189     unset _operator _pv _kdedir
190     fi
191    
192     # Fetch section - If the ebuild's category is not 'kde-base' and if it is not a
193     # koffice ebuild, the URI should be set in the ebuild itself
194     if [[ -n ${KDEBASE} ]]; then
195     if [[ -n ${KMNAME} ]]; then
196     _kmname=${KMNAME}
197     else
198     _kmname=${PN}
199     fi
200     _kmname_pv="${_kmname}-${PV}"
201     if [[ ${NEED_KDE} != "svn" ]]; then
202     case ${KDEBASE} in
203     kde-base)
204     case ${PV} in
205     *) SRC_URI="mirror://kde/stable/${PV}/src/${_kmname_pv}.tar.bz2";;
206     esac
207     ;;
208     koffice)
209     SRC_URI="mirror://kde/unstable/${_kmname_pv}/src/${_kmname_pv}.tar.bz2"
210     ;;
211     esac
212     fi
213     unset _kmname _kmname_pv
214     fi
215    
216     debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
217     debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND ${DEPEND} - before blockers"
218    
219     # Monolithic ebuilds should add blockers for split ebuilds in the same slot.
220     # If KMNAME is not set then this is not a split package
221     if [[ -n ${KDEBASE} && -z ${KMNAME} ]]; then
222     for _x in $(get-child-packages ${CATEGORY}/${PN}); do
223     DEPEND="${DEPEND} !${_x}:${SLOT}"
224     RDEPEND="${RDEPEND} !${_x}:${SLOT}"
225     done
226     unset _x
227     fi
228    
229     debug-print "${BASH_SOURCE} ${LINENO} ${ECLASS} ${FUNCNAME}: DEPEND ${DEPEND} - after blockers"
230    
231     # @ECLASS-VARIABLE: PREFIX
232     # @DESCRIPTION:
233     # Set the installation PREFIX. All kde-base ebuilds go into the KDE4 installation directory.
234     # Applications installed by the other ebuilds go into /usr/ by default, this value
235     # can be superseded by defining PREFIX before inheriting kde4-base.
236     if [[ -n ${KDEBASE} ]]; then
237     PREFIX=${KDEDIR}
238     else
239     # if PREFIX is not defined we set it to the default value of /usr
240     PREFIX="${PREFIX:-/usr}"
241     fi
242    
243     debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SLOT ${SLOT} - KDEDIR ${KDEDIR} - KDEDIRS ${KDEDIRS}- PREFIX ${PREFIX} - NEED_KDE ${NEED_KDE}"
244    
245     # @FUNCTION: kde4-base_pkg_setup
246     # @DESCRIPTION:
247     # Adds flags needed by all of KDE 4 to $QT4_BUILT_WITH_USE_CHECK. Uses
248     # kde4-functions_check_use from kde4-functions.eclass to print appropriate
249     # errors and die if any required flags listed in $QT4_BUILT_WITH_USE_CHECK or
250     # $KDE4_BUILT_WITH_USE_CHECK are missing.
251     kde4-base_pkg_setup() {
252     debug-print-function $FUNCNAME "$@"
253    
254 ingmar 1.2 # KDE4 applications require qt4 compiled with USE="accessibility dbus gif jpeg png qt3support ssl zlib".
255 zlin 1.4 if has_version '<x11-libs/qt-4.4_alpha:4'; then
256     QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK} accessibility dbus gif jpeg png qt3support ssl zlib"
257     else
258     KDE4_BUILT_WITH_USE_CHECK="${KDE4_BUILT_WITH_USE_CHECK}
259     x11-libs/qt-core qt3support ssl
260     x11-libs/qt-gui accessibility dbus
261     x11-libs/qt-qt3support accessibility"
262     fi
263 ingmar 1.1
264     if has debug ${IUSE//+} && use debug; then
265 zlin 1.4 if has_version '<x11-libs/qt-4.4.0_alpha:4'; then
266     QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK} debug"
267     else
268     KDE4_BUILT_WITH_USE_CHECK="${KDE4_BUILT_WITH_USE_CHECK}
269     x11-libs/qt-core:4 debug
270     x11-libs/qt-gui:4 debug
271     x11-libs/qt-qt3support:4 debug
272     x11-libs/qt-svg:4 debug
273     x11-libs/qt-test:4 debug"
274     if [[ ${OPENGL_REQUIRED} == always ]] || has opengl ${IUSE//+} && use opengl; then
275     KDE4_BUILT_WITH_USE_CHECK="${KDE4_BUILT_WITH_USE_CHECK}
276     x11-libs/qt-opengl:4 debug"
277     fi
278     fi
279 ingmar 1.1 fi
280    
281 zlin 1.4 if [[ ${OPENGL_REQUIRED} == always ]] || has opengl ${IUSE//+} && use opengl; then
282     if has_version '<x11-libs/qt-4.4.0_alpha:4'; then
283     QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK} opengl"
284     fi
285 ingmar 1.1 fi
286    
287     kde4-functions_check_use
288     }
289    
290 zlin 1.4 # @FUNCTION: kde4-base_apply_patches
291 ingmar 1.1 # @DESCRIPTION:
292 zlin 1.4 # This function applies patches.
293 ingmar 1.1 #
294     # If the directory ${WORKDIR}/patches/ exists, we apply all patches in that
295     # directory, provided they follow this format:
296     # @CODE
297     # - Monolithic ebuilds, (from kde-base)
298     # - $CATEGORY=kde-base:
299     # Apply ${CHILD_EBUILD_NAME}-${SLOT}-*{diff,patch}
300     # - $CATEGORY=!kde-base:
301     # Apply ${CHILD_EBUILD_NAME}-${PV}-*{diff,patch}
302     # - Split ebuilds:
303     # - $CATEGORY=kde-base:
304     # Apply ${PN}-${SLOT}-*{diff,patch}
305     # - $CATEGORY!=kde-base:
306     # Apply ${PN}-${PV}-*{diff,patch}
307     # @CODE
308     #
309     # If ${PATCHES} is non-zero all patches in it gets applied.
310 zlin 1.4 kde4-base_apply_patches() {
311     local _patchdir _packages _p
312     _patchdir="${WORKDIR}/patches/"
313     if [[ -d "${_patchdir}" ]]; then
314     if is-parent-package ${CATEGORY}/${PN} ; then
315     _packages="$(get-child-packages ${CATEGORY}/${PN})"
316     _packages="${_packages//${CATEGORY}\//} ${PN}"
317     else
318     _packages="${PN}"
319     fi
320     for _p in ${_packages}; do
321     PATCHES="${PATCHES} $(ls ${_patchdir}/${_p}-${PV}-*{diff,patch} 2>/dev/null)"
322     if [[ -n "${KDEBASE}" ]]; then
323     PATCHES="${PATCHES} $(ls ${_patchdir}/${_p}-${SLOT}-*{diff,patch} 2>/dev/null)"
324     fi
325     done
326     fi
327     [[ -n ${PATCHES} ]] && base_src_unpack autopatch
328     }
329    
330     # @FUNCTION: kde4-base_src_unpack
331     # @DESCRIPTION:
332     # This function unpacks the source tarballs for KDE4 applications.
333     #
334     # If no argument is passed to this function, then standard src_unpack is
335     # executed. Otherwise options are passed to base_src_unpack.
336     #
337     # In addition it calls kde4-base_apply_patches when no arguments are passed to
338     # this function.
339 ingmar 1.1 kde4-base_src_unpack() {
340     debug-print-function $FUNCNAME "$@"
341    
342     [[ -z "${KDE_S}" ]] && KDE_S="${S}"
343    
344     if [[ -z $* ]]; then
345     # Unpack first and deal with KDE patches after examing possible patch sets.
346     # To be picked up, patches need to conform to the guidelines stated before.
347     # Monolithic ebuilds will use the split ebuild patches.
348     [[ -d "${KDE_S}" ]] || unpack ${A}
349 zlin 1.4 kde4-base_apply_patches
350 ingmar 1.1 else
351     # Call base_src_unpack, which unpacks and patches
352     # step by step transparently as defined in the ebuild.
353     base_src_unpack $*
354     fi
355    
356     # Updated cmake dir
357     if [[ -d "${WORKDIR}/cmake" ]] && [[ -d "${KDE_S}/cmake" ]]; then
358     ebegin "Updating cmake/ directory..."
359     rm -rf "${KDE_S}/cmake" || die "Unable to remove old cmake/ directory"
360     ln -s "${WORKDIR}/cmake" "${KDE_S}/cmake" || die "Unable to symlink the new cmake/ directory"
361     eend 0
362     fi
363     }
364    
365     # @FUNCTION: kde4-base_src_compile
366     # @DESCRIPTION:
367     # General function for compiling KDE4 applications.
368     kde4-base_src_compile() {
369     debug-print-function ${FUNCNAME} "$@"
370    
371     kde4-base_src_configure
372     kde4-base_src_make
373     }
374    
375     # @FUNCTION: kde4-base_src_configure
376     # @DESCRIPTION:
377     # Function for configuring the build of KDE4 applications.
378     kde4-base_src_configure() {
379     debug-print-function ${FUNCNAME} "$@"
380    
381     # Final flag handling
382     if has kdeenablefinal ${IUSE//+} && use kdeenablefinal; then
383     einfo "Activating enable-final flag"
384     mycmakeargs="${mycmakeargs} -DKDE4_ENABLE_FINAL=ON"
385     fi
386    
387     # Enable generation of HTML handbook
388     if has htmlhandbook ${IUSE//+} && use htmlhandbook; then
389     einfo "Enabling building of HTML handbook"
390     mycmakeargs="${mycmakeargs} -DKDE4_ENABLE_HTMLHANDBOOK=ON"
391     fi
392    
393     # Build tests in src_test only, where we override this value
394     mycmakeargs="${mycmakeargs} -DKDE4_BUILD_TESTS=OFF"
395    
396     # Set distribution name
397     [[ ${PN} == "kdelibs" ]] && mycmakeargs="${mycmakeargs} -DKDE_DISTRIBUTION_TEXT=Gentoo"
398    
399     # runpath linking
400     mycmakeargs="${mycmakeargs} -DKDE4_USE_ALWAYS_FULL_RPATH=ON"
401    
402     # Here we set the install prefix
403     mycmakeargs="${mycmakeargs} -DCMAKE_INSTALL_PREFIX=${PREFIX}"
404    
405     # Set environment
406     QTEST_COLORED=1
407     QT_PLUGIN_PATH=${KDEDIR}/$(get_libdir)/kde4/plugins/
408    
409     cmake-utils_src_configureout
410     }
411    
412     # @FUNCTION: kde4-base_src_make
413     # @DESCRIPTION:
414     # Function for building KDE4 applications.
415     # Options are passed to cmake-utils_src_make.
416     kde4-base_src_make() {
417     debug-print-function ${FUNCNAME} "$@"
418    
419     cmake-utils_src_make "$@"
420     }
421    
422     # @FUNCTION: kde4-base_src_test
423     # @DESCRIPTION:
424     # Function for testing KDE4 applications.
425     kde4-base_src_test() {
426     debug-print-function ${FUNCNAME} "$@"
427    
428     # Override this value, set in kde4-base_src_configure()
429     mycmakeargs="${mycmakeargs} -DKDE4_BUILD_TESTS=ON"
430     cmake-utils_src_compile
431    
432     cmake-utils_src_test
433     }
434    
435     # @FUNCTION: kde4-base_src_install
436     # @DESCRIPTION:
437     # Function for installing KDE4 applications.
438     kde4-base_src_install() {
439     debug-print-function ${FUNCNAME} "$@"
440    
441     kde4-base_src_make_doc
442     cmake-utils_src_install
443     }
444    
445     # @FUNCTION: kde4-base_src_make_doc
446     # @DESCRIPTION:
447     # Function for installing the documentation of KDE4 applications.
448     kde4-base_src_make_doc() {
449     debug-print-function ${FUNCNAME} "$@"
450    
451     local doc
452     for doc in AUTHORS ChangeLog* README* NEWS TODO; do
453     [[ -s $doc ]] && dodoc ${doc}
454     done
455    
456     if [[ -z ${KMNAME} ]]; then
457     for doc in {apps,runtime,workspace,.}/*/{AUTHORS,README*}; do
458     if [[ -s $doc ]]; then
459     local doc_complete=${doc}
460     doc="${doc#*/}"
461     newdoc "$doc_complete" "${doc%/*}.${doc##*/}"
462     fi
463     done
464     fi
465    
466     if [[ -n ${KDEBASE} && -d "${D}"/usr/share/doc/${PF} ]]; then
467     # work around bug #97196
468     dodir /usr/share/doc/kde && \
469     mv "${D}"/usr/share/doc/${PF} "${D}"/usr/share/doc/kde/ || \
470     die "Failed to move docs to kde/ failed."
471     fi
472     }
473    
474     # @FUNCTION: kde4-base_pkg_postinst
475     # @DESCRIPTION:
476     # Function to rebuild the KDE System Configuration Cache after an application has been installed.
477     kde4-base_pkg_postinst() {
478     buildsycoca
479     }
480    
481     # @FUNCTION: kde4-base_pkg_postrm
482     # @DESCRIPTION:
483     # Function to rebuild the KDE System Configuration Cache after an application has been removed.
484     kde4-base_pkg_postrm() {
485     buildsycoca
486     }

  ViewVC Help
Powered by ViewVC 1.1.20