diff options
author | Michael Brown <mcb30@ipxe.org> | 2010-05-29 23:06:06 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2010-05-29 23:49:47 +0100 |
commit | 03b1020acc76047294d7b38abab3207426147dd8 (patch) | |
tree | 1c34ba0f1e47cb72cfa77c40ebe7e2a46125140a /src/include/ipxe/efi/import.pl | |
parent | ae5ce45afe845d58a4c5f46e933e044646b62f36 (diff) | |
download | ipxe-03b1020acc76047294d7b38abab3207426147dd8.zip ipxe-03b1020acc76047294d7b38abab3207426147dd8.tar.gz ipxe-03b1020acc76047294d7b38abab3207426147dd8.tar.bz2 |
[legal] Add FILE_LICENCE declarations to EFI header files
Autodetect the BSD licence statement in EFI header files, and add a
suitable FILE_LICENCE macro to the version imported into the iPXE
tree.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/efi/import.pl')
-rwxr-xr-x | src/include/ipxe/efi/import.pl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/include/ipxe/efi/import.pl b/src/include/ipxe/efi/import.pl index 4ea5175..629624c 100755 --- a/src/include/ipxe/efi/import.pl +++ b/src/include/ipxe/efi/import.pl @@ -16,6 +16,7 @@ sub try_import_file { return unless $filename =~ /\.h$/; print "$filename..."; + ( undef, undef, my $basename ) = splitpath ( $filename ); my $outfile = catfile ( $ipxedir, $filename ); foreach my $edkdir ( @$edkdirs ) { my $infile = catfile ( $edkdir, $filename ); @@ -27,6 +28,8 @@ sub try_import_file { mkpath ( $outdir ); open my $outfh, ">$outfile" or die "Could not open $outfile: $!\n"; my @dependencies = (); + my $licence; + my $guard; while ( <$infh> ) { # Strip CR and trailing whitespace s/\r//g; @@ -36,10 +39,25 @@ sub try_import_file { if ( s/^\#include\s+[<\"](\S+)[>\"]/\#include <ipxe\/efi\/$1>/ ) { push @dependencies, $1; } + # Check for BSD licence statement + if ( /^\s*THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE/ ) { + die "Licence detected after header guard\n" if $guard; + $licence = "BSD3"; + } + # Write out line print $outfh "$_\n"; + # Apply FILE_LICENCE() immediately after include guard + if ( /^\#define\s+_?_\S+_H_?_$/ ) { + die "Duplicate header guard detected in $infile\n" if $guard; + $guard = 1; + print $outfh "\nFILE_LICENCE ( $licence );\n" if $licence; + } } close $outfh; close $infh; + # Warn if no licence was detected + warn "Cannot detect licence in $infile\n" unless $licence; + warn "Cannot detect header guard in $infile\n" unless $guard; # Recurse to handle any included files that we don't already have foreach my $dependency ( @dependencies ) { if ( ! -e catfile ( $ipxedir, $dependency ) ) { |