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

Contents of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.42 - (hide annotations) (download)
Wed Sep 20 18:55:44 2006 UTC (7 years, 6 months ago) by flameeyes
Branch: MAIN
Changes since 1.41: +2 -2 lines
Actually, we need autoconf >=2.50, because of the crazy versioning scheme of autoconf.

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.42 # $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.41 2006/09/20 15:10:03 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 flameeyes 1.42 2.5) _autoconf_atom=">=sys-devel/autoconf-2.50" ;;
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.35 if [[ -z ${FROM_EAUTORECONF} && -f Makefile.in ]]; then
156     local used_automake
157     local installed_automake
158    
159     installed_automake=$(automake --version | head -n 1 | \
160     sed -e 's:.*(GNU automake) ::')
161     used_automake=$(head -n 1 < Makefile.in | \
162     sed -e 's:.*by automake \(.*\) from .*:\1:')
163    
164     if [[ ${installed_automake} != ${used_automake} ]]; then
165     einfo "Automake used for the package (${used_automake}) differs from"
166     einfo "the installed version (${installed_automake})."
167     eautoreconf
168 flameeyes 1.36 return 0
169 flameeyes 1.35 fi
170     fi
171    
172 flameeyes 1.33 [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS ]] \
173 flameeyes 1.24 || extra_opts="${extra_opts} --foreign"
174    
175 flameeyes 1.14 # --force-missing seems not to be recognized by some flavours of automake
176 flameeyes 1.24 autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
177 azarah 1.1 }
178    
179 azarah 1.11
180    
181 azarah 1.17 # Internal function to run an autotools' tool
182     autotools_run_tool() {
183     local STDERR_TARGET="${T}/$$.out"
184     local PATCH_TARGET="${T}/$$.patch"
185     local ris
186    
187     echo "***** $1 *****" > ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
188     echo >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
189    
190 azarah 1.27 ebegin "Running $@"
191 azarah 1.17 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1
192     ris=$?
193     eend ${ris}
194    
195     if [[ ${ris} != 0 ]]; then
196     echo
197     eerror "Failed Running $1 !"
198     eerror
199     eerror "Include in your bugreport the contents of:"
200     eerror
201     eerror " ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}"
202     echo
203     die "Failed Running $1 !"
204     fi
205     }
206    
207     # Internal function to check for support
208     autotools_check_macro() {
209     [[ -f configure.ac || -f configure.in ]] && \
210 flameeyes 1.31 WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
211 azarah 1.17 return 0
212     }
213    
214     # Internal function to get additional subdirs to configure
215     autotools_get_subdirs() {
216     local subdirs_scan_out
217    
218     subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS")
219     [[ -n ${subdirs_scan_out} ]] || return 0
220    
221     echo "${subdirs_scan_out}" | gawk \
222     '($0 !~ /^[[:space:]]*(#|dnl)/) {
223 azarah 1.25 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
224     print res[1]
225 azarah 1.17 }' | uniq
226 azarah 1.16
227 azarah 1.17 return 0
228 azarah 1.11 }
229 azarah 1.17
230 flameeyes 1.38 autotools_get_auxdir() {
231     local auxdir_scan_out
232    
233     auxdir_scan_out=$(autotools_check_macro "AC_CONFIG_AUX_DIR")
234     [[ -n ${auxdir_scan_out} ]] || return 0
235    
236     echo ${auxdir_scan_out} | gawk \
237     '($0 !~ /^[[:space:]]*(#|dnl)/) {
238     if (match($0, /AC_CONFIG_AUX_DIR:(.*)$/, res))
239     print res[1]
240     }' | uniq
241    
242     return 0
243 vapier 1.40 }

  ViewVC Help
Powered by ViewVC 1.1.20