summaryrefslogtreecommitdiff
path: root/scripts
authorkergoth <kergoth>2003-01-16 18:04:11 (UTC)
committer kergoth <kergoth>2003-01-16 18:04:11 (UTC)
commit3904d85eac20dfd21cf2a3245977f9946865fd92 (patch) (unidiff)
tree8d5b2217c1b54a0c439815ec02db3f5235c99daa /scripts
parent0eec393ef2dd8b43db96c86e80e307f73a771fae (diff)
downloadopie-3904d85eac20dfd21cf2a3245977f9946865fd92.zip
opie-3904d85eac20dfd21cf2a3245977f9946865fd92.tar.gz
opie-3904d85eac20dfd21cf2a3245977f9946865fd92.tar.bz2
Update LinuxKernelConf to 1.3, latest available.
Diffstat (limited to 'scripts') (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/kconfig/Makefile110
-rw-r--r--scripts/kconfig/Makefile.kernel44
-rw-r--r--scripts/kconfig/conf.c7
-rw-r--r--scripts/kconfig/confdata.c74
-rw-r--r--scripts/kconfig/expr.h5
-rw-r--r--scripts/kconfig/kconfig.i5
-rw-r--r--scripts/kconfig/lkc.h5
-rw-r--r--scripts/kconfig/mconf.c101
-rw-r--r--scripts/kconfig/menu.c2
-rw-r--r--scripts/kconfig/qconf.cc274
-rw-r--r--scripts/kconfig/qconf.h59
-rw-r--r--scripts/kconfig/symbol.c35
-rw-r--r--scripts/kconfig/zconf.l72
-rw-r--r--scripts/kconfig/zconf.y6
14 files changed, 542 insertions, 257 deletions
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 7e257be..5a0d7e5 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -1,59 +1,43 @@
1VERSION=1.2 1VERSION=1.3
2CC=gcc 2CC=gcc
3CXX=g++ 3CXX=g++
4CFLAGS=-O2 -Wall -g -fPIC 4CFLAGS=-O0 -Wall -g -fPIC
5CXXFLAGS=$(CFLAGS) -I$(HOSTQTDIR)/include 5CXXFLAGS=$(CFLAGS) -I$(HOSTQTDIR)/include
6LDFLAGS= 6LDFLAGS=
7LXXFLAGS=$(LDFLAGS) -L$(HOSTQTDIR)/lib -Wl,-rpath,$(HOSTQTDIR)/lib 7LXXFLAGS=$(LDFLAGS) -L$(HOSTQTDIR)/lib -Wl,-rpath,$(HOSTQTDIR)/lib
8LEX=flex 8LEX=flex
9LFLAGS=-L
9YACC=bison 10YACC=bison
10YFLAGS=-d -t #-v 11YFLAGS=-l
12#YFLAGS=-d -t -v -l
11ifndef HOSTQTDIR 13ifndef HOSTQTDIR
12ifeq ($(shell if [ -e /usr/share/qt ]; then echo foundit; fi),foundit)
13HOSTQTDIR=/usr/share/qt 14HOSTQTDIR=/usr/share/qt
14else
15ifeq ($(shell if [ -e /usr/lib/qt ]; then echo foundit; fi),foundit)
16HOSTQTDIR=/usr/lib/qt
17endif
18endif
19endif
20
21ifndef QTLIB
22ifeq ($(shell if [ -e $(HOSTQTDIR)/lib/libqt-mt.so ]; then echo foundit; fi),foundit)
23QTLIB=-lqt-mt
24else
25ifneq ($(shell if [ -e $(HOSTQTDIR)/lib/libqt.so ]; then echo foundit; fi),foundit)
26$(warning Unable to locate libqt.so!)
27endif 15endif
28QTLIB=-lqt
29endif
30endif
31
32MOC=$(wildcard $(HOSTQTDIR)/bin/moc) 16MOC=$(wildcard $(HOSTQTDIR)/bin/moc)
33 17
34parse_SRC=zconf.y 18parse_SRC=zconf.y
35conf_SRC=conf.c $(parse_SRC) 19conf_SRC=conf.c $(parse_SRC)
36mconf_SRC=mconf.c $(parse_SRC) 20mconf_SRC=mconf.c $(parse_SRC)
37qconf_SRC=qconf.cc 21qconf_SRC=qconf.cc
38lkcc_SRC=cml1.y cml1.l help.l cml1.h expr1.c
39HDR=expr.h lkc.h lkc_proto.h qconf.h 22HDR=expr.h lkc.h lkc_proto.h qconf.h
40OTHER=README lkc_spec lkc_overview Makefile.kernel convert-all prepare-all.diff fixup-all.diff \ 23OTHER=README lkc-language.txt Makefile.kernel \
41 kconfig.i extconf.rb example 24 kconfig.i extconf.rb example
42INST=zconf.y zconf.l confdata.c expr.c symbol.c menu.c conf.c mconf.c qconf.cc kconfig_load.c images.c $(parse_SRC) $(HDR) 25INST=zconf.y zconf.l confdata.c expr.c symbol.c menu.c \
43INSTGEN=lex.zconf.c zconf.tab.c zconf.tab.h 26 conf.c mconf.c qconf.cc kconfig_load.c images.c $(HDR)
27INSTGEN=lex.zconf.c zconf.tab.c
44 28
45#DEBUG=1 29#DEBUG=1
46ifdef DEBUG 30ifdef DEBUG
47CFLAGS+=-DLKC_DIRECT_LINK 31CFLAGS+=-DLKC_DIRECT_LINK
48qconf_SRC+=$(parse_SRC) 32qconf_SRC+=$(parse_SRC)
49else 33else
50qconf_SRC+=kconfig_load.c 34qconf_SRC+=kconfig_load.c
51endif 35endif
52 36
53SRC=$(conf_SRC) $(mconf_SRC) $(qconf_SRC) $(lkcc_SRC) 37SRC=$(conf_SRC) $(mconf_SRC) $(qconf_SRC)
54CSRC=$(filter %.c, $(SRC)) 38CSRC=$(filter %.c, $(SRC))
55YSRC=$(filter %.y, $(SRC)) 39YSRC=$(filter %.y, $(SRC))
56LSRC=$(filter %.l, $(SRC)) 40LSRC=$(filter %.l, $(SRC))
57 41
58parse_OBJ=$(filter %.o, \ 42parse_OBJ=$(filter %.o, \
59 $(patsubst %.c,%.o, \ 43 $(patsubst %.c,%.o, \
@@ -73,34 +57,20 @@ mconf_OBJ=$(filter %.o, \
73qconf_OBJ=$(filter %.o, \ 57qconf_OBJ=$(filter %.o, \
74 $(patsubst %.c,%.o, \ 58 $(patsubst %.c,%.o, \
75 $(patsubst %.cc,%.o, \ 59 $(patsubst %.cc,%.o, \
76 $(patsubst %.y,%.tab.o, \ 60 $(patsubst %.y,%.tab.o, \
77 $(patsubst %.l,lex.%.o, \ 61 $(patsubst %.l,lex.%.o, \
78 $(qconf_SRC)))))) 62 $(qconf_SRC))))))
79lkcc_OBJ=$(filter %.o, \ 63OBJ=$(conf_OBJ) $(mconf_OBJ) $(qconf_OBJ)
80 $(patsubst %.c,%.o, \
81 $(patsubst %.y,%.tab.o, \
82 $(patsubst %.l,lex.%.o, \
83 $(lkcc_SRC)))))
84OBJ=$(conf_OBJ) $(mconf_OBJ) $(qconf_OBJ) $(lkcc_OBJ)
85 64
86ifeq ($(MOC),) 65ifeq ($(MOC),)
87all: lkcc conf mconf 66all: conf mconf
88else 67else
89all: lkcc conf mconf qconf libkconfig.so 68all: conf mconf qconf libkconfig.so
90endif 69endif
91 70
92lex.help.c: help.l
93lex.help.o: lex.help.c cml1.h expr.h
94lex.cml1.c: cml1.l
95lex.cml1.o: lex.cml1.c cml1.tab.h cml1.h expr.h
96cml1.tab.c: cml1.y
97cml1.tab.h: cml1.y
98cml1.tab.o: cml1.tab.c cml1.h expr.h
99expr1.o: expr1.c expr.h
100
101lkc_deps := lkc.h lkc_proto.h lkc_defs.h expr.h 71lkc_deps := lkc.h lkc_proto.h lkc_defs.h expr.h
102 72
103zconf.tab.c: zconf.y 73zconf.tab.c: zconf.y
104zconf.tab.h: zconf.y 74zconf.tab.h: zconf.y
105lex.zconf.c: zconf.l 75lex.zconf.c: zconf.l
106zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(lkc_deps) 76zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(lkc_deps)
@@ -125,33 +95,31 @@ ifeq ($(MOC),)
125qconf: 95qconf:
126 @echo Unable to find the QT installation. Please make sure that the 96 @echo Unable to find the QT installation. Please make sure that the
127 @echo QT development package is correctly installed and the HOSTQTDIR 97 @echo QT development package is correctly installed and the HOSTQTDIR
128 @echo environment variable is set to the correct location. 98 @echo environment variable is set to the correct location.
129 @false 99 @false
130else 100else
131qconf: $(qconf_OBJ) libkconfig.so 101qconf: $(qconf_OBJ)
132 $(CXX) $(LXXFLAGS) $^ $(QTLIB) -o $@ 102 $(CXX) $(LXXFLAGS) $^ -lqt -o $@
133endif 103endif
134 104
135lkcc: $(lkcc_OBJ)
136 $(CC) $(LDFLAGS) $^ -o $@
137
138libkconfig.so: $(parse_OBJ) 105libkconfig.so: $(parse_OBJ)
139 $(CC) -shared $^ -o $@ 106 $(CC) -shared $^ -o $@
140 107
141lkc_defs.h: lkc_proto.h 108lkc_defs.h: lkc_proto.h
142 sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' 109 sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
143 110
144clean: 111clean:
145 rm -f $(OBJ) lkcc conf qconf mconf *.moc lex.* *.tab.? *.output 112 rm -f $(OBJ) conf qconf mconf *.moc lex.* *.tab.? *.output
113 rm -rf .ruby .python
146 114
147tgz: 115tgz:
148 mkdir tmp 116 mkdir tmp
149 mkdir tmp/lkc-$(VERSION) 117 mkdir tmp/lkc-$(VERSION)
150 cp -ra Makefile $(sort $(SRC) $(HDR) $(OTHER) $(INST)) tmp/lkc-$(VERSION) 118 cp -ra Makefile $(sort $(SRC) $(HDR) $(OTHER) $(INST)) tmp/lkc-$(VERSION)
151 tar -cpvz -C tmp -f lkc-$(VERSION).tar.gz lkc-$(VERSION) 119 tar -cpvz -C tmp --exclude CVS -f lkc-$(VERSION).tar.gz lkc-$(VERSION)
152 rm -rf tmp 120 rm -rf tmp
153 121
154%.tab.c %.tab.h: %.y 122%.tab.c %.tab.h: %.y
155 $(YACC) $(YFLAGS) -b $* -p $* $< 123 $(YACC) $(YFLAGS) -b $* -p $* $<
156 124
157lex.%.c: %.l 125lex.%.c: %.l
@@ -164,30 +132,21 @@ lex.%.c: %.l
164 $(CC) $(CFLAGS) -c $< -o $@ 132 $(CC) $(CFLAGS) -c $< -o $@
165 133
166%.o: %.cc 134%.o: %.cc
167 $(CXX) $(CXXFLAGS) -c $< -o $@ 135 $(CXX) $(CXXFLAGS) -c $< -o $@
168 136
169ifdef KERNELSRC 137ifdef KERNELSRC
170install: lkcc $(INSTGEN) 138install: $(INSTGEN)
171 set -x; mkdir $(KERNELSRC)/scripts/kconfig; \ 139 set -x; cp $(sort $(INST)) $(KERNELSRC)/scripts/kconfig; \
172 cp $(sort $(INST)) $(KERNELSRC)/scripts/kconfig; \
173 for f in $(INSTGEN); do cp $$f $(KERNELSRC)/scripts/kconfig/$${f}_shipped; done; \ 140 for f in $(INSTGEN); do cp $$f $(KERNELSRC)/scripts/kconfig/$${f}_shipped; done; \
174 cp Makefile.kernel $(KERNELSRC)/scripts/kconfig/Makefile; \ 141 cp Makefile.kernel $(KERNELSRC)/scripts/kconfig/Makefile
175 LKCSRC=$$PWD; export LKCSRC; \ 142
176 cd $(KERNELSRC); \ 143diff: $(INSTGEN)
177 patch -p0 -N < $$LKCSRC/prepare-all.diff; \ 144 for f in $(sort $(INST)); do diff -u $(KERNELSRC)/scripts/kconfig/$$f $$f; done; \
178 sh $$LKCSRC/convert-all; \ 145 for f in $(INSTGEN); do diff -u $(KERNELSRC)/scripts/kconfig/$${f}_shipped $$f; done; \
179 patch -p0 -N < $$LKCSRC/fixup-all.diff 146 diff -u $(KERNELSRC)/scripts/kconfig/Makefile Makefile.kernel
180
181 #cp Makefile $(KERNELSRC)/scripts/kconfig/Makefile; \
182
183uninstall:
184 patch -p0 -N -R -d $(KERNELSRC) < prepare-all.diff; \
185 cd $(KERNELSRC); \
186 find -name "Kconfig*" | xargs rm; \
187 rm -rf scripts/kconfig log.*
188else 147else
189install: 148install:
190 @echo "Please use KERNELSRC=<path/to/linux-kernel> to install" 149 @echo "Please use KERNELSRC=<path/to/linux-kernel> to install"
191endif 150endif
192 151
193ruby: .ruby libkconfig.so .ruby/kconfig.so 152ruby: .ruby libkconfig.so .ruby/kconfig.so
@@ -201,7 +160,22 @@ ruby: .ruby libkconfig.so .ruby/kconfig.so
201.ruby/Makefile: extconf.rb 160.ruby/Makefile: extconf.rb
202 cd .ruby; ruby ../extconf.rb 161 cd .ruby; ruby ../extconf.rb
203 162
204.ruby/kconfig.so: .ruby/kconfig_wrap.c .ruby/Makefile 163.ruby/kconfig.so: .ruby/kconfig_wrap.c .ruby/Makefile
205 make -C .ruby 164 make -C .ruby
206 165
207.PHONY: all tgz clean ruby 166
167PYTHON_INCLUDE=$(shell python -c "import sys; print '-I'+sys.prefix+'/include/python'+sys.version[:3]")
168
169python: .python .python/kconfig.py .python/_kconfig.so
170
171.python:
172 mkdir .python
173
174.python/kconfig_wrap.c .python/kconfig.py: kconfig.i kconfig_load.c expr.h lkc_proto.h
175 swig -python -o .python/kconfig_wrap.c kconfig.i
176
177.python/_kconfig.so: .python/kconfig_wrap.c
178 cd .python; $(CC) $(CFLAGS) -shared kconfig_wrap.c -o _kconfig.so -I.. $(PYTHON_INCLUDE)
179
180
181.PHONY: all tgz clean ruby python
diff --git a/scripts/kconfig/Makefile.kernel b/scripts/kconfig/Makefile.kernel
index beb4dcf..22724a7 100644
--- a/scripts/kconfig/Makefile.kernel
+++ b/scripts/kconfig/Makefile.kernel
@@ -20,39 +20,49 @@ qconf-cxxobjs := qconf.o
20 20
21 clean-files:= libkconfig.so lkc_defs.h qconf.moc .tmp_qtcheck \ 21 clean-files:= libkconfig.so lkc_defs.h qconf.moc .tmp_qtcheck \
22 zconf.tab.c zconf.tab.h lex.zconf.c 22 zconf.tab.c zconf.tab.h lex.zconf.c
23 23
24include $(TOPDIR)/Rules.make 24include $(TOPDIR)/Rules.make
25 25
26# QT needs some extra effort...
27ifndef QTDIR
28 QTDIR := /usr/share/qt
29endif
30
31# Executable to generate the .moc file
32MOC=$(wildcard $(QTDIR)/bin/moc)
33
34# generated files seem to need this to find local include files 26# generated files seem to need this to find local include files
35 HOSTCFLAGS_lex.zconf.o:= -I$(src) 27 HOSTCFLAGS_lex.zconf.o:= -I$(src)
36 HOSTCFLAGS_zconf.tab.o:= -I$(src) 28 HOSTCFLAGS_zconf.tab.o:= -I$(src)
37 29
38 HOSTLOADLIBES_qconf:= -L$(QTDIR)/lib -Wl,-rpath,$(QTDIR)/lib -lqt -ldl 30 HOSTLOADLIBES_qconf= -L$(QTDIR)/lib -Wl,-rpath,$(QTDIR)/lib -l$(QTLIB) -ldl
39 HOSTCXXFLAGS_qconf.o:= -I$(QTDIR)/include 31 HOSTCXXFLAGS_qconf.o= -I$(QTDIR)/include
40 32
41$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o: $(obj)/zconf.tab.h 33$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o: $(obj)/zconf.tab.h
42 34
43$(obj)/qconf.o: $(obj)/.tmp_qtcheck 35$(obj)/qconf.o: $(obj)/.tmp_qtcheck
44 36
37ifeq ($(MAKECMDGOALS),$(obj)/qconf)
38MOC = $(QTDIR)/bin/moc
39-include $(obj)/.tmp_qtcheck
40
41# QT needs some extra effort...
45$(obj)/.tmp_qtcheck: 42$(obj)/.tmp_qtcheck:
46ifeq ($(MOC),) 43 @set -e; for d in $$QTDIR /usr/share/qt /usr/lib/qt3; do \
47 @echo Unable to find the QT installation. Please make sure that the 44 if [ -f $$d/include/qconfig.h ]; then DIR=$$d; break; fi; \
48 @echo QT development package is correctly installed and the QTDIR 45 done; \
49 @echo environment variable is set to the correct location. 46 if [ -z "$$DIR" ]; then \
50 @false 47 echo "*"; \
51else 48 echo "* Unable to find the QT installation. Please make sure that the"; \
52 @touch $@ 49 echo "* QT development package is correctly installed and the QTDIR"; \
50 echo "* environment variable is set to the correct location."; \
51 echo "*"; \
52 false; \
53 fi; \
54 LIB=qt; \
55 if [ -f $$DIR/lib/libqt-mt.so ]; then LIB=qt-mt; fi; \
56 echo "QTDIR=$$DIR" > $@; echo "QTLIB=$$LIB" >> $@; \
57 if [ ! -x $$DIR/bin/moc -a -x /usr/bin/moc ]; then \
58 echo "*"; \
59 echo "* Unable to find $$DIR/bin/moc, using /usr/bin/moc instead."; \
60 echo "*"; \
61 echo "MOC=/usr/bin/moc" >> $@; \
62 fi
53endif 63endif
54 64
55$(obj)/zconf.tab.o: $(obj)/lex.zconf.c 65$(obj)/zconf.tab.o: $(obj)/lex.zconf.c
56 66
57$(obj)/kconfig_load.o: $(obj)/lkc_defs.h 67$(obj)/kconfig_load.o: $(obj)/lkc_defs.h
58 68
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 74c94c2..1602d5f 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -112,12 +112,13 @@ static void conf_askvalue(struct symbol *sym, const char *def)
112 printf("aborted!\n\n"); 112 printf("aborted!\n\n");
113 printf("Console input/output is redirected. "); 113 printf("Console input/output is redirected. ");
114 printf("Run 'make oldconfig' to update configuration.\n\n"); 114 printf("Run 'make oldconfig' to update configuration.\n\n");
115 exit(1); 115 exit(1);
116 } 116 }
117 case ask_all: 117 case ask_all:
118 fflush(stdout);
118 fgets(line, 128, stdin); 119 fgets(line, 128, stdin);
119 return; 120 return;
120 case set_default: 121 case set_default:
121 printf("%s\n", def); 122 printf("%s\n", def);
122 return; 123 return;
123 default: 124 default:
@@ -339,12 +340,14 @@ static int conf_choice(struct menu *menu)
339 return 1; 340 return 1;
340 } 341 }
341 switch (input_mode) { 342 switch (input_mode) {
342 case ask_new: 343 case ask_new:
343 case ask_silent: 344 case ask_silent:
344 case ask_all: 345 case ask_all:
346 if (is_new)
347 sym->flags |= SYMBOL_NEW;
345 conf_askvalue(sym, menu_get_prompt(def_menu)); 348 conf_askvalue(sym, menu_get_prompt(def_menu));
346 strip(line); 349 strip(line);
347 break; 350 break;
348 default: 351 default:
349 line[0] = 0; 352 line[0] = 0;
350 printf("\n"); 353 printf("\n");
@@ -354,20 +357,20 @@ static int conf_choice(struct menu *menu)
354 if (menu->sym->help) 357 if (menu->sym->help)
355 help = menu->sym->help; 358 help = menu->sym->help;
356 printf("\n%s\n", help); 359 printf("\n%s\n", help);
357 continue; 360 continue;
358 } 361 }
359 if (line[0]) { 362 if (line[0]) {
360 len = strlen(line) - 1; 363 len = strlen(line);
361 line[len] = 0; 364 line[len] = 0;
362 365
363 def_menu = NULL; 366 def_menu = NULL;
364 for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { 367 for (cmenu = menu->list; cmenu; cmenu = cmenu->next) {
365 if (!cmenu->sym || !menu_is_visible(cmenu)) 368 if (!cmenu->sym || !menu_is_visible(cmenu))
366 continue; 369 continue;
367 if (!strncmp(line, menu_get_prompt(cmenu), len)) { 370 if (!strncasecmp(line, menu_get_prompt(cmenu), len)) {
368 def_menu = cmenu; 371 def_menu = cmenu;
369 break; 372 break;
370 } 373 }
371 } 374 }
372 } 375 }
373 if (def_menu) { 376 if (def_menu) {
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 0f5fd97..9bf7af9 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -1,23 +1,22 @@
1/* 1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
4 */ 4 */
5 5
6#include <sys/stat.h>
6#include <ctype.h> 7#include <ctype.h>
7#include <limits.h>
8#include <stdio.h> 8#include <stdio.h>
9#include <stdlib.h> 9#include <stdlib.h>
10#include <string.h> 10#include <string.h>
11#include <unistd.h> 11#include <unistd.h>
12 12
13#define LKC_DIRECT_LINK 13#define LKC_DIRECT_LINK
14#include "lkc.h" 14#include "lkc.h"
15 15
16const char conf_def_filename[] = ".config"; 16const char conf_def_filename[] = ".config";
17char conf_filename[PATH_MAX+1];
18 17
19const char conf_defname[] = "arch/$ARCH/defconfig"; 18const char conf_defname[] = "arch/$ARCH/defconfig";
20 19
21const char *conf_confnames[] = { 20const char *conf_confnames[] = {
22 ".config", 21 ".config",
23 "/lib/modules/$UNAME_RELEASE/.config", 22 "/lib/modules/$UNAME_RELEASE/.config",
@@ -52,35 +51,44 @@ static char *conf_expand_value(const char *in)
52 51
53 return res_value; 52 return res_value;
54} 53}
55 54
56char *conf_get_default_confname(void) 55char *conf_get_default_confname(void)
57{ 56{
58 return conf_expand_value(conf_defname); 57 struct stat buf;
58 static char fullname[PATH_MAX+1];
59 char *env, *name;
60
61 name = conf_expand_value(conf_defname);
62 env = getenv(SRCTREE);
63 if (env) {
64 sprintf(fullname, "%s/%s", env, name);
65 if (!stat(fullname, &buf))
66 return fullname;
67 }
68 return name;
59} 69}
60 70
61int conf_read(const char *name) 71int conf_read(const char *name)
62{ 72{
63 FILE *in = NULL; 73 FILE *in = NULL;
64 char line[128]; 74 char line[1024];
65 char *p, *p2; 75 char *p, *p2;
66 int lineno = 0; 76 int lineno = 0;
67 struct symbol *sym; 77 struct symbol *sym;
68 struct property *prop; 78 struct property *prop;
69 struct expr *e; 79 struct expr *e;
70 int i; 80 int i;
71 81
72 if (name) { 82 if (name) {
73 in = fopen(name, "r"); 83 in = zconf_fopen(name);
74 if (in)
75 strcpy(conf_filename, name);
76 } else { 84 } else {
77 const char **names = conf_confnames; 85 const char **names = conf_confnames;
78 while ((name = *names++)) { 86 while ((name = *names++)) {
79 name = conf_expand_value(name); 87 name = conf_expand_value(name);
80 in = fopen(name, "r"); 88 in = zconf_fopen(name);
81 if (in) { 89 if (in) {
82 printf("#\n" 90 printf("#\n"
83 "# using defaults found in %s\n" 91 "# using defaults found in %s\n"
84 "#\n", name); 92 "#\n", name);
85 break; 93 break;
86 } 94 }
@@ -88,39 +96,38 @@ int conf_read(const char *name)
88 } 96 }
89 97
90 if (!in) 98 if (!in)
91 return 1; 99 return 1;
92 100
93 for_all_symbols(i, sym) { 101 for_all_symbols(i, sym) {
94 sym->flags |= SYMBOL_NEW; 102 sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
103 sym->flags &= ~SYMBOL_VALID;
95 switch (sym->type) { 104 switch (sym->type) {
96 case S_INT: 105 case S_INT:
97 case S_HEX: 106 case S_HEX:
98 case S_STRING: 107 case S_STRING:
99 if (S_VAL(sym->def)) { 108 if (S_VAL(sym->def))
100 free(S_VAL(sym->def)); 109 free(S_VAL(sym->def));
101 S_VAL(sym->def) = NULL;
102 }
103 default: 110 default:
104 ; 111 S_VAL(sym->def) = NULL;
112 S_TRI(sym->def) = no;
105 } 113 }
106 } 114 }
107 115
108 while (fgets(line, 128, in)) { 116 while (fgets(line, sizeof(line), in)) {
109 lineno++; 117 lineno++;
110 switch (line[0]) { 118 switch (line[0]) {
111 case '#': 119 case '#':
112 if (memcmp(line + 2, "CONFIG_", 7)) 120 if (memcmp(line + 2, "CONFIG_", 7))
113 continue; 121 continue;
114 p = strchr(line + 9, ' '); 122 p = strchr(line + 9, ' ');
115 if (!p) 123 if (!p)
116 continue; 124 continue;
117 *p++ = 0; 125 *p++ = 0;
118 if (strncmp(p, "is not set", 10)) 126 if (strncmp(p, "is not set", 10))
119 continue; 127 continue;
120 //printf("%s -> n\n", line + 9);
121 sym = sym_lookup(line + 9, 0); 128 sym = sym_lookup(line + 9, 0);
122 switch (sym->type) { 129 switch (sym->type) {
123 case S_BOOLEAN: 130 case S_BOOLEAN:
124 case S_TRISTATE: 131 case S_TRISTATE:
125 sym->def = symbol_no.curr; 132 sym->def = symbol_no.curr;
126 sym->flags &= ~SYMBOL_NEW; 133 sym->flags &= ~SYMBOL_NEW;
@@ -136,47 +143,59 @@ int conf_read(const char *name)
136 if (!p) 143 if (!p)
137 continue; 144 continue;
138 *p++ = 0; 145 *p++ = 0;
139 p2 = strchr(p, '\n'); 146 p2 = strchr(p, '\n');
140 if (p2) 147 if (p2)
141 *p2 = 0; 148 *p2 = 0;
142 //printf("%s -> %s\n", line + 7, p);
143 sym = sym_find(line + 7); 149 sym = sym_find(line + 7);
144 if (!sym) { 150 if (!sym) {
145 fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 7); 151 fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 7);
146 break; 152 break;
147 } 153 }
148 switch (sym->type) { 154 switch (sym->type) {
149 case S_BOOLEAN:
150 sym->def = symbol_yes.curr;
151 sym->flags &= ~SYMBOL_NEW;
152 break;
153 case S_TRISTATE: 155 case S_TRISTATE:
154 if (p[0] == 'm') 156 if (p[0] == 'm') {
155 sym->def = symbol_mod.curr; 157 S_TRI(sym->def) = mod;
156 else 158 sym->flags &= ~SYMBOL_NEW;
157 sym->def = symbol_yes.curr; 159 break;
158 sym->flags &= ~SYMBOL_NEW; 160 }
161 case S_BOOLEAN:
162 if (p[0] == 'y') {
163 S_TRI(sym->def) = yes;
164 sym->flags &= ~SYMBOL_NEW;
165 break;
166 }
167 if (p[0] == 'n') {
168 S_TRI(sym->def) = no;
169 sym->flags &= ~SYMBOL_NEW;
170 break;
171 }
159 break; 172 break;
160 case S_STRING: 173 case S_STRING:
161 if (*p++ != '"') 174 if (*p++ != '"')
162 break; 175 break;
163 for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { 176 for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
164 if (*p2 == '"') { 177 if (*p2 == '"') {
165 *p2 = 0; 178 *p2 = 0;
166 break; 179 break;
167 } 180 }
168 memmove(p2, p2 + 1, strlen(p2)); 181 memmove(p2, p2 + 1, strlen(p2));
169 } 182 }
183 if (!p2) {
184 fprintf(stderr, "%s:%d: invalid string found\n", name, lineno);
185 exit(1);
186 }
170 case S_INT: 187 case S_INT:
171 case S_HEX: 188 case S_HEX:
172 if (sym_string_valid(sym, p)) { 189 if (sym_string_valid(sym, p)) {
173 S_VAL(sym->def) = strdup(p); 190 S_VAL(sym->def) = strdup(p);
174 sym->flags &= ~SYMBOL_NEW; 191 sym->flags &= ~SYMBOL_NEW;
175 } else 192 } else {
176 fprintf(stderr, "%s:%d:symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); 193 fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name);
194 exit(1);
195 }
177 break; 196 break;
178 default: 197 default:
179 ; 198 ;
180 } 199 }
181 if (sym_is_choice_value(sym)) { 200 if (sym_is_choice_value(sym)) {
182 prop = sym_get_choice_prop(sym); 201 prop = sym_get_choice_prop(sym);
@@ -349,12 +368,11 @@ int conf_write(const char *name)
349 unlink(".tmpconfig.h"); 368 unlink(".tmpconfig.h");
350 369
351 sprintf(oldname, "%s.old", name); 370 sprintf(oldname, "%s.old", name);
352 rename(name, oldname); 371 rename(name, oldname);
353 if (rename(".tmpconfig", name)) 372 if (rename(".tmpconfig", name))
354 return 1; 373 return 1;
355 strcpy(conf_filename, name);
356 374
357 sym_change_count = 0; 375 sym_change_count = 0;
358 376
359 return 0; 377 return 0;
360} 378}
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index fd9c32a..896a296 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -163,18 +163,21 @@ struct menu {
163 struct menu *next; 163 struct menu *next;
164 struct menu *parent; 164 struct menu *parent;
165 struct menu *list; 165 struct menu *list;
166 struct symbol *sym; 166 struct symbol *sym;
167 struct property *prompt; 167 struct property *prompt;
168 struct expr *dep; 168 struct expr *dep;
169 unsigned int flags;
169 //char *help; 170 //char *help;
170 struct file *file; 171 struct file *file;
171 int lineno; 172 int lineno;
172 //void *data; 173 void *data;
173}; 174};
174 175
176 #define MENU_CHANGED 0x0001
177
175#ifndef SWIG 178#ifndef SWIG
176 179
177extern struct file *file_list; 180extern struct file *file_list;
178extern struct file *current_file; 181extern struct file *current_file;
179struct file *lookup_file(const char *name); 182struct file *lookup_file(const char *name);
180 183
diff --git a/scripts/kconfig/kconfig.i b/scripts/kconfig/kconfig.i
index 699cb13..77405fc 100644
--- a/scripts/kconfig/kconfig.i
+++ b/scripts/kconfig/kconfig.i
@@ -28,12 +28,17 @@ static void expr_to_s_help(void *data, const char *str)
28{ 28{
29 rb_str_cat((VALUE)data, str, strlen(str)); 29 rb_str_cat((VALUE)data, str, strlen(str));
30} 30}
31%} 31%}
32#endif 32#endif
33 33
34#ifdef SWIGPYTHON
35%rename (Property) property;
36%rename (default) def;
37#endif
38
34%immutable; 39%immutable;
35%include "expr.h" 40%include "expr.h"
36#define P(name,type,arg) extern type name arg 41#define P(name,type,arg) extern type name arg
37%include "lkc_proto.h" 42%include "lkc_proto.h"
38%mutable; 43%mutable;
39 44
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 688945b..cdd04a9 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -18,18 +18,20 @@ extern "C" {
18#include "lkc_defs.h" 18#include "lkc_defs.h"
19 #define P(name,type,arg)extern type (*name ## _p) arg 19 #define P(name,type,arg)extern type (*name ## _p) arg
20#endif 20#endif
21#include "lkc_proto.h" 21#include "lkc_proto.h"
22#undef P 22#undef P
23 23
24void symbol_end(char *help); 24#define SRCTREE "srctree"
25
25int zconfparse(void); 26int zconfparse(void);
26void zconfdump(FILE *out); 27void zconfdump(FILE *out);
27 28
28extern int zconfdebug; 29extern int zconfdebug;
29void zconf_starthelp(void); 30void zconf_starthelp(void);
31FILE *zconf_fopen(const char *name);
30void zconf_initscan(const char *name); 32void zconf_initscan(const char *name);
31void zconf_nextfile(const char *name); 33void zconf_nextfile(const char *name);
32int zconf_lineno(void); 34int zconf_lineno(void);
33char *zconf_curname(void); 35char *zconf_curname(void);
34 36
35/* confdata.c */ 37/* confdata.c */
@@ -58,12 +60,13 @@ int file_write_dep(const char *name);
58extern struct menu *current_entry; 60extern struct menu *current_entry;
59extern struct menu *current_menu; 61extern struct menu *current_menu;
60 62
61/* symbol.c */ 63/* symbol.c */
62void sym_init(void); 64void sym_init(void);
63void sym_clear_all_valid(void); 65void sym_clear_all_valid(void);
66void sym_set_changed(struct symbol *sym);
64 67
65static inline tristate sym_get_tristate_value(struct symbol *sym) 68static inline tristate sym_get_tristate_value(struct symbol *sym)
66{ 69{
67 return S_TRI(sym->curr); 70 return S_TRI(sym->curr);
68} 71}
69 72
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index dec8603..eba5ff7 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -1,20 +1,25 @@
1/* 1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
4 *
5 * Introduced single menu mode (show all sub-menus in one large tree).
6 * 2002-11-06 Petr Baudis <pasky@ucw.cz>
4 */ 7 */
5 8
6#include <sys/ioctl.h> 9#include <sys/ioctl.h>
7#include <sys/wait.h> 10#include <sys/wait.h>
8#include <ctype.h> 11#include <ctype.h>
9#include <errno.h> 12#include <errno.h>
10#include <fcntl.h> 13#include <fcntl.h>
14#include <limits.h>
11#include <signal.h> 15#include <signal.h>
12#include <stdarg.h> 16#include <stdarg.h>
13#include <stdlib.h> 17#include <stdlib.h>
14#include <string.h> 18#include <string.h>
19#include <termios.h>
15#include <unistd.h> 20#include <unistd.h>
16 21
17#define LKC_DIRECT_LINK 22#define LKC_DIRECT_LINK
18#include "lkc.h" 23#include "lkc.h"
19 24
20static char menu_backtitle[128]; 25static char menu_backtitle[128];
@@ -41,52 +46,55 @@ inputbox_instructions_string[] =
41 "Please enter a string value. " 46 "Please enter a string value. "
42 "Use the <TAB> key to move from the input field to the buttons below it.", 47 "Use the <TAB> key to move from the input field to the buttons below it.",
43setmod_text[] = 48setmod_text[] =
44 "This feature depends on another which has been configured as a module.\n" 49 "This feature depends on another which has been configured as a module.\n"
45 "As a result, this feature will be built as a module.", 50 "As a result, this feature will be built as a module.",
46nohelp_text[] = 51nohelp_text[] =
47 "There is no help available for this option.\n", 52 "There is no help available for this kernel option.\n",
48load_config_text[] = 53load_config_text[] =
49 "Enter the name of the configuration file you wish to load. " 54 "Enter the name of the configuration file you wish to load. "
50 "Accept the name shown to restore the configuration you " 55 "Accept the name shown to restore the configuration you "
51 "last retrieved. Leave blank to abort.", 56 "last retrieved. Leave blank to abort.",
52load_config_help[] = 57load_config_help[] =
53 "\n" 58 "\n"
54 "For various reasons, one may wish to keep several different\n" 59 "For various reasons, one may wish to keep several different kernel\n"
55 "configurations available on a single machine.\n" 60 "configurations available on a single machine.\n"
56 "\n" 61 "\n"
57 "If you have saved a previous configuration in a file other than the\n" 62 "If you have saved a previous configuration in a file other than the\n"
58 "default, entering the name of the file here will allow you\n" 63 "kernel's default, entering the name of the file here will allow you\n"
59 "to modify that configuration.\n" 64 "to modify that configuration.\n"
60 "\n" 65 "\n"
61 "If you are uncertain, then you have probably never used alternate\n" 66 "If you are uncertain, then you have probably never used alternate\n"
62 "configuration files. You should therefor leave this blank to abort.\n", 67 "configuration files. You should therefor leave this blank to abort.\n",
63save_config_text[] = 68save_config_text[] =
64 "Enter a filename to which this configuration should be saved " 69 "Enter a filename to which this configuration should be saved "
65 "as an alternate. Leave blank to abort.", 70 "as an alternate. Leave blank to abort.",
66save_config_help[] = 71save_config_help[] =
67 "\n" 72 "\n"
68 "For various reasons, one may wish to keep different\n" 73 "For various reasons, one may wish to keep different kernel\n"
69 "configurations available on a single machine.\n" 74 "configurations available on a single machine.\n"
70 "\n" 75 "\n"
71 "Entering a file name here will allow you to later retrieve, modify\n" 76 "Entering a file name here will allow you to later retrieve, modify\n"
72 "and use the current configuration as an alternate to whatever\n" 77 "and use the current configuration as an alternate to whatever\n"
73 "configuration options you have selected at that time.\n" 78 "configuration options you have selected at that time.\n"
74 "\n" 79 "\n"
75 "If you are uncertain what all this means then you should probably\n" 80 "If you are uncertain what all this means then you should probably\n"
76 "leave this blank.\n" 81 "leave this blank.\n"
77; 82;
78 83
79static char buf[4096], *bufptr = buf; 84static char buf[4096], *bufptr = buf;
80static char input_buf[4096]; 85static char input_buf[4096];
86static char filename[PATH_MAX+1] = ".config";
81static char *args[1024], **argptr = args; 87static char *args[1024], **argptr = args;
82static int indent = 0; 88static int indent = 0;
89static struct termios ios_org;
83static int rows, cols; 90static int rows, cols;
84static struct menu *current_menu; 91static struct menu *current_menu;
85static int child_count; 92static int child_count;
86static int do_resize; 93static int do_resize;
94static int single_menu_mode;
87 95
88static void conf(struct menu *menu); 96static void conf(struct menu *menu);
89static void conf_choice(struct menu *menu); 97static void conf_choice(struct menu *menu);
90static void conf_string(struct menu *menu); 98static void conf_string(struct menu *menu);
91static void conf_load(void); 99static void conf_load(void);
92static void conf_save(void); 100static void conf_save(void);
@@ -100,19 +108,34 @@ static int cprint1(const char *fmt, ...);
100static void cprint_done(void); 108static void cprint_done(void);
101static int cprint(const char *fmt, ...); 109static int cprint(const char *fmt, ...);
102 110
103static void init_wsize(void) 111static void init_wsize(void)
104{ 112{
105 struct winsize ws; 113 struct winsize ws;
114 char *env;
106 115
107 if (ioctl(1, TIOCGWINSZ, &ws) == -1) { 116 if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
108 rows = 24; 117 rows = 24;
109 cols = 80; 118 cols = 80;
110 } else { 119 } else {
111 rows = ws.ws_row; 120 rows = ws.ws_row;
112 cols = ws.ws_col; 121 cols = ws.ws_col;
122 if (!rows) {
123 env = getenv("LINES");
124 if (env)
125 rows = atoi(env);
126 if (!rows)
127 rows = 24;
128 }
129 if (!cols) {
130 env = getenv("COLUMNS");
131 if (env)
132 cols = atoi(env);
133 if (!cols)
134 cols = 80;
135 }
113 } 136 }
114 137
115 if (rows < 19 || cols < 80) { 138 if (rows < 19 || cols < 80) {
116 fprintf(stderr, "Your display is too small to run Menuconfig!\n"); 139 fprintf(stderr, "Your display is too small to run Menuconfig!\n");
117 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); 140 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n");
118 exit(1); 141 exit(1);
@@ -271,16 +294,26 @@ static void build_conf(struct menu *menu)
271 if (prop && menu != current_menu) { 294 if (prop && menu != current_menu) {
272 const char *prompt = menu_get_prompt(menu); 295 const char *prompt = menu_get_prompt(menu);
273 switch (prop->type) { 296 switch (prop->type) {
274 case P_MENU: 297 case P_MENU:
275 child_count++; 298 child_count++;
276 cprint("m%p", menu); 299 cprint("m%p", menu);
277 if (menu->parent != &rootmenu) 300
278 cprint1(" %*c", indent + 1, ' '); 301 if (single_menu_mode) {
279 cprint1("%s --->", prompt); 302 cprint1("%s%*c%s",
303 menu->data ? "-->" : "++>",
304 indent + 1, ' ', prompt);
305 } else {
306 if (menu->parent != &rootmenu)
307 cprint1(" %*c", indent + 1, ' ');
308 cprint1("%s --->", prompt);
309 }
310
280 cprint_done(); 311 cprint_done();
312 if (single_menu_mode && menu->data)
313 goto conf_childs;
281 return; 314 return;
282 default: 315 default:
283 if (prompt) { 316 if (prompt) {
284 child_count++; 317 child_count++;
285 cprint(":%p", menu); 318 cprint(":%p", menu);
286 cprint("---%*c%s", indent + 1, ' ', prompt); 319 cprint("---%*c%s", indent + 1, ' ', prompt);
@@ -389,12 +422,13 @@ static void conf(struct menu *menu)
389 struct menu *submenu; 422 struct menu *submenu;
390 const char *prompt = menu_get_prompt(menu); 423 const char *prompt = menu_get_prompt(menu);
391 struct symbol *sym; 424 struct symbol *sym;
392 char active_entry[40]; 425 char active_entry[40];
393 int stat, type, i; 426 int stat, type, i;
394 427
428 unlink("lxdialog.scrltmp");
395 active_entry[0] = 0; 429 active_entry[0] = 0;
396 while (1) { 430 while (1) {
397 cprint_init(); 431 cprint_init();
398 cprint("--title"); 432 cprint("--title");
399 cprint("%s", prompt ? prompt : "Main Menu"); 433 cprint("%s", prompt ? prompt : "Main Menu");
400 cprint("--menu"); 434 cprint("--menu");
@@ -439,13 +473,16 @@ static void conf(struct menu *menu)
439 sym = submenu->sym; 473 sym = submenu->sym;
440 474
441 switch (stat) { 475 switch (stat) {
442 case 0: 476 case 0:
443 switch (type) { 477 switch (type) {
444 case 'm': 478 case 'm':
445 conf(submenu); 479 if (single_menu_mode)
480 submenu->data = (void *) !submenu->data;
481 else
482 conf(submenu);
446 break; 483 break;
447 case 't': 484 case 't':
448 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) 485 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
449 conf_choice(submenu); 486 conf_choice(submenu);
450 break; 487 break;
451 case 's': 488 case 's':
@@ -481,12 +518,14 @@ static void conf(struct menu *menu)
481 if (type == 't') 518 if (type == 't')
482 sym_set_tristate_value(sym, mod); 519 sym_set_tristate_value(sym, mod);
483 break; 520 break;
484 case 6: 521 case 6:
485 if (type == 't') 522 if (type == 't')
486 sym_toggle_tristate_value(sym); 523 sym_toggle_tristate_value(sym);
524 else if (type == 'm')
525 conf(submenu);
487 break; 526 break;
488 } 527 }
489 } 528 }
490} 529}
491 530
492static void show_textbox(const char *title, const char *text, int r, int c) 531static void show_textbox(const char *title, const char *text, int r, int c)
@@ -515,17 +554,25 @@ static void show_helptext(const char *title, const char *text)
515 show_textbox(title, text, rows, cols); 554 show_textbox(title, text, rows, cols);
516} 555}
517 556
518static void show_help(struct menu *menu) 557static void show_help(struct menu *menu)
519{ 558{
520 const char *help; 559 const char *help;
560 char *helptext;
561 struct symbol *sym = menu->sym;
521 562
522 help = menu->sym->help; 563 help = sym->help;
523 if (!help) 564 if (!help)
524 help = nohelp_text; 565 help = nohelp_text;
525 show_helptext(menu_get_prompt(menu), help); 566 if (sym->name) {
567 helptext = malloc(strlen(sym->name) + strlen(help) + 16);
568 sprintf(helptext, "CONFIG_%s:\n\n%s", sym->name, help);
569 show_helptext(menu_get_prompt(menu), helptext);
570 free(helptext);
571 } else
572 show_helptext(menu_get_prompt(menu), help);
526} 573}
527 574
528static void show_readme(void) 575static void show_readme(void)
529{ 576{
530 do { 577 do {
531 cprint_init(); 578 cprint_init();
@@ -628,13 +675,13 @@ static void conf_load(void)
628 while (1) { 675 while (1) {
629 cprint_init(); 676 cprint_init();
630 cprint("--inputbox"); 677 cprint("--inputbox");
631 cprint(load_config_text); 678 cprint(load_config_text);
632 cprint("11"); 679 cprint("11");
633 cprint("55"); 680 cprint("55");
634 cprint("%s", conf_filename); 681 cprint("%s", filename);
635 stat = exec_conf(); 682 stat = exec_conf();
636 switch(stat) { 683 switch(stat) {
637 case 0: 684 case 0:
638 if (!input_buf[0]) 685 if (!input_buf[0])
639 return; 686 return;
640 if (!conf_read(input_buf)) 687 if (!conf_read(input_buf))
@@ -657,13 +704,13 @@ static void conf_save(void)
657 while (1) { 704 while (1) {
658 cprint_init(); 705 cprint_init();
659 cprint("--inputbox"); 706 cprint("--inputbox");
660 cprint(save_config_text); 707 cprint(save_config_text);
661 cprint("11"); 708 cprint("11");
662 cprint("55"); 709 cprint("55");
663 cprint("%s", conf_filename); 710 cprint("%s", filename);
664 stat = exec_conf(); 711 stat = exec_conf();
665 switch(stat) { 712 switch(stat) {
666 case 0: 713 case 0:
667 if (!input_buf[0]) 714 if (!input_buf[0])
668 return; 715 return;
669 if (!conf_write(input_buf)) 716 if (!conf_write(input_buf))
@@ -676,20 +723,41 @@ static void conf_save(void)
676 case 255: 723 case 255:
677 return; 724 return;
678 } 725 }
679 } 726 }
680} 727}
681 728
729static void conf_cleanup(void)
730{
731 tcsetattr(1, TCSAFLUSH, &ios_org);
732 unlink(".help.tmp");
733 unlink("lxdialog.scrltmp");
734}
735
682int main(int ac, char **av) 736int main(int ac, char **av)
683{ 737{
738 struct symbol *sym;
739 char *mode;
684 int stat; 740 int stat;
741
685 conf_parse(av[1]); 742 conf_parse(av[1]);
686 conf_read(NULL); 743 conf_read(NULL);
687 744
688 sprintf(menu_backtitle, "Configuration"); 745 sym = sym_lookup("KERNELRELEASE", 0);
746 sym_calc_value(sym);
747 sprintf(menu_backtitle, "Linux Kernel v%s Configuration",
748 sym_get_string_value(sym));
749
750 mode = getenv("MENUCONFIG_MODE");
751 if (mode) {
752 if (!strcasecmp(mode, "single_menu"))
753 single_menu_mode = 1;
754 }
689 755
756 tcgetattr(1, &ios_org);
757 atexit(conf_cleanup);
690 init_wsize(); 758 init_wsize();
691 conf(&rootmenu); 759 conf(&rootmenu);
692 760
693 do { 761 do {
694 cprint_init(); 762 cprint_init();
695 cprint("--yesno"); 763 cprint("--yesno");
@@ -699,13 +767,14 @@ int main(int ac, char **av)
699 stat = exec_conf(); 767 stat = exec_conf();
700 } while (stat < 0); 768 } while (stat < 0);
701 769
702 if (stat == 0) { 770 if (stat == 0) {
703 conf_write(NULL); 771 conf_write(NULL);
704 printf("\n\n" 772 printf("\n\n"
705 "*** End of configuration.\n" 773 "*** End of Linux kernel configuration.\n"
706 "*** Check the top-level Makefile for additional configuration.\n"); 774 "*** Check the top-level Makefile for additional configuration.\n"
775 "*** Next, you may run 'make bzImage', 'make bzdisk', or 'make install'.\n\n");
707 } else 776 } else
708 printf("\n\nYour configuration changes were NOT saved.\n\n"); 777 printf("\n\nYour kernel configuration changes were NOT saved.\n\n");
709 778
710 return 0; 779 return 0;
711} 780}
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 4595110..24be0ec 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -287,13 +287,13 @@ struct file *file_lookup(const char *name)
287int file_write_dep(const char *name) 287int file_write_dep(const char *name)
288{ 288{
289 struct file *file; 289 struct file *file;
290 FILE *out; 290 FILE *out;
291 291
292 if (!name) 292 if (!name)
293 name = "..config.cmd"; 293 name = ".config.cmd";
294 out = fopen("..config.tmp", "w"); 294 out = fopen("..config.tmp", "w");
295 if (!out) 295 if (!out)
296 return 1; 296 return 1;
297 fprintf(out, "deps_config := \\\n"); 297 fprintf(out, "deps_config := \\\n");
298 for (file = file_list; file; file = file->next) { 298 for (file = file_list; file; file = file->next) {
299 if (file->next) 299 if (file->next)
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index feefa1c..bed541d 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -14,21 +14,28 @@
14#include <qmenubar.h> 14#include <qmenubar.h>
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16#include <qaction.h> 16#include <qaction.h>
17#include <qheader.h> 17#include <qheader.h>
18#include <qfiledialog.h> 18#include <qfiledialog.h>
19#include <qregexp.h> 19#include <qregexp.h>
20#if QT_VERSION >= 300
21#include <qsettings.h>
22#endif
23
20#include <stdlib.h> 24#include <stdlib.h>
21 25
22#include "lkc.h" 26#include "lkc.h"
23#include "qconf.h" 27#include "qconf.h"
24 28
25#include "qconf.moc" 29#include "qconf.moc"
26#include "images.c" 30#include "images.c"
27 31
28static QApplication *configApp; 32static QApplication *configApp;
33#if QT_VERSION >= 300
34static QSettings *configSettings;
35#endif
29 36
30/* 37/*
31 * update all the children of a menu entry 38 * update all the children of a menu entry
32 * removes/adds the entries from the parent widget as necessary 39 * removes/adds the entries from the parent widget as necessary
33 * 40 *
34 * parent: either the menu list widget or a menu entry widget 41 * parent: either the menu list widget or a menu entry widget
@@ -70,15 +77,23 @@ static void updateMenuList(P* parent, struct menu* menu)
70 break; 77 break;
71 } 78 }
72 79
73 visible = menu_is_visible(child); 80 visible = menu_is_visible(child);
74 if (showAll || visible) { 81 if (showAll || visible) {
75 if (!item || item->menu != child) 82 if (!item || item->menu != child)
76 item = new ConfigItem(parent, last, child); 83 item = new ConfigItem(parent, last, child, visible);
77 item->visible = visible; 84 else {
78 item->updateMenu(); 85 item->visible = visible;
86 if (item->updateNeeded()) {
87 ConfigItem* i = (ConfigItem*)child->data;
88 for (; i; i = i->nextItem) {
89 i->updateMenu();
90 }
91 } else if (list->updateAll)
92 item->updateMenu();
93 }
79 94
80 if (mode == fullMode || mode == menuMode || 95 if (mode == fullMode || mode == menuMode ||
81 (type != P_MENU && type != P_ROOTMENU)) 96 (type != P_MENU && type != P_ROOTMENU))
82 updateMenuList(item, child); 97 updateMenuList(item, child);
83 else 98 else
84 updateMenuList(item, 0); 99 updateMenuList(item, 0);
@@ -117,42 +132,28 @@ void ConfigItem::updateMenu(void)
117 ConfigList* list; 132 ConfigList* list;
118 struct symbol* sym; 133 struct symbol* sym;
119 QString prompt; 134 QString prompt;
120 int type; 135 int type;
121 enum prop_type ptype; 136 enum prop_type ptype;
122 tristate expr; 137 tristate expr;
123 bool update;
124 138
125 list = listView(); 139 list = listView();
126 update = doInit;
127 if (update)
128 doInit = false;
129 else
130 update = list->updateAll;
131 140
132 sym = menu->sym; 141 sym = menu->sym;
133 if (!sym) { 142 if (!sym) {
134 if (update) { 143 setText(promptColIdx, menu_get_prompt(menu));
135 setText(promptColIdx, menu_get_prompt(menu)); 144 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
136 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; 145 if ((ptype == P_ROOTMENU || ptype == P_MENU) &&
137 if ((ptype == P_ROOTMENU || ptype == P_MENU) && 146 (list->mode == singleMode || list->mode == symbolMode))
138 (list->mode == singleMode || list->mode == symbolMode)) 147 setPixmap(promptColIdx, list->menuPix);
139 setPixmap(promptColIdx, list->menuPix); 148 else
140 else 149 setPixmap(promptColIdx, 0);
141 setPixmap(promptColIdx, 0);
142 }
143 return; 150 return;
144 } 151 }
145 152
146 sym_calc_value(sym); 153 setText(nameColIdx, sym->name);
147 if (!(sym->flags & SYMBOL_CHANGED) && !update)
148 return;
149
150 sym->flags &= ~SYMBOL_CHANGED;
151
152 setText(nameColIdx, menu->sym->name);
153 154
154 type = sym_get_type(sym); 155 type = sym_get_type(sym);
155 switch (type) { 156 switch (type) {
156 case S_BOOLEAN: 157 case S_BOOLEAN:
157 case S_TRISTATE: 158 case S_TRISTATE:
158 char ch; 159 char ch;
@@ -201,13 +202,15 @@ void ConfigItem::updateMenu(void)
201 case S_HEX: 202 case S_HEX:
202 case S_STRING: 203 case S_STRING:
203 const char* data; 204 const char* data;
204 205
205 data = sym_get_string_value(sym); 206 data = sym_get_string_value(sym);
206#if QT_VERSION >= 300 207#if QT_VERSION >= 300
207 setRenameEnabled(list->mapIdx(dataColIdx), TRUE); 208 int i = list->mapIdx(dataColIdx);
209 if (i >= 0)
210 setRenameEnabled(i, TRUE);
208#endif 211#endif
209 setText(dataColIdx, data); 212 setText(dataColIdx, data);
210 if (type == S_STRING) 213 if (type == S_STRING)
211 prompt.sprintf("%s: %s", menu_get_prompt(menu), data); 214 prompt.sprintf("%s: %s", menu_get_prompt(menu), data);
212 else 215 else
213 prompt.sprintf("(%s) %s", data, menu_get_prompt(menu)); 216 prompt.sprintf("(%s) %s", data, menu_get_prompt(menu));
@@ -215,12 +218,24 @@ void ConfigItem::updateMenu(void)
215 } 218 }
216 if (!sym_has_value(sym) && visible) 219 if (!sym_has_value(sym) && visible)
217 prompt += " (NEW)"; 220 prompt += " (NEW)";
218 setText(promptColIdx, prompt); 221 setText(promptColIdx, prompt);
219} 222}
220 223
224bool ConfigItem::updateNeeded(void)
225{
226 struct symbol* sym = menu->sym;
227 if (sym)
228 sym_calc_value(sym);
229 if (menu->flags & MENU_CHANGED) {
230 menu->flags &= ~MENU_CHANGED;
231 return true;
232 }
233 return false;
234}
235
221void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) 236void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align)
222{ 237{
223 ConfigList* list = listView(); 238 ConfigList* list = listView();
224 239
225 if (visible) { 240 if (visible) {
226 if (isSelected() && !list->hasFocus() && list->mode == menuMode) 241 if (isSelected() && !list->hasFocus() && list->mode == menuMode)
@@ -234,27 +249,34 @@ void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int w
234/* 249/*
235 * construct a menu entry 250 * construct a menu entry
236 */ 251 */
237void ConfigItem::init(void) 252void ConfigItem::init(void)
238{ 253{
239 ConfigList* list = listView(); 254 ConfigList* list = listView();
240#if QT_VERSION < 300 255 nextItem = (ConfigItem*)menu->data;
241 visible = TRUE; 256 menu->data = this;
242#endif 257
243 //menu->data = this;
244 if (list->mode != fullMode) 258 if (list->mode != fullMode)
245 setOpen(TRUE); 259 setOpen(TRUE);
246 doInit= true; 260 if (menu->sym)
261 sym_calc_value(menu->sym);
262 updateMenu();
247} 263}
248 264
249/* 265/*
250 * destruct a menu entry 266 * destruct a menu entry
251 */ 267 */
252ConfigItem::~ConfigItem(void) 268ConfigItem::~ConfigItem(void)
253{ 269{
254 //menu->data = 0; 270 ConfigItem** ip = &(ConfigItem*)menu->data;
271 for (; *ip; ip = &(*ip)->nextItem) {
272 if (*ip == this) {
273 *ip = nextItem;
274 break;
275 }
276 }
255} 277}
256 278
257void ConfigLineEdit::show(ConfigItem* i) 279void ConfigLineEdit::show(ConfigItem* i)
258{ 280{
259 item = i; 281 item = i;
260 if (sym_get_string_value(item->menu->sym)) 282 if (sym_get_string_value(item->menu->sym))
@@ -270,23 +292,24 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
270 switch (e->key()) { 292 switch (e->key()) {
271 case Key_Escape: 293 case Key_Escape:
272 break; 294 break;
273 case Key_Return: 295 case Key_Return:
274 case Key_Enter: 296 case Key_Enter:
275 sym_set_string_value(item->menu->sym, text().latin1()); 297 sym_set_string_value(item->menu->sym, text().latin1());
276 emit lineChanged(item); 298 parent()->updateList(item);
277 break; 299 break;
278 default: 300 default:
279 Parent::keyPressEvent(e); 301 Parent::keyPressEvent(e);
280 return; 302 return;
281 } 303 }
282 e->accept(); 304 e->accept();
305 parent()->list->setFocus();
283 hide(); 306 hide();
284} 307}
285 308
286ConfigList::ConfigList(QWidget* p, ConfigView* cv) 309ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv)
287 : Parent(p), cview(cv), 310 : Parent(p), cview(cv),
288 updateAll(false), 311 updateAll(false),
289 symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), 312 symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
290 choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), menuPix(xpm_menu), menuInvPix(xpm_menu_inv), 313 choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), menuPix(xpm_menu), menuInvPix(xpm_menu_inv),
291 showAll(false), showName(false), showRange(false), showData(false), 314 showAll(false), showName(false), showRange(false), showData(false),
292 rootEntry(0) 315 rootEntry(0)
@@ -349,12 +372,13 @@ void ConfigList::updateSelection(void)
349} 372}
350 373
351void ConfigList::updateList(ConfigItem* item) 374void ConfigList::updateList(ConfigItem* item)
352{ 375{
353 (void)item;// unused so far 376 (void)item;// unused so far
354 updateMenuList(this, rootEntry); 377 updateMenuList(this, rootEntry);
378 triggerUpdate();
355} 379}
356 380
357void ConfigList::setAllOpen(bool open) 381void ConfigList::setAllOpen(bool open)
358{ 382{
359 QListViewItemIterator it(this); 383 QListViewItemIterator it(this);
360 384
@@ -379,13 +403,13 @@ void ConfigList::setValue(ConfigItem* item, tristate val)
379 oldval = sym_get_tristate_value(sym); 403 oldval = sym_get_tristate_value(sym);
380 404
381 if (!sym_set_tristate_value(sym, val)) 405 if (!sym_set_tristate_value(sym, val))
382 return; 406 return;
383 if (oldval == no && item->menu->list) 407 if (oldval == no && item->menu->list)
384 item->setOpen(TRUE); 408 item->setOpen(TRUE);
385 emit symbolChanged(item); 409 parent()->updateList(item);
386 break; 410 break;
387 } 411 }
388} 412}
389 413
390void ConfigList::changeValue(ConfigItem* item) 414void ConfigList::changeValue(ConfigItem* item)
391{ 415{
@@ -411,23 +435,23 @@ void ConfigList::changeValue(ConfigItem* item)
411 if (oldexpr == newexpr) 435 if (oldexpr == newexpr)
412 item->setOpen(!item->isOpen()); 436 item->setOpen(!item->isOpen());
413 else if (oldexpr == no) 437 else if (oldexpr == no)
414 item->setOpen(TRUE); 438 item->setOpen(TRUE);
415 } 439 }
416 if (oldexpr != newexpr) 440 if (oldexpr != newexpr)
417 emit symbolChanged(item); 441 parent()->updateList(item);
418 break; 442 break;
419 case S_INT: 443 case S_INT:
420 case S_HEX: 444 case S_HEX:
421 case S_STRING: 445 case S_STRING:
422#if QT_VERSION >= 300 446#if QT_VERSION >= 300
423 if (colMap[dataColIdx] >= 0) 447 if (colMap[dataColIdx] >= 0)
424 item->startRename(colMap[dataColIdx]); 448 item->startRename(colMap[dataColIdx]);
425 else 449 else
426#endif 450#endif
427 lineEdit->show(item); 451 parent()->lineEdit->show(item);
428 break; 452 break;
429 } 453 }
430} 454}
431 455
432void ConfigList::setRootMenu(struct menu *menu) 456void ConfigList::setRootMenu(struct menu *menu)
433{ 457{
@@ -513,13 +537,13 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
513} 537}
514 538
515void ConfigList::contentsMousePressEvent(QMouseEvent* e) 539void ConfigList::contentsMousePressEvent(QMouseEvent* e)
516{ 540{
517 //QPoint p(contentsToViewport(e->pos())); 541 //QPoint p(contentsToViewport(e->pos()));
518 //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); 542 //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y());
519 QListView::contentsMousePressEvent(e); 543 Parent::contentsMousePressEvent(e);
520} 544}
521 545
522void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) 546void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e)
523{ 547{
524 QPoint p(contentsToViewport(e->pos())); 548 QPoint p(contentsToViewport(e->pos()));
525 ConfigItem* item = (ConfigItem*)itemAt(p); 549 ConfigItem* item = (ConfigItem*)itemAt(p);
@@ -560,20 +584,20 @@ void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e)
560 changeValue(item); 584 changeValue(item);
561 break; 585 break;
562 } 586 }
563 587
564skip: 588skip:
565 //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); 589 //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y());
566 QListView::contentsMouseReleaseEvent(e); 590 Parent::contentsMouseReleaseEvent(e);
567} 591}
568 592
569void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) 593void ConfigList::contentsMouseMoveEvent(QMouseEvent* e)
570{ 594{
571 //QPoint p(contentsToViewport(e->pos())); 595 //QPoint p(contentsToViewport(e->pos()));
572 //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); 596 //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y());
573 QListView::contentsMouseMoveEvent(e); 597 Parent::contentsMouseMoveEvent(e);
574} 598}
575 599
576void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) 600void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e)
577{ 601{
578 QPoint p(contentsToViewport(e->pos())); 602 QPoint p(contentsToViewport(e->pos()));
579 ConfigItem* item = (ConfigItem*)itemAt(p); 603 ConfigItem* item = (ConfigItem*)itemAt(p);
@@ -584,16 +608,18 @@ void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e)
584 goto skip; 608 goto skip;
585 menu = item->menu; 609 menu = item->menu;
586 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; 610 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
587 if ((ptype == P_ROOTMENU || ptype == P_MENU) && 611 if ((ptype == P_ROOTMENU || ptype == P_MENU) &&
588 (mode == singleMode || mode == symbolMode)) 612 (mode == singleMode || mode == symbolMode))
589 emit menuSelected(menu); 613 emit menuSelected(menu);
614 else if (menu->sym)
615 changeValue(item);
590 616
591skip: 617skip:
592 //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); 618 //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y());
593 QListView::contentsMouseDoubleClickEvent(e); 619 Parent::contentsMouseDoubleClickEvent(e);
594} 620}
595 621
596void ConfigList::focusInEvent(QFocusEvent *e) 622void ConfigList::focusInEvent(QFocusEvent *e)
597{ 623{
598 Parent::focusInEvent(e); 624 Parent::focusInEvent(e);
599 625
@@ -602,43 +628,97 @@ void ConfigList::focusInEvent(QFocusEvent *e)
602 return; 628 return;
603 629
604 setSelected(item, TRUE); 630 setSelected(item, TRUE);
605 emit gotFocus(); 631 emit gotFocus();
606} 632}
607 633
634ConfigView* ConfigView::viewList;
635
636ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview)
637 : Parent(parent)
638{
639 list = new ConfigList(this, cview);
640 lineEdit = new ConfigLineEdit(this);
641 lineEdit->hide();
642
643 this->nextView = viewList;
644 viewList = this;
645}
646
647ConfigView::~ConfigView(void)
648{
649 ConfigView** vp;
650
651 for (vp = &viewList; *vp; vp = &(*vp)->nextView) {
652 if (*vp == this) {
653 *vp = nextView;
654 break;
655 }
656 }
657}
658
659void ConfigView::updateList(ConfigItem* item)
660{
661 ConfigView* v;
662
663 for (v = viewList; v; v = v->nextView)
664 v->list->updateList(item);
665}
666
667void ConfigView::updateListAll(void)
668{
669 ConfigView* v;
670
671 for (v = viewList; v; v = v->nextView)
672 v->list->updateListAll();
673}
674
608/* 675/*
609 * Construct the complete config widget 676 * Construct the complete config widget
610 */ 677 */
611ConfigView::ConfigView(void) 678ConfigMainWindow::ConfigMainWindow(void)
612{ 679{
680 ConfigView* view;
613 QMenuBar* menu; 681 QMenuBar* menu;
614 QSplitter* split1; 682 QSplitter* split1;
615 QSplitter* split2; 683 QSplitter* split2;
684 bool ok;
685 int x, y, width, height;
686
687 QWidget *d = configApp->desktop();
688
689#if QT_VERSION >= 300
690 width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64);
691 height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64);
692 resize(width, height);
693 x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok);
694 if (ok)
695 y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok);
696 if (ok)
697 move(x, y);
698#else
699 width = d->width() - 64;
700 height = d->height() - 64;
701 resize(width, height);
702#endif
616 703
617 showDebug = false; 704 showDebug = false;
618 705
619 split1 = new QSplitter(this); 706 split1 = new QSplitter(this);
620 split1->setOrientation(QSplitter::Horizontal); 707 split1->setOrientation(QSplitter::Horizontal);
621 setCentralWidget(split1); 708 setCentralWidget(split1);
622 709
623 menuList = new ConfigList(split1, this); 710 view = new ConfigView(split1, this);
711 menuList = view->list;
624 712
625 split2 = new QSplitter(split1); 713 split2 = new QSplitter(split1);
626 split2->setOrientation(QSplitter::Vertical); 714 split2->setOrientation(QSplitter::Vertical);
627 715
628 // create config tree 716 // create config tree
629 QVBox* box = new QVBox(split2); 717 view = new ConfigView(split2, this);
630 configList = new ConfigList(box, this); 718 configList = view->list;
631 configList->lineEdit = new ConfigLineEdit(box);
632 configList->lineEdit->hide();
633 configList->connect(configList, SIGNAL(symbolChanged(ConfigItem*)),
634 configList, SLOT(updateList(ConfigItem*)));
635 configList->connect(configList, SIGNAL(symbolChanged(ConfigItem*)),
636 menuList, SLOT(updateList(ConfigItem*)));
637 configList->connect(configList->lineEdit, SIGNAL(lineChanged(ConfigItem*)),
638 SLOT(updateList(ConfigItem*)));
639 719
640 helpText = new QTextView(split2); 720 helpText = new QTextView(split2);
641 helpText->setTextFormat(Qt::RichText); 721 helpText->setTextFormat(Qt::RichText);
642 722
643 setTabOrder(configList, helpText); 723 setTabOrder(configList, helpText);
644 configList->setFocus(); 724 configList->setFocus();
@@ -682,12 +762,17 @@ ConfigView::ConfigView(void)
682 connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool))); 762 connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool)));
683 QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); 763 QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this);
684 showDebugAction->setToggleAction(TRUE); 764 showDebugAction->setToggleAction(TRUE);
685 showDebugAction->setOn(showDebug); 765 showDebugAction->setOn(showDebug);
686 connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); 766 connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
687 767
768 QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this);
769 connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
770 QAction *showAboutAction = new QAction(NULL, "About", 0, this);
771 connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
772
688 // init tool bar 773 // init tool bar
689 backAction->addTo(toolBar); 774 backAction->addTo(toolBar);
690 toolBar->addSeparator(); 775 toolBar->addSeparator();
691 loadAction->addTo(toolBar); 776 loadAction->addTo(toolBar);
692 saveAction->addTo(toolBar); 777 saveAction->addTo(toolBar);
693 toolBar->addSeparator(); 778 toolBar->addSeparator();
@@ -711,12 +796,19 @@ ConfigView::ConfigView(void)
711 showRangeAction->addTo(optionMenu); 796 showRangeAction->addTo(optionMenu);
712 showDataAction->addTo(optionMenu); 797 showDataAction->addTo(optionMenu);
713 optionMenu->insertSeparator(); 798 optionMenu->insertSeparator();
714 showAllAction->addTo(optionMenu); 799 showAllAction->addTo(optionMenu);
715 showDebugAction->addTo(optionMenu); 800 showDebugAction->addTo(optionMenu);
716 801
802 // create help menu
803 QPopupMenu* helpMenu = new QPopupMenu(this);
804 menu->insertSeparator();
805 menu->insertItem("&Help", helpMenu);
806 showIntroAction->addTo(helpMenu);
807 showAboutAction->addTo(helpMenu);
808
717 connect(configList, SIGNAL(menuSelected(struct menu *)), 809 connect(configList, SIGNAL(menuSelected(struct menu *)),
718 SLOT(changeMenu(struct menu *))); 810 SLOT(changeMenu(struct menu *)));
719 connect(configList, SIGNAL(parentSelected()), 811 connect(configList, SIGNAL(parentSelected()),
720 SLOT(goBack())); 812 SLOT(goBack()));
721 connect(menuList, SIGNAL(menuSelected(struct menu *)), 813 connect(menuList, SIGNAL(menuSelected(struct menu *)),
722 SLOT(changeMenu(struct menu *))); 814 SLOT(changeMenu(struct menu *)));
@@ -766,18 +858,18 @@ static void expr_print_help(void *data, const char *str)
766 ((QString*)data)->append(print_filter(str)); 858 ((QString*)data)->append(print_filter(str));
767} 859}
768 860
769/* 861/*
770 * display a new help entry as soon as a new menu entry is selected 862 * display a new help entry as soon as a new menu entry is selected
771 */ 863 */
772void ConfigView::setHelp(QListViewItem* item) 864void ConfigMainWindow::setHelp(QListViewItem* item)
773{ 865{
774 struct symbol* sym; 866 struct symbol* sym;
775 struct menu* menu; 867 struct menu* menu;
776 868
777 configList->lineEdit->hide(); 869 configList->parent()->lineEdit->hide();
778 if (item) { 870 if (item) {
779 QString head, debug, help; 871 QString head, debug, help;
780 menu = ((ConfigItem*)item)->menu; 872 menu = ((ConfigItem*)item)->menu;
781 sym = menu->sym; 873 sym = menu->sym;
782 if (sym) { 874 if (sym) {
783 if (menu->prompt) { 875 if (menu->prompt) {
@@ -854,54 +946,55 @@ void ConfigView::setHelp(QListViewItem* item)
854 helpText->setText(head + debug + help); 946 helpText->setText(head + debug + help);
855 return; 947 return;
856 } 948 }
857 helpText->setText(NULL); 949 helpText->setText(NULL);
858} 950}
859 951
860void ConfigView::loadConfig(void) 952void ConfigMainWindow::loadConfig(void)
861{ 953{
862 QString s = QFileDialog::getOpenFileName(".config", NULL, this); 954 QString s = QFileDialog::getOpenFileName(".config", NULL, this);
863 if (s.isNull()) 955 if (s.isNull())
864 return; 956 return;
865 if (conf_read(s.latin1())) 957 if (conf_read(s.latin1()))
866 QMessageBox::information(this, "qconf", "Unable to load configuration!"); 958 QMessageBox::information(this, "qconf", "Unable to load configuration!");
959 ConfigView::updateListAll();
867} 960}
868 961
869void ConfigView::saveConfig(void) 962void ConfigMainWindow::saveConfig(void)
870{ 963{
871 if (conf_write(NULL)) 964 if (conf_write(NULL))
872 QMessageBox::information(this, "qconf", "Unable to save configuration!"); 965 QMessageBox::information(this, "qconf", "Unable to save configuration!");
873} 966}
874 967
875void ConfigView::saveConfigAs(void) 968void ConfigMainWindow::saveConfigAs(void)
876{ 969{
877 QString s = QFileDialog::getSaveFileName(".config", NULL, this); 970 QString s = QFileDialog::getSaveFileName(".config", NULL, this);
878 if (s.isNull()) 971 if (s.isNull())
879 return; 972 return;
880 if (conf_write(s.latin1())) 973 if (conf_write(s.latin1()))
881 QMessageBox::information(this, "qconf", "Unable to save configuration!"); 974 QMessageBox::information(this, "qconf", "Unable to save configuration!");
882} 975}
883 976
884void ConfigView::changeMenu(struct menu *menu) 977void ConfigMainWindow::changeMenu(struct menu *menu)
885{ 978{
886 configList->setRootMenu(menu); 979 configList->setRootMenu(menu);
887 backAction->setEnabled(TRUE); 980 backAction->setEnabled(TRUE);
888} 981}
889 982
890void ConfigView::listFocusChanged(void) 983void ConfigMainWindow::listFocusChanged(void)
891{ 984{
892 if (menuList->hasFocus()) { 985 if (menuList->hasFocus()) {
893 if (menuList->mode == menuMode) 986 if (menuList->mode == menuMode)
894 configList->clearSelection(); 987 configList->clearSelection();
895 setHelp(menuList->selectedItem()); 988 setHelp(menuList->selectedItem());
896 } else if (configList->hasFocus()) { 989 } else if (configList->hasFocus()) {
897 setHelp(configList->selectedItem()); 990 setHelp(configList->selectedItem());
898 } 991 }
899} 992}
900 993
901void ConfigView::goBack(void) 994void ConfigMainWindow::goBack(void)
902{ 995{
903 ConfigItem* item; 996 ConfigItem* item;
904 997
905 configList->setParentMenu(); 998 configList->setParentMenu();
906 if (configList->rootEntry == &rootmenu) 999 if (configList->rootEntry == &rootmenu)
907 backAction->setEnabled(FALSE); 1000 backAction->setEnabled(FALSE);
@@ -912,26 +1005,26 @@ void ConfigView::goBack(void)
912 break; 1005 break;
913 } 1006 }
914 item = (ConfigItem*)item->parent(); 1007 item = (ConfigItem*)item->parent();
915 } 1008 }
916} 1009}
917 1010
918void ConfigView::showSingleView(void) 1011void ConfigMainWindow::showSingleView(void)
919{ 1012{
920 menuList->hide(); 1013 menuList->hide();
921 menuList->setRootMenu(0); 1014 menuList->setRootMenu(0);
922 configList->mode = singleMode; 1015 configList->mode = singleMode;
923 if (configList->rootEntry == &rootmenu) 1016 if (configList->rootEntry == &rootmenu)
924 configList->updateListAll(); 1017 configList->updateListAll();
925 else 1018 else
926 configList->setRootMenu(&rootmenu); 1019 configList->setRootMenu(&rootmenu);
927 configList->setAllOpen(TRUE); 1020 configList->setAllOpen(TRUE);
928 configList->setFocus(); 1021 configList->setFocus();
929} 1022}
930 1023
931void ConfigView::showSplitView(void) 1024void ConfigMainWindow::showSplitView(void)
932{ 1025{
933 configList->mode = symbolMode; 1026 configList->mode = symbolMode;
934 if (configList->rootEntry == &rootmenu) 1027 if (configList->rootEntry == &rootmenu)
935 configList->updateListAll(); 1028 configList->updateListAll();
936 else 1029 else
937 configList->setRootMenu(&rootmenu); 1030 configList->setRootMenu(&rootmenu);
@@ -941,71 +1034,71 @@ void ConfigView::showSplitView(void)
941 menuList->setRootMenu(&rootmenu); 1034 menuList->setRootMenu(&rootmenu);
942 menuList->show(); 1035 menuList->show();
943 menuList->setAllOpen(TRUE); 1036 menuList->setAllOpen(TRUE);
944 menuList->setFocus(); 1037 menuList->setFocus();
945} 1038}
946 1039
947void ConfigView::showFullView(void) 1040void ConfigMainWindow::showFullView(void)
948{ 1041{
949 menuList->hide(); 1042 menuList->hide();
950 menuList->setRootMenu(0); 1043 menuList->setRootMenu(0);
951 configList->mode = fullMode; 1044 configList->mode = fullMode;
952 if (configList->rootEntry == &rootmenu) 1045 if (configList->rootEntry == &rootmenu)
953 configList->updateListAll(); 1046 configList->updateListAll();
954 else 1047 else
955 configList->setRootMenu(&rootmenu); 1048 configList->setRootMenu(&rootmenu);
956 configList->setAllOpen(FALSE); 1049 configList->setAllOpen(FALSE);
957 configList->setFocus(); 1050 configList->setFocus();
958} 1051}
959 1052
960void ConfigView::setShowAll(bool b) 1053void ConfigMainWindow::setShowAll(bool b)
961{ 1054{
962 if (configList->showAll == b) 1055 if (configList->showAll == b)
963 return; 1056 return;
964 configList->showAll = b; 1057 configList->showAll = b;
965 configList->updateListAll(); 1058 configList->updateListAll();
966 menuList->showAll = b; 1059 menuList->showAll = b;
967 menuList->updateListAll(); 1060 menuList->updateListAll();
968} 1061}
969 1062
970void ConfigView::setShowDebug(bool b) 1063void ConfigMainWindow::setShowDebug(bool b)
971{ 1064{
972 if (showDebug == b) 1065 if (showDebug == b)
973 return; 1066 return;
974 showDebug = b; 1067 showDebug = b;
975} 1068}
976 1069
977void ConfigView::setShowName(bool b) 1070void ConfigMainWindow::setShowName(bool b)
978{ 1071{
979 if (configList->showName == b) 1072 if (configList->showName == b)
980 return; 1073 return;
981 configList->showName = b; 1074 configList->showName = b;
982 configList->reinit(); 1075 configList->reinit();
983} 1076}
984 1077
985void ConfigView::setShowRange(bool b) 1078void ConfigMainWindow::setShowRange(bool b)
986{ 1079{
987 if (configList->showRange == b) 1080 if (configList->showRange == b)
988 return; 1081 return;
989 configList->showRange = b; 1082 configList->showRange = b;
990 configList->reinit(); 1083 configList->reinit();
991} 1084}
992 1085
993void ConfigView::setShowData(bool b) 1086void ConfigMainWindow::setShowData(bool b)
994{ 1087{
995 if (configList->showData == b) 1088 if (configList->showData == b)
996 return; 1089 return;
997 configList->showData = b; 1090 configList->showData = b;
998 configList->reinit(); 1091 configList->reinit();
999} 1092}
1000 1093
1001/* 1094/*
1002 * ask for saving configuration before quitting 1095 * ask for saving configuration before quitting
1003 * TODO ask only when something changed 1096 * TODO ask only when something changed
1004 */ 1097 */
1005void ConfigView::closeEvent(QCloseEvent* e) 1098void ConfigMainWindow::closeEvent(QCloseEvent* e)
1006{ 1099{
1007 if (!sym_change_count) { 1100 if (!sym_change_count) {
1008 e->accept(); 1101 e->accept();
1009 return; 1102 return;
1010 } 1103 }
1011 QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, 1104 QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning,
@@ -1022,12 +1115,37 @@ void ConfigView::closeEvent(QCloseEvent* e)
1022 case QMessageBox::Cancel: 1115 case QMessageBox::Cancel:
1023 e->ignore(); 1116 e->ignore();
1024 break; 1117 break;
1025 } 1118 }
1026} 1119}
1027 1120
1121void ConfigMainWindow::showIntro(void)
1122{
1123 static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n"
1124 "For each option, a blank box indicates the feature is disabled, a check\n"
1125 "indicates it is enabled, and a dot indicates that it is to be compiled\n"
1126 "as a module. Clicking on the box will cycle through the three states.\n\n"
1127 "If you do not see an option (e.g., a device driver) that you believe\n"
1128 "should be present, try turning on Show All Options under the Options menu.\n"
1129 "Although there is no cross reference yet to help you figure out what other\n"
1130 "options must be enabled to support the option you are interested in, you can\n"
1131 "still view the help of a grayed-out option.\n\n"
1132 "Toggling Show Debug Info under the Options menu will show the dependencies,\n"
1133 "which you can then match by examining other options.\n\n";
1134
1135 QMessageBox::information(this, "qconf", str);
1136}
1137
1138void ConfigMainWindow::showAbout(void)
1139{
1140 static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
1141 "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n";
1142
1143 QMessageBox::information(this, "qconf", str);
1144}
1145
1028void fixup_rootmenu(struct menu *menu) 1146void fixup_rootmenu(struct menu *menu)
1029{ 1147{
1030 struct menu *child; 1148 struct menu *child;
1031 1149
1032 if (!menu->prompt || menu->prompt->type != P_MENU) 1150 if (!menu->prompt || menu->prompt->type != P_MENU)
1033 return; 1151 return;
@@ -1035,20 +1153,23 @@ void fixup_rootmenu(struct menu *menu)
1035 for (child = menu->list; child; child = child->next) 1153 for (child = menu->list; child; child = child->next)
1036 fixup_rootmenu(child); 1154 fixup_rootmenu(child);
1037} 1155}
1038 1156
1039int main(int ac, char** av) 1157int main(int ac, char** av)
1040{ 1158{
1041 ConfigView* v; 1159 ConfigMainWindow* v;
1042 const char *name; 1160 const char *name;
1043 1161
1044#ifndef LKC_DIRECT_LINK 1162#ifndef LKC_DIRECT_LINK
1045 kconfig_load(); 1163 kconfig_load();
1046#endif 1164#endif
1047 1165
1048 configApp = new QApplication(ac, av); 1166 configApp = new QApplication(ac, av);
1167#if QT_VERSION >= 300
1168 configSettings = new QSettings;
1169#endif
1049 if (ac > 1 && av[1][0] == '-') { 1170 if (ac > 1 && av[1][0] == '-') {
1050 switch (av[1][1]) { 1171 switch (av[1][1]) {
1051 case 'a': 1172 case 'a':
1052 //showAll = 1; 1173 //showAll = 1;
1053 break; 1174 break;
1054 case 'h': 1175 case 'h':
@@ -1060,14 +1181,23 @@ int main(int ac, char** av)
1060 } else 1181 } else
1061 name = av[1]; 1182 name = av[1];
1062 conf_parse(name); 1183 conf_parse(name);
1063 fixup_rootmenu(&rootmenu); 1184 fixup_rootmenu(&rootmenu);
1064 conf_read(NULL); 1185 conf_read(NULL);
1065 //zconfdump(stdout); 1186 //zconfdump(stdout);
1066 v = new ConfigView(); 1187
1188 v = new ConfigMainWindow();
1067 1189
1068 //zconfdump(stdout); 1190 //zconfdump(stdout);
1069 v->show(); 1191 v->show();
1070 configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); 1192 configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
1071 configApp->exec(); 1193 configApp->exec();
1194
1195#if QT_VERSION >= 300
1196 configSettings->writeEntry("/kconfig/qconf/window x", v->pos().x());
1197 configSettings->writeEntry("/kconfig/qconf/window y", v->pos().y());
1198 configSettings->writeEntry("/kconfig/qconf/window width", v->size().width());
1199 configSettings->writeEntry("/kconfig/qconf/window height", v->size().height());
1200 delete configSettings;
1201#endif
1072 return 0; 1202 return 0;
1073} 1203}
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index f8f3669..6f096b4 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -2,33 +2,54 @@
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
4 */ 4 */
5 5
6#include <qlistview.h> 6#include <qlistview.h>
7 7
8class ConfigLineEdit; 8class ConfigList;
9class ConfigItem; 9class ConfigItem;
10class ConfigView; 10class ConfigLineEdit;
11class ConfigMainWindow;
12
13class ConfigView : public QVBox {
14 Q_OBJECT
15 typedef class QVBox Parent;
16public:
17 ConfigView(QWidget* parent, ConfigMainWindow* cview);
18 ~ConfigView(void);
19 static void updateList(ConfigItem* item);
20 static void updateListAll(void);
21
22public:
23 ConfigList* list;
24 ConfigLineEdit* lineEdit;
25
26 static ConfigView* viewList;
27 ConfigView* nextView;
28};
11 29
12enum colIdx { 30enum colIdx {
13 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr 31 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
14}; 32};
15enum listMode { 33enum listMode {
16 singleMode, menuMode, symbolMode, fullMode 34 singleMode, menuMode, symbolMode, fullMode
17}; 35};
18 36
19class ConfigList : public QListView { 37class ConfigList : public QListView {
20 Q_OBJECT 38 Q_OBJECT
21 typedef class QListView Parent; 39 typedef class QListView Parent;
22public: 40public:
23 ConfigList(QWidget* p, ConfigView* cview); 41 ConfigList(ConfigView* p, ConfigMainWindow* cview);
24 void reinit(void); 42 void reinit(void);
43 ConfigView* parent(void) const
44 {
45 return (ConfigView*)Parent::parent();
46 }
25 47
26 ConfigLineEdit* lineEdit;
27protected: 48protected:
28 ConfigView* cview; 49 ConfigMainWindow* cview;
29 50
30 void keyPressEvent(QKeyEvent *e); 51 void keyPressEvent(QKeyEvent *e);
31 void contentsMousePressEvent(QMouseEvent *e); 52 void contentsMousePressEvent(QMouseEvent *e);
32 void contentsMouseReleaseEvent(QMouseEvent *e); 53 void contentsMouseReleaseEvent(QMouseEvent *e);
33 void contentsMouseMoveEvent(QMouseEvent *e); 54 void contentsMouseMoveEvent(QMouseEvent *e);
34 void contentsMouseDoubleClickEvent(QMouseEvent *e); 55 void contentsMouseDoubleClickEvent(QMouseEvent *e);
@@ -40,13 +61,12 @@ public slots:
40 void setValue(ConfigItem* item, tristate val); 61 void setValue(ConfigItem* item, tristate val);
41 void changeValue(ConfigItem* item); 62 void changeValue(ConfigItem* item);
42 void updateSelection(void); 63 void updateSelection(void);
43signals: 64signals:
44 void menuSelected(struct menu *menu); 65 void menuSelected(struct menu *menu);
45 void parentSelected(void); 66 void parentSelected(void);
46 void symbolChanged(ConfigItem* item);
47 void gotFocus(void); 67 void gotFocus(void);
48 68
49public: 69public:
50 void updateListAll(void) 70 void updateListAll(void)
51 { 71 {
52 updateAll = true; 72 updateAll = true;
@@ -97,28 +117,29 @@ private:
97 int colRevMap[colNr]; 117 int colRevMap[colNr];
98}; 118};
99 119
100class ConfigItem : public QListViewItem { 120class ConfigItem : public QListViewItem {
101 typedef class QListViewItem Parent; 121 typedef class QListViewItem Parent;
102public: 122public:
103 ConfigItem(QListView *parent, ConfigItem *after, struct menu *m) 123 ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v)
104 : Parent(parent, after), menu(m) 124 : Parent(parent, after), menu(m), visible(v)
105 { 125 {
106 init(); 126 init();
107 } 127 }
108 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m) 128 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
109 : Parent(parent, after), menu(m) 129 : Parent(parent, after), menu(m), visible(v)
110 { 130 {
111 init(); 131 init();
112 } 132 }
113 ~ConfigItem(void); 133 ~ConfigItem(void);
114 void init(void); 134 void init(void);
115#if QT_VERSION >= 300 135#if QT_VERSION >= 300
116 void okRename(int col); 136 void okRename(int col);
117#endif 137#endif
118 void updateMenu(void); 138 void updateMenu(void);
139 bool updateNeeded(void);
119 ConfigList* listView() const 140 ConfigList* listView() const
120 { 141 {
121 return (ConfigList*)Parent::listView(); 142 return (ConfigList*)Parent::listView();
122 } 143 }
123 ConfigItem* firstChild() const 144 ConfigItem* firstChild() const
124 { 145 {
@@ -143,37 +164,39 @@ public:
143 const QPixmap* pixmap(colIdx idx) const 164 const QPixmap* pixmap(colIdx idx) const
144 { 165 {
145 return Parent::pixmap(listView()->mapIdx(idx)); 166 return Parent::pixmap(listView()->mapIdx(idx));
146 } 167 }
147 void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); 168 void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align);
148 169
170 ConfigItem* nextItem;
149 struct menu *menu; 171 struct menu *menu;
150 bool visible; 172 bool visible;
151 bool doInit;
152}; 173};
153 174
154class ConfigLineEdit : public QLineEdit { 175class ConfigLineEdit : public QLineEdit {
155 Q_OBJECT 176 Q_OBJECT
156 typedef class QLineEdit Parent; 177 typedef class QLineEdit Parent;
157public: 178public:
158 ConfigLineEdit(QWidget * parent) 179 ConfigLineEdit(ConfigView* parent)
159 : QLineEdit(parent) 180 : Parent(parent)
160 { } 181 { }
182 ConfigView* parent(void) const
183 {
184 return (ConfigView*)Parent::parent();
185 }
161 void show(ConfigItem *i); 186 void show(ConfigItem *i);
162 void keyPressEvent(QKeyEvent *e); 187 void keyPressEvent(QKeyEvent *e);
163signals:
164 void lineChanged(ConfigItem *item);
165 188
166public: 189public:
167 ConfigItem *item; 190 ConfigItem *item;
168}; 191};
169 192
170class ConfigView : public QMainWindow { 193class ConfigMainWindow : public QMainWindow {
171 Q_OBJECT 194 Q_OBJECT
172public: 195public:
173 ConfigView(void); 196 ConfigMainWindow(void);
174public slots: 197public slots:
175 void setHelp(QListViewItem* item); 198 void setHelp(QListViewItem* item);
176 void changeMenu(struct menu *); 199 void changeMenu(struct menu *);
177 void listFocusChanged(void); 200 void listFocusChanged(void);
178 void goBack(void); 201 void goBack(void);
179 void loadConfig(void); 202 void loadConfig(void);
@@ -184,12 +207,14 @@ public slots:
184 void showFullView(void); 207 void showFullView(void);
185 void setShowAll(bool); 208 void setShowAll(bool);
186 void setShowDebug(bool); 209 void setShowDebug(bool);
187 void setShowRange(bool); 210 void setShowRange(bool);
188 void setShowName(bool); 211 void setShowName(bool);
189 void setShowData(bool); 212 void setShowData(bool);
213 void showIntro(void);
214 void showAbout(void);
190 215
191protected: 216protected:
192 void closeEvent(QCloseEvent *e); 217 void closeEvent(QCloseEvent *e);
193 218
194 ConfigList *menuList; 219 ConfigList *menuList;
195 ConfigList *configList; 220 ConfigList *configList;
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 59c88d2..845d8a3 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -146,13 +146,13 @@ void sym_calc_visibility(struct symbol *sym)
146 oldvisible = sym->visible; 146 oldvisible = sym->visible;
147 visible = no; 147 visible = no;
148 for_all_prompts(sym, prop) 148 for_all_prompts(sym, prop)
149 visible = E_OR(visible, E_CALC(prop->visible)); 149 visible = E_OR(visible, E_CALC(prop->visible));
150 if (oldvisible != visible) { 150 if (oldvisible != visible) {
151 sym->visible = visible; 151 sym->visible = visible;
152 sym->flags |= SYMBOL_CHANGED; 152 sym_set_changed(sym);
153 } 153 }
154} 154}
155 155
156void sym_calc_value(struct symbol *sym) 156void sym_calc_value(struct symbol *sym)
157{ 157{
158 struct symbol_value newval, oldval; 158 struct symbol_value newval, oldval;
@@ -201,13 +201,14 @@ void sym_calc_value(struct symbol *sym)
201 if (!sym_is_choice(sym)) { 201 if (!sym_is_choice(sym)) {
202 prop = sym_get_default_prop(sym); 202 prop = sym_get_default_prop(sym);
203 if (prop) { 203 if (prop) {
204 sym_calc_value(prop->def); 204 sym_calc_value(prop->def);
205 newval = prop->def->curr; 205 newval = prop->def->curr;
206 } 206 }
207 } 207 } else
208 S_TRI(newval) = S_TRI(sym->def);
208 } else 209 } else
209 newval = sym->def; 210 newval = sym->def;
210 211
211 S_TRI(newval) = E_AND(S_TRI(newval), sym->visible); 212 S_TRI(newval) = E_AND(S_TRI(newval), sym->visible);
212 /* if the symbol is visible and not optionial, 213 /* if the symbol is visible and not optionial,
213 * possibly ignore old user choice. */ 214 * possibly ignore old user choice. */
@@ -273,20 +274,23 @@ out:
273 } 274 }
274 275
275 S_VAL(newval) = def_sym; 276 S_VAL(newval) = def_sym;
276 } 277 }
277 278
278 if (memcmp(&oldval, &newval, sizeof(newval))) 279 if (memcmp(&oldval, &newval, sizeof(newval)))
279 sym->flags |= SYMBOL_CHANGED; 280 sym_set_changed(sym);
280 sym->curr = newval; 281 sym->curr = newval;
281 282
282 if (sym_is_choice(sym)) { 283 if (sym_is_choice(sym)) {
283 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE); 284 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
284 prop = sym_get_choice_prop(sym); 285 prop = sym_get_choice_prop(sym);
285 for (e = prop->dep; e; e = e->left.expr) 286 for (e = prop->dep; e; e = e->left.expr) {
286 e->right.sym->flags |= flags; 287 e->right.sym->flags |= flags;
288 if (flags & SYMBOL_CHANGED)
289 sym_set_changed(e->right.sym);
290 }
287 } 291 }
288} 292}
289 293
290void sym_clear_all_valid(void) 294void sym_clear_all_valid(void)
291{ 295{
292 struct symbol *sym; 296 struct symbol *sym;
@@ -294,19 +298,30 @@ void sym_clear_all_valid(void)
294 298
295 for_all_symbols(i, sym) 299 for_all_symbols(i, sym)
296 sym->flags &= ~SYMBOL_VALID; 300 sym->flags &= ~SYMBOL_VALID;
297 sym_change_count++; 301 sym_change_count++;
298} 302}
299 303
304void sym_set_changed(struct symbol *sym)
305{
306 struct property *prop;
307
308 sym->flags |= SYMBOL_CHANGED;
309 for (prop = sym->prop; prop; prop = prop->next) {
310 if (prop->menu)
311 prop->menu->flags |= MENU_CHANGED;
312 }
313}
314
300void sym_set_all_changed(void) 315void sym_set_all_changed(void)
301{ 316{
302 struct symbol *sym; 317 struct symbol *sym;
303 int i; 318 int i;
304 319
305 for_all_symbols(i, sym) 320 for_all_symbols(i, sym)
306 sym->flags |= SYMBOL_CHANGED; 321 sym_set_changed(sym);
307} 322}
308 323
309bool sym_tristate_within_range(struct symbol *sym, tristate val) 324bool sym_tristate_within_range(struct symbol *sym, tristate val)
310{ 325{
311 int type = sym_get_type(sym); 326 int type = sym_get_type(sym);
312 327
@@ -337,13 +352,13 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val)
337 352
338 if (oldval != val && !sym_tristate_within_range(sym, val)) 353 if (oldval != val && !sym_tristate_within_range(sym, val))
339 return false; 354 return false;
340 355
341 if (sym->flags & SYMBOL_NEW) { 356 if (sym->flags & SYMBOL_NEW) {
342 sym->flags &= ~SYMBOL_NEW; 357 sym->flags &= ~SYMBOL_NEW;
343 sym->flags |= SYMBOL_CHANGED; 358 sym_set_changed(sym);
344 } 359 }
345 if (sym_is_choice_value(sym) && val == yes) { 360 if (sym_is_choice_value(sym) && val == yes) {
346 struct property *prop = sym_get_choice_prop(sym); 361 struct property *prop = sym_get_choice_prop(sym);
347 362
348 S_VAL(prop->def->def) = sym; 363 S_VAL(prop->def->def) = sym;
349 prop->def->flags &= ~SYMBOL_NEW; 364 prop->def->flags &= ~SYMBOL_NEW;
@@ -457,13 +472,13 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
457 472
458 if (!sym_string_valid(sym, newval)) 473 if (!sym_string_valid(sym, newval))
459 return false; 474 return false;
460 475
461 if (sym->flags & SYMBOL_NEW) { 476 if (sym->flags & SYMBOL_NEW) {
462 sym->flags &= ~SYMBOL_NEW; 477 sym->flags &= ~SYMBOL_NEW;
463 sym->flags |= SYMBOL_CHANGED; 478 sym_set_changed(sym);
464 } 479 }
465 480
466 oldval = S_VAL(sym->def); 481 oldval = S_VAL(sym->def);
467 size = strlen(newval) + 1; 482 size = strlen(newval) + 1;
468 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { 483 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
469 size += 2; 484 size += 2;
@@ -522,13 +537,12 @@ struct symbol *sym_lookup(const char *name, int isconst)
522{ 537{
523 struct symbol *symbol; 538 struct symbol *symbol;
524 const char *ptr; 539 const char *ptr;
525 char *new_name; 540 char *new_name;
526 int hash = 0; 541 int hash = 0;
527 542
528 //printf("lookup: %s -> ", name);
529 if (name) { 543 if (name) {
530 if (name[0] && !name[1]) { 544 if (name[0] && !name[1]) {
531 switch (name[0]) { 545 switch (name[0]) {
532 case 'y': return &symbol_yes; 546 case 'y': return &symbol_yes;
533 case 'm': return &symbol_mod; 547 case 'm': return &symbol_mod;
534 case 'n': return &symbol_no; 548 case 'n': return &symbol_no;
@@ -538,16 +552,14 @@ struct symbol *sym_lookup(const char *name, int isconst)
538 hash += *ptr; 552 hash += *ptr;
539 hash &= 0xff; 553 hash &= 0xff;
540 554
541 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { 555 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
542 if (!strcmp(symbol->name, name)) { 556 if (!strcmp(symbol->name, name)) {
543 if ((isconst && symbol->flags & SYMBOL_CONST) || 557 if ((isconst && symbol->flags & SYMBOL_CONST) ||
544 (!isconst && !(symbol->flags & SYMBOL_CONST))) { 558 (!isconst && !(symbol->flags & SYMBOL_CONST)))
545 //printf("h:%p\n", symbol);
546 return symbol; 559 return symbol;
547 }
548 } 560 }
549 } 561 }
550 new_name = strdup(name); 562 new_name = strdup(name);
551 } else { 563 } else {
552 new_name = NULL; 564 new_name = NULL;
553 hash = 256; 565 hash = 256;
@@ -561,13 +573,12 @@ struct symbol *sym_lookup(const char *name, int isconst)
561 if (isconst) 573 if (isconst)
562 symbol->flags |= SYMBOL_CONST; 574 symbol->flags |= SYMBOL_CONST;
563 575
564 symbol->next = symbol_hash[hash]; 576 symbol->next = symbol_hash[hash];
565 symbol_hash[hash] = symbol; 577 symbol_hash[hash] = symbol;
566 578
567 //printf("n:%p\n", symbol);
568 return symbol; 579 return symbol;
569} 580}
570 581
571struct symbol *sym_find(const char *name) 582struct symbol *sym_find(const char *name)
572{ 583{
573 struct symbol *symbol = NULL; 584 struct symbol *symbol = NULL;
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 6d81e5e..1471630 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -1,23 +1,23 @@
1%option backup nostdinit noyywrap full ecs 1%option backup nostdinit noyywrap never-interactive full ecs
2%option 8bit backup nodefault perf-report perf-report 2%option 8bit backup nodefault perf-report perf-report
3%x COMMAND HELP STRING PARAM 3%x COMMAND HELP STRING PARAM
4%{ 4%{
5/* 5/*
6 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 6 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
7 * Released under the terms of the GNU GPL v2.0. 7 * Released under the terms of the GNU GPL v2.0.
8 */ 8 */
9 9
10#include <limits.h>
10#include <stdio.h> 11#include <stdio.h>
11#include <stdlib.h> 12#include <stdlib.h>
12#include <string.h> 13#include <string.h>
13#include <unistd.h> 14#include <unistd.h>
14 15
15#define LKC_DIRECT_LINK 16#define LKC_DIRECT_LINK
16#include "lkc.h" 17#include "lkc.h"
17#include "zconf.tab.h"
18 18
19 #define START_STRSIZE16 19 #define START_STRSIZE16
20 20
21char *text; 21char *text;
22static char *text_ptr; 22static char *text_ptr;
23static int text_size, text_asize; 23static int text_size, text_asize;
@@ -80,14 +80,12 @@ n [A-Za-z0-9_]
80 [ \t]+{ 80 [ \t]+{
81 BEGIN(COMMAND); 81 BEGIN(COMMAND);
82} 82}
83 83
84 .{ 84 .{
85 unput(yytext[0]); 85 unput(yytext[0]);
86 //printf("new config: ");
87 //symbol_end(NULL);
88 BEGIN(COMMAND); 86 BEGIN(COMMAND);
89} 87}
90 88
91 89
92<COMMAND>{ 90<COMMAND>{
93 "mainmenu" BEGIN(PARAM); return T_MAINMENU; 91 "mainmenu" BEGIN(PARAM); return T_MAINMENU;
@@ -140,38 +138,52 @@ n [A-Za-z0-9_]
140 ---/* ignore */ 138 ---/* ignore */
141 ({n}|[-/.])+{ 139 ({n}|[-/.])+{
142 alloc_string(yytext, yyleng); 140 alloc_string(yytext, yyleng);
143 zconflval.string = text; 141 zconflval.string = text;
144 return T_WORD; 142 return T_WORD;
145 } 143 }
144 \\\ncurrent_file->lineno++;
146 . 145 .
146 <<EOF>> {
147 BEGIN(INITIAL);
148 }
147} 149}
148 150
149<STRING>{ 151<STRING>{
150 [^'"\n\\]+{ 152 [^'"\\\n]+/\n{
153 append_string(yytext, yyleng);
154 zconflval.string = text;
155 return T_STRING;
156 }
157 [^'"\\\n]+{
151 append_string(yytext, yyleng); 158 append_string(yytext, yyleng);
152 } 159 }
160 \\.?/\n{
161 append_string(yytext + 1, yyleng - 1);
162 zconflval.string = text;
163 return T_STRING;
164 }
165 \\.?{
166 append_string(yytext + 1, yyleng - 1);
167 }
153 \'|\"{ 168 \'|\"{
154 if (str == yytext[0]) { 169 if (str == yytext[0]) {
155 BEGIN(PARAM); 170 BEGIN(PARAM);
156 zconflval.string = text; 171 zconflval.string = text;
157 //printf("s:%s\n", text);
158 return T_STRING; 172 return T_STRING;
159 } else 173 } else
160 append_string(yytext, 1); 174 append_string(yytext, 1);
161 } 175 }
162 \\[ \t]*\nappend_string(yytext+yyleng-1, 1); current_file->lineno++;
163 \\[ \t]*append_string(yytext+1, yyleng-1);
164 \\. append_string(yytext+1, 1);
165 \n{ 176 \n{
166 //printf(":%d: open string!\n", current_file->lineno+1); 177 printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno());
167 exit(0); 178 current_file->lineno++;
179 BEGIN(INITIAL);
180 return T_EOL;
168 } 181 }
169 <<EOF>>{ 182 <<EOF>>{
170 //printf(":%d: open string!\n", current_file->lineno+1); 183 BEGIN(INITIAL);
171 exit(0);
172 } 184 }
173} 185}
174 186
175<HELP>{ 187<HELP>{
176 [ \t]+{ 188 [ \t]+{
177 ts = 0; 189 ts = 0;
@@ -218,12 +230,13 @@ n [A-Za-z0-9_]
218 230
219 <<EOF>>{ 231 <<EOF>>{
220 if (current_buf) { 232 if (current_buf) {
221 zconf_endfile(); 233 zconf_endfile();
222 return T_EOF; 234 return T_EOF;
223 } 235 }
236 fclose(yyin);
224 yyterminate(); 237 yyterminate();
225} 238}
226 239
227%% 240%%
228void zconf_starthelp(void) 241void zconf_starthelp(void)
229{ 242{
@@ -235,20 +248,44 @@ void zconf_starthelp(void)
235static void zconf_endhelp(void) 248static void zconf_endhelp(void)
236{ 249{
237 zconflval.string = text; 250 zconflval.string = text;
238 BEGIN(INITIAL); 251 BEGIN(INITIAL);
239} 252}
240 253
254
255/*
256 * Try to open specified file with following names:
257 * ./name
258 * $(srctree)/name
259 * The latter is used when srctree is separate from objtree
260 * when compiling the kernel.
261 * Return NULL if file is not found.
262 */
263FILE *zconf_fopen(const char *name)
264{
265 char *env, fullname[PATH_MAX+1];
266 FILE *f;
267
268 f = fopen(name, "r");
269 if (!f && name[0] != '/') {
270 env = getenv(SRCTREE);
271 if (env) {
272 sprintf(fullname, "%s/%s", env, name);
273 f = fopen(fullname, "r");
274 }
275 }
276 return f;
277}
278
241void zconf_initscan(const char *name) 279void zconf_initscan(const char *name)
242{ 280{
243 yyin = fopen(name, "r"); 281 yyin = zconf_fopen(name);
244 if (!yyin) { 282 if (!yyin) {
245 printf("can't find file %s\n", name); 283 printf("can't find file %s\n", name);
246 exit(1); 284 exit(1);
247 } 285 }
248 //fprintf(stderr, "zconf_initscan: %s\n", name);
249 286
250 current_buf = malloc(sizeof(*current_buf)); 287 current_buf = malloc(sizeof(*current_buf));
251 memset(current_buf, 0, sizeof(*current_buf)); 288 memset(current_buf, 0, sizeof(*current_buf));
252 289
253 current_file = file_lookup(name); 290 current_file = file_lookup(name);
254 current_file->lineno = 1; 291 current_file->lineno = 1;
@@ -259,23 +296,21 @@ void zconf_nextfile(const char *name)
259{ 296{
260 struct file *file = file_lookup(name); 297 struct file *file = file_lookup(name);
261 struct buffer *buf = malloc(sizeof(*buf)); 298 struct buffer *buf = malloc(sizeof(*buf));
262 memset(buf, 0, sizeof(*buf)); 299 memset(buf, 0, sizeof(*buf));
263 300
264 current_buf->state = YY_CURRENT_BUFFER; 301 current_buf->state = YY_CURRENT_BUFFER;
265 yyin = fopen(name, "r"); 302 yyin = zconf_fopen(name);
266 if (!yyin) { 303 if (!yyin) {
267 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); 304 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
268 exit(1); 305 exit(1);
269 } 306 }
270 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); 307 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
271 buf->parent = current_buf; 308 buf->parent = current_buf;
272 current_buf = buf; 309 current_buf = buf;
273 310
274 //fprintf(stderr, "zconf_nextfile: %s\n", name);
275
276 if (file->flags & FILE_BUSY) { 311 if (file->flags & FILE_BUSY) {
277 printf("recursive scan (%s)?\n", name); 312 printf("recursive scan (%s)?\n", name);
278 exit(1); 313 exit(1);
279 } 314 }
280 if (file->flags & FILE_SCANNED) { 315 if (file->flags & FILE_SCANNED) {
281 printf("file %s already scanned?\n", name); 316 printf("file %s already scanned?\n", name);
@@ -294,12 +329,13 @@ static struct buffer *zconf_endfile(void)
294 current_file->flags |= FILE_SCANNED; 329 current_file->flags |= FILE_SCANNED;
295 current_file->flags &= ~FILE_BUSY; 330 current_file->flags &= ~FILE_BUSY;
296 current_file = current_file->parent; 331 current_file = current_file->parent;
297 332
298 parent = current_buf->parent; 333 parent = current_buf->parent;
299 if (parent) { 334 if (parent) {
335 fclose(yyin);
300 yy_delete_buffer(YY_CURRENT_BUFFER); 336 yy_delete_buffer(YY_CURRENT_BUFFER);
301 yy_switch_to_buffer(parent->state); 337 yy_switch_to_buffer(parent->state);
302 } 338 }
303 free(current_buf); 339 free(current_buf);
304 current_buf = parent; 340 current_buf = parent;
305 341
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index c3f1bd0..996b10a 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -224,16 +224,15 @@ choice_option: T_PROMPT prompt if_expr
224choice_option: T_OPTIONAL 224choice_option: T_OPTIONAL
225{ 225{
226 current_entry->sym->flags |= SYMBOL_OPTIONAL; 226 current_entry->sym->flags |= SYMBOL_OPTIONAL;
227 printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); 227 printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
228}; 228};
229 229
230choice_option: T_DEFAULT symbol 230choice_option: T_DEFAULT symbol if_expr
231{ 231{
232 menu_add_prop(P_DEFAULT, NULL, $2, NULL); 232 menu_add_prop(P_DEFAULT, NULL, $2, $3);
233 //current_choice->prop->def = $2;
234 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); 233 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
235}; 234};
236 235
237choice_block: 236choice_block:
238 /* empty */ 237 /* empty */
239 | choice_block common_block 238 | choice_block common_block
@@ -242,13 +241,12 @@ choice_block:
242/* if entry */ 241/* if entry */
243 242
244if: T_IF expr 243if: T_IF expr
245{ 244{
246 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); 245 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
247 menu_add_entry(NULL); 246 menu_add_entry(NULL);
248 //current_entry->prompt = menu_add_prop(T_IF, NULL, NULL, $2);
249 menu_add_dep($2); 247 menu_add_dep($2);
250 menu_end_entry(); 248 menu_end_entry();
251 menu_add_menu(); 249 menu_add_menu();
252}; 250};
253 251
254if_end: end 252if_end: end