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

Diff of /eclass/base.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.4 Revision 1.55
1# Copyright 1999-2000 Gentoo Technologies, Inc. 1# Copyright 1999-2011 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License, v2 or later 2# Distributed under the terms of the GNU General Public License v2
3# Author Dan Armak <danarmak@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.4 2001/09/29 12:35:38 danarmak Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.55 2011/12/14 23:38:09 vapier Exp $
5# The base eclass defines some default functions and variables. Nearly everything
6# else inherits from here.
7. /usr/portage/eclass/inherit.eclass || die
8inherit virtual || die
9ECLASS=base
10 4
11S=${WORKDIR}/${P} 5# @ECLASS: base.eclass
12DESCRIPTION="Based on the $ECLASS eclass" 6# @MAINTAINER:
7# QA Team <qa@gentoo.org>
8# @AUTHOR:
9# Original author: Dan Armak <danarmak@gentoo.org>
10# @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.
13 14
15if [[ ${___ECLASS_ONCE_BASE} != "recur -_+^+_- spank" ]] ; then
16___ECLASS_ONCE_BASE="recur -_+^+_- spank"
17
18inherit eutils
19
20BASE_EXPF="src_unpack src_compile src_install"
21case "${EAPI:-0}" in
22 2|3|4) BASE_EXPF+=" src_prepare src_configure" ;;
23 *) ;;
24esac
25
26EXPORT_FUNCTIONS ${BASE_EXPF}
27
28# @ECLASS-VARIABLE: DOCS
29# @DESCRIPTION:
30# Array containing documents passed to dodoc command.
31#
32# DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" )
33
34# @ECLASS-VARIABLE: HTML_DOCS
35# @DESCRIPTION:
36# Array containing documents passed to dohtml command.
37#
38# HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" )
39
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#
47# NOTE: if using patches folders with special file suffixes you have to
48# define one additional variable EPATCH_SUFFIX="something"
49#
50# PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" )
51
52
53# @FUNCTION: base_src_unpack
54# @DESCRIPTION:
55# The base src_unpack function, which is exported.
56# Calls also src_prepare with eapi older than 2.
14base_src_unpack() { 57base_src_unpack() {
15 58 debug-print-function $FUNCNAME "$@"
16 echo "in base_src_unpack, 1st parameter is $1" 59
17 [ -z "$1" ] && base_src_unpack all 60 pushd "${WORKDIR}" > /dev/null
18 61
19 while [ "$1" ]; do 62 [[ -n "${A}" ]] && unpack ${A}
20 63 has src_prepare ${BASE_EXPF} || base_src_prepare
21 case $1 in 64
22 unpack) 65 popd > /dev/null
23 echo "in base_src_unpack, action unpack"
24 unpack ${A}
25 ;;
26 all)
27 echo "in base_src_unpack, action all"
28 base_src_unpack unpack
29 ;;
30 esac
31
32 shift
33 done
34
35} 66}
36 67
68# @FUNCTION: base_src_prepare
69# @DESCRIPTION:
70# The base src_prepare function, which is exported
71# EAPI is greater or equal to 2. Here the PATCHES array is evaluated.
37base_src_compile() { 72base_src_prepare() {
73 debug-print-function $FUNCNAME "$@"
74 debug-print "$FUNCNAME: PATCHES=$PATCHES"
38 75
39 echo "in base_src_compile, 1st parameter is $1" 76 local patches_failed=0
40 [ -z "$1" ] && base_src_compile all 77
41 78 pushd "${S}" > /dev/null
42 while [ "$1" ]; do 79 if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
43 80 for x in "${PATCHES[@]}"; do
44 case $1 in 81 debug-print "$FUNCNAME: applying patch from ${x}"
45 configure) 82 if [[ -d "${x}" ]]; then
46 echo "in base_src_compile, action configure" 83 # Use standardized names and locations with bulk patching
47 ./configure || die 84 # Patch directory is ${WORKDIR}/patch
48 ;; 85 # See epatch() in eutils.eclass for more documentation
49 make) 86 EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
50 echo "in base_src_compile, action make" 87
51 make || die 88 # in order to preserve normal EPATCH_SOURCE value that can
52 ;; 89 # be used other way than with base eclass store in local
53 all) 90 # variable and restore later
54 echo "in base_src_compile, action all" 91 oldval=${EPATCH_SOURCE}
55 base_src_compile configure make 92 EPATCH_SOURCE=${x}
56 ;; 93 EPATCH_FORCE=yes
57 esac 94 epatch
58 95 EPATCH_SOURCE=${oldval}
59 shift 96 elif [[ -f "${x}" ]]; then
60 done 97 epatch "${x}"
61 98 else
99 ewarn "QA: File or directory \"${x}\" does not exist."
100 ewarn "QA: Check your PATCHES array or add missing file/directory."
101 patches_failed=1
102 fi
103 done
104 [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages."
105 else
106 for x in ${PATCHES}; do
107 debug-print "$FUNCNAME: patching from ${x}"
108 epatch "${x}"
109 done
110 fi
111
112 # Apply user patches
113 debug-print "$FUNCNAME: applying user patches"
114 epatch_user
115
116 popd > /dev/null
62} 117}
63 118
64base_src_install() { 119# @FUNCTION: base_src_configure
120# @DESCRIPTION:
121# The base src_configure function, which is exported when
122# EAPI is greater or equal to 2. Runs basic econf.
123base_src_configure() {
124 debug-print-function $FUNCNAME "$@"
65 125
66 echo "in base_src_install, 1st parameter is $1" 126 # there is no pushd ${S} so we can override its place where to run
67 [ -z "$1" ] && base_src_install all 127 [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
68
69 while [ "$1" ]; do
70
71 case $1 in
72 make)
73 echo "in base_src_install, action make"
74 make DESTDIR=${D} install || die
75 ;;
76 all)
77 echo "in base_src_install, action all"
78 base_src_install make
79 ;;
80 esac
81
82 shift
83 done
84
85} 128}
86 129
87EXPORT_FUNCTIONS src_unpack src_compile src_install 130# @FUNCTION: base_src_compile
131# @DESCRIPTION:
132# The base src_compile function, calls src_configure with
133# EAPI older than 2.
134base_src_compile() {
135 debug-print-function $FUNCNAME "$@"
88 136
137 has src_configure ${BASE_EXPF} || base_src_configure
138 base_src_make "$@"
139}
140
141# @FUNCTION: base_src_make
142# @DESCRIPTION:
143# Actual function that runs emake command.
144base_src_make() {
145 debug-print-function $FUNCNAME "$@"
146
147 if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
148 emake "$@" || die "died running emake, $FUNCNAME"
149 fi
150}
151
152# @FUNCTION: base_src_install
153# @DESCRIPTION:
154# The base src_install function. Runs make install and
155# installs documents and html documents from DOCS and HTML_DOCS
156# arrays.
157base_src_install() {
158 debug-print-function $FUNCNAME "$@"
159
160 emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME"
161 base_src_install_docs
162}
163
164# @FUNCTION: base_src_install_docs
165# @DESCRIPTION:
166# Actual function that install documentation from
167# DOCS and HTML_DOCS arrays.
168base_src_install_docs() {
169 debug-print-function $FUNCNAME "$@"
170
171 local x
172
173 pushd "${S}" > /dev/null
174
175 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
176 for x in "${DOCS[@]}"; do
177 debug-print "$FUNCNAME: docs: creating document from ${x}"
178 dodoc "${x}" || die "dodoc failed"
179 done
180 fi
181 if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
182 for x in "${HTML_DOCS[@]}"; do
183 debug-print "$FUNCNAME: docs: creating html document from ${x}"
184 dohtml -r "${x}" || die "dohtml failed"
185 done
186 fi
187
188 popd > /dev/null
189}
190
191fi

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.55

  ViewVC Help
Powered by ViewVC 1.1.20