| 1 | # Copyright 1999-2010 Gentoo Foundation |
1 | # Copyright 1999-2010 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.eclass,v 1.99 2010/07/06 18:55:50 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.104 2011/08/07 22:53:28 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: autotools.eclass |
5 | # @ECLASS: autotools.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # base-system@gentoo.org |
7 | # base-system@gentoo.org |
| 8 | # @BLURB: Regenerates auto* build scripts |
8 | # @BLURB: Regenerates auto* build scripts |
| … | |
… | |
| 23 | # @DESCRIPTION: |
23 | # @DESCRIPTION: |
| 24 | # The major version of automake your package needs |
24 | # The major version of automake your package needs |
| 25 | : ${WANT_AUTOMAKE:=latest} |
25 | : ${WANT_AUTOMAKE:=latest} |
| 26 | |
26 | |
| 27 | # @ECLASS-VARIABLE: _LATEST_AUTOMAKE |
27 | # @ECLASS-VARIABLE: _LATEST_AUTOMAKE |
|
|
28 | # @INTERNAL |
| 28 | # @DESCRIPTION: |
29 | # @DESCRIPTION: |
| 29 | # CONSTANT! |
30 | # CONSTANT! |
| 30 | # The latest major version/slot of automake available on each arch. |
31 | # The latest major version/slot of automake available on each arch. |
| 31 | # If a newer version is stable on any arch, and is NOT reflected in this list, |
32 | # If a newer version is stable on any arch, and is NOT reflected in this list, |
| 32 | # then circular dependencies may arise during emerge @system bootstraps. |
33 | # then circular dependencies may arise during emerge @system bootstraps. |
| … | |
… | |
| 72 | fi |
73 | fi |
| 73 | |
74 | |
| 74 | unset _automake_atom _autoconf_atom |
75 | unset _automake_atom _autoconf_atom |
| 75 | |
76 | |
| 76 | # @ECLASS-VARIABLE: AM_OPTS |
77 | # @ECLASS-VARIABLE: AM_OPTS |
|
|
78 | # @DEFAULT_UNSET |
| 77 | # @DESCRIPTION: |
79 | # @DESCRIPTION: |
| 78 | # Additional options to pass to automake during |
80 | # Additional options to pass to automake during |
| 79 | # eautoreconf call. |
81 | # eautoreconf call. |
| 80 | |
82 | |
| 81 | # @ECLASS-VARIABLE: AT_NOELIBTOOLIZE |
83 | # @ECLASS-VARIABLE: AT_NOELIBTOOLIZE |
|
|
84 | # @DEFAULT_UNSET |
| 82 | # @DESCRIPTION: |
85 | # @DESCRIPTION: |
| 83 | # Don't run elibtoolize command if set to 'yes', |
86 | # Don't run elibtoolize command if set to 'yes', |
| 84 | # useful when elibtoolize needs to be ran with |
87 | # useful when elibtoolize needs to be ran with |
| 85 | # particular options |
88 | # particular options |
| 86 | |
89 | |
| 87 | # XXX: M4DIR should be deprecated |
90 | # XXX: M4DIR should be deprecated |
| 88 | # @ECLASS-VARIABLE: AT_M4DIR |
91 | # @ECLASS-VARIABLE: AT_M4DIR |
| 89 | # @DESCRIPTION: |
92 | # @DESCRIPTION: |
| 90 | # Additional director(y|ies) aclocal should search |
93 | # Additional director(y|ies) aclocal should search |
| 91 | : ${AT_M4DIR:=${M4DIR}} |
94 | : ${AT_M4DIR:=${M4DIR}} |
| 92 | AT_GNUCONF_UPDATE="no" |
|
|
| 93 | |
|
|
| 94 | |
95 | |
| 95 | # @FUNCTION: eautoreconf |
96 | # @FUNCTION: eautoreconf |
| 96 | # @DESCRIPTION: |
97 | # @DESCRIPTION: |
| 97 | # This function mimes the behavior of autoreconf, but uses the different |
98 | # This function mimes the behavior of autoreconf, but uses the different |
| 98 | # eauto* functions to run the tools. It doesn't accept parameters, but |
99 | # eauto* functions to run the tools. It doesn't accept parameters, but |
| … | |
… | |
| 149 | local aclocal_opts |
150 | local aclocal_opts |
| 150 | |
151 | |
| 151 | local amflags_file |
152 | local amflags_file |
| 152 | for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in ; do |
153 | for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in ; do |
| 153 | [[ -e ${amflags_file} ]] || continue |
154 | [[ -e ${amflags_file} ]] || continue |
|
|
155 | # setup the env in case the pkg does something crazy |
|
|
156 | # in their ACLOCAL_AMFLAGS. like run a shell script |
|
|
157 | # which turns around and runs autotools #365401 |
|
|
158 | autotools_env_setup |
| 154 | aclocal_opts=$(sed -n '/^ACLOCAL_AMFLAGS[[:space:]]*=/s:[^=]*=::p' ${amflags_file}) |
159 | aclocal_opts=$(sed -n '/^ACLOCAL_AMFLAGS[[:space:]]*=/s:[^=]*=::p' ${amflags_file}) |
| 155 | eval aclocal_opts=\"${aclocal_opts}\" |
160 | eval aclocal_opts=\"${aclocal_opts}\" |
| 156 | break |
161 | break |
| 157 | done |
162 | done |
| 158 | |
163 | |
| 159 | if [[ -n ${AT_M4DIR} ]] ; then |
|
|
| 160 | for x in ${AT_M4DIR} ; do |
|
|
| 161 | case "${x}" in |
|
|
| 162 | "-I") |
|
|
| 163 | # We handle it below |
|
|
| 164 | ;; |
|
|
| 165 | *) |
|
|
| 166 | [[ ! -d ${x} ]] && ewarn "eaclocal: '${x}' does not exist" |
|
|
| 167 | aclocal_opts="${aclocal_opts} -I ${x}" |
|
|
| 168 | ;; |
|
|
| 169 | esac |
|
|
| 170 | done |
|
|
| 171 | fi |
|
|
| 172 | |
|
|
| 173 | [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \ |
164 | [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \ |
| 174 | autotools_run_tool aclocal "$@" ${aclocal_opts} |
165 | autotools_run_tool aclocal $(autotools_m4dir_include) "$@" ${aclocal_opts} |
| 175 | } |
166 | } |
| 176 | |
167 | |
| 177 | # @FUNCTION: _elibtoolize |
168 | # @FUNCTION: _elibtoolize |
| 178 | # @DESCRIPTION: |
169 | # @DESCRIPTION: |
| 179 | # Runs libtoolize. Note the '_' prefix .. to not collide with elibtoolize() from |
170 | # Runs libtoolize. Note the '_' prefix .. to not collide with elibtoolize() from |
| … | |
… | |
| 198 | # @DESCRIPTION: |
189 | # @DESCRIPTION: |
| 199 | # Runs autoheader. |
190 | # Runs autoheader. |
| 200 | eautoheader() { |
191 | eautoheader() { |
| 201 | # Check if we should run autoheader |
192 | # Check if we should run autoheader |
| 202 | [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0 |
193 | [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0 |
| 203 | NO_FAIL=1 autotools_run_tool autoheader "$@" |
194 | NO_FAIL=1 autotools_run_tool autoheader $(autotools_m4dir_include) "$@" |
| 204 | } |
195 | } |
| 205 | |
196 | |
| 206 | # @FUNCTION: eautoconf |
197 | # @FUNCTION: eautoconf |
| 207 | # @DESCRIPTION: |
198 | # @DESCRIPTION: |
| 208 | # Runs autoconf. |
199 | # Runs autoconf. |
| … | |
… | |
| 212 | eerror "No configure.{ac,in} present in '${PWD}'!" |
203 | eerror "No configure.{ac,in} present in '${PWD}'!" |
| 213 | echo |
204 | echo |
| 214 | die "No configure.{ac,in} present!" |
205 | die "No configure.{ac,in} present!" |
| 215 | fi |
206 | fi |
| 216 | |
207 | |
| 217 | autotools_run_tool autoconf "$@" |
208 | autotools_run_tool autoconf $(autotools_m4dir_include) "$@" |
| 218 | } |
209 | } |
| 219 | |
210 | |
| 220 | # @FUNCTION: eautomake |
211 | # @FUNCTION: eautomake |
| 221 | # @DESCRIPTION: |
212 | # @DESCRIPTION: |
| 222 | # Runs automake. |
213 | # Runs automake. |
| … | |
… | |
| 268 | eautopoint() { |
259 | eautopoint() { |
| 269 | autotools_run_tool autopoint "$@" |
260 | autotools_run_tool autopoint "$@" |
| 270 | } |
261 | } |
| 271 | |
262 | |
| 272 | # Internal function to run an autotools' tool |
263 | # Internal function to run an autotools' tool |
| 273 | autotools_run_tool() { |
264 | autotools_env_setup() { |
| 274 | if [[ ${EBUILD_PHASE} != "unpack" && ${EBUILD_PHASE} != "prepare" ]]; then |
|
|
| 275 | ewarn "QA Warning: running $1 in ${EBUILD_PHASE} phase" |
|
|
| 276 | fi |
|
|
| 277 | |
|
|
| 278 | # We do the “latest” → version switch here because it solves |
265 | # We do the “latest” → version switch here because it solves |
| 279 | # possible order problems, see bug #270010 as an example. |
266 | # possible order problems, see bug #270010 as an example. |
| 280 | if [[ ${WANT_AUTOMAKE} == "latest" ]]; then |
267 | if [[ ${WANT_AUTOMAKE} == "latest" ]]; then |
| 281 | local pv |
268 | local pv |
| 282 | for pv in ${_LATEST_AUTOMAKE} ; do |
269 | for pv in ${_LATEST_AUTOMAKE} ; do |
| … | |
… | |
| 286 | done |
273 | done |
| 287 | [[ ${WANT_AUTOMAKE} == "latest" ]] && \ |
274 | [[ ${WANT_AUTOMAKE} == "latest" ]] && \ |
| 288 | die "Cannot find the latest automake! Tried ${_LATEST_AUTOMAKE}" |
275 | die "Cannot find the latest automake! Tried ${_LATEST_AUTOMAKE}" |
| 289 | fi |
276 | fi |
| 290 | [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5 |
277 | [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5 |
|
|
278 | } |
|
|
279 | autotools_run_tool() { |
|
|
280 | if [[ ${EBUILD_PHASE} != "unpack" && ${EBUILD_PHASE} != "prepare" ]]; then |
|
|
281 | ewarn "QA Warning: running $1 in ${EBUILD_PHASE} phase" |
|
|
282 | fi |
|
|
283 | |
|
|
284 | autotools_env_setup |
| 291 | |
285 | |
| 292 | local STDERR_TARGET="${T}/$1.out" |
286 | local STDERR_TARGET="${T}/$1.out" |
| 293 | # most of the time, there will only be one run, but if there are |
287 | # most of the time, there will only be one run, but if there are |
| 294 | # more, make sure we get unique log filenames |
288 | # more, make sure we get unique log filenames |
| 295 | if [[ -e ${STDERR_TARGET} ]] ; then |
289 | if [[ -e ${STDERR_TARGET} ]] ; then |
|
|
290 | local i=1 |
|
|
291 | while :; do |
| 296 | STDERR_TARGET="${T}/$1-$$.out" |
292 | STDERR_TARGET="${T}/$1-${i}.out" |
|
|
293 | [[ -e ${STDERR_TARGET} ]] || break |
|
|
294 | : $(( i++ )) |
|
|
295 | done |
| 297 | fi |
296 | fi |
| 298 | |
297 | |
| 299 | printf "***** $1 *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}" |
298 | printf "***** $1 *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}" |
| 300 | |
299 | |
| 301 | ebegin "Running $@" |
300 | ebegin "Running $@" |
| … | |
… | |
| 317 | # Internal function to check for support |
316 | # Internal function to check for support |
| 318 | autotools_check_macro() { |
317 | autotools_check_macro() { |
| 319 | [[ -f configure.ac || -f configure.in ]] || return 0 |
318 | [[ -f configure.ac || -f configure.in ]] || return 0 |
| 320 | local macro |
319 | local macro |
| 321 | for macro ; do |
320 | for macro ; do |
| 322 | WANT_AUTOCONF="2.5" autoconf --trace="${macro}" 2>/dev/null |
321 | WANT_AUTOCONF="2.5" autoconf $(autotools_m4dir_include) --trace="${macro}" 2>/dev/null |
| 323 | done |
322 | done |
| 324 | return 0 |
323 | return 0 |
| 325 | } |
324 | } |
| 326 | |
325 | |
| 327 | # Internal function to get additional subdirs to configure |
326 | # Internal function to get additional subdirs to configure |
| … | |
… | |
| 352 | print res[1] |
351 | print res[1] |
| 353 | }' | uniq |
352 | }' | uniq |
| 354 | |
353 | |
| 355 | return 0 |
354 | return 0 |
| 356 | } |
355 | } |
|
|
356 | |
|
|
357 | autotools_m4dir_include() { |
|
|
358 | [[ -n ${AT_M4DIR} ]] || return |
|
|
359 | |
|
|
360 | local include_opts= |
|
|
361 | |
|
|
362 | for x in ${AT_M4DIR} ; do |
|
|
363 | case "${x}" in |
|
|
364 | "-I") |
|
|
365 | # We handle it below |
|
|
366 | ;; |
|
|
367 | *) |
|
|
368 | [[ ! -d ${x} ]] && ewarn "autotools.eclass: '${x}' does not exist" |
|
|
369 | include_opts="${include_opts} -I ${x}" |
|
|
370 | ;; |
|
|
371 | esac |
|
|
372 | done |
|
|
373 | |
|
|
374 | echo $include_opts |
|
|
375 | } |