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 # @SUPPORTED_EAPIS: 0 1 2 3 4 5
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"
38 2|3|4|5) BASE_EXPF+=" src_prepare src_configure" ;;
39 *) die "${ECLASS}.eclass is banned in EAPI ${EAPI}";;
42 EXPORT_FUNCTIONS ${BASE_EXPF}
44 # @ECLASS-VARIABLE: DOCS
47 # Array containing documents passed to dodoc command.
49 # DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" )
51 # @ECLASS-VARIABLE: HTML_DOCS
54 # Array containing documents passed to dohtml command.
56 # HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" )
58 # @ECLASS-VARIABLE: PATCHES
61 # PATCHES array variable containing all various patches to be applied.
62 # This variable is expected to be defined in global scope of ebuild.
63 # Make sure to specify the full path. This variable is utilised in
64 # src_unpack/src_prepare phase based on EAPI.
66 # NOTE: if using patches folders with special file suffixes you have to
67 # define one additional variable EPATCH_SUFFIX="something"
69 # PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" )
72 # @FUNCTION: base_src_unpack
74 # The base src_unpack function, which is exported.
75 # Calls also src_prepare with eapi older than 2.
77 debug-print-function $FUNCNAME "$@"
79 pushd "${WORKDIR}" > /dev/null
81 if [[ $(type -t unpacker_src_unpack) == "function" ]] ; then
83 elif [[ -n ${A} ]] ; then
86 has src_prepare ${BASE_EXPF} || base_src_prepare
91 # @FUNCTION: base_src_prepare
93 # The base src_prepare function, which is exported
94 # EAPI is greater or equal to 2. Here the PATCHES array is evaluated.
96 debug-print-function $FUNCNAME "$@"
97 debug-print "$FUNCNAME: PATCHES=$PATCHES"
99 local patches_failed=0
101 pushd "${S}" > /dev/null
102 if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
103 for x in "${PATCHES[@]}"; do
104 debug-print "$FUNCNAME: applying patch from ${x}"
105 if [[ -d "${x}" ]]; then
106 # Use standardized names and locations with bulk patching
107 # Patch directory is ${WORKDIR}/patch
108 # See epatch() in eutils.eclass for more documentation
109 EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
111 # in order to preserve normal EPATCH_SOURCE value that can
112 # be used other way than with base eclass store in local
113 # variable and restore later
114 oldval=${EPATCH_SOURCE}
118 EPATCH_SOURCE=${oldval}
119 elif [[ -f "${x}" ]]; then
122 ewarn "QA: File or directory \"${x}\" does not exist."
123 ewarn "QA: Check your PATCHES array or add missing file/directory."
127 [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages."
129 for x in ${PATCHES}; do
130 debug-print "$FUNCNAME: patching from ${x}"
136 debug-print "$FUNCNAME: applying user patches"
142 # @FUNCTION: base_src_configure
144 # The base src_configure function, which is exported when
145 # EAPI is greater or equal to 2. Runs basic econf.
146 base_src_configure() {
147 debug-print-function $FUNCNAME "$@"
149 # there is no pushd ${S} so we can override its place where to run
150 [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
153 # @FUNCTION: base_src_compile
155 # The base src_compile function, calls src_configure with
158 debug-print-function $FUNCNAME "$@"
160 has src_configure ${BASE_EXPF} || base_src_configure
164 # @FUNCTION: base_src_make
166 # Actual function that runs emake command.
168 debug-print-function $FUNCNAME "$@"
170 if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
171 emake "$@" || die "died running emake, $FUNCNAME"
175 # @FUNCTION: base_src_install
177 # The base src_install function. Runs make install and
178 # installs documents and html documents from DOCS and HTML_DOCS
181 debug-print-function $FUNCNAME "$@"
183 emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME"
184 base_src_install_docs
187 # @FUNCTION: base_src_install_docs
189 # Actual function that install documentation from
190 # DOCS and HTML_DOCS arrays.
191 base_src_install_docs() {
192 debug-print-function $FUNCNAME "$@"
196 pushd "${S}" > /dev/null
198 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
199 for x in "${DOCS[@]}"; do
200 debug-print "$FUNCNAME: docs: creating document from ${x}"
201 dodoc "${x}" || die "dodoc failed"
204 if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
205 for x in "${HTML_DOCS[@]}"; do
206 debug-print "$FUNCNAME: docs: creating html document from ${x}"
207 dohtml -r "${x}" || die "dohtml failed"