1#!/bin/sh
2#
3# kernelcruft.sh
4#
5# Try to find *.c files in /sys which are orphaned
6#
7# $FreeBSD$
8
9cd /sys/conf
10cat files* | sed '
11/^[ 	]*#/d
12s/[ 	].*//
13/^$/d
14' | sort -u > /tmp/_0
15
16cd /sys
17find * -name '*.c' -print | sed '
18/\/compile\//d
19/^boot/d
20' | sort -u > /tmp/_1
21
22find * -name '*.[ch]' -print | xargs grep 'include.*c[>"]' > /tmp/_2
23
24find * -name 'Makefile*' -print | xargs cat | sed '
25/^	/d
26s/:.*//
27/^[ 	]*$/d
28' > /tmp/_3
29
30comm -13 /tmp/_0 /tmp/_1 | while read f
31do
32	b=`basename $f`
33	if grep $b /tmp/_2 > /dev/null ; then
34		# echo "2 $f"
35		continue
36	fi
37	if grep $b /tmp/_3 > /dev/null ; then
38		# echo "3 $f"
39		continue
40	fi
41	echo $f
42done
43
44