4 LICENSE="$TOP/LICENSE-BSD"
8 echo "usage: $0 [options]"
9 echo "The possible options are:"
10 echo " --dry-run|-n Just find files lacking license info."
11 echo " --license|-L <file> Use file to obtain license text."
12 echo " --git|-g Add license only to files in the repository."
13 echo " --exclude|-e <pat> Exclude files matching egrep pattern <pat>."
14 echo " --help|-h Show this help and exit."
24 echo "fatal error: $_msg"
42 echo "Inserting licensing information to $_file..."
44 cat $LICENSE | sed 's/^ / /g;s/^/ * /g' \
45 | sed 's/ *$//g' >> $_out
52 find_missing_licenses () {
53 local _lacking _files _f
56 if [ -z "$EXCLUDE" ]; then
57 _files="`find . -name '*.[hc]'`"
59 _files="`find . -name '*.[hc]' | egrep -v -e $EXCLUDE`"
64 grep -ql 'Copyright .*Intel .*' $_f
66 if [ "$GIT" = "y" ]; then
67 git ls-files | grep -q "$_f\$" && _lacking="$_lacking $_f" || :
69 _lacking="$_lacking $_f"
81 while [ "${1#-}" != "$1" -a -n "$1" ]; do
91 fatal 1 "missing license argument"
102 fatal 1 "missing exclusion pattern"
110 echo "Unknown command line option \'$1\'."
118 if [ ! -f "$LICENSE" ]; then
119 fatal 1 "license file \'$LICENSE\' missing"
122 pushd $TOP >& /dev/null
124 lacking="`find_missing_licenses`"
126 for f in $lacking; do
127 if [ "$DRY_RUN" != "y" ]; then
130 echo "$f is lacking licensing information."