diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | config.ami.template | 6 | ||||
-rw-r--r-- | config.h-vms.template | 6 | ||||
-rw-r--r-- | config.h.W32.template | 6 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | doc/make.texi | 22 | ||||
-rw-r--r-- | main.c | 12 | ||||
-rw-r--r-- | makeint.h | 6 |
8 files changed, 61 insertions, 2 deletions
@@ -15,6 +15,9 @@ A complete list of bugs fixed in this version is available here: http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=105&set=custom +* New variables: $(MAKE_TTYOUT) and $(MAKE_TTYERR) are set if stdout or + stderr, respectively, are believed to be writing to a terminal. + * Allow a no-text-argument form of the $(file ...) function. Without a text argument nothing is written to the file: it is simply opened in the requested mode, then closed again. diff --git a/config.ami.template b/config.ami.template index d9163c0..419824f 100644 --- a/config.ami.template +++ b/config.ami.template @@ -318,6 +318,12 @@ this program. If not, see <http://www.gnu.org/licenses/>. */ /* Define if you have the kstat library (-lkstat). */ /* #undef HAVE_LIBKSTAT */ +/* Define to 1 if you have the `isatty' function. */ +/* #undef HAVE_ISATTY */ + +/* Define to 1 if you have the `ttyname' function. */ +/* #undef HAVE_TTYNAME */ + /* Define if you have the sun library (-lsun). */ /* #undef HAVE_LIBSUN */ diff --git a/config.h-vms.template b/config.h-vms.template index 71fe269..8c0a078 100644 --- a/config.h-vms.template +++ b/config.h-vms.template @@ -362,6 +362,12 @@ this program. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the sun library (-lsun). */ /* #undef HAVE_LIBSUN */ +/* Define to 1 if you have the `isatty' function. */ +/* #undef HAVE_ISATTY */ + +/* Define to 1 if you have the `ttyname' function. */ +/* #undef HAVE_TTYNAME */ + /* Use high resolution file timestamps if nonzero. */ #define FILE_TIMESTAMP_HI_RES 0 diff --git a/config.h.W32.template b/config.h.W32.template index f7aed90..849a855 100644 --- a/config.h.W32.template +++ b/config.h.W32.template @@ -292,6 +292,12 @@ this program. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the 'strsignal' function. */ /* #undef HAVE_STRSIGNAL */ +/* Define to 1 if you have the `isatty' function. */ +#define HAVE_ISATTY 1 + +/* Define to 1 if you have the `ttyname' function. */ +/* #undef HAVE_TTYNAME */ + /* Define to 1 if 'n_un.n_name' is a member of 'struct nlist'. */ /* #undef HAVE_STRUCT_NLIST_N_UN_N_NAME */ diff --git a/configure.ac b/configure.ac index 59333d1..97fd090 100644 --- a/configure.ac +++ b/configure.ac @@ -140,7 +140,7 @@ AC_CHECK_FUNCS([strdup strndup mkstemp mktemp fdopen fileno \ dup dup2 getcwd realpath sigsetmask sigaction \ getgroups seteuid setegid setlinebuf setreuid setregid \ getrlimit setrlimit setvbuf pipe strerror strsignal \ - lstat readlink atexit]) + lstat readlink atexit isatty ttyname]) # We need to check declarations, not just existence, because on Tru64 this # function is not declared without special flags, which themselves cause diff --git a/doc/make.texi b/doc/make.texi index 2aacc70..3a873d7 100644 --- a/doc/make.texi +++ b/doc/make.texi @@ -6321,6 +6321,28 @@ will contain the number of times this instance has restarted. Note this is not the same as recursion (counted by the @code{MAKELEVEL} variable). You should not set, modify, or export this variable. +@vindex MAKE_TTYOUT @r{(whether stdout is a terminal)} +@vindex MAKE_TTYERR @r{(whether stderr is a terminal)} +@item MAKE_TTYOUT +@itemx MAKE_TTYERR +When @code{make} starts it will check whether stdout and stderr will +show their output on a terminal. If so, it will set +@code{MAKE_TTYOUT} and @code{MAKE_TTYERR}, respectively, to the name +of the terminal device (or @code{true} if this cannot be determined). +If set these variables will be marked for export. These variables +will not be changed by @code{make} and they will not be modified if +already set. + +These values can be used (particularly in combination with output +synchronization (@pxref{Parallel Output, ,Output During Parallel +Execution}) to determine whether @code{make} itself is writing to a +terminal; they can be tested to decide whether to force recipe +commands to generate colorized output for example. + +If you invoke a sub-@code{make} and redirect its stdout or stderr it +is your responsibility to reset or unexport these variables as well, +if your makefiles rely on them. + @vindex .RECIPEPREFIX @r{(change the recipe prefix character)} @item .RECIPEPREFIX The first character of the value of this variable is used as the @@ -1374,7 +1374,6 @@ main (int argc, char **argv, char **envp) #endif /* Decode the switches. */ - decode_env_switches (STRING_SIZE_TUPLE ("GNUMAKEFLAGS")); /* Clear GNUMAKEFLAGS to avoid duplication. */ @@ -1398,6 +1397,17 @@ main (int argc, char **argv, char **envp) decode_switches (argc, (const char **)argv, 0); + /* Set a variable specifying whether stdout/stdin is hooked to a TTY. */ +#ifdef HAVE_ISATTY + if (isatty (fileno (stdout))) + define_variable_cname ("MAKE_TTYOUT", TTYNAME (fileno (stdout)), + o_default, 0)->export = v_export; + + if (isatty (fileno (stderr))) + define_variable_cname ("MAKE_TTYERR", TTYNAME (fileno (stderr)), + o_default, 0)->export = v_export; +#endif + /* Reset in case the switches changed our minds. */ syncing = (output_sync == OUTPUT_SYNC_LINE || output_sync == OUTPUT_SYNC_TARGET); @@ -424,6 +424,12 @@ extern struct rlimit stack_limit; /* The number of bytes needed to represent the largest integer as a string. */ #define INTSTR_LENGTH CSTRLEN ("18446744073709551616") +#ifdef HAVE_TTYNAME +# define TTYNAME(_f) ttyname (_f) +#else +# define TTYNAME(_f) "true" +#endif + const char *concat (unsigned int, ...); void message (int prefix, size_t length, const char *fmt, ...) |