aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/Makefile34
-rw-r--r--scripts/kconfig/conf.c24
-rw-r--r--scripts/kconfig/confdata.c2
-rw-r--r--scripts/kconfig/expr.c6
-rw-r--r--scripts/kconfig/gconf.c21
-rw-r--r--scripts/kconfig/gconf.glade4
-rw-r--r--scripts/kconfig/kxgettext.c4
-rw-r--r--scripts/kconfig/lkc_proto.h2
-rw-r--r--scripts/kconfig/mconf.c78
-rw-r--r--scripts/kconfig/menu.c84
-rw-r--r--scripts/kconfig/qconf.cc10
-rw-r--r--scripts/kconfig/streamline_config.pl366
-rw-r--r--scripts/kconfig/symbol.c6
13 files changed, 518 insertions, 123 deletions
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 5ddf8becd7a2..6d69c7ccdcc7 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -2,7 +2,8 @@
2# Kernel configuration targets 2# Kernel configuration targets
3# These targets are used from top-level makefile 3# These targets are used from top-level makefile
4 4
5PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config 5PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \
6 localmodconfig localyesconfig
6 7
7ifdef KBUILD_KCONFIG 8ifdef KBUILD_KCONFIG
8Kconfig := $(KBUILD_KCONFIG) 9Kconfig := $(KBUILD_KCONFIG)
@@ -28,6 +29,35 @@ oldconfig: $(obj)/conf
28silentoldconfig: $(obj)/conf 29silentoldconfig: $(obj)/conf
29 $< -s $(Kconfig) 30 $< -s $(Kconfig)
30 31
32localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
33 $(Q)perl $< $(Kconfig) > .tmp.config
34 $(Q)if [ -f .config ]; then \
35 cmp -s .tmp.config .config || \
36 (mv -f .config .config.old.1; \
37 mv -f .tmp.config .config; \
38 $(obj)/conf -s $(Kconfig); \
39 mv -f .config.old.1 .config.old) \
40 else \
41 mv -f .tmp.config .config; \
42 $(obj)/conf -s $(Kconfig); \
43 fi
44 $(Q)rm -f .tmp.config
45
46localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
47 $(Q)perl $< $(Kconfig) > .tmp.config
48 $(Q)sed -i s/=m/=y/ .tmp.config
49 $(Q)if [ -f .config ]; then \
50 cmp -s .tmp.config .config || \
51 (mv -f .config .config.old.1; \
52 mv -f .tmp.config .config; \
53 $(obj)/conf -s $(Kconfig); \
54 mv -f .config.old.1 .config.old) \
55 else \
56 mv -f .tmp.config .config; \
57 $(obj)/conf -s $(Kconfig); \
58 fi
59 $(Q)rm -f .tmp.config
60
31# Create new linux.pot file 61# Create new linux.pot file
32# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files 62# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
33# The symlink is used to repair a deficiency in arch/um 63# The symlink is used to repair a deficiency in arch/um
@@ -83,6 +113,8 @@ help:
83 @echo ' xconfig - Update current config utilising a QT based front-end' 113 @echo ' xconfig - Update current config utilising a QT based front-end'
84 @echo ' gconfig - Update current config utilising a GTK based front-end' 114 @echo ' gconfig - Update current config utilising a GTK based front-end'
85 @echo ' oldconfig - Update current config utilising a provided .config as base' 115 @echo ' oldconfig - Update current config utilising a provided .config as base'
116 @echo ' localmodconfig - Update current config disabling modules not loaded'
117 @echo ' localyesconfig - Update current config converting local mods to core'
86 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' 118 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
87 @echo ' randconfig - New config with random answer to all options' 119 @echo ' randconfig - New config with random answer to all options'
88 @echo ' defconfig - New config with default answer to all options' 120 @echo ' defconfig - New config with default answer to all options'
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 3baaaecd6b13..9960d1c303f8 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -38,14 +38,14 @@ static int conf_cnt;
38static char line[128]; 38static char line[128];
39static struct menu *rootEntry; 39static struct menu *rootEntry;
40 40
41static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n"); 41static void print_help(struct menu *menu)
42
43static const char *get_help(struct menu *menu)
44{ 42{
45 if (menu_has_help(menu)) 43 struct gstr help = str_new();
46 return _(menu_get_help(menu)); 44
47 else 45 menu_get_ext_help(menu, &help);
48 return nohelp_text; 46
47 printf("\n%s\n", str_get(&help));
48 str_free(&help);
49} 49}
50 50
51static void strip(char *str) 51static void strip(char *str)
@@ -121,7 +121,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
121 return 1; 121 return 1;
122} 122}
123 123
124int conf_string(struct menu *menu) 124static int conf_string(struct menu *menu)
125{ 125{
126 struct symbol *sym = menu->sym; 126 struct symbol *sym = menu->sym;
127 const char *def; 127 const char *def;
@@ -140,7 +140,7 @@ int conf_string(struct menu *menu)
140 case '?': 140 case '?':
141 /* print help */ 141 /* print help */
142 if (line[1] == '\n') { 142 if (line[1] == '\n') {
143 printf("\n%s\n", get_help(menu)); 143 print_help(menu);
144 def = NULL; 144 def = NULL;
145 break; 145 break;
146 } 146 }
@@ -220,7 +220,7 @@ static int conf_sym(struct menu *menu)
220 if (sym_set_tristate_value(sym, newval)) 220 if (sym_set_tristate_value(sym, newval))
221 return 0; 221 return 0;
222help: 222help:
223 printf("\n%s\n", get_help(menu)); 223 print_help(menu);
224 } 224 }
225} 225}
226 226
@@ -307,7 +307,7 @@ static int conf_choice(struct menu *menu)
307 fgets(line, 128, stdin); 307 fgets(line, 128, stdin);
308 strip(line); 308 strip(line);
309 if (line[0] == '?') { 309 if (line[0] == '?') {
310 printf("\n%s\n", get_help(menu)); 310 print_help(menu);
311 continue; 311 continue;
312 } 312 }
313 if (!line[0]) 313 if (!line[0])
@@ -331,7 +331,7 @@ static int conf_choice(struct menu *menu)
331 if (!child) 331 if (!child)
332 continue; 332 continue;
333 if (line[strlen(line) - 1] == '?') { 333 if (line[strlen(line) - 1] == '?') {
334 printf("\n%s\n", get_help(child)); 334 print_help(child);
335 continue; 335 continue;
336 } 336 }
337 sym_set_choice_value(sym, child->sym); 337 sym_set_choice_value(sym, child->sym);
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index a04da3459f0f..b55e72ff2fc6 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -560,7 +560,7 @@ int conf_write(const char *name)
560 return 0; 560 return 0;
561} 561}
562 562
563int conf_split_config(void) 563static int conf_split_config(void)
564{ 564{
565 const char *name; 565 const char *name;
566 char path[128]; 566 char path[128];
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index 579ece4fa584..edd3f39a080a 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -348,7 +348,7 @@ struct expr *expr_trans_bool(struct expr *e)
348/* 348/*
349 * e1 || e2 -> ? 349 * e1 || e2 -> ?
350 */ 350 */
351struct expr *expr_join_or(struct expr *e1, struct expr *e2) 351static struct expr *expr_join_or(struct expr *e1, struct expr *e2)
352{ 352{
353 struct expr *tmp; 353 struct expr *tmp;
354 struct symbol *sym1, *sym2; 354 struct symbol *sym1, *sym2;
@@ -412,7 +412,7 @@ struct expr *expr_join_or(struct expr *e1, struct expr *e2)
412 return NULL; 412 return NULL;
413} 413}
414 414
415struct expr *expr_join_and(struct expr *e1, struct expr *e2) 415static struct expr *expr_join_and(struct expr *e1, struct expr *e2)
416{ 416{
417 struct expr *tmp; 417 struct expr *tmp;
418 struct symbol *sym1, *sym2; 418 struct symbol *sym1, *sym2;
@@ -1098,6 +1098,8 @@ void expr_fprint(struct expr *e, FILE *out)
1098static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str) 1098static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
1099{ 1099{
1100 str_append((struct gstr*)data, str); 1100 str_append((struct gstr*)data, str);
1101 if (sym)
1102 str_printf((struct gstr*)data, " [=%s]", sym_get_string_value(sym));
1101} 1103}
1102 1104
1103void expr_gstr_print(struct expr *e, struct gstr *gs) 1105void expr_gstr_print(struct expr *e, struct gstr *gs)
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 199b22bb49e2..65464366fe38 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -456,19 +456,9 @@ static void text_insert_help(struct menu *menu)
456 GtkTextBuffer *buffer; 456 GtkTextBuffer *buffer;
457 GtkTextIter start, end; 457 GtkTextIter start, end;
458 const char *prompt = _(menu_get_prompt(menu)); 458 const char *prompt = _(menu_get_prompt(menu));
459 gchar *name; 459 struct gstr help = str_new();
460 const char *help;
461 460
462 help = menu_get_help(menu); 461 menu_get_ext_help(menu, &help);
463
464 /* Gettextize if the help text not empty */
465 if ((help != 0) && (help[0] != 0))
466 help = _(help);
467
468 if (menu->sym && menu->sym->name)
469 name = g_strdup_printf(menu->sym->name);
470 else
471 name = g_strdup("");
472 462
473 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w)); 463 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
474 gtk_text_buffer_get_bounds(buffer, &start, &end); 464 gtk_text_buffer_get_bounds(buffer, &start, &end);
@@ -478,14 +468,11 @@ static void text_insert_help(struct menu *menu)
478 gtk_text_buffer_get_end_iter(buffer, &end); 468 gtk_text_buffer_get_end_iter(buffer, &end);
479 gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1, 469 gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1,
480 NULL); 470 NULL);
481 gtk_text_buffer_insert_at_cursor(buffer, " ", 1);
482 gtk_text_buffer_get_end_iter(buffer, &end);
483 gtk_text_buffer_insert_with_tags(buffer, &end, name, -1, tag1,
484 NULL);
485 gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2); 471 gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
486 gtk_text_buffer_get_end_iter(buffer, &end); 472 gtk_text_buffer_get_end_iter(buffer, &end);
487 gtk_text_buffer_insert_with_tags(buffer, &end, help, -1, tag2, 473 gtk_text_buffer_insert_with_tags(buffer, &end, str_get(&help), -1, tag2,
488 NULL); 474 NULL);
475 str_free(&help);
489} 476}
490 477
491 478
diff --git a/scripts/kconfig/gconf.glade b/scripts/kconfig/gconf.glade
index 803233fdd6dd..b1c86c19292c 100644
--- a/scripts/kconfig/gconf.glade
+++ b/scripts/kconfig/gconf.glade
@@ -547,7 +547,7 @@
547 <property name="headers_visible">True</property> 547 <property name="headers_visible">True</property>
548 <property name="rules_hint">False</property> 548 <property name="rules_hint">False</property>
549 <property name="reorderable">False</property> 549 <property name="reorderable">False</property>
550 <property name="enable_search">True</property> 550 <property name="enable_search">False</property>
551 <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:58:22 GMT"/> 551 <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:58:22 GMT"/>
552 <signal name="button_press_event" handler="on_treeview1_button_press_event" last_modification_time="Sun, 12 Jan 2003 16:03:52 GMT"/> 552 <signal name="button_press_event" handler="on_treeview1_button_press_event" last_modification_time="Sun, 12 Jan 2003 16:03:52 GMT"/>
553 <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 16:11:44 GMT"/> 553 <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 16:11:44 GMT"/>
@@ -582,7 +582,7 @@
582 <property name="headers_visible">True</property> 582 <property name="headers_visible">True</property>
583 <property name="rules_hint">False</property> 583 <property name="rules_hint">False</property>
584 <property name="reorderable">False</property> 584 <property name="reorderable">False</property>
585 <property name="enable_search">True</property> 585 <property name="enable_search">False</property>
586 <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:57:55 GMT"/> 586 <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:57:55 GMT"/>
587 <signal name="button_press_event" handler="on_treeview2_button_press_event" last_modification_time="Sun, 12 Jan 2003 15:57:58 GMT"/> 587 <signal name="button_press_event" handler="on_treeview2_button_press_event" last_modification_time="Sun, 12 Jan 2003 15:57:58 GMT"/>
588 <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 15:58:01 GMT"/> 588 <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 15:58:01 GMT"/>
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c
index 8d9ce22b0fc5..dcc3fcc0cc9a 100644
--- a/scripts/kconfig/kxgettext.c
+++ b/scripts/kconfig/kxgettext.c
@@ -166,7 +166,7 @@ static int message__add(const char *msg, char *option, char *file, int lineno)
166 return rc; 166 return rc;
167} 167}
168 168
169void menu_build_message_list(struct menu *menu) 169static void menu_build_message_list(struct menu *menu)
170{ 170{
171 struct menu *child; 171 struct menu *child;
172 172
@@ -211,7 +211,7 @@ static void message__print_gettext_msgid_msgstr(struct message *self)
211 "msgstr \"\"\n", self->msg); 211 "msgstr \"\"\n", self->msg);
212} 212}
213 213
214void menu__xgettext(void) 214static void menu__xgettext(void)
215{ 215{
216 struct message *m = message__list; 216 struct message *m = message__list;
217 217
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 8e69461313d1..ffeb532b2cff 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -17,6 +17,8 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu));
17P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 17P(menu_get_parent_menu,struct menu *,(struct menu *menu));
18P(menu_has_help,bool,(struct menu *menu)); 18P(menu_has_help,bool,(struct menu *menu));
19P(menu_get_help,const char *,(struct menu *menu)); 19P(menu_get_help,const char *,(struct menu *menu));
20P(get_symbol_str,void,(struct gstr *r, struct symbol *sym));
21P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
20 22
21/* symbol.c */ 23/* symbol.c */
22P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); 24P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 25b60bc117f7..d82953573588 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -199,8 +199,6 @@ inputbox_instructions_string[] = N_(
199setmod_text[] = N_( 199setmod_text[] = N_(
200 "This feature depends on another which has been configured as a module.\n" 200 "This feature depends on another which has been configured as a module.\n"
201 "As a result, this feature will be built as a module."), 201 "As a result, this feature will be built as a module."),
202nohelp_text[] = N_(
203 "There is no help available for this kernel option.\n"),
204load_config_text[] = N_( 202load_config_text[] = N_(
205 "Enter the name of the configuration file you wish to load. " 203 "Enter the name of the configuration file you wish to load. "
206 "Accept the name shown to restore the configuration you " 204 "Accept the name shown to restore the configuration you "
@@ -284,66 +282,6 @@ static void show_textbox(const char *title, const char *text, int r, int c);
284static void show_helptext(const char *title, const char *text); 282static void show_helptext(const char *title, const char *text);
285static void show_help(struct menu *menu); 283static void show_help(struct menu *menu);
286 284
287static void get_prompt_str(struct gstr *r, struct property *prop)
288{
289 int i, j;
290 struct menu *submenu[8], *menu;
291
292 str_printf(r, _("Prompt: %s\n"), _(prop->text));
293 str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
294 prop->menu->lineno);
295 if (!expr_is_yes(prop->visible.expr)) {
296 str_append(r, _(" Depends on: "));
297 expr_gstr_print(prop->visible.expr, r);
298 str_append(r, "\n");
299 }
300 menu = prop->menu->parent;
301 for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
302 submenu[i++] = menu;
303 if (i > 0) {
304 str_printf(r, _(" Location:\n"));
305 for (j = 4; --i >= 0; j += 2) {
306 menu = submenu[i];
307 str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
308 if (menu->sym) {
309 str_printf(r, " (%s [=%s])", menu->sym->name ?
310 menu->sym->name : _("<choice>"),
311 sym_get_string_value(menu->sym));
312 }
313 str_append(r, "\n");
314 }
315 }
316}
317
318static void get_symbol_str(struct gstr *r, struct symbol *sym)
319{
320 bool hit;
321 struct property *prop;
322
323 if (sym && sym->name)
324 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
325 sym_get_string_value(sym));
326 for_all_prompts(sym, prop)
327 get_prompt_str(r, prop);
328 hit = false;
329 for_all_properties(sym, prop, P_SELECT) {
330 if (!hit) {
331 str_append(r, " Selects: ");
332 hit = true;
333 } else
334 str_printf(r, " && ");
335 expr_gstr_print(prop->expr, r);
336 }
337 if (hit)
338 str_append(r, "\n");
339 if (sym->rev_dep.expr) {
340 str_append(r, _(" Selected by: "));
341 expr_gstr_print(sym->rev_dep.expr, r);
342 str_append(r, "\n");
343 }
344 str_append(r, "\n\n");
345}
346
347static struct gstr get_relations_str(struct symbol **sym_arr) 285static struct gstr get_relations_str(struct symbol **sym_arr)
348{ 286{
349 struct symbol *sym; 287 struct symbol *sym;
@@ -699,19 +637,9 @@ static void show_helptext(const char *title, const char *text)
699static void show_help(struct menu *menu) 637static void show_help(struct menu *menu)
700{ 638{
701 struct gstr help = str_new(); 639 struct gstr help = str_new();
702 struct symbol *sym = menu->sym; 640
703 641 menu_get_ext_help(menu, &help);
704 if (menu_has_help(menu)) 642
705 {
706 if (sym->name) {
707 str_printf(&help, "CONFIG_%s:\n\n", sym->name);
708 str_append(&help, _(menu_get_help(menu)));
709 str_append(&help, "\n");
710 }
711 } else {
712 str_append(&help, nohelp_text);
713 }
714 get_symbol_str(&help, sym);
715 show_helptext(_(menu_get_prompt(menu)), str_get(&help)); 643 show_helptext(_(menu_get_prompt(menu)), str_get(&help));
716 str_free(&help); 644 str_free(&help);
717} 645}
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 07ff8d105c9d..059a2465c574 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -9,6 +9,9 @@
9#define LKC_DIRECT_LINK 9#define LKC_DIRECT_LINK
10#include "lkc.h" 10#include "lkc.h"
11 11
12static const char nohelp_text[] = N_(
13 "There is no help available for this kernel option.\n");
14
12struct menu rootmenu; 15struct menu rootmenu;
13static struct menu **last_entry_ptr; 16static struct menu **last_entry_ptr;
14 17
@@ -74,7 +77,7 @@ void menu_end_menu(void)
74 current_menu = current_menu->parent; 77 current_menu = current_menu->parent;
75} 78}
76 79
77struct expr *menu_check_dep(struct expr *e) 80static struct expr *menu_check_dep(struct expr *e)
78{ 81{
79 if (!e) 82 if (!e)
80 return e; 83 return e;
@@ -184,7 +187,7 @@ static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
184 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name)); 187 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
185} 188}
186 189
187void sym_check_prop(struct symbol *sym) 190static void sym_check_prop(struct symbol *sym)
188{ 191{
189 struct property *prop; 192 struct property *prop;
190 struct symbol *sym2; 193 struct symbol *sym2;
@@ -451,3 +454,80 @@ const char *menu_get_help(struct menu *menu)
451 else 454 else
452 return ""; 455 return "";
453} 456}
457
458static void get_prompt_str(struct gstr *r, struct property *prop)
459{
460 int i, j;
461 struct menu *submenu[8], *menu;
462
463 str_printf(r, _("Prompt: %s\n"), _(prop->text));
464 str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
465 prop->menu->lineno);
466 if (!expr_is_yes(prop->visible.expr)) {
467 str_append(r, _(" Depends on: "));
468 expr_gstr_print(prop->visible.expr, r);
469 str_append(r, "\n");
470 }
471 menu = prop->menu->parent;
472 for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
473 submenu[i++] = menu;
474 if (i > 0) {
475 str_printf(r, _(" Location:\n"));
476 for (j = 4; --i >= 0; j += 2) {
477 menu = submenu[i];
478 str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
479 if (menu->sym) {
480 str_printf(r, " (%s [=%s])", menu->sym->name ?
481 menu->sym->name : _("<choice>"),
482 sym_get_string_value(menu->sym));
483 }
484 str_append(r, "\n");
485 }
486 }
487}
488
489void get_symbol_str(struct gstr *r, struct symbol *sym)
490{
491 bool hit;
492 struct property *prop;
493
494 if (sym && sym->name)
495 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
496 sym_get_string_value(sym));
497 for_all_prompts(sym, prop)
498 get_prompt_str(r, prop);
499 hit = false;
500 for_all_properties(sym, prop, P_SELECT) {
501 if (!hit) {
502 str_append(r, " Selects: ");
503 hit = true;
504 } else
505 str_printf(r, " && ");
506 expr_gstr_print(prop->expr, r);
507 }
508 if (hit)
509 str_append(r, "\n");
510 if (sym->rev_dep.expr) {
511 str_append(r, _(" Selected by: "));
512 expr_gstr_print(sym->rev_dep.expr, r);
513 str_append(r, "\n");
514 }
515 str_append(r, "\n\n");
516}
517
518void menu_get_ext_help(struct menu *menu, struct gstr *help)
519{
520 struct symbol *sym = menu->sym;
521
522 if (menu_has_help(menu)) {
523 if (sym->name) {
524 str_printf(help, "CONFIG_%s:\n\n", sym->name);
525 str_append(help, _(menu_get_help(menu)));
526 str_append(help, "\n");
527 }
528 } else {
529 str_append(help, nohelp_text);
530 }
531 if (sym)
532 get_symbol_str(help, sym);
533}
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index ce7d508c7520..00c51507cfcc 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1042,12 +1042,10 @@ void ConfigInfoView::menuInfo(void)
1042 if (showDebug()) 1042 if (showDebug())
1043 debug = debug_info(sym); 1043 debug = debug_info(sym);
1044 1044
1045 help = menu_get_help(menu); 1045 struct gstr help_gstr = str_new();
1046 /* Gettextize if the help text not empty */ 1046 menu_get_ext_help(menu, &help_gstr);
1047 if (help.isEmpty()) 1047 help = print_filter(str_get(&help_gstr));
1048 help = print_filter(menu_get_help(menu)); 1048 str_free(&help_gstr);
1049 else
1050 help = print_filter(_(menu_get_help(menu)));
1051 } else if (menu->prompt) { 1049 } else if (menu->prompt) {
1052 head += "<big><b>"; 1050 head += "<big><b>";
1053 head += print_filter(_(menu->prompt->text)); 1051 head += print_filter(_(menu->prompt->text));
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
new file mode 100644
index 000000000000..95984db8e1e0
--- /dev/null
+++ b/scripts/kconfig/streamline_config.pl
@@ -0,0 +1,366 @@
1#!/usr/bin/perl -w
2#
3# Copywrite 2005-2009 - Steven Rostedt
4# Licensed under the terms of the GNU GPL License version 2
5#
6# It's simple enough to figure out how this works.
7# If not, then you can ask me at stripconfig@goodmis.org
8#
9# What it does?
10#
11# If you have installed a Linux kernel from a distribution
12# that turns on way too many modules than you need, and
13# you only want the modules you use, then this program
14# is perfect for you.
15#
16# It gives you the ability to turn off all the modules that are
17# not loaded on your system.
18#
19# Howto:
20#
21# 1. Boot up the kernel that you want to stream line the config on.
22# 2. Change directory to the directory holding the source of the
23# kernel that you just booted.
24# 3. Copy the configuraton file to this directory as .config
25# 4. Have all your devices that you need modules for connected and
26# operational (make sure that their corresponding modules are loaded)
27# 5. Run this script redirecting the output to some other file
28# like config_strip.
29# 6. Back up your old config (if you want too).
30# 7. copy the config_strip file to .config
31# 8. Run "make oldconfig"
32#
33# Now your kernel is ready to be built with only the modules that
34# are loaded.
35#
36# Here's what I did with my Debian distribution.
37#
38# cd /usr/src/linux-2.6.10
39# cp /boot/config-2.6.10-1-686-smp .config
40# ~/bin/streamline_config > config_strip
41# mv .config config_sav
42# mv config_strip .config
43# make oldconfig
44#
45my $config = ".config";
46my $linuxpath = ".";
47
48my $uname = `uname -r`;
49chomp $uname;
50
51my @searchconfigs = (
52 {
53 "file" => ".config",
54 "exec" => "cat",
55 },
56 {
57 "file" => "/proc/config.gz",
58 "exec" => "zcat",
59 },
60 {
61 "file" => "/boot/config-$uname",
62 "exec" => "cat",
63 },
64 {
65 "file" => "/boot/vmlinuz-$uname",
66 "exec" => "scripts/extract-ikconfig",
67 "test" => "scripts/extract-ikconfig",
68 },
69 {
70 "file" => "vmlinux",
71 "exec" => "scripts/extract-ikconfig",
72 "test" => "scripts/extract-ikconfig",
73 },
74 {
75 "file" => "/lib/modules/$uname/kernel/kernel/configs.ko",
76 "exec" => "scripts/extract-ikconfig",
77 "test" => "scripts/extract-ikconfig",
78 },
79 {
80 "file" => "kernel/configs.ko",
81 "exec" => "scripts/extract-ikconfig",
82 "test" => "scripts/extract-ikconfig",
83 },
84 {
85 "file" => "kernel/configs.o",
86 "exec" => "scripts/extract-ikconfig",
87 "test" => "scripts/extract-ikconfig",
88 },
89);
90
91sub find_config {
92 foreach my $conf (@searchconfigs) {
93 my $file = $conf->{"file"};
94
95 next if ( ! -f "$file");
96
97 if (defined($conf->{"test"})) {
98 `$conf->{"test"} $conf->{"file"} 2>/dev/null`;
99 next if ($?);
100 }
101
102 my $exec = $conf->{"exec"};
103
104 print STDERR "using config: '$file'\n";
105
106 open(CIN, "$exec $file |") || die "Failed to run $exec $file";
107 return;
108 }
109 die "No config file found";
110}
111
112find_config;
113
114my @makefiles = `find $linuxpath -name Makefile`;
115my %depends;
116my %selects;
117my %prompts;
118my %objects;
119my $var;
120my $cont = 0;
121
122# Get the top level Kconfig file (passed in)
123my $kconfig = $ARGV[0];
124
125# prevent recursion
126my %read_kconfigs;
127
128sub read_kconfig {
129 my ($kconfig) = @_;
130
131 my $state = "NONE";
132 my $config;
133 my @kconfigs;
134
135 open(KIN, $kconfig) || die "Can't open $kconfig";
136 while (<KIN>) {
137 chomp;
138
139 # collect any Kconfig sources
140 if (/^source\s*"(.*)"/) {
141 $kconfigs[$#kconfigs+1] = $1;
142 }
143
144 # configs found
145 if (/^\s*config\s+(\S+)\s*$/) {
146 $state = "NEW";
147 $config = $1;
148
149 # collect the depends for the config
150 } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
151 $state = "DEP";
152 $depends{$config} = $1;
153 } elsif ($state eq "DEP" && /^\s*depends\s+on\s+(.*)$/) {
154 $depends{$config} .= " " . $1;
155
156 # Get the configs that select this config
157 } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) {
158 if (defined($selects{$1})) {
159 $selects{$1} .= " " . $config;
160 } else {
161 $selects{$1} = $config;
162 }
163
164 # configs without prompts must be selected
165 } elsif ($state ne "NONE" && /^\s*tristate\s\S/) {
166 # note if the config has a prompt
167 $prompt{$config} = 1;
168
169 # stop on "help"
170 } elsif (/^\s*help\s*$/) {
171 $state = "NONE";
172 }
173 }
174 close(KIN);
175
176 # read in any configs that were found.
177 foreach $kconfig (@kconfigs) {
178 if (!defined($read_kconfigs{$kconfig})) {
179 $read_kconfigs{$kconfig} = 1;
180 read_kconfig($kconfig);
181 }
182 }
183}
184
185if ($kconfig) {
186 read_kconfig($kconfig);
187}
188
189# Read all Makefiles to map the configs to the objects
190foreach my $makefile (@makefiles) {
191 chomp $makefile;
192
193 open(MIN,$makefile) || die "Can't open $makefile";
194 while (<MIN>) {
195 my $objs;
196
197 # is this a line after a line with a backslash?
198 if ($cont && /(\S.*)$/) {
199 $objs = $1;
200 }
201 $cont = 0;
202
203 # collect objects after obj-$(CONFIG_FOO_BAR)
204 if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) {
205 $var = $1;
206 $objs = $2;
207 }
208 if (defined($objs)) {
209 # test if the line ends with a backslash
210 if ($objs =~ m,(.*)\\$,) {
211 $objs = $1;
212 $cont = 1;
213 }
214
215 foreach my $obj (split /\s+/,$objs) {
216 $obj =~ s/-/_/g;
217 if ($obj =~ /(.*)\.o$/) {
218 # Objects may bes enabled by more than one config.
219 # Store configs in an array.
220 my @arr;
221
222 if (defined($objects{$1})) {
223 @arr = @{$objects{$1}};
224 }
225
226 $arr[$#arr+1] = $var;
227
228 # The objects have a hash mapping to a reference
229 # of an array of configs.
230 $objects{$1} = \@arr;
231 }
232 }
233 }
234 }
235 close(MIN);
236}
237
238my %modules;
239
240# see what modules are loaded on this system
241open(LIN,"/sbin/lsmod|") || die "Cant lsmod";
242while (<LIN>) {
243 next if (/^Module/); # Skip the first line.
244 if (/^(\S+)/) {
245 $modules{$1} = 1;
246 }
247}
248close (LIN);
249
250# add to the configs hash all configs that are needed to enable
251# a loaded module.
252my %configs;
253foreach my $module (keys(%modules)) {
254 if (defined($objects{$module})) {
255 @arr = @{$objects{$module}};
256 foreach my $conf (@arr) {
257 $configs{$conf} = $module;
258 }
259 } else {
260 # Most likely, someone has a custom (binary?) module loaded.
261 print STDERR "$module config not found!!\n";
262 }
263}
264
265my $valid = "A-Za-z_0-9";
266my $repeat = 1;
267
268#
269# Note, we do not care about operands (like: &&, ||, !) we want to add any
270# config that is in the depend list of another config. This script does
271# not enable configs that are not already enabled. If we come across a
272# config A that depends on !B, we can still add B to the list of depends
273# to keep on. If A was on in the original config, B would not have been
274# and B would not be turned on by this script.
275#
276sub parse_config_dep_select
277{
278 my ($p) = @_;
279
280 while ($p =~ /[$valid]/) {
281
282 if ($p =~ /^[^$valid]*([$valid]+)/) {
283 my $conf = "CONFIG_" . $1;
284
285 $p =~ s/^[^$valid]*[$valid]+//;
286
287 if (!defined($configs{$conf})) {
288 # We must make sure that this config has its
289 # dependencies met.
290 $repeat = 1; # do again
291 $configs{$conf} = 1;
292 }
293 } else {
294 die "this should never happen";
295 }
296 }
297}
298
299while ($repeat) {
300 $repeat = 0;
301
302 foreach my $config (keys %configs) {
303 $config =~ s/^CONFIG_//;
304
305 if (defined($depends{$config})) {
306 # This config has dependencies. Make sure they are also included
307 parse_config_dep_select $depends{$config};
308 }
309
310 if (defined($prompt{$config}) || !defined($selects{$config})) {
311 next;
312 }
313
314 # config has no prompt and must be selected.
315 parse_config_dep_select $selects{$config};
316 }
317}
318
319my %setconfigs;
320
321# Finally, read the .config file and turn off any module enabled that
322# we could not find a reason to keep enabled.
323while(<CIN>) {
324
325 if (/CONFIG_IKCONFIG/) {
326 if (/# CONFIG_IKCONFIG is not set/) {
327 # enable IKCONFIG at least as a module
328 print "CONFIG_IKCONFIG=m\n";
329 # don't ask about PROC
330 print "# CONFIG_IKCONFIG_PROC is not set\n";
331 } else {
332 print;
333 }
334 next;
335 }
336
337 if (/^(CONFIG.*)=(m|y)/) {
338 if (defined($configs{$1})) {
339 $setconfigs{$1} = $2;
340 } elsif ($2 eq "m") {
341 print "# $1 is not set\n";
342 next;
343 }
344 }
345 print;
346}
347close(CIN);
348
349# Integrity check, make sure all modules that we want enabled do
350# indeed have their configs set.
351loop:
352foreach my $module (keys(%modules)) {
353 if (defined($objects{$module})) {
354 my @arr = @{$objects{$module}};
355 foreach my $conf (@arr) {
356 if (defined($setconfigs{$conf})) {
357 next loop;
358 }
359 }
360 print STDERR "module $module did not have configs";
361 foreach my $conf (@arr) {
362 print STDERR " " , $conf;
363 }
364 print STDERR "\n";
365 }
366}
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 18f3e5c33634..6c8fbbb66ebc 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -36,7 +36,7 @@ tristate modules_val;
36 36
37struct expr *sym_env_list; 37struct expr *sym_env_list;
38 38
39void sym_add_default(struct symbol *sym, const char *def) 39static void sym_add_default(struct symbol *sym, const char *def)
40{ 40{
41 struct property *prop = prop_alloc(P_DEFAULT, sym); 41 struct property *prop = prop_alloc(P_DEFAULT, sym);
42 42
@@ -125,7 +125,7 @@ struct property *sym_get_default_prop(struct symbol *sym)
125 return NULL; 125 return NULL;
126} 126}
127 127
128struct property *sym_get_range_prop(struct symbol *sym) 128static struct property *sym_get_range_prop(struct symbol *sym)
129{ 129{
130 struct property *prop; 130 struct property *prop;
131 131
@@ -943,7 +943,7 @@ const char *prop_get_type_name(enum prop_type type)
943 return "unknown"; 943 return "unknown";
944} 944}
945 945
946void prop_add_env(const char *env) 946static void prop_add_env(const char *env)
947{ 947{
948 struct symbol *sym, *sym2; 948 struct symbol *sym, *sym2;
949 struct property *prop; 949 struct property *prop;