@@ -162,6 +162,11 @@ KCONFIG_AUTOCONFIG
This environment variable can be set to specify the path & name of the
"auto.conf" file. Its default value is "include/config/auto.conf".
+KCONFIG_TRISTATE
+----------------
+This environment variable can be set to specify the path & name of the
+"tristate.conf" file. Its default value is "include/config/tristate.conf".
+
KCONFIG_AUTOHEADER
------------------
This environment variable can be set to specify the path & name of the
@@ -793,7 +793,7 @@ $(KCONFIG_CONFIG):
#
# Do not use $(call cmd,...) here. That would suppress prompts from syncconfig,
# so you cannot notice that Kconfig is waiting for the user input.
-%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h %/generated/rustc_cfg: $(KCONFIG_CONFIG)
+%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h %/generated/rustc_cfg %/tristate.conf: $(KCONFIG_CONFIG)
$(Q)$(kecho) " SYNC $@"
$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
else # !may-sync-config
@@ -223,6 +223,13 @@ static const char *conf_get_rustccfg_name(void)
return name ? name : "include/generated/rustc_cfg";
}
+static const char *conf_get_tristate_name(void)
+{
+ char *name = getenv("KCONFIG_TRISTATE");
+
+ return name ? name : "include/config/tristate.conf";
+}
+
static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
{
char *p2;
@@ -670,8 +677,12 @@ static char *escape_string_value(const char *in)
enum output_n { OUTPUT_N, OUTPUT_N_AS_UNSET, OUTPUT_N_NONE };
+#define PRINT_ESCAPE 0x01
+#define PRINT_UPCASE 0x02
+#define PRINT_TRISTATE_ONLY 0x04
+
static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
- bool escape_string)
+ int flags)
{
const char *val;
char *escaped = NULL;
@@ -679,6 +690,9 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
if (sym->type == S_UNKNOWN)
return;
+ if (flags & PRINT_TRISTATE_ONLY && sym->type != S_TRISTATE)
+ return;
+
val = sym_get_string_value(sym);
if ((sym->type == S_BOOLEAN || sym->type == S_TRISTATE) &&
@@ -688,29 +702,38 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
return;
}
- if (sym->type == S_STRING && escape_string) {
+ if (sym->type == S_STRING && flags & PRINT_ESCAPE) {
escaped = escape_string_value(val);
val = escaped;
}
- fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, val);
+ if (flags & PRINT_UPCASE)
+ fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*val));
+ else
+ fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, val);
free(escaped);
}
static void print_symbol_for_dotconfig(FILE *fp, struct symbol *sym)
{
- __print_symbol(fp, sym, OUTPUT_N_AS_UNSET, true);
+ __print_symbol(fp, sym, OUTPUT_N_AS_UNSET, PRINT_ESCAPE);
}
static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym)
{
- __print_symbol(fp, sym, OUTPUT_N_NONE, false);
+ __print_symbol(fp, sym, OUTPUT_N_NONE, 0);
+}
+
+static void print_symbol_for_tristate(FILE *fp, struct symbol *sym)
+{
+ __print_symbol(fp, sym, OUTPUT_N_NONE, PRINT_ESCAPE | PRINT_UPCASE |
+ PRINT_TRISTATE_ONLY);
}
void print_symbol_for_listconfig(struct symbol *sym)
{
- __print_symbol(stdout, sym, OUTPUT_N, true);
+ __print_symbol(stdout, sym, OUTPUT_N, PRINT_ESCAPE);
}
static void print_symbol_for_c(FILE *fp, struct symbol *sym)
@@ -1207,6 +1230,12 @@ int conf_write_autoconf(int overwrite)
if (ret)
return ret;
+ ret = __conf_write_autoconf(conf_get_tristate_name(),
+ print_symbol_for_tristate,
+ &comment_style_pound);
+ if (ret)
+ return ret;
+
/*
* Create include/config/auto.conf. This must be the last step because
* Kbuild has a dependency on auto.conf and this marks the successful