#!/bin/sh
# Space copy of /bin/packdeps, just in case ...
#
#	Hijacked from the Berkely 4.3 Makefile.
# 	Compacts the dependency output produced by cc -M
#
#	First, the sed command removes loops in the relative path.
#	Next, sort and uniq remove multiple entries
#	Finally, the awk command compresses the number of lines taken
#	up by the dependency listing.
#
sed -e ':loop' \
    -e 's/\([^ ./][^ ./]*\)\/\.\.\/\1/\1/' \
    -e 't loop' \
    -e 's/ \.\// /' | \
sort | uniq | \
awk ' { if ($1 != prev) { print rec; rec = $0; prev = $1; }
	else { if (length(rec $2) > 77) { print rec; rec = $0; }
	       else rec = rec " " $2 } }
END { print rec } '
