return 0
}
-# run_make [-e STATUS] [--] [VAR=VAL ...] [MAKE-ARGS...]
-# ------------------------------------------------------
+# run_make [-e STATUS] [-O] [-E] [-M] [--] [VAR=VAL ...] [MAKE-ARGS...]
+# ---------------------------------------------------------------------
+#
# Run $MAKE with the given command-line, and fail if it doesn't exit with
# STATUS (default: 0). If STATUS is "FAIL", then any exit status > 0 is
# acceptable. If STATUS is "IGNORE", any exit value is acceptable.
+#
+# Other options:
+#
+# -O save the standard output from make on disk, in a regular file
+# named 'stdout'.
+#
+# -E save the standard error from make on disk, in a regular file
+# named 'stderr'.
+#
+# -M save both the standard output and standard error from make on
+# disk, in a regular file named 'output'. This option supersedes
+# both the '-O' and '-E' options.
+#
# This function also handle command-line override of variable definition
# in a smart way, using AM_MAKEFLAGS if a non-GNU make implementation
# is in use.
+#
run_make ()
{
+ am__make_redirect=
+ am__make_flags=
# Follow-up code might want to analyse these, so don't make them as
# private, nor unset them later.
am_make_rc_exp=0
while test $# -gt 0; do
case $1 in
-e) am_make_rc_exp=$2; shift;;
+ -O) am__make_redirect="$am__make_redirect >stdout";;
+ -E) am__make_redirect="$am__make_redirect 2>stderr";;
+ -M) am__make_redirect=">output 2>&1";;
--) shift; break;;
*) break;;
esac
shift
done
- am__make_flags=
+
if using_gmake; then
# We can trust GNU make to correctly pass macro definitions given
# on the command line down to sub-make invocations, and this allow
done
unset am__x
fi
+
if test x"$am__make_flags" != x; then
- $MAKE AM_MAKEFLAGS="$am__make_flags" ${1+"$@"} || am_make_rc_got=$?
- else
- $MAKE ${1+"$@"} || am_make_rc_got=$?
+ set AM_MAKEFLAGS="$am__make_flags" ${1+"$@"}
+ unset am__make_flags
fi
- unset am__make_flags
+
+ eval "\$MAKE${am__make_redirect}"' ${1+"$@"}' || am_make_rc_got=$?
+
+ case $am__make_redirect in
+ *output*) cat output;;
+ *stderr*stdout*) cat stdout && cat stderr >&2;;
+ *stdout*stderr*) cat stdout && cat stderr >&2;;
+ *stdout*) cat stdout;;
+ *stderr*) cat stderr >&2;;
+ esac \
+ || fatal_ "displaying make output"
+
case $am_make_rc_exp in
IGNORE)
: Ignore exit status
test $am_make_rc_exp -eq $am_make_rc_got || return 1
;;
esac
+ unset am__make_redirect
}
# AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...]
: > $inst/share/foobar.txt
chmod a-w $inst/share
-$MAKE uninstall >output 2>&1 && { cat output; exit 1; }
-cat output
+run_make -M -e FAIL uninstall
if test $rm_f_is_silent_on_error = yes; then
: "rm -f" is silent on errors, skip the grepping of make output
else
chmod a-rwx $inst/share
(cd $inst/share) && skip_ "cannot make directories fully unreadable"
-$MAKE uninstall >output 2>&1 && { cat output; exit 1; }
-cat output
-#
+run_make -M -e FAIL uninstall
+
# Some shells, like Solaris 10 /bin/ksh and /usr/xpg4/bin/sh, do not
# report the name of the 'cd' builtin upon a chdir error:
#
# > \
# > cd unreadable'
# /bin/ksh[3]: unreadable: permission denied
-#
+
$EGREP "(cd|sh)(\[[0-9]*[0-9]\])?: .*$inst/share" output
: