From eb019515316f671aa375c6250c9c40efe3c8dba8 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 13 May 2005 11:10:05 +0000 Subject: Adapted for direct compilation under Windows VC --- starkit.tcl.in | 269 ++++++++++++++++++++++++--------------------------------- 1 file changed, 115 insertions(+), 154 deletions(-) diff --git a/starkit.tcl.in b/starkit.tcl.in index def36df..b070a8d 100644 --- a/starkit.tcl.in +++ b/starkit.tcl.in @@ -31,170 +31,131 @@ set PATCHLEVEL @PATCHLEVEL@ # main.tcl # -proc crossCompile {} { - global MAJOR_VERSION MINOR_VERSION PATCHLEVEL - global env - - # - # Try to find the Tcl/Tk headers and stubs cache - set kit [file normalize [file join [pwd] .. .kittmp]] - if { ! [file exists $kit] } { - puts "Unable to find the Tcl/Tk headers and stubs in $kit, exiting." - exit - } - puts "Using Tcl/Tk headers and stubs in: $kit" - - set sources { - generic/Track.c generic/Tabular.c generic/Reticle.c generic/Map.c - generic/Rectangle.c generic/Arc.c generic/Curve.c generic/Item.c - generic/PostScript.c generic/MapInfo.c generic/Attrs.c - generic/Draw.c generic/Geo.c generic/List.c generic/perfos.c - generic/Transfo.c generic/Group.c generic/Icon.c generic/Text.c - generic/Image.c generic/Color.c generic/Field.c generic/Triangles.c - generic/Window.c generic/tkZinc.c generic/OverlapMan.c - win/WinPort.c - } - set cFlags [list -I$kit -I$kit/generic -I$kit/xlib -Igeneric -Ilibtess \ - -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 \ - -DVERSION=\"$MAJOR_VERSION.$MINOR_VERSION.$PATCHLEVEL\" \ - -DGL=1 -DGL_DAMAGE=1 -DATC=1 -DOM=1 -O2 -DBUILD_Tkzinc=1 ] - set lFlags [list -shared -s -L$kit/Windows-x86 -ltclstub -ltkstub \ - -lglu32 -lopengl32 -lgdi32 -lwsock32 -luser32 ] - set objs [list] - - set envSave $env(PATH) - set env(PATH) $env(HOME)/cross-tools/bin:$env(PATH) - set logFile [open starkit.log w] - - foreach f $sources { - lappend objs [file rootname [file tail $f]].o - set cmdLine "gcc $cFlags -c $f >&@ $logFile" - puts $logFile $cmdLine - catch {eval exec $cmdLine} result - puts $logFile $result - } - set cmdLine "gcc $objs $lFlags -o Tkzinc$MAJOR_VERSION$MINOR_VERSION$PATCHLEVEL.dll >&@ $logFile" - puts $logFile $cmdLine - catch {eval exec $cmdLine} result - puts $logFile $result - - close $logFile - set env(PATH) $envSave +proc Windows-x86-Compile {} { + set cwd [pwd] + puts "Compiling for Windows $cwd..." + cd win + if { [catch { exec tclsh package.tcl clean } result] } { + puts $result + exit + } + if { [catch { exec tclsh package.tcl subst } result] } { + puts $result + exit + } + if { [catch { exec tclsh package.tcl tcl } result] } { + puts $result + exit + } + # + # Copy the dll in the root dir for updateKit. + file copy -force [glob -directory buildtcl Tkzinc*.dll] [file join $cwd Tkzinc.dll] + + cd $cwd } -proc updateKit {} { - global MAJOR_VERSION MINOR_VERSION PATCHLEVEL - - set zincPath [file join Tkzinc.vfs lib Tkzinc$MAJOR_VERSION.$MINOR_VERSION] - set version $MAJOR_VERSION.$MINOR_VERSION.$PATCHLEVEL - set winVersion $MAJOR_VERSION$MINOR_VERSION$PATCHLEVEL - - file copy -force [file join starkit demo.tcl] [file join starkit main.tcl] Tkzinc.vfs - - set zincPath [file join Tkzinc.vfs lib Tkzinc$MAJOR_VERSION.$MINOR_VERSION] - file mkdir $zincPath - file copy -force Copyright \ - [file join library zincGraphics.tcl] \ - [file join library zincLogo.tcl] \ - [file join library zincText.tcl] \ - $zincPath - - set demosPath [file join $zincPath demos] - file mkdir $demosPath - foreach f [glob -directory demos *.tcl] { - file copy -force $f $demosPath - } - file delete -force [file join $demosPath data] [file join $demosPath images] - file copy -force [file join demos zinc-widget] [file join demos data] [file join demos images] $demosPath - - # - # Emit a merged pkgIndex.tcl - # - set fOut [open [file join $zincPath pkgIndex.tcl] w] - puts $fOut "proc Platform {} {" - puts -nonewline $fOut [info body Platform] - puts $fOut "}" - set fIn [open [file join library pkgIndex.tcl]] - foreach line [split [read $fIn] \n] { - if {![regexp {^\s*$|^#} $line]} { +proc Linux-x86-Compile {} { +} + +proc updateKit { TkzincVfs } { + global MAJOR_VERSION MINOR_VERSION PATCHLEVEL + + set zincPath [file join $TkzincVfs lib Tkzinc$MAJOR_VERSION.$MINOR_VERSION] + set version $MAJOR_VERSION.$MINOR_VERSION.$PATCHLEVEL + set winVersion $MAJOR_VERSION$MINOR_VERSION$PATCHLEVEL + + file copy -force [file join starkit demo.tcl] [file join starkit main.tcl] $TkzincVfs + + set zincPath [file join $TkzincVfs lib Tkzinc$MAJOR_VERSION.$MINOR_VERSION] + file mkdir $zincPath + file copy -force Copyright \ + [file join library zincGraphics.tcl] \ + [file join library zincLogo.tcl] \ + [file join library zincText.tcl] \ + $zincPath + + set demosPath [file join $zincPath demos] + file mkdir $demosPath + foreach f [glob -directory demos *.tcl] { + file copy -force $f $demosPath + } + file delete -force [file join $demosPath data] [file join $demosPath images] + file copy -force [file join demos zinc-widget] [file join demos data] [file join demos images] $demosPath + + # + # Emit a merged pkgIndex.tcl + # + set fOut [open [file join $zincPath pkgIndex.tcl] w] + puts $fOut "proc Platform {} {" + puts -nonewline $fOut [info body Platform] + puts $fOut "}" + set fIn [open [file join library pkgIndex.tcl]] + foreach line [split [read $fIn] \n] { + if {![regexp {^\s*$|^#} $line]} { puts $fOut $line - } - } - close $fIn - puts -nonewline $fOut "package ifneeded Tkzinc $version " - puts $fOut {[list load [file join $dir [Platform] Tkzinc[info sharedlibext]]]} - close $fOut - - # - # Copy the platform dependent libraries - # - if { [file exists libTkzinc$version.so] } { - set platformPath [file join $zincPath Linux-x86] - file mkdir $platformPath - file copy -force libTkzinc$version.so [file join $platformPath Tkzinc.so] - } - if { [file exists Tkzinc$winVersion.dll] } { - set platformPath [file join $zincPath Windows-x86] - file mkdir $platformPath - file copy -force Tkzinc330.dll [file join $platformPath Tkzinc.dll] - } - - exec sdx wrap Tkzinc.kit + } + } + close $fIn + puts -nonewline $fOut "package ifneeded Tkzinc $version " + puts $fOut {[list load [file join $dir [Platform] Tkzinc[info sharedlibext]]]} + close $fOut + + # + # Copy the platform dependent libraries + # + if { [file exists libTkzinc$version.so] } { + set platformPath [file join $zincPath Linux-x86] + file mkdir $platformPath + file copy -force libTkzinc$version.so [file join $platformPath Tkzinc.so] + } + if { [file exists Tkzinc.dll] } { + set platformPath [file join $zincPath Windows-x86] + file mkdir $platformPath + file copy -force Tkzinc.dll [file join $platformPath Tkzinc.dll] + } } proc Platform {} { - global tcl_platform - set plat [lindex $tcl_platform(os) 0] - set mach $tcl_platform(machine) - switch -glob -- $mach { - sun4* { set mach sparc } - intel - - i*86* { set mach x86 } - "Power Macintosh" { set mach ppc } - } - switch -- $plat { - AIX { set mach ppc } - HP-UX { set mach hppa } - } - return "$plat-$mach" + global tcl_platform + set plat [lindex $tcl_platform(os) 0] + set mach $tcl_platform(machine) + switch -glob -- $mach { + sun4* { set mach sparc } + intel - + i*86* { set mach x86 } + "Power Macintosh" { set mach ppc } + } + switch -- $plat { + AIX { set mach ppc } + HP-UX { set mach hppa } + } + return "$plat-$mach" } # -# Build the Windows variant -crossCompile +# Build the current platform variant +[Platform]-Compile + +set TkzincVfs Tkzinc.vfs +set TkzincKit Tkzinc.kit + +set cwd [pwd] +cd .. + +if { ! [file exists $TkzincVfs] } { + if { [file exists $TkzincKit] } { + exec sdx unwrap $TkzincKit + } else { + puts "Unable to find either Tkzinc.kit or Tkzinc.vfs in .. , giving up." + exit + } +} +cd $cwd +updateKit [file join .. $TkzincVfs] -# -# Build the linux variant -catch {exec make clean} -catch {exec make} +puts "Now wrapping the starkit" -# -# If the starkit Tkzinc.kit already exist in the top directory -# simply update it else build a new one according to the layout -# above. In this later case one need to make sure there is a -# valid Tkimg.kit in the top directory's parent. -# -if { [file exists Tkzinc.kit] } { - if { [file exists Tkzinc.vfs] } { - file delete -force Tkzinc.vfs - } - exec sdx unwrap Tkzinc.kit - updateKit -} { - if { [file exists Tkzinc.vfs] } { - file delete -force Tkzinc.vfs - } - file mkdir Tkzinc.vfs - - if { [file exists Tkimg.vfs] } { - file delete -force Tkimg.vfs - } - exec sdx unwrap [file join .. Tkimg.kit] - file copy [file join Tkimg.vfs lib] Tkzinc.vfs - - updateKit -} +cd .. +exec sdx wrap $TkzincKit -file delete -force Tkimg.vfs -file delete -force Tkzinc.vfs -- cgit v1.1