# 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:
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
--- /dev/null
+#!/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' "$(<Makefile.am)"
+ printf '### EXPECTED:\n%s\n' "${exp}"
+ printf '### ACTUAL:\n%s\n' "${flags}"
+ fi
+ rm Makefile.am
+}
+
+test-it simple "-Im4"
+test-it simple "-I m4 -I lakdjfladsfj /////"
+
+test-it shell-exec '`echo hi`' "hi"
+test-it shell-exec '`echo {0..3}`' "0 1 2 3"
+
+test-it multiline '-I oneline \\\n\t-I twoline' "-I oneline -I twoline"