diff options
author | Michal Marek <mmarek@suse.cz> | 2011-03-09 10:15:44 -0500 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2011-03-09 10:15:44 -0500 |
commit | 2d8ad8719591fa803b0d589ed057fa46f49b7155 (patch) | |
tree | 4ae051577dad1161c91dafbf4207bb10a9dc91bb /scripts/kconfig/streamline_config.pl | |
parent | 9b4ce7bce5f30712fd926ab4599a803314a07719 (diff) | |
parent | c56eb8fb6dccb83d9fe62fd4dc00c834de9bc470 (diff) |
Merge commit 'v2.6.38-rc1' into kbuild/packaging
Diffstat (limited to 'scripts/kconfig/streamline_config.pl')
-rw-r--r-- | scripts/kconfig/streamline_config.pl | 109 |
1 files changed, 97 insertions, 12 deletions
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 0d800820c3c..fd81fc33d63 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl | |||
@@ -42,6 +42,8 @@ | |||
42 | # mv config_strip .config | 42 | # mv config_strip .config |
43 | # make oldconfig | 43 | # make oldconfig |
44 | # | 44 | # |
45 | use strict; | ||
46 | |||
45 | my $config = ".config"; | 47 | my $config = ".config"; |
46 | 48 | ||
47 | my $uname = `uname -r`; | 49 | my $uname = `uname -r`; |
@@ -113,14 +115,18 @@ find_config; | |||
113 | # Get the build source and top level Kconfig file (passed in) | 115 | # Get the build source and top level Kconfig file (passed in) |
114 | my $ksource = $ARGV[0]; | 116 | my $ksource = $ARGV[0]; |
115 | my $kconfig = $ARGV[1]; | 117 | my $kconfig = $ARGV[1]; |
118 | my $lsmod_file = $ARGV[2]; | ||
119 | |||
120 | my @makefiles = `find $ksource -name Makefile 2>/dev/null`; | ||
121 | chomp @makefiles; | ||
116 | 122 | ||
117 | my @makefiles = `find $ksource -name Makefile`; | ||
118 | my %depends; | 123 | my %depends; |
119 | my %selects; | 124 | my %selects; |
120 | my %prompts; | 125 | my %prompts; |
121 | my %objects; | 126 | my %objects; |
122 | my $var; | 127 | my $var; |
123 | my $cont = 0; | 128 | my $iflevel = 0; |
129 | my @ifdeps; | ||
124 | 130 | ||
125 | # prevent recursion | 131 | # prevent recursion |
126 | my %read_kconfigs; | 132 | my %read_kconfigs; |
@@ -132,19 +138,54 @@ sub read_kconfig { | |||
132 | my $config; | 138 | my $config; |
133 | my @kconfigs; | 139 | my @kconfigs; |
134 | 140 | ||
135 | open(KIN, "$ksource/$kconfig") || die "Can't open $kconfig"; | 141 | my $cont = 0; |
142 | my $line; | ||
143 | |||
144 | my $source = "$ksource/$kconfig"; | ||
145 | my $last_source = ""; | ||
146 | |||
147 | # Check for any environment variables used | ||
148 | while ($source =~ /\$(\w+)/ && $last_source ne $source) { | ||
149 | my $env = $1; | ||
150 | $last_source = $source; | ||
151 | $source =~ s/\$$env/$ENV{$env}/; | ||
152 | } | ||
153 | |||
154 | open(KIN, "$source") || die "Can't open $kconfig"; | ||
136 | while (<KIN>) { | 155 | while (<KIN>) { |
137 | chomp; | 156 | chomp; |
138 | 157 | ||
158 | # Make sure that lines ending with \ continue | ||
159 | if ($cont) { | ||
160 | $_ = $line . " " . $_; | ||
161 | } | ||
162 | |||
163 | if (s/\\$//) { | ||
164 | $cont = 1; | ||
165 | $line = $_; | ||
166 | next; | ||
167 | } | ||
168 | |||
169 | $cont = 0; | ||
170 | |||
139 | # collect any Kconfig sources | 171 | # collect any Kconfig sources |
140 | if (/^source\s*"(.*)"/) { | 172 | if (/^source\s*"(.*)"/) { |
141 | $kconfigs[$#kconfigs+1] = $1; | 173 | $kconfigs[$#kconfigs+1] = $1; |
142 | } | 174 | } |
143 | 175 | ||
144 | # configs found | 176 | # configs found |
145 | if (/^\s*config\s+(\S+)\s*$/) { | 177 | if (/^\s*(menu)?config\s+(\S+)\s*$/) { |
146 | $state = "NEW"; | 178 | $state = "NEW"; |
147 | $config = $1; | 179 | $config = $2; |
180 | |||
181 | for (my $i = 0; $i < $iflevel; $i++) { | ||
182 | if ($i) { | ||
183 | $depends{$config} .= " " . $ifdeps[$i]; | ||
184 | } else { | ||
185 | $depends{$config} = $ifdeps[$i]; | ||
186 | } | ||
187 | $state = "DEP"; | ||
188 | } | ||
148 | 189 | ||
149 | # collect the depends for the config | 190 | # collect the depends for the config |
150 | } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { | 191 | } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { |
@@ -164,7 +205,22 @@ sub read_kconfig { | |||
164 | # configs without prompts must be selected | 205 | # configs without prompts must be selected |
165 | } elsif ($state ne "NONE" && /^\s*tristate\s\S/) { | 206 | } elsif ($state ne "NONE" && /^\s*tristate\s\S/) { |
166 | # note if the config has a prompt | 207 | # note if the config has a prompt |
167 | $prompt{$config} = 1; | 208 | $prompts{$config} = 1; |
209 | |||
210 | # Check for if statements | ||
211 | } elsif (/^if\s+(.*\S)\s*$/) { | ||
212 | my $deps = $1; | ||
213 | # remove beginning and ending non text | ||
214 | $deps =~ s/^[^a-zA-Z0-9_]*//; | ||
215 | $deps =~ s/[^a-zA-Z0-9_]*$//; | ||
216 | |||
217 | my @deps = split /[^a-zA-Z0-9_]+/, $deps; | ||
218 | |||
219 | $ifdeps[$iflevel++] = join ':', @deps; | ||
220 | |||
221 | } elsif (/^endif/) { | ||
222 | |||
223 | $iflevel-- if ($iflevel); | ||
168 | 224 | ||
169 | # stop on "help" | 225 | # stop on "help" |
170 | } elsif (/^\s*help\s*$/) { | 226 | } elsif (/^\s*help\s*$/) { |
@@ -188,7 +244,8 @@ if ($kconfig) { | |||
188 | 244 | ||
189 | # Read all Makefiles to map the configs to the objects | 245 | # Read all Makefiles to map the configs to the objects |
190 | foreach my $makefile (@makefiles) { | 246 | foreach my $makefile (@makefiles) { |
191 | chomp $makefile; | 247 | |
248 | my $cont = 0; | ||
192 | 249 | ||
193 | open(MIN,$makefile) || die "Can't open $makefile"; | 250 | open(MIN,$makefile) || die "Can't open $makefile"; |
194 | while (<MIN>) { | 251 | while (<MIN>) { |
@@ -215,7 +272,7 @@ foreach my $makefile (@makefiles) { | |||
215 | foreach my $obj (split /\s+/,$objs) { | 272 | foreach my $obj (split /\s+/,$objs) { |
216 | $obj =~ s/-/_/g; | 273 | $obj =~ s/-/_/g; |
217 | if ($obj =~ /(.*)\.o$/) { | 274 | if ($obj =~ /(.*)\.o$/) { |
218 | # Objects may bes enabled by more than one config. | 275 | # Objects may be enabled by more than one config. |
219 | # Store configs in an array. | 276 | # Store configs in an array. |
220 | my @arr; | 277 | my @arr; |
221 | 278 | ||
@@ -237,8 +294,36 @@ foreach my $makefile (@makefiles) { | |||
237 | 294 | ||
238 | my %modules; | 295 | my %modules; |
239 | 296 | ||
240 | # see what modules are loaded on this system | 297 | if (defined($lsmod_file)) { |
241 | open(LIN,"/sbin/lsmod|") || die "Cant lsmod"; | 298 | if ( ! -f $lsmod_file) { |
299 | die "$lsmod_file not found"; | ||
300 | } | ||
301 | if ( -x $lsmod_file) { | ||
302 | # the file is executable, run it | ||
303 | open(LIN, "$lsmod_file|"); | ||
304 | } else { | ||
305 | # Just read the contents | ||
306 | open(LIN, "$lsmod_file"); | ||
307 | } | ||
308 | } else { | ||
309 | |||
310 | # see what modules are loaded on this system | ||
311 | my $lsmod; | ||
312 | |||
313 | foreach my $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) { | ||
314 | if ( -x "$dir/lsmod" ) { | ||
315 | $lsmod = "$dir/lsmod"; | ||
316 | last; | ||
317 | } | ||
318 | } | ||
319 | if (!defined($lsmod)) { | ||
320 | # try just the path | ||
321 | $lsmod = "lsmod"; | ||
322 | } | ||
323 | |||
324 | open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod"; | ||
325 | } | ||
326 | |||
242 | while (<LIN>) { | 327 | while (<LIN>) { |
243 | next if (/^Module/); # Skip the first line. | 328 | next if (/^Module/); # Skip the first line. |
244 | if (/^(\S+)/) { | 329 | if (/^(\S+)/) { |
@@ -252,7 +337,7 @@ close (LIN); | |||
252 | my %configs; | 337 | my %configs; |
253 | foreach my $module (keys(%modules)) { | 338 | foreach my $module (keys(%modules)) { |
254 | if (defined($objects{$module})) { | 339 | if (defined($objects{$module})) { |
255 | @arr = @{$objects{$module}}; | 340 | my @arr = @{$objects{$module}}; |
256 | foreach my $conf (@arr) { | 341 | foreach my $conf (@arr) { |
257 | $configs{$conf} = $module; | 342 | $configs{$conf} = $module; |
258 | } | 343 | } |
@@ -307,7 +392,7 @@ while ($repeat) { | |||
307 | parse_config_dep_select $depends{$config}; | 392 | parse_config_dep_select $depends{$config}; |
308 | } | 393 | } |
309 | 394 | ||
310 | if (defined($prompt{$config}) || !defined($selects{$config})) { | 395 | if (defined($prompts{$config}) || !defined($selects{$config})) { |
311 | next; | 396 | next; |
312 | } | 397 | } |
313 | 398 | ||