Skip to contentSkip to conversation

kconfig frontend updates

PATCH In review Sam Ravnborg 4 participants 18 messages May 2, 2008 – May 10, 2008

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

The following patchset implments the following:

o Inputfiles to all*config can be specified with K=
o less chatty oldconfig mode
o Drop useless warnings

This is work-in-progress aimed for next mergewindow. Posted here mainly to get some feedback and a bit of review.

Patches follows to lkml + kbuild lists

Sam

#1 lore raw

PATCH 1/1 kconfig: add support for K=file

From: Sam Ravnborg <[email protected]>

Input file to all*config, randconfig and defconfig can be specified using the environment variable 'K'. It is expected to be used like this:

make K=my_config alldefconfig

This replaces the KCONFIL_ALLCONFIG support
and the input files named: all*.config

---
 scripts/kconfig/Makefile |   31 ++---
 scripts/kconfig/aconf.c  |  316 ++++++++++++++++++++++++++++++++++++++++++++++
 scripts/kconfig/aconf.sh |   30 +++++
 3 files changed, 360 insertions(+), 17 deletions(-)
 create mode 100644 scripts/kconfig/aconf.c
 create mode 100755 scripts/kconfig/aconf.sh
scripts/kconfig/Makefile +14 -17
index fa1a7d5..3e560a4 100644
@@ -47,30 +47,25 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
 	$(Q)rm -f arch/um/Kconfig.arch
 	$(Q)rm -f $(obj)/config.pot
 
-PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
+aconf-targets := allnoconfig allyesconfig allmodconfig alldefconfig randconfig
+PHONY += $(aconf-targets) defconfig
 
-randconfig: $(obj)/conf
-	$< -r $(Kconfig)
+$(aconf-targets): $(src)/aconf.sh $(obj)/aconf
+	$(Q)$(CONFIG_SHELL) $< $@ $(Kconfig)
 
-allyesconfig: $(obj)/conf
-	$< -y $(Kconfig)
+%_defconfig: $(src)/aconf.sh $(obj)/aconf
+	$(Q)K=arch/$(SRCARCH)/configs/$@ \
+	$(CONFIG_SHELL) $< alldefconfig $(Kconfig)
 
-allnoconfig: $(obj)/conf
-	$< -n $(Kconfig)
-
-allmodconfig: $(obj)/conf
-	$< -m $(Kconfig)
-
-defconfig: $(obj)/conf
 ifeq ($(KBUILD_DEFCONFIG),)
+defconfig: $(obj)/conf
 	$< -d $(Kconfig)
 else
-	@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
-	$(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
+defconfig: $(src)/aconf.sh $(obj)/aconf
+	$(Q)K=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) \
+	$(CONFIG_SHELL) $< alldefconfig $(Kconfig)
 endif
 
-%_defconfig: $(obj)/conf
-	$(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig)
 
 # Help text used by make help
 help:
@@ -100,6 +95,7 @@ HOST_EXTRACFLAGS += -DLOCALE
 # ===========================================================================
 # Shared Makefile for the various kconfig executables:
 # conf:	  Used for defconfig, oldconfig and related targets
+# aconf:  Generate simple configurations (all*config, etc)
 # mconf:  Used for the mconfig target.
 #         Utilizes the lxdialog package
 # qconf:  Used for the xconfig target
@@ -112,10 +108,11 @@ lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
 lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
 
 conf-objs	:= conf.o  zconf.tab.o
+aconf-objs	:= aconf.o zconf.tab.o
 mconf-objs	:= mconf.o zconf.tab.o $(lxdialog)
 kxgettext-objs	:= kxgettext.o zconf.tab.o
 
-hostprogs-y := conf qconf gconf kxgettext
+hostprogs-y := conf aconf qconf gconf kxgettext
 
 ifeq ($(MAKECMDGOALS),menuconfig)
 	hostprogs-y += mconf
scripts/kconfig/aconf.c new file +316 -0

316 lines not on this page · raw message

scripts/kconfig/aconf.sh new file +30 -0
new file mode 100755
index 0000000..c46a868
@@ -0,0 +1,30 @@
+#!/bin/sh
+set -e
+aconf=scripts/kconfig/aconf
+# Find input file
+if [ ! -z $K ]; then
+	config_file="-i $K";
+fi
+
+case "$1" in
+	"allnoconfig")
+		$aconf -n $config_file $2
+		;;
+	"allyesconfig")
+		$aconf -y $config_file $2
+		;;
+	"allmodconfig")
+		$aconf -m $config_file $2
+		;;
+	"alldefconfig")
+		$aconf -d $config_file $2
+		;;
+	"randconfig")
+		$aconf -r $config_file $2
+		;;
+	*)
+		echo "$0: unknow command $1"
+		exit 1
+	;;
+esac
+
Signature · 1 line
1.5.4.1.143.ge7e51
#2 lore raw

PATCH 1/1 kconfig: drop all*config support in conf.c

From: Sam Ravnborg <[email protected]>

With the introduction of aconf we can now kill all the old all*config support code in conf.c Modified Makefile so defconfig is now handled by aconf always.
This removed the feature that kconfig could look up a default configuration in one of the files listed in DEFCONFIG_LIST.
But this was only used by archs that did not define KBUILD_DEFCONFIG so no harm done.

---
 scripts/kconfig/Makefile |   12 ++--
 scripts/kconfig/conf.c   |  128 +---------------------------------------------
 2 files changed, 7 insertions(+), 133 deletions(-)
scripts/kconfig/Makefile +6 -6
index 3e560a4..47d5df8 100644
@@ -57,14 +57,14 @@ $(aconf-targets): $(src)/aconf.sh $(obj)/aconf
 	$(Q)K=arch/$(SRCARCH)/configs/$@ \
 	$(CONFIG_SHELL) $< alldefconfig $(Kconfig)
 
-ifeq ($(KBUILD_DEFCONFIG),)
-defconfig: $(obj)/conf
-	$< -d $(Kconfig)
-else
+defconfig-file := $(if $(KBUILD_DEFCONFIG),            \
+        arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG),   \
+        arch/$(SRCARCH)/defconfig)
+defconfig-file := $(strip $(defconfig-file))
+
 defconfig: $(src)/aconf.sh $(obj)/aconf
-	$(Q)K=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) \
+	$(Q)K=$(defconfig-file) \
 	$(CONFIG_SHELL) $< alldefconfig $(Kconfig)
-endif
 
 
 # Help text used by make help
scripts/kconfig/conf.c +1 -127

189 lines not on this page · raw message

Signature · 1 line
1.5.4.1.143.ge7e51
#3 lore raw

PATCH 1/1 kconfig: conf is less chatty

From: Sam Ravnborg <[email protected]>

No one really used the output generated during a
oldconfig run. So drop it and behave like the
old 'silentoldconfig' always did.

---
 Makefile                 |    2 +-
 scripts/kconfig/Makefile |    5 +----
 scripts/kconfig/conf.c   |   42 ++++++++++++++----------------------------
 3 files changed, 16 insertions(+), 33 deletions(-)
Makefile +1 -1
index d3634cd..99fcf12 100644
@@ -473,7 +473,7 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
 # we execute the config step to be sure to catch updated Kconfig files
 include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
-	$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
+	$(Q)$(MAKE) -f $(srctree)/Makefile oldconfig
 else
 # external modules needs include/linux/autoconf.h and include/config/auto.conf
 # but do not care if they are up-to-date. Use auto.conf to trigger the test
scripts/kconfig/Makefile +1 -4
index 47d5df8..1ccd584 100644
@@ -18,12 +18,9 @@ menuconfig: $(obj)/mconf
 config: $(obj)/conf
 	$< $(Kconfig)
 
-oldconfig: $(obj)/conf
+oldconfig silentoldconfig: $(obj)/conf
 	$< -o $(Kconfig)
 
-silentoldconfig: $(obj)/conf
-	$< -s $(Kconfig)
-
 # Create new linux.pot file
 # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
 # The symlink is used to repair a deficiency in arch/um
scripts/kconfig/conf.c +14 -28

116 lines not on this page · raw message

Signature · 1 line
1.5.4.1.143.ge7e51
#4 lore raw

PATCH 1/1 kconfig: .gitignore aconf

From: Sam Ravnborg <[email protected]>

---
 scripts/kconfig/.gitignore |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
scripts/kconfig/.gitignore +1 -0
index b49584c..ae664f9 100644
@@ -13,6 +13,7 @@ lkc_defs.h
 # configuration programs
 #
 conf
+aconf
 mconf
 qconf
 gconf
Signature · 1 line
1.5.4.1.143.ge7e51
#5 lore raw

PATCH 1/1 kconfig: kill the warning "trying to assign nonexistent symbol"

From: Sam Ravnborg <[email protected]>

The warning is only annoying and not used.
So drop it.

---
 scripts/kconfig/confdata.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
scripts/kconfig/confdata.c +2 -6
index ee5fe94..ea44754 100644
@@ -222,10 +222,8 @@ load:
 				continue;
 			if (def == S_DEF_USER) {
 				sym = sym_find(line + 9);
-				if (!sym) {
-					conf_warning("trying to assign nonexistent symbol %s", line + 9);
+				if (!sym)
 					break;
-				}
 			} else {
 				sym = sym_lookup(line + 9, 0);
 				if (sym->type == S_UNKNOWN)
@@ -261,10 +259,8 @@ load:
 			}
 			if (def == S_DEF_USER) {
 				sym = sym_find(line + 7);
-				if (!sym) {
-					conf_warning("trying to assign nonexistent symbol %s", line + 7);
+				if (!sym)
 					break;
-				}
 			} else {
 				sym = sym_lookup(line + 7, 0);
 				if (sym->type == S_UNKNOWN)
Signature · 1 line
1.5.4.1.143.ge7e51
#6 lore raw

Re: [PATCH] kconfig: add support for K=file

In reply to [email protected]

Sam Ravnborg @ Fri, 2 May 2008 22:49:14 +0200:

Quoted 30 lines

From: Sam Ravnborg <[email protected]>

scripts/kconfig/aconf.sh new file +25 -0
+defconfig: $(src)/aconf.sh $(obj)/aconf
+	$(Q)K=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) \
+	$(CONFIG_SHELL) $< alldefconfig $(Kconfig)
 
+# aconf:  Generate simple configurations (all*config, etc)
 
+++ b/scripts/kconfig/aconf.sh
 
+#!/bin/sh
+set -e
+aconf=scripts/kconfig/aconf
+# Find input file
+if [ ! -z $K ]; then
+	config_file="-i $K";
+fi
+
+case "$1" in
+	"allnoconfig")
+		$aconf -n $config_file $2
+		;;
+	"allyesconfig")
+		$aconf -y $config_file $2
+		;;
+	"allmodconfig")
+		$aconf -m $config_file $2
+		;;
+	"alldefconfig")
+		$aconf -d $config_file $2

scripts/kconfig/aconf.sh line 30

Quoted 10 lines
scripts/kconfig/aconf.sh new file +10 -0
+		;;
+	"randconfig")
+		$aconf -r $config_file $2
+		;;
+	*)
+		echo "$0: unknow command $1"
+		exit 1
+	;;
+esac
+

#!/bin/sh
set -e

aconf="$src_tree/scripts/kconfig/aconf -"
case $1 in

	# and typing of "allbalblabla" is a bit easier: "allb"
	all[mynd]*)
		# add command char using multicores :), yes string
                # processing in shell kind of sucks
		aconf="${aconf}`echo $1 | sed 's ^all\(.\).* \1 '`"
		;;
	rand*)
		aconf="${aconf}r"
		;;
	*)      # fix typo and redirect to stderr
		echo "$0: unknown command \`$1'" >&2
		exit 1
	;;
esac

# Find input file
[ "$K" ] && aconf="$aconf -i $K"

# remove command from parameters
shift 1
# execute with all other parameters
$aconf "$@"
# end

What about something like that (not tested)? There are some fixes and i'm not sure about if "$K" is empty what to do with "$config_file".

Signature · 4 lines
sed 'sed && sh + olecom = love' << ''
-o--=O`C
 #oo'L O
<___=E M
#7 lore raw

Re: [PATCH] kconfig: add support for K=file

Quoted 70 lines · Oleg Verych

Sam Ravnborg @ Fri, 2 May 2008 22:49:14 +0200:

Quoted 30 lines

From: Sam Ravnborg <[email protected]>

scripts/kconfig/aconf.sh new file +25 -0
+defconfig: $(src)/aconf.sh $(obj)/aconf
+	$(Q)K=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) \
+	$(CONFIG_SHELL) $< alldefconfig $(Kconfig)
 
+# aconf:  Generate simple configurations (all*config, etc)
 
+++ b/scripts/kconfig/aconf.sh
 
+#!/bin/sh
+set -e
+aconf=scripts/kconfig/aconf
+# Find input file
+if [ ! -z $K ]; then
+	config_file="-i $K";
+fi
+
+case "$1" in
+	"allnoconfig")
+		$aconf -n $config_file $2
+		;;
+	"allyesconfig")
+		$aconf -y $config_file $2
+		;;
+	"allmodconfig")
+		$aconf -m $config_file $2
+		;;
+	"alldefconfig")
+		$aconf -d $config_file $2

scripts/kconfig/aconf.sh line 30

Quoted 10 lines
scripts/kconfig/aconf.sh new file +10 -0
+		;;
+	"randconfig")
+		$aconf -r $config_file $2
+		;;
+	*)
+		echo "$0: unknow command $1"
+		exit 1
+	;;
+esac
+

#!/bin/sh
set -e

aconf="$src_tree/scripts/kconfig/aconf -"
case $1 in

	# and typing of "allbalblabla" is a bit easier: "allb"
	all[mynd]*)
		# add command char using multicores :), yes string
                # processing in shell kind of sucks
		aconf="${aconf}`echo $1 | sed 's ^all\(.\).* \1 '`"
		;;
	rand*)
		aconf="${aconf}r"
		;;
	*)      # fix typo and redirect to stderr
		echo "$0: unknown command \`$1'" >&2
		exit 1
	;;
esac

# Find input file
[ "$K" ] && aconf="$aconf -i $K"

# remove command from parameters
shift 1
Quoted 6 lines
# execute with all other parameters
$aconf "$@"
# end

What about something like that (not tested)? There are some fixes and i'm not sure about if "$K" is empty what to do with "$config_file".

I killed that shell script in a later patch and now aconf recognize the named option.

But the serie needs to be redone anyway - so lets see what I come up with.

Sam

#8 lore raw

Re: [PATCH] kconfig: add support for K=file

Sam Ravnborg @ Sat, 10 May 2008 23:10:07 +0200

Quoted 2 lines

I killed that shell script in a later patch and now aconf recognize the named option.

Well, good example of wasting time without any kind of patch-tracking system. At least git-mail-notification in the thread about reverts of whole patches and drops of particular files/changes (per patch basis)...

Or maybe just to start using git (with all that traffic fun)?
____

#9 lore raw
In reply to Sam Ravnborg
Quoted 11 lines · Sam Ravnborg

The following patchset implments the following:

o Inputfiles to all*config can be specified with K=
o less chatty oldconfig mode
o Drop useless warnings

This is work-in-progress aimed for next mergewindow. Posted here mainly to get some feedback and a bit of review.

Patches follows to lkml + kbuild lists

git added a bad email address in cc:
Just ignore the error or edit away the
"[email protected]" address.

git config is fixed so it should not happen again.

Sam

#10 lore raw
In reply to Sam Ravnborg
Quoted 9 lines · Sam Ravnborg

The following patchset implments the following:

o Inputfiles to all*config can be specified with K=
o less chatty oldconfig mode
o Drop useless warnings

This is work-in-progress aimed for next mergewindow. Posted here mainly to get some feedback and a bit of review.

New set of patches (2) will follow.
The warning "trying to assign nonexistent symbol" remains for now. I do not want to mix the two things.

The patches are also pushed to kbuild.git so they will appear in -next and -mm.
Let's see how many scripts will break due to this ;-)

Comments /testing welcome.

Sam

#11 lore raw

PATCH 1/2 kconfig: introduce K= support

From 9122065d7fe0c8a9823794e91b16b2493122df80 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Sun, 4 May 2008 20:32:11 +0200
Subject: [PATCH] kconfig: introduce K= support

The base configuration can now be specified for the targets: randconfig, all*config using following syntax:

make K=base-config allnoconfig

The configuration will be based on the file base-config.

Also add a new target: alldefconfig
alldefconfig will set all values to default vaules.

Make defconfig has changed such that it only searches KBUILD_DEFCONFIG or arch/$ARCH/defconfig for the baseconfig.

The verbose output generated as part of an
randconfig, all*config build has been dropped.

To implement this a new program 'aconf' is used which is based on conf.c.

---
 README                     |   28 ++--
 scripts/kconfig/.gitignore |    1 +
 scripts/kconfig/Makefile   |   72 ++++++-----
 scripts/kconfig/aconf.c    |  317 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 374 insertions(+), 44 deletions(-)
 create mode 100644 scripts/kconfig/aconf.c
README +15 -13
index 159912c..f31f19b 100644
@@ -171,11 +171,9 @@ CONFIGURING the kernel:
 	"make oldconfig"   Default all questions based on the contents of
 			   your existing ./.config file and asking about
 			   new config symbols.
-	"make silentoldconfig"
-			   Like above, but avoids cluttering the screen
-			   with questions already answered.
-	"make defconfig"   Create a ./.config file by using the default
-			   symbol values from arch/$ARCH/defconfig.
+	"make defconfig"   Create a ./.config file by using the base
+			   configuration found in the file specified by
+			   the environment variable KBUILD_DEFCONFIG.
 	"make allyesconfig"
 			   Create a ./.config file by setting symbol
 			   values to 'y' as much as possible.
@@ -184,17 +182,21 @@ CONFIGURING the kernel:
 			   values to 'm' as much as possible.
 	"make allnoconfig" Create a ./.config file by setting symbol
 			   values to 'n' as much as possible.
+	"make alldefconfig"
+			   Create a configuration with default values.
 	"make randconfig"  Create a ./.config file by setting symbol
 			   values to random values.
 
-   The allyesconfig/allmodconfig/allnoconfig/randconfig variants can
-   also use the environment variable KCONFIG_ALLCONFIG to specify a
-   filename that contains config options that the user requires to be
-   set to a specific value.  If KCONFIG_ALLCONFIG=filename is not used,
-   "make *config" checks for a file named "all{yes/mod/no/random}.config"
-   for symbol values that are to be forced.  If this file is not found,
-   it checks for a file named "all.config" to contain forced values.
-   
+   The allyesconfig/allmodconfig/allnoconfig/alldefconfig/randconfig
+   variants can be tweaked using a base confguration that can be
+   set either using the syntax:
+
+	make K=base-config allnoconfig
+
+   Or using the environment variable KCONFIG_ALLCONFIG.
+   K= in the example is also used as an environment variable and an
+   assignment to K takes precendence over a KCONFIG_ALLCONFIG assignment.
+
 	NOTES on "make config":
 	- having unnecessary drivers will make the kernel bigger, and can
 	  under some circumstances lead to problems: probing for a
scripts/kconfig/.gitignore +1 -0
index b49584c..ae664f9 100644
@@ -13,6 +13,7 @@ lkc_defs.h
 # configuration programs
 #
 conf
+aconf
 mconf
 qconf
 gconf
scripts/kconfig/Makefile +41 -31

100 lines not on this page · raw message

scripts/kconfig/aconf.c new file +317 -0

317 lines not on this page · raw message

Signature · 1 line
1.5.4.1.143.ge7e51
#12 lore raw

Re: [PATCH 1/2] kconfig: introduce K= support

Hi,

On Sun, 4 May 2008, Sam Ravnborg wrote:

Below is patch which adds a library function to set the default values in a much simpler way.
The behaviour is slightly different, now it's closer to generating a .config with all possible symbols set to some value and using that to generate the final config. It has the advantage of not being as dependend on the order of the symbols, e.g. with allmodconfig this sets a few more symbols to 'm'.

Review

Quoted 6 lines
(quoted diff) +6 -0
+# An arch may use KBUILD_DEFCONFIG to specify defconfig file
+# fallback to arch/$ARCH/defconfig
+defconfig-file := $(if $(KBUILD_DEFCONFIG),            \
+        arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG),   \
+        arch/$(SRCARCH)/defconfig)
+defconfig-file := $(strip $(defconfig-file))

init/Kconfig has a DEFCONFIG_LIST which is intended to be used for this.

Quoted 15 lines
(quoted diff) +15 -0
+	if (ac < 2) {
+		usage();
+		exit(1);
+	}
+	if (strcmp(av[1], "allnoconfig") == 0)
+		default_value = set_no;
+	else if (strcmp(av[1], "allyesconfig") == 0)
+		default_value = set_yes;
+	else if (strcmp(av[1], "allmodconfig") == 0)
+		default_value = set_mod;
+	else if (strcmp(av[1], "alldefconfig") == 0)
+		default_value = set_default;
+	else if (strcmp(av[1], "randconfig") == 0) {
+		default_value = set_random;
+		srand(time(NULL));

Review

Quoted 10 lines
(quoted diff) +10 -0
+	} else {
+		usage();
+		exit(1);
+	}
+	if (strcmp(av[2], "-b") == 0) {
+		config_file = av[3];
+		kconfig_file = av[4];
+	} else {
+		kconfig_file = av[2];
+	}

Even if it has only a single option, please keep using getopt().

bye, Roman

[PATCH] set all new symbols automatically

Add conf_set_all_new_symbols() which set all symbols (which don't have a value yet) to a specifed value.

---
 scripts/kconfig/confdata.c |   72 ++++++++++++++++++++++++++++++++++++++++++++-
 scripts/kconfig/lkc.h      |    9 +++++
 2 files changed, 80 insertions(+), 1 deletion(-)
scripts/kconfig/confdata.c +71 -1
Index: linux-2.6/scripts/kconfig/confdata.c
===================================================================
@@ -510,7 +510,7 @@ int conf_write(const char *name)
 			case S_HEX:
 				str = sym_get_string_value(sym);
 				if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
-					fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
+					fprintf(out, "CONFIG_%s=0x%s\n", sym->name, str);
 					break;
 				}
 			case S_INT:
@@ -812,3 +812,73 @@ void conf_set_changed_callback(void (*fn
 {
 	conf_changed_callback = fn;
 }
+
+
+void conf_set_all_new_symbols(enum conf_def_mode mode)
+{
+	struct symbol *sym, *csym;
+	struct property *prop;
+	struct expr *e;
+	int i, cnt, def;
+
+	for_all_symbols(i, sym) {
+		if (sym_has_value(sym))
+			continue;
+		switch (sym_get_type(sym)) {
+		case S_BOOLEAN:
+		case S_TRISTATE:
+			switch (mode) {
+			case def_yes:
+				sym->def[S_DEF_USER].tri = yes;
+				break;
+			case def_mod:
+				sym->def[S_DEF_USER].tri = mod;
+				break;
+			case def_no:
+				sym->def[S_DEF_USER].tri = no;
+				break;
+			case def_random:
+				sym->def[S_DEF_USER].tri = (tristate)(rand() % 3);
+				break;
+			default:
+				continue;
+			}
+			if (!sym_is_choice(sym) || mode != def_random)
+				sym->flags |= SYMBOL_DEF_USER;
+			break;
+		default:
+			break;
+		}
+
+	}
+
+	if (modules_sym)
+		sym_calc_value(modules_sym);
+
+	if (mode != def_random)
+		return;
+
+	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;
+	}
+}
scripts/kconfig/lkc.h +9 -0
Index: linux-2.6/scripts/kconfig/lkc.h
===================================================================
@@ -42,6 +42,14 @@ extern "C" {
 #define TF_PARAM	0x0002
 #define TF_OPTION	0x0004
 
+enum conf_def_mode {
+	def_default,
+	def_yes,
+	def_mod,
+	def_no,
+	def_random
+};
+
 #define T_OPT_MODULES		1
 #define T_OPT_DEFCONFIG_LIST	2
 #define T_OPT_ENV		3
@@ -69,6 +77,7 @@ const char *conf_get_configname(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);
 
 /* kconfig_load.c */
 void kconfig_load(void);
#13 lore raw

Re: [PATCH 1/2] kconfig: introduce K= support

Quoted 11 lines · Roman Zippel

Hi,

On Sun, 4 May 2008, Sam Ravnborg wrote:

Below is patch which adds a library function to set the default values in a much simpler way.
The behaviour is slightly different, now it's closer to generating a .config with all possible symbols set to some value and using that to generate the final config. It has the advantage of not being as dependend on the order of the symbols, e.g. with allmodconfig this sets a few more symbols to 'm'.

Thanks. I will rework the patch to use this function.

Quoted 9 lines

Review

Quoted 7 lines
(quoted diff) +6 -0
+# An arch may use KBUILD_DEFCONFIG to specify defconfig file
+# fallback to arch/$ARCH/defconfig
+defconfig-file := $(if $(KBUILD_DEFCONFIG),            \
+        arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG),   \
+        arch/$(SRCARCH)/defconfig)
+defconfig-file := $(strip $(defconfig-file))

init/Kconfig has a DEFCONFIG_LIST which is intended to be used for this.

The plan is to drop arch/$(SRCARCH)/defconfig and solely rely on KBUILD_DEFCONFIG.
And I see KBUILD_DEFCONFIG thus for a "make defconfig" the DEFCONFIG_LIST becomes unused.

But I guess your point is that we should dropt KBUILD_DEFCONFIG entirely and rely on DEFCONFIG_LIST instead.

I will try it out.

Quoted 20 lines
Quoted 20 lines
(quoted diff) +19 -0
+	if (ac < 2) {
+		usage();
+		exit(1);
+	}
+	if (strcmp(av[1], "allnoconfig") == 0)
+		default_value = set_no;
+	else if (strcmp(av[1], "allyesconfig") == 0)
+		default_value = set_yes;
+	else if (strcmp(av[1], "allmodconfig") == 0)
+		default_value = set_mod;
+	else if (strcmp(av[1], "alldefconfig") == 0)
+		default_value = set_default;
+	else if (strcmp(av[1], "randconfig") == 0) {
+		default_value = set_random;
+		srand(time(NULL));
+	} else {
+		usage();
+		exit(1);
+	}
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+	if (strcmp(av[2], "-b") == 0) {
+		config_file = av[3];
+		kconfig_file = av[4];
+	} else {
+		kconfig_file = av[2];
+	}

Even if it has only a single option, please keep using getopt().

OK.

Thanks for your feedback.
PS. I will post the updated patches in the weekend. Not that they are difficult but I'm on the way out of the door for a few days travelling.

Sam

#14 lore raw

PATCH 2/2 kconfig: make oldconfig less chatty and clean up conf.c

In reply to Sam Ravnborg

From 48ff933e08c7c5b625a82ffdae5ece9c0f4e0a87 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Sun, 4 May 2008 20:50:14 +0200
Subject: [PATCH] kconfig: make oldconfig less chatty and clean up conf.c

Moving randconfg, all*config support to aconf.c allowed conf.c to be cleaned up.
While cleaning up conf.c the chatty oldconfig mode was killed and conf.c is now only used for two purposes:

make config:
Interactively ask for each config option

make oldconfig
Interactively ask for each new config option

We now check for valid stadin in both cases and this may break a script here and there.

---
 Makefile                 |    2 +-
 scripts/kconfig/Makefile |    5 +-
 scripts/kconfig/conf.c   |  168 ++++------------------------------------------
 3 files changed, 16 insertions(+), 159 deletions(-)
Makefile +1 -1
index 4492984..1e91804 100644
@@ -473,7 +473,7 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
 # we execute the config step to be sure to catch updated Kconfig files
 include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
-	$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
+	$(Q)$(MAKE) -f $(srctree)/Makefile oldconfig
 else
 # external modules needs include/linux/autoconf.h and include/config/auto.conf
 # but do not care if they are up-to-date. Use auto.conf to trigger the test
scripts/kconfig/Makefile +1 -4
index 70b329d..fa4f746 100644
@@ -18,12 +18,9 @@ menuconfig: $(obj)/mconf
 config: $(obj)/conf
 	$< $(Kconfig)
 
-oldconfig: $(obj)/conf
+oldconfig silentoldconfig: $(obj)/conf
 	$< -o $(Kconfig)
 
-silentoldconfig: $(obj)/conf
-	$< -s $(Kconfig)
-
 # Create new linux.pot file
 # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
 # The symlink is used to repair a deficiency in arch/um
scripts/kconfig/conf.c +14 -154

260 lines not on this page · raw message

Signature · 1 line
1.5.4.1.143.ge7e51
#15 lore raw

Re: [PATCH 2/2] kconfig: make oldconfig less chatty and clean up conf.c

Hi,

Quoted 2 lines · Sam Ravnborg

We now check for valid stadin in both cases and this may break a script here and there.

I strongly disagree with this, please preserve the old behaviour. It took a while to work out the current behaviour.
Only silentoldconfig checks for stdin because it's used as hook during kbuild to verify the config. For all other interactive targets the user has to know what he's doing, e.g. it's valid to do "yes '' | make oldconfig".

Quoted 5 lines
scripts/kconfig/conf.c +0 -5
-		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;

scripts/kconfig/conf.c int main(int ac, char **av) · line 465

Quoted 10 lines
scripts/kconfig/conf.c +0 -9
-		default: break;
-		}
-		if (!stat(name, &tmpstat))
-			conf_read_simple(name, S_DEF_USER);
-		else if (!stat("all.config", &tmpstat))
-			conf_read_simple("all.config", S_DEF_USER);
-		break;
-	default:
-		break;
 	}

This isn't yet in aconf.c.

bye, Roman

#16 lore raw

Re: [PATCH 2/2] kconfig: make oldconfig less chatty and clean up conf.c

Quoted 7 lines · Roman Zippel

Hi,

Quoted 2 lines · Sam Ravnborg

We now check for valid stadin in both cases and this may break a script here and there.

Quoted 6 lines

I strongly disagree with this, please preserve the old behaviour. It took a while to work out the current behaviour.
Only silentoldconfig checks for stdin because it's used as hook during kbuild to verify the config. For all other interactive targets the user has to know what he's doing, e.g. it's valid to do "yes '' | make oldconfig".

I will test a bit more and may revert to the old behaviour. One good thing with the new behaviour is that
make oldconfig > /dev/null
does not hang if there is new symbols - and I would like to keep it so.

Quoted 10 lines
Quoted 10 lines
scripts/kconfig/conf.c +0 -9
-		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;
-		default: break;
-		}
-		if (!stat(name, &tmpstat))
-			conf_read_simple(name, S_DEF_USER);
Quoted 8 lines

scripts/kconfig/conf.c int main(int ac, char **av) · line 465

Quoted 6 lines
scripts/kconfig/conf.c +0 -5
-		else if (!stat("all.config", &tmpstat))
-			conf_read_simple("all.config", S_DEF_USER);
-		break;
-	default:
-		break;
 	}

This isn't yet in aconf.c.

On purpose. It is very very seldom used and with K=file it is now much easier to specify a base configuration. So no need for all the special filenames.

Sam

#17 lore raw

Re: [PATCH 2/2] kconfig: make oldconfig less chatty and clean up conf.c

In reply to Roman Zippel
Quoted 7 lines · Roman Zippel

I strongly disagree with this, please preserve the old behaviour. It took a while to work out the current behaviour.
Only silentoldconfig checks for stdin because it's used as hook during kbuild to verify the config. For all other interactive targets the user has to know what he's doing, e.g. it's valid to do "yes '' | make oldconfig".

Noting that yes | make oldconfig is often not the right thing anyway (you want modules most of the time) or does not even work (things that can only be modules [M/n] cannot take y).