[PATCH 2/3] environment symbol support

2008-01-13 Thread Roman Zippel

Add the possibility to import a value from the environment into kconfig
via the option syntax. Beside flexibility this has the advantage
providing proper dependencies.

Signed-off-by: Roman Zippel <[EMAIL PROTECTED]>

---
 Documentation/kbuild/kconfig-language.txt |   21 ++
 scripts/kconfig/expr.h|3 +-
 scripts/kconfig/lkc.h |5 +++
 scripts/kconfig/menu.c|5 ++-
 scripts/kconfig/qconf.cc  |   16 +++---
 scripts/kconfig/symbol.c  |   45 ++
 scripts/kconfig/util.c|   23 ++-
 scripts/kconfig/zconf.gperf   |1 
 scripts/kconfig/zconf.hash.c_shipped  |   45 --
 9 files changed, 129 insertions(+), 35 deletions(-)

Index: linux-2.6/Documentation/kbuild/kconfig-language.txt
===
--- linux-2.6.orig/Documentation/kbuild/kconfig-language.txt
+++ linux-2.6/Documentation/kbuild/kconfig-language.txt
@@ -127,6 +127,27 @@ applicable everywhere (see syntax).
   used to help visually separate configuration logic from help within
   the file as an aid to developers.
 
+- misc options: "option" [=]
+  Various less common options can be defined via this option syntax,
+  which can modify the behaviour of the menu entry and its config
+  symbol. These options are currently possible:
+
+  - "defconfig_list"
+This declares a list of default entries which can be used when
+looking for the default configuration (which is used when the main
+.config doesn't exists yet.)
+
+  - "modules"
+This declares the symbol to be used as the MODULES symbol, which
+enables the third modular state for all config symbols.
+
+  - "env"=
+This imports the environment variable into Kconfig. It behaves like
+a default, except that the value comes from the environment, this
+also means that the behaviour when mixing it with normal defaults is
+undefined at this point. The symbol is currently not exported back
+to the build environment (if this is desired, it can be done via
+another symbol).
 
 Menu dependencies
 -
Index: linux-2.6/scripts/kconfig/expr.h
===
--- linux-2.6.orig/scripts/kconfig/expr.h
+++ linux-2.6/scripts/kconfig/expr.h
@@ -108,7 +108,8 @@ struct symbol {
 #define SYMBOL_HASHMASK0xff
 
 enum prop_type {
-   P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, 
P_RANGE
+   P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE,
+   P_SELECT, P_RANGE, P_ENV
 };
 
 struct property {
Index: linux-2.6/scripts/kconfig/lkc.h
===
--- linux-2.6.orig/scripts/kconfig/lkc.h
+++ linux-2.6/scripts/kconfig/lkc.h
@@ -44,6 +44,7 @@ extern "C" {
 
 #define T_OPT_MODULES  1
 #define T_OPT_DEFCONFIG_LIST   2
+#define T_OPT_ENV  3
 
 struct kconf_id {
int name;
@@ -74,6 +75,7 @@ void kconfig_load(void);
 
 /* menu.c */
 void menu_init(void);
+void menu_warn(struct menu *menu, const char *fmt, ...);
 struct menu *menu_add_menu(void);
 void menu_end_menu(void);
 void menu_add_entry(struct symbol *sym);
@@ -103,6 +105,8 @@ void str_printf(struct gstr *gs, const c
 const char *str_get(struct gstr *gs);
 
 /* symbol.c */
+extern struct expr *sym_env_list;
+
 void sym_init(void);
 void sym_clear_all_valid(void);
 void sym_set_all_changed(void);
@@ -110,6 +114,7 @@ void sym_set_changed(struct symbol *sym)
 struct symbol *sym_check_deps(struct symbol *sym);
 struct property *prop_alloc(enum prop_type type, struct symbol *sym);
 struct symbol *prop_get_symbol(struct property *prop);
+struct property *sym_get_env_prop(struct symbol *sym);
 
 static inline tristate sym_get_tristate_value(struct symbol *sym)
 {
Index: linux-2.6/scripts/kconfig/menu.c
===
--- linux-2.6.orig/scripts/kconfig/menu.c
+++ linux-2.6/scripts/kconfig/menu.c
@@ -15,7 +15,7 @@ static struct menu **last_entry_ptr;
 struct file *file_list;
 struct file *current_file;
 
-static void menu_warn(struct menu *menu, const char *fmt, ...)
+void menu_warn(struct menu *menu, const char *fmt, ...)
 {
va_list ap;
va_start(ap, fmt);
@@ -172,6 +172,9 @@ void menu_add_option(int token, char *ar
else if (sym_defconfig_list != current_entry->sym)
zconf_error("trying to redefine defconfig symbol");
break;
+   case T_OPT_ENV:
+   prop_add_env(arg);
+   break;
}
 }
 
Index: linux-2.6/scripts/kconfig/qconf.cc
===
--- linux-2.6.orig/scripts/kconfig/qconf.cc
+++ linux-2.6/scripts/kconfig/qconf.cc
@@ -1083,7 +1083,11 @@ QString 

[PATCH 2/3] environment symbol support

2008-01-13 Thread Roman Zippel

Add the possibility to import a value from the environment into kconfig
via the option syntax. Beside flexibility this has the advantage
providing proper dependencies.

Signed-off-by: Roman Zippel [EMAIL PROTECTED]

---
 Documentation/kbuild/kconfig-language.txt |   21 ++
 scripts/kconfig/expr.h|3 +-
 scripts/kconfig/lkc.h |5 +++
 scripts/kconfig/menu.c|5 ++-
 scripts/kconfig/qconf.cc  |   16 +++---
 scripts/kconfig/symbol.c  |   45 ++
 scripts/kconfig/util.c|   23 ++-
 scripts/kconfig/zconf.gperf   |1 
 scripts/kconfig/zconf.hash.c_shipped  |   45 --
 9 files changed, 129 insertions(+), 35 deletions(-)

Index: linux-2.6/Documentation/kbuild/kconfig-language.txt
===
--- linux-2.6.orig/Documentation/kbuild/kconfig-language.txt
+++ linux-2.6/Documentation/kbuild/kconfig-language.txt
@@ -127,6 +127,27 @@ applicable everywhere (see syntax).
   used to help visually separate configuration logic from help within
   the file as an aid to developers.
 
+- misc options: option symbol[=value]
+  Various less common options can be defined via this option syntax,
+  which can modify the behaviour of the menu entry and its config
+  symbol. These options are currently possible:
+
+  - defconfig_list
+This declares a list of default entries which can be used when
+looking for the default configuration (which is used when the main
+.config doesn't exists yet.)
+
+  - modules
+This declares the symbol to be used as the MODULES symbol, which
+enables the third modular state for all config symbols.
+
+  - env=value
+This imports the environment variable into Kconfig. It behaves like
+a default, except that the value comes from the environment, this
+also means that the behaviour when mixing it with normal defaults is
+undefined at this point. The symbol is currently not exported back
+to the build environment (if this is desired, it can be done via
+another symbol).
 
 Menu dependencies
 -
Index: linux-2.6/scripts/kconfig/expr.h
===
--- linux-2.6.orig/scripts/kconfig/expr.h
+++ linux-2.6/scripts/kconfig/expr.h
@@ -108,7 +108,8 @@ struct symbol {
 #define SYMBOL_HASHMASK0xff
 
 enum prop_type {
-   P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, 
P_RANGE
+   P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE,
+   P_SELECT, P_RANGE, P_ENV
 };
 
 struct property {
Index: linux-2.6/scripts/kconfig/lkc.h
===
--- linux-2.6.orig/scripts/kconfig/lkc.h
+++ linux-2.6/scripts/kconfig/lkc.h
@@ -44,6 +44,7 @@ extern C {
 
 #define T_OPT_MODULES  1
 #define T_OPT_DEFCONFIG_LIST   2
+#define T_OPT_ENV  3
 
 struct kconf_id {
int name;
@@ -74,6 +75,7 @@ void kconfig_load(void);
 
 /* menu.c */
 void menu_init(void);
+void menu_warn(struct menu *menu, const char *fmt, ...);
 struct menu *menu_add_menu(void);
 void menu_end_menu(void);
 void menu_add_entry(struct symbol *sym);
@@ -103,6 +105,8 @@ void str_printf(struct gstr *gs, const c
 const char *str_get(struct gstr *gs);
 
 /* symbol.c */
+extern struct expr *sym_env_list;
+
 void sym_init(void);
 void sym_clear_all_valid(void);
 void sym_set_all_changed(void);
@@ -110,6 +114,7 @@ void sym_set_changed(struct symbol *sym)
 struct symbol *sym_check_deps(struct symbol *sym);
 struct property *prop_alloc(enum prop_type type, struct symbol *sym);
 struct symbol *prop_get_symbol(struct property *prop);
+struct property *sym_get_env_prop(struct symbol *sym);
 
 static inline tristate sym_get_tristate_value(struct symbol *sym)
 {
Index: linux-2.6/scripts/kconfig/menu.c
===
--- linux-2.6.orig/scripts/kconfig/menu.c
+++ linux-2.6/scripts/kconfig/menu.c
@@ -15,7 +15,7 @@ static struct menu **last_entry_ptr;
 struct file *file_list;
 struct file *current_file;
 
-static void menu_warn(struct menu *menu, const char *fmt, ...)
+void menu_warn(struct menu *menu, const char *fmt, ...)
 {
va_list ap;
va_start(ap, fmt);
@@ -172,6 +172,9 @@ void menu_add_option(int token, char *ar
else if (sym_defconfig_list != current_entry-sym)
zconf_error(trying to redefine defconfig symbol);
break;
+   case T_OPT_ENV:
+   prop_add_env(arg);
+   break;
}
 }
 
Index: linux-2.6/scripts/kconfig/qconf.cc
===
--- linux-2.6.orig/scripts/kconfig/qconf.cc
+++ linux-2.6/scripts/kconfig/qconf.cc
@@ -1083,7 +1083,11 @@ QString