Changes to autosetup/README.autosetup.
Changes to autosetup/autosetup.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
-
+
-
+
-
+
|
#!/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/find-tclsh`" "$0" "$@"
dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@"
set autosetup(version) 0.6.6
set autosetup(version) 0.6.8
# Can be set to 1 to debug early-init problems
set autosetup(debug) 0
set autosetup(debug) [expr {"--debug" in $argv}]
##################################################################
#
# Main flow of control, option handling
#
proc main {argv} {
global autosetup define
|
︙ | | |
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
|
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
|
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
-
-
+
+
+
+
+
+
+
-
+
-
+
-
+
+
+
+
+
+
|
# At the is point we don't know what is a valid option
# We simply parse anything that looks like an option
set autosetup(getopt) [getopt argv]
#"=Core Options:"
options-add {
help:=local => "display help and options. Optionally specify a module name, such as --help=system"
licence license => "display the autosetup license"
version => "display the version of autosetup"
ref:=text manual:=text
reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
debug => "display debugging output as autosetup runs"
install:=. => "install autosetup to the current or given directory (in the 'autosetup/' subdirectory)"
install:=. => "install autosetup to the current or given directory"
}
if {$autosetup(installed)} {
# hidden options so we can produce a nice error
options-add {
sysinstall:path
}
} else {
options-add {
sysinstall:path => "install standalone autosetup to the given directory (e.g.: /usr/local)"
}
}
options-add {
force init:=help => "create initial auto.def, etc. Use --init=help for known types"
# Undocumented options
option-checking=1
nopager
quiet
timing
conf:
}
if {[opt-bool version]} {
puts $autosetup(version)
exit 0
}
# autosetup --conf=alternate-auto.def
if {[opt-val conf] ne ""} {
set autosetup(autodef) [opt-val conf]
set autosetup(autodef) [lindex [opt-val conf] end]
}
# Debugging output (set this early)
incr autosetup(debug) [opt-bool debug]
incr autosetup(force) [opt-bool force]
incr autosetup(msg-quiet) [opt-bool quiet]
incr autosetup(msg-timing) [opt-bool timing]
# If the local module exists, source it now to allow for
# project-local customisations
if {[file exists $autosetup(libdir)/local.tcl]} {
use local
}
# Now any auto-load modules
foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
automf_load source $file
autosetup_load_auto_modules
}
if {[opt-val help] ne ""} {
incr autosetup(showhelp)
use help
autosetup_help [opt-val help]
autosetup_help [lindex [opt-val help] end]
}
if {[opt-bool licence license]} {
use help
autosetup_show_license
exit 0
}
if {[opt-val {manual ref reference}] ne ""} {
use help
autosetup_reference [opt-val {manual ref reference}]
autosetup_reference [lindex [opt-val {manual ref reference}] end]
}
# Allow combining --install and --init
set earlyexit 0
if {[opt-val install] ne ""} {
use install
autosetup_install [opt-val install]
autosetup_install [lindex [opt-val install] end]
incr earlyexit
}
if {[opt-val init] ne ""} {
use init
autosetup_init [opt-val init]
autosetup_init [lindex [opt-val init] end]
incr earlyexit
}
if {$earlyexit} {
exit 0
}
if {[opt-val sysinstall] ne ""} {
use install
autosetup_install [lindex [opt-val sysinstall] end] 1
exit 0
}
if {![file exists $autosetup(autodef)]} {
# Check for invalid option first
options {}
user-error "No auto.def found in \"$autosetup(srcdir)\" (use [file tail $::autosetup(exe)] --init to create one)"
}
|
︙ | | |
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
-
+
-
+
|
# @opt-bool ?-nodefault? option ...
#
# Check each of the named, boolean options and if any have been explicitly enabled
# or disabled by the user, return 1 or 0 accordingly.
#
# If the option was specified more than once, the last value wins.
# e.g. With --enable-foo --disable-foo, [opt-bool foo] will return 0
# e.g. With '--enable-foo --disable-foo', '[opt-bool foo]' will return 0
#
# If no value was specified by the user, returns the default value for the
# first option. If -nodefault is given, this behaviour changes and
# first option. If '-nodefault' is given, this behaviour changes and
# -1 is returned instead.
#
proc opt-bool {args} {
set nodefault 0
if {[lindex $args 0] eq "-nodefault"} {
set nodefault 1
set args [lrange $args 1 end]
|
︙ | | |
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
-
+
-
+
-
+
|
if {$nodefault} {
return -1
}
# Default value is the default for the first option
return [dict get $::autosetup(optdefault) [lindex $args 0]]
}
# @opt-val option-list ?default=""?
# @opt-val optionlist ?default=""?
#
# Returns a list containing all the values given for the non-boolean options in 'option-list'.
# Returns a list containing all the values given for the non-boolean options in '$optionlist'.
# There will be one entry in the list for each option given by the user, including if the
# same option was used multiple times.
# If only a single value is required, use something like:
#
## lindex [opt-val $names] end
#
# If no options were set, $default is returned (exactly, not as a list).
# If no options were set, '$default' is returned (exactly, not as a list).
#
proc opt-val {names {default ""}} {
option-check-names {*}$names
foreach opt $names {
if {[dict exists $::autosetup(optset) $opt]} {
lappend result {*}[dict get $::autosetup(optset) $opt]
|
︙ | | |
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
|
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
|
-
+
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
|
puts $desc
} else {
options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2]
}
}
}
# @options options-spec
# @options optionspec
#
# Specifies configuration-time options which may be selected by the user
# and checked with opt-val and opt-bool. The format of options-spec follows.
# and checked with 'opt-val' and 'opt-bool'. '$optionspec' contains a series
# of options specifications separated by newlines, as follows:
#
# A boolean option is of the form:
#
## name[=0|1] => "Description of this boolean option"
#
# The default is name=0, meaning that the option is disabled by default.
# If name=1 is used to make the option enabled by default, the description should reflect
# The default is 'name=0', meaning that the option is disabled by default.
# If 'name=1' is used to make the option enabled by default, the description should reflect
# that with text like "Disable support for ...".
#
# An argument option (one which takes a parameter) is of the form:
#
## name:[=]value => "Description of this option"
#
# If the name:value form is used, the value must be provided with the option (as --name=myvalue).
# If the name:=value form is used, the value is optional and the given value is used as the default
# If the 'name:value' form is used, the value must be provided with the option (as '--name=myvalue').
# If the 'name:=value' form is used, the value is optional and the given value is used as the default
# if it is not provided.
#
# Undocumented options are also supported by omitting the "=> description.
# These options are not displayed with --help and can be useful for internal options or as aliases.
# Undocumented options are also supported by omitting the '=> description'.
# These options are not displayed with '--help' and can be useful for internal options or as aliases.
#
# For example, --disable-lfs is an alias for --disable=largefile:
# For example, '--disable-lfs' is an alias for '--disable=largefile':
#
## lfs=1 largefile=1 => "Disable large file support"
#
proc options {optlist} {
# Allow options as a list or args
options-add $optlist "Local Options:"
|
︙ | | |
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
|
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
|
-
+
-
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
+
-
+
+
+
+
+
+
-
+
|
user-error "Unknown option --$o"
}
}
}
}
proc config_guess {} {
if {[file-isexec $::autosetup(dir)/config.guess]} {
if {[file-isexec $::autosetup(dir)/autosetup-config.guess]} {
exec-with-stderr sh $::autosetup(dir)/config.guess
if {[catch {exec-with-stderr sh $::autosetup(dir)/config.guess} alias]} {
if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.guess} alias]} {
user-error $alias
}
return $alias
} else {
configlog "No config.guess, so using uname"
configlog "No autosetup-config.guess, so using uname"
string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
}
}
proc config_sub {alias} {
if {[file-isexec $::autosetup(dir)/config.sub]} {
if {[catch {exec-with-stderr sh $::autosetup(dir)/config.sub $alias} alias]} {
if {[file-isexec $::autosetup(dir)/autosetup-config.sub]} {
if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.sub $alias} alias]} {
user-error $alias
}
}
return $alias
}
# @define name ?value=1?
#
# Defines the named variable to the given value.
# These (name, value) pairs represent the results of the configuration check
# and are available to be checked, modified and substituted.
# and are available to be subsequently checked, modified and substituted.
#
proc define {name {value 1}} {
set ::define($name) $value
#dputs "$name <= $value"
}
# @undefine name
#
# Undefine the named variable
# Undefine the named variable.
#
proc undefine {name} {
unset -nocomplain ::define($name)
#dputs "$name <= <undef>"
}
# @define-append name value ...
#
# Appends the given value(s) to the given 'defined' variable.
# If the variable is not defined or empty, it is set to $value.
# Appends the given value(s) to the given "defined" variable.
# If the variable is not defined or empty, it is set to '$value'.
# Otherwise the value is appended, separated by a space.
# Any extra values are similarly appended.
# If any value is already contained in the variable (as a substring) it is omitted.
#
proc define-append {name args} {
if {[get-define $name ""] ne ""} {
# Make a token attempt to avoid duplicates
# Avoid duplicates
foreach arg $args {
set found 0
if {[string first $arg $::define($name)] == -1} {
foreach str [split $::define($name) " "] {
if {$str eq $arg} {
incr found
}
}
if {!$found} {
append ::define($name) " " $arg
}
}
} else {
set ::define($name) [join $args]
}
#dputs "$name += [join $args] => $::define($name)"
}
# @get-define name ?default=0?
#
# Returns the current value of the 'defined' variable, or $default
# Returns the current value of the "defined" variable, or '$default'
# if not set.
#
proc get-define {name {default 0}} {
if {[info exists ::define($name)]} {
#dputs "$name => $::define($name)"
return $::define($name)
}
|
︙ | | |
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
|
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
|
-
+
-
-
-
+
+
+
-
+
-
+
-
+
|
#
proc is-defined {name} {
info exists ::define($name)
}
# @all-defines
#
# Returns a dictionary (name value list) of all defined variables.
# Returns a dictionary (name, value list) of all defined variables.
#
# This is suitable for use with 'dict', 'array set' or 'foreach'
# and allows for arbitrary processing of the defined variables.
#
proc all-defines {} {
array get ::define
}
# @get-env name default
#
# If $name was specified on the command line, return it.
# If $name was set in the environment, return it.
# Otherwise return $default.
# If '$name' was specified on the command line, return it.
# Otherwise if '$name' was set in the environment, return it.
# Otherwise return '$default'.
#
proc get-env {name default} {
if {[dict exists $::autosetup(cmdline) $name]} {
return [dict get $::autosetup(cmdline) $name]
}
getenv $name $default
}
# @env-is-set name
#
# Returns 1 if the $name was specified on the command line or in the environment.
# Returns 1 if '$name' was specified on the command line or in the environment.
# Note that an empty environment variable is not considered to be set.
#
proc env-is-set {name} {
if {[dict exists $::autosetup(cmdline) $name]} {
return 1
}
if {[getenv $name ""] ne ""} {
return 1
}
return 0
}
# @readfile filename ?default=""?
#
# Return the contents of the file, without the trailing newline.
# If the file doesn't exist or can't be read, returns $default.
# If the file doesn't exist or can't be read, returns '$default'.
#
proc readfile {filename {default_value ""}} {
set result $default_value
catch {
set f [open $filename]
set result [read -nonewline $f]
close $f
}
return $result
}
# @writefile filename value
#
# Creates the given file containing $value.
# Creates the given file containing '$value'.
# Does not add an extra newline.
#
proc writefile {filename value} {
set f [open $filename w]
puts -nonewline $f $value
close $f
}
|
︙ | | |
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
|
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
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
|
-
+
-
+
-
-
-
-
-
+
+
-
-
+
+
+
-
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
-
-
-
-
-
-
+
-
-
-
|
set args {}
foreach arg $argv {
lappend args [quote-if-needed $arg]
}
join $args
}
# @suffix suf list
# @list-non-empty list
#
# Takes a list and returns a new list with $suf appended
# Returns a copy of the given list with empty elements removed
# to each element
#
## suffix .c {a b c} => {a.c b.c c.c}
#
proc suffix {suf list} {
proc list-non-empty {list} {
set result {}
foreach p $list {
if {$p ne ""} {
lappend result $p$suf
}
lappend result $p
}
}
return $result
}
# @prefix pre list
# @find-executable-path name
#
# Searches the path for an executable with the given name.
# Note that the name may include some parameters, e.g. 'cc -mbig-endian',
# Takes a list and returns a new list with $pre prepended
# to each element
#
# in which case the parameters are ignored.
# The full path to the executable if found, or "" if not found.
# Returns 1 if found, or 0 if not.
## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
#
proc prefix {pre list} {
set result {}
foreach p $list {
lappend result $pre$p
}
return $result
proc find-executable-path {name} {
# Ignore any parameters
set name [lindex $name 0]
# The empty string is never a valid executable
if {$name ne ""} {
foreach p [split-path] {
dputs "Looking for $name in $p"
set exec [file join $p $name]
if {[file-isexec $exec]} {
dputs "Found $name -> $exec"
return $exec
}
}
}
return {}
}
# @find-executable name
#
# Searches the path for an executable with the given name.
# Note that the name may include some parameters, e.g. "cc -mbig-endian",
# Note that the name may include some parameters, e.g. 'cc -mbig-endian',
# in which case the parameters are ignored.
# Returns 1 if found, or 0 if not.
#
proc find-executable {name} {
# Ignore any parameters
set name [lindex $name 0]
if {$name eq ""} {
# The empty string is never a valid executable
if {[find-executable-path $name] eq {}} {
return 0
}
foreach p [split-path] {
dputs "Looking for $name in $p"
set exec [file join $p $name]
if {[file-isexec $exec]} {
dputs "Found $name -> $exec"
return 1
return 1
}
}
return 0
}
# @find-an-executable ?-required? name ...
#
# Given a list of possible executable names,
# searches for one of these on the path.
#
|
︙ | | |
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
|
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
|
-
+
|
}
}
return ""
}
# @configlog msg
#
# Writes the given message to the configuration log, config.log
# Writes the given message to the configuration log, 'config.log'.
#
proc configlog {msg} {
if {![info exists ::autosetup(logfh)]} {
set ::autosetup(logfh) [open config.log w]
}
puts $::autosetup(logfh) $msg
}
|
︙ | | |
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
|
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
|
-
-
+
+
|
set ::autosetup(msg-checking) 0
show-notices
}
}
# @msg-quiet command ...
#
# msg-quiet evaluates it's arguments as a command with output
# from msg-checking and msg-result suppressed.
# 'msg-quiet' evaluates it's arguments as a command with output
# from 'msg-checking' and 'msg-result' suppressed.
#
# This is useful if a check needs to run a subcheck which isn't
# of interest to the user.
proc msg-quiet {args} {
incr ::autosetup(msg-quiet)
set rc [uplevel 1 $args]
incr ::autosetup(msg-quiet) -1
|
︙ | | |
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
|
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
|
-
+
|
#
# Usage errors such as wrong command line options
# @user-error msg
#
# Indicate incorrect usage to the user, including if required components
# or features are not found.
# autosetup exits with a non-zero return code.
# 'autosetup' exits with a non-zero return code.
#
proc user-error {msg} {
show-notices
puts stderr "Error: $msg"
puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
exit 1
}
|
︙ | | |
885
886
887
888
889
890
891
892
893
894
895
896
897
898
|
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
|
+
+
+
+
+
+
+
+
+
+
+
+
|
}
proc maybe-show-timestamp {} {
if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
}
}
# @autosetup-require-version required
#
# Checks the current version of 'autosetup' against '$required'.
# A fatal error is generated if the current version is less than that required.
#
proc autosetup-require-version {required} {
use util
if {[compare-versions $::autosetup(version) $required] < 0} {
user-error "autosetup version $required is required, but this is $::autosetup(version)"
}
}
proc autosetup_version {} {
return "autosetup v$::autosetup(version)"
}
##################################################################
#
|
︙ | | |
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
|
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
|
+
+
+
+
+
+
-
+
-
-
-
+
+
+
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
|
# or 'autosetup/X/init.tcl'
#
# The latter form is useful for a complex module which requires additional
# support file. In this form, '$::usedir' is set to the module directory
# when it is loaded.
#
proc use {args} {
global autosetup libmodule modsource
set dirs [list $autosetup(libdir)]
if {[info exists autosetup(srcdir)]} {
lappend dirs $autosetup(srcdir)/autosetup
}
foreach m $args {
if {[info exists ::libmodule($m)]} {
if {[info exists libmodule($m)]} {
continue
}
set ::libmodule($m) 1
if {[info exists ::modsource($m)]} {
automf_load eval $::modsource($m)
set libmodule($m) 1
if {[info exists modsource(${m}.tcl)]} {
automf_load eval $modsource(${m}.tcl)
} else {
set sources [list $::autosetup(libdir)/${m}.tcl $::autosetup(libdir)/${m}/init.tcl]
set locs [list ${m}.tcl ${m}/init.tcl]
set found 0
foreach dir $dirs {
foreach loc $locs {
foreach source $sources {
if {[file exists $source]} {
incr found
set source $dir/$loc
if {[file exists $source]} {
incr found
break
}
}
if {$found} {
break
}
}
if {$found} {
# For the convenience of the "use" source, point to the directory
# it is being loaded from
set ::usedir [file dirname $source]
automf_load source $source
autosetup_add_dep $source
} else {
autosetup-error "use: No such module: $m"
}
}
}
}
proc autosetup_load_auto_modules {} {
global autosetup modsource
# First load any embedded auto modules
foreach mod [array names modsource *.auto] {
automf_load eval $modsource($mod)
}
# Now any external auto modules
foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
automf_load source $file
}
}
# Load module source in the global scope by executing the given command
proc automf_load {args} {
if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
}
}
# Initial settings
set autosetup(exe) $::argv0
set autosetup(istcl) 1
set autosetup(start) [clock millis]
set autosetup(installed) 0
set autosetup(sysinstall) 0
set autosetup(msg-checking) 0
set autosetup(msg-quiet) 0
set autosetup(inittypes) {}
# Embedded modules are inserted below here
set autosetup(installed) 1
set autosetup(sysinstall) 0
# ----- module asciidoc-formatting -----
# ----- @module asciidoc-formatting.tcl -----
set modsource(asciidoc-formatting) {
set modsource(asciidoc-formatting.tcl) {
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Module which provides text formatting
# asciidoc format
use formatting
|
︙ | | |
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
|
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
|
-
+
-
+
|
}
set defn [string trim [join $args \n]]
regsub -all "\n\n" $defn "\n ::\n" defn
puts $defn
}
}
# ----- module formatting -----
# ----- @module formatting.tcl -----
set modsource(formatting) {
set modsource(formatting.tcl) {
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Module which provides common text formatting
# This is designed for documenation which looks like:
# code {...}
|
︙ | | |
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
|
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
|
-
+
-
+
|
}
# Return the result
return $lines
}
}
# ----- module getopt -----
# ----- @module getopt.tcl -----
set modsource(getopt) {
set modsource(getopt.tcl) {
# Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Simple getopt module
# Parse everything out of the argv list which looks like an option
# Everything which doesn't look like an option, or is after --, is left unchanged
|
︙ | | |
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
|
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
|
-
+
-
+
-
+
|
break
}
if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
# --name=value
dict lappend opts $name [list str $value]
} elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
if {$prefix in {enable- with- ""}} {
if {$prefix in {enable- ""}} {
set value 1
} else {
set value 0
}
dict lappend opts $name [list bool $value]
} else {
lappend nargv $arg
}
}
#puts "getopt: argv=[join $argv] => [join $nargv]"
#array set getopt $opts
#parray getopt
set argv $nargv
return $opts
}
}
# ----- module help -----
# ----- @module help.tcl -----
set modsource(help) {
set modsource(help.tcl) {
# Copyright (c) 2010 WorkWare Systems http://workware.net.au/
# All rights reserved
# Module which provides usage, help and the command reference
proc autosetup_help {what} {
use_pager
|
︙ | | |
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
|
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
user-error "Unknown module: $what"
} else {
options-show
}
}
exit 0
}
proc autosetup_show_license {} {
global modsource autosetup
use_pager
if {[info exists modsource(LICENSE)]} {
puts $modsource(LICENSE)
return
}
foreach dir [list $autosetup(libdir) $autosetup(srcdir)] {
set path [file join $dir LICENSE]
if {[file exists $path]} {
puts [readfile $path]
return
}
}
puts "LICENSE not found"
}
# If not already paged and stdout is a tty, pipe the output through the pager
# This is done by reinvoking autosetup with --nopager added
proc use_pager {} {
if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
if {[catch {
exec [info nameofexecutable] $::argv0 --nopager {*}$::argv |& {*}[getenv PAGER] >@stdout <@stdin 2>@stderr
|
︙ | | |
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
|
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
|
+
+
+
+
+
+
|
exit 0
}
proc autosetup_output_block {type lines} {
if {[llength $lines]} {
switch $type {
section {
section $lines
}
subsection {
subsection $lines
}
code {
codelines $lines
}
p {
p [join $lines]
}
list {
|
︙ | | |
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
|
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
|
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
|
}
# Generate a command reference from inline documentation
proc automf_command_reference {} {
lappend files $::autosetup(prog)
lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
# We want to process all non-module files before module files
# and then modules in alphabetical order.
# So examine all files and extract docs into doc($modulename) and doc(_core_)
#
# Each entry is a list of {type data} where $type is one of: section, subsection, code, list, p
section "Core Commands"
set type p
set lines {}
set cmd {}
# and $data is a string for section, subsection or a list of text lines for other types.
# XXX: Should commands be in alphabetical order too? Currently they are in file order.
set doc(_core_) {}
lappend doc(_core_) [list section "Core Commands"]
foreach file $files {
set modulename [file rootname [file tail $file]]
set current _core_
set f [open $file]
while {![eof $f]} {
set line [gets $f]
# Find embedded module names
if {[regexp {^#.*@module ([^ ]*)} $line -> modulename]} {
continue
}
# Find lines starting with "# @*" and continuing through the remaining comment lines
if {![regexp {^# @(.*)} $line -> cmd]} {
continue
}
# Synopsis or command?
if {$cmd eq "synopsis:"} {
set current $modulename
section "Module: [file rootname [file tail $file]]"
lappend doc($current) [list section "Module: $modulename"]
} else {
subsection $cmd
lappend doc($current) [list subsection $cmd]
}
set lines {}
set type p
# Now the description
while {![eof $f]} {
|
︙ | | |
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
|
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
|
-
+
-
+
+
+
+
+
+
+
+
+
+
-
+
-
+
|
set t p
}
#puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
if {$t ne $type || $cmd eq ""} {
# Finish the current block
autosetup_output_block $type $lines
lappend doc($current) [list $type $lines]
set lines {}
set type $t
}
if {$cmd ne ""} {
lappend lines $cmd
}
}
autosetup_output_block $type $lines
lappend doc($current) [list $type $lines]
}
close $f
}
# Now format and output the results
# _core_ will sort first
foreach module [lsort [array names doc]] {
foreach item $doc($module) {
autosetup_output_block {*}$item
}
}
}
}
# ----- module init -----
# ----- @module init.tcl -----
set modsource(init) {
set modsource(init.tcl) {
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Module to help create auto.def and configure
proc autosetup_init {type} {
set help 0
|
︙ | | |
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
|
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
|
-
+
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
+
+
+
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
-
+
+
-
-
+
+
+
-
+
+
-
+
+
+
+
+
+
+
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
-
+
|
} else {
puts "I don't see $filename, so I will create it."
}
writefile $filename $contents
}
}
# ----- module install -----
# ----- @module install.tcl -----
set modsource(install) {
set modsource(install.tcl) {
# Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Module which can install autosetup
# autosetup(installed)=1 means that autosetup is not running from source
# autosetup(sysinstall)=1 means that autosetup is running from a sysinstall verion
# shared=1 means that we are trying to do a sysinstall. This is only possible from the development source.
proc autosetup_install {dir} {
proc autosetup_install {dir {shared 0}} {
global autosetup
if {$shared} {
if {$autosetup(installed) || $autosetup(sysinstall)} {
user-error "Can only --sysinstall from development sources"
}
} elseif {$autosetup(installed)} {
user-error "Can't --install from project install"
}
if {$autosetup(sysinstall)} {
# This is the sysinstall version, so install just uses references
cd $dir
puts "[autosetup_version] creating configure to use system-installed autosetup"
autosetup_create_configure 1
puts "Creating autosetup/README.autosetup"
file mkdir autosetup
autosetup_install_readme autosetup/README.autosetup 1
return
}
if {[catch {
if {$shared} {
set target $dir/bin/autosetup
set installedas $target
} else {
if {$dir eq "."} {
set installedas autosetup
} else {
set installedas $dir/autosetup
}
cd $dir
file mkdir autosetup
set f [open autosetup/autosetup w]
cd $dir
file mkdir autosetup
set target autosetup/autosetup
}
set targetdir [file dirname $target]
file mkdir $targetdir
set f [open $target w]
set publicmodules [glob $::autosetup(libdir)/*.auto]
set publicmodules {}
# First the main script, but only up until "CUT HERE"
set in [open $::autosetup(dir)/autosetup]
set in [open $autosetup(dir)/autosetup]
while {[gets $in buf] >= 0} {
if {$buf ne "##-- CUT HERE --##"} {
puts $f $buf
continue
}
# Insert the static modules here
# i.e. those which don't contain @synopsis:
# All modules are inserted if $shared is set
puts $f "set autosetup(installed) 1"
puts $f "set autosetup(sysinstall) $shared"
foreach file [lsort [glob $::autosetup(libdir)/*.tcl]] {
foreach file [lsort [glob $autosetup(libdir)/*.{tcl,auto}]] {
set modname [file tail $file]
set ext [file ext $modname]
set buf [readfile $file]
if {!$shared} {
if {[string match "*\n# @synopsis:*" $buf]} {
lappend publicmodules $file
continue
}
set modname [file rootname [file tail $file]]
puts $f "# ----- module $modname -----"
if {$ext eq ".auto" || [string match "*\n# @synopsis:*" $buf]} {
lappend publicmodules $file
continue
}
}
dputs "install: importing lib/[file tail $file]"
puts $f "# ----- @module $modname -----"
puts $f "\nset modsource($modname) \{"
puts $f $buf
puts $f "\}\n"
}
if {$shared} {
foreach {srcname destname} [list $autosetup(libdir)/README.autosetup-lib README.autosetup \
$autosetup(srcdir)/LICENSE LICENSE] {
dputs "install: importing $srcname as $destname"
puts $f "\nset modsource($destname) \\\n[list [readfile $srcname]\n]\n"
}
}
}
close $in
close $f
exec chmod 755 autosetup/autosetup
catch {exec chmod 755 $target}
set installfiles {autosetup-config.guess autosetup-config.sub autosetup-test-tclsh}
set removefiles {}
if {!$shared} {
autosetup_install_readme $targetdir/README.autosetup 0
# Install public modules
foreach file $publicmodules {
autosetup_install_file $file autosetup
}
# Install public modules
foreach file $publicmodules {
set tail [file tail $file]
autosetup_install_file $file $targetdir/$tail
}
lappend installfiles jimsh0.c autosetup-find-tclsh LICENSE
lappend removefiles config.guess config.sub test-tclsh find-tclsh
} else {
lappend installfiles {sys-find-tclsh autosetup-find-tclsh}
}
# Install support files
foreach file {config.guess config.sub jimsh0.c find-tclsh test-tclsh LICENSE} {
autosetup_install_file $::autosetup(dir)/$file autosetup
foreach fileinfo $installfiles {
if {[llength $fileinfo] == 2} {
lassign $fileinfo source dest
} else {
lassign $fileinfo source
set dest $source
}
autosetup_install_file $autosetup(dir)/$source $targetdir/$dest
}
exec chmod 755 autosetup/config.sub autosetup/config.guess autosetup/find-tclsh
# Remove obsolete files
foreach file $removefiles {
if {[file exists $targetdir/$file]} {
file delete $targetdir/$file
}
writefile autosetup/README.autosetup \
"This is [autosetup_version]. See http://msteveb.github.com/autosetup/\n"
}
} error]} {
user-error "Failed to install autosetup: $error"
}
if {$shared} {
set type "system"
} else {
set type "local"
}
puts "Installed [autosetup_version] to autosetup/"
puts "Installed $type [autosetup_version] to $installedas"
if {!$shared} {
# Now create 'configure' if necessary
autosetup_create_configure
# Now create 'configure' if necessary
autosetup_create_configure 0
}
}
proc autosetup_create_configure {} {
proc autosetup_create_configure {shared} {
if {[file exists configure]} {
if {!$::autosetup(force)} {
# Could this be an autosetup configure?
if {![string match "*\nWRAPPER=*" [readfile configure]]} {
puts "I see configure, but not created by autosetup, so I won't overwrite it."
puts "Remove it or use --force to overwrite."
return
}
} else {
puts "I will overwrite the existing configure because you used --force."
}
} else {
puts "I don't see configure, so I will create it."
}
if {$shared} {
writefile configure \
writefile configure \
{#!/bin/sh
# Note that WRAPPER is set here purely to detect an autosetup-created script
WRAPPER="-"; "autosetup" "$@"
}
} else {
writefile configure \
{#!/bin/sh
dir="`dirname "$0"`/autosetup"
WRAPPER="$0"; export WRAPPER; exec "`$dir/find-tclsh`" "$dir/autosetup" "$@"
WRAPPER="$0"; export WRAPPER; exec "`$dir/autosetup-find-tclsh`" "$dir/autosetup" "$@"
}
}
catch {exec chmod 755 configure}
}
# Append the contents of $file to filehandle $f
proc autosetup_install_append {f file} {
dputs "install: include $file"
set in [open $file]
puts $f [read $in]
close $in
}
proc autosetup_install_file {file dir} {
if {![file exists $file]} {
error "Missing installation file '$file'"
proc autosetup_install_file {source target} {
dputs "install: $source => $target"
if {![file exists $source]} {
error "Missing installation file '$source'"
}
writefile $target [readfile $source]\n
# If possible, copy the file mode
file stat $source stat
set mode [format %o [expr {$stat(mode) & 0x1ff}]]
catch {exec chmod $mode $target}
}
writefile [file join $dir [file tail $file]] [readfile $file]\n
proc autosetup_install_readme {target sysinstall} {
set readme "README.autosetup created by [autosetup_version]\n\n"
if {$sysinstall} {
append readme \
{This is the autosetup directory for a system install of autosetup.
Loadable modules can be added here.
}
} else {
append readme \
{This is the autosetup directory for a local install of autosetup.
It contains autosetup, support files and loadable modules.
if {$::autosetup(installed)} {
user-error "autosetup can only be installed from development source, not from installed copy"
}
}
}
append readme {
*.tcl files in this directory are optional modules which
can be loaded with the 'use' directive.
*.auto files in this directory are auto-loaded.
For more information, see http://msteveb.github.com/autosetup/
}
dputs "install: autosetup/README.autosetup"
writefile $target $readme
# ----- module markdown-formatting -----
}
}
# ----- @module markdown-formatting.tcl -----
set modsource(markdown-formatting) {
set modsource(markdown-formatting.tcl) {
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Module which provides text formatting
# markdown format (kramdown syntax)
use formatting
|
︙ | | |
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
|
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
|
-
+
-
+
|
puts -nonewline ": "
regsub -all "\n\n" $defn "\n: " defn
}
puts "$defn"
}
}
# ----- module misc -----
# ----- @module misc.tcl -----
set modsource(misc) {
set modsource(misc.tcl) {
# Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Module containing misc procs useful to modules
# Largely for platform compatibility
set autosetup(istcl) [info exists ::tcl_library]
|
︙ | | |
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
|
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
|
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
|
# Remove the trailing newline
string trim $result
}
}
}
# ----- module text-formatting -----
# ----- @module text-formatting.tcl -----
set modsource(text-formatting) {
set modsource(text-formatting.tcl) {
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Module which provides text formatting
use formatting
proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
set len 0
set space $firstprefix
foreach word [split $text] {
set word [string trim $word]
if {$word == ""} {
continue
}
if {$len && [string length $space$word] + $len >= $length} {
puts ""
set len 0
set space $nextprefix
}
incr len [string length $space$word]
set len 0
set space $firstprefix
foreach word [split $text] {
set word [string trim $word]
if {$word eq ""} {
continue
}
if {[info exists partial]} {
append partial " " $word
if {[string first $quote $word] < 0} {
# Haven't found end of quoted word
continue
}
# Finished quoted word
set word $partial
unset partial
unset quote
} else {
set quote [string index $word 0]
if {$quote in {' *}} {
if {[string first $quote $word 1] < 0} {
# Haven't found end of quoted word
# Not a whole word.
set first [string index $word 0]
# Start of quoted word
set partial $word
continue
}
}
}
if {$len && [string length $space$word] + $len >= $length} {
puts ""
set len 0
set space $nextprefix
}
incr len [string length $space$word]
# Use man-page conventions for highlighting 'quoted' and *quoted*
# single words.
# Use x^Hx for *bold* and _^Hx for 'underline'.
#
# less and more will both understand this.
# Pipe through 'col -b' to remove them.
if {[regexp {^'(.*)'([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
regsub -all . $bareword "_\b&" word
append word $dot
} elseif {[regexp {^[*](.*)[*]([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
regsub -all . $bareword "&\b&" word
append word $dot
}
puts -nonewline $space$word
set space " "
}
if {$len} {
puts ""
}
# Use man-page conventions for highlighting 'quoted' and *quoted*
# single words.
# Use x^Hx for *bold* and _^Hx for 'underline'.
#
# less and more will both understand this.
# Pipe through 'col -b' to remove them.
if {[regexp {^'(.*)'(.*)} $word -> quoted after]} {
set quoted [string map {~ " "} $quoted]
regsub -all . $quoted "&\b&" quoted
set word $quoted$after
} elseif {[regexp {^[*](.*)[*](.*)} $word -> quoted after]} {
set quoted [string map {~ " "} $quoted]
regsub -all . $quoted "_\b&" quoted
set word $quoted$after
}
puts -nonewline $space$word
set space " "
}
if {[info exists partial]} {
# Missing end of quote
puts -nonewline $space$partial
}
if {$len} {
puts ""
}
}
proc title {text} {
underline [string trim $text] =
nl
underline [string trim $text] =
nl
}
proc p {text} {
wordwrap $text 80
nl
wordwrap $text 80
nl
}
proc codelines {lines} {
foreach line $lines {
puts " $line"
}
nl
foreach line $lines {
puts " $line"
}
nl
}
proc nl {} {
puts ""
puts ""
}
proc underline {text char} {
regexp "^(\[ \t\]*)(.*)" $text -> indent words
puts $text
puts $indent[string repeat $char [string length $words]]
regexp "^(\[ \t\]*)(.*)" $text -> indent words
puts $text
puts $indent[string repeat $char [string length $words]]
}
proc section {text} {
underline "[string trim $text]" -
nl
underline "[string trim $text]" -
nl
}
proc subsection {text} {
underline "$text" ~
nl
underline "$text" ~
nl
}
proc bullet {text} {
wordwrap $text 76 " * " " "
wordwrap $text 76 " * " " "
}
proc indent {text} {
wordwrap $text 76 " " " "
wordwrap $text 76 " " " "
}
proc defn {first args} {
if {$first ne ""} {
underline " $first" ~
}
foreach p $args {
if {$p ne ""} {
indent $p
}
}
if {$first ne ""} {
underline " $first" ~
}
foreach p $args {
if {$p ne ""} {
indent $p
}
}
}
}
# ----- @module util.tcl -----
set modsource(util.tcl) {
# Copyright (c) 2012 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Module which contains miscellaneous utility functions
# @compare-versions version1 version2
#
# Versions are of the form 'a.b.c' (may be any number of numeric components)
#
# Compares the two versions and returns:
## -1 if v1 < v2
## 0 if v1 == v2
## 1 if v1 > v2
#
# If one version has fewer components than the other, 0 is substituted to the right. e.g.
## 0.2 < 0.3
## 0.2.5 > 0.2
## 1.1 == 1.1.0
#
proc compare-versions {v1 v2} {
foreach c1 [split $v1 .] c2 [split $v2 .] {
if {$c1 eq ""} {
set c1 0
}
if {$c2 eq ""} {
set c2 0
}
if {$c1 < $c2} {
return -1
}
if {$c1 > $c2} {
return 1
}
}
return 0
}
# @suffix suf list
#
# Takes a list and returns a new list with '$suf' appended
# to each element
#
## suffix .c {a b c} => {a.c b.c c.c}
#
proc suffix {suf list} {
set result {}
foreach p $list {
lappend result $p$suf
}
return $result
}
# @prefix pre list
#
# Takes a list and returns a new list with '$pre' prepended
# to each element
#
## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
#
proc prefix {pre list} {
set result {}
foreach p $list {
lappend result $pre$p
}
return $result
}
}
# ----- module wiki-formatting -----
# ----- @module wiki-formatting.tcl -----
set modsource(wiki-formatting) {
set modsource(wiki-formatting.tcl) {
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Module which provides text formatting
# wiki.tcl.tk format output
use formatting
|
︙ | | |
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
|
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
|
-
+
|
# Entry/Exit
#
if {$autosetup(debug)} {
main $argv
}
if {[catch {main $argv} msg opts] == 1} {
show-notices
autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
autosetup-full-error [error-dump $msg $opts $autosetup(debug)]
if {!$autosetup(debug)} {
puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
}
exit 1
}
|
Added autosetup/autosetup-config.guess.