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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.48 - (show annotations) (download)
Mon Oct 16 08:12:01 2006 UTC (7 years, 6 months ago) by flameeyes
Branch: MAIN
Changes since 1.47: +11 -5 lines
Make sure that if latest autotools were asked, latest automake is used.

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

  ViewVC Help
Powered by ViewVC 1.1.20