2008-10-30 05:20:13 +08:00
|
|
|
#!/usr/bin/perl -w
|
2008-06-16 03:41:09 +08:00
|
|
|
#
|
|
|
|
# headers_install prepare the listed header files for use in
|
|
|
|
# user space and copy the files to their destination.
|
|
|
|
#
|
2008-06-17 03:29:38 +08:00
|
|
|
# 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
|
2008-06-16 03:41:09 +08:00
|
|
|
#
|
|
|
|
# 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;
|
|
|
|
|
2008-06-17 03:29:38 +08:00
|
|
|
my ($readdir, $installdir, $arch, @files) = @ARGV;
|
2008-06-16 03:41:09 +08:00
|
|
|
|
|
|
|
my $unifdef = "scripts/unifdef -U__KERNEL__";
|
|
|
|
|
|
|
|
foreach my $file (@files) {
|
2008-10-30 05:20:13 +08:00
|
|
|
local *INFILE;
|
|
|
|
local *OUTFILE;
|
2008-06-16 03:41:09 +08:00
|
|
|
my $tmpfile = "$installdir/$file.tmp";
|
2008-10-30 05:20:13 +08:00
|
|
|
open(INFILE, "<$readdir/$file")
|
2008-06-16 03:41:09 +08:00
|
|
|
or die "$readdir/$file: $!\n";
|
2008-10-30 05:20:13 +08:00
|
|
|
open(OUTFILE, ">$tmpfile") or die "$tmpfile: $!\n";
|
|
|
|
while (my $line = <INFILE>) {
|
2008-06-16 03:41:09 +08:00
|
|
|
$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 <linux\/compiler.h>//;
|
2008-10-30 05:20:13 +08:00
|
|
|
printf OUTFILE "%s", $line;
|
2008-06-16 03:41:09 +08:00
|
|
|
}
|
2008-10-30 05:20:13 +08:00
|
|
|
close OUTFILE;
|
|
|
|
close INFILE;
|
2008-06-16 03:41:09 +08:00
|
|
|
system $unifdef . " $tmpfile > $installdir/$file";
|
|
|
|
unlink $tmpfile;
|
|
|
|
}
|
|
|
|
exit 0;
|