From 4408f03fed048fabc1d1cbbd2914924b31ed78b5 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Thu, 3 May 2007 11:06:09 -0700 Subject: build: Update build scripts to handle menuconfig/if/endif From: Trent Piepho Update make_myconfig.pl and make_kconfig.pl to handle menuconfig options the same way as config options. Update make_kconfig.pl to process if/endif directives. All config options inside an if/endif block gain a dependency on the 'if' expression. Make the script a little more efficient by not trying to match a line after it has already found a match for it. This helped to enhance debug mode, so that it will print lines which were not understood rather than silently skipping them. Signed-off-by: Trent Piepho --- v4l/scripts/make_kconfig.pl | 93 ++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 31 deletions(-) (limited to 'v4l/scripts/make_kconfig.pl') diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl index 4fc39383f..8ed189aef 100755 --- a/v4l/scripts/make_kconfig.pl +++ b/v4l/scripts/make_kconfig.pl @@ -140,10 +140,8 @@ sub depends($$) my $key = shift; my $deps = shift; - if(!defined $key || $key eq '') { - print "Got bad key with $deps\n"; - return; - } + (!defined $key || $key eq '') and + die "Got bad key with $deps\n"; finddeps($key, $deps); push @{$depends{$key}}, $deps; } @@ -201,6 +199,7 @@ sub checkdeps() my $deps = $depends{$key}; foreach (@$deps) { if (!eval(toperl($_))) { + print "Disabling $key, dependency '$_' not met\n" if $debug; $allconfig{$key} = 0; return 0; } @@ -238,6 +237,9 @@ EOF # output combined Kconfig file. my @kconfigfiles = (); +# "if" statements found in Kconfig files. +my @kifs = (); + # Read and parse a Kconfig file. First argument is base of source # directory tree, the second is the file to open (with path). Recursivly # parses Kconfig files from 'source' directives. @@ -290,6 +292,7 @@ sub open_kconfig($$) { $default_seen = 0; $key = undef; } + next if (/^\s*#/ || /^\s*$/); # skip comments and blank lines if (m|^\s*source\s+"([^"]+)"\s*$| || m|^\s*source\s+(\S+)\s*$|) { @@ -298,8 +301,10 @@ sub open_kconfig($$) { next; } - if (m|^\s*config (\w+)\s*$|) { + my $nothandled = 0; + if (m|^\s*(?:menu)?config (\w+)\s*$|) { $key = $1; + print "Found config '$key' at $file:$.\n" if $debug; add_config($key); if (exists $minver{$key} && @@ -311,42 +316,68 @@ sub open_kconfig($$) { } else { $disabled=0; } + # Add dependencies from enclosing if/endif blocks + depends($key, $_) foreach (@kifs); } elsif (m|^\s*comment\s+"[^"]*"\s*$|) { $key = 'comment'; } elsif (m|^\s*menu\s+"[^"]*"\s*$|) { $key = 'menu'; + } elsif (m|^\s*if\s+(.+?)\s*$|) { + push @kifs, $1; + } elsif (m|^\s*endif\s*(?:#.*)?$|) { + $#kifs >= 0 or die "Unmatched endif at $file:$.\n"; + pop @kifs; + } else { + $nothandled = 1; } + next unless ($nothandled); # Remaining Kconfig directives only makse sense inside Kconfig blocks - next unless(defined $key); + unless(defined $key) { + print "Skipping $file:$. $_" if $debug; + next; + } # Don't process any directives in comment blocks (or menus) next if ($key eq 'comment' || $key eq 'menu'); - add_bool($key) if(/^\s*bool(ean)?\s/); - add_tristate($key) if (/^\s*tristate\s/); - add_int($key) if (/^\s*int\s/); - add_hex($key) if (/^\s*hex\s/); - - depends($key, $1) if (m|^\s*depends on\s+(.+?)\s*$|); - selects($key, $1, $3) if (m|^\s*select\s+(\w+)(\s+if\s+(.+?))?\s*$|); - - # Get default for int options - if (m|^\s*default "(\d+)"| && exists $intopt{$key}) { - set_int_value($key, $1); - next; - } - # Get default for hex options - if (m|^\s*default "(0x)?([[:xdigit:]]+)"| && exists $hexopt{$key}) { - set_hex_value($key, $2); - next; - } - # Override default for disabled tri/bool options - # We don't care about the default for tri/bool options otherwise - if (m/^\s*default (y|n|m|"yes"|"no")(\s+if .*)?\s*$/ && - exists $tristate{$key} && $disabled) { - $default_seen = 1; - $_ = "\tdefault n\n"; - next; + # config type + if(/^\s*bool(ean)?\s/) { + add_bool($key); + } elsif (/^\s*tristate\s/) { + add_tristate($key); + } elsif (/^\s*int\s/) { + add_int($key); + } elsif (/^\s*hex\s/) { + add_hex($key); + + # select and depend lines + } elsif (m|^\s*depends on\s+(.+?)\s*$|) { + depends($key, $1); + } elsif (m|^\s*select\s+(\w+)(\s+if\s+(.+?))?\s*$|) { + selects($key, $1, $3); + + # default lines + } elsif (m|^\s*default\s+(.+?)(?:\s+if .*)?\s*$|) { + my $o = $1; + # Get default for int options + if ($o =~ m|^"(\d+)"$| && exists $intopt{$key}) { + set_int_value($key, $1); + # Get default for hex options + } elsif ($o =~ m|^"(0x)?([[:xdigit:]]+)"$| && exists $hexopt{$key}) { + set_hex_value($key, $2); + + # 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"; + } + } else { + print "Unknown default at $file:$. $_\n" if $debug; + } + } else { + print "Skipping $file:$. $_" if $debug; } } continue { print OUT $_; -- cgit v1.2.3 From 42bc9b89509b57c5c67c9588e7c37fea83989529 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Thu, 3 May 2007 11:06:10 -0700 Subject: build: Handle string options From: Trent Piepho Deal with string options and the default values. There is only one string option, and it's disabled, but someone could always add more. Signed-off-by: Trent Piepho --- v4l/scripts/make_kconfig.pl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'v4l/scripts/make_kconfig.pl') diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl index 8ed189aef..5e9e416d1 100755 --- a/v4l/scripts/make_kconfig.pl +++ b/v4l/scripts/make_kconfig.pl @@ -5,6 +5,7 @@ use strict; my %depend = (); my %minver = (); my %config = (); +my %stringopt = (); my %intopt = (); my %hexopt = (); my %tristate = (); @@ -70,6 +71,7 @@ sub add_int($) { my $arg=shift; + print "Int: $arg\n" if $debug; exists $config{$arg} or die "Adding unknown int '$arg'"; $intopt{$arg} = 0; } @@ -78,10 +80,20 @@ sub add_hex($) { my $arg=shift; + print "Hex: $arg\n" if $debug; exists $config{$arg} or die "Adding unknown hex '$arg'"; $hexopt{$arg} = 0; } +sub add_string($) +{ + my $arg=shift; + + print "String: $arg\n" if $debug; + exists $config{$arg} or die "Adding unknown string '$arg'"; + $stringopt{$arg} = ""; +} + sub set_int_value($$) { my $key = shift; @@ -100,6 +112,15 @@ sub set_hex_value($$) $hexopt{$key} = "0x$val"; } +sub set_string_value($$) +{ + my $key = shift; + my $val = shift; + + exists $stringopt{$key} or die "Default for unknown string option '$key'"; + $stringopt{$key} = "\"$val\""; +} + sub add_config($) { my $arg = shift; @@ -349,6 +370,8 @@ sub open_kconfig($$) { add_int($key); } elsif (/^\s*hex\s/) { add_hex($key); + } elsif (/^\s*string\s/) { + add_string($key); # select and depend lines } elsif (m|^\s*depends on\s+(.+?)\s*$|) { @@ -365,6 +388,9 @@ sub open_kconfig($$) { # Get default for hex options } elsif ($o =~ m|^"(0x)?([[:xdigit:]]+)"$| && exists $hexopt{$key}) { set_hex_value($key, $2); + # Get default for string options + } elsif ($o =~ m|^"(.*)"$| && exists $stringopt{$key}) { + set_string_value($key, $1); # Override default for disabled tri/bool options # We don't care about the default for tri/bool options otherwise @@ -537,6 +563,9 @@ if ($force_kconfig==1 || !-e '.config') { while (my ($key,$value) = each %hexopt) { print OUT "CONFIG_$key=$value\n" if($config{$key}); } + while (my ($key,$value) = each %stringopt) { + print OUT "CONFIG_$key=$value\n" if($config{$key}); + } close OUT; print "Created default (all yes) .config file\n"; } -- cgit v1.2.3 From db6454131c7fe01249418ecb134a09cc07528be0 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Mon, 21 May 2007 12:10:08 -0700 Subject: build: Update make_kconfig to support depends on in menus From: Trent Piepho A backported kernel patch added a "depends on" clause to a menu, which wasn't yet handled. Everything in a menu gains implicitly gains a copy of the menu's dependencies We handle this the same way as if/endif is handled. It may not work properly if someone makes a nonsense file like: menu "foo" if X endmenu endif Signed-off-by: Trent Piepho --- v4l/scripts/make_kconfig.pl | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'v4l/scripts/make_kconfig.pl') diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl index 5e9e416d1..3bfc26a18 100755 --- a/v4l/scripts/make_kconfig.pl +++ b/v4l/scripts/make_kconfig.pl @@ -219,6 +219,7 @@ sub checkdeps() my $key = shift; my $deps = $depends{$key}; foreach (@$deps) { + next if($_ eq ''); if (!eval(toperl($_))) { print "Disabling $key, dependency '$_' not met\n" if $debug; $allconfig{$key} = 0; @@ -343,10 +344,13 @@ sub open_kconfig($$) { $key = 'comment'; } elsif (m|^\s*menu\s+"[^"]*"\s*$|) { $key = 'menu'; + push @kifs, ''; # placeholder for any depends on clauses } elsif (m|^\s*if\s+(.+?)\s*$|) { push @kifs, $1; - } elsif (m|^\s*endif\s*(?:#.*)?$|) { - $#kifs >= 0 or die "Unmatched endif at $file:$.\n"; + } elsif (/^\s*end(if|menu)\s*(?:#.*)?$/) { + # Won't handle menu/if blocks that aren't strictly + # nested, but no one should do that! + $#kifs >= 0 or die "Unmatched end$1 at $file:$.\n"; pop @kifs; } else { $nothandled = 1; @@ -358,8 +362,21 @@ sub open_kconfig($$) { next; } - # Don't process any directives in comment blocks (or menus) - next if ($key eq 'comment' || $key eq 'menu'); + # Don't process any directives in comment blocks + next if ($key eq 'comment'); + + # Only depends on lines are accepted in menus + if ($key eq 'menu') { + if (m|^\s*depends on\s+(.+?)\s*$|) { + my $x = pop @kifs; + $x .= ' && ' if($x ne ''); + $x .= "($1)"; + push @kifs, $x; + } else { + print "Skipping unexpected line in menu stanza $file:$.$_" if $debug; + } + next; + } # config type if(/^\s*bool(ean)?\s/) { -- cgit v1.2.3 From 45c5a7ed9ff51aa39401e99816d2c212c554e70f Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Mon, 21 May 2007 12:20:58 -0700 Subject: build: work around problem with VIDEO_HELPER_CHIPS_AUTO From: Trent Piepho A number of drivers depend on "!VIDEO_HELPER_CHIPS_AUTO", so when VHCA is on, they are disabled. Make the allyesconfig default be VHCA off so these drivers will be enabled with allyesconfig. Even though these drivers are disabled when VHCA is on, it is still possible to enable them via a "select", at which point a driver will be on even though its dependencies are not met. Which seems like it doesn't follow the specification. Signed-off-by: Trent Piepho --- v4l/scripts/make_kconfig.pl | 1 + 1 file changed, 1 insertion(+) (limited to 'v4l/scripts/make_kconfig.pl') diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl index 3bfc26a18..d558aaeb6 100755 --- a/v4l/scripts/make_kconfig.pl +++ b/v4l/scripts/make_kconfig.pl @@ -535,6 +535,7 @@ close OUT; disable_config('DVB_AV7110_FIRMWARE'); disable_config('DVB_CINERGYT2_TUNING'); disable_config('DVB_FE_CUSTOMISE'); +disable_config('VIDEO_HELPER_CHIPS_AUTO'); # ACI needs some kernel includes that might not be there disable_config('SOUND_ACI_MIXER') if (! -e "$kernel/sound/oss/sound_config.h"); -- cgit v1.2.3