comparison kconfig/confdata.c @ 111:a3b8838c3908

Apply uClibc's changes to this kconfig.
author Rob Landley <rob@landley.net>
date Thu, 15 Mar 2007 13:59:06 -0400
parents 4d21d59f3206
children
comparison
equal deleted inserted replaced
110:db63b2829eda 111:a3b8838c3908
23 static const char *conf_filename; 23 static const char *conf_filename;
24 static int conf_lineno, conf_warnings, conf_unsaved; 24 static int conf_lineno, conf_warnings, conf_unsaved;
25 25
26 #ifndef conf_defname 26 #ifndef conf_defname
27 const char conf_defname[] = "arch/$ARCH/defconfig"; 27 const char conf_defname[] = "arch/$ARCH/defconfig";
28 #endif
29
30 #ifndef CONFIG_PREFIX
31 #define CONFIG_PREFIX "CONFIG_"
28 #endif 32 #endif
29 33
30 static void conf_warning(const char *fmt, ...) 34 static void conf_warning(const char *fmt, ...)
31 { 35 {
32 va_list ap; 36 va_list ap;
152 while (fgets(line, sizeof(line), in)) { 156 while (fgets(line, sizeof(line), in)) {
153 conf_lineno++; 157 conf_lineno++;
154 sym = NULL; 158 sym = NULL;
155 switch (line[0]) { 159 switch (line[0]) {
156 case '#': 160 case '#':
157 if (memcmp(line + 2, "CONFIG_", 7)) 161 if (line[1]!=' ' || memcmp(line + 2, CONFIG_PREFIX,
162 strlen(CONFIG_PREFIX))) {
158 continue; 163 continue;
159 p = strchr(line + 9, ' '); 164 }
165 p = strchr(line + 2 + strlen(CONFIG_PREFIX), ' ');
160 if (!p) 166 if (!p)
161 continue; 167 continue;
162 *p++ = 0; 168 *p++ = 0;
163 if (strncmp(p, "is not set", 10)) 169 if (strncmp(p, "is not set", 10))
164 continue; 170 continue;
165 if (def == S_DEF_USER) { 171 if (def == S_DEF_USER) {
166 sym = sym_find(line + 9); 172 sym = sym_find(line + 2 + strlen(CONFIG_PREFIX));
167 if (!sym) { 173 if (!sym) {
168 conf_warning("trying to assign nonexistent symbol %s", line + 9); 174 conf_warning("trying to assign nonexistent symbol %s", line + 2 + strlen(CONFIG_PREFIX));
169 break; 175 break;
170 } 176 }
171 } else { 177 } else {
172 sym = sym_lookup(line + 9, 0); 178 sym = sym_lookup(line + 9, 0);
173 if (sym->type == S_UNKNOWN) 179 if (sym->type == S_UNKNOWN)
185 break; 191 break;
186 default: 192 default:
187 ; 193 ;
188 } 194 }
189 break; 195 break;
190 case 'C': 196 case 'A' ... 'Z':
191 if (memcmp(line, "CONFIG_", 7)) { 197 if (memcmp(line, CONFIG_PREFIX, strlen(CONFIG_PREFIX))) {
192 conf_warning("unexpected data"); 198 conf_warning("unexpected data");
193 continue; 199 continue;
194 } 200 }
195 p = strchr(line + 7, '='); 201 p = strchr(line + strlen(CONFIG_PREFIX), '=');
196 if (!p) 202 if (!p)
197 continue; 203 continue;
198 *p++ = 0; 204 *p++ = 0;
199 p2 = strchr(p, '\n'); 205 p2 = strchr(p, '\n');
200 if (p2) { 206 if (p2) {
201 *p2-- = 0; 207 *p2-- = 0;
202 if (*p2 == '\r') 208 if (*p2 == '\r')
203 *p2 = 0; 209 *p2 = 0;
204 } 210 }
205 if (def == S_DEF_USER) { 211 if (def == S_DEF_USER) {
206 sym = sym_find(line + 7); 212 sym = sym_find(line + strlen(CONFIG_PREFIX));
207 if (!sym) { 213 if (!sym) {
208 conf_warning("trying to assign nonexistent symbol %s", line + 7); 214 conf_warning("trying to assign nonexistent symbol %s", line + 7);
209 break; 215 break;
210 } 216 }
211 } else { 217 } else {
212 sym = sym_lookup(line + 7, 0); 218 sym = sym_lookup(line + strlen(CONFIG_PREFIX), 0);
213 if (sym->type == S_UNKNOWN) 219 if (sym->type == S_UNKNOWN)
214 sym->type = S_OTHER; 220 sym->type = S_OTHER;
215 } 221 }
216 if (sym->flags & def_flags) { 222 if (sym->flags & def_flags) {
217 conf_warning("trying to reassign symbol %s", sym->name); 223 conf_warning("trying to reassign symbol %s", sym->name);
433 out = fopen(newname, "w"); 439 out = fopen(newname, "w");
434 } 440 }
435 if (!out) 441 if (!out)
436 return 1; 442 return 1;
437 443
438 sym = sym_lookup("KERNELVERSION", 0); 444 sym = sym_lookup("KCONFIG_VERSION", 0);
439 sym_calc_value(sym); 445 sym_calc_value(sym);
440 time(&now); 446 time(&now);
441 env = getenv("KCONFIG_NOTIMESTAMP"); 447 env = getenv("KCONFIG_NOTIMESTAMP");
442 if (env && *env) 448 if (env && *env)
443 use_timestamp = 0; 449 use_timestamp = 0;
490 switch (type) { 496 switch (type) {
491 case S_BOOLEAN: 497 case S_BOOLEAN:
492 case S_TRISTATE: 498 case S_TRISTATE:
493 switch (sym_get_tristate_value(sym)) { 499 switch (sym_get_tristate_value(sym)) {
494 case no: 500 case no:
495 fprintf(out, "# CONFIG_%s is not set\n", sym->name); 501 fprintf(out, "# "CONFIG_PREFIX"%s is not set\n", sym->name);
496 break; 502 break;
497 case mod: 503 case mod:
498 fprintf(out, "CONFIG_%s=m\n", sym->name); 504 fprintf(out, CONFIG_PREFIX"%s=m\n", sym->name);
499 break; 505 break;
500 case yes: 506 case yes:
501 fprintf(out, "CONFIG_%s=y\n", sym->name); 507 fprintf(out, CONFIG_PREFIX"%s=y\n", sym->name);
502 break; 508 break;
503 } 509 }
504 break; 510 break;
505 case S_STRING: 511 case S_STRING:
506 str = sym_get_string_value(sym); 512 str = sym_get_string_value(sym);
507 fprintf(out, "CONFIG_%s=\"", sym->name); 513 fprintf(out, CONFIG_PREFIX"%s=\"", sym->name);
508 while (1) { 514 while (1) {
509 l = strcspn(str, "\"\\"); 515 l = strcspn(str, "\"\\");
510 if (l) { 516 if (l) {
511 fwrite(str, l, 1, out); 517 fwrite(str, l, 1, out);
512 str += l; 518 str += l;
518 fputs("\"\n", out); 524 fputs("\"\n", out);
519 break; 525 break;
520 case S_HEX: 526 case S_HEX:
521 str = sym_get_string_value(sym); 527 str = sym_get_string_value(sym);
522 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { 528 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
523 fprintf(out, "CONFIG_%s=%s\n", sym->name, *str ? str : "0"); 529 fprintf(out, CONFIG_PREFIX"%s=%s\n", sym->name, *str ? str : "0");
524 break; 530 break;
525 } 531 }
526 case S_INT: 532 case S_INT:
527 str = sym_get_string_value(sym); 533 str = sym_get_string_value(sym);
528 fprintf(out, "CONFIG_%s=%s\n", sym->name, *str ? str : "0"); 534 fprintf(out, CONFIG_PREFIX"%s=%s\n", sym->name, *str ? str : "0");
529 break; 535 break;
530 } 536 }
531 } 537 }
532 538
533 next: 539 next:
703 if (!out_h) { 709 if (!out_h) {
704 fclose(out); 710 fclose(out);
705 return 1; 711 return 1;
706 } 712 }
707 713
708 sym = sym_lookup("KERNELVERSION", 0); 714 sym = sym_lookup("KCONFIG_VERSION", 0);
709 sym_calc_value(sym); 715 sym_calc_value(sym);
710 time(&now); 716 time(&now);
711 fprintf(out, "#\n" 717 fprintf(out, "#\n"
712 "# Automatically generated make config: don't edit\n" 718 "# Automatically generated make config: don't edit\n"
713 "# "PROJECT_NAME" version: %s\n" 719 "# "PROJECT_NAME" version: %s\n"
717 fprintf(out_h, "/*\n" 723 fprintf(out_h, "/*\n"
718 " * Automatically generated C config: don't edit\n" 724 " * Automatically generated C config: don't edit\n"
719 " * "PROJECT_NAME" version: %s\n" 725 " * "PROJECT_NAME" version: %s\n"
720 " * %s" 726 " * %s"
721 " */\n" 727 " */\n"
722 "#define AUTOCONF_INCLUDED\n", 728 // "#define AUTOCONF_INCLUDED\n"
723 sym_get_string_value(sym), ctime(&now)); 729 , sym_get_string_value(sym), ctime(&now));
724 730
725 for_all_symbols(i, sym) { 731 for_all_symbols(i, sym) {
726 sym_calc_value(sym); 732 sym_calc_value(sym);
727 if (!(sym->flags & SYMBOL_WRITE) || !sym->name) 733 if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
728 continue; 734 continue;
731 case S_TRISTATE: 737 case S_TRISTATE:
732 switch (sym_get_tristate_value(sym)) { 738 switch (sym_get_tristate_value(sym)) {
733 case no: 739 case no:
734 break; 740 break;
735 case mod: 741 case mod:
736 fprintf(out, "CONFIG_%s=m\n", sym->name); 742 fprintf(out, CONFIG_PREFIX"%s=m\n", sym->name);
737 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); 743 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name);
738 break; 744 break;
739 case yes: 745 case yes:
740 fprintf(out, "CONFIG_%s=y\n", sym->name); 746 fprintf(out, CONFIG_PREFIX"%s=y\n", sym->name);
741 fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); 747 fprintf(out_h, "#define "CONFIG_PREFIX"%s 1\n", sym->name);
742 break; 748 break;
743 } 749 }
744 break; 750 break;
745 case S_STRING: 751 case S_STRING:
746 str = sym_get_string_value(sym); 752 str = sym_get_string_value(sym);
747 fprintf(out, "CONFIG_%s=\"", sym->name); 753 fprintf(out, CONFIG_PREFIX"%s=\"", sym->name);
748 fprintf(out_h, "#define CONFIG_%s \"", sym->name); 754 fprintf(out_h, "#define "CONFIG_PREFIX"%s \"", sym->name);
749 while (1) { 755 while (1) {
750 l = strcspn(str, "\"\\"); 756 l = strcspn(str, "\"\\");
751 if (l) { 757 if (l) {
752 fwrite(str, l, 1, out); 758 fwrite(str, l, 1, out);
753 fwrite(str, l, 1, out_h); 759 fwrite(str, l, 1, out_h);
763 fputs("\"\n", out_h); 769 fputs("\"\n", out_h);
764 break; 770 break;
765 case S_HEX: 771 case S_HEX:
766 str = sym_get_string_value(sym); 772 str = sym_get_string_value(sym);
767 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { 773 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
768 fprintf(out, "CONFIG_%s=%s\n", sym->name, str); 774 fprintf(out, CONFIG_PREFIX"%s=%s\n", sym->name, str);
769 fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); 775 fprintf(out_h, "#define "CONFIG_PREFIX"%s 0x%s\n", sym->name, str);
770 break; 776 break;
771 } 777 }
772 case S_INT: 778 case S_INT:
773 str = sym_get_string_value(sym); 779 str = sym_get_string_value(sym);
774 fprintf(out, "CONFIG_%s=%s\n", sym->name, str); 780 fprintf(out, CONFIG_PREFIX"%s=%s\n", sym->name, str);
775 fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); 781 fprintf(out_h, "#define "CONFIG_PREFIX"%s %s\n", sym->name, str);
776 break; 782 break;
777 default: 783 default:
778 break; 784 break;
779 } 785 }
780 } 786 }