]> bbs.cooldavid.org Git - net-next-2.6.git/blame - scripts/headers_install.pl
kbuild: optimize headers_* targets
[net-next-2.6.git] / scripts / headers_install.pl
CommitLineData
7712401a
SR
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;