Blame SOURCES/merge.pl

e8eba4
#! /usr/bin/perl
e8eba4
e8eba4
my @args=@ARGV;
e8eba4
my %configvalues;
e8eba4
my @configoptions;
e8eba4
my $configcounter = 0;
e8eba4
e8eba4
# optionally print out the architecture as the first line of our output
e8eba4
my $arch = $args[2];
e8eba4
if (defined $arch) {
e8eba4
	print "# $arch\n";
e8eba4
}
e8eba4
e8eba4
# first, read the override file
e8eba4
e8eba4
open (FILE,"$args[0]") || die "Could not open $args[0]";
e8eba4
while (<FILE>) {
e8eba4
	my $str = $_;
e8eba4
	my $configname;
e8eba4
e8eba4
	if (/\# ([\w]+) is not set/) {
e8eba4
		$configname = $1;
e8eba4
	} elsif (/^\#/) {
e8eba4
		# fall through on comments like 'avoid CONFIG_FOO=y'
e8eba4
		;
e8eba4
	} elsif (/([\w]+)=/) {
e8eba4
		$configname = $1;
e8eba4
	}
e8eba4
e8eba4
	if (defined($configname) && !exists($configvalues{$configname})) {
e8eba4
		$configvalues{$configname} = $str;
e8eba4
		$configoptions[$configcounter] = $configname;
e8eba4
		$configcounter ++;
e8eba4
	}
e8eba4
};
e8eba4
e8eba4
# now, read and output the entire configfile, except for the overridden
e8eba4
# parts... for those the new value is printed.
e8eba4
e8eba4
open (FILE2,"$args[1]") || die "Could not open $args[1]";
e8eba4
while (<FILE2>) {
e8eba4
	my $configname;
e8eba4
e8eba4
	if (/\# ([\w]+) is not set/) {
e8eba4
		$configname = $1;
e8eba4
	} elsif (/^\#/) {
e8eba4
		# fall through on comments like 'avoid CONFIG_FOO=y'
e8eba4
		;
e8eba4
	} elsif (/([\w]+)=/) {
e8eba4
		$configname  = $1;
e8eba4
	}
e8eba4
e8eba4
	if (defined($configname) && exists($configvalues{$configname})) {
e8eba4
		print "$configvalues{$configname}";
e8eba4
		delete($configvalues{$configname});
e8eba4
	} else {
e8eba4
		print "$_";
e8eba4
	}
e8eba4
}
e8eba4
e8eba4
# now print the new values from the overridden configfile
e8eba4
my $counter = 0;
e8eba4
e8eba4
while ($counter < $configcounter) {
e8eba4
	my $configname = $configoptions[$counter];
e8eba4
	if (exists($configvalues{$configname})) {
e8eba4
		print "$configvalues{$configname}";
e8eba4
	}
e8eba4
	$counter++;
e8eba4
}
e8eba4
e8eba4
1;