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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.46 - (hide annotations) (download)
Sat Sep 23 19:43:07 2006 UTC (7 years, 11 months ago) by flameeyes
Branch: MAIN
Changes since 1.45: +2 -1 lines
Set empty RDEPEND in eclass, avoids tainting the RDEPENDs with autotools.

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.46 # $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.45 2006/09/22 22:25:06 vapier 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.45 [[ ${WANT_AUTOMAKE} == "latest" ]] && export WANT_AUTOMAKE=1.9
16     [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5
17    
18 vapier 1.40 _automake_atom="sys-devel/automake"
19     _autoconf_atom="sys-devel/autoconf"
20     [[ -n ${WANT_AUTOMAKE} ]] && _automake_atom="=sys-devel/automake-${WANT_AUTOMAKE}*"
21 vapier 1.45 if [[ -n ${WANT_AUTOCONF} ]] ; then
22 flameeyes 1.41 case ${WANT_AUTOCONF} in
23     2.1) _autoconf_atom="=sys-devel/autoconf-${WANT_AUTOCONF}*" ;;
24 vapier 1.44 2.5) _autoconf_atom=">=sys-devel/autoconf-2.59" ;;
25 flameeyes 1.41 esac
26     fi
27 vapier 1.40 DEPEND="${_automake_atom}
28     ${_autoconf_atom}
29 flameeyes 1.28 sys-devel/libtool"
30 flameeyes 1.46 RDEPEND=""
31 vapier 1.40 unset _automake_atom _autoconf_atom
32 azarah 1.11
33 azarah 1.16 # Variables:
34     #
35 flameeyes 1.38 # AT_M4DIR - Additional director(y|ies) aclocal should search
36     # AM_OPTS - Additional options to pass to automake during
37     # eautoreconf call.
38 azarah 1.17
39     # Functions:
40     #
41 flameeyes 1.38 # 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 azarah 1.17 #
52 azarah 1.16
53     # XXX: M4DIR should be depreciated
54     AT_M4DIR=${AT_M4DIR:-${M4DIR}}
55     AT_GNUCONF_UPDATE="no"
56    
57 azarah 1.11
58 azarah 1.17 # 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 flameeyes 1.38 local pwd=$(pwd) x auxdir
63 azarah 1.11
64 flameeyes 1.39 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 azarah 1.11
75 flameeyes 1.38 auxdir=$(autotools_get_auxdir)
76    
77 flameeyes 1.26 einfo "Running eautoreconf in '$(pwd)' ..."
78 flameeyes 1.38 [[ -n ${auxdir} ]] && mkdir -p ${auxdir}
79 azarah 1.17 eaclocal
80     _elibtoolize --copy --force
81     eautoconf
82     eautoheader
83 flameeyes 1.35 FROM_EAUTORECONF="yes" eautomake ${AM_OPTS}
84 azarah 1.1
85 flameeyes 1.32 [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0
86    
87 flameeyes 1.30 # Call it here to prevent failures due to elibtoolize called _before_
88     # eautoreconf.
89     elibtoolize
90    
91 flameeyes 1.21 return 0
92 azarah 1.12 }
93    
94 azarah 1.11 # 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 azarah 1.12 local aclocal_opts
100    
101 azarah 1.16 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 flameeyes 1.15
115 flameeyes 1.22 [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
116 azarah 1.12 autotools_run_tool aclocal "$@" ${aclocal_opts}
117     }
118    
119     _elibtoolize() {
120 azarah 1.19 local opts
121 flameeyes 1.34 local lttest
122 swegener 1.20
123 flameeyes 1.34 # Check if we should run libtoolize (AM_PROG_LIBTOOL is an older macro,
124     # check for both it and the current AC_PROG_LIBTOOL)
125     lttest="$(autotools_check_macro "AC_PROG_LIBTOOL")$(autotools_check_macro "AM_PROG_LIBTOOL")"
126     [[ -n $lttest ]] || return 0
127 azarah 1.19
128     [[ -f Makefile.am ]] && opts="--automake"
129 swegener 1.20
130 flameeyes 1.18 [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize"
131 azarah 1.19 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts}
132 flameeyes 1.15
133 azarah 1.12 # Need to rerun aclocal
134     eaclocal
135 azarah 1.11 }
136 azarah 1.1
137 azarah 1.11 eautoheader() {
138 azarah 1.12 # Check if we should run autoheader
139     [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0
140 azarah 1.11 autotools_run_tool autoheader "$@"
141     }
142 azarah 1.1
143 azarah 1.11 eautoconf() {
144 azarah 1.12 if [[ ! -f configure.ac && ! -f configure.in ]] ; then
145     echo
146     eerror "No configure.{ac,in} present in '$(pwd | sed -e 's:.*/::')'!"
147     echo
148     die "No configure.{ac,in} present!"
149     fi
150    
151 azarah 1.11 autotools_run_tool autoconf "$@"
152     }
153 azarah 1.1
154 azarah 1.11 eautomake() {
155 flameeyes 1.24 local extra_opts
156    
157 azarah 1.12 [[ -f Makefile.am ]] || return 0
158 flameeyes 1.24
159 flameeyes 1.43 if [[ -n ${WANT_AUTOMAKE} ]]; then
160     export WANT_AUTOMAKE # let the automake wrapper pick it up
161     einfo "Required automake ${WANT_AUTOMAKE}. Using $(automake --version | head -n 1)."
162     fi
163    
164 flameeyes 1.35 if [[ -z ${FROM_EAUTORECONF} && -f Makefile.in ]]; then
165     local used_automake
166     local installed_automake
167    
168     installed_automake=$(automake --version | head -n 1 | \
169     sed -e 's:.*(GNU automake) ::')
170     used_automake=$(head -n 1 < Makefile.in | \
171     sed -e 's:.*by automake \(.*\) from .*:\1:')
172    
173     if [[ ${installed_automake} != ${used_automake} ]]; then
174     einfo "Automake used for the package (${used_automake}) differs from"
175     einfo "the installed version (${installed_automake})."
176     eautoreconf
177 flameeyes 1.36 return 0
178 flameeyes 1.35 fi
179     fi
180    
181 flameeyes 1.33 [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS ]] \
182 flameeyes 1.24 || extra_opts="${extra_opts} --foreign"
183    
184 flameeyes 1.14 # --force-missing seems not to be recognized by some flavours of automake
185 flameeyes 1.24 autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
186 azarah 1.1 }
187    
188 azarah 1.11
189    
190 azarah 1.17 # Internal function to run an autotools' tool
191     autotools_run_tool() {
192     local STDERR_TARGET="${T}/$$.out"
193     local PATCH_TARGET="${T}/$$.patch"
194     local ris
195    
196     echo "***** $1 *****" > ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
197     echo >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
198    
199 azarah 1.27 ebegin "Running $@"
200 azarah 1.17 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1
201     ris=$?
202     eend ${ris}
203    
204     if [[ ${ris} != 0 ]]; then
205     echo
206     eerror "Failed Running $1 !"
207     eerror
208     eerror "Include in your bugreport the contents of:"
209     eerror
210     eerror " ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}"
211     echo
212     die "Failed Running $1 !"
213     fi
214     }
215    
216     # Internal function to check for support
217     autotools_check_macro() {
218     [[ -f configure.ac || -f configure.in ]] && \
219 flameeyes 1.31 WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
220 azarah 1.17 return 0
221     }
222    
223     # Internal function to get additional subdirs to configure
224     autotools_get_subdirs() {
225     local subdirs_scan_out
226    
227     subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS")
228     [[ -n ${subdirs_scan_out} ]] || return 0
229    
230     echo "${subdirs_scan_out}" | gawk \
231     '($0 !~ /^[[:space:]]*(#|dnl)/) {
232 azarah 1.25 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
233     print res[1]
234 azarah 1.17 }' | uniq
235 azarah 1.16
236 azarah 1.17 return 0
237 azarah 1.11 }
238 azarah 1.17
239 flameeyes 1.38 autotools_get_auxdir() {
240     local auxdir_scan_out
241    
242     auxdir_scan_out=$(autotools_check_macro "AC_CONFIG_AUX_DIR")
243     [[ -n ${auxdir_scan_out} ]] || return 0
244    
245     echo ${auxdir_scan_out} | gawk \
246     '($0 !~ /^[[:space:]]*(#|dnl)/) {
247     if (match($0, /AC_CONFIG_AUX_DIR:(.*)$/, res))
248     print res[1]
249     }' | uniq
250    
251     return 0
252 vapier 1.40 }

  ViewVC Help
Powered by ViewVC 1.1.20