/[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.46
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.46 2006/09/23 19:43:07 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[[ ${WANT_AUTOMAKE} == "latest" ]] && export WANT_AUTOMAKE=1.9
16# sys-devel/autoconf 16[[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5
17
18_automake_atom="sys-devel/automake"
19_autoconf_atom="sys-devel/autoconf"
20[[ -n ${WANT_AUTOMAKE} ]] && _automake_atom="=sys-devel/automake-${WANT_AUTOMAKE}*"
21if [[ -n ${WANT_AUTOCONF} ]] ; then
22 case ${WANT_AUTOCONF} in
23 2.1) _autoconf_atom="=sys-devel/autoconf-${WANT_AUTOCONF}*" ;;
24 2.5) _autoconf_atom=">=sys-devel/autoconf-2.59" ;;
25 esac
26fi
27DEPEND="${_automake_atom}
28 ${_autoconf_atom}
17# sys-devel/libtool" 29 sys-devel/libtool"
18# 30RDEPEND=""
19# Ebuilds should rather depend on the proper version of the tool. 31unset _automake_atom _autoconf_atom
20 32
21# Variables: 33# Variables:
22# 34#
23# AT_M4DIR - Additional director(y|ies) aclocal should search 35# AT_M4DIR - Additional director(y|ies) aclocal should search
24# AT_GNUCONF_UPDATE - Should gnuconfig_update() be run (normally handled by 36# AM_OPTS - Additional options to pass to automake during
25# econf()) [yes|no] 37# eautoreconf call.
26 38
27# Functions: 39# Functions:
28# 40#
29# eautoreconf() - Should do a full autoreconf - normally what most people 41# eautoreconf() - Should do a full autoreconf - normally what most people
30# will be interested in. Also should handle additional 42# will be interested in. Also should handle additional
31# directories specified by AC_CONFIG_SUBDIRS. 43# directories specified by AC_CONFIG_SUBDIRS.
32# eaclocal() - Runs aclocal. Respects AT_M4DIR for additional directories 44# eaclocal() - Runs aclocal. Respects AT_M4DIR for additional directories
33# to search for macro's. 45# to search for macro's.
34# _elibtoolize() - Runs libtoolize. Note the '_' prefix .. to not collide 46# _elibtoolize() - Runs libtoolize. Note the '_' prefix .. to not collide
35# with elibtoolize() from libtool.eclass 47# with elibtoolize() from libtool.eclass
36# eautoconf - Runs autoconf. 48# eautoconf - Runs autoconf.
37# eautoheader - Runs autoheader. 49# eautoheader - Runs autoheader.
38# eautomake - Runs automake 50# eautomake - Runs automake
39# 51#
40 52
41# XXX: M4DIR should be depreciated 53# XXX: M4DIR should be depreciated
42AT_M4DIR=${AT_M4DIR:-${M4DIR}} 54AT_M4DIR=${AT_M4DIR:-${M4DIR}}
43AT_GNUCONF_UPDATE="no" 55AT_GNUCONF_UPDATE="no"
44 56
45 57
46# This function mimes the behavior of autoreconf, but uses the different 58# This function mimes the behavior of autoreconf, but uses the different
47# eauto* functions to run the tools. It doesn't accept parameters, but 59# 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. 60# 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() { 61eautoreconf() {
52 local pwd=$(pwd) x 62 local pwd=$(pwd) x auxdir
53 63
64 if [[ -z ${AT_NO_RECURSIVE} ]]; then
54 # Take care of subdirs 65 # Take care of subdirs
55 for x in $(autotools_get_subdirs); do 66 for x in $(autotools_get_subdirs); do
56 if [[ -d ${x} ]] ; then 67 if [[ -d ${x} ]] ; then
57 cd "${x}" 68 cd "${x}"
58 eautoreconf 69 AT_NOELIBTOOLIZE="yes" eautoreconf
59 cd "${pwd}" 70 cd "${pwd}"
60 fi 71 fi
61 done 72 done
73 fi
62 74
75 auxdir=$(autotools_get_auxdir)
76
77 einfo "Running eautoreconf in '$(pwd)' ..."
78 [[ -n ${auxdir} ]] && mkdir -p ${auxdir}
63 eaclocal 79 eaclocal
64 _elibtoolize --copy --force 80 _elibtoolize --copy --force
65 eautoconf 81 eautoconf
66 eautoheader 82 eautoheader
67 eautomake 83 FROM_EAUTORECONF="yes" eautomake ${AM_OPTS}
68 84
69 # Normally run by econf() 85 [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0
70 [[ ${AT_GNUCONF_UPDATE} == "yes" ]] && gnuconfig_update 86
87 # Call it here to prevent failures due to elibtoolize called _before_
88 # eautoreconf.
89 elibtoolize
71 90
72 return 0 91 return 0
73} 92}
74 93
75# These functions runs the autotools using autotools_run_tool with the 94# These functions runs the autotools using autotools_run_tool with the
77# without e prefix. 96# without e prefix.
78# They also force installing the support files for safety. 97# They also force installing the support files for safety.
79eaclocal() { 98eaclocal() {
80 local aclocal_opts 99 local aclocal_opts
81 100
82 # XXX: M4DIR should be depreciated
83 AT_M4DIR=${AT_M4DIR:-${M4DIR}}
84
85 if [[ -n ${AT_M4DIR} ]] ; then 101 if [[ -n ${AT_M4DIR} ]] ; then
86 for x in ${AT_M4DIR} ; do 102 for x in ${AT_M4DIR} ; do
87 case "${x}" in 103 case "${x}" in
88 "-I") 104 "-I")
89 # We handle it below 105 # 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 ;; 106 ;;
96 *) 107 *)
97 [[ ! -d ${x} ]] && ewarn "eaclocal: '${x}' does not exist" 108 [[ ! -d ${x} ]] && ewarn "eaclocal: '${x}' does not exist"
98 aclocal_opts="${aclocal_opts} -I ${x}" 109 aclocal_opts="${aclocal_opts} -I ${x}"
99 ;; 110 ;;
100 esac 111 esac
101 done 112 done
102 fi 113 fi
103 114
104 [[ -f aclocal.m4 && -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \ 115 [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
105 autotools_run_tool aclocal "$@" ${aclocal_opts} 116 autotools_run_tool aclocal "$@" ${aclocal_opts}
106} 117}
107 118
108_elibtoolize() { 119_elibtoolize() {
109 local opts 120 local opts
121 local lttest
110 122
111 # Check if we should run libtoolize 123 # Check if we should run libtoolize (AM_PROG_LIBTOOL is an older macro,
112 [[ -n $(autotools_check_macro "AC_PROG_LIBTOOL") ]] || return 0 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
113 127
114 [[ -f Makefile.am ]] && opts="--automake" 128 [[ -f Makefile.am ]] && opts="--automake"
115 129
116 [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize" 130 [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize"
117 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts} 131 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts}
136 150
137 autotools_run_tool autoconf "$@" 151 autotools_run_tool autoconf "$@"
138} 152}
139 153
140eautomake() { 154eautomake() {
155 local extra_opts
156
141 [[ -f Makefile.am ]] || return 0 157 [[ -f Makefile.am ]] || return 0
158
159 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 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 return 0
178 fi
179 fi
180
181 [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS ]] \
182 || extra_opts="${extra_opts} --foreign"
183
142 # --force-missing seems not to be recognized by some flavours of automake 184 # --force-missing seems not to be recognized by some flavours of automake
143 autotools_run_tool automake --add-missing --copy "$@" 185 autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
144} 186}
145 187
146 188
147 189
148# Internal function to run an autotools' tool 190# Internal function to run an autotools' tool
152 local ris 194 local ris
153 195
154 echo "***** $1 *****" > ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 196 echo "***** $1 *****" > ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
155 echo >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 197 echo >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
156 198
157 ebegin "Running $1" 199 ebegin "Running $@"
158 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1 200 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1
159 ris=$? 201 ris=$?
160 eend ${ris} 202 eend ${ris}
161 203
162 if [[ ${ris} != 0 ]]; then 204 if [[ ${ris} != 0 ]]; then
172} 214}
173 215
174# Internal function to check for support 216# Internal function to check for support
175autotools_check_macro() { 217autotools_check_macro() {
176 [[ -f configure.ac || -f configure.in ]] && \ 218 [[ -f configure.ac || -f configure.in ]] && \
177 autoconf --trace=$1 2>/dev/null 219 WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
178 return 0 220 return 0
179} 221}
180 222
181# Internal function to get additional subdirs to configure 223# Internal function to get additional subdirs to configure
182autotools_get_subdirs() { 224autotools_get_subdirs() {
185 subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS") 227 subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS")
186 [[ -n ${subdirs_scan_out} ]] || return 0 228 [[ -n ${subdirs_scan_out} ]] || return 0
187 229
188 echo "${subdirs_scan_out}" | gawk \ 230 echo "${subdirs_scan_out}" | gawk \
189 '($0 !~ /^[[:space:]]*(#|dnl)/) { 231 '($0 !~ /^[[:space:]]*(#|dnl)/) {
190 if (match($0, "AC_CONFIG_SUBDIRS\\(\\[?([^\\])]*)", res)) { 232 if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
191 split(res[1], DIRS, /[\])]/)
192 print DIRS[1] 233 print res[1]
193 }
194 }' | uniq 234 }' | uniq
195 235
196 return 0 236 return 0
197} 237}
198 238
239autotools_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}

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

  ViewVC Help
Powered by ViewVC 1.1.20