From 224a257190694f253f7a4c533fd6958d2e5fa669 Mon Sep 17 00:00:00 2001 From: Bill Pemberton Date: Thu, 9 Aug 2012 09:23:20 -0400 Subject: localmodconfig: Set default value for ksource in streamline_config.pl Running streamline_config.pl as it's shown it in the comment header, you will get a warning about $ksource being uninitialized. This is because $ksource is set to ARGV[0], but the examples don't require any arguments. Fix by setting ksource to . if no ARGV[0] is given. Signed-off-by: Bill Pemberton Signed-off-by: Steven Rostedt --- scripts/kconfig/streamline_config.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 2fbbbc1ddea0..e3687f98e0c8 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -135,7 +135,7 @@ GetOptions("localmodconfig" => \$localmodconfig, "localyesconfig" => \$localyesconfig); # Get the build source and top level Kconfig file (passed in) -my $ksource = $ARGV[0]; +my $ksource = ($ARGV[0] ? $ARGV[0] : '.'); my $kconfig = $ARGV[1]; my $lsmod_file = $ENV{'LSMOD'}; -- cgit v1.2.3 From 3f0c54131679889d64e8b1831bac40c0d64cf511 Mon Sep 17 00:00:00 2001 From: Bill Pemberton Date: Thu, 9 Aug 2012 09:23:21 -0400 Subject: localmodconfig: Rework find_config in streamline_config.pl Change find_config function to read_config. It now finds the config, reads the config into an array, and returns the array. This makes it a little cleaner and changes the open to use perl's 3 option open. Signed-off-by: Bill Pemberton Signed-off-by: Steven Rostedt --- scripts/kconfig/streamline_config.pl | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index e3687f98e0c8..62d64ce5c581 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -100,7 +100,7 @@ my @searchconfigs = ( }, ); -sub find_config { +sub read_config { foreach my $conf (@searchconfigs) { my $file = $conf->{"file"}; @@ -115,17 +115,15 @@ sub find_config { print STDERR "using config: '$file'\n"; - open(CIN, "$exec $file |") || die "Failed to run $exec $file"; - return; + open(my $infile, '-|', "$exec $file") || die "Failed to run $exec $file"; + my @x = <$infile>; + close $infile; + return @x; } die "No config file found"; } -find_config; - -# Read in the entire config file into config_file -my @config_file = ; -close CIN; +my @config_file = read_config; # Parse options my $localmodconfig = 0; -- cgit v1.2.3 From e0d28694d33dc7f37832b4fe4fe229655a64f991 Mon Sep 17 00:00:00 2001 From: Bill Pemberton Date: Thu, 9 Aug 2012 09:23:22 -0400 Subject: localmodconfig: Use 3 parameter open in streamline_config.pl Convert remaining open calls to use the perl's preferred 3 parameter open. Signed-off-by: Bill Pemberton Signed-off-by: Steven Rostedt --- scripts/kconfig/streamline_config.pl | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 62d64ce5c581..22b66cada779 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -171,8 +171,8 @@ sub read_kconfig { $source =~ s/\$$env/$ENV{$env}/; } - open(KIN, "$source") || die "Can't open $kconfig"; - while () { + open(my $kinfile, '<', $source) || die "Can't open $kconfig"; + while (<$kinfile>) { chomp; # Make sure that lines ending with \ continue @@ -249,7 +249,7 @@ sub read_kconfig { $state = "NONE"; } } - close(KIN); + close($kinfile); # read in any configs that were found. foreach $kconfig (@kconfigs) { @@ -293,8 +293,8 @@ foreach my $makefile (@makefiles) { my $line = ""; my %make_vars; - open(MIN,$makefile) || die "Can't open $makefile"; - while () { + open(my $infile, '<', $makefile) || die "Can't open $makefile"; + while (<$infile>) { # if this line ends with a backslash, continue chomp; if (/^(.*)\\$/) { @@ -341,10 +341,11 @@ foreach my $makefile (@makefiles) { } } } - close(MIN); + close($infile); } my %modules; +my $linfile; if (defined($lsmod_file)) { if ( ! -f $lsmod_file) { @@ -354,13 +355,10 @@ if (defined($lsmod_file)) { die "$lsmod_file not found"; } } - if ( -x $lsmod_file) { - # the file is executable, run it - open(LIN, "$lsmod_file|"); - } else { - # Just read the contents - open(LIN, "$lsmod_file"); - } + + my $otype = ( -x $lsmod_file) ? '-|' : '<'; + open($linfile, $otype, $lsmod_file); + } else { # see what modules are loaded on this system @@ -377,16 +375,16 @@ if (defined($lsmod_file)) { $lsmod = "lsmod"; } - open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod"; + open($linfile, '-|', $lsmod) || die "Can not call lsmod with $lsmod"; } -while () { +while (<$linfile>) { next if (/^Module/); # Skip the first line. if (/^(\S+)/) { $modules{$1} = 1; } } -close (LIN); +close ($linfile); # add to the configs hash all configs that are needed to enable # a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o -- cgit v1.2.3 From 45f4c81d690a57838822d4d01ad4c03651b76b95 Mon Sep 17 00:00:00 2001 From: Bill Pemberton Date: Thu, 9 Aug 2012 09:23:23 -0400 Subject: localmodconfig: Use my variable for loop in streamline_config.pl perlcritic complains about $kconfig being reused in the foreach loop at the end of read_kconfig. Change it to a my variable. Signed-off-by: Bill Pemberton Signed-off-by: Steven Rostedt --- scripts/kconfig/streamline_config.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 22b66cada779..39b6314fe634 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -252,7 +252,7 @@ sub read_kconfig { close($kinfile); # read in any configs that were found. - foreach $kconfig (@kconfigs) { + foreach my $kconfig (@kconfigs) { if (!defined($read_kconfigs{$kconfig})) { $read_kconfigs{$kconfig} = 1; read_kconfig($kconfig); -- cgit v1.2.3 From 4eae518d4b01b0cbf2f0d8edb5a6f3d6245ee8fb Mon Sep 17 00:00:00 2001 From: Yuta Ando Date: Mon, 1 Oct 2012 23:24:30 +0900 Subject: localmodconfig: Fix localyesconfig to set to 'y' not 'm' The kbuild target 'localyesconfig' has been same as 'localmodconfig' since the commit 50bce3e "kconfig/streamline_config.pl: merge local{mod,yes}config". The commit expects this script generates different configure depending on target, but it was not yet implemented. So I added code that sets to 'yes' when target is 'localyesconfig'. Link: http://lkml.kernel.org/r/1349101470-12243-1-git-send-email-yuta.and@gmail.com Cc: stable@vger.kernel.org # v3.2 Cc: linux-kbuild@vger.kernel.org Signed-off-by: Yuta Ando Signed-off-by: Steven Rostedt --- scripts/kconfig/streamline_config.pl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 39b6314fe634..33689396953a 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -601,6 +601,8 @@ foreach my $line (@config_file) { if (defined($configs{$1})) { if ($localyesconfig) { $setconfigs{$1} = 'y'; + print "$1=y\n"; + next; } else { $setconfigs{$1} = $2; } -- cgit v1.2.3