dev-util/qbs: version bump
[gentoo.git] / eclass / gpe.eclass
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: gpe.eclass
6 # @MAINTAINER:
7 # gpe@gentoo.org
8 # @AUTHOR:
9 # Original Authors:
10 # Rene Wagner <rw@handhelds.org>
11 # Ned Ludd <solar@gentoo.org>
12 # Angelo Arrifano <miknix@gentoo.org>
13 # EAPI->EAPI2 patch: loki_val
14 # multiple suggestions: Betelgeuse
15 # Based on gnome2.eclass and gpe.bbclass (the latter from OpenEmbedded)
16 # @BLURB: Provides common functionality for the G Palmtop Environment.
17
18 inherit libtool toolchain-funcs
19
20 case "${EAPI:-0}" in
21         0|1)
22                 EXPORT_FUNCTIONS src_unpack src_compile src_install
23                 ;;
24         *)
25                 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
26                 ;;
27 esac
28
29 # @ECLASS-VARIABLE: ELTCONF
30 # @DESCRIPTION:
31 # Extra options passed to elibtoolize on gnome2 eclass.
32 ELTCONF=""
33
34 # @ECLASS-VARIABLE: GPE_DOCS
35 # @DESCRIPTION:
36 # Documentation files to be installed with dodoc.
37 GPE_DOCS=""
38
39 [[ -z "${GPE_MIRROR}" ]] && GPE_MIRROR="http://gpe.linuxtogo.org/download/source"
40 [[ -z "${GPE_TARBALL_SUFFIX}" ]] && GPE_TARBALL_SUFFIX="gz"
41 SRC_URI="${GPE_MIRROR}/${P}.tar.${GPE_TARBALL_SUFFIX}"
42
43 HOMEPAGE="http://gpe.linuxtogo.org"
44
45 IUSE="nls"
46 GPECONF="${GPECONF} --enable-debug=no --disable-debug"
47
48 RDEPEND=""
49 DEPEND="
50         >=dev-util/intltool-0.29
51         virtual/pkgconfig"
52
53 # @FUNCTION: gpe_src_unpack
54 # @DESCRIPTION:
55 # Unpacks and applies some required patches for GPE.
56 gpe_src_unpack() {
57         unpack ${A}
58         cd "${S}"
59         has "${EAPI:-0}" 0 1 && gpe_src_prepare "$@"
60 }
61
62 # Do not call, use gpe_src_unpack() instead.
63 gpe_src_prepare() {
64         # let portage handle stripping.
65         # sort is needed, see #272161 .
66         for file in $(find . -name 'Makefile*' | sort) ; do
67                 sed -i  -e s/'install -s'/'install'/g \
68                         -e s/'install -Ds'/'install -D'/g \
69                         -e 's/$(INSTALL) -s/$(INSTALL) /g' \
70                         -e 's;strip ;#strip ;g' \
71                         ${file} \
72                         ||die "Sedding ${file} failed."
73         done
74         [[ -f configure ]] && elibtoolize
75 }
76
77 # @FUNCTION: gpe_src_configure
78 # @DESCRIPTION:
79 # Configures a GPE package in a cross-compile aware environment.
80 gpe_src_configure() {
81         tc-export CC
82         [[ -f configure ]] && econf "$@" ${GPECONF}
83 }
84
85 # @FUNCTION: gpe_src_compile
86 # @DESCRIPTION:
87 # (Cross-)Compiles a GPE package.
88 gpe_src_compile() {
89         tc-export CC
90         has "${EAPI:-0}" 0 1 && gpe_src_configure "$@"
91         emake PREFIX=/usr || die "emake failed"
92 }
93
94 # @FUNCTION: gpe_src_install
95 # @DESCRIPTION:
96 # Installs a GPE package in the correct way.
97 gpe_src_install() {
98         local use_nls=yes
99
100         use nls || use_nls=no
101
102         if [ -f configure ]; then
103                 einstall "$@" || die "einstall failed"
104         else
105                 emake STRIP=true DESTDIR=${D} PREFIX=/usr \
106                      ENABLE_NLS=${use_nls} "$@" install || die "emake install failed"
107         fi
108
109         use nls || rm -rf ${D}/usr/share/locale
110
111         # manual document installation
112         if [[ "${GPE_DOCS}" ]]; then
113                 dodoc ${GPE_DOCS} || die "dodoc failed"
114         fi
115 }