| 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.19 2011/09/16 15:38:40 mgorny Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/autotools-utils.eclass,v 1.30 2011/12/14 14:55:03 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 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 |
|
|
101 | # @DEFAULT_UNSET |
| 96 | # @DESCRIPTION: |
102 | # @DESCRIPTION: |
| 97 | # Build directory, location where all autotools generated files should be |
103 | # Build directory, location where all autotools generated files should be |
| 98 | # placed. For out of source builds it defaults to ${WORKDIR}/${P}_build. |
104 | # placed. For out of source builds it defaults to ${WORKDIR}/${P}_build. |
| 99 | |
105 | |
| 100 | # @ECLASS-VARIABLE: AUTOTOOLS_IN_SOURCE_BUILD |
106 | # @ECLASS-VARIABLE: AUTOTOOLS_IN_SOURCE_BUILD |
|
|
107 | # @DEFAULT_UNSET |
| 101 | # @DESCRIPTION: |
108 | # @DESCRIPTION: |
| 102 | # Set to enable in-source build. |
109 | # Set to enable in-source build. |
| 103 | |
110 | |
| 104 | # @ECLASS-VARIABLE: ECONF_SOURCE |
111 | # @ECLASS-VARIABLE: ECONF_SOURCE |
|
|
112 | # @DEFAULT_UNSET |
| 105 | # @DESCRIPTION: |
113 | # @DESCRIPTION: |
| 106 | # Specify location of autotools' configure script. By default it uses ${S}. |
114 | # Specify location of autotools' configure script. By default it uses ${S}. |
| 107 | |
115 | |
| 108 | # @ECLASS-VARIABLE: myeconfargs |
116 | # @ECLASS-VARIABLE: myeconfargs |
|
|
117 | # @DEFAULT_UNSET |
| 109 | # @DESCRIPTION: |
118 | # @DESCRIPTION: |
| 110 | # Optional econf arguments as Bash array. Should be defined before calling src_configure. |
119 | # Optional econf arguments as Bash array. Should be defined before calling src_configure. |
| 111 | # @CODE |
120 | # @CODE |
| 112 | # src_configure() { |
121 | # src_configure() { |
| 113 | # local myeconfargs=( |
122 | # local myeconfargs=( |
| … | |
… | |
| 116 | # $(use_enable debug cnddebug) |
125 | # $(use_enable debug cnddebug) |
| 117 | # $(use_enable threads multithreading) |
126 | # $(use_enable threads multithreading) |
| 118 | # ) |
127 | # ) |
| 119 | # autotools-utils_src_configure |
128 | # autotools-utils_src_configure |
| 120 | # } |
129 | # } |
|
|
130 | # @CODE |
|
|
131 | |
|
|
132 | # @ECLASS-VARIABLE: DOCS |
|
|
133 | # @DEFAULT_UNSET |
|
|
134 | # @DESCRIPTION: |
|
|
135 | # Array containing documents passed to dodoc command. |
|
|
136 | # |
|
|
137 | # Example: |
|
|
138 | # @CODE |
|
|
139 | # DOCS=( NEWS README ) |
|
|
140 | # @CODE |
|
|
141 | |
|
|
142 | # @ECLASS-VARIABLE: HTML_DOCS |
|
|
143 | # @DEFAULT_UNSET |
|
|
144 | # @DESCRIPTION: |
|
|
145 | # Array containing documents passed to dohtml command. |
|
|
146 | # |
|
|
147 | # Example: |
|
|
148 | # @CODE |
|
|
149 | # HTML_DOCS=( doc/html/ ) |
|
|
150 | # @CODE |
|
|
151 | |
|
|
152 | # @ECLASS-VARIABLE: PATCHES |
|
|
153 | # @DEFAULT_UNSET |
|
|
154 | # @DESCRIPTION: |
|
|
155 | # PATCHES array variable containing all various patches to be applied. |
|
|
156 | # |
|
|
157 | # Example: |
|
|
158 | # @CODE |
|
|
159 | # PATCHES=( "${FILESDIR}"/${P}-mypatch.patch ) |
| 121 | # @CODE |
160 | # @CODE |
| 122 | |
161 | |
| 123 | # Determine using IN or OUT source build |
162 | # Determine using IN or OUT source build |
| 124 | _check_build_dir() { |
163 | _check_build_dir() { |
| 125 | : ${ECONF_SOURCE:=${S}} |
164 | : ${ECONF_SOURCE:=${S}} |
| … | |
… | |
| 184 | # - user explicitly wants us to remove all .la files, |
223 | # - user explicitly wants us to remove all .la files, |
| 185 | # - respective static archive doesn't exist, |
224 | # - respective static archive doesn't exist, |
| 186 | # - they are covered by a .pc file already, |
225 | # - they are covered by a .pc file already, |
| 187 | # - they don't provide any new information (no libs & no flags). |
226 | # - they don't provide any new information (no libs & no flags). |
| 188 | local removing |
227 | local removing |
| 189 | if [[ ${removing_all} ]]; then removing=1 |
228 | if [[ ${removing_all} ]]; then removing='forced' |
| 190 | elif [[ ! -f ${archivefile} ]]; then removing=1 |
229 | elif [[ ! -f ${archivefile} ]]; then removing='no static archive' |
| 191 | elif has "$(basename "${f}")" "${pc_libs[@]}"; then removing=1 |
230 | elif has "$(basename "${f}")" "${pc_libs[@]}"; then |
|
|
231 | removing='covered by .pc' |
| 192 | elif [[ ! $(sed -n -e \ |
232 | elif [[ ! $(sed -n -e \ |
| 193 | "s/^\(dependency_libs\|inherited_linker_flags\)='\(.*\)'$/\2/p" \ |
233 | "s/^\(dependency_libs\|inherited_linker_flags\)='\(.*\)'$/\2/p" \ |
| 194 | "${f}") ]]; then removing=1 |
234 | "${f}") ]]; then removing='no libs & flags' |
| 195 | fi |
235 | fi |
| 196 | |
236 | |
| 197 | if [[ ${removing} ]]; then |
237 | if [[ ${removing} ]]; then |
| 198 | einfo "Removing unnecessary ${f#${D%/}}" |
238 | einfo "Removing unnecessary ${f#${D%/}} (${removing})" |
| 199 | rm -f "${f}" || die |
239 | rm -f "${f}" || die |
| 200 | fi |
240 | fi |
| 201 | done |
241 | done |
|
|
242 | |
|
|
243 | # check for invalid eclass use |
|
|
244 | # this is the most commonly used function, so do it here |
|
|
245 | _check_build_dir |
|
|
246 | if [[ ! -d "${AUTOTOOLS_BUILD_DIR}" ]]; then |
|
|
247 | eqawarn "autotools-utils used but autotools-utils_src_configure was never called." |
|
|
248 | eqawarn "This is not supported and never was. Please report a bug against" |
|
|
249 | eqawarn "the offending ebuild. This will become a fatal error in a near future." |
|
|
250 | fi |
| 202 | } |
251 | } |
| 203 | |
252 | |
| 204 | # @FUNCTION: autotools-utils_src_prepare |
253 | # @FUNCTION: autotools-utils_src_prepare |
| 205 | # @DESCRIPTION: |
254 | # @DESCRIPTION: |
| 206 | # The src_prepare function. |
255 | # The src_prepare function. |
| 207 | # |
256 | # |
| 208 | # Supporting PATCHES array and user patches. See base.eclass(5) for reference. |
257 | # Supporting PATCHES array and user patches. See base.eclass(5) for reference. |
| 209 | autotools-utils_src_prepare() { |
258 | autotools-utils_src_prepare() { |
| 210 | debug-print-function ${FUNCNAME} "$@" |
259 | debug-print-function ${FUNCNAME} "$@" |
| 211 | |
260 | |
| 212 | base_src_prepare |
261 | [[ ${PATCHES} ]] && epatch "${PATCHES[@]}" |
|
|
262 | epatch_user |
|
|
263 | |
|
|
264 | elibtoolize --patch-only |
| 213 | } |
265 | } |
| 214 | |
266 | |
| 215 | # @FUNCTION: autotools-utils_src_configure |
267 | # @FUNCTION: autotools-utils_src_configure |
| 216 | # @DESCRIPTION: |
268 | # @DESCRIPTION: |
| 217 | # The src_configure function. For out of source build it creates build |
269 | # The src_configure function. For out of source build it creates build |
| 218 | # directory and runs econf there. Configuration parameters defined |
270 | # directory and runs econf there. Configuration parameters defined |
| 219 | # in myeconfargs are passed here to econf. Additionally following USE |
271 | # in myeconfargs are passed here to econf. Additionally following USE |
| 220 | # flags are known: |
272 | # flags are known: |
| 221 | # |
273 | # |
| 222 | # IUSE="debug" passes --disable-debug/--enable-debug to econf respectively. |
|
|
| 223 | # |
|
|
| 224 | # IUSE="static-libs" passes --enable-shared and either --disable-static/--enable-static |
274 | # IUSE="static-libs" passes --enable-shared and either --disable-static/--enable-static |
| 225 | # to econf respectively. |
275 | # to econf respectively. |
| 226 | autotools-utils_src_configure() { |
276 | autotools-utils_src_configure() { |
| 227 | debug-print-function ${FUNCNAME} "$@" |
277 | debug-print-function ${FUNCNAME} "$@" |
| 228 | |
278 | |
|
|
279 | [[ -z ${myeconfargs+1} || $(declare -p myeconfargs) == 'declare -a'* ]] \ |
|
|
280 | || die 'autotools-utils.eclass: myeconfargs has to be an array.' |
|
|
281 | |
| 229 | # Common args |
282 | # Common args |
| 230 | local econfargs=() |
283 | local econfargs=() |
| 231 | |
284 | |
| 232 | # Handle debug found in IUSE |
|
|
| 233 | if has debug ${IUSE//+}; then |
|
|
| 234 | econfargs+=($(use_enable debug)) |
|
|
| 235 | fi |
|
|
| 236 | |
|
|
| 237 | # Handle static-libs found in IUSE, disable them by default |
285 | # Handle static-libs found in IUSE, disable them by default |
| 238 | if has static-libs ${IUSE//+}; then |
286 | if in_iuse static-libs; then |
| 239 | econfargs+=( |
287 | econfargs+=( |
| 240 | --enable-shared |
288 | --enable-shared |
| 241 | $(use_enable static-libs static) |
289 | $(use_enable static-libs static) |
| 242 | ) |
290 | ) |
| 243 | fi |
291 | fi |
| … | |
… | |
| 246 | econfargs+=("${myeconfargs[@]}") |
294 | econfargs+=("${myeconfargs[@]}") |
| 247 | |
295 | |
| 248 | _check_build_dir |
296 | _check_build_dir |
| 249 | mkdir -p "${AUTOTOOLS_BUILD_DIR}" || die "mkdir '${AUTOTOOLS_BUILD_DIR}' failed" |
297 | mkdir -p "${AUTOTOOLS_BUILD_DIR}" || die "mkdir '${AUTOTOOLS_BUILD_DIR}' failed" |
| 250 | pushd "${AUTOTOOLS_BUILD_DIR}" > /dev/null |
298 | pushd "${AUTOTOOLS_BUILD_DIR}" > /dev/null |
| 251 | base_src_configure "${econfargs[@]}" "$@" |
299 | econf "${econfargs[@]}" "$@" |
| 252 | popd > /dev/null |
300 | popd > /dev/null |
| 253 | } |
301 | } |
| 254 | |
302 | |
| 255 | # @FUNCTION: autotools-utils_src_compile |
303 | # @FUNCTION: autotools-utils_src_compile |
| 256 | # @DESCRIPTION: |
304 | # @DESCRIPTION: |
| … | |
… | |
| 258 | autotools-utils_src_compile() { |
306 | autotools-utils_src_compile() { |
| 259 | debug-print-function ${FUNCNAME} "$@" |
307 | debug-print-function ${FUNCNAME} "$@" |
| 260 | |
308 | |
| 261 | _check_build_dir |
309 | _check_build_dir |
| 262 | pushd "${AUTOTOOLS_BUILD_DIR}" > /dev/null |
310 | pushd "${AUTOTOOLS_BUILD_DIR}" > /dev/null |
| 263 | base_src_compile "$@" |
311 | emake "$@" || die 'emake failed' |
| 264 | popd > /dev/null |
312 | popd > /dev/null |
| 265 | } |
313 | } |
| 266 | |
314 | |
| 267 | # @FUNCTION: autotools-utils_src_install |
315 | # @FUNCTION: autotools-utils_src_install |
| 268 | # @DESCRIPTION: |
316 | # @DESCRIPTION: |
| … | |
… | |
| 275 | autotools-utils_src_install() { |
323 | autotools-utils_src_install() { |
| 276 | debug-print-function ${FUNCNAME} "$@" |
324 | debug-print-function ${FUNCNAME} "$@" |
| 277 | |
325 | |
| 278 | _check_build_dir |
326 | _check_build_dir |
| 279 | pushd "${AUTOTOOLS_BUILD_DIR}" > /dev/null |
327 | pushd "${AUTOTOOLS_BUILD_DIR}" > /dev/null |
| 280 | base_src_install "$@" |
328 | emake DESTDIR="${D}" "$@" install || die "emake install failed" |
| 281 | popd > /dev/null |
329 | popd > /dev/null |
|
|
330 | |
|
|
331 | # XXX: support installing them from builddir as well? |
|
|
332 | if [[ ${DOCS} ]]; then |
|
|
333 | dodoc "${DOCS[@]}" || die "dodoc failed" |
|
|
334 | fi |
|
|
335 | if [[ ${HTML_DOCS} ]]; then |
|
|
336 | dohtml -r "${HTML_DOCS[@]}" || die "dohtml failed" |
|
|
337 | fi |
| 282 | |
338 | |
| 283 | # Remove libtool files and unnecessary static libs |
339 | # Remove libtool files and unnecessary static libs |
| 284 | remove_libtool_files |
340 | remove_libtool_files |
| 285 | } |
341 | } |
| 286 | |
342 | |