From 7cf3d73b4360e91b14326632ab1aeda4cb26308d Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 31 Jul 2010 23:35:34 +0200 Subject: kconfig: add savedefconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit savedefconfig will save a minimal config to a file named "defconfig". The config symbols are saved in the same order as they appear in the menu structure so it should be possible to map them to the relevant menus if desired. The implementation was tested against several minimal configs for arm which was created using brute-force. There was one regression related to default numbers which had their valid range further limited by another symbol. Sample: config FOO int "foo" default 4 config BAR int "bar" range 0 FOO If FOO is set to 3 then BAR cannot take a value higher than 3. But the current implementation will set BAR equal to 4. This is seldomly used and the final configuration is OK, and the fix was non-trivial. So it was documented in the code and left as is. Signed-off-by: Sam Ravnborg Acked-by: Uwe Kleine-König Signed-off-by: Michal Marek --- scripts/kconfig/conf.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'scripts/kconfig/conf.c') diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index c8bd33c..010600e 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -30,6 +30,7 @@ enum input_mode { alldefconfig, randconfig, defconfig, + savedefconfig, listnewconfig, oldnoconfig, } input_mode = oldaskconfig; @@ -444,6 +445,7 @@ static struct option long_opts[] = { {"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}, @@ -471,6 +473,7 @@ int main(int ac, char **av) sync_kconfig = 1; break; case defconfig: + case savedefconfig: defconfig_file = optarg; break; case randconfig: @@ -526,6 +529,9 @@ int main(int ac, char **av) exit(1); } break; + case savedefconfig: + conf_read(NULL); + break; case silentoldconfig: case oldaskconfig: case oldconfig: @@ -591,6 +597,8 @@ int main(int ac, char **av) case defconfig: conf_set_all_new_symbols(def_default); break; + case savedefconfig: + break; case oldconfig: case oldaskconfig: rootEntry = &rootmenu; @@ -622,6 +630,12 @@ int main(int ac, char **av) fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); return 1; } + } 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 kernel configuration.\n\n")); -- cgit v1.1