From 7712401ae9006fc9d9b9a3e7861dc73781429a89 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 15 Jun 2008 21:41:09 +0200 Subject: 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 Signed-off-by: Sam Ravnborg --- scripts/headers_install.pl | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 scripts/headers_install.pl (limited to 'scripts/headers_install.pl') diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl new file mode 100644 index 00000000000..f0ff9a35acd --- /dev/null +++ b/scripts/headers_install.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl +# +# headers_install prepare the listed header files for use in +# user space and copy the files to their destination. +# +# Usage: headers_install.pl odir installdir [files...] +# odir: dir to open files +# install: dir to install the files +# files: list of files to check +# +# 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; +use warnings; + +my ($readdir, $installdir, @files) = @ARGV; + +my $unifdef = "scripts/unifdef -U__KERNEL__"; + +foreach my $file (@files) { + my $tmpfile = "$installdir/$file.tmp"; + open(my $infile, '<', "$readdir/$file") + or die "$readdir/$file: $!\n"; + open(my $outfile, '>', "$tmpfile") or die "$tmpfile: $!\n"; + while (my $line = <$infile>) { + $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; + $line =~ s/^#include //; + printf $outfile "%s", $line; + } + close $outfile; + close $infile; + system $unifdef . " $tmpfile > $installdir/$file"; + unlink $tmpfile; +} +exit 0; -- cgit v1.2.3 From db1bec4f5271d7799d481cd4d95fdc268bdd7614 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 16 Jun 2008 21:29:38 +0200 Subject: kbuild: install all headers when arch is changed We see some header files that are selected dependent on the actual architecture so force a reinstallation of all header files when the arch changes. This slows down "make headers_check_all" but then we better reflect reality. Signed-off-by: Sam Ravnborg --- scripts/headers_install.pl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'scripts/headers_install.pl') diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl index f0ff9a35acd..68591cd0873 100644 --- a/scripts/headers_install.pl +++ b/scripts/headers_install.pl @@ -3,10 +3,13 @@ # headers_install prepare the listed header files for use in # user space and copy the files to their destination. # -# Usage: headers_install.pl odir installdir [files...] -# odir: dir to open files -# install: dir to install the files -# files: list of files to check +# Usage: headers_install.pl readdir installdir arch [files...] +# readdir: dir to open files +# installdir: dir to install the files +# 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 # # Step in preparation for users space: # 1) Drop all use of compiler.h definitions @@ -16,7 +19,7 @@ use strict; use warnings; -my ($readdir, $installdir, @files) = @ARGV; +my ($readdir, $installdir, $arch, @files) = @ARGV; my $unifdef = "scripts/unifdef -U__KERNEL__"; -- cgit v1.2.3