mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-01-27 01:27:58 +00:00
* main.c (main): Set MAKE_TTYOUT and MAKE_TTYERR.
* configure.ac: Test for isatty() and ttyname() * makeint.h: provide a substitute for ttyname() if it's not available. * config.ami.template, config.h-vms.template, config.h.W32.template: define/undefine HAVE_ISATTY/HAVE_TTYNAME macros. * NEWS, doc/make.texi: Document these new variables.
This commit is contained in:
parent
621e9edfe9
commit
7f9ce6e97b
8 changed files with 61 additions and 2 deletions
3
NEWS
3
NEWS
|
@ -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.
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
12
main.c
12
main.c
|
@ -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, ...)
|
||||
|
|
Loading…
Reference in a new issue