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