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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.43 - (show annotations) (download)
Wed Sep 20 19:10:36 2006 UTC (7 years, 7 months ago) by flameeyes
Branch: MAIN
Changes since 1.42: +6 -1 lines
Make sure that WANT_AUTOMAKE set in the ebuild is picked up by the automake wrapper (so that it's actually used as intended).

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

  ViewVC Help
Powered by ViewVC 1.1.20