summaryrefslogtreecommitdiff
path: root/scripts/kconfig
Unidiff
Diffstat (limited to 'scripts/kconfig') (more/less context) (show whitespace changes)
-rw-r--r--scripts/kconfig/Makefile189
-rw-r--r--scripts/kconfig/Makefile.kernel85
-rw-r--r--scripts/kconfig/README17
-rw-r--r--scripts/kconfig/cml1.h36
-rw-r--r--scripts/kconfig/cml1.l213
-rw-r--r--scripts/kconfig/cml1.y2482
-rw-r--r--scripts/kconfig/conf.c565
-rw-r--r--scripts/kconfig/confdata.c360
-rw-r--r--scripts/kconfig/convert-all41
-rw-r--r--scripts/kconfig/example/miniconf.rb32
-rw-r--r--scripts/kconfig/example/query.rb34
-rw-r--r--scripts/kconfig/expr.c1054
-rw-r--r--scripts/kconfig/expr.h242
-rw-r--r--scripts/kconfig/expr1.c333
-rw-r--r--scripts/kconfig/extconf.rb5
-rw-r--r--scripts/kconfig/fixup-all.diff925
-rw-r--r--scripts/kconfig/help.l78
-rw-r--r--scripts/kconfig/images.c292
-rw-r--r--scripts/kconfig/kconfig.i133
-rw-r--r--scripts/kconfig/kconfig_load.c35
-rw-r--r--scripts/kconfig/lkc.h106
-rw-r--r--scripts/kconfig/lkc_overview111
-rw-r--r--scripts/kconfig/lkc_proto.h38
-rw-r--r--scripts/kconfig/lkc_spec250
-rw-r--r--scripts/kconfig/mconf.c711
-rw-r--r--scripts/kconfig/menu.c309
-rw-r--r--scripts/kconfig/prepare-all.diff1883
-rw-r--r--scripts/kconfig/qconf.cc1073
-rw-r--r--scripts/kconfig/qconf.h201
-rw-r--r--scripts/kconfig/symbol.c618
-rw-r--r--scripts/kconfig/zconf.l323
-rw-r--r--scripts/kconfig/zconf.y651
32 files changed, 13425 insertions, 0 deletions
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
new file mode 100644
index 0000000..ed57c6f
--- a/dev/null
+++ b/scripts/kconfig/Makefile
@@ -0,0 +1,189 @@
1VERSION=1.2
2CC=gcc
3CXX=g++
4CFLAGS=-O2 -Wall -g -fPIC
5CXXFLAGS=$(CFLAGS) -I$(QTDIR)/include
6LDFLAGS=
7LXXFLAGS=$(LDFLAGS) -L$(QTDIR)/lib -Wl,-rpath,$(QTDIR)/lib
8LEX=flex
9YACC=bison
10YFLAGS=-d -t -v
11ifndef QTDIR
12QTDIR=/usr/share/qt
13endif
14MOC=$(wildcard $(QTDIR)/bin/moc)
15
16parse_SRC=zconf.y
17conf_SRC=conf.c $(parse_SRC)
18mconf_SRC=mconf.c $(parse_SRC)
19qconf_SRC=qconf.cc
20lkcc_SRC=cml1.y cml1.l help.l cml1.h expr1.c
21HDR=expr.h lkc.h lkc_proto.h qconf.h
22OTHER=README lkc_spec lkc_overview Makefile.kernel convert-all prepare-all.diff fixup-all.diff \
23 kconfig.i extconf.rb example
24INST=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)
25INSTGEN=lex.zconf.c zconf.tab.c zconf.tab.h
26
27#DEBUG=1
28ifdef DEBUG
29CFLAGS+=-DLKC_DIRECT_LINK
30qconf_SRC+=$(parse_SRC)
31else
32qconf_SRC+=kconfig_load.c
33endif
34
35SRC=$(conf_SRC) $(mconf_SRC) $(qconf_SRC) $(lkcc_SRC)
36CSRC=$(filter %.c, $(SRC))
37YSRC=$(filter %.y, $(SRC))
38LSRC=$(filter %.l, $(SRC))
39
40parse_OBJ=$(filter %.o, \
41 $(patsubst %.c,%.o, \
42 $(patsubst %.y,%.tab.o, \
43 $(patsubst %.l,lex.%.o, \
44 $(parse_SRC)))))
45conf_OBJ=$(filter %.o, \
46 $(patsubst %.c,%.o, \
47 $(patsubst %.y,%.tab.o, \
48 $(patsubst %.l,lex.%.o, \
49 $(conf_SRC)))))
50mconf_OBJ=$(filter %.o, \
51 $(patsubst %.c,%.o, \
52 $(patsubst %.y,%.tab.o, \
53 $(patsubst %.l,lex.%.o, \
54 $(mconf_SRC)))))
55qconf_OBJ=$(filter %.o, \
56 $(patsubst %.c,%.o, \
57 $(patsubst %.cc,%.o, \
58 $(patsubst %.y,%.tab.o, \
59 $(patsubst %.l,lex.%.o, \
60 $(qconf_SRC))))))
61lkcc_OBJ=$(filter %.o, \
62 $(patsubst %.c,%.o, \
63 $(patsubst %.y,%.tab.o, \
64 $(patsubst %.l,lex.%.o, \
65 $(lkcc_SRC)))))
66OBJ=$(conf_OBJ) $(mconf_OBJ) $(qconf_OBJ) $(lkcc_OBJ)
67
68ifeq ($(MOC),)
69all: lkcc conf mconf
70else
71all: lkcc conf mconf qconf libkconfig.so
72endif
73
74lex.help.c: help.l
75lex.help.o: lex.help.c cml1.h expr.h
76lex.cml1.c: cml1.l
77lex.cml1.o: lex.cml1.c cml1.tab.h cml1.h expr.h
78cml1.tab.c: cml1.y
79cml1.tab.h: cml1.y
80cml1.tab.o: cml1.tab.c cml1.h expr.h
81expr1.o: expr1.c expr.h
82
83lkc_deps := lkc.h lkc_proto.h lkc_defs.h expr.h
84
85zconf.tab.c: zconf.y
86zconf.tab.h: zconf.y
87lex.zconf.c: zconf.l
88zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(lkc_deps)
89#lex.zconf.o: lex.zconf.c zconf.tab.h $(lkc_deps)
90#confdata.o: confdata.c $(lkc_deps)
91#expr.o: expr.c $(lkc_deps)
92#symbol.o: symbol.c $(lkc_deps)
93#menu.o: menu.c $(lkc_deps)
94kconfig_load.o: kconfig_load.c $(lkc_deps)
95conf.o: conf.c $(lkc_deps)
96mconf.o: mconf.c $(lkc_deps)
97qconf.moc: qconf.h
98qconf.o: qconf.cc qconf.moc images.c $(lkc_deps)
99
100mconf: $(mconf_OBJ)
101 $(CC) $(LDFLAGS) $^ -o $@
102
103conf: $(conf_OBJ)
104 $(CC) $(LDFLAGS) $^ -o $@
105
106ifeq ($(MOC),)
107qconf:
108 @echo Unable to find the QT installation. Please make sure that the
109 @echo QT development package is correctly installed and the QTDIR
110 @echo environment variable is set to the correct location.
111 @false
112else
113qconf: $(qconf_OBJ)
114 $(CXX) $(LXXFLAGS) $^ -lqt -o $@
115endif
116
117lkcc: $(lkcc_OBJ)
118 $(CC) $(LDFLAGS) $^ -o $@
119
120libkconfig.so: $(parse_OBJ)
121 $(CC) -shared $^ -o $@
122
123lkc_defs.h: lkc_proto.h
124 sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
125
126clean:
127 rm -f $(OBJ) lkcc conf qconf mconf *.moc lex.* *.tab.? *.output
128
129tgz:
130 mkdir tmp
131 mkdir tmp/lkc-$(VERSION)
132 cp -ra Makefile $(sort $(SRC) $(HDR) $(OTHER) $(INST)) tmp/lkc-$(VERSION)
133 tar -cpvz -C tmp -f lkc-$(VERSION).tar.gz lkc-$(VERSION)
134 rm -rf tmp
135
136%.tab.c %.tab.h: %.y
137 $(YACC) $(YFLAGS) -b $* -p $* $<
138
139lex.%.c: %.l
140 $(LEX) $(LFLAGS) -P$* $<
141
142%.moc: %.h
143 $(QTDIR)/bin/moc -i $< -o $@
144
145%.o: %.c
146 $(CC) $(CFLAGS) -c $< -o $@
147
148%.o: %.cc
149 $(CXX) $(CXXFLAGS) -c $< -o $@
150
151ifdef KERNELSRC
152install: lkcc $(INSTGEN)
153 set -x; mkdir $(KERNELSRC)/scripts/kconfig; \
154 cp $(sort $(INST)) $(KERNELSRC)/scripts/kconfig; \
155 for f in $(INSTGEN); do cp $$f $(KERNELSRC)/scripts/kconfig/$${f}_shipped; done; \
156 cp Makefile.kernel $(KERNELSRC)/scripts/kconfig/Makefile; \
157 LKCSRC=$$PWD; export LKCSRC; \
158 cd $(KERNELSRC); \
159 patch -p0 -N < $$LKCSRC/prepare-all.diff; \
160 sh $$LKCSRC/convert-all; \
161 patch -p0 -N < $$LKCSRC/fixup-all.diff
162
163 #cp Makefile $(KERNELSRC)/scripts/kconfig/Makefile; \
164
165uninstall:
166 patch -p0 -N -R -d $(KERNELSRC) < prepare-all.diff; \
167 cd $(KERNELSRC); \
168 find -name "Kconfig*" | xargs rm; \
169 rm -rf scripts/kconfig log.*
170else
171install:
172 @echo "Please use KERNELSRC=<path/to/linux-kernel> to install"
173endif
174
175ruby: .ruby libkconfig.so .ruby/kconfig.so
176
177.ruby:
178 mkdir .ruby
179
180.ruby/kconfig_wrap.c: kconfig.i kconfig_load.c expr.h lkc_proto.h
181 swig -ruby -o $@ $<
182
183.ruby/Makefile: extconf.rb
184 cd .ruby; ruby ../extconf.rb
185
186.ruby/kconfig.so: .ruby/kconfig_wrap.c .ruby/Makefile
187 make -C .ruby
188
189.PHONY: all tgz clean ruby
diff --git a/scripts/kconfig/Makefile.kernel b/scripts/kconfig/Makefile.kernel
new file mode 100644
index 0000000..beb4dcf
--- a/dev/null
+++ b/scripts/kconfig/Makefile.kernel
@@ -0,0 +1,85 @@
1#################
2#
3# Shared Makefile for the various lkc executables:
4 # conf: Used for defconfig, oldconfig and related targets
5# mconf: Used for the mconfig target.
6# Utilizes the lxdialog package
7# qconf: Used for the xconfig target
8# Based on QT which needs to be installed to compile it
9#
10
11# object files used by all lkc flavours
12libkconfig-objs := zconf.tab.o
13
14 host-progs:= conf mconf qconf
15 conf-objs:= conf.o libkconfig.so
16 mconf-objs:= mconf.o libkconfig.so
17
18 qconf-objs:= kconfig_load.o
19 qconf-cxxobjs:= qconf.o
20
21 clean-files:= libkconfig.so lkc_defs.h qconf.moc .tmp_qtcheck \
22 zconf.tab.c zconf.tab.h lex.zconf.c
23
24include $(TOPDIR)/Rules.make
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
35 HOSTCFLAGS_lex.zconf.o:= -I$(src)
36 HOSTCFLAGS_zconf.tab.o:= -I$(src)
37
38 HOSTLOADLIBES_qconf:= -L$(QTDIR)/lib -Wl,-rpath,$(QTDIR)/lib -lqt -ldl
39 HOSTCXXFLAGS_qconf.o:= -I$(QTDIR)/include
40
41$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o: $(obj)/zconf.tab.h
42
43$(obj)/qconf.o: $(obj)/.tmp_qtcheck
44
45$(obj)/.tmp_qtcheck:
46ifeq ($(MOC),)
47 @echo Unable to find the QT installation. Please make sure that the
48 @echo QT development package is correctly installed and the QTDIR
49 @echo environment variable is set to the correct location.
50 @false
51else
52 @touch $@
53endif
54
55$(obj)/zconf.tab.o: $(obj)/lex.zconf.c
56
57$(obj)/kconfig_load.o: $(obj)/lkc_defs.h
58
59$(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
60
61$(obj)/%.moc: $(src)/%.h
62 $(MOC) -i $< -o $@
63
64$(obj)/lkc_defs.h: $(src)/lkc_proto.h
65 sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
66
67
68###
69# The following requires flex/bison
70# By default we use the _shipped versions, uncomment the following line if
71# you are modifying the flex/bison src.
72# LKC_GENPARSER := 1
73
74ifdef LKC_GENPARSER
75
76$(obj)/zconf.tab.c: $(obj)/zconf.y
77$(obj)/zconf.tab.h: $(obj)/zconf.tab.c
78
79%.tab.c: %.y
80 bison -t -d -v -b $* -p $(notdir $*) $<
81
82lex.%.c: %.l
83 flex -P$(notdir $*) -o$@ $<
84
85endif
diff --git a/scripts/kconfig/README b/scripts/kconfig/README
new file mode 100644
index 0000000..6be26e4
--- a/dev/null
+++ b/scripts/kconfig/README
@@ -0,0 +1,17 @@
1This package requires flex, bison and qt to compile (actually it's
2possible without qt, but you'll miss most of the fun :) ).
3On most systems a simple 'make' should be enough, if you have qt
4installed in unusual location either set the QTDIR environment variable
5or issue 'make QTDIR=<path>'.
6
7'make install KERNELSRC=<path/to/linux/kernel> should be enough to
8install the package. The path must point to recent kernel sources,
9which will be converted to use this package. With 'make uninstall
10KERNELSRC=...' the package can be removed from the kernel again.
11
12lkc include a SWIG interface file. 'make ruby' builds a extension
13library for ruby in the .ruby dir.
14
15Have fun, Roman
16
17Please send all your comments to zippel@linux-m68k.org
diff --git a/scripts/kconfig/cml1.h b/scripts/kconfig/cml1.h
new file mode 100644
index 0000000..4a6d977
--- a/dev/null
+++ b/scripts/kconfig/cml1.h
@@ -0,0 +1,36 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#ifndef CML1_H
7#define CML1_H
8
9#include <stdio.h>
10#ifndef YYBISON
11#include "cml1.tab.h"
12#endif
13#define CML1
14#define WORD T_WORD
15#define prop stmt
16#define property statement
17#include "expr.h"
18
19struct symbol *lookup_symbol(char *name, int type);
20struct symbol *lookup_symbol_ref(char *name);
21
22void new_string(void);
23void append_string(const char *str, int size);
24extern char *text;
25
26extern int cml1debug;
27extern int cml1parse(void);
28extern void helplex(char *help);
29
30extern void scan_init(char *name);
31extern void print_files(FILE *out, const char *name);
32extern void optimize_config(void);
33
34void fprint_expr(FILE *out, struct expr *e, int prevtoken);
35
36#endif /* CML1_H */
diff --git a/scripts/kconfig/cml1.l b/scripts/kconfig/cml1.l
new file mode 100644
index 0000000..d6c33a0
--- a/dev/null
+++ b/scripts/kconfig/cml1.l
@@ -0,0 +1,213 @@
1%option nounput backup nostdinit noyywrap full ecs
2%option 8bit backup nodefault perf-report perf-report
3%x STRING
4%{
5/*
6 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
7 * Released under the terms of the GNU GPL v2.0.
8 */
9
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include <unistd.h>
14#include "cml1.h"
15
16char *text;
17static char *text_ptr;
18static int text_size, text_asize;
19
20struct buffer {
21 struct buffer *parent;
22 YY_BUFFER_STATE state;
23};
24
25struct buffer *current_buf;
26
27int lineno(void)
28{
29 if (current_buf)
30 return current_file->lineno;
31 else
32 return 0;
33}
34
35void scan_init(char *file)
36{
37 struct buffer *buf = malloc(sizeof(*buf));
38 memset(buf, 0, sizeof(*buf));
39
40 yyin = fopen(file, "r");
41 if (!yyin) {
42 printf("can't find file %s\n", file);
43 exit(1);
44 }
45 current_buf = buf;
46
47 current_file = lookup_file(file);
48 current_file->lineno = 0;
49 current_file->flags = FILE_BUSY;
50}
51
52void scan_nextfile(char *name)
53{
54 struct file *file = lookup_file(name);
55 struct buffer *buf = malloc(sizeof(*buf));
56 memset(buf, 0, sizeof(*buf));
57
58 current_buf->state = YY_CURRENT_BUFFER;
59 yyin = fopen(name, "r");
60 if (!yyin) {
61 printf("can't find file %s\n", name);
62 exit(1);
63 }
64 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
65 buf->parent = current_buf;
66 current_buf = buf;
67
68 if (file->flags & FILE_BUSY) {
69 printf("recursive scan (%s)?\n", name);
70 exit(1);
71 }
72 file->flags |= FILE_BUSY;
73 file->lineno = 0;
74 file->parent = current_file;
75 current_file = file;
76}
77
78 #define START_STRSIZE16
79
80void new_string(void)
81{
82 text = malloc(START_STRSIZE);
83 text_asize = START_STRSIZE;
84 text_ptr = text;
85 text_size = 0;
86 *text_ptr = 0;
87}
88
89void append_string(const char *str, int size)
90{
91 int new_size = text_size + size + 1;
92 if (new_size > text_asize) {
93 text = realloc(text, new_size);
94 text_asize = new_size;
95 text_ptr = text + text_size;
96 }
97 memcpy(text_ptr, str, size);
98 text_ptr += size;
99 text_size += size;
100 *text_ptr = 0;
101}
102
103void alloc_string(const char *str, int size)
104{
105 text = malloc(size + 1);
106 memcpy(text, str, size);
107 text[size] = 0;
108}
109
110%}
111%%
112 int str = 0;
113
114 \"|\'{
115 str = yytext[0];
116 new_string();
117 BEGIN(STRING);
118}
119<STRING>{
120 [^'"\n\\]+{
121 append_string(yytext, yyleng);
122 }
123 \'|\"{
124 if (str == yytext[0]) {
125 BEGIN(INITIAL);
126 cml1lval.string = text;
127 //printf("s:%s", text);
128 return str == '"' ? T_WORD_DQUOTE : T_WORD_QUOTE;
129 } else
130 append_string(yytext, 1);
131 }
132 \\[ \t]*\nappend_string(yytext+yyleng-1, 1); current_file->lineno++;
133 \\[ \t]*append_string(yytext+1, yyleng-1);
134 \\. append_string(yytext+1, 1);
135 \n{
136 printf(":%d: open string!\n", current_file->lineno+1);
137 exit(0);
138 }
139 <<EOF>>{
140 printf(":%d: open string!\n", current_file->lineno+1);
141 exit(0);
142 }
143}
144 mainmenu_name[ \t]return T_MAINMENU_NAME;
145 mainmenu_option[ \t]return T_MAINMENU_OPTION;
146 next_comment/[ \t\n]return T_NEXT_COMMENT;
147 endmenu/[ \t\n] return T_ENDMENU;
148 comment[ \t] return T_COMMENT;
149 bool[ \t] return T_BOOL;
150 hex[ \t] return T_HEX;
151 int[ \t] return T_INT;
152 string[ \t] return T_STRING;
153 tristate[ \t] return T_TRISTATE;
154 define_bool[ \t]return T_DEFINE_BOOL;
155 define_hex[ \t] return T_DEFINE_HEX;
156 define_int[ \t] return T_DEFINE_INT;
157 define_string[ \t]return T_DEFINE_STRING;
158 define_tristate[ \t]return T_DEFINE_TRISTATE;
159 dep_bool[ \t] return T_DEP_BOOL;
160 dep_mbool[ \t] return T_DEP_MBOOL;
161 dep_tristate[ \t]return T_DEP_TRISTATE;
162 unset[ \t] return T_UNSET;
163 choice[ \t] return T_CHOICE;
164 source[ \t] return T_SOURCE;
165 if[ \t] return T_IF;
166 else/[ \t\n] return T_ELSE;
167 fi/[ \t\n] return T_FI;
168 then/[ \t\n] return T_THEN;
169 \[ return '[';
170 \] return ']';
171 ; return ';';
172 != return T_UNEQUAL;
173 = return '=';
174 ! return '!';
175 -a return T_AND;
176 -o return T_OR;
177 #[^\n]*{
178 /* comment */
179 current_file->lineno++;
180 alloc_string(yytext, yyleng);
181 cml1lval.string = text;
182 return T_SH_COMMENT;
183}
184 [ \t]+ /* space */
185 \\\n current_file->lineno++;/* ignore */
186 \n{
187 current_file->lineno++;
188 return '\n';
189}
190 [[:alnum:]$/][[:graph:]]*{
191 alloc_string(yytext, yyleng);
192 cml1lval.string = text;
193 //printf("w:%s", text);
194 return T_WORD;
195}
196 .{
197 printf("%s:%d: invalid character 0x%x(%c)\n", current_file->name, current_file->lineno+1, yytext[0], yytext[0]);
198 exit(1);
199}
200 <<EOF>>{
201 if (current_buf->parent) {
202 struct buffer *buf = current_buf;
203 current_buf = buf->parent;
204 current_file->flags |= FILE_SCANNED;
205 current_file->flags &= ~FILE_BUSY;
206 current_file = current_file->parent;
207 yy_delete_buffer(YY_CURRENT_BUFFER);
208 yy_switch_to_buffer(current_buf->state);
209 free(buf);
210 } else
211 yyterminate();
212}
213%%
diff --git a/scripts/kconfig/cml1.y b/scripts/kconfig/cml1.y
new file mode 100644
index 0000000..42c4216
--- a/dev/null
+++ b/scripts/kconfig/cml1.y
@@ -0,0 +1,2482 @@
1%{
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 */
6
7#include <ctype.h>
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11
12 #define PRINTD 0x0001
13 #define DEBUG_PARSE0x0002
14 #define DEBUG_OPT0x0004
15 #define DEBUG_OPT10x0008
16 #define DEBUG_OPT20x0010
17 #define DEBUG_OPT30x0020
18 #define DEBUG_OPT40x0040
19 #define DEBUG_OPT50x0080
20 #define DEBUG_DEP0x0100
21
22int cdebug = PRINTD;//DEBUG_OPT|-1;
23
24#define YYERROR_VERBOSE
25%}
26
27%union
28{
29 char *string;
30 struct expr *expr;
31 struct symbol *symbol;
32 struct statement *stmt;
33}
34
35%token <string> T_WORD
36%token <string> T_WORD_QUOTE
37%token <string> T_WORD_DQUOTE
38%token T_MAINMENU_NAME
39%token T_MAINMENU_OPTION
40%token T_NEXT_COMMENT
41%token T_ENDMENU
42%token T_COMMENT
43%token T_BOOL
44%token T_HEX
45%token T_INT
46%token T_STRING
47%token T_TRISTATE
48%token T_DEFINE_BOOL
49%token T_DEFINE_HEX
50%token T_DEFINE_INT
51%token T_DEFINE_STRING
52%token T_DEFINE_TRISTATE
53%token T_DEP_BOOL
54%token T_DEP_MBOOL
55%token T_DEP_TRISTATE
56%token T_UNSET
57%token T_CHOICE
58%token T_SOURCE
59%token T_IF
60%token T_ELSE
61%token T_FI
62%token T_THEN
63%token T_UNEQUAL
64%token <string> T_SH_COMMENT
65
66%type <string> prompt
67%type <string> word
68%type <string> menu_comment
69%type <symbol> symbol
70%type <symbol> symbol_ref
71%type <symbol> symbol_other
72%type <stmt> statement
73%type <expr> expr
74%type <expr> dep
75%type <expr> deps
76%type <stmt> comment_opt
77
78%left T_OR
79%left T_AND
80%nonassoc '!'
81%left '=' T_UNEQUAL
82
83%{
84#include "cml1.h"
85
86extern int cml1lex(void);
87static void cml1error(const char *err);
88extern int lineno(void);
89extern void scan_nextfile(char *file);
90
91struct statement *create_stmt(int token);
92struct statement *add_stmt(struct symbol *sym, int token,
93 char *prompt, struct symbol *def);
94void print_expr(int mask, struct expr *e, int prevtoken);
95void print_dep(int mask, struct statement *stmt);
96
97void eliminate_eq(int token, struct expr **ep1, struct expr **ep2);
98static inline int expr_is_yes(struct expr *e);
99static inline int expr_is_no(struct expr *e);
100struct expr *trans_dep_bool(struct expr *e);
101struct expr *trans_bool_expr(struct expr *e);
102struct expr *fixup_expr(struct expr *e);
103struct expr *trans_expr(struct expr *e);
104void extract_eq(int token, struct expr **ep, struct expr **ep1, struct expr **ep2);
105struct expr *extract_eq_and(struct expr **ep1, struct expr **ep2);
106struct expr *extract_eq_or(struct expr **ep1, struct expr **ep2);
107struct expr *optimize_expr_or(struct expr *e);
108struct expr *eliminate_dups(struct expr *e);
109struct expr *eliminate_yn(struct expr *e);
110void eliminate_dep(struct symbol *sym, struct expr *dep);
111int contains_expr(struct expr *dep, struct expr *e);
112
113#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
114#define fprintd(f, mask, fmt...) if (cdebug & (mask)) fprintf(f, fmt)
115
116static struct expr *if_expr;
117static struct menu root_menu;
118static struct menu *current_menu = &root_menu;
119
120struct symbol *symbol_hash[257];
121%}
122%%
123 input:line
124;
125
126 line:/* empty */
127;
128
129 line:line statement
130;
131
132 line:line '\n'
133;
134
135statement: T_SH_COMMENT
136{
137 $$ = create_stmt(T_SH_COMMENT);
138 $$->text = $1;
139};
140
141statement: T_MAINMENU_NAME prompt '\n'
142{
143 $$ = create_stmt(T_MAINMENU_NAME);
144 $$->text = $2;
145 printd(DEBUG_PARSE, "%d:mainmenu_name: %s\n", lineno(), $2);
146};
147
148statement: T_COMMENT prompt '\n'
149{
150 $$ = create_stmt(T_COMMENT);
151 $$->text = $2;
152 $$->dep = trans_expr(fixup_expr(expr_copy(if_expr)));
153 printd(DEBUG_PARSE, "%d:comment: %s\n", lineno(), $2);
154};
155
156statement: T_BOOL prompt symbol dep '\n'
157{
158 $$ = add_stmt($3, T_BOOL, $2, NULL);
159 printd(DEBUG_PARSE, "%d:bool: %s %s\n", lineno(), $2, $3->name);
160 if ($4) {
161 printf("%s:%d: warning ignoring dependencies\n", current_file->name, current_file->lineno);
162 expr_free($4);
163 }
164 print_dep(DEBUG_PARSE, $$);
165};
166
167statement: T_HEX prompt symbol symbol_other '\n'
168{
169 $$ = add_stmt($3, T_HEX, $2, NULL);
170 add_stmt($3, T_DEFINE_HEX, NULL, $4);
171 printd(DEBUG_PARSE, "%d:hex: %s %s %s\n", lineno(), $2, $3->name, $4->name);
172 print_dep(DEBUG_PARSE, $$);
173};
174
175statement: T_INT prompt symbol symbol_other '\n'
176{
177 $$ = add_stmt($3, T_INT, $2, NULL);
178 add_stmt($3, T_DEFINE_INT, NULL, $4);
179 printd(DEBUG_PARSE, "%d:int: %s %s %s\n", lineno(), $2, $3->name, $4->name);
180 print_dep(DEBUG_PARSE, $$);
181};
182
183statement: T_STRING prompt symbol symbol_other '\n'
184{
185 $$ = add_stmt($3, T_STRING, $2, NULL);
186 add_stmt($3, T_DEFINE_STRING, NULL, $4);
187 printd(DEBUG_PARSE, "%d:string: %s %s %s\n", lineno(), $2, $3->name, $4->name);
188 print_dep(DEBUG_PARSE, $$);
189};
190
191statement: T_TRISTATE prompt symbol dep '\n'
192{
193 $$ = add_stmt($3, T_TRISTATE, $2, NULL);
194 printd(DEBUG_PARSE, "%d:tristate: %s %s\n", lineno(), $2, $3->name);
195 if ($4) {
196 printf("%s:%d: warning ignoring dependencies\n", current_file->name, current_file->lineno);
197 expr_free($4);
198 }
199 print_dep(DEBUG_PARSE, $$);
200};
201
202statement: T_DEFINE_BOOL symbol symbol_ref comment_opt '\n'
203{
204 $$ = add_stmt($2, T_DEFINE_BOOL, NULL, $3);
205 printd(DEBUG_PARSE, "%d:define_bool: %s %s\n", lineno(), $2->name, $3->name);
206 print_dep(DEBUG_PARSE, $$);
207};
208
209statement: T_DEFINE_HEX symbol symbol_other '\n'
210{
211 $$ = add_stmt($2, T_DEFINE_HEX, NULL, $3);
212 printd(DEBUG_PARSE, "%d:define_hex: %s %s\n", lineno(), $2->name, $3->name);
213 print_dep(DEBUG_PARSE, $$);
214};
215
216statement: T_DEFINE_INT symbol symbol_other comment_opt '\n'
217{
218 $$ = add_stmt($2, T_DEFINE_INT, NULL, $3);
219 printd(DEBUG_PARSE, "%d:define_int: %s %s\n", lineno(), $2->name, $3->name);
220 print_dep(DEBUG_PARSE, $$);
221};
222
223statement: T_DEFINE_STRING symbol symbol_other '\n'
224{
225 $$ = add_stmt($2, T_DEFINE_STRING, NULL, $3);
226 printd(DEBUG_PARSE, "%d:define_string: %s %s\n", lineno(), $2->name, $3->name);
227 print_dep(DEBUG_PARSE, $$);
228};
229
230statement: T_DEFINE_TRISTATE symbol symbol_ref '\n'
231{
232 $$ = add_stmt($2, T_DEFINE_TRISTATE, NULL, $3);
233 printd(DEBUG_PARSE, "%d:define_tristate: %s %s\n", lineno(), $2->name, $3->name);
234 print_dep(DEBUG_PARSE, $$);
235};
236
237statement: T_DEP_BOOL prompt symbol dep '\n'
238{
239 $$ = add_stmt($3, T_DEP_BOOL, $2, NULL);
240 if (!($$->dep2 = $4))
241 printf("%s:%d: warning dep_bool without dependencies\n", current_file->name, current_file->lineno);
242 printd(DEBUG_PARSE, "%d:dep_bool: %s %s\n", lineno(), $2, $3->name);
243 print_dep(DEBUG_PARSE, $$);
244};
245
246statement: T_DEP_MBOOL prompt symbol dep '\n'
247{
248 $$ = add_stmt($3, T_DEP_MBOOL, $2, NULL);
249 if (!($$->dep2 = $4))
250 printf("%s:%d: warning dep_mbool without dependencies\n", current_file->name, current_file->lineno);
251 printd(DEBUG_PARSE, "%d:dep_mbool: %s %s\n", lineno(), $2, $3->name);
252 print_dep(DEBUG_PARSE, $$);
253};
254
255statement: T_DEP_TRISTATE prompt symbol dep '\n'
256{
257 $$ = add_stmt($3, T_DEP_TRISTATE, $2, NULL);
258 if (!($$->dep2 = $4))
259 printf("%s:%d: warning dep_tristate without dependencies\n", current_file->name, current_file->lineno);
260 printd(DEBUG_PARSE, "%d:dep_tristate: %s %s\n", lineno(), $2, $3->name);
261 print_dep(DEBUG_PARSE, $$);
262};
263
264statement: T_UNSET deps '\n'
265{
266 //add_stmt($2, T_UNSET, NULL, NULL);
267 printd(DEBUG_PARSE, "%d:unset\n", lineno());
268 print_dep(DEBUG_PARSE, NULL);
269};
270
271statement: T_CHOICE prompt word word '\n'
272{
273 struct statement *stmt;
274 struct symbol *sym;
275 struct expr **depp;
276 char *ptr, *name, *def, end;
277
278 printd(DEBUG_PARSE, "%d:choice: %s %s %s\n", lineno(), $2, $3, $4);
279 $$ = create_stmt('^');
280 $$->text = $2;
281 ptr = $3;
282 depp = &$$->dep;
283 do {
284 while (isspace(*ptr))
285 ptr++;
286 if (!*ptr)
287 break;
288 def = ptr;
289 while (*ptr && !isspace(*ptr))
290 ptr++;
291 *ptr++ = 0;
292 //def = lookup_symbol(name, SYMBOL_OTHER);
293 while (isspace(*ptr))
294 ptr++;
295 if (!*ptr)
296 break;
297 name = ptr;
298 while (*ptr && !isspace(*ptr))
299 ptr++;
300 end = *ptr;
301 *ptr++ = 0;
302 sym = lookup_symbol(name, SYMBOL_BOOLEAN);
303 if (!$$->def) {
304 if (!strncmp(def, $4, strlen($4)))
305 $$->def = sym;
306 }
307 sym->flags |= SYMBOL_CHOICE;
308 stmt = add_stmt(sym, T_BOOL, strdup(def), NULL);
309 if (!stmt->next) {
310 stmt->next = $$;
311 } else
312 printf("warning: unexpected stmt for choice symbol %s\n", sym->name);
313 *depp = expr_alloc_one('^', NULL);
314 (*depp)->right.sym = sym;
315 depp = &(*depp)->left.expr;
316 printd(DEBUG_PARSE, "added symbol: %s %s\n", sym->name, stmt->text);
317 } while (end);
318 print_dep(DEBUG_PARSE, NULL);
319};
320
321statement: T_IF '[' expr ']' semi_or_nl T_THEN comment_opt '\n'
322{
323 struct expr *e;
324 printd(DEBUG_PARSE, "%d:if ", lineno());
325 print_expr(DEBUG_PARSE, $3, 0);
326 printd(DEBUG_PARSE, "\n");
327 e = expr_alloc_one(T_IF, $3);
328 e->right.expr = if_expr;
329 if_expr = e;
330 $$ = NULL;
331};
332
333semi_or_nl: ';' | '\n'
334;
335
336statement: T_ELSE comment_opt '\n'
337{
338 printd(DEBUG_PARSE, "%d:else\n", lineno());
339 if_expr->token = T_ELSE;
340 $$ = NULL;
341};
342
343statement: T_FI comment_opt '\n'
344{
345 struct expr *e;
346 printd(DEBUG_PARSE, "%d:fi\n", lineno());
347 e = if_expr;
348 if (e) {
349 if_expr = e->right.expr;
350 expr_free(e->left.expr);
351 free(e);
352 } else
353 YYABORT;
354 $$ = NULL;
355};
356
357statement: T_MAINMENU_OPTION T_NEXT_COMMENT menu_comment '\n'
358{
359 printd(DEBUG_PARSE, "%d:mainmenu_option: %s\n", lineno(), $3);
360 $$ = create_stmt(T_MAINMENU_OPTION);
361 $$->text = $3;
362 $$->dep = trans_expr(fixup_expr(expr_copy(if_expr)));
363 current_menu = $$->menu;
364};
365
366menu_comment: '\n' T_COMMENT prompt { $$ = $3; }
367 | '\n' menu_comment { $$ = $2; }
368;
369
370statement: T_ENDMENU '\n'
371{
372 $$ = create_stmt(T_ENDMENU);
373 printd(DEBUG_PARSE, "%d:endmenu\n", lineno());
374 current_menu = current_menu->parent;
375};
376
377statement: T_SOURCE word '\n'
378{
379 static char helppath[256];
380 char *p;
381 $$ = create_stmt(T_SOURCE);
382 $$->text = $2;
383 printd(DEBUG_PARSE, "%d:source: %s\n", lineno(), $2);
384 strcpy(helppath, $2);
385 p = strrchr(helppath, '.');
386 if (p) {
387 strcpy(p, ".help");
388 helplex(helppath);
389 }
390 scan_nextfile($2);
391};
392
393 comment_opt: /* empty */{ $$ = NULL; }
394 |T_SH_COMMENT
395{
396 $$ = create_stmt(T_SH_COMMENT);
397 $$->text = $1;
398};
399
400prompt: T_WORD_QUOTE
401 | T_WORD_DQUOTE
402;
403
404 word: T_WORD
405 | T_WORD_QUOTE
406 | T_WORD_DQUOTE
407;
408
409 dep: /* empty */ { $$ = NULL; }
410 | deps { $$ = $1; }
411;
412
413 deps: symbol_ref { $$ = expr_alloc_symbol($1); }
414 | deps symbol_ref{ $$ = expr_alloc_two('&', $1, expr_alloc_symbol($2)); }
415;
416
417 symbol: T_WORD { $$ = lookup_symbol($1, SYMBOL_UNKNOWN); free($1); }
418;
419
420 expr: symbol_ref '=' symbol_ref { $$ = expr_alloc_comp('=', $1, $3); }
421 | symbol_ref T_UNEQUAL symbol_ref{ $$ = expr_alloc_comp(T_UNEQUAL, $1, $3); }
422 | '!' expr { $$ = expr_alloc_one('!', $2); }
423 | expr T_AND expr{ $$ = expr_alloc_two(T_AND, $1, $3); }
424 | expr T_OR expr{ $$ = expr_alloc_two(T_OR, $1, $3); }
425;
426
427 symbol_ref: T_WORD { $$ = lookup_symbol_ref($1); free($1); }
428 | T_WORD_QUOTE{ $$ = lookup_symbol_ref($1); free($1); }
429 | T_WORD_DQUOTE{ $$ = lookup_symbol_ref($1); free($1); }
430;
431
432 symbol_other: T_WORD { $$ = lookup_symbol($1, SYMBOL_OTHER); free($1); }
433 | T_WORD_QUOTE{ $$ = lookup_symbol($1, SYMBOL_OTHER); free($1); }
434 | T_WORD_DQUOTE{ $$ = lookup_symbol($1, SYMBOL_OTHER); free($1); }
435;
436
437%%
438
439static void yyerror(const char *err)
440{
441 printf("%s:%d: %s\n", current_file->name, current_file->lineno + 1, err);
442 exit(1);
443}
444
445void print_dep(int mask, struct statement *stmt)
446{
447 printd(mask, "dep: ");
448 if (stmt) {
449 if (stmt->dep2)
450 printd(mask, "[");
451 print_expr(mask, stmt->dep, 0);
452 if (stmt->dep2) {
453 printd(mask, " & ");
454 print_expr(mask, stmt->dep2, 0);
455 printd(mask, "]");
456 }
457 } else
458 print_expr(mask, if_expr, 0);
459 printd(mask, "\n");
460}
461
462struct symbol *lookup_symbol(char *name, int type)
463{
464 struct symbol *symbol;
465 char *ptr;
466 int hash = 0;
467
468 //printf("lookup: %s -> ", name);
469 if (type != SYMBOL_OTHER && !strncmp(name, "CONFIG_", 7)) {
470 name += 7;
471 } else {
472 //printf("Warning: Invalid symbol name '%s'\n", name);
473 type = SYMBOL_OTHER;
474 }
475
476 for (ptr = name; *ptr; ptr++)
477 hash += *ptr;
478
479 for (symbol = symbol_hash[hash&255]; symbol; symbol = symbol->next) {
480 if (!strcmp(symbol->name, name)) {
481 //printf("h:%p\n", symbol);
482 if (type == SYMBOL_BOOLEAN)
483 symbol->type = SYMBOL_BOOLEAN;
484 return symbol;
485 }
486 }
487
488 symbol = malloc(sizeof(*symbol));
489 memset(symbol, 0, sizeof(*symbol));
490 symbol->name = strdup(name);
491 symbol->type = type;
492
493 symbol->next = symbol_hash[hash&255];
494 symbol_hash[hash&255] = symbol;
495
496 //printf("n:%p\n", symbol);
497 return symbol;
498}
499
500struct symbol *lookup_symbol_ref(char *name)
501{
502 if (name[0] == 'y' && !name[1])
503 return &symbol_yes;
504 if (name[0] == 'm' && !name[1])
505 return &symbol_mod;
506 if (name[0] == 'n' && !name[1])
507 return &symbol_no;
508 if (name[0] == '$')
509 return lookup_symbol(name+1, SYMBOL_UNKNOWN);
510 return lookup_symbol(name, SYMBOL_OTHER);
511}
512
513struct statement *create_stmt(int token)
514{
515 struct statement *stmt;
516 struct menu *menu, **menup;
517
518 stmt = malloc(sizeof(*stmt));
519 memset(stmt, 0, sizeof(*stmt));
520 stmt->token = token;
521 stmt->file = current_file;
522 stmt->lineno = lineno();
523
524 if (!current_file->stmt)
525 current_file->stmt = stmt;
526 if (current_file->last_stmt)
527 current_file->last_stmt->next_pos = stmt;
528 current_file->last_stmt = stmt;
529
530 menu = malloc(sizeof(*menu));
531 memset(menu, 0, sizeof(*menu));
532 menu->prompt = stmt;
533 menu->parent = current_menu;
534 for (menup = &current_menu->list; *menup; menup = &(*menup)->next)
535 ;
536 *menup = menu;
537
538 stmt->menu = menu;
539
540 return stmt;
541}
542
543struct statement *add_stmt(struct symbol *sym, int token, char *prompt, struct symbol *def)
544{
545 struct statement *stmt = create_stmt(token);
546
547 stmt->dep = expr_copy(if_expr);
548 stmt->text = prompt;
549 stmt->def = def;
550
551 stmt->sym = sym;
552 stmt->next = sym->stmt;
553 sym->stmt = stmt;
554
555 return stmt;
556}
557
558void print_quoted_string(FILE *out, const char *str)
559{
560 const char *p;
561 int len;
562
563 putc('"', out);
564 while ((p = strchr(str, '"'))) {
565 len = p - str;
566 if (len)
567 fprintf(out, "%.*s", len, str);
568 fputs("\\\"", out);
569 str += len + 1;
570 }
571 fputs(str, out);
572 putc('"', out);
573}
574
575const char *skip_space(const char *p)
576{
577 while (*p == ' ')
578 p++;
579 return p;
580}
581
582void do_print_symbol(FILE *out, struct symbol *sym)
583{
584 struct statement *zero_stmt, *stmt, *stmt2;
585 struct expr *dep, *dep2;
586
587#define VALID_STMT(s) (s->token && s->token != '^' && s->menu && s->menu->parent == current_menu)
588
589 dep = NULL;
590 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
591 if (!VALID_STMT(stmt))
592 continue;
593 if (!dep) {
594 if (!stmt->dep)
595 break;
596 dep = stmt->dep;
597 stmt->dep = NULL;
598 } else {
599 struct expr *e = dep;
600 if (stmt->dep) {
601 dep = extract_eq_and(&e, &stmt->dep);
602 if (expr_is_yes(e)) {
603 expr_free(e);
604 continue;
605 }
606 } else
607 dep = NULL;
608 for (stmt2 = sym->stmt; stmt != stmt2; stmt2 = stmt2->next) {
609 if (!VALID_STMT(stmt2))
610 continue;
611 stmt2->dep = !stmt2->dep ? expr_copy(e) :
612 expr_alloc_two(T_AND, expr_copy(e), stmt2->dep);
613 }
614 expr_free(e);
615 if (!dep)
616 break;
617 }
618 }
619
620 zero_stmt = NULL;
621 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
622 if (!stmt->token)
623 zero_stmt = stmt;
624 if (VALID_STMT(stmt))
625 break;
626 }
627 if (!stmt) {
628 if (sym->flags & SYMBOL_PRINTED)
629 return;
630 if (!zero_stmt)
631 return;
632 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
633 if (stmt->token)
634 return;
635 }
636 stmt = zero_stmt;
637 }
638
639 fprintf(out, "config %s\n", sym->name);
640
641 switch (sym->type) {
642 case SYMBOL_BOOLEAN: fputs("\tbool", out); break;
643 case SYMBOL_TRISTATE: fputs("\ttristate", out); break;
644 case SYMBOL_INT: fputs("\tint", out); break;
645 case SYMBOL_HEX: fputs("\thex", out); break;
646 case SYMBOL_STRING: fputs("\tstring", out); break;
647 default: fputs("\t#unknown type?", out); break;
648 }
649
650 if (stmt->text) {
651 fputc(' ', out);
652 print_quoted_string(out, skip_space(stmt->text));
653 if (!expr_is_yes(stmt->dep)) {
654 fputs(" if ", out);
655 fprint_expr(out, stmt->dep, 0);
656 }
657 stmt->menu = NULL;
658 stmt = stmt->next;
659 }
660 fputc('\n', out);
661
662 if (sym->dep || dep) {
663 dep = expr_alloc_and(expr_copy(sym->dep), dep);
664 dep = eliminate_yn(dep);
665 if (current_menu->prompt && current_menu->prompt->dep) {
666 dep2 = expr_copy(current_menu->prompt->dep);
667 switch (sym->type) {
668 case SYMBOL_BOOLEAN: case SYMBOL_INT: case SYMBOL_HEX: case SYMBOL_STRING:
669 dep2 = trans_bool_expr(dep2);
670 break;
671 }
672 eliminate_eq(T_AND, &dep, &dep2);
673 dep = eliminate_yn(dep);
674#if 0
675 dep2 = eliminate_yn(dep2);
676 if (!expr_is_yes(dep2)) {
677 printf("Warning, I'm still confused (%s)?\n", sym->name);
678 print_expr(PRINTD, dep, 0);
679 printf(" - ");
680 print_expr(PRINTD, dep2, 0);
681 printf("\n");
682 }
683#endif
684 expr_free(dep2);
685 }
686 if (!expr_is_yes(dep)) {
687 fputs("\tdepends on ", out);
688 fprint_expr(out, eliminate_yn(dep), 0);
689 fputc('\n', out);
690 }
691 }
692 for (; stmt; stmt = stmt->next) {
693 if (!VALID_STMT(stmt))
694 continue;
695 if (stmt->text) {
696 ;
697 } else if (stmt->def) {
698 if (sym->flags & SYMBOL_CHOICE)
699 printf("Choice value %s has default value!\n", sym->name);
700 fputs( "\tdefault ", out);
701 switch (sym->type) {
702 case SYMBOL_BOOLEAN:
703 case SYMBOL_TRISTATE:
704 fputs(stmt->def->name, out);
705 break;
706 default:
707 print_quoted_string(out, stmt->def->name);
708 break;
709 }
710 if (!expr_is_yes(stmt->dep)) {
711 fputs(" if ", out);
712 fprint_expr(out, eliminate_yn(stmt->dep), 0);
713 }
714 fputc('\n', out);
715 stmt->menu = NULL;
716 }
717 }
718 if (sym->help && !(sym->flags & SYMBOL_PRINTED)) {
719 int len = strlen(sym->help);
720 char *p, *p2;
721 int cnt;
722
723 while (sym->help[--len] == '\n')
724 sym->help[len] = 0;
725 for (p = sym->help, cnt = 0; (p = strchr(p, '\n')); p++, cnt++)
726 ;
727 if (cnt >= 9)
728 fprintf(out, "\t---help---\n");
729 else
730 fprintf(out, "\thelp\n");
731 for (p = sym->help;; p = p2 + 1) {
732 while (*p == ' ')
733 p++;
734 if (*p == '\n') {
735 fputc('\n', out);
736 p2 = p;
737 continue;
738 }
739 p2 = strchr(p, '\n');
740 if (!p2)
741 break;
742 fprintf(out, "\t %.*s\n", p2 - p, p);
743 }
744 fprintf(out, "\t %s\n", p);
745 }
746 fputc('\n', out);
747 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
748 if (!VALID_STMT(stmt))
749 continue;
750 if (stmt->text) {
751 fprintf(out, "config %s\n", sym->name);
752 fputs( "\tprompt ", out);
753 print_quoted_string(out, skip_space(stmt->text));
754 fputc('\n', out);
755 dep2 = expr_alloc_and(expr_copy(dep), expr_copy(stmt->dep));
756 dep2 = eliminate_dups(dep2);
757 if (!expr_is_yes(dep2)) {
758 fputs("\tdepends on ", out);
759 fprint_expr(out, dep2, 0);
760 fputc('\n', out);
761 }
762 expr_free(dep2);
763 fputc('\n', out);
764 stmt->menu = NULL;
765 }
766 }
767 sym->flags |= SYMBOL_PRINTED;
768 expr_free(dep);
769}
770
771void print_choice(FILE *out, struct symbol *sym)
772{
773 struct statement *stmt;
774 struct expr *lst, *dep, *tmp, *tmp2;
775
776 if (sym->flags & SYMBOL_PRINTED)
777 return;
778
779 for (stmt = sym->stmt; stmt; stmt = stmt->next)
780 if (stmt->token == '^')
781 break;
782 if (!stmt)
783 //warn?
784 return;
785
786 fputs("choice\n", out);
787 if (stmt->text) {
788 fputs("\tprompt ", out);
789 print_quoted_string(out, skip_space(stmt->text));
790 fputc('\n', out);
791 }
792
793 dep = NULL;
794 for (lst = stmt->dep; lst; lst = lst->left.expr) {
795 sym = lst->right.sym;
796 if (sym == &symbol_no) {
797 fputs("\toptional\n", out);
798 continue;
799 }
800 if (!dep) {
801 if (!sym->dep)
802 break;
803 dep = sym->dep;
804 sym->dep = NULL;
805 } else {
806 tmp = dep;
807 if (sym->dep) {
808 dep = extract_eq_and(&tmp, &sym->dep);
809 if (expr_is_yes(tmp)) {
810 expr_free(tmp);
811 continue;
812 }
813 } else
814 dep = NULL;
815 for (tmp2 = stmt->dep; tmp2 != lst; tmp2 = tmp2->left.expr) {
816 sym = tmp2->right.sym;
817 if (sym == &symbol_no)
818 continue;
819 sym->dep = !sym->dep ? expr_copy(tmp) :
820 expr_alloc_two(T_AND, expr_copy(tmp), sym->dep);
821 sym->dep = eliminate_yn(sym->dep);
822 }
823 expr_free(tmp);
824 if (!dep)
825 break;
826 }
827 }
828 for (;lst; lst = lst->left.expr) {
829 sym = lst->right.sym;
830 if (sym == &symbol_no) {
831 fputs("\toptional\n", out);
832 continue;
833 }
834 }
835 if (!expr_is_yes(dep)) {
836 fputs("\tdepends on ", out);
837 fprint_expr(out, dep, 0);
838 fputc('\n', out);
839 }
840 if (stmt->def)
841 fprintf(out, "\tdefault %s\n", stmt->def->name);
842
843 fputc('\n', out);
844
845 for (lst = stmt->dep; lst; lst = lst->left.expr) {
846 sym = lst->right.sym;
847 if (sym == &symbol_no)
848 continue;
849 do_print_symbol(out, sym);
850 sym->flags |= SYMBOL_PRINTED;
851 }
852
853 fputs("endchoice\n\n", out);
854}
855
856void print_symbols(FILE *out, struct symbol *sym)
857{
858 //if (sym->flags & SYMBOL_PRINTED)
859 //return;
860 //sym->flags |= SYMBOL_PRINTED;
861
862 if (sym->flags & SYMBOL_CHOICE) {
863 print_choice(out, sym);
864 return;
865 }
866 do_print_symbol(out, sym);
867}
868
869char *gen_filename(const char *name)
870{
871 static char newname[128];
872 char *p;
873
874 strcpy(newname, name);
875 p = strrchr(newname, '/');
876 if (!p)
877 p = newname;
878 else
879 p++;
880#if 0
881 p = strrchr(p, '.');
882 if (!p)
883 p = newname + strlen(newname);
884 strcpy(p, ".new");
885#else
886#if 0
887 memcpy(p, "Build", 5);
888 memmove(p + 5, p + 6, strlen(p) - 5);
889 p = strrchr(p, '.');
890 if (!p)
891 p = newname + strlen(newname);
892 strcpy(p, ".conf");
893#else
894 memmove(p + 1, p, strlen(p) + 1);
895 p[0] = 'K';
896 p[1] = 'c';
897 p = strrchr(p, '.');
898 *p = 0;
899#endif
900#endif
901 return newname;
902}
903
904void print_files(FILE *all_out, const char *name)
905{
906 struct file *file;
907 FILE *out = all_out;
908 struct symbol *sym;
909 struct statement *stmt;
910 struct expr *dep1, *dep2;
911 char *p;
912
913 print_type = 0;
914
915 file = lookup_file(name);
916 if (!file) {
917 fprintf(stderr, "# file %s not found!\n\n", file->name);
918 return;
919 } else if (file->flags & FILE_PRINTED) {
920 fprintf(stderr, "# file %s skipped\n\n", file->name);
921 return;
922 }
923
924 if (!out) {
925 p = gen_filename(file->name);
926 strcat(p, ".lkc");
927 out = fopen(p, "w");
928 if (!out) {
929 printf("unable to open %s for writing!\n", p);
930 exit(1);
931 }
932 }
933
934 if (all_out)
935 fprintf(all_out, "# file %s\n\n", file->name);
936 file->flags |= FILE_PRINTED;
937
938 for (stmt = file->stmt; stmt; stmt = stmt->next_pos) {
939 sym = stmt->sym;
940 if (!sym) {
941 switch (stmt->token) {
942 case T_MAINMENU_NAME:
943 fputs("\nmainmenu ", out);
944 print_quoted_string(out, skip_space(stmt->text));
945 fputs("\n\n", out);
946 break;
947 case T_COMMENT:
948 fputs("comment ", out);
949 print_quoted_string(out, skip_space(stmt->text));
950 stmt->dep = eliminate_dups(trans_expr(stmt->dep));
951 dep1 = expr_copy(stmt->dep);
952 if (dep1 && current_menu->prompt && current_menu->prompt->dep) {
953 dep2 = expr_copy(current_menu->prompt->dep);
954 eliminate_eq(T_AND, &dep1, &dep2);
955 dep1 = eliminate_yn(dep1);
956 dep2 = eliminate_yn(dep2);
957 if (!expr_is_yes(dep2)) {
958 printf("Warning, I'm confused!\n");
959 }
960 expr_free(dep2);
961 }
962 if (!expr_is_yes(dep1)) {
963 dep1 = trans_bool_expr(dep1);
964 fputs("\n\tdepends on ", out);
965 fprint_expr(out, dep1, 0);
966 }
967 expr_free(dep1);
968 fputs("\n\n", out);
969 break;
970 case T_SH_COMMENT:
971 fprintf(out, "%s\n", stmt->text);
972 break;
973 case T_MAINMENU_OPTION:
974 fputs("\nmenu ", out);
975 print_quoted_string(out, skip_space(stmt->text));
976 stmt->dep = eliminate_dups(trans_expr(stmt->dep));
977 dep1 = expr_copy(stmt->dep);
978 if (dep1 && current_menu->prompt && current_menu->prompt->dep) {
979 dep2 = expr_copy(current_menu->prompt->dep);
980 eliminate_eq(T_AND, &dep1, &dep2);
981 dep1 = eliminate_yn(dep1);
982 dep2 = eliminate_yn(dep2);
983 if (!expr_is_yes(dep2)) {
984 printf("Warning, I'm confused!\n");
985 }
986 expr_free(dep2);
987 }
988 if (!expr_is_yes(dep1)) {
989 fputs("\n\tdepends on ", out);
990 fprint_expr(out, dep1, 0);
991 }
992 expr_free(dep1);
993 fputs("\n\n", out);
994 current_menu = stmt->menu;
995 break;
996 case T_ENDMENU:
997 fputs("endmenu\n\n", out);
998 current_menu = current_menu->parent;
999 break;
1000 case T_SOURCE:
1001 fprintf(out, "%ssource ", all_out ? "#" : "");
1002 print_quoted_string(out, gen_filename(stmt->text));
1003 fputs("\n\n", out);
1004 print_files(all_out, stmt->text);
1005 break;
1006 }
1007 } else
1008 print_symbols(out, sym);
1009 }
1010
1011 if (all_out)
1012 fprintf(out, "# fileend %s\n\n", file->name);
1013}
1014
1015static int trans_count;
1016
1017void eliminate_eq(int token, struct expr **ep1, struct expr **ep2)
1018{
1019#define e1 (*ep1)
1020#define e2 (*ep2)
1021
1022 if (e1->token == token) {
1023 eliminate_eq(token, &e1->left.expr, &e2);
1024 eliminate_eq(token, &e1->right.expr, &e2);
1025 return;
1026 }
1027 if (e2->token == token) {
1028 eliminate_eq(token, &e1, &e2->left.expr);
1029 eliminate_eq(token, &e1, &e2->right.expr);
1030 return;
1031 }
1032 if (e1->token == T_WORD && e2->token == T_WORD &&
1033 e1->left.sym == e2->left.sym && (e1->left.sym->flags & (SYMBOL_YES|SYMBOL_NO)))
1034 return;
1035 if (!expr_eq(e1, e2))
1036 return;
1037 trans_count++;
1038 expr_free(e1); expr_free(e2);
1039 switch (token) {
1040 case T_OR:
1041 e1 = expr_alloc_symbol(&symbol_no);
1042 e2 = expr_alloc_symbol(&symbol_no);
1043 break;
1044 case T_AND:
1045 e1 = expr_alloc_symbol(&symbol_yes);
1046 e2 = expr_alloc_symbol(&symbol_yes);
1047 break;
1048 }
1049#undef e1
1050#undef e2
1051}
1052
1053int expr_eq(struct expr *e1, struct expr *e2)
1054{
1055 int res, old_count;
1056
1057 if (e1->token != e2->token)
1058 return 0;
1059 switch (e1->token) {
1060 case '=':
1061 case T_UNEQUAL:
1062 return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym;
1063 case T_WORD:
1064 return e1->left.sym == e2->left.sym;
1065 case '!':
1066 return expr_eq(e1->left.expr, e2->left.expr);
1067 case T_AND:
1068 case T_OR:
1069 e1 = expr_copy(e1);
1070 e2 = expr_copy(e2);
1071 old_count = trans_count;
1072 eliminate_eq(e1->token, &e1, &e2);
1073 e1 = eliminate_yn(e1);
1074 e2 = eliminate_yn(e2);
1075 res = (e1->token == T_WORD &&
1076 e2->token == T_WORD &&
1077 e1->left.sym == e2->left.sym);
1078 expr_free(e1);
1079 expr_free(e2);
1080 trans_count = old_count;
1081 return res;
1082 }
1083 print_expr(PRINTD, e1, 0);
1084 printf(" = ");
1085 print_expr(PRINTD, e2, 0);
1086 printf(" ?\n");
1087 return 0;
1088}
1089
1090/*
1091 * dep_bool FOO -> FOO=y
1092 */
1093struct expr *trans_dep_bool(struct expr *e)
1094{
1095 switch (e->token) {
1096 case '&':
1097 case T_AND:
1098 e->left.expr = trans_dep_bool(e->left.expr);
1099 e->right.expr = trans_dep_bool(e->right.expr);
1100 break;
1101 case T_WORD:
1102 if (e->left.sym->type == SYMBOL_TRISTATE) {
1103 e->token = '=';
1104 e->right.sym = &symbol_yes;
1105 }
1106 break;
1107 }
1108 return e;
1109}
1110
1111/*
1112 * bool FOO!=n => FOO
1113 */
1114struct expr *trans_bool_expr(struct expr *e)
1115{
1116 if (!e)
1117 return NULL;
1118 switch (e->token) {
1119 case T_AND:
1120 case T_OR:
1121 case '!':
1122 e->left.expr = trans_bool_expr(e->left.expr);
1123 e->right.expr = trans_bool_expr(e->right.expr);
1124 break;
1125 case T_UNEQUAL:
1126 // FOO!=n -> FOO
1127 if (e->left.sym->type == SYMBOL_TRISTATE) {
1128 if (e->right.sym == &symbol_no) {
1129 e->token = T_WORD;
1130 e->right.sym = NULL;
1131 }
1132 }
1133 break;
1134 }
1135 return e;
1136}
1137
1138struct expr *fixup_expr(struct expr *e)
1139{
1140 struct expr *tmp;
1141
1142 if (!e)
1143 return NULL;
1144
1145 switch (e->token) {
1146 case T_IF:
1147 // if expr if expr ... -> expr && expr ...
1148 print_expr(DEBUG_OPT1, e, 0);
1149 printd(DEBUG_OPT1, " -> ");
1150 tmp = e->left.expr;
1151 if (!e->right.expr) {
1152 free(e);
1153 e = fixup_expr(tmp);
1154 print_expr(DEBUG_OPT1, e, 0);
1155 printd(DEBUG_OPT1, "\n");
1156 return e;
1157 }
1158 e->left.expr = e->right.expr;
1159 e->right.expr = tmp;
1160 e->token = T_AND;
1161 print_expr(DEBUG_OPT1, e, 0);
1162 printd(DEBUG_OPT1, "\n");
1163 break;
1164 case T_ELSE:
1165 // if expr else expr ... -> expr && !expr ...
1166 print_expr(DEBUG_OPT1, e, 0);
1167 printd(DEBUG_OPT1, " -> ");
1168 e->token = '!';
1169 if (!e->right.expr) {
1170 print_expr(DEBUG_OPT1, e, 0);
1171 printd(DEBUG_OPT1, "\n");
1172 break;
1173 }
1174 tmp = e;
1175 e = expr_alloc_two(T_AND, e->right.expr, e);
1176 tmp->right.expr = NULL;
1177 print_expr(DEBUG_OPT1, e, 0);
1178 printd(DEBUG_OPT1, "\n");
1179 break;
1180 case '&':
1181 // expr & expr -> expr && expr
1182 print_expr(DEBUG_OPT1, e, 0);
1183 printd(DEBUG_OPT1, " -> ");
1184 e->token = T_AND;
1185 print_expr(DEBUG_OPT1, e, 0);
1186 printd(DEBUG_OPT1, "\n");
1187 break;
1188 case '=':
1189 case T_UNEQUAL:
1190 if (!(e->left.sym->flags & SYMBOL_CONST))
1191 return e;
1192 if (e->right.sym->flags & SYMBOL_CONST) {
1193 if (e->left.sym == e->right.sym) {
1194 e->left.sym = e->token == '=' ? &symbol_yes : &symbol_no;
1195 } else {
1196 e->left.sym = e->token != '=' ? &symbol_yes : &symbol_no;
1197 }
1198 e->token = T_WORD;
1199 e->right.sym = NULL;
1200 } else {
1201 // y/n/m = sym -> sym = y/n/m
1202 struct symbol *sym;
1203 print_expr(DEBUG_OPT1, e, 0);
1204 printd(DEBUG_OPT1, " -> ");
1205 sym = e->left.sym;
1206 e->left.sym = e->right.sym;
1207 e->right.sym = sym;
1208 print_expr(DEBUG_OPT1, e, 0);
1209 printd(DEBUG_OPT1, "\n");
1210 }
1211 return e;
1212 case T_WORD:
1213 case '^':
1214 return e;
1215 }
1216 e->left.expr = fixup_expr(e->left.expr);
1217 e->right.expr = fixup_expr(e->right.expr);
1218 return e;
1219}
1220
1221struct expr *join_or(struct expr *e1, struct expr *e2)
1222{
1223 struct expr *tmp;
1224 struct symbol *sym1, *sym2;
1225
1226 if (expr_eq(e1, e2))
1227 return expr_copy(e1);
1228 if (e1->token != '=' && e1->token != T_UNEQUAL && e1->token != T_WORD && e1->token != '!')
1229 return NULL;
1230 if (e2->token != '=' && e2->token != T_UNEQUAL && e2->token != T_WORD && e2->token != '!')
1231 return NULL;
1232 if (e1->token == '!') {
1233 tmp = e1->left.expr;
1234 if (tmp->token != '=' && tmp->token != T_UNEQUAL && tmp->token != T_WORD)
1235 return NULL;
1236 sym1 = tmp->left.sym;
1237 } else
1238 sym1 = e1->left.sym;
1239 if (e2->token == '!') {
1240 if (e2->left.expr->token != T_WORD)
1241 return NULL;
1242 sym2 = e2->left.expr->left.sym;
1243 } else
1244 sym2 = e2->left.sym;
1245 if (sym1 != sym2)
1246 return NULL;
1247 if (sym1->type != SYMBOL_BOOLEAN && sym1->type != SYMBOL_TRISTATE)
1248 return NULL;
1249 if (sym1->type == SYMBOL_TRISTATE) {
1250 if (e1->token == '=' && e2->token == '=' &&
1251 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) ||
1252 (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) {
1253 // (a='y') || (a='m') -> (a!='n')
1254 return expr_alloc_comp(T_UNEQUAL, sym1, &symbol_no);
1255 }
1256 if (e1->token == '=' && e2->token == '=' &&
1257 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) ||
1258 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) {
1259 // (a='y') || (a='n') -> (a!='m')
1260 return expr_alloc_comp(T_UNEQUAL, sym1, &symbol_mod);
1261 }
1262 if (e1->token == '=' && e2->token == '=' &&
1263 ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) ||
1264 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) {
1265 // (a='m') || (a='n') -> (a!='y')
1266 return expr_alloc_comp(T_UNEQUAL, sym1, &symbol_yes);
1267 }
1268 }
1269 if (sym1->type == SYMBOL_BOOLEAN && sym1 == sym2) {
1270 if ((e1->token == '!' && e1->left.expr->token == T_WORD && e2->token == T_WORD) ||
1271 (e2->token == '!' && e2->left.expr->token == T_WORD && e1->token == T_WORD))
1272 return expr_alloc_symbol(&symbol_yes);
1273 }
1274
1275 printf("optimize ");
1276 print_expr(PRINTD, e1, 0);
1277 printf(" || ");
1278 print_expr(PRINTD, e2, 0);
1279 printf(" ?\n");
1280 return NULL;
1281}
1282
1283struct expr *join_and(struct expr *e1, struct expr *e2)
1284{
1285 struct expr *tmp;
1286 struct symbol *sym1, *sym2;
1287
1288 if (expr_eq(e1, e2))
1289 return expr_copy(e1);
1290 if (e1->token != '=' && e1->token != T_UNEQUAL && e1->token != T_WORD && e1->token != '!')
1291 return NULL;
1292 if (e2->token != '=' && e2->token != T_UNEQUAL && e2->token != T_WORD && e2->token != '!')
1293 return NULL;
1294 if (e1->token == '!') {
1295 tmp = e1->left.expr;
1296 if (tmp->token != '=' && tmp->token != T_UNEQUAL && tmp->token != T_WORD)
1297 return NULL;
1298 sym1 = tmp->left.sym;
1299 } else
1300 sym1 = e1->left.sym;
1301 if (e2->token == '!') {
1302 if (e2->left.expr->token != T_WORD)
1303 return NULL;
1304 sym2 = e2->left.expr->left.sym;
1305 } else
1306 sym2 = e2->left.sym;
1307 if (sym1 != sym2)
1308 return NULL;
1309 if (sym1->type != SYMBOL_BOOLEAN && sym1->type != SYMBOL_TRISTATE)
1310 return NULL;
1311
1312 if ((e1->token == T_WORD && e2->token == '=' && e2->right.sym == &symbol_yes) ||
1313 (e2->token == T_WORD && e1->token == '=' && e1->right.sym == &symbol_yes))
1314 // (a) && (a='y') -> (a='y')
1315 return expr_alloc_comp('=', sym1, &symbol_yes);
1316
1317 if ((e1->token == T_WORD && e2->token == T_UNEQUAL && e2->right.sym == &symbol_no) ||
1318 (e2->token == T_WORD && e1->token == T_UNEQUAL && e1->right.sym == &symbol_no))
1319 // (a) && (a!='n') -> (a)
1320 return expr_alloc_symbol(sym1);
1321
1322 if (sym1->type == SYMBOL_TRISTATE) {
1323 if (e1->token == '=' && e2->token == T_UNEQUAL) {
1324 // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
1325 sym2 = e1->right.sym;
1326 if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST))
1327 return sym2 != e2->right.sym ? expr_alloc_comp('=', sym1, sym2)
1328 : expr_alloc_symbol(&symbol_no);
1329 }
1330 if (e1->token == T_UNEQUAL && e2->token == '=') {
1331 // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
1332 sym2 = e2->right.sym;
1333 if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST))
1334 return sym2 != e1->right.sym ? expr_alloc_comp('=', sym1, sym2)
1335 : expr_alloc_symbol(&symbol_no);
1336 }
1337 if (e1->token == T_UNEQUAL && e2->token == T_UNEQUAL &&
1338 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) ||
1339 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes)))
1340 // (a!='y') && (a!='n') -> (a='m')
1341 return expr_alloc_comp('=', sym1, &symbol_mod);
1342
1343 if (e1->token == T_UNEQUAL && e2->token == T_UNEQUAL &&
1344 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) ||
1345 (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes)))
1346 // (a!='y') && (a!='m') -> (a='n')
1347 return expr_alloc_comp('=', sym1, &symbol_no);
1348
1349 if (e1->token == T_UNEQUAL && e2->token == T_UNEQUAL &&
1350 ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) ||
1351 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod)))
1352 // (a!='m') && (a!='n') -> (a='m')
1353 return expr_alloc_comp('=', sym1, &symbol_yes);
1354
1355 if ((e1->token == T_WORD && e2->token == '=' && e2->right.sym == &symbol_mod) ||
1356 (e2->token == T_WORD && e1->token == '=' && e1->right.sym == &symbol_mod) ||
1357 (e1->token == T_WORD && e2->token == T_UNEQUAL && e2->right.sym == &symbol_yes) ||
1358 (e2->token == T_WORD && e1->token == T_UNEQUAL && e1->right.sym == &symbol_yes))
1359 return NULL;
1360 }
1361 printf("optimize ");
1362 print_expr(PRINTD, e1, 0);
1363 printf(" && ");
1364 print_expr(PRINTD, e2, 0);
1365 printf(" ?\n");
1366 return NULL;
1367}
1368
1369void eliminate_dups1(int token, struct expr **ep1, struct expr **ep2)
1370{
1371#define e1 (*ep1)
1372#define e2 (*ep2)
1373 struct expr *tmp;
1374
1375 if (e1->token == token) {
1376 eliminate_dups1(token, &e1->left.expr, &e2);
1377 eliminate_dups1(token, &e1->right.expr, &e2);
1378 return;
1379 }
1380 if (e2->token == token) {
1381 eliminate_dups1(token, &e1, &e2->left.expr);
1382 eliminate_dups1(token, &e1, &e2->right.expr);
1383 return;
1384 }
1385 if (e1 == e2)
1386 return;
1387
1388 switch (e1->token) {
1389 case T_OR: case T_AND:
1390 eliminate_dups1(e1->token, &e1, &e1);
1391 }
1392
1393 switch (token) {
1394 case T_OR:
1395 tmp = join_or(e1, e2);
1396 if (tmp) {
1397 expr_free(e1); expr_free(e2);
1398 e1 = expr_alloc_symbol(&symbol_no);
1399 e2 = tmp;
1400 trans_count++;
1401 }
1402 break;
1403 case T_AND:
1404 tmp = join_and(e1, e2);
1405 if (tmp) {
1406 expr_free(e1); expr_free(e2);
1407 e1 = expr_alloc_symbol(&symbol_yes);
1408 e2 = tmp;
1409 trans_count++;
1410 }
1411 break;
1412 }
1413#undef e1
1414#undef e2
1415}
1416
1417void eliminate_dups2(int token, struct expr **ep1, struct expr **ep2)
1418{
1419#define e1 (*ep1)
1420#define e2 (*ep2)
1421 struct expr *tmp, *tmp1, *tmp2;
1422
1423 if (e1->token == token) {
1424 eliminate_dups2(token, &e1->left.expr, &e2);
1425 eliminate_dups2(token, &e1->right.expr, &e2);
1426 return;
1427 }
1428 if (e2->token == token) {
1429 eliminate_dups2(token, &e1, &e2->left.expr);
1430 eliminate_dups2(token, &e1, &e2->right.expr);
1431 }
1432 if (e1 == e2)
1433 return;
1434
1435 switch (e1->token) {
1436 case T_OR:
1437 eliminate_dups2(e1->token, &e1, &e1);
1438 // (FOO || BAR) && (!FOO && !BAR) -> n
1439 tmp1 = trans_expr(expr_alloc_one('!', expr_copy(e1)));
1440 tmp2 = expr_copy(e2);
1441 tmp = extract_eq_and(&tmp1, &tmp2);
1442 if (expr_is_yes(tmp1)) {
1443 expr_free(e1);
1444 e1 = expr_alloc_symbol(&symbol_no);
1445 trans_count++;
1446 }
1447 expr_free(tmp2);
1448 expr_free(tmp1);
1449 expr_free(tmp);
1450 break;
1451 case T_AND:
1452 eliminate_dups2(e1->token, &e1, &e1);
1453 // (FOO && BAR) || (!FOO || !BAR) -> y
1454 tmp1 = trans_expr(expr_alloc_one('!', expr_copy(e1)));
1455 tmp2 = expr_copy(e2);
1456 tmp = extract_eq_or(&tmp1, &tmp2);
1457 if (expr_is_no(tmp1)) {
1458 expr_free(e1);
1459 e1 = expr_alloc_symbol(&symbol_yes);
1460 trans_count++;
1461 }
1462 expr_free(tmp2);
1463 expr_free(tmp1);
1464 expr_free(tmp);
1465 break;
1466 }
1467#undef e1
1468#undef e2
1469}
1470
1471struct expr *eliminate_dups(struct expr *e)
1472{
1473 int oldcount;
1474 if (!e)
1475 return e;
1476
1477 oldcount = trans_count;
1478 while (1) {
1479 trans_count = 0;
1480 switch (e->token) {
1481 case T_OR: case T_AND:
1482 eliminate_dups1(e->token, &e, &e);
1483 eliminate_dups2(e->token, &e, &e);
1484 }
1485 if (!trans_count)
1486 break;
1487 e = eliminate_yn(e);
1488 }
1489 trans_count = oldcount;
1490 return e;
1491}
1492
1493struct expr *eliminate_yn(struct expr *e)
1494{
1495 struct expr *tmp;
1496
1497 if (e) switch (e->token) {
1498 case T_AND:
1499 e->left.expr = eliminate_yn(e->left.expr);
1500 e->right.expr = eliminate_yn(e->right.expr);
1501 if (e->left.expr->token == T_WORD) {
1502 if (e->left.expr->left.sym == &symbol_no) {
1503 expr_free(e->left.expr);
1504 expr_free(e->right.expr);
1505 e->token = T_WORD;
1506 e->left.sym = &symbol_no;
1507 e->right.expr = NULL;
1508 return e;
1509 } else if (e->left.expr->left.sym == &symbol_yes) {
1510 free(e->left.expr);
1511 tmp = e->right.expr;
1512 *e = *(e->right.expr);
1513 free(tmp);
1514 return e;
1515 }
1516 }
1517 if (e->right.expr->token == T_WORD) {
1518 if (e->right.expr->left.sym == &symbol_no) {
1519 expr_free(e->left.expr);
1520 expr_free(e->right.expr);
1521 e->token = T_WORD;
1522 e->left.sym = &symbol_no;
1523 e->right.expr = NULL;
1524 return e;
1525 } else if (e->right.expr->left.sym == &symbol_yes) {
1526 free(e->right.expr);
1527 tmp = e->left.expr;
1528 *e = *(e->left.expr);
1529 free(tmp);
1530 return e;
1531 }
1532 }
1533 break;
1534 case T_OR:
1535 e->left.expr = eliminate_yn(e->left.expr);
1536 e->right.expr = eliminate_yn(e->right.expr);
1537 if (e->left.expr->token == T_WORD) {
1538 if (e->left.expr->left.sym == &symbol_no) {
1539 free(e->left.expr);
1540 tmp = e->right.expr;
1541 *e = *(e->right.expr);
1542 free(tmp);
1543 return e;
1544 } else if (e->left.expr->left.sym == &symbol_yes) {
1545 expr_free(e->left.expr);
1546 expr_free(e->right.expr);
1547 e->token = T_WORD;
1548 e->left.sym = &symbol_yes;
1549 e->right.expr = NULL;
1550 return e;
1551 }
1552 }
1553 if (e->right.expr->token == T_WORD) {
1554 if (e->right.expr->left.sym == &symbol_no) {
1555 free(e->right.expr);
1556 tmp = e->left.expr;
1557 *e = *(e->left.expr);
1558 free(tmp);
1559 return e;
1560 } else if (e->right.expr->left.sym == &symbol_yes) {
1561 expr_free(e->left.expr);
1562 expr_free(e->right.expr);
1563 e->token = T_WORD;
1564 e->left.sym = &symbol_yes;
1565 e->right.expr = NULL;
1566 return e;
1567 }
1568 }
1569 break;
1570 }
1571 return e;
1572}
1573
1574struct expr *trans_expr(struct expr *e)
1575{
1576 struct expr *tmp;
1577
1578 if (!e)
1579 return NULL;
1580 switch (e->token) {
1581 case '=':
1582 case T_UNEQUAL:
1583 case T_WORD:
1584 case '^':
1585 break;
1586 default:
1587 e->left.expr = trans_expr(e->left.expr);
1588 e->right.expr = trans_expr(e->right.expr);
1589 }
1590
1591 switch (e->token) {
1592 case '=':
1593 if (e->left.sym->type != SYMBOL_BOOLEAN)
1594 break;
1595 if (e->right.sym == &symbol_no) {
1596 print_expr(DEBUG_OPT2, e, 0);
1597 printd(DEBUG_OPT2, " -> ");
1598 e->token = '!';
1599 e->left.expr = expr_alloc_symbol(e->left.sym);
1600 e->right.sym = NULL;
1601 print_expr(DEBUG_OPT2, e, 0);
1602 printd(DEBUG_OPT2, "\n");
1603 break;
1604 }
1605 if (e->right.sym == &symbol_mod) {
1606 printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name);
1607 e->token = T_WORD;
1608 e->left.sym = &symbol_no;
1609 e->right.sym = NULL;
1610 break;
1611 }
1612 if (e->right.sym == &symbol_yes) {
1613 print_expr(DEBUG_OPT2, e, 0);
1614 printd(DEBUG_OPT2, " -> ");
1615 e->token = T_WORD;
1616 e->right.sym = NULL;
1617 print_expr(DEBUG_OPT2, e, 0);
1618 printd(DEBUG_OPT2, "\n");
1619 break;
1620 }
1621 break;
1622 case T_UNEQUAL:
1623 if (e->left.sym->type != SYMBOL_BOOLEAN)
1624 break;
1625 if (e->right.sym == &symbol_no) {
1626 print_expr(DEBUG_OPT2, e, 0);
1627 printd(DEBUG_OPT2, " -> ");
1628 e->token = T_WORD;
1629 e->right.sym = NULL;
1630 print_expr(DEBUG_OPT2, e, 0);
1631 printd(DEBUG_OPT2, "\n");
1632 break;
1633 }
1634 if (e->right.sym == &symbol_mod) {
1635 printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name);
1636 e->token = T_WORD;
1637 e->left.sym = &symbol_yes;
1638 e->right.sym = NULL;
1639 break;
1640 }
1641 if (e->right.sym == &symbol_yes) {
1642 print_expr(DEBUG_OPT2, e, 0);
1643 printd(DEBUG_OPT2, " -> ");
1644 e->token = '!';
1645 e->left.expr = expr_alloc_symbol(e->left.sym);
1646 e->right.sym = NULL;
1647 print_expr(DEBUG_OPT2, e, 0);
1648 printd(DEBUG_OPT2, "\n");
1649 break;
1650 }
1651 break;
1652 case '!':
1653 switch (e->left.expr->token) {
1654 case '!':
1655 // !!a -> a
1656 print_expr(DEBUG_OPT2, e, 0);
1657 printd(DEBUG_OPT2, " -> ");
1658 tmp = e->left.expr->left.expr;
1659 free(e->left.expr);
1660 free(e);
1661 e = tmp;
1662 print_expr(DEBUG_OPT2, e, 0);
1663 printd(DEBUG_OPT2, "\n");
1664 e = trans_expr(e);
1665 break;
1666 case '=':
1667 case T_UNEQUAL:
1668 // !a='x' -> a!='x'
1669 print_expr(DEBUG_OPT2, e, 0);
1670 printd(DEBUG_OPT2, " -> ");
1671 tmp = e->left.expr;
1672 free(e);
1673 e = tmp;
1674 if (e->token == '=')
1675 e->token = T_UNEQUAL;
1676 else
1677 e->token = '=';
1678 print_expr(DEBUG_OPT2, e, 0);
1679 printd(DEBUG_OPT2, "\n");
1680 break;
1681 case T_OR:
1682 // !(a || b) -> !a && !b
1683 print_expr(DEBUG_OPT2, e, 0);
1684 printd(DEBUG_OPT2, " -> ");
1685 tmp = e->left.expr;
1686 e->token = T_AND;
1687 e->right.expr = expr_alloc_one('!', tmp->right.expr);
1688 tmp->token = '!';
1689 tmp->right.expr = NULL;
1690 print_expr(DEBUG_OPT2, e, 0);
1691 printd(DEBUG_OPT2, "\n");
1692 e = trans_expr(e);
1693 break;
1694 case T_AND:
1695 // !(a && b) -> !a || !b
1696 print_expr(DEBUG_OPT2, e, 0);
1697 printd(DEBUG_OPT2, " -> ");
1698 tmp = e->left.expr;
1699 e->token = T_OR;
1700 e->right.expr = expr_alloc_one('!', tmp->right.expr);
1701 tmp->token = '!';
1702 tmp->right.expr = NULL;
1703 print_expr(DEBUG_OPT2, e, 0);
1704 printd(DEBUG_OPT2, "\n");
1705 e = trans_expr(e);
1706 break;
1707 case T_WORD:
1708 if (e->left.expr->left.sym == &symbol_yes) {
1709 // !'y' -> 'n'
1710 print_expr(DEBUG_OPT2, e, 0);
1711 printd(DEBUG_OPT2, " -> ");
1712 tmp = e->left.expr;
1713 free(e);
1714 e = tmp;
1715 e->token = T_WORD;
1716 e->left.sym = &symbol_no;
1717 print_expr(DEBUG_OPT2, e, 0);
1718 printd(DEBUG_OPT2, "\n");
1719 break;
1720 }
1721 if (e->left.expr->left.sym == &symbol_no) {
1722 // !'n' -> 'y'
1723 print_expr(DEBUG_OPT2, e, 0);
1724 printd(DEBUG_OPT2, " -> ");
1725 tmp = e->left.expr;
1726 free(e);
1727 e = tmp;
1728 e->token = T_WORD;
1729 e->left.sym = &symbol_yes;
1730 print_expr(DEBUG_OPT2, e, 0);
1731 printd(DEBUG_OPT2, "\n");
1732 break;
1733 }
1734 break;
1735 }
1736 break;
1737 }
1738 return e;
1739}
1740
1741struct expr *extract_eq_and(struct expr **ep1, struct expr **ep2)
1742{
1743 struct expr *tmp = NULL;
1744 extract_eq(T_AND, &tmp, ep1, ep2);
1745 if (tmp) {
1746 *ep1 = eliminate_yn(*ep1);
1747 *ep2 = eliminate_yn(*ep2);
1748 }
1749 return tmp;
1750}
1751
1752struct expr *extract_eq_or(struct expr **ep1, struct expr **ep2)
1753{
1754 struct expr *tmp = NULL;
1755 extract_eq(T_OR, &tmp, ep1, ep2);
1756 if (tmp) {
1757 *ep1 = eliminate_yn(*ep1);
1758 *ep2 = eliminate_yn(*ep2);
1759 }
1760 return tmp;
1761}
1762
1763void extract_eq(int token, struct expr **ep, struct expr **ep1, struct expr **ep2)
1764{
1765#define e1 (*ep1)
1766#define e2 (*ep2)
1767 if (e1->token == token) {
1768 extract_eq(token, ep, &e1->left.expr, &e2);
1769 extract_eq(token, ep, &e1->right.expr, &e2);
1770 return;
1771 }
1772 if (e2->token == token) {
1773 extract_eq(token, ep, ep1, &e2->left.expr);
1774 extract_eq(token, ep, ep1, &e2->right.expr);
1775 return;
1776 }
1777 if (expr_eq(e1, e2)) {
1778 *ep = *ep ? expr_alloc_two(token, *ep, e1) : e1;
1779 expr_free(e2);
1780 if (token == T_AND) {
1781 e1 = expr_alloc_symbol(&symbol_yes);
1782 e2 = expr_alloc_symbol(&symbol_yes);
1783 } else if (token == T_OR) {
1784 e1 = expr_alloc_symbol(&symbol_no);
1785 e2 = expr_alloc_symbol(&symbol_no);
1786 }
1787 }
1788#undef e1
1789#undef e2
1790}
1791
1792struct expr *optimize_expr_or(struct expr *e)
1793{
1794 struct expr *tmp;
1795
1796 if (!e || e->token != T_OR)
1797 return e;
1798
1799 e->left.expr = optimize_expr_or(e->left.expr);
1800 e->right.expr = optimize_expr_or(e->right.expr);
1801
1802 tmp = extract_eq_and(&e->left.expr, &e->right.expr);
1803 if (!tmp)
1804 return e;
1805 return expr_alloc_two(T_AND, tmp, e);
1806}
1807
1808int contains_expr(struct expr *dep, struct expr *e)
1809{
1810 if (!dep)
1811 return 0;
1812 if (dep->token == T_AND)
1813 return contains_expr(dep->left.expr, e) || contains_expr(dep->right.expr, e);
1814 return expr_eq(dep, e);
1815}
1816
1817struct expr *trans_comp_expr(struct expr *e, int token, struct symbol *sym)
1818{
1819 struct expr *e1, *e2;
1820
1821 switch (e->token) {
1822 case T_AND:
1823 e1 = trans_comp_expr(e->left.expr, '=', sym);
1824 e2 = trans_comp_expr(e->right.expr, '=', sym);
1825 if (sym == &symbol_yes)
1826 e = expr_alloc_two(T_AND, e1, e2);
1827 if (sym == &symbol_no)
1828 e = expr_alloc_two(T_OR, e1, e2);
1829 if (token == T_UNEQUAL)
1830 e = expr_alloc_one('!', e);
1831 return e;
1832 case T_OR:
1833 e1 = trans_comp_expr(e->left.expr, '=', sym);
1834 e2 = trans_comp_expr(e->right.expr, '=', sym);
1835 if (sym == &symbol_yes)
1836 e = expr_alloc_two(T_OR, e1, e2);
1837 if (sym == &symbol_no)
1838 e = expr_alloc_two(T_AND, e1, e2);
1839 if (token == T_UNEQUAL)
1840 e = expr_alloc_one('!', e);
1841 return e;
1842 case '!':
1843 switch (token) {
1844 case '=':
1845 return trans_comp_expr(e->left.expr, T_UNEQUAL, sym);
1846 case T_UNEQUAL:
1847 return trans_comp_expr(e->left.expr, '=', sym);
1848 }
1849 break;
1850 case T_UNEQUAL:
1851 case '=':
1852 if (token == '=') {
1853 if (sym == &symbol_yes)
1854 return expr_copy(e);
1855 if (sym == &symbol_mod)
1856 return expr_alloc_symbol(&symbol_no);
1857 if (sym == &symbol_no)
1858 return expr_alloc_one('!', expr_copy(e));
1859 } else {
1860 if (sym == &symbol_yes)
1861 return expr_alloc_one('!', expr_copy(e));
1862 if (sym == &symbol_mod)
1863 return expr_alloc_symbol(&symbol_yes);
1864 if (sym == &symbol_no)
1865 return expr_copy(e);
1866 }
1867 break;
1868 case T_WORD:
1869 return expr_alloc_comp(token, e->left.sym, sym);
1870 }
1871 return NULL;
1872}
1873
1874void eliminate_dep(struct symbol *sym, struct expr *dep)
1875{
1876 struct symbol *sym2;
1877 struct expr *dep2;
1878
1879 if (dep->token == T_AND) {
1880 eliminate_dep(sym, dep->left.expr);
1881 eliminate_dep(sym, dep->right.expr);
1882 }
1883#if 0
1884 if (dep->token == T_WORD ||
1885 (sym->type == SYMBOL_BOOLEAN &&
1886 ((dep->token == T_UNEQUAL && dep->right.sym == &symbol_no) ||
1887 (dep->token == '=' && dep->right.sym == &symbol_yes)))) {
1888 sym2 = dep->left.sym;
1889 if (sym2->dep) {
1890 if (!sym2->dep2)
1891 eliminate_dep(sym2, sym2->dep);
1892 sym->dep2 = !sym->dep2 ? expr_copy(sym2->dep2)
1893 : expr_alloc_two(T_AND, expr_copy(sym2->dep2), sym->dep2);
1894 }
1895 }
1896#else
1897 switch (dep->token) {
1898 case T_WORD:
1899 case T_UNEQUAL:
1900 case '=':
1901 sym2 = dep->left.sym;
1902 if (sym2->type != SYMBOL_BOOLEAN && sym2->type != SYMBOL_TRISTATE)
1903 break;
1904 if (!sym2->dep)
1905 break;
1906 if (!sym2->dep2)
1907 eliminate_dep(sym2, sym2->dep);
1908 if (dep->token == T_WORD) {
1909 if (sym2->type == SYMBOL_BOOLEAN)
1910 dep2 = trans_comp_expr(sym2->dep2, T_UNEQUAL, &symbol_no);
1911 else
1912 dep2 = expr_copy(sym2->dep2);
1913 } else {
1914 //if ((dep->token == T_UNEQUAL && dep->right.sym == &symbol_no) ||
1915 // (sym2->type == SYMBOL_BOOLEAN &&
1916 // dep->token == '=' && dep->right.sym == &symbol_yes))
1917 if ((dep->token == '=' && dep->right.sym == &symbol_yes) ||
1918 (sym2->type == SYMBOL_BOOLEAN &&
1919 dep->token == T_UNEQUAL && dep->right.sym == &symbol_no))
1920 dep2 = trans_comp_expr(sym2->dep2, dep->token, dep->right.sym);
1921 else
1922 break;
1923 }
1924 dep2 = eliminate_yn(trans_expr(fixup_expr(dep2)));
1925 sym->dep2 = !sym->dep2 ? dep2 : expr_alloc_two(T_AND, dep2, sym->dep2);
1926 }
1927#endif
1928 if (sym->dep == dep) {
1929 printd(DEBUG_DEP, "el: %s (", sym->name);
1930 print_expr(DEBUG_DEP, sym->dep, 0);
1931 printd(DEBUG_DEP, ")\n");
1932 if (sym->dep2) {
1933 print_expr(DEBUG_DEP, sym->dep2, 0); printd(DEBUG_DEP, "\n");
1934 sym->dep2 = eliminate_yn(eliminate_dups(sym->dep2));
1935 switch (sym->type) {
1936 case SYMBOL_BOOLEAN: case SYMBOL_INT: case SYMBOL_HEX: case SYMBOL_STRING:
1937 sym->dep2 = trans_bool_expr(sym->dep2);
1938 break;
1939 }
1940 print_expr(DEBUG_DEP, sym->dep2, 0); printd(DEBUG_DEP, "\n");
1941 sym->dep = expr_alloc_two(T_AND, expr_copy(sym->dep2), sym->dep);
1942 sym->dep = eliminate_dups(sym->dep);
1943 print_expr(DEBUG_DEP, sym->dep, 0); printd(DEBUG_DEP, "\n");
1944 dep = expr_copy(sym->dep2);
1945 eliminate_eq(T_AND, &dep, &sym->dep);
1946 sym->dep = eliminate_yn(sym->dep);
1947 sym->dep2 = expr_alloc_two(T_AND, sym->dep2, expr_copy(sym->dep));
1948 } else
1949 sym->dep2 = expr_copy(sym->dep);
1950 printd(DEBUG_DEP, " -> ");
1951 print_expr(DEBUG_DEP, sym->dep2, 0);
1952 printd(DEBUG_DEP, " -> ");
1953 print_expr(DEBUG_DEP, sym->dep, 0);
1954 printd(DEBUG_DEP, "\n");
1955 }
1956}
1957
1958struct symbol * dep_check_symbol(struct symbol *sym);
1959
1960struct symbol *dep_check_expr(struct expr *e)
1961{
1962 struct symbol *sym;
1963 if (!e)
1964 return 0;
1965 switch (e->token) {
1966 case T_WORD:
1967 case T_WORD_QUOTE:
1968 case T_WORD_DQUOTE:
1969 return dep_check_symbol(e->left.sym);
1970 case '=':
1971 case T_UNEQUAL:
1972 sym = dep_check_symbol(e->left.sym);
1973 if (sym)
1974 return sym;
1975 return dep_check_symbol(e->right.sym);
1976 case T_OR:
1977 case T_AND:
1978 sym = dep_check_expr(e->left.expr);
1979 if (sym)
1980 return sym;
1981 return dep_check_expr(e->right.expr);
1982 case '!':
1983 return dep_check_expr(e->left.expr);
1984 }
1985 printf("how to check %d?\n", e->token);
1986 return NULL;
1987}
1988
1989struct symbol *dep_check_symbol(struct symbol *sym)
1990{
1991 struct statement *stmt, *stmt2;
1992 struct symbol *sym2;
1993 struct expr *e1, *e2;
1994
1995 if (sym->flags & SYMBOL_CHECK) {
1996 printf("recursive dependency: %s", sym->name);
1997 return sym;
1998 }
1999
2000 sym->flags |= SYMBOL_CHECK;
2001 sym2 = dep_check_expr(sym->dep);
2002 if (sym2) {
2003 printf(" %s", sym->name);
2004 if (sym->type != sym2->type)
2005 goto out;
2006 switch (sym->type) {
2007 case SYMBOL_TRISTATE:
2008 e1 = expr_alloc_comp(T_UNEQUAL, sym, &symbol_yes);
2009 e2 = expr_alloc_comp(T_UNEQUAL, sym2, &symbol_yes);
2010 break;
2011 case SYMBOL_BOOLEAN:
2012 e1 = expr_alloc_one('!', expr_alloc_symbol(sym));
2013 e2 = expr_alloc_one('!', expr_alloc_symbol(sym2));
2014 break;
2015 default:
2016 goto out;
2017 }
2018 if (contains_expr(sym->dep, e2) && contains_expr(sym2->dep, e1)) {
2019 printf(" (choice(%d) detected)", sym->type);
2020 sym->flags |= SYMBOL_CHOICE;
2021 eliminate_eq(T_AND, &sym->dep, &e2);
2022 sym->dep = eliminate_yn(sym->dep);
2023 sym2->flags |= SYMBOL_CHOICE;
2024 eliminate_eq(T_AND, &sym2->dep, &e1);
2025 sym2->dep = eliminate_yn(sym2->dep);
2026 stmt = malloc(sizeof(*stmt));
2027 memset(stmt, 0, sizeof(*stmt));
2028 stmt->token = '^';
2029 stmt->text = "change me!";
2030 stmt->dep = expr_alloc_one('^', NULL);
2031 stmt->dep->right.sym = sym;
2032 stmt->dep = expr_alloc_one('^', stmt->dep);
2033 stmt->dep->right.sym = sym2;
2034 stmt->dep = expr_alloc_one('^', stmt->dep);
2035 stmt->dep->right.sym = &symbol_no;
2036 for (stmt2 = sym->stmt; stmt2->next; stmt2 = stmt2->next)
2037 ;
2038 if (stmt2->token == '^')
2039 printf("warning: symbol %s has dup choice statement?\n", sym->name);
2040 else
2041 stmt2->next = stmt;
2042 for (stmt2 = sym2->stmt; stmt2->next; stmt2 = stmt2->next)
2043 ;
2044 if (stmt2->token == '^')
2045 printf("warning: symbol %s has dup choice statement?\n", sym->name);
2046 else
2047 stmt2->next = stmt;
2048 }
2049 expr_free(e1);
2050 expr_free(e2);
2051 }
2052 if (!sym2) for (stmt = sym->stmt; stmt; stmt = stmt->next) {
2053 if (!stmt->token || stmt->token == '^')
2054 continue;
2055 sym2 = dep_check_expr(stmt->dep);
2056 if (sym2) {
2057 printf(" %s", sym->name);
2058 break;
2059 }
2060 }
2061out:
2062 sym->flags &= ~SYMBOL_CHECK;
2063
2064 return sym2;
2065}
2066
2067const char *sym_typename(int type)
2068{
2069 switch (type) {
2070 case SYMBOL_UNKNOWN: return "unknown";
2071 case SYMBOL_BOOLEAN: return "bool";
2072 case SYMBOL_TRISTATE: return "tristate";
2073 case SYMBOL_INT: return "integer";
2074 case SYMBOL_HEX: return "hex";
2075 case SYMBOL_STRING: return "string";
2076 case SYMBOL_OTHER: return "other";
2077 default: return "???";
2078 }
2079}
2080
2081void optimize_config(void)
2082{
2083 struct symbol *sym;
2084 struct statement *stmt, *stmt2, **stmtp;
2085 struct expr *e;
2086 int i;
2087
2088 for_all_symbols(i, sym) {
2089 again:
2090 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
2091 switch (stmt->token) {
2092 case '^':
2093 case T_BOOL:
2094 case T_DEP_BOOL:
2095 case T_DEP_MBOOL:
2096 if (sym->type == SYMBOL_UNKNOWN)
2097 sym->type = SYMBOL_BOOLEAN;
2098 if (sym->type != SYMBOL_BOOLEAN)
2099 printf("%s:%d:warning: symbol %s has conflicting types (%s,%s)\n",
2100 stmt->file->name, stmt->lineno, sym->name,
2101 sym_typename(sym->type), sym_typename(SYMBOL_BOOLEAN));
2102 if (sym->type == SYMBOL_TRISTATE) {
2103 printf("%s:%d:Force stmt to dep_tristate\n",
2104 stmt->file->name, stmt->lineno);
2105 stmt->token = T_DEP_TRISTATE;
2106 }
2107 break;
2108 case T_DEFINE_BOOL:
2109 if (stmt->def == &symbol_mod) {
2110 printf("%s:%d:warning: symbol %s set to 'm', force stmt to define_tristate\n",
2111 stmt->file->name, stmt->lineno, sym->name);
2112 stmt->token = T_DEFINE_TRISTATE;
2113 }
2114 break;
2115 case T_HEX:
2116 if (sym->type == SYMBOL_UNKNOWN)
2117 sym->type = SYMBOL_HEX;
2118 if (sym->type != SYMBOL_HEX)
2119 printf("%s:%d:warning: symbol %s has conflicting types (%s,%s)\n",
2120 stmt->file->name, stmt->lineno, sym->name,
2121 sym_typename(sym->type), sym_typename(SYMBOL_HEX));
2122 break;
2123 case T_INT:
2124 if (sym->type == SYMBOL_UNKNOWN)
2125 sym->type = SYMBOL_INT;
2126 if (sym->type != SYMBOL_INT)
2127 printf("%s:%d:warning: symbol %s has conflicting types (%s,%s)\n",
2128 stmt->file->name, stmt->lineno, sym->name,
2129 sym_typename(sym->type), sym_typename(SYMBOL_INT));
2130 break;
2131 case T_STRING:
2132 if (sym->type == SYMBOL_UNKNOWN)
2133 sym->type = SYMBOL_STRING;
2134 if (sym->type != SYMBOL_STRING)
2135 printf("%s:%d:warning: symbol %s has conflicting types (%s,%s)\n",
2136 stmt->file->name, stmt->lineno, sym->name,
2137 sym_typename(sym->type), sym_typename(SYMBOL_STRING));
2138 break;
2139 case T_TRISTATE:
2140 case T_DEP_TRISTATE:
2141 if (sym->type == SYMBOL_UNKNOWN)
2142 sym->type = SYMBOL_TRISTATE;
2143 if (sym->type != SYMBOL_TRISTATE) {
2144 printf("%s:%d:warning: symbol %s has conflicting types (%s,%s), force symbol to tristate\n",
2145 stmt->file->name, stmt->lineno, sym->name,
2146 sym_typename(sym->type), sym_typename(SYMBOL_TRISTATE));
2147 sym->type = SYMBOL_TRISTATE;
2148 goto again;
2149 }
2150 break;
2151 }
2152 }
2153 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
2154 switch (stmt->token) {
2155 case T_DEFINE_BOOL:
2156 if (sym->type == SYMBOL_UNKNOWN)
2157 sym->type = SYMBOL_BOOLEAN;
2158 if (sym->type != SYMBOL_BOOLEAN)
2159 printf("%s:%d:warning: symbol %s has conflicting types (%s,%s)\n",
2160 stmt->file->name, stmt->lineno, sym->name,
2161 sym_typename(sym->type), sym_typename(SYMBOL_BOOLEAN));
2162 if (sym->type == SYMBOL_TRISTATE) {
2163 printf("%s:%d:Force stmt to define_tristate\n",
2164 stmt->file->name, stmt->lineno);
2165 stmt->token = T_DEFINE_TRISTATE;
2166 }
2167 break;
2168 case T_DEFINE_TRISTATE:
2169 if (sym->type == SYMBOL_UNKNOWN)
2170 sym->type = SYMBOL_TRISTATE;
2171 if (sym->type != SYMBOL_TRISTATE) {
2172 printf("%s:%d:warning: symbol %s has conflicting types (%s,%s), force symbol to tristate\n",
2173 stmt->file->name, stmt->lineno, sym->name,
2174 sym_typename(sym->type), sym_typename(SYMBOL_TRISTATE));
2175 sym->type = SYMBOL_TRISTATE;
2176 goto again;
2177 }
2178 break;
2179 case T_DEFINE_HEX:
2180 if (sym->type == SYMBOL_UNKNOWN)
2181 sym->type = SYMBOL_HEX;
2182 if (sym->type != SYMBOL_HEX)
2183 printf("%s:%d:warning: symbol %s has conflicting types (%s,%s)\n",
2184 stmt->file->name, stmt->lineno, sym->name,
2185 sym_typename(sym->type), sym_typename(SYMBOL_HEX));
2186 break;
2187 case T_DEFINE_INT:
2188 if (sym->type == SYMBOL_UNKNOWN)
2189 sym->type = SYMBOL_INT;
2190 if (sym->type != SYMBOL_INT)
2191 printf("%s:%d:warning: symbol %s has conflicting types (%s,%s)\n",
2192 stmt->file->name, stmt->lineno, sym->name,
2193 sym_typename(sym->type), sym_typename(SYMBOL_INT));
2194 break;
2195 case T_DEFINE_STRING:
2196 if (sym->type == SYMBOL_UNKNOWN)
2197 sym->type = SYMBOL_STRING;
2198 if (sym->type != SYMBOL_STRING)
2199 printf("%s:%d:warning: symbol %s has conflicting types (%s,%s)\n",
2200 stmt->file->name, stmt->lineno, sym->name,
2201 sym_typename(sym->type), sym_typename(SYMBOL_STRING));
2202 break;
2203 }
2204 }
2205 }
2206 for_all_symbols(i, sym) {
2207 printd(DEBUG_OPT1, "o1: %s\n", sym->name);
2208 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
2209 print_expr(DEBUG_OPT1, stmt->dep, 0);
2210 printd(DEBUG_OPT1, " & ");
2211 print_expr(DEBUG_OPT1, stmt->dep2, 0);
2212 printd(DEBUG_OPT1, "\n");
2213 if (stmt->dep || stmt->dep2) {
2214 struct expr *e = stmt->dep2;
2215 if (stmt->token == T_DEP_BOOL) {
2216 e = trans_dep_bool(e);
2217 stmt->token = T_DEP_MBOOL;
2218 }
2219 if (stmt->dep && e) {
2220 stmt->dep = expr_alloc_two(T_AND, stmt->dep, e);
2221 } else if (e)
2222 stmt->dep = e;
2223 stmt->dep2 = NULL;
2224 switch (stmt->token) {
2225 case T_DEP_MBOOL:stmt->token = T_BOOL; break;
2226 case T_DEP_TRISTATE:stmt->token = T_TRISTATE; break;
2227 }
2228 }
2229 stmt->dep = fixup_expr(stmt->dep);
2230 print_expr(DEBUG_OPT1, stmt->dep, 0);
2231 printd(DEBUG_OPT1, "\n");
2232 }
2233 }
2234 for_all_symbols(i, sym) {
2235 printd(DEBUG_OPT3, "o3: %s\n", sym->name);
2236 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
2237 print_expr(DEBUG_OPT3, stmt->dep, 0);
2238 printd(DEBUG_OPT3, "\n");
2239 stmt->dep = eliminate_dups(trans_expr(stmt->dep));
2240 switch (sym->type) {
2241 case SYMBOL_BOOLEAN: case SYMBOL_INT: case SYMBOL_HEX: case SYMBOL_STRING:
2242 stmt->dep = trans_bool_expr(stmt->dep);
2243 break;
2244 }
2245 print_expr(DEBUG_OPT3, stmt->dep, 0);
2246 printd(DEBUG_OPT3, "\n");
2247 }
2248 }
2249 for_all_symbols(i, sym) {
2250 sym->dep = eliminate_yn(sym->dep);
2251 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
2252 stmt->dep = eliminate_yn(stmt->dep);
2253 if (expr_is_no(stmt->dep)) {
2254 printf("%s:%d: stmt can never be reached, removed!\n", stmt->file->name, stmt->lineno);
2255 stmt->token = 0;
2256 }
2257 }
2258 }
2259 for_all_symbols(i, sym) {
2260 stmtp = &sym->stmt;
2261 stmt = *stmtp;
2262 if (!stmt) {
2263 printf("undefined symbol %s\n", sym->name);
2264 continue;
2265 }
2266 //if (sym->flags & SYMBOL_CHOICE)
2267 //continue;
2268 while (stmt) {
2269 if (!stmt->token || stmt->token == '^') {
2270 stmtp = &stmt->next;
2271 stmt = *stmtp;
2272 continue;
2273 }
2274#if 1
2275 if ((stmt->token == T_DEFINE_BOOL || stmt->token == T_DEFINE_TRISTATE) &&
2276 (stmt->def == &symbol_no || expr_is_no(stmt->dep))) {
2277 stmt->token = 0;
2278 stmt->def = NULL;
2279 expr_free(stmt->dep);
2280 stmt->dep = NULL;
2281 continue;
2282 }
2283#endif
2284 //if (stmt->text && stmt != sym->stmt) {
2285 //if (sym->stmt->text)
2286 // printf("warning: another stmt with prompt for %s????\n", sym->name);
2287 //*stmtp = stmt->next;
2288 //stmt->next = sym->stmt;
2289 //sym->stmt = stmt;
2290 //}
2291 for (stmt2 = stmt->next; stmt2; stmt2 = stmt2->next) {
2292 if (stmt->token != stmt2->token || stmt->def != stmt2->def ||
2293 stmt->menu->parent != stmt2->menu->parent)
2294 continue;
2295 if (stmt->text) {
2296 if (strcmp(skip_space(stmt->text), skip_space(stmt2->text))) {
2297 printf("warning: prompts differ for %s?\n", sym->name);
2298 continue;
2299 }
2300 }
2301 if (!stmt->dep)
2302 stmt->dep = expr_alloc_symbol(&symbol_yes);
2303 if (!stmt2->dep)
2304 stmt2->dep = expr_alloc_symbol(&symbol_yes);
2305 stmt->dep = optimize_expr_or(expr_alloc_two(T_OR, stmt->dep, stmt2->dep));
2306 stmt2->token = 0;
2307 free((void *)stmt2->text);
2308 stmt2->text = NULL;
2309 stmt2->def = NULL;
2310 stmt2->dep = NULL;
2311 }
2312 if (stmt->text && stmt != sym->stmt) {
2313 *stmtp = stmt->next;
2314 stmt->next = sym->stmt;
2315 sym->stmt = stmt;
2316 } else
2317 stmtp = &stmt->next;
2318 stmt = *stmtp;
2319 }
2320 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
2321 if (!stmt->token || stmt->token == '^')
2322 continue;
2323 if (!sym->dep) {
2324 if (!stmt->dep)
2325 break;
2326 sym->dep = stmt->dep;
2327 stmt->dep = NULL;
2328 } else {
2329 e = sym->dep;
2330 if (stmt->dep) {
2331 sym->dep = extract_eq_and(&e, &stmt->dep);
2332 if (expr_is_yes(e)) {
2333 expr_free(e);
2334 continue;
2335 }
2336 } else
2337 sym->dep = NULL;
2338 for (stmt2 = sym->stmt; stmt != stmt2; stmt2 = stmt2->next) {
2339 if (!stmt2->token || stmt2->token == '^')
2340 continue;
2341 stmt2->dep = !stmt2->dep ? expr_copy(e) :
2342 expr_alloc_two(T_AND, expr_copy(e), stmt2->dep);
2343 }
2344 expr_free(e);
2345 if (!sym->dep)
2346 break;
2347 }
2348 }
2349#if 0
2350 for (stmt1 = sym->stmt; stmt1; stmt1 = stmt1->next)
2351 if (stmt1->token && stmt1->token != '^')
2352 break;
2353 if (stmt1 && !expr_is_yes(stmt1->dep)) {
2354 e = trans_expr(expr_alloc_one('!', stmt1->dep));
2355 stmt1->dep = NULL;
2356 for (stmt = stmt1->next; stmt; stmt = stmt->next) {
2357 if (!stmt->token || stmt->token == '^')
2358 continue;
2359 if (stmt->dep) {
2360 tmp = extract_eq_and(&e, &stmt->dep);
2361 if (expr_is_yes(e)) {
2362 expr_free(e);
2363 e = tmp;
2364 continue;
2365 }
2366 if (tmp) {
2367 e = expr_alloc_two(T_AND, expr_copy(tmp), e);
2368 stmt->dep = expr_alloc_two(T_AND, tmp, stmt->dep);
2369 }
2370 }
2371 for (stmt2 = stmt1->next; stmt != stmt2; stmt2 = stmt2->next) {
2372 if (!stmt2->token || stmt2->token == '^')
2373 continue;
2374 stmt2->dep = !stmt2->dep ? expr_copy(e) :
2375 expr_alloc_two(T_AND, expr_copy(e), stmt2->dep);
2376 }
2377 stmt1->dep = trans_expr(expr_alloc_one('!', e));
2378 break;
2379 }
2380 if (!stmt1->dep) {
2381 e = trans_expr(expr_alloc_one('!', e));
2382 //sym->dep = sym->dep ? expr_alloc_two(T_AND, sym->dep, e) : e;
2383 stmt1->dep = e;
2384 }
2385 }
2386 for (stmtp = &sym->stmt; *stmtp; stmtp = &stmt->next) {
2387 stmt = *stmtp;
2388 if (!stmt->token || stmt->token == '^')
2389 continue;
2390 if (!stmt->dep || stmt->text)
2391 continue;
2392 for (stmt2 = stmt->next; stmt2; stmt2 = stmt2->next) {
2393 trans_count = 0;
2394 if (!stmt2->dep || stmt2->text)
2395 continue;
2396 e = trans_expr(expr_alloc_one('!', expr_copy(stmt->dep)));
2397 tmp = extract_eq_and(&e, &stmt2->dep);
2398 if (expr_is_yes(e)) {
2399 expr_free(e);
2400 expr_free(tmp);
2401 continue;
2402 }
2403 if (tmp)
2404 stmt2->dep = expr_alloc_two(T_AND, tmp, stmt2->dep);
2405 e = trans_expr(expr_alloc_one('!', expr_copy(stmt2->dep)));
2406 tmp = extract_eq_and(&e, &stmt->dep);
2407 if (expr_is_yes(e)) {
2408 expr_free(e);
2409 expr_free(tmp);
2410 while (stmt->next != stmt2)
2411 stmt = stmt->next;
2412 stmt->next = *stmtp;
2413 *stmtp = stmt2;
2414 stmt = stmt->next;
2415 stmt2 = stmt->next;
2416 stmt->next = (*stmtp)->next;
2417 (*stmtp)->next = stmt2;
2418 continue;
2419 }
2420 if (tmp)
2421 stmt->dep = expr_alloc_two(T_AND, tmp, stmt->dep);
2422 }
2423 }
2424#endif
2425 }
2426 for_all_symbols(i, sym) {
2427 printd(DEBUG_OPT4, "o4: %s\n", sym->name);
2428 print_expr(DEBUG_OPT4, sym->dep, 0); printd(DEBUG_OPT4, "\n");
2429 sym->dep = eliminate_dups(sym->dep);
2430 sym->dep = eliminate_yn(sym->dep);
2431 print_expr(DEBUG_OPT4, sym->dep, 0); printd(DEBUG_OPT4, "\n");
2432 for (stmt = sym->stmt; stmt; stmt = stmt->next) {
2433 print_expr(DEBUG_OPT4, stmt->dep, 0); printd(DEBUG_OPT4, "\n");
2434 stmt->dep = eliminate_dups(stmt->dep);
2435 stmt->dep = eliminate_yn(stmt->dep);
2436 print_expr(DEBUG_OPT4, stmt->dep, 0); printd(DEBUG_OPT4, "\n");
2437 }
2438 }
2439 for_all_symbols(i, sym) {
2440 if (dep_check_symbol(sym))
2441 printf("\n");
2442 }
2443 for_all_symbols(i, sym) {
2444 if (sym->dep && !sym->dep2) {
2445 printd(DEBUG_OPT5, "o5: %s\n", sym->name);
2446 print_expr(DEBUG_OPT5, sym->dep, 0); printd(DEBUG_OPT5, "\n");
2447 eliminate_dep(sym, sym->dep);
2448 print_expr(DEBUG_OPT5, sym->dep, 0); printd(DEBUG_OPT5, "\n");
2449 }
2450 }
2451}
2452
2453int main(int ac, char **av)
2454{
2455 FILE *out = NULL;
2456 char name[128];
2457 struct symbol *sym;
2458 struct statement *stmt;
2459
2460 if (ac > 2)
2461 cml1debug = 1;
2462 helplex("Documentation/Configure.help");
2463 sprintf(name, "arch/%s/Config.help", av[1]);
2464 helplex(name);
2465 sprintf(name, "arch/%s/config.in", av[1]);
2466 scan_init(name);
2467 sym = lookup_symbol("CONFIG_ARCH", SYMBOL_STRING);
2468 stmt = add_stmt(sym, T_DEFINE_STRING, NULL, lookup_symbol(av[1], SYMBOL_OTHER));
2469 stmt->menu = NULL;
2470 cml1parse();
2471 optimize_config();
2472#if 0
2473 out = fopen("config.new", "w");
2474 if (!out) {
2475 printf("unable to open config.new!\n");
2476 exit(1);
2477 }
2478#endif
2479 print_files(out, name);
2480
2481 return 0;
2482}
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
new file mode 100644
index 0000000..74c94c2
--- a/dev/null
+++ b/scripts/kconfig/conf.c
@@ -0,0 +1,565 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <ctype.h>
7#include <stdlib.h>
8#include <string.h>
9#include <unistd.h>
10#include <time.h>
11#include <sys/stat.h>
12
13#define LKC_DIRECT_LINK
14#include "lkc.h"
15
16static void conf(struct menu *menu);
17static void check_conf(struct menu *menu);
18
19enum {
20 ask_all,
21 ask_new,
22 ask_silent,
23 set_default,
24 set_yes,
25 set_mod,
26 set_no,
27 set_random
28} input_mode = ask_all;
29
30static int indent = 1;
31static int valid_stdin = 1;
32static int conf_cnt;
33static char line[128];
34static struct menu *rootEntry;
35
36static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
37
38#if 0
39static void printc(int ch)
40{
41 static int sep = 0;
42
43 if (!sep) {
44 putchar('[');
45 sep = 1;
46 } else if (ch)
47 putchar('/');
48 if (!ch) {
49 putchar(']');
50 putchar(' ');
51 sep = 0;
52 } else
53 putchar(ch);
54}
55#endif
56
57static void printo(const char *o)
58{
59 static int sep = 0;
60
61 if (!sep) {
62 putchar('(');
63 sep = 1;
64 } else if (o) {
65 putchar(',');
66 putchar(' ');
67 }
68 if (!o) {
69 putchar(')');
70 putchar(' ');
71 sep = 0;
72 } else
73 printf("%s", o);
74}
75
76static void strip(char *str)
77{
78 char *p = str;
79 int l;
80
81 while ((isspace(*p)))
82 p++;
83 l = strlen(p);
84 if (p != str)
85 memmove(str, p, l + 1);
86 if (!l)
87 return;
88 p = str + l - 1;
89 while ((isspace(*p)))
90 *p-- = 0;
91}
92
93static void conf_askvalue(struct symbol *sym, const char *def)
94{
95 enum symbol_type type = sym_get_type(sym);
96 tristate val;
97
98 if (!sym_has_value(sym))
99 printf("(NEW) ");
100
101 line[0] = '\n';
102 line[1] = 0;
103
104 switch (input_mode) {
105 case ask_new:
106 case ask_silent:
107 if (sym_has_value(sym)) {
108 printf("%s\n", def);
109 return;
110 }
111 if (!valid_stdin && input_mode == ask_silent) {
112 printf("aborted!\n\n");
113 printf("Console input/output is redirected. ");
114 printf("Run 'make oldconfig' to update configuration.\n\n");
115 exit(1);
116 }
117 case ask_all:
118 fgets(line, 128, stdin);
119 return;
120 case set_default:
121 printf("%s\n", def);
122 return;
123 default:
124 break;
125 }
126
127 switch (type) {
128 case S_INT:
129 case S_HEX:
130 case S_STRING:
131 printf("%s\n", def);
132 return;
133 default:
134 ;
135 }
136 switch (input_mode) {
137 case set_yes:
138 if (sym_tristate_within_range(sym, yes)) {
139 line[0] = 'y';
140 line[1] = '\n';
141 line[2] = 0;
142 break;
143 }
144 case set_mod:
145 if (type == S_TRISTATE) {
146 if (sym_tristate_within_range(sym, mod)) {
147 line[0] = 'm';
148 line[1] = '\n';
149 line[2] = 0;
150 break;
151 }
152 } else {
153 if (sym_tristate_within_range(sym, yes)) {
154 line[0] = 'y';
155 line[1] = '\n';
156 line[2] = 0;
157 break;
158 }
159 }
160 case set_no:
161 if (sym_tristate_within_range(sym, no)) {
162 line[0] = 'n';
163 line[1] = '\n';
164 line[2] = 0;
165 break;
166 }
167 case set_random:
168 do {
169 val = (tristate)(random() % 3);
170 } while (!sym_tristate_within_range(sym, val));
171 switch (val) {
172 case no: line[0] = 'n'; break;
173 case mod: line[0] = 'm'; break;
174 case yes: line[0] = 'y'; break;
175 }
176 line[1] = '\n';
177 line[2] = 0;
178 break;
179 default:
180 break;
181 }
182 printf("%s", line);
183}
184
185int conf_string(struct menu *menu)
186{
187 struct symbol *sym = menu->sym;
188 const char *def, *help;
189
190 while (1) {
191 printf("%*s%s ", indent - 1, "", menu->prompt->text);
192 printf("(%s) ", sym->name);
193 def = sym_get_string_value(sym);
194 if (sym_get_string_value(sym))
195 printf("[%s] ", def);
196 conf_askvalue(sym, def);
197 switch (line[0]) {
198 case '\n':
199 break;
200 case '?':
201 /* print help */
202 if (line[1] == 0) {
203 help = nohelp_text;
204 if (menu->sym->help)
205 help = menu->sym->help;
206 printf("\n%s\n", menu->sym->help);
207 def = NULL;
208 break;
209 }
210 default:
211 line[strlen(line)-1] = 0;
212 def = line;
213 }
214 if (def && sym_set_string_value(sym, def))
215 return 0;
216 }
217}
218
219static int conf_sym(struct menu *menu)
220{
221 struct symbol *sym = menu->sym;
222 int type;
223 tristate oldval, newval;
224 const char *help;
225
226 while (1) {
227 printf("%*s%s ", indent - 1, "", menu->prompt->text);
228 if (sym->name)
229 printf("(%s) ", sym->name);
230 type = sym_get_type(sym);
231 putchar('[');
232 oldval = sym_get_tristate_value(sym);
233 switch (oldval) {
234 case no:
235 putchar('N');
236 break;
237 case mod:
238 putchar('M');
239 break;
240 case yes:
241 putchar('Y');
242 break;
243 }
244 if (oldval != no && sym_tristate_within_range(sym, no))
245 printf("/n");
246 if (oldval != mod && sym_tristate_within_range(sym, mod))
247 printf("/m");
248 if (oldval != yes && sym_tristate_within_range(sym, yes))
249 printf("/y");
250 if (sym->help)
251 printf("/?");
252 printf("] ");
253 conf_askvalue(sym, sym_get_string_value(sym));
254 strip(line);
255
256 switch (line[0]) {
257 case 'n':
258 case 'N':
259 newval = no;
260 if (!line[1] || !strcmp(&line[1], "o"))
261 break;
262 continue;
263 case 'm':
264 case 'M':
265 newval = mod;
266 if (!line[1])
267 break;
268 continue;
269 case 'y':
270 case 'Y':
271 newval = yes;
272 if (!line[1] || !strcmp(&line[1], "es"))
273 break;
274 continue;
275 case 0:
276 newval = oldval;
277 break;
278 case '?':
279 goto help;
280 default:
281 continue;
282 }
283 if (sym_set_tristate_value(sym, newval))
284 return 0;
285help:
286 help = nohelp_text;
287 if (sym->help)
288 help = sym->help;
289 printf("\n%s\n", help);
290 }
291}
292
293static int conf_choice(struct menu *menu)
294{
295 struct symbol *sym, *def_sym;
296 struct menu *cmenu, *def_menu;
297 const char *help;
298 int type, len;
299 bool is_new;
300
301 sym = menu->sym;
302 type = sym_get_type(sym);
303 is_new = !sym_has_value(sym);
304 if (sym_is_changable(sym)) {
305 conf_sym(menu);
306 sym_calc_value(sym);
307 switch (sym_get_tristate_value(sym)) {
308 case no:
309 return 1;
310 case mod:
311 return 0;
312 case yes:
313 break;
314 }
315 } else {
316 sym->def = sym->curr;
317 if (S_TRI(sym->curr) == mod) {
318 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
319 return 0;
320 }
321 }
322
323 while (1) {
324 printf("%*s%s ", indent - 1, "", menu_get_prompt(menu));
325 def_sym = sym_get_choice_value(sym);
326 def_menu = NULL;
327 for (cmenu = menu->list; cmenu; cmenu = cmenu->next) {
328 if (!menu_is_visible(cmenu))
329 continue;
330 printo(menu_get_prompt(cmenu));
331 if (cmenu->sym == def_sym)
332 def_menu = cmenu;
333 }
334 printo(NULL);
335 if (def_menu)
336 printf("[%s] ", menu_get_prompt(def_menu));
337 else {
338 printf("\n");
339 return 1;
340 }
341 switch (input_mode) {
342 case ask_new:
343 case ask_silent:
344 case ask_all:
345 conf_askvalue(sym, menu_get_prompt(def_menu));
346 strip(line);
347 break;
348 default:
349 line[0] = 0;
350 printf("\n");
351 }
352 if (line[0] == '?' && !line[1]) {
353 help = nohelp_text;
354 if (menu->sym->help)
355 help = menu->sym->help;
356 printf("\n%s\n", help);
357 continue;
358 }
359 if (line[0]) {
360 len = strlen(line) - 1;
361 line[len] = 0;
362
363 def_menu = NULL;
364 for (cmenu = menu->list; cmenu; cmenu = cmenu->next) {
365 if (!cmenu->sym || !menu_is_visible(cmenu))
366 continue;
367 if (!strncmp(line, menu_get_prompt(cmenu), len)) {
368 def_menu = cmenu;
369 break;
370 }
371 }
372 }
373 if (def_menu) {
374 sym_set_choice_value(sym, def_menu->sym);
375 if (def_menu->list) {
376 indent += 2;
377 conf(def_menu->list);
378 indent -= 2;
379 }
380 return 1;
381 }
382 }
383}
384
385static void conf(struct menu *menu)
386{
387 struct symbol *sym;
388 struct property *prop;
389 struct menu *child;
390
391 if (!menu_is_visible(menu))
392 return;
393
394 sym = menu->sym;
395 prop = menu->prompt;
396 if (prop) {
397 const char *prompt;
398
399 switch (prop->type) {
400 case P_MENU:
401 if (input_mode == ask_silent && rootEntry != menu) {
402 check_conf(menu);
403 return;
404 }
405 case P_COMMENT:
406 prompt = menu_get_prompt(menu);
407 if (prompt)
408 printf("%*c\n%*c %s\n%*c\n",
409 indent, '*',
410 indent, '*', prompt,
411 indent, '*');
412 default:
413 ;
414 }
415 }
416
417 if (!sym)
418 goto conf_childs;
419
420 if (sym_is_choice(sym)) {
421 conf_choice(menu);
422 if (S_TRI(sym->curr) != mod)
423 return;
424 goto conf_childs;
425 }
426
427 switch (sym->type) {
428 case S_INT:
429 case S_HEX:
430 case S_STRING:
431 conf_string(menu);
432 break;
433 default:
434 conf_sym(menu);
435 break;
436 }
437
438conf_childs:
439 if (sym)
440 indent += 2;
441 for (child = menu->list; child; child = child->next)
442 conf(child);
443 if (sym)
444 indent -= 2;
445}
446
447static void check_conf(struct menu *menu)
448{
449 struct symbol *sym;
450 struct menu *child;
451
452 if (!menu_is_visible(menu))
453 return;
454
455 sym = menu->sym;
456 if (!sym)
457 goto conf_childs;
458
459 if (sym_is_choice(sym)) {
460 if (!sym_has_value(sym)) {
461 if (!conf_cnt++)
462 printf("*\n* Restart config...\n*\n");
463 rootEntry = menu_get_parent_menu(menu);
464 conf(rootEntry);
465 }
466 if (sym_get_tristate_value(sym) != mod)
467 return;
468 goto conf_childs;
469 }
470
471 if (!sym_has_value(sym)) {
472 if (!conf_cnt++)
473 printf("*\n* Restart config...\n*\n");
474 rootEntry = menu_get_parent_menu(menu);
475 conf(rootEntry);
476 }
477
478conf_childs:
479 for (child = menu->list; child; child = child->next)
480 check_conf(child);
481}
482
483int main(int ac, char **av)
484{
485 const char *name;
486 struct stat tmpstat;
487
488 if (ac > 1 && av[1][0] == '-') {
489 switch (av[1][1]) {
490 case 'o':
491 input_mode = ask_new;
492 break;
493 case 's':
494 input_mode = ask_silent;
495 valid_stdin = isatty(0) && isatty(1) && isatty(2);
496 break;
497 case 'd':
498 input_mode = set_default;
499 break;
500 case 'n':
501 input_mode = set_no;
502 break;
503 case 'm':
504 input_mode = set_mod;
505 break;
506 case 'y':
507 input_mode = set_yes;
508 break;
509 case 'r':
510 input_mode = set_random;
511 srandom(time(NULL));
512 break;
513 case 'h':
514 case '?':
515 printf("%s [-o|-s] config\n", av[0]);
516 exit(0);
517 }
518 name = av[2];
519 } else
520 name = av[1];
521 conf_parse(name);
522 //zconfdump(stdout);
523 switch (input_mode) {
524 case set_default:
525 name = conf_get_default_confname();
526 if (conf_read(name)) {
527 printf("***\n"
528 "*** Can't find default configuration \"%s\"!\n"
529 "***\n", name);
530 exit(1);
531 }
532 break;
533 case ask_silent:
534 if (stat(".config", &tmpstat)) {
535 printf("***\n"
536 "*** You have not yet configured your kernel!\n"
537 "***\n"
538 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
539 "*** \"make menuconfig\" or \"make xconfig\").\n"
540 "***\n");
541 exit(1);
542 }
543 case ask_all:
544 case ask_new:
545 conf_read(NULL);
546 break;
547 default:
548 break;
549 }
550
551 if (input_mode != ask_silent) {
552 rootEntry = &rootmenu;
553 conf(&rootmenu);
554 if (input_mode == ask_all) {
555 input_mode = ask_silent;
556 valid_stdin = 1;
557 }
558 }
559 do {
560 conf_cnt = 0;
561 check_conf(&rootmenu);
562 } while (conf_cnt);
563 conf_write(NULL);
564 return 0;
565}
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
new file mode 100644
index 0000000..0f5fd97
--- a/dev/null
+++ b/scripts/kconfig/confdata.c
@@ -0,0 +1,360 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <ctype.h>
7#include <limits.h>
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include <unistd.h>
12
13#define LKC_DIRECT_LINK
14#include "lkc.h"
15
16const char conf_def_filename[] = ".config";
17char conf_filename[PATH_MAX+1];
18
19const char conf_defname[] = "arch/$ARCH/defconfig";
20
21const char *conf_confnames[] = {
22 ".config",
23 "/lib/modules/$UNAME_RELEASE/.config",
24 "/etc/kernel-config",
25 "/boot/config-$UNAME_RELEASE",
26 conf_defname,
27 NULL,
28};
29
30static char *conf_expand_value(const char *in)
31{
32 struct symbol *sym;
33 const char *src;
34 static char res_value[SYMBOL_MAXLENGTH];
35 char *dst, name[SYMBOL_MAXLENGTH];
36
37 res_value[0] = 0;
38 dst = name;
39 while ((src = strchr(in, '$'))) {
40 strncat(res_value, in, src - in);
41 src++;
42 dst = name;
43 while (isalnum(*src) || *src == '_')
44 *dst++ = *src++;
45 *dst = 0;
46 sym = sym_lookup(name, 0);
47 sym_calc_value(sym);
48 strcat(res_value, sym_get_string_value(sym));
49 in = src;
50 }
51 strcat(res_value, in);
52
53 return res_value;
54}
55
56char *conf_get_default_confname(void)
57{
58 return conf_expand_value(conf_defname);
59}
60
61int conf_read(const char *name)
62{
63 FILE *in = NULL;
64 char line[128];
65 char *p, *p2;
66 int lineno = 0;
67 struct symbol *sym;
68 struct property *prop;
69 struct expr *e;
70 int i;
71
72 if (name) {
73 in = fopen(name, "r");
74 if (in)
75 strcpy(conf_filename, name);
76 } else {
77 const char **names = conf_confnames;
78 while ((name = *names++)) {
79 name = conf_expand_value(name);
80 in = fopen(name, "r");
81 if (in) {
82 printf("#\n"
83 "# using defaults found in %s\n"
84 "#\n", name);
85 break;
86 }
87 }
88 }
89
90 if (!in)
91 return 1;
92
93 for_all_symbols(i, sym) {
94 sym->flags |= SYMBOL_NEW;
95 switch (sym->type) {
96 case S_INT:
97 case S_HEX:
98 case S_STRING:
99 if (S_VAL(sym->def)) {
100 free(S_VAL(sym->def));
101 S_VAL(sym->def) = NULL;
102 }
103 default:
104 ;
105 }
106 }
107
108 while (fgets(line, 128, in)) {
109 lineno++;
110 switch (line[0]) {
111 case '#':
112 if (memcmp(line + 2, "CONFIG_", 7))
113 continue;
114 p = strchr(line + 9, ' ');
115 if (!p)
116 continue;
117 *p++ = 0;
118 if (strncmp(p, "is not set", 10))
119 continue;
120 //printf("%s -> n\n", line + 9);
121 sym = sym_lookup(line + 9, 0);
122 switch (sym->type) {
123 case S_BOOLEAN:
124 case S_TRISTATE:
125 sym->def = symbol_no.curr;
126 sym->flags &= ~SYMBOL_NEW;
127 break;
128 default:
129 ;
130 }
131 break;
132 case 'C':
133 if (memcmp(line, "CONFIG_", 7))
134 continue;
135 p = strchr(line + 7, '=');
136 if (!p)
137 continue;
138 *p++ = 0;
139 p2 = strchr(p, '\n');
140 if (p2)
141 *p2 = 0;
142 //printf("%s -> %s\n", line + 7, p);
143 sym = sym_find(line + 7);
144 if (!sym) {
145 fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 7);
146 break;
147 }
148 switch (sym->type) {
149 case S_BOOLEAN:
150 sym->def = symbol_yes.curr;
151 sym->flags &= ~SYMBOL_NEW;
152 break;
153 case S_TRISTATE:
154 if (p[0] == 'm')
155 sym->def = symbol_mod.curr;
156 else
157 sym->def = symbol_yes.curr;
158 sym->flags &= ~SYMBOL_NEW;
159 break;
160 case S_STRING:
161 if (*p++ != '"')
162 break;
163 for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
164 if (*p2 == '"') {
165 *p2 = 0;
166 break;
167 }
168 memmove(p2, p2 + 1, strlen(p2));
169 }
170 case S_INT:
171 case S_HEX:
172 if (sym_string_valid(sym, p)) {
173 S_VAL(sym->def) = strdup(p);
174 sym->flags &= ~SYMBOL_NEW;
175 } else
176 fprintf(stderr, "%s:%d:symbol value '%s' invalid for %s\n", name, lineno, p, sym->name);
177 break;
178 default:
179 ;
180 }
181 if (sym_is_choice_value(sym)) {
182 prop = sym_get_choice_prop(sym);
183 switch (S_TRI(sym->def)) {
184 case mod:
185 if (S_TRI(prop->def->def) == yes)
186 /* warn? */;
187 break;
188 case yes:
189 if (S_TRI(prop->def->def) != no)
190 /* warn? */;
191 S_VAL(prop->def->def) = sym;
192 break;
193 case no:
194 break;
195 }
196 S_TRI(prop->def->def) = S_TRI(sym->def);
197 }
198 break;
199 case '\n':
200 break;
201 default:
202 continue;
203 }
204 }
205 fclose(in);
206
207 for_all_symbols(i, sym) {
208 if (!sym_is_choice(sym))
209 continue;
210 prop = sym_get_choice_prop(sym);
211 sym->flags &= ~SYMBOL_NEW;
212 for (e = prop->dep; e; e = e->left.expr)
213 sym->flags |= e->right.sym->flags & SYMBOL_NEW;
214 }
215
216 sym_change_count = 1;
217
218 return 0;
219}
220
221int conf_write(const char *name)
222{
223 FILE *out, *out_h;
224 struct symbol *sym;
225 struct menu *menu;
226 char oldname[128];
227 int type, l;
228 const char *str;
229
230 out = fopen(".tmpconfig", "w");
231 if (!out)
232 return 1;
233 out_h = fopen(".tmpconfig.h", "w");
234 if (!out_h)
235 return 1;
236 fprintf(out, "#\n"
237 "# Automatically generated make config: don't edit\n"
238 "#\n");
239 fprintf(out_h, "/*\n"
240 " * Automatically generated C config: don't edit\n"
241 " */\n"
242 "#define AUTOCONF_INCLUDED\n");
243
244 if (!sym_change_count)
245 sym_clear_all_valid();
246
247 menu = rootmenu.list;
248 while (menu) {
249 sym = menu->sym;
250 if (!sym) {
251 if (!menu_is_visible(menu))
252 goto next;
253 str = menu_get_prompt(menu);
254 fprintf(out, "\n"
255 "#\n"
256 "# %s\n"
257 "#\n", str);
258 fprintf(out_h, "\n"
259 "/*\n"
260 " * %s\n"
261 " */\n", str);
262 } else if (!(sym->flags & SYMBOL_CHOICE)) {
263 sym_calc_value(sym);
264 if (!(sym->flags & SYMBOL_WRITE))
265 goto next;
266 sym->flags &= ~SYMBOL_WRITE;
267 type = sym->type;
268 if (type == S_TRISTATE) {
269 sym_calc_value(modules_sym);
270 if (S_TRI(modules_sym->curr) == no)
271 type = S_BOOLEAN;
272 }
273 switch (type) {
274 case S_BOOLEAN:
275 case S_TRISTATE:
276 switch (sym_get_tristate_value(sym)) {
277 case no:
278 fprintf(out, "# CONFIG_%s is not set\n", sym->name);
279 fprintf(out_h, "#undef CONFIG_%s\n", sym->name);
280 break;
281 case mod:
282 fprintf(out, "CONFIG_%s=m\n", sym->name);
283 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name);
284 break;
285 case yes:
286 fprintf(out, "CONFIG_%s=y\n", sym->name);
287 fprintf(out_h, "#define CONFIG_%s 1\n", sym->name);
288 break;
289 }
290 break;
291 case S_STRING:
292 // fix me
293 str = sym_get_string_value(sym);
294 fprintf(out, "CONFIG_%s=\"", sym->name);
295 fprintf(out_h, "#define CONFIG_%s \"", sym->name);
296 do {
297 l = strcspn(str, "\"\\");
298 if (l) {
299 fwrite(str, l, 1, out);
300 fwrite(str, l, 1, out_h);
301 }
302 str += l;
303 while (*str == '\\' || *str == '"') {
304 fprintf(out, "\\%c", *str);
305 fprintf(out_h, "\\%c", *str);
306 str++;
307 }
308 } while (*str);
309 fputs("\"\n", out);
310 fputs("\"\n", out_h);
311 break;
312 case S_HEX:
313 str = sym_get_string_value(sym);
314 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
315 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
316 fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str);
317 break;
318 }
319 case S_INT:
320 str = sym_get_string_value(sym);
321 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
322 fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str);
323 break;
324 }
325 }
326
327 next:
328 if (menu->list) {
329 menu = menu->list;
330 continue;
331 }
332 if (menu->next)
333 menu = menu->next;
334 else while ((menu = menu->parent)) {
335 if (menu->next) {
336 menu = menu->next;
337 break;
338 }
339 }
340 }
341 fclose(out);
342 fclose(out_h);
343
344 if (!name) {
345 rename(".tmpconfig.h", "include/linux/autoconf.h");
346 name = conf_def_filename;
347 file_write_dep(NULL);
348 } else
349 unlink(".tmpconfig.h");
350
351 sprintf(oldname, "%s.old", name);
352 rename(name, oldname);
353 if (rename(".tmpconfig", name))
354 return 1;
355 strcpy(conf_filename, name);
356
357 sym_change_count = 0;
358
359 return 0;
360}
diff --git a/scripts/kconfig/convert-all b/scripts/kconfig/convert-all
new file mode 100644
index 0000000..53e52c5
--- a/dev/null
+++ b/scripts/kconfig/convert-all
@@ -0,0 +1,41 @@
1set -x
2#find \( -name "[Cc]onfig" -o -name "[Cc]onfig_*" \) -a ! -name "[Cc]onfig*.in" -a -type f -exec rm {} \;
3find -name "Kconfig*" -exec rm {} \;
4for a in alpha arm cris i386 ia64 m68k mips mips64 parisc ppc ppc64 s390 s390x sh sparc sparc64 um x86_64; do
5 $LKCSRC/lkcc $a >& log.$a
6 find -name "*.lkc" -exec mv {} {}-$a \;
7done
8set +x
9if false; then
10 #check differences between generated configs for archs
11 for c in `find -name "[cC]onfig.in"`; do
12 cn=`echo $c | sed 's,\(.*\)[cC]onfig\.in,\1Build.conf,'`
13 c1=''
14 for ca in $cn-*; do
15 if [ "$c1" = "" ]; then
16 echo "skip $ca"
17 c1=$ca
18 else
19 echo $ca
20 diff -u $c1 $ca
21 fi
22 done
23 done
24 exit 0
25fi
26rm *.lkc-*
27for a in alpha arm cris i386 ia64 m68k mips mips64 parisc ppc ppc64 s390 s390x sh sparc sparc64 um x86_64; do
28 for c in `find arch/$a -name "*.lkc-$a"`; do
29 cn=`echo $c | sed 's,\(.*\)\.lkc-.*,\1,'`
30 mv -v $c $cn
31 done
32done
33for c in `find -name "*.lkc-i386"`; do
34 cn=`echo $c | sed 's,\(.*\)\.lkc-.*,\1,'`
35 mv -v $c $cn
36 rm $cn.lkc-*
37done
38for c in `find -name "*.lkc-*"`; do
39 cn=`echo $c | sed 's,\(.*\)\.lkc-.*,\1,'`
40 mv -v $c $cn
41done
diff --git a/scripts/kconfig/example/miniconf.rb b/scripts/kconfig/example/miniconf.rb
new file mode 100644
index 0000000..e687fbb
--- a/dev/null
+++ b/scripts/kconfig/example/miniconf.rb
@@ -0,0 +1,32 @@
1require "kconfig"
2
3include Kconfig
4
5conf_parse("arch/i386/Kconfig")
6conf_read(nil)
7
8def conf(menu)
9 return unless menu.isVisible?
10 prompt = menu.prompt
11 if prompt.type == P_COMMENT || prompt.type == P_MENU
12 print "* #{prompt.text}\n"
13 end
14 sym = menu.sym
15 if sym
16 begin
17 print "#{prompt.text} (#{sym.get_string})? "
18 unless sym.isChangable?
19 print "\n"
20 break
21 end
22 val = gets.strip
23 end until val.empty? || sym.set_string(val)
24 end
25 menu.each do |child|
26 conf(child)
27 end
28end
29
30conf(Kconfig.rootmenu)
31
32conf_write(nil)
diff --git a/scripts/kconfig/example/query.rb b/scripts/kconfig/example/query.rb
new file mode 100644
index 0000000..2f47880
--- a/dev/null
+++ b/scripts/kconfig/example/query.rb
@@ -0,0 +1,34 @@
1require "kconfig"
2
3include Kconfig
4
5conf_parse("arch/i386/Kconfig")
6conf_read(nil)
7
8sym = Kconfig::Symbol.find(ARGV[0])
9if !sym
10 print "Symbol #{ARGV[0]} not found!\n"
11 exit
12end
13
14sym.calc_value
15print "symbol: #{sym.name}\n"
16print " type: #{Kconfig::Symbol.type_name(sym.type)}\n"
17print " value: #{sym.get_string}\n"
18print " choice\n" if sym.isChoice?
19print " choice value\n" if sym.isChoiceValue?
20print " properties:\n" if sym.prop
21sym.each do |prop|
22 case prop.type
23 when P_PROMPT
24 print " prompt: #{prop.text}\n"
25 when P_DEFAULT
26 prop.def.calc_value
27 print " default: #{prop.def.get_string}\n"
28 when P_CHOICE
29 print " choice reference\n"
30 else
31 print " unknown property: #{Property.type_name(prop.type)}\n"
32 end
33 print " dep: #{prop.visible.expr}\n" if prop.visible.expr
34end
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
new file mode 100644
index 0000000..d1af2a5
--- a/dev/null
+++ b/scripts/kconfig/expr.c
@@ -0,0 +1,1054 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <string.h>
9
10#define LKC_DIRECT_LINK
11#include "lkc.h"
12
13struct expr *expr_alloc_symbol(struct symbol *sym)
14{
15 struct expr *e = malloc(sizeof(*e));
16 memset(e, 0, sizeof(*e));
17 e->type = E_SYMBOL;
18 e->left.sym = sym;
19 return e;
20}
21
22struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
23{
24 struct expr *e = malloc(sizeof(*e));
25 memset(e, 0, sizeof(*e));
26 e->type = type;
27 e->left.expr = ce;
28 return e;
29}
30
31struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
32{
33 struct expr *e = malloc(sizeof(*e));
34 memset(e, 0, sizeof(*e));
35 e->type = type;
36 e->left.expr = e1;
37 e->right.expr = e2;
38 return e;
39}
40
41struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
42{
43 struct expr *e = malloc(sizeof(*e));
44 memset(e, 0, sizeof(*e));
45 e->type = type;
46 e->left.sym = s1;
47 e->right.sym = s2;
48 return e;
49}
50
51struct expr *expr_alloc_and(struct expr *e1, struct expr *e2)
52{
53 if (!e1)
54 return e2;
55 return e2 ? expr_alloc_two(E_AND, e1, e2) : e1;
56}
57
58struct expr *expr_copy(struct expr *org)
59{
60 struct expr *e;
61
62 if (!org)
63 return NULL;
64
65 e = malloc(sizeof(*org));
66 memcpy(e, org, sizeof(*org));
67 switch (org->type) {
68 case E_SYMBOL:
69 e->left = org->left;
70 break;
71 case E_NOT:
72 e->left.expr = expr_copy(org->left.expr);
73 break;
74 case E_EQUAL:
75 case E_UNEQUAL:
76 e->left.sym = org->left.sym;
77 e->right.sym = org->right.sym;
78 break;
79 case E_AND:
80 case E_OR:
81 case E_CHOICE:
82 e->left.expr = expr_copy(org->left.expr);
83 e->right.expr = expr_copy(org->right.expr);
84 break;
85 default:
86 printf("can't copy type %d\n", e->type);
87 free(e);
88 e = NULL;
89 break;
90 }
91
92 return e;
93}
94
95void expr_free(struct expr *e)
96{
97 if (!e)
98 return;
99
100 switch (e->type) {
101 case E_SYMBOL:
102 break;
103 case E_NOT:
104 expr_free(e->left.expr);
105 return;
106 case E_EQUAL:
107 case E_UNEQUAL:
108 break;
109 case E_OR:
110 case E_AND:
111 expr_free(e->left.expr);
112 expr_free(e->right.expr);
113 break;
114 default:
115 printf("how to free type %d?\n", e->type);
116 break;
117 }
118 free(e);
119}
120
121static int trans_count;
122
123#define e1 (*ep1)
124#define e2 (*ep2)
125
126static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2)
127{
128 if (e1->type == type) {
129 __expr_eliminate_eq(type, &e1->left.expr, &e2);
130 __expr_eliminate_eq(type, &e1->right.expr, &e2);
131 return;
132 }
133 if (e2->type == type) {
134 __expr_eliminate_eq(type, &e1, &e2->left.expr);
135 __expr_eliminate_eq(type, &e1, &e2->right.expr);
136 return;
137 }
138 if (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
139 e1->left.sym == e2->left.sym && (e1->left.sym->flags & (SYMBOL_YES|SYMBOL_NO)))
140 return;
141 if (!expr_eq(e1, e2))
142 return;
143 trans_count++;
144 expr_free(e1); expr_free(e2);
145 switch (type) {
146 case E_OR:
147 e1 = expr_alloc_symbol(&symbol_no);
148 e2 = expr_alloc_symbol(&symbol_no);
149 break;
150 case E_AND:
151 e1 = expr_alloc_symbol(&symbol_yes);
152 e2 = expr_alloc_symbol(&symbol_yes);
153 break;
154 default:
155 ;
156 }
157}
158
159void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
160{
161 if (!e1 || !e2 || e1->type != e2->type)
162 return;
163 __expr_eliminate_eq(e1->type, ep1, ep2);
164 e1 = expr_eliminate_yn(e1);
165 e2 = expr_eliminate_yn(e2);
166}
167
168#undef e1
169#undef e2
170
171int expr_eq(struct expr *e1, struct expr *e2)
172{
173 int res, old_count;
174
175 if (e1->type != e2->type)
176 return 0;
177 switch (e1->type) {
178 case E_EQUAL:
179 case E_UNEQUAL:
180 return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym;
181 case E_SYMBOL:
182 return e1->left.sym == e2->left.sym;
183 case E_NOT:
184 return expr_eq(e1->left.expr, e2->left.expr);
185 case E_AND:
186 case E_OR:
187 e1 = expr_copy(e1);
188 e2 = expr_copy(e2);
189 old_count = trans_count;
190 expr_eliminate_eq(&e1, &e2);
191 res = (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
192 e1->left.sym == e2->left.sym);
193 expr_free(e1);
194 expr_free(e2);
195 trans_count = old_count;
196 return res;
197 case E_CHOICE:
198 case E_NONE:
199 /* panic */;
200 }
201
202 print_expr(0, e1, 0);
203 printf(" = ");
204 print_expr(0, e2, 0);
205 printf(" ?\n");
206
207 return 0;
208}
209
210struct expr *expr_eliminate_yn(struct expr *e)
211{
212 struct expr *tmp;
213
214 if (e) switch (e->type) {
215 case E_AND:
216 e->left.expr = expr_eliminate_yn(e->left.expr);
217 e->right.expr = expr_eliminate_yn(e->right.expr);
218 if (e->left.expr->type == E_SYMBOL) {
219 if (e->left.expr->left.sym == &symbol_no) {
220 expr_free(e->left.expr);
221 expr_free(e->right.expr);
222 e->type = E_SYMBOL;
223 e->left.sym = &symbol_no;
224 e->right.expr = NULL;
225 return e;
226 } else if (e->left.expr->left.sym == &symbol_yes) {
227 free(e->left.expr);
228 tmp = e->right.expr;
229 *e = *(e->right.expr);
230 free(tmp);
231 return e;
232 }
233 }
234 if (e->right.expr->type == E_SYMBOL) {
235 if (e->right.expr->left.sym == &symbol_no) {
236 expr_free(e->left.expr);
237 expr_free(e->right.expr);
238 e->type = E_SYMBOL;
239 e->left.sym = &symbol_no;
240 e->right.expr = NULL;
241 return e;
242 } else if (e->right.expr->left.sym == &symbol_yes) {
243 free(e->right.expr);
244 tmp = e->left.expr;
245 *e = *(e->left.expr);
246 free(tmp);
247 return e;
248 }
249 }
250 break;
251 case E_OR:
252 e->left.expr = expr_eliminate_yn(e->left.expr);
253 e->right.expr = expr_eliminate_yn(e->right.expr);
254 if (e->left.expr->type == E_SYMBOL) {
255 if (e->left.expr->left.sym == &symbol_no) {
256 free(e->left.expr);
257 tmp = e->right.expr;
258 *e = *(e->right.expr);
259 free(tmp);
260 return e;
261 } else if (e->left.expr->left.sym == &symbol_yes) {
262 expr_free(e->left.expr);
263 expr_free(e->right.expr);
264 e->type = E_SYMBOL;
265 e->left.sym = &symbol_yes;
266 e->right.expr = NULL;
267 return e;
268 }
269 }
270 if (e->right.expr->type == E_SYMBOL) {
271 if (e->right.expr->left.sym == &symbol_no) {
272 free(e->right.expr);
273 tmp = e->left.expr;
274 *e = *(e->left.expr);
275 free(tmp);
276 return e;
277 } else if (e->right.expr->left.sym == &symbol_yes) {
278 expr_free(e->left.expr);
279 expr_free(e->right.expr);
280 e->type = E_SYMBOL;
281 e->left.sym = &symbol_yes;
282 e->right.expr = NULL;
283 return e;
284 }
285 }
286 break;
287 default:
288 ;
289 }
290 return e;
291}
292
293/*
294 * bool FOO!=n => FOO
295 */
296struct expr *expr_trans_bool(struct expr *e)
297{
298 if (!e)
299 return NULL;
300 switch (e->type) {
301 case E_AND:
302 case E_OR:
303 case E_NOT:
304 e->left.expr = expr_trans_bool(e->left.expr);
305 e->right.expr = expr_trans_bool(e->right.expr);
306 break;
307 case E_UNEQUAL:
308 // FOO!=n -> FOO
309 if (e->left.sym->type == S_TRISTATE) {
310 if (e->right.sym == &symbol_no) {
311 e->type = E_SYMBOL;
312 e->right.sym = NULL;
313 }
314 }
315 break;
316 default:
317 ;
318 }
319 return e;
320}
321
322/*
323 * e1 || e2 -> ?
324 */
325struct expr *expr_join_or(struct expr *e1, struct expr *e2)
326{
327 struct expr *tmp;
328 struct symbol *sym1, *sym2;
329
330 if (expr_eq(e1, e2))
331 return expr_copy(e1);
332 if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT)
333 return NULL;
334 if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT)
335 return NULL;
336 if (e1->type == E_NOT) {
337 tmp = e1->left.expr;
338 if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL)
339 return NULL;
340 sym1 = tmp->left.sym;
341 } else
342 sym1 = e1->left.sym;
343 if (e2->type == E_NOT) {
344 if (e2->left.expr->type != E_SYMBOL)
345 return NULL;
346 sym2 = e2->left.expr->left.sym;
347 } else
348 sym2 = e2->left.sym;
349 if (sym1 != sym2)
350 return NULL;
351 if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE)
352 return NULL;
353 if (sym1->type == S_TRISTATE) {
354 if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
355 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) ||
356 (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) {
357 // (a='y') || (a='m') -> (a!='n')
358 return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no);
359 }
360 if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
361 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) ||
362 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) {
363 // (a='y') || (a='n') -> (a!='m')
364 return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod);
365 }
366 if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
367 ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) ||
368 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) {
369 // (a='m') || (a='n') -> (a!='y')
370 return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes);
371 }
372 }
373 if (sym1->type == S_BOOLEAN && sym1 == sym2) {
374 if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) ||
375 (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL))
376 return expr_alloc_symbol(&symbol_yes);
377 }
378
379 printf("optimize ");
380 print_expr(0, e1, 0);
381 printf(" || ");
382 print_expr(0, e2, 0);
383 printf(" ?\n");
384 return NULL;
385}
386
387struct expr *expr_join_and(struct expr *e1, struct expr *e2)
388{
389 struct expr *tmp;
390 struct symbol *sym1, *sym2;
391
392 if (expr_eq(e1, e2))
393 return expr_copy(e1);
394 if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT)
395 return NULL;
396 if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT)
397 return NULL;
398 if (e1->type == E_NOT) {
399 tmp = e1->left.expr;
400 if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL)
401 return NULL;
402 sym1 = tmp->left.sym;
403 } else
404 sym1 = e1->left.sym;
405 if (e2->type == E_NOT) {
406 if (e2->left.expr->type != E_SYMBOL)
407 return NULL;
408 sym2 = e2->left.expr->left.sym;
409 } else
410 sym2 = e2->left.sym;
411 if (sym1 != sym2)
412 return NULL;
413 if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE)
414 return NULL;
415
416 if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) ||
417 (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes))
418 // (a) && (a='y') -> (a='y')
419 return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes);
420
421 if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) ||
422 (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no))
423 // (a) && (a!='n') -> (a)
424 return expr_alloc_symbol(sym1);
425
426 if (sym1->type == S_TRISTATE) {
427 if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) {
428 // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
429 sym2 = e1->right.sym;
430 if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST))
431 return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2)
432 : expr_alloc_symbol(&symbol_no);
433 }
434 if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) {
435 // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
436 sym2 = e2->right.sym;
437 if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST))
438 return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2)
439 : expr_alloc_symbol(&symbol_no);
440 }
441 if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
442 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) ||
443 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes)))
444 // (a!='y') && (a!='n') -> (a='m')
445 return expr_alloc_comp(E_EQUAL, sym1, &symbol_mod);
446
447 if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
448 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) ||
449 (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes)))
450 // (a!='y') && (a!='m') -> (a='n')
451 return expr_alloc_comp(E_EQUAL, sym1, &symbol_no);
452
453 if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
454 ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) ||
455 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod)))
456 // (a!='m') && (a!='n') -> (a='m')
457 return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes);
458
459 if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) ||
460 (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) ||
461 (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) ||
462 (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes))
463 return NULL;
464 }
465 printf("optimize ");
466 print_expr(0, e1, 0);
467 printf(" && ");
468 print_expr(0, e2, 0);
469 printf(" ?\n");
470 return NULL;
471}
472
473static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2)
474{
475#define e1 (*ep1)
476#define e2 (*ep2)
477 struct expr *tmp;
478
479 if (e1->type == type) {
480 expr_eliminate_dups1(type, &e1->left.expr, &e2);
481 expr_eliminate_dups1(type, &e1->right.expr, &e2);
482 return;
483 }
484 if (e2->type == type) {
485 expr_eliminate_dups1(type, &e1, &e2->left.expr);
486 expr_eliminate_dups1(type, &e1, &e2->right.expr);
487 return;
488 }
489 if (e1 == e2)
490 return;
491
492 switch (e1->type) {
493 case E_OR: case E_AND:
494 expr_eliminate_dups1(e1->type, &e1, &e1);
495 default:
496 ;
497 }
498
499 switch (type) {
500 case E_OR:
501 tmp = expr_join_or(e1, e2);
502 if (tmp) {
503 expr_free(e1); expr_free(e2);
504 e1 = expr_alloc_symbol(&symbol_no);
505 e2 = tmp;
506 trans_count++;
507 }
508 break;
509 case E_AND:
510 tmp = expr_join_and(e1, e2);
511 if (tmp) {
512 expr_free(e1); expr_free(e2);
513 e1 = expr_alloc_symbol(&symbol_yes);
514 e2 = tmp;
515 trans_count++;
516 }
517 break;
518 default:
519 ;
520 }
521#undef e1
522#undef e2
523}
524
525static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct expr **ep2)
526{
527#define e1 (*ep1)
528#define e2 (*ep2)
529 struct expr *tmp, *tmp1, *tmp2;
530
531 if (e1->type == type) {
532 expr_eliminate_dups2(type, &e1->left.expr, &e2);
533 expr_eliminate_dups2(type, &e1->right.expr, &e2);
534 return;
535 }
536 if (e2->type == type) {
537 expr_eliminate_dups2(type, &e1, &e2->left.expr);
538 expr_eliminate_dups2(type, &e1, &e2->right.expr);
539 }
540 if (e1 == e2)
541 return;
542
543 switch (e1->type) {
544 case E_OR:
545 expr_eliminate_dups2(e1->type, &e1, &e1);
546 // (FOO || BAR) && (!FOO && !BAR) -> n
547 tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1)));
548 tmp2 = expr_copy(e2);
549 tmp = expr_extract_eq_and(&tmp1, &tmp2);
550 if (expr_is_yes(tmp1)) {
551 expr_free(e1);
552 e1 = expr_alloc_symbol(&symbol_no);
553 trans_count++;
554 }
555 expr_free(tmp2);
556 expr_free(tmp1);
557 expr_free(tmp);
558 break;
559 case E_AND:
560 expr_eliminate_dups2(e1->type, &e1, &e1);
561 // (FOO && BAR) || (!FOO || !BAR) -> y
562 tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1)));
563 tmp2 = expr_copy(e2);
564 tmp = expr_extract_eq_or(&tmp1, &tmp2);
565 if (expr_is_no(tmp1)) {
566 expr_free(e1);
567 e1 = expr_alloc_symbol(&symbol_yes);
568 trans_count++;
569 }
570 expr_free(tmp2);
571 expr_free(tmp1);
572 expr_free(tmp);
573 break;
574 default:
575 ;
576 }
577#undef e1
578#undef e2
579}
580
581struct expr *expr_eliminate_dups(struct expr *e)
582{
583 int oldcount;
584 if (!e)
585 return e;
586
587 oldcount = trans_count;
588 while (1) {
589 trans_count = 0;
590 switch (e->type) {
591 case E_OR: case E_AND:
592 expr_eliminate_dups1(e->type, &e, &e);
593 expr_eliminate_dups2(e->type, &e, &e);
594 default:
595 ;
596 }
597 if (!trans_count)
598 break;
599 e = expr_eliminate_yn(e);
600 }
601 trans_count = oldcount;
602 return e;
603}
604
605struct expr *expr_transform(struct expr *e)
606{
607 struct expr *tmp;
608
609 if (!e)
610 return NULL;
611 switch (e->type) {
612 case E_EQUAL:
613 case E_UNEQUAL:
614 case E_SYMBOL:
615 case E_CHOICE:
616 break;
617 default:
618 e->left.expr = expr_transform(e->left.expr);
619 e->right.expr = expr_transform(e->right.expr);
620 }
621
622 switch (e->type) {
623 case E_EQUAL:
624 if (e->left.sym->type != S_BOOLEAN)
625 break;
626 if (e->right.sym == &symbol_no) {
627 e->type = E_NOT;
628 e->left.expr = expr_alloc_symbol(e->left.sym);
629 e->right.sym = NULL;
630 break;
631 }
632 if (e->right.sym == &symbol_mod) {
633 printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name);
634 e->type = E_SYMBOL;
635 e->left.sym = &symbol_no;
636 e->right.sym = NULL;
637 break;
638 }
639 if (e->right.sym == &symbol_yes) {
640 e->type = E_SYMBOL;
641 e->right.sym = NULL;
642 break;
643 }
644 break;
645 case E_UNEQUAL:
646 if (e->left.sym->type != S_BOOLEAN)
647 break;
648 if (e->right.sym == &symbol_no) {
649 e->type = E_SYMBOL;
650 e->right.sym = NULL;
651 break;
652 }
653 if (e->right.sym == &symbol_mod) {
654 printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name);
655 e->type = E_SYMBOL;
656 e->left.sym = &symbol_yes;
657 e->right.sym = NULL;
658 break;
659 }
660 if (e->right.sym == &symbol_yes) {
661 e->type = E_NOT;
662 e->left.expr = expr_alloc_symbol(e->left.sym);
663 e->right.sym = NULL;
664 break;
665 }
666 break;
667 case E_NOT:
668 switch (e->left.expr->type) {
669 case E_NOT:
670 // !!a -> a
671 tmp = e->left.expr->left.expr;
672 free(e->left.expr);
673 free(e);
674 e = tmp;
675 e = expr_transform(e);
676 break;
677 case E_EQUAL:
678 case E_UNEQUAL:
679 // !a='x' -> a!='x'
680 tmp = e->left.expr;
681 free(e);
682 e = tmp;
683 e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL;
684 break;
685 case E_OR:
686 // !(a || b) -> !a && !b
687 tmp = e->left.expr;
688 e->type = E_AND;
689 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr);
690 tmp->type = E_NOT;
691 tmp->right.expr = NULL;
692 e = expr_transform(e);
693 break;
694 case E_AND:
695 // !(a && b) -> !a || !b
696 tmp = e->left.expr;
697 e->type = E_OR;
698 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr);
699 tmp->type = E_NOT;
700 tmp->right.expr = NULL;
701 e = expr_transform(e);
702 break;
703 case E_SYMBOL:
704 if (e->left.expr->left.sym == &symbol_yes) {
705 // !'y' -> 'n'
706 tmp = e->left.expr;
707 free(e);
708 e = tmp;
709 e->type = E_SYMBOL;
710 e->left.sym = &symbol_no;
711 break;
712 }
713 if (e->left.expr->left.sym == &symbol_mod) {
714 // !'m' -> 'm'
715 tmp = e->left.expr;
716 free(e);
717 e = tmp;
718 e->type = E_SYMBOL;
719 e->left.sym = &symbol_mod;
720 break;
721 }
722 if (e->left.expr->left.sym == &symbol_no) {
723 // !'n' -> 'y'
724 tmp = e->left.expr;
725 free(e);
726 e = tmp;
727 e->type = E_SYMBOL;
728 e->left.sym = &symbol_yes;
729 break;
730 }
731 break;
732 default:
733 ;
734 }
735 break;
736 default:
737 ;
738 }
739 return e;
740}
741
742int expr_contains_symbol(struct expr *dep, struct symbol *sym)
743{
744 if (!dep)
745 return 0;
746
747 switch (dep->type) {
748 case E_AND:
749 case E_OR:
750 return expr_contains_symbol(dep->left.expr, sym) ||
751 expr_contains_symbol(dep->right.expr, sym);
752 case E_SYMBOL:
753 return dep->left.sym == sym;
754 case E_EQUAL:
755 case E_UNEQUAL:
756 return dep->left.sym == sym ||
757 dep->right.sym == sym;
758 case E_NOT:
759 return expr_contains_symbol(dep->left.expr, sym);
760 default:
761 ;
762 }
763 return 0;
764}
765
766bool expr_depends_symbol(struct expr *dep, struct symbol *sym)
767{
768 if (!dep)
769 return false;
770
771 switch (dep->type) {
772 case E_AND:
773 return expr_depends_symbol(dep->left.expr, sym) ||
774 expr_depends_symbol(dep->right.expr, sym);
775 case E_SYMBOL:
776 return dep->left.sym == sym;
777 case E_EQUAL:
778 if (dep->left.sym == sym) {
779 if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod)
780 return true;
781 }
782 break;
783 case E_UNEQUAL:
784 if (dep->left.sym == sym) {
785 if (dep->right.sym == &symbol_no)
786 return true;
787 }
788 break;
789 default:
790 ;
791 }
792 return false;
793}
794
795struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2)
796{
797 struct expr *tmp = NULL;
798 expr_extract_eq(E_AND, &tmp, ep1, ep2);
799 if (tmp) {
800 *ep1 = expr_eliminate_yn(*ep1);
801 *ep2 = expr_eliminate_yn(*ep2);
802 }
803 return tmp;
804}
805
806struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2)
807{
808 struct expr *tmp = NULL;
809 expr_extract_eq(E_OR, &tmp, ep1, ep2);
810 if (tmp) {
811 *ep1 = expr_eliminate_yn(*ep1);
812 *ep2 = expr_eliminate_yn(*ep2);
813 }
814 return tmp;
815}
816
817void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2)
818{
819#define e1 (*ep1)
820#define e2 (*ep2)
821 if (e1->type == type) {
822 expr_extract_eq(type, ep, &e1->left.expr, &e2);
823 expr_extract_eq(type, ep, &e1->right.expr, &e2);
824 return;
825 }
826 if (e2->type == type) {
827 expr_extract_eq(type, ep, ep1, &e2->left.expr);
828 expr_extract_eq(type, ep, ep1, &e2->right.expr);
829 return;
830 }
831 if (expr_eq(e1, e2)) {
832 *ep = *ep ? expr_alloc_two(type, *ep, e1) : e1;
833 expr_free(e2);
834 if (type == E_AND) {
835 e1 = expr_alloc_symbol(&symbol_yes);
836 e2 = expr_alloc_symbol(&symbol_yes);
837 } else if (type == E_OR) {
838 e1 = expr_alloc_symbol(&symbol_no);
839 e2 = expr_alloc_symbol(&symbol_no);
840 }
841 }
842#undef e1
843#undef e2
844}
845
846struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym)
847{
848 struct expr *e1, *e2;
849
850 if (!e) {
851 e = expr_alloc_symbol(sym);
852 if (type == E_UNEQUAL)
853 e = expr_alloc_one(E_NOT, e);
854 return e;
855 }
856 switch (e->type) {
857 case E_AND:
858 e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym);
859 e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym);
860 if (sym == &symbol_yes)
861 e = expr_alloc_two(E_AND, e1, e2);
862 if (sym == &symbol_no)
863 e = expr_alloc_two(E_OR, e1, e2);
864 if (type == E_UNEQUAL)
865 e = expr_alloc_one(E_NOT, e);
866 return e;
867 case E_OR:
868 e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym);
869 e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym);
870 if (sym == &symbol_yes)
871 e = expr_alloc_two(E_OR, e1, e2);
872 if (sym == &symbol_no)
873 e = expr_alloc_two(E_AND, e1, e2);
874 if (type == E_UNEQUAL)
875 e = expr_alloc_one(E_NOT, e);
876 return e;
877 case E_NOT:
878 return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym);
879 case E_UNEQUAL:
880 case E_EQUAL:
881 if (type == E_EQUAL) {
882 if (sym == &symbol_yes)
883 return expr_copy(e);
884 if (sym == &symbol_mod)
885 return expr_alloc_symbol(&symbol_no);
886 if (sym == &symbol_no)
887 return expr_alloc_one(E_NOT, expr_copy(e));
888 } else {
889 if (sym == &symbol_yes)
890 return expr_alloc_one(E_NOT, expr_copy(e));
891 if (sym == &symbol_mod)
892 return expr_alloc_symbol(&symbol_yes);
893 if (sym == &symbol_no)
894 return expr_copy(e);
895 }
896 break;
897 case E_SYMBOL:
898 return expr_alloc_comp(type, e->left.sym, sym);
899 case E_CHOICE:
900 case E_NONE:
901 /* panic */;
902 }
903 return NULL;
904}
905
906tristate expr_calc_value(struct expr *e)
907{
908 tristate val1, val2;
909 const char *str1, *str2;
910
911 if (!e)
912 return yes;
913
914 switch (e->type) {
915 case E_SYMBOL:
916 sym_calc_value(e->left.sym);
917 return S_TRI(e->left.sym->curr);
918 case E_AND:
919 val1 = expr_calc_value(e->left.expr);
920 val2 = expr_calc_value(e->right.expr);
921 return E_AND(val1, val2);
922 case E_OR:
923 val1 = expr_calc_value(e->left.expr);
924 val2 = expr_calc_value(e->right.expr);
925 return E_OR(val1, val2);
926 case E_NOT:
927 val1 = expr_calc_value(e->left.expr);
928 return E_NOT(val1);
929 case E_EQUAL:
930 sym_calc_value(e->left.sym);
931 sym_calc_value(e->right.sym);
932 str1 = sym_get_string_value(e->left.sym);
933 str2 = sym_get_string_value(e->right.sym);
934 return !strcmp(str1, str2) ? yes : no;
935 case E_UNEQUAL:
936 sym_calc_value(e->left.sym);
937 sym_calc_value(e->right.sym);
938 str1 = sym_get_string_value(e->left.sym);
939 str2 = sym_get_string_value(e->right.sym);
940 return !strcmp(str1, str2) ? no : yes;
941 default:
942 printf("expr_calc_value: %d?\n", e->type);
943 return no;
944 }
945}
946
947int expr_compare_type(enum expr_type t1, enum expr_type t2)
948{
949#if 0
950 return 1;
951#else
952 if (t1 == t2)
953 return 0;
954 switch (t1) {
955 case E_EQUAL:
956 case E_UNEQUAL:
957 if (t2 == E_NOT)
958 return 1;
959 case E_NOT:
960 if (t2 == E_AND)
961 return 1;
962 case E_AND:
963 if (t2 == E_OR)
964 return 1;
965 case E_OR:
966 if (t2 == E_CHOICE)
967 return 1;
968 case E_CHOICE:
969 if (t2 == 0)
970 return 1;
971 default:
972 return -1;
973 }
974 printf("[%dgt%d?]", t1, t2);
975 return 0;
976#endif
977}
978
979void expr_print(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken)
980{
981 if (!e) {
982 fn(data, "y");
983 return;
984 }
985
986 if (expr_compare_type(prevtoken, e->type) > 0)
987 fn(data, "(");
988 switch (e->type) {
989 case E_SYMBOL:
990 if (e->left.sym->name)
991 fn(data, e->left.sym->name);
992 else
993 fn(data, "<choice>");
994 break;
995 case E_NOT:
996 fn(data, "!");
997 expr_print(e->left.expr, fn, data, E_NOT);
998 break;
999 case E_EQUAL:
1000 fn(data, e->left.sym->name);
1001 fn(data, "=");
1002 fn(data, e->right.sym->name);
1003 break;
1004 case E_UNEQUAL:
1005 fn(data, e->left.sym->name);
1006 fn(data, "!=");
1007 fn(data, e->right.sym->name);
1008 break;
1009 case E_OR:
1010 expr_print(e->left.expr, fn, data, E_OR);
1011 fn(data, " || ");
1012 expr_print(e->right.expr, fn, data, E_OR);
1013 break;
1014 case E_AND:
1015 expr_print(e->left.expr, fn, data, E_AND);
1016 fn(data, " && ");
1017 expr_print(e->right.expr, fn, data, E_AND);
1018 break;
1019 case E_CHOICE:
1020 if (e->left.expr) {
1021 expr_print(e->left.expr, fn, data, E_CHOICE);
1022 fn(data, " ^ ");
1023 }
1024 fn(data, e->right.sym->name);
1025 break;
1026 default:
1027 {
1028 char buf[32];
1029 sprintf(buf, "<unknown type %d>", e->type);
1030 fn(data, buf);
1031 break;
1032 }
1033 }
1034 if (expr_compare_type(prevtoken, e->type) > 0)
1035 fn(data, ")");
1036}
1037
1038static void expr_print_file_helper(void *data, const char *str)
1039{
1040 fwrite(str, strlen(str), 1, data);
1041}
1042
1043void expr_fprint(struct expr *e, FILE *out)
1044{
1045 expr_print(e, expr_print_file_helper, out, E_NONE);
1046}
1047
1048void print_expr(int mask, struct expr *e, int prevtoken)
1049{
1050 if (!(cdebug & mask))
1051 return;
1052 expr_fprint(e, stdout);
1053}
1054
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
new file mode 100644
index 0000000..fd9c32a
--- a/dev/null
+++ b/scripts/kconfig/expr.h
@@ -0,0 +1,242 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#ifndef EXPR_H
7#define EXPR_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#include <stdio.h>
14#ifndef __cplusplus
15#include <stdbool.h>
16#endif
17
18struct file {
19 struct file *next;
20 struct file *parent;
21#ifdef CML1
22 struct statement *stmt;
23 struct statement *last_stmt;
24#endif
25 char *name;
26 int lineno;
27 int flags;
28};
29
30 #define FILE_BUSY 0x0001
31 #define FILE_SCANNED 0x0002
32 #define FILE_PRINTED 0x0004
33
34typedef enum tristate {
35 no, mod, yes
36} tristate;
37
38enum expr_type {
39 E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL
40};
41
42union expr_data {
43 struct expr *expr;
44 struct symbol *sym;
45};
46
47struct expr {
48#ifdef CML1
49 int token;
50#else
51 enum expr_type type;
52#endif
53 union expr_data left, right;
54};
55
56 #define E_TRI(ev)((ev).tri)
57 #define E_EXPR(ev)((ev).expr)
58 #define E_CALC(ev)(E_TRI(ev) = expr_calc_value(E_EXPR(ev)))
59
60 #define E_OR(dep1, dep2)(((dep1)>(dep2))?(dep1):(dep2))
61 #define E_AND(dep1, dep2)(((dep1)<(dep2))?(dep1):(dep2))
62 #define E_NOT(dep) (2-(dep))
63
64struct expr_value {
65 struct expr *expr;
66 tristate tri;
67};
68
69 #define S_VAL(sv)((sv).value)
70 #define S_TRI(sv)((sv).tri)
71 #define S_EQ(sv1, sv2)(S_VAL(sv1) == S_VAL(sv2) || !strcmp(S_VAL(sv1), S_VAL(sv2)))
72
73struct symbol_value {
74 void *value;
75 tristate tri;
76};
77
78enum symbol_type {
79 S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
80};
81
82struct symbol {
83 struct symbol *next;
84 char *name;
85 char *help;
86#ifdef CML1
87 int type;
88#else
89 enum symbol_type type;
90#endif
91 struct symbol_value curr, def;
92 tristate visible;
93 int flags;
94 struct property *prop;
95 struct expr *dep, *dep2;
96 struct menu *menu;
97};
98
99#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
100
101#ifdef CML1
102 #define SYMBOL_UNKNOWN S_UNKNOWN
103 #define SYMBOL_BOOLEAN S_BOOLEAN
104 #define SYMBOL_TRISTATE S_TRISTATE
105 #define SYMBOL_INT S_INT
106 #define SYMBOL_HEX S_HEX
107 #define SYMBOL_STRING S_STRING
108 #define SYMBOL_OTHER S_OTHER
109#endif
110
111 #define SYMBOL_YES 0x0001
112 #define SYMBOL_MOD 0x0002
113 #define SYMBOL_NO 0x0004
114 #define SYMBOL_CONST 0x0007
115 #define SYMBOL_CHECK 0x0008
116 #define SYMBOL_CHOICE 0x0010
117 #define SYMBOL_CHOICEVAL0x0020
118 #define SYMBOL_PRINTED 0x0040
119 #define SYMBOL_VALID 0x0080
120 #define SYMBOL_OPTIONAL 0x0100
121 #define SYMBOL_WRITE 0x0200
122 #define SYMBOL_CHANGED 0x0400
123 #define SYMBOL_NEW 0x0800
124 #define SYMBOL_AUTO 0x1000
125
126 #define SYMBOL_MAXLENGTH256
127 #define SYMBOL_HASHSIZE 257
128 #define SYMBOL_HASHMASK 0xff
129
130enum prop_type {
131 P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_ROOTMENU, P_DEFAULT, P_CHOICE
132};
133
134struct property {
135 struct property *next;
136 struct symbol *sym;
137#ifdef CML1
138 int token;
139#else
140 enum prop_type type;
141#endif
142 const char *text;
143 struct symbol *def;
144 struct expr_value visible;
145 struct expr *dep;
146 struct expr *dep2;
147 struct menu *menu;
148 struct file *file;
149 int lineno;
150#ifdef CML1
151 struct property *next_pos;
152#endif
153};
154
155#define for_all_properties(sym, st, tok) \
156 for (st = sym->prop; st; st = st->next) \
157 if (st->type == (tok))
158#define for_all_prompts(sym, st) for_all_properties(sym, st, P_PROMPT)
159#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT)
160#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE)
161
162struct menu {
163 struct menu *next;
164 struct menu *parent;
165 struct menu *list;
166 struct symbol *sym;
167 struct property *prompt;
168 struct expr *dep;
169 //char *help;
170 struct file *file;
171 int lineno;
172 //void *data;
173};
174
175#ifndef SWIG
176
177extern struct file *file_list;
178extern struct file *current_file;
179struct file *lookup_file(const char *name);
180
181extern struct symbol symbol_yes, symbol_no, symbol_mod;
182extern struct symbol *modules_sym;
183extern int cdebug;
184extern int print_type;
185struct expr *expr_alloc_symbol(struct symbol *sym);
186#ifdef CML1
187struct expr *expr_alloc_one(int token, struct expr *ce);
188struct expr *expr_alloc_two(int token, struct expr *e1, struct expr *e2);
189struct expr *expr_alloc_comp(int token, struct symbol *s1, struct symbol *s2);
190#else
191struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
192struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2);
193struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
194#endif
195struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
196struct expr *expr_copy(struct expr *org);
197void expr_free(struct expr *e);
198int expr_eq(struct expr *e1, struct expr *e2);
199void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
200tristate expr_calc_value(struct expr *e);
201struct expr *expr_eliminate_yn(struct expr *e);
202struct expr *expr_trans_bool(struct expr *e);
203struct expr *expr_eliminate_dups(struct expr *e);
204struct expr *expr_transform(struct expr *e);
205int expr_contains_symbol(struct expr *dep, struct symbol *sym);
206bool expr_depends_symbol(struct expr *dep, struct symbol *sym);
207struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
208struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
209void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
210struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
211
212void expr_fprint(struct expr *e, FILE *out);
213void print_expr(int mask, struct expr *e, int prevtoken);
214
215#ifdef CML1
216static inline int expr_is_yes(struct expr *e)
217{
218 return !e || (e->token == WORD && e->left.sym == &symbol_yes);
219}
220
221static inline int expr_is_no(struct expr *e)
222{
223 return e && (e->token == WORD && e->left.sym == &symbol_no);
224}
225#else
226static inline int expr_is_yes(struct expr *e)
227{
228 return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
229}
230
231static inline int expr_is_no(struct expr *e)
232{
233 return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
234}
235#endif
236#endif
237
238#ifdef __cplusplus
239}
240#endif
241
242#endif /* EXPR_H */
diff --git a/scripts/kconfig/expr1.c b/scripts/kconfig/expr1.c
new file mode 100644
index 0000000..8b45801
--- a/dev/null
+++ b/scripts/kconfig/expr1.c
@@ -0,0 +1,333 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <ctype.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10#include "cml1.h"
11
12struct file *file_list;
13struct file *current_file;
14
15struct symbol symbol_yes = {
16 name: "y",
17 curr: { "y", yes },
18 flags: SYMBOL_YES|SYMBOL_VALID,
19}, symbol_mod = {
20 name: "m",
21 curr: { "m", mod },
22 flags: SYMBOL_MOD|SYMBOL_VALID,
23}, symbol_no = {
24 name: "n",
25 curr: { "n", no },
26 flags: SYMBOL_NO|SYMBOL_VALID,
27}, symbol_empty = {
28 name: "",
29 curr: { "", no },
30 flags: SYMBOL_VALID,
31};
32
33struct expr *expr_alloc_symbol(struct symbol *sym)
34{
35 struct expr *e = malloc(sizeof(*e));
36 memset(e, 0, sizeof(*e));
37 e->token = T_WORD;
38 e->left.sym = sym;
39 return e;
40}
41
42struct expr *expr_alloc_one(int token, struct expr *ce)
43{
44 struct expr *e = malloc(sizeof(*e));
45 memset(e, 0, sizeof(*e));
46 e->token = token;
47 e->left.expr = ce;
48 return e;
49}
50
51struct expr *expr_alloc_two(int token, struct expr *e1, struct expr *e2)
52{
53 struct expr *e = malloc(sizeof(*e));
54 memset(e, 0, sizeof(*e));
55 e->token = token;
56 e->left.expr = e1;
57 e->right.expr = e2;
58 return e;
59}
60
61struct expr *expr_alloc_comp(int token, struct symbol *s1, struct symbol *s2)
62{
63 struct expr *e = malloc(sizeof(*e));
64 memset(e, 0, sizeof(*e));
65 e->token = token;
66 e->left.sym = s1;
67 e->right.sym = s2;
68 return e;
69}
70
71struct expr *expr_alloc_and(struct expr *e1, struct expr *e2)
72{
73 if (!e1)
74 return e2;
75 return e2 ? expr_alloc_two(T_AND, e1, e2) : e1;
76}
77
78struct expr *expr_copy(struct expr *org)
79{
80 struct expr *e;
81
82 if (!org)
83 return NULL;
84
85 e = malloc(sizeof(*org));
86 memcpy(e, org, sizeof(*org));
87 switch (org->token) {
88 case T_WORD:
89 e->left = org->left;
90 break;
91 case '!':
92 e->left.expr = expr_copy(org->left.expr);
93 break;
94 case '=':
95 case T_UNEQUAL:
96 e->left.sym = org->left.sym;
97 e->right.sym = org->right.sym;
98 break;
99 case T_OR:
100 case T_AND:
101 case '&':
102 case '|':
103 case '^':
104 case T_IF:
105 case T_ELSE:
106 e->left.expr = expr_copy(org->left.expr);
107 e->right.expr = expr_copy(org->right.expr);
108 break;
109 default:
110 printf("can't copy token %d\n", e->token);
111 free(e);
112 e = NULL;
113 break;
114 }
115
116 return e;
117}
118
119void expr_free(struct expr *e)
120{
121 if (!e)
122 return;
123
124 switch (e->token) {
125 case T_WORD:
126 break;
127 case '!':
128 expr_free(e->left.expr);
129 return;
130 case '=':
131 case T_UNEQUAL:
132 break;
133 case '|':
134 case T_OR:
135 case T_AND:
136 case '&':
137 case T_IF:
138 case T_ELSE:
139 expr_free(e->left.expr);
140 expr_free(e->right.expr);
141 break;
142 default:
143 printf("how to free token %d?\n", e->token);
144 break;
145 }
146 free(e);
147}
148
149static inline int token_gt(int t1, int t2)
150{
151#if 0
152 return 1;
153#else
154 switch (t1) {
155 case '=':
156 case T_UNEQUAL:
157 if (t2 == '!')
158 return 1;
159 case '!':
160 if (t2 == T_AND || t2 == T_IF || t2 == T_ELSE || t2 == '&')
161 return 1;
162 case '&':
163 case T_IF:
164 case T_ELSE:
165 case T_AND:
166 if (t2 == T_OR || t2 == '|')
167 return 1;
168 case '|':
169 case T_OR:
170 if (t2 == '^')
171 return 1;
172 case '^':
173 if (t2 == 0)
174 return 1;
175 case 0:
176 return 0;
177 }
178 printf("[%dgt%d?]", t1, t2);
179 return 0;
180#endif
181}
182
183int print_type = 1;
184
185static void print_sym(FILE *out, struct symbol *sym)
186{
187 fprintf(out, "%s", sym->name);
188 if (print_type)
189 fprintf(out, "%s",
190 sym->type == SYMBOL_BOOLEAN ? "?" :
191 sym->type == SYMBOL_TRISTATE ? "??" :
192 sym->type == SYMBOL_HEX ? "h" :
193 sym->type == SYMBOL_INT ? "i" :
194 sym->type == SYMBOL_STRING ? "s" :
195 "");
196}
197
198void fprint_expr(FILE *out, struct expr *e, int prevtoken)
199{
200 if (!e) {
201 fprintf(out, "<none>");
202 return;
203 }
204
205 switch (e->token) {
206 case T_WORD:
207 print_sym(out, e->left.sym);
208 break;
209 case '!':
210 if (token_gt(prevtoken, '!'))
211 fprintf(out, "(");
212 fprintf(out, "!");
213 fprint_expr(out, e->left.expr, '!');
214 if (token_gt(prevtoken, '!'))
215 fprintf(out, ")");
216 break;
217 case '=':
218 if (token_gt(prevtoken, '='))
219 fprintf(out, "(");
220 print_sym(out, e->left.sym);
221 fprintf(out, "=");
222 print_sym(out, e->right.sym);
223 if (token_gt(prevtoken, '='))
224 fprintf(out, ")");
225 break;
226 case T_UNEQUAL:
227 if (token_gt(prevtoken, T_UNEQUAL))
228 fprintf(out, "(");
229 print_sym(out, e->left.sym);
230 fprintf(out, "!=");
231 print_sym(out, e->right.sym);
232 if (token_gt(prevtoken, T_UNEQUAL))
233 fprintf(out, ")");
234 break;
235 case T_OR:
236 if (token_gt(prevtoken, T_OR))
237 fprintf(out, "(");
238 fprint_expr(out, e->left.expr, T_OR);
239 fprintf(out, " || ");
240 fprint_expr(out, e->right.expr, T_OR);
241 if (token_gt(prevtoken, T_OR))
242 fprintf(out, ")");
243 break;
244 case T_AND:
245 if (token_gt(prevtoken, T_AND))
246 fprintf(out, "(");
247 fprint_expr(out, e->left.expr, T_AND);
248 fprintf(out, " && ");
249 fprint_expr(out, e->right.expr, T_AND);
250 if (token_gt(prevtoken, T_AND))
251 fprintf(out, ")");
252 break;
253 case '|':
254 if (token_gt(prevtoken, '|'))
255 fprintf(out, "(");
256 fprint_expr(out, e->left.expr, '|');
257 fprintf(out, " || ");
258 fprint_expr(out, e->right.expr, '|');
259 if (token_gt(prevtoken, '|'))
260 fprintf(out, ")");
261 break;
262 case '&':
263 if (token_gt(prevtoken, '&'))
264 fprintf(out, "(");
265 fprint_expr(out, e->left.expr, '&');
266 if (print_type)
267 fprintf(out, " & ");
268 else
269 fprintf(out, " && ");
270 fprint_expr(out, e->right.expr, '&');
271 if (token_gt(prevtoken, '&'))
272 fprintf(out, ")");
273 break;
274 case '^':
275 if (e->left.expr) {
276 fprint_expr(out, e->left.expr, '^');
277 fprintf(out, " ^ ");
278 }
279 fprintf(out, "%s", e->right.sym->name);
280 break;
281 case T_IF:
282 if (token_gt(prevtoken, T_IF))
283 fprintf(out, "[");
284 if (e->right.expr) {
285 fprint_expr(out, e->right.expr, T_IF);
286 fprintf(out, " && ");
287 }
288 fprint_expr(out, e->left.expr, T_IF);
289 if (token_gt(prevtoken, T_IF))
290 fprintf(out, "]");
291 break;
292 case T_ELSE:
293 if (token_gt(prevtoken, T_ELSE))
294 fprintf(out, "[");
295 //fprintf(out, "[");
296 if (e->right.expr) {
297 fprint_expr(out, e->right.expr, T_ELSE);
298 fprintf(out, " && ");
299 }
300 fprintf(out, "!");
301 fprint_expr(out, e->left.expr, '!');
302 if (token_gt(prevtoken, T_ELSE))
303 fprintf(out, "]");
304 break;
305 default:
306 fprintf(out, "<unknown token %d>", e->token);
307 break;
308 }
309}
310
311void print_expr(int mask, struct expr *e, int prevtoken)
312{
313 if (!(cdebug & mask))
314 return;
315 fprint_expr(stdout, e, prevtoken);
316}
317
318struct file *lookup_file(const char *name)
319{
320 struct file *file;
321
322 for (file = file_list; file; file = file->next) {
323 if (!strcmp(name, file->name))
324 return file;
325 }
326
327 file = malloc(sizeof(*file));
328 memset(file, 0, sizeof(*file));
329 file->name = strdup(name);
330 file->next = file_list;
331 file_list = file;
332 return file;
333}
diff --git a/scripts/kconfig/extconf.rb b/scripts/kconfig/extconf.rb
new file mode 100644
index 0000000..051446d
--- a/dev/null
+++ b/scripts/kconfig/extconf.rb
@@ -0,0 +1,5 @@
1require 'mkmf'
2$CFLAGS = '-I..'
3$LDFLAGS = '-ldl'
4$objs = ["kconfig_wrap.o"]
5create_makefile 'kconfig'
diff --git a/scripts/kconfig/fixup-all.diff b/scripts/kconfig/fixup-all.diff
new file mode 100644
index 0000000..0844c98
--- a/dev/null
+++ b/scripts/kconfig/fixup-all.diff
@@ -0,0 +1,925 @@
1 --- ./arch/alpha/Kconfig.org2002-10-16 17:09:12.000000000 +0200
2 +++ ./arch/alpha/Kconfig2002-10-16 17:12:17.000000000 +0200
3@@ -791,10 +791,10 @@
4
5 endmenu
6
7-#if [ "$CONFIG_PCI" = "y" ]; then
8+if PCI
9 source "drivers/message/fusion/Kconfig"
10+endif
11
12-#fi
13 source "net/Kconfig"
14
15
16@@ -1046,5 +1046,3 @@
17
18 source "lib/Kconfig"
19
20-source "Kconfig"
21-
22 --- ./arch/arm/Kconfig.org2002-10-16 17:09:13.000000000 +0200
23 +++ ./arch/arm/Kconfig2002-10-16 17:12:17.000000000 +0200
24@@ -876,10 +876,10 @@
25
26 source "drivers/parport/Kconfig"
27
28-#if [ "$CONFIG_ALIGNMENT_TRAP" = "y" ]; then
29+if ALIGNMENT_TRAP
30 source "drivers/mtd/Kconfig"
31+endif
32
33-#else
34 source "drivers/pnp/Kconfig"
35
36 source "drivers/block/Kconfig"
37@@ -1233,5 +1233,3 @@
38
39 source "lib/Kconfig"
40
41-source "Kconfig"
42-
43 --- ./arch/cris/Kconfig.org2002-10-16 17:09:14.000000000 +0200
44 +++ ./arch/cris/Kconfig2002-10-16 17:12:17.000000000 +0200
45@@ -749,5 +749,3 @@
46
47 source "lib/Kconfig"
48
49-source "Kconfig"
50-
51 --- ./arch/i386/Kconfig.org2002-10-16 17:09:15.000000000 +0200
52 +++ ./arch/i386/Kconfig2002-10-16 17:12:17.000000000 +0200
53@@ -1430,7 +1430,8 @@
54 Read the file <file:Documentation/svga.txt> for more information
55 about the Video mode selection support. If unsure, say N.
56
57-#if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
58+if EXPERIMENTAL
59+
60 config MDA_CONSOLE
61 tristate "MDA text console (dual-headed) (EXPERIMENTAL)"
62 ---help---
63@@ -1449,7 +1450,8 @@
64
65 source "drivers/video/Kconfig"
66
67-#fi
68+endif
69+
70 endmenu
71
72
73@@ -1625,5 +1627,3 @@
74 bool
75 default y
76
77-source "Kconfig"
78-
79 --- ./arch/ia64/Kconfig.org2002-10-16 17:09:16.000000000 +0200
80 +++ ./arch/ia64/Kconfig2002-10-16 17:12:17.000000000 +0200
81@@ -120,43 +120,10 @@
82
83 choice
84 prompt "Kernel page size"
85 -depends on ITANIUM
86 -default IA64_PAGE_SIZE_16KB_1
87-
88-config IA64_PAGE_SIZE_4KB_1
89 -bool "4KB"
90-
91-config IA64_PAGE_SIZE_8KB_1
92 -bool "8KB"
93-
94-config IA64_PAGE_SIZE_16KB_1
95 -bool "16KB"
96-
97-endchoice
98-
99-choice
100 -prompt "Kernel page size"
101 -depends on !ITANIUM
102 -default IA64_PAGE_SIZE_16KB_2
103-
104-config IA64_PAGE_SIZE_4KB_2
105 -bool "4KB"
106-
107-config IA64_PAGE_SIZE_8KB_2
108 -bool "8KB"
109-
110-config IA64_PAGE_SIZE_16KB_2
111 -bool "16KB"
112-
113-config IA64_PAGE_SIZE_64KB
114 -bool "64KB"
115-
116-endchoice
117 +default IA64_PAGE_SIZE_16KB
118
119 config IA64_PAGE_SIZE_4KB
120 -bool
121 -depends on IA64_PAGE_SIZE_4KB_1 || IA64_PAGE_SIZE_4KB_2
122 -default y
123 +bool "4KB"
124 ---help---
125 This lets you select the page size of the kernel. For best IA-64
126 performance, a page size of 8KB or 16KB is recommended. For best
127@@ -173,14 +140,16 @@
128 If you don't know what to do, choose 8KB.
129
130 config IA64_PAGE_SIZE_8KB
131 -bool
132 -depends on IA64_PAGE_SIZE_8KB_1 || IA64_PAGE_SIZE_8KB_2
133 -default y
134 +bool "8KB"
135
136 config IA64_PAGE_SIZE_16KB
137 -bool
138 -depends on IA64_PAGE_SIZE_16KB_1 || IA64_PAGE_SIZE_16KB_2
139 -default y
140 +bool "16KB"
141+
142+config IA64_PAGE_SIZE_64KB
143 +depends on !ITANIUM
144 +bool "64KB"
145+
146+endchoice
147
148 config ACPI
149 bool
150@@ -403,87 +372,33 @@
151
152 choice
153 prompt "IA-64 Huge TLB Page Size"
154 -depends on HUGETLB_PAGE && MCKINLEY
155 -default HUGETLB_PAGE_SIZE_16MB_1
156 +depends on HUGETLB_PAGE
157 +default HUGETLB_PAGE_SIZE_16MB
158
159 config HUGETLB_PAGE_SIZE_4GB
160 +depends on MCKINLEY
161 bool "4GB"
162
163-config HUGETLB_PAGE_SIZE_256MB_1
164 -bool "256MB"
165-
166-config HUGETLB_PAGE_SIZE_64MB_1
167 -bool "64MB"
168-
169-config HUGETLB_PAGE_SIZE_16MB_1
170 -bool "16MB"
171-
172-config HUGETLB_PAGE_SIZE_4MB_1
173 -bool "4MB"
174-
175-config HUGETLB_PAGE_SIZE_1MB_1
176 -bool "1MB"
177-
178-config HUGETLB_PAGE_SIZE_256KB_1
179 -bool "256KB"
180-
181-endchoice
182-
183-choice
184 -prompt "IA-64 Huge TLB Page Size"
185 -depends on HUGETLB_PAGE && !MCKINLEY
186 -default HUGETLB_PAGE_SIZE_16MB_2
187-
188-config HUGETLB_PAGE_SIZE_256MB_2
189+config HUGETLB_PAGE_SIZE_256MB
190 bool "256MB"
191
192-config HUGETLB_PAGE_SIZE_64MB_2
193+config HUGETLB_PAGE_SIZE_64MB
194 bool "64MB"
195
196-config HUGETLB_PAGE_SIZE_16MB_2
197+config HUGETLB_PAGE_SIZE_16MB
198 bool "16MB"
199
200-config HUGETLB_PAGE_SIZE_4MB_2
201+config HUGETLB_PAGE_SIZE_4MB
202 bool "4MB"
203
204-config HUGETLB_PAGE_SIZE_1MB_2
205+config HUGETLB_PAGE_SIZE_1MB
206 bool "1MB"
207
208-config HUGETLB_PAGE_SIZE_256KB_2
209+config HUGETLB_PAGE_SIZE_256KB
210 bool "256KB"
211
212 endchoice
213
214-config HUGETLB_PAGE_SIZE_256MB
215 -bool
216 -depends on HUGETLB_PAGE_SIZE_256MB_1 || HUGETLB_PAGE_SIZE_256MB_2
217 -default y
218-
219-config HUGETLB_PAGE_SIZE_64MB
220 -bool
221 -depends on HUGETLB_PAGE_SIZE_64MB_1 || HUGETLB_PAGE_SIZE_64MB_2
222 -default y
223-
224-config HUGETLB_PAGE_SIZE_16MB
225 -bool
226 -depends on HUGETLB_PAGE_SIZE_16MB_1 || HUGETLB_PAGE_SIZE_16MB_2
227 -default y
228-
229-config HUGETLB_PAGE_SIZE_4MB
230 -bool
231 -depends on HUGETLB_PAGE_SIZE_4MB_1 || HUGETLB_PAGE_SIZE_4MB_2
232 -default y
233-
234-config HUGETLB_PAGE_SIZE_1MB
235 -bool
236 -depends on HUGETLB_PAGE_SIZE_1MB_1 || HUGETLB_PAGE_SIZE_1MB_2
237 -default y
238-
239-config HUGETLB_PAGE_SIZE_256KB
240 -bool
241 -depends on HUGETLB_PAGE_SIZE_256KB_1 || HUGETLB_PAGE_SIZE_256KB_2
242 -default y
243-
244 config SMP
245 bool "SMP support"
246 ---help---
247@@ -608,7 +523,8 @@
248 you have use for it; the module is called binfmt_misc.o. If you
249 don't know what to answer at this point, say Y.
250
251-#if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
252+if !IA64_HP_SIM
253+
254 source "drivers/acpi/Kconfig"
255
256 config PCI
257@@ -650,10 +566,12 @@
258
259 source "drivers/parport/Kconfig"
260
261-#fi # !HP_SIM
262+endif
263+
264 endmenu
265
266-#if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
267+if !IA64_HP_SIM
268+
269 source "drivers/mtd/Kconfig"
270
271 source "drivers/pnp/Kconfig"
272@@ -721,7 +639,8 @@
273
274 endmenu
275
276-#fi
277+endif
278+
279
280 menu "SCSI support"
281
282@@ -751,7 +670,8 @@
283
284 source "net/Kconfig"
285
286-#if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
287+
288+if !IA64_HP_SIM
289
290 menu "Network device support"
291 depends on NET
292@@ -841,7 +761,8 @@
293 #source drivers/misc/Config.in
294 source "drivers/media/Kconfig"
295
296-#else # HP_SIM
297+endif
298+
299
300 menu "Block devices"
301 depends on IA64_HP_SIM
302@@ -863,10 +784,10 @@
303
304 endmenu
305
306-# HP_SIM
307 source "fs/Kconfig"
308
309-#if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
310+if !IA64_HP_SIM
311+
312
313 menu "Console drivers"
314 depends on VT
315@@ -936,7 +857,8 @@
316
317 source "net/bluetooth/Kconfig"
318
319-#fi # !HP_SIM
320+endif
321+
322 source "arch/ia64/hp/sim/Kconfig"
323
324
325@@ -1058,5 +980,3 @@
326
327 source "security/Kconfig"
328
329-source "Kconfig"
330-
331 --- ./arch/m68k/Kconfig.org2002-10-16 17:09:18.000000000 +0200
332 +++ ./arch/m68k/Kconfig2002-10-16 17:12:17.000000000 +0200
333@@ -634,10 +634,10 @@
334
335 source "drivers/zorro/Kconfig"
336
337-#if [ "$CONFIG_Q40" = "y" ]; then
338+if Q40
339 source "drivers/pnp/Kconfig"
340+endif
341
342-#fi
343 endmenu
344
345 source "drivers/mtd/Kconfig"
346@@ -646,10 +646,10 @@
347
348 source "drivers/md/Kconfig"
349
350-#if [ "$CONFIG_MAC" = "y" ]; then
351+if MAC
352 source "drivers/input/Kconfig"
353+endif
354
355-#fi
356
357 menu "ATA/ATAPI/MFM/RLL device support"
358
359@@ -2382,5 +2382,3 @@
360
361 source "lib/Kconfig"
362
363-source "Kconfig"
364-
365 --- ./arch/mips/Kconfig.org2002-10-16 17:09:20.000000000 +0200
366 +++ ./arch/mips/Kconfig2002-10-16 17:12:17.000000000 +0200
367@@ -810,10 +810,11 @@
368 # fi
369 endmenu
370
371-#if [ "$CONFIG_ISA" = "y" ]; then
372+
373+if ISA
374 source "drivers/pnp/Kconfig"
375+endif
376
377-#fi
378 source "drivers/mtd/Kconfig"
379
380 source "drivers/parport/Kconfig"
381@@ -903,11 +904,11 @@
382
383 endmenu
384
385-#if [ "$CONFIG_DECSTATION" != "y" -a \
386-# "$CONFIG_SGI_IP22" != "y" ]; then
387+
388+if !DECSTATION" && !SGI_IP22
389 source "drivers/message/i2o/Kconfig"
390+endif
391
392-#fi
393 source "net/Kconfig"
394
395
396@@ -1200,7 +1201,8 @@
397
398 Say Y.
399
400-#if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
401+if EXPERIMENTAL
402+
403 config MDA_CONSOLE
404 tristate "MDA text console (dual-headed) (EXPERIMENTAL)"
405 ---help---
406@@ -1219,7 +1221,8 @@
407
408 source "drivers/video/Kconfig"
409
410-#fi
411+endif
412+
413 endmenu
414
415
416@@ -1333,5 +1336,3 @@
417
418 source "lib/Kconfig"
419
420-source "Kconfig"
421-
422 --- ./arch/mips64/Kconfig.org2002-10-16 17:09:22.000000000 +0200
423 +++ ./arch/mips64/Kconfig2002-10-16 17:12:17.000000000 +0200
424@@ -735,5 +735,3 @@
425
426 source "lib/Kconfig"
427
428-source "Kconfig"
429-
430 --- ./arch/parisc/Kconfig.org2002-10-16 17:09:22.000000000 +0200
431 +++ ./arch/parisc/Kconfig2002-10-16 17:12:17.000000000 +0200
432@@ -759,5 +759,3 @@
433
434 source "lib/Kconfig"
435
436-source "Kconfig"
437-
438 --- ./arch/ppc/Kconfig.org2002-10-16 17:09:23.000000000 +0200
439 +++ ./arch/ppc/Kconfig2002-10-16 17:12:17.000000000 +0200
440@@ -1826,5 +1826,3 @@
441
442 source "security/Kconfig"
443
444-source "Kconfig"
445-
446 --- ./arch/ppc64/Kconfig.org2002-10-16 17:09:24.000000000 +0200
447 +++ ./arch/ppc64/Kconfig2002-10-16 17:12:17.000000000 +0200
448@@ -525,5 +525,3 @@
449
450 source "lib/Kconfig"
451
452-source "Kconfig"
453-
454 --- ./arch/s390/Kconfig.org2002-10-16 17:09:25.000000000 +0200
455 +++ ./arch/s390/Kconfig2002-10-16 17:12:17.000000000 +0200
456@@ -318,5 +318,3 @@
457
458 source "lib/Kconfig"
459
460-source "Kconfig"
461-
462 --- ./arch/s390x/Kconfig.org2002-10-16 17:09:25.000000000 +0200
463 +++ ./arch/s390x/Kconfig2002-10-16 17:12:17.000000000 +0200
464@@ -326,5 +326,3 @@
465
466 source "lib/Kconfig"
467
468-source "Kconfig"
469-
470 --- ./arch/sh/Kconfig.org2002-10-16 17:09:25.000000000 +0200
471 +++ ./arch/sh/Kconfig2002-10-16 17:12:17.000000000 +0200
472@@ -1214,7 +1214,8 @@
473 Read the file <file:Documentation/svga.txt> for more information
474 about the Video mode selection support. If unsure, say N.
475
476-#if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
477+if EXPERIMENTAL
478+
479 config MDA_CONSOLE
480 tristate "MDA text console (dual-headed) (EXPERIMENTAL)"
481 ---help---
482@@ -1233,7 +1234,8 @@
483
484 source "drivers/video/Kconfig"
485
486-#fi
487+endif
488+
489 endmenu
490
491
492@@ -1319,5 +1321,3 @@
493
494 source "lib/Kconfig"
495
496-source "Kconfig"
497-
498 --- ./arch/sparc/Kconfig.org2002-10-16 17:09:28.000000000 +0200
499 +++ ./arch/sparc/Kconfig2002-10-16 17:12:17.000000000 +0200
500@@ -238,7 +238,8 @@
501 a kernel compiled with this option will run only on Sun4.
502 (And the current version will probably work only on sun4/330.)
503
504-#if [ "$CONFIG_SUN4" != "y" ]; then
505+if !SUN4
506+
507 config PCI
508 bool "Support for PCI and PS/2 keyboard/mouse"
509 help
510@@ -254,7 +255,8 @@
511
512 source "drivers/pci/Kconfig"
513
514-#else
515+endif
516+
517 config SUN_OPENPROMFS
518 tristate "Openprom tree appears in /proc/openprom"
519 help
520@@ -429,10 +431,10 @@
521
522 source "drivers/serial/Kconfig"
523
524-#if [ "$CONFIG_SUN4" != "y" ]; then
525+if !SUN4
526 source "drivers/sbus/char/Kconfig"
527+endif
528
529-#fi
530
531 menu "Block devices"
532
533@@ -575,7 +577,7 @@
534 endmenu
535
536 # Don't frighten a common SBus user
537-#if [ "$CONFIG_PCI" = "y" ]; then
538+if PCI
539
540 menu "ATA/ATAPI/MFM/RLL support"
541
542@@ -629,7 +631,8 @@
543
544 endmenu
545
546-#else
547+endif
548+
549 source "drivers/isdn/Kconfig"
550
551
552@@ -1419,5 +1422,3 @@
553
554 source "lib/Kconfig"
555
556-source "Kconfig"
557-
558 --- ./arch/sparc64/Kconfig.org2002-10-16 17:09:28.000000000 +0200
559 +++ ./arch/sparc64/Kconfig2002-10-16 17:12:17.000000000 +0200
560@@ -978,12 +978,58 @@
561 whenever you want). If you want to compile it as a module, say M
562 here and read <file:Documentation/modules.txt>.
563
564-#if [ "$CONFIG_PCI" != "n" ]; then
565+
566+choice
567 +prompt "Adaptec AIC7xxx support"
568 +optional
569 +depends on SCSI && PCI
570+
571 source "drivers/scsi/aic7xxx/Kconfig"
572
573+config SCSI_AIC7XXX_OLD
574 +tristate "Old driver"
575 +---help---
576 + WARNING This driver is an older aic7xxx driver and is no longer
577 + under active development. Adaptec, Inc. is writing a new driver to
578 + take the place of this one, and it is recommended that whenever
579 + possible, people should use the new Adaptec written driver instead
580 + of this one. This driver will eventually be phased out entirely.
581+
582 + This is support for the various aic7xxx based Adaptec SCSI
583 + controllers. These include the 274x EISA cards; 284x VLB cards;
584 + 2902, 2910, 293x, 294x, 394x, 3985 and several other PCI and
585 + motherboard based SCSI controllers from Adaptec. It does not support
586 + the AAA-13x RAID controllers from Adaptec, nor will it likely ever
587 + support them. It does not support the 2920 cards from Adaptec that
588 + use the Future Domain SCSI controller chip. For those cards, you
589 + need the "Future Domain 16xx SCSI support" driver.
590+
591 + In general, if the controller is based on an Adaptec SCSI controller
592 + chip from the aic777x series or the aic78xx series, this driver
593 + should work. The only exception is the 7810 which is specifically
594 + not supported (that's the RAID controller chip on the AAA-13x
595 + cards).
596+
597 + Note that the AHA2920 SCSI host adapter is *not* supported by this
598 + driver; choose "Future Domain 16xx SCSI support" instead if you have
599 + one of those.
600+
601 + Information on the configuration options for this controller can be
602 + found by checking the help file for each of the available
603 + configuration options. You should read
604 + <file:drivers/scsi/aic7xxx_old/README.aic7xxx> at a minimum before
605 + contacting the maintainer with any questions. The SCSI-HOWTO,
606 + available from <http://www.linuxdoc.org/docs.html#howto>, can also
607 + be of great help.
608+
609 + If you want to compile this driver as a module ( = code which can be
610 + inserted in and removed from the running kernel whenever you want),
611 + say M here and read <file:Documentation/modules.txt>. The module
612 + will be called aic7xxx_old.o.
613+
614 config AIC7XXX_OLD_TCQ_ON_BY_DEFAULT
615 bool "Enable Tagged Command Queueing (TCQ) by default"
616 -depends on SCSI_AIC7XXX!=y && SCSI_AIC7XXX_OLD
617 +depends on SCSI_AIC7XXX_OLD
618 ---help---
619 This option causes the aic7xxx driver to attempt to use Tagged
620 Command Queueing (TCQ) on all devices that claim to support it.
621@@ -1019,7 +1065,7 @@
622
623 config AIC7XXX_OLD_CMDS_PER_DEVICE
624 int "Maximum number of TCQ commands per device"
625 -depends on SCSI_AIC7XXX!=y && SCSI_AIC7XXX_OLD
626 +depends on SCSI_AIC7XXX_OLD
627 default "8"
628 ---help---
629 Specify the number of commands you would like to allocate per SCSI
630@@ -1043,7 +1089,7 @@
631
632 config AIC7XXX_OLD_PROC_STATS
633 bool "Collect statistics to report in /proc"
634 -depends on SCSI_AIC7XXX!=y && SCSI_AIC7XXX_OLD
635 +depends on SCSI_AIC7XXX_OLD
636 ---help---
637 This option tells the driver to keep track of how many commands have
638 been sent to each particular device and report that information to
639@@ -1056,6 +1102,8 @@
640
641 If unsure, say N.
642
643+endchoice
644+
645 config SCSI_SYM53C8XX_2
646 tristate "SYM53C8XX Version 2 SCSI support"
647 depends on PCI && SCSI
648@@ -1346,10 +1394,10 @@
649
650 source "drivers/fc4/Kconfig"
651
652-#if [ "$CONFIG_PCI" = "y" ]; then
653+if PCI
654 source "drivers/message/fusion/Kconfig"
655+endif
656
657-#fi
658 source "drivers/ieee1394/Kconfig"
659
660 source "net/Kconfig"
661@@ -1651,5 +1699,3 @@
662
663 source "lib/Kconfig"
664
665-source "Kconfig"
666-
667 --- ./arch/x86_64/Kconfig.org2002-10-16 17:09:29.000000000 +0200
668 +++ ./arch/x86_64/Kconfig2002-10-16 17:12:17.000000000 +0200
669@@ -592,7 +592,8 @@
670 Read the file <file:Documentation/svga.txt> for more information
671 about the Video mode selection support. If unsure, say N.
672
673-#if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
674+if EXPERIMENTAL
675+
676 config MDA_CONSOLE
677 tristate "MDA text console (dual-headed) (EXPERIMENTAL)"
678 ---help---
679@@ -611,7 +612,8 @@
680
681 source "drivers/video/Kconfig"
682
683-#fi
684+endif
685+
686 endmenu
687
688
689@@ -713,5 +715,3 @@
690
691 source "lib/Kconfig"
692
693-source "Kconfig"
694-
695 --- ./arch/um/Kconfig.org2002-10-16 17:09:29.000000000 +0200
696 +++ ./arch/um/Kconfig2002-10-16 17:12:17.000000000 +0200
697@@ -163,5 +163,3 @@
698
699 endmenu
700
701-source "Kconfig"
702-
703 --- ./drivers/isdn/eicon/Kconfig.org2002-10-16 17:09:15.000000000 +0200
704 +++ ./drivers/isdn/eicon/Kconfig2002-10-16 17:12:17.000000000 +0200
705@@ -11,12 +11,12 @@
706 <file:Documentation/isdn/README.eicon> for more information.
707
708 choice
709 -prompt "change me!"
710 +prompt "Eicon active card support"
711 optional
712 depends on ISDN_DRV_EICON && ISDN
713
714 config ISDN_DRV_EICON_DIVAS
715 -tristate "Build Eicon driver type standalone"
716 +tristate "Eicon driver"
717 depends on PCI
718 help
719 Enable this option if you want the eicon driver as standalone
720@@ -26,16 +26,14 @@
721 here.
722
723 config ISDN_DRV_EICON_OLD
724 -tristate "Legacy Eicon driver"
725 +tristate "Legacy driver"
726 help
727 Say Y here to use your Eicon active ISDN card with ISDN4Linux
728 isdn module.
729
730-endchoice
731-
732 config ISDN_DRV_EICON_PCI
733 bool "Eicon PCI DIVA Server BRI/PRI/4BRI support"
734 -depends on ISDN_DRV_EICON_DIVAS!=y && ISDN_DRV_EICON_OLD && PCI
735 +depends on ISDN_DRV_EICON_OLD && PCI
736 help
737 Say Y here if you have an Eicon Diva Server (BRI/PRI/4BRI) ISDN
738 card. Please read <file:Documentation/isdn/README.eicon> for more
739@@ -43,7 +41,7 @@
740
741 config ISDN_DRV_EICON_ISA
742 bool "Eicon S,SX,SCOM,Quadro,S2M support"
743 -depends on ISDN_DRV_EICON_DIVAS!=y && ISDN_DRV_EICON_OLD
744 +depends on ISDN_DRV_EICON_OLD
745 help
746 Say Y here if you have an old-type Eicon active ISDN card. In order
747 to use this card, additional firmware is necessary, which has to be
748@@ -51,3 +49,5 @@
749 the latest isdn4k-utils package. Please read the file
750 <file:Documentation/isdn/README.eicon> for more information.
751
752+endchoice
753+
754 --- ./drivers/scsi/aic7xxx/Kconfig.org2002-10-16 17:09:15.000000000 +0200
755 +++ ./drivers/scsi/aic7xxx/Kconfig2002-10-16 17:12:17.000000000 +0200
756@@ -1,51 +1,5 @@
757-choice
758 -prompt "change me!"
759 -optional
760 -depends on SCSI
761-
762-config SCSI_AIC7XXX_OLD
763 -tristate "Old Adaptec AIC7xxx support"
764 ----help---
765 - WARNING This driver is an older aic7xxx driver and is no longer
766 - under active development. Adaptec, Inc. is writing a new driver to
767 - take the place of this one, and it is recommended that whenever
768 - possible, people should use the new Adaptec written driver instead
769 - of this one. This driver will eventually be phased out entirely.
770-
771 - This is support for the various aic7xxx based Adaptec SCSI
772 - controllers. These include the 274x EISA cards; 284x VLB cards;
773 - 2902, 2910, 293x, 294x, 394x, 3985 and several other PCI and
774 - motherboard based SCSI controllers from Adaptec. It does not support
775 - the AAA-13x RAID controllers from Adaptec, nor will it likely ever
776 - support them. It does not support the 2920 cards from Adaptec that
777 - use the Future Domain SCSI controller chip. For those cards, you
778 - need the "Future Domain 16xx SCSI support" driver.
779-
780 - In general, if the controller is based on an Adaptec SCSI controller
781 - chip from the aic777x series or the aic78xx series, this driver
782 - should work. The only exception is the 7810 which is specifically
783 - not supported (that's the RAID controller chip on the AAA-13x
784 - cards).
785-
786 - Note that the AHA2920 SCSI host adapter is *not* supported by this
787 - driver; choose "Future Domain 16xx SCSI support" instead if you have
788 - one of those.
789-
790 - Information on the configuration options for this controller can be
791 - found by checking the help file for each of the available
792 - configuration options. You should read
793 - <file:drivers/scsi/aic7xxx_old/README.aic7xxx> at a minimum before
794 - contacting the maintainer with any questions. The SCSI-HOWTO,
795 - available from <http://www.linuxdoc.org/docs.html#howto>, can also
796 - be of great help.
797-
798 - If you want to compile this driver as a module ( = code which can be
799 - inserted in and removed from the running kernel whenever you want),
800 - say M here and read <file:Documentation/modules.txt>. The module
801 - will be called aic7xxx_old.o.
802-
803 config SCSI_AIC7XXX
804 -tristate "Adaptec AIC7xxx support"
805 +tristate "New driver"
806 help
807 This driver supports all of Adaptec's PCI based SCSI controllers
808 (not the hardware RAID controllers though) as well as the aic7770
809@@ -54,11 +8,10 @@
810 intended to replace the previous aic7xxx driver maintained by Doug
811 Ledford since Doug is no longer maintaining that driver.
812
813-endchoice
814
815 config AIC7XXX_CMDS_PER_DEVICE
816 int "Maximum number of TCQ commands per device"
817 -depends on SCSI_AIC7XXX_OLD!=y && SCSI_AIC7XXX
818 +depends on SCSI_AIC7XXX
819 default "253"
820 ---help---
821 Specify the number of commands you would like to allocate per SCSI
822@@ -77,7 +30,7 @@
823
824 config AIC7XXX_RESET_DELAY_MS
825 int "Initial bus reset delay in milli-seconds"
826 -depends on SCSI_AIC7XXX_OLD!=y && SCSI_AIC7XXX
827 +depends on SCSI_AIC7XXX
828 default "15000"
829 help
830 The number of milliseconds to delay after an initial bus reset.
831@@ -88,7 +41,7 @@
832
833 config AIC7XXX_BUILD_FIRMWARE
834 bool "Build Adapter Firmware with Kernel Build"
835 -depends on SCSI_AIC7XXX_OLD!=y && SCSI_AIC7XXX
836 +depends on SCSI_AIC7XXX
837 help
838 This option should only be enabled if you are modifying the firmware
839 source to the aic7xxx driver and wish to have the generated firmware
840 --- ./drivers/scsi/Kconfig.org2002-10-16 17:09:15.000000000 +0200
841 +++ ./drivers/scsi/Kconfig2002-10-16 17:12:17.000000000 +0200
842@@ -311,8 +311,57 @@
843 tristate "Adaptec AACRAID support (EXPERIMENTAL)"
844 depends on EXPERIMENTAL && SCSI && PCI
845
846+choice
847 +prompt "Adaptec AIC7xxx support"
848 +optional
849 +depends on SCSI
850+
851 source "drivers/scsi/aic7xxx/Kconfig"
852
853+config SCSI_AIC7XXX_OLD
854 +tristate "Old driver"
855 +help
856 + WARNING This driver is an older aic7xxx driver and is no longer
857 + under active development. Adaptec, Inc. is writing a new driver to
858 + take the place of this one, and it is recommended that whenever
859 + possible, people should use the new Adaptec written driver instead
860 + of this one. This driver will eventually be phased out entirely.
861+
862 + This is support for the various aic7xxx based Adaptec SCSI
863 + controllers. These include the 274x EISA cards; 284x VLB cards;
864 + 2902, 2910, 293x, 294x, 394x, 3985 and several other PCI and
865 + motherboard based SCSI controllers from Adaptec. It does not support
866 + the AAA-13x RAID controllers from Adaptec, nor will it likely ever
867 + support them. It does not support the 2920 cards from Adaptec that
868 + use the Future Domain SCSI controller chip. For those cards, you
869 + need the "Future Domain 16xx SCSI support" driver.
870+
871 + In general, if the controller is based on an Adaptec SCSI controller
872 + chip from the aic777x series or the aic78xx series, this driver
873 + should work. The only exception is the 7810 which is specifically
874 + not supported (that's the RAID controller chip on the AAA-13x
875 + cards).
876+
877 + Note that the AHA2920 SCSI host adapter is *not* supported by this
878 + driver; choose "Future Domain 16xx SCSI support" instead if you have
879 + one of those.
880+
881 + Information on the configuration options for this controller can be
882 + found by checking the help file for each of the available
883 + configuration options. You should read
884 + <file:drivers/scsi/aic7xxx_old/README.aic7xxx> at a minimum before
885 + contacting the maintainer with any questions. The SCSI-HOWTO,
886 + available from <http://www.linuxdoc.org/docs.html#howto>, can also
887 + be of great help.
888+
889 + If you want to compile this driver as a module ( = code which can be
890 + inserted in and removed from the running kernel whenever you want),
891 + say M here and read <file:Documentation/modules.txt>. The module
892 + will be called aic7xxx_old.o.
893+
894+endchoice
895+
896+
897 # All the I2O code and drivers do not seem to be 64bit safe.
898 config SCSI_DPT_I2O
899 tristate "Adaptec I2O RAID support "
900 --- ./sound/oss/Kconfig.org2002-10-16 17:09:15.000000000 +0200
901 +++ ./sound/oss/Kconfig2002-10-16 17:12:17.000000000 +0200
902@@ -1023,12 +1023,12 @@
903 DSP 16 card.
904
905 choice
906 -prompt "change me!"
907 +prompt "Audio Excel DSP 16"
908 optional
909 depends on SOUND_AEDSP16
910
911 config AEDSP16_MSS
912 -bool "Audio Excel DSP 16 (MSS emulation)"
913 +bool "MSS emulation"
914 depends on SOUND_MSS
915 help
916 Answer Y if you want your audio card to emulate Microsoft Sound
917@@ -1036,7 +1036,7 @@
918 and say N to "Audio Excel DSP 16 (SBPro emulation)".
919
920 config AEDSP16_SBPRO
921 -bool "Audio Excel DSP 16 (SBPro emulation)"
922 +bool "SBPro emulation"
923 depends on SOUND_SB
924 help
925 Answer Y if you want your audio card to emulate Sound Blaster Pro.
diff --git a/scripts/kconfig/help.l b/scripts/kconfig/help.l
new file mode 100644
index 0000000..5ac4c2f
--- a/dev/null
+++ b/scripts/kconfig/help.l
@@ -0,0 +1,78 @@
1%option nounput nostdinit noyywrap 8bit
2%x ENTRY
3%{
4/*
5 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
6 * Released under the terms of the GNU GPL v2.0.
7 */
8
9#include <string.h>
10#include <unistd.h>
11#include "cml1.h"
12
13#define YY_DECL void helplex(char *help)
14#undef YY_NULL
15#define YY_NULL
16%}
17
18%%
19 struct symbol *sym = NULL;
20 helpin = fopen(help, "r");
21 if (!helpin)
22 return;
23 //help_flex_debug = 1;
24 yyrestart(helpin);
25 BEGIN(INITIAL);
26
27 ^#.*\n/* skip */
28
29^CONFIG_[[:alnum:]_]+ {
30 char name[256];
31 int ch;
32 while ((ch = input()) != '\n' && ch != EOF)
33 ;
34 memcpy(name, yytext, yyleng);
35 name[yyleng] = 0;
36 sym = lookup_symbol(name, SYMBOL_UNKNOWN);
37 new_string();
38 BEGIN(ENTRY);
39}
40
41<ENTRY>{
42 [ \t].*\n+/[^ \t\n] |
43 <<EOF>> {
44 append_string(yytext, yyleng);
45 if (sym) {
46 if (sym->help) {
47 //printf("symbol %s has duplicated help?\n", sym->name);
48 free(text);
49 } else
50 sym->help = text;
51 sym = NULL;
52 } else
53 printf("no symbol?\n");
54 BEGIN(INITIAL);
55 }
56 \n/[^ \t\n] {
57 append_string(yytext, yyleng);
58 if (sym) {
59 if (sym->help) {
60 //printf("symbol %s has duplicated help?\n", sym->name);
61 free(text);
62 } else
63 sym->help = text;
64 sym = NULL;
65 } else
66 printf("no symbol?\n");
67 BEGIN(INITIAL);
68 }
69 [ \t].*\n |
70 .|
71 \n{
72 append_string(yytext, yyleng);
73 }
74}
75
76.
77\n
78%%
diff --git a/scripts/kconfig/images.c b/scripts/kconfig/images.c
new file mode 100644
index 0000000..65a5d67
--- a/dev/null
+++ b/scripts/kconfig/images.c
@@ -0,0 +1,292 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6static const char *xpm_load[] = {
7"22 22 5 1",
8". c None",
9"# c #000000",
10"c c #838100",
11"a c #ffff00",
12"b c #ffffff",
13"......................",
14"......................",
15"......................",
16"............####....#.",
17"...........#....##.##.",
18"..................###.",
19".................####.",
20".####...........#####.",
21"#abab##########.......",
22"#babababababab#.......",
23"#ababababababa#.......",
24"#babababababab#.......",
25"#ababab###############",
26"#babab##cccccccccccc##",
27"#abab##cccccccccccc##.",
28"#bab##cccccccccccc##..",
29"#ab##cccccccccccc##...",
30"#b##cccccccccccc##....",
31"###cccccccccccc##.....",
32"##cccccccccccc##......",
33"###############.......",
34"......................"};
35
36static const char *xpm_save[] = {
37"22 22 5 1",
38". c None",
39"# c #000000",
40"a c #838100",
41"b c #c5c2c5",
42"c c #cdb6d5",
43"......................",
44".####################.",
45".#aa#bbbbbbbbbbbb#bb#.",
46".#aa#bbbbbbbbbbbb#bb#.",
47".#aa#bbbbbbbbbcbb####.",
48".#aa#bbbccbbbbbbb#aa#.",
49".#aa#bbbccbbbbbbb#aa#.",
50".#aa#bbbbbbbbbbbb#aa#.",
51".#aa#bbbbbbbbbbbb#aa#.",
52".#aa#bbbbbbbbbbbb#aa#.",
53".#aa#bbbbbbbbbbbb#aa#.",
54".#aaa############aaa#.",
55".#aaaaaaaaaaaaaaaaaa#.",
56".#aaaaaaaaaaaaaaaaaa#.",
57".#aaa#############aa#.",
58".#aaa#########bbb#aa#.",
59".#aaa#########bbb#aa#.",
60".#aaa#########bbb#aa#.",
61".#aaa#########bbb#aa#.",
62".#aaa#########bbb#aa#.",
63"..##################..",
64"......................"};
65
66static const char *xpm_back[] = {
67"22 22 3 1",
68". c None",
69"# c #000083",
70"a c #838183",
71"......................",
72"......................",
73"......................",
74"......................",
75"......................",
76"...........######a....",
77"..#......##########...",
78"..##...####......##a..",
79"..###.###.........##..",
80"..######..........##..",
81"..#####...........##..",
82"..######..........##..",
83"..#######.........##..",
84"..########.......##a..",
85"...............a###...",
86"...............###....",
87"......................",
88"......................",
89"......................",
90"......................",
91"......................",
92"......................"};
93
94static const char *xpm_tree_view[] = {
95"22 22 2 1",
96". c None",
97"# c #000000",
98"......................",
99"......................",
100"......#...............",
101"......#...............",
102"......#...............",
103"......#...............",
104"......#...............",
105"......########........",
106"......#...............",
107"......#...............",
108"......#...............",
109"......#...............",
110"......#...............",
111"......########........",
112"......#...............",
113"......#...............",
114"......#...............",
115"......#...............",
116"......#...............",
117"......########........",
118"......................",
119"......................"};
120
121static const char *xpm_single_view[] = {
122"22 22 2 1",
123". c None",
124"# c #000000",
125"......................",
126"......................",
127"..........#...........",
128"..........#...........",
129"..........#...........",
130"..........#...........",
131"..........#...........",
132"..........#...........",
133"..........#...........",
134"..........#...........",
135"..........#...........",
136"..........#...........",
137"..........#...........",
138"..........#...........",
139"..........#...........",
140"..........#...........",
141"..........#...........",
142"..........#...........",
143"..........#...........",
144"..........#...........",
145"......................",
146"......................"};
147
148static const char *xpm_split_view[] = {
149"22 22 2 1",
150". c None",
151"# c #000000",
152"......................",
153"......................",
154"......#......#........",
155"......#......#........",
156"......#......#........",
157"......#......#........",
158"......#......#........",
159"......#......#........",
160"......#......#........",
161"......#......#........",
162"......#......#........",
163"......#......#........",
164"......#......#........",
165"......#......#........",
166"......#......#........",
167"......#......#........",
168"......#......#........",
169"......#......#........",
170"......#......#........",
171"......#......#........",
172"......................",
173"......................"};
174
175static const char *xpm_symbol_no[] = {
176"12 12 2 1",
177" c white",
178". c black",
179" ",
180" .......... ",
181" . . ",
182" . . ",
183" . . ",
184" . . ",
185" . . ",
186" . . ",
187" . . ",
188" . . ",
189" .......... ",
190" "};
191
192static const char *xpm_symbol_mod[] = {
193"12 12 2 1",
194" c white",
195". c black",
196" ",
197" .......... ",
198" . . ",
199" . . ",
200" . .. . ",
201" . .... . ",
202" . .... . ",
203" . .. . ",
204" . . ",
205" . . ",
206" .......... ",
207" "};
208
209static const char *xpm_symbol_yes[] = {
210"12 12 2 1",
211" c white",
212". c black",
213" ",
214" .......... ",
215" . . ",
216" . . ",
217" . . . ",
218" . .. . ",
219" . . .. . ",
220" . .... . ",
221" . .. . ",
222" . . ",
223" .......... ",
224" "};
225
226static const char *xpm_choice_no[] = {
227"12 12 2 1",
228" c white",
229". c black",
230" ",
231" .... ",
232" .. .. ",
233" . . ",
234" . . ",
235" . . ",
236" . . ",
237" . . ",
238" . . ",
239" .. .. ",
240" .... ",
241" "};
242
243static const char *xpm_choice_yes[] = {
244"12 12 2 1",
245" c white",
246". c black",
247" ",
248" .... ",
249" .. .. ",
250" . . ",
251" . .. . ",
252" . .... . ",
253" . .... . ",
254" . .. . ",
255" . . ",
256" .. .. ",
257" .... ",
258" "};
259
260static const char *xpm_menu[] = {
261"12 12 2 1",
262" c white",
263". c black",
264" ",
265" .......... ",
266" . . ",
267" . .. . ",
268" . .... . ",
269" . ...... . ",
270" . ...... . ",
271" . .... . ",
272" . .. . ",
273" . . ",
274" .......... ",
275" "};
276
277static const char *xpm_menu_inv[] = {
278"12 12 2 1",
279" c white",
280". c black",
281" ",
282" .......... ",
283" .......... ",
284" .. ...... ",
285" .. .... ",
286" .. .. ",
287" .. .. ",
288" .. .... ",
289" .. ...... ",
290" .......... ",
291" .......... ",
292" "};
diff --git a/scripts/kconfig/kconfig.i b/scripts/kconfig/kconfig.i
new file mode 100644
index 0000000..699cb13
--- a/dev/null
+++ b/scripts/kconfig/kconfig.i
@@ -0,0 +1,133 @@
1%module kconfig
2%{
3#include "kconfig_load.c"
4%}
5
6%init %{
7 kconfig_load();
8%}
9
10%nodefault;
11
12#ifdef SWIGRUBY
13%typemap (out) char * {
14 if ($1 == NULL)
15 $result = Qnil;
16 else
17 $result = rb_str_new2($1);
18}
19%typemap (in) char * {
20 if ($input == Qnil)
21 $1 = NULL;
22 else
23 $1 = STR2CSTR($input);
24}
25
26%{
27static void expr_to_s_help(void *data, const char *str)
28{
29 rb_str_cat((VALUE)data, str, strlen(str));
30}
31%}
32#endif
33
34%immutable;
35%include "expr.h"
36#define P(name,type,arg) extern type name arg
37%include "lkc_proto.h"
38%mutable;
39
40#ifdef SWIGRUBY
41%predicate menu::isVisible;
42%predicate symbol::isChangable;
43%predicate symbol::isChoice;
44%predicate symbol::isChoiceValue;
45#endif
46
47%extend menu {
48 bool isVisible(void) {
49 return menu_is_visible(self);
50 }
51#ifdef SWIGRUBY
52 void each(void) {
53 struct menu *child;
54 for (child = self->list; child; child = child->next)
55 rb_yield(SWIG_NewPointerObj(child, SWIGTYPE_p_menu, 0));
56 }
57 static void each_menu(void) {
58 struct menu *child;
59 for (child = rootmenu.list; child; child = child->next)
60 rb_yield(SWIG_NewPointerObj(child, SWIGTYPE_p_menu, 0));
61 }
62#endif
63}
64
65%extend symbol {
66 void calc_value(void) {
67 sym_calc_value(self);
68 }
69 tristate set_tristate(tristate val) {
70 return sym_set_tristate_value(self, val);
71 }
72 bool set_string(char *val) {
73 return sym_set_string_value(self, val);
74 }
75 const char *get_string(void) {
76 return sym_get_string_value(self);
77 }
78 bool isChangable(void) {
79 return sym_is_changable(self);
80 }
81 bool isChoice(void) {
82 return sym_is_choice(self);
83 }
84 bool isChoiceValue(void) {
85 return sym_is_choice_value(self);
86 }
87 static struct symbol *lookup(const char *name) {
88 return sym_lookup(name, 0);
89 }
90 static struct symbol *find(const char *name) {
91 return sym_find(name);
92 }
93 static const char *type_name(enum symbol_type type) {
94 return sym_type_name(type);
95 }
96#ifdef SWIGRUBY
97 void each(void) {
98 struct property *prop;
99 for (prop = self->prop; prop; prop = prop->next)
100 rb_yield(SWIG_NewPointerObj(prop, SWIGTYPE_p_property, 0));
101 }
102 static void each_sym(void) {
103 struct symbol *sym;
104 int i;
105 for (i = 0; i < SYMBOL_HASHSIZE; i++) {
106 for (sym = symbol_hash[i]; sym; sym = sym->next) {
107 if (sym->flags & SYMBOL_CONST)
108 continue;
109 rb_yield(SWIG_NewPointerObj(sym, SWIGTYPE_p_symbol, 0));
110 }
111 }
112 }
113#endif
114}
115
116%extend property {
117 static const char *type_name(enum prop_type type) {
118 return prop_get_type_name(type);
119 }
120}
121
122%extend expr {
123 static int comp_type(enum expr_type t1, enum expr_type t2) {
124 return expr_compare_type(t1, t2);
125 }
126#ifdef SWIGRUBY
127 VALUE __str__(void) {
128 VALUE str = rb_str_new2("");
129 expr_print(self, expr_to_s_help, (void*)str, E_NONE);
130 return str;
131 }
132#endif
133}
diff --git a/scripts/kconfig/kconfig_load.c b/scripts/kconfig/kconfig_load.c
new file mode 100644
index 0000000..dbdcaad
--- a/dev/null
+++ b/scripts/kconfig/kconfig_load.c
@@ -0,0 +1,35 @@
1#include <dlfcn.h>
2#include <stdio.h>
3#include <stdlib.h>
4
5#include "lkc.h"
6
7 #define P(name,type,arg)type (*name ## _p) arg
8#include "lkc_proto.h"
9#undef P
10
11void kconfig_load(void)
12{
13 void *handle;
14 char *error;
15
16 handle = dlopen("./libkconfig.so", RTLD_LAZY);
17 if (!handle) {
18 handle = dlopen("./scripts/kconfig/libkconfig.so", RTLD_LAZY);
19 if (!handle) {
20 fprintf(stderr, "%s\n", dlerror());
21 exit(1);
22 }
23 }
24
25 #define P(name,type,arg) \
26 { \
27 name ## _p = dlsym(handle, #name);\
28 if ((error = dlerror())) { \
29 fprintf(stderr, "%s\n", error);\
30 exit(1); \
31 } \
32}
33#include "lkc_proto.h"
34#undef P
35}
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
new file mode 100644
index 0000000..688945b
--- a/dev/null
+++ b/scripts/kconfig/lkc.h
@@ -0,0 +1,106 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#ifndef LKC_H
7#define LKC_H
8
9#include "expr.h"
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#ifdef LKC_DIRECT_LINK
16 #define P(name,type,arg)extern type name arg
17#else
18#include "lkc_defs.h"
19 #define P(name,type,arg)extern type (*name ## _p) arg
20#endif
21#include "lkc_proto.h"
22#undef P
23
24void symbol_end(char *help);
25int zconfparse(void);
26void zconfdump(FILE *out);
27
28extern int zconfdebug;
29void zconf_starthelp(void);
30void zconf_initscan(const char *name);
31void zconf_nextfile(const char *name);
32int zconf_lineno(void);
33char *zconf_curname(void);
34
35/* confdata.c */
36extern const char conf_def_filename[];
37extern char conf_filename[];
38
39char *conf_get_default_confname(void);
40
41/* kconfig_load.c */
42void kconfig_load(void);
43
44/* menu.c */
45void menu_init(void);
46void menu_add_menu(void);
47void menu_end_menu(void);
48void menu_add_entry(struct symbol *sym);
49void menu_end_entry(void);
50struct property *create_prop(enum prop_type type);
51void menu_add_dep(struct expr *dep);
52struct property *menu_add_prop(int token, char *prompt, struct symbol *def, struct expr *dep);
53void menu_finalize(struct menu *parent);
54void menu_set_type(int type);
55struct file *file_lookup(const char *name);
56int file_write_dep(const char *name);
57
58extern struct menu *current_entry;
59extern struct menu *current_menu;
60
61/* symbol.c */
62void sym_init(void);
63void sym_clear_all_valid(void);
64
65static inline tristate sym_get_tristate_value(struct symbol *sym)
66{
67 return S_TRI(sym->curr);
68}
69
70
71static inline struct symbol *sym_get_choice_value(struct symbol *sym)
72{
73 return (struct symbol *)S_VAL(sym->curr);
74}
75
76static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
77{
78 return sym_set_tristate_value(chval, yes);
79}
80
81static inline bool sym_is_choice(struct symbol *sym)
82{
83 return sym->flags & SYMBOL_CHOICE ? true : false;
84}
85
86static inline bool sym_is_choice_value(struct symbol *sym)
87{
88 return sym->flags & SYMBOL_CHOICEVAL ? true : false;
89}
90
91static inline bool sym_is_optional(struct symbol *sym)
92{
93 return sym->flags & SYMBOL_OPTIONAL ? true : false;
94}
95
96static inline bool sym_has_value(struct symbol *sym)
97{
98 //return S_VAL(sym->def) != NULL;
99 return sym->flags & SYMBOL_NEW ? false : true;
100}
101
102#ifdef __cplusplus
103}
104#endif
105
106#endif /* LKC_H */
diff --git a/scripts/kconfig/lkc_overview b/scripts/kconfig/lkc_overview
new file mode 100644
index 0000000..e9db60e
--- a/dev/null
+++ b/scripts/kconfig/lkc_overview
@@ -0,0 +1,111 @@
1Introduction
2------------
3
4The configuration database is collection of configuration options
5organized in a tree structure:
6
7 +- Code maturity level options
8 | +- Prompt for development and/or incomplete code/drivers
9 +- General setup
10 | +- Networking support
11 | +- System V IPC
12 | +- BSD Process Accounting
13 | +- Sysctl support
14 +- Loadable module support
15 | +- Enable loadable module support
16 | +- Set version information on all module symbols
17 | +- Kernel module loader
18 +- ...
19
20Every entry has its own dependencies. These dependencies are used
21to determine the visible of an entry. Any child entry is only
22visible if its parent entry is also visible.
23
24Menu entries
25------------
26
27A single configuration option is defined like this:
28
29config MODVERSIONS
30 bool "Set version information on all module symbols"
31 depends MODULES
32 help
33 Usually, modules have to be recompiled whenever you switch to a new
34 kernel. ...
35
36Every line starts with a key word and can be followed by multiple arguments.
37"config" starts a new config entry. The following lines define attributes
38for this config option. Attributes can be the type of the config option,
39input prompt, dependencies, help text and default values. A config option
40can be defined multiple times, but every definition can have only a single
41input prompt and the type must not conflict.
42
43Menu dependencies
44-----------------
45
46Dependencies define the visibility of a menu entry. When a dependency
47exprecession evaluates not to 'n', the entry is visible. Additionally
48the dependency limits the input range of tristate choice symbols.
49
50Menu structure
51--------------
52
53The position of a menu entry in the tree is determined in two ways. First
54it can be specified explicitely:
55
56menu "Network device support"
57 depends NET
58
59config NETDEVICES
60 ...
61
62endmenu
63
64All entries within the "menu" ... "endmenu" block become a submenu of
65"Processor type and features". All subentries have the same dependencies
66than the menu entry, e.g. this means the dependency "NET" is added to the
67dependencies of the option NETDEVICES.
68The other way to generate the menu structure is done by analyzing the
69dependencies. If a menu entry somehow depends on the previous entry, it
70can be made a submenu of it.
71
72config MODULES
73 bool "Enable loadable module support"
74
75config MODVERSIONS
76 bool "Set version information on all module symbols"
77 depends MODULES
78
79comment "module support disabled"
80 depends !MODULES
81
82MODVERSIONS directly depends on MODULES, this means it's only visible if
83MODULES is different from 'n'. The comment on the other hand is always
84visible when MODULES it's visible (the dependency of MODULES are part
85of the comment dependencies).
86
87Menu attributes
88---------------
89
90A menu attribute can have a number of attributes. Not all of them are
91applicable everywhere (see spec).
92Input prompt: Every menu entry can have at most one menu entry, which
93is used to display to the user. An input prompt is either defined with
94"prompt" or it can be defined with the type.
95Type definition: Every config option must have a type, known types are
96currently: bool, tristate, string, hex, integer.
97Default value: It's possible to assign a config option a default value.
98This default is always used, when the option wasn't explicitly set by
99the user. This means it's either used as default value for input prompts
100or the value is saved to the kernel configuration. Multiple default
101values can be specified and every one has it's own dependencies. If
102multiple default values are visible, the first defined one is active.
103A default is not limited to a single menu entry, this means the default
104doesn't has to be defined with a input prompt, but it can also be
105overridden by prepend it with another definition.
106Dependencies: Dependencies can be either defined with "depends", then
107there are applied to all attributes of a menu entry, or attribute
108specific dependencies can be defined with "if", which immediately
109follows the attribute.
110
111
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
new file mode 100644
index 0000000..116d759
--- a/dev/null
+++ b/scripts/kconfig/lkc_proto.h
@@ -0,0 +1,38 @@
1
2/* confdata.c */
3P(conf_parse,void,(const char *name));
4P(conf_read,int,(const char *name));
5P(conf_write,int,(const char *name));
6
7/* menu.c */
8P(rootmenu,struct menu,);
9
10P(menu_is_visible,bool,(struct menu *menu));
11P(menu_get_prompt,const char *,(struct menu *menu));
12P(menu_get_root_menu,struct menu *,(struct menu *menu));
13P(menu_get_parent_menu,struct menu *,(struct menu *menu));
14
15/* symbol.c */
16P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
17P(sym_change_count,int,);
18
19P(sym_lookup,struct symbol *,(const char *name, int isconst));
20P(sym_find,struct symbol *,(const char *name));
21P(sym_type_name,const char *,(int type));
22P(sym_calc_value,void,(struct symbol *sym));
23P(sym_get_type,int,(struct symbol *sym));
24P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri));
25P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri));
26P(sym_toggle_tristate_value,tristate,(struct symbol *sym));
27P(sym_string_valid,bool,(struct symbol *sym, const char *newval));
28P(sym_set_string_value,bool,(struct symbol *sym, const char *newval));
29P(sym_is_changable,bool,(struct symbol *sym));
30P(sym_get_choice_prop,struct property *,(struct symbol *sym));
31P(sym_get_default_prop,struct property *,(struct symbol *sym));
32P(sym_get_string_value,const char *,(struct symbol *sym));
33
34P(prop_get_type_name,const char *,(enum prop_type type));
35
36/* expr.c */
37P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2));
38P(expr_print,void,(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken));
diff --git a/scripts/kconfig/lkc_spec b/scripts/kconfig/lkc_spec
new file mode 100644
index 0000000..45c36eb
--- a/dev/null
+++ b/scripts/kconfig/lkc_spec
@@ -0,0 +1,250 @@
11. General Structure
2
3The configuration file describes a series of menu entries. These menu
4entries are organized in a tree structure. The following statements
5start a new menu entry definition (and end a previous menu entry):
6- config
7- choice
8- comment
9- menu
10The following statements are control entries and also end the definition
11of a previous menu entry:
12- source
13- if
14
152. Dependencies
16
17Every menu entry has dependencies, which define it's visibility in the
18menu structure. What makes these dependencies more difficult is that
19they use three states instead of two, that most programmers are familiar
20with. The additional 'mod' state is needed to describe drivers which
21are not compiled into the kernel, but are compiled as modules, which
22can be loaded at runtime. Nevertheless they should be straigthforward
23to use.
24Dependencies describe in first place the relation between configuration
25symbols and consequently between different parts of the kernel. To
26simplify the verification of the rule base, dependencies must be
27hierarchical, that means no recursive dependencies are allowed. The only
28possible non-hierarchical dependency are exclusions (aka choices), to
29cover typical uses during kernel configuration the semantic of choice
30statements has been extended (see the choice statement below).
31
32This allows to describe the following basic relationships:
33- initialization order of kernel subsystems. That means which other
34 subsystems are required (initialized and working), before a specific
35 subsystem can be initialized itself. This allows above requirement of
36 hierarchical dependencies.
37- mutual exclusions of kernel subsystems. This allows that only a single
38 of multiple possible subsystems is configured into the kernel.
39These are the same relationships, which are reasonably representable
40with cml1, but with this new config syntax it should be possible to
41easily add further relationships and other properties.
42
43The important usage of the dependency information is for generation of
44the menu structure. First it defines whether a symbol or statement is
45visible at all. If the dependency expression evaluates to 'n', the symbol
46is not visible (and is currently also not saved, this BTW corresponds to
47the behavior of xconfig, which is noted as a bug in Documentation/
48kbuild/config-language.txt, that didn't seem to be a problem so far, but
49that has to be considered).
50If a symbol is visible, it defines the possible input range for tristate
51symbols, if the dependency expression evaluates to 'm', a tristate symbol
52can only be set to 'n' or 'm', otherwise also 'y' is possible.
53Finally dependency information is also used to group symbols together.
54If a symbol entry is followed by other symbol entries which depends on
55the first one, the latter entries are associated with the first entry.
56The text config front end uses this information to automatically indent
57the entries, the qt interface creates further submenus. This can reduce
58the amount of explicit menu information required.
59
60syntax:
61
62This is the syntax of dependency expressions:
63
64 <expr> ::= <symbol> (1)
65 <symbol> '=' <symbol> (2)
66 <symbol> '!=' <symbol> (3)
67 '(' <expr> ')' (4)
68 '!' <expr> (5)
69 <expr> '||' <expr> (6)
70 <expr> '&&' <expr> (7)
71
72Expressions are listed in decreasing order of precedence. An
73expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 respectively
74for calculations below).
75There are two type of symbols: constant and nonconstant symbols.
76Nonconstant symbols are the most common ones and are defined with the
77'config' statement. Nonconstant symbols consist entirely of alphanumeric
78characters or underscores.
79Constant symbols are only part of expressions. Constant symbols are
80always surrounded by single or double quotes. Within the quote any
81other character is allowed and the quotes can be escaped using '\'.
82Nonconstant symbols which are nowhere defined with 'config' are a
83special case, they behave like constant symbols, so that one can do
84"FOO=123", it usage should restricted to number values (this might
85be enforced later).
86
87expression syntax:
88
89(1) Convert the symbol into an expression. Boolean and tristate symbols
90 are simply converted into the respective expression values. All other
91 symbol types result in 'n'.
92(2) If the values of both symbols are equal, it returns 'y', otherwise 'n'.
93(3) If the values of both symbols are equal, it returns 'n', otherwise 'y'.
94(4) Returns the value of the expression. Used to override precedence.
95(5) Returns the result of (2-/expr/).
96(6) Returns the result of min(/expr/, /expr/).
97(7) Returns the result of max(/expr/, /expr/).
98
993. "config"
100
101syntax:
102
103 "config" <symbol>
104 <config options>
105
106Defines a new config symbol. A symbol can be defined multiple times as
107long as the symbol type is always the same.
108
109config options:
110
111 "depends" <expr>
112
113defines the visibility and the input range of the config symbol.
114
115 "tristate" <prompt> "if" <expr>
116 "bool" <prompt> "if" <expr>
117 "int" <prompt> "if" <expr>
118 "hex" <prompt> "if" <expr>
119 "string" <prompt> "if" <expr>
120
121defines the type of the symbol and the prompt which is used to request a
122value from the user. Additional constraints for the visibility and the
123input range of the prompt can be defined after an "if" statement. The
124prompt and the "if" statement are optional, but an "if" statement
125without a prompt is not possible.
126
127 "prompt" <prompt> "if" <expr>
128
129same as above, but without defining the type of the symbol. This was
130generated by earlier versions of the converter and will likely
131disappear unless needed otherwise.
132
133 "default" <symbol> "if" <expr>
134
135defines a default value for the config symbol. Unless the config symbol
136was previously set by the user, it will set to this value. This means
137it will be used as default value for above input prompts or if no user
138prompt is visible the config symbol will be saved with this value. If
139multiple default statements are visible only the first is used.
140
141 "help"
142
143defines a help text for this statement. The end of the help text
144is determined by the level indentation, this means it ends at the first
145line which has a smaller indentation than the first line of the help text.
146
1474. "choice"
148
149syntax:
150
151 "choice"
152 <choice options>
153 <choice block>
154 "endchoice"
155
156defines a group of related config statements. There are two types of
157choice statements - bool and tristate.
158
159bool choice: allows only single config statement to be selected and
160set to "y".
161tristate choice: extends the bool choice by also allowing multiple
162config statement to be selected, but in this mode these will only be set
163"m". This can be used if multiple drivers for a single hardware exists
164and only a single driver can be compiled/loaded into the kernel, but all
165drivers can be compiled as modules.
166
167choice options:
168
169 "depends" <expr>
170
171defines the visibility and the input range of the choice.
172
173 "prompt" <prompt>
174
175defines the prompt which is presented to the user.
176
177 <optional>
178
179by default exactly one of the config statements of a bool choice has
180to be selected, this option allows that also no config statement has to
181be selected.
182
183 "default" <symbol>
184
185defines the default choice presented to the user. The prompt must be a
186one of symbols defined within this choice.
187
188 "help"
189
190defines a help text for this choice statement. The end of the help text
191is determined by the level indentation, this means it ends at the first
192line which has a smaller indentation than the first line of the help text.
193
194choice block:
195
196right now only config statements allowed. (It's possible to also allow
197other statements later.)
198
1995. "comment"
200
201syntax:
202
203 "comment" <prompt>
204 <comment options>
205
206defines the prompt which is displayed to the user during the
207configuration process and is also echoes it to the output files during
208output.
209
210comment options:
211
212 "depends" <expr>
213
214defines the visibility of the comment.
215
2166. "menu"
217
218syntax:
219
220 "menu" <prompt>
221 <menu options>
222 <menu block>
223 "endmenu"
224
225menu options:
226
227 "depends" <expr>
228
229defines the visibility of the menu.
230
231menu block:
232
233Any of the basic statements is allowed within a menu block.
234
2357. "if"
236
237syntax:
238
239 "if" <expr>
240 <if block>
241 "endif"
242
2438. "source"
244
245syntax:
246
247 "source" <prompt>
248
249reads the specified configuration file. this is done unconditionally,
250
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
new file mode 100644
index 0000000..84699be
--- a/dev/null
+++ b/scripts/kconfig/mconf.c
@@ -0,0 +1,711 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <sys/ioctl.h>
7#include <sys/wait.h>
8#include <ctype.h>
9#include <errno.h>
10#include <fcntl.h>
11#include <signal.h>
12#include <stdarg.h>
13#include <stdlib.h>
14#include <string.h>
15#include <unistd.h>
16
17#define LKC_DIRECT_LINK
18#include "lkc.h"
19
20static char menu_backtitle[128];
21static const char menu_instructions[] =
22 "Arrow keys navigate the menu. "
23 "<Enter> selects submenus --->. "
24 "Highlighted letters are hotkeys. "
25 "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
26 "Press <Esc><Esc> to exit, <?> for Help. "
27 "Legend: [*] built-in [ ] excluded <M> module < > module capable",
28radiolist_instructions[] =
29 "Use the arrow keys to navigate this window or "
30 "press the hotkey of the item you wish to select "
31 "followed by the <SPACE BAR>. "
32 "Press <?> for additional information about this option.",
33inputbox_instructions_int[] =
34 "Please enter a decimal value. "
35 "Fractions will not be accepted. "
36 "Use the <TAB> key to move from the input field to the buttons below it.",
37inputbox_instructions_hex[] =
38 "Please enter a hexadecimal value. "
39 "Use the <TAB> key to move from the input field to the buttons below it.",
40inputbox_instructions_string[] =
41 "Please enter a string value. "
42 "Use the <TAB> key to move from the input field to the buttons below it.",
43setmod_text[] =
44 "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.",
46nohelp_text[] =
47 "There is no help available for this kernel option.\n",
48load_config_text[] =
49 "Enter the name of the configuration file you wish to load. "
50 "Accept the name shown to restore the configuration you "
51 "last retrieved. Leave blank to abort.",
52load_config_help[] =
53 "\n"
54 "For various reasons, one may wish to keep several different kernel\n"
55 "configurations available on a single machine.\n"
56 "\n"
57 "If you have saved a previous configuration in a file other than the\n"
58 "kernel's default, entering the name of the file here will allow you\n"
59 "to modify that configuration.\n"
60 "\n"
61 "If you are uncertain, then you have probably never used alternate\n"
62 "configuration files. You should therefor leave this blank to abort.\n",
63save_config_text[] =
64 "Enter a filename to which this configuration should be saved "
65 "as an alternate. Leave blank to abort.",
66save_config_help[] =
67 "\n"
68 "For various reasons, one may wish to keep different kernel\n"
69 "configurations available on a single machine.\n"
70 "\n"
71 "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"
73 "configuration options you have selected at that time.\n"
74 "\n"
75 "If you are uncertain what all this means then you should probably\n"
76 "leave this blank.\n"
77;
78
79static char buf[4096], *bufptr = buf;
80static char input_buf[4096];
81static char *args[1024], **argptr = args;
82static int indent = 0;
83static int rows, cols;
84static struct menu *current_menu;
85static int child_count;
86static int do_resize;
87
88static void conf(struct menu *menu);
89static void conf_choice(struct menu *menu);
90static void conf_string(struct menu *menu);
91static void conf_load(void);
92static void conf_save(void);
93static void show_textbox(const char *title, const char *text, int r, int c);
94static void show_helptext(const char *title, const char *text);
95static void show_help(struct menu *menu);
96static void show_readme(void);
97
98static void cprint_init(void);
99static int cprint1(const char *fmt, ...);
100static void cprint_done(void);
101static int cprint(const char *fmt, ...);
102
103static void init_wsize(void)
104{
105 struct winsize ws;
106
107 if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
108 rows = 24;
109 cols = 80;
110 } else {
111 rows = ws.ws_row;
112 cols = ws.ws_col;
113 }
114
115 if (rows < 19 || cols < 80) {
116 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");
118 exit(1);
119 }
120
121 rows -= 4;
122 cols -= 5;
123}
124
125static void cprint_init(void)
126{
127 bufptr = buf;
128 argptr = args;
129 memset(args, 0, sizeof(args));
130 indent = 0;
131 child_count = 0;
132 cprint("./scripts/lxdialog/lxdialog");
133 cprint("--backtitle");
134 cprint(menu_backtitle);
135}
136
137static int cprint1(const char *fmt, ...)
138{
139 va_list ap;
140 int res;
141
142 if (!*argptr)
143 *argptr = bufptr;
144 va_start(ap, fmt);
145 res = vsprintf(bufptr, fmt, ap);
146 va_end(ap);
147 bufptr += res;
148
149 return res;
150}
151
152static void cprint_done(void)
153{
154 *bufptr++ = 0;
155 argptr++;
156}
157
158static int cprint(const char *fmt, ...)
159{
160 va_list ap;
161 int res;
162
163 *argptr++ = bufptr;
164 va_start(ap, fmt);
165 res = vsprintf(bufptr, fmt, ap);
166 va_end(ap);
167 bufptr += res;
168 *bufptr++ = 0;
169
170 return res;
171}
172
173pid_t pid;
174
175static void winch_handler(int sig)
176{
177 if (!do_resize) {
178 kill(pid, SIGINT);
179 do_resize = 1;
180 }
181}
182
183static int exec_conf(void)
184{
185 int pipefd[2], stat, size;
186 struct sigaction sa;
187 sigset_t sset, osset;
188
189 sigemptyset(&sset);
190 sigaddset(&sset, SIGINT);
191 sigprocmask(SIG_BLOCK, &sset, &osset);
192
193 signal(SIGINT, SIG_DFL);
194
195 sa.sa_handler = winch_handler;
196 sigemptyset(&sa.sa_mask);
197 sa.sa_flags = SA_RESTART;
198 sigaction(SIGWINCH, &sa, NULL);
199
200 *argptr++ = NULL;
201
202 pipe(pipefd);
203 pid = fork();
204 if (pid == 0) {
205 sigprocmask(SIG_SETMASK, &osset, NULL);
206 dup2(pipefd[1], 2);
207 close(pipefd[0]);
208 close(pipefd[1]);
209 execv(args[0], args);
210 _exit(EXIT_FAILURE);
211 }
212
213 close(pipefd[1]);
214 bufptr = input_buf;
215 while (1) {
216 size = input_buf + sizeof(input_buf) - bufptr;
217 size = read(pipefd[0], bufptr, size);
218 if (size <= 0) {
219 if (size < 0) {
220 if (errno == EINTR || errno == EAGAIN)
221 continue;
222 perror("read");
223 }
224 break;
225 }
226 bufptr += size;
227 }
228 *bufptr++ = 0;
229 close(pipefd[0]);
230 waitpid(pid, &stat, 0);
231
232 if (do_resize) {
233 init_wsize();
234 do_resize = 0;
235 sigprocmask(SIG_SETMASK, &osset, NULL);
236 return -1;
237 }
238 if (WIFSIGNALED(stat)) {
239 printf("\finterrupted(%d)\n", WTERMSIG(stat));
240 exit(1);
241 }
242#if 0
243 printf("\fexit state: %d\nexit data: '%s'\n", WEXITSTATUS(stat), input_buf);
244 sleep(1);
245#endif
246 sigpending(&sset);
247 if (sigismember(&sset, SIGINT)) {
248 printf("\finterrupted\n");
249 exit(1);
250 }
251 sigprocmask(SIG_SETMASK, &osset, NULL);
252
253 return WEXITSTATUS(stat);
254}
255
256static void build_conf(struct menu *menu)
257{
258 struct symbol *sym;
259 struct property *prop;
260 struct menu *child;
261 int type, tmp, doint = 2;
262 tristate val;
263 char ch;
264
265 if (!menu_is_visible(menu))
266 return;
267
268 sym = menu->sym;
269 prop = menu->prompt;
270 if (!sym) {
271 if (prop && menu != current_menu) {
272 const char *prompt = menu_get_prompt(menu);
273 switch (prop->type) {
274 case P_MENU:
275 child_count++;
276 cprint("m%p", menu);
277 if (menu->parent != &rootmenu)
278 cprint1(" %*c", indent + 1, ' ');
279 cprint1("%s --->", prompt);
280 cprint_done();
281 return;
282 default:
283 if (prompt) {
284 child_count++;
285 cprint(":%p", menu);
286 cprint("---%*c%s", indent + 1, ' ', prompt);
287 }
288 }
289 } else
290 doint = 0;
291 goto conf_childs;
292 }
293
294 type = sym_get_type(sym);
295 if (sym_is_choice(sym)) {
296 struct symbol *def_sym = sym_get_choice_value(sym);
297 struct menu *def_menu = NULL;
298
299 child_count++;
300 for (child = menu->list; child; child = child->next) {
301 if (menu_is_visible(child) && child->sym == def_sym)
302 def_menu = child;
303 }
304
305 val = sym_get_tristate_value(sym);
306 if (sym_is_changable(sym)) {
307 cprint("t%p", menu);
308 switch (type) {
309 case S_BOOLEAN:
310 cprint1("[%c]", val == no ? ' ' : '*');
311 break;
312 case S_TRISTATE:
313 switch (val) {
314 case yes: ch = '*'; break;
315 case mod: ch = 'M'; break;
316 default: ch = ' '; break;
317 }
318 cprint1("<%c>", ch);
319 break;
320 }
321 } else {
322 cprint("%c%p", def_menu ? 't' : ':', menu);
323 cprint1(" ");
324 }
325
326 cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu));
327 if (val == yes) {
328 if (def_menu) {
329 cprint1(" (%s)", menu_get_prompt(def_menu));
330 cprint1(" --->");
331 cprint_done();
332 if (def_menu->list) {
333 indent += 2;
334 build_conf(def_menu);
335 indent -= 2;
336 }
337 } else
338 cprint_done();
339 return;
340 }
341 cprint_done();
342 } else {
343 child_count++;
344 val = sym_get_tristate_value(sym);
345 if (sym_is_choice_value(sym) && val == yes) {
346 cprint(":%p", menu);
347 cprint1(" ");
348 } else {
349 switch (type) {
350 case S_BOOLEAN:
351 cprint("t%p", menu);
352 cprint1("[%c]", val == no ? ' ' : '*');
353 break;
354 case S_TRISTATE:
355 cprint("t%p", menu);
356 switch (val) {
357 case yes: ch = '*'; break;
358 case mod: ch = 'M'; break;
359 default: ch = ' '; break;
360 }
361 cprint1("<%c>", ch);
362 break;
363 default:
364 cprint("s%p", menu);
365 tmp = cprint1("(%s)", sym_get_string_value(sym));
366 tmp = indent - tmp + 4;
367 if (tmp < 0)
368 tmp = 0;
369 cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
370 sym_has_value(sym) ? "" : " (NEW)");
371 cprint_done();
372 goto conf_childs;
373 }
374 }
375 cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
376 sym_has_value(sym) ? "" : " (NEW)");
377 cprint_done();
378 }
379
380conf_childs:
381 indent += doint;
382 for (child = menu->list; child; child = child->next)
383 build_conf(child);
384 indent -= doint;
385}
386
387static void conf(struct menu *menu)
388{
389 struct menu *submenu;
390 const char *prompt = menu_get_prompt(menu);
391 struct symbol *sym;
392 char active_entry[40];
393 int stat, type, i;
394
395 active_entry[0] = 0;
396 while (1) {
397 cprint_init();
398 cprint("--title");
399 cprint("%s", prompt ? prompt : "Main Menu");
400 cprint("--menu");
401 cprint(menu_instructions);
402 cprint("%d", rows);
403 cprint("%d", cols);
404 cprint("%d", rows - 10);
405 cprint("%s", active_entry);
406 current_menu = menu;
407 build_conf(menu);
408 if (!child_count)
409 break;
410 if (menu == &rootmenu) {
411 cprint(":");
412 cprint("--- ");
413 cprint("L");
414 cprint("Load an Alternate Configuration File");
415 cprint("S");
416 cprint("Save Configuration to an Alternate File");
417 }
418 stat = exec_conf();
419 if (stat < 0)
420 continue;
421
422 if (stat == 1 || stat == 255)
423 break;
424
425 type = input_buf[0];
426 if (!type)
427 continue;
428
429 for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++)
430 ;
431 if (i >= sizeof(active_entry))
432 i = sizeof(active_entry) - 1;
433 input_buf[i] = 0;
434 strcpy(active_entry, input_buf);
435
436 sym = NULL;
437 submenu = NULL;
438 if (sscanf(input_buf + 1, "%p", &submenu) == 1)
439 sym = submenu->sym;
440
441 switch (stat) {
442 case 0:
443 switch (type) {
444 case 'm':
445 conf(submenu);
446 break;
447 case 't':
448 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
449 conf_choice(submenu);
450 break;
451 case 's':
452 conf_string(submenu);
453 break;
454 case 'L':
455 conf_load();
456 break;
457 case 'S':
458 conf_save();
459 break;
460 }
461 break;
462 case 2:
463 if (sym)
464 show_help(submenu);
465 else
466 show_readme();
467 break;
468 case 3:
469 if (type == 't') {
470 if (sym_set_tristate_value(sym, yes))
471 break;
472 if (sym_set_tristate_value(sym, mod))
473 show_textbox(NULL, setmod_text, 6, 74);
474 }
475 break;
476 case 4:
477 if (type == 't')
478 sym_set_tristate_value(sym, no);
479 break;
480 case 5:
481 if (type == 't')
482 sym_set_tristate_value(sym, mod);
483 break;
484 case 6:
485 if (type == 't')
486 sym_toggle_tristate_value(sym);
487 break;
488 }
489 }
490}
491
492static void show_textbox(const char *title, const char *text, int r, int c)
493{
494 int fd;
495
496 fd = creat(".help.tmp", 0777);
497 write(fd, text, strlen(text));
498 close(fd);
499 do {
500 cprint_init();
501 if (title) {
502 cprint("--title");
503 cprint("%s", title);
504 }
505 cprint("--textbox");
506 cprint(".help.tmp");
507 cprint("%d", r);
508 cprint("%d", c);
509 } while (exec_conf() < 0);
510 unlink(".help.tmp");
511}
512
513static void show_helptext(const char *title, const char *text)
514{
515 show_textbox(title, text, rows, cols);
516}
517
518static void show_help(struct menu *menu)
519{
520 const char *help;
521
522 help = menu->sym->help;
523 if (!help)
524 help = nohelp_text;
525 show_helptext(menu_get_prompt(menu), help);
526}
527
528static void show_readme(void)
529{
530 do {
531 cprint_init();
532 cprint("--textbox");
533 cprint("scripts/README.Menuconfig");
534 cprint("%d", rows);
535 cprint("%d", cols);
536 } while (exec_conf() == -1);
537}
538
539static void conf_choice(struct menu *menu)
540{
541 const char *prompt = menu_get_prompt(menu);
542 struct menu *child;
543 struct symbol *active;
544 int stat;
545
546 while (1) {
547 cprint_init();
548 cprint("--title");
549 cprint("%s", prompt ? prompt : "Main Menu");
550 cprint("--radiolist");
551 cprint(radiolist_instructions);
552 cprint("15");
553 cprint("70");
554 cprint("6");
555
556 current_menu = menu;
557 active = sym_get_choice_value(menu->sym);
558 for (child = menu->list; child; child = child->next) {
559 if (!menu_is_visible(child))
560 continue;
561 cprint("%p", child);
562 cprint("%s", menu_get_prompt(child));
563 cprint(child->sym == active ? "ON" : "OFF");
564 }
565
566 stat = exec_conf();
567 switch (stat) {
568 case 0:
569 if (sscanf(input_buf, "%p", &menu) != 1)
570 break;
571 sym_set_tristate_value(menu->sym, yes);
572 return;
573 case 1:
574 show_help(menu);
575 break;
576 case 255:
577 return;
578 }
579 }
580}
581
582static void conf_string(struct menu *menu)
583{
584 const char *prompt = menu_get_prompt(menu);
585 int stat;
586
587 while (1) {
588 cprint_init();
589 cprint("--title");
590 cprint("%s", prompt ? prompt : "Main Menu");
591 cprint("--inputbox");
592 switch (sym_get_type(menu->sym)) {
593 case S_INT:
594 cprint(inputbox_instructions_int);
595 break;
596 case S_HEX:
597 cprint(inputbox_instructions_hex);
598 break;
599 case S_STRING:
600 cprint(inputbox_instructions_string);
601 break;
602 default:
603 /* panic? */;
604 }
605 cprint("10");
606 cprint("75");
607 cprint("%s", sym_get_string_value(menu->sym));
608 stat = exec_conf();
609 switch (stat) {
610 case 0:
611 if (sym_set_string_value(menu->sym, input_buf))
612 return;
613 show_textbox(NULL, "You have made an invalid entry.", 5, 43);
614 break;
615 case 1:
616 show_help(menu);
617 break;
618 case 255:
619 return;
620 }
621 }
622}
623
624static void conf_load(void)
625{
626 int stat;
627
628 while (1) {
629 cprint_init();
630 cprint("--inputbox");
631 cprint(load_config_text);
632 cprint("11");
633 cprint("55");
634 cprint("%s", conf_filename);
635 stat = exec_conf();
636 switch(stat) {
637 case 0:
638 if (!input_buf[0])
639 return;
640 if (!conf_read(input_buf))
641 return;
642 show_textbox(NULL, "File does not exist!", 5, 38);
643 break;
644 case 1:
645 show_helptext("Load Alternate Configuration", load_config_help);
646 break;
647 case 255:
648 return;
649 }
650 }
651}
652
653static void conf_save(void)
654{
655 int stat;
656
657 while (1) {
658 cprint_init();
659 cprint("--inputbox");
660 cprint(save_config_text);
661 cprint("11");
662 cprint("55");
663 cprint("%s", conf_filename);
664 stat = exec_conf();
665 switch(stat) {
666 case 0:
667 if (!input_buf[0])
668 return;
669 if (!conf_write(input_buf))
670 return;
671 show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60);
672 break;
673 case 1:
674 show_helptext("Save Alternate Configuration", save_config_help);
675 break;
676 case 255:
677 return;
678 }
679 }
680}
681
682int main(int ac, char **av)
683{
684 int stat;
685 conf_parse(av[1]);
686 conf_read(NULL);
687
688 sprintf(menu_backtitle, "Configuration");
689
690 init_wsize();
691 conf(&rootmenu);
692
693 do {
694 cprint_init();
695 cprint("--yesno");
696 cprint("Do you wish to save your new configuration?");
697 cprint("5");
698 cprint("60");
699 stat = exec_conf();
700 } while (stat < 0);
701
702 if (stat == 0) {
703 conf_write(NULL);
704 printf("\n\n"
705 "*** End of configuration.\n"
706 "*** Check the top-level Makefile for additional configuration.\n");
707 } else
708 printf("\n\nYour configuration changes were NOT saved.\n\n");
709
710 return 0;
711}
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
new file mode 100644
index 0000000..4595110
--- a/dev/null
+++ b/scripts/kconfig/menu.c
@@ -0,0 +1,309 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <stdlib.h>
7#include <string.h>
8
9#define LKC_DIRECT_LINK
10#include "lkc.h"
11
12struct menu rootmenu;
13struct menu *current_menu, *current_entry;
14static struct menu **last_entry_ptr;
15
16struct file *file_list;
17struct file *current_file;
18
19void menu_init(void)
20{
21 current_entry = current_menu = &rootmenu;
22 last_entry_ptr = &rootmenu.list;
23}
24
25void menu_add_entry(struct symbol *sym)
26{
27 struct menu *menu;
28
29 menu = malloc(sizeof(*menu));
30 memset(menu, 0, sizeof(*menu));
31 menu->sym = sym;
32 menu->parent = current_menu;
33 menu->file = current_file;
34 menu->lineno = zconf_lineno();
35
36 *last_entry_ptr = menu;
37 last_entry_ptr = &menu->next;
38 current_entry = menu;
39}
40
41void menu_end_entry(void)
42{
43}
44
45void menu_add_menu(void)
46{
47 current_menu = current_entry;
48 last_entry_ptr = &current_entry->list;
49}
50
51void menu_end_menu(void)
52{
53 last_entry_ptr = &current_menu->next;
54 current_menu = current_menu->parent;
55}
56
57void menu_add_dep(struct expr *dep)
58{
59 current_entry->dep = expr_alloc_and(current_entry->dep, dep);
60}
61
62void menu_set_type(int type)
63{
64 struct symbol *sym = current_entry->sym;
65
66 if (sym->type == type)
67 return;
68 if (sym->type == S_UNKNOWN) {
69 sym->type = type;
70 return;
71 }
72 fprintf(stderr, "%s:%d: type of '%s' redefined from '%s' to '%s'\n",
73 current_entry->file->name, current_entry->lineno,
74 sym->name ? sym->name : "<choice>", sym_type_name(sym->type), sym_type_name(type));
75}
76
77struct property *create_prop(enum prop_type type)
78{
79 struct property *prop;
80
81 prop = malloc(sizeof(*prop));
82 memset(prop, 0, sizeof(*prop));
83 prop->type = type;
84 prop->file = current_file;
85 prop->lineno = zconf_lineno();
86
87 return prop;
88}
89
90struct property *menu_add_prop(int token, char *prompt, struct symbol *def, struct expr *dep)
91{
92 struct property *prop = create_prop(token);
93 struct property **propp;
94
95 prop->sym = current_entry->sym;
96 prop->menu = current_entry;
97 prop->text = prompt;
98 prop->def = def;
99 E_EXPR(prop->visible) = dep;
100
101 if (prompt)
102 current_entry->prompt = prop;
103
104 /* append property to the prop list of symbol */
105 if (prop->sym) {
106 for (propp = &prop->sym->prop; *propp; propp = &(*propp)->next)
107 ;
108 *propp = prop;
109 }
110
111 return prop;
112}
113
114void menu_add_prompt(int token, char *prompt, struct expr *dep)
115{
116 current_entry->prompt = menu_add_prop(token, prompt, NULL, dep);
117}
118
119void menu_add_default(int token, struct symbol *def, struct expr *dep)
120{
121 current_entry->prompt = menu_add_prop(token, NULL, def, dep);
122}
123
124void menu_finalize(struct menu *parent)
125{
126 struct menu *menu, *last_menu;
127 struct symbol *sym;
128 struct property *prop;
129 struct expr *parentdep, *basedep, *dep, *dep2;
130
131 sym = parent->sym;
132 if (parent->list) {
133 if (sym && sym_is_choice(sym)) {
134 /* find the first choice value and find out choice type */
135 for (menu = parent->list; menu; menu = menu->next) {
136 if (menu->sym) {
137 current_entry = parent;
138 menu_set_type(menu->sym->type);
139 current_entry = menu;
140 menu_set_type(sym->type);
141 break;
142 }
143 }
144 parentdep = expr_alloc_symbol(sym);
145 } else if (parent->prompt)
146 parentdep = E_EXPR(parent->prompt->visible);
147 else
148 parentdep = parent->dep;
149
150 for (menu = parent->list; menu; menu = menu->next) {
151 basedep = expr_transform(menu->dep);
152 basedep = expr_alloc_and(expr_copy(parentdep), basedep);
153 basedep = expr_eliminate_dups(basedep);
154 menu->dep = basedep;
155 if (menu->sym)
156 prop = menu->sym->prop;
157 else
158 prop = menu->prompt;
159 for (; prop; prop = prop->next) {
160 if (prop->menu != menu)
161 continue;
162 dep = expr_transform(E_EXPR(prop->visible));
163 dep = expr_alloc_and(expr_copy(basedep), dep);
164 dep = expr_eliminate_dups(dep);
165 if (menu->sym && menu->sym->type != S_TRISTATE)
166 dep = expr_trans_bool(dep);
167 E_EXPR(prop->visible) = dep;
168 }
169 }
170 for (menu = parent->list; menu; menu = menu->next)
171 menu_finalize(menu);
172 } else if (sym && parent->prompt) {
173 basedep = E_EXPR(parent->prompt->visible);
174 basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
175 basedep = expr_eliminate_dups(expr_transform(basedep));
176 last_menu = NULL;
177 for (menu = parent->next; menu; menu = menu->next) {
178 dep = menu->prompt ? E_EXPR(menu->prompt->visible) : menu->dep;
179 if (!expr_contains_symbol(dep, sym))
180 break;
181 if (expr_depends_symbol(dep, sym))
182 goto next;
183 dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no);
184 dep = expr_eliminate_dups(expr_transform(dep));
185 dep2 = expr_copy(basedep);
186 expr_eliminate_eq(&dep, &dep2);
187 expr_free(dep);
188 if (!expr_is_yes(dep2)) {
189 expr_free(dep2);
190 break;
191 }
192 expr_free(dep2);
193 next:
194 menu_finalize(menu);
195 menu->parent = parent;
196 last_menu = menu;
197 }
198 if (last_menu) {
199 parent->list = parent->next;
200 parent->next = last_menu->next;
201 last_menu->next = NULL;
202 }
203 }
204 for (menu = parent->list; menu; menu = menu->next) {
205 if (sym && sym_is_choice(sym) && menu->sym) {
206 menu->sym->flags |= SYMBOL_CHOICEVAL;
207 current_entry = menu;
208 menu_set_type(sym->type);
209 menu_add_prop(P_CHOICE, NULL, parent->sym, NULL);
210 prop = sym_get_choice_prop(parent->sym);
211 //dep = expr_alloc_one(E_CHOICE, dep);
212 //dep->right.sym = menu->sym;
213 prop->dep = expr_alloc_one(E_CHOICE, prop->dep);
214 prop->dep->right.sym = menu->sym;
215 }
216 if (menu->list && (!menu->prompt || !menu->prompt->text)) {
217 for (last_menu = menu->list; ; last_menu = last_menu->next) {
218 last_menu->parent = parent;
219 if (!last_menu->next)
220 break;
221 }
222 last_menu->next = menu->next;
223 menu->next = menu->list;
224 menu->list = NULL;
225 }
226 }
227}
228
229bool menu_is_visible(struct menu *menu)
230{
231 tristate visible;
232
233 if (!menu->prompt)
234 return false;
235 if (menu->sym) {
236 sym_calc_value(menu->sym);
237 visible = E_TRI(menu->prompt->visible);
238 } else
239 visible = E_CALC(menu->prompt->visible);
240 return visible != no;
241}
242
243const char *menu_get_prompt(struct menu *menu)
244{
245 if (menu->prompt)
246 return menu->prompt->text;
247 else if (menu->sym)
248 return menu->sym->name;
249 return NULL;
250}
251
252struct menu *menu_get_root_menu(struct menu *menu)
253{
254 return &rootmenu;
255}
256
257struct menu *menu_get_parent_menu(struct menu *menu)
258{
259 enum prop_type type;
260
261 while (menu != &rootmenu) {
262 menu = menu->parent;
263 type = menu->prompt ? menu->prompt->type : 0;
264 if (type == P_MENU || type == P_ROOTMENU)
265 break;
266 }
267 return menu;
268}
269
270struct file *file_lookup(const char *name)
271{
272 struct file *file;
273
274 for (file = file_list; file; file = file->next) {
275 if (!strcmp(name, file->name))
276 return file;
277 }
278
279 file = malloc(sizeof(*file));
280 memset(file, 0, sizeof(*file));
281 file->name = strdup(name);
282 file->next = file_list;
283 file_list = file;
284 return file;
285}
286
287int file_write_dep(const char *name)
288{
289 struct file *file;
290 FILE *out;
291
292 if (!name)
293 name = "..config.cmd";
294 out = fopen("..config.tmp", "w");
295 if (!out)
296 return 1;
297 fprintf(out, "deps_config := \\\n");
298 for (file = file_list; file; file = file->next) {
299 if (file->next)
300 fprintf(out, "\t%s \\\n", file->name);
301 else
302 fprintf(out, "\t%s\n", file->name);
303 }
304 fprintf(out, "\n.config include/linux/autoconf.h: $(deps_config)\n\n$(deps_config):\n");
305 fclose(out);
306 rename("..config.tmp", name);
307 return 0;
308}
309
diff --git a/scripts/kconfig/prepare-all.diff b/scripts/kconfig/prepare-all.diff
new file mode 100644
index 0000000..305aabc
--- a/dev/null
+++ b/scripts/kconfig/prepare-all.diff
@@ -0,0 +1,1883 @@
1Index: Makefile
2===================================================================
3RCS file: /usr/src/cvsroot/linux-2.5/Makefile,v
4retrieving revision 1.1.1.44
5diff -u -p -r1.1.1.44 Makefile
6 --- Makefile 16 Oct 2002 19:38:52 -00001.1.1.44
7 +++ Makefile16 Oct 2002 23:00:47 -0000
8@@ -44,7 +44,9 @@
9 TOPDIR:= $(CURDIR)
10
11 HOSTCC = gcc
12 +HOSTCXX = g++
13 HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
14 +HOSTCXXFLAGS= -O2
15
16 CROSS_COMPILE =
17
18@@ -161,7 +163,8 @@
19
20 exportVERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
21 CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
22 -CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS PERL
23 +CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS PERL \
24 +HOSTCXX HOSTCXXFLAGS
25
26 export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
27 export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
28@@ -237,21 +240,7 @@
29
30 #In this section, we need .config
31
32 -#If .config doesn't exist - tough luck
33-
34-.config: arch/$(ARCH)/config.in # FIXME $(shell find . -name Config.in)
35 -@echo '***'
36 -@if [ -f $@ ]; then \
37 - echo '*** The tree was updated, so your .config may be'; \
38 - echo '*** out of date!'; \
39 -else \
40 - echo '*** You have not yet configured your kernel!'; \
41 -fi
42 -@echo '***'
43 -@echo '*** Please run some configurator (e.g. "make oldconfig" or'
44 -@echo '*** "make menuconfig" or "make xconfig").'
45 -@echo '***'
46 -@exit 1
47+-include ..config.cmd
48
49 ifdef CONFIG_MODULES
50 export EXPORT_FLAGS := -DEXPORT_SYMTAB
51@@ -419,11 +408,8 @@
52 # with it and forgot to run make oldconfig
53
54 include/linux/autoconf.h: .config
55 -@echo '***'
56 -@echo '*** You changed .config w/o running make *config?'
57 -@echo '*** Please run "make oldconfig"'
58 -@echo '***'
59 -@exit 1
60 ++@$(call descend,scripts/kconfig,scripts/kconfig/conf)
61 +./scripts/kconfig/conf -s arch/$(ARCH)/Kconfig
62
63 # Generate some files
64 # ---------------------------------------------------------------------------
65@@ -637,34 +623,36 @@
66 .PHONY: oldconfig xconfig menuconfig config \
67 make_with_config
68
69-xconfig:
70 -+@$(call descend,scripts,scripts/kconfig.tk)
71 -wish -f scripts/kconfig.tk
72+scripts/kconfig/conf scripts/kconfig/mconf scripts/kconfig/qconf: scripts/fixdep FORCE
73 ++@$(call descend,scripts/kconfig,$@)
74+
75+xconfig: scripts/kconfig/qconf
76 +./scripts/kconfig/qconf arch/$(ARCH)/Kconfig
77
78-menuconfig:
79 -+@$(call descend,scripts,lxdialog)
80 -$(CONFIG_SHELL) $(src)/scripts/Menuconfig arch/$(ARCH)/config.in
81+menuconfig: scripts/kconfig/mconf
82 ++@$(call descend,scripts/lxdialog,)
83 +./scripts/kconfig/mconf arch/$(ARCH)/Kconfig
84
85-config:
86 -$(CONFIG_SHELL) $(src)/scripts/Configure arch/$(ARCH)/config.in
87+config: scripts/kconfig/conf
88 +./scripts/kconfig/conf arch/$(ARCH)/Kconfig
89
90-oldconfig:
91 -$(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in
92+oldconfig: scripts/kconfig/conf
93 +./scripts/kconfig/conf -o arch/$(ARCH)/Kconfig
94
95-randconfig:
96 -$(CONFIG_SHELL) $(src)/scripts/Configure -r arch/$(ARCH)/config.in
97+randconfig: scripts/kconfig/conf
98 +./scripts/kconfig/conf -r arch/$(ARCH)/Kconfig
99
100-allyesconfig:
101 -$(CONFIG_SHELL) $(src)/scripts/Configure -y arch/$(ARCH)/config.in
102+allyesconfig: scripts/kconfig/conf
103 +./scripts/kconfig/conf -y arch/$(ARCH)/Kconfig
104
105-allnoconfig:
106 -$(CONFIG_SHELL) $(src)/scripts/Configure -n arch/$(ARCH)/config.in
107+allnoconfig: scripts/kconfig/conf
108 +./scripts/kconfig/conf -n arch/$(ARCH)/Kconfig
109
110-allmodconfig:
111 -$(CONFIG_SHELL) $(src)/scripts/Configure -m arch/$(ARCH)/config.in
112+allmodconfig: scripts/kconfig/conf
113 +./scripts/kconfig/conf -m arch/$(ARCH)/Kconfig
114
115-defconfig:
116 -yes '' | $(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in
117+defconfig: scripts/kconfig/conf
118 +./scripts/kconfig/conf -d arch/$(ARCH)/Kconfig
119
120 ###
121 # Cleaning is done on three levels.
122Index: Rules.make
123===================================================================
124RCS file: /usr/src/cvsroot/linux-2.5/Rules.make,v
125retrieving revision 1.1.1.22
126diff -u -p -r1.1.1.22 Rules.make
127 --- Rules.make 12 Oct 2002 11:42:02 -00001.1.1.22
128 +++ Rules.make16 Oct 2002 23:00:49 -0000
129@@ -114,9 +114,33 @@
130 # Only build module versions for files which are selected to be built
131 export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m))
132
133-host-progs-single := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m)))
134-host-progs-multi := $(foreach m,$(host-progs),$(if $($(m)-objs),$(m)))
135-host-progs-multi-objs := $(foreach m,$(host-progs-multi),$($(m)-objs))
136+# C code
137+# Executables compiled from a single .c file
138 +host-csingle:= $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m)))
139+
140+# C executables linked based on several .o files
141 +host-cmulti:= $(foreach m,$(host-progs),\
142 + $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
143+
144+# Object (.o) files compiled from .c files
145 +host-cobjs:= $(sort $(foreach m,$(host-progs),$($(m)-objs)))
146+
147+# C++ code
148+# C++ executables compiled from at least on .cc file
149+# and zero or more .c files
150 +host-cxxmulti:= $(foreach m,$(host-progs),$(if $($(m)-cxxobjs),$(m)))
151+
152+# C++ Object (.o) files compiled from .cc files
153 +host-cxxobjs:= $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
154+
155+# Shared libaries (only .c supported)
156+# Shared libraries (.so) - all .so files referenced in "xxx-objs"
157 +host-cshlib:= $(sort $(filter %.so, $(host-cobjs)))
158+# Remove .so files from "xxx-objs"
159 +host-cobjs:= $(filter-out %.so,$(host-cobjs))
160+
161+#Object (.o) files used by the shared libaries
162 +host-cshobjs:= $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
163
164 # Add subdir path
165
166@@ -134,10 +158,14 @@
167 subdir-ym:= $(addprefix $(obj)/,$(subdir-ym))
168 subdir-ymn:= $(addprefix $(obj)/,$(subdir-ymn))
169 clean-files:= $(addprefix $(obj)/,$(clean-files))
170 -host-progs:= $(addprefix $(obj)/,$(host-progs))
171-host-progs-single := $(addprefix $(obj)/,$(host-progs-single))
172-host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi))
173-host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs))
174+host-progs := $(addprefix $(obj)/,$(host-progs))
175 +host-csingle:= $(addprefix $(obj)/,$(host-csingle))
176 +host-cmulti:= $(addprefix $(obj)/,$(host-cmulti))
177 +host-cobjs:= $(addprefix $(obj)/,$(host-cobjs))
178 +host-cxxmulti:= $(addprefix $(obj)/,$(host-cxxmulti))
179 +host-cxxobjs:= $(addprefix $(obj)/,$(host-cxxobjs))
180 +host-cshlib:= $(addprefix $(obj)/,$(host-cshlib))
181 +host-cshobjs:= $(addprefix $(obj)/,$(host-cshobjs))
182
183 # The temporary file to save gcc -MD generated dependencies must not
184 # contain a comma
185@@ -423,30 +451,96 @@
186
187 # Compile programs on the host
188 # ===========================================================================
189+# host-progs := bin2hex
190+# Will compile bin2hex.c and create an executable named bin2hex
191+#
192+# host-progs := lxdialog
193+# lxdialog-objs := checklist.o lxdialog.o
194+# Will compile lxdialog.c and checklist.c, and then link the executable
195+# lxdialog, based on checklist.o and lxdialog.o
196+#
197+# host-progs := qconf
198+# qconf-cxxobjs := qconf.o
199+# qconf-objs := menu.o
200+# Will compile qconf as a C++ program, and menu as a C program.
201+# They are linked as C++ code to the executable qconf
202+
203+# host-progs := conf
204+# conf-objs := conf.o libkconfig.so
205+# libkconfig-objs := expr.o type.o
206+# Will create a shared library named libkconfig.so that consist of
207+# expr.o and type.o (they are both compiled as C code and the object file
208+# are made as position independent code).
209+# conf.c is compiled as a c program, and conf.o is linked together with
210+# libkconfig.so as the executable conf.
211+# Note: Shared libraries consisting of C++ files are not supported
212+#
213+
214+# Create executable from a single .c file
215+# host-csingle -> Executable
216 +quiet_cmd_host-csingle = HOSTCC $(echo_target)
217 + cmd_host-csingle= $(HOSTCC) -Wp,-MD,$(depfile) \
218 + $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
219 + $(HOST_LOADLIBES) -o $@ $<
220+$(host-csingle): %: %.c FORCE
221 +$(call if_changed_dep,host-csingle)
222+
223+# Link an executable based on list of .o files, all plain c
224+# host-cmulti -> executable
225 +quiet_cmd_host-cmulti= HOSTLD $(echo_target)
226 + cmd_host-cmulti= $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
227 + $(addprefix $(obj)/,$($(@F)-objs)) \
228 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
229+$(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE
230 +$(call if_changed,host-cmulti)
231+
232+# Create .o file from a single .c file
233+# host-cobjs -> .o
234 +quiet_cmd_host-cobjs= HOSTCC $(echo_target)
235 + cmd_host-cobjs= $(HOSTCC) -Wp,-MD,$(depfile) \
236 + $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
237 + $(HOSTCFLAGS_$(@F)) -c -o $@ $<
238+$(host-cobjs): %.o: %.c FORCE
239 +$(call if_changed_dep,host-cobjs)
240+
241+# Link an executable based on list of .o files, a mixture of .c and .cc
242+# host-cxxmulti -> executable
243 +quiet_cmd_host-cxxmulti= HOSTLD $(echo_target)
244 + cmd_host-cxxmulti= $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \
245 + $(foreach o,objs cxxobjs,\
246 + $(addprefix $(obj)/,$($(@F)-$(o)))) \
247 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
248+$(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE
249 +$(call if_changed,host-cxxmulti)
250+
251+# Create .o file from a single .cc (C++) file
252 +quiet_cmd_host-cxxobjs= HOSTCXX $(echo_target)
253 + cmd_host-cxxobjs= $(HOSTCXX) -Wp,-MD,$(depfile) \
254 + $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
255 + $(HOSTCXXFLAGS_$(@F)) -c -o $@ $<
256+$(host-cxxobjs): %.o: %.cc FORCE
257 +$(call if_changed_dep,host-cxxobjs)
258+
259+# Compile .c file, create position independent .o file
260+# host-cshobjs -> .o
261 +quiet_cmd_host-cshobjs= HOSTCC -fPIC $(echo_target)
262 + cmd_host-cshobjs= $(HOSTCC) -Wp,-MD,$(depfile) -fPIC\
263 + $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
264 + $(HOSTCFLAGS_$(@F)) -c -o $@ $<
265+$(host-cshobjs): %.o: %.c FORCE
266 +$(call if_changed_dep,host-cshobjs)
267+
268+# Link a shared library, based on position independent .o files
269+# *.o -> .so shared library (host-cshlib)
270 +quiet_cmd_host-cshlib= HOSTLLD -shared $(echo_target)
271 + cmd_host-cshlib= $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \
272 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
273 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
274+$(host-cshlib): %: $(host-cshobjs) FORCE
275 +$(call if_changed,host-cshlib)
276
277-quiet_cmd_host_cc__c = HOSTCC $(echo_target)
278-cmd_host_cc__c = $(HOSTCC) -Wp,-MD,$(depfile) \
279 - $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
280 - $(HOST_LOADLIBES) -o $@ $<
281-
282-$(host-progs-single): %: %.c FORCE
283 -$(call if_changed_dep,host_cc__c)
284-
285-quiet_cmd_host_cc_o_c = HOSTCC $(echo_target)
286-cmd_host_cc_o_c = $(HOSTCC) -Wp,-MD,$(depfile) \
287 - $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) -c -o $@ $<
288-
289-$(host-progs-multi-objs): %.o: %.c FORCE
290 -$(call if_changed_dep,host_cc_o_c)
291-
292-quiet_cmd_host_cc__o = HOSTLD $(echo_target)
293-cmd_host_cc__o = $(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj)/,$($(subst $(obj)/,,$@)-objs)) \
294 - $(HOST_LOADLIBES)
295-
296-$(host-progs-multi): %: $(host-progs-multi-objs) FORCE
297 -$(call if_changed,host_cc__o)
298-
299-targets += $(host-progs-single) $(host-progs-multi-objs) $(host-progs-multi)
300+targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
301 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
302
303 endif # ! subdirclean
304 endif # ! modules_install
305Index: arch/alpha/config.in
306===================================================================
307RCS file: /usr/src/cvsroot/linux-2.5/arch/alpha/config.in,v
308retrieving revision 1.1.1.16
309diff -u -p -r1.1.1.16 config.in
310 --- arch/alpha/config.in 12 Oct 2002 11:50:40 -00001.1.1.16
311 +++ arch/alpha/config.in16 Oct 2002 23:00:53 -0000
312@@ -19,11 +19,11 @@ choice 'Alpha system type' \
313 Alcor/Alpha-XLT CONFIG_ALPHA_ALCOR \
314 Alpha-XL CONFIG_ALPHA_XL \
315 AlphaBook1 CONFIG_ALPHA_BOOK1 \
316 - Avanti CONFIG_ALPHA_AVANTI \
317 + Avanti CONFIG_ALPHA_AVANTI_CH \
318 Cabriolet CONFIG_ALPHA_CABRIOLET \
319 DP264 CONFIG_ALPHA_DP264 \
320 EB164 CONFIG_ALPHA_EB164 \
321 - EB64+ CONFIG_ALPHA_EB64P \
322 + EB64+ CONFIG_ALPHA_EB64P_CH \
323 EB66 CONFIG_ALPHA_EB66 \
324 EB66+ CONFIG_ALPHA_EB66P \
325 Eiger CONFIG_ALPHA_EIGER \
326@@ -32,7 +32,7 @@ choice 'Alpha system type' \
327 Miata CONFIG_ALPHA_MIATA \
328 Mikasa CONFIG_ALPHA_MIKASA \
329 Nautilus CONFIG_ALPHA_NAUTILUS \
330 - Noname CONFIG_ALPHA_NONAME \
331 + Noname CONFIG_ALPHA_NONAME_CH \
332 Noritake CONFIG_ALPHA_NORITAKE \
333 PC164 CONFIG_ALPHA_PC164 \
334 Platform2000 CONFIG_ALPHA_P2K \
335@@ -69,7 +69,7 @@ else
336 define_bool CONFIG_PCI y
337 fi
338
339-if [ "$CONFIG_ALPHA_BOOK1" = "y" ]
340+if [ "$CONFIG_ALPHA_BOOK1" = "y" -o "$CONFIG_ALPHA_NONAME_CH" = "y" ]
341 then
342 define_bool CONFIG_ALPHA_NONAME y
343 fi
344@@ -79,13 +79,13 @@ then
345 define_bool CONFIG_ALPHA_EV4 y
346 define_bool CONFIG_ALPHA_LCA y
347 fi
348-if [ "$CONFIG_ALPHA_CABRIOLET" = "y" -o "$CONFIG_ALPHA_AVANTI" = "y" \
349 --o "$CONFIG_ALPHA_EB64P" = "y" -o "$CONFIG_ALPHA_XL" = "y" ]
350+if [ "$CONFIG_ALPHA_CABRIOLET" = "y" -o "$CONFIG_ALPHA_AVANTI_CH" = "y" \
351 +-o "$CONFIG_ALPHA_EB64P_CH" = "y" -o "$CONFIG_ALPHA_XL" = "y" ]
352 then
353 define_bool CONFIG_ALPHA_EV4 y
354 define_bool CONFIG_ALPHA_APECS y
355 fi
356-if [ "$CONFIG_ALPHA_CABRIOLET" = "y" ]
357+if [ "$CONFIG_ALPHA_CABRIOLET" = "y" -o "$CONFIG_ALPHA_EB64P_CH" = "y" ]
358 then
359 define_bool CONFIG_ALPHA_EB64P y
360 fi
361@@ -198,7 +198,7 @@ if [ "$CONFIG_ALPHA_JENSEN" = "y" -o "$C
362 then
363 define_bool CONFIG_ALPHA_SRM y
364 fi
365-if [ "$CONFIG_ALPHA_CABRIOLET" = "y" -o "$CONFIG_ALPHA_AVANTI" = "y" \
366+if [ "$CONFIG_ALPHA_CABRIOLET" = "y" -o "$CONFIG_ALPHA_AVANTI_CH" = "y" \
367 -o "$CONFIG_ALPHA_EB64P" = "y" -o "$CONFIG_ALPHA_PC164" = "y" \
368 -o "$CONFIG_ALPHA_TAKARA" = "y" -o "$CONFIG_ALPHA_EB164" = "y" \
369 -o "$CONFIG_ALPHA_ALCOR" = "y" -o "$CONFIG_ALPHA_MIATA" = "y" \
370@@ -214,7 +214,7 @@ if [ "$CONFIG_ALPHA_ALCOR" = "y" -o "$CO
371 then
372 define_bool CONFIG_ALPHA_EISA y
373 fi
374-if [ "$CONFIG_ALPHA_XL" = "y" ]
375+if [ "$CONFIG_ALPHA_XL" = "y" -o "$CONFIG_ALPHA_AVANTI_CH" = "y" ]
376 then
377 define_bool CONFIG_ALPHA_AVANTI y
378 fi
379@@ -253,7 +253,7 @@ bool 'Support for hot-pluggable devices'
380 if [ "$CONFIG_HOTPLUG" = "y" ] ; then
381 source drivers/pcmcia/Config.in
382 else
383- define_bool CONFIG_PCMCIA n
384+ define_tristate CONFIG_PCMCIA n
385 fi
386
387 if [ "$CONFIG_PROC_FS" = "y" ]; then
388@@ -306,9 +306,9 @@ if [ "$CONFIG_SCSI" != "n" ]; then
389 fi
390 endmenu
391
392-if [ "$CONFIG_PCI" = "y" ]; then
393+#if [ "$CONFIG_PCI" = "y" ]; then
394 source drivers/message/fusion/Config.in
395-fi
396+#fi
397
398 if [ "$CONFIG_NET" = "y" ]; then
399 source net/Config.in
400@@ -399,3 +399,4 @@ endmenu
401
402 source security/Config.in
403 source lib/Config.in
404+source config.undef
405Index: arch/arm/config.in
406===================================================================
407RCS file: /usr/src/cvsroot/linux-2.5/arch/arm/config.in,v
408retrieving revision 1.1.1.17
409diff -u -p -r1.1.1.17 config.in
410 --- arch/arm/config.in 16 Oct 2002 19:45:13 -00001.1.1.17
411 +++ arch/arm/config.in16 Oct 2002 23:00:54 -0000
412@@ -356,7 +356,7 @@ bool 'Support for hot-pluggable devices'
413 if [ "$CONFIG_HOTPLUG" = "y" ]; then
414 source drivers/pcmcia/Config.in
415 else
416- define_bool CONFIG_PCMCIA n
417+ define_tristate CONFIG_PCMCIA n
418 fi
419 comment 'At least one math emulation must be selected'
420 tristate 'NWFPE math emulation' CONFIG_FPE_NWFPE
421@@ -416,10 +416,11 @@ endmenu
422
423 source drivers/parport/Config.in
424
425-if [ "$CONFIG_ALIGNMENT_TRAP" = "y" ]; then
426+#if [ "$CONFIG_ALIGNMENT_TRAP" = "y" ]; then
427 source drivers/mtd/Config.in
428-else
429- define_bool CONFIG_MTD n
430+#else
431+if [ "$CONFIG_ALIGNMENT_TRAP" != "y" ]; then
432+ define_tristate CONFIG_MTD n
433 fi
434
435 source drivers/pnp/Config.in
436@@ -442,10 +443,11 @@ if [ "$CONFIG_NET" = "y" ]; then
437 fi
438 endmenu
439
440- source net/ax25/Config.in
441+# source net/ax25/Config.in
442
443 source net/irda/Config.in
444 fi
445+ source net/ax25/Config.in
446
447 mainmenu_option next_comment
448 comment 'ATA/ATAPI/MFM/RLL support'
449@@ -469,9 +471,9 @@ if [ "$CONFIG_SCSI" != "n" ]; then
450 fi
451 endmenu
452
453-if [ "$CONFIG_ARCH_CLPS711X" = "y" ]; then
454- source drivers/ssi/Config.in
455-fi
456+#if [ "$CONFIG_ARCH_CLPS711X" = "y" ]; then
457+# source drivers/ssi/Config.in
458+#fi
459
460 source drivers/ieee1394/Config.in
461
462@@ -554,3 +556,4 @@ endmenu
463
464 source security/Config.in
465 source lib/Config.in
466+source config.undef
467Index: arch/cris/config.in
468===================================================================
469RCS file: /usr/src/cvsroot/linux-2.5/arch/cris/config.in,v
470retrieving revision 1.1.1.8
471diff -u -p -r1.1.1.8 config.in
472 --- arch/cris/config.in 27 Aug 2002 23:44:08 -00001.1.1.8
473 +++ arch/cris/config.in16 Oct 2002 23:00:57 -0000
474@@ -230,3 +230,4 @@ endmenu
475
476 source security/Config.in
477 source lib/Config.in
478+source config.undef
479Index: arch/cris/drivers/Config.in
480===================================================================
481RCS file: /usr/src/cvsroot/linux-2.5/arch/cris/drivers/Config.in,v
482retrieving revision 1.1.1.3
483diff -u -p -r1.1.1.3 Config.in
484 --- arch/cris/drivers/Config.in 25 May 2002 16:26:27 -00001.1.1.3
485 +++ arch/cris/drivers/Config.in16 Oct 2002 23:00:57 -0000
486@@ -111,11 +111,11 @@ if [ "$CONFIG_ETRAX_IDE" = "y" ]; then
487 # general ide drivers so the common case does not need to go
488 # into that config submenu. enable disk and CD support. others
489 # need to go fiddle in the submenu..
490 -define_bool CONFIG_IDE y
491 +define_tristate CONFIG_IDE y
492
493 -define_bool CONFIG_BLK_DEV_IDE y
494 -define_bool CONFIG_BLK_DEV_IDEDISK y
495 -define_bool CONFIG_BLK_DEV_IDECD y
496 +define_tristate CONFIG_BLK_DEV_IDE y
497 +define_tristate CONFIG_BLK_DEV_IDEDISK y
498 +define_tristate CONFIG_BLK_DEV_IDECD y
499
500 define_bool CONFIG_BLK_DEV_IDEDMA y
501
502@@ -127,7 +127,7 @@ if [ "$CONFIG_ETRAX_IDE" = "y" ]; then
503 Port_CSE1_Bit_16 CONFIG_ETRAX_IDE_CSE1_16_RESET\
504 Port_CSP0_Bit_08 CONFIG_ETRAX_IDE_CSP0_8_RESET" Port_PB_Bit_7
505 else
506 -define_bool CONFIG_IDE n
507 +define_tristate CONFIG_IDE n
508 fi
509
510 bool 'Axis flash-map support' CONFIG_ETRAX_AXISFLASHMAP
511@@ -136,17 +136,17 @@ if [ "$CONFIG_ETRAX_AXISFLASHMAP" = "y"
512 int ' Byte-offset of partition table sector' CONFIG_ETRAX_PTABLE_SECTOR 65536
513 # here we define the CONFIG_'s necessary to enable MTD support
514 # for the flash
515 -define_bool CONFIG_MTD y
516 +define_tristate CONFIG_MTD y
517
518 -define_bool CONFIG_MTD_CFI y
519 -define_bool CONFIG_MTD_CFI_INTELEXT n
520 -define_bool CONFIG_MTD_CFI_AMDSTD y
521 +define_tristate CONFIG_MTD_CFI y
522 +define_tristate CONFIG_MTD_CFI_INTELEXT n
523 +define_tristate CONFIG_MTD_CFI_AMDSTD y
524
525 -define_bool CONFIG_MTD_AMDSTD y
526 +define_tristate CONFIG_MTD_AMDSTD y
527
528 -define_bool CONFIG_MTD_CHAR y
529 -define_bool CONFIG_MTD_BLOCK y
530 -define_bool CONFIG_MTD_PARTITIONS y
531 +define_tristate CONFIG_MTD_CHAR y
532 +define_tristate CONFIG_MTD_BLOCK y
533 +define_tristate CONFIG_MTD_PARTITIONS y
534 fi
535
536 bool 'I2C support' CONFIG_ETRAX_I2C
537@@ -182,11 +182,11 @@ fi
538
539 bool 'USB host' CONFIG_ETRAX_USB_HOST
540 if [ "$CONFIG_ETRAX_USB_HOST" = "y" ]; then
541 -define_bool CONFIG_USB y
542 +define_tristate CONFIG_USB y
543 bool ' USB port 1 enabled' CONFIG_ETRAX_USB_HOST_PORT1
544 bool ' USB port 2 enabled' CONFIG_ETRAX_USB_HOST_PORT2
545 else
546 -define_bool CONFIG_USB n
547 +define_tristate CONFIG_USB n
548 fi
549
550 bool 'DS1302 Real Time Clock support' CONFIG_ETRAX_DS1302
551Index: arch/i386/config.in
552===================================================================
553RCS file: /usr/src/cvsroot/linux-2.5/arch/i386/config.in,v
554retrieving revision 1.1.1.28
555diff -u -p -r1.1.1.28 config.in
556 --- arch/i386/config.in 16 Oct 2002 19:44:19 -00001.1.1.28
557 +++ arch/i386/config.in16 Oct 2002 23:00:59 -0000
558@@ -185,6 +185,7 @@ else
559 fi
560 fi
561 fi
562+ define_bool CONFIG_X86_UP_APIC y
563 fi
564
565 bool 'Machine Check Exception' CONFIG_X86_MCE
566@@ -313,8 +314,8 @@ if [ "$CONFIG_HOTPLUG" = "y" ] ; then
567 source drivers/pcmcia/Config.in
568 source drivers/hotplug/Config.in
569 else
570- define_bool CONFIG_PCMCIA n
571- define_bool CONFIG_HOTPLUG_PCI n
572+ define_tristate CONFIG_PCMCIA n
573+ define_tristate CONFIG_HOTPLUG_PCI n
574 fi
575
576 endmenu
577@@ -423,10 +424,10 @@ if [ "$CONFIG_VT" = "y" ]; then
578 comment 'Console drivers'
579 bool 'VGA text console' CONFIG_VGA_CONSOLE
580 bool 'Video mode selection support' CONFIG_VIDEO_SELECT
581- if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
582+ #if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
583 tristate 'MDA text console (dual-headed) (EXPERIMENTAL)' CONFIG_MDA_CONSOLE
584 source drivers/video/Config.in
585- fi
586+ #fi
587 endmenu
588 fi
589
590@@ -480,3 +481,4 @@ if [ "$CONFIG_SMP" = "y" ]; then
591 fi
592
593 define_bool CONFIG_X86_BIOS_REBOOT y
594+source config.undef
595Index: arch/ia64/config.in
596===================================================================
597RCS file: /usr/src/cvsroot/linux-2.5/arch/ia64/config.in,v
598retrieving revision 1.1.1.16
599diff -u -p -r1.1.1.16 config.in
600 --- arch/ia64/config.in 12 Oct 2002 11:52:18 -00001.1.1.16
601 +++ arch/ia64/config.in16 Oct 2002 23:01:01 -0000
602 @@ -28,17 +28,27 @@ choice 'IA-64 system type' \
603
604 if [ "$CONFIG_ITANIUM" = "y" ]; then
605 choice 'Kernel page size' \
606 - "4KB CONFIG_IA64_PAGE_SIZE_4KB \
607 - 8KB CONFIG_IA64_PAGE_SIZE_8KB \
608 - 16KB CONFIG_IA64_PAGE_SIZE_16KB" 16KB
609 + "4KB CONFIG_IA64_PAGE_SIZE_4KB_1 \
610 + 8KB CONFIG_IA64_PAGE_SIZE_8KB_1 \
611 + 16KB CONFIG_IA64_PAGE_SIZE_16KB_1" 16KB
612 else
613 choice 'Kernel page size' \
614 - "4KB CONFIG_IA64_PAGE_SIZE_4KB \
615 - 8KB CONFIG_IA64_PAGE_SIZE_8KB \
616 - 16KB CONFIG_IA64_PAGE_SIZE_16KB \
617 + "4KB CONFIG_IA64_PAGE_SIZE_4KB_2 \
618 + 8KB CONFIG_IA64_PAGE_SIZE_8KB_2 \
619 + 16KB CONFIG_IA64_PAGE_SIZE_16KB_2 \
620 64KB CONFIG_IA64_PAGE_SIZE_64KB" 16KB
621 fi
622
623+if [ "$CONFIG_IA64_PAGE_SIZE_4KB_1" = "y" -o "$CONFIG_IA64_PAGE_SIZE_4KB_2" = "y" ]; then
624+ define_bool CONFIG_IA64_PAGE_SIZE_4KB y
625+fi
626+if [ "$CONFIG_IA64_PAGE_SIZE_8KB_1" = "y" -o "$CONFIG_IA64_PAGE_SIZE_8KB_2" = "y" ]; then
627+ define_bool CONFIG_IA64_PAGE_SIZE_8KB y
628+fi
629+if [ "$CONFIG_IA64_PAGE_SIZE_16KB_1" = "y" -o "$CONFIG_IA64_PAGE_SIZE_16KB_2" = "y" ]; then
630+ define_bool CONFIG_IA64_PAGE_SIZE_16KB y
631+fi
632+
633 if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
634 define_bool CONFIG_ACPI y
635 define_bool CONFIG_ACPI_EFI y
636@@ -64,7 +74,7 @@ if [ "$CONFIG_MCKINLEY" = "y" ]; then
637 fi
638 fi
639
640-if [ "$CONFIG_IA64_GENERIC" = "y" -o "$CONFIG_IA64_DIG" = "y" -o "$CONFIG_IA64_HP_ZX1" = "y" ];
641+if [ "$CONFIG_IA64_GENERIC" = "y" -o "$CONFIG_IA64_DIG" = "y" -o "$CONFIG_IA64_HP_ZX1" = "y" ]
642 then
643 bool ' Enable IA-64 Machine Check Abort' CONFIG_IA64_MCA
644 define_bool CONFIG_PM y
645@@ -95,23 +105,42 @@ if [ "$CONFIG_HUGETLB_PAGE" = "y" ]; the
646 if [ "$CONFIG_MCKINLEY" = "y" ]; then
647 choice ' IA-64 Huge TLB Page Size' \
648 "4GB CONFIG_HUGETLB_PAGE_SIZE_4GB \
649 - 256MB CONFIG_HUGETLB_PAGE_SIZE_256MB \
650 - 64MB CONFIG_HUGETLB_PAGE_SIZE_64MB \
651 - 16MB CONFIG_HUGETLB_PAGE_SIZE_16MB \
652 - 4MB CONFIG_HUGETLB_PAGE_SIZE_4MB \
653 - 1MB CONFIG_HUGETLB_PAGE_SIZE_1MB \
654 - 256KB CONFIG_HUGETLB_PAGE_SIZE_256KB" 16MB
655 + 256MB CONFIG_HUGETLB_PAGE_SIZE_256MB_1 \
656 + 64MB CONFIG_HUGETLB_PAGE_SIZE_64MB_1 \
657 + 16MB CONFIG_HUGETLB_PAGE_SIZE_16MB_1 \
658 + 4MB CONFIG_HUGETLB_PAGE_SIZE_4MB_1 \
659 + 1MB CONFIG_HUGETLB_PAGE_SIZE_1MB_1 \
660 + 256KB CONFIG_HUGETLB_PAGE_SIZE_256KB_1" 16MB
661 else
662 choice ' IA-64 Huge TLB Page Size' \
663 - "256MB CONFIG_HUGETLB_PAGE_SIZE_256MB \
664 - 64MB CONFIG_HUGETLB_PAGE_SIZE_64MB \
665 - 16MB CONFIG_HUGETLB_PAGE_SIZE_16MB \
666 - 4MB CONFIG_HUGETLB_PAGE_SIZE_4MB \
667 - 1MB CONFIG_HUGETLB_PAGE_SIZE_1MB \
668 - 256KB CONFIG_HUGETLB_PAGE_SIZE_256KB" 16MB
669 + "256MB CONFIG_HUGETLB_PAGE_SIZE_256MB_2 \
670 + 64MB CONFIG_HUGETLB_PAGE_SIZE_64MB_2 \
671 + 16MB CONFIG_HUGETLB_PAGE_SIZE_16MB_2 \
672 + 4MB CONFIG_HUGETLB_PAGE_SIZE_4MB_2 \
673 + 1MB CONFIG_HUGETLB_PAGE_SIZE_1MB_2 \
674 + 256KB CONFIG_HUGETLB_PAGE_SIZE_256KB_2" 16MB
675 fi
676 fi
677
678+if [ "$CONFIG_HUGETLB_PAGE_SIZE_256MB_1" = "y" -o "$CONFIG_HUGETLB_PAGE_SIZE_256MB_2" = "y" ]; then
679+ define_bool CONFIG_HUGETLB_PAGE_SIZE_256MB y
680+fi
681+if [ "$CONFIG_HUGETLB_PAGE_SIZE_64MB_1" = "y" -o "$CONFIG_HUGETLB_PAGE_SIZE_64MB_2" = "y" ]; then
682+ define_bool CONFIG_HUGETLB_PAGE_SIZE_64MB y
683+fi
684+if [ "$CONFIG_HUGETLB_PAGE_SIZE_16MB_1" = "y" -o "$CONFIG_HUGETLB_PAGE_SIZE_16MB_2" = "y" ]; then
685+ define_bool CONFIG_HUGETLB_PAGE_SIZE_16MB y
686+fi
687+if [ "$CONFIG_HUGETLB_PAGE_SIZE_4MB_1" = "y" -o "$CONFIG_HUGETLB_PAGE_SIZE_4MB_2" = "y" ]; then
688+ define_bool CONFIG_HUGETLB_PAGE_SIZE_4MB y
689+fi
690+if [ "$CONFIG_HUGETLB_PAGE_SIZE_1MB_1" = "y" -o "$CONFIG_HUGETLB_PAGE_SIZE_1MB_2" = "y" ]; then
691+ define_bool CONFIG_HUGETLB_PAGE_SIZE_1MB y
692+fi
693+if [ "$CONFIG_HUGETLB_PAGE_SIZE_256KB_1" = "y" -o "$CONFIG_HUGETLB_PAGE_SIZE_256KB_2" = "y" ]; then
694+ define_bool CONFIG_HUGETLB_PAGE_SIZE_256KB y
695+fi
696+
697 bool 'SMP support' CONFIG_SMP
698 bool 'Support running of Linux/x86 binaries' CONFIG_IA32_SUPPORT
699 bool 'Performance monitor support' CONFIG_PERFMON
700@@ -125,7 +154,7 @@ fi
701 tristate 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF
702 tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC
703
704-if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
705+#if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
706 source drivers/acpi/Config.in
707
708 bool 'PCI support' CONFIG_PCI
709@@ -136,15 +165,15 @@ if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
710 source drivers/hotplug/Config.in
711 source drivers/pcmcia/Config.in
712 else
713- define_bool CONFIG_PCMCIA n
714+ define_tristate CONFIG_PCMCIA n
715 fi
716
717 source drivers/parport/Config.in
718-fi # !HP_SIM
719+#fi # !HP_SIM
720
721 endmenu
722
723-if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
724+#if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
725 source drivers/mtd/Config.in
726 source drivers/pnp/Config.in
727 source drivers/block/Config.in
728@@ -164,7 +193,7 @@ if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
729 define_bool CONFIG_BLK_DEV_HD n
730 fi
731 endmenu
732-fi
733+#fi
734
735 mainmenu_option next_comment
736 comment 'SCSI support'
737@@ -180,7 +209,7 @@ if [ "$CONFIG_NET" = "y" ]; then
738 source net/Config.in
739 fi
740
741-if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
742+#if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
743 if [ "$CONFIG_NET" = "y" ]; then
744 mainmenu_option next_comment
745 comment 'Network device support'
746@@ -212,7 +241,8 @@ if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
747 #source drivers/misc/Config.in
748
749 source drivers/media/Config.in
750-else # HP_SIM
751+#else # HP_SIM
752+if [ "$CONFIG_IA64_HP_SIM" != "n" ]; then
753
754 mainmenu_option next_comment
755 comment 'Block devices'
756@@ -228,7 +258,7 @@ fi # HP_SIM
757
758 source fs/Config.in
759
760-if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
761+#if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
762 if [ "$CONFIG_VT" = "y" ]; then
763 mainmenu_option next_comment
764 comment 'Console drivers'
765@@ -252,7 +282,7 @@ if [ "$CONFIG_IA64_HP_SIM" = "n" ]; then
766 source drivers/usb/Config.in
767 source lib/Config.in
768 source net/bluetooth/Config.in
769-fi # !HP_SIM
770+#fi # !HP_SIM
771
772 if [ "$CONFIG_IA64_HP_SIM" != "n" -o "$CONFIG_IA64_GENERIC" != "n" ]; then
773 source arch/ia64/hp/sim/Config.in
774@@ -288,3 +318,4 @@ fi
775 endmenu
776
777 source security/Config.in
778+source config.undef
779Index: arch/m68k/config.in
780===================================================================
781RCS file: /usr/src/cvsroot/linux-2.5/arch/m68k/config.in,v
782retrieving revision 1.1.1.13
783diff -u -p -r1.1.1.13 config.in
784 --- arch/m68k/config.in 12 Oct 2002 11:51:33 -00001.1.1.13
785 +++ arch/m68k/config.in16 Oct 2002 23:01:03 -0000
786@@ -18,7 +18,7 @@ comment 'Platform dependent setup'
787
788 define_bool CONFIG_EISA n
789 define_bool CONFIG_MCA n
790-define_bool CONFIG_PCMCIA n
791+define_tristate CONFIG_PCMCIA n
792
793 bool 'Amiga support' CONFIG_AMIGA
794 bool 'Atari support' CONFIG_ATARI
795@@ -141,9 +141,9 @@ fi
796 source drivers/pci/Config.in
797 source drivers/zorro/Config.in
798
799-if [ "$CONFIG_Q40" = "y" ]; then
800+#if [ "$CONFIG_Q40" = "y" ]; then
801 source drivers/pnp/Config.in
802-fi
803+#fi
804
805 endmenu
806
807@@ -153,9 +153,9 @@ source drivers/block/Config.in
808
809 source drivers/md/Config.in
810
811-if [ "$CONFIG_MAC" = "y" ]; then
812+#if [ "$CONFIG_MAC" = "y" ]; then
813 source drivers/input/Config.in
814-fi
815+#fi
816
817 mainmenu_option next_comment
818 comment 'ATA/ATAPI/MFM/RLL device support'
819@@ -504,7 +504,7 @@ if [ "$CONFIG_ATARI" = "y" ]; then
820 bool 'Enhanced Real Time Clock Support' CONFIG_RTC
821 else
822 if [ "$CONFIG_SUN3" = "y" ]; then
823- define_bool CONFIG_GEN_RTC y
824+ define_tristate CONFIG_GEN_RTC y
825 else
826 tristate 'Generic /dev/rtc emulation' CONFIG_GEN_RTC
827 fi
828@@ -548,3 +548,4 @@ endmenu
829
830 source security/Config.in
831 source lib/Config.in
832+source config.undef
833Index: arch/mips/config.in
834===================================================================
835RCS file: /usr/src/cvsroot/linux-2.5/arch/mips/config.in,v
836retrieving revision 1.1.1.13
837diff -u -p -r1.1.1.13 config.in
838 --- arch/mips/config.in 12 Oct 2002 11:50:54 -00001.1.1.13
839 +++ arch/mips/config.in16 Oct 2002 23:01:07 -0000
840@@ -25,7 +25,7 @@ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; the
841 choice 'Galileo Chip Clock' \
842 "75 CONFIG_SYSCLK_75\
843 83.3 CONFIG_SYSCLK_83\
844- 100 CONFIG_SYSCLK_100" CONFIG_SYSCLK_83
845+ 100 CONFIG_SYSCLK_100_1" CONFIG_SYSCLK_83
846 fi
847 bool 'Support for MIPS Atlas board (EXPERIMENTAL)' CONFIG_MIPS_ATLAS
848 bool 'Support for MIPS Malta board (EXPERIMENTAL)' CONFIG_MIPS_MALTA
849@@ -84,8 +84,12 @@ unset CONFIG_SWAP_IO_SPACE
850 unset CONFIG_VIDEO_G364
851 unset CONFIG_PC_KEYB
852
853+define_bool CONFIG_ISA n
854+define_bool CONFIG_EISA n
855+define_bool CONFIG_PCI n
856 define_bool CONFIG_MCA n
857 define_bool CONFIG_SBUS n
858+define_bool CONFIG_I8259 n
859
860 if [ "$CONFIG_MIPS_EV96100" = "y" ]; then
861 define_bool CONFIG_PCI y
862@@ -138,7 +142,7 @@ if [ "$CONFIG_MIPS_MALTA" = "y" ]; then
863 fi
864 if [ "$CONFIG_MOMENCO_OCELOT" = "y" ]; then
865 define_bool CONFIG_PCI y
866- define_bool CONFIG_SYSCLK_100 y
867+ define_bool CONFIG_SYSCLK_100_2 y
868 define_bool CONFIG_SWAP_IO_SPACE y
869 define_bool CONFIG_NEW_IRQ y
870 define_bool CONFIG_OLD_TIME_C y
871@@ -201,19 +205,11 @@ if [ "$CONFIG_NINO" = "y" ]; then
872 define_bool CONFIG_PC_KEYB y
873 fi
874
875-if [ "$CONFIG_ISA" != "y" ]; then
876- define_bool CONFIG_ISA n
877- define_bool CONFIG_EISA n
878-else
879+if [ "$CONFIG_ISA" = "y" ]; then
880 define_bool CONFIG_EISA y
881 fi
882-
883-if [ "$CONFIG_PCI" != "y" ]; then
884- define_bool CONFIG_PCI n
885-fi
886-
887-if [ "$CONFIG_I8259" != "y" ]; then
888- define_bool CONFIG_I8259 n
889+if [ "$CONFIG_SYSCLK_100_1" = "y" -o "$CONFIG_SYSCLK_100_2" = "y" ]; then
890+ define_bool CONFIG_SYSCLK_100 y
891 fi
892 endmenu
893
894@@ -302,7 +298,7 @@ bool 'Support for hot-pluggable devices'
895 if [ "$CONFIG_HOTPLUG" = "y" ] ; then
896 source drivers/pcmcia/Config.in
897 else
898- define_bool CONFIG_PCMCIA n
899+ define_tristate CONFIG_PCMCIA n
900 fi
901
902 if [ "$CONFIG_DECSTATION" = "y" ]; then
903@@ -313,9 +309,9 @@ if [ "$CONFIG_DECSTATION" = "y" ]; then
904 fi
905 endmenu
906
907-if [ "$CONFIG_ISA" = "y" ]; then
908+#if [ "$CONFIG_ISA" = "y" ]; then
909 source drivers/pnp/Config.in
910-fi
911+#fi
912
913 source drivers/mtd/Config.in
914
915@@ -351,10 +347,10 @@ if [ "$CONFIG_SCSI" != "n" ]; then
916 fi
917 endmenu
918
919-if [ "$CONFIG_DECSTATION" != "y" -a \
920- "$CONFIG_SGI_IP22" != "y" ]; then
921+#if [ "$CONFIG_DECSTATION" != "y" -a \
922+# "$CONFIG_SGI_IP22" != "y" ]; then
923 source drivers/message/i2o/Config.in
924-fi
925+#fi
926
927 if [ "$CONFIG_NET" = "y" ]; then
928 source net/Config.in
929@@ -418,7 +414,7 @@ if [ "$CONFIG_DECSTATION" = "y" ]; then
930 # if [ "$CONFIG_ACCESSBUS" = "y" ]; then
931 # bool 'MAXINE Access.Bus mouse (VSXXX-BB/GB) support' CONFIG_DTOP_MOUSE
932 # fi
933- bool 'Enhanced Real Time Clock Support' CONFIG_RTC
934+ tristate 'Enhanced Real Time Clock Support' CONFIG_RTC
935
936 endmenu
937 fi
938@@ -453,10 +449,10 @@ if [ "$CONFIG_VT" = "y" ]; then
939 mainmenu_option next_comment
940 comment 'Console drivers'
941 bool 'VGA text console' CONFIG_VGA_CONSOLE
942- if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
943+ #if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
944 tristate 'MDA text console (dual-headed) (EXPERIMENTAL)' CONFIG_MDA_CONSOLE
945 source drivers/video/Config.in
946- fi
947+ #fi
948 endmenu
949 fi
950
951@@ -498,3 +494,4 @@ endmenu
952
953 source security/Config.in
954 source lib/Config.in
955+source config.undef
956Index: arch/mips64/config.in
957===================================================================
958RCS file: /usr/src/cvsroot/linux-2.5/arch/mips64/config.in,v
959retrieving revision 1.1.1.12
960diff -u -p -r1.1.1.12 config.in
961 --- arch/mips64/config.in 12 Oct 2002 11:52:33 -00001.1.1.12
962 +++ arch/mips64/config.in16 Oct 2002 23:01:09 -0000
963@@ -24,10 +24,6 @@ if [ "$CONFIG_SGI_IP27" = "y" ]; then
964 fi
965 endmenu
966
967-define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y
968-define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n
969-define_bool CONFIG_GENERIC_ISA_DMA y
970-
971 #
972 # Select some configuration options automatically based on user selections
973 #
974@@ -42,6 +38,13 @@ unset CONFIG_ISA
975 unset CONFIG_MAPPED_PCI_IO
976 unset CONFIG_PCI
977
978+define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y
979+define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n
980+define_bool CONFIG_GENERIC_ISA_DMA y
981+define_bool CONFIG_PCI n
982+define_bool CONFIG_ISA n
983+define_bool CONFIG_EISA n
984+
985 if [ "$CONFIG_SGI_IP22" = "y" ]; then
986 define_bool CONFIG_BOOT_ELF32 y
987 define_bool CONFIG_ARC32 y
988@@ -61,17 +64,10 @@ if [ "$CONFIG_SGI_IP27" = "y" ]; then
989 define_int CONFIG_L1_CACHE_SHIFT 7
990 fi
991
992-if [ "$CONFIG_ISA" != "y" ]; then
993- define_bool CONFIG_ISA n
994- define_bool CONFIG_EISA n
995-else
996+if [ "$CONFIG_ISA" = "y" ]; then
997 define_bool CONFIG_EISA y
998 fi
999
1000-if [ "$CONFIG_PCI" != "y" ]; then
1001- define_bool CONFIG_PCI n
1002-fi
1003-
1004 define_bool CONFIG_MCA n
1005 define_bool CONFIG_SBUS n
1006
1007@@ -99,14 +95,12 @@ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; the
1008 bool 'Kernel floating-point emulation' CONFIG_MIPS_FPU_EMULATOR
1009 fi
1010
1011-source drivers/pci/Config.in
1012-
1013 bool 'Support for hot-pluggable devices' CONFIG_HOTPLUG
1014
1015 if [ "$CONFIG_HOTPLUG" = "y" ] ; then
1016 source drivers/pcmcia/Config.in
1017 else
1018- define_bool CONFIG_PCMCIA n
1019+ define_tristate CONFIG_PCMCIA n
1020 fi
1021
1022 if [ "$CONFIG_ARC32" = "y" ]; then
1023@@ -252,3 +246,4 @@ endmenu
1024
1025 source security/Config.in
1026 source lib/Config.in
1027+source config.undef
1028Index: arch/parisc/config.in
1029===================================================================
1030RCS file: /usr/src/cvsroot/linux-2.5/arch/parisc/config.in,v
1031retrieving revision 1.1.1.10
1032diff -u -p -r1.1.1.10 config.in
1033 --- arch/parisc/config.in 12 Oct 2002 11:52:43 -00001.1.1.10
1034 +++ arch/parisc/config.in16 Oct 2002 23:01:10 -0000
1035@@ -196,3 +196,4 @@ endmenu
1036
1037 source security/Config.in
1038 source lib/Config.in
1039+source config.undef
1040Index: arch/ppc/config.in
1041===================================================================
1042RCS file: /usr/src/cvsroot/linux-2.5/arch/ppc/config.in,v
1043retrieving revision 1.1.1.21
1044diff -u -p -r1.1.1.21 config.in
1045 --- arch/ppc/config.in 12 Oct 2002 11:51:09 -00001.1.1.21
1046 +++ arch/ppc/config.in16 Oct 2002 23:01:12 -0000
1047@@ -55,7 +55,7 @@ if [ "$CONFIG_8260" = "y" ]; then
1048 SBS8260 CONFIG_SBS8260\
1049 RPXSUPER CONFIG_RPX6\
1050 TQM8260 CONFIG_TQM8260\
1051 - Willow CONFIG_WILLOW"Willow
1052 + Willow CONFIG_WILLOW_1"Willow
1053 fi
1054
1055 if [ "$CONFIG_40x" = "y" ]; then
1056@@ -114,9 +114,9 @@ fi
1057
1058 if [ "$CONFIG_6xx" = "y" -a "$CONFIG_8260" = "n" ]; then
1059 choice 'Machine Type' \
1060 - "CHRP/PowerMac/PReP CONFIG_ALL_PPC \
1061 + "CHRP/PowerMac/PReP CONFIG_ALL_PPC_CH\
1062 Amiga-APUS CONFIG_APUS \
1063 - Cogent-Willow CONFIG_WILLOW \
1064 + Cogent-Willow CONFIG_WILLOW_2 \
1065 Force-PowerCore CONFIG_PCORE \
1066 Force-PowerPMC250 CONFIG_POWERPMC250\
1067 Galileo-EV-64260-BP CONFIG_EV64260 \
1068@@ -145,6 +145,14 @@ if [ "$CONFIG_6xx" = "y" -a "$CONFIG_826
1069 fi
1070 fi
1071
1072+if [ "$CONFIG_POWER3" = "y" -o "$CONFIG_ALL_PPC_CH" = "y" ]; then
1073+ define_bool CONFIG_ALL_PPC y
1074+fi
1075+
1076+if [ "$CONFIG_WILLOW_1" = "y" -o "$CONFIG_WILLOW_2" = "y" ]; then
1077+ define_bool CONFIG_WILLOW y
1078+fi
1079+
1080 if [ "$CONFIG_FORCE" = "y" -o "$CONFIG_MENF1" = "y" \
1081 -o "$CONFIG_SANDPOINT" = "y" -o "$CONFIG_ZX4500" = "y" ]; then
1082 bool 'Enable MPC10x store gathering' CONFIG_MPC10X_STORE_GATHERING
1083@@ -314,7 +322,7 @@ bool 'Support for hot-pluggable devices'
1084 if [ "$CONFIG_HOTPLUG" = "y" ]; then
1085 source drivers/pcmcia/Config.in
1086 else
1087- define_bool CONFIG_PCMCIA n
1088+ define_tristate CONFIG_PCMCIA n
1089 fi
1090
1091 source drivers/parport/Config.in
1092@@ -488,7 +496,7 @@ if [ "$CONFIG_PPC_ISERIES" = "y" ]; then
1093 fi
1094 if [ "$CONFIG_VIOCD" = "y" ]; then
1095 define_bool CONFIG_CD_NO_IDESCSI y
1096- define_bool CONFIG_BLK_DEV_IDECD y
1097+ define_tristate CONFIG_BLK_DEV_IDECD y
1098 fi
1099 endmenu
1100 else
1101@@ -617,3 +625,4 @@ endmenu
1102
1103 source security/Config.in
1104
1105+source config.undef
1106Index: arch/ppc64/config.in
1107===================================================================
1108RCS file: /usr/src/cvsroot/linux-2.5/arch/ppc64/config.in,v
1109retrieving revision 1.1.1.12
1110diff -u -p -r1.1.1.12 config.in
1111 --- arch/ppc64/config.in 12 Oct 2002 11:52:54 -00001.1.1.12
1112 +++ arch/ppc64/config.in16 Oct 2002 23:01:13 -0000
1113@@ -68,8 +68,8 @@ if [ "$CONFIG_HOTPLUG" = "y" ]; then
1114 source drivers/pcmcia/Config.in
1115 source drivers/hotplug/Config.in
1116 else
1117- define_bool CONFIG_PCMCIA n
1118- define_bool CONFIG_HOTPLUG_PCI n
1119+ define_tristate CONFIG_PCMCIA n
1120+ define_tristate CONFIG_HOTPLUG_PCI n
1121 fi
1122
1123 if [ "$CONFIG_PPC_ISERIES" != "y" ]; then
1124@@ -207,3 +207,4 @@ endmenu
1125
1126 source security/Config.in
1127 source lib/Config.in
1128+source config.undef
1129Index: arch/s390/config.in
1130===================================================================
1131RCS file: /usr/src/cvsroot/linux-2.5/arch/s390/config.in,v
1132retrieving revision 1.1.1.7
1133diff -u -p -r1.1.1.7 config.in
1134 --- arch/s390/config.in 12 Oct 2002 11:52:41 -00001.1.1.7
1135 +++ arch/s390/config.in16 Oct 2002 23:01:15 -0000
1136@@ -77,3 +77,4 @@ endmenu
1137
1138 source security/Config.in
1139 source lib/Config.in
1140+source config.undef
1141Index: arch/s390x/config.in
1142===================================================================
1143RCS file: /usr/src/cvsroot/linux-2.5/arch/s390x/config.in,v
1144retrieving revision 1.1.1.7
1145diff -u -p -r1.1.1.7 config.in
1146 --- arch/s390x/config.in 12 Oct 2002 11:52:52 -00001.1.1.7
1147 +++ arch/s390x/config.in16 Oct 2002 23:01:15 -0000
1148@@ -81,3 +81,4 @@ endmenu
1149
1150 source security/Config.in
1151 source lib/Config.in
1152+source config.undef
1153Index: arch/sh/config.in
1154===================================================================
1155RCS file: /usr/src/cvsroot/linux-2.5/arch/sh/config.in,v
1156retrieving revision 1.1.1.10
1157diff -u -p -r1.1.1.10 config.in
1158 --- arch/sh/config.in 27 Aug 2002 23:43:48 -00001.1.1.10
1159 +++ arch/sh/config.in16 Oct 2002 23:01:15 -0000
1160@@ -186,7 +186,7 @@ bool 'Support for hot-pluggable devices'
1161 if [ "$CONFIG_HOTPLUG" = "y" ] ; then
1162 source drivers/pcmcia/Config.in
1163 else
1164- define_bool CONFIG_PCMCIA n
1165+ define_tristate CONFIG_PCMCIA n
1166 fi
1167
1168 if [ "$CONFIG_PROC_FS" = "y" ]; then
1169@@ -261,9 +261,9 @@ endmenu
1170 #
1171 source drivers/input/Config.in
1172
1173-if [ "$CONFIG_SH_DREAMCAST" = "y" ]; then
1174- source drivers/maple/Config.in
1175-fi
1176+#if [ "$CONFIG_SH_DREAMCAST" = "y" ]; then
1177+# source drivers/maple/Config.in
1178+#fi
1179
1180 mainmenu_option next_comment
1181 comment 'Character devices'
1182@@ -306,7 +306,7 @@ if [ "$CONFIG_SH_DREAMCAST" = "y" -a "$C
1183 endmenu
1184 fi
1185
1186-source drivers/char/joystick/Config.in
1187+#source drivers/char/joystick/Config.in
1188
1189 if [ "$CONFIG_PARPORT" != "n" ]; then
1190 dep_tristate 'Parallel printer support' CONFIG_PRINTER $CONFIG_PARPORT
1191@@ -341,10 +341,10 @@ if [ "$CONFIG_VT" = "y" ]; then
1192 comment 'Console drivers'
1193 bool 'VGA text console' CONFIG_VGA_CONSOLE
1194 bool 'Video mode selection support' CONFIG_VIDEO_SELECT
1195- if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
1196+ #if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
1197 tristate 'MDA text console (dual-headed) (EXPERIMENTAL)' CONFIG_MDA_CONSOLE
1198 source drivers/video/Config.in
1199- fi
1200+ #fi
1201 endmenu
1202 fi
1203
1204@@ -370,3 +370,4 @@ endmenu
1205
1206 source security/Config.in
1207 source lib/Config.in
1208+source config.undef
1209Index: arch/sparc/config.in
1210===================================================================
1211RCS file: /usr/src/cvsroot/linux-2.5/arch/sparc/config.in,v
1212retrieving revision 1.1.1.15
1213diff -u -p -r1.1.1.15 config.in
1214 --- arch/sparc/config.in 12 Oct 2002 11:50:47 -00001.1.1.15
1215 +++ arch/sparc/config.in16 Oct 2002 23:01:16 -0000
1216@@ -30,7 +30,7 @@ define_bool CONFIG_SPARC32 y
1217 define_bool CONFIG_ISA n
1218 define_bool CONFIG_EISA n
1219 define_bool CONFIG_MCA n
1220-define_bool CONFIG_PCMCIA n
1221+define_tristate CONFIG_PCMCIA n
1222 define_bool CONFIG_SBUS y
1223 define_bool CONFIG_SBUSCHAR y
1224 define_bool CONFIG_SERIAL_CONSOLE y
1225@@ -41,10 +41,11 @@ define_bool CONFIG_RWSEM_XCHGADD_ALGORIT
1226 define_bool CONFIG_SUN_PM y
1227
1228 bool 'Support for SUN4 machines (disables SUN4[CDM] support)' CONFIG_SUN4
1229-if [ "$CONFIG_SUN4" != "y" ]; then
1230+#if [ "$CONFIG_SUN4" != "y" ]; then
1231 bool 'Support for PCI and PS/2 keyboard/mouse' CONFIG_PCI
1232 source drivers/pci/Config.in
1233-else
1234+#else
1235+if [ "$CONFIG_SUN4" = "y" ]; then
1236 define_bool CONFIG_PCI n
1237 fi
1238
1239@@ -72,9 +73,9 @@ endmenu
1240 source drivers/mtd/Config.in
1241
1242 source drivers/serial/Config.in
1243-if [ "$CONFIG_SUN4" != "y" ]; then
1244+#if [ "$CONFIG_SUN4" != "y" ]; then
1245 source drivers/sbus/char/Config.in
1246-fi
1247+#fi
1248
1249 mainmenu_option next_comment
1250 comment 'Block devices'
1251@@ -95,7 +96,7 @@ dep_bool ' Initial RAM disk (initrd) su
1252 endmenu
1253
1254 # Don't frighten a common SBus user
1255-if [ "$CONFIG_PCI" = "y" ]; then
1256+#if [ "$CONFIG_PCI" = "y" ]; then
1257
1258 mainmenu_option next_comment
1259 comment 'ATA/ATAPI/MFM/RLL support'
1260@@ -108,8 +109,9 @@ if [ "$CONFIG_PCI" = "y" ]; then
1261 define_bool CONFIG_BLK_DEV_HD n
1262 fi
1263 endmenu
1264-else
1265- define_bool CONFIG_IDE n
1266+#else
1267+if [ "$CONFIG_PCI" != "y" ]; then
1268+ define_tristate CONFIG_IDE n
1269 define_bool CONFIG_BLK_DEV_HD n
1270 fi
1271
1272@@ -226,6 +228,9 @@ source drivers/input/Config.in
1273
1274 source fs/Config.in
1275
1276+mainmenu_option next_comment
1277+comment 'Sound'
1278+
1279 tristate 'Sound card support' CONFIG_SOUND
1280 if [ "$CONFIG_SOUND" != "n" ]; then
1281 source sound/Config.in
1282@@ -253,3 +258,4 @@ endmenu
1283
1284 source security/Config.in
1285 source lib/Config.in
1286+source config.undef
1287Index: arch/sparc64/config.in
1288===================================================================
1289RCS file: /usr/src/cvsroot/linux-2.5/arch/sparc64/config.in,v
1290retrieving revision 1.1.1.15
1291diff -u -p -r1.1.1.15 config.in
1292 --- arch/sparc64/config.in 12 Oct 2002 11:51:46 -00001.1.1.15
1293 +++ arch/sparc64/config.in16 Oct 2002 23:01:17 -0000
1294@@ -35,17 +35,17 @@ define_bool CONFIG_RWSEM_GENERIC_SPINLOC
1295 define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y
1296 define_bool CONFIG_GENERIC_ISA_DMA y
1297 define_bool CONFIG_ISA n
1298-define_bool CONFIG_ISAPNP n
1299+define_bool CONFIG_ISAPNP n
1300 define_bool CONFIG_EISA n
1301 define_bool CONFIG_MCA n
1302-define_bool CONFIG_PCMCIA n
1303+define_tristate CONFIG_PCMCIA n
1304 define_bool CONFIG_SBUS y
1305 define_bool CONFIG_SBUSCHAR y
1306 define_bool CONFIG_SUN_AUXIO y
1307 define_bool CONFIG_SUN_IO y
1308 bool 'PCI support' CONFIG_PCI
1309 if [ "$CONFIG_PCI" = "y" ] ; then
1310- define_bool CONFIG_RTC y
1311+ define_tristate CONFIG_RTC y
1312 fi
1313 source drivers/pci/Config.in
1314
1315@@ -153,8 +153,9 @@ if [ "$CONFIG_SCSI" != "n" ]; then
1316 dep_tristate 'Sparc ESP Scsi Driver' CONFIG_SCSI_SUNESP $CONFIG_SCSI
1317 dep_tristate 'PTI Qlogic, ISP Driver' CONFIG_SCSI_QLOGICPTI $CONFIG_SCSI
1318
1319- if [ "$CONFIG_PCI" != "n" ]; then
1320+ #if [ "$CONFIG_PCI" != "n" ]; then
1321 source drivers/scsi/aic7xxx/Config.in
1322+ if [ "$CONFIG_PCI" != "n" ]; then
1323 if [ "$CONFIG_SCSI_AIC7XXX" != "y" ]; then
1324 dep_tristate 'Old Adaptec AIC7xxx support' CONFIG_SCSI_AIC7XXX_OLD $CONFIG_SCSI
1325 if [ "$CONFIG_SCSI_AIC7XXX_OLD" != "n" ]; then
1326@@ -202,9 +203,9 @@ endmenu
1327
1328 source drivers/fc4/Config.in
1329
1330-if [ "$CONFIG_PCI" = "y" ]; then
1331+#if [ "$CONFIG_PCI" = "y" ]; then
1332 source drivers/message/fusion/Config.in
1333-fi
1334+#fi
1335
1336 source drivers/ieee1394/Config.in
1337
1338@@ -296,3 +297,4 @@ endmenu
1339
1340 source security/Config.in
1341 source lib/Config.in
1342+source config.undef
1343Index: arch/um/config.in
1344===================================================================
1345RCS file: /usr/src/cvsroot/linux-2.5/arch/um/config.in,v
1346retrieving revision 1.1.1.3
1347diff -u -p -r1.1.1.3 config.in
1348 --- arch/um/config.in 16 Oct 2002 19:46:03 -00001.1.1.3
1349 +++ arch/um/config.in16 Oct 2002 23:01:18 -0000
1350@@ -91,3 +91,4 @@ fi
1351 dep_bool 'Enable gprof support' CONFIG_GPROF $CONFIG_DEBUGSYM
1352 dep_bool 'Enable gcov support' CONFIG_GCOV $CONFIG_DEBUGSYM
1353 endmenu
1354+source config.undef
1355Index: arch/x86_64/config.in
1356===================================================================
1357RCS file: /usr/src/cvsroot/linux-2.5/arch/x86_64/config.in,v
1358retrieving revision 1.1.1.11
1359diff -u -p -r1.1.1.11 config.in
1360 --- arch/x86_64/config.in 12 Oct 2002 11:53:03 -00001.1.1.11
1361 +++ arch/x86_64/config.in16 Oct 2002 23:01:20 -0000
1362@@ -90,7 +90,7 @@ if [ "$CONFIG_HOTPLUG" = "y" ] ; then
1363 source drivers/pcmcia/Config.in
1364 source drivers/hotplug/Config.in
1365 else
1366- define_bool CONFIG_PCMCIA n
1367+ define_tristate CONFIG_PCMCIA n
1368 fi
1369
1370 endmenu
1371@@ -193,10 +193,10 @@ if [ "$CONFIG_VT" = "y" ]; then
1372 comment 'Console drivers'
1373 bool 'VGA text console' CONFIG_VGA_CONSOLE
1374 bool 'Video mode selection support' CONFIG_VIDEO_SELECT
1375- if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
1376+ #if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
1377 tristate 'MDA text console (dual-headed) (EXPERIMENTAL)' CONFIG_MDA_CONSOLE
1378 source drivers/video/Config.in
1379- fi
1380+ #fi
1381 endmenu
1382 fi
1383
1384@@ -229,3 +229,4 @@ endmenu
1385
1386 source security/Config.in
1387 source lib/Config.in
1388+source config.undef
1389Index: drivers/acpi/Config.in
1390===================================================================
1391RCS file: /usr/src/cvsroot/linux-2.5/drivers/acpi/Config.in,v
1392retrieving revision 1.1.1.10
1393diff -u -p -r1.1.1.10 Config.in
1394 --- drivers/acpi/Config.in 27 Sep 2002 22:31:52 -00001.1.1.10
1395 +++ drivers/acpi/Config.in16 Oct 2002 23:01:21 -0000
1396@@ -51,10 +51,10 @@ if [ "$CONFIG_IA64" = "y" ]; then
1397 define_bool CONFIG_ACPI_POWER n
1398 define_bool CONFIG_ACPI_SYSTEM n
1399 define_bool CONFIG_ACPI_SLEEP n
1400- define_bool CONFIG_ACPI_BUTTON n
1401- define_bool CONFIG_ACPI_FAN n
1402- define_bool CONFIG_ACPI_PROCESSOR n
1403- define_bool CONFIG_ACPI_THERMAL n
1404+ define_tristate CONFIG_ACPI_BUTTON n
1405+ define_tristate CONFIG_ACPI_FAN n
1406+ define_tristate CONFIG_ACPI_PROCESSOR n
1407+ define_tristate CONFIG_ACPI_THERMAL n
1408 define_bool CONFIG_ACPI_NUMA y
1409 fi
1410
1411Index: drivers/char/agp/Config.in
1412===================================================================
1413RCS file: /usr/src/cvsroot/linux-2.5/drivers/char/agp/Config.in,v
1414retrieving revision 1.1.1.2
1415diff -u -p -r1.1.1.2 Config.in
1416 --- drivers/char/agp/Config.in 27 Sep 2002 22:30:24 -00001.1.1.2
1417 +++ drivers/char/agp/Config.in16 Oct 2002 23:01:24 -0000
1418@@ -1,8 +1,9 @@
1419
1420-if [ "$CONFIG_GART_IOMMU" = "y" ]; then
1421- dep_bool '/dev/agpgart (AGP Support)' CONFIG_AGP $CONFIG_DRM_AGP
1422+if [ "$CONFIG_GART_IOMMU" != "y" ]; then
1423+ tristate '/dev/agpgart (AGP Support)' CONFIG_AGP
1424 else
1425- dep_tristate '/dev/agpgart (AGP Support)' CONFIG_AGP $CONFIG_DRM_AGP
1426+ bool '/dev/agpgart (AGP Support)' CONFIG_AGP_GART
1427+ define_tristate CONFIG_AGP $CONFIG_AGP_GART
1428 fi
1429 if [ "$CONFIG_AGP" != "n" ]; then
1430 bool ' Intel 440LX/BX/GX and I815/I820/I830M/I830MP/I840/I845/I850/I860 support' CONFIG_AGP_INTEL
1431Index: drivers/message/fusion/Config.in
1432===================================================================
1433RCS file: /usr/src/cvsroot/linux-2.5/drivers/message/fusion/Config.in,v
1434retrieving revision 1.1.1.4
1435diff -u -p -r1.1.1.4 Config.in
1436 --- drivers/message/fusion/Config.in 16 Oct 2002 19:44:14 -00001.1.1.4
1437 +++ drivers/message/fusion/Config.in16 Oct 2002 23:01:29 -0000
1438@@ -18,10 +18,10 @@ if [ "$CONFIG_FUSION" = "y" -o "$CONFIG_
1439 dep_tristate " Fusion MPT misc device (ioctl) driver" CONFIG_FUSION_CTL $CONFIG_FUSION m
1440 fi
1441
1442- dep_tristate " Fusion MPT LAN driver" CONFIG_FUSION_LAN $CONFIG_FUSION $CONFIG_NET
1443- if [ "$CONFIG_FUSION_LAN" != "n" ]; then
1444- define_bool CONFIG_NET_FC y
1445- fi
1446+ dep_tristate " Fusion MPT LAN driver" CONFIG_FUSION_LAN $CONFIG_FUSION $CONFIG_NET $CONFIG_NET_FC
1447+# if [ "$CONFIG_FUSION_LAN" != "n" ]; then
1448+# define_bool CONFIG_NET_FC y
1449+# fi
1450
1451 else
1452
1453@@ -29,9 +29,9 @@ else
1454 # These <should> be define_tristate, but we leave them define_bool
1455 # for backward compatibility with pre-linux-2.2.15 kernels.
1456 # (Bugzilla:fibrebugs, #384)
1457- define_bool CONFIG_FUSION_ISENSE n
1458- define_bool CONFIG_FUSION_CTL n
1459- define_bool CONFIG_FUSION_LAN n
1460+ define_tristate CONFIG_FUSION_ISENSE n
1461+ define_tristate CONFIG_FUSION_CTL n
1462+ define_tristate CONFIG_FUSION_LAN n
1463
1464 fi
1465
1466Index: drivers/mtd/chips/Config.in
1467===================================================================
1468RCS file: /usr/src/cvsroot/linux-2.5/drivers/mtd/chips/Config.in,v
1469retrieving revision 1.1.1.1
1470diff -u -p -r1.1.1.1 Config.in
1471 --- drivers/mtd/chips/Config.in 26 Nov 2001 19:31:18 -00001.1.1.1
1472 +++ drivers/mtd/chips/Config.in16 Oct 2002 23:01:30 -0000
1473@@ -11,12 +11,12 @@ dep_tristate ' Detect flash chips by Co
1474 dep_tristate ' Detect non-CFI AMD/JEDEC-compatible flash chips' CONFIG_MTD_JEDECPROBE $CONFIG_MTD
1475
1476 if [ "$CONFIG_MTD_CFI" = "y" -o "$CONFIG_MTD_INTELPROBE" = "y" -o "$CONFIG_MTD_JEDECPROBE" = "y" ]; then
1477- define_bool CONFIG_MTD_GEN_PROBE y
1478+ define_tristate CONFIG_MTD_GEN_PROBE y
1479 else
1480 if [ "$CONFIG_MTD_CFI" = "m" -o "$CONFIG_MTD_INTELPROBE" = "m" -o "$CONFIG_MTD_JEDECPROBE" = "m" ]; then
1481- define_bool CONFIG_MTD_GEN_PROBE m
1482+ define_tristate CONFIG_MTD_GEN_PROBE m
1483 else
1484- define_bool CONFIG_MTD_GEN_PROBE n
1485+ define_tristate CONFIG_MTD_GEN_PROBE n
1486 fi
1487 fi
1488 if [ "$CONFIG_MTD_GEN_PROBE" = "y" -o "$CONFIG_MTD_GEN_PROBE" = "m" ]; then
1489Index: drivers/mtd/devices/Config.in
1490===================================================================
1491RCS file: /usr/src/cvsroot/linux-2.5/drivers/mtd/devices/Config.in,v
1492retrieving revision 1.1.1.1
1493diff -u -p -r1.1.1.1 Config.in
1494 --- drivers/mtd/devices/Config.in 26 Nov 2001 19:31:18 -00001.1.1.1
1495 +++ drivers/mtd/devices/Config.in16 Oct 2002 23:01:30 -0000
1496@@ -29,12 +29,12 @@ comment 'Disk-On-Chip Device Drivers'
1497 dep_tristate ' M-Systems Disk-On-Chip 2000 and Millennium' CONFIG_MTD_DOC2000 $CONFIG_MTD
1498 dep_tristate ' M-Systems Disk-On-Chip Millennium-only alternative driver (see help)' CONFIG_MTD_DOC2001 $CONFIG_MTD
1499 if [ "$CONFIG_MTD_DOC2001" = "y" -o "$CONFIG_MTD_DOC2000" = "y" ]; then
1500- define_bool CONFIG_MTD_DOCPROBE y
1501+ define_tristate CONFIG_MTD_DOCPROBE y
1502 else
1503 if [ "$CONFIG_MTD_DOC2001" = "m" -o "$CONFIG_MTD_DOC2000" = "m" ]; then
1504 - define_bool CONFIG_MTD_DOCPROBE m
1505 + define_tristate CONFIG_MTD_DOCPROBE m
1506 else
1507 - define_bool CONFIG_MTD_DOCPROBE n
1508 + define_tristate CONFIG_MTD_DOCPROBE n
1509 fi
1510 fi
1511
1512Index: drivers/net/Config.in
1513===================================================================
1514RCS file: /usr/src/cvsroot/linux-2.5/drivers/net/Config.in,v
1515retrieving revision 1.1.1.13
1516diff -u -p -r1.1.1.13 Config.in
1517 --- drivers/net/Config.in 7 Oct 2002 19:16:13 -00001.1.1.13
1518 +++ drivers/net/Config.in16 Oct 2002 23:01:30 -0000
1519@@ -305,6 +305,8 @@ if [ "$CONFIG_NET_RADIO" = "y" ]; then
1520
1521 # New directory for Wireless LAN devices - cards above will move there
1522 source drivers/net/wireless/Config.in
1523+else
1524+ define_tristate CONFIG_AIRONET4500 n
1525 fi
1526
1527 endmenu
1528Index: drivers/parport/Config.in
1529===================================================================
1530RCS file: /usr/src/cvsroot/linux-2.5/drivers/parport/Config.in,v
1531retrieving revision 1.1.1.2
1532diff -u -p -r1.1.1.2 Config.in
1533 --- drivers/parport/Config.in 31 Jan 2002 22:18:24 -00001.1.1.2
1534 +++ drivers/parport/Config.in16 Oct 2002 23:01:33 -0000
1535@@ -11,8 +11,8 @@ comment 'Parallel port support'
1536 tristate 'Parallel port support' CONFIG_PARPORT
1537 if [ "$CONFIG_PARPORT" != "n" ]; then
1538 dep_tristate ' PC-style hardware' CONFIG_PARPORT_PC $CONFIG_PARPORT
1539- if [ "$CONFIG_PARPORT_PC" != "n" -a "$CONFIG_SERIAL" != "n" ]; then
1540- if [ "$CONFIG_SERIAL" = "m" ]; then
1541+ if [ "$CONFIG_PARPORT_PC" != "n" -a "$CONFIG_SERIAL_8250" != "n" ]; then
1542+ if [ "$CONFIG_SERIAL_8250" = "m" ]; then
1543 define_tristate CONFIG_PARPORT_PC_CML1 m
1544 else
1545 define_tristate CONFIG_PARPORT_PC_CML1 $CONFIG_PARPORT_PC
1546Index: drivers/pnp/Config.in
1547===================================================================
1548RCS file: /usr/src/cvsroot/linux-2.5/drivers/pnp/Config.in,v
1549retrieving revision 1.1.1.3
1550diff -u -p -r1.1.1.3 Config.in
1551 --- drivers/pnp/Config.in 19 Oct 2002 11:36:15 -00001.1.1.3
1552 +++ drivers/pnp/Config.in19 Oct 2002 13:00:10 -0000
1553@@ -4,15 +4,17 @@
1554 mainmenu_option next_comment
1555 comment 'Plug and Play configuration'
1556
1557-dep_bool 'Plug and Play support' CONFIG_PNP
1558+bool 'Plug and Play support' CONFIG_PNP
1559
1560- dep_bool ' Plug and Play device name database' CONFIG_PNP_NAMES $CONFIG_PNP
1561- dep_bool ' PnP Debug Messages' CONFIG_PNP_DEBUG $CONFIG_PNP
1562+if [ "$CONFIG_PNP" = "y" ]; then
1563+ bool ' Plug and Play device name database' CONFIG_PNP_NAMES
1564+ bool ' PnP Debug Messages' CONFIG_PNP_DEBUG
1565
1566-comment 'Protocols' $CONFIG_PNP
1567+ comment 'Protocols'
1568
1569-if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
1570- dep_bool ' ISA Plug and Play support (EXPERIMENTAL)' CONFIG_ISAPNP $CONFIG_PNP
1571- dep_bool ' Plug and Play BIOS support (EXPERIMENTAL)' CONFIG_PNPBIOS $CONFIG_PNP
1572+ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
1573+ bool ' ISA Plug and Play support (EXPERIMENTAL)' CONFIG_ISAPNP
1574+ bool ' Plug and Play BIOS support (EXPERIMENTAL)' CONFIG_PNPBIOS
1575+ fi
1576 fi
1577 endmenu
1578Index: drivers/serial/Config.in
1579===================================================================
1580RCS file: /usr/src/cvsroot/linux-2.5/drivers/serial/Config.in,v
1581retrieving revision 1.1.1.4
1582diff -u -p -r1.1.1.4 Config.in
1583 --- drivers/serial/Config.in 16 Oct 2002 19:42:48 -00001.1.1.4
1584 +++ drivers/serial/Config.in16 Oct 2002 23:01:36 -0000
1585@@ -62,14 +62,14 @@ if [ "$CONFIG_SERIAL_AMBA" = "y" -o "$
1586 "$CONFIG_SERIAL_ANAKIN" = "y" -o "$CONFIG_SERIAL_UART00" = "y" -o \
1587 "$CONFIG_SERIAL_8250" = "y" -o "$CONFIG_SERIAL_ROCKETPORT" = "y" -o \
1588 "$CONFIG_SERIAL_SUNCORE" = "y" ]; then
1589- define_bool CONFIG_SERIAL_CORE y
1590+ define_tristate CONFIG_SERIAL_CORE y
1591 else
1592 if [ "$CONFIG_SERIAL_AMBA" = "m" -o "$CONFIG_SERIAL_CLPS711X" = "m" -o \
1593 "$CONFIG_SERIAL_21285" = "m" -o "$CONFIG_SERIAL_SA1100" = "m" -o \
1594 "$CONFIG_SERIAL_ANAKIN" = "m" -o "$CONFIG_SERIAL_UART00" = "m" -o \
1595 "$CONFIG_SERIAL_8250" = "m" -o "$CONFIG_SERIAL_ROCKETPORT" = "m" -o \
1596 "$CONFIG_SERIAL_SUNCORE" = "m" ]; then
1597- define_bool CONFIG_SERIAL_CORE m
1598+ define_tristate CONFIG_SERIAL_CORE m
1599 fi
1600 fi
1601 if [ "$CONFIG_SERIAL_AMBA_CONSOLE" = "y" -o \
1602Index: drivers/usb/Config.in
1603===================================================================
1604RCS file: /usr/src/cvsroot/linux-2.5/drivers/usb/Config.in,v
1605retrieving revision 1.1.1.11
1606diff -u -p -r1.1.1.11 Config.in
1607 --- drivers/usb/Config.in 27 Aug 2002 23:41:47 -00001.1.1.11
1608 +++ drivers/usb/Config.in16 Oct 2002 23:01:36 -0000
1609@@ -8,7 +8,7 @@ comment 'USB support'
1610 if [ "$CONFIG_PCI" = "y" -o "$CONFIG_SA1111" = "y" ]; then
1611 tristate 'Support for USB' CONFIG_USB
1612 else
1613- define_bool CONFIG_USB n
1614+ define_tristate CONFIG_USB n
1615 fi
1616
1617 if [ "$CONFIG_USB" = "y" -o "$CONFIG_USB" = "m" ]; then
1618Index: fs/Config.in
1619===================================================================
1620RCS file: /usr/src/cvsroot/linux-2.5/fs/Config.in,v
1621retrieving revision 1.1.1.18
1622diff -u -p -r1.1.1.18 Config.in
1623 --- fs/Config.in 16 Oct 2002 19:38:54 -00001.1.1.18
1624 +++ fs/Config.in16 Oct 2002 23:01:39 -0000
1625@@ -173,7 +173,7 @@ if [ "$CONFIG_NET" = "y" ]; then
1626 else
1627 # for fs/nls/Config.in
1628 define_bool CONFIG_NCPFS_NLS n
1629- define_bool CONFIG_SMB_FS n
1630+ define_tristate CONFIG_SMB_FS n
1631 fi
1632
1633 if [ "$CONFIG_ZISOFS" = "y" ]; then
1634Index: scripts/Makefile
1635===================================================================
1636RCS file: /usr/src/cvsroot/linux-2.5/scripts/Makefile,v
1637retrieving revision 1.1.1.7
1638diff -u -p -r1.1.1.7 Makefile
1639 --- scripts/Makefile 7 Oct 2002 19:20:55 -00001.1.1.7
1640 +++ scripts/Makefile16 Oct 2002 23:02:01 -0000
1641@@ -11,7 +11,7 @@
1642
1643 EXTRA_TARGETS := fixdep split-include docproc conmakehash
1644
1645 -subdir-:= lxdialog
1646 +subdir-:= lxdialog kconfig
1647
1648 # Yikes. We need to build this stuff here even if the user only wants
1649 # modules.
1650Index: sound/oss/Config.in
1651===================================================================
1652RCS file: /usr/src/cvsroot/linux-2.5/sound/oss/Config.in,v
1653retrieving revision 1.1.1.4
1654diff -u -p -r1.1.1.4 Config.in
1655 --- sound/oss/Config.in 27 Aug 2002 23:44:49 -00001.1.1.4
1656 +++ sound/oss/Config.in16 Oct 2002 23:02:04 -0000
1657@@ -201,12 +201,3 @@ fi
1658
1659 dep_tristate ' TV card (bt848) mixer support' CONFIG_SOUND_TVMIXER $CONFIG_SOUND $CONFIG_I2C
1660
1661-# A cross directory dependence. The sound modules will need gameport.o compiled in,
1662-# but it resides in the drivers/char/joystick directory. This define_tristate takes
1663-# care of that. --Vojtech
1664-
1665-if [ "$CONFIG_INPUT_GAMEPORT" != "n" ]; then
1666- if [ "$CONFIG_SOUND_ESSSOLO1" = "y" -o "$CONFIG_SOUND_ES1370" = "y" -o "$CONFIG_SOUND_ES1371" = "y" -o "$CONFIG_SOUND_SONICVIBES" = "y" ]; then
1667- define_tristate CONFIG_INPUT_GAMEPORT y
1668- fi
1669-fi
1670diff -ur config.undef config.undef
1671 --- config.undef1970-01-01 01:00:00.000000000 +0100
1672 +++ config.undef2002-08-22 20:17:58.000000000 +0200
1673@@ -0,0 +1,210 @@
1674+mainmenu_option next_comment
1675+comment ''
1676+define_bool CONFIG_IBM_OCP n
1677+define_bool CONFIG_VISWS n
1678+define_bool CONFIG_HUB6 n
1679+define_bool CONFIG_ALL_PPC n
1680+define_bool CONFIG_ALPHA_BOOK1 n
1681+define_bool CONFIG_8xx n
1682+define_bool CONFIG_SUN3 n
1683+define_bool CONFIG_ARCH_EBSA110 n
1684+define_bool CONFIG_HP300 n
1685+define_bool CONFIG_ARCH_NETWINDER n
1686+define_bool CONFIG_ARCH_ANAKIN n
1687+define_bool CONFIG_SERIAL_CONSOLE n
1688+define_bool CONFIG_MIPS_GT96100 n
1689+define_bool CONFIG_MOMENCO_OCELOT n
1690+define_bool CONFIG_IA64_HP_SIM n
1691+define_bool CONFIG_IA64_SGI_SN n
1692+define_bool CONFIG_MIPS n
1693+define_bool CONFIG_ARCH_A5K n
1694+define_bool CONFIG_SGI_IP22 n
1695+define_bool CONFIG_SGI_IP27 n
1696+define_bool CONFIG_SERIAL_MANY_PORTS n
1697+define_bool CONFIG_MIPS_ITE8172 n
1698+define_bool CONFIG_ARCH_CDB89712 n
1699+define_bool CONFIG_ARCH_ARC n
1700+define_bool CONFIG_PPC_ISERIES n
1701+define_bool CONFIG_SA1100_CERF_CPLD n
1702+define_bool CONFIG_SA1111 n
1703+define_bool CONFIG_PPC_PSERIES n
1704+define_bool CONFIG_AMIGA n
1705+define_bool CONFIG_ARCH_FOOTBRIDGE n
1706+define_bool CONFIG_GSC_LASI n
1707+define_bool CONFIG_ALPHA n
1708+define_bool CONFIG_TQM8xxL n
1709+define_bool CONFIG_IA64_SGI_SN1 n
1710+define_bool CONFIG_ARCH_S390 n
1711+define_bool CONFIG_IT8712 n
1712+define_bool CONFIG_SERIAL_EXTENDED n
1713+define_bool CONFIG_ATARI n
1714+define_bool CONFIG_ARCH_CLPS7500 n
1715+define_bool CONFIG_SPARC n
1716+define_bool CONFIG_ARCH_INTEGRATOR n
1717+define_bool CONFIG_SUN3X n
1718+define_bool CONFIG_ARCH_CAMELOT n
1719+define_bool CONFIG_MIPS_IVR n
1720+define_bool CONFIG_SH_DREAMCAST n
1721+define_bool CONFIG_X86_64 n
1722+define_bool CONFIG_HD64461 n
1723+define_bool CONFIG_HD64465 n
1724+define_bool CONFIG_TC n
1725+define_bool CONFIG_ZORRO n
1726+define_bool CONFIG_ARCH_CLPS711X n
1727+define_bool CONFIG_DDB5477 n
1728+define_bool CONFIG_Q40 n
1729+define_bool CONFIG_ARCH_P720T n
1730+define_bool CONFIG_DEBUG_BUGVERBOSE n
1731+define_bool CONFIG_PARISC n
1732+define_bool CONFIG_APOLLO n
1733+define_bool CONFIG_FB_G364 n
1734+define_bool CONFIG_MAC n
1735+define_bool CONFIG_ARCH_SA1100 n
1736+define_bool CONFIG_SA1100_CERF n
1737+define_bool CONFIG_MIPS_JAZZ n
1738+define_bool CONFIG_SUPERH n
1739+define_bool CONFIG_SERIAL_SHARE_IRQ n
1740+define_bool CONFIG_ARCH_EP7211 n
1741+define_bool CONFIG_SPARC32 n
1742+define_bool CONFIG_ARM n
1743+define_bool CONFIG_SGI n
1744+define_bool CONFIG_PPC n
1745+define_bool CONFIG_SPARC64 n
1746+define_bool CONFIG_FOOTBRIDGE n
1747+define_bool CONFIG_SA1100_LART n
1748+define_bool CONFIG_DECSTATION n
1749+define_bool CONFIG_SERIAL_MULTIPORT n
1750+define_bool CONFIG_MIPS_AU1000 n
1751+define_bool CONFIG_ARCH_ACORN n
1752+define_bool CONFIG_IA64 n
1753+define_bool CONFIG_BAGET_MIPS n
1754+define_bool CONFIG_IA32_EMULATION n
1755+define_bool CONFIG_RPXCLASSIC n
1756+define_bool CONFIG_ARCH_IQ80310 n
1757+define_bool CONFIG_RPXLITE n
1758+define_bool CONFIG_NINO n
1759+define_bool CONFIG_PPC64 n
1760+define_bool CONFIG_APUS n
1761+define_bool CONFIG_ARCH_FTVPCI n
1762+define_bool CONFIG_ARCH_NEXUSPCI n
1763+define_bool CONFIG_ARCH_S390X n
1764+define_bool CONFIG_ARCH_TBOX n
1765+define_bool CONFIG_CARDBUS n
1766+define_bool CONFIG_CD_NO_IDESCSI n
1767+define_bool CONFIG_CPU_DISABLE_DCACHE n
1768+define_bool CONFIG_DEBUG_IOVIRT n
1769+define_bool CONFIG_EISA n
1770+define_bool CONFIG_ETRAX100_SERIAL_FLUSH_DMA_FAST n
1771+define_bool CONFIG_FDDI n
1772+define_bool CONFIG_GG2 n
1773+define_bool CONFIG_GSC_PS2 n
1774+define_bool CONFIG_HOTPLUG n
1775+define_bool CONFIG_IODC_CONSOLE n
1776+define_bool CONFIG_ISA n
1777+define_bool CONFIG_IT8172_SCR0 n
1778+define_bool CONFIG_IT8172_SCR1 n
1779+define_bool CONFIG_JULIETTE n
1780+define_bool CONFIG_MCA n
1781+define_bool CONFIG_MOUSE n
1782+define_bool CONFIG_NETLINK n
1783+define_bool CONFIG_NO_PGT_CACHE n
1784+define_bool CONFIG_NUMA n
1785+define_bool CONFIG_PCI n
1786+define_bool CONFIG_PLD_HOTSWAP n
1787+define_bool CONFIG_REMOTE_DEBUG n
1788+define_bool CONFIG_SBUS n
1789+define_bool CONFIG_SIMNOW n
1790+define_bool CONFIG_SOFTWARE_SUSPEND n
1791+define_bool CONFIG_TQM860 n
1792+define_bool CONFIG_VGA_CONSOLE n
1793+define_bool CONFIG_X86 n
1794+define_bool CONFIG_X86_IO_APIC n
1795+define_bool CONFIG_X86_LOCAL_APIC n
1796+define_bool CONFIG_X86_UP_APIC n
1797+define_bool CONFIG_X86_UP_IOAPIC n
1798+define_bool CONFIG_XSCALE_PMU_TIMER n
1799+define_bool CONFIG_IT8172_TUNING n
1800+define_bool CONFIG_SA1100_CONSUS n
1801+define_bool CONFIG_M68K n
1802+define_bool CONFIG_PPC32 n
1803+define_bool CONFIG_ISAPNP n
1804+define_tristate CONFIG_PCMCIA n
1805+define_tristate CONFIG_SERIAL n
1806+define_tristate CONFIG_DASD_CKD n
1807+define_tristate CONFIG_I2C n
1808+define_tristate CONFIG_I2C_ALGOBIT n
1809+define_tristate CONFIG_PARPORT n
1810+define_tristate CONFIG_PPP_DEFLATE n
1811+define_tristate CONFIG_SCSI_DEBUG n
1812+define_tristate CONFIG_SERIAL_8250 n
1813+define_tristate CONFIG_SONYPI n
1814+define_tristate CONFIG_SOUND_GAMEPORT n
1815+define_tristate CONFIG_MTD n
1816+define_tristate CONFIG_USB n
1817+define_tristate CONFIG_BLK_DEV_IDETAPE n
1818+define_tristate CONFIG_AMIGAMOUSE n
1819+define_tristate CONFIG_SCx200 n
1820+define_tristate CONFIG_DRM_GAMMA n
1821+define_tristate CONFIG_VIDEO_DEV n
1822+define_tristate CONFIG_BT n
1823+define_tristate CONFIG_BT_L2CAP n
1824+define_tristate CONFIG_BT_SCO n
1825+#undef
1826+define_bool CONFIG_HIGHPTE n
1827+define_bool CONFIG_GMAC n
1828+define_bool CONFIG_IEEE1394_PCILYNX_LOCALRAM n
1829+define_bool CONFIG_DRM_AGP n
1830+define_bool CONFIG_SERIAL_DETECT_IRQ n
1831+define_bool CONFIG_DEBUG_OBSOLETE n
1832+define_bool CONFIG_FB_TBOX n
1833+define_bool CONFIG_LOGITECH_3D n
1834+define_bool CONFIG_SERIAL_ROCKETPORT n
1835+define_bool CONFIG_MTD_INTELPROBE n
1836+define_bool CONFIG_SERIAL_ACPI n
1837+define_bool CONFIG_SA1100_BITSY n
1838+define_bool CONFIG_I2C_PARPORT n
1839+define_bool CONFIG_GAMEPORT_CS461X n
1840+define_bool CONFIG_NET_PROFILE n
1841+define_bool CONFIG_OBSOLETE n
1842+define_bool CONFIG_IEEE1394_PCILYNX_PORTS n
1843+define_bool CONFIG_MAPLE n
1844+define_bool CONFIG_L3 n
1845+define_bool CONFIG_SIBYTE_SB1250 n
1846+define_bool CONFIG_SA n
1847+define_bool CONFIG_405 n
1848+define_bool CONFIG_AX25_DAMA_MASTER n
1849+define_bool CONFIG_SND_DEBUG_DETECTION n
1850+define_bool CONFIG_PCMCIA_SERIAL_CS n
1851+define_bool CONFIG_SOUND_SND n
1852+define_bool CONFIG_MTD_CFI_INTELSTD n
1853+define_bool CONFIG_IT8172_REVC n
1854+define_bool CONFIG_UM n
1855+define_bool CONFIG_SIBYTE_SWARM n
1856+define_bool CONFIG_S390 n
1857+define_bool CONFIG_BLK_DEV_TIVO n
1858+define_bool CONFIG_BRIDGE_EBT n
1859+define_bool CONFIG_PPC_RTC n
1860+define_bool CONFIG_GART_IOMMU n
1861+define_bool CONFIG_ARCH_AUTCPU12 n
1862+define_bool CONFIG_ARCH_CEIVA n
1863+#help only
1864+define_bool CONFIG_BLK_DEV_HD_IDE n
1865+define_bool CONFIG_INPUT_GAMEPORT n
1866+define_bool CONFIG_BLK_DEV_IDE_TCQ_DEFAULT n
1867+define_bool CONFIG_BLK_DEV_ATARAID n
1868+define_bool CONFIG_ATAPI n
1869+define_bool CONFIG_AEC6280_BURST n
1870+define_bool CONFIG_BLK_DEV_IDE_TCQ n
1871+define_bool CONFIG_USB_SPEEDTCH n
1872+define_bool CONFIG_BLK_DEV_ATARAID_PDC n
1873+define_bool CONFIG_BLK_DEV_HD_ONLY n
1874+define_bool CONFIG_BLK_DEV_ATARAID_HPT n
1875+define_bool CONFIG_NFS_DIRECTIO n
1876+define_bool CONFIG_AIC7XXX_OLD_PROC_STATS n
1877+define_bool CONFIG_AIC7XXX_OLD_TCQ_ON_BY_DEFAULT n
1878+define_bool CONFIG_ISDN_DIVAS_DIVA2I4L n
1879+define_bool CONFIG_CIFS_DEBUG n
1880+define_bool CONFIG_X86_CYCLONE n
1881+define_bool CONFIG_SA1100_FORTUNET n
1882+define_bool CONFIG_MTD_NAND_EDB7312 n
1883+endmenu
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
new file mode 100644
index 0000000..feefa1c
--- a/dev/null
+++ b/scripts/kconfig/qconf.cc
@@ -0,0 +1,1073 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <qapplication.h>
7#include <qmainwindow.h>
8#include <qtoolbar.h>
9#include <qvbox.h>
10#include <qsplitter.h>
11#include <qlistview.h>
12#include <qtextview.h>
13#include <qlineedit.h>
14#include <qmenubar.h>
15#include <qmessagebox.h>
16#include <qaction.h>
17#include <qheader.h>
18#include <qfiledialog.h>
19#include <qregexp.h>
20#include <stdlib.h>
21
22#include "lkc.h"
23#include "qconf.h"
24
25#include "qconf.moc"
26#include "images.c"
27
28static QApplication *configApp;
29
30/*
31 * update all the children of a menu entry
32 * removes/adds the entries from the parent widget as necessary
33 *
34 * parent: either the menu list widget or a menu entry widget
35 * menu: entry to be updated
36 */
37template <class P>
38static void updateMenuList(P* parent, struct menu* menu)
39{
40 struct menu* child;
41 ConfigList* list = parent->listView();
42 ConfigItem* item;
43 ConfigItem* last;
44 bool visible;
45 bool showAll = list->showAll;
46 enum listMode mode = list->mode;
47 enum prop_type type;
48
49 if (!menu) {
50 while ((item = parent->firstChild()))
51 delete item;
52 return;
53 }
54
55 last = 0;
56 for (child = menu->list; child; child = child->next) {
57 item = last ? last->nextSibling() : parent->firstChild();
58 type = child->prompt ? child->prompt->type : P_UNKNOWN;
59
60 switch (mode) {
61 case menuMode:
62 if (type != P_ROOTMENU)
63 goto hide;
64 break;
65 case symbolMode:
66 if (type == P_ROOTMENU)
67 goto hide;
68 break;
69 default:
70 break;
71 }
72
73 visible = menu_is_visible(child);
74 if (showAll || visible) {
75 if (!item || item->menu != child)
76 item = new ConfigItem(parent, last, child);
77 item->visible = visible;
78 item->updateMenu();
79
80 if (mode == fullMode || mode == menuMode ||
81 (type != P_MENU && type != P_ROOTMENU))
82 updateMenuList(item, child);
83 else
84 updateMenuList(item, 0);
85 last = item;
86 continue;
87 }
88 hide:
89 if (item && item->menu == child) {
90 last = parent->firstChild();
91 if (last == item)
92 last = 0;
93 else while (last->nextSibling() != item)
94 last = last->nextSibling();
95 delete item;
96 }
97 }
98}
99
100#if QT_VERSION >= 300
101/*
102 * set the new data
103 * TODO check the value
104 */
105void ConfigItem::okRename(int col)
106{
107 Parent::okRename(col);
108 sym_set_string_value(menu->sym, text(dataColIdx).latin1());
109}
110#endif
111
112/*
113 * update the displayed of a menu entry
114 */
115void ConfigItem::updateMenu(void)
116{
117 ConfigList* list;
118 struct symbol* sym;
119 QString prompt;
120 int type;
121 enum prop_type ptype;
122 tristate expr;
123 bool update;
124
125 list = listView();
126 update = doInit;
127 if (update)
128 doInit = false;
129 else
130 update = list->updateAll;
131
132 sym = menu->sym;
133 if (!sym) {
134 if (update) {
135 setText(promptColIdx, menu_get_prompt(menu));
136 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
137 if ((ptype == P_ROOTMENU || ptype == P_MENU) &&
138 (list->mode == singleMode || list->mode == symbolMode))
139 setPixmap(promptColIdx, list->menuPix);
140 else
141 setPixmap(promptColIdx, 0);
142 }
143 return;
144 }
145
146 sym_calc_value(sym);
147 if (!(sym->flags & SYMBOL_CHANGED) && !update)
148 return;
149
150 sym->flags &= ~SYMBOL_CHANGED;
151
152 setText(nameColIdx, menu->sym->name);
153
154 type = sym_get_type(sym);
155 switch (type) {
156 case S_BOOLEAN:
157 case S_TRISTATE:
158 char ch;
159
160 prompt = menu_get_prompt(menu);
161 if (!sym_is_changable(sym) && !list->showAll) {
162 setText(noColIdx, 0);
163 setText(modColIdx, 0);
164 setText(yesColIdx, 0);
165 break;
166 }
167 expr = sym_get_tristate_value(sym);
168 switch (expr) {
169 case yes:
170 if (sym_is_choice_value(sym) && type == S_BOOLEAN)
171 setPixmap(promptColIdx, list->choiceYesPix);
172 else
173 setPixmap(promptColIdx, list->symbolYesPix);
174 setText(yesColIdx, "Y");
175 ch = 'Y';
176 break;
177 case mod:
178 setPixmap(promptColIdx, list->symbolModPix);
179 setText(modColIdx, "M");
180 ch = 'M';
181 break;
182 default:
183 if (sym_is_choice_value(sym) && type == S_BOOLEAN)
184 setPixmap(promptColIdx, list->choiceNoPix);
185 else
186 setPixmap(promptColIdx, list->symbolNoPix);
187 setText(noColIdx, "N");
188 ch = 'N';
189 break;
190 }
191 if (expr != no)
192 setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0);
193 if (expr != mod)
194 setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0);
195 if (expr != yes)
196 setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0);
197
198 setText(dataColIdx, QChar(ch));
199 break;
200 case S_INT:
201 case S_HEX:
202 case S_STRING:
203 const char* data;
204
205 data = sym_get_string_value(sym);
206#if QT_VERSION >= 300
207 setRenameEnabled(list->mapIdx(dataColIdx), TRUE);
208#endif
209 setText(dataColIdx, data);
210 if (type == S_STRING)
211 prompt.sprintf("%s: %s", menu_get_prompt(menu), data);
212 else
213 prompt.sprintf("(%s) %s", data, menu_get_prompt(menu));
214 break;
215 }
216 if (!sym_has_value(sym) && visible)
217 prompt += " (NEW)";
218 setText(promptColIdx, prompt);
219}
220
221void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align)
222{
223 ConfigList* list = listView();
224
225 if (visible) {
226 if (isSelected() && !list->hasFocus() && list->mode == menuMode)
227 Parent::paintCell(p, list->inactivedColorGroup, column, width, align);
228 else
229 Parent::paintCell(p, cg, column, width, align);
230 } else
231 Parent::paintCell(p, list->disabledColorGroup, column, width, align);
232}
233
234/*
235 * construct a menu entry
236 */
237void ConfigItem::init(void)
238{
239 ConfigList* list = listView();
240#if QT_VERSION < 300
241 visible = TRUE;
242#endif
243 //menu->data = this;
244 if (list->mode != fullMode)
245 setOpen(TRUE);
246 doInit= true;
247}
248
249/*
250 * destruct a menu entry
251 */
252ConfigItem::~ConfigItem(void)
253{
254 //menu->data = 0;
255}
256
257void ConfigLineEdit::show(ConfigItem* i)
258{
259 item = i;
260 if (sym_get_string_value(item->menu->sym))
261 setText(sym_get_string_value(item->menu->sym));
262 else
263 setText(0);
264 Parent::show();
265 setFocus();
266}
267
268void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
269{
270 switch (e->key()) {
271 case Key_Escape:
272 break;
273 case Key_Return:
274 case Key_Enter:
275 sym_set_string_value(item->menu->sym, text().latin1());
276 emit lineChanged(item);
277 break;
278 default:
279 Parent::keyPressEvent(e);
280 return;
281 }
282 e->accept();
283 hide();
284}
285
286ConfigList::ConfigList(QWidget* p, ConfigView* cv)
287 : Parent(p), cview(cv),
288 updateAll(false),
289 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),
291 showAll(false), showName(false), showRange(false), showData(false),
292 rootEntry(0)
293{
294 int i;
295
296 setSorting(-1);
297 setRootIsDecorated(TRUE);
298 disabledColorGroup = palette().active();
299 disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text());
300 inactivedColorGroup = palette().active();
301 inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight());
302
303 connect(this, SIGNAL(selectionChanged(void)),
304 SLOT(updateSelection(void)));
305
306 for (i = 0; i < colNr; i++)
307 colMap[i] = colRevMap[i] = -1;
308 addColumn(promptColIdx, "Option");
309
310 reinit();
311}
312
313void ConfigList::reinit(void)
314{
315 removeColumn(dataColIdx);
316 removeColumn(yesColIdx);
317 removeColumn(modColIdx);
318 removeColumn(noColIdx);
319 removeColumn(nameColIdx);
320
321 if (showName)
322 addColumn(nameColIdx, "Name");
323 if (showRange) {
324 addColumn(noColIdx, "N");
325 addColumn(modColIdx, "M");
326 addColumn(yesColIdx, "Y");
327 }
328 if (showData)
329 addColumn(dataColIdx, "Value");
330
331 updateListAll();
332}
333
334void ConfigList::updateSelection(void)
335{
336 struct menu *menu;
337 enum prop_type type;
338
339 ConfigItem* item = (ConfigItem*)selectedItem();
340 if (!item)
341 return;
342
343 cview->setHelp(item);
344
345 menu = item->menu;
346 type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
347 if (mode == menuMode && (type == P_MENU || type == P_ROOTMENU))
348 emit menuSelected(menu);
349}
350
351void ConfigList::updateList(ConfigItem* item)
352{
353 (void)item;// unused so far
354 updateMenuList(this, rootEntry);
355}
356
357void ConfigList::setAllOpen(bool open)
358{
359 QListViewItemIterator it(this);
360
361 for (; it.current(); it++)
362 it.current()->setOpen(open);
363}
364
365void ConfigList::setValue(ConfigItem* item, tristate val)
366{
367 struct symbol* sym;
368 int type;
369 tristate oldval;
370
371 sym = item->menu->sym;
372 if (!sym)
373 return;
374
375 type = sym_get_type(sym);
376 switch (type) {
377 case S_BOOLEAN:
378 case S_TRISTATE:
379 oldval = sym_get_tristate_value(sym);
380
381 if (!sym_set_tristate_value(sym, val))
382 return;
383 if (oldval == no && item->menu->list)
384 item->setOpen(TRUE);
385 emit symbolChanged(item);
386 break;
387 }
388}
389
390void ConfigList::changeValue(ConfigItem* item)
391{
392 struct symbol* sym;
393 struct menu* menu;
394 int type, oldexpr, newexpr;
395
396 menu = item->menu;
397 sym = menu->sym;
398 if (!sym) {
399 if (item->menu->list)
400 item->setOpen(!item->isOpen());
401 return;
402 }
403
404 type = sym_get_type(sym);
405 switch (type) {
406 case S_BOOLEAN:
407 case S_TRISTATE:
408 oldexpr = sym_get_tristate_value(sym);
409 newexpr = sym_toggle_tristate_value(sym);
410 if (item->menu->list) {
411 if (oldexpr == newexpr)
412 item->setOpen(!item->isOpen());
413 else if (oldexpr == no)
414 item->setOpen(TRUE);
415 }
416 if (oldexpr != newexpr)
417 emit symbolChanged(item);
418 break;
419 case S_INT:
420 case S_HEX:
421 case S_STRING:
422#if QT_VERSION >= 300
423 if (colMap[dataColIdx] >= 0)
424 item->startRename(colMap[dataColIdx]);
425 else
426#endif
427 lineEdit->show(item);
428 break;
429 }
430}
431
432void ConfigList::setRootMenu(struct menu *menu)
433{
434 enum prop_type type;
435
436 if (rootEntry == menu)
437 return;
438 type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN;
439 if (type != P_MENU && type != P_ROOTMENU)
440 return;
441 updateMenuList(this, 0);
442 rootEntry = menu;
443 updateListAll();
444 setSelected(currentItem(), hasFocus());
445}
446
447void ConfigList::setParentMenu(void)
448{
449 ConfigItem* item;
450 struct menu *oldroot, *newroot;
451
452 oldroot = rootEntry;
453 newroot = menu_get_parent_menu(oldroot);
454 if (newroot == oldroot)
455 return;
456 setRootMenu(newroot);
457
458 QListViewItemIterator it(this);
459 for (; (item = (ConfigItem*)it.current()); it++) {
460 if (item->menu == oldroot) {
461 setCurrentItem(item);
462 ensureItemVisible(item);
463 break;
464 }
465 }
466}
467
468void ConfigList::keyPressEvent(QKeyEvent* ev)
469{
470 QListViewItem* i = currentItem();
471 ConfigItem* item;
472 struct menu *menu;
473 enum prop_type type;
474
475 if (ev->key() == Key_Escape && mode != fullMode) {
476 emit parentSelected();
477 ev->accept();
478 return;
479 }
480
481 if (!i) {
482 Parent::keyPressEvent(ev);
483 return;
484 }
485 item = (ConfigItem*)i;
486
487 switch (ev->key()) {
488 case Key_Return:
489 case Key_Enter:
490 menu = item->menu;
491 type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
492 if ((type == P_MENU || type == P_ROOTMENU) && mode != fullMode) {
493 emit menuSelected(menu);
494 break;
495 }
496 case Key_Space:
497 changeValue(item);
498 break;
499 case Key_N:
500 setValue(item, no);
501 break;
502 case Key_M:
503 setValue(item, mod);
504 break;
505 case Key_Y:
506 setValue(item, yes);
507 break;
508 default:
509 Parent::keyPressEvent(ev);
510 return;
511 }
512 ev->accept();
513}
514
515void ConfigList::contentsMousePressEvent(QMouseEvent* e)
516{
517 //QPoint p(contentsToViewport(e->pos()));
518 //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y());
519 QListView::contentsMousePressEvent(e);
520}
521
522void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e)
523{
524 QPoint p(contentsToViewport(e->pos()));
525 ConfigItem* item = (ConfigItem*)itemAt(p);
526 struct menu *menu;
527 const QPixmap* pm;
528 int idx, x;
529
530 if (!item)
531 goto skip;
532
533 menu = item->menu;
534 x = header()->offset() + p.x();
535 idx = colRevMap[header()->sectionAt(x)];
536 switch (idx) {
537 case promptColIdx:
538 pm = item->pixmap(promptColIdx);
539 if (pm) {
540 int off = header()->sectionPos(0) + itemMargin() +
541 treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0));
542 if (x >= off && x < off + pm->width()) {
543 if (menu->sym)
544 changeValue(item);
545 else
546 emit menuSelected(menu);
547 }
548 }
549 break;
550 case noColIdx:
551 setValue(item, no);
552 break;
553 case modColIdx:
554 setValue(item, mod);
555 break;
556 case yesColIdx:
557 setValue(item, yes);
558 break;
559 case dataColIdx:
560 changeValue(item);
561 break;
562 }
563
564skip:
565 //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y());
566 QListView::contentsMouseReleaseEvent(e);
567}
568
569void ConfigList::contentsMouseMoveEvent(QMouseEvent* e)
570{
571 //QPoint p(contentsToViewport(e->pos()));
572 //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y());
573 QListView::contentsMouseMoveEvent(e);
574}
575
576void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e)
577{
578 QPoint p(contentsToViewport(e->pos()));
579 ConfigItem* item = (ConfigItem*)itemAt(p);
580 struct menu *menu;
581 enum prop_type ptype;
582
583 if (!item)
584 goto skip;
585 menu = item->menu;
586 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
587 if ((ptype == P_ROOTMENU || ptype == P_MENU) &&
588 (mode == singleMode || mode == symbolMode))
589 emit menuSelected(menu);
590
591skip:
592 //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y());
593 QListView::contentsMouseDoubleClickEvent(e);
594}
595
596void ConfigList::focusInEvent(QFocusEvent *e)
597{
598 Parent::focusInEvent(e);
599
600 QListViewItem* item = currentItem();
601 if (!item)
602 return;
603
604 setSelected(item, TRUE);
605 emit gotFocus();
606}
607
608/*
609 * Construct the complete config widget
610 */
611ConfigView::ConfigView(void)
612{
613 QMenuBar* menu;
614 QSplitter* split1;
615 QSplitter* split2;
616
617 showDebug = false;
618
619 split1 = new QSplitter(this);
620 split1->setOrientation(QSplitter::Horizontal);
621 setCentralWidget(split1);
622
623 menuList = new ConfigList(split1, this);
624
625 split2 = new QSplitter(split1);
626 split2->setOrientation(QSplitter::Vertical);
627
628 // create config tree
629 QVBox* box = new QVBox(split2);
630 configList = new ConfigList(box, this);
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
640 helpText = new QTextView(split2);
641 helpText->setTextFormat(Qt::RichText);
642
643 setTabOrder(configList, helpText);
644 configList->setFocus();
645
646 menu = menuBar();
647 toolBar = new QToolBar("Tools", this);
648
649 backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this);
650 connect(backAction, SIGNAL(activated()), SLOT(goBack()));
651 backAction->setEnabled(FALSE);
652 QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this);
653 connect(quitAction, SIGNAL(activated()), SLOT(close()));
654 QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this);
655 connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
656 QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this);
657 connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
658 QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this);
659 connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
660 QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this);
661 connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
662 QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this);
663 connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
664 QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this);
665 connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
666
667 QAction *showNameAction = new QAction(NULL, "Show Name", 0, this);
668 showNameAction->setToggleAction(TRUE);
669 showNameAction->setOn(configList->showName);
670 connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool)));
671 QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this);
672 showRangeAction->setToggleAction(TRUE);
673 showRangeAction->setOn(configList->showRange);
674 connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool)));
675 QAction *showDataAction = new QAction(NULL, "Show Data", 0, this);
676 showDataAction->setToggleAction(TRUE);
677 showDataAction->setOn(configList->showData);
678 connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool)));
679 QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this);
680 showAllAction->setToggleAction(TRUE);
681 showAllAction->setOn(configList->showAll);
682 connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool)));
683 QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this);
684 showDebugAction->setToggleAction(TRUE);
685 showDebugAction->setOn(showDebug);
686 connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
687
688 // init tool bar
689 backAction->addTo(toolBar);
690 toolBar->addSeparator();
691 loadAction->addTo(toolBar);
692 saveAction->addTo(toolBar);
693 toolBar->addSeparator();
694 singleViewAction->addTo(toolBar);
695 splitViewAction->addTo(toolBar);
696 fullViewAction->addTo(toolBar);
697
698 // create config menu
699 QPopupMenu* config = new QPopupMenu(this);
700 menu->insertItem("&File", config);
701 loadAction->addTo(config);
702 saveAction->addTo(config);
703 saveAsAction->addTo(config);
704 config->insertSeparator();
705 quitAction->addTo(config);
706
707 // create options menu
708 QPopupMenu* optionMenu = new QPopupMenu(this);
709 menu->insertItem("&Option", optionMenu);
710 showNameAction->addTo(optionMenu);
711 showRangeAction->addTo(optionMenu);
712 showDataAction->addTo(optionMenu);
713 optionMenu->insertSeparator();
714 showAllAction->addTo(optionMenu);
715 showDebugAction->addTo(optionMenu);
716
717 connect(configList, SIGNAL(menuSelected(struct menu *)),
718 SLOT(changeMenu(struct menu *)));
719 connect(configList, SIGNAL(parentSelected()),
720 SLOT(goBack()));
721 connect(menuList, SIGNAL(menuSelected(struct menu *)),
722 SLOT(changeMenu(struct menu *)));
723
724 connect(configList, SIGNAL(gotFocus(void)),
725 SLOT(listFocusChanged(void)));
726 connect(menuList, SIGNAL(gotFocus(void)),
727 SLOT(listFocusChanged(void)));
728
729 //showFullView();
730 showSplitView();
731}
732
733static QString print_filter(const char *str)
734{
735 QRegExp re("[<>&\"\\n]");
736 QString res = str;
737 for (int i = 0; (i = res.find(re, i)) >= 0;) {
738 switch (res[i].latin1()) {
739 case '<':
740 res.replace(i, 1, "&lt;");
741 i += 4;
742 break;
743 case '>':
744 res.replace(i, 1, "&gt;");
745 i += 4;
746 break;
747 case '&':
748 res.replace(i, 1, "&amp;");
749 i += 5;
750 break;
751 case '"':
752 res.replace(i, 1, "&quot;");
753 i += 6;
754 break;
755 case '\n':
756 res.replace(i, 1, "<br>");
757 i += 4;
758 break;
759 }
760 }
761 return res;
762}
763
764static void expr_print_help(void *data, const char *str)
765{
766 ((QString*)data)->append(print_filter(str));
767}
768
769/*
770 * display a new help entry as soon as a new menu entry is selected
771 */
772void ConfigView::setHelp(QListViewItem* item)
773{
774 struct symbol* sym;
775 struct menu* menu;
776
777 configList->lineEdit->hide();
778 if (item) {
779 QString head, debug, help;
780 menu = ((ConfigItem*)item)->menu;
781 sym = menu->sym;
782 if (sym) {
783 if (menu->prompt) {
784 head += "<big><b>";
785 head += print_filter(menu->prompt->text);
786 head += "</b></big>";
787 if (sym->name) {
788 head += " (";
789 head += print_filter(sym->name);
790 head += ")";
791 }
792 } else if (sym->name) {
793 head += "<big><b>";
794 head += print_filter(sym->name);
795 head += "</b></big>";
796 }
797 head += "<br><br>";
798
799 if (showDebug) {
800 debug += "type: ";
801 debug += print_filter(sym_type_name(sym->type));
802 debug += "<br>";
803 for (struct property *prop = sym->prop; prop; prop = prop->next) {
804 switch (prop->type) {
805 case P_PROMPT:
806 debug += "prompt: ";
807 debug += print_filter(prop->text);
808 debug += "<br>";
809 if (prop->visible.expr) {
810 debug += "&nbsp;&nbsp;dep: ";
811 expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
812 debug += "<br>";
813 }
814 break;
815 case P_DEFAULT:
816 debug += "default: ";
817 if (sym_is_choice(sym))
818 debug += print_filter(prop->def->name);
819 else {
820 sym_calc_value(prop->def);
821 debug += print_filter(sym_get_string_value(prop->def));
822 }
823 debug += "<br>";
824 if (prop->visible.expr) {
825 debug += "&nbsp;&nbsp;dep: ";
826 expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
827 debug += "<br>";
828 }
829 break;
830 case P_CHOICE:
831 break;
832 default:
833 debug += "unknown property: ";
834 debug += prop_get_type_name(prop->type);
835 debug += "<br>";
836 }
837 }
838 debug += "<br>";
839 }
840
841 help = print_filter(sym->help);
842 } else if (menu->prompt) {
843 head += "<big><b>";
844 head += print_filter(menu->prompt->text);
845 head += "</b></big><br><br>";
846 if (showDebug) {
847 if (menu->prompt->visible.expr) {
848 debug += "&nbsp;&nbsp;dep: ";
849 expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
850 debug += "<br>";
851 }
852 }
853 }
854 helpText->setText(head + debug + help);
855 return;
856 }
857 helpText->setText(NULL);
858}
859
860void ConfigView::loadConfig(void)
861{
862 QString s = QFileDialog::getOpenFileName(".config", NULL, this);
863 if (s.isNull())
864 return;
865 if (conf_read(s.latin1()))
866 QMessageBox::information(this, "qconf", "Unable to load configuration!");
867}
868
869void ConfigView::saveConfig(void)
870{
871 if (conf_write(NULL))
872 QMessageBox::information(this, "qconf", "Unable to save configuration!");
873}
874
875void ConfigView::saveConfigAs(void)
876{
877 QString s = QFileDialog::getSaveFileName(".config", NULL, this);
878 if (s.isNull())
879 return;
880 if (conf_write(s.latin1()))
881 QMessageBox::information(this, "qconf", "Unable to save configuration!");
882}
883
884void ConfigView::changeMenu(struct menu *menu)
885{
886 configList->setRootMenu(menu);
887 backAction->setEnabled(TRUE);
888}
889
890void ConfigView::listFocusChanged(void)
891{
892 if (menuList->hasFocus()) {
893 if (menuList->mode == menuMode)
894 configList->clearSelection();
895 setHelp(menuList->selectedItem());
896 } else if (configList->hasFocus()) {
897 setHelp(configList->selectedItem());
898 }
899}
900
901void ConfigView::goBack(void)
902{
903 ConfigItem* item;
904
905 configList->setParentMenu();
906 if (configList->rootEntry == &rootmenu)
907 backAction->setEnabled(FALSE);
908 item = (ConfigItem*)menuList->selectedItem();
909 while (item) {
910 if (item->menu == configList->rootEntry) {
911 menuList->setSelected(item, TRUE);
912 break;
913 }
914 item = (ConfigItem*)item->parent();
915 }
916}
917
918void ConfigView::showSingleView(void)
919{
920 menuList->hide();
921 menuList->setRootMenu(0);
922 configList->mode = singleMode;
923 if (configList->rootEntry == &rootmenu)
924 configList->updateListAll();
925 else
926 configList->setRootMenu(&rootmenu);
927 configList->setAllOpen(TRUE);
928 configList->setFocus();
929}
930
931void ConfigView::showSplitView(void)
932{
933 configList->mode = symbolMode;
934 if (configList->rootEntry == &rootmenu)
935 configList->updateListAll();
936 else
937 configList->setRootMenu(&rootmenu);
938 configList->setAllOpen(TRUE);
939 configApp->processEvents();
940 menuList->mode = menuMode;
941 menuList->setRootMenu(&rootmenu);
942 menuList->show();
943 menuList->setAllOpen(TRUE);
944 menuList->setFocus();
945}
946
947void ConfigView::showFullView(void)
948{
949 menuList->hide();
950 menuList->setRootMenu(0);
951 configList->mode = fullMode;
952 if (configList->rootEntry == &rootmenu)
953 configList->updateListAll();
954 else
955 configList->setRootMenu(&rootmenu);
956 configList->setAllOpen(FALSE);
957 configList->setFocus();
958}
959
960void ConfigView::setShowAll(bool b)
961{
962 if (configList->showAll == b)
963 return;
964 configList->showAll = b;
965 configList->updateListAll();
966 menuList->showAll = b;
967 menuList->updateListAll();
968}
969
970void ConfigView::setShowDebug(bool b)
971{
972 if (showDebug == b)
973 return;
974 showDebug = b;
975}
976
977void ConfigView::setShowName(bool b)
978{
979 if (configList->showName == b)
980 return;
981 configList->showName = b;
982 configList->reinit();
983}
984
985void ConfigView::setShowRange(bool b)
986{
987 if (configList->showRange == b)
988 return;
989 configList->showRange = b;
990 configList->reinit();
991}
992
993void ConfigView::setShowData(bool b)
994{
995 if (configList->showData == b)
996 return;
997 configList->showData = b;
998 configList->reinit();
999}
1000
1001/*
1002 * ask for saving configuration before quitting
1003 * TODO ask only when something changed
1004 */
1005void ConfigView::closeEvent(QCloseEvent* e)
1006{
1007 if (!sym_change_count) {
1008 e->accept();
1009 return;
1010 }
1011 QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning,
1012 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
1013 mb.setButtonText(QMessageBox::Yes, "&Save Changes");
1014 mb.setButtonText(QMessageBox::No, "&Discard Changes");
1015 mb.setButtonText(QMessageBox::Cancel, "Cancel Exit");
1016 switch (mb.exec()) {
1017 case QMessageBox::Yes:
1018 conf_write(NULL);
1019 case QMessageBox::No:
1020 e->accept();
1021 break;
1022 case QMessageBox::Cancel:
1023 e->ignore();
1024 break;
1025 }
1026}
1027
1028void fixup_rootmenu(struct menu *menu)
1029{
1030 struct menu *child;
1031
1032 if (!menu->prompt || menu->prompt->type != P_MENU)
1033 return;
1034 menu->prompt->type = P_ROOTMENU;
1035 for (child = menu->list; child; child = child->next)
1036 fixup_rootmenu(child);
1037}
1038
1039int main(int ac, char** av)
1040{
1041 ConfigView* v;
1042 const char *name;
1043
1044#ifndef LKC_DIRECT_LINK
1045 kconfig_load();
1046#endif
1047
1048 configApp = new QApplication(ac, av);
1049 if (ac > 1 && av[1][0] == '-') {
1050 switch (av[1][1]) {
1051 case 'a':
1052 //showAll = 1;
1053 break;
1054 case 'h':
1055 case '?':
1056 printf("%s <config>\n", av[0]);
1057 exit(0);
1058 }
1059 name = av[2];
1060 } else
1061 name = av[1];
1062 conf_parse(name);
1063 fixup_rootmenu(&rootmenu);
1064 conf_read(NULL);
1065 //zconfdump(stdout);
1066 v = new ConfigView();
1067
1068 //zconfdump(stdout);
1069 v->show();
1070 configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
1071 configApp->exec();
1072 return 0;
1073}
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
new file mode 100644
index 0000000..f8f3669
--- a/dev/null
+++ b/scripts/kconfig/qconf.h
@@ -0,0 +1,201 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <qlistview.h>
7
8class ConfigLineEdit;
9class ConfigItem;
10class ConfigView;
11
12enum colIdx {
13 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
14};
15enum listMode {
16 singleMode, menuMode, symbolMode, fullMode
17};
18
19class ConfigList : public QListView {
20 Q_OBJECT
21 typedef class QListView Parent;
22public:
23 ConfigList(QWidget* p, ConfigView* cview);
24 void reinit(void);
25
26 ConfigLineEdit* lineEdit;
27protected:
28 ConfigView* cview;
29
30 void keyPressEvent(QKeyEvent *e);
31 void contentsMousePressEvent(QMouseEvent *e);
32 void contentsMouseReleaseEvent(QMouseEvent *e);
33 void contentsMouseMoveEvent(QMouseEvent *e);
34 void contentsMouseDoubleClickEvent(QMouseEvent *e);
35 void focusInEvent(QFocusEvent *e);
36public slots:
37 void setRootMenu(struct menu *menu);
38
39 void updateList(ConfigItem *item);
40 void setValue(ConfigItem* item, tristate val);
41 void changeValue(ConfigItem* item);
42 void updateSelection(void);
43signals:
44 void menuSelected(struct menu *menu);
45 void parentSelected(void);
46 void symbolChanged(ConfigItem* item);
47 void gotFocus(void);
48
49public:
50 void updateListAll(void)
51 {
52 updateAll = true;
53 updateList(NULL);
54 updateAll = false;
55 }
56 ConfigList* listView()
57 {
58 return this;
59 }
60 ConfigItem* firstChild() const
61 {
62 return (ConfigItem *)Parent::firstChild();
63 }
64 int mapIdx(colIdx idx)
65 {
66 return colMap[idx];
67 }
68 void addColumn(colIdx idx, const QString& label)
69 {
70 colMap[idx] = Parent::addColumn(label);
71 colRevMap[colMap[idx]] = idx;
72 }
73 void removeColumn(colIdx idx)
74 {
75 int col = colMap[idx];
76 if (col >= 0) {
77 Parent::removeColumn(col);
78 colRevMap[col] = colMap[idx] = -1;
79 }
80 }
81 void setAllOpen(bool open);
82 void setParentMenu(void);
83
84 bool updateAll;
85
86 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
87 QPixmap choiceYesPix, choiceNoPix, menuPix, menuInvPix;
88
89 bool showAll, showName, showRange, showData;
90 enum listMode mode;
91 struct menu *rootEntry;
92 QColorGroup disabledColorGroup;
93 QColorGroup inactivedColorGroup;
94
95private:
96 int colMap[colNr];
97 int colRevMap[colNr];
98};
99
100class ConfigItem : public QListViewItem {
101 typedef class QListViewItem Parent;
102public:
103 ConfigItem(QListView *parent, ConfigItem *after, struct menu *m)
104 : Parent(parent, after), menu(m)
105 {
106 init();
107 }
108 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m)
109 : Parent(parent, after), menu(m)
110 {
111 init();
112 }
113 ~ConfigItem(void);
114 void init(void);
115#if QT_VERSION >= 300
116 void okRename(int col);
117#endif
118 void updateMenu(void);
119 ConfigList* listView() const
120 {
121 return (ConfigList*)Parent::listView();
122 }
123 ConfigItem* firstChild() const
124 {
125 return (ConfigItem *)Parent::firstChild();
126 }
127 ConfigItem* nextSibling() const
128 {
129 return (ConfigItem *)Parent::nextSibling();
130 }
131 void setText(colIdx idx, const QString& text)
132 {
133 Parent::setText(listView()->mapIdx(idx), text);
134 }
135 QString text(colIdx idx) const
136 {
137 return Parent::text(listView()->mapIdx(idx));
138 }
139 void setPixmap(colIdx idx, const QPixmap& pm)
140 {
141 Parent::setPixmap(listView()->mapIdx(idx), pm);
142 }
143 const QPixmap* pixmap(colIdx idx) const
144 {
145 return Parent::pixmap(listView()->mapIdx(idx));
146 }
147 void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align);
148
149 struct menu *menu;
150 bool visible;
151 bool doInit;
152};
153
154class ConfigLineEdit : public QLineEdit {
155 Q_OBJECT
156 typedef class QLineEdit Parent;
157public:
158 ConfigLineEdit(QWidget * parent)
159 : QLineEdit(parent)
160 { }
161 void show(ConfigItem *i);
162 void keyPressEvent(QKeyEvent *e);
163signals:
164 void lineChanged(ConfigItem *item);
165
166public:
167 ConfigItem *item;
168};
169
170class ConfigView : public QMainWindow {
171 Q_OBJECT
172public:
173 ConfigView(void);
174public slots:
175 void setHelp(QListViewItem* item);
176 void changeMenu(struct menu *);
177 void listFocusChanged(void);
178 void goBack(void);
179 void loadConfig(void);
180 void saveConfig(void);
181 void saveConfigAs(void);
182 void showSingleView(void);
183 void showSplitView(void);
184 void showFullView(void);
185 void setShowAll(bool);
186 void setShowDebug(bool);
187 void setShowRange(bool);
188 void setShowName(bool);
189 void setShowData(bool);
190
191protected:
192 void closeEvent(QCloseEvent *e);
193
194 ConfigList *menuList;
195 ConfigList *configList;
196 QTextView *helpText;
197 QToolBar *toolBar;
198 QAction *backAction;
199
200 bool showDebug;
201};
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
new file mode 100644
index 0000000..59c88d2
--- a/dev/null
+++ b/scripts/kconfig/symbol.c
@@ -0,0 +1,618 @@
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <ctype.h>
7#include <stdlib.h>
8#include <string.h>
9#include <sys/utsname.h>
10
11#define LKC_DIRECT_LINK
12#include "lkc.h"
13
14struct symbol symbol_yes = {
15 name: "y",
16 curr: { "y", yes },
17 flags: SYMBOL_YES|SYMBOL_VALID,
18}, symbol_mod = {
19 name: "m",
20 curr: { "m", mod },
21 flags: SYMBOL_MOD|SYMBOL_VALID,
22}, symbol_no = {
23 name: "n",
24 curr: { "n", no },
25 flags: SYMBOL_NO|SYMBOL_VALID,
26}, symbol_empty = {
27 name: "",
28 curr: { "", no },
29 flags: SYMBOL_VALID,
30};
31
32int sym_change_count;
33struct symbol *modules_sym;
34
35void sym_add_default(struct symbol *sym, const char *def)
36{
37 struct property *prop = create_prop(P_DEFAULT);
38 struct property **propp;
39
40 prop->sym = sym;
41 prop->def = sym_lookup(def, 1);
42
43 /* append property to the prop list of symbol */
44 if (prop->sym) {
45 for (propp = &prop->sym->prop; *propp; propp = &(*propp)->next)
46 ;
47 *propp = prop;
48 }
49}
50
51void sym_init(void)
52{
53 struct symbol *sym;
54 struct utsname uts;
55 char *p;
56 static bool inited = false;
57
58 if (inited)
59 return;
60 inited = true;
61
62 uname(&uts);
63
64 sym = sym_lookup("ARCH", 0);
65 sym->type = S_STRING;
66 sym->flags |= SYMBOL_AUTO;
67 p = getenv("ARCH");
68 if (p)
69 sym_add_default(sym, p);
70
71 sym = sym_lookup("KERNELRELEASE", 0);
72 sym->type = S_STRING;
73 sym->flags |= SYMBOL_AUTO;
74 p = getenv("KERNELRELEASE");
75 if (p)
76 sym_add_default(sym, p);
77
78 sym = sym_lookup("UNAME_RELEASE", 0);
79 sym->type = S_STRING;
80 sym->flags |= SYMBOL_AUTO;
81 sym_add_default(sym, uts.release);
82}
83
84int sym_get_type(struct symbol *sym)
85{
86 int type = sym->type;
87 if (type == S_TRISTATE) {
88 if (sym_is_choice_value(sym) && sym->visible == yes)
89 type = S_BOOLEAN;
90 else {
91 sym_calc_value(modules_sym);
92 if (S_TRI(modules_sym->curr) == no)
93 type = S_BOOLEAN;
94 }
95 }
96 return type;
97}
98
99const char *sym_type_name(int type)
100{
101 switch (type) {
102 case S_BOOLEAN:
103 return "boolean";
104 case S_TRISTATE:
105 return "tristate";
106 case S_INT:
107 return "integer";
108 case S_HEX:
109 return "hex";
110 case S_STRING:
111 return "string";
112 case S_UNKNOWN:
113 return "unknown";
114 }
115 return "???";
116}
117
118struct property *sym_get_choice_prop(struct symbol *sym)
119{
120 struct property *prop;
121
122 for_all_choices(sym, prop)
123 return prop;
124 return NULL;
125}
126
127struct property *sym_get_default_prop(struct symbol *sym)
128{
129 struct property *prop;
130 tristate visible;
131
132 for_all_defaults(sym, prop) {
133 visible = E_CALC(prop->visible);
134 if (visible != no)
135 return prop;
136 }
137 return NULL;
138}
139
140void sym_calc_visibility(struct symbol *sym)
141{
142 struct property *prop;
143 tristate visible, oldvisible;
144
145 /* any prompt visible? */
146 oldvisible = sym->visible;
147 visible = no;
148 for_all_prompts(sym, prop)
149 visible = E_OR(visible, E_CALC(prop->visible));
150 if (oldvisible != visible) {
151 sym->visible = visible;
152 sym->flags |= SYMBOL_CHANGED;
153 }
154}
155
156void sym_calc_value(struct symbol *sym)
157{
158 struct symbol_value newval, oldval;
159 struct property *prop, *def_prop;
160 struct symbol *def_sym;
161 struct expr *e;
162
163 if (sym->flags & SYMBOL_VALID)
164 return;
165
166 oldval = sym->curr;
167
168 switch (sym->type) {
169 case S_INT:
170 case S_HEX:
171 case S_STRING:
172 newval = symbol_empty.curr;
173 break;
174 case S_BOOLEAN:
175 case S_TRISTATE:
176 newval = symbol_no.curr;
177 break;
178 default:
179 S_VAL(newval) = sym->name;
180 S_TRI(newval) = no;
181 if (sym->flags & SYMBOL_CONST) {
182 goto out;
183 }
184 //newval = symbol_empty.curr;
185 // generate warning somewhere here later
186 //S_TRI(newval) = yes;
187 goto out;
188 }
189 sym->flags |= SYMBOL_VALID;
190 if (!sym_is_choice_value(sym))
191 sym->flags &= ~SYMBOL_WRITE;
192
193 sym_calc_visibility(sym);
194
195 /* set default if recursively called */
196 sym->curr = newval;
197
198 if (sym->visible != no) {
199 sym->flags |= SYMBOL_WRITE;
200 if (!sym_has_value(sym)) {
201 if (!sym_is_choice(sym)) {
202 prop = sym_get_default_prop(sym);
203 if (prop) {
204 sym_calc_value(prop->def);
205 newval = prop->def->curr;
206 }
207 }
208 } else
209 newval = sym->def;
210
211 S_TRI(newval) = E_AND(S_TRI(newval), sym->visible);
212 /* if the symbol is visible and not optionial,
213 * possibly ignore old user choice. */
214 if (!sym_is_optional(sym) && S_TRI(newval) == no)
215 S_TRI(newval) = sym->visible;
216 if (sym_is_choice_value(sym) && sym->visible == yes) {
217 prop = sym_get_choice_prop(sym);
218 S_TRI(newval) = (S_VAL(prop->def->curr) == sym) ? yes : no;
219 }
220 } else {
221 prop = sym_get_default_prop(sym);
222 if (prop) {
223 sym->flags |= SYMBOL_WRITE;
224 sym_calc_value(prop->def);
225 newval = prop->def->curr;
226 }
227 }
228
229 switch (sym_get_type(sym)) {
230 case S_TRISTATE:
231 if (S_TRI(newval) != mod)
232 break;
233 sym_calc_value(modules_sym);
234 if (S_TRI(modules_sym->curr) == no)
235 S_TRI(newval) = yes;
236 break;
237 case S_BOOLEAN:
238 if (S_TRI(newval) == mod)
239 S_TRI(newval) = yes;
240 }
241
242out:
243 sym->curr = newval;
244
245 if (sym_is_choice(sym) && S_TRI(newval) == yes) {
246 def_sym = S_VAL(sym->def);
247 if (def_sym) {
248 sym_calc_visibility(def_sym);
249 if (def_sym->visible == no)
250 def_sym = NULL;
251 }
252 if (!def_sym) {
253 for_all_defaults(sym, def_prop) {
254 if (E_CALC(def_prop->visible) == no)
255 continue;
256 sym_calc_visibility(def_prop->def);
257 if (def_prop->def->visible != no) {
258 def_sym = def_prop->def;
259 break;
260 }
261 }
262 }
263
264 if (!def_sym) {
265 prop = sym_get_choice_prop(sym);
266 for (e = prop->dep; e; e = e->left.expr) {
267 sym_calc_visibility(e->right.sym);
268 if (e->right.sym->visible != no) {
269 def_sym = e->right.sym;
270 break;
271 }
272 }
273 }
274
275 S_VAL(newval) = def_sym;
276 }
277
278 if (memcmp(&oldval, &newval, sizeof(newval)))
279 sym->flags |= SYMBOL_CHANGED;
280 sym->curr = newval;
281
282 if (sym_is_choice(sym)) {
283 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
284 prop = sym_get_choice_prop(sym);
285 for (e = prop->dep; e; e = e->left.expr)
286 e->right.sym->flags |= flags;
287 }
288}
289
290void sym_clear_all_valid(void)
291{
292 struct symbol *sym;
293 int i;
294
295 for_all_symbols(i, sym)
296 sym->flags &= ~SYMBOL_VALID;
297 sym_change_count++;
298}
299
300void sym_set_all_changed(void)
301{
302 struct symbol *sym;
303 int i;
304
305 for_all_symbols(i, sym)
306 sym->flags |= SYMBOL_CHANGED;
307}
308
309bool sym_tristate_within_range(struct symbol *sym, tristate val)
310{
311 int type = sym_get_type(sym);
312
313 if (sym->visible == no)
314 return false;
315
316 if (type != S_BOOLEAN && type != S_TRISTATE)
317 return false;
318
319 switch (val) {
320 case no:
321 if (sym_is_choice_value(sym) && sym->visible == yes)
322 return false;
323 return sym_is_optional(sym);
324 case mod:
325 if (sym_is_choice_value(sym) && sym->visible == yes)
326 return false;
327 return type == S_TRISTATE;
328 case yes:
329 return type == S_BOOLEAN || sym->visible == yes;
330 }
331 return false;
332}
333
334bool sym_set_tristate_value(struct symbol *sym, tristate val)
335{
336 tristate oldval = sym_get_tristate_value(sym);
337
338 if (oldval != val && !sym_tristate_within_range(sym, val))
339 return false;
340
341 if (sym->flags & SYMBOL_NEW) {
342 sym->flags &= ~SYMBOL_NEW;
343 sym->flags |= SYMBOL_CHANGED;
344 }
345 if (sym_is_choice_value(sym) && val == yes) {
346 struct property *prop = sym_get_choice_prop(sym);
347
348 S_VAL(prop->def->def) = sym;
349 prop->def->flags &= ~SYMBOL_NEW;
350 }
351
352 S_TRI(sym->def) = val;
353 if (oldval != val) {
354 sym_clear_all_valid();
355 if (sym == modules_sym)
356 sym_set_all_changed();
357 }
358
359 return true;
360}
361
362tristate sym_toggle_tristate_value(struct symbol *sym)
363{
364 tristate oldval, newval;
365
366 oldval = newval = sym_get_tristate_value(sym);
367 do {
368 switch (newval) {
369 case no:
370 newval = mod;
371 break;
372 case mod:
373 newval = yes;
374 break;
375 case yes:
376 newval = no;
377 break;
378 }
379 if (sym_set_tristate_value(sym, newval))
380 break;
381 } while (oldval != newval);
382 return newval;
383}
384
385bool sym_string_valid(struct symbol *sym, const char *str)
386{
387 char ch;
388
389 switch (sym->type) {
390 case S_STRING:
391 return true;
392 case S_INT:
393 ch = *str++;
394 if (ch == '-')
395 ch = *str++;
396 if (!isdigit(ch))
397 return false;
398 if (ch == '0' && *str != 0)
399 return false;
400 while ((ch = *str++)) {
401 if (!isdigit(ch))
402 return false;
403 }
404 return true;
405 case S_HEX:
406 if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
407 str += 2;
408 ch = *str++;
409 do {
410 if (!isxdigit(ch))
411 return false;
412 } while ((ch = *str++));
413 return true;
414 case S_BOOLEAN:
415 case S_TRISTATE:
416 switch (str[0]) {
417 case 'y':
418 case 'Y':
419 return sym_tristate_within_range(sym, yes);
420 case 'm':
421 case 'M':
422 return sym_tristate_within_range(sym, mod);
423 case 'n':
424 case 'N':
425 return sym_tristate_within_range(sym, no);
426 }
427 return false;
428 default:
429 return false;
430 }
431}
432
433bool sym_set_string_value(struct symbol *sym, const char *newval)
434{
435 const char *oldval;
436 char *val;
437 int size;
438
439 switch (sym->type) {
440 case S_BOOLEAN:
441 case S_TRISTATE:
442 switch (newval[0]) {
443 case 'y':
444 case 'Y':
445 return sym_set_tristate_value(sym, yes);
446 case 'm':
447 case 'M':
448 return sym_set_tristate_value(sym, mod);
449 case 'n':
450 case 'N':
451 return sym_set_tristate_value(sym, no);
452 }
453 return false;
454 default:
455 ;
456 }
457
458 if (!sym_string_valid(sym, newval))
459 return false;
460
461 if (sym->flags & SYMBOL_NEW) {
462 sym->flags &= ~SYMBOL_NEW;
463 sym->flags |= SYMBOL_CHANGED;
464 }
465
466 oldval = S_VAL(sym->def);
467 size = strlen(newval) + 1;
468 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
469 size += 2;
470 S_VAL(sym->def) = val = malloc(size);
471 *val++ = '0';
472 *val++ = 'x';
473 } else if (!oldval || strcmp(oldval, newval))
474 S_VAL(sym->def) = val = malloc(size);
475 else
476 return true;
477
478 strcpy(val, newval);
479 free((void *)oldval);
480 sym_clear_all_valid();
481
482 return true;
483}
484
485const char *sym_get_string_value(struct symbol *sym)
486{
487 tristate val;
488
489 switch (sym->type) {
490 case S_BOOLEAN:
491 case S_TRISTATE:
492 val = sym_get_tristate_value(sym);
493 switch (val) {
494 case no:
495 return "n";
496 case mod:
497 return "m";
498 case yes:
499 return "y";
500 }
501 break;
502 default:
503 ;
504 }
505 return (const char *)S_VAL(sym->curr);
506}
507
508bool sym_is_changable(struct symbol *sym)
509{
510 if (sym->visible == no)
511 return false;
512 /* at least 'n' and 'y'/'m' is selectable */
513 if (sym_is_optional(sym))
514 return true;
515 /* no 'n', so 'y' and 'm' must be selectable */
516 if (sym_get_type(sym) == S_TRISTATE && sym->visible == yes)
517 return true;
518 return false;
519}
520
521struct symbol *sym_lookup(const char *name, int isconst)
522{
523 struct symbol *symbol;
524 const char *ptr;
525 char *new_name;
526 int hash = 0;
527
528 //printf("lookup: %s -> ", name);
529 if (name) {
530 if (name[0] && !name[1]) {
531 switch (name[0]) {
532 case 'y': return &symbol_yes;
533 case 'm': return &symbol_mod;
534 case 'n': return &symbol_no;
535 }
536 }
537 for (ptr = name; *ptr; ptr++)
538 hash += *ptr;
539 hash &= 0xff;
540
541 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
542 if (!strcmp(symbol->name, name)) {
543 if ((isconst && symbol->flags & SYMBOL_CONST) ||
544 (!isconst && !(symbol->flags & SYMBOL_CONST))) {
545 //printf("h:%p\n", symbol);
546 return symbol;
547 }
548 }
549 }
550 new_name = strdup(name);
551 } else {
552 new_name = NULL;
553 hash = 256;
554 }
555
556 symbol = malloc(sizeof(*symbol));
557 memset(symbol, 0, sizeof(*symbol));
558 symbol->name = new_name;
559 symbol->type = S_UNKNOWN;
560 symbol->flags = SYMBOL_NEW;
561 if (isconst)
562 symbol->flags |= SYMBOL_CONST;
563
564 symbol->next = symbol_hash[hash];
565 symbol_hash[hash] = symbol;
566
567 //printf("n:%p\n", symbol);
568 return symbol;
569}
570
571struct symbol *sym_find(const char *name)
572{
573 struct symbol *symbol = NULL;
574 const char *ptr;
575 int hash = 0;
576
577 if (!name)
578 return NULL;
579
580 if (name[0] && !name[1]) {
581 switch (name[0]) {
582 case 'y': return &symbol_yes;
583 case 'm': return &symbol_mod;
584 case 'n': return &symbol_no;
585 }
586 }
587 for (ptr = name; *ptr; ptr++)
588 hash += *ptr;
589 hash &= 0xff;
590
591 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
592 if (!strcmp(symbol->name, name) &&
593 !(symbol->flags & SYMBOL_CONST))
594 break;
595 }
596
597 return symbol;
598}
599
600const char *prop_get_type_name(enum prop_type type)
601{
602 switch (type) {
603 case P_PROMPT:
604 return "prompt";
605 case P_COMMENT:
606 return "comment";
607 case P_MENU:
608 return "menu";
609 case P_ROOTMENU:
610 return "rootmenu";
611 case P_DEFAULT:
612 return "default";
613 case P_CHOICE:
614 return "choice";
615 default:
616 return "unknown";
617 }
618}
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
new file mode 100644
index 0000000..6d81e5e
--- a/dev/null
+++ b/scripts/kconfig/zconf.l
@@ -0,0 +1,323 @@
1%option backup nostdinit noyywrap full ecs
2%option 8bit backup nodefault perf-report perf-report
3%x COMMAND HELP STRING PARAM
4%{
5/*
6 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
7 * Released under the terms of the GNU GPL v2.0.
8 */
9
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include <unistd.h>
14
15#define LKC_DIRECT_LINK
16#include "lkc.h"
17#include "zconf.tab.h"
18
19 #define START_STRSIZE16
20
21char *text;
22static char *text_ptr;
23static int text_size, text_asize;
24
25struct buffer {
26 struct buffer *parent;
27 YY_BUFFER_STATE state;
28};
29
30struct buffer *current_buf;
31
32static int last_ts, first_ts;
33
34static void zconf_endhelp(void);
35static struct buffer *zconf_endfile(void);
36
37void new_string(void)
38{
39 text = malloc(START_STRSIZE);
40 text_asize = START_STRSIZE;
41 text_ptr = text;
42 text_size = 0;
43 *text_ptr = 0;
44}
45
46void append_string(const char *str, int size)
47{
48 int new_size = text_size + size + 1;
49 if (new_size > text_asize) {
50 text = realloc(text, new_size);
51 text_asize = new_size;
52 text_ptr = text + text_size;
53 }
54 memcpy(text_ptr, str, size);
55 text_ptr += size;
56 text_size += size;
57 *text_ptr = 0;
58}
59
60void alloc_string(const char *str, int size)
61{
62 text = malloc(size + 1);
63 memcpy(text, str, size);
64 text[size] = 0;
65}
66%}
67
68 ws[ \n\t]
69 n[A-Za-z0-9_]
70
71%%
72 int str = 0;
73 int ts, i;
74
75 [ \t]*#.*\ncurrent_file->lineno++;
76[ \t]*#.*
77
78 [ \t]*\ncurrent_file->lineno++; return T_EOL;
79
80 [ \t]+{
81 BEGIN(COMMAND);
82}
83
84 .{
85 unput(yytext[0]);
86 //printf("new config: ");
87 //symbol_end(NULL);
88 BEGIN(COMMAND);
89}
90
91
92<COMMAND>{
93 "mainmenu" BEGIN(PARAM); return T_MAINMENU;
94 "menu" BEGIN(PARAM); return T_MENU;
95 "endmenu" BEGIN(PARAM); return T_ENDMENU;
96 "source" BEGIN(PARAM); return T_SOURCE;
97 "choice" BEGIN(PARAM); return T_CHOICE;
98 "endchoice" BEGIN(PARAM); return T_ENDCHOICE;
99 "comment" BEGIN(PARAM); return T_COMMENT;
100 "config" BEGIN(PARAM); return T_CONFIG;
101 "help" BEGIN(PARAM); return T_HELP;
102 "if" BEGIN(PARAM); return T_IF;
103 "endif" BEGIN(PARAM); return T_ENDIF;
104 "depends" BEGIN(PARAM); return T_DEPENDS;
105 "requires" BEGIN(PARAM); return T_REQUIRES;
106 "optional" BEGIN(PARAM); return T_OPTIONAL;
107 "default" BEGIN(PARAM); return T_DEFAULT;
108 "prompt" BEGIN(PARAM); return T_PROMPT;
109 "tristate" BEGIN(PARAM); return T_TRISTATE;
110 "bool" BEGIN(PARAM); return T_BOOLEAN;
111 "boolean" BEGIN(PARAM); return T_BOOLEAN;
112 "int" BEGIN(PARAM); return T_INT;
113 "hex" BEGIN(PARAM); return T_HEX;
114 "string" BEGIN(PARAM); return T_STRING;
115 {n}+{
116 alloc_string(yytext, yyleng);
117 zconflval.string = text;
118 return T_WORD;
119 }
120 .
121 \ncurrent_file->lineno++; BEGIN(INITIAL);
122}
123
124<PARAM>{
125 "&&"return T_AND;
126 "||"return T_OR;
127 "("return T_OPEN_PAREN;
128 ")"return T_CLOSE_PAREN;
129 "!"return T_NOT;
130 "="return T_EQUAL;
131 "!="return T_UNEQUAL;
132 "if"return T_IF;
133 "on"return T_ON;
134 \"|\'{
135 str = yytext[0];
136 new_string();
137 BEGIN(STRING);
138 }
139 \nBEGIN(INITIAL); current_file->lineno++; return T_EOL;
140 ---/* ignore */
141 ({n}|[-/.])+{
142 alloc_string(yytext, yyleng);
143 zconflval.string = text;
144 return T_WORD;
145 }
146 .
147}
148
149<STRING>{
150 [^'"\n\\]+{
151 append_string(yytext, yyleng);
152 }
153 \'|\"{
154 if (str == yytext[0]) {
155 BEGIN(PARAM);
156 zconflval.string = text;
157 //printf("s:%s\n", text);
158 return T_STRING;
159 } else
160 append_string(yytext, 1);
161 }
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{
166 //printf(":%d: open string!\n", current_file->lineno+1);
167 exit(0);
168 }
169 <<EOF>>{
170 //printf(":%d: open string!\n", current_file->lineno+1);
171 exit(0);
172 }
173}
174
175<HELP>{
176 [ \t]+{
177 ts = 0;
178 for (i = 0; i < yyleng; i++) {
179 if (yytext[i] == '\t')
180 ts = (ts & ~7) + 8;
181 else
182 ts++;
183 }
184 last_ts = ts;
185 if (first_ts) {
186 if (ts < first_ts) {
187 zconf_endhelp();
188 return T_HELPTEXT;
189 }
190 ts -= first_ts;
191 while (ts > 8) {
192 append_string(" ", 8);
193 ts -= 8;
194 }
195 append_string(" ", ts);
196 }
197
198 }
199 \n/[^ \t\n] {
200 current_file->lineno++;
201 zconf_endhelp();
202 return T_HELPTEXT;
203 }
204 [ \t]*\n{
205 current_file->lineno++;
206 append_string("\n", 1);
207 }
208 [^ \t\n].* {
209 append_string(yytext, yyleng);
210 if (!first_ts)
211 first_ts = last_ts;
212 }
213 <<EOF>>{
214 zconf_endhelp();
215 return T_HELPTEXT;
216 }
217}
218
219 <<EOF>>{
220 if (current_buf) {
221 zconf_endfile();
222 return T_EOF;
223 }
224 yyterminate();
225}
226
227%%
228void zconf_starthelp(void)
229{
230 new_string();
231 last_ts = first_ts = 0;
232 BEGIN(HELP);
233}
234
235static void zconf_endhelp(void)
236{
237 zconflval.string = text;
238 BEGIN(INITIAL);
239}
240
241void zconf_initscan(const char *name)
242{
243 yyin = fopen(name, "r");
244 if (!yyin) {
245 printf("can't find file %s\n", name);
246 exit(1);
247 }
248 //fprintf(stderr, "zconf_initscan: %s\n", name);
249
250 current_buf = malloc(sizeof(*current_buf));
251 memset(current_buf, 0, sizeof(*current_buf));
252
253 current_file = file_lookup(name);
254 current_file->lineno = 1;
255 current_file->flags = FILE_BUSY;
256}
257
258void zconf_nextfile(const char *name)
259{
260 struct file *file = file_lookup(name);
261 struct buffer *buf = malloc(sizeof(*buf));
262 memset(buf, 0, sizeof(*buf));
263
264 current_buf->state = YY_CURRENT_BUFFER;
265 yyin = fopen(name, "r");
266 if (!yyin) {
267 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
268 exit(1);
269 }
270 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
271 buf->parent = current_buf;
272 current_buf = buf;
273
274 //fprintf(stderr, "zconf_nextfile: %s\n", name);
275
276 if (file->flags & FILE_BUSY) {
277 printf("recursive scan (%s)?\n", name);
278 exit(1);
279 }
280 if (file->flags & FILE_SCANNED) {
281 printf("file %s already scanned?\n", name);
282 exit(1);
283 }
284 file->flags |= FILE_BUSY;
285 file->lineno = 1;
286 file->parent = current_file;
287 current_file = file;
288}
289
290static struct buffer *zconf_endfile(void)
291{
292 struct buffer *parent;
293
294 current_file->flags |= FILE_SCANNED;
295 current_file->flags &= ~FILE_BUSY;
296 current_file = current_file->parent;
297
298 parent = current_buf->parent;
299 if (parent) {
300 yy_delete_buffer(YY_CURRENT_BUFFER);
301 yy_switch_to_buffer(parent->state);
302 }
303 free(current_buf);
304 current_buf = parent;
305
306 return parent;
307}
308
309int zconf_lineno(void)
310{
311 if (current_buf)
312 return current_file->lineno;
313 else
314 return 0;
315}
316
317char *zconf_curname(void)
318{
319 if (current_buf)
320 return current_file->name;
321 else
322 return "<none>";
323}
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
new file mode 100644
index 0000000..79cb983
--- a/dev/null
+++ b/scripts/kconfig/zconf.y
@@ -0,0 +1,651 @@
1%{
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 */
6
7#include <ctype.h>
8#include <stdarg.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12#include <stdbool.h>
13
14#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
15
16 #define PRINTD 0x0001
17 #define DEBUG_PARSE0x0002
18
19int cdebug = PRINTD;
20
21extern int zconflex(void);
22static void zconfprint(const char *err, ...);
23static void zconferror(const char *err);
24static bool zconf_endtoken(int token, int starttoken, int endtoken);
25
26struct symbol *symbol_hash[257];
27
28#define YYERROR_VERBOSE
29%}
30%expect 36
31
32%union
33{
34 int token;
35 char *string;
36 struct symbol *symbol;
37 struct expr *expr;
38 struct menu *menu;
39}
40
41%token T_MAINMENU
42%token T_MENU
43%token T_ENDMENU
44%token T_SOURCE
45%token T_CHOICE
46%token T_ENDCHOICE
47%token T_COMMENT
48%token T_CONFIG
49%token T_HELP
50%token <string> T_HELPTEXT
51%token T_IF
52%token T_ENDIF
53%token T_DEPENDS
54%token T_REQUIRES
55%token T_OPTIONAL
56%token T_PROMPT
57%token T_DEFAULT
58%token T_TRISTATE
59%token T_BOOLEAN
60%token T_INT
61%token T_HEX
62%token <string> T_WORD
63%token <string> T_STRING
64%token T_UNEQUAL
65%token T_EOF
66%token T_EOL
67%token T_CLOSE_PAREN
68%token T_OPEN_PAREN
69%token T_ON
70
71%left T_OR
72%left T_AND
73%left T_EQUAL T_UNEQUAL
74%nonassoc T_NOT
75
76%type <string> prompt
77%type <string> source
78%type <symbol> symbol
79%type <expr> expr
80%type <expr> if_expr
81%type <token> end
82
83%{
84#define LKC_DIRECT_LINK
85#include "lkc.h"
86%}
87%%
88 input: /* empty */
89 | input block
90;
91
92 block: common_block
93 | choice_stmt
94 | menu_stmt
95 | T_MAINMENU prompt nl_or_eof
96 | T_ENDMENU { zconfprint("unexpected 'endmenu' statement"); }
97 | T_ENDIF { zconfprint("unexpected 'endif' statement"); }
98 | T_ENDCHOICE { zconfprint("unexpected 'endchoice' statement"); }
99 | error nl_or_eof{ zconfprint("syntax error"); yyerrok; }
100;
101
102common_block:
103 if_stmt
104 | comment_stmt
105 | config_stmt
106 | source_stmt
107 | nl_or_eof
108;
109
110
111/* config entry */
112
113config_entry_start: T_CONFIG T_WORD
114{
115 struct symbol *sym = sym_lookup($2, 0);
116 sym->flags |= SYMBOL_OPTIONAL;
117 menu_add_entry(sym);
118 printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2);
119};
120
121config_stmt: config_entry_start T_EOL config_option_list
122{
123 menu_end_entry();
124 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
125};
126
127config_option_list:
128 /* empty */
129 | config_option_list config_option T_EOL
130 | config_option_list depends T_EOL
131 | config_option_list help
132 | config_option_list T_EOL
133{ };
134
135config_option: T_TRISTATE prompt_stmt_opt
136{
137 menu_set_type(S_TRISTATE);
138 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno());
139};
140
141config_option: T_BOOLEAN prompt_stmt_opt
142{
143 menu_set_type(S_BOOLEAN);
144 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno());
145};
146
147config_option: T_INT prompt_stmt_opt
148{
149 menu_set_type(S_INT);
150 printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno());
151};
152
153config_option: T_HEX prompt_stmt_opt
154{
155 menu_set_type(S_HEX);
156 printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno());
157};
158
159config_option: T_STRING prompt_stmt_opt
160{
161 menu_set_type(S_STRING);
162 printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno());
163};
164
165config_option: T_PROMPT prompt if_expr
166{
167 menu_add_prop(P_PROMPT, $2, NULL, $3);
168 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
169};
170
171config_option: T_DEFAULT symbol if_expr
172{
173 menu_add_prop(P_DEFAULT, NULL, $2, $3);
174 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
175};
176
177/* choice entry */
178
179choice: T_CHOICE
180{
181 struct symbol *sym = sym_lookup(NULL, 0);
182 sym->flags |= SYMBOL_CHOICE;
183 menu_add_entry(sym);
184 menu_add_prop(P_CHOICE, NULL, NULL, NULL);
185 printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
186};
187
188choice_entry: choice T_EOL choice_option_list
189{
190 menu_end_entry();
191 menu_add_menu();
192};
193
194choice_end: end
195{
196 if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) {
197 menu_end_menu();
198 printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
199 }
200};
201
202choice_stmt:
203 choice_entry choice_block choice_end T_EOL
204 | choice_entry choice_block
205{
206 printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno);
207 zconfnerrs++;
208};
209
210choice_option_list:
211 /* empty */
212 | choice_option_list choice_option T_EOL
213 | choice_option_list depends T_EOL
214 | choice_option_list help
215 | choice_option_list T_EOL
216;
217
218choice_option: T_PROMPT prompt if_expr
219{
220 menu_add_prop(P_PROMPT, $2, NULL, $3);
221 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
222};
223
224choice_option: T_OPTIONAL
225{
226 current_entry->sym->flags |= SYMBOL_OPTIONAL;
227 printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
228};
229
230choice_option: T_DEFAULT symbol
231{
232 menu_add_prop(P_DEFAULT, NULL, $2, NULL);
233 //current_choice->prop->def = $2;
234 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
235};
236
237choice_block:
238 /* empty */
239 | choice_block common_block
240;
241
242/* if entry */
243
244if: T_IF expr
245{
246 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
247 menu_add_entry(NULL);
248 //current_entry->prompt = menu_add_prop(T_IF, NULL, NULL, $2);
249 menu_add_dep($2);
250 menu_end_entry();
251 menu_add_menu();
252};
253
254if_end: end
255{
256 if (zconf_endtoken($1, T_IF, T_ENDIF)) {
257 menu_end_menu();
258 printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
259 }
260};
261
262if_stmt:
263 if T_EOL if_block if_end T_EOL
264 | if T_EOL if_block
265{
266 printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno);
267 zconfnerrs++;
268};
269
270if_block:
271 /* empty */
272 | if_block common_block
273 | if_block menu_stmt
274 | if_block choice_stmt
275;
276
277/* menu entry */
278
279menu: T_MENU prompt
280{
281 menu_add_entry(NULL);
282 menu_add_prop(P_MENU, $2, NULL, NULL);
283 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
284};
285
286menu_entry: menu T_EOL depends_list
287{
288 menu_end_entry();
289 menu_add_menu();
290};
291
292menu_end: end
293{
294 if (zconf_endtoken($1, T_MENU, T_ENDMENU)) {
295 menu_end_menu();
296 printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
297 }
298};
299
300menu_stmt:
301 menu_entry menu_block menu_end T_EOL
302 | menu_entry menu_block
303{
304 printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno);
305 zconfnerrs++;
306};
307
308menu_block:
309 /* empty */
310 | menu_block common_block
311 | menu_block menu_stmt
312 | menu_block choice_stmt
313 | menu_block error T_EOL { zconfprint("invalid menu option"); yyerrok; }
314;
315
316source: T_SOURCE prompt
317{
318 $$ = $2;
319 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
320};
321
322source_stmt: source T_EOL
323{
324 zconf_nextfile($1);
325};
326
327/* comment entry */
328
329comment: T_COMMENT prompt
330{
331 menu_add_entry(NULL);
332 menu_add_prop(P_COMMENT, $2, NULL, NULL);
333 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
334};
335
336comment_stmt: comment T_EOL depends_list
337{
338 menu_end_entry();
339};
340
341/* help option */
342
343help_start: T_HELP T_EOL
344{
345 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
346 zconf_starthelp();
347};
348
349help: help_start T_HELPTEXT
350{
351 current_entry->sym->help = $2;
352};
353
354/* depends option */
355
356 depends_list: /* empty */
357 | depends_list depends T_EOL
358 | depends_list T_EOL
359{ };
360
361depends: T_DEPENDS T_ON expr
362{
363 menu_add_dep($3);
364 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
365}
366 | T_DEPENDS expr
367{
368 menu_add_dep($2);
369 printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno());
370}
371 | T_REQUIRES expr
372{
373 menu_add_dep($2);
374 printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno());
375};
376
377/* prompt statement */
378
379prompt_stmt_opt:
380 /* empty */
381 | prompt
382{
383 menu_add_prop(P_PROMPT, $1, NULL, NULL);
384}
385 | prompt T_IF expr
386{
387 menu_add_prop(P_PROMPT, $1, NULL, $3);
388};
389
390 prompt: T_WORD
391 | T_STRING
392;
393
394 end: T_ENDMENU { $$ = T_ENDMENU; }
395 | T_ENDCHOICE { $$ = T_ENDCHOICE; }
396 | T_ENDIF { $$ = T_ENDIF; }
397;
398
399nl_or_eof:
400 T_EOL | T_EOF;
401
402 if_expr: /* empty */ { $$ = NULL; }
403 | T_IF expr { $$ = $2; }
404;
405
406 expr: symbol { $$ = expr_alloc_symbol($1); }
407 | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); }
408 | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); }
409 | T_OPEN_PAREN expr T_CLOSE_PAREN{ $$ = $2; }
410 | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); }
411 | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); }
412 | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); }
413;
414
415 symbol: T_WORD{ $$ = sym_lookup($1, 0); free($1); }
416 | T_STRING{ $$ = sym_lookup($1, 1); free($1); }
417;
418
419%%
420
421void conf_parse(const char *name)
422{
423 zconf_initscan(name);
424
425 sym_init();
426 menu_init();
427 rootmenu.prompt = menu_add_prop(P_MENU, "Linux Kernel Configuration", NULL, NULL);
428
429 //zconfdebug = 1;
430 zconfparse();
431 if (zconfnerrs)
432 exit(1);
433 menu_finalize(&rootmenu);
434
435 modules_sym = sym_lookup("MODULES", 0);
436
437 sym_change_count = 1;
438}
439
440const char *zconf_tokenname(int token)
441{
442 switch (token) {
443 case T_MENU: return "menu";
444 case T_ENDMENU: return "endmenu";
445 case T_CHOICE: return "choice";
446 case T_ENDCHOICE:return "endchoice";
447 case T_IF: return "if";
448 case T_ENDIF: return "endif";
449 }
450 return "<token>";
451}
452
453static bool zconf_endtoken(int token, int starttoken, int endtoken)
454{
455 if (token != endtoken) {
456 zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken));
457 zconfnerrs++;
458 return false;
459 }
460 if (current_menu->file != current_file) {
461 zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken));
462 zconfprint("location of the '%s'", zconf_tokenname(starttoken));
463 zconfnerrs++;
464 return false;
465 }
466 return true;
467}
468
469static void zconfprint(const char *err, ...)
470{
471 va_list ap;
472
473 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
474 va_start(ap, err);
475 vfprintf(stderr, err, ap);
476 va_end(ap);
477 fprintf(stderr, "\n");
478}
479
480static void zconferror(const char *err)
481{
482 fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno(), err);
483}
484
485void print_quoted_string(FILE *out, const char *str)
486{
487 const char *p;
488 int len;
489
490 putc('"', out);
491 while ((p = strchr(str, '"'))) {
492 len = p - str;
493 if (len)
494 fprintf(out, "%.*s", len, str);
495 fputs("\\\"", out);
496 str = p + 1;
497 }
498 fputs(str, out);
499 putc('"', out);
500}
501
502void print_symbol(FILE *out, struct menu *menu)
503{
504 struct symbol *sym = menu->sym;
505 struct property *prop;
506
507 //sym->flags |= SYMBOL_PRINTED;
508
509 if (sym_is_choice(sym))
510 fprintf(out, "choice\n");
511 else
512 fprintf(out, "config %s\n", sym->name);
513 switch (sym->type) {
514 case S_BOOLEAN:
515 fputs(" boolean\n", out);
516 break;
517 case S_TRISTATE:
518 fputs(" tristate\n", out);
519 break;
520 case S_STRING:
521 fputs(" string\n", out);
522 break;
523 case S_INT:
524 fputs(" integer\n", out);
525 break;
526 case S_HEX:
527 fputs(" hex\n", out);
528 break;
529 default:
530 fputs(" ???\n", out);
531 break;
532 }
533#if 0
534 if (!expr_is_yes(sym->dep)) {
535 fputs(" depends ", out);
536 expr_fprint(sym->dep, out);
537 fputc('\n', out);
538 }
539#endif
540 for (prop = sym->prop; prop; prop = prop->next) {
541 if (prop->menu != menu)
542 continue;
543 switch (prop->type) {
544 case P_PROMPT:
545 fputs(" prompt ", out);
546 print_quoted_string(out, prop->text);
547 if (prop->def) {
548 fputc(' ', out);
549 if (prop->def->flags & SYMBOL_CONST)
550 print_quoted_string(out, prop->def->name);
551 else
552 fputs(prop->def->name, out);
553 }
554 if (!expr_is_yes(E_EXPR(prop->visible))) {
555 fputs(" if ", out);
556 expr_fprint(E_EXPR(prop->visible), out);
557 }
558 fputc('\n', out);
559 break;
560 case P_DEFAULT:
561 fputs( " default ", out);
562 print_quoted_string(out, prop->def->name);
563 if (!expr_is_yes(E_EXPR(prop->visible))) {
564 fputs(" if ", out);
565 expr_fprint(E_EXPR(prop->visible), out);
566 }
567 fputc('\n', out);
568 break;
569 case P_CHOICE:
570 fputs(" #choice value\n", out);
571 break;
572 default:
573 fprintf(out, " unknown prop %d!\n", prop->type);
574 break;
575 }
576 }
577 if (sym->help) {
578 int len = strlen(sym->help);
579 while (sym->help[--len] == '\n')
580 sym->help[len] = 0;
581 fprintf(out, " help\n%s\n", sym->help);
582 }
583 fputc('\n', out);
584}
585
586void zconfdump(FILE *out)
587{
588 //struct file *file;
589 struct property *prop;
590 struct symbol *sym;
591 struct menu *menu;
592
593 menu = rootmenu.list;
594 while (menu) {
595 if ((sym = menu->sym))
596 print_symbol(out, menu);
597 else if ((prop = menu->prompt)) {
598 switch (prop->type) {
599 //case T_MAINMENU:
600 //fputs("\nmainmenu ", out);
601 //print_quoted_string(out, prop->text);
602 //fputs("\n", out);
603 //break;
604 case P_COMMENT:
605 fputs("\ncomment ", out);
606 print_quoted_string(out, prop->text);
607 fputs("\n", out);
608 break;
609 case P_MENU:
610 fputs("\nmenu ", out);
611 print_quoted_string(out, prop->text);
612 fputs("\n", out);
613 break;
614 //case T_SOURCE:
615 //fputs("\nsource ", out);
616 //print_quoted_string(out, prop->text);
617 //fputs("\n", out);
618 //break;
619 //case T_IF:
620 //fputs("\nif\n", out);
621 default:
622 ;
623 }
624 if (!expr_is_yes(E_EXPR(prop->visible))) {
625 fputs(" depends ", out);
626 expr_fprint(E_EXPR(prop->visible), out);
627 fputc('\n', out);
628 }
629 fputs("\n", out);
630 }
631
632 if (menu->list)
633 menu = menu->list;
634 else if (menu->next)
635 menu = menu->next;
636 else while ((menu = menu->parent)) {
637 if (menu->prompt && menu->prompt->type == P_MENU)
638 fputs("\nendmenu\n", out);
639 if (menu->next) {
640 menu = menu->next;
641 break;
642 }
643 }
644 }
645}
646
647#include "lex.zconf.c"
648#include "confdata.c"
649#include "expr.c"
650#include "symbol.c"
651#include "menu.c"