Skip to content

Commit

Permalink
Merge branch 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/rostedt/linux-2.6-kconfig

* 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-kconfig:
  kconfig: Simplify LSMOD= handling
  kconfig: Add LSMOD=file to override the lsmod for localmodconfig
  kconfig: Look in both /bin and /sbin for lsmod in streamline_config.pl
  kconfig: Check for if conditions in Kconfig for localmodconfig
  kconfig: Create include/generated for localmodconfig
  • Loading branch information
Linus Torvalds committed Feb 25, 2010
2 parents 1954ee5 + 3cebbb8 commit b6d9702
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
14 changes: 12 additions & 2 deletions scripts/kconfig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ silentoldconfig: $(obj)/conf
$(Q)mkdir -p include/generated
$< -s $(Kconfig)

# if no path is given, then use src directory to find file
ifdef LSMOD
LSMOD_F := $(LSMOD)
ifeq ($(findstring /,$(LSMOD)),)
LSMOD_F := $(objtree)/$(LSMOD)
endif
endif

localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
$(Q)perl $< $(srctree) $(Kconfig) > .tmp.config
$(Q)mkdir -p include/generated
$(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
$(Q)if [ -f .config ]; then \
cmp -s .tmp.config .config || \
(mv -f .config .config.old.1; \
Expand All @@ -45,7 +54,8 @@ localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
$(Q)rm -f .tmp.config

localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
$(Q)perl $< $(srctree) $(Kconfig) > .tmp.config
$(Q)mkdir -p include/generated
$(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
$(Q)sed -i s/=m/=y/ .tmp.config
$(Q)if [ -f .config ]; then \
cmp -s .tmp.config .config || \
Expand Down
59 changes: 57 additions & 2 deletions scripts/kconfig/streamline_config.pl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ sub find_config {
# Get the build source and top level Kconfig file (passed in)
my $ksource = $ARGV[0];
my $kconfig = $ARGV[1];
my $lsmod_file = $ARGV[2];

my @makefiles = `find $ksource -name Makefile`;
my %depends;
Expand All @@ -121,6 +122,8 @@ sub find_config {
my %objects;
my $var;
my $cont = 0;
my $iflevel = 0;
my @ifdeps;

# prevent recursion
my %read_kconfigs;
Expand All @@ -146,6 +149,15 @@ sub read_kconfig {
$state = "NEW";
$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
} elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
$state = "DEP";
Expand All @@ -166,6 +178,21 @@ sub read_kconfig {
# note if the config has a prompt
$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"
} elsif (/^\s*help\s*$/) {
$state = "NONE";
Expand Down Expand Up @@ -237,8 +264,36 @@ sub read_kconfig {

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>) {
next if (/^Module/); # Skip the first line.
if (/^(\S+)/) {
Expand Down

0 comments on commit b6d9702

Please sign in to comment.