3 # Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # List of licences we can handle
24 my $known_licences = {
26 desc
=> "GPL (any version)",
36 desc
=> "GPL version 2 (or, at your option, any later version)",
47 desc
=> "GPL version 2 only",
59 desc
=> "Public Domain",
63 desc
=> "BSD Licence (with advertising clause)",
73 desc
=> "BSD Licence (without advertising clause)",
82 desc
=> "BSD Licence (without advertising or endorsement clauses)",
90 desc
=> "MIT/X11/Xorg Licence",
97 desc
=> "ISC Licence",
104 # Parse command-line options
106 Getopt
::Long
::Configure
( 'bundling', 'auto_abbrev' );
108 'verbose|v+' => sub { $verbosity++; },
109 'quiet|q+' => sub { $verbosity--; },
110 ) or die "Could not parse command-line options\n";
112 # Parse licence list from command line
114 foreach my $licence ( @ARGV ) {
115 die "Unknown licence \"$licence\"\n"
116 unless exists $known_licences->{$licence};
117 $licences->{$licence} = $known_licences->{$licence};
119 die "No licences specified\n" unless %$licences;
122 if ( $verbosity >= 1 ) {
123 print "The following licences appear within this file:\n";
124 foreach my $licence ( keys %$licences ) {
125 print " ".$licences->{$licence}->{desc
}."\n"
129 # Apply licence compatibilities to reduce to a single resulting licence
130 foreach my $licence ( keys %$licences ) {
131 # Skip already-deleted licences
132 next unless exists $licences->{$licence};
133 # Subsume any subsumable licences
134 foreach my $can_subsume ( keys %{$licences->{$licence}->{can_subsume
}} ) {
135 if ( exists $licences->{$can_subsume} ) {
136 print $licences->{$licence}->{desc
}." subsumes ".
137 $licences->{$can_subsume}->{desc
}."\n"
139 delete $licences->{$can_subsume};
144 # Print resulting licence
145 die "Cannot reduce to a single resulting licence!\n"
146 if ( keys %$licences ) != 1;
147 ( my $licence ) = keys %$licences;
148 print "The overall licence for this file is:\n " if $verbosity >= 1;
149 print $licences->{$licence}->{desc
}."\n";