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

Contents of /eclass/base.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.55 - (hide 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 vapier 1.54 # Copyright 1999-2011 Gentoo Foundation
2 vapier 1.18 # Distributed under the terms of the GNU General Public License v2
3 vapier 1.55 # $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.54 2011/08/22 04:46:31 vapier Exp $
4 pva 1.34
5     # @ECLASS: base.eclass
6     # @MAINTAINER:
7 scarabeus 1.41 # QA Team <qa@gentoo.org>
8 vapier 1.54 # @AUTHOR:
9     # Original author: Dan Armak <danarmak@gentoo.org>
10 pva 1.34 # @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 vapier 1.18
15 vapier 1.55 if [[ ${___ECLASS_ONCE_BASE} != "recur -_+^+_- spank" ]] ; then
16     ___ECLASS_ONCE_BASE="recur -_+^+_- spank"
17    
18 flameeyes 1.29 inherit eutils
19    
20 scarabeus 1.41 BASE_EXPF="src_unpack src_compile src_install"
21 loki_val 1.35 case "${EAPI:-0}" in
22 scarabeus 1.44 2|3|4) BASE_EXPF+=" src_prepare src_configure" ;;
23 scarabeus 1.41 *) ;;
24 loki_val 1.35 esac
25    
26 scarabeus 1.41 EXPORT_FUNCTIONS ${BASE_EXPF}
27    
28     # @ECLASS-VARIABLE: DOCS
29     # @DESCRIPTION:
30     # Array containing documents passed to dodoc command.
31 scarabeus 1.42 #
32     # DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" )
33 scarabeus 1.41
34     # @ECLASS-VARIABLE: HTML_DOCS
35     # @DESCRIPTION:
36     # Array containing documents passed to dohtml command.
37 scarabeus 1.42 #
38     # HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" )
39 scarabeus 1.41
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 scarabeus 1.42 #
47 scarabeus 1.41 # NOTE: if using patches folders with special file suffixes you have to
48     # define one additional variable EPATCH_SUFFIX="something"
49 scarabeus 1.42 #
50     # PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" )
51 scarabeus 1.41
52 danarmak 1.1
53 pva 1.34 # @FUNCTION: base_src_unpack
54     # @DESCRIPTION:
55 scarabeus 1.41 # The base src_unpack function, which is exported.
56     # Calls also src_prepare with eapi older than 2.
57 danarmak 1.1 base_src_unpack() {
58 scarabeus 1.41 debug-print-function $FUNCNAME "$@"
59 danarmak 1.6
60 scarabeus 1.41 pushd "${WORKDIR}" > /dev/null
61    
62     [[ -n "${A}" ]] && unpack ${A}
63     has src_prepare ${BASE_EXPF} || base_src_prepare
64 loki_val 1.35
65 scarabeus 1.41 popd > /dev/null
66 loki_val 1.35 }
67    
68     # @FUNCTION: base_src_prepare
69     # @DESCRIPTION:
70 scarabeus 1.41 # The base src_prepare function, which is exported
71 reavertm 1.51 # EAPI is greater or equal to 2. Here the PATCHES array is evaluated.
72 loki_val 1.35 base_src_prepare() {
73     debug-print-function $FUNCNAME "$@"
74 scarabeus 1.41 debug-print "$FUNCNAME: PATCHES=$PATCHES"
75 danarmak 1.6
76 scarabeus 1.48 local patches_failed=0
77    
78 scarabeus 1.41 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 scarabeus 1.50 EPATCH_FORCE=yes
94 scarabeus 1.41 epatch
95     EPATCH_SOURCE=${oldval}
96 scarabeus 1.46 elif [[ -f "${x}" ]]; then
97     epatch "${x}"
98 spatz 1.45 else
99 scarabeus 1.47 ewarn "QA: File or directory \"${x}\" does not exist."
100     ewarn "QA: Check your PATCHES array or add missing file/directory."
101 scarabeus 1.48 patches_failed=1
102 mr_bones_ 1.36 fi
103 scarabeus 1.41 done
104 scarabeus 1.48 [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages."
105 scarabeus 1.41 else
106     for x in ${PATCHES}; do
107     debug-print "$FUNCNAME: patching from ${x}"
108     epatch "${x}"
109     done
110     fi
111 danarmak 1.6
112 scarabeus 1.41 # Apply user patches
113     debug-print "$FUNCNAME: applying user patches"
114     epatch_user
115 swegener 1.27
116 scarabeus 1.41 popd > /dev/null
117 danarmak 1.1 }
118    
119 loki_val 1.35 # @FUNCTION: base_src_configure
120     # @DESCRIPTION:
121 scarabeus 1.41 # The base src_configure function, which is exported when
122 reavertm 1.51 # EAPI is greater or equal to 2. Runs basic econf.
123 loki_val 1.35 base_src_configure() {
124     debug-print-function $FUNCNAME "$@"
125    
126 scarabeus 1.41 # there is no pushd ${S} so we can override its place where to run
127 reavertm 1.52 [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
128 loki_val 1.35 }
129    
130 pva 1.34 # @FUNCTION: base_src_compile
131     # @DESCRIPTION:
132 scarabeus 1.41 # The base src_compile function, calls src_configure with
133     # EAPI older than 2.
134 danarmak 1.1 base_src_compile() {
135 loki_val 1.35 debug-print-function $FUNCNAME "$@"
136    
137 scarabeus 1.41 has src_configure ${BASE_EXPF} || base_src_configure
138 reavertm 1.52 base_src_make "$@"
139 loki_val 1.35 }
140    
141 scarabeus 1.41 # @FUNCTION: base_src_make
142     # @DESCRIPTION:
143     # Actual function that runs emake command.
144 scarabeus 1.39 base_src_make() {
145 mr_bones_ 1.40 debug-print-function $FUNCNAME "$@"
146 scarabeus 1.41
147     if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
148 scarabeus 1.53 emake "$@" || die "died running emake, $FUNCNAME"
149 scarabeus 1.41 fi
150 scarabeus 1.39 }
151    
152 scarabeus 1.41 # @FUNCTION: base_src_install
153 loki_val 1.35 # @DESCRIPTION:
154 scarabeus 1.41 # 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 loki_val 1.35 debug-print-function $FUNCNAME "$@"
159 danarmak 1.6
160 scarabeus 1.53 emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME"
161 scarabeus 1.41 base_src_install_docs
162 danarmak 1.1 }
163    
164 scarabeus 1.41 # @FUNCTION: base_src_install_docs
165 pva 1.34 # @DESCRIPTION:
166 scarabeus 1.41 # Actual function that install documentation from
167     # DOCS and HTML_DOCS arrays.
168     base_src_install_docs() {
169 loki_val 1.35 debug-print-function $FUNCNAME "$@"
170 danarmak 1.6
171 scarabeus 1.41 local x
172 danarmak 1.12
173 scarabeus 1.41 pushd "${S}" > /dev/null
174 danarmak 1.4
175 scarabeus 1.41 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 scarabeus 1.49 dodoc "${x}" || die "dodoc failed"
179 scarabeus 1.41 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 danarmak 1.6
188 scarabeus 1.41 popd > /dev/null
189 danarmak 1.1 }
190 vapier 1.55
191     fi

  ViewVC Help
Powered by ViewVC 1.1.20