kconfig/conf.c
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon May 25 19:48:42 2009 +0000 (2009-05-25)
branchgcc-4.4
changeset 1387 a52504ffac55
parent 860 3ff8038f904c
child 1524 1031ea5af395
permissions -rw-r--r--
/devel/gcc-4.4:
- TODO: remove completed items

-------- diffstat follows --------
/devel/gcc-4.4/TODO | 1 0 1 0 -
1 file changed, 1 deletion(-)
yann@1
     1
/*
yann@1
     2
 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
yann@1
     3
 * Released under the terms of the GNU GPL v2.0.
yann@1
     4
 */
yann@1
     5
yann@943
     6
#include <locale.h>
yann@1
     7
#include <ctype.h>
yann@943
     8
#include <stdio.h>
yann@1
     9
#include <stdlib.h>
yann@1
    10
#include <string.h>
yann@943
    11
#include <time.h>
yann@1
    12
#include <unistd.h>
yann@1
    13
#include <sys/stat.h>
yann@1
    14
yann@1
    15
#define LKC_DIRECT_LINK
yann@1
    16
#include "lkc.h"
yann@1
    17
yann@1
    18
static void conf(struct menu *menu);
yann@1
    19
static void check_conf(struct menu *menu);
yann@1
    20
yann@1
    21
enum {
yann@1
    22
	ask_all,
yann@1
    23
	ask_new,
yann@1
    24
	ask_silent,
yann@1
    25
	set_default,
yann@1
    26
	set_yes,
yann@1
    27
	set_mod,
yann@1
    28
	set_no,
yann@1
    29
	set_random
yann@1
    30
} input_mode = ask_all;
yann@1
    31
char *defconfig_file;
yann@1
    32
yann@1
    33
static int indent = 1;
yann@1
    34
static int valid_stdin = 1;
yann@943
    35
static int sync_kconfig;
yann@1
    36
static int conf_cnt;
yann@1
    37
static char line[128];
yann@1
    38
static struct menu *rootEntry;
yann@1
    39
yann@1
    40
static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
yann@1
    41
yann@943
    42
static const char *get_help(struct menu *menu)
yann@943
    43
{
yann@943
    44
	if (menu_has_help(menu))
yann@943
    45
		return _(menu_get_help(menu));
yann@943
    46
	else
yann@943
    47
		return nohelp_text;
yann@943
    48
}
yann@943
    49
yann@1
    50
static void strip(char *str)
yann@1
    51
{
yann@1
    52
	char *p = str;
yann@1
    53
	int l;
yann@1
    54
yann@1
    55
	while ((isspace(*p)))
yann@1
    56
		p++;
yann@1
    57
	l = strlen(p);
yann@1
    58
	if (p != str)
yann@1
    59
		memmove(str, p, l + 1);
yann@1
    60
	if (!l)
yann@1
    61
		return;
yann@1
    62
	p = str + l - 1;
yann@1
    63
	while ((isspace(*p)))
yann@1
    64
		*p-- = 0;
yann@1
    65
}
yann@1
    66
yann@1
    67
static void check_stdin(void)
yann@1
    68
{
yann@943
    69
	if (!valid_stdin) {
yann@1
    70
		printf(_("aborted!\n\n"));
yann@1
    71
		printf(_("Console input/output is redirected. "));
yann@1
    72
		printf(_("Run 'make oldconfig' to update configuration.\n\n"));
yann@1
    73
		exit(1);
yann@1
    74
	}
yann@1
    75
}
yann@1
    76
yann@943
    77
static int conf_askvalue(struct symbol *sym, const char *def)
yann@1
    78
{
yann@1
    79
	enum symbol_type type = sym_get_type(sym);
yann@1
    80
yann@1
    81
	if (!sym_has_value(sym))
yann@943
    82
		printf(_("(NEW) "));
yann@1
    83
yann@1
    84
	line[0] = '\n';
yann@1
    85
	line[1] = 0;
yann@1
    86
yann@1
    87
	if (!sym_is_changable(sym)) {
yann@1
    88
		printf("%s\n", def);
yann@1
    89
		line[0] = '\n';
yann@1
    90
		line[1] = 0;
yann@943
    91
		return 0;
yann@1
    92
	}
yann@1
    93
yann@1
    94
	switch (input_mode) {
yann@1
    95
	case ask_new:
yann@1
    96
	case ask_silent:
yann@1
    97
		if (sym_has_value(sym)) {
yann@1
    98
			printf("%s\n", def);
yann@943
    99
			return 0;
yann@1
   100
		}
yann@1
   101
		check_stdin();
yann@1
   102
	case ask_all:
yann@1
   103
		fflush(stdout);
yann@1
   104
		fgets(line, 128, stdin);
yann@943
   105
		return 1;
yann@1
   106
	default:
yann@1
   107
		break;
yann@1
   108
	}
yann@1
   109
yann@1
   110
	switch (type) {
yann@1
   111
	case S_INT:
yann@1
   112
	case S_HEX:
yann@1
   113
	case S_STRING:
yann@1
   114
		printf("%s\n", def);
yann@943
   115
		return 1;
yann@1
   116
	default:
yann@1
   117
		;
yann@1
   118
	}
yann@1
   119
	printf("%s", line);
yann@943
   120
	return 1;
yann@1
   121
}
yann@1
   122
yann@1
   123
int conf_string(struct menu *menu)
yann@1
   124
{
yann@1
   125
	struct symbol *sym = menu->sym;
yann@943
   126
	const char *def;
yann@1
   127
yann@1
   128
	while (1) {
yann@943
   129
		printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
yann@1
   130
		printf("(%s) ", sym->name);
yann@1
   131
		def = sym_get_string_value(sym);
yann@1
   132
		if (sym_get_string_value(sym))
yann@1
   133
			printf("[%s] ", def);
yann@943
   134
		if (!conf_askvalue(sym, def))
yann@943
   135
			return 0;
yann@1
   136
		switch (line[0]) {
yann@1
   137
		case '\n':
yann@1
   138
			break;
yann@1
   139
		case '?':
yann@1
   140
			/* print help */
yann@1
   141
			if (line[1] == '\n') {
yann@943
   142
				printf("\n%s\n", get_help(menu));
yann@1
   143
				def = NULL;
yann@1
   144
				break;
yann@1
   145
			}
yann@1
   146
		default:
yann@1
   147
			line[strlen(line)-1] = 0;
yann@1
   148
			def = line;
yann@1
   149
		}
yann@1
   150
		if (def && sym_set_string_value(sym, def))
yann@1
   151
			return 0;
yann@1
   152
	}
yann@1
   153
}
yann@1
   154
yann@1
   155
static int conf_sym(struct menu *menu)
yann@1
   156
{
yann@1
   157
	struct symbol *sym = menu->sym;
yann@1
   158
	int type;
yann@1
   159
	tristate oldval, newval;
yann@1
   160
yann@1
   161
	while (1) {
yann@943
   162
		printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
yann@1
   163
		if (sym->name)
yann@1
   164
			printf("(%s) ", sym->name);
yann@1
   165
		type = sym_get_type(sym);
yann@1
   166
		putchar('[');
yann@1
   167
		oldval = sym_get_tristate_value(sym);
yann@1
   168
		switch (oldval) {
yann@1
   169
		case no:
yann@1
   170
			putchar('N');
yann@1
   171
			break;
yann@1
   172
		case mod:
yann@1
   173
			putchar('M');
yann@1
   174
			break;
yann@1
   175
		case yes:
yann@1
   176
			putchar('Y');
yann@1
   177
			break;
yann@1
   178
		}
yann@1
   179
		if (oldval != no && sym_tristate_within_range(sym, no))
yann@1
   180
			printf("/n");
yann@1
   181
		if (oldval != mod && sym_tristate_within_range(sym, mod))
yann@1
   182
			printf("/m");
yann@1
   183
		if (oldval != yes && sym_tristate_within_range(sym, yes))
yann@1
   184
			printf("/y");
yann@943
   185
		if (menu_has_help(menu))
yann@1
   186
			printf("/?");
yann@1
   187
		printf("] ");
yann@943
   188
		if (!conf_askvalue(sym, sym_get_string_value(sym)))
yann@943
   189
			return 0;
yann@1
   190
		strip(line);
yann@1
   191
yann@1
   192
		switch (line[0]) {
yann@1
   193
		case 'n':
yann@1
   194
		case 'N':
yann@1
   195
			newval = no;
yann@1
   196
			if (!line[1] || !strcmp(&line[1], "o"))
yann@1
   197
				break;
yann@1
   198
			continue;
yann@1
   199
		case 'm':
yann@1
   200
		case 'M':
yann@1
   201
			newval = mod;
yann@1
   202
			if (!line[1])
yann@1
   203
				break;
yann@1
   204
			continue;
yann@1
   205
		case 'y':
yann@1
   206
		case 'Y':
yann@1
   207
			newval = yes;
yann@1
   208
			if (!line[1] || !strcmp(&line[1], "es"))
yann@1
   209
				break;
yann@1
   210
			continue;
yann@1
   211
		case 0:
yann@1
   212
			newval = oldval;
yann@1
   213
			break;
yann@1
   214
		case '?':
yann@1
   215
			goto help;
yann@1
   216
		default:
yann@1
   217
			continue;
yann@1
   218
		}
yann@1
   219
		if (sym_set_tristate_value(sym, newval))
yann@1
   220
			return 0;
yann@1
   221
help:
yann@943
   222
		printf("\n%s\n", get_help(menu));
yann@1
   223
	}
yann@1
   224
}
yann@1
   225
yann@1
   226
static int conf_choice(struct menu *menu)
yann@1
   227
{
yann@1
   228
	struct symbol *sym, *def_sym;
yann@1
   229
	struct menu *child;
yann@1
   230
	int type;
yann@1
   231
	bool is_new;
yann@1
   232
yann@1
   233
	sym = menu->sym;
yann@1
   234
	type = sym_get_type(sym);
yann@1
   235
	is_new = !sym_has_value(sym);
yann@1
   236
	if (sym_is_changable(sym)) {
yann@1
   237
		conf_sym(menu);
yann@1
   238
		sym_calc_value(sym);
yann@1
   239
		switch (sym_get_tristate_value(sym)) {
yann@1
   240
		case no:
yann@1
   241
			return 1;
yann@1
   242
		case mod:
yann@1
   243
			return 0;
yann@1
   244
		case yes:
yann@1
   245
			break;
yann@1
   246
		}
yann@1
   247
	} else {
yann@1
   248
		switch (sym_get_tristate_value(sym)) {
yann@1
   249
		case no:
yann@1
   250
			return 1;
yann@1
   251
		case mod:
yann@943
   252
			printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
yann@1
   253
			return 0;
yann@1
   254
		case yes:
yann@1
   255
			break;
yann@1
   256
		}
yann@1
   257
	}
yann@1
   258
yann@1
   259
	while (1) {
yann@1
   260
		int cnt, def;
yann@1
   261
yann@943
   262
		printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
yann@1
   263
		def_sym = sym_get_choice_value(sym);
yann@1
   264
		cnt = def = 0;
yann@1
   265
		line[0] = 0;
yann@1
   266
		for (child = menu->list; child; child = child->next) {
yann@1
   267
			if (!menu_is_visible(child))
yann@1
   268
				continue;
yann@1
   269
			if (!child->sym) {
yann@943
   270
				printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
yann@1
   271
				continue;
yann@1
   272
			}
yann@1
   273
			cnt++;
yann@1
   274
			if (child->sym == def_sym) {
yann@1
   275
				def = cnt;
yann@1
   276
				printf("%*c", indent, '>');
yann@1
   277
			} else
yann@1
   278
				printf("%*c", indent, ' ');
yann@943
   279
			printf(" %d. %s", cnt, _(menu_get_prompt(child)));
yann@1
   280
			if (child->sym->name)
yann@1
   281
				printf(" (%s)", child->sym->name);
yann@1
   282
			if (!sym_has_value(child->sym))
yann@943
   283
				printf(_(" (NEW)"));
yann@1
   284
			printf("\n");
yann@1
   285
		}
yann@943
   286
		printf(_("%*schoice"), indent - 1, "");
yann@1
   287
		if (cnt == 1) {
yann@1
   288
			printf("[1]: 1\n");
yann@1
   289
			goto conf_childs;
yann@1
   290
		}
yann@1
   291
		printf("[1-%d", cnt);
yann@943
   292
		if (menu_has_help(menu))
yann@1
   293
			printf("?");
yann@1
   294
		printf("]: ");
yann@1
   295
		switch (input_mode) {
yann@1
   296
		case ask_new:
yann@1
   297
		case ask_silent:
yann@1
   298
			if (!is_new) {
yann@1
   299
				cnt = def;
yann@1
   300
				printf("%d\n", cnt);
yann@1
   301
				break;
yann@1
   302
			}
yann@1
   303
			check_stdin();
yann@1
   304
		case ask_all:
yann@1
   305
			fflush(stdout);
yann@1
   306
			fgets(line, 128, stdin);
yann@1
   307
			strip(line);
yann@1
   308
			if (line[0] == '?') {
yann@943
   309
				printf("\n%s\n", get_help(menu));
yann@1
   310
				continue;
yann@1
   311
			}
yann@1
   312
			if (!line[0])
yann@1
   313
				cnt = def;
yann@1
   314
			else if (isdigit(line[0]))
yann@1
   315
				cnt = atoi(line);
yann@1
   316
			else
yann@1
   317
				continue;
yann@1
   318
			break;
yann@943
   319
		default:
yann@1
   320
			break;
yann@1
   321
		}
yann@1
   322
yann@1
   323
	conf_childs:
yann@1
   324
		for (child = menu->list; child; child = child->next) {
yann@1
   325
			if (!child->sym || !menu_is_visible(child))
yann@1
   326
				continue;
yann@1
   327
			if (!--cnt)
yann@1
   328
				break;
yann@1
   329
		}
yann@1
   330
		if (!child)
yann@1
   331
			continue;
yann@1
   332
		if (line[strlen(line) - 1] == '?') {
yann@943
   333
			printf("\n%s\n", get_help(child));
yann@1
   334
			continue;
yann@1
   335
		}
yann@1
   336
		sym_set_choice_value(sym, child->sym);
yann@943
   337
		for (child = child->list; child; child = child->next) {
yann@1
   338
			indent += 2;
yann@943
   339
			conf(child);
yann@1
   340
			indent -= 2;
yann@1
   341
		}
yann@1
   342
		return 1;
yann@1
   343
	}
yann@1
   344
}
yann@1
   345
yann@1
   346
static void conf(struct menu *menu)
yann@1
   347
{
yann@1
   348
	struct symbol *sym;
yann@1
   349
	struct property *prop;
yann@1
   350
	struct menu *child;
yann@1
   351
yann@1
   352
	if (!menu_is_visible(menu))
yann@1
   353
		return;
yann@1
   354
yann@1
   355
	sym = menu->sym;
yann@1
   356
	prop = menu->prompt;
yann@1
   357
	if (prop) {
yann@1
   358
		const char *prompt;
yann@1
   359
yann@1
   360
		switch (prop->type) {
yann@1
   361
		case P_MENU:
yann@1
   362
			if (input_mode == ask_silent && rootEntry != menu) {
yann@1
   363
				check_conf(menu);
yann@1
   364
				return;
yann@1
   365
			}
yann@1
   366
		case P_COMMENT:
yann@1
   367
			prompt = menu_get_prompt(menu);
yann@1
   368
			if (prompt)
yann@1
   369
				printf("%*c\n%*c %s\n%*c\n",
yann@1
   370
					indent, '*',
yann@943
   371
					indent, '*', _(prompt),
yann@1
   372
					indent, '*');
yann@1
   373
		default:
yann@1
   374
			;
yann@1
   375
		}
yann@1
   376
	}
yann@1
   377
yann@1
   378
	if (!sym)
yann@1
   379
		goto conf_childs;
yann@1
   380
yann@1
   381
	if (sym_is_choice(sym)) {
yann@1
   382
		conf_choice(menu);
yann@1
   383
		if (sym->curr.tri != mod)
yann@1
   384
			return;
yann@1
   385
		goto conf_childs;
yann@1
   386
	}
yann@1
   387
yann@1
   388
	switch (sym->type) {
yann@1
   389
	case S_INT:
yann@1
   390
	case S_HEX:
yann@1
   391
	case S_STRING:
yann@1
   392
		conf_string(menu);
yann@1
   393
		break;
yann@1
   394
	default:
yann@1
   395
		conf_sym(menu);
yann@1
   396
		break;
yann@1
   397
	}
yann@1
   398
yann@1
   399
conf_childs:
yann@1
   400
	if (sym)
yann@1
   401
		indent += 2;
yann@1
   402
	for (child = menu->list; child; child = child->next)
yann@1
   403
		conf(child);
yann@1
   404
	if (sym)
yann@1
   405
		indent -= 2;
yann@1
   406
}
yann@1
   407
yann@1
   408
static void check_conf(struct menu *menu)
yann@1
   409
{
yann@1
   410
	struct symbol *sym;
yann@1
   411
	struct menu *child;
yann@1
   412
yann@1
   413
	if (!menu_is_visible(menu))
yann@1
   414
		return;
yann@1
   415
yann@1
   416
	sym = menu->sym;
yann@1
   417
	if (sym && !sym_has_value(sym)) {
yann@1
   418
		if (sym_is_changable(sym) ||
yann@1
   419
		    (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
yann@1
   420
			if (!conf_cnt++)
yann@1
   421
				printf(_("*\n* Restart config...\n*\n"));
yann@1
   422
			rootEntry = menu_get_parent_menu(menu);
yann@1
   423
			conf(rootEntry);
yann@1
   424
		}
yann@1
   425
	}
yann@1
   426
yann@1
   427
	for (child = menu->list; child; child = child->next)
yann@1
   428
		check_conf(child);
yann@1
   429
}
yann@1
   430
yann@1
   431
int main(int ac, char **av)
yann@1
   432
{
yann@943
   433
	int opt;
yann@1
   434
	const char *name;
yann@1
   435
	struct stat tmpstat;
yann@1
   436
yann@943
   437
	setlocale(LC_ALL, "");
yann@943
   438
	bindtextdomain(PACKAGE, LOCALEDIR);
yann@943
   439
	textdomain(PACKAGE);
yann@943
   440
yann@943
   441
	while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
yann@943
   442
		switch (opt) {
yann@1
   443
		case 'o':
yann@943
   444
			input_mode = ask_silent;
yann@1
   445
			break;
yann@1
   446
		case 's':
yann@1
   447
			input_mode = ask_silent;
yann@943
   448
			sync_kconfig = 1;
yann@1
   449
			break;
yann@1
   450
		case 'd':
yann@1
   451
			input_mode = set_default;
yann@1
   452
			break;
yann@1
   453
		case 'D':
yann@1
   454
			input_mode = set_default;
yann@943
   455
			defconfig_file = optarg;
yann@1
   456
			break;
yann@1
   457
		case 'n':
yann@1
   458
			input_mode = set_no;
yann@1
   459
			break;
yann@1
   460
		case 'm':
yann@1
   461
			input_mode = set_mod;
yann@1
   462
			break;
yann@1
   463
		case 'y':
yann@1
   464
			input_mode = set_yes;
yann@1
   465
			break;
yann@1
   466
		case 'r':
yann@1
   467
			input_mode = set_random;
yann@943
   468
			srand(time(NULL));
yann@1
   469
			break;
yann@1
   470
		case 'h':
yann@943
   471
			printf(_("See README for usage info\n"));
yann@1
   472
			exit(0);
yann@943
   473
			break;
yann@943
   474
		default:
yann@943
   475
			fprintf(stderr, _("See README for usage info\n"));
yann@943
   476
			exit(1);
yann@1
   477
		}
yann@1
   478
	}
yann@943
   479
	if (ac == optind) {
yann@1
   480
		printf(_("%s: Kconfig file missing\n"), av[0]);
yann@1
   481
		exit(1);
yann@1
   482
	}
yann@943
   483
	name = av[optind];
yann@1
   484
	conf_parse(name);
yann@1
   485
	//zconfdump(stdout);
yann@943
   486
	if (sync_kconfig) {
yann@943
   487
		if (stat(".config", &tmpstat)) {
yann@943
   488
			fprintf(stderr, _("***\n"
yann@943
   489
				"*** Please run some configurator (e.g. \"make menuconfig\").\n"
yann@943
   490
				"***\n"));
yann@943
   491
			exit(1);
yann@943
   492
		}
yann@943
   493
	}
yann@943
   494
yann@1
   495
	switch (input_mode) {
yann@1
   496
	case set_default:
yann@1
   497
		if (!defconfig_file)
yann@1
   498
			defconfig_file = conf_get_default_confname();
yann@1
   499
		if (conf_read(defconfig_file)) {
yann@943
   500
			printf(_("***\n"
yann@1
   501
				"*** Can't find default configuration \"%s\"!\n"
yann@943
   502
				"***\n"), defconfig_file);
yann@1
   503
			exit(1);
yann@1
   504
		}
yann@1
   505
		break;
yann@1
   506
	case ask_silent:
yann@1
   507
	case ask_all:
yann@1
   508
	case ask_new:
yann@1
   509
		conf_read(NULL);
yann@1
   510
		break;
yann@1
   511
	case set_no:
yann@1
   512
	case set_mod:
yann@1
   513
	case set_yes:
yann@1
   514
	case set_random:
yann@1
   515
		name = getenv("KCONFIG_ALLCONFIG");
yann@1
   516
		if (name && !stat(name, &tmpstat)) {
yann@1
   517
			conf_read_simple(name, S_DEF_USER);
yann@1
   518
			break;
yann@1
   519
		}
yann@1
   520
		switch (input_mode) {
yann@1
   521
		case set_no:	 name = "allno.config"; break;
yann@1
   522
		case set_mod:	 name = "allmod.config"; break;
yann@1
   523
		case set_yes:	 name = "allyes.config"; break;
yann@1
   524
		case set_random: name = "allrandom.config"; break;
yann@1
   525
		default: break;
yann@1
   526
		}
yann@1
   527
		if (!stat(name, &tmpstat))
yann@1
   528
			conf_read_simple(name, S_DEF_USER);
yann@1
   529
		else if (!stat("all.config", &tmpstat))
yann@1
   530
			conf_read_simple("all.config", S_DEF_USER);
yann@1
   531
		break;
yann@1
   532
	default:
yann@1
   533
		break;
yann@1
   534
	}
yann@1
   535
yann@943
   536
	if (sync_kconfig) {
yann@943
   537
		if (conf_get_changed()) {
yann@943
   538
			name = getenv("KCONFIG_NOSILENTUPDATE");
yann@943
   539
			if (name && *name) {
yann@943
   540
				fprintf(stderr,
yann@943
   541
					_("\n*** Configuration requires explicit update.\n\n"));
yann@943
   542
				return 1;
yann@943
   543
			}
yann@943
   544
		}
yann@943
   545
		valid_stdin = isatty(0) && isatty(1) && isatty(2);
yann@943
   546
	}
yann@943
   547
yann@943
   548
	switch (input_mode) {
yann@943
   549
	case set_no:
yann@943
   550
		conf_set_all_new_symbols(def_no);
yann@943
   551
		break;
yann@943
   552
	case set_yes:
yann@943
   553
		conf_set_all_new_symbols(def_yes);
yann@943
   554
		break;
yann@943
   555
	case set_mod:
yann@943
   556
		conf_set_all_new_symbols(def_mod);
yann@943
   557
		break;
yann@943
   558
	case set_random:
yann@943
   559
		conf_set_all_new_symbols(def_random);
yann@943
   560
		break;
yann@943
   561
	case set_default:
yann@943
   562
		conf_set_all_new_symbols(def_default);
yann@943
   563
		break;
yann@943
   564
	case ask_new:
yann@943
   565
	case ask_all:
yann@1
   566
		rootEntry = &rootmenu;
yann@1
   567
		conf(&rootmenu);
yann@943
   568
		input_mode = ask_silent;
yann@943
   569
		/* fall through */
yann@943
   570
	case ask_silent:
yann@943
   571
		/* Update until a loop caused no more changes */
yann@943
   572
		do {
yann@943
   573
			conf_cnt = 0;
yann@943
   574
			check_conf(&rootmenu);
yann@943
   575
		} while (conf_cnt);
yann@943
   576
		break;
yann@943
   577
	}
yann@943
   578
yann@943
   579
	if (sync_kconfig) {
yann@943
   580
		/* silentoldconfig is used during the build so we shall update autoconf.
yann@943
   581
		 * All other commands are only used to generate a config.
yann@943
   582
		 */
yann@943
   583
		if (conf_get_changed() && conf_write(NULL)) {
yann@943
   584
			fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
yann@943
   585
			exit(1);
yann@1
   586
		}
yann@943
   587
	} else {
yann@943
   588
		if (conf_write(NULL)) {
yann@943
   589
			fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
yann@943
   590
			exit(1);
yann@1
   591
		}
yann@39
   592
	}
yann@39
   593
	return 0;
yann@1
   594
}