aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/confdata.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /scripts/kconfig/confdata.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'scripts/kconfig/confdata.c')
-rw-r--r--scripts/kconfig/confdata.c167
1 files changed, 81 insertions, 86 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 515253fe46cf..2bafd9a7c8da 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -5,6 +5,7 @@
5 5
6#include <sys/stat.h> 6#include <sys/stat.h>
7#include <ctype.h> 7#include <ctype.h>
8#include <errno.h>
8#include <fcntl.h> 9#include <fcntl.h>
9#include <stdio.h> 10#include <stdio.h>
10#include <stdlib.h> 11#include <stdlib.h>
@@ -18,6 +19,9 @@
18static void conf_warning(const char *fmt, ...) 19static void conf_warning(const char *fmt, ...)
19 __attribute__ ((format (printf, 1, 2))); 20 __attribute__ ((format (printf, 1, 2)));
20 21
22static void conf_message(const char *fmt, ...)
23 __attribute__ ((format (printf, 1, 2)));
24
21static const char *conf_filename; 25static const char *conf_filename;
22static int conf_lineno, conf_warnings, conf_unsaved; 26static int conf_lineno, conf_warnings, conf_unsaved;
23 27
@@ -34,6 +38,29 @@ static void conf_warning(const char *fmt, ...)
34 conf_warnings++; 38 conf_warnings++;
35} 39}
36 40
41static void conf_default_message_callback(const char *fmt, va_list ap)
42{
43 printf("#\n# ");
44 vprintf(fmt, ap);
45 printf("\n#\n");
46}
47
48static void (*conf_message_callback) (const char *fmt, va_list ap) =
49 conf_default_message_callback;
50void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))
51{
52 conf_message_callback = fn;
53}
54
55static void conf_message(const char *fmt, ...)
56{
57 va_list ap;
58
59 va_start(ap, fmt);
60 if (conf_message_callback)
61 conf_message_callback(fmt, ap);
62}
63
37const char *conf_get_configname(void) 64const char *conf_get_configname(void)
38{ 65{
39 char *name = getenv("KCONFIG_CONFIG"); 66 char *name = getenv("KCONFIG_CONFIG");
@@ -183,9 +210,8 @@ int conf_read_simple(const char *name, int def)
183 name = conf_expand_value(prop->expr->left.sym->name); 210 name = conf_expand_value(prop->expr->left.sym->name);
184 in = zconf_fopen(name); 211 in = zconf_fopen(name);
185 if (in) { 212 if (in) {
186 printf(_("#\n" 213 conf_message(_("using defaults found in %s"),
187 "# using defaults found in %s\n" 214 name);
188 "#\n"), name);
189 goto load; 215 goto load;
190 } 216 }
191 } 217 }
@@ -220,24 +246,23 @@ load:
220 while (fgets(line, sizeof(line), in)) { 246 while (fgets(line, sizeof(line), in)) {
221 conf_lineno++; 247 conf_lineno++;
222 sym = NULL; 248 sym = NULL;
223 switch (line[0]) { 249 if (line[0] == '#') {
224 case '#': 250 if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
225 if (memcmp(line + 2, "CONFIG_", 7))
226 continue; 251 continue;
227 p = strchr(line + 9, ' '); 252 p = strchr(line + 2 + strlen(CONFIG_), ' ');
228 if (!p) 253 if (!p)
229 continue; 254 continue;
230 *p++ = 0; 255 *p++ = 0;
231 if (strncmp(p, "is not set", 10)) 256 if (strncmp(p, "is not set", 10))
232 continue; 257 continue;
233 if (def == S_DEF_USER) { 258 if (def == S_DEF_USER) {
234 sym = sym_find(line + 9); 259 sym = sym_find(line + 2 + strlen(CONFIG_));
235 if (!sym) { 260 if (!sym) {
236 sym_add_change_count(1); 261 sym_add_change_count(1);
237 break; 262 goto setsym;
238 } 263 }
239 } else { 264 } else {
240 sym = sym_lookup(line + 9, 0); 265 sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
241 if (sym->type == S_UNKNOWN) 266 if (sym->type == S_UNKNOWN)
242 sym->type = S_BOOLEAN; 267 sym->type = S_BOOLEAN;
243 } 268 }
@@ -253,13 +278,8 @@ load:
253 default: 278 default:
254 ; 279 ;
255 } 280 }
256 break; 281 } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
257 case 'C': 282 p = strchr(line + strlen(CONFIG_), '=');
258 if (memcmp(line, "CONFIG_", 7)) {
259 conf_warning("unexpected data");
260 continue;
261 }
262 p = strchr(line + 7, '=');
263 if (!p) 283 if (!p)
264 continue; 284 continue;
265 *p++ = 0; 285 *p++ = 0;
@@ -270,13 +290,13 @@ load:
270 *p2 = 0; 290 *p2 = 0;
271 } 291 }
272 if (def == S_DEF_USER) { 292 if (def == S_DEF_USER) {
273 sym = sym_find(line + 7); 293 sym = sym_find(line + strlen(CONFIG_));
274 if (!sym) { 294 if (!sym) {
275 sym_add_change_count(1); 295 sym_add_change_count(1);
276 break; 296 goto setsym;
277 } 297 }
278 } else { 298 } else {
279 sym = sym_lookup(line + 7, 0); 299 sym = sym_lookup(line + strlen(CONFIG_), 0);
280 if (sym->type == S_UNKNOWN) 300 if (sym->type == S_UNKNOWN)
281 sym->type = S_OTHER; 301 sym->type = S_OTHER;
282 } 302 }
@@ -285,14 +305,12 @@ load:
285 } 305 }
286 if (conf_set_sym_val(sym, def, def_flags, p)) 306 if (conf_set_sym_val(sym, def, def_flags, p))
287 continue; 307 continue;
288 break; 308 } else {
289 case '\r': 309 if (line[0] != '\r' && line[0] != '\n')
290 case '\n': 310 conf_warning("unexpected data");
291 break;
292 default:
293 conf_warning("unexpected data");
294 continue; 311 continue;
295 } 312 }
313setsym:
296 if (sym && sym_is_choice_value(sym)) { 314 if (sym && sym_is_choice_value(sym)) {
297 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); 315 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
298 switch (sym->def[def].tri) { 316 switch (sym->def[def].tri) {
@@ -405,9 +423,9 @@ static void conf_write_string(bool headerfile, const char *name,
405{ 423{
406 int l; 424 int l;
407 if (headerfile) 425 if (headerfile)
408 fprintf(out, "#define CONFIG_%s \"", name); 426 fprintf(out, "#define %s%s \"", CONFIG_, name);
409 else 427 else
410 fprintf(out, "CONFIG_%s=\"", name); 428 fprintf(out, "%s%s=\"", CONFIG_, name);
411 429
412 while (1) { 430 while (1) {
413 l = strcspn(str, "\"\\"); 431 l = strcspn(str, "\"\\");
@@ -422,24 +440,24 @@ static void conf_write_string(bool headerfile, const char *name,
422 fputs("\"\n", out); 440 fputs("\"\n", out);
423} 441}
424 442
425static void conf_write_symbol(struct symbol *sym, enum symbol_type type, 443static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no)
426 FILE *out, bool write_no)
427{ 444{
428 const char *str; 445 const char *str;
429 446
430 switch (type) { 447 switch (sym->type) {
431 case S_BOOLEAN: 448 case S_BOOLEAN:
432 case S_TRISTATE: 449 case S_TRISTATE:
433 switch (sym_get_tristate_value(sym)) { 450 switch (sym_get_tristate_value(sym)) {
434 case no: 451 case no:
435 if (write_no) 452 if (write_no)
436 fprintf(out, "# CONFIG_%s is not set\n", sym->name); 453 fprintf(out, "# %s%s is not set\n",
454 CONFIG_, sym->name);
437 break; 455 break;
438 case mod: 456 case mod:
439 fprintf(out, "CONFIG_%s=m\n", sym->name); 457 fprintf(out, "%s%s=m\n", CONFIG_, sym->name);
440 break; 458 break;
441 case yes: 459 case yes:
442 fprintf(out, "CONFIG_%s=y\n", sym->name); 460 fprintf(out, "%s%s=y\n", CONFIG_, sym->name);
443 break; 461 break;
444 } 462 }
445 break; 463 break;
@@ -449,7 +467,7 @@ static void conf_write_symbol(struct symbol *sym, enum symbol_type type,
449 case S_HEX: 467 case S_HEX:
450 case S_INT: 468 case S_INT:
451 str = sym_get_string_value(sym); 469 str = sym_get_string_value(sym);
452 fprintf(out, "CONFIG_%s=%s\n", sym->name, str); 470 fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str);
453 break; 471 break;
454 case S_OTHER: 472 case S_OTHER:
455 case S_UNKNOWN: 473 case S_UNKNOWN:
@@ -513,7 +531,7 @@ int conf_write_defconfig(const char *filename)
513 goto next_menu; 531 goto next_menu;
514 } 532 }
515 } 533 }
516 conf_write_symbol(sym, sym->type, out, true); 534 conf_write_symbol(sym, out, true);
517 } 535 }
518next_menu: 536next_menu:
519 if (menu->list != NULL) { 537 if (menu->list != NULL) {
@@ -541,10 +559,7 @@ int conf_write(const char *name)
541 struct menu *menu; 559 struct menu *menu;
542 const char *basename; 560 const char *basename;
543 const char *str; 561 const char *str;
544 char dirname[128], tmpname[128], newname[128]; 562 char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
545 enum symbol_type type;
546 time_t now;
547 int use_timestamp = 1;
548 char *env; 563 char *env;
549 564
550 dirname[0] = 0; 565 dirname[0] = 0;
@@ -581,21 +596,11 @@ int conf_write(const char *name)
581 if (!out) 596 if (!out)
582 return 1; 597 return 1;
583 598
584 sym = sym_lookup("KERNELVERSION", 0);
585 sym_calc_value(sym);
586 time(&now);
587 env = getenv("KCONFIG_NOTIMESTAMP");
588 if (env && *env)
589 use_timestamp = 0;
590
591 fprintf(out, _("#\n" 599 fprintf(out, _("#\n"
592 "# Automatically generated make config: don't edit\n" 600 "# Automatically generated make config: don't edit\n"
593 "# Linux kernel version: %s\n" 601 "# %s\n"
594 "%s%s"
595 "#\n"), 602 "#\n"),
596 sym_get_string_value(sym), 603 rootmenu.prompt->text);
597 use_timestamp ? "# " : "",
598 use_timestamp ? ctime(&now) : "");
599 604
600 if (!conf_get_changed()) 605 if (!conf_get_changed())
601 sym_clear_all_valid(); 606 sym_clear_all_valid();
@@ -616,14 +621,8 @@ int conf_write(const char *name)
616 if (!(sym->flags & SYMBOL_WRITE)) 621 if (!(sym->flags & SYMBOL_WRITE))
617 goto next; 622 goto next;
618 sym->flags &= ~SYMBOL_WRITE; 623 sym->flags &= ~SYMBOL_WRITE;
619 type = sym->type;
620 if (type == S_TRISTATE) {
621 sym_calc_value(modules_sym);
622 if (modules_sym->curr.tri == no)
623 type = S_BOOLEAN;
624 }
625 /* Write config symbol to file */ 624 /* Write config symbol to file */
626 conf_write_symbol(sym, type, out, true); 625 conf_write_symbol(sym, out, true);
627 } 626 }
628 627
629next: 628next:
@@ -650,9 +649,7 @@ next:
650 return 1; 649 return 1;
651 } 650 }
652 651
653 printf(_("#\n" 652 conf_message(_("configuration written to %s"), newname);
654 "# configuration written to %s\n"
655 "#\n"), newname);
656 653
657 sym_set_change_count(0); 654 sym_set_change_count(0);
658 655
@@ -662,7 +659,7 @@ next:
662static int conf_split_config(void) 659static int conf_split_config(void)
663{ 660{
664 const char *name; 661 const char *name;
665 char path[128]; 662 char path[PATH_MAX+1];
666 char *s, *d, c; 663 char *s, *d, c;
667 struct symbol *sym; 664 struct symbol *sym;
668 struct stat sb; 665 struct stat sb;
@@ -777,7 +774,6 @@ int conf_write_autoconf(void)
777 const char *str; 774 const char *str;
778 const char *name; 775 const char *name;
779 FILE *out, *tristate, *out_h; 776 FILE *out, *tristate, *out_h;
780 time_t now;
781 int i; 777 int i;
782 778
783 sym_clear_all_valid(); 779 sym_clear_all_valid();
@@ -804,25 +800,19 @@ int conf_write_autoconf(void)
804 return 1; 800 return 1;
805 } 801 }
806 802
807 sym = sym_lookup("KERNELVERSION", 0);
808 sym_calc_value(sym);
809 time(&now);
810 fprintf(out, "#\n" 803 fprintf(out, "#\n"
811 "# Automatically generated make config: don't edit\n" 804 "# Automatically generated make config: don't edit\n"
812 "# Linux kernel version: %s\n" 805 "# %s\n"
813 "# %s"
814 "#\n", 806 "#\n",
815 sym_get_string_value(sym), ctime(&now)); 807 rootmenu.prompt->text);
816 fprintf(tristate, "#\n" 808 fprintf(tristate, "#\n"
817 "# Automatically generated - do not edit\n" 809 "# Automatically generated - do not edit\n"
818 "\n"); 810 "\n");
819 fprintf(out_h, "/*\n" 811 fprintf(out_h, "/*\n"
820 " * Automatically generated C config: don't edit\n" 812 " * Automatically generated C config: don't edit\n"
821 " * Linux kernel version: %s\n" 813 " * %s\n"
822 " * %s" 814 " */\n",
823 " */\n" 815 rootmenu.prompt->text);
824 "#define AUTOCONF_INCLUDED\n",
825 sym_get_string_value(sym), ctime(&now));
826 816
827 for_all_symbols(i, sym) { 817 for_all_symbols(i, sym) {
828 sym_calc_value(sym); 818 sym_calc_value(sym);
@@ -830,7 +820,7 @@ int conf_write_autoconf(void)
830 continue; 820 continue;
831 821
832 /* write symbol to config file */ 822 /* write symbol to config file */
833 conf_write_symbol(sym, sym->type, out, false); 823 conf_write_symbol(sym, out, false);
834 824
835 /* update autoconf and tristate files */ 825 /* update autoconf and tristate files */
836 switch (sym->type) { 826 switch (sym->type) {
@@ -840,14 +830,17 @@ int conf_write_autoconf(void)
840 case no: 830 case no:
841 break; 831 break;
842 case mod: 832 case mod:
843 fprintf(tristate, "CONFIG_%s=M\n", sym->name); 833 fprintf(tristate, "%s%s=M\n",
844 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); 834 CONFIG_, sym->name);
835 fprintf(out_h, "#define %s%s_MODULE 1\n",
836 CONFIG_, sym->name);
845 break; 837 break;
846 case yes: 838 case yes:
847 if (sym->type == S_TRISTATE) 839 if (sym->type == S_TRISTATE)
848 fprintf(tristate, "CONFIG_%s=Y\n", 840 fprintf(tristate,"%s%s=Y\n",
849 sym->name); 841 CONFIG_, sym->name);
850 fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); 842 fprintf(out_h, "#define %s%s 1\n",
843 CONFIG_, sym->name);
851 break; 844 break;
852 } 845 }
853 break; 846 break;
@@ -857,12 +850,14 @@ int conf_write_autoconf(void)
857 case S_HEX: 850 case S_HEX:
858 str = sym_get_string_value(sym); 851 str = sym_get_string_value(sym);
859 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { 852 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
860 fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); 853 fprintf(out_h, "#define %s%s 0x%s\n",
854 CONFIG_, sym->name, str);
861 break; 855 break;
862 } 856 }
863 case S_INT: 857 case S_INT:
864 str = sym_get_string_value(sym); 858 str = sym_get_string_value(sym);
865 fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); 859 fprintf(out_h, "#define %s%s %s\n",
860 CONFIG_, sym->name, str);
866 break; 861 break;
867 default: 862 default:
868 break; 863 break;
@@ -928,7 +923,7 @@ static void randomize_choice_values(struct symbol *csym)
928 int cnt, def; 923 int cnt, def;
929 924
930 /* 925 /*
931 * If choice is mod then we may have more items slected 926 * If choice is mod then we may have more items selected
932 * and if no then no-one. 927 * and if no then no-one.
933 * In both cases stop. 928 * In both cases stop.
934 */ 929 */
@@ -1024,10 +1019,10 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
1024 1019
1025 /* 1020 /*
1026 * We have different type of choice blocks. 1021 * We have different type of choice blocks.
1027 * If curr.tri equal to mod then we can select several 1022 * If curr.tri equals to mod then we can select several
1028 * choice symbols in one block. 1023 * choice symbols in one block.
1029 * In this case we do nothing. 1024 * In this case we do nothing.
1030 * If curr.tri equal yes then only one symbol can be 1025 * If curr.tri equals yes then only one symbol can be
1031 * selected in a choice block and we set it to yes, 1026 * selected in a choice block and we set it to yes,
1032 * and the rest to no. 1027 * and the rest to no.
1033 */ 1028 */