From dfd0521eeb7ee2d90425a6a6372152117151d2b0 Mon Sep 17 00:00:00 2001 From: Paul Smith <paul@mad-scientist.net> Date: Mon, 11 Nov 2019 12:00:58 -0500 Subject: [PATCH] Terminal: Support GNU make's TTY notification environment variable Starting with release 4.0, GNU make provides for collecting recipe output and printing it all at once after the recipe is complete, as well as ensuring that only one rule is printing output at a time. This allows parallel builds without mangled output. However, it means that programs run by make do not have a TTY for their stdout or stderr: make is collecting this. GNU make 4.1 and above will set an environment variable MAKE_TERMOUT to a non-empty value if make believes that after it's done collecting stdout, the results will be displayed on a TTY. This patch teaches KWsys to check that environment variable and if set, proceed as if output is going to a TTY. --- Terminal.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Terminal.c b/Terminal.c index 4dd24614..c9515ee7 100644 --- a/Terminal.c +++ b/Terminal.c @@ -172,6 +172,14 @@ static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100, } } + /* GNU make 4.1+ may tell us that its output is destined for a TTY. */ + { + const char* termout = getenv("MAKE_TERMOUT"); + if (termout && *termout != '\0') { + return 1; + } + } + /* If running inside emacs the terminal is not VT100. Some emacs seem to claim the TERM is xterm even though they do not support VT100 escapes. */ -- GitLab