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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.57 - (hide annotations) (download)
Thu Dec 14 00:33:10 2006 UTC (7 years, 7 months ago) by flameeyes
Branch: MAIN
Changes since 1.56: +3 -3 lines
As autoheader is as bugged a cellphone, don't fail even if it fails... it treats warnings as error even if you tell him not to.

1 azarah 1.11 # Copyright 1999-2005 Gentoo Foundation
2 vapier 1.6 # Distributed under the terms of the GNU General Public License v2
3 flameeyes 1.57 # $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.56 2006/11/01 10:58:46 flameeyes Exp $
4 vapier 1.7 #
5 azarah 1.11 # Author: Diego Pettenò <flameeyes@gentoo.org>
6 azarah 1.12 # Enhancements: Martin Schlemmer <azarah@gentoo.org>
7 vapier 1.7 #
8 azarah 1.11 # This eclass is for handling autotooled software packages that
9     # needs to regenerate their build scripts.
10 azarah 1.1 #
11 azarah 1.11 # NB: If you add anything, please comment it!
12 azarah 1.1
13 flameeyes 1.37 inherit eutils libtool
14 azarah 1.11
15 vapier 1.40 _automake_atom="sys-devel/automake"
16     _autoconf_atom="sys-devel/autoconf"
17 peper 1.55 if [[ -n ${WANT_AUTOMAKE} ]]; then
18 flameeyes 1.49 case ${WANT_AUTOMAKE} in
19     # workaround while we have different versions of automake in arch and ~arch
20 flameeyes 1.50 latest) _automake_atom="|| ( =sys-devel/automake-1.10* =sys-devel/automake-1.9* )" ;;
21 flameeyes 1.49 *) _automake_atom="=sys-devel/automake-${WANT_AUTOMAKE}*" ;;
22     esac
23 flameeyes 1.48 fi
24    
25 vapier 1.45 if [[ -n ${WANT_AUTOCONF} ]] ; then
26 flameeyes 1.41 case ${WANT_AUTOCONF} in
27     2.1) _autoconf_atom="=sys-devel/autoconf-${WANT_AUTOCONF}*" ;;
28 flameeyes 1.49 latest | 2.5) _autoconf_atom=">=sys-devel/autoconf-2.59" ;;
29 flameeyes 1.41 esac
30     fi
31 vapier 1.40 DEPEND="${_automake_atom}
32     ${_autoconf_atom}
33 flameeyes 1.28 sys-devel/libtool"
34 flameeyes 1.46 RDEPEND=""
35 vapier 1.40 unset _automake_atom _autoconf_atom
36 azarah 1.11
37 azarah 1.16 # Variables:
38     #
39 flameeyes 1.38 # AT_M4DIR - Additional director(y|ies) aclocal should search
40     # AM_OPTS - Additional options to pass to automake during
41     # eautoreconf call.
42 azarah 1.17
43     # Functions:
44     #
45 flameeyes 1.38 # 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 azarah 1.17 #
56 azarah 1.16
57     # XXX: M4DIR should be depreciated
58     AT_M4DIR=${AT_M4DIR:-${M4DIR}}
59     AT_GNUCONF_UPDATE="no"
60    
61 azarah 1.11
62 azarah 1.17 # 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 flameeyes 1.38 local pwd=$(pwd) x auxdir
67 azarah 1.11
68 flameeyes 1.39 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 azarah 1.11
79 flameeyes 1.38 auxdir=$(autotools_get_auxdir)
80    
81 flameeyes 1.26 einfo "Running eautoreconf in '$(pwd)' ..."
82 flameeyes 1.38 [[ -n ${auxdir} ]] && mkdir -p ${auxdir}
83 azarah 1.17 eaclocal
84     _elibtoolize --copy --force
85     eautoconf
86     eautoheader
87 flameeyes 1.35 FROM_EAUTORECONF="yes" eautomake ${AM_OPTS}
88 azarah 1.1
89 flameeyes 1.32 [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0
90    
91 flameeyes 1.30 # Call it here to prevent failures due to elibtoolize called _before_
92     # eautoreconf.
93     elibtoolize
94    
95 flameeyes 1.21 return 0
96 azarah 1.12 }
97    
98 azarah 1.11 # 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 azarah 1.12 local aclocal_opts
104    
105 azarah 1.16 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 flameeyes 1.15
119 flameeyes 1.47 autotools_set_versions
120 flameeyes 1.22 [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
121 azarah 1.12 autotools_run_tool aclocal "$@" ${aclocal_opts}
122     }
123    
124     _elibtoolize() {
125 azarah 1.19 local opts
126 flameeyes 1.34 local lttest
127 swegener 1.20
128 flameeyes 1.34 # 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 azarah 1.19
133     [[ -f Makefile.am ]] && opts="--automake"
134 swegener 1.20
135 flameeyes 1.18 [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize"
136 azarah 1.19 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts}
137 flameeyes 1.15
138 azarah 1.12 # Need to rerun aclocal
139     eaclocal
140 azarah 1.11 }
141 azarah 1.1
142 azarah 1.11 eautoheader() {
143 azarah 1.12 # Check if we should run autoheader
144     [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0
145 flameeyes 1.47 autotools_set_versions
146 flameeyes 1.57 NOFAIL=1 autotools_run_tool autoheader "$@"
147 azarah 1.11 }
148 azarah 1.1
149 azarah 1.11 eautoconf() {
150 azarah 1.12 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 flameeyes 1.47 autotools_set_versions
158 azarah 1.11 autotools_run_tool autoconf "$@"
159     }
160 azarah 1.1
161 azarah 1.11 eautomake() {
162 flameeyes 1.24 local extra_opts
163    
164 azarah 1.12 [[ -f Makefile.am ]] || return 0
165 flameeyes 1.24
166 flameeyes 1.47 autotools_set_versions
167 flameeyes 1.35 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 flameeyes 1.36 return 0
181 flameeyes 1.35 fi
182     fi
183    
184 flameeyes 1.33 [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS ]] \
185 flameeyes 1.24 || extra_opts="${extra_opts} --foreign"
186    
187 flameeyes 1.14 # --force-missing seems not to be recognized by some flavours of automake
188 flameeyes 1.24 autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
189 azarah 1.1 }
190    
191 flameeyes 1.47 autotools_set_versions() {
192     [[ -n ${autotools_version_sets} ]] && return 0
193    
194     if [[ -n ${WANT_AUTOCONF} ]]; then
195 flameeyes 1.48 [[ ${WANT_AUTOCONF} == "latest" ]] && WANT_AUTOCONF="2.5"
196 flameeyes 1.47 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 azarah 1.11
202 flameeyes 1.47 if [[ -n ${WANT_AUTOMAKE} ]]; then
203 flameeyes 1.56 local latest_automake
204 flameeyes 1.48 if [[ ${WANT_AUTOMAKE} == "latest" ]]; then
205 flameeyes 1.56 latest_automake="latest: "
206 flameeyes 1.52 for amver in 1.10 1.9 1.8 1.7 1.6; do
207 flameeyes 1.54 WANT_AUTOMAKE="${amver}"
208     ROOT=/ has_version =sys-devel/automake-${amver}* && break
209 flameeyes 1.52 done
210 flameeyes 1.48 fi
211 flameeyes 1.47 export WANT_AUTOMAKE
212 flameeyes 1.56 einfo "Requested automake ${latest_automake}${WANT_AUTOMAKE}"
213 flameeyes 1.47 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 azarah 1.11
220 azarah 1.17 # 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 azarah 1.27 ebegin "Running $@"
230 azarah 1.17 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1
231     ris=$?
232     eend ${ris}
233    
234 flameeyes 1.57 if [[ ${ris} != 0 && ${NO_FAIL} != 1 ]]; then
235 azarah 1.17 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 flameeyes 1.31 WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
250 azarah 1.17 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 azarah 1.25 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
263     print res[1]
264 azarah 1.17 }' | uniq
265 azarah 1.16
266 azarah 1.17 return 0
267 azarah 1.11 }
268 azarah 1.17
269 flameeyes 1.38 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 vapier 1.40 }

  ViewVC Help
Powered by ViewVC 1.1.20