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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.50 - (show annotations) (download)
Tue Oct 17 18:59:36 2006 UTC (7 years, 11 months ago) by flameeyes
Branch: MAIN
Changes since 1.49: +2 -2 lines
Try not to have the undo and commit keybindings too near.

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

  ViewVC Help
Powered by ViewVC 1.1.20