2007-03-26 08:48:00 +04:00
#!/bin/sh -f
2009-10-10 00:40:33 +04:00
CC=$1
CFLAGS=$2; shift 2
2007-03-26 08:48:00 +04:00
outfile="$1"; shift
2007-07-01 15:08:30 +04:00
bin="$(echo $0 | sed 's,/[^/]*$,,')"
2007-03-26 08:48:00 +04:00
# Derived from Russ Cox's 9c in plan9port.
xtmp=/tmp/cc.$$.$USER.out
2007-07-01 15:08:30 +04:00
echo CC $($bin/cleanname ${BASE}$outfile)
2007-07-17 00:52:35 +04:00
[ -n "$noisycc" ] && echo $CC -o $outfile $CFLAGS $@
2009-09-17 17:27:11 +04:00
eval '$CC -o $outfile '"$CFLAGS"' $@ >$xtmp 2>&1'
2007-03-26 08:48:00 +04:00
status=$?
2008-08-25 20:47:56 +04:00
[ $? -eq 0 ] || echo $CC -o $outfile $CFLAGS $@ >&2
2007-03-26 08:48:00 +04:00
2007-07-02 01:43:27 +04:00
base=$(echo $BASE | sed 's/,/\\,/g')
2007-07-01 23:26:14 +04:00
re='\([^[:space:]/]*\..:[0-9]\)'
2007-06-08 20:35:19 +04:00
2008-01-14 23:42:21 +03:00
undup() { # GCC is crap.
awk '
function shift() {
for(n=1; n<=3; n++)
if(2*n <= nl)
for(i=1; i<=n; i++) {
if(l[i] != l[i+n])
break;
if(i == n) {
for(i=1; i<=n; i++)
print l[i]
nl -= 2*n;
for(i=1; i<=nl; i++)
l[i] = l[i+2*n];
return;
}
}
if(nl == 0)
return
print l[1]
for(i=1; i<nl; i++)
l[i] = l[i+1]
nl--
}
BEGIN{
nl=0
maxl=6
}
{
if(nl == maxl)
shift()
l[++nl] = $0
}
END{
while(nl > 0)
shift();
}'
}
2007-07-02 01:43:27 +04:00
cat $xtmp | sed "s,^$re,$base&,g; s,\([[:space:]]\)$re,\1$base\2,g" |
2009-10-27 11:44:53 +03:00
egrep -v ': error: .Each undeclared identifier|: error: for each function it appears|is dangerous, better use|is almost always misused|: In function |: At top level:|support .long long.|use of C99 long long|ISO C forbids conversion|warning:.*warn_unused_result' |
2007-04-14 03:23:24 +04:00
sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
2008-01-29 01:58:23 +03:00
awk '$1 == "warning:"{t=$2" "$1; sub(/^[^ ]+ [^ ]+ /, ""); $0 = t" "$0}; //' |
awk '{sub(/\[/, ": [", $1); print}' |
2008-01-14 23:42:21 +03:00
undup 1>&2
2007-03-26 08:48:00 +04:00
2007-04-14 03:23:24 +04:00
rm -f $xtmp
2007-03-26 08:48:00 +04:00
exit $status