Skip to contentSkip to conversation

Kconfig add reportoldconfig and updateoldconfig targets

PATCH In review maximilian attems 4 participants 7 messages Sep 13, 2010 – Oct 2, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

From: Bastian Blank <[email protected]>

This patch has been around for a looong time in Debian kernels and might be useful for others. The reportoldconfig target is used for the official linux-2.6 image builds. It outputs to the build log the changed configs and sets any unset to it's default.

---

 scripts/kconfig/Makefile    |    8 ++-
 scripts/kconfig/conf.c      |   11 ++++
 scripts/kconfig/confdata.c  |   80 ++++++++++++++++++++++++++++++++++
 scripts/kconfig/expr.h      |    1 
 scripts/kconfig/lkc_proto.h |    1 
 5 files changed, 100 insertions(+), 1 deletion(-)
scripts/kconfig/Makefile +7 -1
index de934de..57e96aa 100644
@@ -3,7 +3,7 @@
 # These targets are used from top-level makefile
 
 PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \
-	localmodconfig localyesconfig
+	localmodconfig localyesconfig reportoldconfig updateoldconfig
 
 ifdef KBUILD_KCONFIG
 Kconfig := $(KBUILD_KCONFIG)
@@ -29,10 +29,16 @@ nconfig: $(obj)/nconf
 oldconfig: $(obj)/conf
 	$< --$@ $(Kconfig)
 
+reportoldconfig: $(obj)/conf
+	$< --$@ $(Kconfig)
+
 silentoldconfig: $(obj)/conf
 	$(Q)mkdir -p include/generated
 	$< --$@ $(Kconfig)
 
+updateoldconfig: $(obj)/conf
+	$< --$@ $(Kconfig)
+
 # if no path is given, then use src directory to find file
 ifdef LSMOD
 LSMOD_F := $(LSMOD)
scripts/kconfig/conf.c +11 -0
index 5b7c86e..9c2171c 100644
@@ -33,6 +33,8 @@ enum input_mode {
 	savedefconfig,
 	listnewconfig,
 	oldnoconfig,
+	reportoldconfig,
+	updateoldconfig,
 } input_mode = oldaskconfig;
 
 char *defconfig_file;
@@ -453,6 +455,8 @@ static struct option long_opts[] = {
 	{"randconfig",      no_argument,       NULL, randconfig},
 	{"listnewconfig",   no_argument,       NULL, listnewconfig},
 	{"oldnoconfig",     no_argument,       NULL, oldnoconfig},
+	{"reportoldconfig", no_argument,       NULL, reportoldconfig},
+	{"updateoldconfig", no_argument,       NULL, updateoldconfig},
 	{NULL, 0, NULL, 0}
 };
 
@@ -530,6 +534,8 @@ int main(int ac, char **av)
 		}
 		break;
 	case savedefconfig:
+	case reportoldconfig:
+	case updateoldconfig:
 		conf_read(NULL);
 		break;
 	case silentoldconfig:
@@ -595,6 +601,8 @@ int main(int ac, char **av)
 		conf_set_all_new_symbols(def_random);
 		break;
 	case defconfig:
+	case reportoldconfig:
+	case updateoldconfig:
 		conf_set_all_new_symbols(def_default);
 		break;
 	case savedefconfig:
@@ -618,6 +626,9 @@ int main(int ac, char **av)
 		break;
 	}
 
+	if (input_mode == reportoldconfig)
+		conf_write_changes();
+
 	if (sync_kconfig) {
 		/* silentoldconfig is used during the build so we shall update autoconf.
 		 * All other commands are only used to generate a config.
scripts/kconfig/confdata.c +80 -0

92 lines not on this page · raw message

scripts/kconfig/expr.h +1 -0
index 6ee2e4f..09a6a7c 100644
@@ -107,6 +107,7 @@ struct symbol {
 #define SYMBOL_DEF_AUTO   0x20000  /* symbol.def[S_DEF_AUTO] is valid */
 #define SYMBOL_DEF3       0x40000  /* symbol.def[S_DEF_3] is valid */
 #define SYMBOL_DEF4       0x80000  /* symbol.def[S_DEF_4] is valid */
+#define SYMBOL_NEW        0x100000
 
 #define SYMBOL_MAXLENGTH	256
 #define SYMBOL_HASHSIZE		9973
scripts/kconfig/lkc_proto.h +1 -0
index 9a948c9..d5aeb72 100644
@@ -6,6 +6,7 @@ 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_write_changes,void,(void));
 P(conf_get_changed,bool,(void));
 P(conf_set_changed_callback, void,(void (*fn)(void)));
 
#1 lore raw
Quoted 7 lines · maximilian attems

From: Bastian Blank <[email protected]>

This patch has been around for a looong time in Debian kernels and might be useful for others. The reportoldconfig target is used for the official linux-2.6 image builds. It outputs to the build log the changed configs and sets any unset to it's default.

2.6.26-rc1 has listnewconfig and oldnoconfig, which do more or less the same. And I think we have enough *config targets already, so unless there is a problem that is hard to solve with the current kconfig plus some scripting (*), I'd vote for not adding further special-purpose *config targets.

(*) Such as the defconfig cleanup that took hours with a brute-force python script, but was easily achieved by a patch that added the savedefconfig target.

Michal

#2 lore raw

PATCH 1/2 Kbuild: Treat KBUILD_DEFCONFIG=old as request to use .config as the base

---
This should work as a substitute for Debian's updateoldconfig.

Ben.

 scripts/kconfig/Makefile |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
scripts/kconfig/Makefile +4 -0
index cef3f75..19558a7 100644
@@ -112,9 +112,13 @@ defconfig: $(obj)/conf
 ifeq ($(KBUILD_DEFCONFIG),)
 	$< --defconfig $(Kconfig)
 else
+ifeq ($(KBUILD_DEFCONFIG),old)
+	$< --defconfig=.config $(Kconfig)
+else
 	@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
 	$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
 endif
+endif
 
 %_defconfig: $(obj)/conf
 	$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
Signature · 5 lines
1.7.1

-- 
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.
#3 lore raw

Re: [PATCH 1/2] Kbuild: Treat KBUILD_DEFCONFIG=old as request to use .config as the base

Quoted 14 lines · Ben Hutchings

---
This should work as a substitute for Debian's updateoldconfig.

Ben.

 scripts/kconfig/Makefile |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
scripts/kconfig/Makefile +0 -0
index cef3f75..19558a7 100644

scripts/kconfig/Makefile defconfig: $(obj)/conf · line 121

Quoted 10 lines
scripts/kconfig/Makefile +4 -0
@@ -112,9 +112,13 @@ defconfig: $(obj)/conf
 ifeq ($(KBUILD_DEFCONFIG),)
 	$< --defconfig $(Kconfig)
 else
+ifeq ($(KBUILD_DEFCONFIG),old)
+	$< --defconfig=.config $(Kconfig)
+else
 	@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
 	$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
 endif
+endif

KBUILD_DEFCONFIG is an internal variable used by arch Makefiles to select the defconfig file, it should not be abused for a completely different purpose. Also, the same can be achieved with 'make oldnoconfig' or 'yes "" | make oldconfig' in older kernels.

Michal

#4 lore raw

Re: [PATCH 1/2] Kbuild: Treat KBUILD_DEFCONFIG=old as request to use .config as the base

Quoted 21 lines · Michal Marek
Quoted 20 lines · Ben Hutchings

---
This should work as a substitute for Debian's updateoldconfig.

Ben.

 scripts/kconfig/Makefile |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
scripts/kconfig/Makefile +3 -0
index cef3f75..19558a7 100644
@@ -112,9 +112,13 @@ defconfig: $(obj)/conf
 ifeq ($(KBUILD_DEFCONFIG),)
 	$< --defconfig $(Kconfig)
 else
+ifeq ($(KBUILD_DEFCONFIG),old)
+	$< --defconfig=.config $(Kconfig)
+else
Quoted 8 lines

scripts/kconfig/Makefile defconfig: $(obj)/conf · line 121

Quoted 4 lines
scripts/kconfig/Makefile +1 -0
 	@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
 	$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
 endif
+endif

KBUILD_DEFCONFIG is an internal variable used by arch Makefiles to select the defconfig file, it should not be abused for a completely different purpose.

OK.

Quoted 2 lines

Also, the same can be achieved with 'make oldnoconfig' or 'yes "" | make oldconfig' in older kernels.

'make oldnoconfig' does something different - it answers N to all questions rather than accepting the default.

'yes "" | make oldconfig' does pretty much what we want, except that it's noisy. But personally I don't care that much about it. Max, Bastian, do you rely on this target?

Ben.

Signature · 2 lines
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.
#5 lore raw

Re: [PATCH 1/2] Kbuild: Treat KBUILD_DEFCONFIG=old as request to use .config as the base

Quoted 31 lines · Ben Hutchings
Quoted 21 lines · Michal Marek
Quoted 20 lines · Ben Hutchings

---
This should work as a substitute for Debian's updateoldconfig.

Ben.

 scripts/kconfig/Makefile |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
scripts/kconfig/Makefile +3 -0
index cef3f75..19558a7 100644
@@ -112,9 +112,13 @@ defconfig: $(obj)/conf
 ifeq ($(KBUILD_DEFCONFIG),)
 	$< --defconfig $(Kconfig)
 else
+ifeq ($(KBUILD_DEFCONFIG),old)
+	$< --defconfig=.config $(Kconfig)
+else
Quoted 8 lines

scripts/kconfig/Makefile defconfig: $(obj)/conf · line 121

Quoted 4 lines
scripts/kconfig/Makefile +1 -0
 	@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
 	$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
 endif
+endif

KBUILD_DEFCONFIG is an internal variable used by arch Makefiles to select the defconfig file, it should not be abused for a completely different purpose.

Quoted 7 lines

OK.

Quoted 2 lines

Also, the same can be achieved with 'make oldnoconfig' or 'yes "" | make oldconfig' in older kernels.

'make oldnoconfig' does something different - it answers N to all questions rather than accepting the default.

To get default value for all new options you can use:
KCONFIG_ALLCONFIG=.config make alldefconfig

Sam

#6 lore raw

PATCH 2/2 Kbuild: kconfig: Verbose version of --listnewconfig and --defconfig

In reply to Michal Marek

If the KBUILD_VERBOSE environment variable is set to non-zero, show the default values of new symbols and not just their names.

Also do that for --defconfig if KBUILD_VERBOSE is set.

Based on work by Bastian Blank <[email protected]> and maximilian attems <[email protected]>.

---
This should work as a substitute for Debian's reportoldconfig.

Ben.

 scripts/kconfig/conf.c     |   97 +++++++++++++++++++++++++++++++++++++++-----
 scripts/kconfig/confdata.c |    1 +
 scripts/kconfig/expr.h     |    2 +
 3 files changed, 90 insertions(+), 10 deletions(-)
scripts/kconfig/conf.c +87 -10
index 6968f5b..5bc4e16 100644
@@ -35,6 +35,8 @@ enum input_mode {
 	oldnoconfig,
 } input_mode = oldaskconfig;
 
+static bool verbose;
+
 char *defconfig_file;
 
 static int indent = 1;
@@ -363,7 +365,6 @@ static void conf(struct menu *menu)
 		switch (prop->type) {
 		case P_MENU:
 			if ((input_mode == silentoldconfig ||
-			     input_mode == listnewconfig ||
 			     input_mode == oldnoconfig) &&
 			    rootEntry != menu) {
 				check_conf(menu);
@@ -423,11 +424,7 @@ 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 (input_mode == listnewconfig) {
-				if (sym->name && !sym_is_choice_value(sym)) {
-					printf("CONFIG_%s\n", sym->name);
-				}
-			} else if (input_mode != oldnoconfig) {
+			if (input_mode != oldnoconfig) {
 				if (!conf_cnt++)
 					printf(_("*\n* Restart config...\n*\n"));
 				rootEntry = menu_get_parent_menu(menu);
@@ -440,6 +437,78 @@ static void check_conf(struct menu *menu)
 		check_conf(child);
 }
 
+static void report_conf(struct menu *menu)
+{
+	struct symbol *sym;
+	struct menu *child;
+	int l;
+	const char *str;
+
+	if (!menu_is_visible(menu))
+		return;
+
+	if (verbose && menu == &rootmenu) {
+		printf("\n#\n"
+		       "# Changes:\n"
+		       "#\n");
+	}
+
+	sym = menu->sym;
+	if (sym && (sym->flags & SYMBOL_NEW) &&
+	    sym_is_changable(sym) && sym->name && !sym_is_choice_value(sym)) {
+		if (verbose) {
+			switch (sym->type) {
+			case S_BOOLEAN:
+			case S_TRISTATE:
+				switch (sym_get_tristate_value(sym)) {
+				case no:
+					printf("# CONFIG_%s is not set\n", sym->name);
+					break;
+				case mod:
+					printf("CONFIG_%s=m\n", sym->name);
+					break;
+				case yes:
+					printf("CONFIG_%s=y\n", sym->name);
+					break;
+				}
+				break;
+			case S_STRING:
+				str = sym_get_string_value(sym);
+				printf("CONFIG_%s=\"", sym->name);
+				while (1) {
+					l = strcspn(str, "\"\\");
+					if (l) {
+						fwrite(str, l, 1, stdout);
+						str += l;
+					}
+					if (!*str)
+						break;
+					printf("\\%c", *str++);
+				}
+				fputs("\"\n", stdout);
+				break;
+			case S_HEX:
+				str = sym_get_string_value(sym);
+				if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
+					printf("CONFIG_%s=%s\n", sym->name, str);
+					break;
+				}
+			case S_INT:
+				str = sym_get_string_value(sym);
+				printf("CONFIG_%s=%s\n", sym->name, str);
+				break;
+                        default:
+                                break;
+			}
+		} else {
+			printf("CONFIG_%s\n", sym->name);
+		}
+	}
+
+	for (child = menu->list; child; child = child->next)
+		report_conf(child);
+}
+
 static struct option long_opts[] = {
 	{"oldaskconfig",    no_argument,       NULL, oldaskconfig},
 	{"oldconfig",       no_argument,       NULL, oldconfig},
@@ -460,12 +529,17 @@ int main(int ac, char **av)
 {
 	int opt;
 	const char *name;
+	const char *value;
 	struct stat tmpstat;
 
 	setlocale(LC_ALL, "");
 	bindtextdomain(PACKAGE, LOCALEDIR);
 	textdomain(PACKAGE);
 
+	value = getenv("KBUILD_VERBOSE");
+	if (value && atoi(value))
+		verbose = true;
+
 	while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) {
 		input_mode = (enum input_mode)opt;
 		switch (opt) {
@@ -596,6 +670,8 @@ int main(int ac, char **av)
 		break;
 	case defconfig:
 		conf_set_all_new_symbols(def_default);
+		if (verbose)
+			report_conf(&rootmenu);
 		break;
 	case savedefconfig:
 		break;
@@ -605,16 +681,17 @@ int main(int ac, char **av)
 		input_mode = silentoldconfig;
 		/* fall through */
 	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 &&
-			 (input_mode != listnewconfig &&
-			  input_mode != oldnoconfig));
+		} while (conf_cnt && input_mode != oldnoconfig);
+		break;
+	case listnewconfig:
+		conf_set_all_new_symbols(def_default);
+		report_conf(&rootmenu);
 		break;
 	}
 
scripts/kconfig/confdata.c +1 -0
index dc11d51..c626060 100644
@@ -992,6 +992,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
 	for_all_symbols(i, sym) {
 		if (sym_has_value(sym))
 			continue;
+		sym->flags |= SYMBOL_NEW;
 		switch (sym_get_type(sym)) {
 		case S_BOOLEAN:
 		case S_TRISTATE:
scripts/kconfig/expr.h +2 -0
index 6ee2e4f..c8f1934 100644
@@ -108,6 +108,8 @@ struct symbol {
 #define SYMBOL_DEF3       0x40000  /* symbol.def[S_DEF_3] is valid */
 #define SYMBOL_DEF4       0x80000  /* symbol.def[S_DEF_4] is valid */
 
+#define SYMBOL_NEW        0x100000 /* symbol is new (loaded config did not provide a value) */
+
 #define SYMBOL_MAXLENGTH	256
 #define SYMBOL_HASHSIZE		9973
 
Signature · 6 lines
1.7.1


-- 
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.