186111Sphk#!/bin/sh
286111Sphk#
386111Sphk# kernelcruft.sh
486111Sphk#
586111Sphk# Try to find *.c files in /sys which are orphaned
686111Sphk#
786111Sphk# $FreeBSD$
886111Sphk
986111Sphkcd /sys/conf
1086111Sphkcat files* | sed '
1186111Sphk/^[ 	]*#/d
1286111Sphks/[ 	].*//
1386111Sphk/^$/d
1486111Sphk' | sort -u > /tmp/_0
1586111Sphk
1686111Sphkcd /sys
1786111Sphkfind * -name '*.c' -print | sed '
1886111Sphk/\/compile\//d
1986111Sphk/^boot/d
2086111Sphk' | sort -u > /tmp/_1
2186111Sphk
2286111Sphkfind * -name '*.[ch]' -print | xargs grep 'include.*c[>"]' > /tmp/_2
2386111Sphk
2486111Sphkfind * -name 'Makefile*' -print | xargs cat | sed '
2586111Sphk/^	/d
2686111Sphks/:.*//
2786111Sphk/^[ 	]*$/d
2886111Sphk' > /tmp/_3
2986111Sphk
3086111Sphkcomm -13 /tmp/_0 /tmp/_1 | while read f
3186111Sphkdo
3286111Sphk	b=`basename $f`
3386111Sphk	if grep $b /tmp/_2 > /dev/null ; then
3486111Sphk		# echo "2 $f"
3586111Sphk		continue
3686111Sphk	fi
3786111Sphk	if grep $b /tmp/_3 > /dev/null ; then
3886111Sphk		# echo "3 $f"
3986111Sphk		continue
4086111Sphk	fi
4186111Sphk	echo $f
4286111Sphkdone
4386111Sphk
44