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., 51 Franklin Street, Fifth Floor, Boston, MA
24 # List of licences we can handle
25 my $known_licences = {
27 desc => "GPL (any version)",
37 desc => "GPL version 2 (or, at your option, any later version)",
40 gpl2_or_later_or_ubdl => 1,
49 desc => "GPL version 2 only",
53 gpl2_or_later_or_ubdl => 1,
61 gpl2_or_later_or_ubdl => {
62 desc => ( "GPL version 2 (or, at your option, any later version) or ".
63 "Unmodified Binary Distribution Licence" ),
73 desc => "Public Domain",
77 desc => "BSD Licence (with advertising clause)",
87 desc => "BSD Licence (without advertising clause)",
96 desc => "BSD Licence (without advertising or endorsement clauses)",
104 desc => "MIT/X11/Xorg Licence",
111 desc => "ISC Licence",
118 # Parse command-line options
120 Getopt::Long::Configure ( 'bundling', 'auto_abbrev' );
122 'verbose|v+' => sub { $verbosity++; },
123 'quiet|q+' => sub { $verbosity--; },
124 ) or die "Could not parse command-line options\n";
126 # Parse licence list from command line
128 foreach my $licence ( @ARGV ) {
129 die "Unknown licence \"$licence\"\n"
130 unless exists $known_licences->{$licence};
131 $licences->{$licence} = $known_licences->{$licence};
133 die "No licences specified\n" unless %$licences;
136 if ( $verbosity >= 1 ) {
137 print "The following licences appear within this file:\n";
138 foreach my $licence ( keys %$licences ) {
139 print " ".$licences->{$licence}->{desc}."\n"
143 # Apply licence compatibilities to reduce to a single resulting licence
144 foreach my $licence ( keys %$licences ) {
145 # Skip already-deleted licences
146 next unless exists $licences->{$licence};
147 # Subsume any subsumable licences
148 foreach my $can_subsume ( keys %{$licences->{$licence}->{can_subsume}} ) {
149 if ( exists $licences->{$can_subsume} ) {
150 print $licences->{$licence}->{desc}." subsumes ".
151 $licences->{$can_subsume}->{desc}."\n"
153 delete $licences->{$can_subsume};
158 # Print resulting licence
159 die "Cannot reduce to a single resulting licence!\n"
160 if ( keys %$licences ) != 1;
161 ( my $licence ) = keys %$licences;
162 print "The overall licence for this file is:\n " if $verbosity >= 1;
163 print $licences->{$licence}->{desc}."\n";