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

Contents of /eclass/base.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.56 - (hide annotations) (download)
Mon Feb 6 21:33:59 2012 UTC (2 years, 6 months ago) by vapier
Branch: MAIN
Changes since 1.55: +6 -2 lines
automatically use unpacker eclass if it is available

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.56 # $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.55 2011/12/14 23:38:09 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 vapier 1.56 if [[ $(type -t unpacker_src_unpack) == "function" ]] ; then
63     unpacker_src_unpack
64     elif [[ -n ${A} ]] ; then
65     unpack ${A}
66     fi
67 scarabeus 1.41 has src_prepare ${BASE_EXPF} || base_src_prepare
68 loki_val 1.35
69 scarabeus 1.41 popd > /dev/null
70 loki_val 1.35 }
71    
72     # @FUNCTION: base_src_prepare
73     # @DESCRIPTION:
74 scarabeus 1.41 # The base src_prepare function, which is exported
75 reavertm 1.51 # EAPI is greater or equal to 2. Here the PATCHES array is evaluated.
76 loki_val 1.35 base_src_prepare() {
77     debug-print-function $FUNCNAME "$@"
78 scarabeus 1.41 debug-print "$FUNCNAME: PATCHES=$PATCHES"
79 danarmak 1.6
80 scarabeus 1.48 local patches_failed=0
81    
82 scarabeus 1.41 pushd "${S}" > /dev/null
83     if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
84     for x in "${PATCHES[@]}"; do
85     debug-print "$FUNCNAME: applying patch from ${x}"
86     if [[ -d "${x}" ]]; then
87     # Use standardized names and locations with bulk patching
88     # Patch directory is ${WORKDIR}/patch
89     # See epatch() in eutils.eclass for more documentation
90     EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
91    
92     # in order to preserve normal EPATCH_SOURCE value that can
93     # be used other way than with base eclass store in local
94     # variable and restore later
95     oldval=${EPATCH_SOURCE}
96     EPATCH_SOURCE=${x}
97 scarabeus 1.50 EPATCH_FORCE=yes
98 scarabeus 1.41 epatch
99     EPATCH_SOURCE=${oldval}
100 scarabeus 1.46 elif [[ -f "${x}" ]]; then
101     epatch "${x}"
102 spatz 1.45 else
103 scarabeus 1.47 ewarn "QA: File or directory \"${x}\" does not exist."
104     ewarn "QA: Check your PATCHES array or add missing file/directory."
105 scarabeus 1.48 patches_failed=1
106 mr_bones_ 1.36 fi
107 scarabeus 1.41 done
108 scarabeus 1.48 [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages."
109 scarabeus 1.41 else
110     for x in ${PATCHES}; do
111     debug-print "$FUNCNAME: patching from ${x}"
112     epatch "${x}"
113     done
114     fi
115 danarmak 1.6
116 scarabeus 1.41 # Apply user patches
117     debug-print "$FUNCNAME: applying user patches"
118     epatch_user
119 swegener 1.27
120 scarabeus 1.41 popd > /dev/null
121 danarmak 1.1 }
122    
123 loki_val 1.35 # @FUNCTION: base_src_configure
124     # @DESCRIPTION:
125 scarabeus 1.41 # The base src_configure function, which is exported when
126 reavertm 1.51 # EAPI is greater or equal to 2. Runs basic econf.
127 loki_val 1.35 base_src_configure() {
128     debug-print-function $FUNCNAME "$@"
129    
130 scarabeus 1.41 # there is no pushd ${S} so we can override its place where to run
131 reavertm 1.52 [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
132 loki_val 1.35 }
133    
134 pva 1.34 # @FUNCTION: base_src_compile
135     # @DESCRIPTION:
136 scarabeus 1.41 # The base src_compile function, calls src_configure with
137     # EAPI older than 2.
138 danarmak 1.1 base_src_compile() {
139 loki_val 1.35 debug-print-function $FUNCNAME "$@"
140    
141 scarabeus 1.41 has src_configure ${BASE_EXPF} || base_src_configure
142 reavertm 1.52 base_src_make "$@"
143 loki_val 1.35 }
144    
145 scarabeus 1.41 # @FUNCTION: base_src_make
146     # @DESCRIPTION:
147     # Actual function that runs emake command.
148 scarabeus 1.39 base_src_make() {
149 mr_bones_ 1.40 debug-print-function $FUNCNAME "$@"
150 scarabeus 1.41
151     if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
152 scarabeus 1.53 emake "$@" || die "died running emake, $FUNCNAME"
153 scarabeus 1.41 fi
154 scarabeus 1.39 }
155    
156 scarabeus 1.41 # @FUNCTION: base_src_install
157 loki_val 1.35 # @DESCRIPTION:
158 scarabeus 1.41 # The base src_install function. Runs make install and
159     # installs documents and html documents from DOCS and HTML_DOCS
160     # arrays.
161     base_src_install() {
162 loki_val 1.35 debug-print-function $FUNCNAME "$@"
163 danarmak 1.6
164 scarabeus 1.53 emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME"
165 scarabeus 1.41 base_src_install_docs
166 danarmak 1.1 }
167    
168 scarabeus 1.41 # @FUNCTION: base_src_install_docs
169 pva 1.34 # @DESCRIPTION:
170 scarabeus 1.41 # Actual function that install documentation from
171     # DOCS and HTML_DOCS arrays.
172     base_src_install_docs() {
173 loki_val 1.35 debug-print-function $FUNCNAME "$@"
174 danarmak 1.6
175 scarabeus 1.41 local x
176 danarmak 1.12
177 scarabeus 1.41 pushd "${S}" > /dev/null
178 danarmak 1.4
179 scarabeus 1.41 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
180     for x in "${DOCS[@]}"; do
181     debug-print "$FUNCNAME: docs: creating document from ${x}"
182 scarabeus 1.49 dodoc "${x}" || die "dodoc failed"
183 scarabeus 1.41 done
184     fi
185     if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
186     for x in "${HTML_DOCS[@]}"; do
187     debug-print "$FUNCNAME: docs: creating html document from ${x}"
188     dohtml -r "${x}" || die "dohtml failed"
189     done
190     fi
191 danarmak 1.6
192 scarabeus 1.41 popd > /dev/null
193 danarmak 1.1 }
194 vapier 1.55
195     fi

  ViewVC Help
Powered by ViewVC 1.1.20