Blame view
scripts/kconfig/conf.c
15.7 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 |
/* * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> * Released under the terms of the GNU GPL v2.0. */ |
534a450c3 kconfig: gettext ... |
5 |
#include <locale.h> |
1da177e4c Linux-2.6.12-rc2 |
6 |
#include <ctype.h> |
74dba8091 kconfig: allow kc... |
7 |
#include <limits.h> |
9dfb563b0 [PATCH] config: u... |
8 |
#include <stdio.h> |
75ff4309c kconfig: fix whit... |
9 |
#include <stdlib.h> |
1da177e4c Linux-2.6.12-rc2 |
10 |
#include <string.h> |
1da177e4c Linux-2.6.12-rc2 |
11 |
#include <time.h> |
75ff4309c kconfig: fix whit... |
12 |
#include <unistd.h> |
4062f1a4c kconfig: use long... |
13 |
#include <getopt.h> |
1da177e4c Linux-2.6.12-rc2 |
14 |
#include <sys/stat.h> |
b0fe55100 kconfig: improve ... |
15 |
#include <sys/time.h> |
0d8024c6e kconfig: allow sp... |
16 |
#include <errno.h> |
1da177e4c Linux-2.6.12-rc2 |
17 |
|
1da177e4c Linux-2.6.12-rc2 |
18 19 20 21 |
#include "lkc.h" static void conf(struct menu *menu); static void check_conf(struct menu *menu); |
ab63f58f2 kconfig/conf: mar... |
22 |
static void xfgets(char *str, int size, FILE *in); |
1da177e4c Linux-2.6.12-rc2 |
23 |
|
4062f1a4c kconfig: use long... |
24 25 26 27 28 29 30 |
enum input_mode { oldaskconfig, silentoldconfig, oldconfig, allnoconfig, allyesconfig, allmodconfig, |
0748cb3e1 kconfig: add alld... |
31 |
alldefconfig, |
4062f1a4c kconfig: use long... |
32 33 |
randconfig, defconfig, |
7cf3d73b4 kconfig: add save... |
34 |
savedefconfig, |
861b4ea4c kconfig: change n... |
35 |
listnewconfig, |
fb16d8912 kconfig: replace ... |
36 |
olddefconfig, |
4062f1a4c kconfig: use long... |
37 |
} input_mode = oldaskconfig; |
1da177e4c Linux-2.6.12-rc2 |
38 |
static int indent = 1; |
62dc98992 kbuild: Fix missi... |
39 |
static int tty_stdio; |
1da177e4c Linux-2.6.12-rc2 |
40 |
static int valid_stdin = 1; |
204c96f60 kconfig: fix sile... |
41 |
static int sync_kconfig; |
1da177e4c Linux-2.6.12-rc2 |
42 |
static int conf_cnt; |
74dba8091 kconfig: allow kc... |
43 |
static char line[PATH_MAX]; |
1da177e4c Linux-2.6.12-rc2 |
44 |
static struct menu *rootEntry; |
66c4bd808 kconfig: make use... |
45 |
static void print_help(struct menu *menu) |
03d291227 kconfig: attach h... |
46 |
{ |
66c4bd808 kconfig: make use... |
47 48 49 50 51 52 53 54 |
struct gstr help = str_new(); menu_get_ext_help(menu, &help); printf(" %s ", str_get(&help)); str_free(&help); |
03d291227 kconfig: attach h... |
55 |
} |
48b9d03c5 [PATCH] Kill sign... |
56 |
static void strip(char *str) |
1da177e4c Linux-2.6.12-rc2 |
57 |
{ |
48b9d03c5 [PATCH] Kill sign... |
58 |
char *p = str; |
1da177e4c Linux-2.6.12-rc2 |
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
int l; while ((isspace(*p))) p++; l = strlen(p); if (p != str) memmove(str, p, l + 1); if (!l) return; p = str + l - 1; while ((isspace(*p))) *p-- = 0; } static void check_stdin(void) { |
204c96f60 kconfig: fix sile... |
75 |
if (!valid_stdin) { |
3b9fa0931 [PATCH] Kconfig i... |
76 77 78 79 80 81 82 |
printf(_("aborted! ")); printf(_("Console input/output is redirected. ")); printf(_("Run 'make oldconfig' to update configuration. ")); |
1da177e4c Linux-2.6.12-rc2 |
83 84 85 |
exit(1); } } |
f82f3f942 kconfig: oldconfi... |
86 |
static int conf_askvalue(struct symbol *sym, const char *def) |
1da177e4c Linux-2.6.12-rc2 |
87 88 |
{ enum symbol_type type = sym_get_type(sym); |
1da177e4c Linux-2.6.12-rc2 |
89 90 |
if (!sym_has_value(sym)) |
534a450c3 kconfig: gettext ... |
91 |
printf(_("(NEW) ")); |
1da177e4c Linux-2.6.12-rc2 |
92 93 94 95 96 97 98 99 100 101 102 |
line[0] = ' '; line[1] = 0; if (!sym_is_changable(sym)) { printf("%s ", def); line[0] = ' '; line[1] = 0; |
f82f3f942 kconfig: oldconfi... |
103 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
104 105 106 |
} switch (input_mode) { |
4062f1a4c kconfig: use long... |
107 108 |
case oldconfig: case silentoldconfig: |
1da177e4c Linux-2.6.12-rc2 |
109 110 111 |
if (sym_has_value(sym)) { printf("%s ", def); |
f82f3f942 kconfig: oldconfi... |
112 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
113 114 |
} check_stdin(); |
d8fc32007 kconfig: annotate... |
115 |
/* fall through */ |
4062f1a4c kconfig: use long... |
116 |
case oldaskconfig: |
1da177e4c Linux-2.6.12-rc2 |
117 |
fflush(stdout); |
74dba8091 kconfig: allow kc... |
118 |
xfgets(line, sizeof(line), stdin); |
62dc98992 kbuild: Fix missi... |
119 120 121 |
if (!tty_stdio) printf(" "); |
f82f3f942 kconfig: oldconfi... |
122 |
return 1; |
1da177e4c Linux-2.6.12-rc2 |
123 124 125 126 127 128 129 130 131 132 |
default: break; } switch (type) { case S_INT: case S_HEX: case S_STRING: printf("%s ", def); |
f82f3f942 kconfig: oldconfi... |
133 |
return 1; |
1da177e4c Linux-2.6.12-rc2 |
134 135 136 |
default: ; } |
1da177e4c Linux-2.6.12-rc2 |
137 |
printf("%s", line); |
f82f3f942 kconfig: oldconfi... |
138 |
return 1; |
1da177e4c Linux-2.6.12-rc2 |
139 |
} |
4356f4890 kbuild: add stati... |
140 |
static int conf_string(struct menu *menu) |
1da177e4c Linux-2.6.12-rc2 |
141 142 |
{ struct symbol *sym = menu->sym; |
03d291227 kconfig: attach h... |
143 |
const char *def; |
1da177e4c Linux-2.6.12-rc2 |
144 145 |
while (1) { |
534a450c3 kconfig: gettext ... |
146 |
printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); |
1da177e4c Linux-2.6.12-rc2 |
147 148 149 150 |
printf("(%s) ", sym->name); def = sym_get_string_value(sym); if (sym_get_string_value(sym)) printf("[%s] ", def); |
f82f3f942 kconfig: oldconfi... |
151 152 |
if (!conf_askvalue(sym, def)) return 0; |
1da177e4c Linux-2.6.12-rc2 |
153 154 155 156 157 158 159 160 |
switch (line[0]) { case ' ': break; case '?': /* print help */ if (line[1] == ' ') { |
66c4bd808 kconfig: make use... |
161 |
print_help(menu); |
1da177e4c Linux-2.6.12-rc2 |
162 163 164 |
def = NULL; break; } |
d8fc32007 kconfig: annotate... |
165 |
/* fall through */ |
1da177e4c Linux-2.6.12-rc2 |
166 167 168 169 170 171 172 173 174 175 176 177 |
default: line[strlen(line)-1] = 0; def = line; } if (def && sym_set_string_value(sym, def)) return 0; } } static int conf_sym(struct menu *menu) { struct symbol *sym = menu->sym; |
1da177e4c Linux-2.6.12-rc2 |
178 |
tristate oldval, newval; |
1da177e4c Linux-2.6.12-rc2 |
179 180 |
while (1) { |
534a450c3 kconfig: gettext ... |
181 |
printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); |
1da177e4c Linux-2.6.12-rc2 |
182 183 |
if (sym->name) printf("(%s) ", sym->name); |
1da177e4c Linux-2.6.12-rc2 |
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
putchar('['); oldval = sym_get_tristate_value(sym); switch (oldval) { case no: putchar('N'); break; case mod: putchar('M'); break; case yes: putchar('Y'); break; } if (oldval != no && sym_tristate_within_range(sym, no)) printf("/n"); if (oldval != mod && sym_tristate_within_range(sym, mod)) printf("/m"); if (oldval != yes && sym_tristate_within_range(sym, yes)) printf("/y"); |
03d291227 kconfig: attach h... |
203 |
if (menu_has_help(menu)) |
1da177e4c Linux-2.6.12-rc2 |
204 205 |
printf("/?"); printf("] "); |
f82f3f942 kconfig: oldconfi... |
206 207 |
if (!conf_askvalue(sym, sym_get_string_value(sym))) return 0; |
1da177e4c Linux-2.6.12-rc2 |
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
strip(line); switch (line[0]) { case 'n': case 'N': newval = no; if (!line[1] || !strcmp(&line[1], "o")) break; continue; case 'm': case 'M': newval = mod; if (!line[1]) break; continue; case 'y': case 'Y': newval = yes; if (!line[1] || !strcmp(&line[1], "es")) break; continue; case 0: newval = oldval; break; case '?': goto help; default: continue; } if (sym_set_tristate_value(sym, newval)) return 0; help: |
66c4bd808 kconfig: make use... |
240 |
print_help(menu); |
1da177e4c Linux-2.6.12-rc2 |
241 242 243 244 245 246 247 |
} } static int conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *child; |
1da177e4c Linux-2.6.12-rc2 |
248 249 250 |
bool is_new; sym = menu->sym; |
1da177e4c Linux-2.6.12-rc2 |
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); sym_calc_value(sym); switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: return 0; case yes: break; } } else { switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: |
534a450c3 kconfig: gettext ... |
268 269 |
printf("%*s%s ", indent - 1, "", _(menu_get_prompt(menu))); |
1da177e4c Linux-2.6.12-rc2 |
270 271 272 273 274 275 276 277 |
return 0; case yes: break; } } while (1) { int cnt, def; |
534a450c3 kconfig: gettext ... |
278 279 |
printf("%*s%s ", indent - 1, "", _(menu_get_prompt(menu))); |
1da177e4c Linux-2.6.12-rc2 |
280 281 |
def_sym = sym_get_choice_value(sym); cnt = def = 0; |
40aee729b kconfig: fix defa... |
282 |
line[0] = 0; |
1da177e4c Linux-2.6.12-rc2 |
283 284 285 286 |
for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; if (!child->sym) { |
534a450c3 kconfig: gettext ... |
287 288 |
printf("%*c %s ", indent, '*', _(menu_get_prompt(child))); |
1da177e4c Linux-2.6.12-rc2 |
289 290 291 292 293 294 295 296 |
continue; } cnt++; if (child->sym == def_sym) { def = cnt; printf("%*c", indent, '>'); } else printf("%*c", indent, ' '); |
534a450c3 kconfig: gettext ... |
297 |
printf(" %d. %s", cnt, _(menu_get_prompt(child))); |
1da177e4c Linux-2.6.12-rc2 |
298 299 300 |
if (child->sym->name) printf(" (%s)", child->sym->name); if (!sym_has_value(child->sym)) |
534a450c3 kconfig: gettext ... |
301 |
printf(_(" (NEW)")); |
1da177e4c Linux-2.6.12-rc2 |
302 303 304 |
printf(" "); } |
534a450c3 kconfig: gettext ... |
305 |
printf(_("%*schoice"), indent - 1, ""); |
1da177e4c Linux-2.6.12-rc2 |
306 307 308 309 310 311 |
if (cnt == 1) { printf("[1]: 1 "); goto conf_childs; } printf("[1-%d", cnt); |
03d291227 kconfig: attach h... |
312 |
if (menu_has_help(menu)) |
1da177e4c Linux-2.6.12-rc2 |
313 314 315 |
printf("?"); printf("]: "); switch (input_mode) { |
4062f1a4c kconfig: use long... |
316 317 |
case oldconfig: case silentoldconfig: |
1da177e4c Linux-2.6.12-rc2 |
318 319 320 321 322 323 324 |
if (!is_new) { cnt = def; printf("%d ", cnt); break; } check_stdin(); |
d8fc32007 kconfig: annotate... |
325 |
/* fall through */ |
4062f1a4c kconfig: use long... |
326 |
case oldaskconfig: |
1da177e4c Linux-2.6.12-rc2 |
327 |
fflush(stdout); |
74dba8091 kconfig: allow kc... |
328 |
xfgets(line, sizeof(line), stdin); |
1da177e4c Linux-2.6.12-rc2 |
329 330 |
strip(line); if (line[0] == '?') { |
66c4bd808 kconfig: make use... |
331 |
print_help(menu); |
1da177e4c Linux-2.6.12-rc2 |
332 333 334 335 336 337 338 339 340 |
continue; } if (!line[0]) cnt = def; else if (isdigit(line[0])) cnt = atoi(line); else continue; break; |
f443d2ecc kconfig: speed up... |
341 342 |
default: break; |
1da177e4c Linux-2.6.12-rc2 |
343 344 345 346 347 348 349 350 351 352 353 |
} conf_childs: for (child = menu->list; child; child = child->next) { if (!child->sym || !menu_is_visible(child)) continue; if (!--cnt) break; } if (!child) continue; |
3ba416211 kconfig: Avoid bu... |
354 |
if (line[0] && line[strlen(line) - 1] == '?') { |
66c4bd808 kconfig: make use... |
355 |
print_help(child); |
1da177e4c Linux-2.6.12-rc2 |
356 357 358 |
continue; } sym_set_choice_value(sym, child->sym); |
f5eaa323e kconfig: tristate... |
359 |
for (child = child->list; child; child = child->next) { |
1da177e4c Linux-2.6.12-rc2 |
360 |
indent += 2; |
f5eaa323e kconfig: tristate... |
361 |
conf(child); |
1da177e4c Linux-2.6.12-rc2 |
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
indent -= 2; } return 1; } } static void conf(struct menu *menu) { struct symbol *sym; struct property *prop; struct menu *child; if (!menu_is_visible(menu)) return; sym = menu->sym; prop = menu->prompt; if (prop) { const char *prompt; switch (prop->type) { case P_MENU: |
4062f1a4c kconfig: use long... |
384 |
if ((input_mode == silentoldconfig || |
861b4ea4c kconfig: change n... |
385 |
input_mode == listnewconfig || |
fb16d8912 kconfig: replace ... |
386 |
input_mode == olddefconfig) && |
f0778c8c4 kconfig: introduc... |
387 |
rootEntry != menu) { |
1da177e4c Linux-2.6.12-rc2 |
388 389 390 |
check_conf(menu); return; } |
d8fc32007 kconfig: annotate... |
391 |
/* fall through */ |
1da177e4c Linux-2.6.12-rc2 |
392 393 394 395 396 397 398 399 |
case P_COMMENT: prompt = menu_get_prompt(menu); if (prompt) printf("%*c %*c %s %*c ", indent, '*', |
534a450c3 kconfig: gettext ... |
400 |
indent, '*', _(prompt), |
1da177e4c Linux-2.6.12-rc2 |
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
indent, '*'); default: ; } } if (!sym) goto conf_childs; if (sym_is_choice(sym)) { conf_choice(menu); if (sym->curr.tri != mod) return; goto conf_childs; } switch (sym->type) { case S_INT: case S_HEX: case S_STRING: conf_string(menu); break; default: conf_sym(menu); break; } conf_childs: if (sym) indent += 2; for (child = menu->list; child; child = child->next) conf(child); if (sym) indent -= 2; } static void check_conf(struct menu *menu) { struct symbol *sym; struct menu *child; if (!menu_is_visible(menu)) return; sym = menu->sym; |
3f23ca2b3 [PATCH] kconfig: ... |
446 447 448 |
if (sym && !sym_has_value(sym)) { if (sym_is_changable(sym) || (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { |
861b4ea4c kconfig: change n... |
449 450 |
if (input_mode == listnewconfig) { if (sym->name && !sym_is_choice_value(sym)) { |
ffb5957bc kconfig: allow bu... |
451 452 |
printf("%s%s ", CONFIG_, sym->name); |
f0778c8c4 kconfig: introduc... |
453 |
} |
fb16d8912 kconfig: replace ... |
454 |
} else if (input_mode != olddefconfig) { |
f0778c8c4 kconfig: introduc... |
455 456 457 458 459 460 461 462 |
if (!conf_cnt++) printf(_("* * Restart config... * ")); rootEntry = menu_get_parent_menu(menu); conf(rootEntry); } |
1da177e4c Linux-2.6.12-rc2 |
463 |
} |
1da177e4c Linux-2.6.12-rc2 |
464 465 466 467 468 |
} for (child = menu->list; child; child = child->next) check_conf(child); } |
4062f1a4c kconfig: use long... |
469 470 471 472 473 |
static struct option long_opts[] = { {"oldaskconfig", no_argument, NULL, oldaskconfig}, {"oldconfig", no_argument, NULL, oldconfig}, {"silentoldconfig", no_argument, NULL, silentoldconfig}, {"defconfig", optional_argument, NULL, defconfig}, |
7cf3d73b4 kconfig: add save... |
474 |
{"savedefconfig", required_argument, NULL, savedefconfig}, |
4062f1a4c kconfig: use long... |
475 476 477 |
{"allnoconfig", no_argument, NULL, allnoconfig}, {"allyesconfig", no_argument, NULL, allyesconfig}, {"allmodconfig", no_argument, NULL, allmodconfig}, |
0748cb3e1 kconfig: add alld... |
478 |
{"alldefconfig", no_argument, NULL, alldefconfig}, |
4062f1a4c kconfig: use long... |
479 |
{"randconfig", no_argument, NULL, randconfig}, |
861b4ea4c kconfig: change n... |
480 |
{"listnewconfig", no_argument, NULL, listnewconfig}, |
fb16d8912 kconfig: replace ... |
481 482 483 484 485 486 487 |
{"olddefconfig", no_argument, NULL, olddefconfig}, /* * oldnoconfig is an alias of olddefconfig, because people already * are dependent on its behavior(sets new symbols to their default * value but not 'n') with the counter-intuitive name. */ {"oldnoconfig", no_argument, NULL, olddefconfig}, |
4062f1a4c kconfig: use long... |
488 489 |
{NULL, 0, NULL, 0} }; |
32543999f kconfig/conf: add... |
490 491 |
static void conf_usage(const char *progname) { |
0a1f00a1c kconfig: Do not p... |
492 493 |
printf("Usage: %s [-s] [option] <kconfig-file> ", progname); |
32543999f kconfig/conf: add... |
494 495 496 497 498 499 500 501 502 503 |
printf("[option] is _one_ of the following: "); printf(" --listnewconfig List new options "); printf(" --oldaskconfig Start a new configuration using a line-oriented program "); printf(" --oldconfig Update a configuration using a provided .config as base "); printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps "); |
fb16d8912 kconfig: replace ... |
504 505 506 507 |
printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value "); printf(" --oldnoconfig An alias of olddefconfig "); |
32543999f kconfig/conf: add... |
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
printf(" --defconfig <file> New config with default defined in <file> "); printf(" --savedefconfig <file> Save the minimal current configuration to <file> "); printf(" --allnoconfig New config where all options are answered with no "); printf(" --allyesconfig New config where all options are answered with yes "); printf(" --allmodconfig New config where all options are answered with mod "); printf(" --alldefconfig New config with all symbols set to default "); printf(" --randconfig New config with random answer to all options "); } |
1da177e4c Linux-2.6.12-rc2 |
523 524 |
int main(int ac, char **av) { |
32543999f kconfig/conf: add... |
525 |
const char *progname = av[0]; |
2f4b489b7 kconfig: use geto... |
526 |
int opt; |
275744cc8 kconfig/conf: red... |
527 |
const char *name, *defconfig_file = NULL /* gcc uninit */; |
1da177e4c Linux-2.6.12-rc2 |
528 |
struct stat tmpstat; |
534a450c3 kconfig: gettext ... |
529 530 531 |
setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); |
62dc98992 kbuild: Fix missi... |
532 |
tty_stdio = isatty(0) && isatty(1) && isatty(2); |
0a1f00a1c kconfig: Do not p... |
533 534 535 536 537 |
while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) { if (opt == 's') { conf_set_message_callback(NULL); continue; } |
4062f1a4c kconfig: use long... |
538 |
input_mode = (enum input_mode)opt; |
2f4b489b7 kconfig: use geto... |
539 |
switch (opt) { |
4062f1a4c kconfig: use long... |
540 |
case silentoldconfig: |
204c96f60 kconfig: fix sile... |
541 |
sync_kconfig = 1; |
1da177e4c Linux-2.6.12-rc2 |
542 |
break; |
4062f1a4c kconfig: use long... |
543 |
case defconfig: |
7cf3d73b4 kconfig: add save... |
544 |
case savedefconfig: |
2f4b489b7 kconfig: use geto... |
545 |
defconfig_file = optarg; |
1da177e4c Linux-2.6.12-rc2 |
546 |
break; |
4062f1a4c kconfig: use long... |
547 |
case randconfig: |
b0fe55100 kconfig: improve ... |
548 549 550 |
{ struct timeval now; unsigned int seed; |
0d8024c6e kconfig: allow sp... |
551 |
char *seed_env; |
b0fe55100 kconfig: improve ... |
552 553 554 555 556 557 |
/* * Use microseconds derived seed, * compensate for systems where it may be zero */ gettimeofday(&now, NULL); |
b0fe55100 kconfig: improve ... |
558 |
seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); |
0d8024c6e kconfig: allow sp... |
559 560 561 562 |
seed_env = getenv("KCONFIG_SEED"); if( seed_env && *seed_env ) { char *endp; |
e85ac1244 kconfig/conf: acc... |
563 |
int tmp = (int)strtol(seed_env, &endp, 0); |
0d8024c6e kconfig: allow sp... |
564 565 566 567 |
if (*endp == '\0') { seed = tmp; } } |
a5f6d795f kconfig/conf: pri... |
568 569 |
fprintf( stderr, "KCONFIG_SEED=0x%X ", seed ); |
b0fe55100 kconfig: improve ... |
570 |
srand(seed); |
1da177e4c Linux-2.6.12-rc2 |
571 |
break; |
b0fe55100 kconfig: improve ... |
572 |
} |
32543999f kconfig/conf: add... |
573 574 575 576 577 578 579 |
case oldaskconfig: case oldconfig: case allnoconfig: case allyesconfig: case allmodconfig: case alldefconfig: case listnewconfig: |
fb16d8912 kconfig: replace ... |
580 |
case olddefconfig: |
32543999f kconfig/conf: add... |
581 |
break; |
4062f1a4c kconfig: use long... |
582 |
case '?': |
32543999f kconfig/conf: add... |
583 |
conf_usage(progname); |
2f4b489b7 kconfig: use geto... |
584 |
exit(1); |
4062f1a4c kconfig: use long... |
585 |
break; |
1da177e4c Linux-2.6.12-rc2 |
586 587 |
} } |
2f4b489b7 kconfig: use geto... |
588 |
if (ac == optind) { |
3b9fa0931 [PATCH] Kconfig i... |
589 590 |
printf(_("%s: Kconfig file missing "), av[0]); |
32543999f kconfig/conf: add... |
591 |
conf_usage(progname); |
250725aa1 kconfig: exit if ... |
592 |
exit(1); |
1da177e4c Linux-2.6.12-rc2 |
593 |
} |
2f4b489b7 kconfig: use geto... |
594 |
name = av[optind]; |
1da177e4c Linux-2.6.12-rc2 |
595 596 |
conf_parse(name); //zconfdump(stdout); |
204c96f60 kconfig: fix sile... |
597 |
if (sync_kconfig) { |
284026cdf kconfig: do not h... |
598 599 |
name = conf_get_configname(); if (stat(name, &tmpstat)) { |
204c96f60 kconfig: fix sile... |
600 601 |
fprintf(stderr, _("*** " |
652cf9821 kconfig: rephrase... |
602 603 |
"*** Configuration file \"%s\" not found! " |
204c96f60 kconfig: fix sile... |
604 605 606 607 608 609 |
"*** " "*** Please run some configurator (e.g. \"make oldconfig\" or " "*** \"make menuconfig\" or \"make xconfig\"). " |
284026cdf kconfig: do not h... |
610 611 |
"*** "), name); |
204c96f60 kconfig: fix sile... |
612 613 614 |
exit(1); } } |
1da177e4c Linux-2.6.12-rc2 |
615 |
switch (input_mode) { |
4062f1a4c kconfig: use long... |
616 |
case defconfig: |
1da177e4c Linux-2.6.12-rc2 |
617 618 619 |
if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { |
534a450c3 kconfig: gettext ... |
620 621 |
printf(_("*** " |
1da177e4c Linux-2.6.12-rc2 |
622 623 |
"*** Can't find default configuration \"%s\"! " |
534a450c3 kconfig: gettext ... |
624 625 |
"*** "), defconfig_file); |
1da177e4c Linux-2.6.12-rc2 |
626 627 628 |
exit(1); } break; |
7cf3d73b4 kconfig: add save... |
629 |
case savedefconfig: |
4062f1a4c kconfig: use long... |
630 631 632 |
case silentoldconfig: case oldaskconfig: case oldconfig: |
861b4ea4c kconfig: change n... |
633 |
case listnewconfig: |
fb16d8912 kconfig: replace ... |
634 |
case olddefconfig: |
1da177e4c Linux-2.6.12-rc2 |
635 636 |
conf_read(NULL); break; |
4062f1a4c kconfig: use long... |
637 638 639 |
case allnoconfig: case allyesconfig: case allmodconfig: |
0748cb3e1 kconfig: add alld... |
640 |
case alldefconfig: |
4062f1a4c kconfig: use long... |
641 |
case randconfig: |
90389160e [PATCH] kconfig: ... |
642 |
name = getenv("KCONFIG_ALLCONFIG"); |
9f420bf0f kbuild: all{no,ye... |
643 644 645 |
if (!name) break; if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) { |
5efe241ea kconfig: Add erro... |
646 647 648 649 650 651 652 |
if (conf_read_simple(name, S_DEF_USER)) { fprintf(stderr, _("*** Can't read seed configuration \"%s\"! "), name); exit(1); } |
90389160e [PATCH] kconfig: ... |
653 654 655 |
break; } switch (input_mode) { |
4062f1a4c kconfig: use long... |
656 657 658 |
case allnoconfig: name = "allno.config"; break; case allyesconfig: name = "allyes.config"; break; case allmodconfig: name = "allmod.config"; break; |
0748cb3e1 kconfig: add alld... |
659 |
case alldefconfig: name = "alldef.config"; break; |
4062f1a4c kconfig: use long... |
660 |
case randconfig: name = "allrandom.config"; break; |
90389160e [PATCH] kconfig: ... |
661 662 |
default: break; } |
5efe241ea kconfig: Add erro... |
663 664 665 666 667 668 669 670 |
if (conf_read_simple(name, S_DEF_USER) && conf_read_simple("all.config", S_DEF_USER)) { fprintf(stderr, _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found "), name); exit(1); } |
90389160e [PATCH] kconfig: ... |
671 |
break; |
1da177e4c Linux-2.6.12-rc2 |
672 673 674 |
default: break; } |
204c96f60 kconfig: fix sile... |
675 676 677 678 679 680 |
if (sync_kconfig) { if (conf_get_changed()) { name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, |
652cf9821 kconfig: rephrase... |
681 682 683 684 |
_(" *** The configuration requires explicit update. ")); |
204c96f60 kconfig: fix sile... |
685 686 687 |
return 1; } } |
62dc98992 kbuild: Fix missi... |
688 |
valid_stdin = tty_stdio; |
204c96f60 kconfig: fix sile... |
689 |
} |
f443d2ecc kconfig: speed up... |
690 |
switch (input_mode) { |
4062f1a4c kconfig: use long... |
691 |
case allnoconfig: |
f443d2ecc kconfig: speed up... |
692 693 |
conf_set_all_new_symbols(def_no); break; |
4062f1a4c kconfig: use long... |
694 |
case allyesconfig: |
f443d2ecc kconfig: speed up... |
695 696 |
conf_set_all_new_symbols(def_yes); break; |
4062f1a4c kconfig: use long... |
697 |
case allmodconfig: |
f443d2ecc kconfig: speed up... |
698 699 |
conf_set_all_new_symbols(def_mod); break; |
0748cb3e1 kconfig: add alld... |
700 701 702 |
case alldefconfig: conf_set_all_new_symbols(def_default); break; |
4062f1a4c kconfig: use long... |
703 |
case randconfig: |
3b9a19e08 kconfig: loop as ... |
704 705 |
/* Really nothing to do in this loop */ while (conf_set_all_new_symbols(def_random)) ; |
f443d2ecc kconfig: speed up... |
706 |
break; |
4062f1a4c kconfig: use long... |
707 |
case defconfig: |
09748e178 kconfig: make def... |
708 709 |
conf_set_all_new_symbols(def_default); break; |
7cf3d73b4 kconfig: add save... |
710 711 |
case savedefconfig: break; |
4062f1a4c kconfig: use long... |
712 |
case oldaskconfig: |
204c96f60 kconfig: fix sile... |
713 714 |
rootEntry = &rootmenu; conf(&rootmenu); |
4062f1a4c kconfig: use long... |
715 |
input_mode = silentoldconfig; |
204c96f60 kconfig: fix sile... |
716 |
/* fall through */ |
148283497 kconfig: fix make... |
717 |
case oldconfig: |
861b4ea4c kconfig: change n... |
718 |
case listnewconfig: |
fb16d8912 kconfig: replace ... |
719 |
case olddefconfig: |
4062f1a4c kconfig: use long... |
720 |
case silentoldconfig: |
204c96f60 kconfig: fix sile... |
721 722 723 724 |
/* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); |
f0778c8c4 kconfig: introduc... |
725 |
} while (conf_cnt && |
861b4ea4c kconfig: change n... |
726 |
(input_mode != listnewconfig && |
fb16d8912 kconfig: replace ... |
727 |
input_mode != olddefconfig)); |
f443d2ecc kconfig: speed up... |
728 729 |
break; } |
1da177e4c Linux-2.6.12-rc2 |
730 |
|
204c96f60 kconfig: fix sile... |
731 732 733 734 735 |
if (sync_kconfig) { /* silentoldconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config. */ if (conf_get_changed() && conf_write(NULL)) { |
652cf9821 kconfig: rephrase... |
736 737 738 739 |
fprintf(stderr, _(" *** Error during writing of the configuration. ")); |
204c96f60 kconfig: fix sile... |
740 741 742 |
exit(1); } if (conf_write_autoconf()) { |
652cf9821 kconfig: rephrase... |
743 744 745 746 |
fprintf(stderr, _(" *** Error during update of the configuration. ")); |
204c96f60 kconfig: fix sile... |
747 748 |
return 1; } |
7cf3d73b4 kconfig: add save... |
749 750 751 752 753 |
} else if (input_mode == savedefconfig) { if (conf_write_defconfig(defconfig_file)) { fprintf(stderr, _("n*** Error while saving defconfig to: %s "), |
bb66fc671 kbuild: trivial -... |
754 |
defconfig_file); |
7cf3d73b4 kconfig: add save... |
755 756 |
return 1; } |
861b4ea4c kconfig: change n... |
757 |
} else if (input_mode != listnewconfig) { |
204c96f60 kconfig: fix sile... |
758 |
if (conf_write(NULL)) { |
652cf9821 kconfig: rephrase... |
759 760 761 762 |
fprintf(stderr, _(" *** Error during writing of the configuration. ")); |
204c96f60 kconfig: fix sile... |
763 764 |
exit(1); } |
c955ccafc kconfig: fix .con... |
765 |
} |
861b4ea4c kconfig: change n... |
766 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
767 |
} |
ab63f58f2 kconfig/conf: mar... |
768 |
|
4418a2b90 kconfig: Fix warn... |
769 770 771 |
/* * Helper function to facilitate fgets() by Jean Sacren. */ |
ab63f58f2 kconfig/conf: mar... |
772 |
void xfgets(char *str, int size, FILE *in) |
4418a2b90 kconfig: Fix warn... |
773 774 775 776 777 778 |
{ if (fgets(str, size, in) == NULL) fprintf(stderr, " Error in reading or end of file. "); } |