クイックアンサー
システム ファイルを変更しないことをお勧めします。ここにいくつかの変数と、コンパイルの出力をパイプする単純なcolorgccシェル関数があります。戻りコードを失いますが、本当に必要な場合は別の方法で処理できます。
n=$(tput setaf 0)
r=$(tput setaf 1)
g=$(tput setaf 2)
y=$(tput setaf 3)
b=$(tput setaf 4)
m=$(tput setaf 5)
c=$(tput setaf 6)
w=$(tput setaf 7)
N=$(tput setaf 8)
R=$(tput setaf 9)
G=$(tput setaf 10)
Y=$(tput setaf 11)
B=$(tput setaf 12)
M=$(tput setaf 13)
C=$(tput setaf 14)
W=$(tput setaf 15)
END=$(tput sgr0)
colorgcc()
{
perl -wln -M'Term::ANSIColor' -e '
m/not found$/ and print "$ENV{N}$`$ENV{END}", "$&", "$ENV{END}"
or
m/found$/ and print "$ENV{N}$`${g}", "$&", "$ENV{END}"
or
m/yes$/ and print "$ENV{N}$`${g}", "$&", "$ENV{END}"
or
m/no$/ and print "$ENV{N}$`$ENV{END}", "$&", "$ENV{END}"
or
m/undefined reference to/i and print "$ENV{r}", "$_", "$ENV{END}"
or
m/ Error |error:/i and print "$ENV{r}", "$_", "$ENV{END}"
or
m/ Warning |warning:/i and print "$ENV{y}", "$_", "$ENV{END}"
or
m/nsinstall / and print "$ENV{c}", "$_", "$ENV{END}"
or
m/Linking |\.a\b/ and print "$ENV{C}", "$_", "$ENV{END}"
or
m/Building|gcc|g\+\+|\bCC\b|\bcc\b/ and print "$ENV{N}", "$_", "$ENV{END}"
or
print; '
}
そのように使用します:
./configure | tee -a yourlog.configure.log | colorgcc
make | tee -a yourlog.make.log | colorgcc
make install | tee -a yourlog.install.log | colorgcc