Subversion Repositories HelenOS

Rev

Rev 4341 | Rev 4343 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4341 Rev 4342
1
#!/usr/bin/env python
1
#!/usr/bin/env python
2
#
2
#
3
# Copyright (c) 2006 Ondrej Palkovsky
3
# Copyright (c) 2006 Ondrej Palkovsky
4
# Copyright (c) 2009 Martin Decky
4
# Copyright (c) 2009 Martin Decky
5
# All rights reserved.
5
# All rights reserved.
6
#
6
#
7
# Redistribution and use in source and binary forms, with or without
7
# Redistribution and use in source and binary forms, with or without
8
# modification, are permitted provided that the following conditions
8
# modification, are permitted provided that the following conditions
9
# are met:
9
# are met:
10
#
10
#
11
# - Redistributions of source code must retain the above copyright
11
# - Redistributions of source code must retain the above copyright
12
#   notice, this list of conditions and the following disclaimer.
12
#   notice, this list of conditions and the following disclaimer.
13
# - Redistributions in binary form must reproduce the above copyright
13
# - Redistributions in binary form must reproduce the above copyright
14
#   notice, this list of conditions and the following disclaimer in the
14
#   notice, this list of conditions and the following disclaimer in the
15
#   documentation and/or other materials provided with the distribution.
15
#   documentation and/or other materials provided with the distribution.
16
# - The name of the author may not be used to endorse or promote products
16
# - The name of the author may not be used to endorse or promote products
17
#   derived from this software without specific prior written permission.
17
#   derived from this software without specific prior written permission.
18
#
18
#
19
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
#
29
#
30
"""
30
"""
31
HelenOS configuration system
31
HelenOS configuration system
32
"""
32
"""
33
import sys
33
import sys
34
import os
34
import os
35
import re
35
import re
36
import commands
36
import commands
37
import xtui
37
import xtui
38
 
38
 
39
INPUT = sys.argv[1]
39
INPUT = sys.argv[1]
40
OUTPUT = 'Makefile.config'
40
MAKEFILE = 'Makefile.config'
-
 
41
MACROS = 'config.h'
-
 
42
DEFS = 'config.defs'
41
 
43
 
42
def read_defaults(fname, defaults):
44
def read_defaults(fname, defaults):
43
    "Read saved values from last configuration run"
45
    "Read saved values from last configuration run"
44
   
46
   
45
    inf = file(fname,'r')
47
    inf = file(fname, 'r')
46
   
48
   
47
    for line in inf:
49
    for line in inf:
48
        res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
50
        res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
49
        if (res):
51
        if (res):
50
            defaults[res.group(1)] = res.group(2)
52
            defaults[res.group(1)] = res.group(2)
51
   
53
   
52
    inf.close()
54
    inf.close()
53
 
55
 
54
def check_condition(text, defaults, ask_names):
56
def check_condition(text, defaults, ask_names):
55
    "Check for condition"
57
    "Check for condition"
56
   
58
   
57
    ctype = 'cnf'
59
    ctype = 'cnf'
58
   
60
   
59
    if ((')|' in text) or ('|(' in text)):
61
    if ((')|' in text) or ('|(' in text)):
60
        ctype = 'dnf'
62
        ctype = 'dnf'
61
   
63
   
62
    if (ctype == 'cnf'):
64
    if (ctype == 'cnf'):
63
        conds = text.split('&')
65
        conds = text.split('&')
64
    else:
66
    else:
65
        conds = text.split('|')
67
        conds = text.split('|')
66
   
68
   
67
    for cond in conds:
69
    for cond in conds:
68
        if (cond.startswith('(')) and (cond.endswith(')')):
70
        if (cond.startswith('(')) and (cond.endswith(')')):
69
            cond = cond[1:-1]
71
            cond = cond[1:-1]
70
       
72
       
71
        inside = check_inside(cond, defaults, ctype)
73
        inside = check_inside(cond, defaults, ctype)
72
       
74
       
73
        if (ctype == 'cnf') and (not inside):
75
        if (ctype == 'cnf') and (not inside):
74
            return False
76
            return False
75
       
77
       
76
        if (ctype == 'dnf') and (inside):
78
        if (ctype == 'dnf') and (inside):
77
            return True
79
            return True
78
   
80
   
79
    if (ctype == 'cnf'):
81
    if (ctype == 'cnf'):
80
        return True
82
        return True
81
    return False
83
    return False
82
 
84
 
83
def check_inside(text, defaults, ctype):
85
def check_inside(text, defaults, ctype):
84
    "Check that the condition specified on input line is True (only CNF is supported)"
86
    "Check that the condition specified on input line is True (only CNF is supported)"
85
   
87
   
86
    if (ctype == 'cnf'):
88
    if (ctype == 'cnf'):
87
        conds = text.split('|')
89
        conds = text.split('|')
88
    else:
90
    else:
89
        conds = text.split('&')
91
        conds = text.split('&')
90
   
92
   
91
    for cond in conds:
93
    for cond in conds:
92
        res = re.match(r'^(.*?)(!?=)(.*)$', cond)
94
        res = re.match(r'^(.*?)(!?=)(.*)$', cond)
93
        if (not res):
95
        if (not res):
94
            raise RuntimeError("Invalid condition: %s" % cond)
96
            raise RuntimeError("Invalid condition: %s" % cond)
95
       
97
       
96
        condname = res.group(1)
98
        condname = res.group(1)
97
        oper = res.group(2)
99
        oper = res.group(2)
98
        condval = res.group(3)
100
        condval = res.group(3)
99
       
101
       
100
        if (not defaults.has_key(condname)):
102
        if (not defaults.has_key(condname)):
101
            varval = ''
103
            varval = ''
102
        else:
104
        else:
103
            varval = defaults[condname]
105
            varval = defaults[condname]
104
       
106
       
105
        if (ctype == 'cnf'):
107
        if (ctype == 'cnf'):
106
            if (oper == '=') and (condval == varval):
108
            if (oper == '=') and (condval == varval):
107
                return True
109
                return True
108
       
110
       
109
            if (oper == '!=') and (condval != varval):
111
            if (oper == '!=') and (condval != varval):
110
                return True
112
                return True
111
        else:
113
        else:
112
            if (oper == '=') and (condval != varval):
114
            if (oper == '=') and (condval != varval):
113
                return False
115
                return False
114
           
116
           
115
            if (oper == '!=') and (condval == varval):
117
            if (oper == '!=') and (condval == varval):
116
                return False
118
                return False
117
   
119
   
118
    if (ctype == 'cnf'):
120
    if (ctype == 'cnf'):
119
        return False
121
        return False
120
   
122
   
121
    return True
123
    return True
122
 
124
 
123
def parse_config(fname, ask_names):
125
def parse_config(fname, ask_names):
124
    "Parse configuration file"
126
    "Parse configuration file"
125
   
127
   
126
    inf = file(fname, 'r')
128
    inf = file(fname, 'r')
127
   
129
   
128
    name = ''
130
    name = ''
129
    choices = []
131
    choices = []
130
   
132
   
131
    for line in inf:
133
    for line in inf:
132
       
134
       
133
        if (line.startswith('!')):
135
        if (line.startswith('!')):
134
            # Ask a question
136
            # Ask a question
135
            res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line)
137
            res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line)
136
           
138
           
137
            if (not res):
139
            if (not res):
138
                raise RuntimeError("Weird line: %s" % line)
140
                raise RuntimeError("Weird line: %s" % line)
139
           
141
           
140
            cond = res.group(1)
142
            cond = res.group(1)
141
            varname = res.group(2)
143
            varname = res.group(2)
142
            vartype = res.group(3)
144
            vartype = res.group(3)
143
           
145
           
144
            ask_names.append((varname, vartype, name, choices, cond))
146
            ask_names.append((varname, vartype, name, choices, cond))
145
            name = ''
147
            name = ''
146
            choices = []
148
            choices = []
147
            continue
149
            continue
148
       
150
       
149
        if (line.startswith('@')):
151
        if (line.startswith('@')):
150
            # Add new line into the 'choices' array
152
            # Add new line into the 'choices' array
151
            res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line)
153
            res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line)
152
           
154
           
153
            if not res:
155
            if not res:
154
                raise RuntimeError("Bad line: %s" % line)
156
                raise RuntimeError("Bad line: %s" % line)
155
           
157
           
156
            choices.append((res.group(2), res.group(3)))
158
            choices.append((res.group(2), res.group(3)))
157
            continue
159
            continue
158
       
160
       
159
        if (line.startswith('%')):
161
        if (line.startswith('%')):
160
            # Name of the option
162
            # Name of the option
161
            name = line[1:].strip()
163
            name = line[1:].strip()
162
            continue
164
            continue
163
       
165
       
164
        if ((line.startswith('#')) or (line == '\n')):
166
        if ((line.startswith('#')) or (line == '\n')):
165
            # Comment or empty line
167
            # Comment or empty line
166
            continue
168
            continue
167
       
169
       
168
       
170
       
169
        raise RuntimeError("Unknown syntax: %s" % line)
171
        raise RuntimeError("Unknown syntax: %s" % line)
170
   
172
   
171
    inf.close()
173
    inf.close()
172
 
174
 
173
def yes_no(default):
175
def yes_no(default):
174
    "Return '*' if yes, ' ' if no"
176
    "Return '*' if yes, ' ' if no"
175
   
177
   
176
    if (default == 'y'):
178
    if (default == 'y'):
177
        return '*'
179
        return '*'
178
   
180
   
179
    return ' '
181
    return ' '
180
 
182
 
181
def subchoice(screen, name, choices, default):
183
def subchoice(screen, name, choices, default):
182
    "Return choice of choices"
184
    "Return choice of choices"
183
   
185
   
184
    maxkey = 0
186
    maxkey = 0
185
    for key, val in choices:
187
    for key, val in choices:
186
        length = len(key)
188
        length = len(key)
187
        if (length > maxkey):
189
        if (length > maxkey):
188
            maxkey = length
190
            maxkey = length
189
   
191
   
190
    options = []
192
    options = []
191
    position = None
193
    position = None
192
    cnt = 0
194
    cnt = 0
193
    for key, val in choices:
195
    for key, val in choices:
194
        if ((default) and (key == default)):
196
        if ((default) and (key == default)):
195
            position = cnt
197
            position = cnt
196
       
198
       
197
        options.append(" %-*s  %s " % (maxkey, key, val))
199
        options.append(" %-*s  %s " % (maxkey, key, val))
198
        cnt += 1
200
        cnt += 1
199
   
201
   
200
    (button, value) = xtui.choice_window(screen, name, 'Choose value', options, position)
202
    (button, value) = xtui.choice_window(screen, name, 'Choose value', options, position)
201
   
203
   
202
    if (button == 'cancel'):
204
    if (button == 'cancel'):
203
        return None
205
        return None
204
   
206
   
205
    return choices[value][0]
207
    return choices[value][0]
206
 
208
 
207
def check_choices(defaults, ask_names):
209
def check_choices(defaults, ask_names):
208
    "Check whether all accessible variables have a default"
210
    "Check whether all accessible variables have a default"
209
   
211
   
210
    for varname, vartype, name, choices, cond in ask_names:
212
    for varname, vartype, name, choices, cond in ask_names:
211
        if ((cond) and (not check_condition(cond, defaults, ask_names))):
213
        if ((cond) and (not check_condition(cond, defaults, ask_names))):
212
            continue
214
            continue
213
       
215
       
214
        if (not defaults.has_key(varname)):
216
        if (not defaults.has_key(varname)):
215
            return False
217
            return False
216
   
218
   
217
    return True
219
    return True
218
 
220
 
219
def create_output(fname, defaults, ask_names):
221
def create_output(mkname, mcname, dfname, defaults, ask_names):
220
    "Create output configuration"
222
    "Create output configuration"
221
   
223
   
-
 
224
    revision = commands.getoutput('svnversion . 2> /dev/null')
222
    outf = file(fname, 'w')
225
    timestamp = commands.getoutput('date "+%Y-%m-%d %H:%M:%S"')
223
   
226
   
-
 
227
    outmk = file(mkname, 'w')
-
 
228
    outmc = file(mcname, 'w')
-
 
229
    outdf = file(dfname, 'w')
-
 
230
   
-
 
231
    outmk.write('#########################################\n')
-
 
232
    outmk.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
-
 
233
    outmk.write('#########################################\n\n')
-
 
234
   
-
 
235
    outmc.write('/***************************************\n')
-
 
236
    outmc.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
-
 
237
    outmc.write(' ***************************************/\n\n')
-
 
238
   
224
    outf.write('#########################################\n')
239
    outdf.write('#########################################\n')
225
    outf.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
240
    outdf.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
226
    outf.write('#########################################\n\n')
241
    outdf.write('#########################################\n\n')
-
 
242
    outdf.write('CONFIG_DEFS =')
227
   
243
   
228
    for varname, vartype, name, choices, cond in ask_names:
244
    for varname, vartype, name, choices, cond in ask_names:
229
        if ((cond) and (not check_condition(cond, defaults, ask_names))):
245
        if ((cond) and (not check_condition(cond, defaults, ask_names))):
230
            continue
246
            continue
231
       
247
       
232
        if (not defaults.has_key(varname)):
248
        if (not defaults.has_key(varname)):
233
            default = ''
249
            default = ''
234
        else:
250
        else:
235
            default = defaults[varname]
251
            default = defaults[varname]
236
       
252
       
237
        outf.write('# %s\n%s = %s\n\n' % (name, varname, default))
253
        outmk.write('# %s\n%s = %s\n\n' % (name, varname, default))
-
 
254
       
-
 
255
        if ((vartype == "y") or (vartype == "y/n") or (vartype == "n/y")):
-
 
256
            if (default == "y"):
-
 
257
                outmc.write('/* %s */\n#define %s\n\n' % (name, varname))
-
 
258
                outdf.write(' -D%s' % varname)
-
 
259
        else:
-
 
260
            outmc.write('/* %s */\n#define %s %s\n\n' % (name, varname, default))
-
 
261
            outdf.write(' -D%s=%s' % (varname, default))
-
 
262
   
-
 
263
    outmk.write('REVISION = %s\n' % revision)
-
 
264
    outmk.write('TIMESTAMP = %s\n' % timestamp)
238
   
265
   
239
    outf.write('REVISION = %s\n' % commands.getoutput('svnversion . 2> /dev/null'))
266
    outmc.write('#define REVISION %s\n' % revision)
-
 
267
    outmc.write('#define TIMESTAMP %s\n' % timestamp)
-
 
268
   
240
    outf.write('TIMESTAMP = %s\n' % commands.getoutput('date "+%Y-%m-%d %H:%M:%S"'))
269
    outdf.write(' "-DREVISION=%s" "-DTIMESTAMP=%s"\n' % (revision, timestamp))
-
 
270
   
-
 
271
    outmk.close()
-
 
272
    outmc.close()
241
    outf.close()
273
    outdf.close()
242
 
274
 
243
def main():
275
def main():
244
    defaults = {}
276
    defaults = {}
245
    ask_names = []
277
    ask_names = []
246
   
278
   
247
    # Parse configuration file
279
    # Parse configuration file
248
    parse_config(INPUT, ask_names)
280
    parse_config(INPUT, ask_names)
249
   
281
   
250
    # Read defaults from previous run
282
    # Read defaults from previous run
251
    if os.path.exists(OUTPUT):
283
    if os.path.exists(MAKEFILE):
252
        read_defaults(OUTPUT, defaults)
284
        read_defaults(MAKEFILE, defaults)
253
   
285
   
254
    # Default mode: only check defaults and regenerate configuration
286
    # Default mode: only check defaults and regenerate configuration
255
    if ((len(sys.argv) >= 3) and (sys.argv[2] == 'default')):
287
    if ((len(sys.argv) >= 3) and (sys.argv[2] == 'default')):
256
        if (check_choices(defaults, ask_names)):
288
        if (check_choices(defaults, ask_names)):
257
            create_output(OUTPUT, defaults, ask_names)
289
            create_output(MAKEFILE, MACROS, DEFS, defaults, ask_names)
258
            return 0
290
            return 0
259
   
291
   
260
    # Check mode: only check defaults
292
    # Check mode: only check defaults
261
    if ((len(sys.argv) >= 3) and (sys.argv[2] == 'check')):
293
    if ((len(sys.argv) >= 3) and (sys.argv[2] == 'check')):
262
        if (check_choices(defaults, ask_names)):
294
        if (check_choices(defaults, ask_names)):
263
            return 0
295
            return 0
264
        return 1
296
        return 1
265
   
297
   
266
    screen = xtui.screen_init()
298
    screen = xtui.screen_init()
267
    try:
299
    try:
268
        selname = None
300
        selname = None
269
        while True:
301
        while True:
270
           
302
           
271
            options = []
303
            options = []
272
            opt2row = {}
304
            opt2row = {}
273
            position = None
305
            position = None
274
            cnt = 0
306
            cnt = 0
275
            for varname, vartype, name, choices, cond in ask_names:
307
            for varname, vartype, name, choices, cond in ask_names:
276
               
308
               
277
                if ((cond) and (not check_condition(cond, defaults, ask_names))):
309
                if ((cond) and (not check_condition(cond, defaults, ask_names))):
278
                    continue
310
                    continue
279
               
311
               
280
                if (varname == selname):
312
                if (varname == selname):
281
                    position = cnt
313
                    position = cnt
282
               
314
               
283
                if (not defaults.has_key(varname)):
315
                if (not defaults.has_key(varname)):
284
                    default = None
316
                    default = None
285
                else:
317
                else:
286
                    default = defaults[varname]
318
                    default = defaults[varname]
287
               
319
               
288
                if (vartype == 'choice'):
320
                if (vartype == 'choice'):
289
                    # Check if the default is an acceptable value
321
                    # Check if the default is an acceptable value
290
                    if ((default) and (not default in [choice[0] for choice in choices])):
322
                    if ((default) and (not default in [choice[0] for choice in choices])):
291
                        default = None
323
                        default = None
292
                        defaults.pop(varname)
324
                        defaults.pop(varname)
293
                   
325
                   
294
                    # If there is just one option, use it
326
                    # If there is just one option, use it
295
                    if (len(choices) == 1):
327
                    if (len(choices) == 1):
296
                        default = choices[0][0]
328
                        defaults[varname] = choices[0][0]
297
                        defaults[varname] = default
329
                        continue
298
                   
330
                   
299
                    options.append("     %s [%s] --> " % (name, default))
331
                    options.append("     %s [%s] --> " % (name, default))
-
 
332
                elif (vartype == 'y'):
-
 
333
                    defaults[varname] = 'y'
-
 
334
                    continue
300
                elif (vartype == 'y/n'):
335
                elif (vartype == 'y/n'):
301
                    if (default == None):
336
                    if (default == None):
302
                        default = 'y'
337
                        default = 'y'
303
                        defaults[varname] = default
338
                        defaults[varname] = default
304
                    options.append(" <%s> %s " % (yes_no(default), name))
339
                    options.append(" <%s> %s " % (yes_no(default), name))
305
                elif (vartype == 'n/y'):
340
                elif (vartype == 'n/y'):
306
                    if (default == None):
341
                    if (default == None):
307
                        default = 'n'
342
                        default = 'n'
308
                        defaults[varname] = default
343
                        defaults[varname] = default
309
                    options.append(" <%s> %s " % (yes_no(default), name))
344
                    options.append(" <%s> %s " % (yes_no(default), name))
310
                else:
345
                else:
311
                    raise RuntimeError("Unknown variable type: %s" % vartype)
346
                    raise RuntimeError("Unknown variable type: %s" % vartype)
312
               
347
               
313
                opt2row[cnt] = (varname, vartype, name, choices)
348
                opt2row[cnt] = (varname, vartype, name, choices)
314
               
349
               
315
                cnt += 1
350
                cnt += 1
316
           
351
           
317
            (button, value) = xtui.choice_window(screen, 'HelenOS configuration', 'Choose configuration option', options, position)
352
            (button, value) = xtui.choice_window(screen, 'HelenOS configuration', 'Choose configuration option', options, position)
318
           
353
           
319
            if (button == 'cancel'):
354
            if (button == 'cancel'):
320
                return 'Configuration canceled'
355
                return 'Configuration canceled'
321
           
356
           
322
            if (not opt2row.has_key(value)):
357
            if (not opt2row.has_key(value)):
323
                raise RuntimeError("Error selecting value: %s" % value)
358
                raise RuntimeError("Error selecting value: %s" % value)
324
           
359
           
325
            (selname, seltype, name, choices) = opt2row[value]
360
            (selname, seltype, name, choices) = opt2row[value]
326
           
361
           
327
            if (not defaults.has_key(selname)):
362
            if (not defaults.has_key(selname)):
328
                    default = None
363
                    default = None
329
            else:
364
            else:
330
                default = defaults[selname]
365
                default = defaults[selname]
331
           
366
           
332
            if (button == 'done'):
367
            if (button == 'done'):
333
                if (check_choices(defaults, ask_names)):
368
                if (check_choices(defaults, ask_names)):
334
                    break
369
                    break
335
                else:
370
                else:
336
                    xtui.error_dialog(screen, 'Error', 'Some options have still undefined values.')
371
                    xtui.error_dialog(screen, 'Error', 'Some options have still undefined values.')
337
                    continue
372
                    continue
338
           
373
           
339
            if (seltype == 'choice'):
374
            if (seltype == 'choice'):
340
                defaults[selname] = subchoice(screen, name, choices, default)
375
                defaults[selname] = subchoice(screen, name, choices, default)
341
            elif ((seltype == 'y/n') or (seltype == 'n/y')):
376
            elif ((seltype == 'y/n') or (seltype == 'n/y')):
342
                if (defaults[selname] == 'y'):
377
                if (defaults[selname] == 'y'):
343
                    defaults[selname] = 'n'
378
                    defaults[selname] = 'n'
344
                else:
379
                else:
345
                    defaults[selname] = 'y'
380
                    defaults[selname] = 'y'
346
    finally:
381
    finally:
347
        xtui.screen_done(screen)
382
        xtui.screen_done(screen)
348
   
383
   
349
    create_output(OUTPUT, defaults, ask_names)
384
    create_output(MAKEFILE, MACROS, DEFS, defaults, ask_names)
350
    return 0
385
    return 0
351
 
386
 
352
if __name__ == '__main__':
387
if __name__ == '__main__':
353
    sys.exit(main())
388
    sys.exit(main())
354
 
389