1 # Copyright 1999-2017 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
46 # Array containing documents passed to dodoc command.
48 # DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" )
50 # @ECLASS-VARIABLE: HTML_DOCS
53 # Array containing documents passed to dohtml command.
55 # HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" )
57 # @ECLASS-VARIABLE: PATCHES
60 # PATCHES array variable containing all various patches to be applied.
61 # This variable is expected to be defined in global scope of ebuild.
62 # Make sure to specify the full path. This variable is utilised in
63 # src_unpack/src_prepare phase based on EAPI.
65 # NOTE: if using patches folders with special file suffixes you have to
66 # define one additional variable EPATCH_SUFFIX="something"
68 # PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" )
71 # @FUNCTION: base_src_unpack
73 # The base src_unpack function, which is exported.
74 # Calls also src_prepare with eapi older than 2.
76 debug-print-function $FUNCNAME "$@"
78 pushd "${WORKDIR}" > /dev/null
80 if [[ $(type -t unpacker_src_unpack) == "function" ]] ; then
82 elif [[ -n ${A} ]] ; then
85 has src_prepare ${BASE_EXPF} || base_src_prepare
90 # @FUNCTION: base_src_prepare
92 # The base src_prepare function, which is exported
93 # EAPI is greater or equal to 2. Here the PATCHES array is evaluated.
95 debug-print-function $FUNCNAME "$@"
96 debug-print "$FUNCNAME: PATCHES=$PATCHES"
98 local patches_failed=0
100 pushd "${S}" > /dev/null
101 if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
102 for x in "${PATCHES[@]}"; do
103 debug-print "$FUNCNAME: applying patch from ${x}"
104 if [[ -d "${x}" ]]; then
105 # Use standardized names and locations with bulk patching
106 # Patch directory is ${WORKDIR}/patch
107 # See epatch() in eutils.eclass for more documentation
108 EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
110 # in order to preserve normal EPATCH_SOURCE value that can
111 # be used other way than with base eclass store in local
112 # variable and restore later
113 oldval=${EPATCH_SOURCE}
117 EPATCH_SOURCE=${oldval}
118 elif [[ -f "${x}" ]]; then
121 ewarn "QA: File or directory \"${x}\" does not exist."
122 ewarn "QA: Check your PATCHES array or add missing file/directory."
126 [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages."
128 for x in ${PATCHES}; do
129 debug-print "$FUNCNAME: patching from ${x}"
135 debug-print "$FUNCNAME: applying user patches"
141 # @FUNCTION: base_src_configure
143 # The base src_configure function, which is exported when
144 # EAPI is greater or equal to 2. Runs basic econf.
145 base_src_configure() {
146 debug-print-function $FUNCNAME "$@"
148 # there is no pushd ${S} so we can override its place where to run
149 [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
152 # @FUNCTION: base_src_compile
154 # The base src_compile function, calls src_configure with
157 debug-print-function $FUNCNAME "$@"
159 has src_configure ${BASE_EXPF} || base_src_configure
163 # @FUNCTION: base_src_make
165 # Actual function that runs emake command.
167 debug-print-function $FUNCNAME "$@"
169 if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
170 emake "$@" || die "died running emake, $FUNCNAME"
174 # @FUNCTION: base_src_install
176 # The base src_install function. Runs make install and
177 # installs documents and html documents from DOCS and HTML_DOCS
180 debug-print-function $FUNCNAME "$@"
182 emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME"
183 base_src_install_docs
186 # @FUNCTION: base_src_install_docs
188 # Actual function that install documentation from
189 # DOCS and HTML_DOCS arrays.
190 base_src_install_docs() {
191 debug-print-function $FUNCNAME "$@"
195 pushd "${S}" > /dev/null
197 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
198 for x in "${DOCS[@]}"; do
199 debug-print "$FUNCNAME: docs: creating document from ${x}"
200 dodoc "${x}" || die "dodoc failed"
203 if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
204 for x in "${HTML_DOCS[@]}"; do
205 debug-print "$FUNCNAME: docs: creating html document from ${x}"
206 dohtml -r "${x}" || die "dohtml failed"