Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <limits.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <getopt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <sys/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <sys/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include "lkc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static void conf(struct menu *menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) static void check_conf(struct menu *menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) enum input_mode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	oldaskconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	syncconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	oldconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	allnoconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	allyesconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	allmodconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	alldefconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	randconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	defconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	savedefconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	listnewconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	helpnewconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	olddefconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	yes2modconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	mod2yesconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) static enum input_mode input_mode = oldaskconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static int indent = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static int tty_stdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static int sync_kconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static int conf_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) static char line[PATH_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static struct menu *rootEntry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static void print_help(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct gstr help = str_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	menu_get_ext_help(menu, &help);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	printf("\n%s\n", str_get(&help));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	str_free(&help);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static void strip(char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	char *p = str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	int l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	while ((isspace(*p)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		p++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	l = strlen(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if (p != str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		memmove(str, p, l + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	if (!l)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	p = str + l - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	while ((isspace(*p)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		*p-- = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) /* Helper function to facilitate fgets() by Jean Sacren. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) static void xfgets(char *str, int size, FILE *in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	if (!fgets(str, size, in))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		fprintf(stderr, "\nError in reading or end of file.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	if (!tty_stdio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		printf("%s", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) static int conf_askvalue(struct symbol *sym, const char *def)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	enum symbol_type type = sym_get_type(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	if (!sym_has_value(sym))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		printf("(NEW) ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	line[0] = '\n';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	line[1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	if (!sym_is_changeable(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		printf("%s\n", def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		line[0] = '\n';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		line[1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	switch (input_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	case oldconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	case syncconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		if (sym_has_value(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			printf("%s\n", def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		/* fall through */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	case oldaskconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		fflush(stdout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		xfgets(line, sizeof(line), stdin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	case S_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	case S_HEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	case S_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		printf("%s\n", def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	printf("%s", line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static int conf_string(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	struct symbol *sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	const char *def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		printf("%*s%s ", indent - 1, "", menu->prompt->text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		printf("(%s) ", sym->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		def = sym_get_string_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		if (sym_get_string_value(sym))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			printf("[%s] ", def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		if (!conf_askvalue(sym, def))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		switch (line[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		case '\n':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		case '?':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			/* print help */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			if (line[1] == '\n') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 				print_help(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 				def = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			/* fall through */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 			line[strlen(line)-1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			def = line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		if (def && sym_set_string_value(sym, def))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static int conf_sym(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	struct symbol *sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	tristate oldval, newval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		printf("%*s%s ", indent - 1, "", menu->prompt->text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		if (sym->name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 			printf("(%s) ", sym->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		putchar('[');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		oldval = sym_get_tristate_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		switch (oldval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		case no:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			putchar('N');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		case mod:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			putchar('M');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		case yes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			putchar('Y');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		if (oldval != no && sym_tristate_within_range(sym, no))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 			printf("/n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		if (oldval != mod && sym_tristate_within_range(sym, mod))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			printf("/m");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		if (oldval != yes && sym_tristate_within_range(sym, yes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			printf("/y");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		printf("/?] ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		if (!conf_askvalue(sym, sym_get_string_value(sym)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		strip(line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		switch (line[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		case 'n':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		case 'N':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 			newval = no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 			if (!line[1] || !strcmp(&line[1], "o"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		case 'm':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		case 'M':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 			newval = mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 			if (!line[1])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		case 'y':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		case 'Y':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			newval = yes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			if (!line[1] || !strcmp(&line[1], "es"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			newval = oldval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		case '?':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			goto help;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		if (sym_set_tristate_value(sym, newval))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) help:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		print_help(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) static int conf_choice(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	struct symbol *sym, *def_sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	struct menu *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	bool is_new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	is_new = !sym_has_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	if (sym_is_changeable(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		conf_sym(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		sym_calc_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		switch (sym_get_tristate_value(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		case no:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		case mod:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		case yes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		switch (sym_get_tristate_value(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		case no:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		case mod:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		case yes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		int cnt, def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		def_sym = sym_get_choice_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		cnt = def = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		line[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		for (child = menu->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 			if (!menu_is_visible(child))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 			if (!child->sym) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 				printf("%*c %s\n", indent, '*', menu_get_prompt(child));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 			cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 			if (child->sym == def_sym) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 				def = cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 				printf("%*c", indent, '>');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 			} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 				printf("%*c", indent, ' ');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			printf(" %d. %s", cnt, menu_get_prompt(child));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 			if (child->sym->name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 				printf(" (%s)", child->sym->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 			if (!sym_has_value(child->sym))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 				printf(" (NEW)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 			printf("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		printf("%*schoice", indent - 1, "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		if (cnt == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 			printf("[1]: 1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 			goto conf_childs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		printf("[1-%d?]: ", cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		switch (input_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		case oldconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		case syncconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 			if (!is_new) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 				cnt = def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 				printf("%d\n", cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 			/* fall through */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		case oldaskconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 			fflush(stdout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			xfgets(line, sizeof(line), stdin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 			strip(line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 			if (line[0] == '?') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 				print_help(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			if (!line[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 				cnt = def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 			else if (isdigit(line[0]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 				cnt = atoi(line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	conf_childs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		for (child = menu->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 			if (!child->sym || !menu_is_visible(child))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 			if (!--cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		if (!child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		if (line[0] && line[strlen(line) - 1] == '?') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 			print_help(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		sym_set_choice_value(sym, child->sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		for (child = child->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 			indent += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 			conf(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 			indent -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) static void conf(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	struct symbol *sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	struct property *prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	struct menu *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	if (!menu_is_visible(menu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	prop = menu->prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	if (prop) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		const char *prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		switch (prop->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		case P_MENU:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 			 * Except in oldaskconfig mode, we show only menus that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 			 * contain new symbols.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			if (input_mode != oldaskconfig && rootEntry != menu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 				check_conf(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 			/* fall through */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		case P_COMMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 			prompt = menu_get_prompt(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 			if (prompt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 				printf("%*c\n%*c %s\n%*c\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 					indent, '*',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 					indent, '*', prompt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 					indent, '*');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 			;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	if (!sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		goto conf_childs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	if (sym_is_choice(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		conf_choice(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		if (sym->curr.tri != mod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		goto conf_childs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	switch (sym->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	case S_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	case S_HEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	case S_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		conf_string(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		conf_sym(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) conf_childs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	if (sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		indent += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	for (child = menu->list; child; child = child->next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		conf(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	if (sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		indent -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) static void check_conf(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	struct symbol *sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	struct menu *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	if (!menu_is_visible(menu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	if (sym && !sym_has_value(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 		if (sym_is_changeable(sym) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 		    (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 			if (input_mode == listnewconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 				if (sym->name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 					const char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 					if (sym->type == S_STRING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 						str = sym_get_string_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 						str = sym_escape_string_value(str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 						printf("%s%s=%s\n", CONFIG_, sym->name, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 						free((void *)str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 					} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 						str = sym_get_string_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 						printf("%s%s=%s\n", CONFIG_, sym->name, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 					}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 			} else if (input_mode == helpnewconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 				printf("-----\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 				print_help(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 				printf("-----\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 				if (!conf_cnt++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 					printf("*\n* Restart config...\n*\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 				rootEntry = menu_get_parent_menu(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 				conf(rootEntry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	for (child = menu->list; child; child = child->next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 		check_conf(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) static struct option long_opts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	{"oldaskconfig",    no_argument,       NULL, oldaskconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	{"oldconfig",       no_argument,       NULL, oldconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	{"syncconfig",      no_argument,       NULL, syncconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	{"defconfig",       required_argument, NULL, defconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	{"savedefconfig",   required_argument, NULL, savedefconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	{"allnoconfig",     no_argument,       NULL, allnoconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	{"allyesconfig",    no_argument,       NULL, allyesconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	{"allmodconfig",    no_argument,       NULL, allmodconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	{"alldefconfig",    no_argument,       NULL, alldefconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	{"randconfig",      no_argument,       NULL, randconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	{"listnewconfig",   no_argument,       NULL, listnewconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	{"helpnewconfig",   no_argument,       NULL, helpnewconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	{"olddefconfig",    no_argument,       NULL, olddefconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	{"yes2modconfig",   no_argument,       NULL, yes2modconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	{"mod2yesconfig",   no_argument,       NULL, mod2yesconfig},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	{NULL, 0, NULL, 0}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) static void conf_usage(const char *progname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	printf("Usage: %s [-s] [option] <kconfig-file>\n", progname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	printf("[option] is _one_ of the following:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	printf("  --listnewconfig         List new options\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	printf("  --helpnewconfig         List new options and help text\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	printf("  --oldaskconfig          Start a new configuration using a line-oriented program\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	printf("  --oldconfig             Update a configuration using a provided .config as base\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	printf("  --syncconfig            Similar to oldconfig but generates configuration in\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	       "                          include/{generated/,config/}\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	printf("  --olddefconfig          Same as oldconfig but sets new symbols to their default value\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	printf("  --defconfig <file>      New config with default defined in <file>\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	printf("  --savedefconfig <file>  Save the minimal current configuration to <file>\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	printf("  --allnoconfig           New config where all options are answered with no\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	printf("  --allyesconfig          New config where all options are answered with yes\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	printf("  --allmodconfig          New config where all options are answered with mod\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	printf("  --alldefconfig          New config with all symbols set to default\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	printf("  --randconfig            New config with random answer to all options\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	printf("  --yes2modconfig         Change answers from yes to mod if possible\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	printf("  --mod2yesconfig         Change answers from mod to yes if possible\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) int main(int ac, char **av)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	const char *progname = av[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	int opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	const char *name, *defconfig_file = NULL /* gcc uninit */;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	int no_conf_write = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	tty_stdio = isatty(0) && isatty(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		if (opt == 's') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 			conf_set_message_callback(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		input_mode = (enum input_mode)opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		switch (opt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 		case syncconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 			 * syncconfig is invoked during the build stage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 			 * Suppress distracting "configuration written to ..."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 			conf_set_message_callback(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 			sync_kconfig = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 		case defconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 		case savedefconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 			defconfig_file = optarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 		case randconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 			struct timeval now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 			unsigned int seed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 			char *seed_env;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 			 * Use microseconds derived seed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 			 * compensate for systems where it may be zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 			gettimeofday(&now, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 			seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 			seed_env = getenv("KCONFIG_SEED");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 			if( seed_env && *seed_env ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 				char *endp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 				int tmp = (int)strtol(seed_env, &endp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 				if (*endp == '\0') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 					seed = tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 			fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 			srand(seed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 		case oldaskconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 		case oldconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 		case allnoconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 		case allyesconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 		case allmodconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 		case alldefconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 		case listnewconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 		case helpnewconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 		case olddefconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 		case yes2modconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 		case mod2yesconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 		case '?':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 			conf_usage(progname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 			exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	if (ac == optind) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 		fprintf(stderr, "%s: Kconfig file missing\n", av[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		conf_usage(progname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 		exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	name = av[optind];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	conf_parse(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	//zconfdump(stdout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	switch (input_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	case defconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 		if (conf_read(defconfig_file)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 			fprintf(stderr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 				"***\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 				  "*** Can't find default configuration \"%s\"!\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 				  "***\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 				defconfig_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 			exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	case savedefconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	case syncconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	case oldaskconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	case oldconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	case listnewconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	case helpnewconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	case olddefconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	case yes2modconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	case mod2yesconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 		conf_read(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 	case allnoconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	case allyesconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	case allmodconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	case alldefconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	case randconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 		name = getenv("KCONFIG_ALLCONFIG");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 		if (!name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 		if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 			if (conf_read_simple(name, S_DEF_USER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 				fprintf(stderr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 					"*** Can't read seed configuration \"%s\"!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 					name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 				exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 		switch (input_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 		case allnoconfig:	name = "allno.config"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 		case allyesconfig:	name = "allyes.config"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 		case allmodconfig:	name = "allmod.config"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 		case alldefconfig:	name = "alldef.config"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 		case randconfig:	name = "allrandom.config"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 		default: break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 		if (conf_read_simple(name, S_DEF_USER) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 		    conf_read_simple("all.config", S_DEF_USER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 			fprintf(stderr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 				"*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 				name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 			exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 	if (sync_kconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 		name = getenv("KCONFIG_NOSILENTUPDATE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 		if (name && *name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 			if (conf_get_changed()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 				fprintf(stderr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 					"\n*** The configuration requires explicit update.\n\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 				return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 			no_conf_write = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	switch (input_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 	case allnoconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 		conf_set_all_new_symbols(def_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 	case allyesconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 		conf_set_all_new_symbols(def_yes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	case allmodconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 		conf_set_all_new_symbols(def_mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 	case alldefconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 		conf_set_all_new_symbols(def_default);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	case randconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 		/* Really nothing to do in this loop */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 		while (conf_set_all_new_symbols(def_random)) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	case defconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 		conf_set_all_new_symbols(def_default);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 	case savedefconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	case yes2modconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 		conf_rewrite_mod_or_yes(def_y2m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	case mod2yesconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 		conf_rewrite_mod_or_yes(def_m2y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 	case oldaskconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		rootEntry = &rootmenu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 		conf(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 		input_mode = oldconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 		/* fall through */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 	case oldconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 	case listnewconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 	case helpnewconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 	case syncconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 		/* Update until a loop caused no more changes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 		do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 			conf_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 			check_conf(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 		} while (conf_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 	case olddefconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 	if (input_mode == savedefconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 		if (conf_write_defconfig(defconfig_file)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 			fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 				defconfig_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 	} else if (input_mode != listnewconfig && input_mode != helpnewconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 		if (!no_conf_write && conf_write(NULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 			fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 			exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 		 * Create auto.conf if it does not exist.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 		 * This prevents GNU Make 4.1 or older from emitting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 		 * "include/config/auto.conf: No such file or directory"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 		 * in the top-level Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 		 * syncconfig always creates or updates auto.conf because it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 		 * used during the build.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 		if (conf_write_autoconf(sync_kconfig) && sync_kconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 			fprintf(stderr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 				"\n*** Error during sync of the configuration.\n\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) }