From 02e41418e9e050031f77b1a2458cdc665a737019 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 17 Jul 2008 19:18:52 -0300 Subject: Improve make_config.pl script From: Mauro Carvalho Chehab This patch adds the capability of processing some tags that contains "if", like: menuconfig foo if bar boolean foo if bar tristate foo if bar default foo if bar Signed-off-by: Mauro Carvalho Chehab --- v4l/scripts/make_kconfig.pl | 47 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'v4l') diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl index b553a8a06..ee649f574 100755 --- a/v4l/scripts/make_kconfig.pl +++ b/v4l/scripts/make_kconfig.pl @@ -276,6 +276,7 @@ sub open_kconfig($$) { my $disabled = 0; my $in_help = 0; my $default_seen = 0; + my $if; print "Opening $file\n" if $debug; open $in, '<', $file or die "File not found: $file"; @@ -314,6 +315,7 @@ sub open_kconfig($$) { $disabled = 0; $default_seen = 0; $key = undef; + $if = ""; } next if (/^\s*#/ || /^\s*$/); # skip comments and blank lines @@ -327,6 +329,7 @@ sub open_kconfig($$) { my $nothandled = 0; if (m|^\s*(?:menu)?config (\w+)\s*$|) { $key = $1; + $if = ""; print "Found config '$key' at $file:$.\n" if $debug; add_config($key); @@ -382,8 +385,24 @@ sub open_kconfig($$) { # config type if(/^\s*bool(ean)?\s/) { add_bool($key); + if (m|if (.*)\s*$|) { + printf("Boolean $key with if '$1'\n") if $debug; + if ($if eq "") { + $if = "($1)"; + } else { + $if .= " && ($1)"; + } + } } elsif (/^\s*tristate\s/) { add_tristate($key); + if (m|if (.*)\s*$|) { + printf("Boolean $key with if '$1'\n") if $debug; + if ($if eq "") { + $if = "($1)"; + } else { + $if .= " && ($1)"; + } + } } elsif (/^\s*int\s/) { add_int($key); } elsif (/^\s*hex\s/) { @@ -400,6 +419,14 @@ sub open_kconfig($$) { # default lines } elsif (m|^\s*default\s+(.+?)(?:\s+if .*)?\s*$|) { my $o = $1; + if ($2 ne "") { + if ($if eq "") { + $if = "($2)"; + } else { + $if .= " && ($2)"; + } + } + # Get default for int options if ($o =~ m|^"(\d+)"$| && exists $intopt{$key}) { set_int_value($key, $1); @@ -412,13 +439,21 @@ sub open_kconfig($$) { # Override default for disabled tri/bool options # We don't care about the default for tri/bool options otherwise - } elsif ($o =~ /^(y|n|m|"yes"|"no")$/i && exists $tristate{$key}) { - if ($disabled) { - $default_seen = 1; - $_ = "\tdefault n\n"; + } elsif (!$o =~ /^(y|n|m|"yes"|"no")$/i && exists $tristate{$key}) { + print "Default is an expression at $file:$. $_\n" if $debug; + if ($if eq "") { + depends($key, "$o"); } - } else { - print "Unknown default at $file:$. $_\n" if $debug; + } + if ($if ne "") { + # FIXME: What happens if no default clause exists? + # the $if won't be handled + depends($key, "$if || $o"); + } + + if ($disabled) { + $default_seen = 1; + $_ = "\tdefault n\n"; } } else { print "Skipping $file:$. $_" if $debug; -- cgit v1.2.3