#!/bin/sh -f CC=$1 PACKAGES=$2 CFLAGS=$3; shift 3 [ -n "$PACKAGES" ] && CFLAGS="$CFLAGS $(pkg-config --cflags $PACKAGES)" outfile="$1"; shift bin="$(echo $0 | sed 's,/[^/]*$,,')" xtmp=/tmp/cc.$$.$USER.out # Derived from Russ Cox's 9c in plan9port. echo CC $($bin/cleanname ${BASE}$outfile) [ -n "$noisycc" ] && echo $CC -o $outfile $CFLAGS $@ eval '$CC -o $outfile '"$CFLAGS"' $@ >$xtmp 2>&1' status=$? [ $status -eq 0 ] || echo $CC -o $outfile $CFLAGS $@ >&2 base=$(echo $BASE | sed 's/,/\\,/g') re='\([^[:space:]/][^[:space:]]*\..:[0-9]\)' 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 0) shift(); }' } cat $xtmp | sed "s,^$re,$base&,g; s,\([[:space:]]\)$re,\1$base\2,g" | sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' | undup >&2 rm -f $xtmp exit $status