/[gentoo-x86]/eclass/autotools.eclass
Gentoo

Diff of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.106 Revision 1.113
1# Copyright 1999-2011 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.eclass,v 1.106 2011/08/22 19:39:52 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.113 2011/12/13 21:57:05 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
9# @DESCRIPTION: 9# @DESCRIPTION:
10# This eclass is for safely handling autotooled software packages that need to 10# This eclass is for safely handling autotooled software packages that need to
11# regenerate their build scripts. All functions will abort in case of errors. 11# regenerate their build scripts. All functions will abort in case of errors.
12# 12
13# NB: If you add anything, please comment it! 13if [[ ${___ECLASS_ONCE_AUTOTOOLS} != "recur -_+^+_- spank" ]] ; then
14___ECLASS_ONCE_AUTOTOOLS="recur -_+^+_- spank"
14 15
15inherit eutils libtool 16inherit eutils libtool
16 17
17# @ECLASS-VARIABLE: WANT_AUTOCONF 18# @ECLASS-VARIABLE: WANT_AUTOCONF
18# @DESCRIPTION: 19# @DESCRIPTION:
105# @ECLASS-VARIABLE: AT_M4DIR 106# @ECLASS-VARIABLE: AT_M4DIR
106# @DESCRIPTION: 107# @DESCRIPTION:
107# Additional director(y|ies) aclocal should search 108# Additional director(y|ies) aclocal should search
108: ${AT_M4DIR:=${M4DIR}} 109: ${AT_M4DIR:=${M4DIR}}
109 110
111# @ECLASS-VARIABLE: AT_SYS_M4DIR
112# @INTERNAL
113# @DESCRIPTION:
114# For system integrators, a list of additional aclocal search paths.
115# This variable gets eval-ed, so you can use variables in the definition
116# that may not be valid until eautoreconf & friends are run.
117: ${AT_SYS_M4DIR:=}
118
110# @FUNCTION: eautoreconf 119# @FUNCTION: eautoreconf
111# @DESCRIPTION: 120# @DESCRIPTION:
112# This function mimes the behavior of autoreconf, but uses the different 121# This function mimes the behavior of autoreconf, but uses the different
113# eauto* functions to run the tools. It doesn't accept parameters, but 122# eauto* functions to run the tools. It doesn't accept parameters, but
114# the directory with include files can be specified with AT_M4DIR variable. 123# the directory with include files can be specified with AT_M4DIR variable.
146 155
147 [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0 156 [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0
148 157
149 # Call it here to prevent failures due to elibtoolize called _before_ 158 # Call it here to prevent failures due to elibtoolize called _before_
150 # eautoreconf. We set $S because elibtoolize runs on that #265319 159 # eautoreconf. We set $S because elibtoolize runs on that #265319
151 S=${PWD} elibtoolize 160 S=${PWD} elibtoolize --force
152 161
153 return 0 162 return 0
163}
164
165# @FUNCTION: eaclocal_amflags
166# @DESCRIPTION:
167# Extract the ACLOCAL_AMFLAGS value from the Makefile.am and try to handle
168# (most) of the crazy crap that people throw at us.
169eaclocal_amflags() {
170 local aclocal_opts amflags_file
171
172 for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in ; do
173 [[ -e ${amflags_file} ]] || continue
174 # setup the env in case the pkg does something crazy
175 # in their ACLOCAL_AMFLAGS. like run a shell script
176 # which turns around and runs autotools. #365401
177 # or split across multiple lines. #383525
178 autotools_env_setup
179 aclocal_opts=$(sed -n \
180 "/^ACLOCAL_AMFLAGS[[:space:]]*=/{ \
181 # match the first line
182 s:[^=]*=::p; \
183 # then gobble up all escaped lines
184 : nextline /\\\\$/{ n; p; b nextline; } \
185 }" ${amflags_file})
186 eval aclocal_opts=\""${aclocal_opts}"\"
187 break
188 done
189
190 echo ${aclocal_opts}
154} 191}
155 192
156# @FUNCTION: eaclocal 193# @FUNCTION: eaclocal
157# @DESCRIPTION: 194# @DESCRIPTION:
158# These functions runs the autotools using autotools_run_tool with the 195# These functions runs the autotools using autotools_run_tool with the
159# specified parametes. The name of the tool run is the same of the function 196# specified parametes. The name of the tool run is the same of the function
160# without e prefix. 197# without e prefix.
161# They also force installing the support files for safety. 198# They also force installing the support files for safety.
162# Respects AT_M4DIR for additional directories to search for macro's. 199# Respects AT_M4DIR for additional directories to search for macro's.
163eaclocal() { 200eaclocal() {
164 local aclocal_opts
165
166 local amflags_file
167 for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in ; do
168 [[ -e ${amflags_file} ]] || continue
169 # setup the env in case the pkg does something crazy
170 # in their ACLOCAL_AMFLAGS. like run a shell script
171 # which turns around and runs autotools #365401
172 autotools_env_setup
173 aclocal_opts=$(sed -n '/^ACLOCAL_AMFLAGS[[:space:]]*=/s:[^=]*=::p' ${amflags_file})
174 eval aclocal_opts=\"${aclocal_opts}\"
175 break
176 done
177
178 [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \ 201 [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
179 autotools_run_tool aclocal $(autotools_m4dir_include) "$@" ${aclocal_opts} 202 autotools_run_tool aclocal $(autotools_m4dir_include) "$@" $(eaclocal_amflags)
180} 203}
181 204
182# @FUNCTION: _elibtoolize 205# @FUNCTION: _elibtoolize
183# @DESCRIPTION: 206# @DESCRIPTION:
184# Runs libtoolize. Note the '_' prefix .. to not collide with elibtoolize() from 207# Runs libtoolize. Note the '_' prefix .. to not collide with elibtoolize() from
258 eautoreconf 281 eautoreconf
259 return 0 282 return 0
260 fi 283 fi
261 fi 284 fi
262 285
263 [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS ]] \ 286 [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS && -f README ]] \
264 || extra_opts="${extra_opts} --foreign" 287 || extra_opts="${extra_opts} --foreign"
265 288
266 # --force-missing seems not to be recognized by some flavours of automake 289 # --force-missing seems not to be recognized by some flavours of automake
267 autotools_run_tool automake --add-missing --copy ${extra_opts} "$@" 290 autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
268} 291}
335 WANT_AUTOCONF="2.5" autoconf $(autotools_m4dir_include) --trace="${macro}" 2>/dev/null 358 WANT_AUTOCONF="2.5" autoconf $(autotools_m4dir_include) --trace="${macro}" 2>/dev/null
336 done 359 done
337 return 0 360 return 0
338} 361}
339 362
363# Internal function to look for a macro and extract its value
364autotools_check_macro_val() {
365 local macro=$1 scan_out
366
367 autotools_check_macro "${macro}" | \
368 gawk -v macro="${macro}" \
369 '($0 !~ /^[[:space:]]*(#|dnl)/) {
370 if (match($0, macro ":(.*)$", res))
371 print res[1]
372 }' | uniq
373
374 return 0
375}
376
340# Internal function to get additional subdirs to configure 377# Internal function to get additional subdirs to configure
341autotools_get_subdirs() { 378autotools_get_subdirs() { autotools_check_macro_val AC_CONFIG_SUBDIRS ; }
342 local subdirs_scan_out 379autotools_get_auxdir() { autotools_check_macro_val AC_CONFIG_AUX_DIR ; }
343
344 subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS")
345 [[ -n ${subdirs_scan_out} ]] || return 0
346
347 echo "${subdirs_scan_out}" | gawk \
348 '($0 !~ /^[[:space:]]*(#|dnl)/) {
349 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
350 print res[1]
351 }' | uniq
352
353 return 0
354}
355
356autotools_get_auxdir() {
357 local auxdir_scan_out
358
359 auxdir_scan_out=$(autotools_check_macro "AC_CONFIG_AUX_DIR")
360 [[ -n ${auxdir_scan_out} ]] || return 0
361
362 echo ${auxdir_scan_out} | gawk \
363 '($0 !~ /^[[:space:]]*(#|dnl)/) {
364 if (match($0, /AC_CONFIG_AUX_DIR:(.*)$/, res))
365 print res[1]
366 }' | uniq
367
368 return 0
369}
370 380
371autotools_m4dir_include() { 381autotools_m4dir_include() {
372 [[ -n ${AT_M4DIR} ]] || return
373
374 local include_opts= 382 local x include_opts
375 383
376 for x in ${AT_M4DIR} ; do 384 for x in ${AT_M4DIR} $(eval echo ${AT_SYS_M4DIR}) ; do
377 case "${x}" in 385 case "${x}" in
378 "-I") 386 "-I")
379 # We handle it below 387 # We handle it below
380 ;; 388 ;;
381 *) 389 *)
382 [[ ! -d ${x} ]] && ewarn "autotools.eclass: '${x}' does not exist" 390 [[ ! -d ${x} ]] && ewarn "autotools.eclass: '${x}' does not exist"
383 include_opts="${include_opts} -I ${x}" 391 include_opts+=" -I ${x}"
384 ;; 392 ;;
385 esac 393 esac
386 done 394 done
387 395
388 echo $include_opts 396 echo ${include_opts}
389} 397}
398
399fi

Legend:
Removed from v.1.106  
changed lines
  Added in v.1.113

  ViewVC Help
Powered by ViewVC 1.1.20