summaryrefslogtreecommitdiff
path: root/extra/config
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2009-08-17 19:17:00 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2009-08-17 19:17:00 +0200
commit49d8a0e9c6e32701c7eca91a1204237d3a334e38 (patch)
tree500e0c09a66970494dffbfe3a36f958762d22f99 /extra/config
parent7f779e7937cca133ea5f2d18c154c6564516fd9f (diff)
support building out-of-tree
Handle O= Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'extra/config')
-rw-r--r--extra/config/Makefile87
-rw-r--r--extra/config/Makefile.kconfig4
-rw-r--r--extra/config/conf.c19
-rw-r--r--extra/config/confdata.c70
-rw-r--r--extra/config/expr.h82
-rw-r--r--extra/config/lex.zconf.c_shipped7
-rwxr-xr-xextra/config/lxdialog/check-lxdialog.sh2
-rw-r--r--extra/config/qconf.cc2
-rw-r--r--extra/config/zconf.l7
-rw-r--r--extra/config/zconf.tab.c_shipped2
10 files changed, 201 insertions, 81 deletions
diff --git a/extra/config/Makefile b/extra/config/Makefile
index 836f1f9f1..7d8a1e4ad 100644
--- a/extra/config/Makefile
+++ b/extra/config/Makefile
@@ -1,45 +1,86 @@
-obj := .
-src := .
-top_srcdir=../../
-top_builddir=../../
-srctree := .
-include $(top_builddir)Rules.mak
+top_srcdir ?= ../../
-include Makefile.kconfig
+include $(top_srcdir)Rules.mak
+include $(top_srcdir)Makerules
+
+# ugh
+top_srcdir:=$(shell cd $(top_srcdir) && pwd)/
+ifdef O
+top_builddir ?= ../../
+else
+top_builddir = ../../
+endif
+srctree := $(top_srcdir)
+src := extra/config
+obj := $(top_builddir)$(src)
+
+generated := $(patsubst %_shipped,%,$(wildcard *_shipped))
+generated := $(addprefix $(obj)/,$(generated:.c=.o))
+
+include $(top_srcdir)extra/config/Makefile.kconfig
+PHONY += $(always)
+chk-lxdialog := $(top_srcdir)$(src)/lxdialog/check-lxdialog.sh
+check-lxdialog := cd $(obj) && $(chk-lxdialog)
+HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) -c '$(check-lxdialog) -ccflags')
+HOST_LOADLIBES = $(shell $(CONFIG_SHELL) -c '$(check-lxdialog) -ldflags $(HOSTCC)')
+HOST_EXTRACFLAGS += -DLOCALE
+HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) -c '$(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)')
+
+# do not create temporary object in the readonly srctree
+$(obj)/dochecklxdialog:
+ $(Q)cd $(obj) && $(CONFIG_SHELL) $(chk-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES)
+HOSTCFLAGS_lex.zconf.o := -I$(top_srcdir)$(src)
+HOSTCFLAGS_zconf.tab.o := -I$(top_srcdir)$(src)
+conf-objs := $(addprefix $(obj)/,$(conf-objs))
+mconf-objs := $(addprefix $(obj)/,$(mconf-objs))
+kxgettext-objs := $(addprefix $(obj)/,$(kxgettext-objs))
ifeq ($(findstring mconf,$(MAKECMDGOALS)),mconf)
hostprogs-y += mconf
endif
--include .depend
-.depend: $(wildcard *.h *.c)
- $(Q)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > .depend 2>/dev/null || :
+#BUILD_CFLAGS-config = -W -Wall -pedantic
+#BUILD_CFLAGS-lxdialog = -W -Wall -pedantic
__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
-host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
+host-csingle:= $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
host-cmulti := $(foreach m,$(__hostprogs),\
$(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
-$(host-csingle): %: %.c
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) $< $(HOST_LOADLIBES) -o $@
+conf mconf kxgettext: %: $(obj)/%
+$(obj)/conf $(obj)/mconf $(obj)/kxgettext: BUILD_LDFLAGS=$(HOST_LOADLIBES)
+$(obj)/conf: $(conf-objs)
+ $(hcompile.u)
+$(obj)/mconf: $(mconf-objs)
+ $(hcompile.u)
+$(obj)/kxgettext: $(kxgettext-objs)
+ $(hcompile.u)
-$(host-cmulti): %: $(host-cobjs) $(host-cshlib)
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) $($@-objs) $(HOST_LOADLIBES) -o $@
+$(host-csingle) $(host-cmulti) $(host-cobjs): BUILD_CFLAGS=$(HOST_EXTRACFLAGS) \
+ $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F))
-$(host-cobjs): %.o: %.c
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) -c $< -o $@
+host-cobjs.nogen := $(filter-out $(generated),$(host-cobjs))
+host-cobjs.generated := $(filter $(generated),$(host-cobjs))
-$(obj)/%:: $(src)/%_shipped
- $(Q)cat $< > $@
+$(host-cobjs.nogen): $(obj)/%.o: $(top_srcdir)$(src)/%.c
+ $(hcompile.o)
+$(host-cobjs.generated): $(obj)/%.o: $(obj)/%.c
+ $(hcompile.o)
+ifndef LKC_GENPARSER
+$(obj)/%:: $(top_srcdir)$(src)/%_shipped
+ @$(disp_gen)
+ $(Q)cat $< > $@
+endif
clean:
- $(Q)rm -f $(clean-files) conf
+ $(do_rm) $(clean-files) conf
distclean: clean
- $(Q)rm -f $(lxdialog) $(conf-objs) $(mconf-objs) $(kxgettext-objs) \
+ $(do_rm) $(lxdialog) $(conf-objs) $(mconf-objs) \
+ $(kxgettext-objs) \
$(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) \
.depend
- $(Q)rm -r -f $(top_builddir)include/config
+ $(do_rm) -r $(top_builddir)include/config
FORCE:
-.PHONY: FORCE clean distclean
+.PHONY: FORCE clean distclean $(always)
diff --git a/extra/config/Makefile.kconfig b/extra/config/Makefile.kconfig
index fa1a7d565..fa8c2dd9c 100644
--- a/extra/config/Makefile.kconfig
+++ b/extra/config/Makefile.kconfig
@@ -4,7 +4,11 @@
PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
+ifdef KBUILD_KCONFIG
+Kconfig := $(KBUILD_KCONFIG)
+else
Kconfig := arch/$(SRCARCH)/Kconfig
+endif
xconfig: $(obj)/qconf
$< $(Kconfig)
diff --git a/extra/config/conf.c b/extra/config/conf.c
index 02b2600c2..d623ed1d3 100644
--- a/extra/config/conf.c
+++ b/extra/config/conf.c
@@ -11,6 +11,7 @@
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <sys/time.h>
#define LKC_DIRECT_LINK
#include "lkc.h"
@@ -432,6 +433,7 @@ int main(int ac, char **av)
{
int opt;
const char *name;
+ const char *configname = conf_get_configname();
struct stat tmpstat;
setlocale(LC_ALL, "");
@@ -464,9 +466,22 @@ int main(int ac, char **av)
input_mode = set_yes;
break;
case 'r':
+ {
+ struct timeval now;
+ unsigned int seed;
+
+ /*
+ * Use microseconds derived seed,
+ * compensate for systems where it may be zero
+ */
+ gettimeofday(&now, NULL);
+
+ seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
+ srand(seed);
+
input_mode = set_random;
- srand(time(NULL));
break;
+ }
case 'h':
printf(_("See README for usage info\n"));
exit(0);
@@ -484,7 +499,7 @@ int main(int ac, char **av)
conf_parse(name);
//zconfdump(stdout);
if (sync_kconfig) {
- if (stat(".config", &tmpstat)) {
+ if (stat(configname, &tmpstat)) {
fprintf(stderr, _("***\n"
"*** You have not yet configured!\n"
"*** (missing .config file)\n"
diff --git a/extra/config/confdata.c b/extra/config/confdata.c
index 9da48ebdc..281dd0024 100644
--- a/extra/config/confdata.c
+++ b/extra/config/confdata.c
@@ -11,6 +11,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <libgen.h>
#define LKC_DIRECT_LINK
#include "lkc.h"
@@ -553,7 +554,7 @@ int conf_write(const char *name)
int conf_split_config(void)
{
- char *name, path[128];
+ char *name, path[128], opwd[512];
char *s, *d, c;
struct symbol *sym;
struct stat sb;
@@ -564,7 +565,9 @@ int conf_split_config(void)
name = "include/config/auto.conf";
conf_read_simple(name, S_DEF_AUTO);
- if (chdir("include/config"))
+ if (getcwd(opwd, sizeof(opwd)) == NULL)
+ return 1;
+ if (chdir(dirname(strdup(name))))
return 1;
res = 0;
@@ -658,7 +661,7 @@ int conf_split_config(void)
close(fd);
}
out:
- if (chdir("../.."))
+ if (chdir(opwd))
return 1;
return res;
@@ -666,6 +669,7 @@ out:
int conf_write_autoconf(void)
{
+ char opwd[512];
struct symbol *sym;
const char *str;
char *name;
@@ -673,6 +677,10 @@ int conf_write_autoconf(void)
time_t now;
int i, l;
+ if (getcwd(opwd, sizeof(opwd)) == NULL)
+ return 1;
+ if (chdir(dirname(strdup(conf_get_configname()))))
+ return 1;
sym_clear_all_valid();
file_write_dep("include/config/auto.conf.cmd");
@@ -780,7 +788,7 @@ int conf_write_autoconf(void)
*/
if (rename(".tmpconfig", name))
return 1;
-
+ chdir(opwd);
return 0;
}
@@ -841,7 +849,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
default:
continue;
}
- if (!sym_is_choice(sym) || mode != def_random)
+ if (!(sym_is_choice(sym) && mode == def_random))
sym->flags |= SYMBOL_DEF_USER;
break;
default:
@@ -850,33 +858,53 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
}
- if (modules_sym)
- sym_calc_value(modules_sym);
+ sym_clear_all_valid();
if (mode != def_random)
return;
-
+ /*
+ * We have different type of choice blocks.
+ * If curr.tri equal to mod then we can select several
+ * choice symbols in one block.
+ * In this case we do nothing.
+ * If curr.tri equal yes then only one symbol can be
+ * selected in a choice block and we set it to yes,
+ * and the rest to no.
+ */
for_all_symbols(i, csym) {
if (sym_has_value(csym) || !sym_is_choice(csym))
continue;
sym_calc_value(csym);
+
+ if (csym->curr.tri != yes)
+ continue;
+
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;
- }
+
+ /* count entries in choice block */
+ cnt = 0;
+ expr_list_for_each_sym(prop->expr, e, sym)
+ cnt++;
+
+ /*
+ * find a random value and set it to yes,
+ * set the rest to no so we have only one set
+ */
+ def = (rand() % cnt);
+
+ cnt = 0;
+ expr_list_for_each_sym(prop->expr, e, sym) {
+ if (def == cnt++) {
+ sym->def[S_DEF_USER].tri = yes;
+ csym->def[S_DEF_USER].val = sym;
+ }
+ else {
+ sym->def[S_DEF_USER].tri = no;
}
- if (def >= 0 || cnt < 2)
- break;
- def = (rand() % cnt) + 1;
}
csym->flags |= SYMBOL_DEF_USER;
+ /* clear VALID to get value calculated */
+ csym->flags &= ~(SYMBOL_VALID);
}
}
diff --git a/extra/config/expr.h b/extra/config/expr.h
index 9d4cba1c0..6408fefae 100644
--- a/extra/config/expr.h
+++ b/extra/config/expr.h
@@ -65,9 +65,13 @@ enum symbol_type {
S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
};
+/* enum values are used as index to symbol.def[] */
enum {
S_DEF_USER, /* main user value */
- S_DEF_AUTO,
+ S_DEF_AUTO, /* values read from auto.conf */
+ S_DEF_DEF3, /* Reserved for UI usage */
+ S_DEF_DEF4, /* Reserved for UI usage */
+ S_DEF_COUNT
};
struct symbol {
@@ -75,7 +79,7 @@ struct symbol {
char *name;
enum symbol_type type;
struct symbol_value curr;
- struct symbol_value def[4];
+ struct symbol_value def[S_DEF_COUNT];
tristate visible;
int flags;
struct property *prop;
@@ -84,42 +88,64 @@ struct symbol {
#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
-#define SYMBOL_CONST 0x0001
-#define SYMBOL_CHECK 0x0008
-#define SYMBOL_CHOICE 0x0010
-#define SYMBOL_CHOICEVAL 0x0020
-#define SYMBOL_VALID 0x0080
-#define SYMBOL_OPTIONAL 0x0100
-#define SYMBOL_WRITE 0x0200
-#define SYMBOL_CHANGED 0x0400
-#define SYMBOL_AUTO 0x1000
-#define SYMBOL_CHECKED 0x2000
-#define SYMBOL_WARNED 0x8000
-#define SYMBOL_DEF 0x10000
-#define SYMBOL_DEF_USER 0x10000
-#define SYMBOL_DEF_AUTO 0x20000
-#define SYMBOL_DEF3 0x40000
-#define SYMBOL_DEF4 0x80000
+#define SYMBOL_CONST 0x0001 /* symbol is const */
+#define SYMBOL_CHECK 0x0008 /* used during dependency checking */
+#define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */
+#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */
+#define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */
+#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
+#define SYMBOL_WRITE 0x0200 /* ? */
+#define SYMBOL_CHANGED 0x0400 /* ? */
+#define SYMBOL_AUTO 0x1000 /* value from environment variable */
+#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
+#define SYMBOL_WARNED 0x8000 /* warning has been issued */
+
+/* Set when symbol.def[] is used */
+#define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */
+#define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */
+#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_MAXLENGTH 256
#define SYMBOL_HASHSIZE 257
#define SYMBOL_HASHMASK 0xff
+/* A property represent the config options that can be associated
+ * with a config "symbol".
+ * Sample:
+ * config FOO
+ * default y
+ * prompt "foo prompt"
+ * select BAR
+ * config BAZ
+ * int "BAZ Value"
+ * range 1..255
+ */
enum prop_type {
- P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE,
- P_SELECT, P_RANGE, P_ENV
+ P_UNKNOWN,
+ P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */
+ P_COMMENT, /* text associated with a comment */
+ P_MENU, /* prompt associated with a menuconfig option */
+ P_DEFAULT, /* default y */
+ P_CHOICE, /* choice value */
+ P_SELECT, /* select BAR */
+ P_RANGE, /* range 7..100 (for a symbol) */
+ P_ENV, /* value from environment variable */
};
struct property {
- struct property *next;
- struct symbol *sym;
- enum prop_type type;
- const char *text;
+ struct property *next; /* next property - null if last */
+ struct symbol *sym; /* the symbol for which the property is associated */
+ enum prop_type type; /* type of property */
+ const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */
struct expr_value visible;
- struct expr *expr;
- struct menu *menu;
- struct file *file;
- int lineno;
+ struct expr *expr; /* the optional conditional part of the property */
+ struct menu *menu; /* the menu the property are associated with
+ * valid for: P_SELECT, P_RANGE, P_CHOICE,
+ * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */
+ struct file *file; /* what file was this property defined */
+ int lineno; /* what lineno was this property defined */
};
#define for_all_properties(sym, st, tok) \
diff --git a/extra/config/lex.zconf.c_shipped b/extra/config/lex.zconf.c_shipped
index 09a1ec8e3..f6e38b689 100644
--- a/extra/config/lex.zconf.c_shipped
+++ b/extra/config/lex.zconf.c_shipped
@@ -2370,11 +2370,14 @@ void zconf_nextfile(const char *name)
current_buf = buf;
if (file->flags & FILE_BUSY) {
- printf("recursive scan (%s)?\n", name);
+ printf("%s:%d: do not source '%s' from itself\n",
+ zconf_curname(), zconf_lineno(), name);
exit(1);
}
if (file->flags & FILE_SCANNED) {
- printf("file %s already scanned?\n", name);
+ printf("%s:%d: file '%s' is already sourced from '%s'\n",
+ zconf_curname(), zconf_lineno(), name,
+ file->parent->name);
exit(1);
}
file->flags |= FILE_BUSY;
diff --git a/extra/config/lxdialog/check-lxdialog.sh b/extra/config/lxdialog/check-lxdialog.sh
index 5552154cb..fcef0f59d 100755
--- a/extra/config/lxdialog/check-lxdialog.sh
+++ b/extra/config/lxdialog/check-lxdialog.sh
@@ -52,7 +52,7 @@ EOF
}
usage() {
- printf "Usage: $0 [-check compiler options|-header|-library]\n"
+ printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
}
if [ $# -eq 0 ]; then
diff --git a/extra/config/qconf.cc b/extra/config/qconf.cc
index ec3b5bb1e..ec89fd7ff 100644
--- a/extra/config/qconf.cc
+++ b/extra/config/qconf.cc
@@ -1648,7 +1648,7 @@ void ConfigMainWindow::showIntro(void)
void ConfigMainWindow::showAbout(void)
{
static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
- "Bug reports and feature request can also be entered at http://bugs.uClibc.org/\n");
+ "Bug reports and feature request can also be entered at https://bugs.uClibc.org/\n");
QMessageBox::information(this, "qconf", str);
}
diff --git a/extra/config/zconf.l b/extra/config/zconf.l
index 5164ef7ce..21ff69c9a 100644
--- a/extra/config/zconf.l
+++ b/extra/config/zconf.l
@@ -314,11 +314,14 @@ void zconf_nextfile(const char *name)
current_buf = buf;
if (file->flags & FILE_BUSY) {
- printf("recursive scan (%s)?\n", name);
+ printf("%s:%d: do not source '%s' from itself\n",
+ zconf_curname(), zconf_lineno(), name);
exit(1);
}
if (file->flags & FILE_SCANNED) {
- printf("file %s already scanned?\n", name);
+ printf("%s:%d: file '%s' is already sourced from '%s'\n",
+ zconf_curname(), zconf_lineno(), name,
+ file->parent->name);
exit(1);
}
file->flags |= FILE_BUSY;
diff --git a/extra/config/zconf.tab.c_shipped b/extra/config/zconf.tab.c_shipped
index 08223ec4c..aa9cc2877 100644
--- a/extra/config/zconf.tab.c_shipped
+++ b/extra/config/zconf.tab.c_shipped
@@ -1281,7 +1281,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
}
}
#endif /* YYERROR_VERBOSE */
-
+
/*-----------------------------------------------.
| Release the memory associated to this symbol. |