File ia64-fix-pagesize.pl of Package kvm.import4640
#!/usr/bin/perl
my $bits = 0;
my $kconfig = "/usr/src/linux-obj/ia64/default/.config";
my $kconfig = ".config";
my $header = "qemu/target-ia64/cpu.h";
open( IN, "< $kconfig") || exit( 0);
while ( <IN> ) {
if ( /^CONFIG_IA64_PAGE_SIZE_16KB=y/ ) {
$bits = 14;
} elsif ( /^CONFIG_IA64_PAGE_SIZE_8KB=y/ ) {
$bits = 13;
} elsif ( /^CONFIG_IA64_PAGE_SIZE_4KB=y/ ) {
$bits = 12;
}
}
close( IN);
exit( 0) unless ( $bits );
print "bits=$bits\n";
open( IN, "< $header") || exit( 1);
$O="";
while ( <IN> ) {
s{TARGET_PAGE_BITS \d+}{TARGET_PAGE_BITS $bits};
$O .= $_;
}
close( IN);
rename( $header, $header . ".orig") unless ( -r $header . ".orig" );
open( OUT, "> $header") || exit( 1);
print OUT $O;
close( OUT);