1# $Id: installWin.tcl,v 1.1 2004/05/23 22:50:39 neumann Exp $
2if {$::argc > 0} {
3  set DESTINATION [lindex $argv 0]
4} else {
5  # if now argument is given -> set to default
6  set DESTINATION "/Progra~1/Tcl"
7}
8
9puts "Installing to Directory: $DESTINATION"
10
11#rename file tcl_file
12#proc file args {
13#  puts stderr "...$args"
14#  eval ::tcl_file $args
15#}
16
17#
18# find out the XOTcl version
19#
20cd ..
21set xotclDir .
22set buildDir $xotclDir/win/Release
23cd $buildDir
24set xotcllib [lindex [glob -nocomplain libxotcl*.dll] 0]
25cd ../..
26regexp {^libxotcl([0-9]\.[0-9]).dll$} $xotcllib _ xotclVersion
27puts "XOTcl Version is   $xotclVersion"
28set MAKEXOTCL $xotclDir/library/lib/make.xotcl
29
30#
31# copy binaries
32#
33file mkdir $DESTINATION/bin
34set bin "xotclsh.exe xowish.exe"
35foreach b $bin {
36  if {[file exists $buildDir/$b]} {
37    puts "Copying $b"
38    file copy -force $buildDir/$b $DESTINATION/bin
39  } elseif {[file exists  $xotclDir/$b]} {
40    puts "Copying $b"
41    file copy -force $xotclDir/$b $DESTINATION/bin
42  }
43}
44
45#
46# copy libraries
47#
48file mkdir $DESTINATION/include
49set includes "xotcl.h xotclInt.h xotclDecls.h xotclIntDecls.h"
50foreach i $includes {
51    puts "Copying $i"
52    file copy -force $xotclDir/generic/$i $DESTINATION/include
53}
54
55#
56# create the XOTcl library directory
57#
58puts "Creating XOTcl Lib Dir"
59file mkdir $DESTINATION/lib
60file mkdir $DESTINATION/lib/xotcl$xotclVersion
61
62#
63# copy the dll
64#
65set b libxotcl${xotclVersion}.dll
66if {[file exists $buildDir/$b]} {
67    puts "Copying $b"
68    file copy -force $buildDir/$b $DESTINATION/lib
69} elseif {[file exists $xotclDir/$b]} {
70    puts "Copying $b"
71    file copy -force $xotclDir/$b $DESTINATION/lib
72}
73
74#
75# create a pkgindex file for xotcl in the library directoy
76#
77#file mkdir $DESTINATION/lib/xotcl$xotclVersion/libxotcl
78puts "Creating pkgindex files for xotcl in the library directory"
79#set pkgIndex "package ifneeded XOTcl $xotclVersion \[list load \[file join \$dir ../../../bin \"libxotcl${xotclVersion}.dll\"\] XOTcl\]"
80#set F [open $DESTINATION/lib/xotcl$xotclVersion/libxotcl/pkgIndex.tcl w]
81#puts $F $pkgIndex
82#puts $F "\n"
83#close $F
84## and one in the xotcl-<VERSION> directory
85set pkgIndex "package ifneeded XOTcl $xotclVersion \[list load \[file join \$dir ../../ \"libxotcl${xotclVersion}.dll\"\] XOTcl\]"
86file mkdir $DESTINATION/lib/xotcl$xotclVersion/xotcl
87set F [open $DESTINATION/lib/xotcl$xotclVersion/xotcl/pkgIndex.tcl w]
88puts $F $pkgIndex
89puts $F "\n"
90close $F
91
92proc copyDir {dir dest} {
93  puts "Copying directory: $dir"
94  set files [glob -nocomplain $dir/*]
95  foreach f $files {
96    doDir $f $dest
97  }
98}
99
100proc doDir {f dest} {
101  if {[file isdirectory $f]} {
102    file mkdir $dest/$f
103    copyDir $f $dest
104  } else {
105    file copy -force $f $dest/$f
106 }
107}
108
109cd library
110
111foreach f [glob -nocomplain *] {
112  doDir $f $DESTINATION/lib/xotcl$xotclVersion
113}
114
115cd ..
116set pwd [pwd]
117
118puts "Indexing the packages"
119set shell [info nameofexecutable]
120#puts "SHELL=$shell"
121cd $DESTINATION/lib/xotcl$xotclVersion
122if {[catch {exec $shell $pwd/$MAKEXOTCL -target $DESTINATION/lib/xotcl$xotclVersion -all} errMsg]} {
123  puts "  ... resulting message: $errMsg\n"
124} else {
125  puts " ... Package Indexing SUCCEEDED\n"
126}
127
128puts stderr "***************************************************"
129puts stderr "INSTALLATION COMPLETE."
130puts stderr "\nIn order to use XOTcl set PATH to "
131puts stderr "  '$DESTINATION/bin' and"
132puts stderr "set TCLLIBPATH to "
133puts stderr "  '$DESTINATION/lib/xotcl$xotclVersion'"
134puts stderr "***************************************************"
135
136
137