From: Martin Schlemmer Date: Sun, 28 Aug 2005 17:26:33 +0000 (+0000) Subject: Enhance eautoreconf() to also run in subdirs, and do the order of calling properly... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4e717e6536ec2f39da557d96725552b0882f728a;p=gentoo.git Enhance eautoreconf() to also run in subdirs, and do the order of calling properly. Also only run the tools when needed. --- diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass index e8aadccf49a3..36e748ef1d6e 100644 --- a/eclass/autotools.eclass +++ b/eclass/autotools.eclass @@ -1,8 +1,9 @@ # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.11 2005/08/28 17:23:48 azarah Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.12 2005/08/28 17:26:33 azarah Exp $ # # Author: Diego Pettenò +# Enhancements: Martin Schlemmer # # This eclass is for handling autotooled software packages that # needs to regenerate their build scripts. @@ -11,9 +12,11 @@ inherit eutils gnuconfig -DELEND="sys-devel/automake - sys-devel/autoconf - sys-devel/libtool" +#DEPEND="sys-devel/automake +# sys-devel/autoconf +# sys-devel/libtool" +# +# Ebuilds should rather depend on the proper version of the tool. # Internal function to run an autotools' tool autotools_run_tool() { @@ -27,9 +30,9 @@ autotools_run_tool() { ebegin "Running $1" $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1 ris=$? - eend $ris + eend ${ris} - if [[ $ris != 0 ]]; then + if [[ ${ris} != 0 ]]; then echo eerror "Failed Running $1 !" eerror @@ -41,23 +44,74 @@ autotools_run_tool() { fi } +# Internal function to check for support +autotools_check_macro() { + [[ -f configure.ac || -f configure.in ]] && \ + autoconf --trace=$1 2>/dev/null + return 0 +} + +# Internal function to get additional subdirs to configure +autotools_get_subdirs() { + local subdirs_scan_out + + subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS") + [[ -n ${subdirs_scan_out} ]] || return 0 + + echo "${subdirs_scan_out}" | gawk \ + '($0 !~ /^[[:space:]]*(#|dnl)/) { + if (match($0, "AC_CONFIG_SUBDIRS\\(\\[?([^\\])]*)", res)) { + split(res[1], DIRS, /[\])]/) + print DIRS[1] + } + }' | uniq + + return 0 +} + + + # These functions runs the autotools using autotools_run_tool with the # specified parametes. The name of the tool run is the same of the function # without e prefix. # They also force installing the support files for safety. eaclocal() { - autotools_run_tool aclocal "$@" + local aclocal_opts + + [[ -n ${M4DIR} ]] && aclocal_opts="-I \"${M4DIR}\"" + + [[ -f aclocal.m4 && -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \ + autotools_run_tool aclocal "$@" ${aclocal_opts} +} + +_elibtoolize() { + # Check if we should run libtoolize + [[ -n $(autotools_check_macro "AC_PROG_LIBTOOL") ]] || return 0 + autotools_run_tool libtoolize "$@" + + # Need to rerun aclocal + eaclocal } eautoheader() { + # Check if we should run autoheader + [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0 autotools_run_tool autoheader "$@" } eautoconf() { + if [[ ! -f configure.ac && ! -f configure.in ]] ; then + echo + eerror "No configure.{ac,in} present in '$(pwd | sed -e 's:.*/::')'!" + echo + die "No configure.{ac,in} present!" + fi + autotools_run_tool autoconf "$@" } eautomake() { + [[ -f Makefile.am ]] || return 0 autotools_run_tool automake --add-missing --force-missing --copy "$@" } @@ -67,15 +121,21 @@ eautomake() { # # Note: doesn't run autopoint right now, but runs gnuconfig_update. eautoreconf() { - local aclocal_opts + local pwd=$(pwd) x - [[ -n ${M4DIR} ]] && aclocal_opts="-I ${M4DIR}" + # Take care of subdirs + for x in $(autotools_get_subdirs); do + if [[ -d ${x} ]] ; then + cd "${x}" + eautoreconf + cd "${pwd}" + fi + done - eaclocal $aclocal_opts + eaclocal + _elibtoolize --copy --force eautoconf eautoheader eautomake gnuconfig_update - - autotools_run_tool libtoolize --copy --force }