From 7091127e318c1b5c244b7ae3cbd0edf8966c14f0 Mon Sep 17 00:00:00 2001 From: Daniel Hermann Date: Thu, 3 Apr 2014 09:58:26 +0200 Subject: [PATCH] gen_config: respect dependencies (fixes out-of-tree builds) --- scripts/gen_config.pl | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/scripts/gen_config.pl b/scripts/gen_config.pl index 993ce90c..465ff37b 100755 --- a/scripts/gen_config.pl +++ b/scripts/gen_config.pl @@ -15,6 +15,8 @@ my $DEBUG = 0; my $option; my $type; +my $depends; +my $value; my @default; my %setByEnv; @@ -23,18 +25,30 @@ while (my $line = ) { $option = $1; $setByEnv{$option} = $ENV{$option} if exists $ENV{$option}; printf STDERR "OPTION: %s\n", $option if $DEBUG; - printf STDERR "ENV: %s='%s'\n", $option, $setByEnv{$option} if $DEBUG && exists $ENV{$option}; + printf STDERR "--> ENV: %s='%s'\n", $option, $setByEnv{$option} if $DEBUG && exists $ENV{$option}; } elsif ($line =~ /^\s+(tristate|bool|int|string)\s+.*$/) { $type = $1; - printf STDERR "TYPE: %s\n", $type if $DEBUG; + printf STDERR "--> TYPE: %s\n", $type if $DEBUG; + } + elsif ($line =~/^\s+depends\s+on\s+(.*)$/) { + $depends = ($option ne 'MARS') ? $1 : ''; + printf STDERR "--> DEPENDS: %s\n", $depends if $DEBUG; } elsif ($line =~ /^\s+default\s+(.*)$/) { - printf STDERR "DEFAULT: %s\n", $1 if $DEBUG; + if ($option eq 'MARS') { + $value = 'y'; + printf STDERR "--> DEFAULT: y (OVERRIDDEN by script)\n" if $DEBUG; + } + else { + $value = $1; + printf STDERR "--> DEFAULT: %s\n", $value if $DEBUG; + } push @default, { option => $option, type => $type, - value => $1, + depends => $depends, + value => $value, } if $option; } elsif ($line =~ /^\s+---help---\s+$/) { @@ -45,7 +59,7 @@ while (my $line = ) { } } -print STDERR Dumper(\@default) if $DEBUG; +print STDERR Dumper(\@default) if $DEBUG >= 2; ## @@ -94,6 +108,16 @@ foreach my $opt (@default) { next; } + if ($opt->{depends}) { + my @deps = grep { $_->{option} eq $opt->{depends} } @default; + if (scalar @deps && $deps[0]->{value} eq 'n') { + print qq% +/* CONFIG_$optname is unset (depends on $deps[0]->{option}, which is unset) */ +%; + next; + } + } + given ($opt->{type}) { when ('tristate') {