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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.52 - (show annotations) (download)
Wed Oct 25 18:30:01 2006 UTC (7 years, 9 months ago) by flameeyes
Branch: MAIN
Changes since 1.51: +7 -4 lines
Implement a better way to find the latest autotools to use.

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.51 2006/10/17 19:17:31 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 WANT_AUTOMAKE="${amver}"
206 if WANT_AUTOMAKE="${amver}" automake --version &> /dev/null; then
207 break
208 fi
209 done
210 fi
211 export WANT_AUTOMAKE
212 einfo "Requested automake ${WANT_AUTOMAKE}"
213 einfo "Using $(automake --version 2>/dev/null | head -n 1)"
214 einfo "Using $(aclocal --version 2>/dev/null | head -n 1)"
215 fi
216
217 autotools_version_sets="yes"
218 }
219
220 # Internal function to run an autotools' tool
221 autotools_run_tool() {
222 local STDERR_TARGET="${T}/$$.out"
223 local PATCH_TARGET="${T}/$$.patch"
224 local ris
225
226 echo "***** $1 *****" > ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
227 echo >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
228
229 ebegin "Running $@"
230 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1
231 ris=$?
232 eend ${ris}
233
234 if [[ ${ris} != 0 ]]; then
235 echo
236 eerror "Failed Running $1 !"
237 eerror
238 eerror "Include in your bugreport the contents of:"
239 eerror
240 eerror " ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}"
241 echo
242 die "Failed Running $1 !"
243 fi
244 }
245
246 # Internal function to check for support
247 autotools_check_macro() {
248 [[ -f configure.ac || -f configure.in ]] && \
249 WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
250 return 0
251 }
252
253 # Internal function to get additional subdirs to configure
254 autotools_get_subdirs() {
255 local subdirs_scan_out
256
257 subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS")
258 [[ -n ${subdirs_scan_out} ]] || return 0
259
260 echo "${subdirs_scan_out}" | gawk \
261 '($0 !~ /^[[:space:]]*(#|dnl)/) {
262 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
263 print res[1]
264 }' | uniq
265
266 return 0
267 }
268
269 autotools_get_auxdir() {
270 local auxdir_scan_out
271
272 auxdir_scan_out=$(autotools_check_macro "AC_CONFIG_AUX_DIR")
273 [[ -n ${auxdir_scan_out} ]] || return 0
274
275 echo ${auxdir_scan_out} | gawk \
276 '($0 !~ /^[[:space:]]*(#|dnl)/) {
277 if (match($0, /AC_CONFIG_AUX_DIR:(.*)$/, res))
278 print res[1]
279 }' | uniq
280
281 return 0
282 }

  ViewVC Help
Powered by ViewVC 1.1.20