   
   
   
#Start here
wm title . "Configure Tutorial" 
tk_bisque   

#***************************************************************
proc config_wish {path} {
    set pdir [exec pwd]
  catch {  set out [open /dev/tty w] }
catch {exec find $pdir -name "*.tk" -print > tkfiles} 
if { [file readable tkfiles] } {
    set fid [open tkfiles r]
    while { [eof $fid] != 1 } {
        gets $fid fn
        if { $fn == "" } {
            continue
            }
       catch { puts $out "Changing $fn" }
        set file [open $fn "r"]
    	gets $file 
    	gets $file 
    	gets $file
    	set content [read $file]
    	close $file
    	set file [open $fn "w"]
    	puts $file "#!$path"
    	puts $file "set pothome $pdir"
    	puts $file "source $pdir/tkheader.h"
    	puts $file $content
    	close $file
        }
     close $fid
     set tkrm "rm -f tkfiles"
     catch { eval exec $tkrm }
    } else {
        puts "File tkfiles not readable"
    }

#update Configure.tk because the wish path gets added here too, we
# remove it after we are all done.
set file [open Configure.tk r]
gets $file 
gets $file
gets $file
set content [read $file]
close $file
set file [open Configure.tk w]
puts $file "   "
puts $file "   "
puts $file "   "
puts $file $content
close $file
}

frame .f1
frame .f2 -height 10m -relief flat
frame .f3 -height 10m -relief flat
frame .f4 -height 10m -relief flat
frame .f4a -height 10m -relief flat
frame .f5 -height 10m -relief flat
frame .f6 -height 10m -relief flat
frame .f7 -height 10m -relief flat
frame .f8 -height 10m -relief flat
pack .f8 .f7 .f6 .f5 .f4a .f4 .f3 .f2 -side bottom -expand y
pack .f1 -side bottom -fill both -expand y
button .f2.button -text "?"
label .f2.labelwish -text "Enter Path For Wish"
entry .f2.entrywish -width 25 -textvariable wishpath
pack  .f2.labelwish .f2.entrywish .f2.button -side left -expand 1

bind .f2.button <1> {
        toplevel .dlg -class Dialog
        wm title .dlg "Path for the wish executable"
        wm transient .dlg .
        wm geometry .dlg +450+300
        message .dlg.msg -justify left -text "Please enter the exact path for
the wish program.  If you type in 'whereis wish' at your system prompt, you should see paths such as /usr/bin usr/bin/wish etc.  Choose the appropriate wish and enter the path in the space provided to your right.  For example you could enter either /usr/wish or /usr/bin/wish for the above case"
        button .dlg.exit -text "Ok"\
		-command { destroy .dlg}
        pack .dlg.msg 
	pack .dlg.exit 
    }

button .f3.button -text "?"
label .f3.labelinclude -text "Path for Include Files"
entry .f3.entryinclude -width 25 -textvariable include
pack .f3.labelinclude .f3.entryinclude .f3.button -side left -expand 1
bind .f3.button <1> {
        toplevel .dlg2 -class Dialog
        wm title .dlg2 "Path for the OpenGL include files"
        wm transient .dlg2 .
        wm geometry .dlg2 +450+300
        message .dlg2.msg -justify left -text " OpenGL programs need certain specific header files to be included.  Examples of these are gl.h, glut.h.  If you are unsure as to where these are located on the system, use the search module provided below to locate them.  The above files are necessary for both OpenGL and Mesa programs.
Example:  Say you have installed Mesa-2.3 in the following directory :
users/proj/myname/Mesa-2.3 and after searching for glut.h you get an answer such as /users/proj/myname/Mesa-2.3/include/GL/glut.h then you can enter /users/proj/myname/Mesa-2.3/include as the path for the include files.  If you are unsure about the path, simply enter a period (.) in this field and see if the programs compile properly, else contact your system administrator."
        button .dlg2.exit -text "Ok"\
		-command { destroy .dlg2}
        pack .dlg2.msg 
	pack .dlg2.exit 
    }
button .f4.button -text "?"
label .f4.labellibrary -text "Path for Library Files"
entry .f4.entrylibrary -width 25 -textvariable library
pack .f4.labellibrary .f4.entrylibrary .f4.button -side left -expand 1
bind .f4.button <1> {
        toplevel .dlg3 -class Dialog
        wm title .dlg3 "Path for the OpenGL Library files"
        wm transient .dlg3 .
        wm geometry .dlg3 +450+300
        message .dlg3.msg -justify left -text " OpenGL programs need certain specific files to be linked.  Examples of these are MesaGL, MesaGLU with the counter parts in OGL being GL, GLU.  If you are unsure as to where these are located on the system, use the search module provided below to locate them.  The above files are necessary for both OpenGL and Mesa programs.
Example:  Say you have installed Mesa-2.3 in the following directory :
users/proj/myname/Mesa-2.3 and after searching for MesaGL.a you get an answer such as /users/proj/myname/Mesa-2.3/lib/GL/ then you can enter /users/proj/myname/Mesa-2.3/lib as the path for the Library files.  If you are unsure about the path, simply enter a period (.) in this field and see if the programs compile properly, else contact your system administrator for help."
        button .dlg3.exit -text "Ok"\
		-command { destroy .dlg3}
        pack .dlg3.msg 
	pack .dlg3.exit 
    }
button .f4a.button -text "?"
label .f4a.labellinker -text "Libraries to Link"
entry .f4a.entrylinker -width 25 -textvariable linker
pack .f4a.labellinker .f4a.entrylinker .f4a.button -side left -expand 1
bind .f4a.button <1> {
        toplevel .dlg3 -class Dialog
        wm title .dlg3 "Path for the OpenGL Library files"
        wm transient .dlg3 .
        wm geometry .dlg3 +450+300
        message .dlg3.msg -justify left -text " OpenGL programs need certain specific files to be linked.  Examples of these are MesaGL, MesaGLU with the counter parts in OGL being GL, GLU.  To link properly enter appropriate files to link in here.  
Example : While running  Mesa on an OSF1 platform I typically use :
-lglut -lMesaGLU -lMesaGL -lm -lX11 -lXext -lXmu
If running OpenGL I tend to use :
-lglut -lGL -lGLU -lm -limage -lX11 -lXext -lXmu
You can enter one of the above directly and see if the files compile.  For
linux users you might have to add -libXi to the above"
        button .dlg3.exit -text "Ok"\
		-command { destroy .dlg3}
        pack .dlg3.msg 
	pack .dlg3.exit 
    }


button .f5.button -text "?"
label .f5.searchstart -text "In Directory" 
entry .f5.entrystart -width 15  -textvariable start


button .f5.search -text "Search For" -relief raised
entry .f5.entrysearch -width 15 -textvariable searchfile
pack .f5.search .f5.entrysearch .f5.searchstart .f5.entrystart .f5.button   -side left -expand 1
bind .f5.button <1> {
        toplevel .dlg4 -class Dialog
        wm title .dlg4 "Search Module"
        wm transient .dlg4 .
        wm geometry .dlg4 +450+300
        message .dlg4.msg -justify left -text "Enter the file name to serach for and also to make your search easier and faster, enter the directory to start the search from.  eg glut.h for the file to search for and start the search
from /users/myname/Mesa-2.3 ."
        button .dlg4.exit -text "Ok"\
		-command { destroy .dlg4}
        pack .dlg4.msg 
	pack .dlg4.exit 
    }

bind .f5.search <1> {
global .f7.text
set cmd "myloc $start $searchfile"
catch { eval exec $cmd }
set file [eval open "result" r]
set temp [eval read $file]
close $file
.f7.text delete 1.0 end
.f7.text insert 1.0 "$temp"
}

button .f6.button -text "?"
label .f6.srchresult -text "Search Results:"
button .f6.configureMesa -text "MesaConfigure " -relief raised
button .f6.configureOgl -text "OGLConfigure" -relief raised
pack .f6.srchresult -side left -padx 2c
pack .f6.button .f6.configureMesa .f6.configureOgl -side right 
bind .f6.button <1> {
        toplevel .dlg5 -class Dialog
        wm title .dlg5 "Configure Engine"
        wm transient .dlg5 .
        wm geometry .dlg5 +450+300
        message .dlg5.msg -justify left -text "If you have OpenGL loaded on your system click on 'OGL Configure' else if you are running Mesa click on 'Mesa Configure"
        button .dlg5.exit -text "Ok"\
		-command { destroy .dlg5}
        pack .dlg5.msg 
	pack .dlg5.exit 
    }
bind .f6.configureMesa <1> {
set file [open Config "w" ]
puts $file "LINKS = $linker"
puts $file "LDPATH = -L$library"
puts $file "INCS = -I. -I$include"
puts $file "WISH = $wishpath"
puts $file "CC = gcc"
close $file
config_wish $wishpath
set file [ open mesa_sgi.h "w" ]
puts $file  "#define ALIASMODE 1"
close $file

set fileid [open tkheader.h "r"]
gets $fileid
gets $fileid
set content [read $fileid]
close $fileid
set fileid [open tkheader.h "w"]
puts $fileid "#!$wishpath"
puts $fileid "set lib \[list -I$include -L$library $linker\]"
puts $file $content
close $fileid

exit
}

bind .f6.configureOgl <1> {
set file [open Config "w" ]
puts $file "LINKS = $linker"
puts $file "LDPATH = -L$library"
puts $file "INCS = -I. -I$include"
puts $file "WISH = $wishpath"
puts $file "CC = gcc"
close $file
config_wish $wishpath
set file [ open mesa_sgi.h "w" ]
puts $file  "#define ALIASMODE 0"
close $file
set fileid [open tkheader.h "r"]
gets $fileid
gets $fileid
set content [read $fileid]
close $fileid
set fileid [open tkheader.h "w"]
puts $fileid "#!$wishpath"
puts $fileid "set lib \[list -I$include -L$library $linker\]"
puts $file $content

close $fileid
exit
}

text .f7.text -relief sunken -height 20 -bd 2 -yscrollcommand ".f7.scroll set"
scrollbar .f7.scroll -command ".f7.text yview"
pack .f7.scroll -side right -fill y
pack .f7.text -side left

text   .f1.text -relief sunken -bd 2 -yscrollcommand ".f1.scroll set"
scrollbar  .f1.scroll -command ".f1.text yview"
pack .f1.scroll -side right -fill y
pack .f1.text -side left
 
set ftemp [eval open "Configure_Read" r]

set a [eval read $ftemp]
close $ftemp

.f1.text insert 1.0 "$a"

.f1.text config -state disabled

button .f8.button -foreground red -text "I AM TOTALLY LOST"
pack .f8.button -side left -expand y
bind .f8.button <1> {
        global .f7.text
        set file [eval open "lost" r]
        set temp [eval read $file]
        close $file
        .f7.text delete 1.0 end
        .f7.text insert 1.0 "$temp"
}




































































































































































