Commit ffb5957b authored by Arnaud Lacombe's avatar Arnaud Lacombe

kconfig: allow build-time definition of the internal config prefix

Signed-off-by: default avatarArnaud Lacombe <lacombar@gmail.com>
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Reviewed-by: default avatarMichal Marek <mmarek@suse.cz>
parent 59dfa24d
...@@ -425,7 +425,7 @@ static void check_conf(struct menu *menu) ...@@ -425,7 +425,7 @@ static void check_conf(struct menu *menu)
(sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
if (input_mode == listnewconfig) { if (input_mode == listnewconfig) {
if (sym->name && !sym_is_choice_value(sym)) { if (sym->name && !sym_is_choice_value(sym)) {
printf("CONFIG_%s\n", sym->name); printf("%s%s\n", CONFIG_, sym->name);
} }
} else if (input_mode != oldnoconfig) { } else if (input_mode != oldnoconfig) {
if (!conf_cnt++) if (!conf_cnt++)
......
...@@ -222,22 +222,22 @@ int conf_read_simple(const char *name, int def) ...@@ -222,22 +222,22 @@ int conf_read_simple(const char *name, int def)
conf_lineno++; conf_lineno++;
sym = NULL; sym = NULL;
if (line[0] == '#') { if (line[0] == '#') {
if (memcmp(line + 2, "CONFIG_", 7)) if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
continue; continue;
p = strchr(line + 9, ' '); p = strchr(line + 2 + strlen(CONFIG_), ' ');
if (!p) if (!p)
continue; continue;
*p++ = 0; *p++ = 0;
if (strncmp(p, "is not set", 10)) if (strncmp(p, "is not set", 10))
continue; continue;
if (def == S_DEF_USER) { if (def == S_DEF_USER) {
sym = sym_find(line + 9); sym = sym_find(line + 2 + strlen(CONFIG_));
if (!sym) { if (!sym) {
sym_add_change_count(1); sym_add_change_count(1);
break; break;
} }
} else { } else {
sym = sym_lookup(line + 9, 0); sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
if (sym->type == S_UNKNOWN) if (sym->type == S_UNKNOWN)
sym->type = S_BOOLEAN; sym->type = S_BOOLEAN;
} }
...@@ -253,8 +253,8 @@ int conf_read_simple(const char *name, int def) ...@@ -253,8 +253,8 @@ int conf_read_simple(const char *name, int def)
default: default:
; ;
} }
} else if (memcmp(line, "CONFIG_", 7) == 0) { } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
p = strchr(line + 7, '='); p = strchr(line + strlen(CONFIG_), '=');
if (!p) if (!p)
continue; continue;
*p++ = 0; *p++ = 0;
...@@ -265,13 +265,13 @@ int conf_read_simple(const char *name, int def) ...@@ -265,13 +265,13 @@ int conf_read_simple(const char *name, int def)
*p2 = 0; *p2 = 0;
} }
if (def == S_DEF_USER) { if (def == S_DEF_USER) {
sym = sym_find(line + 7); sym = sym_find(line + strlen(CONFIG_));
if (!sym) { if (!sym) {
sym_add_change_count(1); sym_add_change_count(1);
break; break;
} }
} else { } else {
sym = sym_lookup(line + 7, 0); sym = sym_lookup(line + strlen(CONFIG_), 0);
if (sym->type == S_UNKNOWN) if (sym->type == S_UNKNOWN)
sym->type = S_OTHER; sym->type = S_OTHER;
} }
...@@ -397,9 +397,9 @@ static void conf_write_string(bool headerfile, const char *name, ...@@ -397,9 +397,9 @@ static void conf_write_string(bool headerfile, const char *name,
{ {
int l; int l;
if (headerfile) if (headerfile)
fprintf(out, "#define CONFIG_%s \"", name); fprintf(out, "#define %s%s \"", CONFIG_, name);
else else
fprintf(out, "CONFIG_%s=\"", name); fprintf(out, "%s%s=\"", CONFIG_, name);
while (1) { while (1) {
l = strcspn(str, "\"\\"); l = strcspn(str, "\"\\");
...@@ -425,13 +425,14 @@ static void conf_write_symbol(struct symbol *sym, enum symbol_type type, ...@@ -425,13 +425,14 @@ static void conf_write_symbol(struct symbol *sym, enum symbol_type type,
switch (sym_get_tristate_value(sym)) { switch (sym_get_tristate_value(sym)) {
case no: case no:
if (write_no) if (write_no)
fprintf(out, "# CONFIG_%s is not set\n", sym->name); fprintf(out, "# %s%s is not set\n",
CONFIG_, sym->name);
break; break;
case mod: case mod:
fprintf(out, "CONFIG_%s=m\n", sym->name); fprintf(out, "%s%s=m\n", CONFIG_, sym->name);
break; break;
case yes: case yes:
fprintf(out, "CONFIG_%s=y\n", sym->name); fprintf(out, "%s%s=y\n", CONFIG_, sym->name);
break; break;
} }
break; break;
...@@ -441,7 +442,7 @@ static void conf_write_symbol(struct symbol *sym, enum symbol_type type, ...@@ -441,7 +442,7 @@ static void conf_write_symbol(struct symbol *sym, enum symbol_type type,
case S_HEX: case S_HEX:
case S_INT: case S_INT:
str = sym_get_string_value(sym); str = sym_get_string_value(sym);
fprintf(out, "CONFIG_%s=%s\n", sym->name, str); fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str);
break; break;
case S_OTHER: case S_OTHER:
case S_UNKNOWN: case S_UNKNOWN:
...@@ -832,14 +833,17 @@ int conf_write_autoconf(void) ...@@ -832,14 +833,17 @@ int conf_write_autoconf(void)
case no: case no:
break; break;
case mod: case mod:
fprintf(tristate, "CONFIG_%s=M\n", sym->name); fprintf(tristate, "%s%s=M\n",
fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); CONFIG_, sym->name);
fprintf(out_h, "#define %s%s_MODULE 1\n",
CONFIG_, sym->name);
break; break;
case yes: case yes:
if (sym->type == S_TRISTATE) if (sym->type == S_TRISTATE)
fprintf(tristate, "CONFIG_%s=Y\n", fprintf(tristate,"%s%s=Y\n",
sym->name); CONFIG_, sym->name);
fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); fprintf(out_h, "#define %s%s 1\n",
CONFIG_, sym->name);
break; break;
} }
break; break;
...@@ -849,12 +853,14 @@ int conf_write_autoconf(void) ...@@ -849,12 +853,14 @@ int conf_write_autoconf(void)
case S_HEX: case S_HEX:
str = sym_get_string_value(sym); str = sym_get_string_value(sym);
if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); fprintf(out_h, "#define %s%s 0x%s\n",
CONFIG_, sym->name, str);
break; break;
} }
case S_INT: case S_INT:
str = sym_get_string_value(sym); str = sym_get_string_value(sym);
fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); fprintf(out_h, "#define %s%s %s\n",
CONFIG_, sym->name, str);
break; break;
default: default:
break; break;
......
...@@ -37,6 +37,9 @@ extern "C" { ...@@ -37,6 +37,9 @@ extern "C" {
#define _(text) gettext(text) #define _(text) gettext(text)
#define N_(text) (text) #define N_(text) (text)
#ifndef CONFIG_
#define CONFIG_ "CONFIG_"
#endif
#define TF_COMMAND 0x0001 #define TF_COMMAND 0x0001
#define TF_PARAM 0x0002 #define TF_PARAM 0x0002
......
...@@ -316,8 +316,8 @@ static void search_conf(void) ...@@ -316,8 +316,8 @@ static void search_conf(void)
again: again:
dialog_clear(); dialog_clear();
dres = dialog_inputbox(_("Search Configuration Parameter"), dres = dialog_inputbox(_("Search Configuration Parameter"),
_("Enter CONFIG_ (sub)string to search for " _("Enter " CONFIG_ " (sub)string to search for "
"(with or without \"CONFIG\")"), "(with or without \"" CONFIG_ "\")"),
10, 75, ""); 10, 75, "");
switch (dres) { switch (dres) {
case 0: case 0:
...@@ -329,10 +329,10 @@ static void search_conf(void) ...@@ -329,10 +329,10 @@ static void search_conf(void)
return; return;
} }
/* strip CONFIG_ if necessary */ /* strip the prefix if necessary */
dialog_input = dialog_input_result; dialog_input = dialog_input_result;
if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
dialog_input += 7; dialog_input += strlen(CONFIG_);
sym_arr = sym_re_search(dialog_input); sym_arr = sym_re_search(dialog_input);
res = get_relations_str(sym_arr); res = get_relations_str(sym_arr);
......
...@@ -566,7 +566,7 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help) ...@@ -566,7 +566,7 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help)
if (menu_has_help(menu)) { if (menu_has_help(menu)) {
if (sym->name) { if (sym->name) {
str_printf(help, "CONFIG_%s:\n\n", sym->name); str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
str_append(help, _(menu_get_help(menu))); str_append(help, _(menu_get_help(menu)));
str_append(help, "\n"); str_append(help, "\n");
} }
......
...@@ -744,8 +744,8 @@ static void search_conf(void) ...@@ -744,8 +744,8 @@ static void search_conf(void)
again: again:
dres = dialog_inputbox(main_window, dres = dialog_inputbox(main_window,
_("Search Configuration Parameter"), _("Search Configuration Parameter"),
_("Enter CONFIG_ (sub)string to search for " _("Enter " CONFIG_ " (sub)string to search for "
"(with or without \"CONFIG\")"), "(with or without \"" CONFIG_ "\")"),
"", dialog_input_result, 99); "", dialog_input_result, 99);
switch (dres) { switch (dres) {
case 0: case 0:
...@@ -758,10 +758,10 @@ static void search_conf(void) ...@@ -758,10 +758,10 @@ static void search_conf(void)
return; return;
} }
/* strip CONFIG_ if necessary */ /* strip the prefix if necessary */
dialog_input = dialog_input_result; dialog_input = dialog_input_result;
if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
dialog_input += 7; dialog_input += strlen(CONFIG_);
sym_arr = sym_re_search(dialog_input); sym_arr = sym_re_search(dialog_input);
res = get_relations_str(sym_arr); res = get_relations_str(sym_arr);
...@@ -1261,7 +1261,7 @@ static void show_help(struct menu *menu) ...@@ -1261,7 +1261,7 @@ static void show_help(struct menu *menu)
if (menu && menu->sym && menu_has_help(menu)) { if (menu && menu->sym && menu_has_help(menu)) {
if (menu->sym->name) { if (menu->sym->name) {
str_printf(&help, "CONFIG_%s:\n\n", menu->sym->name); str_printf(&help, "%s%s:\n\n", CONFIG_, menu->sym->name);
str_append(&help, _(menu_get_help(menu))); str_append(&help, _(menu_get_help(menu)));
str_append(&help, "\n"); str_append(&help, "\n");
get_symbol_str(&help, menu->sym); get_symbol_str(&help, menu->sym);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment