URL
https://opencores.org/ocsvn/or1k_old/or1k_old/trunk
Subversion Repositories or1k_old
[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [scripts/] [header.tk] - Rev 1629
Go to most recent revision | Compare with Previous | Blame | View Log
## This is a handy replacement for ".widget cget" that requires neither tk4# nor additional source code uglification.#proc cget { w option } {return "[lindex [$w configure $option] 4]"}## Function to compensate for broken config.in scripts like the sound driver,# which make dependencies on variables that are never even conditionally# defined.#proc vfix { var } {global $varif [ catch {eval concat $$var} ] {puts stdout "WARNING - broken Config.in! $var was not declared!"set $var 0}}## Create a "reference" object to steal colors from.#button .ref## On monochrome displays, -disabledforeground is blank by default; that's# bad. Fill it with -foreground instead.#if { [cget .ref -disabledforeground] == "" } {.ref configure -disabledforeground [cget .ref -foreground]}## Define some macros we will need to parse the config.in file.#proc mainmenu_name { text } {message .header.message -width 400 -relief raised -text "$text"pack .header.label .header.message -side left -padx 15wm title . "$text"}proc menu_option { w menu_num text } {button .f0.x$menu_num -text "$text" -width 50 -command "$w .$w \"$text\""pack .f0.x$menu_num -pady 1 -expand on}## Not used at the moment, but this runs a command in a subprocess and# displays the result in a window with a scrollbar.## For now, we just do external "make" commands to stdout with do_make, so# this function is never called.#proc do_cmd { w command } {catch {destroy $w}toplevel $w -class Dialogframe $w.tbtext $w.tb.text -relief raised -bd 2 -yscrollcommand "$w.tb.scroll set"scrollbar $w.tb.scroll -command "$w.tb.text yview"pack $w.tb.scroll -side right -fill ypack $w.tb.text -side leftset oldFocus [focus]frame $w.backbutton $w.back.ok -text "OK" -width 20 \-command "destroy $w; focus $oldFocus" -state disabledbutton $w.back.ccl -text "Cancel" -width 20 \-command "destroy $w; focus $oldFocus"pack $w.tb -side toppack $w.back.ok $w.back.ccl -side leftpack $w.back -side bottom -pady 10focus $wwm geometry $w +30+35$w.tb.text delete 1.0 endset f [open |$command]while {![eof $f]} {$w.tb.text insert end [read $f 256]}close $f$w.back.ok configure -state normal}proc load_configfile { w title func } {catch {destroy $w}toplevel $w -class Dialogglobal loadfileframe $w.xlabel $w.bm -bitmap questheadpack $w.bm -pady 10 -side top -padx 10label $w.x.l -text "Enter filename:" -relief raisedentry $w.x.x -width 35 -relief sunken -borderwidth 2 \-textvariable loadfilepack $w.x.l $w.x.x -anchor w -side leftpack $w.x -side top -pady 10wm title $w "$title"set oldFocus [focus]frame $w.fbutton $w.f.back -text "OK" -width 20 \-command "destroy $w; focus $oldFocus;$func .fileio"button $w.f.canc -text "Cancel" \-width 20 -command "destroy $w; focus $oldFocus"pack $w.f.back $w.f.canc -side left -pady 10 -padx 45pack $w.f -pady 10 -side bottom -padx 10 -anchor wfocus $wglobal winx; global winyset winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]wm geometry $w +$winx+$winy}proc maybe_exit { w } {catch {destroy $w}toplevel $w -class Dialoglabel $w.bm -bitmap questheadpack $w.bm -pady 10 -side top -padx 10message $w.m -width 400 -aspect 300 \-text "Changes will be lost. Are you sure?" -relief flatpack $w.m -pady 10 -side top -padx 10wm title $w "Are you sure?"set oldFocus [focus]frame $w.fbutton $w.f.back -text "OK" -width 20 \-command "exit"button $w.f.canc -text "Cancel" \-width 20 -command "destroy $w; focus $oldFocus"pack $w.f.back $w.f.canc -side left -pady 10 -padx 45pack $w.f -pady 10 -side bottom -padx 10 -anchor wfocus $wglobal winx; global winyset winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]wm geometry $w +$winx+$winy}proc read_config_file { w } {global loadfileif { [string length $loadfile] != 0 && [file readable $loadfile] == 1 } then {read_config $loadfile} else {catch {destroy $w}toplevel $w -class Dialogmessage $w.m -width 400 -aspect 300 -text \"Unable to read file $loadfile" \-relief raisedlabel $w.bm -bitmap errorpack $w.bm $w.m -pady 10 -side top -padx 10wm title $w "Oops"set oldFocus [focus]frame $w.fbutton $w.f.back -text "Bummer" \-width 10 -command "destroy $w; focus $oldFocus"pack $w.f.back -side bottom -pady 10 -anchor spack $w.f -pady 10 -side top -padx 10 -anchor sfocus $wglobal winx; global winyset winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]wm geometry $w +$winx+$winy}}proc write_config_file { w } {global loadfileif { [string length $loadfile] != 0&& ([file writable $loadfile] == 1 || ([file exists $loadfile] == 0 && [file writable [file dirname $loadfile]] == 1)) } then {writeconfig $loadfile /dev/null} else {catch {destroy $w}toplevel $w -class Dialogmessage $w.m -width 400 -aspect 300 -text \"Unable to write file $loadfile" \-relief raisedlabel $w.bm -bitmap errorpack $w.bm $w.m -pady 10 -side top -padx 10wm title $w "Oops"set oldFocus [focus]frame $w.fbutton $w.f.back -text "OK" \-width 10 -command "destroy $w; focus $oldFocus"pack $w.f.back -side bottom -pady 10 -anchor spack $w.f -pady 10 -side top -padx 10 -anchor sfocus $wglobal winx; global winyset winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]wm geometry $w +$winx+$winy}}proc read_config { filename } {set file1 [open $filename r]clear_choiceswhile { [gets $file1 line] >= 0} {if [regexp {([0-9A-Za-z_]+)=([ynm])} $line foo var value] {if { $value == "y" } then { set cmd "global $var; set $var 1" }if { $value == "n" } then { set cmd "global $var; set $var 0" }if { $value == "m" } then { set cmd "global $var; set $var 2" }eval $cmd}if [regexp {# ([0-9A-Za-z_]+) is not set} $line foo var] {set cmd "global $var; set $var 0"eval $cmd}if [regexp {([0-9A-Za-z_]+)=([0-9A-Fa-f]+)} $line foo var value] {set cmd "global $var; set $var $value"eval $cmd}}close $file1update_choicesupdate_mainmenu .rdupd}proc write_comment { file1 file2 text } {puts $file1 ""puts $file1 "#"puts $file1 "# $text"puts $file1 "#"puts $file2 "/*"puts $file2 " * $text"puts $file2 " */"}proc write_tristate { file1 file2 varname variable dep } {if { $variable == 0 } \then { puts $file1 "# $varname is not set"; \puts $file2 "#undef $varname"} \elseif { $variable == 2 || ($dep == 2 && $variable == 1) } \then { puts $file1 "$varname=m"; \puts $file2 "#undef $varname"; \puts $file2 "#define ${varname}_MODULE 1" } \elseif { $variable == 1 && $dep != 2 } \then { puts $file1 "$varname=y"; \puts $file2 "#define $varname 1" } \else { \error "Attempting to write value for variable that is not configured ($varname)." \}}proc write_int { file1 file2 varname variable dep } {if { $dep == 0 } \then { puts $file1 "# $varname is not set"; \puts $file2 "#undef $varname"} \else {puts $file1 "$varname=$variable"; \puts $file2 "#define $varname $variable"; \}}proc write_hex { file1 file2 varname variable dep } {if { $dep == 0 } \then { puts $file1 "# $varname is not set"; \puts $file2 "#undef $varname"} \else {puts $file1 "$varname=$variable"; \puts $file2 "#define $varname 0x$variable"; \}}proc option_name {w mnum line text helpidx} {button $w.x$line.l -text "$text" -relief groove -anchor w$w.x$line.l configure -activefore [cget $w.x$line.l -fg] \-activeback [cget $w.x$line.l -bg]button $w.x$line.help -text "Help" -relief raised \-command "dohelp .dohelp $helpidx"pack $w.x$line.help -side right -fill ypack $w.x$line.l -side right -fill both -expand on}proc toggle_switch {w mnum line text variable} {frame $w.x$line -relief sunkenradiobutton $w.x$line.y -text "y" -variable $variable -value 1 \-relief groove -width 2 -command "update_menu$mnum .menu$mnum"radiobutton $w.x$line.m -text "m" -variable $variable -value 2 \-relief groove -width 2 -command "update_menu$mnum .menu$mnum"radiobutton $w.x$line.n -text "n" -variable $variable -value 0 \-relief groove -width 2 -command "update_menu$mnum .menu$mnum"option_name $w $mnum $line $text $variablepack $w.x$line.n $w.x$line.m $w.x$line.y -side right -fill y}proc bool {w mnum line text variable} {toggle_switch $w $mnum $line $text $variable$w.x$line.m configure -state disabledpack $w.x$line -anchor w -fill both -expand on}proc tristate {w mnum line text variable } {toggle_switch $w $mnum $line $text $variablepack $w.x$line -anchor w -fill both -expand on}proc dep_tristate {w mnum line text variable depend } {tristate $w $mnum $line $text $variable}proc int { w mnum line text variable } {frame $w.x$lineentry $w.x$line.x -width 18 -relief sunken -borderwidth 2 \-textvariable $variableoption_name $w $mnum $line $text $variablepack $w.x$line.x -anchor w -side right -fill ypack $w.x$line -anchor w -fill both -expand on}proc hex { w mnum line text variable } {int $w $mnum $line $text $variable}proc minimenu { w mnum line text variable helpidx } {frame $w.x$linemenubutton $w.x$line.x -textvariable $variable -menu \$w.x$line.x.menu -relief raised \-width 15 -anchor woption_name $w $mnum $line $text $helpidxpack $w.x$line.x -anchor w -side right -fill ypack $w.x$line -anchor w -fill both -expand on}proc comment {w line text } {#nothing done for comments now.}proc do_make { command } {exec sh -c $command <@stdin >@stdout 2>@stderr# do_cmd .make_window "sh -c $command"}proc dohelp {w var } {catch {destroy $w}toplevel $w -class Dialogset filefound 0set found 0set lineno 0if { [file readable Documentation/Configure.help] == 1} then {set filefound 1set message [exec sed -n "/^$var\[ \]*\$/,\${/^$var\[ \]*\$/c\\${var}:\\/^#.*/d/^\[ \]*\$/bLH}d:L xs/\\n //s/\\n / /gpq" Documentation/Configure.help]set found [expr [string length "$message"] > 0]}frame $w.f1if { $found == 0 } then {if { $filefound == 0 } then {message $w.f1.m -width 750 -aspect 300 -relief flat -text \"No help available - unable to open file Documentation/Configure.help. This file should have come with your kernel."} else {message $w.f1.m -width 400 -aspect 300 -relief flat -text \"No help available for $var"}label $w.f1.bm -bitmap errorwm title $w "RTFM"} else {message $w.f1.m -width 400 -aspect 300 -text $message \-relief flatlabel $w.f1.bm -bitmap infowm title $w "Configuration help"}pack $w.f1.bm $w.f1.m -side left -padx 10pack $w.f1 -side topset oldFocus [focus]# Do the OK button#frame $w.f2button $w.f2.ok -text "OK" \-width 10 -command "destroy $w; focus $oldFocus"pack $w.f2.ok -side bottom -pady 10 -anchor spack $w.f2 -side bottom -padx 10 -anchor s# Finish off the window#focus $wglobal winx; global winyset winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]wm geometry $w +$winx+$winy}proc wrapup {w } {catch {destroy $w}toplevel $w -class Dialogmessage $w.m -width 400 -aspect 300 -text \"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 raisedlabel $w.bm -bitmap infopack $w.bm $w.m -pady 10 -side top -padx 10wm title $w "Kernel build instructions"set oldFocus [focus]frame $w.fbutton $w.f.back -text "OK" \-width 10 -command "exit"pack $w.f.back -side bottom -pady 10 -anchor spack $w.f -pady 10 -side top -padx 10 -anchor sfocus $wglobal winx; global winyset winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]wm geometry $w +$winx+$winy}proc check_sound_config { num } {#nothing for now.}proc do_sound {w mnum line} {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 raisedpack $w.x$line -side top -pady 10}## Next set up the particulars for the top level menu, and define a few# buttons which we will stick down at the bottom.#frame .headerlabel .header.labelframe .f0
Go to most recent revision | Compare with Previous | Blame | View Log
