author | kergoth <kergoth> | 2003-01-16 18:04:11 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-01-16 18:04:11 (UTC) |
commit | 3904d85eac20dfd21cf2a3245977f9946865fd92 (patch) (unidiff) | |
tree | 8d5b2217c1b54a0c439815ec02db3f5235c99daa /scripts/kconfig/confdata.c | |
parent | 0eec393ef2dd8b43db96c86e80e307f73a771fae (diff) | |
download | opie-3904d85eac20dfd21cf2a3245977f9946865fd92.zip opie-3904d85eac20dfd21cf2a3245977f9946865fd92.tar.gz opie-3904d85eac20dfd21cf2a3245977f9946865fd92.tar.bz2 |
Update LinuxKernelConf to 1.3, latest available.
-rw-r--r-- | scripts/kconfig/confdata.c | 74 |
1 files changed, 46 insertions, 28 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 0f5fd97..9bf7af9 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -1,29 +1,28 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
3 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <sys/stat.h> | ||
6 | #include <ctype.h> | 7 | #include <ctype.h> |
7 | #include <limits.h> | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | #include <string.h> | 10 | #include <string.h> |
11 | #include <unistd.h> | 11 | #include <unistd.h> |
12 | 12 | ||
13 | #define LKC_DIRECT_LINK | 13 | #define LKC_DIRECT_LINK |
14 | #include "lkc.h" | 14 | #include "lkc.h" |
15 | 15 | ||
16 | const char conf_def_filename[] = ".config"; | 16 | const char conf_def_filename[] = ".config"; |
17 | char conf_filename[PATH_MAX+1]; | ||
18 | 17 | ||
19 | const char conf_defname[] = "arch/$ARCH/defconfig"; | 18 | const char conf_defname[] = "arch/$ARCH/defconfig"; |
20 | 19 | ||
21 | const char *conf_confnames[] = { | 20 | const char *conf_confnames[] = { |
22 | ".config", | 21 | ".config", |
23 | "/lib/modules/$UNAME_RELEASE/.config", | 22 | "/lib/modules/$UNAME_RELEASE/.config", |
24 | "/etc/kernel-config", | 23 | "/etc/kernel-config", |
25 | "/boot/config-$UNAME_RELEASE", | 24 | "/boot/config-$UNAME_RELEASE", |
26 | conf_defname, | 25 | conf_defname, |
27 | NULL, | 26 | NULL, |
28 | }; | 27 | }; |
29 | 28 | ||
@@ -46,143 +45,163 @@ static char *conf_expand_value(const char *in) | |||
46 | sym = sym_lookup(name, 0); | 45 | sym = sym_lookup(name, 0); |
47 | sym_calc_value(sym); | 46 | sym_calc_value(sym); |
48 | strcat(res_value, sym_get_string_value(sym)); | 47 | strcat(res_value, sym_get_string_value(sym)); |
49 | in = src; | 48 | in = src; |
50 | } | 49 | } |
51 | strcat(res_value, in); | 50 | strcat(res_value, in); |
52 | 51 | ||
53 | return res_value; | 52 | return res_value; |
54 | } | 53 | } |
55 | 54 | ||
56 | char *conf_get_default_confname(void) | 55 | char *conf_get_default_confname(void) |
57 | { | 56 | { |
58 | return conf_expand_value(conf_defname); | 57 | struct stat buf; |
58 | static char fullname[PATH_MAX+1]; | ||
59 | char *env, *name; | ||
60 | |||
61 | name = conf_expand_value(conf_defname); | ||
62 | env = getenv(SRCTREE); | ||
63 | if (env) { | ||
64 | sprintf(fullname, "%s/%s", env, name); | ||
65 | if (!stat(fullname, &buf)) | ||
66 | return fullname; | ||
67 | } | ||
68 | return name; | ||
59 | } | 69 | } |
60 | 70 | ||
61 | int conf_read(const char *name) | 71 | int conf_read(const char *name) |
62 | { | 72 | { |
63 | FILE *in = NULL; | 73 | FILE *in = NULL; |
64 | char line[128]; | 74 | char line[1024]; |
65 | char *p, *p2; | 75 | char *p, *p2; |
66 | int lineno = 0; | 76 | int lineno = 0; |
67 | struct symbol *sym; | 77 | struct symbol *sym; |
68 | struct property *prop; | 78 | struct property *prop; |
69 | struct expr *e; | 79 | struct expr *e; |
70 | int i; | 80 | int i; |
71 | 81 | ||
72 | if (name) { | 82 | if (name) { |
73 | in = fopen(name, "r"); | 83 | in = zconf_fopen(name); |
74 | if (in) | ||
75 | strcpy(conf_filename, name); | ||
76 | } else { | 84 | } else { |
77 | const char **names = conf_confnames; | 85 | const char **names = conf_confnames; |
78 | while ((name = *names++)) { | 86 | while ((name = *names++)) { |
79 | name = conf_expand_value(name); | 87 | name = conf_expand_value(name); |
80 | in = fopen(name, "r"); | 88 | in = zconf_fopen(name); |
81 | if (in) { | 89 | if (in) { |
82 | printf("#\n" | 90 | printf("#\n" |
83 | "# using defaults found in %s\n" | 91 | "# using defaults found in %s\n" |
84 | "#\n", name); | 92 | "#\n", name); |
85 | break; | 93 | break; |
86 | } | 94 | } |
87 | } | 95 | } |
88 | } | 96 | } |
89 | 97 | ||
90 | if (!in) | 98 | if (!in) |
91 | return 1; | 99 | return 1; |
92 | 100 | ||
93 | for_all_symbols(i, sym) { | 101 | for_all_symbols(i, sym) { |
94 | sym->flags |= SYMBOL_NEW; | 102 | sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; |
103 | sym->flags &= ~SYMBOL_VALID; | ||
95 | switch (sym->type) { | 104 | switch (sym->type) { |
96 | case S_INT: | 105 | case S_INT: |
97 | case S_HEX: | 106 | case S_HEX: |
98 | case S_STRING: | 107 | case S_STRING: |
99 | if (S_VAL(sym->def)) { | 108 | if (S_VAL(sym->def)) |
100 | free(S_VAL(sym->def)); | 109 | free(S_VAL(sym->def)); |
101 | S_VAL(sym->def) = NULL; | ||
102 | } | ||
103 | default: | 110 | default: |
104 | ; | 111 | S_VAL(sym->def) = NULL; |
112 | S_TRI(sym->def) = no; | ||
105 | } | 113 | } |
106 | } | 114 | } |
107 | 115 | ||
108 | while (fgets(line, 128, in)) { | 116 | while (fgets(line, sizeof(line), in)) { |
109 | lineno++; | 117 | lineno++; |
110 | switch (line[0]) { | 118 | switch (line[0]) { |
111 | case '#': | 119 | case '#': |
112 | if (memcmp(line + 2, "CONFIG_", 7)) | 120 | if (memcmp(line + 2, "CONFIG_", 7)) |
113 | continue; | 121 | continue; |
114 | p = strchr(line + 9, ' '); | 122 | p = strchr(line + 9, ' '); |
115 | if (!p) | 123 | if (!p) |
116 | continue; | 124 | continue; |
117 | *p++ = 0; | 125 | *p++ = 0; |
118 | if (strncmp(p, "is not set", 10)) | 126 | if (strncmp(p, "is not set", 10)) |
119 | continue; | 127 | continue; |
120 | //printf("%s -> n\n", line + 9); | ||
121 | sym = sym_lookup(line + 9, 0); | 128 | sym = sym_lookup(line + 9, 0); |
122 | switch (sym->type) { | 129 | switch (sym->type) { |
123 | case S_BOOLEAN: | 130 | case S_BOOLEAN: |
124 | case S_TRISTATE: | 131 | case S_TRISTATE: |
125 | sym->def = symbol_no.curr; | 132 | sym->def = symbol_no.curr; |
126 | sym->flags &= ~SYMBOL_NEW; | 133 | sym->flags &= ~SYMBOL_NEW; |
127 | break; | 134 | break; |
128 | default: | 135 | default: |
129 | ; | 136 | ; |
130 | } | 137 | } |
131 | break; | 138 | break; |
132 | case 'C': | 139 | case 'C': |
133 | if (memcmp(line, "CONFIG_", 7)) | 140 | if (memcmp(line, "CONFIG_", 7)) |
134 | continue; | 141 | continue; |
135 | p = strchr(line + 7, '='); | 142 | p = strchr(line + 7, '='); |
136 | if (!p) | 143 | if (!p) |
137 | continue; | 144 | continue; |
138 | *p++ = 0; | 145 | *p++ = 0; |
139 | p2 = strchr(p, '\n'); | 146 | p2 = strchr(p, '\n'); |
140 | if (p2) | 147 | if (p2) |
141 | *p2 = 0; | 148 | *p2 = 0; |
142 | //printf("%s -> %s\n", line + 7, p); | ||
143 | sym = sym_find(line + 7); | 149 | sym = sym_find(line + 7); |
144 | if (!sym) { | 150 | if (!sym) { |
145 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 7); | 151 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 7); |
146 | break; | 152 | break; |
147 | } | 153 | } |
148 | switch (sym->type) { | 154 | switch (sym->type) { |
149 | case S_BOOLEAN: | ||
150 | sym->def = symbol_yes.curr; | ||
151 | sym->flags &= ~SYMBOL_NEW; | ||
152 | break; | ||
153 | case S_TRISTATE: | 155 | case S_TRISTATE: |
154 | if (p[0] == 'm') | 156 | if (p[0] == 'm') { |
155 | sym->def = symbol_mod.curr; | 157 | S_TRI(sym->def) = mod; |
156 | else | 158 | sym->flags &= ~SYMBOL_NEW; |
157 | sym->def = symbol_yes.curr; | 159 | break; |
158 | sym->flags &= ~SYMBOL_NEW; | 160 | } |
161 | case S_BOOLEAN: | ||
162 | if (p[0] == 'y') { | ||
163 | S_TRI(sym->def) = yes; | ||
164 | sym->flags &= ~SYMBOL_NEW; | ||
165 | break; | ||
166 | } | ||
167 | if (p[0] == 'n') { | ||
168 | S_TRI(sym->def) = no; | ||
169 | sym->flags &= ~SYMBOL_NEW; | ||
170 | break; | ||
171 | } | ||
159 | break; | 172 | break; |
160 | case S_STRING: | 173 | case S_STRING: |
161 | if (*p++ != '"') | 174 | if (*p++ != '"') |
162 | break; | 175 | break; |
163 | for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { | 176 | for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { |
164 | if (*p2 == '"') { | 177 | if (*p2 == '"') { |
165 | *p2 = 0; | 178 | *p2 = 0; |
166 | break; | 179 | break; |
167 | } | 180 | } |
168 | memmove(p2, p2 + 1, strlen(p2)); | 181 | memmove(p2, p2 + 1, strlen(p2)); |
169 | } | 182 | } |
183 | if (!p2) { | ||
184 | fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); | ||
185 | exit(1); | ||
186 | } | ||
170 | case S_INT: | 187 | case S_INT: |
171 | case S_HEX: | 188 | case S_HEX: |
172 | if (sym_string_valid(sym, p)) { | 189 | if (sym_string_valid(sym, p)) { |
173 | S_VAL(sym->def) = strdup(p); | 190 | S_VAL(sym->def) = strdup(p); |
174 | sym->flags &= ~SYMBOL_NEW; | 191 | sym->flags &= ~SYMBOL_NEW; |
175 | } else | 192 | } else { |
176 | fprintf(stderr, "%s:%d:symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); | 193 | fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); |
194 | exit(1); | ||
195 | } | ||
177 | break; | 196 | break; |
178 | default: | 197 | default: |
179 | ; | 198 | ; |
180 | } | 199 | } |
181 | if (sym_is_choice_value(sym)) { | 200 | if (sym_is_choice_value(sym)) { |
182 | prop = sym_get_choice_prop(sym); | 201 | prop = sym_get_choice_prop(sym); |
183 | switch (S_TRI(sym->def)) { | 202 | switch (S_TRI(sym->def)) { |
184 | case mod: | 203 | case mod: |
185 | if (S_TRI(prop->def->def) == yes) | 204 | if (S_TRI(prop->def->def) == yes) |
186 | /* warn? */; | 205 | /* warn? */; |
187 | break; | 206 | break; |
188 | case yes: | 207 | case yes: |
@@ -343,18 +362,17 @@ int conf_write(const char *name) | |||
343 | 362 | ||
344 | if (!name) { | 363 | if (!name) { |
345 | rename(".tmpconfig.h", "include/linux/autoconf.h"); | 364 | rename(".tmpconfig.h", "include/linux/autoconf.h"); |
346 | name = conf_def_filename; | 365 | name = conf_def_filename; |
347 | file_write_dep(NULL); | 366 | file_write_dep(NULL); |
348 | } else | 367 | } else |
349 | unlink(".tmpconfig.h"); | 368 | unlink(".tmpconfig.h"); |
350 | 369 | ||
351 | sprintf(oldname, "%s.old", name); | 370 | sprintf(oldname, "%s.old", name); |
352 | rename(name, oldname); | 371 | rename(name, oldname); |
353 | if (rename(".tmpconfig", name)) | 372 | if (rename(".tmpconfig", name)) |
354 | return 1; | 373 | return 1; |
355 | strcpy(conf_filename, name); | ||
356 | 374 | ||
357 | sym_change_count = 0; | 375 | sym_change_count = 0; |
358 | 376 | ||
359 | return 0; | 377 | return 0; |
360 | } | 378 | } |