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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.45 - (hide annotations) (download)
Fri Sep 22 22:25:06 2006 UTC (8 years, 1 month ago) by vapier
Branch: MAIN
Changes since 1.44: +5 -2 lines
add support for WANT_AUTO{MAKE,CONF}=latest

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 vapier 1.45 # $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.44 2006/09/21 03:06:18 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 vapier 1.40 unset _automake_atom _autoconf_atom
31 azarah 1.11
32 azarah 1.16 # Variables:
33     #
34 flameeyes 1.38 # AT_M4DIR - Additional director(y|ies) aclocal should search
35     # AM_OPTS - Additional options to pass to automake during
36     # eautoreconf call.
37 azarah 1.17
38     # Functions:
39     #
40 flameeyes 1.38 # 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 azarah 1.17 #
51 azarah 1.16
52     # XXX: M4DIR should be depreciated
53     AT_M4DIR=${AT_M4DIR:-${M4DIR}}
54     AT_GNUCONF_UPDATE="no"
55    
56 azarah 1.11
57 azarah 1.17 # 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 flameeyes 1.38 local pwd=$(pwd) x auxdir
62 azarah 1.11
63 flameeyes 1.39 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 azarah 1.11
74 flameeyes 1.38 auxdir=$(autotools_get_auxdir)
75    
76 flameeyes 1.26 einfo "Running eautoreconf in '$(pwd)' ..."
77 flameeyes 1.38 [[ -n ${auxdir} ]] && mkdir -p ${auxdir}
78 azarah 1.17 eaclocal
79     _elibtoolize --copy --force
80     eautoconf
81     eautoheader
82 flameeyes 1.35 FROM_EAUTORECONF="yes" eautomake ${AM_OPTS}
83 azarah 1.1
84 flameeyes 1.32 [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0
85    
86 flameeyes 1.30 # Call it here to prevent failures due to elibtoolize called _before_
87     # eautoreconf.
88     elibtoolize
89    
90 flameeyes 1.21 return 0
91 azarah 1.12 }
92    
93 azarah 1.11 # 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 azarah 1.12 local aclocal_opts
99    
100 azarah 1.16 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 flameeyes 1.15
114 flameeyes 1.22 [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
115 azarah 1.12 autotools_run_tool aclocal "$@" ${aclocal_opts}
116     }
117    
118     _elibtoolize() {
119 azarah 1.19 local opts
120 flameeyes 1.34 local lttest
121 swegener 1.20
122 flameeyes 1.34 # 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 azarah 1.19
127     [[ -f Makefile.am ]] && opts="--automake"
128 swegener 1.20
129 flameeyes 1.18 [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize"
130 azarah 1.19 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts}
131 flameeyes 1.15
132 azarah 1.12 # Need to rerun aclocal
133     eaclocal
134 azarah 1.11 }
135 azarah 1.1
136 azarah 1.11 eautoheader() {
137 azarah 1.12 # Check if we should run autoheader
138     [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0
139 azarah 1.11 autotools_run_tool autoheader "$@"
140     }
141 azarah 1.1
142 azarah 1.11 eautoconf() {
143 azarah 1.12 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 azarah 1.11 autotools_run_tool autoconf "$@"
151     }
152 azarah 1.1
153 azarah 1.11 eautomake() {
154 flameeyes 1.24 local extra_opts
155    
156 azarah 1.12 [[ -f Makefile.am ]] || return 0
157 flameeyes 1.24
158 flameeyes 1.43 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 flameeyes 1.35 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 flameeyes 1.36 return 0
177 flameeyes 1.35 fi
178     fi
179    
180 flameeyes 1.33 [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS ]] \
181 flameeyes 1.24 || extra_opts="${extra_opts} --foreign"
182    
183 flameeyes 1.14 # --force-missing seems not to be recognized by some flavours of automake
184 flameeyes 1.24 autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
185 azarah 1.1 }
186    
187 azarah 1.11
188    
189 azarah 1.17 # 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 azarah 1.27 ebegin "Running $@"
199 azarah 1.17 $@ >> ${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 flameeyes 1.31 WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
219 azarah 1.17 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 azarah 1.25 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
232     print res[1]
233 azarah 1.17 }' | uniq
234 azarah 1.16
235 azarah 1.17 return 0
236 azarah 1.11 }
237 azarah 1.17
238 flameeyes 1.38 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 vapier 1.40 }

  ViewVC Help
Powered by ViewVC 1.1.20