Blame view
scripts/headers_install.pl
1.92 KB
15a2ee74d Fix incompatibili... |
1 |
#!/usr/bin/perl -w |
7712401ae kbuild: optimize ... |
2 3 4 5 |
# # headers_install prepare the listed header files for use in # user space and copy the files to their destination. # |
db1bec4f5 kbuild: install a... |
6 |
# Usage: headers_install.pl readdir installdir arch [files...] |
10b63956f UAPI: Plumb the U... |
7 |
# installdir: dir to install the files to |
db1bec4f5 kbuild: install a... |
8 9 10 11 |
# arch: current architecture # arch is used to force a reinstallation when the arch # changes because kbuild then detect a command line change. # files: list of files to check |
7712401ae kbuild: optimize ... |
12 13 14 15 16 17 18 |
# # Step in preparation for users space: # 1) Drop all use of compiler.h definitions # 2) Drop include of compiler.h # 3) Drop all sections defined out by __KERNEL__ (using unifdef) use strict; |
7712401ae kbuild: optimize ... |
19 |
|
10b63956f UAPI: Plumb the U... |
20 |
my ($installdir, $arch, @files) = @ARGV; |
7712401ae kbuild: optimize ... |
21 |
|
c01226c31 warn about use of... |
22 |
my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__"; |
7712401ae kbuild: optimize ... |
23 |
|
10b63956f UAPI: Plumb the U... |
24 25 26 |
foreach my $filename (@files) { my $file = $filename; $file =~ s!^.*/!!; |
7712401ae kbuild: optimize ... |
27 |
my $tmpfile = "$installdir/$file.tmp"; |
bae4cecc0 headers_install: ... |
28 |
|
10b63956f UAPI: Plumb the U... |
29 30 31 |
open(my $in, '<', $filename) or die "$filename: $! "; |
bae4cecc0 headers_install: ... |
32 33 34 35 |
open(my $out, '>', $tmpfile) or die "$tmpfile: $! "; while (my $line = <$in>) { |
7712401ae kbuild: optimize ... |
36 37 38 39 40 |
$line =~ s/([\s(])__user\s/$1/g; $line =~ s/([\s(])__force\s/$1/g; $line =~ s/([\s(])__iomem\s/$1/g; $line =~ s/\s__attribute_const__\s/ /g; $line =~ s/\s__attribute_const__$//g; |
f210735fe headers_install: ... |
41 |
$line =~ s/\b__packed\b/__attribute__((packed))/g; |
7712401ae kbuild: optimize ... |
42 |
$line =~ s/^#include <linux\/compiler.h>//; |
4307184f2 kbuild: in header... |
43 44 45 |
$line =~ s/(^|\s)(inline)\b/$1__$2__/g; $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; |
8a7eab2b5 UAPI: Strip _UAPI... |
46 47 48 |
$line =~ s/#ifndef\s+_UAPI/#ifndef /; $line =~ s/#define\s+_UAPI/#define /; $line =~ s!#endif\s+/[*]\s*_UAPI!#endif /* !; |
bae4cecc0 headers_install: ... |
49 |
printf {$out} "%s", $line; |
7712401ae kbuild: optimize ... |
50 |
} |
bae4cecc0 headers_install: ... |
51 52 |
close $out; close $in; |
7712401ae kbuild: optimize ... |
53 |
system $unifdef . " $tmpfile > $installdir/$file"; |
2979076fb headers_install: ... |
54 55 56 57 58 59 60 61 |
# unifdef will exit 0 on success, and will exit 1 when the # file was processed successfully but no changes were made, # so abort only when it's higher than that. my $e = $? >> 8; if ($e > 1) { die "$tmpfile: $! "; } |
7712401ae kbuild: optimize ... |
62 63 64 |
unlink $tmpfile; } exit 0; |