2 # This script was originally based on the script of the same name from
3 # the KDE SDK (by dfaure@kde.org)
6 # Copyright (C) 2007, 2008 Adam D. Barratt
7 # Copyright (C) 2012 Francesco Poli
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with this program. If not, see <http://www.gnu.org/licenses/>.
24 licensecheck - simple license checker for source files
28 B<licensecheck> B<--help>|B<--version>
30 B<licensecheck> [B<--no-conf>] [B<--verbose>] [B<--copyright>]
31 [B<-l>|B<--lines=>I<N>] [B<-i>|B<--ignore=>I<regex>] [B<-c>|B<--check=>I<regex>]
32 [B<-m>|B<--machine>] [B<-r>|B<--recursive>]
33 I<list of files and directories to check>
37 B<licensecheck> attempts to determine the license that applies to each file
38 passed to it, by searching the start of the file for text belonging to
41 If any of the arguments passed are directories, B<licensecheck> will add
42 the files contained within to the list of files to process.
48 =item B<--verbose>, B<--no-verbose>
50 Specify whether to output the text being processed from each file before
51 the corresponding license information.
53 Default is to be quiet.
55 =item B<-l=>I<N>, B<--lines=>I<N>
57 Specify the number of lines of each file's header which should be parsed
58 for license information. (Default is 60).
60 =item B<-i=>I<regex>, B<--ignore=>I<regex>
62 When processing the list of files and directories, the regular
63 expression specified by this option will be used to indicate those which
64 should not be considered (e.g. backup files, VCS metadata).
66 =item B<-r>, B<--recursive>
68 Specify that the contents of directories should be added
71 =item B<-c=>I<regex>, B<--check=>I<regex>
73 Specify a pattern against which filenames will be matched in order to
74 decide which files to check the license of.
76 The default includes common source files.
80 Also display copyright text found within the file
82 =item B<-m>, B<--machine>
84 Display the information in a machine readable way, i.e. in the form
85 <file><tab><license>[<tab><copyright>] so that it can be easily sorted
86 and/or filtered, e.g. with the B<awk> and B<sort> commands.
87 Note that using the B<--verbose> option will kill the readability.
89 =item B<--no-conf>, B<--noconf>
91 Do not read any configuration files. This can only be used as the first
92 option given on the command-line.
96 =head1 CONFIGURATION VARIABLES
98 The two configuration files F</etc/devscripts.conf> and
99 F<~/.devscripts> are sourced by a shell in that order to set
100 configuration variables. Command line options can be used to override
101 configuration file settings. Environment variable settings are
102 ignored for this purpose. The currently recognised variables are:
106 =item B<LICENSECHECK_VERBOSE>
108 If this is set to I<yes>, then it is the same as the B<--verbose> command
109 line parameter being used. The default is I<no>.
111 =item B<LICENSECHECK_PARSELINES>
113 If this is set to a positive number then the specified number of lines
114 at the start of each file will be read whilst attempting to determine
115 the license(s) in use. This is equivalent to the B<--lines> command line
122 This code is copyright by Adam D. Barratt <I<adam@adam-barratt.org.uk>>,
123 all rights reserved; based on a script of the same name from the KDE
124 SDK, which is copyright by <I<dfaure@kde.org>>.
125 This program comes with ABSOLUTELY NO WARRANTY.
126 You are free to redistribute this code under the terms of the GNU
127 General Public License, version 2 or later.
131 Adam D. Barratt <adam@adam-barratt.org.uk>
137 use Getopt
::Long
qw(:config gnu_getopt);
140 use Fcntl
'O_RDONLY';
143 sub parse_copyright
($);
145 sub remove_comments
($);
147 my $progname = basename
($0);
150 my $default_ignore_regex = '
151 # Ignore general backup files
153 # Ignore emacs recovery files
155 # Ignore vi swap files
157 # Ignore baz-style junk files or directories
158 (?:^|/),,.*(?:$|/.*$)|
159 # File-names that should be ignored (never directories)
160 (?:^|/)(?:DEADJOE|\.cvsignore|\.arch-inventory|\.bzrignore|\.gitignore)$|
161 # File or directory names that should be ignored
162 (?:^|/)(?:CVS|RCS|\.deps|\{arch\}|\.arch-ids|\.svn|\.hg|_darcs|\.git|
163 \.shelf|_MTN|\.bzr(?:\.backup|tags)?)(?:$|/.*$)
166 # Take out comments and newlines
167 $default_ignore_regex =~ s/^#.*$//mg;
168 $default_ignore_regex =~ s/\n//sg;
170 my $default_check_regex = '\.(c(c|pp|xx)?|h(h|pp|xx)?|f(77|90)?|p(l|m)|xs|sh|php|py(|x)|rb|java|vala|el|sc(i|e)|cs|pas|inc|dtd|xsl|mod|m|tex|mli?)$';
172 my $modified_conf_msg;
174 my ($opt_verbose, $opt_lines, $opt_noconf) = ('', '', '');
175 my $opt_ignore_regex = $default_ignore_regex;
176 my $opt_check_regex = $default_check_regex;
177 my $opt_recursive = 0;
178 my $opt_copyright = 0;
180 my ($opt_help, $opt_version);
183 # Read configuration files and then command line
184 # This is boilerplate
186 if (@ARGV and $ARGV[0] =~ /^--no-?conf$/) {
187 $modified_conf_msg = " (no configuration files read)";
190 my @config_files = ('/etc/devscripts.conf', '~/.devscripts');
192 'LICENSECHECK_VERBOSE' => 'no',
193 'LICENSECHECK_PARSELINES' => $def_lines,
195 my %config_default = %config_vars;
199 foreach my $var (keys %config_vars) {
200 $shell_cmd .= qq[$var="$config_vars{$var}";\n];
202 $shell_cmd .= 'for file in ' . join(" ", @config_files) . "; do\n";
203 $shell_cmd .= '[ -f $file ] && . $file; done;' . "\n";
205 foreach my $var (keys %config_vars) { $shell_cmd .= "echo \$$var;\n" }
206 my $shell_out = `/bin/bash -c '$shell_cmd'`;
207 @config_vars{keys %config_vars} = split /\n/, $shell_out, -1;
210 $config_vars{'LICENSECHECK_VERBOSE'} =~ /^(yes|no)$/
211 or $config_vars{'LICENSECHECK_VERBOSE'} = 'no';
212 $config_vars{'LICENSECHECK_PARSELINES'} =~ /^[1-9][0-9]*$/
213 or $config_vars{'LICENSECHECK_PARSELINES'} = $def_lines;
215 foreach my $var (sort keys %config_vars) {
216 if ($config_vars{$var} ne $config_default{$var}) {
217 $modified_conf_msg .= " $var=$config_vars{$var}\n";
220 $modified_conf_msg ||= " (none)\n";
221 chomp $modified_conf_msg;
223 $opt_verbose = $config_vars{'LICENSECHECK_VERBOSE'} eq 'yes' ?
1 : 0;
224 $opt_lines = $config_vars{'LICENSECHECK_PARSELINES'};
227 GetOptions
("help|h" => \
$opt_help,
228 "version|v" => \
$opt_version,
229 "verbose!" => \
$opt_verbose,
230 "lines|l=i" => \
$opt_lines,
231 "ignore|i=s" => \
$opt_ignore_regex,
232 "recursive|r" => \
$opt_recursive,
233 "check|c=s" => \
$opt_check_regex,
234 "copyright" => \
$opt_copyright,
235 "machine|m" => \
$opt_machine,
236 "noconf" => \
$opt_noconf,
237 "no-conf" => \
$opt_noconf,
239 or die "Usage: $progname [options] filelist\nRun $progname --help for more details\n";
241 $opt_lines = $def_lines if $opt_lines !~ /^[1-9][0-9]*$/;
244 fatal
"--no-conf is only acceptable as the first command-line option!";
246 if ($opt_help) { help
(); exit 0; }
247 if ($opt_version) { version
(); exit 0; }
249 die "Usage: $progname [options] filelist\nRun $progname --help for more details\n" unless @ARGV;
251 $opt_lines = $def_lines if not defined $opt_lines;
255 my $files_count = @ARGV;
257 push @find_args, qw(-not ( -path */LayoutTests/* -prune ) );
258 push @find_args, qw(-not ( -path */out/Debug/* -prune ) );
259 push @find_args, qw(-not ( -path */out/Release/* -prune ) );
260 push @find_args, qw(-not ( -path .git* -prune ) );
261 push @find_args, qw(-not ( -path .svn* -prune ) );
263 push @find_args, qw(-maxdepth 1) unless $opt_recursive;
264 push @find_args, qw(-follow -type f -print);
267 my $file = shift @ARGV;
270 open FIND
, '-|', 'find', $file, @find_args
271 or die "$progname: couldn't exec find: $!\n";
275 next unless m
%$opt_check_regex%;
278 push @files, $_ unless m
%$opt_ignore_regex%;
282 next unless ($files_count == 1) or $file =~ m
%$opt_check_regex%;
283 push @files, $file unless $file =~ m
%$opt_ignore_regex%;
288 my $file = shift @files;
295 open (F
, "<$file") or die "Unable to access $file\n";
297 last if ($. > $opt_lines);
302 $copyright = join(" / ", values %copyrights);
304 print qq(----- $file header
-----\n$header----- end header
-----\n\n)
307 remove_comments
($header);
308 $license = parselicense
($header);
310 # If no license in header, check footer (slow, because read file backwards)
311 # Need for instance for Perl files, which often use the footer
312 if ($license eq "UNKNOWN") {
314 tie
(my @file_lines, "Tie::File", $file, autochomp
=> 0, mode
=> O_RDONLY
) or die("Unable to access $file\n");
315 # Avoid indexing error if header is entire file
316 if ($#file_lines >= $opt_lines) {
317 foreach (@file_lines[-$opt_lines .. -1]) {
321 print qq(----- $file footer
-----\n$header----- end footer
-----\n\n)
323 remove_comments
($footer);
324 $license = parselicense
($footer);
328 print "$file\t$license";
329 print "\t" . ($copyright or "*No copyright*") if $opt_copyright;
333 print "*No copyright* " unless $copyright;
334 print $license . "\n";
335 print " [Copyright: " . $copyright . "]\n"
336 if $copyright and $opt_copyright;
337 print "\n" if $opt_copyright;
341 sub remove_comments
($) {
343 # Remove Fortran comments
346 # Remove C / C++ comments
348 tr
% A
-Za
-z
.,@
;0-9\
(\
)/-%%cd;
353 sub parse_copyright
($) {
357 my $copyright_indicator_regex = '
358 (?:copyright # The full word
359 |copr\. # Legally-valid abbreviation
360 |\x{00a9} # Unicode character COPYRIGHT SIGN
361 |\xc2\xa9 # Unicode copyright sign encoded in iso8859
362 |\(c\) # Legally-null representation of sign
364 my $copyright_disindicator_regex = '
365 \b(?:info(?:rmation)? # Discussing copyright information
366 |notice # Discussing the notice
367 |and|or # Part of a sentence
370 if (m
%$copyright_indicator_regex(?
::\s
*|\s
+)(\S
.*)$%ix) {
373 # Ignore lines matching "see foo for copyright information" etc.
374 if ($match !~ m
%^\s
*$copyright_disindicator_regex%ix) {
376 $match =~ s/([,.])?\s*$//;
377 $match =~ s/$copyright_indicator_regex//igx;
379 $match =~ s/\s{2,}/ /g;
390 Usage: $progname [options] filename [filename ...]
392 --help, -h Display this message
393 --version, -v Display version and copyright info
394 --no-conf, --noconf Don't read devscripts config files; must be
395 the first option given
396 --verbose Display the header of each file before its
398 --lines, -l Specify how many lines of the file header
399 should be parsed for license information
400 (Default: $def_lines)
401 --check, -c Specify a pattern indicating which files should
403 (Default: '$default_check_regex')
404 --machine, -m Display in a machine readable way (good for awk)
405 --recursive, -r Add the contents of directories recursively
406 --copyright Also display the file's copyright
407 --ignore, -i Specify that files / directories matching the
408 regular expression should be ignored when
410 (Default: '$default_ignore_regex')
412 Default settings modified by devscripts configuration files:
419 This is $progname, from the Debian devscripts package, version ###VERSION###
420 Copyright (C) 2007, 2008 by Adam D. Barratt <adam\@adam-barratt.org.uk>; based
421 on a script of the same name from the KDE SDK by <dfaure\@kde.org>.
423 This program comes with ABSOLUTELY NO WARRANTY.
424 You are free to redistribute this code under the terms of the
425 GNU General Public License, version 2, or (at your option) any
430 sub parselicense
($) {
431 my ($licensetext) = @_;
438 if ($licensetext =~ /version ([^, ]+?)[.,]? (?:\(?only\)?.? )?(?:of the GNU (Affero )?General Public License )?(as )?published by the Free Software Foundation/i or
439 $licensetext =~ /GNU (?:Affero )?General Public License (?:as )?published by the Free Software Foundation; version ([^, ]+?)[.,]? /i or
440 $licensetext =~ /GNU (?:Affero )?General Public License,? [Vv]ersion (\d+(?:\.\d+)?)[ \.]/) {
442 } elsif ($licensetext =~ /either version ([^ ]+)(?: of the License)?, or \(at your option\) any later version/) {
443 $gplver = " (v$1 or later)";
446 if ($licensetext =~ /version ([^, ]+?)[.,]? (?:or later|or any later version) (?:of the GNU (?:Lesser |Library )General Public License )(as )?published by the Free Software Foundation/i or
447 $licensetext =~ /(?:GNU (?:Lesser |Library )|(?:Lesser|Library) GNU )General Public License (?:(?:as )?published by the Free Software Foundation;)?,? (?:either )?[Vv]ersion ([^, ]+?)(?: of the license)?[.,]? (?:or later|or (?:\(at your option\) )?any later version)/i or
448 $licensetext =~ /GNU (?:Lesser |Library )General Public License(?: \(LGPL\))?,? [Vv]ersion (\d+(?:\.\d+)?)[ \.]/) {
449 $lgplver = " (v$1 or later)";
452 if ($licensetext =~ /permission (?:is (also granted|given))? to link (the code of )?this program with (any edition of )?(Qt|the Qt library)/i) {
453 $extrainfo = " (with Qt exception)$extrainfo"
456 if ($licensetext =~ /(All changes made in this file will be lost|DO NOT (EDIT|delete this file)|Generated (automatically|by|from)|generated.*file)/i) {
457 $license = "GENERATED FILE";
460 if ($licensetext =~ /is (free software.? you can redistribute it and\/or modify it
|licensed
) under the terms of
(version
[^ ]+ of
)?the
(GNU
(Library
|Lesser
)General Public License
|LGPL
)/i
or
461 $licensetext =~ /(is distributed|may be used|can redistribute).*terms.*(LGPL|(Lesser|Library) GNU General Public License)/) {
463 $license = "LGPL$lgplver$extrainfo $license";
465 $license = "LGPL (unversioned/unknown version) $license";
469 if ($licensetext =~ /is free software.? you (can|may) redistribute it and\/or modify it under the terms of
(?
:version
[^ ]+ (?
:\
(?only\
)?
)?of
)?the GNU General Public License
/i
) {
470 $license = "GPL$gplver$extrainfo $license";
471 } elsif ($licensetext =~ /is distributed under the terms of the GNU General Public License,/
473 $license = "GPL$gplver$extrainfo $license";
474 } elsif ($licensetext =~ /is distributed.*terms.*[^L]GPL/) {
476 $license = "GPL$gplver$extrainfo $license";
478 $license = "GPL (unversioned/unknown version) $license";
482 if ($licensetext =~ /This file is part of the .*Qt GUI Toolkit. This file may be distributed under the terms of the Q Public License as defined/) {
483 $license = "QPL (part of Qt) $license";
484 } elsif ($licensetext =~ /may be distributed under the terms of the Q Public License as defined/) {
485 $license = "QPL $license";
488 if ($licensetext =~ /opensource\.org\/licenses\
/mit/) {
489 $license = "MIT/X11 (BSD like) $license";
490 } elsif ($licensetext =~ /Permission is hereby granted, free of charge, to any person obtaining a copy of this software and(\/or
)? associated documentation files \
(the
(Software
|Materials
)\
), to deal
in the
(Software
|Materials
)/) {
491 $license = "MIT/X11 (BSD like) $license";
492 } elsif ($licensetext =~ /Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose/) {
493 $license = "MIT/X11 (BSD like) $license";
494 } elsif ($licensetext =~ /Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee/) {
495 $license = "MIT/X11 (BSD like) $license";
496 } elsif ($licensetext =~ /MIT .* License/) {
497 $license = "MIT/X11 (BSD like) $license";
500 if ($licensetext =~ /This file is part of the Independent JPEG Group(')?s software.*For conditions of distribution and use, see the accompanying README file/i) {
501 $license = "Independent JPEG Group License $license";
504 if ($licensetext =~ /the University of Illinois Open Source License/){
505 $license = "University of Illinois/NCSA Open Source License (BSD like) $license";
508 if ($licensetext =~ /Permission to use, copy, modify, and(\/or
)? distribute this software
(and its documentation
)?
for any purpose
(with
or )?without fee is hereby granted
, provided
.*(copyright
|entire
) notice
.*all copies
/i
) {
509 $license = "ISC $license";
512 if ($licensetext =~ /THIS SOFTWARE IS PROVIDED .*AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY/ ||
513 $licensetext =~ /THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- ITY/) {
514 if ($licensetext =~ /All advertising materials mentioning features or use of this software must display the following/) {
515 $license = "BSD (4 clause) $license";
516 } elsif ($licensetext =~ /be used to endorse or promote products derived from this software/) {
517 $license = "BSD (3 clause) $license";
518 } elsif ($licensetext =~ /Redistributions of source code must retain the above copyright notice/) {
519 $license = "BSD (2 clause) $license";
521 $license = "BSD $license";
523 } elsif ($licensetext =~ /Use of this source code is governed by a BSD-style license/) {
524 $license = "BSD-like $license";
525 } elsif ($licensetext =~ /BSD terms apply/) {
526 $license = "BSD-like $license";
527 } elsif ($licensetext =~ /subject to the BSD License/) {
528 # TODO(sbc): remove this case once we fix: http://crbug.com/177268
529 $license = "BSD-like $license";
530 } elsif ($licensetext =~ /license BSD/) {
531 $license = "BSD-like $license";
532 } elsif ($licensetext =~ /GOVERNED BY A BSD-STYLE SOURCE LICENSE/) {
533 $license = "BSD-like $license";
534 } elsif ($licensetext =~ /BSD 3-Clause license/) {
535 $license = "BSD (3 clause) $license";
538 if ($licensetext =~ /Mozilla Public License( Version|, v.) ([^ ]+[^., ]),?/) {
539 $license = "MPL (v$2) $license";
542 if ($licensetext =~ /Released under the terms of the Artistic License ([^ ]+)/) {
543 $license = "Artistic (v$1) $license";
546 if ($licensetext =~ /is free software under the Artistic [Ll]icense/) {
547 $license = "Artistic $license";
550 if ($licensetext =~ /This (program|library) is free software; you can redistribute it and\/or modify it under the same terms as Perl itself
/) {
551 $license = "Perl $license";
554 if ($licensetext =~ /under the terms of the Apache ([^ ]+) License OR version 2 of the GNU/) {
555 $license = "Apache (v$1) GPL (v2) $license";
556 } elsif ($licensetext =~ /under the Apache License, Version ([^ ]+)/) {
557 $license = "Apache (v$1) $license";
560 if ($licensetext =~ /(THE BEER-WARE LICENSE)/i) {
561 $license = "Beerware $license";
564 if ($licensetext =~ /This source file is subject to version ([^ ]+) of the PHP license/) {
565 $license = "PHP (v$1) $license";
568 if ($licensetext =~ /under the terms of the CeCILL /) {
569 $license = "CeCILL $license";
572 if ($licensetext =~ /under the terms of the CeCILL-([^ ]+) /) {
573 $license = "CeCILL-$1 $license";
576 if ($licensetext =~ /under the SGI Free Software (B License|License B)/) {
577 $license = "SGI Free Software License B $license";
580 if ($licensetext =~ /(in|into) the public domain/i) {
581 $license = "Public domain $license";
584 if ($licensetext =~ /terms of the Common Development and Distribution License(, Version ([^(]+))? \(the License\)/) {
585 $license = "CDDL " . ($1 ?
"(v$2) " : '') . $license;
588 if ($licensetext =~ /Microsoft Permissive License \(Ms-PL\)/) {
589 $license = "Ms-PL $license";
592 if ($licensetext =~ /as defined in and that are subject to the Apple Public Source License([ ,-]+Version ([^ ]+)?(\.))/) {
593 $license = "APSL " . ($1 ?
"(v$2) " : '') . $license;
594 } elsif ($licensetext =~ /provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software/) {
595 # https://fedoraproject.org/wiki/Licensing/Apple_MIT_License
596 $license = "Apple MIT $license";
599 if ($licensetext =~ /Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license \([\"]?the Software[\"]?\)/ or
600 $licensetext =~ /Boost Software License([ ,-]+Version ([^ ]+)?(\.))/i) {
601 $license = "BSL " . ($1 ?
"(v$2) " : '') . $license;
604 if ($licensetext =~ /PYTHON SOFTWARE FOUNDATION LICENSE (VERSION ([^ ]+))/i) {
605 $license = "PSF " . ($1 ?
"(v$2) " : '') . $license;
608 if ($licensetext =~ /The origin of this software must not be misrepresented.*Altered source versions must be plainly marked as such.*This notice may not be removed or altered from any source distribution/ or
609 $licensetext =~ /see copyright notice in zlib\.h/) {
610 $license = "zlib/libpng $license";
611 } elsif ($licensetext =~ /This code is released under the libpng license/) {
612 $license = "libpng $license";
615 if ($licensetext =~ /under MIT license/) {
616 $license = "MIT/X11 (BSD like) $license";
619 if ($licensetext =~ /License MIT(-| )License/) {
620 $license = "MIT/X11 (BSD like) $license";
623 if ($licensetext =~ /As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice/) {
624 $license = $license . "with Bison parser exception";
627 if ($licensetext =~ /As a special exception to the GNU General Public License, if you distribute this file as part of a program or library that is built using GNU Libtool, you may include this file under the same distribution terms that you use for the rest of that program/) {
628 $license = $license . "with libtool exception";
631 if ($licensetext =~ /These materials are protected by copyright laws and contain material proprietary to the Khronos Group, Inc\. You may use these materials for implementing Khronos specifications, without altering or removing any trademark, copyright or other notice from the specification/) {
632 $license = $license . "Khronos Group";
635 if ($licensetext =~ /This file is part of the FreeType project, and may only be used(,)? modified(,)? and distributed under the terms of the FreeType project license, LICENSE\.TXT\. By continuing to use, modify, or distribute this file you indicate that you have read the license and understand and accept it fully/) {
636 $license = "FreeType (BSD like) $license";
638 if ($licensetext =~ /This software, and all works of authorship, whether in source or object code form as indicated by the copyright notice.*is made available, and may only be used, modified, and distributed under the FreeType Project License, LICENSE\.TXT\. Additionally, subject to the terms and conditions of the FreeType Project License, each contributor to the Work hereby grants to any individual or legal entity exercising permissions granted by the FreeType Project License and this section.*a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable.*patent license to make/) {
639 $license = "FreeType (BSD like) with patent clause $license";
642 if ($licensetext =~ /Anti-Grain Geometry.*Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears in all copies. This software is provided as is without express or impl/) {
643 $license = "Anti-Grain Geometry $license";
646 if ($licensetext =~ /Developed at SunSoft, a Sun Microsystems, Inc\. business\. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved\./) {
647 $license = "SunSoft (BSD like) $license";
650 $license = "UNKNOWN" unless $license;
652 # Remove trailing spaces.
653 $license =~ s/\s+$//;
659 my ($pack,$file,$line);
660 ($pack,$file,$line) = caller();
661 (my $msg = "$progname: fatal error at line $line:\n@_\n") =~ tr/\0//d;