Typically from a shell script, we can detect if the output is redirected to a file, along the lines of:
if [ -t 1 ]; then echo "shell"; fi
But, I'd like to do this inside of a makefile, which means that AFAIK, the only way to do it is:
ifeq ($(shell if [ -t 1 ]; then echo "1"; fi),1)
## in shell
endif
However, this appears to be the case all the time, whether the output is redirected to a file or not. I guess it's down to how $(shell...)
is implemented. So my question is, is there anything that I can test in make
that will let me know if the output is redirected to a file.
A little background, my makefiles generate lots of useful output and to make things a bit more obvious, I use some colouring of text - on the console this is fine, however in Hudson when the same build job runs, the output (which is redirected to a file) has all the control characters in it... So what I'd like to do is to disable all the colour codes in make if the file is redirected.