mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-18 20:37:56 +00:00
kconfig: update from linux-next
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
This commit is contained in:
parent
db796067af
commit
084a8e18f5
251
kconfig/conf.c
251
kconfig/conf.c
@ -10,7 +10,9 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define LKC_DIRECT_LINK
|
||||
#include "lkc.h"
|
||||
@ -18,16 +20,21 @@
|
||||
static void conf(struct menu *menu);
|
||||
static void check_conf(struct menu *menu);
|
||||
|
||||
enum {
|
||||
ask_all,
|
||||
ask_new,
|
||||
ask_silent,
|
||||
set_default,
|
||||
set_yes,
|
||||
set_mod,
|
||||
set_no,
|
||||
set_random
|
||||
} input_mode = ask_all;
|
||||
enum input_mode {
|
||||
oldaskconfig,
|
||||
silentoldconfig,
|
||||
oldconfig,
|
||||
allnoconfig,
|
||||
allyesconfig,
|
||||
allmodconfig,
|
||||
alldefconfig,
|
||||
randconfig,
|
||||
defconfig,
|
||||
savedefconfig,
|
||||
listnewconfig,
|
||||
oldnoconfig,
|
||||
} input_mode = oldaskconfig;
|
||||
|
||||
char *defconfig_file;
|
||||
|
||||
static int indent = 1;
|
||||
@ -37,14 +44,14 @@ static int conf_cnt;
|
||||
static char line[128];
|
||||
static struct menu *rootEntry;
|
||||
|
||||
static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
|
||||
|
||||
static const char *get_help(struct menu *menu)
|
||||
static void print_help(struct menu *menu)
|
||||
{
|
||||
if (menu_has_help(menu))
|
||||
return _(menu_get_help(menu));
|
||||
else
|
||||
return nohelp_text;
|
||||
struct gstr help = str_new();
|
||||
|
||||
menu_get_ext_help(menu, &help);
|
||||
|
||||
printf("\n%s\n", str_get(&help));
|
||||
str_free(&help);
|
||||
}
|
||||
|
||||
static void strip(char *str)
|
||||
@ -92,16 +99,16 @@ static int conf_askvalue(struct symbol *sym, const char *def)
|
||||
}
|
||||
|
||||
switch (input_mode) {
|
||||
case ask_new:
|
||||
case ask_silent:
|
||||
case oldconfig:
|
||||
case silentoldconfig:
|
||||
if (sym_has_value(sym)) {
|
||||
printf("%s\n", def);
|
||||
return 0;
|
||||
}
|
||||
check_stdin();
|
||||
case ask_all:
|
||||
case oldaskconfig:
|
||||
fflush(stdout);
|
||||
fgets(line, 128, stdin);
|
||||
xfgets(line, 128, stdin);
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
@ -120,7 +127,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int conf_string(struct menu *menu)
|
||||
static int conf_string(struct menu *menu)
|
||||
{
|
||||
struct symbol *sym = menu->sym;
|
||||
const char *def;
|
||||
@ -139,7 +146,7 @@ int conf_string(struct menu *menu)
|
||||
case '?':
|
||||
/* print help */
|
||||
if (line[1] == '\n') {
|
||||
printf("\n%s\n", get_help(menu));
|
||||
print_help(menu);
|
||||
def = NULL;
|
||||
break;
|
||||
}
|
||||
@ -155,14 +162,12 @@ int conf_string(struct menu *menu)
|
||||
static int conf_sym(struct menu *menu)
|
||||
{
|
||||
struct symbol *sym = menu->sym;
|
||||
int type;
|
||||
tristate oldval, newval;
|
||||
|
||||
while (1) {
|
||||
printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
|
||||
if (sym->name)
|
||||
printf("(%s) ", sym->name);
|
||||
type = sym_get_type(sym);
|
||||
putchar('[');
|
||||
oldval = sym_get_tristate_value(sym);
|
||||
switch (oldval) {
|
||||
@ -219,7 +224,7 @@ static int conf_sym(struct menu *menu)
|
||||
if (sym_set_tristate_value(sym, newval))
|
||||
return 0;
|
||||
help:
|
||||
printf("\n%s\n", get_help(menu));
|
||||
print_help(menu);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,11 +232,9 @@ static int conf_choice(struct menu *menu)
|
||||
{
|
||||
struct symbol *sym, *def_sym;
|
||||
struct menu *child;
|
||||
int type;
|
||||
bool is_new;
|
||||
|
||||
sym = menu->sym;
|
||||
type = sym_get_type(sym);
|
||||
is_new = !sym_has_value(sym);
|
||||
if (sym_is_changable(sym)) {
|
||||
conf_sym(menu);
|
||||
@ -293,20 +296,20 @@ static int conf_choice(struct menu *menu)
|
||||
printf("?");
|
||||
printf("]: ");
|
||||
switch (input_mode) {
|
||||
case ask_new:
|
||||
case ask_silent:
|
||||
case oldconfig:
|
||||
case silentoldconfig:
|
||||
if (!is_new) {
|
||||
cnt = def;
|
||||
printf("%d\n", cnt);
|
||||
break;
|
||||
}
|
||||
check_stdin();
|
||||
case ask_all:
|
||||
case oldaskconfig:
|
||||
fflush(stdout);
|
||||
fgets(line, 128, stdin);
|
||||
xfgets(line, 128, stdin);
|
||||
strip(line);
|
||||
if (line[0] == '?') {
|
||||
printf("\n%s\n", get_help(menu));
|
||||
print_help(menu);
|
||||
continue;
|
||||
}
|
||||
if (!line[0])
|
||||
@ -329,8 +332,8 @@ static int conf_choice(struct menu *menu)
|
||||
}
|
||||
if (!child)
|
||||
continue;
|
||||
if (line[strlen(line) - 1] == '?') {
|
||||
printf("\n%s\n", get_help(child));
|
||||
if (line[0] && line[strlen(line) - 1] == '?') {
|
||||
print_help(child);
|
||||
continue;
|
||||
}
|
||||
sym_set_choice_value(sym, child->sym);
|
||||
@ -359,7 +362,10 @@ static void conf(struct menu *menu)
|
||||
|
||||
switch (prop->type) {
|
||||
case P_MENU:
|
||||
if (input_mode == ask_silent && rootEntry != menu) {
|
||||
if ((input_mode == silentoldconfig ||
|
||||
input_mode == listnewconfig ||
|
||||
input_mode == oldnoconfig) &&
|
||||
rootEntry != menu) {
|
||||
check_conf(menu);
|
||||
return;
|
||||
}
|
||||
@ -417,10 +423,16 @@ static void check_conf(struct menu *menu)
|
||||
if (sym && !sym_has_value(sym)) {
|
||||
if (sym_is_changable(sym) ||
|
||||
(sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
|
||||
if (!conf_cnt++)
|
||||
printf(_("*\n* Restart config...\n*\n"));
|
||||
rootEntry = menu_get_parent_menu(menu);
|
||||
conf(rootEntry);
|
||||
if (input_mode == listnewconfig) {
|
||||
if (sym->name && !sym_is_choice_value(sym)) {
|
||||
printf("%s%s\n", CONFIG_, sym->name);
|
||||
}
|
||||
} else if (input_mode != oldnoconfig) {
|
||||
if (!conf_cnt++)
|
||||
printf(_("*\n* Restart config...\n*\n"));
|
||||
rootEntry = menu_get_parent_menu(menu);
|
||||
conf(rootEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -428,6 +440,22 @@ static void check_conf(struct menu *menu)
|
||||
check_conf(child);
|
||||
}
|
||||
|
||||
static struct option long_opts[] = {
|
||||
{"oldaskconfig", no_argument, NULL, oldaskconfig},
|
||||
{"oldconfig", no_argument, NULL, oldconfig},
|
||||
{"silentoldconfig", no_argument, NULL, silentoldconfig},
|
||||
{"defconfig", optional_argument, NULL, defconfig},
|
||||
{"savedefconfig", required_argument, NULL, savedefconfig},
|
||||
{"allnoconfig", no_argument, NULL, allnoconfig},
|
||||
{"allyesconfig", no_argument, NULL, allyesconfig},
|
||||
{"allmodconfig", no_argument, NULL, allmodconfig},
|
||||
{"alldefconfig", no_argument, NULL, alldefconfig},
|
||||
{"randconfig", no_argument, NULL, randconfig},
|
||||
{"listnewconfig", no_argument, NULL, listnewconfig},
|
||||
{"oldnoconfig", no_argument, NULL, oldnoconfig},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
int opt;
|
||||
@ -438,42 +466,35 @@ int main(int ac, char **av)
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
|
||||
while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
|
||||
while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) {
|
||||
input_mode = (enum input_mode)opt;
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
input_mode = ask_silent;
|
||||
break;
|
||||
case 's':
|
||||
input_mode = ask_silent;
|
||||
case silentoldconfig:
|
||||
sync_kconfig = 1;
|
||||
break;
|
||||
case 'd':
|
||||
input_mode = set_default;
|
||||
break;
|
||||
case 'D':
|
||||
input_mode = set_default;
|
||||
case defconfig:
|
||||
case savedefconfig:
|
||||
defconfig_file = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
input_mode = set_no;
|
||||
case randconfig:
|
||||
{
|
||||
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);
|
||||
break;
|
||||
case 'm':
|
||||
input_mode = set_mod;
|
||||
break;
|
||||
case 'y':
|
||||
input_mode = set_yes;
|
||||
break;
|
||||
case 'r':
|
||||
input_mode = set_random;
|
||||
srand(time(NULL));
|
||||
break;
|
||||
case 'h':
|
||||
printf(_("See README for usage info\n"));
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
case '?':
|
||||
fprintf(stderr, _("See README for usage info\n"));
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ac == optind) {
|
||||
@ -484,16 +505,20 @@ int main(int ac, char **av)
|
||||
conf_parse(name);
|
||||
//zconfdump(stdout);
|
||||
if (sync_kconfig) {
|
||||
if (stat(".config", &tmpstat)) {
|
||||
name = conf_get_configname();
|
||||
if (stat(name, &tmpstat)) {
|
||||
fprintf(stderr, _("***\n"
|
||||
"*** Please run some configurator (e.g. \"make menuconfig\").\n"
|
||||
"***\n"));
|
||||
"*** Configuration file \"%s\" not found!\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:
|
||||
case defconfig:
|
||||
if (!defconfig_file)
|
||||
defconfig_file = conf_get_default_confname();
|
||||
if (conf_read(defconfig_file)) {
|
||||
@ -503,25 +528,30 @@ int main(int ac, char **av)
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case ask_silent:
|
||||
case ask_all:
|
||||
case ask_new:
|
||||
case savedefconfig:
|
||||
case silentoldconfig:
|
||||
case oldaskconfig:
|
||||
case oldconfig:
|
||||
case listnewconfig:
|
||||
case oldnoconfig:
|
||||
conf_read(NULL);
|
||||
break;
|
||||
case set_no:
|
||||
case set_mod:
|
||||
case set_yes:
|
||||
case set_random:
|
||||
case allnoconfig:
|
||||
case allyesconfig:
|
||||
case allmodconfig:
|
||||
case alldefconfig:
|
||||
case randconfig:
|
||||
name = getenv("KCONFIG_ALLCONFIG");
|
||||
if (name && !stat(name, &tmpstat)) {
|
||||
conf_read_simple(name, S_DEF_USER);
|
||||
break;
|
||||
}
|
||||
switch (input_mode) {
|
||||
case set_no: name = "allno.config"; break;
|
||||
case set_mod: name = "allmod.config"; break;
|
||||
case set_yes: name = "allyes.config"; break;
|
||||
case set_random: name = "allrandom.config"; break;
|
||||
case allnoconfig: name = "allno.config"; break;
|
||||
case allyesconfig: name = "allyes.config"; break;
|
||||
case allmodconfig: name = "allmod.config"; break;
|
||||
case alldefconfig: name = "alldef.config"; break;
|
||||
case randconfig: name = "allrandom.config"; break;
|
||||
default: break;
|
||||
}
|
||||
if (!stat(name, &tmpstat))
|
||||
@ -538,7 +568,7 @@ int main(int ac, char **av)
|
||||
name = getenv("KCONFIG_NOSILENTUPDATE");
|
||||
if (name && *name) {
|
||||
fprintf(stderr,
|
||||
_("\n*** Configuration requires explicit update.\n\n"));
|
||||
_("\n*** The configuration requires explicit update.\n\n"));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -546,33 +576,42 @@ int main(int ac, char **av)
|
||||
}
|
||||
|
||||
switch (input_mode) {
|
||||
case set_no:
|
||||
case allnoconfig:
|
||||
conf_set_all_new_symbols(def_no);
|
||||
break;
|
||||
case set_yes:
|
||||
case allyesconfig:
|
||||
conf_set_all_new_symbols(def_yes);
|
||||
break;
|
||||
case set_mod:
|
||||
case allmodconfig:
|
||||
conf_set_all_new_symbols(def_mod);
|
||||
break;
|
||||
case set_random:
|
||||
conf_set_all_new_symbols(def_random);
|
||||
break;
|
||||
case set_default:
|
||||
case alldefconfig:
|
||||
conf_set_all_new_symbols(def_default);
|
||||
break;
|
||||
case ask_new:
|
||||
case ask_all:
|
||||
case randconfig:
|
||||
conf_set_all_new_symbols(def_random);
|
||||
break;
|
||||
case defconfig:
|
||||
conf_set_all_new_symbols(def_default);
|
||||
break;
|
||||
case savedefconfig:
|
||||
break;
|
||||
case oldaskconfig:
|
||||
rootEntry = &rootmenu;
|
||||
conf(&rootmenu);
|
||||
input_mode = ask_silent;
|
||||
input_mode = silentoldconfig;
|
||||
/* fall through */
|
||||
case ask_silent:
|
||||
case oldconfig:
|
||||
case listnewconfig:
|
||||
case oldnoconfig:
|
||||
case silentoldconfig:
|
||||
/* Update until a loop caused no more changes */
|
||||
do {
|
||||
conf_cnt = 0;
|
||||
check_conf(&rootmenu);
|
||||
} while (conf_cnt);
|
||||
} while (conf_cnt &&
|
||||
(input_mode != listnewconfig &&
|
||||
input_mode != oldnoconfig));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -584,7 +623,14 @@ int main(int ac, char **av)
|
||||
fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
/* In crosstool-NG, we do not use the autoconf stuff */
|
||||
} else if (input_mode == savedefconfig) {
|
||||
if (conf_write_defconfig(defconfig_file)) {
|
||||
fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
|
||||
defconfig_file);
|
||||
return 1;
|
||||
}
|
||||
} else if (input_mode != listnewconfig) {
|
||||
if (conf_write(NULL)) {
|
||||
fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
|
||||
exit(1);
|
||||
@ -592,3 +638,14 @@ int main(int ac, char **av)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Helper function to facilitate fgets() by Jean Sacren.
|
||||
*/
|
||||
void xfgets(str, size, in)
|
||||
char *str;
|
||||
int size;
|
||||
FILE *in;
|
||||
{
|
||||
if (fgets(str, size, in) == NULL)
|
||||
fprintf(stderr, "\nError in reading or end of file.\n");
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -18,6 +19,9 @@
|
||||
static void conf_warning(const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
static void conf_message(const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
static const char *conf_filename;
|
||||
static int conf_lineno, conf_warnings, conf_unsaved;
|
||||
|
||||
@ -34,6 +38,29 @@ static void conf_warning(const char *fmt, ...)
|
||||
conf_warnings++;
|
||||
}
|
||||
|
||||
static void conf_default_message_callback(const char *fmt, va_list ap)
|
||||
{
|
||||
printf("#\n# ");
|
||||
vprintf(fmt, ap);
|
||||
printf("\n#\n");
|
||||
}
|
||||
|
||||
static void (*conf_message_callback) (const char *fmt, va_list ap) =
|
||||
conf_default_message_callback;
|
||||
void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))
|
||||
{
|
||||
conf_message_callback = fn;
|
||||
}
|
||||
|
||||
static void conf_message(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (conf_message_callback)
|
||||
conf_message_callback(fmt, ap);
|
||||
}
|
||||
|
||||
const char *conf_get_configname(void)
|
||||
{
|
||||
char *name = getenv("KCONFIG_CONFIG");
|
||||
@ -41,6 +68,13 @@ const char *conf_get_configname(void)
|
||||
return name ? name : ".config";
|
||||
}
|
||||
|
||||
const char *conf_get_autoconfig_name(void)
|
||||
{
|
||||
char *name = getenv("KCONFIG_AUTOCONFIG");
|
||||
|
||||
return name ? name : "include/config/auto.conf";
|
||||
}
|
||||
|
||||
static char *conf_expand_value(const char *in)
|
||||
{
|
||||
struct symbol *sym;
|
||||
@ -163,8 +197,11 @@ int conf_read_simple(const char *name, int def)
|
||||
if (in)
|
||||
goto load;
|
||||
sym_add_change_count(1);
|
||||
if (!sym_defconfig_list)
|
||||
if (!sym_defconfig_list) {
|
||||
if (modules_sym)
|
||||
sym_calc_value(modules_sym);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for_all_defaults(sym_defconfig_list, prop) {
|
||||
if (expr_calc_value(prop->visible.expr) == no ||
|
||||
@ -173,9 +210,8 @@ int conf_read_simple(const char *name, int def)
|
||||
name = conf_expand_value(prop->expr->left.sym->name);
|
||||
in = zconf_fopen(name);
|
||||
if (in) {
|
||||
printf(_("#\n"
|
||||
"# using defaults found in %s\n"
|
||||
"#\n"), name);
|
||||
conf_message(_("using defaults found in %s"),
|
||||
name);
|
||||
goto load;
|
||||
}
|
||||
}
|
||||
@ -210,24 +246,23 @@ load:
|
||||
while (fgets(line, sizeof(line), in)) {
|
||||
conf_lineno++;
|
||||
sym = NULL;
|
||||
switch (line[0]) {
|
||||
case '#':
|
||||
if (memcmp(line + 2, "CT_", 3))
|
||||
if (line[0] == '#') {
|
||||
if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
|
||||
continue;
|
||||
p = strchr(line + 5, ' ');
|
||||
p = strchr(line + 2 + strlen(CONFIG_), ' ');
|
||||
if (!p)
|
||||
continue;
|
||||
*p++ = 0;
|
||||
if (strncmp(p, "is not set", 10))
|
||||
continue;
|
||||
if (def == S_DEF_USER) {
|
||||
sym = sym_find(line + 5);
|
||||
sym = sym_find(line + 2 + strlen(CONFIG_));
|
||||
if (!sym) {
|
||||
sym_add_change_count(1);
|
||||
break;
|
||||
goto setsym;
|
||||
}
|
||||
} else {
|
||||
sym = sym_lookup(line + 5, 0);
|
||||
sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
|
||||
if (sym->type == S_UNKNOWN)
|
||||
sym->type = S_BOOLEAN;
|
||||
}
|
||||
@ -243,13 +278,8 @@ load:
|
||||
default:
|
||||
;
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
if (memcmp(line, "CT_", 3)) {
|
||||
conf_warning("unexpected data");
|
||||
continue;
|
||||
}
|
||||
p = strchr(line + 3, '=');
|
||||
} else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
|
||||
p = strchr(line + strlen(CONFIG_), '=');
|
||||
if (!p)
|
||||
continue;
|
||||
*p++ = 0;
|
||||
@ -260,13 +290,13 @@ load:
|
||||
*p2 = 0;
|
||||
}
|
||||
if (def == S_DEF_USER) {
|
||||
sym = sym_find(line + 3);
|
||||
sym = sym_find(line + strlen(CONFIG_));
|
||||
if (!sym) {
|
||||
sym_add_change_count(1);
|
||||
break;
|
||||
goto setsym;
|
||||
}
|
||||
} else {
|
||||
sym = sym_lookup(line + 3, 0);
|
||||
sym = sym_lookup(line + strlen(CONFIG_), 0);
|
||||
if (sym->type == S_UNKNOWN)
|
||||
sym->type = S_OTHER;
|
||||
}
|
||||
@ -275,14 +305,12 @@ load:
|
||||
}
|
||||
if (conf_set_sym_val(sym, def, def_flags, p))
|
||||
continue;
|
||||
break;
|
||||
case '\r':
|
||||
case '\n':
|
||||
break;
|
||||
default:
|
||||
conf_warning("unexpected data");
|
||||
} else {
|
||||
if (line[0] != '\r' && line[0] != '\n')
|
||||
conf_warning("unexpected data");
|
||||
continue;
|
||||
}
|
||||
setsym:
|
||||
if (sym && sym_is_choice_value(sym)) {
|
||||
struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
|
||||
switch (sym->def[def].tri) {
|
||||
@ -389,15 +417,149 @@ int conf_read(const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write a S_STRING */
|
||||
static void conf_write_string(bool headerfile, const char *name,
|
||||
const char *str, FILE *out)
|
||||
{
|
||||
int l;
|
||||
if (headerfile)
|
||||
fprintf(out, "#define %s%s \"", CONFIG_, name);
|
||||
else
|
||||
fprintf(out, "%s%s=\"", CONFIG_, name);
|
||||
|
||||
while (1) {
|
||||
l = strcspn(str, "\"\\");
|
||||
if (l) {
|
||||
xfwrite(str, l, 1, out);
|
||||
str += l;
|
||||
}
|
||||
if (!*str)
|
||||
break;
|
||||
fprintf(out, "\\%c", *str++);
|
||||
}
|
||||
fputs("\"\n", out);
|
||||
}
|
||||
|
||||
static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
switch (sym->type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
switch (sym_get_tristate_value(sym)) {
|
||||
case no:
|
||||
if (write_no)
|
||||
fprintf(out, "# %s%s is not set\n",
|
||||
CONFIG_, sym->name);
|
||||
break;
|
||||
case mod:
|
||||
fprintf(out, "%s%s=m\n", CONFIG_, sym->name);
|
||||
break;
|
||||
case yes:
|
||||
fprintf(out, "%s%s=y\n", CONFIG_, sym->name);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case S_STRING:
|
||||
conf_write_string(false, sym->name, sym_get_string_value(sym), out);
|
||||
break;
|
||||
case S_HEX:
|
||||
case S_INT:
|
||||
str = sym_get_string_value(sym);
|
||||
fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str);
|
||||
break;
|
||||
case S_OTHER:
|
||||
case S_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out a minimal config.
|
||||
* All values that has default values are skipped as this is redundant.
|
||||
*/
|
||||
int conf_write_defconfig(const char *filename)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct menu *menu;
|
||||
FILE *out;
|
||||
|
||||
out = fopen(filename, "w");
|
||||
if (!out)
|
||||
return 1;
|
||||
|
||||
sym_clear_all_valid();
|
||||
|
||||
/* Traverse all menus to find all relevant symbols */
|
||||
menu = rootmenu.list;
|
||||
|
||||
while (menu != NULL)
|
||||
{
|
||||
sym = menu->sym;
|
||||
if (sym == NULL) {
|
||||
if (!menu_is_visible(menu))
|
||||
goto next_menu;
|
||||
} else if (!sym_is_choice(sym)) {
|
||||
sym_calc_value(sym);
|
||||
if (!(sym->flags & SYMBOL_WRITE))
|
||||
goto next_menu;
|
||||
sym->flags &= ~SYMBOL_WRITE;
|
||||
/* If we cannot change the symbol - skip */
|
||||
if (!sym_is_changable(sym))
|
||||
goto next_menu;
|
||||
/* If symbol equals to default value - skip */
|
||||
if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
|
||||
goto next_menu;
|
||||
|
||||
/*
|
||||
* If symbol is a choice value and equals to the
|
||||
* default for a choice - skip.
|
||||
* But only if value is bool and equal to "y" and
|
||||
* choice is not "optional".
|
||||
* (If choice is "optional" then all values can be "n")
|
||||
*/
|
||||
if (sym_is_choice_value(sym)) {
|
||||
struct symbol *cs;
|
||||
struct symbol *ds;
|
||||
|
||||
cs = prop_get_symbol(sym_get_choice_prop(sym));
|
||||
ds = sym_choice_default(cs);
|
||||
if (!sym_is_optional(cs) && sym == ds) {
|
||||
if ((sym->type == S_BOOLEAN) &&
|
||||
sym_get_tristate_value(sym) == yes)
|
||||
goto next_menu;
|
||||
}
|
||||
}
|
||||
conf_write_symbol(sym, out, true);
|
||||
}
|
||||
next_menu:
|
||||
if (menu->list != NULL) {
|
||||
menu = menu->list;
|
||||
}
|
||||
else if (menu->next != NULL) {
|
||||
menu = menu->next;
|
||||
} else {
|
||||
while ((menu = menu->parent)) {
|
||||
if (menu->next != NULL) {
|
||||
menu = menu->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int conf_write(const char *name)
|
||||
{
|
||||
FILE *out;
|
||||
struct symbol *sym;
|
||||
struct menu *menu;
|
||||
const char *basename;
|
||||
char dirname[128], tmpname[128], newname[128];
|
||||
int type, l;
|
||||
const char *str;
|
||||
char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
|
||||
time_t now;
|
||||
int use_timestamp = 1;
|
||||
char *env;
|
||||
@ -436,8 +598,6 @@ int conf_write(const char *name)
|
||||
if (!out)
|
||||
return 1;
|
||||
|
||||
sym = sym_lookup("PROJECTVERSION", 0);
|
||||
sym_calc_value(sym);
|
||||
time(&now);
|
||||
env = getenv("KCONFIG_NOTIMESTAMP");
|
||||
if (env && *env)
|
||||
@ -445,10 +605,10 @@ int conf_write(const char *name)
|
||||
|
||||
fprintf(out, _("#\n"
|
||||
"# Automatically generated make config: don't edit\n"
|
||||
"# " PACKAGE " version: %s\n"
|
||||
"# %s\n"
|
||||
"%s%s"
|
||||
"#\n"),
|
||||
sym_get_string_value(sym),
|
||||
rootmenu.prompt->text,
|
||||
use_timestamp ? "# " : "",
|
||||
use_timestamp ? ctime(&now) : "");
|
||||
|
||||
@ -471,56 +631,11 @@ int conf_write(const char *name)
|
||||
if (!(sym->flags & SYMBOL_WRITE))
|
||||
goto next;
|
||||
sym->flags &= ~SYMBOL_WRITE;
|
||||
type = sym->type;
|
||||
if (type == S_TRISTATE) {
|
||||
sym_calc_value(modules_sym);
|
||||
if (modules_sym->curr.tri == no)
|
||||
type = S_BOOLEAN;
|
||||
}
|
||||
switch (type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
switch (sym_get_tristate_value(sym)) {
|
||||
case no:
|
||||
fprintf(out, "# CT_%s is not set\n", sym->name);
|
||||
break;
|
||||
case mod:
|
||||
fprintf(out, "CT_%s=m\n", sym->name);
|
||||
break;
|
||||
case yes:
|
||||
fprintf(out, "CT_%s=y\n", sym->name);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case S_STRING:
|
||||
str = sym_get_string_value(sym);
|
||||
fprintf(out, "CT_%s=\"", sym->name);
|
||||
while (1) {
|
||||
l = strcspn(str, "\"\\");
|
||||
if (l) {
|
||||
fwrite(str, l, 1, out);
|
||||
str += l;
|
||||
}
|
||||
if (!*str)
|
||||
break;
|
||||
fprintf(out, "\\%c", *str++);
|
||||
}
|
||||
fputs("\"\n", out);
|
||||
break;
|
||||
case S_HEX:
|
||||
str = sym_get_string_value(sym);
|
||||
if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
|
||||
fprintf(out, "CT_%s=%s\n", sym->name, str);
|
||||
break;
|
||||
}
|
||||
case S_INT:
|
||||
str = sym_get_string_value(sym);
|
||||
fprintf(out, "CT_%s=%s\n", sym->name, str);
|
||||
break;
|
||||
}
|
||||
/* Write config symbol to file */
|
||||
conf_write_symbol(sym, out, true);
|
||||
}
|
||||
|
||||
next:
|
||||
next:
|
||||
if (menu->list) {
|
||||
menu = menu->list;
|
||||
continue;
|
||||
@ -544,22 +659,23 @@ int conf_write(const char *name)
|
||||
return 1;
|
||||
}
|
||||
|
||||
conf_message(_("configuration written to %s"), newname);
|
||||
|
||||
sym_set_change_count(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int conf_split_config(void)
|
||||
static int conf_split_config(void)
|
||||
{
|
||||
char *name, path[128];
|
||||
const char *name;
|
||||
char path[PATH_MAX+1];
|
||||
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);
|
||||
|
||||
if (chdir("include/config"))
|
||||
@ -666,10 +782,9 @@ int conf_write_autoconf(void)
|
||||
{
|
||||
struct symbol *sym;
|
||||
const char *str;
|
||||
char *name;
|
||||
FILE *out, *out_h;
|
||||
time_t now;
|
||||
int i, l;
|
||||
const char *name;
|
||||
FILE *out, *tristate, *out_h;
|
||||
int i;
|
||||
|
||||
sym_clear_all_valid();
|
||||
|
||||
@ -682,33 +797,42 @@ int conf_write_autoconf(void)
|
||||
if (!out)
|
||||
return 1;
|
||||
|
||||
out_h = fopen(".tmpconfig.h", "w");
|
||||
if (!out_h) {
|
||||
tristate = fopen(".tmpconfig_tristate", "w");
|
||||
if (!tristate) {
|
||||
fclose(out);
|
||||
return 1;
|
||||
}
|
||||
|
||||
sym = sym_lookup("PROJECTVERSION", 0);
|
||||
sym_calc_value(sym);
|
||||
time(&now);
|
||||
out_h = fopen(".tmpconfig.h", "w");
|
||||
if (!out_h) {
|
||||
fclose(out);
|
||||
fclose(tristate);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(out, "#\n"
|
||||
"# Automatically generated make config: don't edit\n"
|
||||
"# " PACKAGE " version: %s\n"
|
||||
"# %s"
|
||||
"# %s\n"
|
||||
"#\n",
|
||||
sym_get_string_value(sym), ctime(&now));
|
||||
rootmenu.prompt->text);
|
||||
fprintf(tristate, "#\n"
|
||||
"# Automatically generated - do not edit\n"
|
||||
"\n");
|
||||
fprintf(out_h, "/*\n"
|
||||
" * Automatically generated C config: don't edit\n"
|
||||
" * " PACKAGE " version: %s\n"
|
||||
" * %s"
|
||||
" */\n"
|
||||
"#define AUTOCONF_INCLUDED\n",
|
||||
sym_get_string_value(sym), ctime(&now));
|
||||
" * %s\n"
|
||||
" */\n",
|
||||
rootmenu.prompt->text);
|
||||
|
||||
for_all_symbols(i, sym) {
|
||||
sym_calc_value(sym);
|
||||
if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
|
||||
continue;
|
||||
|
||||
/* write symbol to config file */
|
||||
conf_write_symbol(sym, out, false);
|
||||
|
||||
/* update autoconf and tristate files */
|
||||
switch (sym->type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
@ -716,62 +840,54 @@ int conf_write_autoconf(void)
|
||||
case no:
|
||||
break;
|
||||
case mod:
|
||||
fprintf(out, "CT_%s=m\n", sym->name);
|
||||
fprintf(out_h, "#define CT_%s_MODULE 1\n", sym->name);
|
||||
fprintf(tristate, "%s%s=M\n",
|
||||
CONFIG_, sym->name);
|
||||
fprintf(out_h, "#define %s%s_MODULE 1\n",
|
||||
CONFIG_, sym->name);
|
||||
break;
|
||||
case yes:
|
||||
fprintf(out, "CT_%s=y\n", sym->name);
|
||||
fprintf(out_h, "#define CT_%s 1\n", sym->name);
|
||||
if (sym->type == S_TRISTATE)
|
||||
fprintf(tristate,"%s%s=Y\n",
|
||||
CONFIG_, sym->name);
|
||||
fprintf(out_h, "#define %s%s 1\n",
|
||||
CONFIG_, sym->name);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case S_STRING:
|
||||
str = sym_get_string_value(sym);
|
||||
fprintf(out, "CT_%s=\"", sym->name);
|
||||
fprintf(out_h, "#define CT_%s \"", sym->name);
|
||||
while (1) {
|
||||
l = strcspn(str, "\"\\");
|
||||
if (l) {
|
||||
fwrite(str, l, 1, out);
|
||||
fwrite(str, l, 1, out_h);
|
||||
str += l;
|
||||
}
|
||||
if (!*str)
|
||||
break;
|
||||
fprintf(out, "\\%c", *str);
|
||||
fprintf(out_h, "\\%c", *str);
|
||||
str++;
|
||||
}
|
||||
fputs("\"\n", out);
|
||||
fputs("\"\n", out_h);
|
||||
conf_write_string(true, sym->name, sym_get_string_value(sym), out_h);
|
||||
break;
|
||||
case S_HEX:
|
||||
str = sym_get_string_value(sym);
|
||||
if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
|
||||
fprintf(out, "CT_%s=%s\n", sym->name, str);
|
||||
fprintf(out_h, "#define CT_%s 0x%s\n", sym->name, str);
|
||||
fprintf(out_h, "#define %s%s 0x%s\n",
|
||||
CONFIG_, sym->name, str);
|
||||
break;
|
||||
}
|
||||
case S_INT:
|
||||
str = sym_get_string_value(sym);
|
||||
fprintf(out, "CT_%s=%s\n", sym->name, str);
|
||||
fprintf(out_h, "#define CT_%s %s\n", sym->name, str);
|
||||
fprintf(out_h, "#define %s%s %s\n",
|
||||
CONFIG_, sym->name, str);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(out);
|
||||
fclose(tristate);
|
||||
fclose(out_h);
|
||||
|
||||
name = getenv("KCONFIG_AUTOHEADER");
|
||||
if (!name)
|
||||
name = "include/linux/autoconf.h";
|
||||
name = "include/generated/autoconf.h";
|
||||
if (rename(".tmpconfig.h", name))
|
||||
return 1;
|
||||
name = getenv("KCONFIG_AUTOCONFIG");
|
||||
name = getenv("KCONFIG_TRISTATE");
|
||||
if (!name)
|
||||
name = "include/config/auto.conf";
|
||||
name = "include/config/tristate.conf";
|
||||
if (rename(".tmpconfig_tristate", name))
|
||||
return 1;
|
||||
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.
|
||||
@ -809,13 +925,73 @@ void conf_set_changed_callback(void (*fn)(void))
|
||||
conf_changed_callback = fn;
|
||||
}
|
||||
|
||||
static void randomize_choice_values(struct symbol *csym)
|
||||
{
|
||||
struct property *prop;
|
||||
struct symbol *sym;
|
||||
struct expr *e;
|
||||
int cnt, def;
|
||||
|
||||
/*
|
||||
* If choice is mod then we may have more items selected
|
||||
* and if no then no-one.
|
||||
* In both cases stop.
|
||||
*/
|
||||
if (csym->curr.tri != yes)
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void set_all_choice_values(struct symbol *csym)
|
||||
{
|
||||
struct property *prop;
|
||||
struct symbol *sym;
|
||||
struct expr *e;
|
||||
|
||||
prop = sym_get_choice_prop(csym);
|
||||
|
||||
/*
|
||||
* Set all non-assinged choice values to no
|
||||
*/
|
||||
expr_list_for_each_sym(prop->expr, e, sym) {
|
||||
if (!sym_has_value(sym))
|
||||
sym->def[S_DEF_USER].tri = no;
|
||||
}
|
||||
csym->flags |= SYMBOL_DEF_USER;
|
||||
/* clear VALID to get value calculated */
|
||||
csym->flags &= ~(SYMBOL_VALID);
|
||||
}
|
||||
|
||||
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;
|
||||
int i, cnt;
|
||||
|
||||
for_all_symbols(i, sym) {
|
||||
if (sym_has_value(sym))
|
||||
@ -834,12 +1010,13 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
|
||||
sym->def[S_DEF_USER].tri = no;
|
||||
break;
|
||||
case def_random:
|
||||
sym->def[S_DEF_USER].tri = (tristate)(rand() % 3);
|
||||
cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
|
||||
sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
if (!sym_is_choice(sym) || mode != def_random)
|
||||
if (!(sym_is_choice(sym) && mode == def_random))
|
||||
sym->flags |= SYMBOL_DEF_USER;
|
||||
break;
|
||||
default:
|
||||
@ -850,30 +1027,23 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
|
||||
|
||||
sym_clear_all_valid();
|
||||
|
||||
if (mode != def_random)
|
||||
return;
|
||||
|
||||
/*
|
||||
* We have different type of choice blocks.
|
||||
* If curr.tri equals to mod then we can select several
|
||||
* choice symbols in one block.
|
||||
* In this case we do nothing.
|
||||
* If curr.tri equals 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);
|
||||
prop = sym_get_choice_prop(csym);
|
||||
def = -1;
|
||||
while (1) {
|
||||
cnt = 0;
|
||||
expr_list_for_each_sym(prop->expr, e, sym) {
|
||||
if (sym->visible == no)
|
||||
continue;
|
||||
if (def == cnt++) {
|
||||
csym->def[S_DEF_USER].val = sym;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (def >= 0 || cnt < 2)
|
||||
break;
|
||||
def = (rand() % cnt) + 1;
|
||||
}
|
||||
csym->flags |= SYMBOL_DEF_USER;
|
||||
if (mode == def_random)
|
||||
randomize_choice_values(csym);
|
||||
else
|
||||
set_all_choice_values(csym);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ struct expr *expr_alloc_or(struct expr *e1, struct expr *e2)
|
||||
return e2 ? expr_alloc_two(E_OR, e1, e2) : e1;
|
||||
}
|
||||
|
||||
struct expr *expr_copy(struct expr *org)
|
||||
struct expr *expr_copy(const struct expr *org)
|
||||
{
|
||||
struct expr *e;
|
||||
|
||||
@ -348,7 +348,7 @@ struct expr *expr_trans_bool(struct expr *e)
|
||||
/*
|
||||
* e1 || e2 -> ?
|
||||
*/
|
||||
struct expr *expr_join_or(struct expr *e1, struct expr *e2)
|
||||
static struct expr *expr_join_or(struct expr *e1, struct expr *e2)
|
||||
{
|
||||
struct expr *tmp;
|
||||
struct symbol *sym1, *sym2;
|
||||
@ -412,7 +412,7 @@ struct expr *expr_join_or(struct expr *e1, struct expr *e2)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct expr *expr_join_and(struct expr *e1, struct expr *e2)
|
||||
static struct expr *expr_join_and(struct expr *e1, struct expr *e2)
|
||||
{
|
||||
struct expr *tmp;
|
||||
struct symbol *sym1, *sym2;
|
||||
@ -1013,6 +1013,48 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline struct expr *
|
||||
expr_get_leftmost_symbol(const struct expr *e)
|
||||
{
|
||||
|
||||
if (e == NULL)
|
||||
return NULL;
|
||||
|
||||
while (e->type != E_SYMBOL)
|
||||
e = e->left.expr;
|
||||
|
||||
return expr_copy(e);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given expression `e1' and `e2', returns the leaf of the longest
|
||||
* sub-expression of `e1' not containing 'e2.
|
||||
*/
|
||||
struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
|
||||
{
|
||||
struct expr *ret;
|
||||
|
||||
switch (e1->type) {
|
||||
case E_OR:
|
||||
return expr_alloc_and(
|
||||
expr_simplify_unmet_dep(e1->left.expr, e2),
|
||||
expr_simplify_unmet_dep(e1->right.expr, e2));
|
||||
case E_AND: {
|
||||
struct expr *e;
|
||||
e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
|
||||
e = expr_eliminate_dups(e);
|
||||
ret = (!expr_eq(e, e1)) ? e1 : NULL;
|
||||
expr_free(e);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = e1;
|
||||
break;
|
||||
}
|
||||
|
||||
return expr_get_leftmost_symbol(ret);
|
||||
}
|
||||
|
||||
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
|
||||
{
|
||||
if (!e) {
|
||||
@ -1087,7 +1129,7 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
|
||||
|
||||
static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
|
||||
{
|
||||
fwrite(str, strlen(str), 1, data);
|
||||
xfwrite(str, strlen(str), 1, data);
|
||||
}
|
||||
|
||||
void expr_fprint(struct expr *e, FILE *out)
|
||||
@ -1097,7 +1139,32 @@ void expr_fprint(struct expr *e, FILE *out)
|
||||
|
||||
static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
|
||||
{
|
||||
str_append((struct gstr*)data, str);
|
||||
struct gstr *gs = (struct gstr*)data;
|
||||
const char *sym_str = NULL;
|
||||
|
||||
if (sym)
|
||||
sym_str = sym_get_string_value(sym);
|
||||
|
||||
if (gs->max_width) {
|
||||
unsigned extra_length = strlen(str);
|
||||
const char *last_cr = strrchr(gs->s, '\n');
|
||||
unsigned last_line_length;
|
||||
|
||||
if (sym_str)
|
||||
extra_length += 4 + strlen(sym_str);
|
||||
|
||||
if (!last_cr)
|
||||
last_cr = gs->s;
|
||||
|
||||
last_line_length = strlen(gs->s) - (last_cr - gs->s);
|
||||
|
||||
if ((last_line_length + extra_length) > gs->max_width)
|
||||
str_append(gs, "\\\n");
|
||||
}
|
||||
|
||||
str_append(gs, str);
|
||||
if (sym && sym->type != S_UNKNOWN)
|
||||
str_printf(gs, " [=%s]", sym_str);
|
||||
}
|
||||
|
||||
void expr_gstr_print(struct expr *e, struct gstr *gs)
|
||||
|
@ -18,14 +18,10 @@ extern "C" {
|
||||
struct file {
|
||||
struct file *next;
|
||||
struct file *parent;
|
||||
char *name;
|
||||
const char *name;
|
||||
int lineno;
|
||||
int flags;
|
||||
};
|
||||
|
||||
#define FILE_BUSY 0x0001
|
||||
#define FILE_SCANNED 0x0002
|
||||
|
||||
typedef enum tristate {
|
||||
no, mod, yes
|
||||
} tristate;
|
||||
@ -83,10 +79,11 @@ struct symbol {
|
||||
tristate visible;
|
||||
int flags;
|
||||
struct property *prop;
|
||||
struct expr_value dir_dep;
|
||||
struct expr_value rev_dep;
|
||||
};
|
||||
|
||||
#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
|
||||
#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
|
||||
|
||||
#define SYMBOL_CONST 0x0001 /* symbol is const */
|
||||
#define SYMBOL_CHECK 0x0008 /* used during dependency checking */
|
||||
@ -108,8 +105,7 @@ struct symbol {
|
||||
#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */
|
||||
|
||||
#define SYMBOL_MAXLENGTH 256
|
||||
#define SYMBOL_HASHSIZE 257
|
||||
#define SYMBOL_HASHMASK 0xff
|
||||
#define SYMBOL_HASHSIZE 9973
|
||||
|
||||
/* A property represent the config options that can be associated
|
||||
* with a config "symbol".
|
||||
@ -132,6 +128,7 @@ enum prop_type {
|
||||
P_SELECT, /* select BAR */
|
||||
P_RANGE, /* range 7..100 (for a symbol) */
|
||||
P_ENV, /* value from environment variable */
|
||||
P_SYMBOL, /* where a symbol is defined */
|
||||
};
|
||||
|
||||
struct property {
|
||||
@ -163,6 +160,7 @@ struct menu {
|
||||
struct menu *list;
|
||||
struct symbol *sym;
|
||||
struct property *prompt;
|
||||
struct expr *visibility;
|
||||
struct expr *dep;
|
||||
unsigned int flags;
|
||||
char *help;
|
||||
@ -190,7 +188,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e
|
||||
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
|
||||
struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
|
||||
struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
|
||||
struct expr *expr_copy(struct expr *org);
|
||||
struct expr *expr_copy(const struct expr *org);
|
||||
void expr_free(struct expr *e);
|
||||
int expr_eq(struct expr *e1, struct expr *e2);
|
||||
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
|
||||
@ -205,6 +203,7 @@ struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
|
||||
struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
|
||||
void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
|
||||
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
|
||||
struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
|
||||
|
||||
void expr_fprint(struct expr *e, FILE *out);
|
||||
struct gstr; /* forward */
|
||||
|
@ -22,7 +22,7 @@ menuconfig: $(obj)/mconf
|
||||
|
||||
oldconfig: $(obj)/conf .config
|
||||
@$(ECHO) " CONF $(KCONFIG_TOP)"
|
||||
$(SILENT)$< -s $(KCONFIG_TOP)
|
||||
$(SILENT)$< --silent$@ $(KCONFIG_TOP)
|
||||
|
||||
# Always be silent, the stdout an be >.config
|
||||
extractconfig:
|
||||
@ -61,11 +61,11 @@ HOST_CC ?= gcc -funsigned-char
|
||||
HOST_LD ?= gcc
|
||||
|
||||
# Helpers
|
||||
check_gettext = $(CT_LIB_DIR)/kconfig/check-gettext.sh
|
||||
check_gettext = $(CT_LIB_DIR)/kconfig/check.sh
|
||||
check_lxdialog = $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh
|
||||
|
||||
# Build flags
|
||||
CFLAGS =
|
||||
CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE=\"crosstool-NG\"
|
||||
LDFLAGS =
|
||||
|
||||
# Compiler flags to use gettext
|
||||
|
@ -160,7 +160,15 @@ typedef unsigned int flex_uint32_t;
|
||||
|
||||
/* Size of default input buffer. */
|
||||
#ifndef YY_BUF_SIZE
|
||||
#ifdef __ia64__
|
||||
/* On IA-64, the buffer size is 16k, not 8k.
|
||||
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
|
||||
* Ditto for the __ia64__ case accordingly.
|
||||
*/
|
||||
#define YY_BUF_SIZE 32768
|
||||
#else
|
||||
#define YY_BUF_SIZE 16384
|
||||
#endif /* __ia64__ */
|
||||
#endif
|
||||
|
||||
/* The state buf must be large enough to hold one state per character in the main buffer.
|
||||
@ -802,7 +810,7 @@ static int last_ts, first_ts;
|
||||
static void zconf_endhelp(void);
|
||||
static void zconf_endfile(void);
|
||||
|
||||
void new_string(void)
|
||||
static void new_string(void)
|
||||
{
|
||||
text = malloc(START_STRSIZE);
|
||||
text_asize = START_STRSIZE;
|
||||
@ -810,7 +818,7 @@ void new_string(void)
|
||||
*text = 0;
|
||||
}
|
||||
|
||||
void append_string(const char *str, int size)
|
||||
static void append_string(const char *str, int size)
|
||||
{
|
||||
int new_size = text_size + size + 1;
|
||||
if (new_size > text_asize) {
|
||||
@ -824,7 +832,7 @@ void append_string(const char *str, int size)
|
||||
text[text_size] = 0;
|
||||
}
|
||||
|
||||
void alloc_string(const char *str, int size)
|
||||
static void alloc_string(const char *str, int size)
|
||||
{
|
||||
text = malloc(size + 1);
|
||||
memcpy(text, str, size);
|
||||
@ -914,7 +922,12 @@ static int input (void );
|
||||
|
||||
/* Amount of stuff to slurp up with each read. */
|
||||
#ifndef YY_READ_BUF_SIZE
|
||||
#ifdef __ia64__
|
||||
/* On IA-64, the buffer size is 16k, not 8k */
|
||||
#define YY_READ_BUF_SIZE 16384
|
||||
#else
|
||||
#define YY_READ_BUF_SIZE 8192
|
||||
#endif /* __ia64__ */
|
||||
#endif
|
||||
|
||||
/* Copy whatever the last rule matched to the standard output. */
|
||||
@ -922,7 +935,7 @@ static int input (void );
|
||||
/* This used to be an fputs(), but since the string might contain NUL's,
|
||||
* we now use fwrite().
|
||||
*/
|
||||
#define ECHO fwrite( zconftext, zconfleng, 1, zconfout )
|
||||
#define ECHO do { if (fwrite( zconftext, zconfleng, 1, zconfout )) {} } while (0)
|
||||
#endif
|
||||
|
||||
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
|
||||
@ -2060,8 +2073,8 @@ YY_BUFFER_STATE zconf_scan_string (yyconst char * yystr )
|
||||
|
||||
/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will
|
||||
* scan from a @e copy of @a bytes.
|
||||
* @param bytes the byte buffer to scan
|
||||
* @param len the number of bytes in the buffer pointed to by @a bytes.
|
||||
* @param yybytes the byte buffer to scan
|
||||
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
|
||||
*
|
||||
* @return the newly allocated buffer state object.
|
||||
*/
|
||||
@ -2350,37 +2363,45 @@ void zconf_initscan(const char *name)
|
||||
|
||||
current_file = file_lookup(name);
|
||||
current_file->lineno = 1;
|
||||
current_file->flags = FILE_BUSY;
|
||||
}
|
||||
|
||||
void zconf_nextfile(const char *name)
|
||||
{
|
||||
struct file *iter;
|
||||
struct file *file = file_lookup(name);
|
||||
struct buffer *buf = malloc(sizeof(*buf));
|
||||
memset(buf, 0, sizeof(*buf));
|
||||
|
||||
current_buf->state = YY_CURRENT_BUFFER;
|
||||
zconfin = zconf_fopen(name);
|
||||
zconfin = zconf_fopen(file->name);
|
||||
if (!zconfin) {
|
||||
printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
|
||||
printf("%s:%d: can't open file \"%s\"\n",
|
||||
zconf_curname(), zconf_lineno(), file->name);
|
||||
exit(1);
|
||||
}
|
||||
zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE));
|
||||
buf->parent = current_buf;
|
||||
current_buf = buf;
|
||||
|
||||
if (file->flags & FILE_BUSY) {
|
||||
printf("%s:%d: do not source '%s' from itself\n",
|
||||
zconf_curname(), zconf_lineno(), name);
|
||||
exit(1);
|
||||
for (iter = current_file->parent; iter; iter = iter->parent ) {
|
||||
if (!strcmp(current_file->name,iter->name) ) {
|
||||
printf("%s:%d: recursive inclusion detected. "
|
||||
"Inclusion path:\n current file : '%s'\n",
|
||||
zconf_curname(), zconf_lineno(),
|
||||
zconf_curname());
|
||||
iter = current_file->parent;
|
||||
while (iter && \
|
||||
strcmp(iter->name,current_file->name)) {
|
||||
printf(" included from: '%s:%d'\n",
|
||||
iter->name, iter->lineno-1);
|
||||
iter = iter->parent;
|
||||
}
|
||||
if (iter)
|
||||
printf(" included from: '%s:%d'\n",
|
||||
iter->name, iter->lineno+1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (file->flags & FILE_SCANNED) {
|
||||
printf("%s:%d: file '%s' is already sourced from '%s'\n",
|
||||
zconf_curname(), zconf_lineno(), name,
|
||||
file->parent->name);
|
||||
exit(1);
|
||||
}
|
||||
file->flags |= FILE_BUSY;
|
||||
file->lineno = 1;
|
||||
file->parent = current_file;
|
||||
current_file = file;
|
||||
@ -2390,8 +2411,6 @@ static void zconf_endfile(void)
|
||||
{
|
||||
struct buffer *parent;
|
||||
|
||||
current_file->flags |= FILE_SCANNED;
|
||||
current_file->flags &= ~FILE_BUSY;
|
||||
current_file = current_file->parent;
|
||||
|
||||
parent = current_buf->parent;
|
||||
@ -2409,7 +2428,7 @@ int zconf_lineno(void)
|
||||
return current_pos.lineno;
|
||||
}
|
||||
|
||||
char *zconf_curname(void)
|
||||
const char *zconf_curname(void)
|
||||
{
|
||||
return current_pos.file ? current_pos.file->name : "<none>";
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
static inline const char *gettext(const char *txt) { return txt; }
|
||||
static inline void textdomain(const char *domainname) {}
|
||||
static inline void bindtextdomain(const char *name, const char *dir) {}
|
||||
static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; }
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -31,12 +32,18 @@ extern "C" {
|
||||
|
||||
#define SRCTREE "srctree"
|
||||
|
||||
#define PACKAGE "crosstool-NG"
|
||||
#ifndef PACKAGE
|
||||
#define PACKAGE "linux"
|
||||
#endif
|
||||
|
||||
#define LOCALEDIR "/usr/share/locale"
|
||||
|
||||
#define _(text) gettext(text)
|
||||
#define N_(text) (text)
|
||||
|
||||
#ifndef CONFIG_
|
||||
#define CONFIG_ "CONFIG_"
|
||||
#endif
|
||||
|
||||
#define TF_COMMAND 0x0001
|
||||
#define TF_PARAM 0x0002
|
||||
@ -61,35 +68,49 @@ struct kconf_id {
|
||||
enum symbol_type stype;
|
||||
};
|
||||
|
||||
#ifdef YYDEBUG
|
||||
extern int zconfdebug;
|
||||
#endif
|
||||
|
||||
int zconfparse(void);
|
||||
void zconfdump(FILE *out);
|
||||
|
||||
extern int zconfdebug;
|
||||
void zconf_starthelp(void);
|
||||
FILE *zconf_fopen(const char *name);
|
||||
void zconf_initscan(const char *name);
|
||||
void zconf_nextfile(const char *name);
|
||||
int zconf_lineno(void);
|
||||
char *zconf_curname(void);
|
||||
const char *zconf_curname(void);
|
||||
|
||||
/* conf.c */
|
||||
void xfgets(char *str, int size, FILE *in);
|
||||
|
||||
/* confdata.c */
|
||||
const char *conf_get_configname(void);
|
||||
const char *conf_get_autoconfig_name(void);
|
||||
char *conf_get_default_confname(void);
|
||||
void sym_set_change_count(int count);
|
||||
void sym_add_change_count(int count);
|
||||
void conf_set_all_new_symbols(enum conf_def_mode mode);
|
||||
|
||||
/* confdata.c and expr.c */
|
||||
static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
|
||||
{
|
||||
if (fwrite(str, len, count, out) < count)
|
||||
fprintf(stderr, "\nError in writing or end of file.\n");
|
||||
}
|
||||
|
||||
/* kconfig_load.c */
|
||||
void kconfig_load(void);
|
||||
|
||||
/* menu.c */
|
||||
void menu_init(void);
|
||||
void _menu_init(void);
|
||||
void menu_warn(struct menu *menu, const char *fmt, ...);
|
||||
struct menu *menu_add_menu(void);
|
||||
void menu_end_menu(void);
|
||||
void menu_add_entry(struct symbol *sym);
|
||||
void menu_end_entry(void);
|
||||
void menu_add_dep(struct expr *dep);
|
||||
void menu_add_visibility(struct expr *dep);
|
||||
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
|
||||
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
|
||||
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
|
||||
@ -105,6 +126,11 @@ int file_write_dep(const char *name);
|
||||
struct gstr {
|
||||
size_t len;
|
||||
char *s;
|
||||
/*
|
||||
* when max_width is not zero long lines in string s (if any) get
|
||||
* wrapped not to exceed the max_width value
|
||||
*/
|
||||
int max_width;
|
||||
};
|
||||
struct gstr str_new(void);
|
||||
struct gstr str_assign(const char *s);
|
||||
@ -120,6 +146,8 @@ void sym_init(void);
|
||||
void sym_clear_all_valid(void);
|
||||
void sym_set_all_changed(void);
|
||||
void sym_set_changed(struct symbol *sym);
|
||||
struct symbol *sym_choice_default(struct symbol *sym);
|
||||
const char *sym_get_string_default(struct symbol *sym);
|
||||
struct symbol *sym_check_deps(struct symbol *sym);
|
||||
struct property *prop_alloc(enum prop_type type, struct symbol *sym);
|
||||
struct symbol *prop_get_symbol(struct property *prop);
|
||||
|
@ -1,28 +1,36 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
/* confdata.c */
|
||||
P(conf_parse,void,(const char *name));
|
||||
P(conf_read,int,(const char *name));
|
||||
P(conf_read_simple,int,(const char *name, int));
|
||||
P(conf_write_defconfig,int,(const char *name));
|
||||
P(conf_write,int,(const char *name));
|
||||
P(conf_write_autoconf,int,(void));
|
||||
P(conf_get_changed,bool,(void));
|
||||
P(conf_set_changed_callback, void,(void (*fn)(void)));
|
||||
P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
|
||||
|
||||
/* menu.c */
|
||||
P(rootmenu,struct menu,);
|
||||
|
||||
P(menu_is_visible,bool,(struct menu *menu));
|
||||
P(menu_is_visible, bool, (struct menu *menu));
|
||||
P(menu_has_prompt, bool, (struct menu *menu));
|
||||
P(menu_get_prompt,const char *,(struct menu *menu));
|
||||
P(menu_get_root_menu,struct menu *,(struct menu *menu));
|
||||
P(menu_get_parent_menu,struct menu *,(struct menu *menu));
|
||||
P(menu_has_help,bool,(struct menu *menu));
|
||||
P(menu_get_help,const char *,(struct menu *menu));
|
||||
P(get_symbol_str, void, (struct gstr *r, struct symbol *sym));
|
||||
P(get_relations_str, struct gstr, (struct symbol **sym_arr));
|
||||
P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
|
||||
|
||||
/* symbol.c */
|
||||
P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
|
||||
|
||||
P(sym_lookup,struct symbol *,(const char *name, int flags));
|
||||
P(sym_find,struct symbol *,(const char *name));
|
||||
P(sym_expand_string_value,const char *,(const char *in));
|
||||
P(sym_re_search,struct symbol **,(const char *pattern));
|
||||
P(sym_type_name,const char *,(enum symbol_type type));
|
||||
P(sym_calc_value,void,(struct symbol *sym));
|
||||
|
@ -23,6 +23,8 @@ ccflags()
|
||||
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
|
||||
elif [ -f /usr/include/ncurses/curses.h ]; then
|
||||
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
|
||||
elif [ -f /usr/include/ncursesw/curses.h ]; then
|
||||
echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
|
||||
elif [ -f /usr/include/ncurses.h ]; then
|
||||
echo '-DCURSES_LOC="<ncurses.h>"'
|
||||
else
|
||||
|
@ -31,6 +31,10 @@ static int list_width, check_x, item_x;
|
||||
static void print_item(WINDOW * win, int choice, int selected)
|
||||
{
|
||||
int i;
|
||||
char *list_item = malloc(list_width + 1);
|
||||
|
||||
strncpy(list_item, item_str(), list_width - item_x);
|
||||
list_item[list_width - item_x] = '\0';
|
||||
|
||||
/* Clear 'residue' of last item */
|
||||
wattrset(win, dlg.menubox.atr);
|
||||
@ -41,16 +45,18 @@ static void print_item(WINDOW * win, int choice, int selected)
|
||||
wmove(win, choice, check_x);
|
||||
wattrset(win, selected ? dlg.check_selected.atr
|
||||
: dlg.check.atr);
|
||||
wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' ');
|
||||
if (!item_is_tag(':'))
|
||||
wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' ');
|
||||
|
||||
wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr);
|
||||
mvwaddch(win, choice, item_x, item_str()[0]);
|
||||
mvwaddch(win, choice, item_x, list_item[0]);
|
||||
wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
|
||||
waddstr(win, (char *)item_str() + 1);
|
||||
waddstr(win, list_item + 1);
|
||||
if (selected) {
|
||||
wmove(win, choice, check_x + 1);
|
||||
wrefresh(win);
|
||||
}
|
||||
free(list_item);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -174,6 +180,7 @@ do_resize:
|
||||
check_x = 0;
|
||||
item_foreach()
|
||||
check_x = MAX(check_x, strlen(item_str()) + 4);
|
||||
check_x = MIN(check_x, list_width);
|
||||
|
||||
check_x = (list_width - check_x) / 2;
|
||||
item_x = check_x + 4;
|
||||
|
@ -180,7 +180,7 @@ do_resize:
|
||||
case KEY_LEFT:
|
||||
switch (button) {
|
||||
case -1:
|
||||
button = 1; /* Indicates "Cancel" button is selected */
|
||||
button = 1; /* Indicates "Help" button is selected */
|
||||
print_buttons(dialog, height, width, 1);
|
||||
break;
|
||||
case 0:
|
||||
@ -204,7 +204,7 @@ do_resize:
|
||||
print_buttons(dialog, height, width, 0);
|
||||
break;
|
||||
case 0:
|
||||
button = 1; /* Indicates "Cancel" button is selected */
|
||||
button = 1; /* Indicates "Help" button is selected */
|
||||
print_buttons(dialog, height, width, 1);
|
||||
break;
|
||||
case 1:
|
||||
|
@ -383,6 +383,10 @@ do_resize:
|
||||
case 'n':
|
||||
case 'm':
|
||||
case '/':
|
||||
case 'h':
|
||||
case '?':
|
||||
case 'z':
|
||||
case '\n':
|
||||
/* save scroll info */
|
||||
*s_scroll = scroll;
|
||||
delwin(menu);
|
||||
@ -390,8 +394,10 @@ do_resize:
|
||||
item_set(scroll + choice);
|
||||
item_set_selected(1);
|
||||
switch (key) {
|
||||
case 'h':
|
||||
case '?':
|
||||
return 2;
|
||||
case 's':
|
||||
return 3;
|
||||
case 'y':
|
||||
return 3;
|
||||
case 'n':
|
||||
@ -402,18 +408,12 @@ do_resize:
|
||||
return 6;
|
||||
case '/':
|
||||
return 7;
|
||||
case 'z':
|
||||
return 8;
|
||||
case '\n':
|
||||
return button;
|
||||
}
|
||||
return 0;
|
||||
case 'h':
|
||||
case '?':
|
||||
button = 2;
|
||||
case '\n':
|
||||
*s_scroll = scroll;
|
||||
delwin(menu);
|
||||
delwin(dialog);
|
||||
item_set(scroll + choice);
|
||||
item_set_selected(1);
|
||||
return button;
|
||||
case 'e':
|
||||
case 'x':
|
||||
key = KEY_ESC;
|
||||
|
@ -19,6 +19,8 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "dialog.h"
|
||||
|
||||
struct dialog_info dlg;
|
||||
|
190
kconfig/mconf.c
190
kconfig/mconf.c
@ -25,11 +25,9 @@
|
||||
static const char mconf_readme[] = N_(
|
||||
"Overview\n"
|
||||
"--------\n"
|
||||
"Some kernel features may be built directly into the kernel.\n"
|
||||
"Some may be made into loadable runtime modules. Some features\n"
|
||||
"may be completely removed altogether. There are also certain\n"
|
||||
"kernel parameters which are not really features, but must be\n"
|
||||
"entered in as decimal or hexadecimal numbers or possibly text.\n"
|
||||
"This interface let you select features and parameters for the build.\n"
|
||||
"Features can either be built-in, modularized, or ignored. Parameters\n"
|
||||
"must be entered in as decimal or hexadecimal numbers or text.\n"
|
||||
"\n"
|
||||
"Menu items beginning with following braces represent features that\n"
|
||||
" [ ] can be built in or removed\n"
|
||||
@ -67,13 +65,15 @@ static const char mconf_readme[] = N_(
|
||||
" there is a delayed response which you may find annoying.\n"
|
||||
"\n"
|
||||
" Also, the <TAB> and cursor keys will cycle between <Select>,\n"
|
||||
" <Exit> and <Help>\n"
|
||||
" <Exit> and <Help>.\n"
|
||||
"\n"
|
||||
"o To get help with an item, use the cursor keys to highlight <Help>\n"
|
||||
" and Press <ENTER>.\n"
|
||||
" and press <ENTER>.\n"
|
||||
"\n"
|
||||
" Shortcut: Press <H> or <?>.\n"
|
||||
"\n"
|
||||
"o To toggle the display of hidden options, press <Z>.\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Radiolists (Choice lists)\n"
|
||||
"-----------\n"
|
||||
@ -115,7 +115,7 @@ static const char mconf_readme[] = N_(
|
||||
"-----------------------------\n"
|
||||
"Menuconfig supports the use of alternate configuration files for\n"
|
||||
"those who, for various reasons, find it necessary to switch\n"
|
||||
"between different kernel configurations.\n"
|
||||
"between different configurations.\n"
|
||||
"\n"
|
||||
"At the end of the main menu you will find two options. One is\n"
|
||||
"for saving the current configuration to a file of your choosing.\n"
|
||||
@ -148,9 +148,9 @@ static const char mconf_readme[] = N_(
|
||||
"\n"
|
||||
"Optional personality available\n"
|
||||
"------------------------------\n"
|
||||
"If you prefer to have all of the kernel options listed in a single\n"
|
||||
"menu, rather than the default multimenu hierarchy, run the menuconfig\n"
|
||||
"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
|
||||
"If you prefer to have all of the options listed in a single menu, rather\n"
|
||||
"than the default multimenu hierarchy, run the menuconfig with\n"
|
||||
"MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
|
||||
"\n"
|
||||
"make MENUCONFIG_MODE=single_menu menuconfig\n"
|
||||
"\n"
|
||||
@ -199,30 +199,28 @@ inputbox_instructions_string[] = N_(
|
||||
setmod_text[] = N_(
|
||||
"This feature depends on another which has been configured as a module.\n"
|
||||
"As a result, this feature will be built as a module."),
|
||||
nohelp_text[] = N_(
|
||||
"There is no help available for this kernel option.\n"),
|
||||
load_config_text[] = N_(
|
||||
"Enter the name of the configuration file you wish to load. "
|
||||
"Accept the name shown to restore the configuration you "
|
||||
"last retrieved. Leave blank to abort."),
|
||||
load_config_help[] = N_(
|
||||
"\n"
|
||||
"For various reasons, one may wish to keep several different kernel\n"
|
||||
"For various reasons, one may wish to keep several different\n"
|
||||
"configurations available on a single machine.\n"
|
||||
"\n"
|
||||
"If you have saved a previous configuration in a file other than the\n"
|
||||
"kernel's default, entering the name of the file here will allow you\n"
|
||||
"to modify that configuration.\n"
|
||||
"default one, entering its name here will allow you to modify that\n"
|
||||
"configuration.\n"
|
||||
"\n"
|
||||
"If you are uncertain, then you have probably never used alternate\n"
|
||||
"configuration files. You should therefor leave this blank to abort.\n"),
|
||||
"configuration files. You should therefore leave this blank to abort.\n"),
|
||||
save_config_text[] = N_(
|
||||
"Enter a filename to which this configuration should be saved "
|
||||
"as an alternate. Leave blank to abort."),
|
||||
save_config_help[] = N_(
|
||||
"\n"
|
||||
"For various reasons, one may wish to keep different kernel\n"
|
||||
"configurations available on a single machine.\n"
|
||||
"For various reasons, one may wish to keep different configurations\n"
|
||||
"available on a single machine.\n"
|
||||
"\n"
|
||||
"Entering a file name here will allow you to later retrieve, modify\n"
|
||||
"and use the current configuration as an alternate to whatever\n"
|
||||
@ -232,7 +230,7 @@ save_config_help[] = N_(
|
||||
"leave this blank.\n"),
|
||||
search_help[] = N_(
|
||||
"\n"
|
||||
"Search for CT_ symbols and display their relations.\n"
|
||||
"Search for symbols and display their relations.\n"
|
||||
"Regular expressions are allowed.\n"
|
||||
"Example: search for \"^FOO\"\n"
|
||||
"Result:\n"
|
||||
@ -249,7 +247,7 @@ search_help[] = N_(
|
||||
"Selected by: BAR\n"
|
||||
"-----------------------------------------------------------------\n"
|
||||
"o The line 'Prompt:' shows the text used in the menu structure for\n"
|
||||
" this CT_ symbol\n"
|
||||
" this symbol\n"
|
||||
"o The 'Defined at' line tell at what file / line number the symbol\n"
|
||||
" is defined\n"
|
||||
"o The 'Depends on:' line tell what symbols needs to be defined for\n"
|
||||
@ -265,15 +263,16 @@ search_help[] = N_(
|
||||
"Only relevant lines are shown.\n"
|
||||
"\n\n"
|
||||
"Search examples:\n"
|
||||
"Examples: USB => find all CT_ symbols containing USB\n"
|
||||
" ^USB => find all CT_ symbols starting with USB\n"
|
||||
" USB$ => find all CT_ symbols ending with USB\n"
|
||||
"Examples: USB => find all symbols containing USB\n"
|
||||
" ^USB => find all symbols starting with USB\n"
|
||||
" USB$ => find all symbols ending with USB\n"
|
||||
"\n");
|
||||
|
||||
static int indent;
|
||||
static struct menu *current_menu;
|
||||
static int child_count;
|
||||
static int single_menu_mode;
|
||||
static int show_all_options;
|
||||
|
||||
static void conf(struct menu *menu);
|
||||
static void conf_choice(struct menu *menu);
|
||||
@ -284,91 +283,14 @@ static void show_textbox(const char *title, const char *text, int r, int c);
|
||||
static void show_helptext(const char *title, const char *text);
|
||||
static void show_help(struct menu *menu);
|
||||
|
||||
static void get_prompt_str(struct gstr *r, struct property *prop)
|
||||
{
|
||||
int i, j;
|
||||
struct menu *submenu[8], *menu;
|
||||
|
||||
str_printf(r, _("Prompt: %s\n"), _(prop->text));
|
||||
str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
|
||||
prop->menu->lineno);
|
||||
if (!expr_is_yes(prop->visible.expr)) {
|
||||
str_append(r, _(" Depends on: "));
|
||||
expr_gstr_print(prop->visible.expr, r);
|
||||
str_append(r, "\n");
|
||||
}
|
||||
menu = prop->menu->parent;
|
||||
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
|
||||
submenu[i++] = menu;
|
||||
if (i > 0) {
|
||||
str_printf(r, _(" Location:\n"));
|
||||
for (j = 4; --i >= 0; j += 2) {
|
||||
menu = submenu[i];
|
||||
str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
|
||||
if (menu->sym) {
|
||||
str_printf(r, " (%s [=%s])", menu->sym->name ?
|
||||
menu->sym->name : _("<choice>"),
|
||||
sym_get_string_value(menu->sym));
|
||||
}
|
||||
str_append(r, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void get_symbol_str(struct gstr *r, struct symbol *sym)
|
||||
{
|
||||
bool hit;
|
||||
struct property *prop;
|
||||
|
||||
if (sym && sym->name)
|
||||
str_printf(r, "Symbol: %s [=%s]\n", sym->name,
|
||||
sym_get_string_value(sym));
|
||||
for_all_prompts(sym, prop)
|
||||
get_prompt_str(r, prop);
|
||||
hit = false;
|
||||
for_all_properties(sym, prop, P_SELECT) {
|
||||
if (!hit) {
|
||||
str_append(r, " Selects: ");
|
||||
hit = true;
|
||||
} else
|
||||
str_printf(r, " && ");
|
||||
expr_gstr_print(prop->expr, r);
|
||||
}
|
||||
if (hit)
|
||||
str_append(r, "\n");
|
||||
if (sym->rev_dep.expr) {
|
||||
str_append(r, _(" Selected by: "));
|
||||
expr_gstr_print(sym->rev_dep.expr, r);
|
||||
str_append(r, "\n");
|
||||
}
|
||||
str_append(r, "\n\n");
|
||||
}
|
||||
|
||||
static struct gstr get_relations_str(struct symbol **sym_arr)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct gstr res = str_new();
|
||||
int i;
|
||||
|
||||
for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
|
||||
get_symbol_str(&res, sym);
|
||||
if (!i)
|
||||
str_append(&res, _("No matches found.\n"));
|
||||
return res;
|
||||
}
|
||||
|
||||
static char filename[PATH_MAX+1];
|
||||
static void set_config_filename(const char *config_filename)
|
||||
{
|
||||
static char menu_backtitle[PATH_MAX+128];
|
||||
int size;
|
||||
struct symbol *sym;
|
||||
|
||||
sym = sym_lookup("PROJECTVERSION", 0);
|
||||
sym_calc_value(sym);
|
||||
size = snprintf(menu_backtitle, sizeof(menu_backtitle),
|
||||
_(PACKAGE " v%s Configuration - %s"),
|
||||
sym_get_string_value(sym), config_filename);
|
||||
"%s - %s", config_filename, rootmenu.prompt->text);
|
||||
if (size >= sizeof(menu_backtitle))
|
||||
menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
|
||||
set_dialog_backtitle(menu_backtitle);
|
||||
@ -388,8 +310,8 @@ static void search_conf(void)
|
||||
again:
|
||||
dialog_clear();
|
||||
dres = dialog_inputbox(_("Search Configuration Parameter"),
|
||||
_("Enter CT_ (sub)string to search for "
|
||||
"(with or without \"CT\")"),
|
||||
_("Enter " CONFIG_ " (sub)string to search for "
|
||||
"(with or without \"" CONFIG_ "\")"),
|
||||
10, 75, "");
|
||||
switch (dres) {
|
||||
case 0:
|
||||
@ -401,10 +323,10 @@ again:
|
||||
return;
|
||||
}
|
||||
|
||||
/* strip CT_ if necessary */
|
||||
/* strip the prefix if necessary */
|
||||
dialog_input = dialog_input_result;
|
||||
if (strncasecmp(dialog_input_result, "CT_", 3) == 0)
|
||||
dialog_input += 7;
|
||||
if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
|
||||
dialog_input += strlen(CONFIG_);
|
||||
|
||||
sym_arr = sym_re_search(dialog_input);
|
||||
res = get_relations_str(sym_arr);
|
||||
@ -421,8 +343,16 @@ static void build_conf(struct menu *menu)
|
||||
int type, tmp, doint = 2;
|
||||
tristate val;
|
||||
char ch;
|
||||
bool visible;
|
||||
|
||||
if (!menu_is_visible(menu))
|
||||
/*
|
||||
* note: menu_is_visible() has side effect that it will
|
||||
* recalc the value of the symbol.
|
||||
*/
|
||||
visible = menu_is_visible(menu);
|
||||
if (show_all_options && !menu_has_prompt(menu))
|
||||
return;
|
||||
else if (!show_all_options && !visible)
|
||||
return;
|
||||
|
||||
sym = menu->sym;
|
||||
@ -681,6 +611,9 @@ static void conf(struct menu *menu)
|
||||
case 7:
|
||||
search_conf();
|
||||
break;
|
||||
case 8:
|
||||
show_all_options = !show_all_options;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -699,19 +632,10 @@ static void show_helptext(const char *title, const char *text)
|
||||
static void show_help(struct menu *menu)
|
||||
{
|
||||
struct gstr help = str_new();
|
||||
struct symbol *sym = menu->sym;
|
||||
|
||||
if (menu_has_help(menu))
|
||||
{
|
||||
if (sym->name) {
|
||||
str_printf(&help, "CT_%s:\n\n", sym->name);
|
||||
str_append(&help, _(menu_get_help(menu)));
|
||||
str_append(&help, "\n");
|
||||
}
|
||||
} else {
|
||||
str_append(&help, nohelp_text);
|
||||
}
|
||||
get_symbol_str(&help, sym);
|
||||
help.max_width = getmaxx(stdscr) - 10;
|
||||
menu_get_ext_help(menu, &help);
|
||||
|
||||
show_helptext(_(menu_get_prompt(menu)), str_get(&help));
|
||||
str_free(&help);
|
||||
}
|
||||
@ -732,7 +656,12 @@ static void conf_choice(struct menu *menu)
|
||||
for (child = menu->list; child; child = child->next) {
|
||||
if (!menu_is_visible(child))
|
||||
continue;
|
||||
item_make("%s", _(menu_get_prompt(child)));
|
||||
if (child->sym)
|
||||
item_make("%s", _(menu_get_prompt(child)));
|
||||
else {
|
||||
item_make("*** %s ***", _(menu_get_prompt(child)));
|
||||
item_set_tag(':');
|
||||
}
|
||||
item_set_data(child);
|
||||
if (child->sym == active)
|
||||
item_set_selected(1);
|
||||
@ -748,6 +677,9 @@ static void conf_choice(struct menu *menu)
|
||||
case 0:
|
||||
if (selected) {
|
||||
child = item_data();
|
||||
if (!child->sym)
|
||||
break;
|
||||
|
||||
sym_set_tristate_value(child->sym, yes);
|
||||
}
|
||||
return;
|
||||
@ -880,6 +812,8 @@ int main(int ac, char **av)
|
||||
single_menu_mode = 1;
|
||||
}
|
||||
|
||||
initscr();
|
||||
|
||||
getyx(stdscr, saved_y, saved_x);
|
||||
if (init_dialog(NULL)) {
|
||||
fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
|
||||
@ -894,7 +828,7 @@ int main(int ac, char **av)
|
||||
if (conf_get_changed())
|
||||
res = dialog_yesno(NULL,
|
||||
_("Do you wish to save your "
|
||||
"new " PACKAGE " configuration?\n"
|
||||
"new configuration?\n"
|
||||
"<ESC><ESC> to continue."),
|
||||
6, 60);
|
||||
else
|
||||
@ -906,15 +840,21 @@ int main(int ac, char **av)
|
||||
case 0:
|
||||
if (conf_write(filename)) {
|
||||
fprintf(stderr, _("\n\n"
|
||||
"Error during writing of " PACKAGE " configuration.\n"
|
||||
"Your " PACKAGE " configuration changes were NOT saved."
|
||||
"Error while writing of the configuration.\n"
|
||||
"Your configuration changes were NOT saved."
|
||||
"\n\n"));
|
||||
return 1;
|
||||
}
|
||||
case -1:
|
||||
printf(_("\n\n"
|
||||
"*** End of the configuration.\n"
|
||||
"*** Execute 'make' to start the build or try 'make help'."
|
||||
"\n\n"));
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, _("Your configuration changes were NOT saved.\n"));
|
||||
fprintf(stderr, _("\n\n"
|
||||
"Your configuration changes were NOT saved."
|
||||
"\n\n"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
186
kconfig/menu.c
186
kconfig/menu.c
@ -9,6 +9,9 @@
|
||||
#define LKC_DIRECT_LINK
|
||||
#include "lkc.h"
|
||||
|
||||
static const char nohelp_text[] = N_(
|
||||
"There is no help available for this option.\n");
|
||||
|
||||
struct menu rootmenu;
|
||||
static struct menu **last_entry_ptr;
|
||||
|
||||
@ -35,7 +38,7 @@ static void prop_warn(struct property *prop, const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void menu_init(void)
|
||||
void _menu_init(void)
|
||||
{
|
||||
current_entry = current_menu = &rootmenu;
|
||||
last_entry_ptr = &rootmenu.list;
|
||||
@ -55,6 +58,8 @@ void menu_add_entry(struct symbol *sym)
|
||||
*last_entry_ptr = menu;
|
||||
last_entry_ptr = &menu->next;
|
||||
current_entry = menu;
|
||||
if (sym)
|
||||
menu_add_symbol(P_SYMBOL, sym, NULL);
|
||||
}
|
||||
|
||||
void menu_end_entry(void)
|
||||
@ -74,7 +79,7 @@ void menu_end_menu(void)
|
||||
current_menu = current_menu->parent;
|
||||
}
|
||||
|
||||
struct expr *menu_check_dep(struct expr *e)
|
||||
static struct expr *menu_check_dep(struct expr *e)
|
||||
{
|
||||
if (!e)
|
||||
return e;
|
||||
@ -128,19 +133,27 @@ struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *e
|
||||
prop->visible.expr = menu_check_dep(dep);
|
||||
|
||||
if (prompt) {
|
||||
/* For crostool-NG, a leading pipe followed with spaces
|
||||
* means that pipe shall be removed, and the spaces should
|
||||
* not be trimmed.
|
||||
*/
|
||||
if (*prompt == '|')
|
||||
prompt++;
|
||||
else if (isspace(*prompt)) {
|
||||
/* Silently trim leading spaces */
|
||||
if (isspace(*prompt)) {
|
||||
prop_warn(prop, "leading whitespace ignored");
|
||||
while (isspace(*prompt))
|
||||
prompt++;
|
||||
}
|
||||
if (current_entry->prompt)
|
||||
if (current_entry->prompt && current_entry != &rootmenu)
|
||||
prop_warn(prop, "prompt redefined");
|
||||
|
||||
/* Apply all upper menus' visibilities to actual prompts. */
|
||||
if(type == P_PROMPT) {
|
||||
struct menu *menu = current_entry;
|
||||
|
||||
while ((menu = menu->parent) != NULL) {
|
||||
if (!menu->visibility)
|
||||
continue;
|
||||
prop->visible.expr
|
||||
= expr_alloc_and(prop->visible.expr,
|
||||
menu->visibility);
|
||||
}
|
||||
}
|
||||
|
||||
current_entry->prompt = prop;
|
||||
}
|
||||
prop->text = prompt;
|
||||
@ -153,6 +166,12 @@ struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr
|
||||
return menu_add_prop(type, prompt, NULL, dep);
|
||||
}
|
||||
|
||||
void menu_add_visibility(struct expr *expr)
|
||||
{
|
||||
current_entry->visibility = expr_alloc_and(current_entry->visibility,
|
||||
expr);
|
||||
}
|
||||
|
||||
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
|
||||
{
|
||||
menu_add_prop(type, NULL, expr, dep);
|
||||
@ -184,13 +203,13 @@ void menu_add_option(int token, char *arg)
|
||||
}
|
||||
}
|
||||
|
||||
static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
|
||||
static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
|
||||
{
|
||||
return sym2->type == S_INT || sym2->type == S_HEX ||
|
||||
(sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
|
||||
}
|
||||
|
||||
void sym_check_prop(struct symbol *sym)
|
||||
static void sym_check_prop(struct symbol *sym)
|
||||
{
|
||||
struct property *prop;
|
||||
struct symbol *sym2;
|
||||
@ -200,8 +219,17 @@ void sym_check_prop(struct symbol *sym)
|
||||
if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) &&
|
||||
prop->expr->type != E_SYMBOL)
|
||||
prop_warn(prop,
|
||||
"default for config symbol '%'"
|
||||
"default for config symbol '%s'"
|
||||
" must be a single symbol", sym->name);
|
||||
if (prop->expr->type != E_SYMBOL)
|
||||
break;
|
||||
sym2 = prop_get_symbol(prop);
|
||||
if (sym->type == S_HEX || sym->type == S_INT) {
|
||||
if (!menu_validate_number(sym, sym2))
|
||||
prop_warn(prop,
|
||||
"'%s': number is invalid",
|
||||
sym->name);
|
||||
}
|
||||
break;
|
||||
case P_SELECT:
|
||||
sym2 = prop_get_symbol(prop);
|
||||
@ -221,8 +249,8 @@ void sym_check_prop(struct symbol *sym)
|
||||
if (sym->type != S_INT && sym->type != S_HEX)
|
||||
prop_warn(prop, "range is only allowed "
|
||||
"for int or hex symbols");
|
||||
if (!menu_range_valid_sym(sym, prop->expr->left.sym) ||
|
||||
!menu_range_valid_sym(sym, prop->expr->right.sym))
|
||||
if (!menu_validate_number(sym, prop->expr->left.sym) ||
|
||||
!menu_validate_number(sym, prop->expr->right.sym))
|
||||
prop_warn(prop, "range is invalid");
|
||||
break;
|
||||
default:
|
||||
@ -321,6 +349,8 @@ void menu_finalize(struct menu *parent)
|
||||
parent->next = last_menu->next;
|
||||
last_menu->next = NULL;
|
||||
}
|
||||
|
||||
sym->dir_dep.expr = parent->dep;
|
||||
}
|
||||
for (menu = parent->list; menu; menu = menu->next) {
|
||||
if (sym && sym_is_choice(sym) &&
|
||||
@ -393,6 +423,13 @@ void menu_finalize(struct menu *parent)
|
||||
}
|
||||
}
|
||||
|
||||
bool menu_has_prompt(struct menu *menu)
|
||||
{
|
||||
if (!menu->prompt)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool menu_is_visible(struct menu *menu)
|
||||
{
|
||||
struct menu *child;
|
||||
@ -401,6 +438,12 @@ bool menu_is_visible(struct menu *menu)
|
||||
|
||||
if (!menu->prompt)
|
||||
return false;
|
||||
|
||||
if (menu->visibility) {
|
||||
if (expr_calc_value(menu->visibility) == no)
|
||||
return no;
|
||||
}
|
||||
|
||||
sym = menu->sym;
|
||||
if (sym) {
|
||||
sym_calc_value(sym);
|
||||
@ -410,12 +453,18 @@ bool menu_is_visible(struct menu *menu)
|
||||
|
||||
if (visible != no)
|
||||
return true;
|
||||
|
||||
if (!sym || sym_get_tristate_value(menu->sym) == no)
|
||||
return false;
|
||||
|
||||
for (child = menu->list; child; child = child->next)
|
||||
if (menu_is_visible(child))
|
||||
for (child = menu->list; child; child = child->next) {
|
||||
if (menu_is_visible(child)) {
|
||||
if (sym)
|
||||
sym->flags |= SYMBOL_DEF_USER;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -457,3 +506,104 @@ const char *menu_get_help(struct menu *menu)
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
static void get_prompt_str(struct gstr *r, struct property *prop)
|
||||
{
|
||||
int i, j;
|
||||
struct menu *submenu[8], *menu;
|
||||
|
||||
str_printf(r, _("Prompt: %s\n"), _(prop->text));
|
||||
str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
|
||||
prop->menu->lineno);
|
||||
if (!expr_is_yes(prop->visible.expr)) {
|
||||
str_append(r, _(" Depends on: "));
|
||||
expr_gstr_print(prop->visible.expr, r);
|
||||
str_append(r, "\n");
|
||||
}
|
||||
menu = prop->menu->parent;
|
||||
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
|
||||
submenu[i++] = menu;
|
||||
if (i > 0) {
|
||||
str_printf(r, _(" Location:\n"));
|
||||
for (j = 4; --i >= 0; j += 2) {
|
||||
menu = submenu[i];
|
||||
str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
|
||||
if (menu->sym) {
|
||||
str_printf(r, " (%s [=%s])", menu->sym->name ?
|
||||
menu->sym->name : _("<choice>"),
|
||||
sym_get_string_value(menu->sym));
|
||||
}
|
||||
str_append(r, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void get_symbol_str(struct gstr *r, struct symbol *sym)
|
||||
{
|
||||
bool hit;
|
||||
struct property *prop;
|
||||
|
||||
if (sym && sym->name) {
|
||||
str_printf(r, "Symbol: %s [=%s]\n", sym->name,
|
||||
sym_get_string_value(sym));
|
||||
str_printf(r, "Type : %s\n", sym_type_name(sym->type));
|
||||
if (sym->type == S_INT || sym->type == S_HEX) {
|
||||
prop = sym_get_range_prop(sym);
|
||||
if (prop) {
|
||||
str_printf(r, "Range : ");
|
||||
expr_gstr_print(prop->expr, r);
|
||||
str_append(r, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
for_all_prompts(sym, prop)
|
||||
get_prompt_str(r, prop);
|
||||
hit = false;
|
||||
for_all_properties(sym, prop, P_SELECT) {
|
||||
if (!hit) {
|
||||
str_append(r, " Selects: ");
|
||||
hit = true;
|
||||
} else
|
||||
str_printf(r, " && ");
|
||||
expr_gstr_print(prop->expr, r);
|
||||
}
|
||||
if (hit)
|
||||
str_append(r, "\n");
|
||||
if (sym->rev_dep.expr) {
|
||||
str_append(r, _(" Selected by: "));
|
||||
expr_gstr_print(sym->rev_dep.expr, r);
|
||||
str_append(r, "\n");
|
||||
}
|
||||
str_append(r, "\n\n");
|
||||
}
|
||||
|
||||
struct gstr get_relations_str(struct symbol **sym_arr)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct gstr res = str_new();
|
||||
int i;
|
||||
|
||||
for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
|
||||
get_symbol_str(&res, sym);
|
||||
if (!i)
|
||||
str_append(&res, _("No matches found.\n"));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void menu_get_ext_help(struct menu *menu, struct gstr *help)
|
||||
{
|
||||
struct symbol *sym = menu->sym;
|
||||
|
||||
if (menu_has_help(menu)) {
|
||||
if (sym->name) {
|
||||
str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
|
||||
str_append(help, _(menu_get_help(menu)));
|
||||
str_append(help, "\n");
|
||||
}
|
||||
} else {
|
||||
str_append(help, nohelp_text);
|
||||
}
|
||||
if (sym)
|
||||
get_symbol_str(help, sym);
|
||||
}
|
||||
|
393
kconfig/symbol.c
393
kconfig/symbol.c
@ -36,7 +36,7 @@ tristate modules_val;
|
||||
|
||||
struct expr *sym_env_list;
|
||||
|
||||
void sym_add_default(struct symbol *sym, const char *def)
|
||||
static void sym_add_default(struct symbol *sym, const char *def)
|
||||
{
|
||||
struct property *prop = prop_alloc(P_DEFAULT, sym);
|
||||
|
||||
@ -48,7 +48,6 @@ void sym_init(void)
|
||||
struct symbol *sym;
|
||||
struct utsname uts;
|
||||
static bool inited = false;
|
||||
char* p;
|
||||
|
||||
if (inited)
|
||||
return;
|
||||
@ -60,13 +59,6 @@ void sym_init(void)
|
||||
sym->type = S_STRING;
|
||||
sym->flags |= SYMBOL_AUTO;
|
||||
sym_add_default(sym, uts.release);
|
||||
|
||||
sym = sym_lookup("PROJECTVERSION", 0);
|
||||
sym->type = S_STRING;
|
||||
sym->flags |= SYMBOL_AUTO;
|
||||
p = getenv("PROJECTVERSION");
|
||||
if (p)
|
||||
sym_add_default(sym, p);
|
||||
}
|
||||
|
||||
enum symbol_type sym_get_type(struct symbol *sym)
|
||||
@ -133,7 +125,7 @@ struct property *sym_get_default_prop(struct symbol *sym)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct property *sym_get_range_prop(struct symbol *sym)
|
||||
static struct property *sym_get_range_prop(struct symbol *sym)
|
||||
{
|
||||
struct property *prop;
|
||||
|
||||
@ -213,6 +205,16 @@ static void sym_calc_visibility(struct symbol *sym)
|
||||
}
|
||||
if (sym_is_choice_value(sym))
|
||||
return;
|
||||
/* defaulting to "yes" if no explicit "depends on" are given */
|
||||
tri = yes;
|
||||
if (sym->dir_dep.expr)
|
||||
tri = expr_calc_value(sym->dir_dep.expr);
|
||||
if (tri == mod)
|
||||
tri = yes;
|
||||
if (sym->dir_dep.tri != tri) {
|
||||
sym->dir_dep.tri = tri;
|
||||
sym_set_changed(sym);
|
||||
}
|
||||
tri = no;
|
||||
if (sym->rev_dep.expr)
|
||||
tri = expr_calc_value(sym->rev_dep.expr);
|
||||
@ -224,44 +226,63 @@ static void sym_calc_visibility(struct symbol *sym)
|
||||
}
|
||||
}
|
||||
|
||||
static struct symbol *sym_calc_choice(struct symbol *sym)
|
||||
/*
|
||||
* Find the default symbol for a choice.
|
||||
* First try the default values for the choice symbol
|
||||
* Next locate the first visible choice value
|
||||
* Return NULL if none was found
|
||||
*/
|
||||
struct symbol *sym_choice_default(struct symbol *sym)
|
||||
{
|
||||
struct symbol *def_sym;
|
||||
struct property *prop;
|
||||
struct expr *e;
|
||||
|
||||
/* is the user choice visible? */
|
||||
def_sym = sym->def[S_DEF_USER].val;
|
||||
if (def_sym) {
|
||||
sym_calc_visibility(def_sym);
|
||||
if (def_sym->visible != no)
|
||||
return def_sym;
|
||||
}
|
||||
|
||||
/* any of the defaults visible? */
|
||||
for_all_defaults(sym, prop) {
|
||||
prop->visible.tri = expr_calc_value(prop->visible.expr);
|
||||
if (prop->visible.tri == no)
|
||||
continue;
|
||||
def_sym = prop_get_symbol(prop);
|
||||
sym_calc_visibility(def_sym);
|
||||
if (def_sym->visible != no)
|
||||
return def_sym;
|
||||
}
|
||||
|
||||
/* just get the first visible value */
|
||||
prop = sym_get_choice_prop(sym);
|
||||
expr_list_for_each_sym(prop->expr, e, def_sym) {
|
||||
sym_calc_visibility(def_sym);
|
||||
expr_list_for_each_sym(prop->expr, e, def_sym)
|
||||
if (def_sym->visible != no)
|
||||
return def_sym;
|
||||
}
|
||||
|
||||
/* no choice? reset tristate value */
|
||||
sym->curr.tri = no;
|
||||
/* failed to locate any defaults */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct symbol *sym_calc_choice(struct symbol *sym)
|
||||
{
|
||||
struct symbol *def_sym;
|
||||
struct property *prop;
|
||||
struct expr *e;
|
||||
|
||||
/* first calculate all choice values' visibilities */
|
||||
prop = sym_get_choice_prop(sym);
|
||||
expr_list_for_each_sym(prop->expr, e, def_sym)
|
||||
sym_calc_visibility(def_sym);
|
||||
|
||||
/* is the user choice visible? */
|
||||
def_sym = sym->def[S_DEF_USER].val;
|
||||
if (def_sym && def_sym->visible != no)
|
||||
return def_sym;
|
||||
|
||||
def_sym = sym_choice_default(sym);
|
||||
|
||||
if (def_sym == NULL)
|
||||
/* no choice? reset tristate value */
|
||||
sym->curr.tri = no;
|
||||
|
||||
return def_sym;
|
||||
}
|
||||
|
||||
void sym_calc_value(struct symbol *sym)
|
||||
{
|
||||
struct symbol_value newval, oldval;
|
||||
@ -329,6 +350,18 @@ void sym_calc_value(struct symbol *sym)
|
||||
}
|
||||
}
|
||||
calc_newval:
|
||||
if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
|
||||
struct expr *e;
|
||||
e = expr_simplify_unmet_dep(sym->rev_dep.expr,
|
||||
sym->dir_dep.expr);
|
||||
fprintf(stderr, "warning: (");
|
||||
expr_fprint(e, stderr);
|
||||
fprintf(stderr, ") selects %s which has unmet direct dependencies (",
|
||||
sym->name);
|
||||
expr_fprint(sym->dir_dep.expr, stderr);
|
||||
fprintf(stderr, ")\n");
|
||||
expr_free(e);
|
||||
}
|
||||
newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
|
||||
}
|
||||
if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
|
||||
@ -373,12 +406,13 @@ void sym_calc_value(struct symbol *sym)
|
||||
|
||||
if (sym_is_choice(sym)) {
|
||||
struct symbol *choice_sym;
|
||||
int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
|
||||
|
||||
prop = sym_get_choice_prop(sym);
|
||||
expr_list_for_each_sym(prop->expr, e, choice_sym) {
|
||||
choice_sym->flags |= flags;
|
||||
if (flags & SYMBOL_CHANGED)
|
||||
if ((sym->flags & SYMBOL_WRITE) &&
|
||||
choice_sym->visible != no)
|
||||
choice_sym->flags |= SYMBOL_WRITE;
|
||||
if (sym->flags & SYMBOL_CHANGED)
|
||||
sym_set_changed(choice_sym);
|
||||
}
|
||||
}
|
||||
@ -631,6 +665,80 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the default value associated to a symbol.
|
||||
* For tristate symbol handle the modules=n case
|
||||
* in which case "m" becomes "y".
|
||||
* If the symbol does not have any default then fallback
|
||||
* to the fixed default values.
|
||||
*/
|
||||
const char *sym_get_string_default(struct symbol *sym)
|
||||
{
|
||||
struct property *prop;
|
||||
struct symbol *ds;
|
||||
const char *str;
|
||||
tristate val;
|
||||
|
||||
sym_calc_visibility(sym);
|
||||
sym_calc_value(modules_sym);
|
||||
val = symbol_no.curr.tri;
|
||||
str = symbol_empty.curr.val;
|
||||
|
||||
/* If symbol has a default value look it up */
|
||||
prop = sym_get_default_prop(sym);
|
||||
if (prop != NULL) {
|
||||
switch (sym->type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
/* The visibility may limit the value from yes => mod */
|
||||
val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* The following fails to handle the situation
|
||||
* where a default value is further limited by
|
||||
* the valid range.
|
||||
*/
|
||||
ds = prop_get_symbol(prop);
|
||||
if (ds != NULL) {
|
||||
sym_calc_value(ds);
|
||||
str = (const char *)ds->curr.val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle select statements */
|
||||
val = EXPR_OR(val, sym->rev_dep.tri);
|
||||
|
||||
/* transpose mod to yes if modules are not enabled */
|
||||
if (val == mod)
|
||||
if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
|
||||
val = yes;
|
||||
|
||||
/* transpose mod to yes if type is bool */
|
||||
if (sym->type == S_BOOLEAN && val == mod)
|
||||
val = yes;
|
||||
|
||||
switch (sym->type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
switch (val) {
|
||||
case no: return "n";
|
||||
case mod: return "m";
|
||||
case yes: return "y";
|
||||
}
|
||||
case S_INT:
|
||||
case S_HEX:
|
||||
return str;
|
||||
case S_STRING:
|
||||
return str;
|
||||
case S_OTHER:
|
||||
case S_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *sym_get_string_value(struct symbol *sym)
|
||||
{
|
||||
tristate val;
|
||||
@ -659,12 +767,20 @@ bool sym_is_changable(struct symbol *sym)
|
||||
return sym->visible > sym->rev_dep.tri;
|
||||
}
|
||||
|
||||
static unsigned strhash(const char *s)
|
||||
{
|
||||
/* fnv32 hash */
|
||||
unsigned hash = 2166136261U;
|
||||
for (; *s; s++)
|
||||
hash = (hash ^ *s) * 0x01000193;
|
||||
return hash;
|
||||
}
|
||||
|
||||
struct symbol *sym_lookup(const char *name, int flags)
|
||||
{
|
||||
struct symbol *symbol;
|
||||
const char *ptr;
|
||||
char *new_name;
|
||||
int hash = 0;
|
||||
int hash;
|
||||
|
||||
if (name) {
|
||||
if (name[0] && !name[1]) {
|
||||
@ -674,12 +790,11 @@ struct symbol *sym_lookup(const char *name, int flags)
|
||||
case 'n': return &symbol_no;
|
||||
}
|
||||
}
|
||||
for (ptr = name; *ptr; ptr++)
|
||||
hash += *ptr;
|
||||
hash &= 0xff;
|
||||
hash = strhash(name) % SYMBOL_HASHSIZE;
|
||||
|
||||
for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
|
||||
if (!strcmp(symbol->name, name) &&
|
||||
if (symbol->name &&
|
||||
!strcmp(symbol->name, name) &&
|
||||
(flags ? symbol->flags & flags
|
||||
: !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
|
||||
return symbol;
|
||||
@ -687,7 +802,7 @@ struct symbol *sym_lookup(const char *name, int flags)
|
||||
new_name = strdup(name);
|
||||
} else {
|
||||
new_name = NULL;
|
||||
hash = 256;
|
||||
hash = 0;
|
||||
}
|
||||
|
||||
symbol = malloc(sizeof(*symbol));
|
||||
@ -705,7 +820,6 @@ struct symbol *sym_lookup(const char *name, int flags)
|
||||
struct symbol *sym_find(const char *name)
|
||||
{
|
||||
struct symbol *symbol = NULL;
|
||||
const char *ptr;
|
||||
int hash = 0;
|
||||
|
||||
if (!name)
|
||||
@ -718,12 +832,11 @@ struct symbol *sym_find(const char *name)
|
||||
case 'n': return &symbol_no;
|
||||
}
|
||||
}
|
||||
for (ptr = name; *ptr; ptr++)
|
||||
hash += *ptr;
|
||||
hash &= 0xff;
|
||||
hash = strhash(name) % SYMBOL_HASHSIZE;
|
||||
|
||||
for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
|
||||
if (!strcmp(symbol->name, name) &&
|
||||
if (symbol->name &&
|
||||
!strcmp(symbol->name, name) &&
|
||||
!(symbol->flags & SYMBOL_CONST))
|
||||
break;
|
||||
}
|
||||
@ -731,6 +844,55 @@ struct symbol *sym_find(const char *name)
|
||||
return symbol;
|
||||
}
|
||||
|
||||
/*
|
||||
* Expand symbol's names embedded in the string given in argument. Symbols'
|
||||
* name to be expanded shall be prefixed by a '$'. Unknown symbol expands to
|
||||
* the empty string.
|
||||
*/
|
||||
const char *sym_expand_string_value(const char *in)
|
||||
{
|
||||
const char *src;
|
||||
char *res;
|
||||
size_t reslen;
|
||||
|
||||
reslen = strlen(in) + 1;
|
||||
res = malloc(reslen);
|
||||
res[0] = '\0';
|
||||
|
||||
while ((src = strchr(in, '$'))) {
|
||||
char *p, name[SYMBOL_MAXLENGTH];
|
||||
const char *symval = "";
|
||||
struct symbol *sym;
|
||||
size_t newlen;
|
||||
|
||||
strncat(res, in, src - in);
|
||||
src++;
|
||||
|
||||
p = name;
|
||||
while (isalnum(*src) || *src == '_')
|
||||
*p++ = *src++;
|
||||
*p = '\0';
|
||||
|
||||
sym = sym_find(name);
|
||||
if (sym != NULL) {
|
||||
sym_calc_value(sym);
|
||||
symval = sym_get_string_value(sym);
|
||||
}
|
||||
|
||||
newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
|
||||
if (newlen > reslen) {
|
||||
reslen = newlen;
|
||||
res = realloc(res, reslen);
|
||||
}
|
||||
|
||||
strcat(res, symval);
|
||||
in = src;
|
||||
}
|
||||
strcat(res, in);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
struct symbol **sym_re_search(const char *pattern)
|
||||
{
|
||||
struct symbol *sym, **sym_arr = NULL;
|
||||
@ -758,6 +920,7 @@ struct symbol **sym_re_search(const char *pattern)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
sym_calc_value(sym);
|
||||
sym_arr[cnt++] = sym;
|
||||
}
|
||||
if (sym_arr)
|
||||
@ -767,6 +930,112 @@ struct symbol **sym_re_search(const char *pattern)
|
||||
return sym_arr;
|
||||
}
|
||||
|
||||
/*
|
||||
* When we check for recursive dependencies we use a stack to save
|
||||
* current state so we can print out relevant info to user.
|
||||
* The entries are located on the call stack so no need to free memory.
|
||||
* Note inser() remove() must always match to properly clear the stack.
|
||||
*/
|
||||
static struct dep_stack {
|
||||
struct dep_stack *prev, *next;
|
||||
struct symbol *sym;
|
||||
struct property *prop;
|
||||
struct expr *expr;
|
||||
} *check_top;
|
||||
|
||||
static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
|
||||
{
|
||||
memset(stack, 0, sizeof(*stack));
|
||||
if (check_top)
|
||||
check_top->next = stack;
|
||||
stack->prev = check_top;
|
||||
stack->sym = sym;
|
||||
check_top = stack;
|
||||
}
|
||||
|
||||
static void dep_stack_remove(void)
|
||||
{
|
||||
check_top = check_top->prev;
|
||||
if (check_top)
|
||||
check_top->next = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when we have detected a recursive dependency.
|
||||
* check_top point to the top of the stact so we use
|
||||
* the ->prev pointer to locate the bottom of the stack.
|
||||
*/
|
||||
static void sym_check_print_recursive(struct symbol *last_sym)
|
||||
{
|
||||
struct dep_stack *stack;
|
||||
struct symbol *sym, *next_sym;
|
||||
struct menu *menu = NULL;
|
||||
struct property *prop;
|
||||
struct dep_stack cv_stack;
|
||||
|
||||
if (sym_is_choice_value(last_sym)) {
|
||||
dep_stack_insert(&cv_stack, last_sym);
|
||||
last_sym = prop_get_symbol(sym_get_choice_prop(last_sym));
|
||||
}
|
||||
|
||||
for (stack = check_top; stack != NULL; stack = stack->prev)
|
||||
if (stack->sym == last_sym)
|
||||
break;
|
||||
if (!stack) {
|
||||
fprintf(stderr, "unexpected recursive dependency error\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (; stack; stack = stack->next) {
|
||||
sym = stack->sym;
|
||||
next_sym = stack->next ? stack->next->sym : last_sym;
|
||||
prop = stack->prop;
|
||||
if (prop == NULL)
|
||||
prop = stack->sym->prop;
|
||||
|
||||
/* for choice values find the menu entry (used below) */
|
||||
if (sym_is_choice(sym) || sym_is_choice_value(sym)) {
|
||||
for (prop = sym->prop; prop; prop = prop->next) {
|
||||
menu = prop->menu;
|
||||
if (prop->menu)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (stack->sym == last_sym)
|
||||
fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
|
||||
prop->file->name, prop->lineno);
|
||||
if (stack->expr) {
|
||||
fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
|
||||
prop->file->name, prop->lineno,
|
||||
sym->name ? sym->name : "<choice>",
|
||||
prop_get_type_name(prop->type),
|
||||
next_sym->name ? next_sym->name : "<choice>");
|
||||
} else if (stack->prop) {
|
||||
fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
|
||||
prop->file->name, prop->lineno,
|
||||
sym->name ? sym->name : "<choice>",
|
||||
next_sym->name ? next_sym->name : "<choice>");
|
||||
} else if (sym_is_choice(sym)) {
|
||||
fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
|
||||
menu->file->name, menu->lineno,
|
||||
sym->name ? sym->name : "<choice>",
|
||||
next_sym->name ? next_sym->name : "<choice>");
|
||||
} else if (sym_is_choice_value(sym)) {
|
||||
fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
|
||||
menu->file->name, menu->lineno,
|
||||
sym->name ? sym->name : "<choice>",
|
||||
next_sym->name ? next_sym->name : "<choice>");
|
||||
} else {
|
||||
fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
|
||||
prop->file->name, prop->lineno,
|
||||
sym->name ? sym->name : "<choice>",
|
||||
next_sym->name ? next_sym->name : "<choice>");
|
||||
}
|
||||
}
|
||||
|
||||
if (check_top == &cv_stack)
|
||||
dep_stack_remove();
|
||||
}
|
||||
|
||||
static struct symbol *sym_check_expr_deps(struct expr *e)
|
||||
{
|
||||
@ -803,24 +1072,33 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym)
|
||||
{
|
||||
struct symbol *sym2;
|
||||
struct property *prop;
|
||||
struct dep_stack stack;
|
||||
|
||||
dep_stack_insert(&stack, sym);
|
||||
|
||||
sym2 = sym_check_expr_deps(sym->rev_dep.expr);
|
||||
if (sym2)
|
||||
return sym2;
|
||||
goto out;
|
||||
|
||||
for (prop = sym->prop; prop; prop = prop->next) {
|
||||
if (prop->type == P_CHOICE || prop->type == P_SELECT)
|
||||
continue;
|
||||
stack.prop = prop;
|
||||
sym2 = sym_check_expr_deps(prop->visible.expr);
|
||||
if (sym2)
|
||||
break;
|
||||
if (prop->type != P_DEFAULT || sym_is_choice(sym))
|
||||
continue;
|
||||
stack.expr = prop->expr;
|
||||
sym2 = sym_check_expr_deps(prop->expr);
|
||||
if (sym2)
|
||||
break;
|
||||
stack.expr = NULL;
|
||||
}
|
||||
|
||||
out:
|
||||
dep_stack_remove();
|
||||
|
||||
return sym2;
|
||||
}
|
||||
|
||||
@ -829,6 +1107,9 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice)
|
||||
struct symbol *sym, *sym2;
|
||||
struct property *prop;
|
||||
struct expr *e;
|
||||
struct dep_stack stack;
|
||||
|
||||
dep_stack_insert(&stack, choice);
|
||||
|
||||
prop = sym_get_choice_prop(choice);
|
||||
expr_list_for_each_sym(prop->expr, e, sym)
|
||||
@ -842,10 +1123,8 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice)
|
||||
|
||||
expr_list_for_each_sym(prop->expr, e, sym) {
|
||||
sym2 = sym_check_sym_deps(sym);
|
||||
if (sym2) {
|
||||
fprintf(stderr, " -> %s", sym->name);
|
||||
if (sym2)
|
||||
break;
|
||||
}
|
||||
}
|
||||
out:
|
||||
expr_list_for_each_sym(prop->expr, e, sym)
|
||||
@ -855,6 +1134,8 @@ out:
|
||||
prop_get_symbol(sym_get_choice_prop(sym2)) == choice)
|
||||
sym2 = choice;
|
||||
|
||||
dep_stack_remove();
|
||||
|
||||
return sym2;
|
||||
}
|
||||
|
||||
@ -864,18 +1145,20 @@ struct symbol *sym_check_deps(struct symbol *sym)
|
||||
struct property *prop;
|
||||
|
||||
if (sym->flags & SYMBOL_CHECK) {
|
||||
fprintf(stderr, "%s:%d:error: found recursive dependency: %s",
|
||||
sym->prop->file->name, sym->prop->lineno,
|
||||
sym->name ? sym->name : "<choice>");
|
||||
sym_check_print_recursive(sym);
|
||||
return sym;
|
||||
}
|
||||
if (sym->flags & SYMBOL_CHECKED)
|
||||
return NULL;
|
||||
|
||||
if (sym_is_choice_value(sym)) {
|
||||
struct dep_stack stack;
|
||||
|
||||
/* for choice groups start the check with main choice symbol */
|
||||
dep_stack_insert(&stack, sym);
|
||||
prop = sym_get_choice_prop(sym);
|
||||
sym2 = sym_check_deps(prop_get_symbol(prop));
|
||||
dep_stack_remove();
|
||||
} else if (sym_is_choice(sym)) {
|
||||
sym2 = sym_check_choice_deps(sym);
|
||||
} else {
|
||||
@ -884,14 +1167,8 @@ struct symbol *sym_check_deps(struct symbol *sym)
|
||||
sym->flags &= ~SYMBOL_CHECK;
|
||||
}
|
||||
|
||||
if (sym2) {
|
||||
fprintf(stderr, " -> %s", sym->name ? sym->name : "<choice>");
|
||||
if (sym2 == sym) {
|
||||
fprintf(stderr, "\n");
|
||||
zconfnerrs++;
|
||||
sym2 = NULL;
|
||||
}
|
||||
}
|
||||
if (sym2 && sym2 == sym)
|
||||
sym2 = NULL;
|
||||
|
||||
return sym2;
|
||||
}
|
||||
@ -945,13 +1222,15 @@ const char *prop_get_type_name(enum prop_type type)
|
||||
return "select";
|
||||
case P_RANGE:
|
||||
return "range";
|
||||
case P_SYMBOL:
|
||||
return "symbol";
|
||||
case P_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
void prop_add_env(const char *env)
|
||||
static void prop_add_env(const char *env)
|
||||
{
|
||||
struct symbol *sym, *sym2;
|
||||
struct property *prop;
|
||||
@ -976,4 +1255,6 @@ void prop_add_env(const char *env)
|
||||
p = getenv(env);
|
||||
if (p)
|
||||
sym_add_default(sym, p);
|
||||
else
|
||||
menu_warn(current_entry, "environment variable %s undefined", env);
|
||||
}
|
||||
|
@ -12,15 +12,18 @@
|
||||
struct file *file_lookup(const char *name)
|
||||
{
|
||||
struct file *file;
|
||||
const char *file_name = sym_expand_string_value(name);
|
||||
|
||||
for (file = file_list; file; file = file->next) {
|
||||
if (!strcmp(name, file->name))
|
||||
if (!strcmp(name, file->name)) {
|
||||
free((void *)file_name);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
file = malloc(sizeof(*file));
|
||||
memset(file, 0, sizeof(*file));
|
||||
file->name = strdup(name);
|
||||
file->name = file_name;
|
||||
file->next = file_list;
|
||||
file_list = file;
|
||||
return file;
|
||||
@ -46,8 +49,8 @@ int file_write_dep(const char *name)
|
||||
else
|
||||
fprintf(out, "\t%s\n", file->name);
|
||||
}
|
||||
fprintf(out, "\ninclude/config/auto.conf: \\\n"
|
||||
"\t$(deps_config)\n\n");
|
||||
fprintf(out, "\n%s: \\\n"
|
||||
"\t$(deps_config)\n\n", conf_get_autoconfig_name());
|
||||
|
||||
expr_list_for_each_sym(sym_env_list, e, sym) {
|
||||
struct property *prop;
|
||||
@ -61,7 +64,7 @@ int file_write_dep(const char *name)
|
||||
if (!value)
|
||||
value = "";
|
||||
fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value);
|
||||
fprintf(out, "include/config/auto.conf: FORCE\n");
|
||||
fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name());
|
||||
fprintf(out, "endif\n");
|
||||
}
|
||||
|
||||
@ -72,12 +75,13 @@ int file_write_dep(const char *name)
|
||||
}
|
||||
|
||||
|
||||
/* Allocate initial growable sting */
|
||||
/* Allocate initial growable string */
|
||||
struct gstr str_new(void)
|
||||
{
|
||||
struct gstr gs;
|
||||
gs.s = malloc(sizeof(char) * 64);
|
||||
gs.len = 64;
|
||||
gs.max_width = 0;
|
||||
strcpy(gs.s, "\0");
|
||||
return gs;
|
||||
}
|
||||
@ -88,6 +92,7 @@ struct gstr str_assign(const char *s)
|
||||
struct gstr gs;
|
||||
gs.s = strdup(s);
|
||||
gs.len = strlen(s) + 1;
|
||||
gs.max_width = 0;
|
||||
return gs;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,9 @@
|
||||
#endif
|
||||
|
||||
struct kconf_id;
|
||||
/* maximum key range = 47, duplicates = 0 */
|
||||
|
||||
static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
|
||||
/* maximum key range = 50, duplicates = 0 */
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
@ -44,32 +46,32 @@ kconf_id_hash (register const char *str, register unsigned int len)
|
||||
{
|
||||
static unsigned char asso_values[] =
|
||||
{
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 11, 5,
|
||||
0, 0, 5, 49, 5, 20, 49, 49, 5, 20,
|
||||
5, 0, 30, 49, 0, 15, 0, 10, 0, 49,
|
||||
25, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 40, 5,
|
||||
0, 0, 5, 52, 0, 20, 52, 52, 10, 20,
|
||||
5, 0, 35, 52, 0, 30, 0, 15, 0, 52,
|
||||
15, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
|
||||
52, 52, 52, 52, 52, 52
|
||||
};
|
||||
register int hval = len;
|
||||
|
||||
@ -100,25 +102,26 @@ struct kconf_id_strings_t
|
||||
char kconf_id_strings_str12[sizeof("default")];
|
||||
char kconf_id_strings_str13[sizeof("def_bool")];
|
||||
char kconf_id_strings_str14[sizeof("help")];
|
||||
char kconf_id_strings_str15[sizeof("bool")];
|
||||
char kconf_id_strings_str16[sizeof("config")];
|
||||
char kconf_id_strings_str17[sizeof("def_tristate")];
|
||||
char kconf_id_strings_str18[sizeof("boolean")];
|
||||
char kconf_id_strings_str18[sizeof("hex")];
|
||||
char kconf_id_strings_str19[sizeof("defconfig_list")];
|
||||
char kconf_id_strings_str21[sizeof("string")];
|
||||
char kconf_id_strings_str22[sizeof("if")];
|
||||
char kconf_id_strings_str23[sizeof("int")];
|
||||
char kconf_id_strings_str26[sizeof("select")];
|
||||
char kconf_id_strings_str27[sizeof("modules")];
|
||||
char kconf_id_strings_str28[sizeof("tristate")];
|
||||
char kconf_id_strings_str29[sizeof("menu")];
|
||||
char kconf_id_strings_str31[sizeof("source")];
|
||||
char kconf_id_strings_str32[sizeof("comment")];
|
||||
char kconf_id_strings_str33[sizeof("hex")];
|
||||
char kconf_id_strings_str35[sizeof("menuconfig")];
|
||||
char kconf_id_strings_str36[sizeof("prompt")];
|
||||
char kconf_id_strings_str37[sizeof("depends")];
|
||||
char kconf_id_strings_str36[sizeof("string")];
|
||||
char kconf_id_strings_str37[sizeof("visible")];
|
||||
char kconf_id_strings_str41[sizeof("prompt")];
|
||||
char kconf_id_strings_str42[sizeof("depends")];
|
||||
char kconf_id_strings_str44[sizeof("bool")];
|
||||
char kconf_id_strings_str46[sizeof("select")];
|
||||
char kconf_id_strings_str47[sizeof("boolean")];
|
||||
char kconf_id_strings_str48[sizeof("mainmenu")];
|
||||
char kconf_id_strings_str51[sizeof("source")];
|
||||
};
|
||||
static struct kconf_id_strings_t kconf_id_strings_contents =
|
||||
{
|
||||
@ -134,25 +137,26 @@ static struct kconf_id_strings_t kconf_id_strings_contents =
|
||||
"default",
|
||||
"def_bool",
|
||||
"help",
|
||||
"bool",
|
||||
"config",
|
||||
"def_tristate",
|
||||
"boolean",
|
||||
"hex",
|
||||
"defconfig_list",
|
||||
"string",
|
||||
"if",
|
||||
"int",
|
||||
"select",
|
||||
"modules",
|
||||
"tristate",
|
||||
"menu",
|
||||
"source",
|
||||
"comment",
|
||||
"hex",
|
||||
"menuconfig",
|
||||
"string",
|
||||
"visible",
|
||||
"prompt",
|
||||
"depends",
|
||||
"mainmenu"
|
||||
"bool",
|
||||
"select",
|
||||
"boolean",
|
||||
"mainmenu",
|
||||
"source"
|
||||
};
|
||||
#define kconf_id_strings ((const char *) &kconf_id_strings_contents)
|
||||
#ifdef __GNUC__
|
||||
@ -166,11 +170,11 @@ kconf_id_lookup (register const char *str, register unsigned int len)
|
||||
{
|
||||
enum
|
||||
{
|
||||
TOTAL_KEYWORDS = 31,
|
||||
TOTAL_KEYWORDS = 32,
|
||||
MIN_WORD_LENGTH = 2,
|
||||
MAX_WORD_LENGTH = 14,
|
||||
MIN_HASH_VALUE = 2,
|
||||
MAX_HASH_VALUE = 48
|
||||
MAX_HASH_VALUE = 51
|
||||
};
|
||||
|
||||
static struct kconf_id wordlist[] =
|
||||
@ -189,31 +193,35 @@ kconf_id_lookup (register const char *str, register unsigned int len)
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str15, T_TYPE, TF_COMMAND, S_BOOLEAN},
|
||||
{-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_BOOLEAN},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_HEX},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION},
|
||||
{-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_TYPE, TF_COMMAND, S_STRING},
|
||||
{-1}, {-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT},
|
||||
{-1}, {-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SELECT, TF_COMMAND},
|
||||
{-1}, {-1}, {-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND},
|
||||
{-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SOURCE, TF_COMMAND},
|
||||
{-1}, {-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_TYPE, TF_COMMAND, S_HEX},
|
||||
{-1},
|
||||
{-1}, {-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_PROMPT, TF_COMMAND},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_DEPENDS, TF_COMMAND},
|
||||
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_TYPE, TF_COMMAND, S_STRING},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_VISIBLE, TF_COMMAND},
|
||||
{-1}, {-1}, {-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_PROMPT, TF_COMMAND},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_DEPENDS, TF_COMMAND},
|
||||
{-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND}
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str44, T_TYPE, TF_COMMAND, S_BOOLEAN},
|
||||
{-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_SELECT, TF_COMMAND},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND},
|
||||
{-1}, {-1},
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_SOURCE, TF_COMMAND}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
|
1081
kconfig/zconf.tab.c
1081
kconfig/zconf.tab.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user