1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # This eclass has been deprecated and must not be used by any new
6 # ebuilds or eclasses. Replacements for particular phase functions
9 # base_src_unpack() - default (or unpacker_src_unpack if unpacker.eclass
11 # base_src_prepare() - inherit eutils, inline:
12 # epatch "${PATCHES[@]}" # if PATCHES defined as array
13 # epatch ${PATCHES} # if PATCHES defined as string
15 # base_src_configure() - default
16 # base_src_compile() - default
17 # base_src_install() - default
18 # base_src_install_docs() - einstalldocs from eutils.eclass
20 # @ECLASS: base.eclass
22 # QA Team <qa@gentoo.org>
24 # Original author: Dan Armak <danarmak@gentoo.org>
25 # @BLURB: The base eclass defines some default functions and variables.
27 # The base eclass defines some default functions and variables.
29 if [[ -z ${_BASE_ECLASS} ]]; then
34 BASE_EXPF="src_unpack src_compile src_install"
36 6) die "${ECLASS}.eclass is banned in EAPI ${EAPI}";;
37 2|3|4|5) BASE_EXPF+=" src_prepare src_configure" ;;
41 EXPORT_FUNCTIONS ${BASE_EXPF}
43 # @ECLASS-VARIABLE: DOCS
45 # Array containing documents passed to dodoc command.
47 # DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" )
49 # @ECLASS-VARIABLE: HTML_DOCS
51 # Array containing documents passed to dohtml command.
53 # HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" )
55 # @ECLASS-VARIABLE: PATCHES
57 # PATCHES array variable containing all various patches to be applied.
58 # This variable is expected to be defined in global scope of ebuild.
59 # Make sure to specify the full path. This variable is utilised in
60 # src_unpack/src_prepare phase based on EAPI.
62 # NOTE: if using patches folders with special file suffixes you have to
63 # define one additional variable EPATCH_SUFFIX="something"
65 # PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" )
68 # @FUNCTION: base_src_unpack
70 # The base src_unpack function, which is exported.
71 # Calls also src_prepare with eapi older than 2.
73 debug-print-function $FUNCNAME "$@"
75 pushd "${WORKDIR}" > /dev/null
77 if [[ $(type -t unpacker_src_unpack) == "function" ]] ; then
79 elif [[ -n ${A} ]] ; then
82 has src_prepare ${BASE_EXPF} || base_src_prepare
87 # @FUNCTION: base_src_prepare
89 # The base src_prepare function, which is exported
90 # EAPI is greater or equal to 2. Here the PATCHES array is evaluated.
92 debug-print-function $FUNCNAME "$@"
93 debug-print "$FUNCNAME: PATCHES=$PATCHES"
95 local patches_failed=0
97 pushd "${S}" > /dev/null
98 if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
99 for x in "${PATCHES[@]}"; do
100 debug-print "$FUNCNAME: applying patch from ${x}"
101 if [[ -d "${x}" ]]; then
102 # Use standardized names and locations with bulk patching
103 # Patch directory is ${WORKDIR}/patch
104 # See epatch() in eutils.eclass for more documentation
105 EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
107 # in order to preserve normal EPATCH_SOURCE value that can
108 # be used other way than with base eclass store in local
109 # variable and restore later
110 oldval=${EPATCH_SOURCE}
114 EPATCH_SOURCE=${oldval}
115 elif [[ -f "${x}" ]]; then
118 ewarn "QA: File or directory \"${x}\" does not exist."
119 ewarn "QA: Check your PATCHES array or add missing file/directory."
123 [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages."
125 for x in ${PATCHES}; do
126 debug-print "$FUNCNAME: patching from ${x}"
132 debug-print "$FUNCNAME: applying user patches"
138 # @FUNCTION: base_src_configure
140 # The base src_configure function, which is exported when
141 # EAPI is greater or equal to 2. Runs basic econf.
142 base_src_configure() {
143 debug-print-function $FUNCNAME "$@"
145 # there is no pushd ${S} so we can override its place where to run
146 [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
149 # @FUNCTION: base_src_compile
151 # The base src_compile function, calls src_configure with
154 debug-print-function $FUNCNAME "$@"
156 has src_configure ${BASE_EXPF} || base_src_configure
160 # @FUNCTION: base_src_make
162 # Actual function that runs emake command.
164 debug-print-function $FUNCNAME "$@"
166 if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
167 emake "$@" || die "died running emake, $FUNCNAME"
171 # @FUNCTION: base_src_install
173 # The base src_install function. Runs make install and
174 # installs documents and html documents from DOCS and HTML_DOCS
177 debug-print-function $FUNCNAME "$@"
179 emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME"
180 base_src_install_docs
183 # @FUNCTION: base_src_install_docs
185 # Actual function that install documentation from
186 # DOCS and HTML_DOCS arrays.
187 base_src_install_docs() {
188 debug-print-function $FUNCNAME "$@"
192 pushd "${S}" > /dev/null
194 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
195 for x in "${DOCS[@]}"; do
196 debug-print "$FUNCNAME: docs: creating document from ${x}"
197 dodoc "${x}" || die "dodoc failed"
200 if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
201 for x in "${HTML_DOCS[@]}"; do
202 debug-print "$FUNCNAME: docs: creating html document from ${x}"
203 dohtml -r "${x}" || die "dohtml failed"