profiles: plasma: Add activities to make.defaults
[gentoo.git] / eclass / gkrellm-plugin.eclass
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 #
5 # Original Author: Jim Ramsay <lack@gentoo.org>
6 #
7 # Purpose:
8 #   Provides common methods used by (almost) all gkrellm plugins:
9 #    - Sets up default dependencies
10 #    - Adds pkg_setup check to ensure gkrellm was built with USE="X" (bug
11 #      167227)
12 #    - Provides utility routines in lieu of hard-coding the plugin directories.
13 #    - Provides the most common src_install method to avoid code duplication.
14 #
15 # Utility Routines:
16 #   gkrellm-plugin_dir - Returns the gkrellm-2 plugin directory
17 #   gkrellm-plugin_server_dir - Returns the gkrellm-2 server plugin directory
18 #
19 # Environment:
20 #   For src_install:
21 #     PLUGIN_SO - The name of the plugin's .so file which will be installed in
22 #       the plugin dir.  Defaults to "${PN}.so".
23 #     PLUGIN_DOCS - An optional list of docs to be installed.  Defaults to
24 #       unset.
25 #     PLUGIN_SERVER_SO - The name of the plugin's server plugin .so portion.
26 #       Defaults to unset.
27 #       Important: This will also cause the pkg_setup check to be skipped, so
28 #       you need to check 'build_with_use app-admin/gkrellm X' in your
29 #       src_compile and only compile the GUI portion if that returns true.  (see
30 #       x11-plugins/gkrelltop as an example)
31 #
32 # Changelog:
33 #   12 March 2007: Jim Ramsay <lack@gentoo.org>
34 #     - Added server plugin support
35 #   09 March 2007: Jim Ramsay <lack@gentoo.org>
36 #     - Initial commit
37 #
38
39 inherit multilib eutils
40
41 RDEPEND="=app-admin/gkrellm-2*"
42 DEPEND="${RDEPEND}
43         virtual/pkgconfig"
44
45 gkrellm-plugin_dir() {
46         echo /usr/$(get_libdir)/gkrellm2/plugins
47 }
48
49 gkrellm-plugin_server_dir() {
50         echo /usr/$(get_libdir)/gkrellm2/plugins-gkrellmd
51 }
52
53 gkrellm-plugin_pkg_setup() {
54         if [[ -z "${PLUGIN_SERVER_SO}" ]] &&
55                 ! built_with_use app-admin/gkrellm X; then
56                 eerror "This plugin requires the X frontend of gkrellm."
57                 eerror "Please re-emerge app-admin/gkrellm with USE=\"X\""
58                 die "Please re-emerge app-admin/gkrellm with USE=\"X\""
59         fi
60 }
61
62 gkrellm-plugin_src_install() {
63         if built_with_use app-admin/gkrellm X; then
64                 insinto $(gkrellm-plugin_dir)
65                 doins ${PLUGIN_SO:-${PN}.so} || die "Plugin shared library was not installed"
66         fi
67
68         if [[ -n "${PLUGIN_SERVER_SO}" ]]; then
69                 insinto $(gkrellm-plugin_server_dir)
70                 doins ${PLUGIN_SERVER_SO} || die "Server plugin shared library was not installed"
71         fi
72
73         DDOCS="README* Change* AUTHORS FAQ TODO INSTALL"
74
75         for doc in ${DDOCS}; do
76                 [ -s "$doc" ] && dodoc $doc
77         done
78
79         [ -n "${PLUGIN_DOCS}" ] && dodoc ${PLUGIN_DOCS}
80 }
81
82 EXPORT_FUNCTIONS pkg_setup src_install