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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.53 - (show annotations) (download)
Thu Oct 26 22:05:21 2006 UTC (7 years, 9 months ago) by peper
Branch: MAIN
Changes since 1.52: +3 -5 lines
Fix WANT_AUTOMAKE=latest.

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.52 2006/10/25 18:30:01 flameeyes Exp $
4 #
5 # Author: Diego Pettenò <flameeyes@gentoo.org>
6 # Enhancements: Martin Schlemmer <azarah@gentoo.org>
7 #
8 # This eclass is for handling autotooled software packages that
9 # needs to regenerate their build scripts.
10 #
11 # NB: If you add anything, please comment it!
12
13 inherit eutils libtool
14
15 _automake_atom="sys-devel/automake"
16 _autoconf_atom="sys-devel/autoconf"
17 if [[ -n ${WANT_AUTOMAKE} ]] && [[ ${WANT_AUTOMAKE} != "latest" ]]; then
18 case ${WANT_AUTOMAKE} in
19 # workaround while we have different versions of automake in arch and ~arch
20 latest) _automake_atom="|| ( =sys-devel/automake-1.10* =sys-devel/automake-1.9* )" ;;
21 *) _automake_atom="=sys-devel/automake-${WANT_AUTOMAKE}*" ;;
22 esac
23 fi
24
25 if [[ -n ${WANT_AUTOCONF} ]] ; then
26 case ${WANT_AUTOCONF} in
27 2.1) _autoconf_atom="=sys-devel/autoconf-${WANT_AUTOCONF}*" ;;
28 latest | 2.5) _autoconf_atom=">=sys-devel/autoconf-2.59" ;;
29 esac
30 fi
31 DEPEND="${_automake_atom}
32 ${_autoconf_atom}
33 sys-devel/libtool"
34 RDEPEND=""
35 unset _automake_atom _autoconf_atom
36
37 # Variables:
38 #
39 # AT_M4DIR - Additional director(y|ies) aclocal should search
40 # AM_OPTS - Additional options to pass to automake during
41 # eautoreconf call.
42
43 # Functions:
44 #
45 # eautoreconf() - Should do a full autoreconf - normally what most people
46 # will be interested in. Also should handle additional
47 # directories specified by AC_CONFIG_SUBDIRS.
48 # eaclocal() - Runs aclocal. Respects AT_M4DIR for additional directories
49 # to search for macro's.
50 # _elibtoolize() - Runs libtoolize. Note the '_' prefix .. to not collide
51 # with elibtoolize() from libtool.eclass
52 # eautoconf - Runs autoconf.
53 # eautoheader - Runs autoheader.
54 # eautomake - Runs automake
55 #
56
57 # XXX: M4DIR should be depreciated
58 AT_M4DIR=${AT_M4DIR:-${M4DIR}}
59 AT_GNUCONF_UPDATE="no"
60
61
62 # This function mimes the behavior of autoreconf, but uses the different
63 # eauto* functions to run the tools. It doesn't accept parameters, but
64 # the directory with include files can be specified with AT_M4DIR variable.
65 eautoreconf() {
66 local pwd=$(pwd) x auxdir
67
68 if [[ -z ${AT_NO_RECURSIVE} ]]; then
69 # Take care of subdirs
70 for x in $(autotools_get_subdirs); do
71 if [[ -d ${x} ]] ; then
72 cd "${x}"
73 AT_NOELIBTOOLIZE="yes" eautoreconf
74 cd "${pwd}"
75 fi
76 done
77 fi
78
79 auxdir=$(autotools_get_auxdir)
80
81 einfo "Running eautoreconf in '$(pwd)' ..."
82 [[ -n ${auxdir} ]] && mkdir -p ${auxdir}
83 eaclocal
84 _elibtoolize --copy --force
85 eautoconf
86 eautoheader
87 FROM_EAUTORECONF="yes" eautomake ${AM_OPTS}
88
89 [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0
90
91 # Call it here to prevent failures due to elibtoolize called _before_
92 # eautoreconf.
93 elibtoolize
94
95 return 0
96 }
97
98 # These functions runs the autotools using autotools_run_tool with the
99 # specified parametes. The name of the tool run is the same of the function
100 # without e prefix.
101 # They also force installing the support files for safety.
102 eaclocal() {
103 local aclocal_opts
104
105 if [[ -n ${AT_M4DIR} ]] ; then
106 for x in ${AT_M4DIR} ; do
107 case "${x}" in
108 "-I")
109 # We handle it below
110 ;;
111 *)
112 [[ ! -d ${x} ]] && ewarn "eaclocal: '${x}' does not exist"
113 aclocal_opts="${aclocal_opts} -I ${x}"
114 ;;
115 esac
116 done
117 fi
118
119 autotools_set_versions
120 [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
121 autotools_run_tool aclocal "$@" ${aclocal_opts}
122 }
123
124 _elibtoolize() {
125 local opts
126 local lttest
127
128 # Check if we should run libtoolize (AM_PROG_LIBTOOL is an older macro,
129 # check for both it and the current AC_PROG_LIBTOOL)
130 lttest="$(autotools_check_macro "AC_PROG_LIBTOOL")$(autotools_check_macro "AM_PROG_LIBTOOL")"
131 [[ -n $lttest ]] || return 0
132
133 [[ -f Makefile.am ]] && opts="--automake"
134
135 [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize"
136 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts}
137
138 # Need to rerun aclocal
139 eaclocal
140 }
141
142 eautoheader() {
143 # Check if we should run autoheader
144 [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0
145 autotools_set_versions
146 autotools_run_tool autoheader "$@"
147 }
148
149 eautoconf() {
150 if [[ ! -f configure.ac && ! -f configure.in ]] ; then
151 echo
152 eerror "No configure.{ac,in} present in '$(pwd | sed -e 's:.*/::')'!"
153 echo
154 die "No configure.{ac,in} present!"
155 fi
156
157 autotools_set_versions
158 autotools_run_tool autoconf "$@"
159 }
160
161 eautomake() {
162 local extra_opts
163
164 [[ -f Makefile.am ]] || return 0
165
166 autotools_set_versions
167 if [[ -z ${FROM_EAUTORECONF} && -f Makefile.in ]]; then
168 local used_automake
169 local installed_automake
170
171 installed_automake=$(automake --version | head -n 1 | \
172 sed -e 's:.*(GNU automake) ::')
173 used_automake=$(head -n 1 < Makefile.in | \
174 sed -e 's:.*by automake \(.*\) from .*:\1:')
175
176 if [[ ${installed_automake} != ${used_automake} ]]; then
177 einfo "Automake used for the package (${used_automake}) differs from"
178 einfo "the installed version (${installed_automake})."
179 eautoreconf
180 return 0
181 fi
182 fi
183
184 [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS ]] \
185 || extra_opts="${extra_opts} --foreign"
186
187 # --force-missing seems not to be recognized by some flavours of automake
188 autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
189 }
190
191 autotools_set_versions() {
192 [[ -n ${autotools_version_sets} ]] && return 0
193
194 if [[ -n ${WANT_AUTOCONF} ]]; then
195 [[ ${WANT_AUTOCONF} == "latest" ]] && WANT_AUTOCONF="2.5"
196 export WANT_AUTOCONF
197 einfo "Requested autoconf ${WANT_AUTOCONF}"
198 einfo "Using $(autoconf --version 2>/dev/null | head -n 1)"
199 einfo "Using $(autoheader --version 2>/dev/null | head -n 1)"
200 fi
201
202 if [[ -n ${WANT_AUTOMAKE} ]]; then
203 if [[ ${WANT_AUTOMAKE} == "latest" ]]; then
204 for amver in 1.10 1.9 1.8 1.7 1.6; do
205 has_version "=sys-devel/automake-${amver}*" && \
206 WANT_AUTOMAKE="${amver}" && break
207 done
208 fi
209 export WANT_AUTOMAKE
210 einfo "Requested automake ${WANT_AUTOMAKE}"
211 einfo "Using $(automake --version 2>/dev/null | head -n 1)"
212 einfo "Using $(aclocal --version 2>/dev/null | head -n 1)"
213 fi
214
215 autotools_version_sets="yes"
216 }
217
218 # Internal function to run an autotools' tool
219 autotools_run_tool() {
220 local STDERR_TARGET="${T}/$$.out"
221 local PATCH_TARGET="${T}/$$.patch"
222 local ris
223
224 echo "***** $1 *****" > ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
225 echo >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
226
227 ebegin "Running $@"
228 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1
229 ris=$?
230 eend ${ris}
231
232 if [[ ${ris} != 0 ]]; then
233 echo
234 eerror "Failed Running $1 !"
235 eerror
236 eerror "Include in your bugreport the contents of:"
237 eerror
238 eerror " ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}"
239 echo
240 die "Failed Running $1 !"
241 fi
242 }
243
244 # Internal function to check for support
245 autotools_check_macro() {
246 [[ -f configure.ac || -f configure.in ]] && \
247 WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
248 return 0
249 }
250
251 # Internal function to get additional subdirs to configure
252 autotools_get_subdirs() {
253 local subdirs_scan_out
254
255 subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS")
256 [[ -n ${subdirs_scan_out} ]] || return 0
257
258 echo "${subdirs_scan_out}" | gawk \
259 '($0 !~ /^[[:space:]]*(#|dnl)/) {
260 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
261 print res[1]
262 }' | uniq
263
264 return 0
265 }
266
267 autotools_get_auxdir() {
268 local auxdir_scan_out
269
270 auxdir_scan_out=$(autotools_check_macro "AC_CONFIG_AUX_DIR")
271 [[ -n ${auxdir_scan_out} ]] || return 0
272
273 echo ${auxdir_scan_out} | gawk \
274 '($0 !~ /^[[:space:]]*(#|dnl)/) {
275 if (match($0, /AC_CONFIG_AUX_DIR:(.*)$/, res))
276 print res[1]
277 }' | uniq
278
279 return 0
280 }

  ViewVC Help
Powered by ViewVC 1.1.20