GNU Automake: Append `-I' flags stemming from $ACLOCAL_PATH instead of prepending them.

See <http://lists.gnu.org/archive/html/bug-gnulib/2011-07/msg00100.html>
for an illustration of the bug.

svn path=/nixpkgs/trunk/; revision=27622
This commit is contained in:
Ludovic Courtès 2011-07-07 15:10:40 +00:00
parent 9cbb1dbec6
commit 4d7d10da6b

View file

@ -1,5 +1,33 @@
source $stdenv/setup
# Wrap the given `aclocal' program, appending extra `-I' flags
# corresponding to the directories listed in $ACLOCAL_PATH. (Note
# that `wrapProgram' can't be used for that purpose since it can only
# prepend flags, not append them.)
wrapAclocal() {
local program="$1"
local wrapped="$(dirname $program)/.$(basename $program)-wrapped"
mv "$program" "$wrapped"
cat > "$program"<<EOF
#! $SHELL -e
unset extraFlagsArray
declare -a extraFlagsArray
oldIFS=\$IFS
IFS=:
for dir in \$ACLOCAL_PATH; do
if test -n "\$dir" -a -d "\$dir"; then
extraFlagsArray=("\${extraFlagsArray[@]}" "-I" "\$dir")
fi
done
IFS=\$oldIFS
exec "$wrapped" "\$@" "\${extraFlagsArray[@]}"
EOF
chmod +x "$program"
}
postInstall() {
# Create a wrapper around `aclocal' that converts every element in
@ -9,16 +37,7 @@ postInstall() {
# `-I' options explicitly.
for prog in $out/bin/aclocal*; do
wrapProgram $prog --run \
'
oldIFS=$IFS
IFS=:
for dir in $ACLOCAL_PATH; do
if test -n "$dir" -a -d "$dir"; then
extraFlagsArray=("${extraFlagsArray[@]}" "-I" "$dir")
fi
done
IFS=$oldIFS'
wrapAclocal "$prog"
done
}