History

kconfig: Add LSMOD=file to override the lsmod for localmodconfig

Doing the following: make LSMOD=file localmodconfig Will make the streamline-config code use the given file instead of lsmod. If the file is an executable, it will execute it, otherwise it will read it as text. make LSMOD=/my/local/path/lsmod localmodconfig The above will execute the lsmod in /my/local/path instead of the lsmods that may be located elsewhere. make LSMOD=embedded_board_lsmod localmodconfig The above will read the "embedded_board_lsmod" as a text file. This is useful if you are doing a cross compile and need to run the config against modules that exist on an embedded device. Note, if the LSMOD= file does is not a path, it will add the path to the object directory. That is, the above example will look for "embedded_board_lsmod" in the directory that the binary will be built in (the O=dir directory). Signed-off-by: Steven Rostedt <rostedt@goodmis.org> On branch config/linus

Steven Rostedt committed 16 years ago

Commit 615f0831 parent 88f66ea2 files · +38 −13Browse files

Unified · Split

2 files
  1. scripts/kconfig/Makefile +11 −2
  2. scripts/kconfig/streamline_config.pl +27 −11
scripts/kconfig/Makefile+11−2
@@ -30,9 +30,18 @@ silentoldconfig: $(obj)/conf · 29 unmodified lines
3030 $(Q)mkdir -p include/generated
3131 $< -s $(Kconfig)
3232
33+# if no path is given, then use src directory to find file
34+ifdef LSMOD
35+LSMOD_F = $(shell if [ `basename $(LSMOD)` == $(LSMOD) ]; then \
36+ echo $(objtree)/$(LSMOD); \
37+ else \
38+ echo $(LSMOD); \
39+ fi)
40+endif
41+
3342 localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
3443 $(Q)mkdir -p include/generated
35− $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config
44+ $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
3645 $(Q)if [ -f .config ]; then \
3746 cmp -s .tmp.config .config || \
3847 (mv -f .config .config.old.1; \
@@ -47,7 +56,7 @@ localmodconfig: $(obj)/streamline_config.pl $(obj)/conf · 8 unmodified lines
4756
4857 localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
4958 $(Q)mkdir -p include/generated
50− $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config
59+ $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
5160 $(Q)sed -i s/=m/=y/ .tmp.config
5261 $(Q)if [ -f .config ]; then \
5362 cmp -s .tmp.config .config || \
scripts/kconfig/streamline_config.pl+27−11
@@ -113,6 +113,7 @@ find_config; · 112 unmodified lines
113113 # Get the build source and top level Kconfig file (passed in)
114114 my $ksource = $ARGV[0];
115115 my $kconfig = $ARGV[1];
116+my $lsmod_file = $ARGV[2];
116117
117118 my @makefiles = `find $ksource -name Makefile`;
118119 my %depends;
@@ -263,21 +264,36 @@ foreach my $makefile (@makefiles) { · 144 unmodified lines
263264
264265 my %modules;
265266
266−# see what modules are loaded on this system
267−my $lsmod;
268−
269−foreach $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) {
270− if ( -x "$dir/lsmod" ) {
271− $lsmod = "$dir/lsmod";
272− last;
267+if (defined($lsmod_file)) {
268+ if ( ! -f $lsmod_file) {
269+ die "$lsmod_file not found";
270+ }
271+ if ( -x $lsmod_file) {
272+ # the file is executable, run it
273+ open(LIN, "$lsmod_file|");
274+ } else {
275+ # Just read the contents
276+ open(LIN, "$lsmod_file");
273277 }
278+} else {
279+
280+ # see what modules are loaded on this system
281+ my $lsmod;
282+
283+ foreach $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) {
284+ if ( -x "$dir/lsmod" ) {
285+ $lsmod = "$dir/lsmod";
286+ last;
287+ }
274288 }
275−if (!defined($lsmod)) {
276− # try just the path
277− $lsmod = "lsmod";
289+ if (!defined($lsmod)) {
290+ # try just the path
291+ $lsmod = "lsmod";
292+ }
293+
294+ open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod";
278295 }
279296
280−open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod";
281297 while (<LIN>) {
282298 next if (/^Module/); # Skip the first line.
283299 if (/^(\S+)/) {