aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/streamline_config.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/streamline_config.pl')
-rw-r--r--scripts/kconfig/streamline_config.pl68
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)
114my $ksource = $ARGV[0]; 114my $ksource = $ARGV[0];
115my $kconfig = $ARGV[1]; 115my $kconfig = $ARGV[1];
116my $lsmod_file = $ARGV[2];
117
118my @makefiles = `find $ksource -name Makefile 2>/dev/null`;
119chomp @makefiles;
116 120
117my @makefiles = `find $ksource -name Makefile`;
118my %depends; 121my %depends;
119my %selects; 122my %selects;
120my %prompts; 123my %prompts;
121my %objects; 124my %objects;
122my $var; 125my $var;
123my $cont = 0; 126my $cont = 0;
127my $iflevel = 0;
128my @ifdeps;
124 129
125# prevent recursion 130# prevent recursion
126my %read_kconfigs; 131my %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
190foreach my $makefile (@makefiles) { 219foreach 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
238my %modules; 266my %modules;
239 267
240# see what modules are loaded on this system 268if (defined($lsmod_file)) {
241open(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
242while (<LIN>) { 298while (<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);
252my %configs; 308my %configs;
253foreach my $module (keys(%modules)) { 309foreach 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 }