Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / util / licence.pl
1 #!/usr/bin/perl -w
2 #
3 # Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 2 of the
8 # License, or any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 # 02110-1301, USA.
19
20 use strict;
21 use warnings;
22 use Getopt::Long;
23
24 # List of licences we can handle
25 my $known_licences = {
26   gpl_any => {
27     desc => "GPL (any version)",
28     can_subsume => {
29       public_domain => 1,
30       bsd3 => 1,
31       bsd2 => 1,
32       mit  => 1,
33       isc  => 1,
34     },
35   },
36   gpl2_or_later => {
37     desc => "GPL version 2 (or, at your option, any later version)",
38     can_subsume => {
39       gpl_any => 1,
40       public_domain => 1,
41       bsd3 => 1,
42       bsd2 => 1,
43       mit  => 1,
44       isc  => 1,
45     },
46   },
47   gpl2_only => {
48     desc => "GPL version 2 only",
49     can_subsume => {
50       gpl_any => 1,
51       gpl2_or_later => 1,
52       public_domain => 1,
53       bsd3 => 1,
54       bsd2 => 1,
55       mit  => 1,
56       isc  => 1,
57     },
58   },
59   public_domain => {
60     desc => "Public Domain",
61     can_subsume => {},
62   },
63   bsd4 => {
64     desc => "BSD Licence (with advertising clause)",
65     can_subsume => {
66       public_domain => 1,
67       bsd3 => 1,
68       bsd2 => 1,
69       mit  => 1,
70       isc  => 1,
71     },
72   },
73   bsd3 => {
74     desc => "BSD Licence (without advertising clause)",
75     can_subsume => {
76       public_domain => 1,
77       bsd2 => 1,
78       mit  => 1,
79       isc  => 1,
80     },
81   },
82   bsd2 => {
83     desc => "BSD Licence (without advertising or endorsement clauses)",
84     can_subsume => {
85       public_domain => 1,
86       mit  => 1,
87       isc  => 1,
88     },
89   },
90   mit => {
91     desc => "MIT/X11/Xorg Licence",
92     can_subsume => {
93       public_domain => 1,
94       isc => 1,
95     },
96   },
97   isc => {
98     desc => "ISC Licence",
99     can_subsume => {
100       public_domain => 1,
101     },
102   },
103 };
104
105 # Parse command-line options
106 my $verbosity = 1;
107 Getopt::Long::Configure ( 'bundling', 'auto_abbrev' );
108 GetOptions (
109   'verbose|v+' => sub { $verbosity++; },
110   'quiet|q+' => sub { $verbosity--; },
111 ) or die "Could not parse command-line options\n";
112
113 # Parse licence list from command line
114 my $licences = {};
115 foreach my $licence ( @ARGV ) {
116   die "Unknown licence \"$licence\"\n"
117       unless exists $known_licences->{$licence};
118   $licences->{$licence} = $known_licences->{$licence};
119 }
120 die "No licences specified\n" unless %$licences;
121
122 # Dump licence list
123 if ( $verbosity >= 1 ) {
124   print "The following licences appear within this file:\n";
125   foreach my $licence ( keys %$licences ) {
126     print "  ".$licences->{$licence}->{desc}."\n"
127   }
128 }
129
130 # Apply licence compatibilities to reduce to a single resulting licence
131 foreach my $licence ( keys %$licences ) {
132   # Skip already-deleted licences
133   next unless exists $licences->{$licence};
134   # Subsume any subsumable licences
135   foreach my $can_subsume ( keys %{$licences->{$licence}->{can_subsume}} ) {
136     if ( exists $licences->{$can_subsume} ) {
137       print $licences->{$licence}->{desc}." subsumes ".
138           $licences->{$can_subsume}->{desc}."\n"
139           if $verbosity >= 1;
140       delete $licences->{$can_subsume};
141     }
142   }
143 }
144
145 # Print resulting licence
146 die "Cannot reduce to a single resulting licence!\n"
147     if ( keys %$licences ) != 1;
148 ( my $licence ) = keys %$licences;
149 print "The overall licence for this file is:\n  " if $verbosity >= 1;
150 print $licences->{$licence}->{desc}."\n";