aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/Makefile15
-rw-r--r--scripts/kconfig/confdata.c24
-rw-r--r--scripts/kconfig/mconf.c2
-rw-r--r--scripts/kconfig/streamline_config.pl59
4 files changed, 93 insertions, 7 deletions
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 80599e3a7994..186c46604d06 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -27,10 +27,20 @@ oldconfig: $(obj)/conf
27 $< -o $(Kconfig) 27 $< -o $(Kconfig)
28 28
29silentoldconfig: $(obj)/conf 29silentoldconfig: $(obj)/conf
30 $(Q)mkdir -p include/generated
30 $< -s $(Kconfig) 31 $< -s $(Kconfig)
31 32
33# if no path is given, then use src directory to find file
34ifdef LSMOD
35LSMOD_F := $(LSMOD)
36ifeq ($(findstring /,$(LSMOD)),)
37 LSMOD_F := $(objtree)/$(LSMOD)
38endif
39endif
40
32localmodconfig: $(obj)/streamline_config.pl $(obj)/conf 41localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
33 $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config 42 $(Q)mkdir -p include/generated
43 $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
34 $(Q)if [ -f .config ]; then \ 44 $(Q)if [ -f .config ]; then \
35 cmp -s .tmp.config .config || \ 45 cmp -s .tmp.config .config || \
36 (mv -f .config .config.old.1; \ 46 (mv -f .config .config.old.1; \
@@ -44,7 +54,8 @@ localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
44 $(Q)rm -f .tmp.config 54 $(Q)rm -f .tmp.config
45 55
46localyesconfig: $(obj)/streamline_config.pl $(obj)/conf 56localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
47 $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config 57 $(Q)mkdir -p include/generated
58 $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
48 $(Q)sed -i s/=m/=y/ .tmp.config 59 $(Q)sed -i s/=m/=y/ .tmp.config
49 $(Q)if [ -f .config ]; then \ 60 $(Q)if [ -f .config ]; then \
50 cmp -s .tmp.config .config || \ 61 cmp -s .tmp.config .config || \
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index b55e72ff2fc6..c4dec80cfd8e 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -677,7 +677,7 @@ int conf_write_autoconf(void)
677 struct symbol *sym; 677 struct symbol *sym;
678 const char *str; 678 const char *str;
679 const char *name; 679 const char *name;
680 FILE *out, *out_h; 680 FILE *out, *tristate, *out_h;
681 time_t now; 681 time_t now;
682 int i, l; 682 int i, l;
683 683
@@ -692,9 +692,16 @@ int conf_write_autoconf(void)
692 if (!out) 692 if (!out)
693 return 1; 693 return 1;
694 694
695 tristate = fopen(".tmpconfig_tristate", "w");
696 if (!tristate) {
697 fclose(out);
698 return 1;
699 }
700
695 out_h = fopen(".tmpconfig.h", "w"); 701 out_h = fopen(".tmpconfig.h", "w");
696 if (!out_h) { 702 if (!out_h) {
697 fclose(out); 703 fclose(out);
704 fclose(tristate);
698 return 1; 705 return 1;
699 } 706 }
700 707
@@ -707,6 +714,9 @@ int conf_write_autoconf(void)
707 "# %s" 714 "# %s"
708 "#\n", 715 "#\n",
709 sym_get_string_value(sym), ctime(&now)); 716 sym_get_string_value(sym), ctime(&now));
717 fprintf(tristate, "#\n"
718 "# Automatically generated - do not edit\n"
719 "\n");
710 fprintf(out_h, "/*\n" 720 fprintf(out_h, "/*\n"
711 " * Automatically generated C config: don't edit\n" 721 " * Automatically generated C config: don't edit\n"
712 " * Linux kernel version: %s\n" 722 " * Linux kernel version: %s\n"
@@ -727,10 +737,14 @@ int conf_write_autoconf(void)
727 break; 737 break;
728 case mod: 738 case mod:
729 fprintf(out, "CONFIG_%s=m\n", sym->name); 739 fprintf(out, "CONFIG_%s=m\n", sym->name);
740 fprintf(tristate, "CONFIG_%s=M\n", sym->name);
730 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); 741 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name);
731 break; 742 break;
732 case yes: 743 case yes:
733 fprintf(out, "CONFIG_%s=y\n", sym->name); 744 fprintf(out, "CONFIG_%s=y\n", sym->name);
745 if (sym->type == S_TRISTATE)
746 fprintf(tristate, "CONFIG_%s=Y\n",
747 sym->name);
734 fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); 748 fprintf(out_h, "#define CONFIG_%s 1\n", sym->name);
735 break; 749 break;
736 } 750 }
@@ -772,13 +786,19 @@ int conf_write_autoconf(void)
772 } 786 }
773 } 787 }
774 fclose(out); 788 fclose(out);
789 fclose(tristate);
775 fclose(out_h); 790 fclose(out_h);
776 791
777 name = getenv("KCONFIG_AUTOHEADER"); 792 name = getenv("KCONFIG_AUTOHEADER");
778 if (!name) 793 if (!name)
779 name = "include/linux/autoconf.h"; 794 name = "include/generated/autoconf.h";
780 if (rename(".tmpconfig.h", name)) 795 if (rename(".tmpconfig.h", name))
781 return 1; 796 return 1;
797 name = getenv("KCONFIG_TRISTATE");
798 if (!name)
799 name = "include/config/tristate.conf";
800 if (rename(".tmpconfig_tristate", name))
801 return 1;
782 name = conf_get_autoconfig_name(); 802 name = conf_get_autoconfig_name();
783 /* 803 /*
784 * This must be the last step, kbuild has a dependency on auto.conf 804 * This must be the last step, kbuild has a dependency on auto.conf
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index d82953573588..8413cf38ed27 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -213,7 +213,7 @@ load_config_help[] = N_(
213 "to modify that configuration.\n" 213 "to modify that configuration.\n"
214 "\n" 214 "\n"
215 "If you are uncertain, then you have probably never used alternate\n" 215 "If you are uncertain, then you have probably never used alternate\n"
216 "configuration files. You should therefor leave this blank to abort.\n"), 216 "configuration files. You should therefore leave this blank to abort.\n"),
217save_config_text[] = N_( 217save_config_text[] = N_(
218 "Enter a filename to which this configuration should be saved " 218 "Enter a filename to which this configuration should be saved "
219 "as an alternate. Leave blank to abort."), 219 "as an alternate. Leave blank to abort."),
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index 0d800820c3cd..afbd54ac1d83 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -113,6 +113,7 @@ 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];
116 117
117my @makefiles = `find $ksource -name Makefile`; 118my @makefiles = `find $ksource -name Makefile`;
118my %depends; 119my %depends;
@@ -121,6 +122,8 @@ my %prompts;
121my %objects; 122my %objects;
122my $var; 123my $var;
123my $cont = 0; 124my $cont = 0;
125my $iflevel = 0;
126my @ifdeps;
124 127
125# prevent recursion 128# prevent recursion
126my %read_kconfigs; 129my %read_kconfigs;
@@ -146,6 +149,15 @@ sub read_kconfig {
146 $state = "NEW"; 149 $state = "NEW";
147 $config = $1; 150 $config = $1;
148 151
152 for (my $i = 0; $i < $iflevel; $i++) {
153 if ($i) {
154 $depends{$config} .= " " . $ifdeps[$i];
155 } else {
156 $depends{$config} = $ifdeps[$i];
157 }
158 $state = "DEP";
159 }
160
149 # collect the depends for the config 161 # collect the depends for the config
150 } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { 162 } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
151 $state = "DEP"; 163 $state = "DEP";
@@ -166,6 +178,21 @@ sub read_kconfig {
166 # note if the config has a prompt 178 # note if the config has a prompt
167 $prompt{$config} = 1; 179 $prompt{$config} = 1;
168 180
181 # Check for if statements
182 } elsif (/^if\s+(.*\S)\s*$/) {
183 my $deps = $1;
184 # remove beginning and ending non text
185 $deps =~ s/^[^a-zA-Z0-9_]*//;
186 $deps =~ s/[^a-zA-Z0-9_]*$//;
187
188 my @deps = split /[^a-zA-Z0-9_]+/, $deps;
189
190 $ifdeps[$iflevel++] = join ':', @deps;
191
192 } elsif (/^endif/) {
193
194 $iflevel-- if ($iflevel);
195
169 # stop on "help" 196 # stop on "help"
170 } elsif (/^\s*help\s*$/) { 197 } elsif (/^\s*help\s*$/) {
171 $state = "NONE"; 198 $state = "NONE";
@@ -237,8 +264,36 @@ foreach my $makefile (@makefiles) {
237 264
238my %modules; 265my %modules;
239 266
240# see what modules are loaded on this system 267if (defined($lsmod_file)) {
241open(LIN,"/sbin/lsmod|") || die "Cant lsmod"; 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");
277 }
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 }
288}
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";
295}
296
242while (<LIN>) { 297while (<LIN>) {
243 next if (/^Module/); # Skip the first line. 298 next if (/^Module/); # Skip the first line.
244 if (/^(\S+)/) { 299 if (/^(\S+)/) {