fix a prereq bug
[openwrt.git] / scripts / config.pl
index a452537..53b8f11 100755 (executable)
@@ -18,12 +18,12 @@ sub load_config($) {
        open FILE, "$file" or die "can't open file";
        while (<FILE>) {
                chomp;
-               /^CONFIG_(.+)=(.+)/ and do {
+               /^CONFIG_(.+?)=(.+)/ and do {
                        $config{$1} = $2;
                        next;
                };
-               /^# CONFIG_(.+) is not set/ and do {
-                       $config{$1} = -1;
+               /^# CONFIG_(.+?) is not set/ and do {
+                       $config{$1} = "#undef";
                        next;
                };
                /^#/ and next;
@@ -49,15 +49,17 @@ sub config_and($$) {
 }
 
 
-sub config_add($$) {
+sub config_add($$$) {
        my $cfg1 = shift;
        my $cfg2 = shift;
+       my $mod_plus = shift;
        my %config;
        
        for ($cfg1, $cfg2) {
                my %cfg = %$_;
                
                foreach my $config (keys %cfg) {
+                       next if $mod_plus and $config{$config} and $config{$config} eq "y";
                        $config{$config} = $cfg{$config};
                }
        }
@@ -91,7 +93,7 @@ sub config_sub($$) {
 sub print_cfgline($$) {
        my $name = shift;
        my $val = shift;
-       if ($val eq '-1') {
+       if ($val eq '#undef') {
                print "# CONFIG_$name is not set\n";
        } else {
                print "CONFIG_$name=$val\n";
@@ -123,7 +125,11 @@ sub parse_expr($) {
        } elsif ($arg =~ /^\+/) {
                my $arg1 = parse_expr($pos);
                my $arg2 = parse_expr($pos);
-               return config_add($arg1, $arg2);
+               return config_add($arg1, $arg2, 0);
+       } elsif ($arg =~ /^m\+/) {
+               my $arg1 = parse_expr($pos);
+               my $arg2 = parse_expr($pos);
+               return config_add($arg1, $arg2, 1);
        } elsif ($arg eq '>') {
                my $arg1 = parse_expr($pos);
                my $arg2 = parse_expr($pos);