tree-wide: fix assorted typos all over the place
[safe/jmp/linux-2.6] / scripts / kconfig / streamline_config.pl
index 2334641..95984db 100644 (file)
 my $config = ".config";
 my $linuxpath = ".";
 
-open(CIN,$config) || die "Can't open current config file: $config";
+my $uname = `uname -r`;
+chomp $uname;
+
+my @searchconfigs = (
+       {
+           "file" => ".config",
+           "exec" => "cat",
+       },
+       {
+           "file" => "/proc/config.gz",
+           "exec" => "zcat",
+       },
+       {
+           "file" => "/boot/config-$uname",
+           "exec" => "cat",
+       },
+       {
+           "file" => "/boot/vmlinuz-$uname",
+           "exec" => "scripts/extract-ikconfig",
+           "test" => "scripts/extract-ikconfig",
+       },
+       {
+           "file" => "vmlinux",
+           "exec" => "scripts/extract-ikconfig",
+           "test" => "scripts/extract-ikconfig",
+       },
+       {
+           "file" => "/lib/modules/$uname/kernel/kernel/configs.ko",
+           "exec" => "scripts/extract-ikconfig",
+           "test" => "scripts/extract-ikconfig",
+       },
+       {
+           "file" => "kernel/configs.ko",
+           "exec" => "scripts/extract-ikconfig",
+           "test" => "scripts/extract-ikconfig",
+       },
+       {
+           "file" => "kernel/configs.o",
+           "exec" => "scripts/extract-ikconfig",
+           "test" => "scripts/extract-ikconfig",
+       },
+);
+
+sub find_config {
+    foreach my $conf (@searchconfigs) {
+       my $file = $conf->{"file"};
+
+       next if ( ! -f "$file");
+
+       if (defined($conf->{"test"})) {
+           `$conf->{"test"} $conf->{"file"} 2>/dev/null`;
+           next if ($?);
+       }
+
+       my $exec = $conf->{"exec"};
+
+       print STDERR "using config: '$file'\n";
+
+       open(CIN, "$exec $file |") || die "Failed to run $exec $file";
+       return;
+    }
+    die "No config file found";
+}
+
+find_config;
+
 my @makefiles = `find $linuxpath -name Makefile`;
 my %depends;
 my %selects;
@@ -262,7 +327,7 @@ while(<CIN>) {
            # enable IKCONFIG at least as a module
            print "CONFIG_IKCONFIG=m\n";
            # don't ask about PROC
-           print "# CONFIG_IKCONFIG is not set\n";
+           print "# CONFIG_IKCONFIG_PROC is not set\n";
        } else {
            print;
        }
@@ -272,15 +337,12 @@ while(<CIN>) {
     if (/^(CONFIG.*)=(m|y)/) {
        if (defined($configs{$1})) {
            $setconfigs{$1} = $2;
-           print;
        } elsif ($2 eq "m") {
            print "# $1 is not set\n";
-       } else {
-           print;
+           next;
        }
-    } else {
-       print;
     }
+    print;
 }
 close(CIN);