1 |
1629 |
jcastillo |
#
|
2 |
|
|
# This is a handy replacement for ".widget cget" that requires neither tk4
|
3 |
|
|
# nor additional source code uglification.
|
4 |
|
|
#
|
5 |
|
|
proc cget { w option } {
|
6 |
|
|
return "[lindex [$w configure $option] 4]"
|
7 |
|
|
}
|
8 |
|
|
|
9 |
|
|
#
|
10 |
|
|
# Function to compensate for broken config.in scripts like the sound driver,
|
11 |
|
|
# which make dependencies on variables that are never even conditionally
|
12 |
|
|
# defined.
|
13 |
|
|
#
|
14 |
|
|
proc vfix { var } {
|
15 |
|
|
global $var
|
16 |
|
|
if [ catch {eval concat $$var} ] {
|
17 |
|
|
puts stdout "WARNING - broken Config.in! $var was not declared!"
|
18 |
|
|
set $var 0
|
19 |
|
|
}
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
#
|
23 |
|
|
# Create a "reference" object to steal colors from.
|
24 |
|
|
#
|
25 |
|
|
button .ref
|
26 |
|
|
#
|
27 |
|
|
# On monochrome displays, -disabledforeground is blank by default; that's
|
28 |
|
|
# bad. Fill it with -foreground instead.
|
29 |
|
|
#
|
30 |
|
|
if { [cget .ref -disabledforeground] == "" } {
|
31 |
|
|
.ref configure -disabledforeground [cget .ref -foreground]
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
#
|
36 |
|
|
# Define some macros we will need to parse the config.in file.
|
37 |
|
|
#
|
38 |
|
|
proc mainmenu_name { text } {
|
39 |
|
|
message .header.message -width 400 -relief raised -text "$text"
|
40 |
|
|
pack .header.label .header.message -side left -padx 15
|
41 |
|
|
wm title . "$text"
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
proc menu_option { w menu_num text } {
|
45 |
|
|
button .f0.x$menu_num -text "$text" -width 50 -command "$w .$w \"$text\""
|
46 |
|
|
pack .f0.x$menu_num -pady 1 -expand on
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
#
|
50 |
|
|
# Not used at the moment, but this runs a command in a subprocess and
|
51 |
|
|
# displays the result in a window with a scrollbar.
|
52 |
|
|
#
|
53 |
|
|
# For now, we just do external "make" commands to stdout with do_make, so
|
54 |
|
|
# this function is never called.
|
55 |
|
|
#
|
56 |
|
|
proc do_cmd { w command } {
|
57 |
|
|
catch {destroy $w}
|
58 |
|
|
toplevel $w -class Dialog
|
59 |
|
|
frame $w.tb
|
60 |
|
|
text $w.tb.text -relief raised -bd 2 -yscrollcommand "$w.tb.scroll set"
|
61 |
|
|
scrollbar $w.tb.scroll -command "$w.tb.text yview"
|
62 |
|
|
pack $w.tb.scroll -side right -fill y
|
63 |
|
|
pack $w.tb.text -side left
|
64 |
|
|
|
65 |
|
|
set oldFocus [focus]
|
66 |
|
|
frame $w.back
|
67 |
|
|
button $w.back.ok -text "OK" -width 20 \
|
68 |
|
|
-command "destroy $w; focus $oldFocus" -state disabled
|
69 |
|
|
button $w.back.ccl -text "Cancel" -width 20 \
|
70 |
|
|
-command "destroy $w; focus $oldFocus"
|
71 |
|
|
pack $w.tb -side top
|
72 |
|
|
pack $w.back.ok $w.back.ccl -side left
|
73 |
|
|
pack $w.back -side bottom -pady 10
|
74 |
|
|
|
75 |
|
|
focus $w
|
76 |
|
|
wm geometry $w +30+35
|
77 |
|
|
|
78 |
|
|
$w.tb.text delete 1.0 end
|
79 |
|
|
set f [open |$command]
|
80 |
|
|
while {![eof $f]} {
|
81 |
|
|
$w.tb.text insert end [read $f 256]
|
82 |
|
|
}
|
83 |
|
|
close $f
|
84 |
|
|
$w.back.ok configure -state normal
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
proc load_configfile { w title func } {
|
88 |
|
|
catch {destroy $w}
|
89 |
|
|
toplevel $w -class Dialog
|
90 |
|
|
global loadfile
|
91 |
|
|
frame $w.x
|
92 |
|
|
label $w.bm -bitmap questhead
|
93 |
|
|
pack $w.bm -pady 10 -side top -padx 10
|
94 |
|
|
label $w.x.l -text "Enter filename:" -relief raised
|
95 |
|
|
entry $w.x.x -width 35 -relief sunken -borderwidth 2 \
|
96 |
|
|
-textvariable loadfile
|
97 |
|
|
pack $w.x.l $w.x.x -anchor w -side left
|
98 |
|
|
pack $w.x -side top -pady 10
|
99 |
|
|
wm title $w "$title"
|
100 |
|
|
|
101 |
|
|
set oldFocus [focus]
|
102 |
|
|
frame $w.f
|
103 |
|
|
button $w.f.back -text "OK" -width 20 \
|
104 |
|
|
-command "destroy $w; focus $oldFocus;$func .fileio"
|
105 |
|
|
button $w.f.canc -text "Cancel" \
|
106 |
|
|
-width 20 -command "destroy $w; focus $oldFocus"
|
107 |
|
|
pack $w.f.back $w.f.canc -side left -pady 10 -padx 45
|
108 |
|
|
pack $w.f -pady 10 -side bottom -padx 10 -anchor w
|
109 |
|
|
focus $w
|
110 |
|
|
global winx; global winy
|
111 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
112 |
|
|
wm geometry $w +$winx+$winy
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
proc maybe_exit { w } {
|
116 |
|
|
catch {destroy $w}
|
117 |
|
|
toplevel $w -class Dialog
|
118 |
|
|
label $w.bm -bitmap questhead
|
119 |
|
|
pack $w.bm -pady 10 -side top -padx 10
|
120 |
|
|
message $w.m -width 400 -aspect 300 \
|
121 |
|
|
-text "Changes will be lost. Are you sure?" -relief flat
|
122 |
|
|
pack $w.m -pady 10 -side top -padx 10
|
123 |
|
|
wm title $w "Are you sure?"
|
124 |
|
|
|
125 |
|
|
set oldFocus [focus]
|
126 |
|
|
frame $w.f
|
127 |
|
|
button $w.f.back -text "OK" -width 20 \
|
128 |
|
|
-command "exit"
|
129 |
|
|
button $w.f.canc -text "Cancel" \
|
130 |
|
|
-width 20 -command "destroy $w; focus $oldFocus"
|
131 |
|
|
pack $w.f.back $w.f.canc -side left -pady 10 -padx 45
|
132 |
|
|
pack $w.f -pady 10 -side bottom -padx 10 -anchor w
|
133 |
|
|
focus $w
|
134 |
|
|
global winx; global winy
|
135 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
136 |
|
|
wm geometry $w +$winx+$winy
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
proc read_config_file { w } {
|
140 |
|
|
global loadfile
|
141 |
|
|
if { [string length $loadfile] != 0 && [file readable $loadfile] == 1 } then {
|
142 |
|
|
read_config $loadfile
|
143 |
|
|
} else {
|
144 |
|
|
catch {destroy $w}
|
145 |
|
|
toplevel $w -class Dialog
|
146 |
|
|
message $w.m -width 400 -aspect 300 -text \
|
147 |
|
|
"Unable to read file $loadfile" \
|
148 |
|
|
-relief raised
|
149 |
|
|
label $w.bm -bitmap error
|
150 |
|
|
pack $w.bm $w.m -pady 10 -side top -padx 10
|
151 |
|
|
wm title $w "Oops"
|
152 |
|
|
|
153 |
|
|
set oldFocus [focus]
|
154 |
|
|
frame $w.f
|
155 |
|
|
button $w.f.back -text "Bummer" \
|
156 |
|
|
-width 10 -command "destroy $w; focus $oldFocus"
|
157 |
|
|
pack $w.f.back -side bottom -pady 10 -anchor s
|
158 |
|
|
pack $w.f -pady 10 -side top -padx 10 -anchor s
|
159 |
|
|
focus $w
|
160 |
|
|
global winx; global winy
|
161 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
162 |
|
|
wm geometry $w +$winx+$winy
|
163 |
|
|
}
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
proc write_config_file { w } {
|
167 |
|
|
global loadfile
|
168 |
|
|
if { [string length $loadfile] != 0
|
169 |
|
|
&& ([file writable $loadfile] == 1 || ([file exists $loadfile] == 0 && [file writable [file dirname $loadfile]] == 1)) } then {
|
170 |
|
|
writeconfig $loadfile /dev/null
|
171 |
|
|
} else {
|
172 |
|
|
catch {destroy $w}
|
173 |
|
|
toplevel $w -class Dialog
|
174 |
|
|
message $w.m -width 400 -aspect 300 -text \
|
175 |
|
|
"Unable to write file $loadfile" \
|
176 |
|
|
-relief raised
|
177 |
|
|
label $w.bm -bitmap error
|
178 |
|
|
pack $w.bm $w.m -pady 10 -side top -padx 10
|
179 |
|
|
wm title $w "Oops"
|
180 |
|
|
|
181 |
|
|
set oldFocus [focus]
|
182 |
|
|
frame $w.f
|
183 |
|
|
button $w.f.back -text "OK" \
|
184 |
|
|
-width 10 -command "destroy $w; focus $oldFocus"
|
185 |
|
|
pack $w.f.back -side bottom -pady 10 -anchor s
|
186 |
|
|
pack $w.f -pady 10 -side top -padx 10 -anchor s
|
187 |
|
|
focus $w
|
188 |
|
|
global winx; global winy
|
189 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
190 |
|
|
wm geometry $w +$winx+$winy
|
191 |
|
|
}
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
proc read_config { filename } {
|
195 |
|
|
set file1 [open $filename r]
|
196 |
|
|
clear_choices
|
197 |
|
|
while { [gets $file1 line] >= 0} {
|
198 |
|
|
if [regexp {([0-9A-Za-z_]+)=([ynm])} $line foo var value] {
|
199 |
|
|
if { $value == "y" } then { set cmd "global $var; set $var 1" }
|
200 |
|
|
if { $value == "n" } then { set cmd "global $var; set $var 0" }
|
201 |
|
|
if { $value == "m" } then { set cmd "global $var; set $var 2" }
|
202 |
|
|
eval $cmd
|
203 |
|
|
}
|
204 |
|
|
if [regexp {# ([0-9A-Za-z_]+) is not set} $line foo var] {
|
205 |
|
|
set cmd "global $var; set $var 0"
|
206 |
|
|
eval $cmd
|
207 |
|
|
}
|
208 |
|
|
if [regexp {([0-9A-Za-z_]+)=([0-9A-Fa-f]+)} $line foo var value] {
|
209 |
|
|
set cmd "global $var; set $var $value"
|
210 |
|
|
eval $cmd
|
211 |
|
|
}
|
212 |
|
|
}
|
213 |
|
|
close $file1
|
214 |
|
|
update_choices
|
215 |
|
|
update_mainmenu .rdupd
|
216 |
|
|
}
|
217 |
|
|
proc write_comment { file1 file2 text } {
|
218 |
|
|
puts $file1 ""
|
219 |
|
|
puts $file1 "#"
|
220 |
|
|
puts $file1 "# $text"
|
221 |
|
|
puts $file1 "#"
|
222 |
|
|
puts $file2 "/*"
|
223 |
|
|
puts $file2 " * $text"
|
224 |
|
|
puts $file2 " */"
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
proc write_tristate { file1 file2 varname variable dep } {
|
228 |
|
|
if { $variable == 0 } \
|
229 |
|
|
then { puts $file1 "# $varname is not set"; \
|
230 |
|
|
puts $file2 "#undef $varname"} \
|
231 |
|
|
elseif { $variable == 2 || ($dep == 2 && $variable == 1) } \
|
232 |
|
|
then { puts $file1 "$varname=m"; \
|
233 |
|
|
puts $file2 "#undef $varname"; \
|
234 |
|
|
puts $file2 "#define ${varname}_MODULE 1" } \
|
235 |
|
|
elseif { $variable == 1 && $dep != 2 } \
|
236 |
|
|
then { puts $file1 "$varname=y"; \
|
237 |
|
|
puts $file2 "#define $varname 1" } \
|
238 |
|
|
else { \
|
239 |
|
|
error "Attempting to write value for variable that is not configured ($varname)." \
|
240 |
|
|
}
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
proc write_int { file1 file2 varname variable dep } {
|
244 |
|
|
if { $dep == 0 } \
|
245 |
|
|
then { puts $file1 "# $varname is not set"; \
|
246 |
|
|
puts $file2 "#undef $varname"} \
|
247 |
|
|
else {
|
248 |
|
|
puts $file1 "$varname=$variable"; \
|
249 |
|
|
puts $file2 "#define $varname $variable"; \
|
250 |
|
|
}
|
251 |
|
|
}
|
252 |
|
|
|
253 |
|
|
proc write_hex { file1 file2 varname variable dep } {
|
254 |
|
|
if { $dep == 0 } \
|
255 |
|
|
then { puts $file1 "# $varname is not set"; \
|
256 |
|
|
puts $file2 "#undef $varname"} \
|
257 |
|
|
else {
|
258 |
|
|
puts $file1 "$varname=$variable"; \
|
259 |
|
|
puts $file2 "#define $varname 0x$variable"; \
|
260 |
|
|
}
|
261 |
|
|
}
|
262 |
|
|
|
263 |
|
|
proc option_name {w mnum line text helpidx} {
|
264 |
|
|
button $w.x$line.l -text "$text" -relief groove -anchor w
|
265 |
|
|
$w.x$line.l configure -activefore [cget $w.x$line.l -fg] \
|
266 |
|
|
-activeback [cget $w.x$line.l -bg]
|
267 |
|
|
button $w.x$line.help -text "Help" -relief raised \
|
268 |
|
|
-command "dohelp .dohelp $helpidx"
|
269 |
|
|
pack $w.x$line.help -side right -fill y
|
270 |
|
|
pack $w.x$line.l -side right -fill both -expand on
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
proc toggle_switch {w mnum line text variable} {
|
274 |
|
|
frame $w.x$line -relief sunken
|
275 |
|
|
radiobutton $w.x$line.y -text "y" -variable $variable -value 1 \
|
276 |
|
|
-relief groove -width 2 -command "update_menu$mnum .menu$mnum"
|
277 |
|
|
radiobutton $w.x$line.m -text "m" -variable $variable -value 2 \
|
278 |
|
|
-relief groove -width 2 -command "update_menu$mnum .menu$mnum"
|
279 |
|
|
radiobutton $w.x$line.n -text "n" -variable $variable -value 0 \
|
280 |
|
|
-relief groove -width 2 -command "update_menu$mnum .menu$mnum"
|
281 |
|
|
|
282 |
|
|
option_name $w $mnum $line $text $variable
|
283 |
|
|
|
284 |
|
|
pack $w.x$line.n $w.x$line.m $w.x$line.y -side right -fill y
|
285 |
|
|
}
|
286 |
|
|
|
287 |
|
|
proc bool {w mnum line text variable} {
|
288 |
|
|
toggle_switch $w $mnum $line $text $variable
|
289 |
|
|
$w.x$line.m configure -state disabled
|
290 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
291 |
|
|
}
|
292 |
|
|
|
293 |
|
|
proc tristate {w mnum line text variable } {
|
294 |
|
|
toggle_switch $w $mnum $line $text $variable
|
295 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
296 |
|
|
}
|
297 |
|
|
|
298 |
|
|
proc dep_tristate {w mnum line text variable depend } {
|
299 |
|
|
tristate $w $mnum $line $text $variable
|
300 |
|
|
}
|
301 |
|
|
|
302 |
|
|
proc int { w mnum line text variable } {
|
303 |
|
|
frame $w.x$line
|
304 |
|
|
entry $w.x$line.x -width 18 -relief sunken -borderwidth 2 \
|
305 |
|
|
-textvariable $variable
|
306 |
|
|
option_name $w $mnum $line $text $variable
|
307 |
|
|
pack $w.x$line.x -anchor w -side right -fill y
|
308 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
309 |
|
|
}
|
310 |
|
|
|
311 |
|
|
proc hex { w mnum line text variable } {
|
312 |
|
|
int $w $mnum $line $text $variable
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
proc minimenu { w mnum line text variable helpidx } {
|
316 |
|
|
frame $w.x$line
|
317 |
|
|
menubutton $w.x$line.x -textvariable $variable -menu \
|
318 |
|
|
$w.x$line.x.menu -relief raised \
|
319 |
|
|
-width 15 -anchor w
|
320 |
|
|
option_name $w $mnum $line $text $helpidx
|
321 |
|
|
pack $w.x$line.x -anchor w -side right -fill y
|
322 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
323 |
|
|
}
|
324 |
|
|
|
325 |
|
|
proc comment {w line text } {
|
326 |
|
|
#nothing done for comments now.
|
327 |
|
|
}
|
328 |
|
|
|
329 |
|
|
proc do_make { command } {
|
330 |
|
|
exec sh -c $command <@stdin >@stdout 2>@stderr
|
331 |
|
|
# do_cmd .make_window "sh -c $command"
|
332 |
|
|
}
|
333 |
|
|
|
334 |
|
|
proc dohelp {w var } {
|
335 |
|
|
catch {destroy $w}
|
336 |
|
|
toplevel $w -class Dialog
|
337 |
|
|
|
338 |
|
|
set filefound 0
|
339 |
|
|
set found 0
|
340 |
|
|
set lineno 0
|
341 |
|
|
|
342 |
|
|
if { [file readable Documentation/Configure.help] == 1} then {
|
343 |
|
|
set filefound 1
|
344 |
|
|
set message [exec sed -n "
|
345 |
|
|
/^$var\[ \]*\$/,\${
|
346 |
|
|
/^$var\[ \]*\$/c\\
|
347 |
|
|
${var}:\\
|
348 |
|
|
|
349 |
|
|
/^#.*/d
|
350 |
|
|
/^\[ \]*\$/bL
|
351 |
|
|
H
|
352 |
|
|
}
|
353 |
|
|
d
|
354 |
|
|
:L x
|
355 |
|
|
s/\\n //
|
356 |
|
|
s/\\n / /g
|
357 |
|
|
p
|
358 |
|
|
q
|
359 |
|
|
" Documentation/Configure.help]
|
360 |
|
|
set found [expr [string length "$message"] > 0]
|
361 |
|
|
}
|
362 |
|
|
|
363 |
|
|
frame $w.f1
|
364 |
|
|
|
365 |
|
|
if { $found == 0 } then {
|
366 |
|
|
if { $filefound == 0 } then {
|
367 |
|
|
message $w.f1.m -width 750 -aspect 300 -relief flat -text \
|
368 |
|
|
"No help available - unable to open file Documentation/Configure.help. This file should have come with your kernel."
|
369 |
|
|
} else {
|
370 |
|
|
message $w.f1.m -width 400 -aspect 300 -relief flat -text \
|
371 |
|
|
"No help available for $var"
|
372 |
|
|
}
|
373 |
|
|
label $w.f1.bm -bitmap error
|
374 |
|
|
wm title $w "RTFM"
|
375 |
|
|
} else {
|
376 |
|
|
message $w.f1.m -width 400 -aspect 300 -text $message \
|
377 |
|
|
-relief flat
|
378 |
|
|
label $w.f1.bm -bitmap info
|
379 |
|
|
wm title $w "Configuration help"
|
380 |
|
|
}
|
381 |
|
|
pack $w.f1.bm $w.f1.m -side left -padx 10
|
382 |
|
|
pack $w.f1 -side top
|
383 |
|
|
set oldFocus [focus]
|
384 |
|
|
|
385 |
|
|
# Do the OK button
|
386 |
|
|
#
|
387 |
|
|
frame $w.f2
|
388 |
|
|
button $w.f2.ok -text "OK" \
|
389 |
|
|
-width 10 -command "destroy $w; focus $oldFocus"
|
390 |
|
|
pack $w.f2.ok -side bottom -pady 10 -anchor s
|
391 |
|
|
pack $w.f2 -side bottom -padx 10 -anchor s
|
392 |
|
|
|
393 |
|
|
# Finish off the window
|
394 |
|
|
#
|
395 |
|
|
focus $w
|
396 |
|
|
global winx; global winy
|
397 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
398 |
|
|
wm geometry $w +$winx+$winy
|
399 |
|
|
}
|
400 |
|
|
|
401 |
|
|
proc wrapup {w } {
|
402 |
|
|
catch {destroy $w}
|
403 |
|
|
toplevel $w -class Dialog
|
404 |
|
|
message $w.m -width 400 -aspect 300 -text \
|
405 |
|
|
"The linux kernel is now hopefully configured for your setup. Check the top-level Makefile for additional configuration, and do a 'make dep ; make clean' if you want to be sure all the files are correctly re-made." -relief raised
|
406 |
|
|
label $w.bm -bitmap info
|
407 |
|
|
pack $w.bm $w.m -pady 10 -side top -padx 10
|
408 |
|
|
wm title $w "Kernel build instructions"
|
409 |
|
|
|
410 |
|
|
set oldFocus [focus]
|
411 |
|
|
frame $w.f
|
412 |
|
|
button $w.f.back -text "OK" \
|
413 |
|
|
-width 10 -command "exit"
|
414 |
|
|
pack $w.f.back -side bottom -pady 10 -anchor s
|
415 |
|
|
pack $w.f -pady 10 -side top -padx 10 -anchor s
|
416 |
|
|
focus $w
|
417 |
|
|
global winx; global winy
|
418 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
419 |
|
|
wm geometry $w +$winx+$winy
|
420 |
|
|
|
421 |
|
|
}
|
422 |
|
|
|
423 |
|
|
proc check_sound_config { num } {
|
424 |
|
|
#nothing for now.
|
425 |
|
|
}
|
426 |
|
|
|
427 |
|
|
proc do_sound {w mnum line} {
|
428 |
|
|
message $w.x$line -width 400 -aspect 300 -text "Note: The sound drivers cannot as of yet be configured via the X-based interface" -relief raised
|
429 |
|
|
pack $w.x$line -side top -pady 10
|
430 |
|
|
}
|
431 |
|
|
|
432 |
|
|
#
|
433 |
|
|
# Next set up the particulars for the top level menu, and define a few
|
434 |
|
|
# buttons which we will stick down at the bottom.
|
435 |
|
|
#
|
436 |
|
|
frame .header
|
437 |
|
|
label .header.label
|
438 |
|
|
|
439 |
|
|
frame .f0
|
440 |
|
|
|