| 1 | # Copyright 1999-2008 Gentoo Foundation |
1 | # Copyright 1999-2008 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.43 2010/01/13 01:58:53 patrick Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.53 2010/05/27 08:09:33 scarabeus Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: base.eclass |
5 | # @ECLASS: base.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # QA Team <qa@gentoo.org> |
7 | # QA Team <qa@gentoo.org> |
| 8 | # |
8 | # |
| … | |
… | |
| 14 | |
14 | |
| 15 | inherit eutils |
15 | inherit eutils |
| 16 | |
16 | |
| 17 | BASE_EXPF="src_unpack src_compile src_install" |
17 | BASE_EXPF="src_unpack src_compile src_install" |
| 18 | case "${EAPI:-0}" in |
18 | case "${EAPI:-0}" in |
| 19 | 2|3|4) BASE_EXPF="${BASE_EXPF} src_prepare src_configure" ;; |
19 | 2|3|4) BASE_EXPF+=" src_prepare src_configure" ;; |
| 20 | *) ;; |
20 | *) ;; |
| 21 | esac |
21 | esac |
| 22 | |
22 | |
| 23 | EXPORT_FUNCTIONS ${BASE_EXPF} |
23 | EXPORT_FUNCTIONS ${BASE_EXPF} |
| 24 | |
24 | |
| … | |
… | |
| 63 | } |
63 | } |
| 64 | |
64 | |
| 65 | # @FUNCTION: base_src_prepare |
65 | # @FUNCTION: base_src_prepare |
| 66 | # @DESCRIPTION: |
66 | # @DESCRIPTION: |
| 67 | # The base src_prepare function, which is exported |
67 | # The base src_prepare function, which is exported |
| 68 | # EAPI is greater or equal to 2. |
68 | # EAPI is greater or equal to 2. Here the PATCHES array is evaluated. |
| 69 | base_src_prepare() { |
69 | base_src_prepare() { |
| 70 | debug-print-function $FUNCNAME "$@" |
70 | debug-print-function $FUNCNAME "$@" |
| 71 | debug-print "$FUNCNAME: PATCHES=$PATCHES" |
71 | debug-print "$FUNCNAME: PATCHES=$PATCHES" |
|
|
72 | |
|
|
73 | local patches_failed=0 |
| 72 | |
74 | |
| 73 | pushd "${S}" > /dev/null |
75 | pushd "${S}" > /dev/null |
| 74 | if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
76 | if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
| 75 | for x in "${PATCHES[@]}"; do |
77 | for x in "${PATCHES[@]}"; do |
| 76 | debug-print "$FUNCNAME: applying patch from ${x}" |
78 | debug-print "$FUNCNAME: applying patch from ${x}" |
| 77 | [[ -f "${x}" ]] && epatch "${x}" |
|
|
| 78 | if [[ -d "${x}" ]]; then |
79 | if [[ -d "${x}" ]]; then |
| 79 | # Use standardized names and locations with bulk patching |
80 | # Use standardized names and locations with bulk patching |
| 80 | # Patch directory is ${WORKDIR}/patch |
81 | # Patch directory is ${WORKDIR}/patch |
| 81 | # See epatch() in eutils.eclass for more documentation |
82 | # See epatch() in eutils.eclass for more documentation |
| 82 | EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch} |
83 | EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch} |
| … | |
… | |
| 84 | # in order to preserve normal EPATCH_SOURCE value that can |
85 | # in order to preserve normal EPATCH_SOURCE value that can |
| 85 | # be used other way than with base eclass store in local |
86 | # be used other way than with base eclass store in local |
| 86 | # variable and restore later |
87 | # variable and restore later |
| 87 | oldval=${EPATCH_SOURCE} |
88 | oldval=${EPATCH_SOURCE} |
| 88 | EPATCH_SOURCE=${x} |
89 | EPATCH_SOURCE=${x} |
|
|
90 | EPATCH_FORCE=yes |
| 89 | epatch |
91 | epatch |
| 90 | EPATCH_SOURCE=${oldval} |
92 | EPATCH_SOURCE=${oldval} |
|
|
93 | elif [[ -f "${x}" ]]; then |
|
|
94 | epatch "${x}" |
|
|
95 | else |
|
|
96 | ewarn "QA: File or directory \"${x}\" does not exist." |
|
|
97 | ewarn "QA: Check your PATCHES array or add missing file/directory." |
|
|
98 | patches_failed=1 |
| 91 | fi |
99 | fi |
| 92 | done |
100 | done |
|
|
101 | [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages." |
| 93 | else |
102 | else |
| 94 | for x in ${PATCHES}; do |
103 | for x in ${PATCHES}; do |
| 95 | debug-print "$FUNCNAME: patching from ${x}" |
104 | debug-print "$FUNCNAME: patching from ${x}" |
| 96 | epatch "${x}" |
105 | epatch "${x}" |
| 97 | done |
106 | done |
| … | |
… | |
| 105 | } |
114 | } |
| 106 | |
115 | |
| 107 | # @FUNCTION: base_src_configure |
116 | # @FUNCTION: base_src_configure |
| 108 | # @DESCRIPTION: |
117 | # @DESCRIPTION: |
| 109 | # The base src_configure function, which is exported when |
118 | # The base src_configure function, which is exported when |
| 110 | # EAPI is greater or equal to 2. Runs basic econf. Here the PATCHES array is |
119 | # EAPI is greater or equal to 2. Runs basic econf. |
| 111 | # evaluated. |
|
|
| 112 | base_src_configure() { |
120 | base_src_configure() { |
| 113 | debug-print-function $FUNCNAME "$@" |
121 | debug-print-function $FUNCNAME "$@" |
| 114 | |
122 | |
| 115 | # there is no pushd ${S} so we can override its place where to run |
123 | # there is no pushd ${S} so we can override its place where to run |
| 116 | [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf |
124 | [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@" |
| 117 | } |
125 | } |
| 118 | |
126 | |
| 119 | # @FUNCTION: base_src_compile |
127 | # @FUNCTION: base_src_compile |
| 120 | # @DESCRIPTION: |
128 | # @DESCRIPTION: |
| 121 | # The base src_compile function, calls src_configure with |
129 | # The base src_compile function, calls src_configure with |
| 122 | # EAPI older than 2. |
130 | # EAPI older than 2. |
| 123 | base_src_compile() { |
131 | base_src_compile() { |
| 124 | debug-print-function $FUNCNAME "$@" |
132 | debug-print-function $FUNCNAME "$@" |
| 125 | |
133 | |
| 126 | has src_configure ${BASE_EXPF} || base_src_configure |
134 | has src_configure ${BASE_EXPF} || base_src_configure |
| 127 | base_src_make $@ |
135 | base_src_make "$@" |
| 128 | } |
136 | } |
| 129 | |
137 | |
| 130 | # @FUNCTION: base_src_make |
138 | # @FUNCTION: base_src_make |
| 131 | # @DESCRIPTION: |
139 | # @DESCRIPTION: |
| 132 | # Actual function that runs emake command. |
140 | # Actual function that runs emake command. |
| 133 | base_src_make() { |
141 | base_src_make() { |
| 134 | debug-print-function $FUNCNAME "$@" |
142 | debug-print-function $FUNCNAME "$@" |
| 135 | |
143 | |
| 136 | if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then |
144 | if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then |
| 137 | emake $@ || die "died running emake, $FUNCNAME:make" |
145 | emake "$@" || die "died running emake, $FUNCNAME" |
| 138 | fi |
146 | fi |
| 139 | } |
147 | } |
| 140 | |
148 | |
| 141 | # @FUNCTION: base_src_install |
149 | # @FUNCTION: base_src_install |
| 142 | # @DESCRIPTION: |
150 | # @DESCRIPTION: |
| … | |
… | |
| 144 | # installs documents and html documents from DOCS and HTML_DOCS |
152 | # installs documents and html documents from DOCS and HTML_DOCS |
| 145 | # arrays. |
153 | # arrays. |
| 146 | base_src_install() { |
154 | base_src_install() { |
| 147 | debug-print-function $FUNCNAME "$@" |
155 | debug-print-function $FUNCNAME "$@" |
| 148 | |
156 | |
| 149 | emake DESTDIR="${D}" $@ install || die "died running make install, $FUNCNAME:make" |
157 | emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME" |
| 150 | base_src_install_docs |
158 | base_src_install_docs |
| 151 | } |
159 | } |
| 152 | |
160 | |
| 153 | # @FUNCTION: base_src_install_docs |
161 | # @FUNCTION: base_src_install_docs |
| 154 | # @DESCRIPTION: |
162 | # @DESCRIPTION: |
| … | |
… | |
| 162 | pushd "${S}" > /dev/null |
170 | pushd "${S}" > /dev/null |
| 163 | |
171 | |
| 164 | if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
172 | if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
| 165 | for x in "${DOCS[@]}"; do |
173 | for x in "${DOCS[@]}"; do |
| 166 | debug-print "$FUNCNAME: docs: creating document from ${x}" |
174 | debug-print "$FUNCNAME: docs: creating document from ${x}" |
| 167 | dodoc -r "${x}" || die "dodoc failed" |
175 | dodoc "${x}" || die "dodoc failed" |
| 168 | done |
176 | done |
| 169 | fi |
177 | fi |
| 170 | if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
178 | if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
| 171 | for x in "${HTML_DOCS[@]}"; do |
179 | for x in "${HTML_DOCS[@]}"; do |
| 172 | debug-print "$FUNCNAME: docs: creating html document from ${x}" |
180 | debug-print "$FUNCNAME: docs: creating html document from ${x}" |