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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.44 - (hide annotations) (download)
Thu Sep 21 03:06:18 2006 UTC (7 years, 7 months ago) by vapier
Branch: MAIN
Changes since 1.43: +2 -2 lines
force autoconf-2.59+ as that is safe

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.44 # $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.43 2006/09/20 19:10:36 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     [[ -n ${WANT_AUTOMAKE} ]] && _automake_atom="=sys-devel/automake-${WANT_AUTOMAKE}*"
18 flameeyes 1.41 if [[ -n ${WANT_AUTOCONF} ]]; then
19     case ${WANT_AUTOCONF} in
20     2.1) _autoconf_atom="=sys-devel/autoconf-${WANT_AUTOCONF}*" ;;
21 vapier 1.44 2.5) _autoconf_atom=">=sys-devel/autoconf-2.59" ;;
22 flameeyes 1.41 esac
23     fi
24 vapier 1.40 DEPEND="${_automake_atom}
25     ${_autoconf_atom}
26 flameeyes 1.28 sys-devel/libtool"
27 vapier 1.40 unset _automake_atom _autoconf_atom
28 azarah 1.11
29 azarah 1.16 # Variables:
30     #
31 flameeyes 1.38 # AT_M4DIR - Additional director(y|ies) aclocal should search
32     # AM_OPTS - Additional options to pass to automake during
33     # eautoreconf call.
34 azarah 1.17
35     # Functions:
36     #
37 flameeyes 1.38 # 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 azarah 1.17 #
48 azarah 1.16
49     # XXX: M4DIR should be depreciated
50     AT_M4DIR=${AT_M4DIR:-${M4DIR}}
51     AT_GNUCONF_UPDATE="no"
52    
53 azarah 1.11
54 azarah 1.17 # 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 flameeyes 1.38 local pwd=$(pwd) x auxdir
59 azarah 1.11
60 flameeyes 1.39 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 azarah 1.11
71 flameeyes 1.38 auxdir=$(autotools_get_auxdir)
72    
73 flameeyes 1.26 einfo "Running eautoreconf in '$(pwd)' ..."
74 flameeyes 1.38 [[ -n ${auxdir} ]] && mkdir -p ${auxdir}
75 azarah 1.17 eaclocal
76     _elibtoolize --copy --force
77     eautoconf
78     eautoheader
79 flameeyes 1.35 FROM_EAUTORECONF="yes" eautomake ${AM_OPTS}
80 azarah 1.1
81 flameeyes 1.32 [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0
82    
83 flameeyes 1.30 # Call it here to prevent failures due to elibtoolize called _before_
84     # eautoreconf.
85     elibtoolize
86    
87 flameeyes 1.21 return 0
88 azarah 1.12 }
89    
90 azarah 1.11 # 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 azarah 1.12 local aclocal_opts
96    
97 azarah 1.16 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 flameeyes 1.15
111 flameeyes 1.22 [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
112 azarah 1.12 autotools_run_tool aclocal "$@" ${aclocal_opts}
113     }
114    
115     _elibtoolize() {
116 azarah 1.19 local opts
117 flameeyes 1.34 local lttest
118 swegener 1.20
119 flameeyes 1.34 # 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 azarah 1.19
124     [[ -f Makefile.am ]] && opts="--automake"
125 swegener 1.20
126 flameeyes 1.18 [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize"
127 azarah 1.19 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts}
128 flameeyes 1.15
129 azarah 1.12 # Need to rerun aclocal
130     eaclocal
131 azarah 1.11 }
132 azarah 1.1
133 azarah 1.11 eautoheader() {
134 azarah 1.12 # Check if we should run autoheader
135     [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0
136 azarah 1.11 autotools_run_tool autoheader "$@"
137     }
138 azarah 1.1
139 azarah 1.11 eautoconf() {
140 azarah 1.12 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 azarah 1.11 autotools_run_tool autoconf "$@"
148     }
149 azarah 1.1
150 azarah 1.11 eautomake() {
151 flameeyes 1.24 local extra_opts
152    
153 azarah 1.12 [[ -f Makefile.am ]] || return 0
154 flameeyes 1.24
155 flameeyes 1.43 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 flameeyes 1.35 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 flameeyes 1.36 return 0
174 flameeyes 1.35 fi
175     fi
176    
177 flameeyes 1.33 [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS ]] \
178 flameeyes 1.24 || extra_opts="${extra_opts} --foreign"
179    
180 flameeyes 1.14 # --force-missing seems not to be recognized by some flavours of automake
181 flameeyes 1.24 autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
182 azarah 1.1 }
183    
184 azarah 1.11
185    
186 azarah 1.17 # 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 azarah 1.27 ebegin "Running $@"
196 azarah 1.17 $@ >> ${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 flameeyes 1.31 WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
216 azarah 1.17 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 azarah 1.25 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
229     print res[1]
230 azarah 1.17 }' | uniq
231 azarah 1.16
232 azarah 1.17 return 0
233 azarah 1.11 }
234 azarah 1.17
235 flameeyes 1.38 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 vapier 1.40 }

  ViewVC Help
Powered by ViewVC 1.1.20