From: Mike Frysinger Date: Fri, 23 Sep 2011 04:14:02 +0000 (+0000) Subject: handle multiline ACLOCAL_AMFLAGS #383525 by Mikael Morin X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=5bfdca5445933ee8e4b3fe9453e63c2d578e74c2;p=gentoo.git handle multiline ACLOCAL_AMFLAGS #383525 by Mikael Morin --- diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass index ab67d5c66e79..0ed2556db2b6 100644 --- a/eclass/autotools.eclass +++ b/eclass/autotools.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.106 2011/08/22 19:39:52 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.107 2011/09/23 04:14:02 vapier Exp $ # @ECLASS: autotools.eclass # @MAINTAINER: @@ -153,30 +153,44 @@ eautoreconf() { return 0 } -# @FUNCTION: eaclocal +# @FUNCTION: eaclocal_amflags # @DESCRIPTION: -# 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. -# Respects AT_M4DIR for additional directories to search for macro's. -eaclocal() { - local aclocal_opts +# Extract the ACLOCAL_AMFLAGS value from the Makefile.am and try to handle +# (most) of the crazy crap that people throw at us. +eaclocal_amflags() { + local aclocal_opts amflags_file - local amflags_file for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in ; do [[ -e ${amflags_file} ]] || continue # setup the env in case the pkg does something crazy # in their ACLOCAL_AMFLAGS. like run a shell script - # which turns around and runs autotools #365401 + # which turns around and runs autotools. #365401 + # or split across multiple lines. #383525 autotools_env_setup - aclocal_opts=$(sed -n '/^ACLOCAL_AMFLAGS[[:space:]]*=/s:[^=]*=::p' ${amflags_file}) - eval aclocal_opts=\"${aclocal_opts}\" + aclocal_opts=$(sed -n \ + "/^ACLOCAL_AMFLAGS[[:space:]]*=/{ \ + # match the first line + s:[^=]*=::p; \ + # then gobble up all escaped lines + : nextline /\\\\$/{ n; p; b nextline; } \ + }" ${amflags_file}) + eval aclocal_opts=\""${aclocal_opts}"\" break done + echo ${aclocal_opts} +} + +# @FUNCTION: eaclocal +# @DESCRIPTION: +# 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. +# Respects AT_M4DIR for additional directories to search for macro's. +eaclocal() { [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \ - autotools_run_tool aclocal $(autotools_m4dir_include) "$@" ${aclocal_opts} + autotools_run_tool aclocal $(autotools_m4dir_include) "$@" $(eaclocal_amflags) } # @FUNCTION: _elibtoolize diff --git a/eclass/tests/autotools:eaclocal_amflags.sh b/eclass/tests/autotools:eaclocal_amflags.sh new file mode 100755 index 000000000000..ac0ab767aa55 --- /dev/null +++ b/eclass/tests/autotools:eaclocal_amflags.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +source tests-common.sh + +inherit autotools + +test-it() { + ebegin "Testing eaclocal_amflags $1: $2" + printf "ACLOCAL_AMFLAGS = %b\n" "$2" > Makefile.am + local flags=$(eaclocal_amflags) exp=${3:-$2} + [[ "${flags}" == "${exp}" ]] + if ! eend $? ; then + printf '### INPUT:\n%s\n' "$2" + printf '### FILE:\n%s\n' "$(