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

Contents of /eclass/base.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.55 - (show annotations) (download)
Wed Dec 14 23:38:09 2011 UTC (2 years, 9 months ago) by vapier
Branch: MAIN
Changes since 1.54: +6 -1 lines
avoid multiple inclusions when possible to speed caching up

1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.54 2011/08/22 04:46:31 vapier Exp $
4
5 # @ECLASS: base.eclass
6 # @MAINTAINER:
7 # QA Team <qa@gentoo.org>
8 # @AUTHOR:
9 # Original author: Dan Armak <danarmak@gentoo.org>
10 # @BLURB: The base eclass defines some default functions and variables.
11 # @DESCRIPTION:
12 # The base eclass defines some default functions and variables. Nearly
13 # everything else inherits from here.
14
15 if [[ ${___ECLASS_ONCE_BASE} != "recur -_+^+_- spank" ]] ; then
16 ___ECLASS_ONCE_BASE="recur -_+^+_- spank"
17
18 inherit eutils
19
20 BASE_EXPF="src_unpack src_compile src_install"
21 case "${EAPI:-0}" in
22 2|3|4) BASE_EXPF+=" src_prepare src_configure" ;;
23 *) ;;
24 esac
25
26 EXPORT_FUNCTIONS ${BASE_EXPF}
27
28 # @ECLASS-VARIABLE: DOCS
29 # @DESCRIPTION:
30 # Array containing documents passed to dodoc command.
31 #
32 # DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" )
33
34 # @ECLASS-VARIABLE: HTML_DOCS
35 # @DESCRIPTION:
36 # Array containing documents passed to dohtml command.
37 #
38 # HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" )
39
40 # @ECLASS-VARIABLE: PATCHES
41 # @DESCRIPTION:
42 # PATCHES array variable containing all various patches to be applied.
43 # This variable is expected to be defined in global scope of ebuild.
44 # Make sure to specify the full path. This variable is utilised in
45 # src_unpack/src_prepare phase based on EAPI.
46 #
47 # NOTE: if using patches folders with special file suffixes you have to
48 # define one additional variable EPATCH_SUFFIX="something"
49 #
50 # PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" )
51
52
53 # @FUNCTION: base_src_unpack
54 # @DESCRIPTION:
55 # The base src_unpack function, which is exported.
56 # Calls also src_prepare with eapi older than 2.
57 base_src_unpack() {
58 debug-print-function $FUNCNAME "$@"
59
60 pushd "${WORKDIR}" > /dev/null
61
62 [[ -n "${A}" ]] && unpack ${A}
63 has src_prepare ${BASE_EXPF} || base_src_prepare
64
65 popd > /dev/null
66 }
67
68 # @FUNCTION: base_src_prepare
69 # @DESCRIPTION:
70 # The base src_prepare function, which is exported
71 # EAPI is greater or equal to 2. Here the PATCHES array is evaluated.
72 base_src_prepare() {
73 debug-print-function $FUNCNAME "$@"
74 debug-print "$FUNCNAME: PATCHES=$PATCHES"
75
76 local patches_failed=0
77
78 pushd "${S}" > /dev/null
79 if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
80 for x in "${PATCHES[@]}"; do
81 debug-print "$FUNCNAME: applying patch from ${x}"
82 if [[ -d "${x}" ]]; then
83 # Use standardized names and locations with bulk patching
84 # Patch directory is ${WORKDIR}/patch
85 # See epatch() in eutils.eclass for more documentation
86 EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
87
88 # in order to preserve normal EPATCH_SOURCE value that can
89 # be used other way than with base eclass store in local
90 # variable and restore later
91 oldval=${EPATCH_SOURCE}
92 EPATCH_SOURCE=${x}
93 EPATCH_FORCE=yes
94 epatch
95 EPATCH_SOURCE=${oldval}
96 elif [[ -f "${x}" ]]; then
97 epatch "${x}"
98 else
99 ewarn "QA: File or directory \"${x}\" does not exist."
100 ewarn "QA: Check your PATCHES array or add missing file/directory."
101 patches_failed=1
102 fi
103 done
104 [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages."
105 else
106 for x in ${PATCHES}; do
107 debug-print "$FUNCNAME: patching from ${x}"
108 epatch "${x}"
109 done
110 fi
111
112 # Apply user patches
113 debug-print "$FUNCNAME: applying user patches"
114 epatch_user
115
116 popd > /dev/null
117 }
118
119 # @FUNCTION: base_src_configure
120 # @DESCRIPTION:
121 # The base src_configure function, which is exported when
122 # EAPI is greater or equal to 2. Runs basic econf.
123 base_src_configure() {
124 debug-print-function $FUNCNAME "$@"
125
126 # there is no pushd ${S} so we can override its place where to run
127 [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
128 }
129
130 # @FUNCTION: base_src_compile
131 # @DESCRIPTION:
132 # The base src_compile function, calls src_configure with
133 # EAPI older than 2.
134 base_src_compile() {
135 debug-print-function $FUNCNAME "$@"
136
137 has src_configure ${BASE_EXPF} || base_src_configure
138 base_src_make "$@"
139 }
140
141 # @FUNCTION: base_src_make
142 # @DESCRIPTION:
143 # Actual function that runs emake command.
144 base_src_make() {
145 debug-print-function $FUNCNAME "$@"
146
147 if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
148 emake "$@" || die "died running emake, $FUNCNAME"
149 fi
150 }
151
152 # @FUNCTION: base_src_install
153 # @DESCRIPTION:
154 # The base src_install function. Runs make install and
155 # installs documents and html documents from DOCS and HTML_DOCS
156 # arrays.
157 base_src_install() {
158 debug-print-function $FUNCNAME "$@"
159
160 emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME"
161 base_src_install_docs
162 }
163
164 # @FUNCTION: base_src_install_docs
165 # @DESCRIPTION:
166 # Actual function that install documentation from
167 # DOCS and HTML_DOCS arrays.
168 base_src_install_docs() {
169 debug-print-function $FUNCNAME "$@"
170
171 local x
172
173 pushd "${S}" > /dev/null
174
175 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
176 for x in "${DOCS[@]}"; do
177 debug-print "$FUNCNAME: docs: creating document from ${x}"
178 dodoc "${x}" || die "dodoc failed"
179 done
180 fi
181 if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
182 for x in "${HTML_DOCS[@]}"; do
183 debug-print "$FUNCNAME: docs: creating html document from ${x}"
184 dohtml -r "${x}" || die "dohtml failed"
185 done
186 fi
187
188 popd > /dev/null
189 }
190
191 fi

  ViewVC Help
Powered by ViewVC 1.1.20