1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 # This eclass has been deprecated and must not be used by any new
7 # ebuilds or eclasses. Replacements for particular phase functions
10 # base_src_unpack() - default (or unpacker_src_unpack if unpacker.eclass
12 # base_src_prepare() - inherit eutils, inline:
13 # epatch "${PATCHES[@]}" # if PATCHES defined as array
14 # epatch ${PATCHES} # if PATCHES defined as string
16 # base_src_configure() - default
17 # base_src_compile() - default
18 # base_src_install() - default
19 # base_src_install_docs() - einstalldocs from eutils.eclass
21 # @ECLASS: base.eclass
23 # QA Team <qa@gentoo.org>
25 # Original author: Dan Armak <danarmak@gentoo.org>
26 # @BLURB: The base eclass defines some default functions and variables.
28 # The base eclass defines some default functions and variables.
30 if [[ -z ${_BASE_ECLASS} ]]; then
35 BASE_EXPF="src_unpack src_compile src_install"
37 6) die "${ECLASS}.eclass is banned in EAPI ${EAPI}";;
38 2|3|4|5) BASE_EXPF+=" src_prepare src_configure" ;;
42 EXPORT_FUNCTIONS ${BASE_EXPF}
44 # @ECLASS-VARIABLE: DOCS
46 # Array containing documents passed to dodoc command.
48 # DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" )
50 # @ECLASS-VARIABLE: HTML_DOCS
52 # Array containing documents passed to dohtml command.
54 # HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" )
56 # @ECLASS-VARIABLE: PATCHES
58 # PATCHES array variable containing all various patches to be applied.
59 # This variable is expected to be defined in global scope of ebuild.
60 # Make sure to specify the full path. This variable is utilised in
61 # src_unpack/src_prepare phase based on EAPI.
63 # NOTE: if using patches folders with special file suffixes you have to
64 # define one additional variable EPATCH_SUFFIX="something"
66 # PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" )
69 # @FUNCTION: base_src_unpack
71 # The base src_unpack function, which is exported.
72 # Calls also src_prepare with eapi older than 2.
74 debug-print-function $FUNCNAME "$@"
76 pushd "${WORKDIR}" > /dev/null
78 if [[ $(type -t unpacker_src_unpack) == "function" ]] ; then
80 elif [[ -n ${A} ]] ; then
83 has src_prepare ${BASE_EXPF} || base_src_prepare
88 # @FUNCTION: base_src_prepare
90 # The base src_prepare function, which is exported
91 # EAPI is greater or equal to 2. Here the PATCHES array is evaluated.
93 debug-print-function $FUNCNAME "$@"
94 debug-print "$FUNCNAME: PATCHES=$PATCHES"
96 local patches_failed=0
98 pushd "${S}" > /dev/null
99 if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
100 for x in "${PATCHES[@]}"; do
101 debug-print "$FUNCNAME: applying patch from ${x}"
102 if [[ -d "${x}" ]]; then
103 # Use standardized names and locations with bulk patching
104 # Patch directory is ${WORKDIR}/patch
105 # See epatch() in eutils.eclass for more documentation
106 EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
108 # in order to preserve normal EPATCH_SOURCE value that can
109 # be used other way than with base eclass store in local
110 # variable and restore later
111 oldval=${EPATCH_SOURCE}
115 EPATCH_SOURCE=${oldval}
116 elif [[ -f "${x}" ]]; then
119 ewarn "QA: File or directory \"${x}\" does not exist."
120 ewarn "QA: Check your PATCHES array or add missing file/directory."
124 [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages."
126 for x in ${PATCHES}; do
127 debug-print "$FUNCNAME: patching from ${x}"
133 debug-print "$FUNCNAME: applying user patches"
139 # @FUNCTION: base_src_configure
141 # The base src_configure function, which is exported when
142 # EAPI is greater or equal to 2. Runs basic econf.
143 base_src_configure() {
144 debug-print-function $FUNCNAME "$@"
146 # there is no pushd ${S} so we can override its place where to run
147 [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
150 # @FUNCTION: base_src_compile
152 # The base src_compile function, calls src_configure with
155 debug-print-function $FUNCNAME "$@"
157 has src_configure ${BASE_EXPF} || base_src_configure
161 # @FUNCTION: base_src_make
163 # Actual function that runs emake command.
165 debug-print-function $FUNCNAME "$@"
167 if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
168 emake "$@" || die "died running emake, $FUNCNAME"
172 # @FUNCTION: base_src_install
174 # The base src_install function. Runs make install and
175 # installs documents and html documents from DOCS and HTML_DOCS
178 debug-print-function $FUNCNAME "$@"
180 emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME"
181 base_src_install_docs
184 # @FUNCTION: base_src_install_docs
186 # Actual function that install documentation from
187 # DOCS and HTML_DOCS arrays.
188 base_src_install_docs() {
189 debug-print-function $FUNCNAME "$@"
193 pushd "${S}" > /dev/null
195 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
196 for x in "${DOCS[@]}"; do
197 debug-print "$FUNCNAME: docs: creating document from ${x}"
198 dodoc "${x}" || die "dodoc failed"
201 if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
202 for x in "${HTML_DOCS[@]}"; do
203 debug-print "$FUNCNAME: docs: creating html document from ${x}"
204 dohtml -r "${x}" || die "dohtml failed"