dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libc / extract-copyright.sh
blob20c5d0cfa965e519aec49d05e878b20a9c4890c3
1 #! /usr/bin/ksh
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms version
6 # 1.0 of the CDDL.
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy is of the CDDL is also available via the Internet
10 # at http://www.illumos.org/license/CDDL.
14 # Copyright 2010 Nexenta Systems, Inc. All rights reserved.
15 # Copyright 2014 Garett D'Amore <garrett@damore.org>
16 # Copyright 2016 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
20 # This extracts all the BSD copyrights (excluding the CDDL licenses)
21 # for use in a THIRDPARTYLICENSE file. It tries hard to avoid duplicates.
24 typeset -A LICENSE
26 function dofile {
27 typeset file
28 typeset comment
29 typeset license
30 typeset line
31 typeset copyr
32 typeset block
33 typeset -i i
35 typeset nl=$(print)
36 file=$1 ; shift
38 comment=
39 unset license
40 unset block
41 copyr=
43 cat $file | while IFS="" read line; do
44 if [[ "$line" == /* ]] ; then
45 comment=y
46 copyr=
47 block=
48 continue
51 if [[ -z $comment ]]; then
52 # not in a comment
53 continue
57 # We don't want to know about CDDL files. They don't
58 # require an explicit THIRDPARTYLICENSE file.
60 if [[ "$line" == *CDDL* ]]
61 then
62 return
65 if [[ "$line" == *Copyright* ]]
66 then
67 copyr=y
70 if [[ "$line" != */ ]]
71 then
72 line="${line# \* }"
73 line="${line# \*}"
74 line="${line% \*/}"
75 # append to block array
76 block="${block}${line}"'\n'
77 continue
81 # We have reached the end of the comment now.
83 comment=
85 # Check to see if we saw a copyright.
86 if [[ -z "$copyr" ]]; then
87 block=
88 continue
90 license="${license}${block}"
91 block=
92 done
94 if [[ -n "$license" ]]
95 then
96 LICENSE["${license}"]="${LICENSE["${license}"]} $file"
100 find "$@" -type f -name '*.[chs]' -print | sort | while read f
102 dofile $f
103 done
105 for lic in "${!LICENSE[@]}"; do
106 print "The following files from the C library:"
107 for f in ${LICENSE[$lic]}; do
108 print " $f"
109 done
110 print "are provided under the following terms:"
111 print
112 print "$lic"
113 done