diff options
| -rw-r--r-- | scripts/kconfig/streamline_config.pl | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 2fbbbc1ddea0..33689396953a 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl | |||
| @@ -100,7 +100,7 @@ my @searchconfigs = ( | |||
| 100 | }, | 100 | }, |
| 101 | ); | 101 | ); |
| 102 | 102 | ||
| 103 | sub find_config { | 103 | sub read_config { |
| 104 | foreach my $conf (@searchconfigs) { | 104 | foreach my $conf (@searchconfigs) { |
| 105 | my $file = $conf->{"file"}; | 105 | my $file = $conf->{"file"}; |
| 106 | 106 | ||
| @@ -115,17 +115,15 @@ sub find_config { | |||
| 115 | 115 | ||
| 116 | print STDERR "using config: '$file'\n"; | 116 | print STDERR "using config: '$file'\n"; |
| 117 | 117 | ||
| 118 | open(CIN, "$exec $file |") || die "Failed to run $exec $file"; | 118 | open(my $infile, '-|', "$exec $file") || die "Failed to run $exec $file"; |
| 119 | return; | 119 | my @x = <$infile>; |
| 120 | close $infile; | ||
| 121 | return @x; | ||
| 120 | } | 122 | } |
| 121 | die "No config file found"; | 123 | die "No config file found"; |
| 122 | } | 124 | } |
| 123 | 125 | ||
| 124 | find_config; | 126 | my @config_file = read_config; |
| 125 | |||
| 126 | # Read in the entire config file into config_file | ||
| 127 | my @config_file = <CIN>; | ||
| 128 | close CIN; | ||
| 129 | 127 | ||
| 130 | # Parse options | 128 | # Parse options |
| 131 | my $localmodconfig = 0; | 129 | my $localmodconfig = 0; |
| @@ -135,7 +133,7 @@ GetOptions("localmodconfig" => \$localmodconfig, | |||
| 135 | "localyesconfig" => \$localyesconfig); | 133 | "localyesconfig" => \$localyesconfig); |
| 136 | 134 | ||
| 137 | # Get the build source and top level Kconfig file (passed in) | 135 | # Get the build source and top level Kconfig file (passed in) |
| 138 | my $ksource = $ARGV[0]; | 136 | my $ksource = ($ARGV[0] ? $ARGV[0] : '.'); |
| 139 | my $kconfig = $ARGV[1]; | 137 | my $kconfig = $ARGV[1]; |
| 140 | my $lsmod_file = $ENV{'LSMOD'}; | 138 | my $lsmod_file = $ENV{'LSMOD'}; |
| 141 | 139 | ||
| @@ -173,8 +171,8 @@ sub read_kconfig { | |||
| 173 | $source =~ s/\$$env/$ENV{$env}/; | 171 | $source =~ s/\$$env/$ENV{$env}/; |
| 174 | } | 172 | } |
| 175 | 173 | ||
| 176 | open(KIN, "$source") || die "Can't open $kconfig"; | 174 | open(my $kinfile, '<', $source) || die "Can't open $kconfig"; |
| 177 | while (<KIN>) { | 175 | while (<$kinfile>) { |
| 178 | chomp; | 176 | chomp; |
| 179 | 177 | ||
| 180 | # Make sure that lines ending with \ continue | 178 | # Make sure that lines ending with \ continue |
| @@ -251,10 +249,10 @@ sub read_kconfig { | |||
| 251 | $state = "NONE"; | 249 | $state = "NONE"; |
| 252 | } | 250 | } |
| 253 | } | 251 | } |
| 254 | close(KIN); | 252 | close($kinfile); |
| 255 | 253 | ||
| 256 | # read in any configs that were found. | 254 | # read in any configs that were found. |
| 257 | foreach $kconfig (@kconfigs) { | 255 | foreach my $kconfig (@kconfigs) { |
| 258 | if (!defined($read_kconfigs{$kconfig})) { | 256 | if (!defined($read_kconfigs{$kconfig})) { |
| 259 | $read_kconfigs{$kconfig} = 1; | 257 | $read_kconfigs{$kconfig} = 1; |
| 260 | read_kconfig($kconfig); | 258 | read_kconfig($kconfig); |
| @@ -295,8 +293,8 @@ foreach my $makefile (@makefiles) { | |||
| 295 | my $line = ""; | 293 | my $line = ""; |
| 296 | my %make_vars; | 294 | my %make_vars; |
| 297 | 295 | ||
| 298 | open(MIN,$makefile) || die "Can't open $makefile"; | 296 | open(my $infile, '<', $makefile) || die "Can't open $makefile"; |
| 299 | while (<MIN>) { | 297 | while (<$infile>) { |
| 300 | # if this line ends with a backslash, continue | 298 | # if this line ends with a backslash, continue |
| 301 | chomp; | 299 | chomp; |
| 302 | if (/^(.*)\\$/) { | 300 | if (/^(.*)\\$/) { |
| @@ -343,10 +341,11 @@ foreach my $makefile (@makefiles) { | |||
| 343 | } | 341 | } |
| 344 | } | 342 | } |
| 345 | } | 343 | } |
| 346 | close(MIN); | 344 | close($infile); |
| 347 | } | 345 | } |
| 348 | 346 | ||
| 349 | my %modules; | 347 | my %modules; |
| 348 | my $linfile; | ||
| 350 | 349 | ||
| 351 | if (defined($lsmod_file)) { | 350 | if (defined($lsmod_file)) { |
| 352 | if ( ! -f $lsmod_file) { | 351 | if ( ! -f $lsmod_file) { |
| @@ -356,13 +355,10 @@ if (defined($lsmod_file)) { | |||
| 356 | die "$lsmod_file not found"; | 355 | die "$lsmod_file not found"; |
| 357 | } | 356 | } |
| 358 | } | 357 | } |
| 359 | if ( -x $lsmod_file) { | 358 | |
| 360 | # the file is executable, run it | 359 | my $otype = ( -x $lsmod_file) ? '-|' : '<'; |
| 361 | open(LIN, "$lsmod_file|"); | 360 | open($linfile, $otype, $lsmod_file); |
| 362 | } else { | 361 | |
| 363 | # Just read the contents | ||
| 364 | open(LIN, "$lsmod_file"); | ||
| 365 | } | ||
| 366 | } else { | 362 | } else { |
| 367 | 363 | ||
| 368 | # see what modules are loaded on this system | 364 | # see what modules are loaded on this system |
| @@ -379,16 +375,16 @@ if (defined($lsmod_file)) { | |||
| 379 | $lsmod = "lsmod"; | 375 | $lsmod = "lsmod"; |
| 380 | } | 376 | } |
| 381 | 377 | ||
| 382 | open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod"; | 378 | open($linfile, '-|', $lsmod) || die "Can not call lsmod with $lsmod"; |
| 383 | } | 379 | } |
| 384 | 380 | ||
| 385 | while (<LIN>) { | 381 | while (<$linfile>) { |
| 386 | next if (/^Module/); # Skip the first line. | 382 | next if (/^Module/); # Skip the first line. |
| 387 | if (/^(\S+)/) { | 383 | if (/^(\S+)/) { |
| 388 | $modules{$1} = 1; | 384 | $modules{$1} = 1; |
| 389 | } | 385 | } |
| 390 | } | 386 | } |
| 391 | close (LIN); | 387 | close ($linfile); |
| 392 | 388 | ||
| 393 | # add to the configs hash all configs that are needed to enable | 389 | # add to the configs hash all configs that are needed to enable |
| 394 | # a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o | 390 | # a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o |
| @@ -605,6 +601,8 @@ foreach my $line (@config_file) { | |||
| 605 | if (defined($configs{$1})) { | 601 | if (defined($configs{$1})) { |
| 606 | if ($localyesconfig) { | 602 | if ($localyesconfig) { |
| 607 | $setconfigs{$1} = 'y'; | 603 | $setconfigs{$1} = 'y'; |
| 604 | print "$1=y\n"; | ||
| 605 | next; | ||
| 608 | } else { | 606 | } else { |
| 609 | $setconfigs{$1} = $2; | 607 | $setconfigs{$1} = $2; |
| 610 | } | 608 | } |
