#!/usr/bin/env perl

use strict;

my $RCSID = '$Id: makefilter 1.6 2003/01/16 11:16:15 lefevre Exp $';
my ($proc,$vers) = $RCSID =~ /^.Id: (\S+) ([.\d]+) / or die;

my @col = map { `tput bold; tput setaf $_` } (0..7);
my $sgr0 = `tput sgr0`;

$| = 1;
my $sao = '(?:;|&&|\|\|)';
my $ite = '(?:if|then|else)';
my $cmds = 'ar|c\+\+|cc|ccache|gcc|ld|mv|ranlib|rm';
while (<>)
  { s/^(Making .*)/$col[7]$1$sgr0/o;
    s/^(make\[\d.*)/$col[6]$1$sgr0/o;
    s/(^(?:$ite +)?|$sao +)($cmds) /$1$col[5]$2$sgr0 /og;
    s/^(\S+:\d+: warning:.*)/$col[1]$1$sgr0/o;
    s/($sao|\b($ite|fi)\b)/$col[3]$1$sgr0/og;
    s/^(PASS:)/$col[2]$1$sgr0/og;
    s/^(FAIL:)/$col[1]$1$sgr0/og;
    s/^(SKIP:)/$col[7]$1$sgr0/og;
    print; }