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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.45 - (show annotations) (download)
Fri Sep 22 22:25:06 2006 UTC (8 years, 3 months ago) by vapier
Branch: MAIN
Changes since 1.44: +5 -2 lines
add support for WANT_AUTO{MAKE,CONF}=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.44 2006/09/21 03:06:18 vapier 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 [[ ${WANT_AUTOMAKE} == "latest" ]] && export WANT_AUTOMAKE=1.9
16 [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5
17
18 _automake_atom="sys-devel/automake"
19 _autoconf_atom="sys-devel/autoconf"
20 [[ -n ${WANT_AUTOMAKE} ]] && _automake_atom="=sys-devel/automake-${WANT_AUTOMAKE}*"
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 unset _automake_atom _autoconf_atom
31
32 # Variables:
33 #
34 # AT_M4DIR - Additional director(y|ies) aclocal should search
35 # AM_OPTS - Additional options to pass to automake during
36 # eautoreconf call.
37
38 # Functions:
39 #
40 # eautoreconf() - Should do a full autoreconf - normally what most people
41 # will be interested in. Also should handle additional
42 # directories specified by AC_CONFIG_SUBDIRS.
43 # eaclocal() - Runs aclocal. Respects AT_M4DIR for additional directories
44 # to search for macro's.
45 # _elibtoolize() - Runs libtoolize. Note the '_' prefix .. to not collide
46 # with elibtoolize() from libtool.eclass
47 # eautoconf - Runs autoconf.
48 # eautoheader - Runs autoheader.
49 # eautomake - Runs automake
50 #
51
52 # XXX: M4DIR should be depreciated
53 AT_M4DIR=${AT_M4DIR:-${M4DIR}}
54 AT_GNUCONF_UPDATE="no"
55
56
57 # This function mimes the behavior of autoreconf, but uses the different
58 # eauto* functions to run the tools. It doesn't accept parameters, but
59 # the directory with include files can be specified with AT_M4DIR variable.
60 eautoreconf() {
61 local pwd=$(pwd) x auxdir
62
63 if [[ -z ${AT_NO_RECURSIVE} ]]; then
64 # Take care of subdirs
65 for x in $(autotools_get_subdirs); do
66 if [[ -d ${x} ]] ; then
67 cd "${x}"
68 AT_NOELIBTOOLIZE="yes" eautoreconf
69 cd "${pwd}"
70 fi
71 done
72 fi
73
74 auxdir=$(autotools_get_auxdir)
75
76 einfo "Running eautoreconf in '$(pwd)' ..."
77 [[ -n ${auxdir} ]] && mkdir -p ${auxdir}
78 eaclocal
79 _elibtoolize --copy --force
80 eautoconf
81 eautoheader
82 FROM_EAUTORECONF="yes" eautomake ${AM_OPTS}
83
84 [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0
85
86 # Call it here to prevent failures due to elibtoolize called _before_
87 # eautoreconf.
88 elibtoolize
89
90 return 0
91 }
92
93 # These functions runs the autotools using autotools_run_tool with the
94 # specified parametes. The name of the tool run is the same of the function
95 # without e prefix.
96 # They also force installing the support files for safety.
97 eaclocal() {
98 local aclocal_opts
99
100 if [[ -n ${AT_M4DIR} ]] ; then
101 for x in ${AT_M4DIR} ; do
102 case "${x}" in
103 "-I")
104 # We handle it below
105 ;;
106 *)
107 [[ ! -d ${x} ]] && ewarn "eaclocal: '${x}' does not exist"
108 aclocal_opts="${aclocal_opts} -I ${x}"
109 ;;
110 esac
111 done
112 fi
113
114 [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
115 autotools_run_tool aclocal "$@" ${aclocal_opts}
116 }
117
118 _elibtoolize() {
119 local opts
120 local lttest
121
122 # Check if we should run libtoolize (AM_PROG_LIBTOOL is an older macro,
123 # check for both it and the current AC_PROG_LIBTOOL)
124 lttest="$(autotools_check_macro "AC_PROG_LIBTOOL")$(autotools_check_macro "AM_PROG_LIBTOOL")"
125 [[ -n $lttest ]] || return 0
126
127 [[ -f Makefile.am ]] && opts="--automake"
128
129 [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize"
130 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts}
131
132 # Need to rerun aclocal
133 eaclocal
134 }
135
136 eautoheader() {
137 # Check if we should run autoheader
138 [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0
139 autotools_run_tool autoheader "$@"
140 }
141
142 eautoconf() {
143 if [[ ! -f configure.ac && ! -f configure.in ]] ; then
144 echo
145 eerror "No configure.{ac,in} present in '$(pwd | sed -e 's:.*/::')'!"
146 echo
147 die "No configure.{ac,in} present!"
148 fi
149
150 autotools_run_tool autoconf "$@"
151 }
152
153 eautomake() {
154 local extra_opts
155
156 [[ -f Makefile.am ]] || return 0
157
158 if [[ -n ${WANT_AUTOMAKE} ]]; then
159 export WANT_AUTOMAKE # let the automake wrapper pick it up
160 einfo "Required automake ${WANT_AUTOMAKE}. Using $(automake --version | head -n 1)."
161 fi
162
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
188
189 # Internal function to run an autotools' tool
190 autotools_run_tool() {
191 local STDERR_TARGET="${T}/$$.out"
192 local PATCH_TARGET="${T}/$$.patch"
193 local ris
194
195 echo "***** $1 *****" > ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
196 echo >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
197
198 ebegin "Running $@"
199 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1
200 ris=$?
201 eend ${ris}
202
203 if [[ ${ris} != 0 ]]; then
204 echo
205 eerror "Failed Running $1 !"
206 eerror
207 eerror "Include in your bugreport the contents of:"
208 eerror
209 eerror " ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}"
210 echo
211 die "Failed Running $1 !"
212 fi
213 }
214
215 # Internal function to check for support
216 autotools_check_macro() {
217 [[ -f configure.ac || -f configure.in ]] && \
218 WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
219 return 0
220 }
221
222 # Internal function to get additional subdirs to configure
223 autotools_get_subdirs() {
224 local subdirs_scan_out
225
226 subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS")
227 [[ -n ${subdirs_scan_out} ]] || return 0
228
229 echo "${subdirs_scan_out}" | gawk \
230 '($0 !~ /^[[:space:]]*(#|dnl)/) {
231 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
232 print res[1]
233 }' | uniq
234
235 return 0
236 }
237
238 autotools_get_auxdir() {
239 local auxdir_scan_out
240
241 auxdir_scan_out=$(autotools_check_macro "AC_CONFIG_AUX_DIR")
242 [[ -n ${auxdir_scan_out} ]] || return 0
243
244 echo ${auxdir_scan_out} | gawk \
245 '($0 !~ /^[[:space:]]*(#|dnl)/) {
246 if (match($0, /AC_CONFIG_AUX_DIR:(.*)$/, res))
247 print res[1]
248 }' | uniq
249
250 return 0
251 }

  ViewVC Help
Powered by ViewVC 1.1.20