| 1 | # Copyright 1999-2010 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/autotools-utils.eclass,v 1.18 2011/09/16 15:38:26 mgorny Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/autotools-utils.eclass,v 1.29 2011/11/27 09:57:20 mgorny Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: autotools-utils.eclass |
5 | # @ECLASS: autotools-utils.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Maciej Mrozowski <reavertm@gentoo.org> |
7 | # Maciej Mrozowski <reavertm@gentoo.org> |
| 8 | # Michał Górny <mgorny@gentoo.org> |
8 | # Michał Górny <mgorny@gentoo.org> |
| 9 | # @BLURB: common ebuild functions for autotools-based packages |
9 | # @BLURB: common ebuild functions for autotools-based packages |
| 10 | # @DESCRIPTION: |
10 | # @DESCRIPTION: |
| 11 | # autotools-utils.eclass is autotools.eclass(5) and base.eclass(5) wrapper |
11 | # autotools-utils.eclass is autotools.eclass(5) and base.eclass(5) wrapper |
| 12 | # providing all inherited features along with econf arguments as Bash array, |
12 | # providing all inherited features along with econf arguments as Bash array, |
| 13 | # out of source build with overridable build dir location, static archives |
13 | # out of source build with overridable build dir location, static archives |
| 14 | # handling, libtool files removal, enable/disable debug handling. |
14 | # handling, libtool files removal. |
|
|
15 | # |
|
|
16 | # Please note note that autotools-utils does not support mixing of its phase |
|
|
17 | # functions with regular econf/emake calls. If necessary, please call |
|
|
18 | # autotools-utils_src_compile instead of the latter. |
| 15 | # |
19 | # |
| 16 | # @EXAMPLE: |
20 | # @EXAMPLE: |
| 17 | # Typical ebuild using autotools-utils.eclass: |
21 | # Typical ebuild using autotools-utils.eclass: |
| 18 | # |
22 | # |
| 19 | # @CODE |
23 | # @CODE |
| … | |
… | |
| 56 | # "${FILESDIR}/${P}-unbundle_libpng.patch" |
60 | # "${FILESDIR}/${P}-unbundle_libpng.patch" |
| 57 | # ) |
61 | # ) |
| 58 | # |
62 | # |
| 59 | # src_configure() { |
63 | # src_configure() { |
| 60 | # local myeconfargs=( |
64 | # local myeconfargs=( |
|
|
65 | # $(use_enable debug) |
| 61 | # $(use_with qt4) |
66 | # $(use_with qt4) |
| 62 | # $(use_enable threads multithreading) |
67 | # $(use_enable threads multithreading) |
| 63 | # $(use_with tiff) |
68 | # $(use_with tiff) |
| 64 | # ) |
69 | # ) |
| 65 | # autotools-utils_src_configure |
70 | # autotools-utils_src_configure |
| … | |
… | |
| 86 | case ${EAPI:-0} in |
91 | case ${EAPI:-0} in |
| 87 | 2|3|4) ;; |
92 | 2|3|4) ;; |
| 88 | *) die "EAPI=${EAPI} is not supported" ;; |
93 | *) die "EAPI=${EAPI} is not supported" ;; |
| 89 | esac |
94 | esac |
| 90 | |
95 | |
| 91 | inherit autotools base |
96 | inherit autotools base eutils libtool |
| 92 | |
97 | |
| 93 | EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install src_test |
98 | EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install src_test |
| 94 | |
99 | |
| 95 | # @ECLASS-VARIABLE: AUTOTOOLS_BUILD_DIR |
100 | # @ECLASS-VARIABLE: AUTOTOOLS_BUILD_DIR |
| 96 | # @DESCRIPTION: |
101 | # @DESCRIPTION: |
| … | |
… | |
| 154 | *) |
159 | *) |
| 155 | die "Invalid argument to ${FUNCNAME}(): ${1}" |
160 | die "Invalid argument to ${FUNCNAME}(): ${1}" |
| 156 | esac |
161 | esac |
| 157 | fi |
162 | fi |
| 158 | |
163 | |
|
|
164 | local pc_libs=() |
|
|
165 | if [[ ! ${removing_all} ]]; then |
|
|
166 | local arg |
|
|
167 | for arg in $(find "${D}" -name '*.pc' -exec \ |
|
|
168 | sed -n -e 's;^Libs:;;p' {} +); do |
|
|
169 | [[ ${arg} == -l* ]] && pc_libs+=(lib${arg#-l}.la) |
|
|
170 | done |
|
|
171 | fi |
|
|
172 | |
| 159 | local f |
173 | local f |
| 160 | find "${D}" -type f -name '*.la' -print0 | while read -r -d '' f; do |
174 | find "${D}" -type f -name '*.la' -print0 | while read -r -d '' f; do |
| 161 | local shouldnotlink=$(sed -ne '/^shouldnotlink=yes$/p' "${f}") |
175 | local shouldnotlink=$(sed -ne '/^shouldnotlink=yes$/p' "${f}") |
| 162 | local archivefile=${f/%.la/.a} |
176 | local archivefile=${f/%.la/.a} |
| 163 | [[ "${f}" != "${archivefile}" ]] || die 'regex sanity check failed' |
177 | [[ "${f}" != "${archivefile}" ]] || die 'regex sanity check failed' |
| … | |
… | |
| 172 | fi |
186 | fi |
| 173 | |
187 | |
| 174 | # Remove .la files when: |
188 | # Remove .la files when: |
| 175 | # - user explicitly wants us to remove all .la files, |
189 | # - user explicitly wants us to remove all .la files, |
| 176 | # - respective static archive doesn't exist, |
190 | # - respective static archive doesn't exist, |
|
|
191 | # - they are covered by a .pc file already, |
| 177 | # - they don't provide any new information (no libs & no flags). |
192 | # - they don't provide any new information (no libs & no flags). |
| 178 | local removing |
193 | local removing |
| 179 | if [[ ${removing_all} ]]; then removing=1 |
194 | if [[ ${removing_all} ]]; then removing='forced' |
| 180 | elif [[ ! -f ${archivefile} ]]; then removing=1 |
195 | elif [[ ! -f ${archivefile} ]]; then removing='no static archive' |
|
|
196 | elif has "$(basename "${f}")" "${pc_libs[@]}"; then |
|
|
197 | removing='covered by .pc' |
| 181 | elif [[ ! $(sed -n -e \ |
198 | elif [[ ! $(sed -n -e \ |
| 182 | "s/^\(dependency_libs\|inherited_linker_flags\)='\(.*\)'$/\2/p" \ |
199 | "s/^\(dependency_libs\|inherited_linker_flags\)='\(.*\)'$/\2/p" \ |
| 183 | "${f}") ]]; then removing=1 |
200 | "${f}") ]]; then removing='no libs & flags' |
| 184 | fi |
201 | fi |
| 185 | |
202 | |
| 186 | if [[ ${removing} ]]; then |
203 | if [[ ${removing} ]]; then |
| 187 | einfo "Removing unnecessary ${f#${D%/}}" |
204 | einfo "Removing unnecessary ${f#${D%/}} (${removing})" |
| 188 | rm -f "${f}" || die |
205 | rm -f "${f}" || die |
| 189 | fi |
206 | fi |
| 190 | done |
207 | done |
|
|
208 | |
|
|
209 | # check for invalid eclass use |
|
|
210 | # this is the most commonly used function, so do it here |
|
|
211 | _check_build_dir |
|
|
212 | if [[ ! -d "${AUTOTOOLS_BUILD_DIR}" ]]; then |
|
|
213 | eqawarn "autotools-utils used but autotools-utils_src_configure was never called." |
|
|
214 | eqawarn "This is not supported and never was. Please report a bug against" |
|
|
215 | eqawarn "the offending ebuild. This will become a fatal error in a near future." |
|
|
216 | fi |
| 191 | } |
217 | } |
| 192 | |
218 | |
| 193 | # @FUNCTION: autotools-utils_src_prepare |
219 | # @FUNCTION: autotools-utils_src_prepare |
| 194 | # @DESCRIPTION: |
220 | # @DESCRIPTION: |
| 195 | # The src_prepare function. |
221 | # The src_prepare function. |
| … | |
… | |
| 197 | # Supporting PATCHES array and user patches. See base.eclass(5) for reference. |
223 | # Supporting PATCHES array and user patches. See base.eclass(5) for reference. |
| 198 | autotools-utils_src_prepare() { |
224 | autotools-utils_src_prepare() { |
| 199 | debug-print-function ${FUNCNAME} "$@" |
225 | debug-print-function ${FUNCNAME} "$@" |
| 200 | |
226 | |
| 201 | base_src_prepare |
227 | base_src_prepare |
|
|
228 | elibtoolize --patch-only |
| 202 | } |
229 | } |
| 203 | |
230 | |
| 204 | # @FUNCTION: autotools-utils_src_configure |
231 | # @FUNCTION: autotools-utils_src_configure |
| 205 | # @DESCRIPTION: |
232 | # @DESCRIPTION: |
| 206 | # The src_configure function. For out of source build it creates build |
233 | # The src_configure function. For out of source build it creates build |
| 207 | # directory and runs econf there. Configuration parameters defined |
234 | # directory and runs econf there. Configuration parameters defined |
| 208 | # in myeconfargs are passed here to econf. Additionally following USE |
235 | # in myeconfargs are passed here to econf. Additionally following USE |
| 209 | # flags are known: |
236 | # flags are known: |
| 210 | # |
237 | # |
| 211 | # IUSE="debug" passes --disable-debug/--enable-debug to econf respectively. |
|
|
| 212 | # |
|
|
| 213 | # IUSE="static-libs" passes --enable-shared and either --disable-static/--enable-static |
238 | # IUSE="static-libs" passes --enable-shared and either --disable-static/--enable-static |
| 214 | # to econf respectively. |
239 | # to econf respectively. |
| 215 | autotools-utils_src_configure() { |
240 | autotools-utils_src_configure() { |
| 216 | debug-print-function ${FUNCNAME} "$@" |
241 | debug-print-function ${FUNCNAME} "$@" |
| 217 | |
242 | |
|
|
243 | [[ -z ${myeconfargs+1} || $(declare -p myeconfargs) == 'declare -a'* ]] \ |
|
|
244 | || die 'autotools-utils.eclass: myeconfargs has to be an array.' |
|
|
245 | |
| 218 | # Common args |
246 | # Common args |
| 219 | local econfargs=() |
247 | local econfargs=() |
| 220 | |
248 | |
| 221 | # Handle debug found in IUSE |
|
|
| 222 | if has debug ${IUSE//+}; then |
|
|
| 223 | econfargs+=($(use_enable debug)) |
|
|
| 224 | fi |
|
|
| 225 | |
|
|
| 226 | # Handle static-libs found in IUSE, disable them by default |
249 | # Handle static-libs found in IUSE, disable them by default |
| 227 | if has static-libs ${IUSE//+}; then |
250 | if in_iuse static-libs; then |
| 228 | econfargs+=( |
251 | econfargs+=( |
| 229 | --enable-shared |
252 | --enable-shared |
| 230 | $(use_enable static-libs static) |
253 | $(use_enable static-libs static) |
| 231 | ) |
254 | ) |
| 232 | fi |
255 | fi |