mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
3ed96312af
The color strings COLOR_* are redefined so that they don't have to be processed by "echo -e". This is done by storing the already interpreted ANSI sequence in a shell variable. With this change, not only can color messages be printed using normal `echo` with no switches: colors also work with the `info` and `warning` builtins of make. The COLOR_ECHO variable is kept because it is also being used (confusingly) to intepret tabs an newlines. This will be fixed in another commit. This change should change absolutely anything and colors should still work as always.
31 lines
826 B
Makefile
31 lines
826 B
Makefile
# Set colored output control sequences if the terminal supports it and if
|
|
# not disabled by the user
|
|
|
|
COLOR_GREEN :=
|
|
COLOR_RED :=
|
|
COLOR_YELLOW :=
|
|
COLOR_PURPLE :=
|
|
COLOR_RESET :=
|
|
COLOR_ECHO := /usr/bin/env echo
|
|
|
|
# Check if colored output is not disabled by user, i.e: CC_NOCOLOR unset
|
|
# or 0
|
|
ifneq ($(CC_NOCOLOR),1)
|
|
IS_TERMINAL = $(if $(MAKE_TERMOUT),$(MAKE_TERMERR),)
|
|
# Check if terminal support colored output
|
|
ifneq ($(IS_TERMINAL),)
|
|
_ANSI_ESC := $(shell printf "\033")
|
|
COLOR_GREEN := $(_ANSI_ESC)[1;32m
|
|
COLOR_RED := $(_ANSI_ESC)[1;31m
|
|
COLOR_YELLOW := $(_ANSI_ESC)[1;33m
|
|
COLOR_PURPLE := $(_ANSI_ESC)[1;35m
|
|
COLOR_RESET := $(_ANSI_ESC)[0m
|
|
ifeq ($(OS),Darwin)
|
|
COLOR_ECHO := echo -e
|
|
SHELL=bash
|
|
else
|
|
COLOR_ECHO := /usr/bin/env echo -e
|
|
endif
|
|
endif
|
|
endif
|