diff options
author | Michal Marek <mmarek@suse.cz> | 2010-08-04 08:05:07 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-08-04 08:05:07 -0400 |
commit | 7a996d3ab150bb0e1b71fa182f70199a703efdd1 (patch) | |
tree | 96a36947d90c9b96580899abd38cb3b70cd9d40b /scripts/kconfig/streamline_config.pl | |
parent | 7cf3d73b4360e91b14326632ab1aeda4cb26308d (diff) | |
parent | 9fe6206f400646a2322096b56c59891d530e8d51 (diff) |
Merge commit 'v2.6.35' into kbuild/kconfig
Conflicts:
scripts/kconfig/Makefile
Diffstat (limited to 'scripts/kconfig/streamline_config.pl')
-rw-r--r-- | scripts/kconfig/streamline_config.pl | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 0d800820c3cd..c70a27d924f0 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl | |||
@@ -113,14 +113,19 @@ find_config; | |||
113 | # Get the build source and top level Kconfig file (passed in) | 113 | # Get the build source and top level Kconfig file (passed in) |
114 | my $ksource = $ARGV[0]; | 114 | my $ksource = $ARGV[0]; |
115 | my $kconfig = $ARGV[1]; | 115 | my $kconfig = $ARGV[1]; |
116 | my $lsmod_file = $ARGV[2]; | ||
117 | |||
118 | my @makefiles = `find $ksource -name Makefile 2>/dev/null`; | ||
119 | chomp @makefiles; | ||
116 | 120 | ||
117 | my @makefiles = `find $ksource -name Makefile`; | ||
118 | my %depends; | 121 | my %depends; |
119 | my %selects; | 122 | my %selects; |
120 | my %prompts; | 123 | my %prompts; |
121 | my %objects; | 124 | my %objects; |
122 | my $var; | 125 | my $var; |
123 | my $cont = 0; | 126 | my $cont = 0; |
127 | my $iflevel = 0; | ||
128 | my @ifdeps; | ||
124 | 129 | ||
125 | # prevent recursion | 130 | # prevent recursion |
126 | my %read_kconfigs; | 131 | my %read_kconfigs; |
@@ -146,6 +151,15 @@ sub read_kconfig { | |||
146 | $state = "NEW"; | 151 | $state = "NEW"; |
147 | $config = $1; | 152 | $config = $1; |
148 | 153 | ||
154 | for (my $i = 0; $i < $iflevel; $i++) { | ||
155 | if ($i) { | ||
156 | $depends{$config} .= " " . $ifdeps[$i]; | ||
157 | } else { | ||
158 | $depends{$config} = $ifdeps[$i]; | ||
159 | } | ||
160 | $state = "DEP"; | ||
161 | } | ||
162 | |||
149 | # collect the depends for the config | 163 | # collect the depends for the config |
150 | } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { | 164 | } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { |
151 | $state = "DEP"; | 165 | $state = "DEP"; |
@@ -166,6 +180,21 @@ sub read_kconfig { | |||
166 | # note if the config has a prompt | 180 | # note if the config has a prompt |
167 | $prompt{$config} = 1; | 181 | $prompt{$config} = 1; |
168 | 182 | ||
183 | # Check for if statements | ||
184 | } elsif (/^if\s+(.*\S)\s*$/) { | ||
185 | my $deps = $1; | ||
186 | # remove beginning and ending non text | ||
187 | $deps =~ s/^[^a-zA-Z0-9_]*//; | ||
188 | $deps =~ s/[^a-zA-Z0-9_]*$//; | ||
189 | |||
190 | my @deps = split /[^a-zA-Z0-9_]+/, $deps; | ||
191 | |||
192 | $ifdeps[$iflevel++] = join ':', @deps; | ||
193 | |||
194 | } elsif (/^endif/) { | ||
195 | |||
196 | $iflevel-- if ($iflevel); | ||
197 | |||
169 | # stop on "help" | 198 | # stop on "help" |
170 | } elsif (/^\s*help\s*$/) { | 199 | } elsif (/^\s*help\s*$/) { |
171 | $state = "NONE"; | 200 | $state = "NONE"; |
@@ -188,7 +217,6 @@ if ($kconfig) { | |||
188 | 217 | ||
189 | # Read all Makefiles to map the configs to the objects | 218 | # Read all Makefiles to map the configs to the objects |
190 | foreach my $makefile (@makefiles) { | 219 | foreach my $makefile (@makefiles) { |
191 | chomp $makefile; | ||
192 | 220 | ||
193 | open(MIN,$makefile) || die "Can't open $makefile"; | 221 | open(MIN,$makefile) || die "Can't open $makefile"; |
194 | while (<MIN>) { | 222 | while (<MIN>) { |
@@ -215,7 +243,7 @@ foreach my $makefile (@makefiles) { | |||
215 | foreach my $obj (split /\s+/,$objs) { | 243 | foreach my $obj (split /\s+/,$objs) { |
216 | $obj =~ s/-/_/g; | 244 | $obj =~ s/-/_/g; |
217 | if ($obj =~ /(.*)\.o$/) { | 245 | if ($obj =~ /(.*)\.o$/) { |
218 | # Objects may bes enabled by more than one config. | 246 | # Objects may be enabled by more than one config. |
219 | # Store configs in an array. | 247 | # Store configs in an array. |
220 | my @arr; | 248 | my @arr; |
221 | 249 | ||
@@ -237,8 +265,36 @@ foreach my $makefile (@makefiles) { | |||
237 | 265 | ||
238 | my %modules; | 266 | my %modules; |
239 | 267 | ||
240 | # see what modules are loaded on this system | 268 | if (defined($lsmod_file)) { |
241 | open(LIN,"/sbin/lsmod|") || die "Cant lsmod"; | 269 | if ( ! -f $lsmod_file) { |
270 | die "$lsmod_file not found"; | ||
271 | } | ||
272 | if ( -x $lsmod_file) { | ||
273 | # the file is executable, run it | ||
274 | open(LIN, "$lsmod_file|"); | ||
275 | } else { | ||
276 | # Just read the contents | ||
277 | open(LIN, "$lsmod_file"); | ||
278 | } | ||
279 | } else { | ||
280 | |||
281 | # see what modules are loaded on this system | ||
282 | my $lsmod; | ||
283 | |||
284 | foreach $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) { | ||
285 | if ( -x "$dir/lsmod" ) { | ||
286 | $lsmod = "$dir/lsmod"; | ||
287 | last; | ||
288 | } | ||
289 | } | ||
290 | if (!defined($lsmod)) { | ||
291 | # try just the path | ||
292 | $lsmod = "lsmod"; | ||
293 | } | ||
294 | |||
295 | open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod"; | ||
296 | } | ||
297 | |||
242 | while (<LIN>) { | 298 | while (<LIN>) { |
243 | next if (/^Module/); # Skip the first line. | 299 | next if (/^Module/); # Skip the first line. |
244 | if (/^(\S+)/) { | 300 | if (/^(\S+)/) { |
@@ -252,7 +308,7 @@ close (LIN); | |||
252 | my %configs; | 308 | my %configs; |
253 | foreach my $module (keys(%modules)) { | 309 | foreach my $module (keys(%modules)) { |
254 | if (defined($objects{$module})) { | 310 | if (defined($objects{$module})) { |
255 | @arr = @{$objects{$module}}; | 311 | my @arr = @{$objects{$module}}; |
256 | foreach my $conf (@arr) { | 312 | foreach my $conf (@arr) { |
257 | $configs{$conf} = $module; | 313 | $configs{$conf} = $module; |
258 | } | 314 | } |