diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 8e23faab5d22..28faf8cd0e2a 100755 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -146,7 +146,7 @@ my %objects; my %config2kfile; my %defaults; my $var; -my $iflevel = 0; +my $iflevel = -1; my @ifdeps; # prevent recursion @@ -206,7 +206,7 @@ sub read_kconfig { $config2kfile{"CONFIG_$config"} = $kconfig; # Add depends for 'if' nesting - for (my $i = 0; $i < $iflevel; $i++) { + for (my $i = 0; $i <= $iflevel; $i++) { if ($i) { $depends{$config} .= " " . $ifdeps[$i]; } else { @@ -221,6 +221,10 @@ sub read_kconfig { $depends{$config} = $1; } elsif ($state eq "DEP" && /^\s*depends\s+on\s+(.*)$/) { $depends{$config} .= " " . $1; + } elsif ($state eq "NONE" && /^\s*depends\s+on\s+(.*)$/) { + # "depends on" in the "NONE" state is from a choice block. + # Propagate the dependency to its member config options. + $ifdeps[$iflevel] .= ':' . $ifdeps[$iflevel]; } elsif ($state ne "NONE" && /^\s*def(_(bool|tristate)|ault)\s+(\S.*)$/) { my $dep = $3; $defaults{$config} = 1; @@ -253,11 +258,16 @@ sub read_kconfig { my @deps = split /[^a-zA-Z0-9_]+/, $deps; - $ifdeps[$iflevel++] = join ':', @deps; + $ifdeps[++$iflevel] = join ':', @deps; - } elsif (/^endif/) { + } elsif (/^\s*choice\s*$/) { - $iflevel-- if ($iflevel); + $state = "NONE"; + $ifdeps[++$iflevel] = ''; + + } elsif (/^(endif|endchoice)/) { + + --$iflevel if ($iflevel > -1); # stop on "help" and keywords that end a menu entry } elsif (/^\s*(---)?help(---)?\s*$/ || /^(comment|choice|menu)\b/) {