|
@@ -113,6 +113,7 @@ find_config;
|
|
# Get the build source and top level Kconfig file (passed in)
|
|
# Get the build source and top level Kconfig file (passed in)
|
|
my $ksource = $ARGV[0];
|
|
my $ksource = $ARGV[0];
|
|
my $kconfig = $ARGV[1];
|
|
my $kconfig = $ARGV[1];
|
|
|
|
+my $lsmod_file = $ARGV[2];
|
|
|
|
|
|
my @makefiles = `find $ksource -name Makefile`;
|
|
my @makefiles = `find $ksource -name Makefile`;
|
|
my %depends;
|
|
my %depends;
|
|
@@ -121,6 +122,8 @@ my %prompts;
|
|
my %objects;
|
|
my %objects;
|
|
my $var;
|
|
my $var;
|
|
my $cont = 0;
|
|
my $cont = 0;
|
|
|
|
+my $iflevel = 0;
|
|
|
|
+my @ifdeps;
|
|
|
|
|
|
# prevent recursion
|
|
# prevent recursion
|
|
my %read_kconfigs;
|
|
my %read_kconfigs;
|
|
@@ -146,6 +149,15 @@ sub read_kconfig {
|
|
$state = "NEW";
|
|
$state = "NEW";
|
|
$config = $1;
|
|
$config = $1;
|
|
|
|
|
|
|
|
+ for (my $i = 0; $i < $iflevel; $i++) {
|
|
|
|
+ if ($i) {
|
|
|
|
+ $depends{$config} .= " " . $ifdeps[$i];
|
|
|
|
+ } else {
|
|
|
|
+ $depends{$config} = $ifdeps[$i];
|
|
|
|
+ }
|
|
|
|
+ $state = "DEP";
|
|
|
|
+ }
|
|
|
|
+
|
|
# collect the depends for the config
|
|
# collect the depends for the config
|
|
} elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
|
|
} elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
|
|
$state = "DEP";
|
|
$state = "DEP";
|
|
@@ -166,6 +178,21 @@ sub read_kconfig {
|
|
# note if the config has a prompt
|
|
# note if the config has a prompt
|
|
$prompt{$config} = 1;
|
|
$prompt{$config} = 1;
|
|
|
|
|
|
|
|
+ # Check for if statements
|
|
|
|
+ } elsif (/^if\s+(.*\S)\s*$/) {
|
|
|
|
+ my $deps = $1;
|
|
|
|
+ # remove beginning and ending non text
|
|
|
|
+ $deps =~ s/^[^a-zA-Z0-9_]*//;
|
|
|
|
+ $deps =~ s/[^a-zA-Z0-9_]*$//;
|
|
|
|
+
|
|
|
|
+ my @deps = split /[^a-zA-Z0-9_]+/, $deps;
|
|
|
|
+
|
|
|
|
+ $ifdeps[$iflevel++] = join ':', @deps;
|
|
|
|
+
|
|
|
|
+ } elsif (/^endif/) {
|
|
|
|
+
|
|
|
|
+ $iflevel-- if ($iflevel);
|
|
|
|
+
|
|
# stop on "help"
|
|
# stop on "help"
|
|
} elsif (/^\s*help\s*$/) {
|
|
} elsif (/^\s*help\s*$/) {
|
|
$state = "NONE";
|
|
$state = "NONE";
|
|
@@ -237,8 +264,36 @@ foreach my $makefile (@makefiles) {
|
|
|
|
|
|
my %modules;
|
|
my %modules;
|
|
|
|
|
|
-# see what modules are loaded on this system
|
|
|
|
-open(LIN,"/sbin/lsmod|") || die "Cant lsmod";
|
|
|
|
|
|
+if (defined($lsmod_file)) {
|
|
|
|
+ if ( ! -f $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");
|
|
|
|
+ }
|
|
|
|
+} else {
|
|
|
|
+
|
|
|
|
+ # see what modules are loaded on this system
|
|
|
|
+ my $lsmod;
|
|
|
|
+
|
|
|
|
+ foreach $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) {
|
|
|
|
+ if ( -x "$dir/lsmod" ) {
|
|
|
|
+ $lsmod = "$dir/lsmod";
|
|
|
|
+ last;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+ if (!defined($lsmod)) {
|
|
|
|
+ # try just the path
|
|
|
|
+ $lsmod = "lsmod";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod";
|
|
|
|
+}
|
|
|
|
+
|
|
while (<LIN>) {
|
|
while (<LIN>) {
|
|
next if (/^Module/); # Skip the first line.
|
|
next if (/^Module/); # Skip the first line.
|
|
if (/^(\S+)/) {
|
|
if (/^(\S+)/) {
|