Changes On Branch gort
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to tclconference@googlegroups.com or submit via the online form
by Aug 20.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch gort Excluding Merge-Ins

This is equivalent to a diff from bc425bad42 to 07c8c54701

2016-03-01
18:13
Closing the gort branch check-in: 02f5a924cb user: hypnotoad tags: trunk
18:12
Instead of embedding the package ifneeded script for TK in the tclIndex file, it now gets its own "pkgIndex.tcl" file in boot/tk The packages.tcl file for the VFS is now loaded on startup (if present) Cleaned up and straightened up the boot process for kits Closed-Leaf check-in: 07c8c54701 user: hypnotoad tags: gort
11:42
Upgraded all the tcl bits to reference 8.6.5 Fixed more platform aphorisms for Windows that didn't translate to unix check-in: c77f5a58bd user: hypnotoad tags: gort
2016-02-18
17:23
Fixes to make odie build with "gort" instead of "sherpa" check-in: d0db26f6a0 user: hypnotoad tags: gort
16:10
Restructuring "ODIE" as a one trick pony to manage Tcl and Kit builds, as well as perform whatever autoconfiguring a high level integtrator may need check-in: bc425bad42 user: hypnotoad tags: trunk
15:36
Pulling in the kitscript branch check-in: bc81bcba25 user: hypnotoad tags: trunk

Changes to Makefile.
12
13
14
15
16
17
18
19

20
21
22
23
24

25
26
27
28
29

30
31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
46
47
48
49
50
51

52
53
54
55
56
57
58
59
60
61

62


63
64





65
66
67
68
69
70
71
12
13
14
15
16
17
18

19
20
21
22
23

24
25
26
27
28

29
30
31
32
33
34
35
36
37

38
39
40
41
42
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
58
59
60

61
62
63
64


65
66
67
68
69
70
71
72
73
74
75
76







-
+




-
+




-
+








-
+












-
+









-
+

+
+
-
-
+
+
+
+
+







	cp -a ${ODIE_SRC_DIR}/odieConfig.tcl ${LOCAL_REPO}/lib/odieConfig.tcl
	cp -a ${ODIE_SRC_DIR}/odieConfig.sh ${LOCAL_REPO}/lib/odieConfig.sh

install: sherpa
	$(SHELL) scripts/make_skel.sh
	$(SHELL) scripts/make_tcl.sh
	ODIE_BUILD_TCLSH=`autosetup/find-tclsh`
	$(ODIE_BUILD_TCLSH) scripts/make_sherpa.tcl
	$(ODIE_BUILD_TCLSH) scripts/make_gort.tcl
	$(SHERPA) upgrade sqlite odielib tcllib
	${ODIE_BUILD_TCLSH} build.tcl toadkit

packages: sherpa
	$(SHERPA) install sqlite odielib tcllib
	$(SHERPA) install odielib tcllib

upgrade:
	$(FOSSIL) update
	${ODIE_BUILD_TCLSH} scripts/upgrade.tcl
	$(ODIE_BUILD_TCLSH) scripts/make_sherpa.tcl
	$(ODIE_BUILD_TCLSH) scripts/make_gort.tcl
	$(SHERPA) upgrade sqlite odielib tcllib
	${ODIE_BUILD_TCLSH} build.tcl toadkit

upgrade-tcl:
	$(FOSSIL) update
	$(SHELL) scripts/make_tcl.sh
	ODIE_BUILD_TCLSH=`autosetup/find-tclsh`
	${ODIE_BUILD_TCLSH} scripts/upgrade.tcl
	$(ODIE_BUILD_TCLSH) scripts/make_sherpa.tcl
	$(ODIE_BUILD_TCLSH) scripts/make_gort.tcl
	$(SHERPA) upgrade sqlite odielib tcllib
	${ODIE_BUILD_TCLSH} build.tcl clean
	rm -rf tcl tk
	${ODIE_BUILD_TCLSH} build.tcl toadkit

tcl:
	$(SHELL) scripts/make_tcl.sh

rebuild:
	$(SHELL) scripts/make_distclean.sh
	$(FOSSIL) update
	$(SHELL) scripts/make_tcl.sh
	$(ODIE_BUILD_TCLSH) scripts/make_sherpa.tcl
	$(ODIE_BUILD_TCLSH) scripts/make_gort.tcl
	$(SHERPA) upgrade sqlite odielib tcllib
	${ODIE_BUILD_TCLSH} build.tcl toadkit

distclean:
	$(SHELL) scripts/make_distclean.sh

basekit:
	${ODIE_BUILD_TCLSH} build.tcl toadkit

sherpa: $ODIE_DOWNLOAD/sherpa/sherpa.tcl
sherpa: $ODIE_SANDBOX/sherpa/sherpa.tcl

gort: $ODIE_SANDBOX/gort/gort.tcl

$ODIE_DOWNLOAD/sherpa/sherpa.tcl:
	$(ODIE_BUILD_TCLSH) scripts/make_sherpa.tcl
$ODIE_SANDBOX/sherpa/sherpa.tcl:
	$(ODIE_BUILD_TCLSH) scripts/make_gort.tcl

$ODIE_SANDBOX/gort/gort.tcl:
	$(ODIE_BUILD_TCLSH) scripts/make_gort.tcl

$(ODIE_MKHDR):
	$(CC) -o mkhdr.o scripts/mkhdr.c
	$(CC) mkhdr.o -o mkhdr${EXE_SUFFIX}
	cp -f mkhdr@EXE@ $(ODIE_MKHDR)

mkhdr: $(ODIE_MKHDR)
Changes to auto.def.
86
87
88
89
90
91
92
93

94
95
96
97
98
99
100
86
87
88
89
90
91
92

93
94
95
96
97
98
99
100







-
+







foreach {program required domake} {
  zip 	 1 0
  unzip  1 0
  tar    1 0
  git    0 1
  strip  0 0
  mkhdr  0 1
  sherpa 0 1
  gort 0 1
} {
  if {$required} {
    set exename [lindex [find-an-executable -required $program] 0]
  } else {
    set exename [lindex [find-an-executable $program] 0]
  }
  if {$domake && $exename eq {}} {
Changes to autosetup/lib/odie.tcl.
1
2
3
4

5
6
7
8
9
10
11
1
2
3

4
5
6
7
8
9
10
11



-
+







# @synopsis:
#
# ODIE modules adds teacup platform data and integration with
# sherpa
# gort
#
use system codebale
# Build procs for this modules

options {
nodots => "Suppress dots in version numbers in lib names"
pkgdir: => "Where to install the package (default $prefix/lib)"
248
249
250
251
252
253
254
255

256
257
258
259
260
261
262
263

264
265
266
267
268
269
270
248
249
250
251
252
253
254

255
256
257
258
259
260
261
262

263
264
265
266
267
268
269
270







-
+







-
+







# Initialize our picture of the world
###
array set odie_tcl {
  config_flags {}
  version 8.6
  major_version 8
  minor_version 6
  patch_level .4
  patch_level .5
  fossil_branch release
}
array set odie_tk {
  config_flags {}
  version 8.6
  major_version 8
  minor_version 6
  patch_level .4
  patch_level .5
  fossil_branch release
}
array set odie {
  exe_suffix {}
  platform unix
  tea_platform_dir unix
  tcl_platform_dir unix
313
314
315
316
317
318
319
320

321
322
323
324
325
326
327
313
314
315
316
317
318
319

320
321
322
323
324
325
326
327







-
+







    set ::odie(ld_flags) "-static-libgcc -static-libstdc++"
  }
  *win32* - *WIN32* {
    ###
    # With visual studio, 64 bit should be assumed
    # but is otherwise to taste
    ###
    set odie(windows) 1
    set ::odie(windows) 1
    set ::odie(os) windows

  } 
}

###
# Build information about the local tools
551
552
553
554
555
556
557
558

559
560
561
562
563
551
552
553
554
555
556
557

558
559
560
561
562
563







-
+





set ::force_check 0
###
# Under MSYS/Cygwin transform the Cygwinized paths
# pack into proper names for Windows
###
foreach path {
  sandbox download src_dir tcl_shell wish_shell build_tclsh
  fossil git zip unzip sherpa lib local_repo
  fossil git zip unzip lib local_repo
} {
  if {[info exists ::odie($path)]} {
    set ::odie_build($path) [::realpath $::odie($path)]
  }
}
Changes to build.tcl.
1
2
3
4
5
6
7
8

9
10
11
12
13
14

15
16
17
18

19
20

21
22
23
24
25
26
27







28





29

30


31
32
33
34
35
36
37
38
39
40






































































































41
42






































43
44
45
46
47
48
49
1
2
3


4


5






6




7

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

30
31
32
33










34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182



-
-

-
-
+
-
-
-
-
-
-
+
-
-
-
-
+
-

+







+
+
+
+
+
+
+

+
+
+
+
+
-
+

+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







###
# script to build a tclkit
###
set HERE [file dirname [file normalize [info script]]]
set PWD [pwd]

package ifneeded zipfile::mkzip 1.2 [list source [file join $HERE scripts mkzip.tcl]]

#####
if {[lindex $argv 0] eq "clean"} {
  file delete -force build
  file delete -force tcl
  file delete -force tk
  foreach file [glob -nocomplain *.a] {
    file delete $file
# Define procedures
  }
  exit
}

#####
package require fileutil

namespace eval ::practcl {}
proc ::cat fname {
    set fname [open $fname r]
    set data [read $fname]
    close $fname
    return $data
}

proc ::practcl::localtools {} {
  
}

proc ::practcl::_isdirectory name {
  return [file isdirectory $name]
}
###
# topic: ebd68484cb7f18cad38beaab3cf574e2de5702ea
###
proc ::practcl::_istcl name {
  return [string match *.tcl $name]
}
# topic: 15c41a8a701fb2afdfbd8d479d464bda

###
# topic: 2e481bd24d970304a1dd0acad3d75198b56c122e
###
proc ::pkgIndexDir {root fout d1} {
  puts [format {%*sIndexing %s} [expr {4 * [info level]}] {} [file tail $d1]]
  set idx [string length $root]
  foreach ftail [glob -directory $d1 -nocomplain -tails *] {
    set f [file join $d1 $ftail]
    if {[file isdirectory $f] && [string compare CVS $ftail]} {
      pkgIndexDir $root $fout $f
    } elseif {[file tail $f] eq "pkgIndex.tcl"} {
      puts $fout "set dir \${VFSROOT}[string range $d1 $idx end]"
      puts $fout [cat $f]
proc ::practcl::_istm name {
  return [string match *.tm $name]
}

###
# Return true if the pkgindex file contains
# any statement other than "package ifneeded"
# and/or if any package ifneeded loads a DLL
###
proc ::practcl::_pkgindex_directory {path} {
  set buffer {}
  set pkgidxfile [file join $path pkgIndex.tcl]
  if {![file exists $pkgidxfile]} {
    # No pkgIndex file, read the source
    foreach file [glob -nocomplain $path/*.tm] {
      set file [file normalize $file]
      set fname [file rootname [file tail $file]]
      ###
      # We used to be able to ... Assume the package is correct in the filename
      # No hunt for a "package provides"
      ###
      set package [lindex [split $fname -] 0]
      set version [lindex [split $fname -] 1]
      ###
      # Read the file, and override assumptions as needed
      ###
      set fin [open $file r]
      set dat [read $fin]
      close $fin
      # Look for a teapot style Package statement
      foreach line [split $dat \n] {
        set line [string trim $line]
        if { [string range $line 0 9] != "# Package " } continue
        set package [lindex $line 2]
        set version [lindex $line 3]
        break
      }
      # Look for a package provide statement
      foreach line [split $dat \n] {
        set line [string trim $line]              
        if { [string range $line 0 14] != "package provide" } continue
        set package [lindex $line 2]
        set version [lindex $line 3]
        break
      }
      append buffer "package ifneeded $package $version \[list source \[file join \$dir [file tail $file]\]\]" \n
    }
    foreach file [glob -nocomplain $path/*.tcl] {
      if { [file tail $file] == "version_info.tcl" } continue
      set fin [open $file r]
      set dat [read $fin]
      close $fin
      if {![regexp "package provide" $dat]} continue
      set fname [file rootname [file tail $file]]
      # Look for a package provide statement
      foreach line [split $dat \n] {
        set line [string trim $line]              
        if { [string range $line 0 14] != "package provide" } continue
        set package [lindex $line 2]
        set version [lindex $line 3]
        if {[string index $package 0] in "\$ \["} continue
        if {[string index $version 0] in "\$ \["} continue
        append buffer "package ifneeded $package $version \[list source \[file join \$dir [file tail $file]\]\]" \n
        break
      }
    }
    return $buffer
  }
  set fin [open $pkgidxfile r]
  set dat [read $fin]
  close $fin
  set thisline {}
  foreach line [split $dat \n] {
    append thisline $line \n
    if {![info complete $thisline]} continue
    set line [string trim $line]
    if {[string length $line]==0} {
      set thisline {} ; continue
    }
    if {[string index $line 0] eq "#"} {
      set thisline {} ; continue
    }
    try {
      # Ignore contditionals
      if {[regexp "if.*catch.*package.*Tcl.*return" $thisline]} continue
      if {[regexp "if.*package.*vsatisfies.*package.*provide.*return" $thisline]} continue
      if {![regexp "package.*ifneeded" $thisline]} {
        # This package index contains arbitrary code
        # source instead of trying to add it to the master
        # package index
        return {source [file join $dir pkgIndex.tcl]} 
      }
      append buffer $thisline \n
    } on error {err opts} {
      puts ***
      puts "GOOF: $pkgidxfile"
      puts $line
      puts $err
      puts [dict get $opts -errorinfo]
      puts ***
    } finally {
      set thisline {}
    }
  }
  return $buffer
}

###
# Index all paths given as though they will end up in the same
# virtual file system
###
proc ::practcl::pkgindex_path args {
  set stack {}
  set buffer {
lappend ::PATHSTACK $dir
  }
  foreach base $args {
    set i    [string length  $base]
    # Build a list of all of the paths
    set paths [fileutil::find $base ::practcl::_isdirectory]
    foreach path $paths {
      if {$path eq $base} continue
      set path_indexed($path) 0
    }
    set path_index([file join $base boot tcl]) 1
    set path_index([file join $base boot tk]) 1
  
    foreach path $paths {
      set thisdir [::fileutil::relative $base $path]
      set idxbuf [::practcl::_pkgindex_directory $path]
      if {[string length $idxbuf]} {
        incr path_indexed($path)
        append buffer "set dir \[file join \[lindex \$::PATHSTACK end\] $thisdir\]" \n
        append buffer [string trimright $idxbuf] \n
      } 
    }
  }
  append buffer {
set dir [lindex $::PATHSTACK end]  
set ::PATHSTACK [lrange $::PATHSTACK 0 end-1]
}
  return $buffer
}

proc read_Config.sh {filename} {
  set fin [open $filename r]
  set result {}
  while {[gets $fin line] >= 0} {
    set line [string trim $line]
74
75
76
77
78
79
80
81

82
83
84
85
86

87
88
89
90
91
92
93
94
95

96

97
98
99
100
101
102
103
104
105
106
107
108





























































109
110


















































111


112
113


114

115



116
117
118
119
120
121
122
123




















124
125
126
127
128
129









130
131
132







133


134
135
136
137






138
139
140
141
142
143
144
145
146
147
































148

149
150
151
152
153







154
155





156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
























173
174
175
176
177
178
179
180
181
182
183
184
185




















186
187
188
189
190
191
192






193
194
195
196
197
198
199

200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223




224
225
226
227
228




229
230
231


232
233

234
235
236
237
238
239















240
241
242
243
244
245
246
247
248
249
250
251
252
253

254
255
256
257
258
259
260
261
262





263
264
265
266
267
268



269




270
271

272
273
274




275
276
277
278
279

280
281
282
283
284
285
286
287
288
289

290
291
292
293
294
295
296
297


298
299
300
301
302
303
304
305
306
307
308



309
310
311
312
313
314
315
316


317
318
319


320
321
322
323
324
325



326
327
328
329
330
331
332

333
334
335
336


337
338
339
340
341
342
343
344
345
346








347
348
349
350



351
352
353
354
355
356


357



358





359
360
361









362
363
364
365
366
367
368









369
370

371
372

373
374

375
376
377
378


379
380
381
382
383



384
385

386
387
388


389
390
391
392
393
394
395
396

397
398
399


400
401

402
403
404
405

406
407
408
409
410
411
412
413


414
415
416
417
418
419
420
421
422


423
424
425

426
427
428
429
430
431
207
208
209
210
211
212
213

214
215
216
217
218

219
220
221
222
223
224
225
226
227
228
229

230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303


304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366








367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387





388
389
390
391
392
393
394
395
396



397
398
399
400
401
402
403
404
405
406




407
408
409
410
411
412










413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444

445
446




447
448
449
450
451
452
453
454
455
456
457
458
459
460

















461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486











487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506







507
508
509
510
511
512
513
514

515
516
517

518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538




539
540
541
542
543




544
545
546
547
548


549
550
551

552
553
554
555



556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578



579
580

581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604

605
606
607
608
609

610
611


612
613
614
615
616
617
618
619

620
621
622
623
624
625
626
627
628
629

630
631
632
633
634
635
636


637
638
639
640
641
642
643
644





645
646
647
648
649
650
651
652
653


654
655



656
657
658
659
660



661
662
663







664




665
666










667
668
669
670
671
672
673
674




675
676
677
678
679
680
681


682
683
684
685
686
687
688
689
690
691
692
693



694
695
696
697
698
699
700
701
702
703






704
705
706
707
708
709
710
711
712
713

714
715

716
717

718
719
720


721
722
723
724



725
726
727
728

729
730


731
732








733



734
735
736

737
738



739
740
741
742
743




744
745





746
747


748
749



750





751







-
+




-
+









+
-
+












+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+


+
+

+

+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+

+
+
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+

-
-
-
-
+
+
+
+
+
+
+


+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+


-



-
+




















-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+

-
-
+
+

-
+



-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+








-
-
-


-
+









+
+
+
+
+






+
+
+
-
+
+
+
+

-
+

-
-
+
+
+
+




-
+









-
+






-
-
+
+






-
-
-
-
-
+
+
+






-
-
+
+
-
-
-
+
+



-
-
-
+
+
+
-
-
-
-
-
-
-
+
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+




-
-
+
+

+
+
+

+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+

-
-
-
-
-
-
+
+
+
+
+
+
+
+
+

-
+

-
+

-
+


-
-
+
+


-
-
-
+
+
+

-
+

-
-
+
+
-
-
-
-
-
-
-
-
+
-
-
-
+
+

-
+

-
-
-
+




-
-
-
-
+
+
-
-
-
-
-


-
-
+
+
-
-
-
+
-
-
-
-
-


proc ::domake {args} {
  puts [list make {*}$args]
  exec make {*}$args >&@ stdout
}

proc ::COMPILE {which cfile {extras {}}} {
  set objfile [file normalize build/[file tail [file dirname $cfile]]_[file rootname [file tail $cfile]].o]
  set objfile [file normalize [file join $::PWD build [file tail [file dirname $cfile]]_[file rootname [file tail $cfile]].o]]
  lappend ::KIT(${which}_OBJS) $objfile
  if {[file exists $objfile] && [file mtime $objfile] > [file mtime $cfile]} return
  lappend cmd  $::KIT(cc) {*}$::KIT(cflags_optimize) {*}$::KIT(shlib_cflags) {*}$::KIT(cflags_warning) {*}$::KIT(extra_cflags) {*}$::KIT(defs) {*}$extras
  foreach path $::KIT(INCLUDES) {
    lappend cmd -I./[fileutil::relative $::PWD $HERE]
    lappend cmd -I./[fileutil::relative $::PWD $path]
  }
  lappend cmd {*}$::KIT(EXTRA_CFLAGS)
  lappend cmd -c [fileutil::relative $::PWD $cfile] -o $objfile
  puts [list [file tail $cfile] -> [file tail $objfile]]
  puts $cmd
  exec {*}$cmd >&@ stdout
}

proc ::copyDir {d1 d2} {
  #puts [list $d1 -> $d2]
  file delete -force -- $d2
  #file delete -force -- $d2
  file mkdir $d2

  foreach ftail [glob -directory $d1 -nocomplain -tails *] {
    set f [file join $d1 $ftail]
    if {[file isdirectory $f] && [string compare CVS $ftail]} {
      copyDir $f [file join $d2 $ftail]
    } elseif {[file isfile $f]} {
      file copy -force $f [file join $d2 $ftail]
    }
  }
}

proc ::practcl::wrap {PWD name vfspath args} {
  cd $PWD
  if {![file exists $vfspath]} {
    file mkdir $vfspath
  }
  package ifneeded zipfile::mkzip 1.2 [list source [file join $::HERE scripts mkzip.tcl]]
  package require zipfile::mkzip
  set fout [open [file join $vfspath packages.tcl] w]
  set buffer [::practcl::pkgindex_path $::KIT(BASEVFS) $vfspath]
  puts $fout $buffer
  close $fout
  copyDir $::KIT(BASEVFS) $vfspath
  foreach arg $args {
     copyDir $arg $vfspath
  }
  ::zipfile::mkzip::mkzip ${name}$::KIT(EXEEXT) -runtime $::TARGET(tclkit_bare) -directory $vfspath
  file attributes ${name}$::KIT(EXEEXT) -permissions a+x
}

#########################################
#
# BUILD THE INTERPRETER ENVIRONMENT
#
#########################################

set HERE [file dirname [file normalize [info script]]]
set PWD [pwd]

lappend auto_path [file normalize [file join $HERE .. tcllib modules]]
lappend auto_path [file normalize [file join $HERE .. odielib modules]]
#package ifneeded zipfile::mkzip 1.2 [list source [file join $::HERE scripts mkzip.tcl]]

package require fileutil

#########################################
#
# BEGIN THE KITBUILDING PROCESS HERE
#
#########################################
set _search_paths {{$PWD} {$PWD ..}}
if {![file exists [file join $::HERE odieConfig.tcl]]} {
  # Build the local toolset
  cd $HERE
  exec [info nameofexecutable] [file join $HERE autosetup autosetup]
  cd $PWD
}
puts "AUTOPATH (276): $::auto_path"
source [file join $::HERE odieConfig.tcl]
set ::KIT(platform) ::odie(platform)
set ::KIT(ORIG_TCL_SRC_DIR) $::odie_tcl(src_dir)
set ::KIT(ORIG_TK_SRC_DIR) $::odie_tk(src_dir)
set ::KIT(TCL_BUILD_OPTS) $::odie_tcl(config_flags)
set ::KIT(TK_BUILD_OPTS) $::odie_tk(config_flags)
set ::KIT(HOST) $::odie(host)
set ::KIT(TARGET) $::odie(target)
set ::KIT(TCL_VERSION) $::odie_tcl(version)
set ::KIT(TK_VERSION) $::odie_tk(version)
set ::KIT(TCL_PATCH_LEVEL) $::odie_tcl(patch_level)
set ::KIT(TK_PATCH_LEVEL) $::odie_tk(patch_level)

if {[file exists [file join $PWD project.rc]]} {
source [file join $HERE odieConfig.tcl]
if { $::odie(platform) eq "windows" } {
  source [file join $PWD project.rc]
  set ::KIT(platform) $::project(TEA_PLATFORM)
  set ::KIT(ORIG_TCL_SRC_DIR) $::project(TCL_SRC_DIR)
  set ::KIT(ORIG_TK_SRC_DIR) $::project(TK_SRC_DIR)
  set ::KIT(TARGET) $::project(TEA_PLATFORM)
  set ::KIT(TCL_VERSION) $::project(TCL_VERSION)
  set ::KIT(TK_VERSION) $::project(TK_VERSION)  
  set ::KIT(TCL_PATCH_LEVEL) $::project(TCL_PATCH_LEVEL)
  set ::KIT(TK_PATCH_LEVEL) $::project(TCL_PATCH_LEVEL)
  lappend _search_paths {[file dirname $::project(srcdir)]}
}
lappend _search_paths $::odie(sandbox)


array set build {
  tcl 0
  tk  0
  packages 0
  basekitvfs 0
  toadkit.rc 0
  toadkit 0
  tclkit_bare 0
  libtoadkit.a 0
}

###
# Begin processing our arguments
###
set COMMAND [lindex $argv 0]
switch $COMMAND {
  localtcl {
    
  }
  toadkit {
    set build(toadkit) 1
  }
  basekit {
    set build(toadkit) 1
  }
  wrap {
    
  }
  clean {
  }
  default {
    error "Unknown command $COMMAND. Valid: clean tcl toadkit wrap"
  }
}

if { $::KIT(platform) eq "windows" } {
  set ::KIT(EXEEXT) .exe
  set ::KIT(platform_src_dir) win
  set USEMSVC [info exists env(VisualStudioVersion)]
} else {
  set ::KIT(EXEEXT) {}
  set ::KIT(platform_src_dir) unix
  set USEMSVC 0
}
set ::KIT(PKGPREFIX) /zvfs

foreach dpath $_search_paths {
  set path [file normalize [file join {*}[subst $dpath] toadkit$::KIT(TCL_VERSION)$::KIT(TCL_PATCH_LEVEL)]]
  set ::KIT(TCLSRCDIR)  [file join $path tcl]
set fout [open [file join $PWD wrap.tcl] w]
puts $::fout [list set ::KIT(EXEEXT) $::KIT(EXEEXT)]
puts $::fout [list package ifneeded zipfile::mkzip 1.2 [list source [file join $HERE scripts mkzip.tcl]]]
puts $::fout "if {!\[file exists tclkit_bare\$::KIT(EXEEXT)\]} \{[list exec \[info nameofexecutable\] [info script] >&@ stdout]}"
puts $fout {
proc ::copyDir {d1 d2} {
  file delete -force -- $d2
  file mkdir $d2
  set ::KIT(TKSRCDIR)   [file join $path tk]
  set ::KIT(PKGROOT)    [file join $path pkg]
  set ::KIT(BASEVFS)    [file join $path vfs]
  if {[file exists $::KIT(TCLSRCDIR)]} {
    break
  }
}


###
# Sort out our various build products
###
set _TclSrcDir [file join $::KIT(TCLSRCDIR) $::KIT(platform_src_dir)]
set _TkSrcDir  [file join $::KIT(TKSRCDIR) $::KIT(platform_src_dir)]

set ::TARGET(tclConfig.sh) [file join $_TclSrcDir tclConfig.sh]
set ::TARGET(tkConfig.sh)  [file join $_TkSrcDir tkConfig.sh]
set ::TARGET(libtoadkit.a) [file join $PWD libtoadkit.a]
set ::TARGET(tclkit_bare)  [file join $PWD tclkit_bare$::KIT(EXEEXT)]
set ::TARGET(toadkit.rc)   [file join $PWD toadkit.rc]

  foreach ftail [glob -directory $d1 -nocomplain -tails *] {
    set f [file join $d1 $ftail]
    if {[file isdirectory $f] && [string compare CVS $ftail]} {
      copyDir $f [file join $d2 $ftail]
    } elseif {[file isfile $f]} {

if {![file exists $::TARGET(tclkit_bare)]} {
  set build(tclkit_bare) 1
}
if {![file exists $::TARGET(tclConfig.sh)]} {
  set build(tcl) 1
  set build(tk) 1
}
if {![file exists $::TARGET(tkConfig.sh)]} {
      file copy -force $f [file join $d2 $ftail]
    }
  }
  set build(tk) 1
}
if {![file exists $::TARGET(libtoadkit.a)]} {
  set build(libtoadkit.a) 1
}
if {![file exists $::KIT(PKGROOT)]} {
  set build(packages) 1
}
if {![file exists $::KIT(BASEVFS)]} {
  set build(basekitvfs) 1
    
set name [lindex $argv 0]
set path [lindex $argv 1]
file copy -force tclkit_bare$::KIT(EXEEXT) toadkit$::KIT(EXEEXT) 
}
if {$build(tcl) || $build(tk) || $build(toadkit)} {
  set build(packages) 1
  set build(basekitvfs) 1
  set build(toadkit.rc) 1
  set build(tclkit_bare) 1
package require zipfile::mkzip
copyDir tclkit.vfs/boot $HERE/boot
copyDir tclkit.vfs/lib $HERE/lib

::zipfile::mkzip::mkzip ${name}$::KIT(EXEEXT) -runtime tclkit_bare$::KIT(EXEEXT) -directory $HERE
}
close $fout


puts "BUILDING ZipVFS KITS"
  set build(libtoadkit.a) 1
}
if {$build(libtoadkit.a)} {
  set build(tclkit_bare) 1
}
if {$build(packages)} {
  set build(basekitvfs) 1
}
if {![file exists $::TARGET(toadkit.rc)]} {
  set build(toadkit.rc) 1
}
file mkdir build


puts "***
::KIT(TCLSRCDIR):  [file exists $::KIT(TCLSRCDIR)] $::KIT(TCLSRCDIR)
::KIT(TKSRCDIR):   [file exists $::KIT(TKSRCDIR)] $::KIT(TKSRCDIR)
::KIT(PKGROOT):    [file exists $::KIT(PKGROOT)] $::KIT(PKGROOT)
::KIT(BASEVFS):    [file exists $::KIT(BASEVFS)] $::KIT(BASEVFS)
toadkit.rc:      [file exists $::TARGET(toadkit.rc)] $::TARGET(toadkit.rc)
***"
parray build

if {$COMMAND eq "clean"} {
  file delete -force $path
  file delete -force build/
  foreach file [glob -nocomplain *.a] {
    file delete $file
  }
  exit
}

if {![file exists tclkit_bare$::KIT(EXEEXT)]} {
if {$build(tcl)} {
  file mkdir build
  file mkdir tclkit.vfs/boot
  if {![file exists [file join $PWD tcl]]} {
    copyDir $::odie_tcl(src_dir) [file join $PWD tcl]
    cd [file join $PWD tcl $::odie(tcl_src_dir)]
  file mkdir [file join $::KIT(BASEVFS) boot]
  ###
  # Build a starter VFS for both Tcl and wish
  ###
  if {![file exists $::KIT(TCLSRCDIR)]} {
    copyDir $::KIT(ORIG_TCL_SRC_DIR) $::KIT(TCLSRCDIR)
    cd $_TclSrcDir
    catch {domake distclean}
  }
  if {$USEMSVC} {
    puts "BUILDING Static Tcl"
    cd $_TclSrcDir
    doexec nmake -f makefile.vc INSTALLDIR=$::KIT(PKGROOT) release
    doexec nmake -f makefile.vc INSTALLDIR=$::KIT(PKGROOT) install
  set tclConfig.sh [file join $PWD tcl $::odie(tcl_src_dir) tclConfig.sh]
  if {![file exists ${tclConfig.sh}]} {
    cd [file join $PWD tcl $::odie(tcl_src_dir)]
    set opts {}
    if {$::odie(host) != $::odie(target)} {
      lappend opts --host=$::odie(target)
    }
    lappend opts {*}$::odie(tcl_config_flags) --with-tzdata --enable-shared=no
    doexec sh configure {*}$opts
    domake binaries
    domake packages
    cd $PWD
  }

  if {![file exists [file join $PWD tk]]} {
    copyDir $::odie_tk(src_dir) [file join $PWD tk]
    cd [file join $PWD tk $::odie(tcl_src_dir)]
    cd $PWD
  } else {
    if {![file exists $::TARGET(tclConfig.sh)]} {
      puts "BUILDING Static Tcl"
      cd $_TclSrcDir
      set opts {}
      if {$::KIT(HOST) != $::KIT(TARGET)} {
        lappend opts --host=$::KIT(TARGET)
      }
      lappend opts {*}$::KIT(TCL_BUILD_OPTS) --prefix=$::KIT(PKGPREFIX) --exec_prefix=$::KIT(PKGPREFIX) --with-tzdata --enable-shared=no
      puts ***
      puts "CONFIGURE {*}opts"
      puts ***
      doexec sh configure {*}$opts
      domake binaries
      domake packages
      cd $PWD
    }
  }
}
if {$build(tk)} {
  if {![file exists $::KIT(TKSRCDIR)]} {
    copyDir $::KIT(ORIG_TK_SRC_DIR) $::KIT(TKSRCDIR)
    cd [file join $_TkSrcDir]
    catch {domake distclean}
  }

  set tkConfig.sh  [file join $PWD tk $::odie(tcl_src_dir) tkConfig.sh]
  if {![file exists ${tkConfig.sh}]} {
    set opts {}
    cd [file join $PWD tk $::odie(tcl_src_dir)]
    if {$::odie(host) != $::odie(target)} {
      lappend opts --host=$::odie(target)
    }
    lappend opts {*}$::odie(tk_config_flags) --with-tcl=[file join $PWD tcl $::odie(tcl_src_dir)] --enable-shared=yes
    doexec sh configure {*}$opts
    domake binaries
  if {$USEMSVC} {
    cd $_TkSrcDir
    puts "BUILD TK"
    doexec nmake -f makefile.vc TCLDIR=[file nativename $::KIT(TCLSRCDIR)] INSTALLDIR=$::KIT(PKGROOT) release
    doexec nmake -f makefile.vc TCLDIR=[file nativename $::KIT(TCLSRCDIR)] INSTALLDIR=$::KIT(PKGROOT) install
    cd $PWD
  } else {
    if {![file exists $::TARGET(tkConfig.sh)]} {
      puts "BUILD TK"
      set opts {}
      cd $_TkSrcDir
      if {$::KIT(HOST) != $::KIT(TARGET)} {
        lappend opts --host=$::KIT(TARGET)
      }
      lappend opts {*}$::KIT(TK_BUILD_OPTS) --with-tcl=$_TclSrcDir --enable-shared=yes
      puts ***
      puts "CONFIGURE {*}opts"
      puts ***
      doexec sh configure {*}$opts
      domake binaries
    if { $::odie(platform) eq "windows" } {
      domake tk.res.o
      domake wish.res.o
    }
    cd $PWD
  }

      cd $PWD
    }
  }
}

if {$build(toadkit.rc)} {
  set ::KIT(OBJS) {}
  set ::KIT(INCLUDES) {}
  
  ###
  # Read tclConfig.sh and tkConfig.sh
  ###
  foreach {array pre file} [list ::TCL tcl ${tclConfig.sh} ::TK tk ${tkConfig.sh}] {
  foreach {array pre file} [list ::TCL tcl $::TARGET(tclConfig.sh) ::TK tk $::TARGET(tkConfig.sh)] {
    set l [expr {[string length $pre]+1}]
    foreach {field dat} [read_Config.sh $file] {
      set field [string tolower $field]
      if {[string match ${pre}_* $field]} {
        set field [string range $field $l end]
      }
      set ${array}($field) $dat
      if {[info exists ::KIT($field)]} {
        if {$::KIT($field) ne $dat} {
          unset ::KIT($field)
        }
      } else {
        set ::KIT($field) $dat
      }
    }
  }

  ###
  # Add/synthesize bits
  ###
  lappend ::KIT(INCLUDES) [file join $PWD tk generic]
  lappend ::KIT(INCLUDES) [file join $PWD tk $::odie(tcl_src_dir)]
  lappend ::KIT(INCLUDES) [file join $PWD tk bitmaps]
  lappend ::KIT(INCLUDES) [file join $PWD tk xlib]
  lappend ::KIT(INCLUDES) [file join $::KIT(TKSRCDIR) generic]
  lappend ::KIT(INCLUDES) [file join $::KIT(TKSRCDIR) $::KIT(platform_src_dir)]
  lappend ::KIT(INCLUDES) [file join $::KIT(TKSRCDIR) bitmaps]
  lappend ::KIT(INCLUDES) [file join $::KIT(TKSRCDIR) xlib]
  
  lappend ::KIT(INCLUDES) [file join $PWD tcl generic]
  lappend ::KIT(INCLUDES) [file join $PWD tcl $::odie(tcl_src_dir)]
  #lappend ::KIT(INCLUDES) [file join $PWD tcl compat]
  lappend ::KIT(INCLUDES) [file join $PWD tcl compat zlib]
  lappend ::KIT(INCLUDES) [file join $::KIT(TCLSRCDIR) generic]
  lappend ::KIT(INCLUDES) [file join $::KIT(TCLSRCDIR) $::KIT(platform_src_dir)]
  #lappend ::KIT(INCLUDES) [file join $$::KIT(TCLSRCDIR) compat]
  lappend ::KIT(INCLUDES) [file join $::KIT(TCLSRCDIR) compat zlib]
  
  lappend ::KIT(INCLUDES) [file join $HERE generic]
  lappend ::KIT(INCLUDES) [file join $HERE $::odie(tcl_src_dir)]
  lappend ::KIT(INCLUDES) [file join $::HERE generic]
  lappend ::KIT(INCLUDES) [file join $::HERE $::KIT(platform_src_dir)]
  
  if { $::odie(platform) eq "windows" } {
  if { $::KIT(platform) eq "windows" } {
    set ::KIT(EXEEXT) .exe
    set ::KIT(LDFLAGS_CONSOLE) {-mconsole -pipe -static-libgcc}
    set ::KIT(LDFLAGS_WINDOW) {-mwindows -pipe -static-libgcc}
    set ::KIT(EXTRA_CFLAGS) {-DTCL_TOMMATH -DMP_PREC=4 -DUNICODE -D_UNICODE -DBUILD_tcl -DBUILD_tk -DBUILD_ttk}
    lappend ::KIT(OBJS) [file join $PWD tk $::odie(tcl_src_dir) tk.res.o] [file join $PWD tk $::odie(tcl_src_dir) wish.res.o] 
    lappend ::KIT(INCLUDES) [file join $PWD tk $::odie(tcl_src_dir) rc]
    set ::KIT(EXTRA_CFLAGS) {-DTCL_TOMMATH -DMP_PREC=4 -DUNICODE -D_UNICODE -DBUILD_tcl -DBUILD_tk -DBUILD_ttk -DSTATIC_BUILD}

    if {[file exists [file join $PWD tclkit.rc]]} {
      set RCSRC [file join $PWD tclkit.rc]
    } else {
      set RCSRC [file join $_TkSrcDir rc wish.rc]
    }
    doexec windres -o [file join $PWD tclkit.res.o] -DSTATIC_BUILD \
      --include [file join $::KIT(TCLSRCDIR) generic] --include [file join $::KIT(TKSRCDIR) generic] \
      --include $_TkSrcDir \
      --include [file join $_TkSrcDir rc] $RCSRC

    lappend ::KIT(TCLSHELL_OBJS) [file join $PWD tclkit.res.o] 
    lappend ::KIT(WISHSHELL_OBJS) [file join $PWD tclkit.res.o]
    lappend ::KIT(INCLUDES) [file join $_TkSrcDir rc]
  } else {
    set ::KIT(EXEEXT) {}
    set ::KIT(LDFLAGS_CONSOLE) {}
    set ::KIT(LDFLAGS_WINDOW) {}
    set ::KIT(EXTRA_CFLAGS) {-DTCL_TOMMATH -DMP_PREC=4 -DBUILD_tk -DBUILD_ttk}
  }

  set ::KIT(LIBS) {}
  #lappend ::KIT(LIBS) {*}$::TCL(build_lib_spec) {*}$::TCL(build_stub_lib_spec) {*}$::TCL(libs)
  #{*}$::TK(build_lib_spec) {*}$::TCL(build_stub_lib_spec)
  #{*}$::TCL(build_stub_lib_spec) {*}$::TK(build_stub_lib_spec)
  set ::KIT(defs) $::TK(defs)
  
  set fout [open toadkit.rc w]
  set fout [open $::TARGET(toadkit.rc) w]
  puts $fout "array set ::TCL \{"
  foreach {field value} [lsort -stride 2 [array get ::TCL]] {
    puts $fout "  [list $field $value]"
  }
  puts $fout "\}"
  puts $fout "array set ::TK \{"
  foreach {field value} [lsort -stride 2 [array get ::TK]] {
    puts $fout "  [list $field $value]"
  }
  puts $fout "\}"
  puts $fout "array set ::TARGET \{"
  foreach {field value} [lsort -stride 2 [array get ::TARGET]] {
    puts $fout "  [list $field $value]"
  }
  puts $fout "\}"
  puts $fout "array set ::KIT \{"
  foreach {field value} [lsort -stride 2 [array get ::KIT]] {
    puts $fout "  [list $field $value]"
  }
  puts $fout "\}"
  close $fout
} else {
  source $::TARGET(toadkit.rc)
  
}


if {$build(libtoadkit.a)} {
  ###
  # Compile our C bits
  # Compile our resident static C library
  ###
  
  
  cd $PWD
  if {[file exists $::TARGET(libtoadkit.a)]} {
    file delete $::TARGET(libtoadkit.a)
  }
  ###
  # Rig ourselves to statically build the bits of
  # zlib we need
  ###
  set cdir [file join $PWD tcl compat zlib]
  set cdir [file join $::KIT(TCLSRCDIR) compat zlib]
  foreach file {
    adler32.c compress.c crc32.c
    deflate.c infback.c inffast.c
    inflate.c inftrees.c trees.c
    uncompr.c zutil.c
  } {
    COMPILE LIBTOADKIT [file join $cdir $file]
  }
  
  set cdir [file join $HERE generic]
  set cdir [file join $::HERE generic]
  foreach file {
    password.c rc4.c tclkit_init.c zvfs.c zvfsboot.c
  } {
    COMPILE LIBTOADKIT [file join $cdir $file]
  }
  
  set cdir [file join $HERE $::odie(tcl_src_dir)]
  if { $::odie(platform) eq "windows" } {
  set cdir [file join $::HERE $::KIT(platform_src_dir)]
  if { $::KIT(platform) eq "windows" } {
    # tkwinico.c tlink32.c
    foreach file {
      tclsh_packages.c
    } {
      COMPILE LIBTOADKIT [file join $cdir $file]
    }
    #COMPILE LIBTOADKIT [file join $PWD tcl win tclWinReg.c] [list -DSTATIC_BUILD]
    #COMPILE LIBTOADKIT [file join $PWD tcl win tclWinDde.c] [list -DSTATIC_BUILD]
  
    COMPILE TCLSHELL [file join $PWD tcl win tclAppInit.c] [list -DTCL_LOCAL_MAIN_HOOK=Toadkit_MainHook -DTCL_LOCAL_APPINIT=Toadkit_AppInit]
    COMPILE WISHSHELL [file join $PWD tk win winMain.c] [list -DTK_LOCAL_MAIN_HOOK=Toadkit_MainHook -DTK_LOCAL_APPINIT=Toadkit_AppInit]
    COMPILE TCLSHELL [file join $_TclSrcDir tclAppInit.c] [list -DTCL_LOCAL_MAIN_HOOK=Toadkit_MainHook -DTCL_LOCAL_APPINIT=Toadkit_AppInit]
    COMPILE WISHSHELL [file join $_TkSrcDir winMain.c] [list -DTK_LOCAL_MAIN_HOOK=Toadkit_MainHook -DTK_LOCAL_APPINIT=Toadkit_AppInit]
    lappend ::KIT(LIBTOADKIT_OBJS) [file join $_TclSrcDir libtclstub86.a]
  } else {
    foreach file {
      tclsh_packages.c
    } {
      COMPILE LIBTOADKIT [file join $cdir $file]
    }
    COMPILE TCLSHELL [file join $PWD tcl unix tclAppInit.c] [list -DTCL_LOCAL_MAIN_HOOK=Toadkit_MainHook -DTCL_LOCAL_APPINIT=Toadkit_AppInit]
    COMPILE WISHSHELL [file join $PWD tk unix tclAppInit.c] [list -DTK_LOCAL_MAIN_HOOK=Toadkit_MainHook -DTK_LOCAL_APPINIT=Toadkit_AppInit]
    COMPILE TCLSHELL [file join $_TclSrcDir tclAppInit.c] [list -DTCL_LOCAL_MAIN_HOOK=Toadkit_MainHook -DTCL_LOCAL_APPINIT=Toadkit_AppInit]
    COMPILE WISHSHELL [file join $_TkSrcDir tkAppInit.c] [list -DTK_LOCAL_MAIN_HOOK=Toadkit_MainHook -DTK_LOCAL_APPINIT=Toadkit_AppInit]
  }
  
  
    lappend ::KIT(LIBTOADKIT_OBJS) [file join $_TclSrcDir libtclstub8.6.a]
  }
  ###
  # Link together our executable
  ###
  doexec ar cr libtoadkit.a {*}$::KIT(LIBTOADKIT_OBJS) [file join tcl  $::odie(tcl_src_dir) libtclstub86.a]
  doexec ranlib libtoadkit.a
  
  doexec ar cr $::TARGET(libtoadkit.a) {*}$::KIT(LIBTOADKIT_OBJS)
  doexec ranlib $::TARGET(libtoadkit.a)
}
  # Build a Tcl-only shell
  set cmd [list $::KIT(cc)  {*}$::KIT(cflags_optimize) {*}$::KIT(shlib_cflags)]
  lappend cmd {*}$::KIT(TCLSHELL_OBJS)
  set _TclSrcDir [file join tcl  $::odie(tcl_src_dir)]
  foreach item [glob ${_TclSrcDir}/*.a] {
    lappend cmd $item
  }

  lappend cmd libtoadkit.a {*}$::TCL(libs)
  lappend cmd -o tclkit_bare$::KIT(EXEEXT) {*}$::KIT(LDFLAGS_CONSOLE)
  doexec {*}$cmd
  
if {$build(packages)} {
  cd $PWD
  ###
  # Build a starter VFS for both Tcl and wish
  ###
  set VFSROOT [file join $PWD tclkit.vfs]
  set PKGROOT [file join $PWD tclkit.pkg]

  foreach path [glob [file join $PWD tcl pkgs *]] {
    if {[string range [file tail $HERE] 0 3] eq "itcl"} continue
    if {![file isdirectory $HERE]} continue
    cd $HERE
  if {[file exists $::KIT(PKGROOT)]} {
    file delete -force $::KIT(PKGROOT)
  }
  set pkg_paths [glob [file join $::KIT(TCLSRCDIR) pkgs *]]
  foreach pkgpath $pkg_paths {
    if {[string range [file tail $pkgpath] 0 3] eq "itcl"} continue
    if {![file isdirectory $pkgpath]} continue
    cd $pkgpath
    puts "$HERE"
    if {![file exists $HERE/Makefile]} {
      if {[file exists $HERE/Makefile.in]} {
        doexec sh configure --with-tcl=$PWD/tcl/$::odie(tcl_src_dir) --with-tclinclude=$PWD/tcl/generic --with-tzdata --enable-shared --enable-threads
    if {![file exists [file join $pkgpath Makefile]]} {
      if {[file exists [file join $pkgpath Makefile.in]]} {
        doexec sh configure --with-tcl=$_TclSrcDir --with-tclinclude=[file join $::KIT(TCLSRCDIR) generic] --with-tzdata --enable-shared --enable-threads
      } else {
        continue
      }
    }
    puts "INSTALLING to VFS [file tail $HERE]"
    domake install DESTDIR=$PKGROOT
    puts "INSTALLING to VFS [file tail $pkgpath]"
    domake install DESTDIR=$::KIT(PKGROOT)
  }
}

if {$build(tclkit_bare)} {
  cd $PWD
  # Build a Tcl-only shell
  set cmd [list $::KIT(cc)  {*}$::KIT(cflags_optimize) {*}$::KIT(shlib_cflags)]
  lappend cmd {*}$::KIT(TCLSHELL_OBJS)
  foreach item [glob ${_TclSrcDir}/*.a] {
    lappend cmd $item

  if {[file exists $VFSROOT]} {
    file delete -force $VFSROOT
  }
  lappend cmd $::TARGET(libtoadkit.a) {*}$::TCL(libs)
  lappend cmd -o $::TARGET(tclkit_bare) {*}$::KIT(LDFLAGS_CONSOLE)
  doexec {*}$cmd
}
if {$build(basekitvfs)} {
  cd $PWD
  if {[file exists $::KIT(BASEVFS)]} {
    file delete -force $::KIT(BASEVFS)
  }
  copyDir $PKGROOT/usr/local/lib $VFSROOT/pkgs
  

  copyDir tcl/library $VFSROOT/boot/tcl
  if { $::odie(platform) eq "windows" } {
    set ddedll [glob -nocomplain tcl/win/tcldde*.dll]
  puts "***
*** BASE KIT VFS PACKAGES
***"
  puts [list COPY [file join $::KIT(PKGROOT) [string trimleft $::KIT(PKGPREFIX) /] lib]]
  copyDir [file join $::KIT(PKGROOT) [string trimleft $::KIT(PKGPREFIX) /] lib] [file join $::KIT(BASEVFS) pkgs]
  
  copyDir [file join $::KIT(TCLSRCDIR) library] [file join $::KIT(BASEVFS) boot tcl]
  if { $::KIT(platform) eq "windows" } {
    set ddedll [glob -nocomplain [file join $_TclSrcDir tcldde*.dll]]
    if {$ddedll != {}} {
      file copy $ddedll $VFSROOT/boot/tcl/dde
      file copy $ddedll [file join $::KIT(BASEVFS) boot tcl dde]
    }
    set regdll [glob -nocomplain tcl/win/tclreg*.dll]
    set regdll [glob -nocomplain [file join $_TclSrcDir tclreg*.dll]]
    if {$regdll != {}} {
      file copy $regdll $VFSROOT/boot/tcl/reg
      file copy $regdll [file join $::KIT(BASEVFS) boot tcl reg]
    }
  } else {
    file delete -force $VFSROOT/boot/tcl/dde
    file delete -force $VFSROOT/boot/tcl/reg
    file delete -force [file join $::KIT(BASEVFS) boot tcl dde]
    file delete -force [file join $::KIT(BASEVFS) boot tcl reg]
  }
  
  # For the following packages, cat their pkgIndex files to tclIndex
  if {$::tcl_platform(platform) eq {unix}} {
      file attributes [file join $VFSROOT boot tcl tclIndex] -permissions 0744
  copyDir [file join $::KIT(TKSRCDIR) library] $::KIT(BASEVFS)/boot/tk
  if { $::KIT(platform) eq "windows" } {
    set dllsrc [file join $_TkSrcDir [string trim $::TK(dll_file) \"]]
  } else {
      file attributes [file join $VFSROOT boot tcl tclIndex] -readonly 0
    set dllsrc [file join $_TkSrcDir [string trim $::TK(lib_file) \"]]
  }

  set fout [open [file join $VFSROOT boot tcl tclIndex] a]
  file copy -force $dllsrc [file join $::KIT(BASEVFS) boot tk]
  set fout [open [file join $::KIT(BASEVFS) boot tk pkgIndex.tcl] w]
  puts $fout {#
# MANIFEST OF INCLUDED PACKAGES
#
set VFSROOT $dir
}
  pkgIndexDir tcl/library $fout [file join $VFSROOT boot tcl]
  close $fout

  set map [list @TKVERSION@ $::TK(version)$::TK(patch_level)]
  copyDir tk/library $VFSROOT/boot/tk
  if { $::odie(platform) eq "windows" } {
    set dllsrc tk/win/[string trim $::TK(dll_file) \"]
  if { $::KIT(platform) eq "windows" } {
    lappend map @TKDLL@ [string trim $::TK(dll_file) \"]
  } else {
    set dllsrc tk/unix/[string trim $::TK(dll_file) \"]
    lappend map @TKDLL@ [string trim $::TK(lib_file) \"]
  }
  file copy -force $dllsrc [file join $VFSROOT BOOT tk]
  set fout [open [file join $VFSROOT BOOT tcl tclIndex] a]
  puts $fout [string map [list @TKVERSION@ $::TK(version)$::TK(patch_level) @TKDLL@ [string trim $::TK(dll_file) \"]] {
  puts $fout [string map $map {
package ifneeded Tk @TKVERSION@ [list load $::tk_library/@TKDLL@ Tk]
  }]
  close $fout
}
cd $PWD

if {[lindex $argv 0] eq "toadkit"} {
  file copy -force tclkit_bare$::KIT(EXEEXT) toadkit$::KIT(EXEEXT) 
if {$COMMAND eq "toadkit"} {
  ::practcl::wrap $::PWD toadkit toadkit-vfs
  puts [list AUTOPATH $::auto_path]
  package ifneeded zipfile::mkzip 1.2 [list source [file join $HERE mkzip.tcl]]
  package require zipfile::mkzip
  #file copy -force [file join $HERE default_tclsh.tcl] tclkit.vfs/main.tcl
  ::zipfile::mkzip::mkzip toadkit$::KIT(EXEEXT) -runtime tclkit_bare$::KIT(EXEEXT) -directory tclkit.vfs
}

if {[lindex $argv 0] eq "wrap"} {
  set name [lindex $argv 1]
if {$COMMAND eq "wrap"} {
  puts "WRAP {*}[lrange $argv 1 end]"
  set path [lindex $argv 2]
  file copy -force tclkit_bare$::KIT(EXEEXT) toadkit$::KIT(EXEEXT) 
  puts [list AUTOPATH $::auto_path]
  ::practcl::wrap $::PWD {*}[lrange $argv 1 end]
  package ifneeded zipfile::mkzip 1.2 [list source [file join $HERE mkzip.tcl]]
  package require zipfile::mkzip
  copyDir tclkit.vfs/boot $HERE/boot
  copyDir tclkit.vfs/lib $HERE/lib
  ::zipfile::mkzip::mkzip ${name}$::KIT(EXEEXT) -runtime tclkit_bare$::KIT(EXEEXT) -directory $HERE
}
Changes to generic/rc4.c.
100
101
102
103
104
105
106

107


108
109
110
111
112
113
114
100
101
102
103
104
105
106
107

108
109
110
111
112
113
114
115
116







+
-
+
+







  return TCL_OK;
}

/*
** Destructor for codec.
*/
static void CodecDestructor(void *pCodec){
  printf("CODE DESTRUCTOR (shell)\n");
  Tcl_Free(pCodec);
  Tcl_Free((char *)pCodec);
  printf("/CODE DESTRUCTOR (shell)\n");
}

/*
** Usage:   rc4  NAME  PASSWORD
**
** Create a new rc4 codec called NAME and initialized using PASSWORD.
*/
482
483
484
485
486
487
488





489
490
491
492
493
494
495
496
497
498
499
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506







+
+
+
+
+











  return code;
}

/*
** Initialize the rc4 codec subsystem.
*/
DLLEXPORT int Rc4_Init(Tcl_Interp *interp){
  #ifdef USE_TCL_STUBS
  if (Tcl_InitStubs(interp, "8.5", 0)==NULL) {
    return TCL_ERROR;
  }
  #endif
  Tcl_CreateObjCommand(interp, "rc4", Rc4ObjCmd, 0, 0);
  Tcl_CreateObjCommand(interp, "rc4seed", Rc4SeedObjCmd, 0, 0);
  Tcl_CreateObjCommand(interp, "rc4encrypt", Rc4EncryptObjCmd, 0, 0);
  Tcl_CreateObjCommand(interp, "rc4decrypt", Rc4DecryptObjCmd, 0, 0);
  Tcl_CreateObjCommand(interp, "source_encrypt", Rc4EncryptSourceObjCmd, 0, 0);
  //Tcl_CreateObjCommand(interp, "source_decrypt", Rc4DecryptSourceObjCmd, 0, 0);
  Tcl_CreateObjCommand(interp, "eval_decrypt", Rc4DecryptEvalObjCmd, 0, 0);
  Tcl_StaticPackage(interp, "rc4", "2.0", 0);

  return TCL_OK;
}
Changes to generic/zvfsboot.c.
61
62
63
64
65
66
67

68
69
70
71
72





73

74
75
76
77
78
79
80
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

79
80
81
82
83
84
85
86







+





+
+
+
+
+
-
+







      Tcl_DStringAppendElement(&preinit,vfsmountpoint);
      Tcl_DStringAppend(&preinit,"\nset ::SRCDIR ",-1);
      Tcl_DStringAppendElement(&preinit,vfsmountpoint);
      
      if(Tcl_FSAccess(vfstcllib,F_OK)==0) {
        Tcl_DStringAppend(&preinit,"\nset tcl_library ",-1);
        Tcl_DStringAppendElement(&preinit,Tcl_GetString(vfstcllib));
        Tcl_DStringAppend(&preinit,"\nset auto_path {}",-1);
      }
      if(Tcl_FSAccess(vfstklib,F_OK)==0) {
        Tcl_DStringAppend(&preinit,"\nset tk_library ",-1);
        Tcl_DStringAppendElement(&preinit,Tcl_GetString(vfstklib));
      }
      Tcl_DStringAppend(&preinit,"\nif {[file exists [file join $::SRCDIR packages.tcl]]} \{",-1);
      Tcl_DStringAppend(&preinit,"\n  #In a wrapped exe, we don't go out to the environment",-1);
      Tcl_DStringAppend(&preinit,"\n  set auto_path {}",-1);
      Tcl_DStringAppend(&preinit,"\n  set dir $::SRCDIR",-1);
      Tcl_DStringAppend(&preinit,"\n  source [file join $::SRCDIR packages.tcl]",-1);
      Tcl_DStringAppend(&preinit,"\nlappend ::auto_path [file join $::SRCDIR pkgs]",-1);
      Tcl_DStringAppend(&preinit,"\n\}",-1);
      
      vfspreinit=Tcl_NewStringObj(Tcl_DStringValue(&preinit),-1);
      /* NOTE: We never decr this refcount, lest the contents of the script be deallocated */
      Tcl_IncrRefCount(vfspreinit);
      TclSetPreInitScript(Tcl_GetString(vfspreinit));

      Tcl_DecrRefCount(vfsinitscript);
Changes to odieConfig.sh.in.
74
75
76
77
78
79
80
81



82
83
84
85
86
87
74
75
76
77
78
79
80

81
82
83
84
85
86
87
88
89







-
+
+
+






MKHDR=@MKHDR_PROG@
ZIP=@ZIP_PROG@
UNZIP=@UNZIP_PROG@

ODIE_RM=${ODIE_BUILD_TCLSH}
ODIE_RM+=${ODIE_SRC_DIR}/scripts/rmdir.tcl
SHERPA=${ODIE_BUILD_TCLSH}
SHERPA+=@ODIE_SANDBOX_PATH@/sherpa/sherpa.tcl
SHERPA+=@ODIE_SANDBOX_PATH@/gort/gort.tcl
GORT=${ODIE_BUILD_TCLSH}
GORT+=@ODIE_SANDBOX_PATH@/gort/gort.tcl
KETTLE=${ODIE_BUILD_TCLSH}
KETTLE+=${exec_prefix}/bin/kettle

###
# Bits generated by autosetup
###
Changes to odieConfig.tcl.in.
65
66
67
68
69
70
71

72

73
74
75
76
77
78
79
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
80







+
-
+







  fossil       "@FOSSIL_PROG@"
  tcl_shell    "@TCLSH_PROG@"
  wish_shell   "@WISH_PROG@"
  zzetup       "${exec_prefix}/bin/zzipsetupstub@EXEEXT@"
  wish_kit     "@TKKIT_PROG@"
  tcl_kit      "@TCLKIT_PROG@"
  toad_kit     "@TOADKIT_PROG@"
  gort         "@ODIE_BUILD_TCLSH@ @ODIE_SANDBOX_PATH@/gort/gort.tcl"
  sherpa       "@ODIE_BUILD_TCLSH@ @ODIE_SANDBOX_PATH@/sherpa/sherpa.tcl"
  sherpa       "@ODIE_BUILD_TCLSH@ @ODIE_SANDBOX_PATH@/gort/gort.tcl"
  kettle       "${exec_prefix}/bin/kettle"
  zip_kit      "${exec_prefix}/bin/zipkit.zip"
  lib          "$prefix/lib"
  rc           "@RC@"
  res          "@RES@"
  tk_res       "@TK_RES@"
  vfs_cp       "@VFS_CP@"
Changes to scripts/common.tcl.
27
28
29
30
31
32
33
34

35
36

37
38
39
40
41
42
43
27
28
29
30
31
32
33

34
35

36
37
38
39
40
41
42
43







-
+

-
+







  core.tcl formatting.tcl getopt.tcl misc.tcl
} {
  source [file join $::autosetup(libdir) $file]
}

proc ::noop args {}

namespace eval ::sherpa_bootstrap {}
namespace eval ::gort_bootstrap {}

proc ::sherpa_bootstrap::download_fossil {pkg} {
proc ::gort_bootstrap::download_fossil {pkg} {
  variable distribution
  set PKG_SRCPATH [sandbox_path $pkg]
  set fosdb [fossil_db $pkg]
  if {![file exists $fosdb]} {
    puts "Fossil clone $pkg"
    set fossil_url {}
    if {[dict exists $distribution $pkg fossil_url]} {
60
61
62
63
64
65
66
67

68
69
70
71
72
73
74
75

76
77
78
79

80
81
82
83
84
85
86
60
61
62
63
64
65
66

67
68
69
70
71
72
73
74

75
76
77
78

79
80
81
82
83
84
85
86







-
+







-
+



-
+







      doexec $::odie(fossil) update [dict get $distribution $pkg fossil_branch]
  } else {
      doexec $::odie(fossil) update
  }
  return ${PKG_SRCPATH}
}

proc ::sherpa_bootstrap::fossil_db pkg {
proc ::gort_bootstrap::fossil_db pkg {
  if {[file exists [file join $::odie(download) $pkg.fossil]]} {
    return [file join $::odie(download) $pkg.fossil]
  }
  return [file join $::odie(download) $pkg.fos]
}


proc ::sherpa_bootstrap::sandbox_path pkg {
proc ::gort_bootstrap::sandbox_path pkg {
  return [file join $::odie(sandbox) $pkg]
}

proc ::sherpa_bootstrap::build_gnumake {pkg action} {
proc ::gort_bootstrap::build_gnumake {pkg action} {
  puts "BUILD GNUMAKE $pkg $action"
  if {$action eq "install"} {
    set PKG_SRCPATH [sandbox_path $pkg]
    cd ${PKG_SRCPATH}
    doexec $::odie(fossil) update
    set args [list  --prefix=$::odie(local_repo)]
    if {$::odie(host) != $::odie(target)} {
106
107
108
109
110
111
112
113

114
115
116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131
132

133
134
135
136
137
138
139
106
107
108
109
110
111
112

113
114
115
116
117
118
119
120
121
122

123
124
125
126
127
128
129
130
131

132
133
134
135
136
137
138
139







-
+









-
+








-
+







    } err] {
	puts "Died on $err"
	exit 1
    }
  }
}

proc ::sherpa_bootstrap::build_sak {pkg action} {
proc ::gort_bootstrap::build_sak {pkg action} {
  if {$action eq "install"} {
    set PKG_SRCPATH [sandbox_path $pkg]
    doexec $::odie(build_tclsh) [file join $PKG_SRCPATH installer.tcl] \
		-app-path $::odie(prefix)/bin -pkg-path $::odie(prefix)/lib/$pkg \
                -no-examples -no-nroff -no-html \
                -no-wait -no-gui
  }
}

proc ::sherpa_bootstrap::build_kettle {pkg action} {
proc ::gort_bootstrap::build_kettle {pkg action} {
  set PKG_SRCPATH [sandbox_path $pkg]
  if {$pkg eq "kettle"} {
    doexec $::odie(build_tclsh) [file join $PKG_SRCPATH kettle] -f [file join $PKG_SRCPATH build.tcl] $action
  } else {
    doexec $::odie(build_tclsh) $::odie(kettle) -f [file join $PKG_SRCPATH build.tcl] $action
  }
}

proc ::sherpa_bootstrap::build_sqlite {pkg action} {
proc ::gort_bootstrap::build_sqlite {pkg action} {
    ###
    # Sqlite
    ###
    puts "INSTALLING SQLITE"
    set SQLITE_VERSION 3.8.7.2
    set SQLITE_TFNAME sqlite-autoconf-3080704
    set SQLITE_SRCPATH $::odie(sandbox)/sqlite
154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
169
170
171

172
173
174
175
176
177
178
179
180
181
182
183
184
185

186
187
188
189
190
191
192

193
194
195
196
197

198
199
200
201
202
203
204

205
206
207
208
209

210
211
212
213
214

215
216
217
218
219

220
221
222
223
224
225

226
227
228
229
230
231
232

233
234
235
236
237
238
239
240
241
242
243
244
245
246
247

248
249
250
251
252
253
254
255
256

257
258
259
260
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168
169
170

171
172
173
174
175
176
177
178
179
180
181
182
183
184

185
186
187
188
189
190
191

192
193
194
195
196

197
198
199
200
201
202
203

204
205
206
207
208

209
210
211
212
213

214
215
216
217
218

219
220
221
222
223
224

225
226
227
228
229
230
231

232
233
234
235
236
237
238
239
240
241
242
243
244
245
246

247
248
249
250
251
252
253
254
255

256
257
258
259
260







-
+









-
+













-
+






-
+




-
+






-
+




-
+




-
+




-
+





-
+






-
+














-
+








-
+




    cd ${SQLITE_SRCPATH}/tea
    if {![file exists ${SQLITE_SRCPATH}/tea/Makefile]} {
      doexec sh ./configure --prefix=[::cygpath $::odie(local_repo)] --libdir=[::cygpath $::odie(local_repo)/lib] --host=$::odie(host)
    }
    doexec make install
}

proc ::sherpa_bootstrap::install_package package {
proc ::gort_bootstrap::install_package package {
  variable distribution
  set pkginfo [dict get $distribution $package]
  puts [list $package $pkginfo]
  set download [dict get $pkginfo get_proc]
  $download $package
  set build    [dict get $pkginfo build_proc]
  $build $package install
}

proc ::sherpa_bootstrap::distribution {name properties} {
proc ::gort_bootstrap::distribution {name properties} {
  variable distribution
  foreach {field value} $properties {
    
    dict set distribution $name $field $value
  }
  if {![dict exists $distribution $name get_proc]} {
    dict set distribution $name get_proc ::noop
  }
  if {![dict exists $distribution $name build_proc]} {
    dict set distribution $name build_proc ::noop
  }
}

::sherpa_bootstrap::distribution sqlite {
::gort_bootstrap::distribution sqlite {
  get_proc   ::noop
  build_proc build_sqlite
  #build_proc ::noop
}

if {!$::odie(windows)} {
    ::sherpa_bootstrap::distribution tclx {
    ::gort_bootstrap::distribution tclx {
      get_proc   download_fossil
      build_proc build_gnumake
    }
if 0 {
    ::sherpa_bootstrap::distribution kettle {
    ::gort_bootstrap::distribution kettle {
      get_proc   download_fossil
      requires {tclx tcllib tklib}
      build_proc build_kettle
    }
}
}
::sherpa_bootstrap::distribution tclvfs {
::gort_bootstrap::distribution tclvfs {
  get_proc   download_fossil
  requires tcllib
  build_proc build_gnumake
}
::sherpa_bootstrap::distribution taolib {
::gort_bootstrap::distribution taolib {
  get_proc   download_fossil
  requires {sqlite tcllib tklib}
  build_proc build_sak
}
::sherpa_bootstrap::distribution tcllib {
::gort_bootstrap::distribution tcllib {
  get_proc   download_fossil
  fossil_branch odie
  build_proc build_sak
}
::sherpa_bootstrap::distribution tklib {
::gort_bootstrap::distribution tklib {
  get_proc   download_fossil
  requires tcllib
  build_proc build_sak
}

::sherpa_bootstrap::distribution odielib {
::gort_bootstrap::distribution odielib {
  get_proc   download_fossil
  fossil_branch autosetup
  requires {tcllib sqlite}
  build_proc build_gnumake
}

::sherpa_bootstrap::distribution sherpa {
::gort_bootstrap::distribution gort {
  get_proc   download_fossil
  fossil_branch trunk
  requires {tcllib odielib taolib sqlite}
  build_proc build_gnumake
}

proc ::doexec args {
  exec {*}$args >&@ stdout
}

###
# Make sure the odielib toolkit is downloaded
###
if {![file exists [file join $::odie(sandbox) odielib modules odie index.tcl]]} {
  ::sherpa_bootstrap::download_fossil odielib
  ::gort_bootstrap::download_fossil odielib
}
source [file join $path .. odielib modules odie index.tcl]
source [file join $path .. odielib modules cmdline cmdline.tcl]
source [file join $path .. odielib modules fileutil index.tcl]
source [file join $path .. odielib modules codebale index.tcl]



#::sherpa_bootstrap::distribution sherpa {
#::gort_bootstrap::distribution gort {
#  get_proc   download_fossil
#  requires {taolib tcllib odielib kettle}
#  build_proc build_kettle
#}
Added scripts/gort.tcl.

















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
# Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# vim:se syntax=tcl:
# \
dir=`dirname "$0"`; exec "`$dir/../autosetup/find-tclsh`" "$0" "$@"

###
# Micronized version of gort for bootstrapping Odie
###

set path [file normalize [file join [file dirname [file normalize [info script]]] ..]]
source [file join $path scripts common.tcl]

namespace eval ::command {}

proc ::command::help {} {
  foreach command [lsort -dictionary [info command ::command::*]] {
    puts " * [namespace tail $command]"
  }
}

proc ::command::package-list {} {
  foreach distro [lsort -dictionary [dict keys $::gort_bootstrap::distribution]] {
    puts " * $distro"
  }
}

proc ::command::install {package} {
  if {$package eq "all"} {
    install-all
    return
  }
  ::gort_bootstrap::install_package $package
}

proc ::command::install-all {} {
  set info $::gort_bootstrap::distribution
  set allpkgs [lsort -dictionary [dict keys $info]]
  set installed {}
  foreach item $allpkgs {
    if {[dict exists $info $item requires]} {
      set requires($item) [dict get $info $item requires]
    } else {
      set requires($item) {}
    }
  }

  for {set i 0} {$i < [llength $allpkgs]} {incr i} {
    foreach item $allpkgs {
      if { $item in $installed } continue
      set needs {}
      foreach req $requires($item) {
        if { $req ni $installed } {
          lappend needs $req
        }
      }
      if {[llength $needs]}  {
        puts [list $item needs $needs]
        continue
      }
      lappend installed $item
    }
  }
  foreach item $installed {
    puts "INSTALLING $item"
  }
  foreach item $installed {
    ::gort_bootstrap::install_package $item
  }  
}

set method [lindex $argv 0]
if { [info command ::command::$method] eq {} } {
  puts stderr "Invalid command: $method."
  ::command::help
  exit 1
}
::command::$method {*}[lrange $argv 1 end]
update
exit 0
Changes to scripts/make_distclean.sh.
10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
25
26
27
10
11
12
13
14
15
16

17



18
19
20
21
22
23
24







-
+
-
-
-







cd ${ODIE_SANDBOX_PATH}/tcl/${ODIE_TCL_PLATFORM_DIR} ; make distclean
cd ${ODIE_SANDBOX_PATH}/tk/${ODIE_TCL_PLATFORM_DIR} ; make distclean
cd ${ODIE_SANDBOX_PATH}/tcl-static/${ODIE_TCL_PLATFORM_DIR} ; make distclean
cd ${ODIE_SANDBOX_PATH}/tk-static/${ODIE_TCL_PLATFORM_DIR} ; make distclean
cd ${ODIE_SANDBOX_PATH}/sqlite/tea ; make distclean
cd ${ODIE_SANDBOX_PATH}/tclvfs ; make distclean
cd ${ODIE_SANDBOX_PATH}/tcllib ; make distclean
cd ${ODIE_SRC_DIR}/apps/sherpa ; make clean
cd ${ODIE_SRC_DIR} ; ${ODIE_BUILD_TCLSH} build.tcl clean
cd ${ODIE_SRC_DIR}/src/toadkit ; make clean
cd ${ODIE_SRC_DIR}/src/odielib ; make clean
cd ${ODIE_SRC_DIR}/src/odielib ; make distclean

find ${ODIE_SRC_DIR} -type d -iname "*.vfs" -exec rm {} \;

if [ ! -f "odieConfig.sh" ]; then
  rm odieConfig.sh
fi
if [ ! -f "odieConfig.tcl" ]; then
Added scripts/make_gort.tcl.
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
# Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# vim:se syntax=tcl:
# \
dir=`dirname "$0"`; exec "`$dir/../autosetup/find-tclsh`" "$0" "$@"

set path [file dirname [file normalize [info script]]]
proc ::doexec args {
  exec {*}$args >&@ stdout
}

source $path/../odieConfig.tcl

proc get_distro {pkg {tag trunk} {local_path {}}} {
  if {$local_path eq {}} {
    set local_path $pkg
  }
  set PKG_SRCPATH $::odie(sandbox)/$local_path
  if {![file exists $::odie(download)/$pkg.fos]} {
    puts "Fossil clone $pkg"
    doexec $::odie(fossil) clone $::odie(mirror_url)/$pkg $::odie(download)/$pkg.fos
  }

  if {![file exists ${PKG_SRCPATH}/$::odie(fossil_checkout)]} {
    puts "Fossil open $local_path"
    file mkdir ${PKG_SRCPATH}
    cd ${PKG_SRCPATH}
    doexec $::odie(fossil) open $::odie(download)/$pkg.fos
  }
  cd ${PKG_SRCPATH}
  doexec $::odie(fossil) update $tag
  return ${PKG_SRCPATH}
}

get_distro tcllib odie
get_distro gort trunk
get_distro gort sherpa sherpa

###
# Build supporting libraries needed by Gort
##
file mkdir $::odie(prefix)/bin
# Rebuild gort
set GORT_SRCPATH $::odie(src_dir)/../gort
set SHERPA_SRCPATH $::odie(src_dir)/../sherpa

if {$::tcl_platform(platform) eq "windows"} {
  file copy -force ${GORT_SRCPATH}/gort.tcl $::odie(prefix)/bin/gort.tcl
  file copy -force ${SHERPA_SRCPATH}/sherpa.tcl $::odie(prefix)/bin/sherpa.tcl
} else {
  file delete $::odie(prefix)/bin/gort
  file link -symbolic $::odie(prefix)/bin/gort ${GORT_SRCPATH}/gort.tcl 
  file delete $::odie(prefix)/bin/sherpa
  file link -symbolic $::odie(prefix)/bin/sherpa ${SHERPA_SRCPATH}/sherpa.tcl 
}
Deleted scripts/make_sherpa.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# vim:se syntax=tcl:
# \
dir=`dirname "$0"`; exec "`$dir/../autosetup/find-tclsh`" "$0" "$@"

set path [file dirname [file normalize [info script]]]
proc ::doexec args {
  exec {*}$args >&@ stdout
}

source $path/../odieConfig.tcl

proc get_distro {pkg {tag trunk}} {
  set PKG_SRCPATH $::odie(sandbox)/$pkg
  if {![file exists $::odie(download)/$pkg.fos]} {
    puts "Fossil clone $pkg"
    doexec $::odie(fossil) clone $::odie(mirror_url)/$pkg $::odie(download)/$pkg.fos
  }

  if {![file exists ${PKG_SRCPATH}/$::odie(fossil_checkout)]} {
    puts "Fossil open $pkg"
    file mkdir ${PKG_SRCPATH}
    cd ${PKG_SRCPATH}
    doexec $::odie(fossil) open $::odie(download)/$pkg.fos
  }
  cd ${PKG_SRCPATH}
  doexec $::odie(fossil) update $tag
  return ${PKG_SRCPATH}
}

get_distro tcllib odie
get_distro sherpa sherpa

###
# Build supporting libraries needed by Sherpa
##
file mkdir $::odie(prefix)/bin
# Rebuild sherpa
set SHERPA_SRCPATH $::odie(src_dir)/../sherpa
if {$::tcl_platform(platform) eq "windows"} {
  file copy -force ${SHERPA_SRCPATH}/sherpa.cmd $::odie(prefix)/bin/sherpa.cmd
  file copy -force ${SHERPA_SRCPATH}/sherpa.tcl $::odie(prefix)/bin/sherpa.tcl
  file copy -force ${SHERPA_SRCPATH}/sherpa.tcl $::odie(prefix)/bin/sherpa
} else {
  file delete $::odie(prefix)/bin/sherpa
  file link -symbolic $::odie(prefix)/bin/sherpa ${SHERPA_SRCPATH}/sherpa.tcl 
}
Changes to scripts/make_tcl.sh.
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51












52
53

54
55
56
57
58
59
60
33
34
35
36
37
38
39












40
41
42
43
44
45
46
47
48
49
50
51


52
53
54
55
56
57
58
59







-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+







echo $ODIE_HOST
echo $ODIE_TARGET

#cd ${SANDBOX}/tcl
#${FOSSIL} update ${TCL_FOSSIL_BRANCH}
cd ${TCL_SRCPATH}
# Build Tcl twice. Once statically, once dynamically
echo Build Static Tcl
if [ "${ODIE_HOST}" != "${ODIE_TARGET}" ] ; then
    sh ./configure --enable-shared=no --with-tzdata --host=${ODIE_TARGET} ${TCL_CONFIG_FLAGS}
else
    sh ./configure --enable-shared=no --with-tzdata ${TCL_CONFIG_FLAGS}
fi
make clean
make binaries
echo "COPYING STATIC LIBRARY"
source tclConfig.sh
cp -f $TCL_LIB_FILE ${ODIE_STATIC_TCLLIB}
cp -f tclConfig.sh ${exec_prefix}/lib/tclkitConfig.sh
#echo Build Static Tcl
#if [ "${ODIE_HOST}" != "${ODIE_TARGET}" ] ; then
#    sh ./configure --enable-shared=no --with-tzdata --host=${ODIE_TARGET} ${TCL_CONFIG_FLAGS}
#else
#    sh ./configure --enable-shared=no --with-tzdata ${TCL_CONFIG_FLAGS}
#fi
#make clean
#make binaries
#echo "COPYING STATIC LIBRARY"
#source tclConfig.sh
#cp -f $TCL_LIB_FILE ${ODIE_STATIC_TCLLIB}
#cp -f tclConfig.sh ${exec_prefix}/lib/tclkitConfig.sh

cd ${TCL_SRCPATH}
#cd ${TCL_SRCPATH}
echo Build Dynamic Tcl
if [ "${ODIE_HOST}" != "${ODIE_TARGET}" ] ; then
    sh ./configure --prefix=${LOCAL_REPO} --libdir=${LOCAL_REPO}/lib --with-tzdata --host=${ODIE_TARGET} ${TCL_CONFIG_FLAGS}
else
    sh ./configure --prefix=${LOCAL_REPO} --libdir=${LOCAL_REPO}/lib --with-tzdata ${TCL_CONFIG_FLAGS}
fi
make clean
Changes to scripts/mkdoc.tcl.
1
2
3
4
5
6
7
8
9
10
11
12





1
2
3
4
5
6
7
-
-
-
-
-







namespace eval sherpa {}

###
# Begin
###

source [file join [file dirname [file normalize [info script]]] common.tcl]

package require codebale
::codebale::mkdoc_embedded_html $::odielib(srcroot) $::odielib(modules)  [file join $::odielib(srcroot) autodoc]  \
	-nav {Odie Home} /fossil/odie/home \
	-o /var/www/odie/docs 
Deleted scripts/sherpa.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# vim:se syntax=tcl:
# \
dir=`dirname "$0"`; exec "`$dir/../autosetup/find-tclsh`" "$0" "$@"

###
# Micronized version of sherpa for bootstrapping Odie
###

set path [file normalize [file join [file dirname [file normalize [info script]]] ..]]
source [file join $path scripts common.tcl]

namespace eval ::command {}

proc ::command::help {} {
  foreach command [lsort -dictionary [info command ::command::*]] {
    puts " * [namespace tail $command]"
  }
}

proc ::command::package-list {} {
  foreach distro [lsort -dictionary [dict keys $::sherpa_bootstrap::distribution]] {
    puts " * $distro"
  }
}

proc ::command::install {package} {
  if {$package eq "all"} {
    install-all
    return
  }
  ::sherpa_bootstrap::install_package $package
}

proc ::command::install-all {} {
  set info $::sherpa_bootstrap::distribution
  set allpkgs [lsort -dictionary [dict keys $info]]
  set installed {}
  foreach item $allpkgs {
    if {[dict exists $info $item requires]} {
      set requires($item) [dict get $info $item requires]
    } else {
      set requires($item) {}
    }
  }

  for {set i 0} {$i < [llength $allpkgs]} {incr i} {
    foreach item $allpkgs {
      if { $item in $installed } continue
      set needs {}
      foreach req $requires($item) {
        if { $req ni $installed } {
          lappend needs $req
        }
      }
      if {[llength $needs]}  {
        puts [list $item needs $needs]
        continue
      }
      lappend installed $item
    }
  }
  foreach item $installed {
    puts "INSTALLING $item"
  }
  foreach item $installed {
    ::sherpa_bootstrap::install_package $item
  }  
}

set method [lindex $argv 0]
if { [info command ::command::$method] eq {} } {
  puts stderr "Invalid command: $method."
  ::command::help
  exit 1
}
::command::$method {*}[lrange $argv 1 end]
update
exit 0
Changes to scripts/upload.tcl.
58
59
60
61
62
63
64
65

66
67
68
69
70
71
72
58
59
60
61
62
63
64

65
66
67
68
69
70
71
72







-
+







puts $fout "<TABLE>"
puts $fout "<tr><th colspan=2>Self contained executables</th></tr>"
if {[file exists $::odie(wish_kit)]} {
  upload $fout $::odie(wish_kit) ${server} $path "Base kit with tk"
}
upload $fout $::odie(tcl_kit) ${server} $path "Base kit with no tk"
upload $fout $::odie(zip_kit) ${server} $path "Sourceable Zipfile"
upload $fout $::odie(sherpa) ${server} $path "The Sherpa package manager"
upload $fout $::odie(gort) ${server} $path "The Gort package manager"
puts $fout "<tr><th colspan=2>Config Files</th></tr>"
upload $fout $here/../odieConfig.sh ${server} $path "Odie Configuration Paramters (sh readable)"
upload $fout $here/../odieConfig.tcl ${server} $path "Odie Configuration Paramters (tcl readable)"
upload $fout ${exec_prefix}/lib/tclConfig.sh ${server} $path "Tcl Configuration Paramters (sh readable)"
upload $fout ${exec_prefix}/lib/tkConfig.sh ${server} $path "Tk Configuration Paramters (sh readable)"
puts $fout "<tr><th colspan=2>Packages</th></tr>"
upload $fout $::odie(toad_kit) ${server} $path "Batteries included binary"