aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/headers_install.pl
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2008-06-15 15:41:09 -0400
committerSam Ravnborg <sam@ravnborg.org>2008-07-25 16:12:16 -0400
commit7712401ae9006fc9d9b9a3e7861dc73781429a89 (patch)
treecb0989cc5a1db8b7e4f490eef8e33225a2e40e93 /scripts/headers_install.pl
parent88181ec30f58a28cd78b26aaac38bef4062b23dc (diff)
kbuild: optimize headers_* targets
Move the core functionality of headers_install and headers_check to two small perl scripts. The makefile is adapted to use the perl scrip and changed to operate on all files in a directory. So if one file is changed then all files in the directory is processed. perl were chosen for the helper scripts because this is pure text processing which perl is good at and especially the headers_check.pl script are expected to see changes / new checks implmented. The speed is ~300% faster on this box. And the output generated to the screen is now down to two lines per directory (one for install, one for check) so it is easier to scroll back after a kernel build. The perl scripts has been brought to sanity by patient feedback from: Vegard Nossum <vegard.nossum@gmail.com> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/headers_install.pl')
-rw-r--r--scripts/headers_install.pl42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
new file mode 100644
index 000000000000..f0ff9a35acd0
--- /dev/null
+++ b/scripts/headers_install.pl
@@ -0,0 +1,42 @@
1#!/usr/bin/perl
2#
3# headers_install prepare the listed header files for use in
4# user space and copy the files to their destination.
5#
6# Usage: headers_install.pl odir installdir [files...]
7# odir: dir to open files
8# install: dir to install the files
9# files: list of files to check
10#
11# Step in preparation for users space:
12# 1) Drop all use of compiler.h definitions
13# 2) Drop include of compiler.h
14# 3) Drop all sections defined out by __KERNEL__ (using unifdef)
15
16use strict;
17use warnings;
18
19my ($readdir, $installdir, @files) = @ARGV;
20
21my $unifdef = "scripts/unifdef -U__KERNEL__";
22
23foreach my $file (@files) {
24 my $tmpfile = "$installdir/$file.tmp";
25 open(my $infile, '<', "$readdir/$file")
26 or die "$readdir/$file: $!\n";
27 open(my $outfile, '>', "$tmpfile") or die "$tmpfile: $!\n";
28 while (my $line = <$infile>) {
29 $line =~ s/([\s(])__user\s/$1/g;
30 $line =~ s/([\s(])__force\s/$1/g;
31 $line =~ s/([\s(])__iomem\s/$1/g;
32 $line =~ s/\s__attribute_const__\s/ /g;
33 $line =~ s/\s__attribute_const__$//g;
34 $line =~ s/^#include <linux\/compiler.h>//;
35 printf $outfile "%s", $line;
36 }
37 close $outfile;
38 close $infile;
39 system $unifdef . " $tmpfile > $installdir/$file";
40 unlink $tmpfile;
41}
42exit 0;