Commit 4b3e11b3 authored by Alper Yildirim's avatar Alper Yildirim Committed by Thomas Petazzoni
Browse files

config: Update package/config to Kconfig 2.6.30



Update the package/config stuff with the code available in the Linux
kernel 2.6.30.

Signed-off-by: default avatarAlper Yildirim <ayildirim@aselsan.com>
parent ea536503
Loading
Loading
Loading
Loading
+33 −20
Original line number Diff line number Diff line
@@ -4,7 +4,11 @@

PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config

ifdef KBUILD_KCONFIG
Kconfig := $(KBUILD_KCONFIG)
else
Kconfig := arch/$(SRCARCH)/Kconfig
endif

xconfig: $(obj)/qconf
	$< $(Kconfig)
@@ -24,22 +28,25 @@ oldconfig: $(obj)/conf
silentoldconfig: $(obj)/conf
	$< -s $(Kconfig)

# Create new linux.po file
# Create new linux.pot file
# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
# The symlink is used to repair a deficiency in arch/um
update-po-config: $(obj)/kxgettext
	xgettext --default-domain=linux                  \
update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
	$(Q)echo "  GEN config"
	$(Q)xgettext --default-domain=linux              \
	    --add-comments --keyword=_ --keyword=N_      \
	    --from-code=UTF-8                            \
	    --files-from=scripts/kconfig/POTFILES.in     \
	    --output $(obj)/config.pot
	$(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
	$(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch
	(for i in `ls arch/`;                            \
	$(Q)(for i in `ls arch/*/Kconfig`;               \
	    do                                           \
	    $(obj)/kxgettext arch/$$i/Kconfig;           \
	done ) >> $(obj)/config.pot
	msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
		echo "  GEN $$i";                        \
		$(obj)/kxgettext $$i                     \
		     >> $(obj)/config.pot;               \
	    done )
	$(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
	    --output $(obj)/linux.pot
	$(Q)rm -f arch/um/Kconfig.arch
	$(Q)rm -f $(obj)/config.pot
@@ -76,7 +83,7 @@ help:
	@echo  '  xconfig	  - Update current config utilising a QT based front-end'
	@echo  '  gconfig	  - Update current config utilising a GTK based front-end'
	@echo  '  oldconfig	  - Update current config utilising a provided .config as base'
	@echo  '  silentoldconfig - Same as oldconfig, but quietly'
	@echo  '  silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
	@echo  '  randconfig	  - New config with random answer to all options'
	@echo  '  defconfig	  - New config with default answer to all options'
	@echo  '  allmodconfig	  - New config selecting modules when possible'
@@ -93,17 +100,11 @@ HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))

HOST_EXTRACFLAGS += -DLOCALE

PHONY += $(obj)/dochecklxdialog
$(obj)/dochecklxdialog:
	$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)

always := dochecklxdialog


# ===========================================================================
# Shared Makefile for the various kconfig executables:
# conf:	  Used for defconfig, oldconfig and related targets
# mconf:  Used for the mconfig target.
# mconf:  Used for the menuconfig target
#         Utilizes the lxdialog package
# qconf:  Used for the xconfig target
#         Based on QT which needs to be installed to compile it
@@ -145,8 +146,17 @@ gconf-objs := gconf.o kconfig_load.o zconf.tab.o
endif

clean-files	:= lkc_defs.h qconf.moc .tmp_qtcheck \
		   .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c
		   .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
clean-files     += mconf qconf gconf
clean-files     += config.pot linux.pot

# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
PHONY += $(obj)/dochecklxdialog
$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
$(obj)/dochecklxdialog:
	$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES)

always := dochecklxdialog

# Add environment specific flags
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
@@ -184,8 +194,8 @@ $(obj)/.tmp_qtcheck:
	  done; \
	  if [ -z "$$dir" ]; then \
	    echo "*"; \
	    echo "* Unable to find the QT installation. Please make sure that"; \
	    echo "* the QT development package is correctly installed and"; \
	    echo "* Unable to find the QT3 installation. Please make sure that"; \
	    echo "* the QT3 development package is correctly installed and"; \
	    echo "* either install pkg-config or set the QTDIR environment"; \
	    echo "* variable to the correct location."; \
	    echo "*"; \
@@ -251,6 +261,9 @@ $(obj)/%.moc: $(src)/%.h
$(obj)/lkc_defs.h: $(src)/lkc_proto.h
	sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'

# Extract gconf menu items for I18N support
$(obj)/gconf.glade.h: $(obj)/gconf.glade
	intltool-extract --type=gettext/glade $(obj)/gconf.glade

###
# The following requires flex/bison/gperf
+7 −0
Original line number Diff line number Diff line
scripts/kconfig/lxdialog/checklist.c
scripts/kconfig/lxdialog/inputbox.c
scripts/kconfig/lxdialog/menubox.c
scripts/kconfig/lxdialog/textbox.c
scripts/kconfig/lxdialog/util.c
scripts/kconfig/lxdialog/yesno.c
scripts/kconfig/mconf.c
scripts/kconfig/conf.c
scripts/kconfig/confdata.c
scripts/kconfig/gconf.c
scripts/kconfig/gconf.glade.h
scripts/kconfig/qconf.cc
+122 −137
Original line number Diff line number Diff line
@@ -3,13 +3,15 @@
 * Released under the terms of the GNU GPL v2.0.
 */

#include <locale.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>

#define LKC_DIRECT_LINK
#include "lkc.h"
@@ -31,6 +33,7 @@ char *defconfig_file;

static int indent = 1;
static int valid_stdin = 1;
static int sync_kconfig;
static int conf_cnt;
static char line[128];
static struct menu *rootEntry;
@@ -40,7 +43,7 @@ static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n"
static const char *get_help(struct menu *menu)
{
	if (menu_has_help(menu))
		return menu_get_help(menu);
		return _(menu_get_help(menu));
	else
		return nohelp_text;
}
@@ -64,7 +67,7 @@ static void strip(char *str)

static void check_stdin(void)
{
	if (!valid_stdin && input_mode == ask_silent) {
	if (!valid_stdin) {
		printf(_("aborted!\n\n"));
		printf(_("Console input/output is redirected. "));
		printf(_("Run 'make oldconfig' to update configuration.\n\n"));
@@ -75,10 +78,9 @@ static void check_stdin(void)
static int conf_askvalue(struct symbol *sym, const char *def)
{
	enum symbol_type type = sym_get_type(sym);
	tristate val;

	if (!sym_has_value(sym))
		printf("(NEW) ");
		printf(_("(NEW) "));

	line[0] = '\n';
	line[1] = 0;
@@ -91,15 +93,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
	}

	switch (input_mode) {
	case set_no:
	case set_mod:
	case set_yes:
	case set_random:
		if (sym_has_value(sym)) {
			printf("%s\n", def);
			return 0;
		}
		break;
	case ask_new:
	case ask_silent:
		if (sym_has_value(sym)) {
@@ -111,9 +104,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
		fflush(stdout);
		fgets(line, 128, stdin);
		return 1;
	case set_default:
		printf("%s\n", def);
		return 1;
	default:
		break;
	}
@@ -127,52 +117,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
	default:
		;
	}
	switch (input_mode) {
	case set_yes:
		if (sym_tristate_within_range(sym, yes)) {
			line[0] = 'y';
			line[1] = '\n';
			line[2] = 0;
			break;
		}
	case set_mod:
		if (type == S_TRISTATE) {
			if (sym_tristate_within_range(sym, mod)) {
				line[0] = 'm';
				line[1] = '\n';
				line[2] = 0;
				break;
			}
		} else {
			if (sym_tristate_within_range(sym, yes)) {
				line[0] = 'y';
				line[1] = '\n';
				line[2] = 0;
				break;
			}
		}
	case set_no:
		if (sym_tristate_within_range(sym, no)) {
			line[0] = 'n';
			line[1] = '\n';
			line[2] = 0;
			break;
		}
	case set_random:
		do {
			val = (tristate)(random() % 3);
		} while (!sym_tristate_within_range(sym, val));
		switch (val) {
		case no: line[0] = 'n'; break;
		case mod: line[0] = 'm'; break;
		case yes: line[0] = 'y'; break;
		}
		line[1] = '\n';
		line[2] = 0;
		break;
	default:
		break;
	}
	printf("%s", line);
	return 1;
}
@@ -183,7 +127,7 @@ int conf_string(struct menu *menu)
	const char *def;

	while (1) {
		printf("%*s%s ", indent - 1, "", menu->prompt->text);
		printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
		printf("(%s) ", sym->name);
		def = sym_get_string_value(sym);
		if (sym_get_string_value(sym))
@@ -216,7 +160,7 @@ static int conf_sym(struct menu *menu)
	tristate oldval, newval;

	while (1) {
		printf("%*s%s ", indent - 1, "", menu->prompt->text);
		printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
		if (sym->name)
			printf("(%s) ", sym->name);
		type = sym_get_type(sym);
@@ -306,7 +250,7 @@ static int conf_choice(struct menu *menu)
		case no:
			return 1;
		case mod:
			printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
			printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
			return 0;
		case yes:
			break;
@@ -316,7 +260,7 @@ static int conf_choice(struct menu *menu)
	while (1) {
		int cnt, def;

		printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
		printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
		def_sym = sym_get_choice_value(sym);
		cnt = def = 0;
		line[0] = 0;
@@ -324,7 +268,7 @@ static int conf_choice(struct menu *menu)
			if (!menu_is_visible(child))
				continue;
			if (!child->sym) {
				printf("%*c %s\n", indent, '*', menu_get_prompt(child));
				printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
				continue;
			}
			cnt++;
@@ -333,14 +277,14 @@ static int conf_choice(struct menu *menu)
				printf("%*c", indent, '>');
			} else
				printf("%*c", indent, ' ');
			printf(" %d. %s", cnt, menu_get_prompt(child));
			printf(" %d. %s", cnt, _(menu_get_prompt(child)));
			if (child->sym->name)
				printf(" (%s)", child->sym->name);
			if (!sym_has_value(child->sym))
				printf(" (NEW)");
				printf(_(" (NEW)"));
			printf("\n");
		}
		printf("%*schoice", indent - 1, "");
		printf(_("%*schoice"), indent - 1, "");
		if (cnt == 1) {
			printf("[1]: 1\n");
			goto conf_childs;
@@ -373,15 +317,7 @@ static int conf_choice(struct menu *menu)
			else
				continue;
			break;
		case set_random:
			if (is_new)
				def = (random() % cnt) + 1;
		case set_default:
		case set_yes:
		case set_mod:
		case set_no:
			cnt = def;
			printf("%d\n", cnt);
		default:
			break;
		}

@@ -399,9 +335,9 @@ static int conf_choice(struct menu *menu)
			continue;
		}
		sym_set_choice_value(sym, child->sym);
		if (child->list) {
		for (child = child->list; child; child = child->next) {
			indent += 2;
			conf(child->list);
			conf(child);
			indent -= 2;
		}
		return 1;
@@ -433,7 +369,7 @@ static void conf(struct menu *menu)
			if (prompt)
				printf("%*c\n%*c %s\n%*c\n",
					indent, '*',
					indent, '*', prompt,
					indent, '*', _(prompt),
					indent, '*');
		default:
			;
@@ -495,30 +431,29 @@ static void check_conf(struct menu *menu)

int main(int ac, char **av)
{
	int i = 1;
	int opt;
	const char *name;
	struct stat tmpstat;

	if (ac > i && av[i][0] == '-') {
		switch (av[i++][1]) {
	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
		switch (opt) {
		case 'o':
			input_mode = ask_new;
			input_mode = ask_silent;
			break;
		case 's':
			input_mode = ask_silent;
			valid_stdin = isatty(0) && isatty(1) && isatty(2);
			sync_kconfig = 1;
			break;
		case 'd':
			input_mode = set_default;
			break;
		case 'D':
			input_mode = set_default;
			defconfig_file = av[i++];
			if (!defconfig_file) {
				printf(_("%s: No default config file specified\n"),
					av[0]);
				exit(1);
			}
			defconfig_file = optarg;
			break;
		case 'n':
			input_mode = set_no;
@@ -530,44 +465,63 @@ int main(int ac, char **av)
			input_mode = set_yes;
			break;
		case 'r':
		{
			struct timeval now;
			unsigned int seed;

			/*
			 * Use microseconds derived seed,
			 * compensate for systems where it may be zero
			 */
			gettimeofday(&now, NULL);

			seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
			srand(seed);

			input_mode = set_random;
			srandom(time(NULL));
			break;
		}
		case 'h':
		case '?':
			fprintf(stderr, "See README for usage info\n");
			printf(_("See README for usage info\n"));
			exit(0);
			break;
		default:
			fprintf(stderr, _("See README for usage info\n"));
			exit(1);
		}
	}
  	name = av[i];
	if (!name) {
	if (ac == optind) {
		printf(_("%s: Kconfig file missing\n"), av[0]);
		exit(1);
	}
	name = av[optind];
	conf_parse(name);
	/*zconfdump(stdout);*/
	if (sync_kconfig) {
		name = conf_get_configname();
		if (stat(name, &tmpstat)) {
			fprintf(stderr, _("***\n"
				"*** You have not yet configured Buildroot!\n"
				"*** (missing .config file \"%s\")\n"
				"***\n"
				"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
				"*** \"make menuconfig\" or \"make xconfig\").\n"
				"***\n"), name);
			exit(1);
		}
	}

	switch (input_mode) {
	case set_default:
		if (!defconfig_file)
			defconfig_file = conf_get_default_confname();
		if (conf_read(defconfig_file)) {
			printf("***\n"
			printf(_("***\n"
				"*** Can't find default configuration \"%s\"!\n"
				"***\n", defconfig_file);
				"***\n"), defconfig_file);
			exit(1);
		}
		break;
	case ask_silent:
		if (stat(".config", &tmpstat)) {
			printf(_("***\n"
				"*** You have not yet configured Buildroot!\n"
				"*** (missing .config file)\n"
				"***\n"
				"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
				"*** \"make menuconfig\" or \"make config\").\n"
				"***\n"));
			exit(1);
		}
	case ask_all:
	case ask_new:
		conf_read(NULL);
@@ -597,35 +551,66 @@ int main(int ac, char **av)
		break;
	}

	if (input_mode != ask_silent) {
		rootEntry = &rootmenu;
		conf(&rootmenu);
		if (input_mode == ask_all) {
			input_mode = ask_silent;
			valid_stdin = 1;
		}
	} else if (conf_get_changed()) {
	if (sync_kconfig) {
		if (conf_get_changed()) {
			name = getenv("KCONFIG_NOSILENTUPDATE");
			if (name && *name) {
			fprintf(stderr, _("\n*** Buildroot configuration requires explicit update.\n\n"));
				fprintf(stderr,
					_("\n*** Buildroot configuration requires explicit update.\n\n"));
				return 1;
			}
	} else
		goto skip_check;
		}
		valid_stdin = isatty(0) && isatty(1) && isatty(2);
	}

	switch (input_mode) {
	case set_no:
		conf_set_all_new_symbols(def_no);
		break;
	case set_yes:
		conf_set_all_new_symbols(def_yes);
		break;
	case set_mod:
		conf_set_all_new_symbols(def_mod);
		break;
	case set_random:
		conf_set_all_new_symbols(def_random);
		break;
	case set_default:
		conf_set_all_new_symbols(def_default);
		break;
	case ask_new:
	case ask_all:
		rootEntry = &rootmenu;
		conf(&rootmenu);
		input_mode = ask_silent;
		/* fall through */
	case ask_silent:
		/* Update until a loop caused no more changes */
		do {
			conf_cnt = 0;
			check_conf(&rootmenu);
		} while (conf_cnt);
	if (conf_write(NULL)) {
		break;
	}

	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)) {
			fprintf(stderr, _("\n*** Error during writing of the Buildroot configuration.\n\n"));
			exit(1);
		}
		if (conf_write_autoconf()) {
			fprintf(stderr, _("\n*** Error during update of the Buildroot configuration.\n\n"));
			return 1;
		}
skip_check:
	if (/*input_mode == ask_silent &&*/ conf_write_autoconf()) {
	} else {
		if (conf_write(NULL)) {
			fprintf(stderr, _("\n*** Error during writing of the Buildroot configuration.\n\n"));
		return 1;
			exit(1);
		}
	}

	return 0;
}
+115 −24
Original line number Diff line number Diff line
@@ -42,6 +42,13 @@ const char *conf_get_configname(void)
	return name ? name : ".config";
}

const char *conf_get_autoconfig_name(void)
{
	char *name = getenv("BUILDROOT_AUTOCONFIG");

	return name ? name : "$(BR2_DEPENDS_DIR)/config/auto.conf";
}

static char *conf_expand_value(const char *in)
{
	struct symbol *sym;
@@ -224,7 +231,7 @@ load:
			if (def == S_DEF_USER) {
				sym = sym_find(line + 2);
				if (!sym) {
					conf_warning("trying to assign nonexistent symbol %s", line + 2);
					sym_add_change_count(1);
					break;
				}
			} else {
@@ -233,8 +240,7 @@ load:
					sym->type = S_BOOLEAN;
			}
			if (sym->flags & def_flags) {
				conf_warning("trying to reassign symbol %s", sym->name);
				break;
				conf_warning("override: reassigning to symbol %s", sym->name);
			}
			switch (sym->type) {
			case S_BOOLEAN:
@@ -260,7 +266,7 @@ load:
			if (def == S_DEF_USER) {
				sym = sym_find(line);
				if (!sym) {
					conf_warning("trying to assign nonexistent symbol %s", line);
					sym_add_change_count(1);
					break;
				}
			} else {
@@ -269,8 +275,7 @@ load:
					sym->type = S_OTHER;
			}
			if (sym->flags & def_flags) {
				conf_warning("trying to reassign symbol %s", sym->name);
				break;
				conf_warning("override: reassigning to symbol %s", sym->name);
			}
			if (conf_set_sym_val(sym, def, def_flags, p))
				continue;
@@ -294,14 +299,12 @@ load:
				}
				break;
			case yes:
				if (cs->def[def].tri != no) {
					conf_warning("%s creates inconsistent choice state", sym->name);
					cs->flags &= ~def_flags;
				} else
				if (cs->def[def].tri != no)
					conf_warning("override: %s changes choice state", sym->name);
				cs->def[def].val = sym;
				break;
			}
			cs->def[def].tri = E_OR(cs->def[def].tri, sym->def[def].tri);
			cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
		}
	}
	fclose(in);
@@ -313,7 +316,7 @@ load:

int conf_read(const char *name)
{
	struct symbol *sym;
	struct symbol *sym, *choice_sym;
	struct property *prop;
	struct expr *e;
	int i, flags;
@@ -354,9 +357,9 @@ int conf_read(const char *name)
		 */
		prop = sym_get_choice_prop(sym);
		flags = sym->flags;
		for (e = prop->expr; e; e = e->left.expr)
			if (e->right.sym->visible != no)
				flags &= e->right.sym->flags;
		expr_list_for_each_sym(prop->expr, e, choice_sym)
			if (choice_sym->visible != no)
				flags &= choice_sym->flags;
		sym->flags &= flags | ~SYMBOL_DEF_USER;
	}

@@ -554,15 +557,15 @@ int conf_write(const char *name)

int conf_split_config(void)
{
	char *name, path[128], *opwd, *dir, *_name;
	const char *name;
	char path[128];
	char *opwd, *dir, *_name;
	char *s, *d, c;
	struct symbol *sym;
	struct stat sb;
	int res, i, fd;

	name = getenv("KCONFIG_AUTOCONFIG");
	if (!name)
		name = "include/config/auto.conf";
	name = conf_get_autoconfig_name();
	conf_read_simple(name, S_DEF_AUTO);

	opwd = malloc(256);
@@ -683,7 +686,7 @@ int conf_write_autoconf(void)
{
	struct symbol *sym;
	const char *str;
	char *name;
	const char *name;
	FILE *out, *out_h;
	time_t now;
	int i, l;
@@ -783,9 +786,7 @@ int conf_write_autoconf(void)
		name = "include/linux/autoconf.h";
	if (rename(".tmpconfig.h", name))
		return 1;
	name = getenv("KCONFIG_AUTOCONFIG");
	if (!name)
		name = "include/config/auto.conf";
	name = conf_get_autoconfig_name();
	/*
	 * This must be the last step, kbuild has a dependency on auto.conf
	 * and this marks the successful completion of the previous steps.
@@ -822,3 +823,93 @@ void conf_set_changed_callback(void (*fn)(void))
{
	conf_changed_callback = fn;
}


void conf_set_all_new_symbols(enum conf_def_mode mode)
{
	struct symbol *sym, *csym;
	struct property *prop;
	struct expr *e;
	int i, cnt, def;

	for_all_symbols(i, sym) {
		if (sym_has_value(sym))
			continue;
		switch (sym_get_type(sym)) {
		case S_BOOLEAN:
		case S_TRISTATE:
			switch (mode) {
			case def_yes:
				sym->def[S_DEF_USER].tri = yes;
				break;
			case def_mod:
				sym->def[S_DEF_USER].tri = mod;
				break;
			case def_no:
				sym->def[S_DEF_USER].tri = no;
				break;
			case def_random:
				sym->def[S_DEF_USER].tri = (tristate)(rand() % 3);
				break;
			default:
				continue;
			}
			if (!(sym_is_choice(sym) && mode == def_random))
				sym->flags |= SYMBOL_DEF_USER;
			break;
		default:
			break;
		}

	}

	sym_clear_all_valid();

	if (mode != def_random)
		return;
	/*
	 * We have different type of choice blocks.
	 * If curr.tri equal to mod then we can select several
	 * choice symbols in one block.
	 * In this case we do nothing.
	 * If curr.tri equal yes then only one symbol can be
	 * selected in a choice block and we set it to yes,
	 * and the rest to no.
	 */
	for_all_symbols(i, csym) {
		if (sym_has_value(csym) || !sym_is_choice(csym))
			continue;

		sym_calc_value(csym);

		if (csym->curr.tri != yes)
			continue;

		prop = sym_get_choice_prop(csym);

		/* count entries in choice block */
		cnt = 0;
		expr_list_for_each_sym(prop->expr, e, sym)
			cnt++;

		/*
		 * find a random value and set it to yes,
		 * set the rest to no so we have only one set
		 */
		def = (rand() % cnt);

		cnt = 0;
		expr_list_for_each_sym(prop->expr, e, sym) {
			if (def == cnt++) {
				sym->def[S_DEF_USER].tri = yes;
				csym->def[S_DEF_USER].val = sym;
			}
			else {
				sym->def[S_DEF_USER].tri = no;
			}
		}
		csym->flags |= SYMBOL_DEF_USER;
		/* clear VALID to get value calculated */
		csym->flags &= ~(SYMBOL_VALID);
	}
}
+19 −13
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ struct expr *expr_copy(struct expr *org)
		break;
	case E_AND:
	case E_OR:
	case E_CHOICE:
	case E_LIST:
		e->left.expr = expr_copy(org->left.expr);
		e->right.expr = expr_copy(org->right.expr);
		break;
@@ -217,7 +217,7 @@ int expr_eq(struct expr *e1, struct expr *e2)
		expr_free(e2);
		trans_count = old_count;
		return res;
	case E_CHOICE:
	case E_LIST:
	case E_RANGE:
	case E_NONE:
		/* panic */;
@@ -648,7 +648,7 @@ struct expr *expr_transform(struct expr *e)
	case E_EQUAL:
	case E_UNEQUAL:
	case E_SYMBOL:
	case E_CHOICE:
	case E_LIST:
		break;
	default:
		e->left.expr = expr_transform(e->left.expr);
@@ -932,7 +932,7 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb
		break;
	case E_SYMBOL:
		return expr_alloc_comp(type, e->left.sym, sym);
	case E_CHOICE:
	case E_LIST:
	case E_RANGE:
	case E_NONE:
		/* panic */;
@@ -955,14 +955,14 @@ tristate expr_calc_value(struct expr *e)
	case E_AND:
		val1 = expr_calc_value(e->left.expr);
		val2 = expr_calc_value(e->right.expr);
		return E_AND(val1, val2);
		return EXPR_AND(val1, val2);
	case E_OR:
		val1 = expr_calc_value(e->left.expr);
		val2 = expr_calc_value(e->right.expr);
		return E_OR(val1, val2);
		return EXPR_OR(val1, val2);
	case E_NOT:
		val1 = expr_calc_value(e->left.expr);
		return E_NOT(val1);
		return EXPR_NOT(val1);
	case E_EQUAL:
		sym_calc_value(e->left.sym);
		sym_calc_value(e->right.sym);
@@ -1000,9 +1000,9 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
		if (t2 == E_OR)
			return 1;
	case E_OR:
		if (t2 == E_CHOICE)
		if (t2 == E_LIST)
			return 1;
	case E_CHOICE:
	case E_LIST:
		if (t2 == 0)
			return 1;
	default:
@@ -1034,12 +1034,18 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
		expr_print(e->left.expr, fn, data, E_NOT);
		break;
	case E_EQUAL:
		if (e->left.sym->name)
			fn(data, e->left.sym, e->left.sym->name);
		else
			fn(data, NULL, "<choice>");
		fn(data, NULL, "=");
		fn(data, e->right.sym, e->right.sym->name);
		break;
	case E_UNEQUAL:
		if (e->left.sym->name)
			fn(data, e->left.sym, e->left.sym->name);
		else
			fn(data, NULL, "<choice>");
		fn(data, NULL, "!=");
		fn(data, e->right.sym, e->right.sym->name);
		break;
@@ -1053,11 +1059,11 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
		fn(data, NULL, " && ");
		expr_print(e->right.expr, fn, data, E_AND);
		break;
	case E_CHOICE:
	case E_LIST:
		fn(data, e->right.sym, e->right.sym->name);
		if (e->left.expr) {
			fn(data, NULL, " ^ ");
			expr_print(e->left.expr, fn, data, E_CHOICE);
			expr_print(e->left.expr, fn, data, E_LIST);
		}
		break;
	case E_RANGE:
Loading