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

Diff of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.21 Revision 1.63
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2005 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.21 2005/09/08 15:04:47 flameeyes Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.63 2007/01/08 23:25:30 flameeyes Exp $
4# 4#
5# Author: Diego Pettenò <flameeyes@gentoo.org> 5# Author: Diego Pettenò <flameeyes@gentoo.org>
6# Enhancements: Martin Schlemmer <azarah@gentoo.org> 6# Enhancements: Martin Schlemmer <azarah@gentoo.org>
7# 7#
8# This eclass is for handling autotooled software packages that 8# This eclass is for handling autotooled software packages that
9# needs to regenerate their build scripts. 9# needs to regenerate their build scripts.
10# 10#
11# NB: If you add anything, please comment it! 11# NB: If you add anything, please comment it!
12 12
13inherit eutils gnuconfig 13inherit eutils libtool
14 14
15#DEPEND="sys-devel/automake 15[[ -z ${WANT_AUTOCONF} ]] && WANT_AUTOCONF="latest"
16# sys-devel/autoconf 16[[ -z ${WANT_AUTOMAKE} ]] && WANT_AUTOMAKE="latest"
17
18_automake_atom="sys-devel/automake"
19_autoconf_atom="sys-devel/autoconf"
20if [[ -n ${WANT_AUTOMAKE} ]]; then
21 case ${WANT_AUTOMAKE} in
22 # workaround while we have different versions of automake in arch and ~arch
23 none) _automake_atom="" ;; # some packages don't require automake at all
24 latest) _automake_atom="|| ( =sys-devel/automake-1.10* =sys-devel/automake-1.9* )" ;;
25 *) _automake_atom="=sys-devel/automake-${WANT_AUTOMAKE}*" ;;
26 esac
27fi
28
29if [[ -n ${WANT_AUTOCONF} ]] ; then
30 case ${WANT_AUTOCONF} in
31 2.1) _autoconf_atom="=sys-devel/autoconf-${WANT_AUTOCONF}*" ;;
32 latest | 2.5) _autoconf_atom=">=sys-devel/autoconf-2.59" ;;
33 esac
34fi
35DEPEND="${_automake_atom}
36 ${_autoconf_atom}
17# sys-devel/libtool" 37 sys-devel/libtool"
18# 38RDEPEND=""
19# Ebuilds should rather depend on the proper version of the tool. 39unset _automake_atom _autoconf_atom
20 40
21# Variables: 41# Variables:
22# 42#
23# AT_M4DIR - Additional director(y|ies) aclocal should search 43# AT_M4DIR - Additional director(y|ies) aclocal should search
24# AT_GNUCONF_UPDATE - Should gnuconfig_update() be run (normally handled by 44# AM_OPTS - Additional options to pass to automake during
25# econf()) [yes|no] 45# eautoreconf call.
46# AT_NOELIBTOOLIZE - Don't run elibtoolize command if set to 'yes',
47# useful when elibtoolize needs to be ran with
48# particular options
26 49
27# Functions: 50# Functions:
28# 51#
29# eautoreconf() - Should do a full autoreconf - normally what most people 52# eautoreconf() - Should do a full autoreconf - normally what most people
30# will be interested in. Also should handle additional 53# will be interested in. Also should handle additional
31# directories specified by AC_CONFIG_SUBDIRS. 54# directories specified by AC_CONFIG_SUBDIRS.
32# eaclocal() - Runs aclocal. Respects AT_M4DIR for additional directories 55# eaclocal() - Runs aclocal. Respects AT_M4DIR for additional directories
33# to search for macro's. 56# to search for macro's.
34# _elibtoolize() - Runs libtoolize. Note the '_' prefix .. to not collide 57# _elibtoolize() - Runs libtoolize. Note the '_' prefix .. to not collide
35# with elibtoolize() from libtool.eclass 58# with elibtoolize() from libtool.eclass
36# eautoconf - Runs autoconf. 59# eautoconf - Runs autoconf.
37# eautoheader - Runs autoheader. 60# eautoheader - Runs autoheader.
38# eautomake - Runs automake 61# eautomake - Runs automake
39# 62#
40 63
41# XXX: M4DIR should be depreciated 64# XXX: M4DIR should be depreciated
42AT_M4DIR=${AT_M4DIR:-${M4DIR}} 65AT_M4DIR=${AT_M4DIR:-${M4DIR}}
43AT_GNUCONF_UPDATE="no" 66AT_GNUCONF_UPDATE="no"
44 67
45 68
46# This function mimes the behavior of autoreconf, but uses the different 69# This function mimes the behavior of autoreconf, but uses the different
47# eauto* functions to run the tools. It doesn't accept parameters, but 70# eauto* functions to run the tools. It doesn't accept parameters, but
48# the directory with include files can be specified with AT_M4DIR variable. 71# the directory with include files can be specified with AT_M4DIR variable.
49#
50# Note: doesn't run autopoint right now, but runs gnuconfig_update.
51eautoreconf() { 72eautoreconf() {
52 local pwd=$(pwd) x 73 local pwd=$(pwd) x auxdir
53 74
75 if [[ -z ${AT_NO_RECURSIVE} ]]; then
54 # Take care of subdirs 76 # Take care of subdirs
55 for x in $(autotools_get_subdirs); do 77 for x in $(autotools_get_subdirs); do
56 if [[ -d ${x} ]] ; then 78 if [[ -d ${x} ]] ; then
57 cd "${x}" 79 cd "${x}"
58 eautoreconf 80 AT_NOELIBTOOLIZE="yes" eautoreconf
59 cd "${pwd}" 81 cd "${pwd}"
60 fi 82 fi
61 done 83 done
84 fi
62 85
86 auxdir=$(autotools_get_auxdir)
87
88 einfo "Running eautoreconf in '$(pwd)' ..."
89 [[ -n ${auxdir} ]] && mkdir -p ${auxdir}
63 eaclocal 90 eaclocal
64 _elibtoolize --copy --force 91 _elibtoolize --copy --force
65 eautoconf 92 eautoconf
66 eautoheader 93 eautoheader
67 eautomake 94 FROM_EAUTORECONF="yes" eautomake ${AM_OPTS}
68 95
69 # Normally run by econf() 96 [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0
70 [[ ${AT_GNUCONF_UPDATE} == "yes" ]] && gnuconfig_update 97
98 # Call it here to prevent failures due to elibtoolize called _before_
99 # eautoreconf.
100 elibtoolize
71 101
72 return 0 102 return 0
73} 103}
74 104
75# These functions runs the autotools using autotools_run_tool with the 105# These functions runs the autotools using autotools_run_tool with the
77# without e prefix. 107# without e prefix.
78# They also force installing the support files for safety. 108# They also force installing the support files for safety.
79eaclocal() { 109eaclocal() {
80 local aclocal_opts 110 local aclocal_opts
81 111
82 # XXX: M4DIR should be depreciated
83 AT_M4DIR=${AT_M4DIR:-${M4DIR}}
84
85 if [[ -n ${AT_M4DIR} ]] ; then 112 if [[ -n ${AT_M4DIR} ]] ; then
86 for x in ${AT_M4DIR} ; do 113 for x in ${AT_M4DIR} ; do
87 case "${x}" in 114 case "${x}" in
88 "-I") 115 "-I")
89 # We handle it below 116 # We handle it below
90 ;;
91 "-I"*)
92 # Invalid syntax, but maybe we should help out ...
93 ewarn "eaclocal: Proper syntax is (note the space after '-I'): aclocal -I <dir>"
94 aclocal_opts="${aclocal_opts} -I ${x}"
95 ;; 117 ;;
96 *) 118 *)
97 [[ ! -d ${x} ]] && ewarn "eaclocal: '${x}' does not exist" 119 [[ ! -d ${x} ]] && ewarn "eaclocal: '${x}' does not exist"
98 aclocal_opts="${aclocal_opts} -I ${x}" 120 aclocal_opts="${aclocal_opts} -I ${x}"
99 ;; 121 ;;
100 esac 122 esac
101 done 123 done
102 fi 124 fi
103 125
126 autotools_set_versions
104 [[ -f aclocal.m4 && -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \ 127 [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
105 autotools_run_tool aclocal "$@" ${aclocal_opts} 128 autotools_run_tool aclocal "$@" ${aclocal_opts}
106} 129}
107 130
108_elibtoolize() { 131_elibtoolize() {
109 local opts 132 local opts
133 local lttest
110 134
111 # Check if we should run libtoolize 135 # Check if we should run libtoolize (AM_PROG_LIBTOOL is an older macro,
112 [[ -n $(autotools_check_macro "AC_PROG_LIBTOOL") ]] || return 0 136 # check for both it and the current AC_PROG_LIBTOOL)
137 lttest="$(autotools_check_macro "AC_PROG_LIBTOOL")$(autotools_check_macro "AM_PROG_LIBTOOL")"
138 [[ -n $lttest ]] || return 0
113 139
114 [[ -f Makefile.am ]] && opts="--automake" 140 [[ -f Makefile.am ]] && opts="--automake"
115 141
116 [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize" 142 [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize"
117 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts} 143 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts}
121} 147}
122 148
123eautoheader() { 149eautoheader() {
124 # Check if we should run autoheader 150 # Check if we should run autoheader
125 [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0 151 [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0
152 autotools_set_versions
126 autotools_run_tool autoheader "$@" 153 NO_FAIL=1 autotools_run_tool autoheader "$@"
127} 154}
128 155
129eautoconf() { 156eautoconf() {
130 if [[ ! -f configure.ac && ! -f configure.in ]] ; then 157 if [[ ! -f configure.ac && ! -f configure.in ]] ; then
131 echo 158 echo
132 eerror "No configure.{ac,in} present in '$(pwd | sed -e 's:.*/::')'!" 159 eerror "No configure.{ac,in} present in '$(pwd | sed -e 's:.*/::')'!"
133 echo 160 echo
134 die "No configure.{ac,in} present!" 161 die "No configure.{ac,in} present!"
135 fi 162 fi
136 163
164 autotools_set_versions
137 autotools_run_tool autoconf "$@" 165 autotools_run_tool autoconf "$@"
138} 166}
139 167
140eautomake() { 168eautomake() {
169 local extra_opts
170
141 [[ -f Makefile.am ]] || return 0 171 [[ -f Makefile.am ]] || return 0
172
173 autotools_set_versions
174 if [[ -z ${FROM_EAUTORECONF} && -f Makefile.in ]]; then
175 local used_automake
176 local installed_automake
177
178 installed_automake=$(automake --version | head -n 1 | \
179 sed -e 's:.*(GNU automake) ::')
180 used_automake=$(head -n 1 < Makefile.in | \
181 sed -e 's:.*by automake \(.*\) from .*:\1:')
182
183 if [[ ${installed_automake} != ${used_automake} ]]; then
184 einfo "Automake used for the package (${used_automake}) differs from"
185 einfo "the installed version (${installed_automake})."
186 eautoreconf
187 return 0
188 fi
189 fi
190
191 [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS ]] \
192 || extra_opts="${extra_opts} --foreign"
193
142 # --force-missing seems not to be recognized by some flavours of automake 194 # --force-missing seems not to be recognized by some flavours of automake
143 autotools_run_tool automake --add-missing --copy "$@" 195 autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
144} 196}
145 197
198autotools_set_versions() {
199 [[ -n ${autotools_version_sets} ]] && return 0
146 200
201 if [[ -n ${WANT_AUTOCONF} ]]; then
202 [[ ${WANT_AUTOCONF} == "latest" ]] && WANT_AUTOCONF="2.5"
203 export WANT_AUTOCONF
204 einfo "Requested autoconf ${WANT_AUTOCONF}"
205 einfo "Using $(autoconf --version 2>/dev/null | head -n 1)"
206 einfo "Using $(autoheader --version 2>/dev/null | head -n 1)"
207 else
208 ewarn "QA Notice: \${WANT_AUTOCONF} variable unset. Please report on http://bugs.gentoo.org/"
209 fi
210
211 if [[ -n ${WANT_AUTOMAKE} ]]; then
212 local latest_automake
213 if [[ ${WANT_AUTOMAKE} == "latest" ]]; then
214 latest_automake="latest: "
215 for amver in 1.10 1.9 1.8 1.7 1.6; do
216 WANT_AUTOMAKE="${amver}"
217 ROOT=/ has_version =sys-devel/automake-${amver}* && break
218 done
219 fi
220
221 # Don't do stuff if no autoamke is requested/required
222 if [[ ${WANT_AUTOMAKE} != "none" ]]; then
223 export WANT_AUTOMAKE
224 einfo "Requested automake ${latest_automake}${WANT_AUTOMAKE}"
225 einfo "Using $(automake --version 2>/dev/null | head -n 1)"
226 einfo "Using $(aclocal --version 2>/dev/null | head -n 1)"
227 fi
228 else
229 ewarn "QA Notice: \${WANT_AUTOMAKE} variable unset. Please report on http://bugs.gentoo.org/"
230 fi
231
232 autotools_version_sets="yes"
233}
147 234
148# Internal function to run an autotools' tool 235# Internal function to run an autotools' tool
149autotools_run_tool() { 236autotools_run_tool() {
150 local STDERR_TARGET="${T}/$$.out" 237 local STDERR_TARGET="${T}/$$.out"
151 local PATCH_TARGET="${T}/$$.patch"
152 local ris 238 local ris
153 239
154 echo "***** $1 *****" > ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 240 echo "***** $1 *****" > ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
155 echo >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 241 echo >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
156 242
157 ebegin "Running $1" 243 ebegin "Running $@"
158 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1 244 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1
159 ris=$? 245 ris=$?
160 eend ${ris} 246 eend ${ris}
161 247
162 if [[ ${ris} != 0 ]]; then 248 if [[ ${ris} != 0 && ${NO_FAIL} != 1 ]]; then
163 echo 249 echo
164 eerror "Failed Running $1 !" 250 eerror "Failed Running $1 !"
165 eerror 251 eerror
166 eerror "Include in your bugreport the contents of:" 252 eerror "Include in your bugreport the contents of:"
167 eerror 253 eerror
172} 258}
173 259
174# Internal function to check for support 260# Internal function to check for support
175autotools_check_macro() { 261autotools_check_macro() {
176 [[ -f configure.ac || -f configure.in ]] && \ 262 [[ -f configure.ac || -f configure.in ]] && \
177 autoconf --trace=$1 2>/dev/null 263 WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
178 return 0 264 return 0
179} 265}
180 266
181# Internal function to get additional subdirs to configure 267# Internal function to get additional subdirs to configure
182autotools_get_subdirs() { 268autotools_get_subdirs() {
185 subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS") 271 subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS")
186 [[ -n ${subdirs_scan_out} ]] || return 0 272 [[ -n ${subdirs_scan_out} ]] || return 0
187 273
188 echo "${subdirs_scan_out}" | gawk \ 274 echo "${subdirs_scan_out}" | gawk \
189 '($0 !~ /^[[:space:]]*(#|dnl)/) { 275 '($0 !~ /^[[:space:]]*(#|dnl)/) {
190 if (match($0, "AC_CONFIG_SUBDIRS\\(\\[?([^\\])]*)", res)) { 276 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
191 split(res[1], DIRS, /[\])]/)
192 print DIRS[1] 277 print res[1]
193 }
194 }' | uniq 278 }' | uniq
195 279
196 return 0 280 return 0
197} 281}
198 282
283autotools_get_auxdir() {
284 local auxdir_scan_out
285
286 auxdir_scan_out=$(autotools_check_macro "AC_CONFIG_AUX_DIR")
287 [[ -n ${auxdir_scan_out} ]] || return 0
288
289 echo ${auxdir_scan_out} | gawk \
290 '($0 !~ /^[[:space:]]*(#|dnl)/) {
291 if (match($0, /AC_CONFIG_AUX_DIR:(.*)$/, res))
292 print res[1]
293 }' | uniq
294
295 return 0
296}

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.63

  ViewVC Help
Powered by ViewVC 1.1.20