#!/usr/bin/perl -w
use strict;
if (@ARGV < 2) {
print STDERR "Usage: $0 <config1> <config2>\n";
print STDERR "Merge kernel config files config1 and config2. " .
"Differences will be selected from config2.\n";
exit 1;
}
my %config;
my @lines;
open CONFIG1, $ARGV[0]
or die $ARGV[0] . ": $!\n";
while (<CONFIG1>) {
push(@lines, $_);
next unless /^(CONFIG_[A-Za-z0-9_]+)/ || /^# (CONFIG_[A-Za-z0-9_]+) is not set/;
$config{$1} = $_;
}
close(CONFIG1);
open CONFIG2, $ARGV[1]
or die $ARGV[1] . ": $!\n";
while (<CONFIG2>) {
next unless /^(CONFIG_[A-Za-z0-9_]+)/ || /^# (CONFIG_[A-Za-z0-9_]+) is not set/;
$config{$1} = $_;
}
close(CONFIG2);
foreach (@lines) {
if (/^(CONFIG_[A-Za-z0-9_]+)/ || /^# (CONFIG_[A-Za-z0-9_]+) is not set/) {
if (exists($config{$1})) {
print $config{$1};
delete $config{$1};
}
} else {
print;
}
}
foreach my $value (sort(values(%config))) {
print $value;
}