aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2007-10-14 02:15:37 +0000
committerJohn Crispin <john@openwrt.org>2007-10-14 02:15:37 +0000
commit1a3c4d109008e36e8d158670cf461f131d13f75e (patch)
tree5ee2d061ce0c569c159d99300db5d821b264b0bc
parent3568f0c247fda145643fd6395fab6d440ab1e83c (diff)
downloadupstream-1a3c4d109008e36e8d158670cf461f131d13f75e.tar.gz
upstream-1a3c4d109008e36e8d158670cf461f131d13f75e.tar.bz2
upstream-1a3c4d109008e36e8d158670cf461f131d13f75e.zip
add possibility to set default .config values
SVN-Revision: 9300
-rw-r--r--Config.in9
-rw-r--r--include/toplevel.mk2
-rw-r--r--rules.mk2
-rw-r--r--scripts/config/Makefile4
-rw-r--r--scripts/config/confdata.c140
-rw-r--r--scripts/config/lkc_proto.h2
6 files changed, 100 insertions, 59 deletions
diff --git a/Config.in b/Config.in
index df331fc2bf..9142ad371c 100644
--- a/Config.in
+++ b/Config.in
@@ -144,8 +144,17 @@ config SOURCE_FEEDS_REV
source "toolchain/Config.in"
+menuconfig BUILDSYSTEM_SETTINGS
+ bool "Buildsystem settings"
+
+config DOWNLOAD_FOLDER
+ string
+ prompt "Download folder"
+ default ""
+ depends BUILDSYSTEM_SETTINGS
source "target/imagebuilder/Config.in"
source "target/sdk/Config.in"
source "tmp/.config-package.in"
+
diff --git a/include/toplevel.mk b/include/toplevel.mk
index 359c7cf712..dcbcb3eb75 100644
--- a/include/toplevel.mk
+++ b/include/toplevel.mk
@@ -52,6 +52,8 @@ prepare-tmpinfo: FORCE
scripts/config/mconf:
@+$(MAKE) -C scripts/config all
+$(call rdep,scripts/config,scripts/config/mconf)
+
scripts/config/conf:
@+$(MAKE) -C scripts/config conf
diff --git a/rules.mk b/rules.mk
index 514aa6b9d2..950efebc8b 100644
--- a/rules.mk
+++ b/rules.mk
@@ -32,7 +32,7 @@ SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
OPTIMIZE_FOR_CPU:=$(ARCH)
-DL_DIR:=$(TOPDIR)/dl
+DL_DIR:=$(call qstrip,$(if $(CONFIG_DOWNLOAD_FOLDER), $(CONFIG_DOWNLOAD_FOLDER),$(TOPDIR)/dl))
BIN_DIR:=$(TOPDIR)/bin
INCLUDE_DIR:=$(TOPDIR)/include
SCRIPT_DIR:=$(TOPDIR)/scripts
diff --git a/scripts/config/Makefile b/scripts/config/Makefile
index ef11542fc6..54c5fe25af 100644
--- a/scripts/config/Makefile
+++ b/scripts/config/Makefile
@@ -27,13 +27,13 @@ lxdialog/lxdialog:
$(MAKE) -C lxdialog
conf: $(conf-objs)
-mconf: $(mconf-objs)
+mconf: $(mconf-objs)
clean:
rm -f *.o $(clean-files) conf mconf
$(MAKE) -C lxdialog clean
-zconf.tab.o: lex.zconf.c zconf.hash.c
+zconf.tab.o: lex.zconf.c zconf.hash.c confdata.c
kconfig_load.o: lkc_defs.h
diff --git a/scripts/config/confdata.c b/scripts/config/confdata.c
index 4524d512c1..c77bef2e25 100644
--- a/scripts/config/confdata.c
+++ b/scripts/config/confdata.c
@@ -14,6 +14,8 @@
#define LKC_DIRECT_LINK
#include "lkc.h"
+#define LOCAL_BUILD_SETTINGS "/.openwrt/defconfig"
+
static void conf_warning(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
@@ -87,7 +89,7 @@ void conf_reset(void)
{
struct symbol *sym;
int i;
-
+
for_all_symbols(i, sym) {
sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
if (sym_is_choice(sym))
@@ -104,55 +106,12 @@ void conf_reset(void)
sym->user.tri = no;
}
}
+ conf_read_simple(NULL, 0);
}
-int conf_read_simple(const char *name)
-{
- FILE *in = NULL;
+int conf_read_file(FILE *in, struct symbol *sym){
char line[1024];
char *p, *p2;
- struct symbol *sym;
- int i;
-
- if (name) {
- in = zconf_fopen(name);
- } else {
- const char **names = conf_confnames;
- while ((name = *names++)) {
- name = conf_expand_value(name);
- in = zconf_fopen(name);
- if (in) {
- printf(_("#\n"
- "# using defaults found in %s\n"
- "#\n"), name);
- break;
- }
- }
- }
- if (!in)
- return 1;
-
- conf_filename = name;
- conf_lineno = 0;
- conf_warnings = 0;
- conf_unsaved = 0;
-
- for_all_symbols(i, sym) {
- sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
- if (sym_is_choice(sym))
- sym->flags &= ~SYMBOL_NEW;
- sym->flags &= ~SYMBOL_VALID;
- switch (sym->type) {
- case S_INT:
- case S_HEX:
- case S_STRING:
- if (sym->user.val)
- free(sym->user.val);
- default:
- sym->user.val = NULL;
- sym->user.tri = no;
- }
- }
while (fgets(line, sizeof(line), in)) {
conf_lineno++;
@@ -169,12 +128,12 @@ int conf_read_simple(const char *name)
continue;
sym = sym_find(line + 9);
if (!sym) {
- conf_warning("trying to assign nonexistent symbol %s", line + 9);
+ //conf_warning("trying to assign nonexistent symbol %s", line + 9);
break;
- } else if (!(sym->flags & SYMBOL_NEW)) {
- conf_warning("trying to reassign symbol %s", sym->name);
+ } /*else if (!(sym->flags & SYMBOL_NEW)) {
+ //conf_warning("trying to reassign symbol %s", sym->name);
break;
- }
+ }*/
switch (sym->type) {
case S_BOOLEAN:
case S_TRISTATE:
@@ -199,12 +158,12 @@ int conf_read_simple(const char *name)
*p2 = 0;
sym = sym_find(line + 7);
if (!sym) {
- conf_warning("trying to assign nonexistent symbol %s", line + 7);
+ //conf_warning("trying to assign nonexistent symbol %s", line + 7);
break;
- } else if (!(sym->flags & SYMBOL_NEW)) {
+ } /*else if (!(sym->flags & SYMBOL_NEW)) {
conf_warning("trying to reassign symbol %s", sym->name);
break;
- }
+ }*/
switch (sym->type) {
case S_TRISTATE:
if (p[0] == 'm') {
@@ -283,9 +242,80 @@ int conf_read_simple(const char *name)
}
fclose(in);
+ return 0;
+}
+
+int conf_read_simple(const char *name, int load_config)
+{
+ FILE *in = NULL;
+ FILE *defaults = NULL;
+ struct symbol *sym;
+ int i;
+ char *home_dir = getenv("HOME");
+ char *default_config_path = NULL;
+
+ if(home_dir){
+ default_config_path = malloc(strlen(home_dir) + sizeof(LOCAL_BUILD_SETTINGS) + 1);
+ sprintf(default_config_path, "%s%s", home_dir, LOCAL_BUILD_SETTINGS);
+ defaults = zconf_fopen(default_config_path);
+ if(defaults)
+ printf("# using buildsystem predefines from %s\n", default_config_path);
+ free(default_config_path);
+ }
+
+ if(load_config){
+ if (name) {
+ in = zconf_fopen(name);
+ } else {
+ const char **names = conf_confnames;
+ while ((name = *names++)) {
+ name = conf_expand_value(name);
+ in = zconf_fopen(name);
+ if (in) {
+ printf(_("#\n"
+ "# using defaults found in %s\n"
+ "#\n"), name);
+ break;
+ }
+ }
+ }
+ }
+
+ if (!in && !defaults)
+ return 1;
+
+ conf_filename = name;
+ conf_lineno = 0;
+ conf_warnings = 0;
+ conf_unsaved = 0;
+
+ for_all_symbols(i, sym) {
+ sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
+ if (sym_is_choice(sym))
+ sym->flags &= ~SYMBOL_NEW;
+ sym->flags &= ~SYMBOL_VALID;
+ switch (sym->type) {
+ case S_INT:
+ case S_HEX:
+ case S_STRING:
+ if (sym->user.val)
+ free(sym->user.val);
+ default:
+ sym->user.val = NULL;
+ sym->user.tri = no;
+ }
+ }
+
+ if(defaults)
+ conf_read_file(defaults, sym);
+
+ if(in)
+ conf_read_file(in, sym);
+
if (modules_sym)
sym_calc_value(modules_sym);
- return 0;
+
+ return 0;
}
int conf_read(const char *name)
@@ -295,7 +325,7 @@ int conf_read(const char *name)
struct expr *e;
int i;
- if (conf_read_simple(name))
+ if (conf_read_simple(name, 1))
return 1;
for_all_symbols(i, sym) {
diff --git a/scripts/config/lkc_proto.h b/scripts/config/lkc_proto.h
index 15fafd01b0..e5fd58e7d6 100644
--- a/scripts/config/lkc_proto.h
+++ b/scripts/config/lkc_proto.h
@@ -3,7 +3,7 @@
P(conf_parse,void,(const char *name));
P(conf_read,int,(const char *name));
P(conf_reset,void,(void));
-P(conf_read_simple,int,(const char *name));
+P(conf_read_simple,int,(const char *name, int load_config));
P(conf_write,int,(const char *name));
/* menu.c */