From: Sam Ravnborg <sam@ravnborg.org>
To: linux-kbuild <linux-kbuild@vger.kernel.org>
Subject: perl help needed...
Date: Sun, 8 Jun 2008 09:30:30 +0200 [thread overview]
Message-ID: <20080608073030.GA13796@uranus.ravnborg.org> (raw)
I'm trying to optimize "make headers_install" and need
some perl help...
What I have today:
#!/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 opendir installdir [files...]
# opendir: 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__
my ($opendir, $installdir, @files) = @ARGV;
my $ret = 0;
foreach $file (@files) {
open(INFILE, "< $opendir/$file") or die "$openddir/$file: $!\n";
open(UNIFDEF, "| scripts/unifdef -U__KERNEL__ |");
open(OUTFILE, "> $installdir/$file") or die "$installdir/$file: $!\n";
while ($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 <linux\/compiler.h>//;
# this part is broken:
printf UNIFDEF $line;
$newline = <UNIFDEF>;
printf OUTFILE $newline;
# until here
}
close(OUTFILE);
close(INFILE);
}
exit($ret);
But the bidirectional IO for unifdef does not work.
This is in several places documented to not work - so no
suprise here.
But my googling did not turn up the solution I needed.
What I need to do in the above is to pass the modified
lines through unifdef to remove the __KERNEL__ sections.
I would much rather have this done by the perl script itself
and this looks reasonably simple. But I have not tried that
path yet - wanted to get the simple stuff working first.
Can you improve the above script so it actually passes the
lines through unifdef and correct any other stupid
mistakes of mine I would appreciate it very much!
Note: I have moved the HDRSED functionality from the Makefile.headersinst
file to the perl script.
Sam
reply other threads:[~2008-06-08 7:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080608073030.GA13796@uranus.ravnborg.org \
--to=sam@ravnborg.org \
--cc=linux-kbuild@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox