Blame view

scripts/headers_install.pl 1.38 KB
15a2ee74d   Jeremy Huntwork   Fix incompatibili...
1
  #!/usr/bin/perl -w
7712401ae   Sam Ravnborg   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   Sam Ravnborg   kbuild: install a...
6
7
8
9
10
11
12
  # 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
7712401ae   Sam Ravnborg   kbuild: optimize ...
13
14
15
16
17
18
19
  #
  # 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   Sam Ravnborg   kbuild: optimize ...
20

db1bec4f5   Sam Ravnborg   kbuild: install a...
21
  my ($readdir, $installdir, $arch, @files) = @ARGV;
7712401ae   Sam Ravnborg   kbuild: optimize ...
22
23
24
25
  
  my $unifdef = "scripts/unifdef -U__KERNEL__";
  
  foreach my $file (@files) {
15a2ee74d   Jeremy Huntwork   Fix incompatibili...
26
27
  	local *INFILE;
  	local *OUTFILE;
7712401ae   Sam Ravnborg   kbuild: optimize ...
28
  	my $tmpfile = "$installdir/$file.tmp";
15a2ee74d   Jeremy Huntwork   Fix incompatibili...
29
  	open(INFILE, "<$readdir/$file")
7712401ae   Sam Ravnborg   kbuild: optimize ...
30
31
  		or die "$readdir/$file: $!
  ";
15a2ee74d   Jeremy Huntwork   Fix incompatibili...
32
33
34
  	open(OUTFILE, ">$tmpfile") or die "$tmpfile: $!
  ";
  	while (my $line = <INFILE>) {
7712401ae   Sam Ravnborg   kbuild: optimize ...
35
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;
  		$line =~ s/^#include <linux\/compiler.h>//;
15a2ee74d   Jeremy Huntwork   Fix incompatibili...
41
  		printf OUTFILE "%s", $line;
7712401ae   Sam Ravnborg   kbuild: optimize ...
42
  	}
15a2ee74d   Jeremy Huntwork   Fix incompatibili...
43
44
  	close OUTFILE;
  	close INFILE;
7712401ae   Sam Ravnborg   kbuild: optimize ...
45
46
47
48
  	system $unifdef . " $tmpfile > $installdir/$file";
  	unlink $tmpfile;
  }
  exit 0;