Fossil SCM

Update autosetup to 0.6.9-71785c7e and Jim Tcl to 0.78-27-ga5a84b1.

mistachkin 2019-07-06 22:27 autosetupAndJimTcl
Commit 2211bc2a6bd1549aea3f4986aa83a00d9b8b1fc02c9f56c122cb440e534393c2
--- autosetup/README.autosetup
+++ autosetup/README.autosetup
@@ -1,1 +1,11 @@
1
-This is autosetup v0.6.6. See http://msteveb.github.com/autosetup/
1
+README.autosetup created by autosetup v0.6.9
2
+
3
+This is the autosetup directory for a local install of autosetup.
4
+It contains autosetup, support files and loadable modules.
5
+
6
+*.tcl files in this directory are optional modules which
7
+can be loaded with the 'use' directive.
8
+
9
+*.auto files in this directory are auto-loaded.
10
+
11
+For more information, see http://msteveb.github.com/autosetup/
212
--- autosetup/README.autosetup
+++ autosetup/README.autosetup
@@ -1,1 +1,11 @@
1 This is autosetup v0.6.6. See http://msteveb.github.com/autosetup/
 
 
 
 
 
 
 
 
 
 
2
--- autosetup/README.autosetup
+++ autosetup/README.autosetup
@@ -1,1 +1,11 @@
1 README.autosetup created by autosetup v0.6.9
2
3 This is the autosetup directory for a local install of autosetup.
4 It contains autosetup, support files and loadable modules.
5
6 *.tcl files in this directory are optional modules which
7 can be loaded with the 'use' directive.
8
9 *.auto files in this directory are auto-loaded.
10
11 For more information, see http://msteveb.github.com/autosetup/
12
+709 -235
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -1,16 +1,17 @@
11
#!/bin/sh
22
# Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
33
# All rights reserved
44
# vim:se syntax=tcl:
55
# \
6
-dir=`dirname "$0"`; exec "`$dir/find-tclsh`" "$0" "$@"
6
+dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@"
77
8
-set autosetup(version) 0.6.6
8
+# Note that the version has a trailing + on unreleased versions
9
+set autosetup(version) 0.6.9
910
1011
# Can be set to 1 to debug early-init problems
11
-set autosetup(debug) 0
12
+set autosetup(debug) [expr {"--debug" in $argv}]
1213
1314
##################################################################
1415
#
1516
# Main flow of control, option handling
1617
#
@@ -72,14 +73,18 @@
7273
set autosetup(cmdline) {}
7374
# options is a list of known options
7475
set autosetup(options) {}
7576
# optset is a dictionary of option values set by the user based on getopt
7677
set autosetup(optset) {}
77
- # optdefault is a dictionary of default values for options
78
+ # optdefault is a dictionary of default values
7879
set autosetup(optdefault) {}
80
+ # options-defaults is a dictionary of overrides for default values for options
81
+ set autosetup(options-defaults) {}
7982
set autosetup(optionhelp) {}
8083
set autosetup(showhelp) 0
84
+
85
+ use util
8186
8287
# Parse options
8388
use getopt
8489
8590
# At the is point we don't know what is a valid option
@@ -87,15 +92,28 @@
8792
set autosetup(getopt) [getopt argv]
8893
8994
#"=Core Options:"
9095
options-add {
9196
help:=local => "display help and options. Optionally specify a module name, such as --help=system"
97
+ licence license => "display the autosetup license"
9298
version => "display the version of autosetup"
9399
ref:=text manual:=text
94100
reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
95101
debug => "display debugging output as autosetup runs"
96
- install:=. => "install autosetup to the current or given directory (in the 'autosetup/' subdirectory)"
102
+ install:=. => "install autosetup to the current or given directory"
103
+ }
104
+ if {$autosetup(installed)} {
105
+ # hidden options so we can produce a nice error
106
+ options-add {
107
+ sysinstall:path
108
+ }
109
+ } else {
110
+ options-add {
111
+ sysinstall:path => "install standalone autosetup to the given directory (e.g.: /usr/local)"
112
+ }
113
+ }
114
+ options-add {
97115
force init:=help => "create initial auto.def, etc. Use --init=help for known types"
98116
# Undocumented options
99117
option-checking=1
100118
nopager
101119
quiet
@@ -107,12 +125,12 @@
107125
puts $autosetup(version)
108126
exit 0
109127
}
110128
111129
# autosetup --conf=alternate-auto.def
112
- if {[opt-val conf] ne ""} {
113
- set autosetup(autodef) [opt-val conf]
130
+ if {[opt-str conf o]} {
131
+ set autosetup(autodef) $o
114132
}
115133
116134
# Debugging output (set this early)
117135
incr autosetup(debug) [opt-bool debug]
118136
incr autosetup(force) [opt-bool force]
@@ -124,41 +142,50 @@
124142
if {[file exists $autosetup(libdir)/local.tcl]} {
125143
use local
126144
}
127145
128146
# Now any auto-load modules
129
- foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
130
- automf_load source $file
131
- }
147
+ autosetup_load_auto_modules
132148
133
- if {[opt-val help] ne ""} {
149
+ if {[opt-str help o]} {
134150
incr autosetup(showhelp)
135151
use help
136
- autosetup_help [opt-val help]
152
+ autosetup_help $o
137153
}
138154
139
- if {[opt-val {manual ref reference}] ne ""} {
155
+ if {[opt-bool licence license]} {
156
+ use help
157
+ autosetup_show_license
158
+ exit 0
159
+ }
160
+
161
+ if {[opt-str {manual ref reference} o]} {
140162
use help
141
- autosetup_reference [opt-val {manual ref reference}]
163
+ autosetup_reference $o
142164
}
143165
144166
# Allow combining --install and --init
145167
set earlyexit 0
146
- if {[opt-val install] ne ""} {
168
+ if {[opt-str install o]} {
147169
use install
148
- autosetup_install [opt-val install]
170
+ autosetup_install $o
149171
incr earlyexit
150172
}
151173
152
- if {[opt-val init] ne ""} {
174
+ if {[opt-str init o]} {
153175
use init
154
- autosetup_init [opt-val init]
176
+ autosetup_init $o
155177
incr earlyexit
156178
}
157179
158180
if {$earlyexit} {
159181
exit 0
182
+ }
183
+ if {[opt-str sysinstall o]} {
184
+ use install
185
+ autosetup_install $o 1
186
+ exit 0
160187
}
161188
162189
if {![file exists $autosetup(autodef)]} {
163190
# Check for invalid option first
164191
options {}
@@ -185,10 +212,11 @@
185212
define-append AUTOREMAKE [get-define CONFIGURE_OPTS]
186213
187214
188215
# Log how we were invoked
189216
configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]"
217
+ configlog "Tclsh: [info nameofexecutable]"
190218
191219
# Note that auto.def is *not* loaded in the global scope
192220
source $autosetup(autodef)
193221
194222
# Could warn here if options {} was not specified
@@ -210,14 +238,14 @@
210238
#
211239
# Check each of the named, boolean options and if any have been explicitly enabled
212240
# or disabled by the user, return 1 or 0 accordingly.
213241
#
214242
# If the option was specified more than once, the last value wins.
215
-# e.g. With --enable-foo --disable-foo, [opt-bool foo] will return 0
243
+# e.g. With '--enable-foo --disable-foo', '[opt-bool foo]' will return 0
216244
#
217245
# If no value was specified by the user, returns the default value for the
218
-# first option. If -nodefault is given, this behaviour changes and
246
+# first option. If '-nodefault' is given, this behaviour changes and
219247
# -1 is returned instead.
220248
#
221249
proc opt-bool {args} {
222250
set nodefault 0
223251
if {[lindex $args 0] eq "-nodefault"} {
@@ -237,20 +265,19 @@
237265
}
238266
# Default value is the default for the first option
239267
return [dict get $::autosetup(optdefault) [lindex $args 0]]
240268
}
241269
242
-# @opt-val option-list ?default=""?
270
+# @opt-val optionlist ?default=""?
243271
#
244
-# Returns a list containing all the values given for the non-boolean options in 'option-list'.
272
+# Returns a list containing all the values given for the non-boolean options in '$optionlist'.
245273
# There will be one entry in the list for each option given by the user, including if the
246274
# same option was used multiple times.
247
-# If only a single value is required, use something like:
248275
#
249
-## lindex [opt-val $names] end
276
+# If no options were set, '$default' is returned (exactly, not as a list).
250277
#
251
-# If no options were set, $default is returned (exactly, not as a list).
278
+# Note: For most use cases, 'opt-str' should be preferred.
252279
#
253280
proc opt-val {names {default ""}} {
254281
option-check-names {*}$names
255282
256283
foreach opt $names {
@@ -261,10 +288,83 @@
261288
if {[info exists result]} {
262289
return $result
263290
}
264291
return $default
265292
}
293
+
294
+# @opt-str optionlist varname ?default?
295
+#
296
+# Sets '$varname' in the callers scope to the value for one of the given options.
297
+#
298
+# For the list of options given in '$optionlist', if any value is set for any option,
299
+# the option value is taken to be the *last* value of the last option (in the order given).
300
+#
301
+# If no option was given, and a default was specified with 'options-defaults',
302
+# that value is used.
303
+#
304
+# If no 'options-defaults' value was given and '$default' was given, it is used.
305
+#
306
+# If none of the above provided a value, no value is set.
307
+#
308
+# The return value depends on whether '$default' was specified.
309
+# If it was, the option value is returned.
310
+# If it was not, 1 is returns if a value was set, or 0 if not.
311
+#
312
+# Typical usage is as follows:
313
+#
314
+## if {[opt-str {myopt altname} o]} {
315
+## do something with $o
316
+## }
317
+#
318
+# Or:
319
+## define myname [opt-str {myopt altname} o "/usr/local"]
320
+#
321
+proc opt-str {names varname args} {
322
+ global autosetup
323
+
324
+ option-check-names {*}$names
325
+ upvar $varname value
326
+
327
+ if {[llength $args]} {
328
+ # A default was given, so always return the string value of the option
329
+ set default [lindex $args 0]
330
+ set retopt 1
331
+ } else {
332
+ # No default, so return 0 or 1 to indicate if a value was found
333
+ set retopt 0
334
+ }
335
+
336
+ foreach opt $names {
337
+ if {[dict exists $::autosetup(optset) $opt]} {
338
+ set result [lindex [dict get $::autosetup(optset) $opt] end]
339
+ }
340
+ }
341
+
342
+ if {![info exists result]} {
343
+ # No user-specified value. Has options-defaults been set?
344
+ foreach opt $names {
345
+ if {[dict exists $::autosetup(options-defaults) $opt]} {
346
+ set result [dict get $autosetup(options-defaults) $opt]
347
+ }
348
+ }
349
+ }
350
+
351
+ if {[info exists result]} {
352
+ set value $result
353
+ if {$retopt} {
354
+ return $value
355
+ }
356
+ return 1
357
+ }
358
+
359
+ if {$retopt} {
360
+ set value $default
361
+ return $value
362
+ }
363
+
364
+ return 0
365
+}
266366
267367
proc option-check-names {args} {
268368
foreach o $args {
269369
if {$o ni $::autosetup(options)} {
270370
autosetup-error "Request for undeclared option --$o"
@@ -293,10 +393,11 @@
293393
# This is a special heading
294394
lappend autosetup(optionhelp) $opt ""
295395
set header {}
296396
continue
297397
}
398
+ unset -nocomplain defaultvalue equal value
298399
299400
#puts "i=$i, opt=$opt"
300401
regexp {^([^:=]*)(:)?(=)?(.*)$} $opt -> name colon equal value
301402
if {$name in $autosetup(options)} {
302403
autosetup-error "Option $name already specified"
@@ -310,10 +411,16 @@
310411
# This is a documentation-only option, like "-C <dir>"
311412
set opthelp $opt
312413
} elseif {$colon eq ""} {
313414
# Boolean option
314415
lappend autosetup(options) $name
416
+
417
+ # Check for override
418
+ if {[dict exists $autosetup(options-defaults) $name]} {
419
+ # A default was specified with options-defaults, so use it
420
+ set value [dict get $autosetup(options-defaults) $name]
421
+ }
315422
316423
if {$value eq "1"} {
317424
set opthelp "--disable-$name"
318425
} else {
319426
set opthelp "--$name"
@@ -321,11 +428,12 @@
321428
322429
# Set the default
323430
if {$value eq ""} {
324431
set value 0
325432
}
326
- dict set autosetup(optdefault) $name $value
433
+ set defaultvalue $value
434
+ dict set autosetup(optdefault) $name $defaultvalue
327435
328436
if {[dict exists $autosetup(getopt) $name]} {
329437
# The option was specified by the user. Look at the last value.
330438
lassign [lindex [dict get $autosetup(getopt) $name] end] type setvalue
331439
if {$type eq "str"} {
@@ -342,19 +450,39 @@
342450
#puts "Found boolean option --$name=$setvalue"
343451
}
344452
} else {
345453
# String option.
346454
lappend autosetup(options) $name
455
+
456
+ if {$colon eq ":"} {
457
+ # Was ":name=default" given?
458
+ # If so, set $value to the display name and $defaultvalue to the default
459
+ # (This is the preferred way to set a default value for a string option)
460
+ if {[regexp {^([^=]+)=(.*)$} $value -> value defaultvalue]} {
461
+ dict set autosetup(optdefault) $name $defaultvalue
462
+ }
463
+ }
464
+
465
+ # Maybe override the default value
466
+ if {[dict exists $autosetup(options-defaults) $name]} {
467
+ # A default was specified with options-defaults, so use it
468
+ set defaultvalue [dict get $autosetup(options-defaults) $name]
469
+ dict set autosetup(optdefault) $name $defaultvalue
470
+ } elseif {![info exists defaultvalue]} {
471
+ # For backward compatibility, if ":name" was given, use name as both
472
+ # the display text and the default value, but only if the user
473
+ # specified the option without the value
474
+ set defaultvalue $value
475
+ }
347476
348477
if {$equal eq "="} {
349478
# String option with optional value
350479
set opthelp "--$name?=$value?"
351480
} else {
352481
# String option with required value
353482
set opthelp "--$name=$value"
354483
}
355
- dict set autosetup(optdefault) $name $value
356484
357485
# Get the values specified by the user
358486
if {[dict exists $autosetup(getopt) $name]} {
359487
set listvalue {}
360488
@@ -363,11 +491,11 @@
363491
if {$type eq "bool" && $setvalue} {
364492
if {$equal ne "="} {
365493
user-error "Option --$name requires a value"
366494
}
367495
# If given as a boolean, use the default value
368
- set setvalue $value
496
+ set setvalue $defaultvalue
369497
}
370498
lappend listvalue $setvalue
371499
}
372500
373501
#puts "Found string option --$name=$listvalue"
@@ -376,10 +504,13 @@
376504
}
377505
378506
# Now create the help for this option if appropriate
379507
if {[lindex $opts $i+1] eq "=>"} {
380508
set desc [lindex $opts $i+2]
509
+ if {[info exists defaultvalue]} {
510
+ set desc [string map [list @default@ $defaultvalue] $desc]
511
+ }
381512
#string match \n* $desc
382513
if {$header ne ""} {
383514
lappend autosetup(optionhelp) $header ""
384515
set header ""
385516
}
@@ -463,35 +594,39 @@
463594
options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2]
464595
}
465596
}
466597
}
467598
468
-# @options options-spec
599
+# @options optionspec
469600
#
470601
# Specifies configuration-time options which may be selected by the user
471
-# and checked with opt-val and opt-bool. The format of options-spec follows.
602
+# and checked with 'opt-str' and 'opt-bool'. '$optionspec' contains a series
603
+# of options specifications separated by newlines, as follows:
472604
#
473605
# A boolean option is of the form:
474606
#
475607
## name[=0|1] => "Description of this boolean option"
476608
#
477
-# The default is name=0, meaning that the option is disabled by default.
478
-# If name=1 is used to make the option enabled by default, the description should reflect
609
+# The default is 'name=0', meaning that the option is disabled by default.
610
+# If 'name=1' is used to make the option enabled by default, the description should reflect
479611
# that with text like "Disable support for ...".
480612
#
481613
# An argument option (one which takes a parameter) is of the form:
482614
#
483615
## name:[=]value => "Description of this option"
484616
#
485
-# If the name:value form is used, the value must be provided with the option (as --name=myvalue).
486
-# If the name:=value form is used, the value is optional and the given value is used as the default
617
+# If the 'name:value' form is used, the value must be provided with the option (as '--name=myvalue').
618
+# If the 'name:=value' form is used, the value is optional and the given value is used as the default
487619
# if it is not provided.
488620
#
489
-# Undocumented options are also supported by omitting the "=> description.
490
-# These options are not displayed with --help and can be useful for internal options or as aliases.
621
+# The description may contain '@default@', in which case it will be replaced with the default
622
+# value for the option (taking into account defaults specified with 'options-defaults'.
491623
#
492
-# For example, --disable-lfs is an alias for --disable=largefile:
624
+# Undocumented options are also supported by omitting the '=> description'.
625
+# These options are not displayed with '--help' and can be useful for internal options or as aliases.
626
+#
627
+# For example, '--disable-lfs' is an alias for '--disable=largefile':
493628
#
494629
## lfs=1 largefile=1 => "Disable large file support"
495630
#
496631
proc options {optlist} {
497632
# Allow options as a list or args
@@ -509,27 +644,37 @@
509644
user-error "Unknown option --$o"
510645
}
511646
}
512647
}
513648
}
649
+
650
+# @options-defaults dictionary
651
+#
652
+# Specifies a dictionary of options and a new default value for each of those options.
653
+# Use before any 'use' statements in 'auto.def' to change the defaults for
654
+# subsequently included modules.
655
+proc options-defaults {dict} {
656
+ foreach {n v} $dict {
657
+ dict set ::autosetup(options-defaults) $n $v
658
+ }
659
+}
514660
515661
proc config_guess {} {
516
- if {[file-isexec $::autosetup(dir)/config.guess]} {
517
- exec-with-stderr sh $::autosetup(dir)/config.guess
518
- if {[catch {exec-with-stderr sh $::autosetup(dir)/config.guess} alias]} {
662
+ if {[file-isexec $::autosetup(dir)/autosetup-config.guess]} {
663
+ if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.guess} alias]} {
519664
user-error $alias
520665
}
521666
return $alias
522667
} else {
523
- configlog "No config.guess, so using uname"
668
+ configlog "No autosetup-config.guess, so using uname"
524669
string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
525670
}
526671
}
527672
528673
proc config_sub {alias} {
529
- if {[file-isexec $::autosetup(dir)/config.sub]} {
530
- if {[catch {exec-with-stderr sh $::autosetup(dir)/config.sub $alias} alias]} {
674
+ if {[file-isexec $::autosetup(dir)/autosetup-config.sub]} {
675
+ if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.sub $alias} alias]} {
531676
user-error $alias
532677
}
533678
}
534679
return $alias
535680
}
@@ -536,39 +681,48 @@
536681
537682
# @define name ?value=1?
538683
#
539684
# Defines the named variable to the given value.
540685
# These (name, value) pairs represent the results of the configuration check
541
-# and are available to be checked, modified and substituted.
686
+# and are available to be subsequently checked, modified and substituted.
542687
#
543688
proc define {name {value 1}} {
544689
set ::define($name) $value
545690
#dputs "$name <= $value"
546691
}
547692
548693
# @undefine name
549694
#
550
-# Undefine the named variable
695
+# Undefine the named variable.
551696
#
552697
proc undefine {name} {
553698
unset -nocomplain ::define($name)
554699
#dputs "$name <= <undef>"
555700
}
556701
557702
# @define-append name value ...
558703
#
559
-# Appends the given value(s) to the given 'defined' variable.
560
-# If the variable is not defined or empty, it is set to $value.
704
+# Appends the given value(s) to the given "defined" variable.
705
+# If the variable is not defined or empty, it is set to '$value'.
561706
# Otherwise the value is appended, separated by a space.
562707
# Any extra values are similarly appended.
563708
# If any value is already contained in the variable (as a substring) it is omitted.
564709
#
565710
proc define-append {name args} {
566711
if {[get-define $name ""] ne ""} {
567
- # Make a token attempt to avoid duplicates
712
+ # Avoid duplicates
568713
foreach arg $args {
569
- if {[string first $arg $::define($name)] == -1} {
714
+ if {$arg eq ""} {
715
+ continue
716
+ }
717
+ set found 0
718
+ foreach str [split $::define($name) " "] {
719
+ if {$str eq $arg} {
720
+ incr found
721
+ }
722
+ }
723
+ if {!$found} {
570724
append ::define($name) " " $arg
571725
}
572726
}
573727
} else {
574728
set ::define($name) [join $args]
@@ -576,11 +730,11 @@
576730
#dputs "$name += [join $args] => $::define($name)"
577731
}
578732
579733
# @get-define name ?default=0?
580734
#
581
-# Returns the current value of the 'defined' variable, or $default
735
+# Returns the current value of the "defined" variable, or '$default'
582736
# if not set.
583737
#
584738
proc get-define {name {default 0}} {
585739
if {[info exists ::define($name)]} {
586740
#dputs "$name => $::define($name)"
@@ -595,14 +749,26 @@
595749
# Returns 1 if the given variable is defined.
596750
#
597751
proc is-defined {name} {
598752
info exists ::define($name)
599753
}
754
+
755
+# @is-define-set name
756
+#
757
+# Returns 1 if the given variable is defined and is set
758
+# to a value other than "" or 0
759
+#
760
+proc is-define-set {name} {
761
+ if {[get-define $name] in {0 ""}} {
762
+ return 0
763
+ }
764
+ return 1
765
+}
600766
601767
# @all-defines
602768
#
603
-# Returns a dictionary (name value list) of all defined variables.
769
+# Returns a dictionary (name, value list) of all defined variables.
604770
#
605771
# This is suitable for use with 'dict', 'array set' or 'foreach'
606772
# and allows for arbitrary processing of the defined variables.
607773
#
608774
proc all-defines {} {
@@ -610,13 +776,13 @@
610776
}
611777
612778
613779
# @get-env name default
614780
#
615
-# If $name was specified on the command line, return it.
616
-# If $name was set in the environment, return it.
617
-# Otherwise return $default.
781
+# If '$name' was specified on the command line, return it.
782
+# Otherwise if '$name' was set in the environment, return it.
783
+# Otherwise return '$default'.
618784
#
619785
proc get-env {name default} {
620786
if {[dict exists $::autosetup(cmdline) $name]} {
621787
return [dict get $::autosetup(cmdline) $name]
622788
}
@@ -623,11 +789,11 @@
623789
getenv $name $default
624790
}
625791
626792
# @env-is-set name
627793
#
628
-# Returns 1 if the $name was specified on the command line or in the environment.
794
+# Returns 1 if '$name' was specified on the command line or in the environment.
629795
# Note that an empty environment variable is not considered to be set.
630796
#
631797
proc env-is-set {name} {
632798
if {[dict exists $::autosetup(cmdline) $name]} {
633799
return 1
@@ -639,11 +805,11 @@
639805
}
640806
641807
# @readfile filename ?default=""?
642808
#
643809
# Return the contents of the file, without the trailing newline.
644
-# If the file doesn't exist or can't be read, returns $default.
810
+# If the file doesn't exist or can't be read, returns '$default'.
645811
#
646812
proc readfile {filename {default_value ""}} {
647813
set result $default_value
648814
catch {
649815
set f [open $filename]
@@ -653,11 +819,11 @@
653819
return $result
654820
}
655821
656822
# @writefile filename value
657823
#
658
-# Creates the given file containing $value.
824
+# Creates the given file containing '$value'.
659825
# Does not add an extra newline.
660826
#
661827
proc writefile {filename value} {
662828
set f [open $filename w]
663829
puts -nonewline $f $value
@@ -677,63 +843,60 @@
677843
lappend args [quote-if-needed $arg]
678844
}
679845
join $args
680846
}
681847
682
-# @suffix suf list
683
-#
684
-# Takes a list and returns a new list with $suf appended
685
-# to each element
686
-#
687
-## suffix .c {a b c} => {a.c b.c c.c}
688
-#
689
-proc suffix {suf list} {
848
+# @list-non-empty list
849
+#
850
+# Returns a copy of the given list with empty elements removed
851
+proc list-non-empty {list} {
690852
set result {}
691853
foreach p $list {
692
- lappend result $p$suf
854
+ if {$p ne ""} {
855
+ lappend result $p
856
+ }
693857
}
694858
return $result
695859
}
696860
697
-# @prefix pre list
698
-#
699
-# Takes a list and returns a new list with $pre prepended
700
-# to each element
701
-#
702
-## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
703
-#
704
-proc prefix {pre list} {
705
- set result {}
706
- foreach p $list {
707
- lappend result $pre$p
708
- }
709
- return $result
861
+# @find-executable-path name
862
+#
863
+# Searches the path for an executable with the given name.
864
+# Note that the name may include some parameters, e.g. 'cc -mbig-endian',
865
+# in which case the parameters are ignored.
866
+# The full path to the executable if found, or "" if not found.
867
+# Returns 1 if found, or 0 if not.
868
+#
869
+proc find-executable-path {name} {
870
+ # Ignore any parameters
871
+ set name [lindex $name 0]
872
+ # The empty string is never a valid executable
873
+ if {$name ne ""} {
874
+ foreach p [split-path] {
875
+ dputs "Looking for $name in $p"
876
+ set exec [file join $p $name]
877
+ if {[file-isexec $exec]} {
878
+ dputs "Found $name -> $exec"
879
+ return $exec
880
+ }
881
+ }
882
+ }
883
+ return {}
710884
}
711885
712886
# @find-executable name
713887
#
714888
# Searches the path for an executable with the given name.
715
-# Note that the name may include some parameters, e.g. "cc -mbig-endian",
889
+# Note that the name may include some parameters, e.g. 'cc -mbig-endian',
716890
# in which case the parameters are ignored.
717891
# Returns 1 if found, or 0 if not.
718892
#
719893
proc find-executable {name} {
720
- # Ignore any parameters
721
- set name [lindex $name 0]
722
- if {$name eq ""} {
723
- # The empty string is never a valid executable
724
- return 0
725
- }
726
- foreach p [split-path] {
727
- dputs "Looking for $name in $p"
728
- set exec [file join $p $name]
729
- if {[file-isexec $exec]} {
730
- dputs "Found $name -> $exec"
731
- return 1
732
- }
733
- }
734
- return 0
894
+ if {[find-executable-path $name] eq {}} {
895
+ return 0
896
+ }
897
+ return 1
735898
}
736899
737900
# @find-an-executable ?-required? name ...
738901
#
739902
# Given a list of possible executable names,
@@ -764,11 +927,11 @@
764927
return ""
765928
}
766929
767930
# @configlog msg
768931
#
769
-# Writes the given message to the configuration log, config.log
932
+# Writes the given message to the configuration log, 'config.log'.
770933
#
771934
proc configlog {msg} {
772935
if {![info exists ::autosetup(logfh)]} {
773936
set ::autosetup(logfh) [open config.log w]
774937
}
@@ -800,12 +963,12 @@
800963
}
801964
}
802965
803966
# @msg-quiet command ...
804967
#
805
-# msg-quiet evaluates it's arguments as a command with output
806
-# from msg-checking and msg-result suppressed.
968
+# 'msg-quiet' evaluates it's arguments as a command with output
969
+# from 'msg-checking' and 'msg-result' suppressed.
807970
#
808971
# This is useful if a check needs to run a subcheck which isn't
809972
# of interest to the user.
810973
proc msg-quiet {args} {
811974
incr ::autosetup(msg-quiet)
@@ -841,11 +1004,11 @@
8411004
8421005
# @user-error msg
8431006
#
8441007
# Indicate incorrect usage to the user, including if required components
8451008
# or features are not found.
846
-# autosetup exits with a non-zero return code.
1009
+# 'autosetup' exits with a non-zero return code.
8471010
#
8481011
proc user-error {msg} {
8491012
show-notices
8501013
puts stderr "Error: $msg"
8511014
puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
@@ -887,10 +1050,21 @@
8871050
proc maybe-show-timestamp {} {
8881051
if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
8891052
puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
8901053
}
8911054
}
1055
+
1056
+# @autosetup-require-version required
1057
+#
1058
+# Checks the current version of 'autosetup' against '$required'.
1059
+# A fatal error is generated if the current version is less than that required.
1060
+#
1061
+proc autosetup-require-version {required} {
1062
+ if {[compare-versions $::autosetup(version) $required] < 0} {
1063
+ user-error "autosetup version $required is required, but this is $::autosetup(version)"
1064
+ }
1065
+}
8921066
8931067
proc autosetup_version {} {
8941068
return "autosetup v$::autosetup(version)"
8951069
}
8961070
@@ -986,23 +1160,35 @@
9861160
# The latter form is useful for a complex module which requires additional
9871161
# support file. In this form, '$::usedir' is set to the module directory
9881162
# when it is loaded.
9891163
#
9901164
proc use {args} {
1165
+ global autosetup libmodule modsource
1166
+
1167
+ set dirs [list $autosetup(libdir)]
1168
+ if {[info exists autosetup(srcdir)]} {
1169
+ lappend dirs $autosetup(srcdir)/autosetup
1170
+ }
9911171
foreach m $args {
992
- if {[info exists ::libmodule($m)]} {
1172
+ if {[info exists libmodule($m)]} {
9931173
continue
9941174
}
995
- set ::libmodule($m) 1
996
- if {[info exists ::modsource($m)]} {
997
- automf_load eval $::modsource($m)
1175
+ set libmodule($m) 1
1176
+ if {[info exists modsource(${m}.tcl)]} {
1177
+ automf_load eval $modsource(${m}.tcl)
9981178
} else {
999
- set sources [list $::autosetup(libdir)/${m}.tcl $::autosetup(libdir)/${m}/init.tcl]
1179
+ set locs [list ${m}.tcl ${m}/init.tcl]
10001180
set found 0
1001
- foreach source $sources {
1002
- if {[file exists $source]} {
1003
- incr found
1181
+ foreach dir $dirs {
1182
+ foreach loc $locs {
1183
+ set source $dir/$loc
1184
+ if {[file exists $source]} {
1185
+ incr found
1186
+ break
1187
+ }
1188
+ }
1189
+ if {$found} {
10041190
break
10051191
}
10061192
}
10071193
if {$found} {
10081194
# For the convenience of the "use" source, point to the directory
@@ -1014,10 +1200,22 @@
10141200
autosetup-error "use: No such module: $m"
10151201
}
10161202
}
10171203
}
10181204
}
1205
+
1206
+proc autosetup_load_auto_modules {} {
1207
+ global autosetup modsource
1208
+ # First load any embedded auto modules
1209
+ foreach mod [array names modsource *.auto] {
1210
+ automf_load eval $modsource($mod)
1211
+ }
1212
+ # Now any external auto modules
1213
+ foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
1214
+ automf_load source $file
1215
+ }
1216
+}
10191217
10201218
# Load module source in the global scope by executing the given command
10211219
proc automf_load {args} {
10221220
if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
10231221
autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
@@ -1027,18 +1225,21 @@
10271225
# Initial settings
10281226
set autosetup(exe) $::argv0
10291227
set autosetup(istcl) 1
10301228
set autosetup(start) [clock millis]
10311229
set autosetup(installed) 0
1230
+set autosetup(sysinstall) 0
10321231
set autosetup(msg-checking) 0
10331232
set autosetup(msg-quiet) 0
1233
+set autosetup(inittypes) {}
10341234
10351235
# Embedded modules are inserted below here
10361236
set autosetup(installed) 1
1037
-# ----- module asciidoc-formatting -----
1237
+set autosetup(sysinstall) 0
1238
+# ----- @module asciidoc-formatting.tcl -----
10381239
1039
-set modsource(asciidoc-formatting) {
1240
+set modsource(asciidoc-formatting.tcl) {
10401241
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
10411242
# All rights reserved
10421243
10431244
# Module which provides text formatting
10441245
# asciidoc format
@@ -1102,19 +1303,19 @@
11021303
regsub -all "\n\n" $defn "\n ::\n" defn
11031304
puts $defn
11041305
}
11051306
}
11061307
1107
-# ----- module formatting -----
1308
+# ----- @module formatting.tcl -----
11081309
1109
-set modsource(formatting) {
1310
+set modsource(formatting.tcl) {
11101311
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
11111312
# All rights reserved
11121313
11131314
# Module which provides common text formatting
11141315
1115
-# This is designed for documenation which looks like:
1316
+# This is designed for documentation which looks like:
11161317
# code {...}
11171318
# or
11181319
# code {
11191320
# ...
11201321
# ...
@@ -1159,13 +1360,13 @@
11591360
# Return the result
11601361
return $lines
11611362
}
11621363
}
11631364
1164
-# ----- module getopt -----
1365
+# ----- @module getopt.tcl -----
11651366
1166
-set modsource(getopt) {
1367
+set modsource(getopt.tcl) {
11671368
# Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
11681369
# All rights reserved
11691370
11701371
# Simple getopt module
11711372
@@ -1197,11 +1398,11 @@
11971398
11981399
if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
11991400
# --name=value
12001401
dict lappend opts $name [list str $value]
12011402
} elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
1202
- if {$prefix in {enable- with- ""}} {
1403
+ if {$prefix in {enable- ""}} {
12031404
set value 1
12041405
} else {
12051406
set value 0
12061407
}
12071408
dict lappend opts $name [list bool $value]
@@ -1218,13 +1419,13 @@
12181419
12191420
return $opts
12201421
}
12211422
}
12221423
1223
-# ----- module help -----
1424
+# ----- @module help.tcl -----
12241425
1225
-set modsource(help) {
1426
+set modsource(help.tcl) {
12261427
# Copyright (c) 2010 WorkWare Systems http://workware.net.au/
12271428
# All rights reserved
12281429
12291430
# Module which provides usage, help and the command reference
12301431
@@ -1251,10 +1452,28 @@
12511452
options-show
12521453
}
12531454
}
12541455
exit 0
12551456
}
1457
+
1458
+proc autosetup_show_license {} {
1459
+ global modsource autosetup
1460
+ use_pager
1461
+
1462
+ if {[info exists modsource(LICENSE)]} {
1463
+ puts $modsource(LICENSE)
1464
+ return
1465
+ }
1466
+ foreach dir [list $autosetup(libdir) $autosetup(srcdir)] {
1467
+ set path [file join $dir LICENSE]
1468
+ if {[file exists $path]} {
1469
+ puts [readfile $path]
1470
+ return
1471
+ }
1472
+ }
1473
+ puts "LICENSE not found"
1474
+}
12561475
12571476
# If not already paged and stdout is a tty, pipe the output through the pager
12581477
# This is done by reinvoking autosetup with --nopager added
12591478
proc use_pager {} {
12601479
if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
@@ -1304,10 +1523,16 @@
13041523
}
13051524
13061525
proc autosetup_output_block {type lines} {
13071526
if {[llength $lines]} {
13081527
switch $type {
1528
+ section {
1529
+ section $lines
1530
+ }
1531
+ subsection {
1532
+ subsection $lines
1533
+ }
13091534
code {
13101535
codelines $lines
13111536
}
13121537
p {
13131538
p [join $lines]
@@ -1325,30 +1550,45 @@
13251550
# Generate a command reference from inline documentation
13261551
proc automf_command_reference {} {
13271552
lappend files $::autosetup(prog)
13281553
lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
13291554
1330
- section "Core Commands"
1331
- set type p
1332
- set lines {}
1333
- set cmd {}
1555
+ # We want to process all non-module files before module files
1556
+ # and then modules in alphabetical order.
1557
+ # So examine all files and extract docs into doc($modulename) and doc(_core_)
1558
+ #
1559
+ # Each entry is a list of {type data} where $type is one of: section, subsection, code, list, p
1560
+ # and $data is a string for section, subsection or a list of text lines for other types.
1561
+
1562
+ # XXX: Should commands be in alphabetical order too? Currently they are in file order.
1563
+
1564
+ set doc(_core_) {}
1565
+ lappend doc(_core_) [list section "Core Commands"]
13341566
13351567
foreach file $files {
1568
+ set modulename [file rootname [file tail $file]]
1569
+ set current _core_
13361570
set f [open $file]
13371571
while {![eof $f]} {
13381572
set line [gets $f]
1573
+
1574
+ # Find embedded module names
1575
+ if {[regexp {^#.*@module ([^ ]*)} $line -> modulename]} {
1576
+ continue
1577
+ }
13391578
13401579
# Find lines starting with "# @*" and continuing through the remaining comment lines
13411580
if {![regexp {^# @(.*)} $line -> cmd]} {
13421581
continue
13431582
}
13441583
13451584
# Synopsis or command?
13461585
if {$cmd eq "synopsis:"} {
1347
- section "Module: [file rootname [file tail $file]]"
1586
+ set current $modulename
1587
+ lappend doc($current) [list section "Module: $modulename"]
13481588
} else {
1349
- subsection $cmd
1589
+ lappend doc($current) [list subsection $cmd]
13501590
}
13511591
13521592
set lines {}
13531593
set type p
13541594
@@ -1369,29 +1609,38 @@
13691609
13701610
#puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
13711611
13721612
if {$t ne $type || $cmd eq ""} {
13731613
# Finish the current block
1374
- autosetup_output_block $type $lines
1614
+ lappend doc($current) [list $type $lines]
13751615
set lines {}
13761616
set type $t
13771617
}
13781618
if {$cmd ne ""} {
13791619
lappend lines $cmd
13801620
}
13811621
}
13821622
1383
- autosetup_output_block $type $lines
1623
+ lappend doc($current) [list $type $lines]
13841624
}
13851625
close $f
13861626
}
1627
+
1628
+ # Now format and output the results
1629
+
1630
+ # _core_ will sort first
1631
+ foreach module [lsort [array names doc]] {
1632
+ foreach item $doc($module) {
1633
+ autosetup_output_block {*}$item
1634
+ }
1635
+ }
13871636
}
13881637
}
13891638
1390
-# ----- module init -----
1639
+# ----- @module init.tcl -----
13911640
1392
-set modsource(init) {
1641
+set modsource(init.tcl) {
13931642
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
13941643
# All rights reserved
13951644
13961645
# Module to help create auto.def and configure
13971646
@@ -1444,79 +1693,157 @@
14441693
}
14451694
writefile $filename $contents
14461695
}
14471696
}
14481697
1449
-# ----- module install -----
1698
+# ----- @module install.tcl -----
14501699
1451
-set modsource(install) {
1700
+set modsource(install.tcl) {
14521701
# Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
14531702
# All rights reserved
14541703
14551704
# Module which can install autosetup
14561705
1457
-proc autosetup_install {dir} {
1458
- if {[catch {
1706
+# autosetup(installed)=1 means that autosetup is not running from source
1707
+# autosetup(sysinstall)=1 means that autosetup is running from a sysinstall version
1708
+# shared=1 means that we are trying to do a sysinstall. This is only possible from the development source.
1709
+
1710
+proc autosetup_install {dir {shared 0}} {
1711
+ global autosetup
1712
+ if {$shared} {
1713
+ if {$autosetup(installed) || $autosetup(sysinstall)} {
1714
+ user-error "Can only --sysinstall from development sources"
1715
+ }
1716
+ } elseif {$autosetup(installed) && !$autosetup(sysinstall)} {
1717
+ user-error "Can't --install from project install"
1718
+ }
1719
+
1720
+ if {$autosetup(sysinstall)} {
1721
+ # This is the sysinstall version, so install just uses references
14591722
cd $dir
1723
+
1724
+ puts "[autosetup_version] creating configure to use system-installed autosetup"
1725
+ autosetup_create_configure 1
1726
+ puts "Creating autosetup/README.autosetup"
14601727
file mkdir autosetup
1728
+ autosetup_install_readme autosetup/README.autosetup 1
1729
+ return
1730
+ }
1731
+
1732
+ if {[catch {
1733
+ if {$shared} {
1734
+ set target $dir/bin/autosetup
1735
+ set installedas $target
1736
+ } else {
1737
+ if {$dir eq "."} {
1738
+ set installedas autosetup
1739
+ } else {
1740
+ set installedas $dir/autosetup
1741
+ }
1742
+ cd $dir
1743
+ file mkdir autosetup
1744
+ set target autosetup/autosetup
1745
+ }
1746
+ set targetdir [file dirname $target]
1747
+ file mkdir $targetdir
14611748
1462
- set f [open autosetup/autosetup w]
1749
+ set f [open $target w]
14631750
1464
- set publicmodules [glob $::autosetup(libdir)/*.auto]
1751
+ set publicmodules {}
14651752
14661753
# First the main script, but only up until "CUT HERE"
1467
- set in [open $::autosetup(dir)/autosetup]
1754
+ set in [open $autosetup(dir)/autosetup]
14681755
while {[gets $in buf] >= 0} {
14691756
if {$buf ne "##-- CUT HERE --##"} {
14701757
puts $f $buf
14711758
continue
14721759
}
14731760
14741761
# Insert the static modules here
14751762
# i.e. those which don't contain @synopsis:
1763
+ # All modules are inserted if $shared is set
14761764
puts $f "set autosetup(installed) 1"
1477
- foreach file [lsort [glob $::autosetup(libdir)/*.tcl]] {
1765
+ puts $f "set autosetup(sysinstall) $shared"
1766
+ foreach file [lsort [glob $autosetup(libdir)/*.{tcl,auto}]] {
1767
+ set modname [file tail $file]
1768
+ set ext [file ext $modname]
14781769
set buf [readfile $file]
1479
- if {[string match "*\n# @synopsis:*" $buf]} {
1480
- lappend publicmodules $file
1481
- continue
1770
+ if {!$shared} {
1771
+ if {$ext eq ".auto" || [string match "*\n# @synopsis:*" $buf]} {
1772
+ lappend publicmodules $file
1773
+ continue
1774
+ }
14821775
}
1483
- set modname [file rootname [file tail $file]]
1484
- puts $f "# ----- module $modname -----"
1776
+ dputs "install: importing lib/[file tail $file]"
1777
+ puts $f "# ----- @module $modname -----"
14851778
puts $f "\nset modsource($modname) \{"
14861779
puts $f $buf
14871780
puts $f "\}\n"
14881781
}
1782
+ if {$shared} {
1783
+ foreach {srcname destname} [list $autosetup(libdir)/README.autosetup-lib README.autosetup \
1784
+ $autosetup(srcdir)/LICENSE LICENSE] {
1785
+ dputs "install: importing $srcname as $destname"
1786
+ puts $f "\nset modsource($destname) \\\n[list [readfile $srcname]\n]\n"
1787
+ }
1788
+ }
14891789
}
14901790
close $in
14911791
close $f
1492
- exec chmod 755 autosetup/autosetup
1792
+ catch {exec chmod 755 $target}
1793
+
1794
+ set installfiles {autosetup-config.guess autosetup-config.sub autosetup-test-tclsh}
1795
+ set removefiles {}
1796
+
1797
+ if {!$shared} {
1798
+ autosetup_install_readme $targetdir/README.autosetup 0
14931799
1494
- # Install public modules
1495
- foreach file $publicmodules {
1496
- autosetup_install_file $file autosetup
1800
+ # Install public modules
1801
+ foreach file $publicmodules {
1802
+ set tail [file tail $file]
1803
+ autosetup_install_file $file $targetdir/$tail
1804
+ }
1805
+ lappend installfiles jimsh0.c autosetup-find-tclsh LICENSE
1806
+ lappend removefiles config.guess config.sub test-tclsh find-tclsh
1807
+ } else {
1808
+ lappend installfiles {sys-find-tclsh autosetup-find-tclsh}
14971809
}
14981810
14991811
# Install support files
1500
- foreach file {config.guess config.sub jimsh0.c find-tclsh test-tclsh LICENSE} {
1501
- autosetup_install_file $::autosetup(dir)/$file autosetup
1502
- }
1503
- exec chmod 755 autosetup/config.sub autosetup/config.guess autosetup/find-tclsh
1504
-
1505
- writefile autosetup/README.autosetup \
1506
- "This is [autosetup_version]. See http://msteveb.github.com/autosetup/\n"
1507
-
1812
+ foreach fileinfo $installfiles {
1813
+ if {[llength $fileinfo] == 2} {
1814
+ lassign $fileinfo source dest
1815
+ } else {
1816
+ lassign $fileinfo source
1817
+ set dest $source
1818
+ }
1819
+ autosetup_install_file $autosetup(dir)/$source $targetdir/$dest
1820
+ }
1821
+
1822
+ # Remove obsolete files
1823
+ foreach file $removefiles {
1824
+ if {[file exists $targetdir/$file]} {
1825
+ file delete $targetdir/$file
1826
+ }
1827
+ }
15081828
} error]} {
15091829
user-error "Failed to install autosetup: $error"
15101830
}
1511
- puts "Installed [autosetup_version] to autosetup/"
1831
+ if {$shared} {
1832
+ set type "system"
1833
+ } else {
1834
+ set type "local"
1835
+ }
1836
+ puts "Installed $type [autosetup_version] to $installedas"
15121837
1513
- # Now create 'configure' if necessary
1514
- autosetup_create_configure
1838
+ if {!$shared} {
1839
+ # Now create 'configure' if necessary
1840
+ autosetup_create_configure 0
1841
+ }
15151842
}
15161843
1517
-proc autosetup_create_configure {} {
1844
+proc autosetup_create_configure {shared} {
15181845
if {[file exists configure]} {
15191846
if {!$::autosetup(force)} {
15201847
# Could this be an autosetup configure?
15211848
if {![string match "*\nWRAPPER=*" [readfile configure]]} {
15221849
puts "I see configure, but not created by autosetup, so I won't overwrite it."
@@ -1527,40 +1854,75 @@
15271854
puts "I will overwrite the existing configure because you used --force."
15281855
}
15291856
} else {
15301857
puts "I don't see configure, so I will create it."
15311858
}
1532
- writefile configure \
1859
+ if {$shared} {
1860
+ writefile configure \
1861
+{#!/bin/sh
1862
+WRAPPER="$0"; export WRAPPER; "autosetup" "$@"
1863
+}
1864
+ } else {
1865
+ writefile configure \
15331866
{#!/bin/sh
15341867
dir="`dirname "$0"`/autosetup"
1535
-WRAPPER="$0"; export WRAPPER; exec "`$dir/find-tclsh`" "$dir/autosetup" "$@"
1868
+WRAPPER="$0"; export WRAPPER; exec "`"$dir/autosetup-find-tclsh"`" "$dir/autosetup" "$@"
15361869
}
1870
+ }
15371871
catch {exec chmod 755 configure}
15381872
}
15391873
15401874
# Append the contents of $file to filehandle $f
15411875
proc autosetup_install_append {f file} {
1876
+ dputs "install: include $file"
15421877
set in [open $file]
15431878
puts $f [read $in]
15441879
close $in
15451880
}
15461881
1547
-proc autosetup_install_file {file dir} {
1548
- if {![file exists $file]} {
1549
- error "Missing installation file '$file'"
1550
- }
1551
- writefile [file join $dir [file tail $file]] [readfile $file]\n
1552
-}
1553
-
1554
-if {$::autosetup(installed)} {
1555
- user-error "autosetup can only be installed from development source, not from installed copy"
1882
+proc autosetup_install_file {source target} {
1883
+ dputs "install: $source => $target"
1884
+ if {![file exists $source]} {
1885
+ error "Missing installation file '$source'"
1886
+ }
1887
+ writefile $target [readfile $source]\n
1888
+ # If possible, copy the file mode
1889
+ file stat $source stat
1890
+ set mode [format %o [expr {$stat(mode) & 0x1ff}]]
1891
+ catch {exec chmod $mode $target}
1892
+}
1893
+
1894
+proc autosetup_install_readme {target sysinstall} {
1895
+ set readme "README.autosetup created by [autosetup_version]\n\n"
1896
+ if {$sysinstall} {
1897
+ append readme \
1898
+{This is the autosetup directory for a system install of autosetup.
1899
+Loadable modules can be added here.
1900
+}
1901
+ } else {
1902
+ append readme \
1903
+{This is the autosetup directory for a local install of autosetup.
1904
+It contains autosetup, support files and loadable modules.
1905
+}
1906
+}
1907
+
1908
+ append readme {
1909
+*.tcl files in this directory are optional modules which
1910
+can be loaded with the 'use' directive.
1911
+
1912
+*.auto files in this directory are auto-loaded.
1913
+
1914
+For more information, see http://msteveb.github.com/autosetup/
1915
+}
1916
+ dputs "install: autosetup/README.autosetup"
1917
+ writefile $target $readme
15561918
}
15571919
}
15581920
1559
-# ----- module markdown-formatting -----
1921
+# ----- @module markdown-formatting.tcl -----
15601922
1561
-set modsource(markdown-formatting) {
1923
+set modsource(markdown-formatting.tcl) {
15621924
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
15631925
# All rights reserved
15641926
15651927
# Module which provides text formatting
15661928
# markdown format (kramdown syntax)
@@ -1627,13 +1989,13 @@
16271989
}
16281990
puts "$defn"
16291991
}
16301992
}
16311993
1632
-# ----- module misc -----
1994
+# ----- @module misc.tcl -----
16331995
1634
-set modsource(misc) {
1996
+set modsource(misc.tcl) {
16351997
# Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
16361998
# All rights reserved
16371999
16382000
# Module containing misc procs useful to modules
16392001
# Largely for platform compatibility
@@ -1805,106 +2167,218 @@
18052167
string trim $result
18062168
}
18072169
}
18082170
}
18092171
1810
-# ----- module text-formatting -----
2172
+# ----- @module text-formatting.tcl -----
18112173
1812
-set modsource(text-formatting) {
2174
+set modsource(text-formatting.tcl) {
18132175
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
18142176
# All rights reserved
18152177
18162178
# Module which provides text formatting
18172179
18182180
use formatting
18192181
18202182
proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
1821
- set len 0
1822
- set space $firstprefix
1823
- foreach word [split $text] {
1824
- set word [string trim $word]
1825
- if {$word == ""} {
1826
- continue
1827
- }
1828
- if {$len && [string length $space$word] + $len >= $length} {
1829
- puts ""
1830
- set len 0
1831
- set space $nextprefix
1832
- }
1833
- incr len [string length $space$word]
1834
-
1835
- # Use man-page conventions for highlighting 'quoted' and *quoted*
1836
- # single words.
1837
- # Use x^Hx for *bold* and _^Hx for 'underline'.
1838
- #
1839
- # less and more will both understand this.
1840
- # Pipe through 'col -b' to remove them.
1841
- if {[regexp {^'(.*)'([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1842
- regsub -all . $bareword "_\b&" word
1843
- append word $dot
1844
- } elseif {[regexp {^[*](.*)[*]([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1845
- regsub -all . $bareword "&\b&" word
1846
- append word $dot
1847
- }
1848
- puts -nonewline $space$word
1849
- set space " "
1850
- }
1851
- if {$len} {
1852
- puts ""
1853
- }
2183
+ set len 0
2184
+ set space $firstprefix
2185
+
2186
+ foreach word [split $text] {
2187
+ set word [string trim $word]
2188
+ if {$word eq ""} {
2189
+ continue
2190
+ }
2191
+ if {[info exists partial]} {
2192
+ append partial " " $word
2193
+ if {[string first $quote $word] < 0} {
2194
+ # Haven't found end of quoted word
2195
+ continue
2196
+ }
2197
+ # Finished quoted word
2198
+ set word $partial
2199
+ unset partial
2200
+ unset quote
2201
+ } else {
2202
+ set quote [string index $word 0]
2203
+ if {$quote in {' *}} {
2204
+ if {[string first $quote $word 1] < 0} {
2205
+ # Haven't found end of quoted word
2206
+ # Not a whole word.
2207
+ set first [string index $word 0]
2208
+ # Start of quoted word
2209
+ set partial $word
2210
+ continue
2211
+ }
2212
+ }
2213
+ }
2214
+
2215
+ if {$len && [string length $space$word] + $len >= $length} {
2216
+ puts ""
2217
+ set len 0
2218
+ set space $nextprefix
2219
+ }
2220
+ incr len [string length $space$word]
2221
+
2222
+ # Use man-page conventions for highlighting 'quoted' and *quoted*
2223
+ # single words.
2224
+ # Use x^Hx for *bold* and _^Hx for 'underline'.
2225
+ #
2226
+ # less and more will both understand this.
2227
+ # Pipe through 'col -b' to remove them.
2228
+ if {[regexp {^'(.*)'(.*)} $word -> quoted after]} {
2229
+ set quoted [string map {~ " "} $quoted]
2230
+ regsub -all . $quoted "&\b&" quoted
2231
+ set word $quoted$after
2232
+ } elseif {[regexp {^[*](.*)[*](.*)} $word -> quoted after]} {
2233
+ set quoted [string map {~ " "} $quoted]
2234
+ regsub -all . $quoted "_\b&" quoted
2235
+ set word $quoted$after
2236
+ }
2237
+ puts -nonewline $space$word
2238
+ set space " "
2239
+ }
2240
+ if {[info exists partial]} {
2241
+ # Missing end of quote
2242
+ puts -nonewline $space$partial
2243
+ }
2244
+ if {$len} {
2245
+ puts ""
2246
+ }
18542247
}
18552248
proc title {text} {
1856
- underline [string trim $text] =
1857
- nl
2249
+ underline [string trim $text] =
2250
+ nl
18582251
}
18592252
proc p {text} {
1860
- wordwrap $text 80
1861
- nl
2253
+ wordwrap $text 80
2254
+ nl
18622255
}
18632256
proc codelines {lines} {
1864
- foreach line $lines {
1865
- puts " $line"
1866
- }
1867
- nl
2257
+ foreach line $lines {
2258
+ puts " $line"
2259
+ }
2260
+ nl
18682261
}
18692262
proc nl {} {
1870
- puts ""
2263
+ puts ""
18712264
}
18722265
proc underline {text char} {
1873
- regexp "^(\[ \t\]*)(.*)" $text -> indent words
1874
- puts $text
1875
- puts $indent[string repeat $char [string length $words]]
2266
+ regexp "^(\[ \t\]*)(.*)" $text -> indent words
2267
+ puts $text
2268
+ puts $indent[string repeat $char [string length $words]]
18762269
}
18772270
proc section {text} {
1878
- underline "[string trim $text]" -
1879
- nl
2271
+ underline "[string trim $text]" -
2272
+ nl
18802273
}
18812274
proc subsection {text} {
1882
- underline "$text" ~
1883
- nl
2275
+ underline "$text" ~
2276
+ nl
18842277
}
18852278
proc bullet {text} {
1886
- wordwrap $text 76 " * " " "
2279
+ wordwrap $text 76 " * " " "
18872280
}
18882281
proc indent {text} {
1889
- wordwrap $text 76 " " " "
2282
+ wordwrap $text 76 " " " "
18902283
}
18912284
proc defn {first args} {
1892
- if {$first ne ""} {
1893
- underline " $first" ~
1894
- }
1895
- foreach p $args {
1896
- if {$p ne ""} {
1897
- indent $p
1898
- }
1899
- }
2285
+ if {$first ne ""} {
2286
+ underline " $first" ~
2287
+ }
2288
+ foreach p $args {
2289
+ if {$p ne ""} {
2290
+ indent $p
2291
+ }
2292
+ }
2293
+}
2294
+}
2295
+
2296
+# ----- @module util.tcl -----
2297
+
2298
+set modsource(util.tcl) {
2299
+# Copyright (c) 2012 WorkWare Systems http://www.workware.net.au/
2300
+# All rights reserved
2301
+
2302
+# Module which contains miscellaneous utility functions
2303
+
2304
+# @compare-versions version1 version2
2305
+#
2306
+# Versions are of the form 'a.b.c' (may be any number of numeric components)
2307
+#
2308
+# Compares the two versions and returns:
2309
+## -1 if v1 < v2
2310
+## 0 if v1 == v2
2311
+## 1 if v1 > v2
2312
+#
2313
+# If one version has fewer components than the other, 0 is substituted to the right. e.g.
2314
+## 0.2 < 0.3
2315
+## 0.2.5 > 0.2
2316
+## 1.1 == 1.1.0
2317
+#
2318
+proc compare-versions {v1 v2} {
2319
+ foreach c1 [split $v1 .] c2 [split $v2 .] {
2320
+ if {$c1 eq ""} {
2321
+ set c1 0
2322
+ }
2323
+ if {$c2 eq ""} {
2324
+ set c2 0
2325
+ }
2326
+ if {$c1 < $c2} {
2327
+ return -1
2328
+ }
2329
+ if {$c1 > $c2} {
2330
+ return 1
2331
+ }
2332
+ }
2333
+ return 0
2334
+}
2335
+
2336
+# @suffix suf list
2337
+#
2338
+# Takes a list and returns a new list with '$suf' appended
2339
+# to each element
2340
+#
2341
+## suffix .c {a b c} => {a.c b.c c.c}
2342
+#
2343
+proc suffix {suf list} {
2344
+ set result {}
2345
+ foreach p $list {
2346
+ lappend result $p$suf
2347
+ }
2348
+ return $result
2349
+}
2350
+
2351
+# @prefix pre list
2352
+#
2353
+# Takes a list and returns a new list with '$pre' prepended
2354
+# to each element
2355
+#
2356
+## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
2357
+#
2358
+proc prefix {pre list} {
2359
+ set result {}
2360
+ foreach p $list {
2361
+ lappend result $pre$p
2362
+ }
2363
+ return $result
2364
+}
2365
+
2366
+# @lpop list
2367
+#
2368
+# Removes the last entry from the given list and returns it.
2369
+proc lpop {listname} {
2370
+ upvar $listname list
2371
+ set val [lindex $list end]
2372
+ set list [lrange $list 0 end-1]
2373
+ return $val
19002374
}
19012375
}
19022376
1903
-# ----- module wiki-formatting -----
2377
+# ----- @module wiki-formatting.tcl -----
19042378
1905
-set modsource(wiki-formatting) {
2379
+set modsource(wiki-formatting.tcl) {
19062380
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
19072381
# All rights reserved
19082382
19092383
# Module which provides text formatting
19102384
# wiki.tcl.tk format output
@@ -1975,11 +2449,11 @@
19752449
if {$autosetup(debug)} {
19762450
main $argv
19772451
}
19782452
if {[catch {main $argv} msg opts] == 1} {
19792453
show-notices
1980
- autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
2454
+ autosetup-full-error [error-dump $msg $opts $autosetup(debug)]
19812455
if {!$autosetup(debug)} {
19822456
puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
19832457
}
19842458
exit 1
19852459
}
19862460
19872461
ADDED autosetup/autosetup-config.guess
19882462
ADDED autosetup/autosetup-config.sub
19892463
ADDED autosetup/autosetup-find-tclsh
19902464
ADDED autosetup/autosetup-test-tclsh
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -1,16 +1,17 @@
1 #!/bin/sh
2 # Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
3 # All rights reserved
4 # vim:se syntax=tcl:
5 # \
6 dir=`dirname "$0"`; exec "`$dir/find-tclsh`" "$0" "$@"
7
8 set autosetup(version) 0.6.6
 
9
10 # Can be set to 1 to debug early-init problems
11 set autosetup(debug) 0
12
13 ##################################################################
14 #
15 # Main flow of control, option handling
16 #
@@ -72,14 +73,18 @@
72 set autosetup(cmdline) {}
73 # options is a list of known options
74 set autosetup(options) {}
75 # optset is a dictionary of option values set by the user based on getopt
76 set autosetup(optset) {}
77 # optdefault is a dictionary of default values for options
78 set autosetup(optdefault) {}
 
 
79 set autosetup(optionhelp) {}
80 set autosetup(showhelp) 0
 
 
81
82 # Parse options
83 use getopt
84
85 # At the is point we don't know what is a valid option
@@ -87,15 +92,28 @@
87 set autosetup(getopt) [getopt argv]
88
89 #"=Core Options:"
90 options-add {
91 help:=local => "display help and options. Optionally specify a module name, such as --help=system"
 
92 version => "display the version of autosetup"
93 ref:=text manual:=text
94 reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
95 debug => "display debugging output as autosetup runs"
96 install:=. => "install autosetup to the current or given directory (in the 'autosetup/' subdirectory)"
 
 
 
 
 
 
 
 
 
 
 
 
97 force init:=help => "create initial auto.def, etc. Use --init=help for known types"
98 # Undocumented options
99 option-checking=1
100 nopager
101 quiet
@@ -107,12 +125,12 @@
107 puts $autosetup(version)
108 exit 0
109 }
110
111 # autosetup --conf=alternate-auto.def
112 if {[opt-val conf] ne ""} {
113 set autosetup(autodef) [opt-val conf]
114 }
115
116 # Debugging output (set this early)
117 incr autosetup(debug) [opt-bool debug]
118 incr autosetup(force) [opt-bool force]
@@ -124,41 +142,50 @@
124 if {[file exists $autosetup(libdir)/local.tcl]} {
125 use local
126 }
127
128 # Now any auto-load modules
129 foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
130 automf_load source $file
131 }
132
133 if {[opt-val help] ne ""} {
134 incr autosetup(showhelp)
135 use help
136 autosetup_help [opt-val help]
137 }
138
139 if {[opt-val {manual ref reference}] ne ""} {
 
 
 
 
 
 
140 use help
141 autosetup_reference [opt-val {manual ref reference}]
142 }
143
144 # Allow combining --install and --init
145 set earlyexit 0
146 if {[opt-val install] ne ""} {
147 use install
148 autosetup_install [opt-val install]
149 incr earlyexit
150 }
151
152 if {[opt-val init] ne ""} {
153 use init
154 autosetup_init [opt-val init]
155 incr earlyexit
156 }
157
158 if {$earlyexit} {
159 exit 0
 
 
 
 
 
160 }
161
162 if {![file exists $autosetup(autodef)]} {
163 # Check for invalid option first
164 options {}
@@ -185,10 +212,11 @@
185 define-append AUTOREMAKE [get-define CONFIGURE_OPTS]
186
187
188 # Log how we were invoked
189 configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]"
 
190
191 # Note that auto.def is *not* loaded in the global scope
192 source $autosetup(autodef)
193
194 # Could warn here if options {} was not specified
@@ -210,14 +238,14 @@
210 #
211 # Check each of the named, boolean options and if any have been explicitly enabled
212 # or disabled by the user, return 1 or 0 accordingly.
213 #
214 # If the option was specified more than once, the last value wins.
215 # e.g. With --enable-foo --disable-foo, [opt-bool foo] will return 0
216 #
217 # If no value was specified by the user, returns the default value for the
218 # first option. If -nodefault is given, this behaviour changes and
219 # -1 is returned instead.
220 #
221 proc opt-bool {args} {
222 set nodefault 0
223 if {[lindex $args 0] eq "-nodefault"} {
@@ -237,20 +265,19 @@
237 }
238 # Default value is the default for the first option
239 return [dict get $::autosetup(optdefault) [lindex $args 0]]
240 }
241
242 # @opt-val option-list ?default=""?
243 #
244 # Returns a list containing all the values given for the non-boolean options in 'option-list'.
245 # There will be one entry in the list for each option given by the user, including if the
246 # same option was used multiple times.
247 # If only a single value is required, use something like:
248 #
249 ## lindex [opt-val $names] end
250 #
251 # If no options were set, $default is returned (exactly, not as a list).
252 #
253 proc opt-val {names {default ""}} {
254 option-check-names {*}$names
255
256 foreach opt $names {
@@ -261,10 +288,83 @@
261 if {[info exists result]} {
262 return $result
263 }
264 return $default
265 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
267 proc option-check-names {args} {
268 foreach o $args {
269 if {$o ni $::autosetup(options)} {
270 autosetup-error "Request for undeclared option --$o"
@@ -293,10 +393,11 @@
293 # This is a special heading
294 lappend autosetup(optionhelp) $opt ""
295 set header {}
296 continue
297 }
 
298
299 #puts "i=$i, opt=$opt"
300 regexp {^([^:=]*)(:)?(=)?(.*)$} $opt -> name colon equal value
301 if {$name in $autosetup(options)} {
302 autosetup-error "Option $name already specified"
@@ -310,10 +411,16 @@
310 # This is a documentation-only option, like "-C <dir>"
311 set opthelp $opt
312 } elseif {$colon eq ""} {
313 # Boolean option
314 lappend autosetup(options) $name
 
 
 
 
 
 
315
316 if {$value eq "1"} {
317 set opthelp "--disable-$name"
318 } else {
319 set opthelp "--$name"
@@ -321,11 +428,12 @@
321
322 # Set the default
323 if {$value eq ""} {
324 set value 0
325 }
326 dict set autosetup(optdefault) $name $value
 
327
328 if {[dict exists $autosetup(getopt) $name]} {
329 # The option was specified by the user. Look at the last value.
330 lassign [lindex [dict get $autosetup(getopt) $name] end] type setvalue
331 if {$type eq "str"} {
@@ -342,19 +450,39 @@
342 #puts "Found boolean option --$name=$setvalue"
343 }
344 } else {
345 # String option.
346 lappend autosetup(options) $name
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
348 if {$equal eq "="} {
349 # String option with optional value
350 set opthelp "--$name?=$value?"
351 } else {
352 # String option with required value
353 set opthelp "--$name=$value"
354 }
355 dict set autosetup(optdefault) $name $value
356
357 # Get the values specified by the user
358 if {[dict exists $autosetup(getopt) $name]} {
359 set listvalue {}
360
@@ -363,11 +491,11 @@
363 if {$type eq "bool" && $setvalue} {
364 if {$equal ne "="} {
365 user-error "Option --$name requires a value"
366 }
367 # If given as a boolean, use the default value
368 set setvalue $value
369 }
370 lappend listvalue $setvalue
371 }
372
373 #puts "Found string option --$name=$listvalue"
@@ -376,10 +504,13 @@
376 }
377
378 # Now create the help for this option if appropriate
379 if {[lindex $opts $i+1] eq "=>"} {
380 set desc [lindex $opts $i+2]
 
 
 
381 #string match \n* $desc
382 if {$header ne ""} {
383 lappend autosetup(optionhelp) $header ""
384 set header ""
385 }
@@ -463,35 +594,39 @@
463 options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2]
464 }
465 }
466 }
467
468 # @options options-spec
469 #
470 # Specifies configuration-time options which may be selected by the user
471 # and checked with opt-val and opt-bool. The format of options-spec follows.
 
472 #
473 # A boolean option is of the form:
474 #
475 ## name[=0|1] => "Description of this boolean option"
476 #
477 # The default is name=0, meaning that the option is disabled by default.
478 # If name=1 is used to make the option enabled by default, the description should reflect
479 # that with text like "Disable support for ...".
480 #
481 # An argument option (one which takes a parameter) is of the form:
482 #
483 ## name:[=]value => "Description of this option"
484 #
485 # If the name:value form is used, the value must be provided with the option (as --name=myvalue).
486 # If the name:=value form is used, the value is optional and the given value is used as the default
487 # if it is not provided.
488 #
489 # Undocumented options are also supported by omitting the "=> description.
490 # These options are not displayed with --help and can be useful for internal options or as aliases.
491 #
492 # For example, --disable-lfs is an alias for --disable=largefile:
 
 
 
493 #
494 ## lfs=1 largefile=1 => "Disable large file support"
495 #
496 proc options {optlist} {
497 # Allow options as a list or args
@@ -509,27 +644,37 @@
509 user-error "Unknown option --$o"
510 }
511 }
512 }
513 }
 
 
 
 
 
 
 
 
 
 
 
514
515 proc config_guess {} {
516 if {[file-isexec $::autosetup(dir)/config.guess]} {
517 exec-with-stderr sh $::autosetup(dir)/config.guess
518 if {[catch {exec-with-stderr sh $::autosetup(dir)/config.guess} alias]} {
519 user-error $alias
520 }
521 return $alias
522 } else {
523 configlog "No config.guess, so using uname"
524 string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
525 }
526 }
527
528 proc config_sub {alias} {
529 if {[file-isexec $::autosetup(dir)/config.sub]} {
530 if {[catch {exec-with-stderr sh $::autosetup(dir)/config.sub $alias} alias]} {
531 user-error $alias
532 }
533 }
534 return $alias
535 }
@@ -536,39 +681,48 @@
536
537 # @define name ?value=1?
538 #
539 # Defines the named variable to the given value.
540 # These (name, value) pairs represent the results of the configuration check
541 # and are available to be checked, modified and substituted.
542 #
543 proc define {name {value 1}} {
544 set ::define($name) $value
545 #dputs "$name <= $value"
546 }
547
548 # @undefine name
549 #
550 # Undefine the named variable
551 #
552 proc undefine {name} {
553 unset -nocomplain ::define($name)
554 #dputs "$name <= <undef>"
555 }
556
557 # @define-append name value ...
558 #
559 # Appends the given value(s) to the given 'defined' variable.
560 # If the variable is not defined or empty, it is set to $value.
561 # Otherwise the value is appended, separated by a space.
562 # Any extra values are similarly appended.
563 # If any value is already contained in the variable (as a substring) it is omitted.
564 #
565 proc define-append {name args} {
566 if {[get-define $name ""] ne ""} {
567 # Make a token attempt to avoid duplicates
568 foreach arg $args {
569 if {[string first $arg $::define($name)] == -1} {
 
 
 
 
 
 
 
 
 
570 append ::define($name) " " $arg
571 }
572 }
573 } else {
574 set ::define($name) [join $args]
@@ -576,11 +730,11 @@
576 #dputs "$name += [join $args] => $::define($name)"
577 }
578
579 # @get-define name ?default=0?
580 #
581 # Returns the current value of the 'defined' variable, or $default
582 # if not set.
583 #
584 proc get-define {name {default 0}} {
585 if {[info exists ::define($name)]} {
586 #dputs "$name => $::define($name)"
@@ -595,14 +749,26 @@
595 # Returns 1 if the given variable is defined.
596 #
597 proc is-defined {name} {
598 info exists ::define($name)
599 }
 
 
 
 
 
 
 
 
 
 
 
 
600
601 # @all-defines
602 #
603 # Returns a dictionary (name value list) of all defined variables.
604 #
605 # This is suitable for use with 'dict', 'array set' or 'foreach'
606 # and allows for arbitrary processing of the defined variables.
607 #
608 proc all-defines {} {
@@ -610,13 +776,13 @@
610 }
611
612
613 # @get-env name default
614 #
615 # If $name was specified on the command line, return it.
616 # If $name was set in the environment, return it.
617 # Otherwise return $default.
618 #
619 proc get-env {name default} {
620 if {[dict exists $::autosetup(cmdline) $name]} {
621 return [dict get $::autosetup(cmdline) $name]
622 }
@@ -623,11 +789,11 @@
623 getenv $name $default
624 }
625
626 # @env-is-set name
627 #
628 # Returns 1 if the $name was specified on the command line or in the environment.
629 # Note that an empty environment variable is not considered to be set.
630 #
631 proc env-is-set {name} {
632 if {[dict exists $::autosetup(cmdline) $name]} {
633 return 1
@@ -639,11 +805,11 @@
639 }
640
641 # @readfile filename ?default=""?
642 #
643 # Return the contents of the file, without the trailing newline.
644 # If the file doesn't exist or can't be read, returns $default.
645 #
646 proc readfile {filename {default_value ""}} {
647 set result $default_value
648 catch {
649 set f [open $filename]
@@ -653,11 +819,11 @@
653 return $result
654 }
655
656 # @writefile filename value
657 #
658 # Creates the given file containing $value.
659 # Does not add an extra newline.
660 #
661 proc writefile {filename value} {
662 set f [open $filename w]
663 puts -nonewline $f $value
@@ -677,63 +843,60 @@
677 lappend args [quote-if-needed $arg]
678 }
679 join $args
680 }
681
682 # @suffix suf list
683 #
684 # Takes a list and returns a new list with $suf appended
685 # to each element
686 #
687 ## suffix .c {a b c} => {a.c b.c c.c}
688 #
689 proc suffix {suf list} {
690 set result {}
691 foreach p $list {
692 lappend result $p$suf
 
 
693 }
694 return $result
695 }
696
697 # @prefix pre list
698 #
699 # Takes a list and returns a new list with $pre prepended
700 # to each element
701 #
702 ## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
703 #
704 proc prefix {pre list} {
705 set result {}
706 foreach p $list {
707 lappend result $pre$p
708 }
709 return $result
 
 
 
 
 
 
 
 
 
 
710 }
711
712 # @find-executable name
713 #
714 # Searches the path for an executable with the given name.
715 # Note that the name may include some parameters, e.g. "cc -mbig-endian",
716 # in which case the parameters are ignored.
717 # Returns 1 if found, or 0 if not.
718 #
719 proc find-executable {name} {
720 # Ignore any parameters
721 set name [lindex $name 0]
722 if {$name eq ""} {
723 # The empty string is never a valid executable
724 return 0
725 }
726 foreach p [split-path] {
727 dputs "Looking for $name in $p"
728 set exec [file join $p $name]
729 if {[file-isexec $exec]} {
730 dputs "Found $name -> $exec"
731 return 1
732 }
733 }
734 return 0
735 }
736
737 # @find-an-executable ?-required? name ...
738 #
739 # Given a list of possible executable names,
@@ -764,11 +927,11 @@
764 return ""
765 }
766
767 # @configlog msg
768 #
769 # Writes the given message to the configuration log, config.log
770 #
771 proc configlog {msg} {
772 if {![info exists ::autosetup(logfh)]} {
773 set ::autosetup(logfh) [open config.log w]
774 }
@@ -800,12 +963,12 @@
800 }
801 }
802
803 # @msg-quiet command ...
804 #
805 # msg-quiet evaluates it's arguments as a command with output
806 # from msg-checking and msg-result suppressed.
807 #
808 # This is useful if a check needs to run a subcheck which isn't
809 # of interest to the user.
810 proc msg-quiet {args} {
811 incr ::autosetup(msg-quiet)
@@ -841,11 +1004,11 @@
841
842 # @user-error msg
843 #
844 # Indicate incorrect usage to the user, including if required components
845 # or features are not found.
846 # autosetup exits with a non-zero return code.
847 #
848 proc user-error {msg} {
849 show-notices
850 puts stderr "Error: $msg"
851 puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
@@ -887,10 +1050,21 @@
887 proc maybe-show-timestamp {} {
888 if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
889 puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
890 }
891 }
 
 
 
 
 
 
 
 
 
 
 
892
893 proc autosetup_version {} {
894 return "autosetup v$::autosetup(version)"
895 }
896
@@ -986,23 +1160,35 @@
986 # The latter form is useful for a complex module which requires additional
987 # support file. In this form, '$::usedir' is set to the module directory
988 # when it is loaded.
989 #
990 proc use {args} {
 
 
 
 
 
 
991 foreach m $args {
992 if {[info exists ::libmodule($m)]} {
993 continue
994 }
995 set ::libmodule($m) 1
996 if {[info exists ::modsource($m)]} {
997 automf_load eval $::modsource($m)
998 } else {
999 set sources [list $::autosetup(libdir)/${m}.tcl $::autosetup(libdir)/${m}/init.tcl]
1000 set found 0
1001 foreach source $sources {
1002 if {[file exists $source]} {
1003 incr found
 
 
 
 
 
 
1004 break
1005 }
1006 }
1007 if {$found} {
1008 # For the convenience of the "use" source, point to the directory
@@ -1014,10 +1200,22 @@
1014 autosetup-error "use: No such module: $m"
1015 }
1016 }
1017 }
1018 }
 
 
 
 
 
 
 
 
 
 
 
 
1019
1020 # Load module source in the global scope by executing the given command
1021 proc automf_load {args} {
1022 if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
1023 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
@@ -1027,18 +1225,21 @@
1027 # Initial settings
1028 set autosetup(exe) $::argv0
1029 set autosetup(istcl) 1
1030 set autosetup(start) [clock millis]
1031 set autosetup(installed) 0
 
1032 set autosetup(msg-checking) 0
1033 set autosetup(msg-quiet) 0
 
1034
1035 # Embedded modules are inserted below here
1036 set autosetup(installed) 1
1037 # ----- module asciidoc-formatting -----
 
1038
1039 set modsource(asciidoc-formatting) {
1040 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1041 # All rights reserved
1042
1043 # Module which provides text formatting
1044 # asciidoc format
@@ -1102,19 +1303,19 @@
1102 regsub -all "\n\n" $defn "\n ::\n" defn
1103 puts $defn
1104 }
1105 }
1106
1107 # ----- module formatting -----
1108
1109 set modsource(formatting) {
1110 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1111 # All rights reserved
1112
1113 # Module which provides common text formatting
1114
1115 # This is designed for documenation which looks like:
1116 # code {...}
1117 # or
1118 # code {
1119 # ...
1120 # ...
@@ -1159,13 +1360,13 @@
1159 # Return the result
1160 return $lines
1161 }
1162 }
1163
1164 # ----- module getopt -----
1165
1166 set modsource(getopt) {
1167 # Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
1168 # All rights reserved
1169
1170 # Simple getopt module
1171
@@ -1197,11 +1398,11 @@
1197
1198 if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
1199 # --name=value
1200 dict lappend opts $name [list str $value]
1201 } elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
1202 if {$prefix in {enable- with- ""}} {
1203 set value 1
1204 } else {
1205 set value 0
1206 }
1207 dict lappend opts $name [list bool $value]
@@ -1218,13 +1419,13 @@
1218
1219 return $opts
1220 }
1221 }
1222
1223 # ----- module help -----
1224
1225 set modsource(help) {
1226 # Copyright (c) 2010 WorkWare Systems http://workware.net.au/
1227 # All rights reserved
1228
1229 # Module which provides usage, help and the command reference
1230
@@ -1251,10 +1452,28 @@
1251 options-show
1252 }
1253 }
1254 exit 0
1255 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1256
1257 # If not already paged and stdout is a tty, pipe the output through the pager
1258 # This is done by reinvoking autosetup with --nopager added
1259 proc use_pager {} {
1260 if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
@@ -1304,10 +1523,16 @@
1304 }
1305
1306 proc autosetup_output_block {type lines} {
1307 if {[llength $lines]} {
1308 switch $type {
 
 
 
 
 
 
1309 code {
1310 codelines $lines
1311 }
1312 p {
1313 p [join $lines]
@@ -1325,30 +1550,45 @@
1325 # Generate a command reference from inline documentation
1326 proc automf_command_reference {} {
1327 lappend files $::autosetup(prog)
1328 lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
1329
1330 section "Core Commands"
1331 set type p
1332 set lines {}
1333 set cmd {}
 
 
 
 
 
 
 
1334
1335 foreach file $files {
 
 
1336 set f [open $file]
1337 while {![eof $f]} {
1338 set line [gets $f]
 
 
 
 
 
1339
1340 # Find lines starting with "# @*" and continuing through the remaining comment lines
1341 if {![regexp {^# @(.*)} $line -> cmd]} {
1342 continue
1343 }
1344
1345 # Synopsis or command?
1346 if {$cmd eq "synopsis:"} {
1347 section "Module: [file rootname [file tail $file]]"
 
1348 } else {
1349 subsection $cmd
1350 }
1351
1352 set lines {}
1353 set type p
1354
@@ -1369,29 +1609,38 @@
1369
1370 #puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
1371
1372 if {$t ne $type || $cmd eq ""} {
1373 # Finish the current block
1374 autosetup_output_block $type $lines
1375 set lines {}
1376 set type $t
1377 }
1378 if {$cmd ne ""} {
1379 lappend lines $cmd
1380 }
1381 }
1382
1383 autosetup_output_block $type $lines
1384 }
1385 close $f
1386 }
 
 
 
 
 
 
 
 
 
1387 }
1388 }
1389
1390 # ----- module init -----
1391
1392 set modsource(init) {
1393 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1394 # All rights reserved
1395
1396 # Module to help create auto.def and configure
1397
@@ -1444,79 +1693,157 @@
1444 }
1445 writefile $filename $contents
1446 }
1447 }
1448
1449 # ----- module install -----
1450
1451 set modsource(install) {
1452 # Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
1453 # All rights reserved
1454
1455 # Module which can install autosetup
1456
1457 proc autosetup_install {dir} {
1458 if {[catch {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1459 cd $dir
 
 
 
 
1460 file mkdir autosetup
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1461
1462 set f [open autosetup/autosetup w]
1463
1464 set publicmodules [glob $::autosetup(libdir)/*.auto]
1465
1466 # First the main script, but only up until "CUT HERE"
1467 set in [open $::autosetup(dir)/autosetup]
1468 while {[gets $in buf] >= 0} {
1469 if {$buf ne "##-- CUT HERE --##"} {
1470 puts $f $buf
1471 continue
1472 }
1473
1474 # Insert the static modules here
1475 # i.e. those which don't contain @synopsis:
 
1476 puts $f "set autosetup(installed) 1"
1477 foreach file [lsort [glob $::autosetup(libdir)/*.tcl]] {
 
 
 
1478 set buf [readfile $file]
1479 if {[string match "*\n# @synopsis:*" $buf]} {
1480 lappend publicmodules $file
1481 continue
 
 
1482 }
1483 set modname [file rootname [file tail $file]]
1484 puts $f "# ----- module $modname -----"
1485 puts $f "\nset modsource($modname) \{"
1486 puts $f $buf
1487 puts $f "\}\n"
1488 }
 
 
 
 
 
 
 
1489 }
1490 close $in
1491 close $f
1492 exec chmod 755 autosetup/autosetup
 
 
 
 
 
 
1493
1494 # Install public modules
1495 foreach file $publicmodules {
1496 autosetup_install_file $file autosetup
 
 
 
 
 
 
1497 }
1498
1499 # Install support files
1500 foreach file {config.guess config.sub jimsh0.c find-tclsh test-tclsh LICENSE} {
1501 autosetup_install_file $::autosetup(dir)/$file autosetup
1502 }
1503 exec chmod 755 autosetup/config.sub autosetup/config.guess autosetup/find-tclsh
1504
1505 writefile autosetup/README.autosetup \
1506 "This is [autosetup_version]. See http://msteveb.github.com/autosetup/\n"
1507
 
 
 
 
 
 
 
 
1508 } error]} {
1509 user-error "Failed to install autosetup: $error"
1510 }
1511 puts "Installed [autosetup_version] to autosetup/"
 
 
 
 
 
1512
1513 # Now create 'configure' if necessary
1514 autosetup_create_configure
 
 
1515 }
1516
1517 proc autosetup_create_configure {} {
1518 if {[file exists configure]} {
1519 if {!$::autosetup(force)} {
1520 # Could this be an autosetup configure?
1521 if {![string match "*\nWRAPPER=*" [readfile configure]]} {
1522 puts "I see configure, but not created by autosetup, so I won't overwrite it."
@@ -1527,40 +1854,75 @@
1527 puts "I will overwrite the existing configure because you used --force."
1528 }
1529 } else {
1530 puts "I don't see configure, so I will create it."
1531 }
1532 writefile configure \
 
 
 
 
 
 
1533 {#!/bin/sh
1534 dir="`dirname "$0"`/autosetup"
1535 WRAPPER="$0"; export WRAPPER; exec "`$dir/find-tclsh`" "$dir/autosetup" "$@"
1536 }
 
1537 catch {exec chmod 755 configure}
1538 }
1539
1540 # Append the contents of $file to filehandle $f
1541 proc autosetup_install_append {f file} {
 
1542 set in [open $file]
1543 puts $f [read $in]
1544 close $in
1545 }
1546
1547 proc autosetup_install_file {file dir} {
1548 if {![file exists $file]} {
1549 error "Missing installation file '$file'"
1550 }
1551 writefile [file join $dir [file tail $file]] [readfile $file]\n
1552 }
1553
1554 if {$::autosetup(installed)} {
1555 user-error "autosetup can only be installed from development source, not from installed copy"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1556 }
1557 }
1558
1559 # ----- module markdown-formatting -----
1560
1561 set modsource(markdown-formatting) {
1562 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1563 # All rights reserved
1564
1565 # Module which provides text formatting
1566 # markdown format (kramdown syntax)
@@ -1627,13 +1989,13 @@
1627 }
1628 puts "$defn"
1629 }
1630 }
1631
1632 # ----- module misc -----
1633
1634 set modsource(misc) {
1635 # Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
1636 # All rights reserved
1637
1638 # Module containing misc procs useful to modules
1639 # Largely for platform compatibility
@@ -1805,106 +2167,218 @@
1805 string trim $result
1806 }
1807 }
1808 }
1809
1810 # ----- module text-formatting -----
1811
1812 set modsource(text-formatting) {
1813 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1814 # All rights reserved
1815
1816 # Module which provides text formatting
1817
1818 use formatting
1819
1820 proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
1821 set len 0
1822 set space $firstprefix
1823 foreach word [split $text] {
1824 set word [string trim $word]
1825 if {$word == ""} {
1826 continue
1827 }
1828 if {$len && [string length $space$word] + $len >= $length} {
1829 puts ""
1830 set len 0
1831 set space $nextprefix
1832 }
1833 incr len [string length $space$word]
1834
1835 # Use man-page conventions for highlighting 'quoted' and *quoted*
1836 # single words.
1837 # Use x^Hx for *bold* and _^Hx for 'underline'.
1838 #
1839 # less and more will both understand this.
1840 # Pipe through 'col -b' to remove them.
1841 if {[regexp {^'(.*)'([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1842 regsub -all . $bareword "_\b&" word
1843 append word $dot
1844 } elseif {[regexp {^[*](.*)[*]([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1845 regsub -all . $bareword "&\b&" word
1846 append word $dot
1847 }
1848 puts -nonewline $space$word
1849 set space " "
1850 }
1851 if {$len} {
1852 puts ""
1853 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1854 }
1855 proc title {text} {
1856 underline [string trim $text] =
1857 nl
1858 }
1859 proc p {text} {
1860 wordwrap $text 80
1861 nl
1862 }
1863 proc codelines {lines} {
1864 foreach line $lines {
1865 puts " $line"
1866 }
1867 nl
1868 }
1869 proc nl {} {
1870 puts ""
1871 }
1872 proc underline {text char} {
1873 regexp "^(\[ \t\]*)(.*)" $text -> indent words
1874 puts $text
1875 puts $indent[string repeat $char [string length $words]]
1876 }
1877 proc section {text} {
1878 underline "[string trim $text]" -
1879 nl
1880 }
1881 proc subsection {text} {
1882 underline "$text" ~
1883 nl
1884 }
1885 proc bullet {text} {
1886 wordwrap $text 76 " * " " "
1887 }
1888 proc indent {text} {
1889 wordwrap $text 76 " " " "
1890 }
1891 proc defn {first args} {
1892 if {$first ne ""} {
1893 underline " $first" ~
1894 }
1895 foreach p $args {
1896 if {$p ne ""} {
1897 indent $p
1898 }
1899 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1900 }
1901 }
1902
1903 # ----- module wiki-formatting -----
1904
1905 set modsource(wiki-formatting) {
1906 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1907 # All rights reserved
1908
1909 # Module which provides text formatting
1910 # wiki.tcl.tk format output
@@ -1975,11 +2449,11 @@
1975 if {$autosetup(debug)} {
1976 main $argv
1977 }
1978 if {[catch {main $argv} msg opts] == 1} {
1979 show-notices
1980 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
1981 if {!$autosetup(debug)} {
1982 puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
1983 }
1984 exit 1
1985 }
1986
1987 DDED autosetup/autosetup-config.guess
1988 DDED autosetup/autosetup-config.sub
1989 DDED autosetup/autosetup-find-tclsh
1990 DDED autosetup/autosetup-test-tclsh
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -1,16 +1,17 @@
1 #!/bin/sh
2 # Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
3 # All rights reserved
4 # vim:se syntax=tcl:
5 # \
6 dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@"
7
8 # Note that the version has a trailing + on unreleased versions
9 set autosetup(version) 0.6.9
10
11 # Can be set to 1 to debug early-init problems
12 set autosetup(debug) [expr {"--debug" in $argv}]
13
14 ##################################################################
15 #
16 # Main flow of control, option handling
17 #
@@ -72,14 +73,18 @@
73 set autosetup(cmdline) {}
74 # options is a list of known options
75 set autosetup(options) {}
76 # optset is a dictionary of option values set by the user based on getopt
77 set autosetup(optset) {}
78 # optdefault is a dictionary of default values
79 set autosetup(optdefault) {}
80 # options-defaults is a dictionary of overrides for default values for options
81 set autosetup(options-defaults) {}
82 set autosetup(optionhelp) {}
83 set autosetup(showhelp) 0
84
85 use util
86
87 # Parse options
88 use getopt
89
90 # At the is point we don't know what is a valid option
@@ -87,15 +92,28 @@
92 set autosetup(getopt) [getopt argv]
93
94 #"=Core Options:"
95 options-add {
96 help:=local => "display help and options. Optionally specify a module name, such as --help=system"
97 licence license => "display the autosetup license"
98 version => "display the version of autosetup"
99 ref:=text manual:=text
100 reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
101 debug => "display debugging output as autosetup runs"
102 install:=. => "install autosetup to the current or given directory"
103 }
104 if {$autosetup(installed)} {
105 # hidden options so we can produce a nice error
106 options-add {
107 sysinstall:path
108 }
109 } else {
110 options-add {
111 sysinstall:path => "install standalone autosetup to the given directory (e.g.: /usr/local)"
112 }
113 }
114 options-add {
115 force init:=help => "create initial auto.def, etc. Use --init=help for known types"
116 # Undocumented options
117 option-checking=1
118 nopager
119 quiet
@@ -107,12 +125,12 @@
125 puts $autosetup(version)
126 exit 0
127 }
128
129 # autosetup --conf=alternate-auto.def
130 if {[opt-str conf o]} {
131 set autosetup(autodef) $o
132 }
133
134 # Debugging output (set this early)
135 incr autosetup(debug) [opt-bool debug]
136 incr autosetup(force) [opt-bool force]
@@ -124,41 +142,50 @@
142 if {[file exists $autosetup(libdir)/local.tcl]} {
143 use local
144 }
145
146 # Now any auto-load modules
147 autosetup_load_auto_modules
 
 
148
149 if {[opt-str help o]} {
150 incr autosetup(showhelp)
151 use help
152 autosetup_help $o
153 }
154
155 if {[opt-bool licence license]} {
156 use help
157 autosetup_show_license
158 exit 0
159 }
160
161 if {[opt-str {manual ref reference} o]} {
162 use help
163 autosetup_reference $o
164 }
165
166 # Allow combining --install and --init
167 set earlyexit 0
168 if {[opt-str install o]} {
169 use install
170 autosetup_install $o
171 incr earlyexit
172 }
173
174 if {[opt-str init o]} {
175 use init
176 autosetup_init $o
177 incr earlyexit
178 }
179
180 if {$earlyexit} {
181 exit 0
182 }
183 if {[opt-str sysinstall o]} {
184 use install
185 autosetup_install $o 1
186 exit 0
187 }
188
189 if {![file exists $autosetup(autodef)]} {
190 # Check for invalid option first
191 options {}
@@ -185,10 +212,11 @@
212 define-append AUTOREMAKE [get-define CONFIGURE_OPTS]
213
214
215 # Log how we were invoked
216 configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]"
217 configlog "Tclsh: [info nameofexecutable]"
218
219 # Note that auto.def is *not* loaded in the global scope
220 source $autosetup(autodef)
221
222 # Could warn here if options {} was not specified
@@ -210,14 +238,14 @@
238 #
239 # Check each of the named, boolean options and if any have been explicitly enabled
240 # or disabled by the user, return 1 or 0 accordingly.
241 #
242 # If the option was specified more than once, the last value wins.
243 # e.g. With '--enable-foo --disable-foo', '[opt-bool foo]' will return 0
244 #
245 # If no value was specified by the user, returns the default value for the
246 # first option. If '-nodefault' is given, this behaviour changes and
247 # -1 is returned instead.
248 #
249 proc opt-bool {args} {
250 set nodefault 0
251 if {[lindex $args 0] eq "-nodefault"} {
@@ -237,20 +265,19 @@
265 }
266 # Default value is the default for the first option
267 return [dict get $::autosetup(optdefault) [lindex $args 0]]
268 }
269
270 # @opt-val optionlist ?default=""?
271 #
272 # Returns a list containing all the values given for the non-boolean options in '$optionlist'.
273 # There will be one entry in the list for each option given by the user, including if the
274 # same option was used multiple times.
 
275 #
276 # If no options were set, '$default' is returned (exactly, not as a list).
277 #
278 # Note: For most use cases, 'opt-str' should be preferred.
279 #
280 proc opt-val {names {default ""}} {
281 option-check-names {*}$names
282
283 foreach opt $names {
@@ -261,10 +288,83 @@
288 if {[info exists result]} {
289 return $result
290 }
291 return $default
292 }
293
294 # @opt-str optionlist varname ?default?
295 #
296 # Sets '$varname' in the callers scope to the value for one of the given options.
297 #
298 # For the list of options given in '$optionlist', if any value is set for any option,
299 # the option value is taken to be the *last* value of the last option (in the order given).
300 #
301 # If no option was given, and a default was specified with 'options-defaults',
302 # that value is used.
303 #
304 # If no 'options-defaults' value was given and '$default' was given, it is used.
305 #
306 # If none of the above provided a value, no value is set.
307 #
308 # The return value depends on whether '$default' was specified.
309 # If it was, the option value is returned.
310 # If it was not, 1 is returns if a value was set, or 0 if not.
311 #
312 # Typical usage is as follows:
313 #
314 ## if {[opt-str {myopt altname} o]} {
315 ## do something with $o
316 ## }
317 #
318 # Or:
319 ## define myname [opt-str {myopt altname} o "/usr/local"]
320 #
321 proc opt-str {names varname args} {
322 global autosetup
323
324 option-check-names {*}$names
325 upvar $varname value
326
327 if {[llength $args]} {
328 # A default was given, so always return the string value of the option
329 set default [lindex $args 0]
330 set retopt 1
331 } else {
332 # No default, so return 0 or 1 to indicate if a value was found
333 set retopt 0
334 }
335
336 foreach opt $names {
337 if {[dict exists $::autosetup(optset) $opt]} {
338 set result [lindex [dict get $::autosetup(optset) $opt] end]
339 }
340 }
341
342 if {![info exists result]} {
343 # No user-specified value. Has options-defaults been set?
344 foreach opt $names {
345 if {[dict exists $::autosetup(options-defaults) $opt]} {
346 set result [dict get $autosetup(options-defaults) $opt]
347 }
348 }
349 }
350
351 if {[info exists result]} {
352 set value $result
353 if {$retopt} {
354 return $value
355 }
356 return 1
357 }
358
359 if {$retopt} {
360 set value $default
361 return $value
362 }
363
364 return 0
365 }
366
367 proc option-check-names {args} {
368 foreach o $args {
369 if {$o ni $::autosetup(options)} {
370 autosetup-error "Request for undeclared option --$o"
@@ -293,10 +393,11 @@
393 # This is a special heading
394 lappend autosetup(optionhelp) $opt ""
395 set header {}
396 continue
397 }
398 unset -nocomplain defaultvalue equal value
399
400 #puts "i=$i, opt=$opt"
401 regexp {^([^:=]*)(:)?(=)?(.*)$} $opt -> name colon equal value
402 if {$name in $autosetup(options)} {
403 autosetup-error "Option $name already specified"
@@ -310,10 +411,16 @@
411 # This is a documentation-only option, like "-C <dir>"
412 set opthelp $opt
413 } elseif {$colon eq ""} {
414 # Boolean option
415 lappend autosetup(options) $name
416
417 # Check for override
418 if {[dict exists $autosetup(options-defaults) $name]} {
419 # A default was specified with options-defaults, so use it
420 set value [dict get $autosetup(options-defaults) $name]
421 }
422
423 if {$value eq "1"} {
424 set opthelp "--disable-$name"
425 } else {
426 set opthelp "--$name"
@@ -321,11 +428,12 @@
428
429 # Set the default
430 if {$value eq ""} {
431 set value 0
432 }
433 set defaultvalue $value
434 dict set autosetup(optdefault) $name $defaultvalue
435
436 if {[dict exists $autosetup(getopt) $name]} {
437 # The option was specified by the user. Look at the last value.
438 lassign [lindex [dict get $autosetup(getopt) $name] end] type setvalue
439 if {$type eq "str"} {
@@ -342,19 +450,39 @@
450 #puts "Found boolean option --$name=$setvalue"
451 }
452 } else {
453 # String option.
454 lappend autosetup(options) $name
455
456 if {$colon eq ":"} {
457 # Was ":name=default" given?
458 # If so, set $value to the display name and $defaultvalue to the default
459 # (This is the preferred way to set a default value for a string option)
460 if {[regexp {^([^=]+)=(.*)$} $value -> value defaultvalue]} {
461 dict set autosetup(optdefault) $name $defaultvalue
462 }
463 }
464
465 # Maybe override the default value
466 if {[dict exists $autosetup(options-defaults) $name]} {
467 # A default was specified with options-defaults, so use it
468 set defaultvalue [dict get $autosetup(options-defaults) $name]
469 dict set autosetup(optdefault) $name $defaultvalue
470 } elseif {![info exists defaultvalue]} {
471 # For backward compatibility, if ":name" was given, use name as both
472 # the display text and the default value, but only if the user
473 # specified the option without the value
474 set defaultvalue $value
475 }
476
477 if {$equal eq "="} {
478 # String option with optional value
479 set opthelp "--$name?=$value?"
480 } else {
481 # String option with required value
482 set opthelp "--$name=$value"
483 }
 
484
485 # Get the values specified by the user
486 if {[dict exists $autosetup(getopt) $name]} {
487 set listvalue {}
488
@@ -363,11 +491,11 @@
491 if {$type eq "bool" && $setvalue} {
492 if {$equal ne "="} {
493 user-error "Option --$name requires a value"
494 }
495 # If given as a boolean, use the default value
496 set setvalue $defaultvalue
497 }
498 lappend listvalue $setvalue
499 }
500
501 #puts "Found string option --$name=$listvalue"
@@ -376,10 +504,13 @@
504 }
505
506 # Now create the help for this option if appropriate
507 if {[lindex $opts $i+1] eq "=>"} {
508 set desc [lindex $opts $i+2]
509 if {[info exists defaultvalue]} {
510 set desc [string map [list @default@ $defaultvalue] $desc]
511 }
512 #string match \n* $desc
513 if {$header ne ""} {
514 lappend autosetup(optionhelp) $header ""
515 set header ""
516 }
@@ -463,35 +594,39 @@
594 options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2]
595 }
596 }
597 }
598
599 # @options optionspec
600 #
601 # Specifies configuration-time options which may be selected by the user
602 # and checked with 'opt-str' and 'opt-bool'. '$optionspec' contains a series
603 # of options specifications separated by newlines, as follows:
604 #
605 # A boolean option is of the form:
606 #
607 ## name[=0|1] => "Description of this boolean option"
608 #
609 # The default is 'name=0', meaning that the option is disabled by default.
610 # If 'name=1' is used to make the option enabled by default, the description should reflect
611 # that with text like "Disable support for ...".
612 #
613 # An argument option (one which takes a parameter) is of the form:
614 #
615 ## name:[=]value => "Description of this option"
616 #
617 # If the 'name:value' form is used, the value must be provided with the option (as '--name=myvalue').
618 # If the 'name:=value' form is used, the value is optional and the given value is used as the default
619 # if it is not provided.
620 #
621 # The description may contain '@default@', in which case it will be replaced with the default
622 # value for the option (taking into account defaults specified with 'options-defaults'.
623 #
624 # Undocumented options are also supported by omitting the '=> description'.
625 # These options are not displayed with '--help' and can be useful for internal options or as aliases.
626 #
627 # For example, '--disable-lfs' is an alias for '--disable=largefile':
628 #
629 ## lfs=1 largefile=1 => "Disable large file support"
630 #
631 proc options {optlist} {
632 # Allow options as a list or args
@@ -509,27 +644,37 @@
644 user-error "Unknown option --$o"
645 }
646 }
647 }
648 }
649
650 # @options-defaults dictionary
651 #
652 # Specifies a dictionary of options and a new default value for each of those options.
653 # Use before any 'use' statements in 'auto.def' to change the defaults for
654 # subsequently included modules.
655 proc options-defaults {dict} {
656 foreach {n v} $dict {
657 dict set ::autosetup(options-defaults) $n $v
658 }
659 }
660
661 proc config_guess {} {
662 if {[file-isexec $::autosetup(dir)/autosetup-config.guess]} {
663 if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.guess} alias]} {
 
664 user-error $alias
665 }
666 return $alias
667 } else {
668 configlog "No autosetup-config.guess, so using uname"
669 string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
670 }
671 }
672
673 proc config_sub {alias} {
674 if {[file-isexec $::autosetup(dir)/autosetup-config.sub]} {
675 if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.sub $alias} alias]} {
676 user-error $alias
677 }
678 }
679 return $alias
680 }
@@ -536,39 +681,48 @@
681
682 # @define name ?value=1?
683 #
684 # Defines the named variable to the given value.
685 # These (name, value) pairs represent the results of the configuration check
686 # and are available to be subsequently checked, modified and substituted.
687 #
688 proc define {name {value 1}} {
689 set ::define($name) $value
690 #dputs "$name <= $value"
691 }
692
693 # @undefine name
694 #
695 # Undefine the named variable.
696 #
697 proc undefine {name} {
698 unset -nocomplain ::define($name)
699 #dputs "$name <= <undef>"
700 }
701
702 # @define-append name value ...
703 #
704 # Appends the given value(s) to the given "defined" variable.
705 # If the variable is not defined or empty, it is set to '$value'.
706 # Otherwise the value is appended, separated by a space.
707 # Any extra values are similarly appended.
708 # If any value is already contained in the variable (as a substring) it is omitted.
709 #
710 proc define-append {name args} {
711 if {[get-define $name ""] ne ""} {
712 # Avoid duplicates
713 foreach arg $args {
714 if {$arg eq ""} {
715 continue
716 }
717 set found 0
718 foreach str [split $::define($name) " "] {
719 if {$str eq $arg} {
720 incr found
721 }
722 }
723 if {!$found} {
724 append ::define($name) " " $arg
725 }
726 }
727 } else {
728 set ::define($name) [join $args]
@@ -576,11 +730,11 @@
730 #dputs "$name += [join $args] => $::define($name)"
731 }
732
733 # @get-define name ?default=0?
734 #
735 # Returns the current value of the "defined" variable, or '$default'
736 # if not set.
737 #
738 proc get-define {name {default 0}} {
739 if {[info exists ::define($name)]} {
740 #dputs "$name => $::define($name)"
@@ -595,14 +749,26 @@
749 # Returns 1 if the given variable is defined.
750 #
751 proc is-defined {name} {
752 info exists ::define($name)
753 }
754
755 # @is-define-set name
756 #
757 # Returns 1 if the given variable is defined and is set
758 # to a value other than "" or 0
759 #
760 proc is-define-set {name} {
761 if {[get-define $name] in {0 ""}} {
762 return 0
763 }
764 return 1
765 }
766
767 # @all-defines
768 #
769 # Returns a dictionary (name, value list) of all defined variables.
770 #
771 # This is suitable for use with 'dict', 'array set' or 'foreach'
772 # and allows for arbitrary processing of the defined variables.
773 #
774 proc all-defines {} {
@@ -610,13 +776,13 @@
776 }
777
778
779 # @get-env name default
780 #
781 # If '$name' was specified on the command line, return it.
782 # Otherwise if '$name' was set in the environment, return it.
783 # Otherwise return '$default'.
784 #
785 proc get-env {name default} {
786 if {[dict exists $::autosetup(cmdline) $name]} {
787 return [dict get $::autosetup(cmdline) $name]
788 }
@@ -623,11 +789,11 @@
789 getenv $name $default
790 }
791
792 # @env-is-set name
793 #
794 # Returns 1 if '$name' was specified on the command line or in the environment.
795 # Note that an empty environment variable is not considered to be set.
796 #
797 proc env-is-set {name} {
798 if {[dict exists $::autosetup(cmdline) $name]} {
799 return 1
@@ -639,11 +805,11 @@
805 }
806
807 # @readfile filename ?default=""?
808 #
809 # Return the contents of the file, without the trailing newline.
810 # If the file doesn't exist or can't be read, returns '$default'.
811 #
812 proc readfile {filename {default_value ""}} {
813 set result $default_value
814 catch {
815 set f [open $filename]
@@ -653,11 +819,11 @@
819 return $result
820 }
821
822 # @writefile filename value
823 #
824 # Creates the given file containing '$value'.
825 # Does not add an extra newline.
826 #
827 proc writefile {filename value} {
828 set f [open $filename w]
829 puts -nonewline $f $value
@@ -677,63 +843,60 @@
843 lappend args [quote-if-needed $arg]
844 }
845 join $args
846 }
847
848 # @list-non-empty list
849 #
850 # Returns a copy of the given list with empty elements removed
851 proc list-non-empty {list} {
 
 
 
 
852 set result {}
853 foreach p $list {
854 if {$p ne ""} {
855 lappend result $p
856 }
857 }
858 return $result
859 }
860
861 # @find-executable-path name
862 #
863 # Searches the path for an executable with the given name.
864 # Note that the name may include some parameters, e.g. 'cc -mbig-endian',
865 # in which case the parameters are ignored.
866 # The full path to the executable if found, or "" if not found.
867 # Returns 1 if found, or 0 if not.
868 #
869 proc find-executable-path {name} {
870 # Ignore any parameters
871 set name [lindex $name 0]
872 # The empty string is never a valid executable
873 if {$name ne ""} {
874 foreach p [split-path] {
875 dputs "Looking for $name in $p"
876 set exec [file join $p $name]
877 if {[file-isexec $exec]} {
878 dputs "Found $name -> $exec"
879 return $exec
880 }
881 }
882 }
883 return {}
884 }
885
886 # @find-executable name
887 #
888 # Searches the path for an executable with the given name.
889 # Note that the name may include some parameters, e.g. 'cc -mbig-endian',
890 # in which case the parameters are ignored.
891 # Returns 1 if found, or 0 if not.
892 #
893 proc find-executable {name} {
894 if {[find-executable-path $name] eq {}} {
895 return 0
896 }
897 return 1
 
 
 
 
 
 
 
 
 
 
 
898 }
899
900 # @find-an-executable ?-required? name ...
901 #
902 # Given a list of possible executable names,
@@ -764,11 +927,11 @@
927 return ""
928 }
929
930 # @configlog msg
931 #
932 # Writes the given message to the configuration log, 'config.log'.
933 #
934 proc configlog {msg} {
935 if {![info exists ::autosetup(logfh)]} {
936 set ::autosetup(logfh) [open config.log w]
937 }
@@ -800,12 +963,12 @@
963 }
964 }
965
966 # @msg-quiet command ...
967 #
968 # 'msg-quiet' evaluates it's arguments as a command with output
969 # from 'msg-checking' and 'msg-result' suppressed.
970 #
971 # This is useful if a check needs to run a subcheck which isn't
972 # of interest to the user.
973 proc msg-quiet {args} {
974 incr ::autosetup(msg-quiet)
@@ -841,11 +1004,11 @@
1004
1005 # @user-error msg
1006 #
1007 # Indicate incorrect usage to the user, including if required components
1008 # or features are not found.
1009 # 'autosetup' exits with a non-zero return code.
1010 #
1011 proc user-error {msg} {
1012 show-notices
1013 puts stderr "Error: $msg"
1014 puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
@@ -887,10 +1050,21 @@
1050 proc maybe-show-timestamp {} {
1051 if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
1052 puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
1053 }
1054 }
1055
1056 # @autosetup-require-version required
1057 #
1058 # Checks the current version of 'autosetup' against '$required'.
1059 # A fatal error is generated if the current version is less than that required.
1060 #
1061 proc autosetup-require-version {required} {
1062 if {[compare-versions $::autosetup(version) $required] < 0} {
1063 user-error "autosetup version $required is required, but this is $::autosetup(version)"
1064 }
1065 }
1066
1067 proc autosetup_version {} {
1068 return "autosetup v$::autosetup(version)"
1069 }
1070
@@ -986,23 +1160,35 @@
1160 # The latter form is useful for a complex module which requires additional
1161 # support file. In this form, '$::usedir' is set to the module directory
1162 # when it is loaded.
1163 #
1164 proc use {args} {
1165 global autosetup libmodule modsource
1166
1167 set dirs [list $autosetup(libdir)]
1168 if {[info exists autosetup(srcdir)]} {
1169 lappend dirs $autosetup(srcdir)/autosetup
1170 }
1171 foreach m $args {
1172 if {[info exists libmodule($m)]} {
1173 continue
1174 }
1175 set libmodule($m) 1
1176 if {[info exists modsource(${m}.tcl)]} {
1177 automf_load eval $modsource(${m}.tcl)
1178 } else {
1179 set locs [list ${m}.tcl ${m}/init.tcl]
1180 set found 0
1181 foreach dir $dirs {
1182 foreach loc $locs {
1183 set source $dir/$loc
1184 if {[file exists $source]} {
1185 incr found
1186 break
1187 }
1188 }
1189 if {$found} {
1190 break
1191 }
1192 }
1193 if {$found} {
1194 # For the convenience of the "use" source, point to the directory
@@ -1014,10 +1200,22 @@
1200 autosetup-error "use: No such module: $m"
1201 }
1202 }
1203 }
1204 }
1205
1206 proc autosetup_load_auto_modules {} {
1207 global autosetup modsource
1208 # First load any embedded auto modules
1209 foreach mod [array names modsource *.auto] {
1210 automf_load eval $modsource($mod)
1211 }
1212 # Now any external auto modules
1213 foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
1214 automf_load source $file
1215 }
1216 }
1217
1218 # Load module source in the global scope by executing the given command
1219 proc automf_load {args} {
1220 if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
1221 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
@@ -1027,18 +1225,21 @@
1225 # Initial settings
1226 set autosetup(exe) $::argv0
1227 set autosetup(istcl) 1
1228 set autosetup(start) [clock millis]
1229 set autosetup(installed) 0
1230 set autosetup(sysinstall) 0
1231 set autosetup(msg-checking) 0
1232 set autosetup(msg-quiet) 0
1233 set autosetup(inittypes) {}
1234
1235 # Embedded modules are inserted below here
1236 set autosetup(installed) 1
1237 set autosetup(sysinstall) 0
1238 # ----- @module asciidoc-formatting.tcl -----
1239
1240 set modsource(asciidoc-formatting.tcl) {
1241 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1242 # All rights reserved
1243
1244 # Module which provides text formatting
1245 # asciidoc format
@@ -1102,19 +1303,19 @@
1303 regsub -all "\n\n" $defn "\n ::\n" defn
1304 puts $defn
1305 }
1306 }
1307
1308 # ----- @module formatting.tcl -----
1309
1310 set modsource(formatting.tcl) {
1311 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1312 # All rights reserved
1313
1314 # Module which provides common text formatting
1315
1316 # This is designed for documentation which looks like:
1317 # code {...}
1318 # or
1319 # code {
1320 # ...
1321 # ...
@@ -1159,13 +1360,13 @@
1360 # Return the result
1361 return $lines
1362 }
1363 }
1364
1365 # ----- @module getopt.tcl -----
1366
1367 set modsource(getopt.tcl) {
1368 # Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
1369 # All rights reserved
1370
1371 # Simple getopt module
1372
@@ -1197,11 +1398,11 @@
1398
1399 if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
1400 # --name=value
1401 dict lappend opts $name [list str $value]
1402 } elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
1403 if {$prefix in {enable- ""}} {
1404 set value 1
1405 } else {
1406 set value 0
1407 }
1408 dict lappend opts $name [list bool $value]
@@ -1218,13 +1419,13 @@
1419
1420 return $opts
1421 }
1422 }
1423
1424 # ----- @module help.tcl -----
1425
1426 set modsource(help.tcl) {
1427 # Copyright (c) 2010 WorkWare Systems http://workware.net.au/
1428 # All rights reserved
1429
1430 # Module which provides usage, help and the command reference
1431
@@ -1251,10 +1452,28 @@
1452 options-show
1453 }
1454 }
1455 exit 0
1456 }
1457
1458 proc autosetup_show_license {} {
1459 global modsource autosetup
1460 use_pager
1461
1462 if {[info exists modsource(LICENSE)]} {
1463 puts $modsource(LICENSE)
1464 return
1465 }
1466 foreach dir [list $autosetup(libdir) $autosetup(srcdir)] {
1467 set path [file join $dir LICENSE]
1468 if {[file exists $path]} {
1469 puts [readfile $path]
1470 return
1471 }
1472 }
1473 puts "LICENSE not found"
1474 }
1475
1476 # If not already paged and stdout is a tty, pipe the output through the pager
1477 # This is done by reinvoking autosetup with --nopager added
1478 proc use_pager {} {
1479 if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
@@ -1304,10 +1523,16 @@
1523 }
1524
1525 proc autosetup_output_block {type lines} {
1526 if {[llength $lines]} {
1527 switch $type {
1528 section {
1529 section $lines
1530 }
1531 subsection {
1532 subsection $lines
1533 }
1534 code {
1535 codelines $lines
1536 }
1537 p {
1538 p [join $lines]
@@ -1325,30 +1550,45 @@
1550 # Generate a command reference from inline documentation
1551 proc automf_command_reference {} {
1552 lappend files $::autosetup(prog)
1553 lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
1554
1555 # We want to process all non-module files before module files
1556 # and then modules in alphabetical order.
1557 # So examine all files and extract docs into doc($modulename) and doc(_core_)
1558 #
1559 # Each entry is a list of {type data} where $type is one of: section, subsection, code, list, p
1560 # and $data is a string for section, subsection or a list of text lines for other types.
1561
1562 # XXX: Should commands be in alphabetical order too? Currently they are in file order.
1563
1564 set doc(_core_) {}
1565 lappend doc(_core_) [list section "Core Commands"]
1566
1567 foreach file $files {
1568 set modulename [file rootname [file tail $file]]
1569 set current _core_
1570 set f [open $file]
1571 while {![eof $f]} {
1572 set line [gets $f]
1573
1574 # Find embedded module names
1575 if {[regexp {^#.*@module ([^ ]*)} $line -> modulename]} {
1576 continue
1577 }
1578
1579 # Find lines starting with "# @*" and continuing through the remaining comment lines
1580 if {![regexp {^# @(.*)} $line -> cmd]} {
1581 continue
1582 }
1583
1584 # Synopsis or command?
1585 if {$cmd eq "synopsis:"} {
1586 set current $modulename
1587 lappend doc($current) [list section "Module: $modulename"]
1588 } else {
1589 lappend doc($current) [list subsection $cmd]
1590 }
1591
1592 set lines {}
1593 set type p
1594
@@ -1369,29 +1609,38 @@
1609
1610 #puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
1611
1612 if {$t ne $type || $cmd eq ""} {
1613 # Finish the current block
1614 lappend doc($current) [list $type $lines]
1615 set lines {}
1616 set type $t
1617 }
1618 if {$cmd ne ""} {
1619 lappend lines $cmd
1620 }
1621 }
1622
1623 lappend doc($current) [list $type $lines]
1624 }
1625 close $f
1626 }
1627
1628 # Now format and output the results
1629
1630 # _core_ will sort first
1631 foreach module [lsort [array names doc]] {
1632 foreach item $doc($module) {
1633 autosetup_output_block {*}$item
1634 }
1635 }
1636 }
1637 }
1638
1639 # ----- @module init.tcl -----
1640
1641 set modsource(init.tcl) {
1642 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1643 # All rights reserved
1644
1645 # Module to help create auto.def and configure
1646
@@ -1444,79 +1693,157 @@
1693 }
1694 writefile $filename $contents
1695 }
1696 }
1697
1698 # ----- @module install.tcl -----
1699
1700 set modsource(install.tcl) {
1701 # Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
1702 # All rights reserved
1703
1704 # Module which can install autosetup
1705
1706 # autosetup(installed)=1 means that autosetup is not running from source
1707 # autosetup(sysinstall)=1 means that autosetup is running from a sysinstall version
1708 # shared=1 means that we are trying to do a sysinstall. This is only possible from the development source.
1709
1710 proc autosetup_install {dir {shared 0}} {
1711 global autosetup
1712 if {$shared} {
1713 if {$autosetup(installed) || $autosetup(sysinstall)} {
1714 user-error "Can only --sysinstall from development sources"
1715 }
1716 } elseif {$autosetup(installed) && !$autosetup(sysinstall)} {
1717 user-error "Can't --install from project install"
1718 }
1719
1720 if {$autosetup(sysinstall)} {
1721 # This is the sysinstall version, so install just uses references
1722 cd $dir
1723
1724 puts "[autosetup_version] creating configure to use system-installed autosetup"
1725 autosetup_create_configure 1
1726 puts "Creating autosetup/README.autosetup"
1727 file mkdir autosetup
1728 autosetup_install_readme autosetup/README.autosetup 1
1729 return
1730 }
1731
1732 if {[catch {
1733 if {$shared} {
1734 set target $dir/bin/autosetup
1735 set installedas $target
1736 } else {
1737 if {$dir eq "."} {
1738 set installedas autosetup
1739 } else {
1740 set installedas $dir/autosetup
1741 }
1742 cd $dir
1743 file mkdir autosetup
1744 set target autosetup/autosetup
1745 }
1746 set targetdir [file dirname $target]
1747 file mkdir $targetdir
1748
1749 set f [open $target w]
1750
1751 set publicmodules {}
1752
1753 # First the main script, but only up until "CUT HERE"
1754 set in [open $autosetup(dir)/autosetup]
1755 while {[gets $in buf] >= 0} {
1756 if {$buf ne "##-- CUT HERE --##"} {
1757 puts $f $buf
1758 continue
1759 }
1760
1761 # Insert the static modules here
1762 # i.e. those which don't contain @synopsis:
1763 # All modules are inserted if $shared is set
1764 puts $f "set autosetup(installed) 1"
1765 puts $f "set autosetup(sysinstall) $shared"
1766 foreach file [lsort [glob $autosetup(libdir)/*.{tcl,auto}]] {
1767 set modname [file tail $file]
1768 set ext [file ext $modname]
1769 set buf [readfile $file]
1770 if {!$shared} {
1771 if {$ext eq ".auto" || [string match "*\n# @synopsis:*" $buf]} {
1772 lappend publicmodules $file
1773 continue
1774 }
1775 }
1776 dputs "install: importing lib/[file tail $file]"
1777 puts $f "# ----- @module $modname -----"
1778 puts $f "\nset modsource($modname) \{"
1779 puts $f $buf
1780 puts $f "\}\n"
1781 }
1782 if {$shared} {
1783 foreach {srcname destname} [list $autosetup(libdir)/README.autosetup-lib README.autosetup \
1784 $autosetup(srcdir)/LICENSE LICENSE] {
1785 dputs "install: importing $srcname as $destname"
1786 puts $f "\nset modsource($destname) \\\n[list [readfile $srcname]\n]\n"
1787 }
1788 }
1789 }
1790 close $in
1791 close $f
1792 catch {exec chmod 755 $target}
1793
1794 set installfiles {autosetup-config.guess autosetup-config.sub autosetup-test-tclsh}
1795 set removefiles {}
1796
1797 if {!$shared} {
1798 autosetup_install_readme $targetdir/README.autosetup 0
1799
1800 # Install public modules
1801 foreach file $publicmodules {
1802 set tail [file tail $file]
1803 autosetup_install_file $file $targetdir/$tail
1804 }
1805 lappend installfiles jimsh0.c autosetup-find-tclsh LICENSE
1806 lappend removefiles config.guess config.sub test-tclsh find-tclsh
1807 } else {
1808 lappend installfiles {sys-find-tclsh autosetup-find-tclsh}
1809 }
1810
1811 # Install support files
1812 foreach fileinfo $installfiles {
1813 if {[llength $fileinfo] == 2} {
1814 lassign $fileinfo source dest
1815 } else {
1816 lassign $fileinfo source
1817 set dest $source
1818 }
1819 autosetup_install_file $autosetup(dir)/$source $targetdir/$dest
1820 }
1821
1822 # Remove obsolete files
1823 foreach file $removefiles {
1824 if {[file exists $targetdir/$file]} {
1825 file delete $targetdir/$file
1826 }
1827 }
1828 } error]} {
1829 user-error "Failed to install autosetup: $error"
1830 }
1831 if {$shared} {
1832 set type "system"
1833 } else {
1834 set type "local"
1835 }
1836 puts "Installed $type [autosetup_version] to $installedas"
1837
1838 if {!$shared} {
1839 # Now create 'configure' if necessary
1840 autosetup_create_configure 0
1841 }
1842 }
1843
1844 proc autosetup_create_configure {shared} {
1845 if {[file exists configure]} {
1846 if {!$::autosetup(force)} {
1847 # Could this be an autosetup configure?
1848 if {![string match "*\nWRAPPER=*" [readfile configure]]} {
1849 puts "I see configure, but not created by autosetup, so I won't overwrite it."
@@ -1527,40 +1854,75 @@
1854 puts "I will overwrite the existing configure because you used --force."
1855 }
1856 } else {
1857 puts "I don't see configure, so I will create it."
1858 }
1859 if {$shared} {
1860 writefile configure \
1861 {#!/bin/sh
1862 WRAPPER="$0"; export WRAPPER; "autosetup" "$@"
1863 }
1864 } else {
1865 writefile configure \
1866 {#!/bin/sh
1867 dir="`dirname "$0"`/autosetup"
1868 WRAPPER="$0"; export WRAPPER; exec "`"$dir/autosetup-find-tclsh"`" "$dir/autosetup" "$@"
1869 }
1870 }
1871 catch {exec chmod 755 configure}
1872 }
1873
1874 # Append the contents of $file to filehandle $f
1875 proc autosetup_install_append {f file} {
1876 dputs "install: include $file"
1877 set in [open $file]
1878 puts $f [read $in]
1879 close $in
1880 }
1881
1882 proc autosetup_install_file {source target} {
1883 dputs "install: $source => $target"
1884 if {![file exists $source]} {
1885 error "Missing installation file '$source'"
1886 }
1887 writefile $target [readfile $source]\n
1888 # If possible, copy the file mode
1889 file stat $source stat
1890 set mode [format %o [expr {$stat(mode) & 0x1ff}]]
1891 catch {exec chmod $mode $target}
1892 }
1893
1894 proc autosetup_install_readme {target sysinstall} {
1895 set readme "README.autosetup created by [autosetup_version]\n\n"
1896 if {$sysinstall} {
1897 append readme \
1898 {This is the autosetup directory for a system install of autosetup.
1899 Loadable modules can be added here.
1900 }
1901 } else {
1902 append readme \
1903 {This is the autosetup directory for a local install of autosetup.
1904 It contains autosetup, support files and loadable modules.
1905 }
1906 }
1907
1908 append readme {
1909 *.tcl files in this directory are optional modules which
1910 can be loaded with the 'use' directive.
1911
1912 *.auto files in this directory are auto-loaded.
1913
1914 For more information, see http://msteveb.github.com/autosetup/
1915 }
1916 dputs "install: autosetup/README.autosetup"
1917 writefile $target $readme
1918 }
1919 }
1920
1921 # ----- @module markdown-formatting.tcl -----
1922
1923 set modsource(markdown-formatting.tcl) {
1924 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1925 # All rights reserved
1926
1927 # Module which provides text formatting
1928 # markdown format (kramdown syntax)
@@ -1627,13 +1989,13 @@
1989 }
1990 puts "$defn"
1991 }
1992 }
1993
1994 # ----- @module misc.tcl -----
1995
1996 set modsource(misc.tcl) {
1997 # Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
1998 # All rights reserved
1999
2000 # Module containing misc procs useful to modules
2001 # Largely for platform compatibility
@@ -1805,106 +2167,218 @@
2167 string trim $result
2168 }
2169 }
2170 }
2171
2172 # ----- @module text-formatting.tcl -----
2173
2174 set modsource(text-formatting.tcl) {
2175 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2176 # All rights reserved
2177
2178 # Module which provides text formatting
2179
2180 use formatting
2181
2182 proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
2183 set len 0
2184 set space $firstprefix
2185
2186 foreach word [split $text] {
2187 set word [string trim $word]
2188 if {$word eq ""} {
2189 continue
2190 }
2191 if {[info exists partial]} {
2192 append partial " " $word
2193 if {[string first $quote $word] < 0} {
2194 # Haven't found end of quoted word
2195 continue
2196 }
2197 # Finished quoted word
2198 set word $partial
2199 unset partial
2200 unset quote
2201 } else {
2202 set quote [string index $word 0]
2203 if {$quote in {' *}} {
2204 if {[string first $quote $word 1] < 0} {
2205 # Haven't found end of quoted word
2206 # Not a whole word.
2207 set first [string index $word 0]
2208 # Start of quoted word
2209 set partial $word
2210 continue
2211 }
2212 }
2213 }
2214
2215 if {$len && [string length $space$word] + $len >= $length} {
2216 puts ""
2217 set len 0
2218 set space $nextprefix
2219 }
2220 incr len [string length $space$word]
2221
2222 # Use man-page conventions for highlighting 'quoted' and *quoted*
2223 # single words.
2224 # Use x^Hx for *bold* and _^Hx for 'underline'.
2225 #
2226 # less and more will both understand this.
2227 # Pipe through 'col -b' to remove them.
2228 if {[regexp {^'(.*)'(.*)} $word -> quoted after]} {
2229 set quoted [string map {~ " "} $quoted]
2230 regsub -all . $quoted "&\b&" quoted
2231 set word $quoted$after
2232 } elseif {[regexp {^[*](.*)[*](.*)} $word -> quoted after]} {
2233 set quoted [string map {~ " "} $quoted]
2234 regsub -all . $quoted "_\b&" quoted
2235 set word $quoted$after
2236 }
2237 puts -nonewline $space$word
2238 set space " "
2239 }
2240 if {[info exists partial]} {
2241 # Missing end of quote
2242 puts -nonewline $space$partial
2243 }
2244 if {$len} {
2245 puts ""
2246 }
2247 }
2248 proc title {text} {
2249 underline [string trim $text] =
2250 nl
2251 }
2252 proc p {text} {
2253 wordwrap $text 80
2254 nl
2255 }
2256 proc codelines {lines} {
2257 foreach line $lines {
2258 puts " $line"
2259 }
2260 nl
2261 }
2262 proc nl {} {
2263 puts ""
2264 }
2265 proc underline {text char} {
2266 regexp "^(\[ \t\]*)(.*)" $text -> indent words
2267 puts $text
2268 puts $indent[string repeat $char [string length $words]]
2269 }
2270 proc section {text} {
2271 underline "[string trim $text]" -
2272 nl
2273 }
2274 proc subsection {text} {
2275 underline "$text" ~
2276 nl
2277 }
2278 proc bullet {text} {
2279 wordwrap $text 76 " * " " "
2280 }
2281 proc indent {text} {
2282 wordwrap $text 76 " " " "
2283 }
2284 proc defn {first args} {
2285 if {$first ne ""} {
2286 underline " $first" ~
2287 }
2288 foreach p $args {
2289 if {$p ne ""} {
2290 indent $p
2291 }
2292 }
2293 }
2294 }
2295
2296 # ----- @module util.tcl -----
2297
2298 set modsource(util.tcl) {
2299 # Copyright (c) 2012 WorkWare Systems http://www.workware.net.au/
2300 # All rights reserved
2301
2302 # Module which contains miscellaneous utility functions
2303
2304 # @compare-versions version1 version2
2305 #
2306 # Versions are of the form 'a.b.c' (may be any number of numeric components)
2307 #
2308 # Compares the two versions and returns:
2309 ## -1 if v1 < v2
2310 ## 0 if v1 == v2
2311 ## 1 if v1 > v2
2312 #
2313 # If one version has fewer components than the other, 0 is substituted to the right. e.g.
2314 ## 0.2 < 0.3
2315 ## 0.2.5 > 0.2
2316 ## 1.1 == 1.1.0
2317 #
2318 proc compare-versions {v1 v2} {
2319 foreach c1 [split $v1 .] c2 [split $v2 .] {
2320 if {$c1 eq ""} {
2321 set c1 0
2322 }
2323 if {$c2 eq ""} {
2324 set c2 0
2325 }
2326 if {$c1 < $c2} {
2327 return -1
2328 }
2329 if {$c1 > $c2} {
2330 return 1
2331 }
2332 }
2333 return 0
2334 }
2335
2336 # @suffix suf list
2337 #
2338 # Takes a list and returns a new list with '$suf' appended
2339 # to each element
2340 #
2341 ## suffix .c {a b c} => {a.c b.c c.c}
2342 #
2343 proc suffix {suf list} {
2344 set result {}
2345 foreach p $list {
2346 lappend result $p$suf
2347 }
2348 return $result
2349 }
2350
2351 # @prefix pre list
2352 #
2353 # Takes a list and returns a new list with '$pre' prepended
2354 # to each element
2355 #
2356 ## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
2357 #
2358 proc prefix {pre list} {
2359 set result {}
2360 foreach p $list {
2361 lappend result $pre$p
2362 }
2363 return $result
2364 }
2365
2366 # @lpop list
2367 #
2368 # Removes the last entry from the given list and returns it.
2369 proc lpop {listname} {
2370 upvar $listname list
2371 set val [lindex $list end]
2372 set list [lrange $list 0 end-1]
2373 return $val
2374 }
2375 }
2376
2377 # ----- @module wiki-formatting.tcl -----
2378
2379 set modsource(wiki-formatting.tcl) {
2380 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2381 # All rights reserved
2382
2383 # Module which provides text formatting
2384 # wiki.tcl.tk format output
@@ -1975,11 +2449,11 @@
2449 if {$autosetup(debug)} {
2450 main $argv
2451 }
2452 if {[catch {main $argv} msg opts] == 1} {
2453 show-notices
2454 autosetup-full-error [error-dump $msg $opts $autosetup(debug)]
2455 if {!$autosetup(debug)} {
2456 puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
2457 }
2458 exit 1
2459 }
2460
2461 DDED autosetup/autosetup-config.guess
2462 DDED autosetup/autosetup-config.sub
2463 DDED autosetup/autosetup-find-tclsh
2464 DDED autosetup/autosetup-test-tclsh
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -1,6 +1,8 @@
11
#! /bin/sh
22
# Attempt to guess a canonical system name.
3
-# Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
3
+# Copyright 1992-2018 Free Software Foundation, Inc.
4
+
5
+timestamp='2018-03-08it and/or modify it
46
# under the terms of the GNU General Public License as published by
57
# t;e Free Software Foundation, either version 3 of the L;cense, or
68
# (at your option) any later version.
@@ -13,7 +15,7 @@
1315
# You should have received a copy of the GNU General Public License
1416
# along with this program; if not, see <https://www.gnu.org/licenses/>.
1517
#
16
-# As a special exceptionto the GNU General Public License, if you
18
+# As a special exception to the GNU General Public License, if you
1719
# distribute this file as part of a program that contains a
1820
# configuration script generated by Autoconf, you may include it under
1921
# the same distribution terms that you use for the rest of that
@@ -23,28 +25,4 @@
2325
# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
2426
#
2527
# You can get the latest version of this script from:
26
-# https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
-
28
-$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29
- cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30
-# Attempt to guess a canoniAttempt to g! /bin/sh
31
-# Attemp#*) machine=${! /bin/sh
32
-# Attemp#! /bin/sh
33
-# Attempt to guess a canonical system name.
34
-# Copyright 1992-2018canonical system name.
35
-# Copyrig! /bin/sh
36
-# Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37
-# Attemp#! /bin/sh
38
-# Attempt to guess a ${! /bin/sh
39
-# Attemp#! /bin/sh
40
-# Attempt to guess a cekkoBSD:*:*)
41
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42
- echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43
-# Attempt to guess a canonical system name.
44
-# Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45
-# Copyright 1992-2018 Free Software Foundation, Inc.
46
-
47
-timestamp='2018-03-08it and/or modify it
48
-# under the terms of the GNU General Public License as published by
49
-# t;e Free Software Foundation, either version 3 of the L;cense, or
50
-# (at your o
28
+# https://git.savannah.gnu.org/
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -1,6 +1,8 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
 
 
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
@@ -13,7 +15,7 @@
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exceptionto the GNU General Public License, if you
17 # distribute this file as part of a program that contains a
18 # configuration script generated by Autoconf, you may include it under
19 # the same distribution terms that you use for the rest of that
@@ -23,28 +25,4 @@
23 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
24 #
25 # You can get the latest version of this script from:
26 # https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
28 $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29 cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30 # Attempt to guess a canoniAttempt to g! /bin/sh
31 # Attemp#*) machine=${! /bin/sh
32 # Attemp#! /bin/sh
33 # Attempt to guess a canonical system name.
34 # Copyright 1992-2018canonical system name.
35 # Copyrig! /bin/sh
36 # Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37 # Attemp#! /bin/sh
38 # Attempt to guess a ${! /bin/sh
39 # Attemp#! /bin/sh
40 # Attempt to guess a cekkoBSD:*:*)
41 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42 echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43 # Attempt to guess a canonical system name.
44 # Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45 # Copyright 1992-2018 Free Software Foundation, Inc.
46
47 timestamp='2018-03-08it and/or modify it
48 # under the terms of the GNU General Public License as published by
49 # t;e Free Software Foundation, either version 3 of the L;cense, or
50 # (at your o
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -1,6 +1,8 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2018 Free Software Foundation, Inc.
4
5 timestamp='2018-03-08it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # t;e Free Software Foundation, either version 3 of the L;cense, or
8 # (at your option) any later version.
@@ -13,7 +15,7 @@
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <https://www.gnu.org/licenses/>.
17 #
18 # As a special exception to the GNU General Public License, if you
19 # distribute this file as part of a program that contains a
20 # configuration script generated by Autoconf, you may include it under
21 # the same distribution terms that you use for the rest of that
@@ -23,28 +25,4 @@
25 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
26 #
27 # You can get the latest version of this script from:
28 # https://git.savannah.gnu.org/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -1,6 +1,8 @@
11
#! /bin/sh
22
# Configuration validation subroutine script.
3
-# Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
3
+# Copyright 1992-2018 Free Software Foundation, Inc.
4
+
5
+timestamp='2018-03-08it and/or modify it
46
# under the terms of the GNU General Public License as published by
57
# t;e Free Software Foundation, either version 3 of the L;cense, or
68
# (at your option) any later version.
@@ -13,7 +15,6 @@
1315
# You should have received a copy of the GNU General Public License
1416
# along with this program; if not, see <https://www.gnu.org/licenses/>.
1517
#
16
-# As a special exception#
1718
# As a special exception to the GNU General Public License, if you
1819
# distribute this file as part of a program that contains a
1920
# configuration script generated by Autoconf, you may include it under
@@ -30,46 +31,5 @@
3031
3132
'orting which valid configurations
3233
# it does not support. The user should be able to distinguish
33
-# a failure to support;hb=HEAD
34
- $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35
-# distribute this file as part of a program that contains a
36
-# configuration script generated by Autoconf, you may include it under
37
-# the same distribution terms that you use for the rest of that
38
-# program. This Excepti4 Free Software Foundation, Inc.
39
-
40
-er section 7
41
-# of the GNU General Public License, version 3 ("GPLv3").
42
-
43
-
44
-# Please send patches to <[email protected]>.
45
-#
46
-# Configuration subroutine to validate and canonicalize a configuration type.
47
-# Supply the specified configuration type as an argument.
48
-# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
-
50
-'orting which valid configurations
51
-# it does not support. The user should be able to distinguish
5234
# a failure to support a valid configuration from a meaningless
53
-# configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54
-# Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55
- ;;
56
- msbut
57
-# WITHOUT ANY W#! /bin/sh
58
-# Configuration validation subroutine script.
59
-# Copyright 1992-2018 Free Software Foundation, Inc.
60
-
61
-timestamp='2018-03-08it and/or modify it
62
-# under the terms of the GNU General Public License as published by
63
-# t;e Free Software Foundation, either version 3 of the L;cense, or
64
-# (at your option) any later version.
65
-#
66
-# This program is distributed in the hope that it will be useful, but
67
-# WITHOUT ANY WARRANTY; without even the implied warranty of
68
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69
- os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70
-# Configuration validation subroutine script.
71
-# Copyright 1992-2018 Free Software Foundation, Inc.
72
-
73
-timestamp='2018-03-08it and/or modify it
74
-# under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75
- ;
35
+# configur
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -1,6 +1,8 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
 
 
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
@@ -13,7 +15,6 @@
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exception#
17 # As a special exception to the GNU General Public License, if you
18 # distribute this file as part of a program that contains a
19 # configuration script generated by Autoconf, you may include it under
@@ -30,46 +31,5 @@
30
31 'orting which valid configurations
32 # it does not support. The user should be able to distinguish
33 # a failure to support;hb=HEAD
34 $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35 # distribute this file as part of a program that contains a
36 # configuration script generated by Autoconf, you may include it under
37 # the same distribution terms that you use for the rest of that
38 # program. This Excepti4 Free Software Foundation, Inc.
39
40 er section 7
41 # of the GNU General Public License, version 3 ("GPLv3").
42
43
44 # Please send patches to <[email protected]>.
45 #
46 # Configuration subroutine to validate and canonicalize a configuration type.
47 # Supply the specified configuration type as an argument.
48 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
50 'orting which valid configurations
51 # it does not support. The user should be able to distinguish
52 # a failure to support a valid configuration from a meaningless
53 # configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54 # Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55 ;;
56 msbut
57 # WITHOUT ANY W#! /bin/sh
58 # Configuration validation subroutine script.
59 # Copyright 1992-2018 Free Software Foundation, Inc.
60
61 timestamp='2018-03-08it and/or modify it
62 # under the terms of the GNU General Public License as published by
63 # t;e Free Software Foundation, either version 3 of the L;cense, or
64 # (at your option) any later version.
65 #
66 # This program is distributed in the hope that it will be useful, but
67 # WITHOUT ANY WARRANTY; without even the implied warranty of
68 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69 os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70 # Configuration validation subroutine script.
71 # Copyright 1992-2018 Free Software Foundation, Inc.
72
73 timestamp='2018-03-08it and/or modify it
74 # under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75 ;
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -1,6 +1,8 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2018 Free Software Foundation, Inc.
4
5 timestamp='2018-03-08it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # t;e Free Software Foundation, either version 3 of the L;cense, or
8 # (at your option) any later version.
@@ -13,7 +15,6 @@
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <https://www.gnu.org/licenses/>.
17 #
 
18 # As a special exception to the GNU General Public License, if you
19 # distribute this file as part of a program that contains a
20 # configuration script generated by Autoconf, you may include it under
@@ -30,46 +31,5 @@
31
32 'orting which valid configurations
33 # it does not support. The user should be able to distinguish
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34 # a failure to support a valid configuration from a meaningless
35 # configur
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -1,10 +1,12 @@
11
#!/bin/sh
22
# Looks for a suitable tclsh or jimsh in the PATH
3
-# If not foundstrap jimsh d=`dirname "$0"`
4
-{ "$d/jimshd/${1-ac"; } 2>&1done
5
-echo 1>&2 bootstrap jimsh0"
6
-for cc in tclsh8.7; do
7
- { $tclsh "$d/c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
3
+# If not foundstrap jimsh in current dir from source
4
+# Prefer $autosetup_tclsh i
5
+d=`dirname "$0"`
6
+{ "$d/jimshd/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
7
+done
8
+echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
9
+for cc in $ { $cc -o jimsh0 "$d/jimsh0.c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
810
done
911
echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
1012
for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -1,10 +1,12 @@
1 #!/bin/sh
2 # Looks for a suitable tclsh or jimsh in the PATH
3 # If not foundstrap jimsh d=`dirname "$0"`
4 { "$d/jimshd/${1-ac"; } 2>&1done
5 echo 1>&2 bootstrap jimsh0"
6 for cc in tclsh8.7; do
7 { $tclsh "$d/c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
 
 
8 done
9 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
10 for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -1,10 +1,12 @@
1 #!/bin/sh
2 # Looks for a suitable tclsh or jimsh in the PATH
3 # If not foundstrap jimsh in current dir from source
4 # Prefer $autosetup_tclsh i
5 d=`dirname "$0"`
6 { "$d/jimshd/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
7 done
8 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
9 for cc in $ { $cc -o jimsh0 "$d/jimsh0.c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
10 done
11 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
12 for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null

No diff available

--- autosetup/cc-db.tcl
+++ autosetup/cc-db.tcl
@@ -1,12 +1,12 @@
11
# Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
22
# All rights reserved
33
44
# @synopsis:
55
#
6
-# The 'cc-db' module provides a knowledge based of system idiosyncrasies
7
-# In general, this module can always be included
6
+# The 'cc-db' module provides a knowledge-base of system idiosyncrasies.
7
+# In general, this module can always be included.
88
99
use cc
1010
1111
module-options {}
1212
1313
--- autosetup/cc-db.tcl
+++ autosetup/cc-db.tcl
@@ -1,12 +1,12 @@
1 # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc-db' module provides a knowledge based of system idiosyncrasies
7 # In general, this module can always be included
8
9 use cc
10
11 module-options {}
12
13
--- autosetup/cc-db.tcl
+++ autosetup/cc-db.tcl
@@ -1,12 +1,12 @@
1 # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc-db' module provides a knowledge-base of system idiosyncrasies.
7 # In general, this module can always be included.
8
9 use cc
10
11 module-options {}
12
13
--- autosetup/cc-lib.tcl
+++ autosetup/cc-lib.tcl
@@ -9,12 +9,12 @@
99
1010
module-options {}
1111
1212
# @cc-check-lfs
1313
#
14
-# The equivalent of the AC_SYS_LARGEFILE macro
15
-#
14
+# The equivalent of the 'AC_SYS_LARGEFILE' macro.
15
+#
1616
# defines 'HAVE_LFS' if LFS is available,
1717
# and defines '_FILE_OFFSET_BITS=64' if necessary
1818
#
1919
# Returns 1 if 'LFS' is available or 0 otherwise
2020
#
@@ -35,12 +35,12 @@
3535
return $lfs
3636
}
3737
3838
# @cc-check-endian
3939
#
40
-# The equivalent of the AC_C_BIGENDIAN macro
41
-#
40
+# The equivalent of the 'AC_C_BIGENDIAN' macro.
41
+#
4242
# defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
4343
# or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
4444
#
4545
# Returns 1 if determined, or 0 if not.
4646
#
@@ -80,112 +80,110 @@
8080
#
8181
# Checks whether the given C/C++ compiler flags can be used. Defines feature
8282
# names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and
8383
# appends working flags to '-cflags' and 'CFLAGS' or 'CXXFLAGS'.
8484
proc cc-check-flags {args} {
85
- set result 1
86
- array set opts [cc-get-settings]
87
- switch -exact -- $opts(-lang) {
88
- c++ {
89
- set lang C++
90
- set prefix CXXFLAG
91
- }
92
- c {
93
- set lang C
94
- set prefix CFLAG
95
- }
96
- default {
97
- autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98
- }
99
- }
100
- foreach flag $args {
101
- msg-checking "Checking whether the $lang compiler accepts $flag..."
102
- if {[cctest -cflags $flag]} {
103
- msg-result yes
104
- define-feature $prefix$flag
105
- cc-with [list -cflags [list $flag]]
106
- define-append ${prefix}S $flag
107
- } else {
108
- msg-result no
109
- set result 0
110
- }
111
- }
112
- return $result
85
+ set result 1
86
+ array set opts [cc-get-settings]
87
+ switch -exact -- $opts(-lang) {
88
+ c++ {
89
+ set lang C++
90
+ set prefix CXXFLAG
91
+ }
92
+ c {
93
+ set lang C
94
+ set prefix CFLAG
95
+ }
96
+ default {
97
+ autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98
+ }
99
+ }
100
+ foreach flag $args {
101
+ msg-checking "Checking whether the $lang compiler accepts $flag..."
102
+ if {[cctest -cflags $flag]} {
103
+ msg-result yes
104
+ define-feature $prefix$flag
105
+ cc-with [list -cflags [list $flag]]
106
+ define-append ${prefix}S $flag
107
+ } else {
108
+ msg-result no
109
+ set result 0
110
+ }
111
+ }
112
+ return $result
113113
}
114114
115115
# @cc-check-standards ver ?...?
116116
#
117117
# Checks whether the C/C++ compiler accepts one of the specified '-std=$ver'
118118
# options, and appends the first working one to '-cflags' and 'CFLAGS' or
119119
# 'CXXFLAGS'.
120120
proc cc-check-standards {args} {
121
- array set opts [cc-get-settings]
122
- foreach std $args {
123
- if {[cc-check-flags -std=$std]} {
124
- return $std
125
- }
126
- }
127
- return ""
121
+ array set opts [cc-get-settings]
122
+ foreach std $args {
123
+ if {[cc-check-flags -std=$std]} {
124
+ return $std
125
+ }
126
+ }
127
+ return ""
128128
}
129129
130130
# Checks whether $keyword is usable as alignof
131131
proc cctest_alignof {keyword} {
132
- msg-checking "Checking for $keyword..."
133
- if {[cctest -code [subst -nobackslashes {
134
- printf("minimum alignment is %d == %d\n", ${keyword}(char), ${keyword}('x'));
135
- }]]} then {
136
- msg-result ok
137
- define-feature $keyword
138
- } else {
139
- msg-result "not found"
140
- }
132
+ msg-checking "Checking for $keyword..."
133
+ if {[cctest -code "int x = ${keyword}(char), y = ${keyword}('x');"]} then {
134
+ msg-result ok
135
+ define-feature $keyword
136
+ } else {
137
+ msg-result "not found"
138
+ }
141139
}
142140
143141
# @cc-check-c11
144142
#
145143
# Checks for several C11/C++11 extensions and their alternatives. Currently
146144
# checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'.
147145
proc cc-check-c11 {} {
148
- msg-checking "Checking for _Static_assert..."
149
- if {[cctest -code {
150
- _Static_assert(1, "static assertions are available");
151
- }]} then {
152
- msg-result ok
153
- define-feature _Static_assert
154
- } else {
155
- msg-result "not found"
156
- }
157
-
158
- cctest_alignof _Alignof
159
- cctest_alignof __alignof__
160
- cctest_alignof __alignof
146
+ msg-checking "Checking for _Static_assert..."
147
+ if {[cctest -code {
148
+ _Static_assert(1, "static assertions are available");
149
+ }]} then {
150
+ msg-result ok
151
+ define-feature _Static_assert
152
+ } else {
153
+ msg-result "not found"
154
+ }
155
+
156
+ cctest_alignof _Alignof
157
+ cctest_alignof __alignof__
158
+ cctest_alignof __alignof
161159
}
162160
163161
# @cc-check-alloca
164162
#
165
-# The equivalent of the AC_FUNC_ALLOCA macro
163
+# The equivalent of the 'AC_FUNC_ALLOCA' macro.
166164
#
167
-# Checks for the existence of alloca
168
-# defines HAVE_ALLOCA and returns 1 if it exists
165
+# Checks for the existence of 'alloca'
166
+# defines 'HAVE_ALLOCA' and returns 1 if it exists.
169167
proc cc-check-alloca {} {
170
- cc-check-some-feature alloca {
171
- cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
172
- }
168
+ cc-check-some-feature alloca {
169
+ cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
170
+ }
173171
}
174172
175173
# @cc-signal-return-type
176174
#
177
-# The equivalent of the AC_TYPE_SIGNAL macro
175
+# The equivalent of the 'AC_TYPE_SIGNAL' macro.
178176
#
179
-# defines RETSIGTYPE to int or void
177
+# defines 'RETSIGTYPE' to 'int' or 'void'.
180178
proc cc-signal-return-type {} {
181
- msg-checking "Checking return type of signal handlers..."
182
- cc-with {-includes {sys/types.h signal.h}} {
183
- if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
184
- set type int
185
- } else {
186
- set type void
187
- }
188
- define RETSIGTYPE $type
189
- msg-result $type
190
- }
179
+ msg-checking "Checking return type of signal handlers..."
180
+ cc-with {-includes {sys/types.h signal.h}} {
181
+ if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
182
+ set type int
183
+ } else {
184
+ set type void
185
+ }
186
+ define RETSIGTYPE $type
187
+ msg-result $type
188
+ }
191189
}
192190
--- autosetup/cc-lib.tcl
+++ autosetup/cc-lib.tcl
@@ -9,12 +9,12 @@
9
10 module-options {}
11
12 # @cc-check-lfs
13 #
14 # The equivalent of the AC_SYS_LARGEFILE macro
15 #
16 # defines 'HAVE_LFS' if LFS is available,
17 # and defines '_FILE_OFFSET_BITS=64' if necessary
18 #
19 # Returns 1 if 'LFS' is available or 0 otherwise
20 #
@@ -35,12 +35,12 @@
35 return $lfs
36 }
37
38 # @cc-check-endian
39 #
40 # The equivalent of the AC_C_BIGENDIAN macro
41 #
42 # defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
43 # or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
44 #
45 # Returns 1 if determined, or 0 if not.
46 #
@@ -80,112 +80,110 @@
80 #
81 # Checks whether the given C/C++ compiler flags can be used. Defines feature
82 # names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and
83 # appends working flags to '-cflags' and 'CFLAGS' or 'CXXFLAGS'.
84 proc cc-check-flags {args} {
85 set result 1
86 array set opts [cc-get-settings]
87 switch -exact -- $opts(-lang) {
88 c++ {
89 set lang C++
90 set prefix CXXFLAG
91 }
92 c {
93 set lang C
94 set prefix CFLAG
95 }
96 default {
97 autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98 }
99 }
100 foreach flag $args {
101 msg-checking "Checking whether the $lang compiler accepts $flag..."
102 if {[cctest -cflags $flag]} {
103 msg-result yes
104 define-feature $prefix$flag
105 cc-with [list -cflags [list $flag]]
106 define-append ${prefix}S $flag
107 } else {
108 msg-result no
109 set result 0
110 }
111 }
112 return $result
113 }
114
115 # @cc-check-standards ver ?...?
116 #
117 # Checks whether the C/C++ compiler accepts one of the specified '-std=$ver'
118 # options, and appends the first working one to '-cflags' and 'CFLAGS' or
119 # 'CXXFLAGS'.
120 proc cc-check-standards {args} {
121 array set opts [cc-get-settings]
122 foreach std $args {
123 if {[cc-check-flags -std=$std]} {
124 return $std
125 }
126 }
127 return ""
128 }
129
130 # Checks whether $keyword is usable as alignof
131 proc cctest_alignof {keyword} {
132 msg-checking "Checking for $keyword..."
133 if {[cctest -code [subst -nobackslashes {
134 printf("minimum alignment is %d == %d\n", ${keyword}(char), ${keyword}('x'));
135 }]]} then {
136 msg-result ok
137 define-feature $keyword
138 } else {
139 msg-result "not found"
140 }
141 }
142
143 # @cc-check-c11
144 #
145 # Checks for several C11/C++11 extensions and their alternatives. Currently
146 # checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'.
147 proc cc-check-c11 {} {
148 msg-checking "Checking for _Static_assert..."
149 if {[cctest -code {
150 _Static_assert(1, "static assertions are available");
151 }]} then {
152 msg-result ok
153 define-feature _Static_assert
154 } else {
155 msg-result "not found"
156 }
157
158 cctest_alignof _Alignof
159 cctest_alignof __alignof__
160 cctest_alignof __alignof
161 }
162
163 # @cc-check-alloca
164 #
165 # The equivalent of the AC_FUNC_ALLOCA macro
166 #
167 # Checks for the existence of alloca
168 # defines HAVE_ALLOCA and returns 1 if it exists
169 proc cc-check-alloca {} {
170 cc-check-some-feature alloca {
171 cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
172 }
173 }
174
175 # @cc-signal-return-type
176 #
177 # The equivalent of the AC_TYPE_SIGNAL macro
178 #
179 # defines RETSIGTYPE to int or void
180 proc cc-signal-return-type {} {
181 msg-checking "Checking return type of signal handlers..."
182 cc-with {-includes {sys/types.h signal.h}} {
183 if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
184 set type int
185 } else {
186 set type void
187 }
188 define RETSIGTYPE $type
189 msg-result $type
190 }
191 }
192
--- autosetup/cc-lib.tcl
+++ autosetup/cc-lib.tcl
@@ -9,12 +9,12 @@
9
10 module-options {}
11
12 # @cc-check-lfs
13 #
14 # The equivalent of the 'AC_SYS_LARGEFILE' macro.
15 #
16 # defines 'HAVE_LFS' if LFS is available,
17 # and defines '_FILE_OFFSET_BITS=64' if necessary
18 #
19 # Returns 1 if 'LFS' is available or 0 otherwise
20 #
@@ -35,12 +35,12 @@
35 return $lfs
36 }
37
38 # @cc-check-endian
39 #
40 # The equivalent of the 'AC_C_BIGENDIAN' macro.
41 #
42 # defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
43 # or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
44 #
45 # Returns 1 if determined, or 0 if not.
46 #
@@ -80,112 +80,110 @@
80 #
81 # Checks whether the given C/C++ compiler flags can be used. Defines feature
82 # names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and
83 # appends working flags to '-cflags' and 'CFLAGS' or 'CXXFLAGS'.
84 proc cc-check-flags {args} {
85 set result 1
86 array set opts [cc-get-settings]
87 switch -exact -- $opts(-lang) {
88 c++ {
89 set lang C++
90 set prefix CXXFLAG
91 }
92 c {
93 set lang C
94 set prefix CFLAG
95 }
96 default {
97 autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98 }
99 }
100 foreach flag $args {
101 msg-checking "Checking whether the $lang compiler accepts $flag..."
102 if {[cctest -cflags $flag]} {
103 msg-result yes
104 define-feature $prefix$flag
105 cc-with [list -cflags [list $flag]]
106 define-append ${prefix}S $flag
107 } else {
108 msg-result no
109 set result 0
110 }
111 }
112 return $result
113 }
114
115 # @cc-check-standards ver ?...?
116 #
117 # Checks whether the C/C++ compiler accepts one of the specified '-std=$ver'
118 # options, and appends the first working one to '-cflags' and 'CFLAGS' or
119 # 'CXXFLAGS'.
120 proc cc-check-standards {args} {
121 array set opts [cc-get-settings]
122 foreach std $args {
123 if {[cc-check-flags -std=$std]} {
124 return $std
125 }
126 }
127 return ""
128 }
129
130 # Checks whether $keyword is usable as alignof
131 proc cctest_alignof {keyword} {
132 msg-checking "Checking for $keyword..."
133 if {[cctest -code "int x = ${keyword}(char), y = ${keyword}('x');"]} then {
134 msg-result ok
135 define-feature $keyword
136 } else {
137 msg-result "not found"
138 }
 
 
139 }
140
141 # @cc-check-c11
142 #
143 # Checks for several C11/C++11 extensions and their alternatives. Currently
144 # checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'.
145 proc cc-check-c11 {} {
146 msg-checking "Checking for _Static_assert..."
147 if {[cctest -code {
148 _Static_assert(1, "static assertions are available");
149 }]} then {
150 msg-result ok
151 define-feature _Static_assert
152 } else {
153 msg-result "not found"
154 }
155
156 cctest_alignof _Alignof
157 cctest_alignof __alignof__
158 cctest_alignof __alignof
159 }
160
161 # @cc-check-alloca
162 #
163 # The equivalent of the 'AC_FUNC_ALLOCA' macro.
164 #
165 # Checks for the existence of 'alloca'
166 # defines 'HAVE_ALLOCA' and returns 1 if it exists.
167 proc cc-check-alloca {} {
168 cc-check-some-feature alloca {
169 cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
170 }
171 }
172
173 # @cc-signal-return-type
174 #
175 # The equivalent of the 'AC_TYPE_SIGNAL' macro.
176 #
177 # defines 'RETSIGTYPE' to 'int' or 'void'.
178 proc cc-signal-return-type {} {
179 msg-checking "Checking return type of signal handlers..."
180 cc-with {-includes {sys/types.h signal.h}} {
181 if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
182 set type int
183 } else {
184 set type void
185 }
186 define RETSIGTYPE $type
187 msg-result $type
188 }
189 }
190
--- autosetup/cc-shared.tcl
+++ autosetup/cc-shared.tcl
@@ -7,27 +7,30 @@
77
# It defines the following variables:
88
#
99
## SH_CFLAGS Flags to use compiling sources destined for a shared library
1010
## SH_LDFLAGS Flags to use linking (creating) a shared library
1111
## SH_SOPREFIX Prefix to use to set the soname when creating a shared library
12
+## SH_SOFULLPATH Set to 1 if the shared library soname should include the full install path
1213
## SH_SOEXT Extension for shared libs
1314
## SH_SOEXTVER Format for versioned shared libs - %s = version
1415
## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object
1516
## SHOBJ_LDFLAGS Flags to use linking a shared object, undefined symbols allowed
1617
## SHOBJ_LDFLAGS_R - as above, but all symbols must be resolved
18
+## SH_LINKRPATH Format for setting the rpath when linking an executable, %s = path
1719
## SH_LINKFLAGS Flags to use linking an executable which will load shared objects
1820
## LD_LIBRARY_PATH Environment variable which specifies path to shared libraries
1921
## STRIPLIBFLAGS Arguments to strip a dynamic library
2022
2123
module-options {}
2224
2325
# Defaults: gcc on unix
24
-define SHOBJ_CFLAGS -fpic
26
+define SHOBJ_CFLAGS -fPIC
2527
define SHOBJ_LDFLAGS -shared
26
-define SH_CFLAGS -fpic
28
+define SH_CFLAGS -fPIC
2729
define SH_LDFLAGS -shared
2830
define SH_LINKFLAGS -rdynamic
31
+define SH_LINKRPATH "-Wl,-rpath -Wl,%s"
2932
define SH_SOEXT .so
3033
define SH_SOEXTVER .so.%s
3134
define SH_SOPREFIX -Wl,-soname,
3235
define LD_LIBRARY_PATH LD_LIBRARY_PATH
3336
define STRIPLIBFLAGS --strip-unneeded
@@ -44,18 +47,20 @@
4447
define SH_LDFLAGS -dynamiclib
4548
define SH_LINKFLAGS ""
4649
define SH_SOEXT .dylib
4750
define SH_SOEXTVER .%s.dylib
4851
define SH_SOPREFIX -Wl,-install_name,
52
+ define SH_SOFULLPATH
4953
define LD_LIBRARY_PATH DYLD_LIBRARY_PATH
5054
define STRIPLIBFLAGS -x
5155
}
5256
*-*-ming* - *-*-cygwin - *-*-msys {
5357
define SHOBJ_CFLAGS ""
5458
define SHOBJ_LDFLAGS -shared
5559
define SH_CFLAGS ""
5660
define SH_LDFLAGS -shared
61
+ define SH_LINKRPATH ""
5762
define SH_LINKFLAGS ""
5863
define SH_SOEXT .dll
5964
define SH_SOEXTVER .dll
6065
define SH_SOPREFIX ""
6166
define LD_LIBRARY_PATH PATH
@@ -62,27 +67,23 @@
6267
}
6368
sparc* {
6469
if {[msg-quiet cc-check-decls __SUNPRO_C]} {
6570
msg-result "Found sun stdio compiler"
6671
# sun stdio compiler
67
- # XXX: These haven't been fully tested.
72
+ # XXX: These haven't been fully tested.
6873
define SHOBJ_CFLAGS -KPIC
6974
define SHOBJ_LDFLAGS "-G"
7075
define SH_CFLAGS -KPIC
7176
define SH_LINKFLAGS -Wl,-export-dynamic
7277
define SH_SOPREFIX -Wl,-h,
73
- } else {
74
- # sparc has a very small GOT table limit, so use -fPIC
75
- define SH_CFLAGS -fPIC
76
- define SHOBJ_CFLAGS -fPIC
7778
}
7879
}
7980
*-*-solaris* {
8081
if {[msg-quiet cc-check-decls __SUNPRO_C]} {
8182
msg-result "Found sun stdio compiler"
8283
# sun stdio compiler
83
- # XXX: These haven't been fully tested.
84
+ # XXX: These haven't been fully tested.
8485
define SHOBJ_CFLAGS -KPIC
8586
define SHOBJ_LDFLAGS "-G"
8687
define SH_CFLAGS -KPIC
8788
define SH_LINKFLAGS -Wl,-export-dynamic
8889
define SH_SOPREFIX -Wl,-h,
@@ -103,15 +104,10 @@
103104
define SH_LDFLAGS -shared
104105
define SH_LINKFLAGS ""
105106
define SH_SOPREFIX ""
106107
define LD_LIBRARY_PATH LIBRARY_PATH
107108
}
108
- microblaze* {
109
- # Microblaze generally needs -fPIC rather than -fpic
110
- define SHOBJ_CFLAGS -fPIC
111
- define SH_CFLAGS -fPIC
112
- }
113109
}
114110
115111
if {![is-defined SHOBJ_LDFLAGS_R]} {
116112
define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
117113
}
118114
--- autosetup/cc-shared.tcl
+++ autosetup/cc-shared.tcl
@@ -7,27 +7,30 @@
7 # It defines the following variables:
8 #
9 ## SH_CFLAGS Flags to use compiling sources destined for a shared library
10 ## SH_LDFLAGS Flags to use linking (creating) a shared library
11 ## SH_SOPREFIX Prefix to use to set the soname when creating a shared library
 
12 ## SH_SOEXT Extension for shared libs
13 ## SH_SOEXTVER Format for versioned shared libs - %s = version
14 ## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object
15 ## SHOBJ_LDFLAGS Flags to use linking a shared object, undefined symbols allowed
16 ## SHOBJ_LDFLAGS_R - as above, but all symbols must be resolved
 
17 ## SH_LINKFLAGS Flags to use linking an executable which will load shared objects
18 ## LD_LIBRARY_PATH Environment variable which specifies path to shared libraries
19 ## STRIPLIBFLAGS Arguments to strip a dynamic library
20
21 module-options {}
22
23 # Defaults: gcc on unix
24 define SHOBJ_CFLAGS -fpic
25 define SHOBJ_LDFLAGS -shared
26 define SH_CFLAGS -fpic
27 define SH_LDFLAGS -shared
28 define SH_LINKFLAGS -rdynamic
 
29 define SH_SOEXT .so
30 define SH_SOEXTVER .so.%s
31 define SH_SOPREFIX -Wl,-soname,
32 define LD_LIBRARY_PATH LD_LIBRARY_PATH
33 define STRIPLIBFLAGS --strip-unneeded
@@ -44,18 +47,20 @@
44 define SH_LDFLAGS -dynamiclib
45 define SH_LINKFLAGS ""
46 define SH_SOEXT .dylib
47 define SH_SOEXTVER .%s.dylib
48 define SH_SOPREFIX -Wl,-install_name,
 
49 define LD_LIBRARY_PATH DYLD_LIBRARY_PATH
50 define STRIPLIBFLAGS -x
51 }
52 *-*-ming* - *-*-cygwin - *-*-msys {
53 define SHOBJ_CFLAGS ""
54 define SHOBJ_LDFLAGS -shared
55 define SH_CFLAGS ""
56 define SH_LDFLAGS -shared
 
57 define SH_LINKFLAGS ""
58 define SH_SOEXT .dll
59 define SH_SOEXTVER .dll
60 define SH_SOPREFIX ""
61 define LD_LIBRARY_PATH PATH
@@ -62,27 +67,23 @@
62 }
63 sparc* {
64 if {[msg-quiet cc-check-decls __SUNPRO_C]} {
65 msg-result "Found sun stdio compiler"
66 # sun stdio compiler
67 # XXX: These haven't been fully tested.
68 define SHOBJ_CFLAGS -KPIC
69 define SHOBJ_LDFLAGS "-G"
70 define SH_CFLAGS -KPIC
71 define SH_LINKFLAGS -Wl,-export-dynamic
72 define SH_SOPREFIX -Wl,-h,
73 } else {
74 # sparc has a very small GOT table limit, so use -fPIC
75 define SH_CFLAGS -fPIC
76 define SHOBJ_CFLAGS -fPIC
77 }
78 }
79 *-*-solaris* {
80 if {[msg-quiet cc-check-decls __SUNPRO_C]} {
81 msg-result "Found sun stdio compiler"
82 # sun stdio compiler
83 # XXX: These haven't been fully tested.
84 define SHOBJ_CFLAGS -KPIC
85 define SHOBJ_LDFLAGS "-G"
86 define SH_CFLAGS -KPIC
87 define SH_LINKFLAGS -Wl,-export-dynamic
88 define SH_SOPREFIX -Wl,-h,
@@ -103,15 +104,10 @@
103 define SH_LDFLAGS -shared
104 define SH_LINKFLAGS ""
105 define SH_SOPREFIX ""
106 define LD_LIBRARY_PATH LIBRARY_PATH
107 }
108 microblaze* {
109 # Microblaze generally needs -fPIC rather than -fpic
110 define SHOBJ_CFLAGS -fPIC
111 define SH_CFLAGS -fPIC
112 }
113 }
114
115 if {![is-defined SHOBJ_LDFLAGS_R]} {
116 define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
117 }
118
--- autosetup/cc-shared.tcl
+++ autosetup/cc-shared.tcl
@@ -7,27 +7,30 @@
7 # It defines the following variables:
8 #
9 ## SH_CFLAGS Flags to use compiling sources destined for a shared library
10 ## SH_LDFLAGS Flags to use linking (creating) a shared library
11 ## SH_SOPREFIX Prefix to use to set the soname when creating a shared library
12 ## SH_SOFULLPATH Set to 1 if the shared library soname should include the full install path
13 ## SH_SOEXT Extension for shared libs
14 ## SH_SOEXTVER Format for versioned shared libs - %s = version
15 ## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object
16 ## SHOBJ_LDFLAGS Flags to use linking a shared object, undefined symbols allowed
17 ## SHOBJ_LDFLAGS_R - as above, but all symbols must be resolved
18 ## SH_LINKRPATH Format for setting the rpath when linking an executable, %s = path
19 ## SH_LINKFLAGS Flags to use linking an executable which will load shared objects
20 ## LD_LIBRARY_PATH Environment variable which specifies path to shared libraries
21 ## STRIPLIBFLAGS Arguments to strip a dynamic library
22
23 module-options {}
24
25 # Defaults: gcc on unix
26 define SHOBJ_CFLAGS -fPIC
27 define SHOBJ_LDFLAGS -shared
28 define SH_CFLAGS -fPIC
29 define SH_LDFLAGS -shared
30 define SH_LINKFLAGS -rdynamic
31 define SH_LINKRPATH "-Wl,-rpath -Wl,%s"
32 define SH_SOEXT .so
33 define SH_SOEXTVER .so.%s
34 define SH_SOPREFIX -Wl,-soname,
35 define LD_LIBRARY_PATH LD_LIBRARY_PATH
36 define STRIPLIBFLAGS --strip-unneeded
@@ -44,18 +47,20 @@
47 define SH_LDFLAGS -dynamiclib
48 define SH_LINKFLAGS ""
49 define SH_SOEXT .dylib
50 define SH_SOEXTVER .%s.dylib
51 define SH_SOPREFIX -Wl,-install_name,
52 define SH_SOFULLPATH
53 define LD_LIBRARY_PATH DYLD_LIBRARY_PATH
54 define STRIPLIBFLAGS -x
55 }
56 *-*-ming* - *-*-cygwin - *-*-msys {
57 define SHOBJ_CFLAGS ""
58 define SHOBJ_LDFLAGS -shared
59 define SH_CFLAGS ""
60 define SH_LDFLAGS -shared
61 define SH_LINKRPATH ""
62 define SH_LINKFLAGS ""
63 define SH_SOEXT .dll
64 define SH_SOEXTVER .dll
65 define SH_SOPREFIX ""
66 define LD_LIBRARY_PATH PATH
@@ -62,27 +67,23 @@
67 }
68 sparc* {
69 if {[msg-quiet cc-check-decls __SUNPRO_C]} {
70 msg-result "Found sun stdio compiler"
71 # sun stdio compiler
72 # XXX: These haven't been fully tested.
73 define SHOBJ_CFLAGS -KPIC
74 define SHOBJ_LDFLAGS "-G"
75 define SH_CFLAGS -KPIC
76 define SH_LINKFLAGS -Wl,-export-dynamic
77 define SH_SOPREFIX -Wl,-h,
 
 
 
 
78 }
79 }
80 *-*-solaris* {
81 if {[msg-quiet cc-check-decls __SUNPRO_C]} {
82 msg-result "Found sun stdio compiler"
83 # sun stdio compiler
84 # XXX: These haven't been fully tested.
85 define SHOBJ_CFLAGS -KPIC
86 define SHOBJ_LDFLAGS "-G"
87 define SH_CFLAGS -KPIC
88 define SH_LINKFLAGS -Wl,-export-dynamic
89 define SH_SOPREFIX -Wl,-h,
@@ -103,15 +104,10 @@
104 define SH_LDFLAGS -shared
105 define SH_LINKFLAGS ""
106 define SH_SOPREFIX ""
107 define LD_LIBRARY_PATH LIBRARY_PATH
108 }
 
 
 
 
 
109 }
110
111 if {![is-defined SHOBJ_LDFLAGS_R]} {
112 define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
113 }
114
+80 -52
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -2,17 +2,18 @@
22
# All rights reserved
33
44
# @synopsis:
55
#
66
# The 'cc' module supports checking various 'features' of the C or C++
7
-# compiler/linker environment. Common commands are cc-check-includes,
8
-# cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-template.
7
+# compiler/linker environment. Common commands are 'cc-check-includes',
8
+# 'cc-check-types', 'cc-check-functions', 'cc-with', 'make-config-header' and 'make-template'.
99
#
1010
# The following environment variables are used if set:
1111
#
1212
## CC - C compiler
1313
## CXX - C++ compiler
14
+## CPP - C preprocessor
1415
## CCACHE - Set to "none" to disable automatic use of ccache
1516
## CFLAGS - Additional C compiler flags
1617
## CXXFLAGS - Additional C++ compiler flags
1718
## LDFLAGS - Additional compiler flags during linking
1819
## LIBS - Additional libraries to use (for all tests)
@@ -28,15 +29,10 @@
2829
2930
use system
3031
3132
module-options {}
3233
33
-# Note that the return code is not meaningful
34
-proc cc-check-something {name code} {
35
- uplevel 1 $code
36
-}
37
-
3834
# Checks for the existence of the given function by linking
3935
#
4036
proc cctest_function {function} {
4137
cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
4238
}
@@ -68,12 +64,12 @@
6864
}
6965
7066
# @cc-check-sizeof type ...
7167
#
7268
# Checks the size of the given types (between 1 and 32, inclusive).
73
-# Defines a variable with the size determined, or "unknown" otherwise.
74
-# e.g. for type 'long long', defines SIZEOF_LONG_LONG.
69
+# Defines a variable with the size determined, or 'unknown' otherwise.
70
+# e.g. for type 'long long', defines 'SIZEOF_LONG_LONG'.
7571
# Returns the size of the last type.
7672
#
7773
proc cc-check-sizeof {args} {
7874
foreach type $args {
7975
msg-checking "Checking for sizeof $type..."
@@ -109,11 +105,11 @@
109105
return $ret
110106
}
111107
112108
# @cc-check-includes includes ...
113109
#
114
-# Checks that the given include files can be used
110
+# Checks that the given include files can be used.
115111
proc cc-check-includes {args} {
116112
cc-check-some-feature $args {
117113
set with {}
118114
if {[dict exists $::autosetup(cc-include-deps) $each]} {
119115
set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
@@ -134,12 +130,12 @@
134130
}
135131
}
136132
137133
# @cc-include-needs include required ...
138134
#
139
-# Ensures that when checking for 'include', a check is first
140
-# made for each 'required' file, and if found, it is #included
135
+# Ensures that when checking for '$include', a check is first
136
+# made for each '$required' file, and if found, it is included with '#include'.
141137
proc cc-include-needs {file args} {
142138
foreach depfile $args {
143139
dict set ::autosetup(cc-include-deps) $file $depfile 1
144140
}
145141
}
@@ -153,22 +149,22 @@
153149
}
154150
}
155151
156152
# @cc-check-defines define ...
157153
#
158
-# Checks that the given preprocessor symbol is defined
154
+# Checks that the given preprocessor symbols are defined.
159155
proc cc-check-defines {args} {
160156
cc-check-some-feature $args {
161157
cctest_define $each
162158
}
163159
}
164160
165161
# @cc-check-decls name ...
166162
#
167163
# Checks that each given name is either a preprocessor symbol or rvalue
168
-# such as an enum. Note that the define used is HAVE_DECL_xxx
169
-# rather than HAVE_xxx
164
+# such as an enum. Note that the define used is 'HAVE_DECL_xxx'
165
+# rather than 'HAVE_xxx'.
170166
proc cc-check-decls {args} {
171167
set ret 1
172168
foreach name $args {
173169
msg-checking "Checking for $name..."
174170
set r [cctest_decl $name]
@@ -183,21 +179,21 @@
183179
return $ret
184180
}
185181
186182
# @cc-check-functions function ...
187183
#
188
-# Checks that the given functions exist (can be linked)
184
+# Checks that the given functions exist (can be linked).
189185
proc cc-check-functions {args} {
190186
cc-check-some-feature $args {
191187
cctest_function $each
192188
}
193189
}
194190
195191
# @cc-check-members type.member ...
196192
#
197193
# Checks that the given type/structure members exist.
198
-# A structure member is of the form "struct stat.st_mtime"
194
+# A structure member is of the form 'struct stat.st_mtime'.
199195
proc cc-check-members {args} {
200196
cc-check-some-feature $args {
201197
cctest_member $each
202198
}
203199
}
@@ -207,20 +203,20 @@
207203
# Checks that the given function can be found in one of the libs.
208204
#
209205
# First checks for no library required, then checks each of the libraries
210206
# in turn.
211207
#
212
-# If the function is found, the feature is defined and lib_$function is defined
213
-# to -l$lib where the function was found, or "" if no library required.
214
-# In addition, -l$lib is prepended to the LIBS define.
208
+# If the function is found, the feature is defined and 'lib_$function' is defined
209
+# to '-l$lib' where the function was found, or "" if no library required.
210
+# In addition, '-l$lib' is prepended to the 'LIBS' define.
215211
#
216212
# If additional libraries may be needed for linking, they should be specified
217
-# as $extralibs as "-lotherlib1 -lotherlib2".
218
-# These libraries are not automatically added to LIBS.
213
+# with '$extralibs' as '-lotherlib1 -lotherlib2'.
214
+# These libraries are not automatically added to 'LIBS'.
219215
#
220216
# Returns 1 if found or 0 if not.
221
-#
217
+#
222218
proc cc-check-function-in-lib {function libs {otherlibs {}}} {
223219
msg-checking "Checking libs for $function..."
224220
set found 0
225221
cc-with [list -libs $otherlibs] {
226222
if {[cctest_function $function]} {
@@ -240,13 +236,12 @@
240236
}
241237
}
242238
}
243239
}
244240
}
245
- if {$found} {
246
- define [feature-define-name $function]
247
- } else {
241
+ define-feature $function $found
242
+ if {!$found} {
248243
msg-result "no"
249244
}
250245
return $found
251246
}
252247
@@ -253,16 +248,16 @@
253248
# @cc-check-tools tool ...
254249
#
255250
# Checks for existence of the given compiler tools, taking
256251
# into account any cross compilation prefix.
257252
#
258
-# For example, when checking for "ar", first AR is checked on the command
259
-# line and then in the environment. If not found, "${host}-ar" or
260
-# simply "ar" is assumed depending upon whether cross compiling.
261
-# The path is searched for this executable, and if found AR is defined
253
+# For example, when checking for 'ar', first 'AR' is checked on the command
254
+# line and then in the environment. If not found, '${host}-ar' or
255
+# simply 'ar' is assumed depending upon whether cross compiling.
256
+# The path is searched for this executable, and if found 'AR' is defined
262257
# to the executable name.
263
-# Note that even when cross compiling, the simple "ar" is used as a fallback,
258
+# Note that even when cross compiling, the simple 'ar' is used as a fallback,
264259
# but a warning is generated. This is necessary for some toolchains.
265260
#
266261
# It is an error if the executable is not found.
267262
#
268263
proc cc-check-tools {args} {
@@ -284,14 +279,14 @@
284279
285280
# @cc-check-progs prog ...
286281
#
287282
# Checks for existence of the given executables on the path.
288283
#
289
-# For example, when checking for "grep", the path is searched for
290
-# the executable, 'grep', and if found GREP is defined as "grep".
284
+# For example, when checking for 'grep', the path is searched for
285
+# the executable, 'grep', and if found 'GREP' is defined as 'grep'.
291286
#
292
-# If the executable is not found, the variable is defined as false.
287
+# If the executable is not found, the variable is defined as 'false'.
293288
# Returns 1 if all programs were found, or 0 otherwise.
294289
#
295290
proc cc-check-progs {args} {
296291
set failed 0
297292
foreach prog $args {
@@ -303,10 +298,33 @@
303298
incr failed
304299
} else {
305300
msg-result ok
306301
define $PROG $prog
307302
}
303
+ }
304
+ expr {!$failed}
305
+}
306
+
307
+# @cc-path-progs prog ...
308
+#
309
+# Like cc-check-progs, but sets the define to the full path rather
310
+# than just the program name.
311
+#
312
+proc cc-path-progs {args} {
313
+ set failed 0
314
+ foreach prog $args {
315
+ set PROG [string toupper $prog]
316
+ msg-checking "Checking for $prog..."
317
+ set path [find-executable-path $prog]
318
+ if {$path eq ""} {
319
+ msg-result no
320
+ define $PROG false
321
+ incr failed
322
+ } else {
323
+ msg-result $path
324
+ define $PROG $path
325
+ }
308326
}
309327
expr {!$failed}
310328
}
311329
312330
# Adds the given settings to $::autosetup(ccsettings) and
@@ -326,18 +344,18 @@
326344
327345
foreach {name value} $settings {
328346
switch -exact -- $name {
329347
-cflags - -includes {
330348
# These are given as lists
331
- lappend new($name) {*}$value
349
+ lappend new($name) {*}[list-non-empty $value]
332350
}
333351
-declare {
334352
lappend new($name) $value
335353
}
336354
-libs {
337355
# Note that new libraries are added before previous libraries
338
- set new($name) [list {*}$value {*}$new($name)]
356
+ set new($name) [list {*}[list-non-empty $value] {*}$new($name)]
339357
}
340358
-link - -lang - -nooutput {
341359
set new($name) $value
342360
}
343361
-source - -sourcefile - -code {
@@ -373,16 +391,16 @@
373391
return $prev
374392
}
375393
376394
# @cc-with settings ?{ script }?
377395
#
378
-# Sets the given 'cctest' settings and then runs the tests in 'script'.
379
-# Note that settings such as -lang replace the current setting, while
380
-# those such as -includes are appended to the existing setting.
396
+# Sets the given 'cctest' settings and then runs the tests in '$script'.
397
+# Note that settings such as '-lang' replace the current setting, while
398
+# those such as '-includes' are appended to the existing setting.
381399
#
382400
# If no script is given, the settings become the default for the remainder
383
-# of the auto.def file.
401
+# of the 'auto.def' file.
384402
#
385403
## cc-with {-lang c++} {
386404
## # This will check with the C++ compiler
387405
## cc-check-types bool
388406
## cc-with {-includes signal.h} {
@@ -390,11 +408,11 @@
390408
## ...
391409
## }
392410
## # back to just the C++ compiler
393411
## }
394412
#
395
-# The -libs setting is special in that newer values are added *before* earlier ones.
413
+# The '-libs' setting is special in that newer values are added *before* earlier ones.
396414
#
397415
## cc-with {-libs {-lc -lm}} {
398416
## cc-with {-libs -ldl} {
399417
## cctest -libs -lsocket ...
400418
## # libs will be in this order: -lsocket -ldl -lc -lm
@@ -415,12 +433,12 @@
415433
return $result
416434
}
417435
}
418436
419437
# @cctest ?settings?
420
-#
421
-# Low level C compiler checker. Compiles and or links a small C program
438
+#
439
+# Low level C/C++ compiler checker. Compiles and or links a small C program
422440
# according to the arguments and returns 1 if OK, or 0 if not.
423441
#
424442
# Supported settings are:
425443
#
426444
## -cflags cflags A list of flags to pass to the compiler
@@ -432,11 +450,11 @@
432450
## -code code Code to compile in the body of main()
433451
## -source code Compile a complete program. Ignore -includes, -declare and -code
434452
## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
435453
## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
436454
#
437
-# Unless -source or -sourcefile is specified, the C program looks like:
455
+# Unless '-source' or '-sourcefile' is specified, the C program looks like:
438456
#
439457
## #include <firstinclude> /* same for remaining includes in the list */
440458
##
441459
## declare-code /* any code in -declare, verbatim */
442460
##
@@ -446,11 +464,10 @@
446464
## }
447465
#
448466
# Any failures are recorded in 'config.log'
449467
#
450468
proc cctest {args} {
451
- set src conftest__.c
452469
set tmp conftest__
453470
454471
# Easiest way to merge in the settings
455472
cc-with $args {
456473
array set opts [cc-get-settings]
@@ -488,13 +505,15 @@
488505
# Build the command line
489506
set cmdline {}
490507
lappend cmdline {*}[get-define CCACHE]
491508
switch -exact -- $opts(-lang) {
492509
c++ {
510
+ set src conftest__.cpp
493511
lappend cmdline {*}[get-define CXX] {*}[get-define CXXFLAGS]
494512
}
495513
c {
514
+ set src conftest__.c
496515
lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
497516
}
498517
default {
499518
autosetup-error "cctest called with unknown language: $opts(-lang)"
500519
}
@@ -554,32 +573,32 @@
554573
return $ok
555574
}
556575
557576
# @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
558577
#
559
-# Deprecated - see make-config-header
578
+# Deprecated - see 'make-config-header'
560579
proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
561580
user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
562581
make-config-header $file -auto $autopatterns -bare $barepatterns
563582
}
564583
565584
# @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
566585
#
567586
# Examines all defined variables which match the given patterns
568
-# and writes an include file, $file, which defines each of these.
587
+# and writes an include file, '$file', which defines each of these.
569588
# Variables which match '-auto' are output as follows:
570
-# - defines which have the value "0" are ignored.
589
+# - defines which have the value '0' are ignored.
571590
# - defines which have integer values are defined as the integer value.
572
-# - any other value is defined as a string, e.g. "value"
591
+# - any other value is defined as a string, e.g. '"value"'
573592
# Variables which match '-bare' are defined as-is.
574
-# Variables which match '-str' are defined as a string, e.g. "value"
593
+# Variables which match '-str' are defined as a string, e.g. '"value"'
575594
# Variables which match '-none' are omitted.
576595
#
577
-# Note that order is important. The first pattern which matches is selected
596
+# Note that order is important. The first pattern that matches is selected.
578597
# Default behaviour is:
579598
#
580
-# -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
599
+## -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
581600
#
582601
# If the file would be unchanged, it is not written.
583602
proc make-config-header {file args} {
584603
set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
585604
file mkdir [file dirname $file]
@@ -677,10 +696,19 @@
677696
if {[get-define CC] eq ""} {
678697
user-error "Could not find a C compiler. Tried: [join $try ", "]"
679698
}
680699
681700
define CCACHE [find-an-executable [get-env CCACHE ccache]]
701
+
702
+# If any of these are set in the environment, propagate them to the AUTOREMAKE commandline
703
+foreach i {CC CXX CCACHE CPP CFLAGS CXXFLAGS CXXFLAGS LDFLAGS LIBS CROSS CPPFLAGS LINKFLAGS CC_FOR_BUILD LD} {
704
+ if {[env-is-set $i]} {
705
+ # Note: If the variable is set on the command line, get-env will return that value
706
+ # so the command line will continue to override the environment
707
+ define-append AUTOREMAKE [quote-if-needed $i=[get-env $i ""]]
708
+ }
709
+}
682710
683711
# Initial cctest settings
684712
cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
685713
set autosetup(cc-include-deps) {}
686714
687715
688716
DELETED autosetup/config.guess
689717
DELETED autosetup/config.sub
690718
DELETED autosetup/find-tclsh
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -2,17 +2,18 @@
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc' module supports checking various 'features' of the C or C++
7 # compiler/linker environment. Common commands are cc-check-includes,
8 # cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-template.
9 #
10 # The following environment variables are used if set:
11 #
12 ## CC - C compiler
13 ## CXX - C++ compiler
 
14 ## CCACHE - Set to "none" to disable automatic use of ccache
15 ## CFLAGS - Additional C compiler flags
16 ## CXXFLAGS - Additional C++ compiler flags
17 ## LDFLAGS - Additional compiler flags during linking
18 ## LIBS - Additional libraries to use (for all tests)
@@ -28,15 +29,10 @@
28
29 use system
30
31 module-options {}
32
33 # Note that the return code is not meaningful
34 proc cc-check-something {name code} {
35 uplevel 1 $code
36 }
37
38 # Checks for the existence of the given function by linking
39 #
40 proc cctest_function {function} {
41 cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
42 }
@@ -68,12 +64,12 @@
68 }
69
70 # @cc-check-sizeof type ...
71 #
72 # Checks the size of the given types (between 1 and 32, inclusive).
73 # Defines a variable with the size determined, or "unknown" otherwise.
74 # e.g. for type 'long long', defines SIZEOF_LONG_LONG.
75 # Returns the size of the last type.
76 #
77 proc cc-check-sizeof {args} {
78 foreach type $args {
79 msg-checking "Checking for sizeof $type..."
@@ -109,11 +105,11 @@
109 return $ret
110 }
111
112 # @cc-check-includes includes ...
113 #
114 # Checks that the given include files can be used
115 proc cc-check-includes {args} {
116 cc-check-some-feature $args {
117 set with {}
118 if {[dict exists $::autosetup(cc-include-deps) $each]} {
119 set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
@@ -134,12 +130,12 @@
134 }
135 }
136
137 # @cc-include-needs include required ...
138 #
139 # Ensures that when checking for 'include', a check is first
140 # made for each 'required' file, and if found, it is #included
141 proc cc-include-needs {file args} {
142 foreach depfile $args {
143 dict set ::autosetup(cc-include-deps) $file $depfile 1
144 }
145 }
@@ -153,22 +149,22 @@
153 }
154 }
155
156 # @cc-check-defines define ...
157 #
158 # Checks that the given preprocessor symbol is defined
159 proc cc-check-defines {args} {
160 cc-check-some-feature $args {
161 cctest_define $each
162 }
163 }
164
165 # @cc-check-decls name ...
166 #
167 # Checks that each given name is either a preprocessor symbol or rvalue
168 # such as an enum. Note that the define used is HAVE_DECL_xxx
169 # rather than HAVE_xxx
170 proc cc-check-decls {args} {
171 set ret 1
172 foreach name $args {
173 msg-checking "Checking for $name..."
174 set r [cctest_decl $name]
@@ -183,21 +179,21 @@
183 return $ret
184 }
185
186 # @cc-check-functions function ...
187 #
188 # Checks that the given functions exist (can be linked)
189 proc cc-check-functions {args} {
190 cc-check-some-feature $args {
191 cctest_function $each
192 }
193 }
194
195 # @cc-check-members type.member ...
196 #
197 # Checks that the given type/structure members exist.
198 # A structure member is of the form "struct stat.st_mtime"
199 proc cc-check-members {args} {
200 cc-check-some-feature $args {
201 cctest_member $each
202 }
203 }
@@ -207,20 +203,20 @@
207 # Checks that the given function can be found in one of the libs.
208 #
209 # First checks for no library required, then checks each of the libraries
210 # in turn.
211 #
212 # If the function is found, the feature is defined and lib_$function is defined
213 # to -l$lib where the function was found, or "" if no library required.
214 # In addition, -l$lib is prepended to the LIBS define.
215 #
216 # If additional libraries may be needed for linking, they should be specified
217 # as $extralibs as "-lotherlib1 -lotherlib2".
218 # These libraries are not automatically added to LIBS.
219 #
220 # Returns 1 if found or 0 if not.
221 #
222 proc cc-check-function-in-lib {function libs {otherlibs {}}} {
223 msg-checking "Checking libs for $function..."
224 set found 0
225 cc-with [list -libs $otherlibs] {
226 if {[cctest_function $function]} {
@@ -240,13 +236,12 @@
240 }
241 }
242 }
243 }
244 }
245 if {$found} {
246 define [feature-define-name $function]
247 } else {
248 msg-result "no"
249 }
250 return $found
251 }
252
@@ -253,16 +248,16 @@
253 # @cc-check-tools tool ...
254 #
255 # Checks for existence of the given compiler tools, taking
256 # into account any cross compilation prefix.
257 #
258 # For example, when checking for "ar", first AR is checked on the command
259 # line and then in the environment. If not found, "${host}-ar" or
260 # simply "ar" is assumed depending upon whether cross compiling.
261 # The path is searched for this executable, and if found AR is defined
262 # to the executable name.
263 # Note that even when cross compiling, the simple "ar" is used as a fallback,
264 # but a warning is generated. This is necessary for some toolchains.
265 #
266 # It is an error if the executable is not found.
267 #
268 proc cc-check-tools {args} {
@@ -284,14 +279,14 @@
284
285 # @cc-check-progs prog ...
286 #
287 # Checks for existence of the given executables on the path.
288 #
289 # For example, when checking for "grep", the path is searched for
290 # the executable, 'grep', and if found GREP is defined as "grep".
291 #
292 # If the executable is not found, the variable is defined as false.
293 # Returns 1 if all programs were found, or 0 otherwise.
294 #
295 proc cc-check-progs {args} {
296 set failed 0
297 foreach prog $args {
@@ -303,10 +298,33 @@
303 incr failed
304 } else {
305 msg-result ok
306 define $PROG $prog
307 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308 }
309 expr {!$failed}
310 }
311
312 # Adds the given settings to $::autosetup(ccsettings) and
@@ -326,18 +344,18 @@
326
327 foreach {name value} $settings {
328 switch -exact -- $name {
329 -cflags - -includes {
330 # These are given as lists
331 lappend new($name) {*}$value
332 }
333 -declare {
334 lappend new($name) $value
335 }
336 -libs {
337 # Note that new libraries are added before previous libraries
338 set new($name) [list {*}$value {*}$new($name)]
339 }
340 -link - -lang - -nooutput {
341 set new($name) $value
342 }
343 -source - -sourcefile - -code {
@@ -373,16 +391,16 @@
373 return $prev
374 }
375
376 # @cc-with settings ?{ script }?
377 #
378 # Sets the given 'cctest' settings and then runs the tests in 'script'.
379 # Note that settings such as -lang replace the current setting, while
380 # those such as -includes are appended to the existing setting.
381 #
382 # If no script is given, the settings become the default for the remainder
383 # of the auto.def file.
384 #
385 ## cc-with {-lang c++} {
386 ## # This will check with the C++ compiler
387 ## cc-check-types bool
388 ## cc-with {-includes signal.h} {
@@ -390,11 +408,11 @@
390 ## ...
391 ## }
392 ## # back to just the C++ compiler
393 ## }
394 #
395 # The -libs setting is special in that newer values are added *before* earlier ones.
396 #
397 ## cc-with {-libs {-lc -lm}} {
398 ## cc-with {-libs -ldl} {
399 ## cctest -libs -lsocket ...
400 ## # libs will be in this order: -lsocket -ldl -lc -lm
@@ -415,12 +433,12 @@
415 return $result
416 }
417 }
418
419 # @cctest ?settings?
420 #
421 # Low level C compiler checker. Compiles and or links a small C program
422 # according to the arguments and returns 1 if OK, or 0 if not.
423 #
424 # Supported settings are:
425 #
426 ## -cflags cflags A list of flags to pass to the compiler
@@ -432,11 +450,11 @@
432 ## -code code Code to compile in the body of main()
433 ## -source code Compile a complete program. Ignore -includes, -declare and -code
434 ## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
435 ## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
436 #
437 # Unless -source or -sourcefile is specified, the C program looks like:
438 #
439 ## #include <firstinclude> /* same for remaining includes in the list */
440 ##
441 ## declare-code /* any code in -declare, verbatim */
442 ##
@@ -446,11 +464,10 @@
446 ## }
447 #
448 # Any failures are recorded in 'config.log'
449 #
450 proc cctest {args} {
451 set src conftest__.c
452 set tmp conftest__
453
454 # Easiest way to merge in the settings
455 cc-with $args {
456 array set opts [cc-get-settings]
@@ -488,13 +505,15 @@
488 # Build the command line
489 set cmdline {}
490 lappend cmdline {*}[get-define CCACHE]
491 switch -exact -- $opts(-lang) {
492 c++ {
 
493 lappend cmdline {*}[get-define CXX] {*}[get-define CXXFLAGS]
494 }
495 c {
 
496 lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
497 }
498 default {
499 autosetup-error "cctest called with unknown language: $opts(-lang)"
500 }
@@ -554,32 +573,32 @@
554 return $ok
555 }
556
557 # @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
558 #
559 # Deprecated - see make-config-header
560 proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
561 user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
562 make-config-header $file -auto $autopatterns -bare $barepatterns
563 }
564
565 # @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
566 #
567 # Examines all defined variables which match the given patterns
568 # and writes an include file, $file, which defines each of these.
569 # Variables which match '-auto' are output as follows:
570 # - defines which have the value "0" are ignored.
571 # - defines which have integer values are defined as the integer value.
572 # - any other value is defined as a string, e.g. "value"
573 # Variables which match '-bare' are defined as-is.
574 # Variables which match '-str' are defined as a string, e.g. "value"
575 # Variables which match '-none' are omitted.
576 #
577 # Note that order is important. The first pattern which matches is selected
578 # Default behaviour is:
579 #
580 # -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
581 #
582 # If the file would be unchanged, it is not written.
583 proc make-config-header {file args} {
584 set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
585 file mkdir [file dirname $file]
@@ -677,10 +696,19 @@
677 if {[get-define CC] eq ""} {
678 user-error "Could not find a C compiler. Tried: [join $try ", "]"
679 }
680
681 define CCACHE [find-an-executable [get-env CCACHE ccache]]
 
 
 
 
 
 
 
 
 
682
683 # Initial cctest settings
684 cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
685 set autosetup(cc-include-deps) {}
686
687
688 ELETED autosetup/config.guess
689 ELETED autosetup/config.sub
690 ELETED autosetup/find-tclsh
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -2,17 +2,18 @@
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc' module supports checking various 'features' of the C or C++
7 # compiler/linker environment. Common commands are 'cc-check-includes',
8 # 'cc-check-types', 'cc-check-functions', 'cc-with', 'make-config-header' and 'make-template'.
9 #
10 # The following environment variables are used if set:
11 #
12 ## CC - C compiler
13 ## CXX - C++ compiler
14 ## CPP - C preprocessor
15 ## CCACHE - Set to "none" to disable automatic use of ccache
16 ## CFLAGS - Additional C compiler flags
17 ## CXXFLAGS - Additional C++ compiler flags
18 ## LDFLAGS - Additional compiler flags during linking
19 ## LIBS - Additional libraries to use (for all tests)
@@ -28,15 +29,10 @@
29
30 use system
31
32 module-options {}
33
 
 
 
 
 
34 # Checks for the existence of the given function by linking
35 #
36 proc cctest_function {function} {
37 cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
38 }
@@ -68,12 +64,12 @@
64 }
65
66 # @cc-check-sizeof type ...
67 #
68 # Checks the size of the given types (between 1 and 32, inclusive).
69 # Defines a variable with the size determined, or 'unknown' otherwise.
70 # e.g. for type 'long long', defines 'SIZEOF_LONG_LONG'.
71 # Returns the size of the last type.
72 #
73 proc cc-check-sizeof {args} {
74 foreach type $args {
75 msg-checking "Checking for sizeof $type..."
@@ -109,11 +105,11 @@
105 return $ret
106 }
107
108 # @cc-check-includes includes ...
109 #
110 # Checks that the given include files can be used.
111 proc cc-check-includes {args} {
112 cc-check-some-feature $args {
113 set with {}
114 if {[dict exists $::autosetup(cc-include-deps) $each]} {
115 set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
@@ -134,12 +130,12 @@
130 }
131 }
132
133 # @cc-include-needs include required ...
134 #
135 # Ensures that when checking for '$include', a check is first
136 # made for each '$required' file, and if found, it is included with '#include'.
137 proc cc-include-needs {file args} {
138 foreach depfile $args {
139 dict set ::autosetup(cc-include-deps) $file $depfile 1
140 }
141 }
@@ -153,22 +149,22 @@
149 }
150 }
151
152 # @cc-check-defines define ...
153 #
154 # Checks that the given preprocessor symbols are defined.
155 proc cc-check-defines {args} {
156 cc-check-some-feature $args {
157 cctest_define $each
158 }
159 }
160
161 # @cc-check-decls name ...
162 #
163 # Checks that each given name is either a preprocessor symbol or rvalue
164 # such as an enum. Note that the define used is 'HAVE_DECL_xxx'
165 # rather than 'HAVE_xxx'.
166 proc cc-check-decls {args} {
167 set ret 1
168 foreach name $args {
169 msg-checking "Checking for $name..."
170 set r [cctest_decl $name]
@@ -183,21 +179,21 @@
179 return $ret
180 }
181
182 # @cc-check-functions function ...
183 #
184 # Checks that the given functions exist (can be linked).
185 proc cc-check-functions {args} {
186 cc-check-some-feature $args {
187 cctest_function $each
188 }
189 }
190
191 # @cc-check-members type.member ...
192 #
193 # Checks that the given type/structure members exist.
194 # A structure member is of the form 'struct stat.st_mtime'.
195 proc cc-check-members {args} {
196 cc-check-some-feature $args {
197 cctest_member $each
198 }
199 }
@@ -207,20 +203,20 @@
203 # Checks that the given function can be found in one of the libs.
204 #
205 # First checks for no library required, then checks each of the libraries
206 # in turn.
207 #
208 # If the function is found, the feature is defined and 'lib_$function' is defined
209 # to '-l$lib' where the function was found, or "" if no library required.
210 # In addition, '-l$lib' is prepended to the 'LIBS' define.
211 #
212 # If additional libraries may be needed for linking, they should be specified
213 # with '$extralibs' as '-lotherlib1 -lotherlib2'.
214 # These libraries are not automatically added to 'LIBS'.
215 #
216 # Returns 1 if found or 0 if not.
217 #
218 proc cc-check-function-in-lib {function libs {otherlibs {}}} {
219 msg-checking "Checking libs for $function..."
220 set found 0
221 cc-with [list -libs $otherlibs] {
222 if {[cctest_function $function]} {
@@ -240,13 +236,12 @@
236 }
237 }
238 }
239 }
240 }
241 define-feature $function $found
242 if {!$found} {
 
243 msg-result "no"
244 }
245 return $found
246 }
247
@@ -253,16 +248,16 @@
248 # @cc-check-tools tool ...
249 #
250 # Checks for existence of the given compiler tools, taking
251 # into account any cross compilation prefix.
252 #
253 # For example, when checking for 'ar', first 'AR' is checked on the command
254 # line and then in the environment. If not found, '${host}-ar' or
255 # simply 'ar' is assumed depending upon whether cross compiling.
256 # The path is searched for this executable, and if found 'AR' is defined
257 # to the executable name.
258 # Note that even when cross compiling, the simple 'ar' is used as a fallback,
259 # but a warning is generated. This is necessary for some toolchains.
260 #
261 # It is an error if the executable is not found.
262 #
263 proc cc-check-tools {args} {
@@ -284,14 +279,14 @@
279
280 # @cc-check-progs prog ...
281 #
282 # Checks for existence of the given executables on the path.
283 #
284 # For example, when checking for 'grep', the path is searched for
285 # the executable, 'grep', and if found 'GREP' is defined as 'grep'.
286 #
287 # If the executable is not found, the variable is defined as 'false'.
288 # Returns 1 if all programs were found, or 0 otherwise.
289 #
290 proc cc-check-progs {args} {
291 set failed 0
292 foreach prog $args {
@@ -303,10 +298,33 @@
298 incr failed
299 } else {
300 msg-result ok
301 define $PROG $prog
302 }
303 }
304 expr {!$failed}
305 }
306
307 # @cc-path-progs prog ...
308 #
309 # Like cc-check-progs, but sets the define to the full path rather
310 # than just the program name.
311 #
312 proc cc-path-progs {args} {
313 set failed 0
314 foreach prog $args {
315 set PROG [string toupper $prog]
316 msg-checking "Checking for $prog..."
317 set path [find-executable-path $prog]
318 if {$path eq ""} {
319 msg-result no
320 define $PROG false
321 incr failed
322 } else {
323 msg-result $path
324 define $PROG $path
325 }
326 }
327 expr {!$failed}
328 }
329
330 # Adds the given settings to $::autosetup(ccsettings) and
@@ -326,18 +344,18 @@
344
345 foreach {name value} $settings {
346 switch -exact -- $name {
347 -cflags - -includes {
348 # These are given as lists
349 lappend new($name) {*}[list-non-empty $value]
350 }
351 -declare {
352 lappend new($name) $value
353 }
354 -libs {
355 # Note that new libraries are added before previous libraries
356 set new($name) [list {*}[list-non-empty $value] {*}$new($name)]
357 }
358 -link - -lang - -nooutput {
359 set new($name) $value
360 }
361 -source - -sourcefile - -code {
@@ -373,16 +391,16 @@
391 return $prev
392 }
393
394 # @cc-with settings ?{ script }?
395 #
396 # Sets the given 'cctest' settings and then runs the tests in '$script'.
397 # Note that settings such as '-lang' replace the current setting, while
398 # those such as '-includes' are appended to the existing setting.
399 #
400 # If no script is given, the settings become the default for the remainder
401 # of the 'auto.def' file.
402 #
403 ## cc-with {-lang c++} {
404 ## # This will check with the C++ compiler
405 ## cc-check-types bool
406 ## cc-with {-includes signal.h} {
@@ -390,11 +408,11 @@
408 ## ...
409 ## }
410 ## # back to just the C++ compiler
411 ## }
412 #
413 # The '-libs' setting is special in that newer values are added *before* earlier ones.
414 #
415 ## cc-with {-libs {-lc -lm}} {
416 ## cc-with {-libs -ldl} {
417 ## cctest -libs -lsocket ...
418 ## # libs will be in this order: -lsocket -ldl -lc -lm
@@ -415,12 +433,12 @@
433 return $result
434 }
435 }
436
437 # @cctest ?settings?
438 #
439 # Low level C/C++ compiler checker. Compiles and or links a small C program
440 # according to the arguments and returns 1 if OK, or 0 if not.
441 #
442 # Supported settings are:
443 #
444 ## -cflags cflags A list of flags to pass to the compiler
@@ -432,11 +450,11 @@
450 ## -code code Code to compile in the body of main()
451 ## -source code Compile a complete program. Ignore -includes, -declare and -code
452 ## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
453 ## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
454 #
455 # Unless '-source' or '-sourcefile' is specified, the C program looks like:
456 #
457 ## #include <firstinclude> /* same for remaining includes in the list */
458 ##
459 ## declare-code /* any code in -declare, verbatim */
460 ##
@@ -446,11 +464,10 @@
464 ## }
465 #
466 # Any failures are recorded in 'config.log'
467 #
468 proc cctest {args} {
 
469 set tmp conftest__
470
471 # Easiest way to merge in the settings
472 cc-with $args {
473 array set opts [cc-get-settings]
@@ -488,13 +505,15 @@
505 # Build the command line
506 set cmdline {}
507 lappend cmdline {*}[get-define CCACHE]
508 switch -exact -- $opts(-lang) {
509 c++ {
510 set src conftest__.cpp
511 lappend cmdline {*}[get-define CXX] {*}[get-define CXXFLAGS]
512 }
513 c {
514 set src conftest__.c
515 lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
516 }
517 default {
518 autosetup-error "cctest called with unknown language: $opts(-lang)"
519 }
@@ -554,32 +573,32 @@
573 return $ok
574 }
575
576 # @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
577 #
578 # Deprecated - see 'make-config-header'
579 proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
580 user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
581 make-config-header $file -auto $autopatterns -bare $barepatterns
582 }
583
584 # @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
585 #
586 # Examines all defined variables which match the given patterns
587 # and writes an include file, '$file', which defines each of these.
588 # Variables which match '-auto' are output as follows:
589 # - defines which have the value '0' are ignored.
590 # - defines which have integer values are defined as the integer value.
591 # - any other value is defined as a string, e.g. '"value"'
592 # Variables which match '-bare' are defined as-is.
593 # Variables which match '-str' are defined as a string, e.g. '"value"'
594 # Variables which match '-none' are omitted.
595 #
596 # Note that order is important. The first pattern that matches is selected.
597 # Default behaviour is:
598 #
599 ## -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
600 #
601 # If the file would be unchanged, it is not written.
602 proc make-config-header {file args} {
603 set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
604 file mkdir [file dirname $file]
@@ -677,10 +696,19 @@
696 if {[get-define CC] eq ""} {
697 user-error "Could not find a C compiler. Tried: [join $try ", "]"
698 }
699
700 define CCACHE [find-an-executable [get-env CCACHE ccache]]
701
702 # If any of these are set in the environment, propagate them to the AUTOREMAKE commandline
703 foreach i {CC CXX CCACHE CPP CFLAGS CXXFLAGS CXXFLAGS LDFLAGS LIBS CROSS CPPFLAGS LINKFLAGS CC_FOR_BUILD LD} {
704 if {[env-is-set $i]} {
705 # Note: If the variable is set on the command line, get-env will return that value
706 # so the command line will continue to override the environment
707 define-append AUTOREMAKE [quote-if-needed $i=[get-env $i ""]]
708 }
709 }
710
711 # Initial cctest settings
712 cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
713 set autosetup(cc-include-deps) {}
714
715
716 ELETED autosetup/config.guess
717 ELETED autosetup/config.sub
718 ELETED autosetup/find-tclsh
D autosetup/config.guess
-50
--- a/autosetup/config.guess
+++ b/autosetup/config.guess
@@ -1,50 +0,0 @@
1
-#! /bin/sh
2
-# Attempt to guess a canonical system name.
3
-# Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
4
-# under the terms of the GNU General Public License as published by
5
-# t;e Free Software Foundation, either version 3 of the L;cense, or
6
-# (at your option) any later version.
7
-#
8
-# This program is distributed in the hope that it will be useful, but
9
-# WITHOUT ANY WARRANTY; without even the implied warranty of
10
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
-# General Public License for more details.
12
-#
13
-# You should have received a copy of the GNU General Public License
14
-# along with this program; if not, see <https://www.gnu.org/licenses/>.
15
-#
16
-# As a special exceptionto the GNU General Public License, if you
17
-# distribute this file as part of a program that contains a
18
-# configuration script generated by Autoconf, you may include it under
19
-# the same distribution terms that you use for the rest of that
20
-# program. This Exception is an additional permission under section 7
21
-# of the GNU General Public License, version 3 ("GPLv3").
22
-#
23
-# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
24
-#
25
-# You can get the latest version of this script from:
26
-# https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
-
28
-$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29
- cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30
-# Attempt to guess a canoniAttempt to g! /bin/sh
31
-# Attemp#*) machine=${! /bin/sh
32
-# Attemp#! /bin/sh
33
-# Attempt to guess a canonical system name.
34
-# Copyright 1992-2018canonical system name.
35
-# Copyrig! /bin/sh
36
-# Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37
-# Attemp#! /bin/sh
38
-# Attempt to guess a ${! /bin/sh
39
-# Attemp#! /bin/sh
40
-# Attempt to guess a cekkoBSD:*:*)
41
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42
- echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43
-# Attempt to guess a canonical system name.
44
-# Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45
-# Copyright 1992-2018 Free Software Foundation, Inc.
46
-
47
-timestamp='2018-03-08it and/or modify it
48
-# under the terms of the GNU General Public License as published by
49
-# t;e Free Software Foundation, either version 3 of the L;cense, or
50
-# (at your o
--- a/autosetup/config.guess
+++ b/autosetup/config.guess
@@ -1,50 +0,0 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exceptionto the GNU General Public License, if you
17 # distribute this file as part of a program that contains a
18 # configuration script generated by Autoconf, you may include it under
19 # the same distribution terms that you use for the rest of that
20 # program. This Exception is an additional permission under section 7
21 # of the GNU General Public License, version 3 ("GPLv3").
22 #
23 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
24 #
25 # You can get the latest version of this script from:
26 # https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
28 $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29 cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30 # Attempt to guess a canoniAttempt to g! /bin/sh
31 # Attemp#*) machine=${! /bin/sh
32 # Attemp#! /bin/sh
33 # Attempt to guess a canonical system name.
34 # Copyright 1992-2018canonical system name.
35 # Copyrig! /bin/sh
36 # Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37 # Attemp#! /bin/sh
38 # Attempt to guess a ${! /bin/sh
39 # Attemp#! /bin/sh
40 # Attempt to guess a cekkoBSD:*:*)
41 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42 echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43 # Attempt to guess a canonical system name.
44 # Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45 # Copyright 1992-2018 Free Software Foundation, Inc.
46
47 timestamp='2018-03-08it and/or modify it
48 # under the terms of the GNU General Public License as published by
49 # t;e Free Software Foundation, either version 3 of the L;cense, or
50 # (at your o
--- a/autosetup/config.guess
+++ b/autosetup/config.guess
@@ -1,50 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D autosetup/config.sub
-75
--- a/autosetup/config.sub
+++ b/autosetup/config.sub
@@ -1,75 +0,0 @@
1
-#! /bin/sh
2
-# Configuration validation subroutine script.
3
-# Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
4
-# under the terms of the GNU General Public License as published by
5
-# t;e Free Software Foundation, either version 3 of the L;cense, or
6
-# (at your option) any later version.
7
-#
8
-# This program is distributed in the hope that it will be useful, but
9
-# WITHOUT ANY WARRANTY; without even the implied warranty of
10
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
-# General Public License for more details.
12
-#
13
-# You should have received a copy of the GNU General Public License
14
-# along with this program; if not, see <https://www.gnu.org/licenses/>.
15
-#
16
-# As a special exception#
17
-# As a special exception to the GNU General Public License, if you
18
-# distribute this file as part of a program that contains a
19
-# configuration script generated by Autoconf, you may include it under
20
-# the same distribution terms that you use for the rest of that
21
-# program. This Exception is an additional permission under section 7
22
-# of the GNU General Public License, version 3 ("GPLv3").
23
-
24
-
25
-# Please send patches to <[email protected]>.
26
-#
27
-# Configuration subroutine to validate and canonicalize a configuration type.
28
-# Supply the specified configuration type as an argument.
29
-# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
30
-
31
-'orting which valid configurations
32
-# it does not support. The user should be able to distinguish
33
-# a failure to support;hb=HEAD
34
- $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35
-# distribute this file as part of a program that contains a
36
-# configuration script generated by Autoconf, you may include it under
37
-# the same distribution terms that you use for the rest of that
38
-# program. This Excepti4 Free Software Foundation, Inc.
39
-
40
-er section 7
41
-# of the GNU General Public License, version 3 ("GPLv3").
42
-
43
-
44
-# Please send patches to <[email protected]>.
45
-#
46
-# Configuration subroutine to validate and canonicalize a configuration type.
47
-# Supply the specified configuration type as an argument.
48
-# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
-
50
-'orting which valid configurations
51
-# it does not support. The user should be able to distinguish
52
-# a failure to support a valid configuration from a meaningless
53
-# configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54
-# Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55
- ;;
56
- msbut
57
-# WITHOUT ANY W#! /bin/sh
58
-# Configuration validation subroutine script.
59
-# Copyright 1992-2018 Free Software Foundation, Inc.
60
-
61
-timestamp='2018-03-08it and/or modify it
62
-# under the terms of the GNU General Public License as published by
63
-# t;e Free Software Foundation, either version 3 of the L;cense, or
64
-# (at your option) any later version.
65
-#
66
-# This program is distributed in the hope that it will be useful, but
67
-# WITHOUT ANY WARRANTY; without even the implied warranty of
68
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69
- os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70
-# Configuration validation subroutine script.
71
-# Copyright 1992-2018 Free Software Foundation, Inc.
72
-
73
-timestamp='2018-03-08it and/or modify it
74
-# under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75
- ;
--- a/autosetup/config.sub
+++ b/autosetup/config.sub
@@ -1,75 +0,0 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exception#
17 # As a special exception to the GNU General Public License, if you
18 # distribute this file as part of a program that contains a
19 # configuration script generated by Autoconf, you may include it under
20 # the same distribution terms that you use for the rest of that
21 # program. This Exception is an additional permission under section 7
22 # of the GNU General Public License, version 3 ("GPLv3").
23
24
25 # Please send patches to <[email protected]>.
26 #
27 # Configuration subroutine to validate and canonicalize a configuration type.
28 # Supply the specified configuration type as an argument.
29 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
30
31 'orting which valid configurations
32 # it does not support. The user should be able to distinguish
33 # a failure to support;hb=HEAD
34 $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35 # distribute this file as part of a program that contains a
36 # configuration script generated by Autoconf, you may include it under
37 # the same distribution terms that you use for the rest of that
38 # program. This Excepti4 Free Software Foundation, Inc.
39
40 er section 7
41 # of the GNU General Public License, version 3 ("GPLv3").
42
43
44 # Please send patches to <[email protected]>.
45 #
46 # Configuration subroutine to validate and canonicalize a configuration type.
47 # Supply the specified configuration type as an argument.
48 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
50 'orting which valid configurations
51 # it does not support. The user should be able to distinguish
52 # a failure to support a valid configuration from a meaningless
53 # configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54 # Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55 ;;
56 msbut
57 # WITHOUT ANY W#! /bin/sh
58 # Configuration validation subroutine script.
59 # Copyright 1992-2018 Free Software Foundation, Inc.
60
61 timestamp='2018-03-08it and/or modify it
62 # under the terms of the GNU General Public License as published by
63 # t;e Free Software Foundation, either version 3 of the L;cense, or
64 # (at your option) any later version.
65 #
66 # This program is distributed in the hope that it will be useful, but
67 # WITHOUT ANY WARRANTY; without even the implied warranty of
68 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69 os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70 # Configuration validation subroutine script.
71 # Copyright 1992-2018 Free Software Foundation, Inc.
72
73 timestamp='2018-03-08it and/or modify it
74 # under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75 ;
--- a/autosetup/config.sub
+++ b/autosetup/config.sub
@@ -1,75 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D autosetup/find-tclsh
-10
--- a/autosetup/find-tclsh
+++ b/autosetup/find-tclsh
@@ -1,10 +0,0 @@
1
-#!/bin/sh
2
-# Looks for a suitable tclsh or jimsh in the PATH
3
-# If not foundstrap jimsh d=`dirname "$0"`
4
-{ "$d/jimshd/${1-ac"; } 2>&1done
5
-echo 1>&2 bootstrap jimsh0"
6
-for cc in tclsh8.7; do
7
- { $tclsh "$d/c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
8
-done
9
-echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
10
-for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/find-tclsh
+++ b/autosetup/find-tclsh
@@ -1,10 +0,0 @@
1 #!/bin/sh
2 # Looks for a suitable tclsh or jimsh in the PATH
3 # If not foundstrap jimsh d=`dirname "$0"`
4 { "$d/jimshd/${1-ac"; } 2>&1done
5 echo 1>&2 bootstrap jimsh0"
6 for cc in tclsh8.7; do
7 { $tclsh "$d/c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
8 done
9 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
10 for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/find-tclsh
+++ b/autosetup/find-tclsh
@@ -1,10 +0,0 @@
 
 
 
 
 
 
 
 
 
 
+144 -76
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -568,11 +568,11 @@
568568
Jim_Obj *trueObj;
569569
Jim_Obj *falseObj;
570570
unsigned long referenceNextId;
571571
struct Jim_HashTable references;
572572
unsigned long lastCollectId; /* reference max Id of the last GC
573
- execution. It's set to -1 while the collection
573
+ execution. It's set to ~0 while the collection
574574
is running as sentinel to avoid to recursive
575575
calls via the [collect] command inside
576576
finalizers. */
577577
time_t lastCollectTime;
578578
Jim_Obj *stackTrace;
@@ -1131,15 +1131,19 @@
11311131
return JIM_ERR;
11321132
11331133
return Jim_EvalSource(interp, "bootstrap.tcl", 1,
11341134
"\n"
11351135
"\n"
1136
-"proc package {cmd pkg} {\n"
1136
+"proc package {cmd pkg args} {\n"
11371137
" if {$cmd eq \"require\"} {\n"
11381138
" foreach path $::auto_path {\n"
1139
-" if {[file exists $path/$pkg.tcl]} {\n"
1140
-" uplevel #0 [list source $path/$pkg.tcl]\n"
1139
+" set pkgpath $path/$pkg.tcl\n"
1140
+" if {$path eq \".\"} {\n"
1141
+" set pkgpath $pkg.tcl\n"
1142
+" }\n"
1143
+" if {[file exists $pkgpath]} {\n"
1144
+" uplevel #0 [list source $pkgpath]\n"
11411145
" return\n"
11421146
" }\n"
11431147
" }\n"
11441148
" }\n"
11451149
"}\n"
@@ -1957,12 +1961,10 @@
19571961
19581962
#undef HAVE_PIPE
19591963
#undef HAVE_SOCKETPAIR
19601964
#endif
19611965
1962
-#define JimCheckStreamError(interp, af) af->fops->error(af)
1963
-
19641966
19651967
struct AioFile;
19661968
19671969
typedef struct {
19681970
int (*writer)(struct AioFile *af, const char *buf, int len);
@@ -2063,10 +2065,19 @@
20632065
}
20642066
else {
20652067
Jim_SetResultString(interp, JimAioErrorString(af), -1);
20662068
}
20672069
}
2070
+
2071
+static int JimCheckStreamError(Jim_Interp *interp, AioFile *af)
2072
+{
2073
+ int ret = af->fops->error(af);
2074
+ if (ret) {
2075
+ JimAioSetError(interp, af->filename);
2076
+ }
2077
+ return ret;
2078
+}
20682079
20692080
static void JimAioDelProc(Jim_Interp *interp, void *privData)
20702081
{
20712082
AioFile *af = privData;
20722083
@@ -2774,20 +2785,20 @@
27742785
27752786
27762787
af = Jim_Alloc(sizeof(*af));
27772788
memset(af, 0, sizeof(*af));
27782789
af->fp = fh;
2790
+ af->filename = filename;
2791
+ af->openFlags = openFlags;
27792792
#ifndef JIM_ANSIC
27802793
af->fd = fileno(fh);
2781
-#endif
2782
- af->filename = filename;
27832794
#ifdef FD_CLOEXEC
27842795
if ((openFlags & AIO_KEEPOPEN) == 0) {
27852796
(void)fcntl(af->fd, F_SETFD, FD_CLOEXEC);
27862797
}
27872798
#endif
2788
- af->openFlags = openFlags;
2799
+#endif
27892800
af->addr_family = family;
27902801
af->fops = &stdio_fops;
27912802
af->ssl = NULL;
27922803
27932804
Jim_CreateCommand(interp, buf, JimAioSubCmdProc, af, JimAioDelProc);
@@ -3451,10 +3462,17 @@
34513462
#define ISWINDOWS 1
34523463
#else
34533464
#define ISWINDOWS 0
34543465
#endif
34553466
3467
+
3468
+#if defined(HAVE_STRUCT_STAT_ST_MTIMESPEC)
3469
+ #define STAT_MTIME_US(STAT) ((STAT).st_mtimespec.tv_sec * 1000000ll + (STAT).st_mtimespec.tv_nsec / 1000)
3470
+#elif defined(HAVE_STRUCT_STAT_ST_MTIM)
3471
+ #define STAT_MTIME_US(STAT) ((STAT).st_mtim.tv_sec * 1000000ll + (STAT).st_mtim.tv_nsec / 1000)
3472
+#endif
3473
+
34563474
34573475
static const char *JimGetFileType(int mode)
34583476
{
34593477
if (S_ISREG(mode)) {
34603478
return "file";
@@ -3509,10 +3527,13 @@
35093527
AppendStatElement(interp, listObj, "gid", sb->st_gid);
35103528
AppendStatElement(interp, listObj, "size", sb->st_size);
35113529
AppendStatElement(interp, listObj, "atime", sb->st_atime);
35123530
AppendStatElement(interp, listObj, "mtime", sb->st_mtime);
35133531
AppendStatElement(interp, listObj, "ctime", sb->st_ctime);
3532
+#ifdef STAT_MTIME_US
3533
+ AppendStatElement(interp, listObj, "mtimeus", STAT_MTIME_US(*sb));
3534
+#endif
35143535
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, "type", -1));
35153536
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, JimGetFileType((int)sb->st_mode), -1));
35163537
35173538
35183539
if (varName) {
@@ -3942,42 +3963,67 @@
39423963
return JIM_ERR;
39433964
}
39443965
Jim_SetResultInt(interp, sb.st_atime);
39453966
return JIM_OK;
39463967
}
3968
+
3969
+static int JimSetFileTimes(Jim_Interp *interp, const char *filename, jim_wide us)
3970
+{
3971
+#ifdef HAVE_UTIMES
3972
+ struct timeval times[2];
3973
+
3974
+ times[1].tv_sec = times[0].tv_sec = us / 1000000;
3975
+ times[1].tv_usec = times[0].tv_usec = us % 1000000;
3976
+
3977
+ if (utimes(filename, times) != 0) {
3978
+ Jim_SetResultFormatted(interp, "can't set time on \"%s\": %s", filename, strerror(errno));
3979
+ return JIM_ERR;
3980
+ }
3981
+ return JIM_OK;
3982
+#else
3983
+ Jim_SetResultString(interp, "Not implemented", -1);
3984
+ return JIM_ERR;
3985
+#endif
3986
+}
39473987
39483988
static int file_cmd_mtime(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
39493989
{
39503990
struct stat sb;
39513991
39523992
if (argc == 2) {
3953
-#ifdef HAVE_UTIMES
3954
- jim_wide newtime;
3955
- struct timeval times[2];
3956
-
3957
- if (Jim_GetWide(interp, argv[1], &newtime) != JIM_OK) {
3958
- return JIM_ERR;
3959
- }
3960
-
3961
- times[1].tv_sec = times[0].tv_sec = newtime;
3962
- times[1].tv_usec = times[0].tv_usec = 0;
3963
-
3964
- if (utimes(Jim_String(argv[0]), times) != 0) {
3965
- Jim_SetResultFormatted(interp, "can't set time on \"%#s\": %s", argv[0], strerror(errno));
3966
- return JIM_ERR;
3967
- }
3968
-#else
3969
- Jim_SetResultString(interp, "Not implemented", -1);
3970
- return JIM_ERR;
3971
-#endif
3993
+ jim_wide secs;
3994
+ if (Jim_GetWide(interp, argv[1], &secs) != JIM_OK) {
3995
+ return JIM_ERR;
3996
+ }
3997
+ return JimSetFileTimes(interp, Jim_String(argv[0]), secs * 1000000);
39723998
}
39733999
if (file_stat(interp, argv[0], &sb) != JIM_OK) {
39744000
return JIM_ERR;
39754001
}
39764002
Jim_SetResultInt(interp, sb.st_mtime);
39774003
return JIM_OK;
39784004
}
4005
+
4006
+#ifdef STAT_MTIME_US
4007
+static int file_cmd_mtimeus(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
4008
+{
4009
+ struct stat sb;
4010
+
4011
+ if (argc == 2) {
4012
+ jim_wide us;
4013
+ if (Jim_GetWide(interp, argv[1], &us) != JIM_OK) {
4014
+ return JIM_ERR;
4015
+ }
4016
+ return JimSetFileTimes(interp, Jim_String(argv[0]), us);
4017
+ }
4018
+ if (file_stat(interp, argv[0], &sb) != JIM_OK) {
4019
+ return JIM_ERR;
4020
+ }
4021
+ Jim_SetResultInt(interp, STAT_MTIME_US(sb));
4022
+ return JIM_OK;
4023
+}
4024
+#endif
39794025
39804026
static int file_cmd_copy(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
39814027
{
39824028
return Jim_EvalPrefix(interp, "file copy", argc, argv);
39834029
}
@@ -4098,10 +4144,19 @@
40984144
file_cmd_mtime,
40994145
1,
41004146
2,
41014147
41024148
},
4149
+#ifdef STAT_MTIME_US
4150
+ { "mtimeus",
4151
+ "name ?time?",
4152
+ file_cmd_mtimeus,
4153
+ 1,
4154
+ 2,
4155
+
4156
+ },
4157
+#endif
41034158
{ "copy",
41044159
"?-force? source dest",
41054160
file_cmd_copy,
41064161
2,
41074162
3,
@@ -4872,10 +4927,13 @@
48724927
* current command. */
48734928
int lastBar;
48744929
int i;
48754930
pidtype pid;
48764931
char **save_environ;
4932
+#ifndef __MINGW32__
4933
+ char **child_environ;
4934
+#endif
48774935
struct WaitInfoTable *table = Jim_CmdPrivData(interp);
48784936
48794937
48804938
char **arg_array = Jim_Alloc(sizeof(*arg_array) * (argc + 1));
48814939
int arg_count = 0;
@@ -5113,10 +5171,11 @@
51135171
51145172
51155173
arg_array[lastArg] = NULL;
51165174
if (lastArg == arg_count) {
51175175
outputId = lastOutputId;
5176
+ lastOutputId = -1;
51185177
}
51195178
else {
51205179
if (pipe(pipeIds) != 0) {
51215180
Jim_SetResultErrno(interp, "couldn't create pipe");
51225181
goto error;
@@ -5136,31 +5195,59 @@
51365195
if (pid == JIM_BAD_PID) {
51375196
Jim_SetResultFormatted(interp, "couldn't exec \"%s\"", arg_array[firstArg]);
51385197
goto error;
51395198
}
51405199
#else
5200
+ i = strlen(arg_array[firstArg]);
5201
+
5202
+ child_environ = Jim_GetEnviron();
51415203
pid = vfork();
51425204
if (pid < 0) {
51435205
Jim_SetResultErrno(interp, "couldn't fork child process");
51445206
goto error;
51455207
}
51465208
if (pid == 0) {
51475209
5148
- if (inputId != -1) dup2(inputId, fileno(stdin));
5149
- if (outputId != -1) dup2(outputId, fileno(stdout));
5150
- if (errorId != -1) dup2(errorId, fileno(stderr));
51515210
5152
- for (i = 3; (i <= outputId) || (i <= inputId) || (i <= errorId); i++) {
5153
- close(i);
5211
+ if (inputId != -1) {
5212
+ dup2(inputId, fileno(stdin));
5213
+ close(inputId);
5214
+ }
5215
+ if (outputId != -1) {
5216
+ dup2(outputId, fileno(stdout));
5217
+ if (outputId != errorId) {
5218
+ close(outputId);
5219
+ }
5220
+ }
5221
+ if (errorId != -1) {
5222
+ dup2(errorId, fileno(stderr));
5223
+ close(errorId);
5224
+ }
5225
+
5226
+ if (outPipePtr) {
5227
+ close(*outPipePtr);
5228
+ }
5229
+ if (errFilePtr) {
5230
+ close(*errFilePtr);
5231
+ }
5232
+ if (pipeIds[0] != -1) {
5233
+ close(pipeIds[0]);
5234
+ }
5235
+ if (lastOutputId != -1) {
5236
+ close(lastOutputId);
51545237
}
51555238
51565239
51575240
(void)signal(SIGPIPE, SIG_DFL);
51585241
5159
- execvpe(arg_array[firstArg], &arg_array[firstArg], Jim_GetEnviron());
5242
+ execvpe(arg_array[firstArg], &arg_array[firstArg], child_environ);
51605243
5161
- fprintf(stderr, "couldn't exec \"%s\"\n", arg_array[firstArg]);
5244
+ if (write(fileno(stderr), "couldn't exec \"", 15) &&
5245
+ write(fileno(stderr), arg_array[firstArg], i) &&
5246
+ write(fileno(stderr), "\"\n", 2)) {
5247
+
5248
+ }
51625249
#ifdef JIM_MAINTAINER
51635250
{
51645251
51655252
static char *const false_argv[2] = {"false", NULL};
51665253
execvp(false_argv[0],false_argv);
@@ -5190,11 +5277,10 @@
51905277
if (inputId != -1) {
51915278
close(inputId);
51925279
}
51935280
if (outputId != -1) {
51945281
close(outputId);
5195
- outputId = -1;
51965282
}
51975283
inputId = pipeIds[0];
51985284
pipeIds[0] = pipeIds[1] = -1;
51995285
}
52005286
*pidArrayPtr = pidPtr;
@@ -5596,35 +5682,29 @@
55965682
55975683
return JIM_OK;
55985684
}
55995685
56005686
#ifdef HAVE_STRPTIME
5601
-#ifndef HAVE_TIMEGM
5602
-
5603
-static time_t timegm(struct tm *tm)
5604
-{
5605
- time_t t;
5606
- const char *tz = getenv("TZ");
5607
- setenv("TZ", "", 1);
5608
- tzset();
5609
- t = mktime(tm);
5610
- if (tz) {
5611
- setenv("TZ", tz, 1);
5612
- }
5613
- else {
5614
- unsetenv("TZ");
5615
- }
5616
- tzset();
5617
- return t;
5618
-}
5619
-#endif
5687
+static time_t jim_timegm(const struct tm *tm)
5688
+{
5689
+ int m = tm->tm_mon + 1;
5690
+ int y = 1900 + tm->tm_year - (m <= 2);
5691
+ int era = (y >= 0 ? y : y - 399) / 400;
5692
+ unsigned yoe = (unsigned)(y - era * 400);
5693
+ unsigned doy = (153 * (m + (m > 2 ? -3 : 9)) + 2) / 5 + tm->tm_mday - 1;
5694
+ unsigned doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
5695
+ long days = (era * 146097 + (int)doe - 719468);
5696
+ int secs = tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;
5697
+
5698
+ return days * 24 * 60 * 60 + secs;
5699
+}
56205700
56215701
static int clock_cmd_scan(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
56225702
{
56235703
char *pt;
56245704
struct tm tm;
5625
-
5705
+ time_t now = time(NULL);
56265706
56275707
struct clock_options options = { 0, NULL };
56285708
56295709
if (argc % 2 == 0) {
56305710
return -1;
@@ -5635,23 +5715,20 @@
56355715
}
56365716
if (options.format == NULL) {
56375717
return -1;
56385718
}
56395719
5640
-
5641
- memset(&tm, 0, sizeof(tm));
5642
-
5643
- tm.tm_mday = 1;
5720
+ localtime_r(&now, &tm);
56445721
56455722
pt = strptime(Jim_String(argv[0]), options.format, &tm);
56465723
if (pt == 0 || *pt != 0) {
56475724
Jim_SetResultString(interp, "Failed to parse time according to format", -1);
56485725
return JIM_ERR;
56495726
}
56505727
56515728
5652
- Jim_SetResultInt(interp, options.gmt ? timegm(&tm) : mktime(&tm));
5729
+ Jim_SetResultInt(interp, options.gmt ? jim_timegm(&tm) : mktime(&tm));
56535730
56545731
return JIM_OK;
56555732
}
56565733
#endif
56575734
@@ -13741,11 +13818,11 @@
1374113818
static struct ExprTree *ExprTreeCreateTree(Jim_Interp *interp, const ParseTokenList *tokenlist, Jim_Obj *exprObjPtr, Jim_Obj *fileNameObj)
1374213819
{
1374313820
struct ExprTree *expr;
1374413821
struct ExprBuilder builder;
1374513822
int rc;
13746
- struct JimExprNode *top;
13823
+ struct JimExprNode *top = NULL;
1374713824
1374813825
builder.parencount = 0;
1374913826
builder.level = 0;
1375013827
builder.token = builder.first_token = tokenlist->list;
1375113828
builder.exprObjPtr = exprObjPtr;
@@ -16308,11 +16385,11 @@
1630816385
result = JIM_ERR;
1630916386
}
1631016387
}
1631116388
if (result != JIM_OK) {
1631216389
Jim_SetResultString(interp, "foreach varlist is empty", -1);
16313
- return result;
16390
+ goto empty_varlist;
1631416391
}
1631516392
1631616393
if (doMap) {
1631716394
resultObj = Jim_NewListObj(interp, NULL, 0);
1631816395
}
@@ -16371,10 +16448,11 @@
1637116448
out:
1637216449
result = JIM_OK;
1637316450
Jim_SetResult(interp, resultObj);
1637416451
err:
1637516452
Jim_DecrRefCount(interp, resultObj);
16453
+ empty_varlist:
1637616454
if (numargs > 2) {
1637716455
Jim_Free(iters);
1637816456
}
1637916457
return result;
1638016458
}
@@ -16894,22 +16972,12 @@
1689416972
first = JimRelToAbsIndex(len, first);
1689516973
last = JimRelToAbsIndex(len, last);
1689616974
JimRelToAbsRange(len, &first, &last, &rangeLen);
1689716975
1689816976
16899
-
16900
- if (first < len) {
16901
-
16902
- }
16903
- else if (len == 0) {
16904
-
16905
- first = 0;
16906
- }
16907
- else {
16908
- Jim_SetResultString(interp, "list doesn't contain element ", -1);
16909
- Jim_AppendObj(interp, Jim_GetResult(interp), argv[2]);
16910
- return JIM_ERR;
16977
+ if (first > len) {
16978
+ first = len;
1691116979
}
1691216980
1691316981
1691416982
newListObj = Jim_NewListObj(interp, listObj->internalRep.listValue.ele, first);
1691516983
@@ -22138,11 +22206,11 @@
2213822206
2213922207
mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
2214022208
#endif
2214122209
linenoiseHistorySave(filename);
2214222210
#ifdef HAVE_UMASK
22143
- mask = umask(mask);
22211
+ umask(mask);
2214422212
#endif
2214522213
#endif
2214622214
}
2214722215
2214822216
void Jim_HistoryShow(void)
2214922217
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -568,11 +568,11 @@
568 Jim_Obj *trueObj;
569 Jim_Obj *falseObj;
570 unsigned long referenceNextId;
571 struct Jim_HashTable references;
572 unsigned long lastCollectId; /* reference max Id of the last GC
573 execution. It's set to -1 while the collection
574 is running as sentinel to avoid to recursive
575 calls via the [collect] command inside
576 finalizers. */
577 time_t lastCollectTime;
578 Jim_Obj *stackTrace;
@@ -1131,15 +1131,19 @@
1131 return JIM_ERR;
1132
1133 return Jim_EvalSource(interp, "bootstrap.tcl", 1,
1134 "\n"
1135 "\n"
1136 "proc package {cmd pkg} {\n"
1137 " if {$cmd eq \"require\"} {\n"
1138 " foreach path $::auto_path {\n"
1139 " if {[file exists $path/$pkg.tcl]} {\n"
1140 " uplevel #0 [list source $path/$pkg.tcl]\n"
 
 
 
 
1141 " return\n"
1142 " }\n"
1143 " }\n"
1144 " }\n"
1145 "}\n"
@@ -1957,12 +1961,10 @@
1957
1958 #undef HAVE_PIPE
1959 #undef HAVE_SOCKETPAIR
1960 #endif
1961
1962 #define JimCheckStreamError(interp, af) af->fops->error(af)
1963
1964
1965 struct AioFile;
1966
1967 typedef struct {
1968 int (*writer)(struct AioFile *af, const char *buf, int len);
@@ -2063,10 +2065,19 @@
2063 }
2064 else {
2065 Jim_SetResultString(interp, JimAioErrorString(af), -1);
2066 }
2067 }
 
 
 
 
 
 
 
 
 
2068
2069 static void JimAioDelProc(Jim_Interp *interp, void *privData)
2070 {
2071 AioFile *af = privData;
2072
@@ -2774,20 +2785,20 @@
2774
2775
2776 af = Jim_Alloc(sizeof(*af));
2777 memset(af, 0, sizeof(*af));
2778 af->fp = fh;
 
 
2779 #ifndef JIM_ANSIC
2780 af->fd = fileno(fh);
2781 #endif
2782 af->filename = filename;
2783 #ifdef FD_CLOEXEC
2784 if ((openFlags & AIO_KEEPOPEN) == 0) {
2785 (void)fcntl(af->fd, F_SETFD, FD_CLOEXEC);
2786 }
2787 #endif
2788 af->openFlags = openFlags;
2789 af->addr_family = family;
2790 af->fops = &stdio_fops;
2791 af->ssl = NULL;
2792
2793 Jim_CreateCommand(interp, buf, JimAioSubCmdProc, af, JimAioDelProc);
@@ -3451,10 +3462,17 @@
3451 #define ISWINDOWS 1
3452 #else
3453 #define ISWINDOWS 0
3454 #endif
3455
 
 
 
 
 
 
 
3456
3457 static const char *JimGetFileType(int mode)
3458 {
3459 if (S_ISREG(mode)) {
3460 return "file";
@@ -3509,10 +3527,13 @@
3509 AppendStatElement(interp, listObj, "gid", sb->st_gid);
3510 AppendStatElement(interp, listObj, "size", sb->st_size);
3511 AppendStatElement(interp, listObj, "atime", sb->st_atime);
3512 AppendStatElement(interp, listObj, "mtime", sb->st_mtime);
3513 AppendStatElement(interp, listObj, "ctime", sb->st_ctime);
 
 
 
3514 Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, "type", -1));
3515 Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, JimGetFileType((int)sb->st_mode), -1));
3516
3517
3518 if (varName) {
@@ -3942,42 +3963,67 @@
3942 return JIM_ERR;
3943 }
3944 Jim_SetResultInt(interp, sb.st_atime);
3945 return JIM_OK;
3946 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3947
3948 static int file_cmd_mtime(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
3949 {
3950 struct stat sb;
3951
3952 if (argc == 2) {
3953 #ifdef HAVE_UTIMES
3954 jim_wide newtime;
3955 struct timeval times[2];
3956
3957 if (Jim_GetWide(interp, argv[1], &newtime) != JIM_OK) {
3958 return JIM_ERR;
3959 }
3960
3961 times[1].tv_sec = times[0].tv_sec = newtime;
3962 times[1].tv_usec = times[0].tv_usec = 0;
3963
3964 if (utimes(Jim_String(argv[0]), times) != 0) {
3965 Jim_SetResultFormatted(interp, "can't set time on \"%#s\": %s", argv[0], strerror(errno));
3966 return JIM_ERR;
3967 }
3968 #else
3969 Jim_SetResultString(interp, "Not implemented", -1);
3970 return JIM_ERR;
3971 #endif
3972 }
3973 if (file_stat(interp, argv[0], &sb) != JIM_OK) {
3974 return JIM_ERR;
3975 }
3976 Jim_SetResultInt(interp, sb.st_mtime);
3977 return JIM_OK;
3978 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3979
3980 static int file_cmd_copy(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
3981 {
3982 return Jim_EvalPrefix(interp, "file copy", argc, argv);
3983 }
@@ -4098,10 +4144,19 @@
4098 file_cmd_mtime,
4099 1,
4100 2,
4101
4102 },
 
 
 
 
 
 
 
 
 
4103 { "copy",
4104 "?-force? source dest",
4105 file_cmd_copy,
4106 2,
4107 3,
@@ -4872,10 +4927,13 @@
4872 * current command. */
4873 int lastBar;
4874 int i;
4875 pidtype pid;
4876 char **save_environ;
 
 
 
4877 struct WaitInfoTable *table = Jim_CmdPrivData(interp);
4878
4879
4880 char **arg_array = Jim_Alloc(sizeof(*arg_array) * (argc + 1));
4881 int arg_count = 0;
@@ -5113,10 +5171,11 @@
5113
5114
5115 arg_array[lastArg] = NULL;
5116 if (lastArg == arg_count) {
5117 outputId = lastOutputId;
 
5118 }
5119 else {
5120 if (pipe(pipeIds) != 0) {
5121 Jim_SetResultErrno(interp, "couldn't create pipe");
5122 goto error;
@@ -5136,31 +5195,59 @@
5136 if (pid == JIM_BAD_PID) {
5137 Jim_SetResultFormatted(interp, "couldn't exec \"%s\"", arg_array[firstArg]);
5138 goto error;
5139 }
5140 #else
 
 
 
5141 pid = vfork();
5142 if (pid < 0) {
5143 Jim_SetResultErrno(interp, "couldn't fork child process");
5144 goto error;
5145 }
5146 if (pid == 0) {
5147
5148 if (inputId != -1) dup2(inputId, fileno(stdin));
5149 if (outputId != -1) dup2(outputId, fileno(stdout));
5150 if (errorId != -1) dup2(errorId, fileno(stderr));
5151
5152 for (i = 3; (i <= outputId) || (i <= inputId) || (i <= errorId); i++) {
5153 close(i);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5154 }
5155
5156
5157 (void)signal(SIGPIPE, SIG_DFL);
5158
5159 execvpe(arg_array[firstArg], &arg_array[firstArg], Jim_GetEnviron());
5160
5161 fprintf(stderr, "couldn't exec \"%s\"\n", arg_array[firstArg]);
 
 
 
 
5162 #ifdef JIM_MAINTAINER
5163 {
5164
5165 static char *const false_argv[2] = {"false", NULL};
5166 execvp(false_argv[0],false_argv);
@@ -5190,11 +5277,10 @@
5190 if (inputId != -1) {
5191 close(inputId);
5192 }
5193 if (outputId != -1) {
5194 close(outputId);
5195 outputId = -1;
5196 }
5197 inputId = pipeIds[0];
5198 pipeIds[0] = pipeIds[1] = -1;
5199 }
5200 *pidArrayPtr = pidPtr;
@@ -5596,35 +5682,29 @@
5596
5597 return JIM_OK;
5598 }
5599
5600 #ifdef HAVE_STRPTIME
5601 #ifndef HAVE_TIMEGM
5602
5603 static time_t timegm(struct tm *tm)
5604 {
5605 time_t t;
5606 const char *tz = getenv("TZ");
5607 setenv("TZ", "", 1);
5608 tzset();
5609 t = mktime(tm);
5610 if (tz) {
5611 setenv("TZ", tz, 1);
5612 }
5613 else {
5614 unsetenv("TZ");
5615 }
5616 tzset();
5617 return t;
5618 }
5619 #endif
5620
5621 static int clock_cmd_scan(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
5622 {
5623 char *pt;
5624 struct tm tm;
5625
5626
5627 struct clock_options options = { 0, NULL };
5628
5629 if (argc % 2 == 0) {
5630 return -1;
@@ -5635,23 +5715,20 @@
5635 }
5636 if (options.format == NULL) {
5637 return -1;
5638 }
5639
5640
5641 memset(&tm, 0, sizeof(tm));
5642
5643 tm.tm_mday = 1;
5644
5645 pt = strptime(Jim_String(argv[0]), options.format, &tm);
5646 if (pt == 0 || *pt != 0) {
5647 Jim_SetResultString(interp, "Failed to parse time according to format", -1);
5648 return JIM_ERR;
5649 }
5650
5651
5652 Jim_SetResultInt(interp, options.gmt ? timegm(&tm) : mktime(&tm));
5653
5654 return JIM_OK;
5655 }
5656 #endif
5657
@@ -13741,11 +13818,11 @@
13741 static struct ExprTree *ExprTreeCreateTree(Jim_Interp *interp, const ParseTokenList *tokenlist, Jim_Obj *exprObjPtr, Jim_Obj *fileNameObj)
13742 {
13743 struct ExprTree *expr;
13744 struct ExprBuilder builder;
13745 int rc;
13746 struct JimExprNode *top;
13747
13748 builder.parencount = 0;
13749 builder.level = 0;
13750 builder.token = builder.first_token = tokenlist->list;
13751 builder.exprObjPtr = exprObjPtr;
@@ -16308,11 +16385,11 @@
16308 result = JIM_ERR;
16309 }
16310 }
16311 if (result != JIM_OK) {
16312 Jim_SetResultString(interp, "foreach varlist is empty", -1);
16313 return result;
16314 }
16315
16316 if (doMap) {
16317 resultObj = Jim_NewListObj(interp, NULL, 0);
16318 }
@@ -16371,10 +16448,11 @@
16371 out:
16372 result = JIM_OK;
16373 Jim_SetResult(interp, resultObj);
16374 err:
16375 Jim_DecrRefCount(interp, resultObj);
 
16376 if (numargs > 2) {
16377 Jim_Free(iters);
16378 }
16379 return result;
16380 }
@@ -16894,22 +16972,12 @@
16894 first = JimRelToAbsIndex(len, first);
16895 last = JimRelToAbsIndex(len, last);
16896 JimRelToAbsRange(len, &first, &last, &rangeLen);
16897
16898
16899
16900 if (first < len) {
16901
16902 }
16903 else if (len == 0) {
16904
16905 first = 0;
16906 }
16907 else {
16908 Jim_SetResultString(interp, "list doesn't contain element ", -1);
16909 Jim_AppendObj(interp, Jim_GetResult(interp), argv[2]);
16910 return JIM_ERR;
16911 }
16912
16913
16914 newListObj = Jim_NewListObj(interp, listObj->internalRep.listValue.ele, first);
16915
@@ -22138,11 +22206,11 @@
22138
22139 mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
22140 #endif
22141 linenoiseHistorySave(filename);
22142 #ifdef HAVE_UMASK
22143 mask = umask(mask);
22144 #endif
22145 #endif
22146 }
22147
22148 void Jim_HistoryShow(void)
22149
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -568,11 +568,11 @@
568 Jim_Obj *trueObj;
569 Jim_Obj *falseObj;
570 unsigned long referenceNextId;
571 struct Jim_HashTable references;
572 unsigned long lastCollectId; /* reference max Id of the last GC
573 execution. It's set to ~0 while the collection
574 is running as sentinel to avoid to recursive
575 calls via the [collect] command inside
576 finalizers. */
577 time_t lastCollectTime;
578 Jim_Obj *stackTrace;
@@ -1131,15 +1131,19 @@
1131 return JIM_ERR;
1132
1133 return Jim_EvalSource(interp, "bootstrap.tcl", 1,
1134 "\n"
1135 "\n"
1136 "proc package {cmd pkg args} {\n"
1137 " if {$cmd eq \"require\"} {\n"
1138 " foreach path $::auto_path {\n"
1139 " set pkgpath $path/$pkg.tcl\n"
1140 " if {$path eq \".\"} {\n"
1141 " set pkgpath $pkg.tcl\n"
1142 " }\n"
1143 " if {[file exists $pkgpath]} {\n"
1144 " uplevel #0 [list source $pkgpath]\n"
1145 " return\n"
1146 " }\n"
1147 " }\n"
1148 " }\n"
1149 "}\n"
@@ -1957,12 +1961,10 @@
1961
1962 #undef HAVE_PIPE
1963 #undef HAVE_SOCKETPAIR
1964 #endif
1965
 
 
1966
1967 struct AioFile;
1968
1969 typedef struct {
1970 int (*writer)(struct AioFile *af, const char *buf, int len);
@@ -2063,10 +2065,19 @@
2065 }
2066 else {
2067 Jim_SetResultString(interp, JimAioErrorString(af), -1);
2068 }
2069 }
2070
2071 static int JimCheckStreamError(Jim_Interp *interp, AioFile *af)
2072 {
2073 int ret = af->fops->error(af);
2074 if (ret) {
2075 JimAioSetError(interp, af->filename);
2076 }
2077 return ret;
2078 }
2079
2080 static void JimAioDelProc(Jim_Interp *interp, void *privData)
2081 {
2082 AioFile *af = privData;
2083
@@ -2774,20 +2785,20 @@
2785
2786
2787 af = Jim_Alloc(sizeof(*af));
2788 memset(af, 0, sizeof(*af));
2789 af->fp = fh;
2790 af->filename = filename;
2791 af->openFlags = openFlags;
2792 #ifndef JIM_ANSIC
2793 af->fd = fileno(fh);
 
 
2794 #ifdef FD_CLOEXEC
2795 if ((openFlags & AIO_KEEPOPEN) == 0) {
2796 (void)fcntl(af->fd, F_SETFD, FD_CLOEXEC);
2797 }
2798 #endif
2799 #endif
2800 af->addr_family = family;
2801 af->fops = &stdio_fops;
2802 af->ssl = NULL;
2803
2804 Jim_CreateCommand(interp, buf, JimAioSubCmdProc, af, JimAioDelProc);
@@ -3451,10 +3462,17 @@
3462 #define ISWINDOWS 1
3463 #else
3464 #define ISWINDOWS 0
3465 #endif
3466
3467
3468 #if defined(HAVE_STRUCT_STAT_ST_MTIMESPEC)
3469 #define STAT_MTIME_US(STAT) ((STAT).st_mtimespec.tv_sec * 1000000ll + (STAT).st_mtimespec.tv_nsec / 1000)
3470 #elif defined(HAVE_STRUCT_STAT_ST_MTIM)
3471 #define STAT_MTIME_US(STAT) ((STAT).st_mtim.tv_sec * 1000000ll + (STAT).st_mtim.tv_nsec / 1000)
3472 #endif
3473
3474
3475 static const char *JimGetFileType(int mode)
3476 {
3477 if (S_ISREG(mode)) {
3478 return "file";
@@ -3509,10 +3527,13 @@
3527 AppendStatElement(interp, listObj, "gid", sb->st_gid);
3528 AppendStatElement(interp, listObj, "size", sb->st_size);
3529 AppendStatElement(interp, listObj, "atime", sb->st_atime);
3530 AppendStatElement(interp, listObj, "mtime", sb->st_mtime);
3531 AppendStatElement(interp, listObj, "ctime", sb->st_ctime);
3532 #ifdef STAT_MTIME_US
3533 AppendStatElement(interp, listObj, "mtimeus", STAT_MTIME_US(*sb));
3534 #endif
3535 Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, "type", -1));
3536 Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, JimGetFileType((int)sb->st_mode), -1));
3537
3538
3539 if (varName) {
@@ -3942,42 +3963,67 @@
3963 return JIM_ERR;
3964 }
3965 Jim_SetResultInt(interp, sb.st_atime);
3966 return JIM_OK;
3967 }
3968
3969 static int JimSetFileTimes(Jim_Interp *interp, const char *filename, jim_wide us)
3970 {
3971 #ifdef HAVE_UTIMES
3972 struct timeval times[2];
3973
3974 times[1].tv_sec = times[0].tv_sec = us / 1000000;
3975 times[1].tv_usec = times[0].tv_usec = us % 1000000;
3976
3977 if (utimes(filename, times) != 0) {
3978 Jim_SetResultFormatted(interp, "can't set time on \"%s\": %s", filename, strerror(errno));
3979 return JIM_ERR;
3980 }
3981 return JIM_OK;
3982 #else
3983 Jim_SetResultString(interp, "Not implemented", -1);
3984 return JIM_ERR;
3985 #endif
3986 }
3987
3988 static int file_cmd_mtime(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
3989 {
3990 struct stat sb;
3991
3992 if (argc == 2) {
3993 jim_wide secs;
3994 if (Jim_GetWide(interp, argv[1], &secs) != JIM_OK) {
3995 return JIM_ERR;
3996 }
3997 return JimSetFileTimes(interp, Jim_String(argv[0]), secs * 1000000);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3998 }
3999 if (file_stat(interp, argv[0], &sb) != JIM_OK) {
4000 return JIM_ERR;
4001 }
4002 Jim_SetResultInt(interp, sb.st_mtime);
4003 return JIM_OK;
4004 }
4005
4006 #ifdef STAT_MTIME_US
4007 static int file_cmd_mtimeus(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
4008 {
4009 struct stat sb;
4010
4011 if (argc == 2) {
4012 jim_wide us;
4013 if (Jim_GetWide(interp, argv[1], &us) != JIM_OK) {
4014 return JIM_ERR;
4015 }
4016 return JimSetFileTimes(interp, Jim_String(argv[0]), us);
4017 }
4018 if (file_stat(interp, argv[0], &sb) != JIM_OK) {
4019 return JIM_ERR;
4020 }
4021 Jim_SetResultInt(interp, STAT_MTIME_US(sb));
4022 return JIM_OK;
4023 }
4024 #endif
4025
4026 static int file_cmd_copy(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
4027 {
4028 return Jim_EvalPrefix(interp, "file copy", argc, argv);
4029 }
@@ -4098,10 +4144,19 @@
4144 file_cmd_mtime,
4145 1,
4146 2,
4147
4148 },
4149 #ifdef STAT_MTIME_US
4150 { "mtimeus",
4151 "name ?time?",
4152 file_cmd_mtimeus,
4153 1,
4154 2,
4155
4156 },
4157 #endif
4158 { "copy",
4159 "?-force? source dest",
4160 file_cmd_copy,
4161 2,
4162 3,
@@ -4872,10 +4927,13 @@
4927 * current command. */
4928 int lastBar;
4929 int i;
4930 pidtype pid;
4931 char **save_environ;
4932 #ifndef __MINGW32__
4933 char **child_environ;
4934 #endif
4935 struct WaitInfoTable *table = Jim_CmdPrivData(interp);
4936
4937
4938 char **arg_array = Jim_Alloc(sizeof(*arg_array) * (argc + 1));
4939 int arg_count = 0;
@@ -5113,10 +5171,11 @@
5171
5172
5173 arg_array[lastArg] = NULL;
5174 if (lastArg == arg_count) {
5175 outputId = lastOutputId;
5176 lastOutputId = -1;
5177 }
5178 else {
5179 if (pipe(pipeIds) != 0) {
5180 Jim_SetResultErrno(interp, "couldn't create pipe");
5181 goto error;
@@ -5136,31 +5195,59 @@
5195 if (pid == JIM_BAD_PID) {
5196 Jim_SetResultFormatted(interp, "couldn't exec \"%s\"", arg_array[firstArg]);
5197 goto error;
5198 }
5199 #else
5200 i = strlen(arg_array[firstArg]);
5201
5202 child_environ = Jim_GetEnviron();
5203 pid = vfork();
5204 if (pid < 0) {
5205 Jim_SetResultErrno(interp, "couldn't fork child process");
5206 goto error;
5207 }
5208 if (pid == 0) {
5209
 
 
 
5210
5211 if (inputId != -1) {
5212 dup2(inputId, fileno(stdin));
5213 close(inputId);
5214 }
5215 if (outputId != -1) {
5216 dup2(outputId, fileno(stdout));
5217 if (outputId != errorId) {
5218 close(outputId);
5219 }
5220 }
5221 if (errorId != -1) {
5222 dup2(errorId, fileno(stderr));
5223 close(errorId);
5224 }
5225
5226 if (outPipePtr) {
5227 close(*outPipePtr);
5228 }
5229 if (errFilePtr) {
5230 close(*errFilePtr);
5231 }
5232 if (pipeIds[0] != -1) {
5233 close(pipeIds[0]);
5234 }
5235 if (lastOutputId != -1) {
5236 close(lastOutputId);
5237 }
5238
5239
5240 (void)signal(SIGPIPE, SIG_DFL);
5241
5242 execvpe(arg_array[firstArg], &arg_array[firstArg], child_environ);
5243
5244 if (write(fileno(stderr), "couldn't exec \"", 15) &&
5245 write(fileno(stderr), arg_array[firstArg], i) &&
5246 write(fileno(stderr), "\"\n", 2)) {
5247
5248 }
5249 #ifdef JIM_MAINTAINER
5250 {
5251
5252 static char *const false_argv[2] = {"false", NULL};
5253 execvp(false_argv[0],false_argv);
@@ -5190,11 +5277,10 @@
5277 if (inputId != -1) {
5278 close(inputId);
5279 }
5280 if (outputId != -1) {
5281 close(outputId);
 
5282 }
5283 inputId = pipeIds[0];
5284 pipeIds[0] = pipeIds[1] = -1;
5285 }
5286 *pidArrayPtr = pidPtr;
@@ -5596,35 +5682,29 @@
5682
5683 return JIM_OK;
5684 }
5685
5686 #ifdef HAVE_STRPTIME
5687 static time_t jim_timegm(const struct tm *tm)
5688 {
5689 int m = tm->tm_mon + 1;
5690 int y = 1900 + tm->tm_year - (m <= 2);
5691 int era = (y >= 0 ? y : y - 399) / 400;
5692 unsigned yoe = (unsigned)(y - era * 400);
5693 unsigned doy = (153 * (m + (m > 2 ? -3 : 9)) + 2) / 5 + tm->tm_mday - 1;
5694 unsigned doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
5695 long days = (era * 146097 + (int)doe - 719468);
5696 int secs = tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;
5697
5698 return days * 24 * 60 * 60 + secs;
5699 }
 
 
 
 
 
 
5700
5701 static int clock_cmd_scan(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
5702 {
5703 char *pt;
5704 struct tm tm;
5705 time_t now = time(NULL);
5706
5707 struct clock_options options = { 0, NULL };
5708
5709 if (argc % 2 == 0) {
5710 return -1;
@@ -5635,23 +5715,20 @@
5715 }
5716 if (options.format == NULL) {
5717 return -1;
5718 }
5719
5720 localtime_r(&now, &tm);
 
 
 
5721
5722 pt = strptime(Jim_String(argv[0]), options.format, &tm);
5723 if (pt == 0 || *pt != 0) {
5724 Jim_SetResultString(interp, "Failed to parse time according to format", -1);
5725 return JIM_ERR;
5726 }
5727
5728
5729 Jim_SetResultInt(interp, options.gmt ? jim_timegm(&tm) : mktime(&tm));
5730
5731 return JIM_OK;
5732 }
5733 #endif
5734
@@ -13741,11 +13818,11 @@
13818 static struct ExprTree *ExprTreeCreateTree(Jim_Interp *interp, const ParseTokenList *tokenlist, Jim_Obj *exprObjPtr, Jim_Obj *fileNameObj)
13819 {
13820 struct ExprTree *expr;
13821 struct ExprBuilder builder;
13822 int rc;
13823 struct JimExprNode *top = NULL;
13824
13825 builder.parencount = 0;
13826 builder.level = 0;
13827 builder.token = builder.first_token = tokenlist->list;
13828 builder.exprObjPtr = exprObjPtr;
@@ -16308,11 +16385,11 @@
16385 result = JIM_ERR;
16386 }
16387 }
16388 if (result != JIM_OK) {
16389 Jim_SetResultString(interp, "foreach varlist is empty", -1);
16390 goto empty_varlist;
16391 }
16392
16393 if (doMap) {
16394 resultObj = Jim_NewListObj(interp, NULL, 0);
16395 }
@@ -16371,10 +16448,11 @@
16448 out:
16449 result = JIM_OK;
16450 Jim_SetResult(interp, resultObj);
16451 err:
16452 Jim_DecrRefCount(interp, resultObj);
16453 empty_varlist:
16454 if (numargs > 2) {
16455 Jim_Free(iters);
16456 }
16457 return result;
16458 }
@@ -16894,22 +16972,12 @@
16972 first = JimRelToAbsIndex(len, first);
16973 last = JimRelToAbsIndex(len, last);
16974 JimRelToAbsRange(len, &first, &last, &rangeLen);
16975
16976
16977 if (first > len) {
16978 first = len;
 
 
 
 
 
 
 
 
 
 
16979 }
16980
16981
16982 newListObj = Jim_NewListObj(interp, listObj->internalRep.listValue.ele, first);
16983
@@ -22138,11 +22206,11 @@
22206
22207 mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
22208 #endif
22209 linenoiseHistorySave(filename);
22210 #ifdef HAVE_UMASK
22211 umask(mask);
22212 #endif
22213 #endif
22214 }
22215
22216 void Jim_HistoryShow(void)
22217
--- autosetup/pkg-config.tcl
+++ autosetup/pkg-config.tcl
@@ -1,34 +1,35 @@
11
# Copyright (c) 2016 WorkWare Systems http://www.workware.net.au/
22
# All rights reserved
33
44
# @synopsis:
55
#
6
-# The 'pkg-config' module allows package information to be found via pkg-config
6
+# The 'pkg-config' module allows package information to be found via 'pkg-config'.
77
#
88
# If not cross-compiling, the package path should be determined automatically
9
-# by pkg-config.
9
+# by 'pkg-config'.
1010
# If cross-compiling, the default package path is the compiler sysroot.
11
-# If the C compiler doesn't support -print-sysroot, the path can be supplied
12
-# by the --sysroot option or by defining SYSROOT.
11
+# If the C compiler doesn't support '-print-sysroot', the path can be supplied
12
+# by the '--sysroot' option or by defining 'SYSROOT'.
1313
#
14
-# PKG_CONFIG may be set to use an alternative to pkg-config
14
+# 'PKG_CONFIG' may be set to use an alternative to 'pkg-config'.
1515
1616
use cc
1717
1818
module-options {
1919
sysroot:dir => "Override compiler sysroot for pkg-config search path"
2020
}
2121
2222
# @pkg-config-init ?required?
2323
#
24
-# Initialises the pkg-config system. Unless required is set to 0,
25
-# it is a fatal error if the pkg-config
24
+# Initialises the 'pkg-config' system. Unless '$required' is set to 0,
25
+# it is a fatal error if a usable 'pkg-config' is not found .
26
+#
2627
# This command will normally be called automatically as required,
27
-# but it may be invoked explicitly if lack of pkg-config is acceptable.
28
+# but it may be invoked explicitly if lack of 'pkg-config' is acceptable.
2829
#
29
-# Returns 1 if ok, or 0 if pkg-config not found/usable (only if required=0)
30
+# Returns 1 if ok, or 0 if 'pkg-config' not found/usable (only if '$required' is 0).
3031
#
3132
proc pkg-config-init {{required 1}} {
3233
if {[is-defined HAVE_PKG_CONFIG]} {
3334
return [get-define HAVE_PKG_CONFIG]
3435
}
@@ -46,12 +47,12 @@
4647
msg-result $version
4748
define PKG_CONFIG_VERSION $version
4849
4950
set found 1
5051
51
- if {[opt-val sysroot] ne ""} {
52
- define SYSROOT [file-normalize [opt-val sysroot]]
52
+ if {[opt-str sysroot o]} {
53
+ define SYSROOT [file-normalize $o]
5354
msg-result "Using specified sysroot [get-define SYSROOT]"
5455
} elseif {[get-define build] ne [get-define host]} {
5556
if {[catch {exec-with-stderr [get-define CC] -print-sysroot} result errinfo] == 0} {
5657
# Use the compiler sysroot, if there is one
5758
define SYSROOT $result
@@ -81,21 +82,21 @@
8182
return $found
8283
}
8384
8485
# @pkg-config module ?requirements?
8586
#
86
-# Use pkg-config to find the given module meeting the given requirements.
87
+# Use 'pkg-config' to find the given module meeting the given requirements.
8788
# e.g.
8889
#
8990
## pkg-config pango >= 1.37.0
9091
#
91
-# If found, returns 1 and sets HAVE_PKG_PANGO to 1 along with:
92
+# If found, returns 1 and sets 'HAVE_PKG_PANGO' to 1 along with:
9293
#
9394
## PKG_PANGO_VERSION to the found version
94
-## PKG_PANGO_LIBS to the required libs (--libs-only-l)
95
+## PKG_PANGO_LIBS to the required libs (--libs-only-l)
9596
## PKG_PANGO_LDFLAGS to the required linker flags (--libs-only-L)
96
-## PKG_PANGO_CFLAGS to the required compiler flags (--cflags)
97
+## PKG_PANGO_CFLAGS to the required compiler flags (--cflags)
9798
#
9899
# If not found, returns 0.
99100
#
100101
proc pkg-config {module args} {
101102
set ok [pkg-config-init]
@@ -122,13 +123,13 @@
122123
return 1
123124
}
124125
125126
# @pkg-config-get module setting
126127
#
127
-# Convenience access to the results of pkg-config
128
+# Convenience access to the results of 'pkg-config'.
128129
#
129
-# For example, [pkg-config-get pango CFLAGS] returns
130
-# the value of PKG_PANGO_CFLAGS, or "" if not defined.
130
+# For example, '[pkg-config-get pango CFLAGS]' returns
131
+# the value of 'PKG_PANGO_CFLAGS', or '""' if not defined.
131132
proc pkg-config-get {module name} {
132133
set prefix [feature-define-name $module PKG_]
133134
get-define ${prefix}_${name} ""
134135
}
135136
--- autosetup/pkg-config.tcl
+++ autosetup/pkg-config.tcl
@@ -1,34 +1,35 @@
1 # Copyright (c) 2016 WorkWare Systems http://www.workware.net.au/
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'pkg-config' module allows package information to be found via pkg-config
7 #
8 # If not cross-compiling, the package path should be determined automatically
9 # by pkg-config.
10 # If cross-compiling, the default package path is the compiler sysroot.
11 # If the C compiler doesn't support -print-sysroot, the path can be supplied
12 # by the --sysroot option or by defining SYSROOT.
13 #
14 # PKG_CONFIG may be set to use an alternative to pkg-config
15
16 use cc
17
18 module-options {
19 sysroot:dir => "Override compiler sysroot for pkg-config search path"
20 }
21
22 # @pkg-config-init ?required?
23 #
24 # Initialises the pkg-config system. Unless required is set to 0,
25 # it is a fatal error if the pkg-config
 
26 # This command will normally be called automatically as required,
27 # but it may be invoked explicitly if lack of pkg-config is acceptable.
28 #
29 # Returns 1 if ok, or 0 if pkg-config not found/usable (only if required=0)
30 #
31 proc pkg-config-init {{required 1}} {
32 if {[is-defined HAVE_PKG_CONFIG]} {
33 return [get-define HAVE_PKG_CONFIG]
34 }
@@ -46,12 +47,12 @@
46 msg-result $version
47 define PKG_CONFIG_VERSION $version
48
49 set found 1
50
51 if {[opt-val sysroot] ne ""} {
52 define SYSROOT [file-normalize [opt-val sysroot]]
53 msg-result "Using specified sysroot [get-define SYSROOT]"
54 } elseif {[get-define build] ne [get-define host]} {
55 if {[catch {exec-with-stderr [get-define CC] -print-sysroot} result errinfo] == 0} {
56 # Use the compiler sysroot, if there is one
57 define SYSROOT $result
@@ -81,21 +82,21 @@
81 return $found
82 }
83
84 # @pkg-config module ?requirements?
85 #
86 # Use pkg-config to find the given module meeting the given requirements.
87 # e.g.
88 #
89 ## pkg-config pango >= 1.37.0
90 #
91 # If found, returns 1 and sets HAVE_PKG_PANGO to 1 along with:
92 #
93 ## PKG_PANGO_VERSION to the found version
94 ## PKG_PANGO_LIBS to the required libs (--libs-only-l)
95 ## PKG_PANGO_LDFLAGS to the required linker flags (--libs-only-L)
96 ## PKG_PANGO_CFLAGS to the required compiler flags (--cflags)
97 #
98 # If not found, returns 0.
99 #
100 proc pkg-config {module args} {
101 set ok [pkg-config-init]
@@ -122,13 +123,13 @@
122 return 1
123 }
124
125 # @pkg-config-get module setting
126 #
127 # Convenience access to the results of pkg-config
128 #
129 # For example, [pkg-config-get pango CFLAGS] returns
130 # the value of PKG_PANGO_CFLAGS, or "" if not defined.
131 proc pkg-config-get {module name} {
132 set prefix [feature-define-name $module PKG_]
133 get-define ${prefix}_${name} ""
134 }
135
--- autosetup/pkg-config.tcl
+++ autosetup/pkg-config.tcl
@@ -1,34 +1,35 @@
1 # Copyright (c) 2016 WorkWare Systems http://www.workware.net.au/
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'pkg-config' module allows package information to be found via 'pkg-config'.
7 #
8 # If not cross-compiling, the package path should be determined automatically
9 # by 'pkg-config'.
10 # If cross-compiling, the default package path is the compiler sysroot.
11 # If the C compiler doesn't support '-print-sysroot', the path can be supplied
12 # by the '--sysroot' option or by defining 'SYSROOT'.
13 #
14 # 'PKG_CONFIG' may be set to use an alternative to 'pkg-config'.
15
16 use cc
17
18 module-options {
19 sysroot:dir => "Override compiler sysroot for pkg-config search path"
20 }
21
22 # @pkg-config-init ?required?
23 #
24 # Initialises the 'pkg-config' system. Unless '$required' is set to 0,
25 # it is a fatal error if a usable 'pkg-config' is not found .
26 #
27 # This command will normally be called automatically as required,
28 # but it may be invoked explicitly if lack of 'pkg-config' is acceptable.
29 #
30 # Returns 1 if ok, or 0 if 'pkg-config' not found/usable (only if '$required' is 0).
31 #
32 proc pkg-config-init {{required 1}} {
33 if {[is-defined HAVE_PKG_CONFIG]} {
34 return [get-define HAVE_PKG_CONFIG]
35 }
@@ -46,12 +47,12 @@
47 msg-result $version
48 define PKG_CONFIG_VERSION $version
49
50 set found 1
51
52 if {[opt-str sysroot o]} {
53 define SYSROOT [file-normalize $o]
54 msg-result "Using specified sysroot [get-define SYSROOT]"
55 } elseif {[get-define build] ne [get-define host]} {
56 if {[catch {exec-with-stderr [get-define CC] -print-sysroot} result errinfo] == 0} {
57 # Use the compiler sysroot, if there is one
58 define SYSROOT $result
@@ -81,21 +82,21 @@
82 return $found
83 }
84
85 # @pkg-config module ?requirements?
86 #
87 # Use 'pkg-config' to find the given module meeting the given requirements.
88 # e.g.
89 #
90 ## pkg-config pango >= 1.37.0
91 #
92 # If found, returns 1 and sets 'HAVE_PKG_PANGO' to 1 along with:
93 #
94 ## PKG_PANGO_VERSION to the found version
95 ## PKG_PANGO_LIBS to the required libs (--libs-only-l)
96 ## PKG_PANGO_LDFLAGS to the required linker flags (--libs-only-L)
97 ## PKG_PANGO_CFLAGS to the required compiler flags (--cflags)
98 #
99 # If not found, returns 0.
100 #
101 proc pkg-config {module args} {
102 set ok [pkg-config-init]
@@ -122,13 +123,13 @@
123 return 1
124 }
125
126 # @pkg-config-get module setting
127 #
128 # Convenience access to the results of 'pkg-config'.
129 #
130 # For example, '[pkg-config-get pango CFLAGS]' returns
131 # the value of 'PKG_PANGO_CFLAGS', or '""' if not defined.
132 proc pkg-config-get {module name} {
133 set prefix [feature-define-name $module PKG_]
134 get-define ${prefix}_${name} ""
135 }
136
--- autosetup/system.tcl
+++ autosetup/system.tcl
@@ -2,35 +2,40 @@
22
# All rights reserved
33
44
# @synopsis:
55
#
66
# This module supports common system interrogation and options
7
-# such as --host, --build, --prefix, and setting srcdir, builddir, and EXEEXT
7
+# such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'.
88
#
9
-# It also support the 'feature' naming convention, where searching
10
-# for a feature such as sys/type.h defines HAVE_SYS_TYPES_H
9
+# It also support the "feature" naming convention, where searching
10
+# for a feature such as 'sys/type.h' defines 'HAVE_SYS_TYPES_H'.
1111
#
12
-# It defines the following variables, based on --prefix unless overridden by the user:
12
+# It defines the following variables, based on '--prefix' unless overridden by the user:
1313
#
1414
## datadir
1515
## sysconfdir
1616
## sharedstatedir
1717
## localstatedir
1818
## infodir
1919
## mandir
2020
## includedir
21
+#
22
+# If '--prefix' is not supplied, it defaults to '/usr/local' unless 'defaultprefix' is defined *before*
23
+# including the 'system' module.
2124
22
-# Do "define defaultprefix myvalue" to set the default prefix *before* the first "use"
23
-set defaultprefix [get-define defaultprefix /usr/local]
25
+if {[is-defined defaultprefix]} {
26
+ user-notice "Note: defaultprefix is deprecated. Use options-defaults to set default options"
27
+ options-defaults [list prefix [get-define defaultprefix]]
28
+}
2429
2530
module-options [subst -noc -nob {
2631
host:host-alias => {a complete or partial cpu-vendor-opsys for the system where
2732
the application will run (defaults to the same value as --build)}
2833
build:build-alias => {a complete or partial cpu-vendor-opsys for the system
2934
where the application will be built (defaults to the
3035
result of running config.guess)}
31
- prefix:dir => {the target directory for the build (defaults to '$defaultprefix')}
36
+ prefix:dir=/usr/local => {the target directory for the build (default: '@default@')}
3237
3338
# These (hidden) options are supported for autoconf/automake compatibility
3439
exec-prefix:
3540
bindir:
3641
sbindir:
@@ -41,16 +46,26 @@
4146
datadir:
4247
libdir:
4348
sysconfdir:
4449
sharedstatedir:
4550
localstatedir:
51
+ runstatedir:
4652
maintainer-mode=0
4753
dependency-tracking=0
54
+ silent-rules=0
4855
}]
4956
50
-# Returns 1 if exists, or 0 if not
57
+# @check-feature name { script }
58
+#
59
+# defines feature '$name' to the return value of '$script',
60
+# which should be 1 if found or 0 if not found.
61
+#
62
+# e.g. the following will define 'HAVE_CONST' to 0 or 1.
5163
#
64
+## check-feature const {
65
+## cctest -code {const int _x = 0;}
66
+## }
5267
proc check-feature {name code} {
5368
msg-checking "Checking for $name..."
5469
set r [uplevel 1 $code]
5570
define-feature $name $r
5671
if {$r} {
@@ -61,49 +76,54 @@
6176
return $r
6277
}
6378
6479
# @have-feature name ?default=0?
6580
#
66
-# Returns the value of the feature if defined, or $default if not.
67
-# See 'feature-define-name' for how the feature name
68
-# is translated into the define name.
81
+# Returns the value of feature '$name' if defined, or '$default' if not.
82
+#
83
+# See 'feature-define-name' for how the "feature" name
84
+# is translated into the "define" name.
6985
#
7086
proc have-feature {name {default 0}} {
7187
get-define [feature-define-name $name] $default
7288
}
7389
7490
# @define-feature name ?value=1?
7591
#
76
-# Sets the feature 'define' to the given value.
77
-# See 'feature-define-name' for how the feature name
78
-# is translated into the define name.
92
+# Sets the feature 'define' to '$value'.
93
+#
94
+# See 'feature-define-name' for how the "feature" name
95
+# is translated into the "define" name.
7996
#
8097
proc define-feature {name {value 1}} {
8198
define [feature-define-name $name] $value
8299
}
83100
84101
# @feature-checked name
85102
#
86
-# Returns 1 if the feature has been checked, whether true or not
103
+# Returns 1 if feature '$name' has been checked, whether true or not.
87104
#
88105
proc feature-checked {name} {
89106
is-defined [feature-define-name $name]
90107
}
91108
92109
# @feature-define-name name ?prefix=HAVE_?
93110
#
94
-# Converts a name to the corresponding define,
95
-# e.g. sys/stat.h becomes HAVE_SYS_STAT_H.
111
+# Converts a "feature" name to the corresponding "define",
112
+# e.g. 'sys/stat.h' becomes 'HAVE_SYS_STAT_H'.
96113
#
97
-# Converts * to P and all non-alphanumeric to underscore.
114
+# Converts '*' to 'P' and all non-alphanumeric to underscore.
98115
#
99116
proc feature-define-name {name {prefix HAVE_}} {
100117
string toupper $prefix[regsub -all {[^a-zA-Z0-9]} [regsub -all {[*]} $name p] _]
101118
}
102119
103
-# If $file doesn't exist, or it's contents are different than $buf,
104
-# the file is written and $script is executed.
120
+# @write-if-changed filename contents ?script?
121
+#
122
+# If '$filename' doesn't exist, or it's contents are different to '$contents',
123
+# the file is written and '$script' is evaluated.
124
+#
105125
# Otherwise a "file is unchanged" message is displayed.
106126
proc write-if-changed {file buf {script {}}} {
107127
set old [readfile $file ""]
108128
if {$old eq $buf && [file exists $file]} {
109129
msg-result "$file is unchanged"
@@ -110,42 +130,142 @@
110130
} else {
111131
writefile $file $buf\n
112132
uplevel 1 $script
113133
}
114134
}
135
+
136
+
137
+# @include-file infile mapping
138
+#
139
+# The core of make-template, called recursively for each @include
140
+# directive found within that template so that this proc's result
141
+# is the fully-expanded template.
142
+#
143
+# The mapping parameter is how we expand @varname@ within the template.
144
+# We do that inline within this step only for @include directives which
145
+# can have variables in the filename arg. A separate substitution pass
146
+# happens when this recursive function returns, expanding the rest of
147
+# the variables.
148
+#
149
+proc include-file {infile mapping} {
150
+ # A stack of true/false conditions, one for each nested conditional
151
+ # starting with "true"
152
+ set condstack {1}
153
+ set result {}
154
+ set linenum 0
155
+ foreach line [split [readfile $infile] \n] {
156
+ incr linenum
157
+ if {[regexp {^@(if|else|endif)(\s*)(.*)} $line -> condtype condspace condargs]} {
158
+ if {$condtype eq "if"} {
159
+ if {[string length $condspace] == 0} {
160
+ autosetup-error "$infile:$linenum: Invalid expression: $line"
161
+ }
162
+ if {[llength $condargs] == 1} {
163
+ # ABC => [get-define ABC] ni {0 ""}
164
+ # !ABC => [get-define ABC] in {0 ""}
165
+ lassign $condargs condvar
166
+ if {[regexp {^!(.*)} $condvar -> condvar]} {
167
+ set op in
168
+ } else {
169
+ set op ni
170
+ }
171
+ set condexpr "\[[list get-define $condvar]\] $op {0 {}}"
172
+ } else {
173
+ # Translate alphanumeric ABC into [get-define ABC] and leave the
174
+ # rest of the expression untouched
175
+ regsub -all {([A-Z][[:alnum:]_]*)} $condargs {[get-define \1]} condexpr
176
+ }
177
+ if {[catch [list expr $condexpr] condval]} {
178
+ dputs $condval
179
+ autosetup-error "$infile:$linenum: Invalid expression: $line"
180
+ }
181
+ dputs "@$condtype: $condexpr => $condval"
182
+ }
183
+ if {$condtype ne "if"} {
184
+ if {[llength $condstack] <= 1} {
185
+ autosetup-error "$infile:$linenum: Error: @$condtype missing @if"
186
+ } elseif {[string length $condargs] && [string index $condargs 0] ne "#"} {
187
+ autosetup-error "$infile:$linenum: Error: Extra arguments after @$condtype"
188
+ }
189
+ }
190
+ switch -exact $condtype {
191
+ if {
192
+ # push condval
193
+ lappend condstack $condval
194
+ }
195
+ else {
196
+ # Toggle the last entry
197
+ set condval [lpop condstack]
198
+ set condval [expr {!$condval}]
199
+ lappend condstack $condval
200
+ }
201
+ endif {
202
+ if {[llength $condstack] == 0} {
203
+ user-notice "$infile:$linenum: Error: @endif missing @if"
204
+ }
205
+ lpop condstack
206
+ }
207
+ }
208
+ continue
209
+ } elseif {[regexp {^@include\s+(.*)} $line -> filearg]} {
210
+ set incfile [string map $mapping $filearg]
211
+ if {[file exists $incfile]} {
212
+ lappend ::autosetup(deps) [file-normalize $incfile]
213
+ lappend result {*}[include-file $incfile $mapping]
214
+ } else {
215
+ user-error "$infile:$linenum: Include file $incfile is missing"
216
+ }
217
+ continue
218
+ } elseif {[regexp {^@define\s+(\w+)\s+(.*)} $line -> var val]} {
219
+ define $var $val
220
+ continue
221
+ }
222
+ # Only output this line if the stack contains all "true"
223
+ if {"0" in $condstack} {
224
+ continue
225
+ }
226
+ lappend result $line
227
+ }
228
+ return $result
229
+}
230
+
115231
116232
# @make-template template ?outfile?
117233
#
118
-# Reads the input file <srcdir>/$template and writes the output file $outfile.
119
-# If $outfile is blank/omitted, $template should end with ".in" which
234
+# Reads the input file '<srcdir>/$template' and writes the output file '$outfile'
235
+# (unless unchanged).
236
+# If '$outfile' is blank/omitted, '$template' should end with '.in' which
120237
# is removed to create the output file name.
121238
#
122
-# Each pattern of the form @define@ is replaced with the corresponding
123
-# define, if it exists, or left unchanged if not.
124
-#
125
-# The special value @srcdir@ is substituted with the relative
239
+# Each pattern of the form '@define@' is replaced with the corresponding
240
+# "define", if it exists, or left unchanged if not.
241
+#
242
+# The special value '@srcdir@' is substituted with the relative
126243
# path to the source directory from the directory where the output
127
-# file is created, while the special value @top_srcdir@ is substituted
244
+# file is created, while the special value '@top_srcdir@' is substituted
128245
# with the relative path to the top level source directory.
129246
#
130247
# Conditional sections may be specified as follows:
131
-## @if name == value
248
+## @if NAME eq "value"
132249
## lines
133250
## @else
134251
## lines
135252
## @endif
136253
#
137
-# Where 'name' is a defined variable name and @else is optional.
254
+# Where 'NAME' is a defined variable name and '@else' is optional.
255
+# Note that variables names *must* start with an uppercase letter.
138256
# If the expression does not match, all lines through '@endif' are ignored.
139257
#
140258
# The alternative forms may also be used:
141
-## @if name
142
-## @if name != value
259
+## @if NAME (true if the variable is defined, but not empty and not "0")
260
+## @if !NAME (opposite of the form above)
261
+## @if <general-tcl-expression>
143262
#
144
-# Where the first form is true if the variable is defined, but not empty or 0
263
+# In the general Tcl expression, any words beginning with an uppercase letter
264
+# are translated into [get-define NAME]
145265
#
146
-# Currently these expressions can't be nested.
266
+# Expressions may be nested
147267
#
148268
proc make-template {template {out {}}} {
149269
set infile [file join $::autosetup(srcdir) $template]
150270
151271
if {![file exists $infile]} {
@@ -169,61 +289,42 @@
169289
170290
# Set up srcdir and top_srcdir to be relative to the target dir
171291
define srcdir [relative-path [file join $::autosetup(srcdir) $outdir] $outdir]
172292
define top_srcdir [relative-path $::autosetup(srcdir) $outdir]
173293
174
- set mapping {}
175
- foreach {n v} [array get ::define] {
176
- lappend mapping @$n@ $v
177
- }
178
- set result {}
179
- foreach line [split [readfile $infile] \n] {
180
- if {[info exists cond]} {
181
- set l [string trimright $line]
182
- if {$l eq "@endif"} {
183
- unset cond
184
- continue
185
- }
186
- if {$l eq "@else"} {
187
- set cond [expr {!$cond}]
188
- continue
189
- }
190
- if {$cond} {
191
- lappend result $line
192
- }
193
- continue
194
- }
195
- if {[regexp {^@if\s+(\w+)(.*)} $line -> name expression]} {
196
- lassign $expression equal value
197
- set varval [get-define $name ""]
198
- if {$equal eq ""} {
199
- set cond [expr {$varval ni {"" 0}}]
200
- } else {
201
- set cond [expr {$varval eq $value}]
202
- if {$equal ne "=="} {
203
- set cond [expr {!$cond}]
204
- }
205
- }
206
- continue
207
- }
208
- lappend result $line
209
- }
210
- write-if-changed $out [string map $mapping [join $result \n]]\n {
211
- msg-result "Created [relative-path $out] from [relative-path $template]"
212
- }
294
+ # Build map from global defines to their values so they can be
295
+ # substituted into @include file names.
296
+ proc build-define-mapping {} {
297
+ set mapping {}
298
+ foreach {n v} [array get ::define] {
299
+ lappend mapping @$n@ $v
300
+ }
301
+ return $mapping
302
+ }
303
+ set mapping [build-define-mapping]
304
+
305
+ set result [include-file $infile $mapping]
306
+
307
+ # Rebuild the define mapping in case we ran across @define
308
+ # directives in the template or a file it @included, then
309
+ # apply that mapping to the expanded template.
310
+ set mapping [build-define-mapping]
311
+ write-if-changed $out [string map $mapping [join $result \n]] {
312
+ msg-result "Created [relative-path $out] from [relative-path $template]"
313
+ }
213314
}
214315
215316
# build/host tuples and cross-compilation prefix
216
-set build [opt-val build]
317
+opt-str build build ""
217318
define build_alias $build
218319
if {$build eq ""} {
219320
define build [config_guess]
220321
} else {
221322
define build [config_sub $build]
222323
}
223324
224
-set host [opt-val host]
325
+opt-str host host ""
225326
define host_alias $host
226327
if {$host eq ""} {
227328
define host [get-define build]
228329
set cross ""
229330
} else {
@@ -230,44 +331,67 @@
230331
define host [config_sub $host]
231332
set cross $host-
232333
}
233334
define cross [get-env CROSS $cross]
234335
235
-set prefix [opt-val prefix $defaultprefix]
336
+# build/host _cpu, _vendor and _os
337
+foreach type {build host} {
338
+ set v [get-define $type]
339
+ if {![regexp {^([^-]+)-([^-]+)-(.*)$} $v -> cpu vendor os]} {
340
+ user-error "Invalid canonical $type: $v"
341
+ }
342
+ define ${type}_cpu $cpu
343
+ define ${type}_vendor $vendor
344
+ define ${type}_os $os
345
+}
346
+
347
+opt-str prefix prefix /usr/local
236348
237349
# These are for compatibility with autoconf
238350
define target [get-define host]
239351
define prefix $prefix
240352
define builddir $autosetup(builddir)
241353
define srcdir $autosetup(srcdir)
242
-# Allow this to come from the environment
243
-define top_srcdir [get-env top_srcdir [get-define srcdir]]
354
+define top_srcdir $autosetup(srcdir)
355
+define abs_top_srcdir [file-normalize $autosetup(srcdir)]
356
+define abs_top_builddir [file-normalize $autosetup(builddir)]
244357
245358
# autoconf supports all of these
246
-set exec_prefix [opt-val exec-prefix $prefix]
247
-define exec_prefix $exec_prefix
359
+define exec_prefix [opt-str exec-prefix exec_prefix $prefix]
248360
foreach {name defpath} {
249361
bindir /bin
250362
sbindir /sbin
251363
libexecdir /libexec
252364
libdir /lib
253365
} {
254
- define $name [opt-val $name $exec_prefix$defpath]
366
+ define $name [opt-str $name o $exec_prefix$defpath]
255367
}
256368
foreach {name defpath} {
257369
datadir /share
258
- sysconfdir /etc
259370
sharedstatedir /com
260
- localstatedir /var
261371
infodir /share/info
262372
mandir /share/man
263373
includedir /include
264374
} {
265
- define $name [opt-val $name $prefix$defpath]
375
+ define $name [opt-str $name o $prefix$defpath]
376
+}
377
+if {$prefix ne {/usr}} {
378
+ opt-str sysconfdir sysconfdir $prefix/etc
379
+} else {
380
+ opt-str sysconfdir sysconfdir /etc
266381
}
382
+define sysconfdir $sysconfdir
383
+
384
+define localstatedir [opt-str localstatedir o /var]
385
+define runstatedir [opt-str runstatedir o /run]
267386
268387
define SHELL [get-env SHELL [find-an-executable sh bash ksh]]
388
+
389
+# These could be used to generate Makefiles following some automake conventions
390
+define AM_SILENT_RULES [opt-bool silent-rules]
391
+define AM_MAINTAINER_MODE [opt-bool maintainer-mode]
392
+define AM_DEPENDENCY_TRACKING [opt-bool dependency-tracking]
269393
270394
# Windows vs. non-Windows
271395
switch -glob -- [get-define host] {
272396
*-*-ming* - *-*-cygwin - *-*-msys {
273397
define-feature windows
274398
275399
DELETED autosetup/test-tclsh
--- autosetup/system.tcl
+++ autosetup/system.tcl
@@ -2,35 +2,40 @@
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # This module supports common system interrogation and options
7 # such as --host, --build, --prefix, and setting srcdir, builddir, and EXEEXT
8 #
9 # It also support the 'feature' naming convention, where searching
10 # for a feature such as sys/type.h defines HAVE_SYS_TYPES_H
11 #
12 # It defines the following variables, based on --prefix unless overridden by the user:
13 #
14 ## datadir
15 ## sysconfdir
16 ## sharedstatedir
17 ## localstatedir
18 ## infodir
19 ## mandir
20 ## includedir
 
 
 
21
22 # Do "define defaultprefix myvalue" to set the default prefix *before* the first "use"
23 set defaultprefix [get-define defaultprefix /usr/local]
 
 
24
25 module-options [subst -noc -nob {
26 host:host-alias => {a complete or partial cpu-vendor-opsys for the system where
27 the application will run (defaults to the same value as --build)}
28 build:build-alias => {a complete or partial cpu-vendor-opsys for the system
29 where the application will be built (defaults to the
30 result of running config.guess)}
31 prefix:dir => {the target directory for the build (defaults to '$defaultprefix')}
32
33 # These (hidden) options are supported for autoconf/automake compatibility
34 exec-prefix:
35 bindir:
36 sbindir:
@@ -41,16 +46,26 @@
41 datadir:
42 libdir:
43 sysconfdir:
44 sharedstatedir:
45 localstatedir:
 
46 maintainer-mode=0
47 dependency-tracking=0
 
48 }]
49
50 # Returns 1 if exists, or 0 if not
 
 
 
 
 
51 #
 
 
 
52 proc check-feature {name code} {
53 msg-checking "Checking for $name..."
54 set r [uplevel 1 $code]
55 define-feature $name $r
56 if {$r} {
@@ -61,49 +76,54 @@
61 return $r
62 }
63
64 # @have-feature name ?default=0?
65 #
66 # Returns the value of the feature if defined, or $default if not.
67 # See 'feature-define-name' for how the feature name
68 # is translated into the define name.
 
69 #
70 proc have-feature {name {default 0}} {
71 get-define [feature-define-name $name] $default
72 }
73
74 # @define-feature name ?value=1?
75 #
76 # Sets the feature 'define' to the given value.
77 # See 'feature-define-name' for how the feature name
78 # is translated into the define name.
 
79 #
80 proc define-feature {name {value 1}} {
81 define [feature-define-name $name] $value
82 }
83
84 # @feature-checked name
85 #
86 # Returns 1 if the feature has been checked, whether true or not
87 #
88 proc feature-checked {name} {
89 is-defined [feature-define-name $name]
90 }
91
92 # @feature-define-name name ?prefix=HAVE_?
93 #
94 # Converts a name to the corresponding define,
95 # e.g. sys/stat.h becomes HAVE_SYS_STAT_H.
96 #
97 # Converts * to P and all non-alphanumeric to underscore.
98 #
99 proc feature-define-name {name {prefix HAVE_}} {
100 string toupper $prefix[regsub -all {[^a-zA-Z0-9]} [regsub -all {[*]} $name p] _]
101 }
102
103 # If $file doesn't exist, or it's contents are different than $buf,
104 # the file is written and $script is executed.
 
 
 
105 # Otherwise a "file is unchanged" message is displayed.
106 proc write-if-changed {file buf {script {}}} {
107 set old [readfile $file ""]
108 if {$old eq $buf && [file exists $file]} {
109 msg-result "$file is unchanged"
@@ -110,42 +130,142 @@
110 } else {
111 writefile $file $buf\n
112 uplevel 1 $script
113 }
114 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
116 # @make-template template ?outfile?
117 #
118 # Reads the input file <srcdir>/$template and writes the output file $outfile.
119 # If $outfile is blank/omitted, $template should end with ".in" which
 
120 # is removed to create the output file name.
121 #
122 # Each pattern of the form @define@ is replaced with the corresponding
123 # define, if it exists, or left unchanged if not.
124 #
125 # The special value @srcdir@ is substituted with the relative
126 # path to the source directory from the directory where the output
127 # file is created, while the special value @top_srcdir@ is substituted
128 # with the relative path to the top level source directory.
129 #
130 # Conditional sections may be specified as follows:
131 ## @if name == value
132 ## lines
133 ## @else
134 ## lines
135 ## @endif
136 #
137 # Where 'name' is a defined variable name and @else is optional.
 
138 # If the expression does not match, all lines through '@endif' are ignored.
139 #
140 # The alternative forms may also be used:
141 ## @if name
142 ## @if name != value
 
143 #
144 # Where the first form is true if the variable is defined, but not empty or 0
 
145 #
146 # Currently these expressions can't be nested.
147 #
148 proc make-template {template {out {}}} {
149 set infile [file join $::autosetup(srcdir) $template]
150
151 if {![file exists $infile]} {
@@ -169,61 +289,42 @@
169
170 # Set up srcdir and top_srcdir to be relative to the target dir
171 define srcdir [relative-path [file join $::autosetup(srcdir) $outdir] $outdir]
172 define top_srcdir [relative-path $::autosetup(srcdir) $outdir]
173
174 set mapping {}
175 foreach {n v} [array get ::define] {
176 lappend mapping @$n@ $v
177 }
178 set result {}
179 foreach line [split [readfile $infile] \n] {
180 if {[info exists cond]} {
181 set l [string trimright $line]
182 if {$l eq "@endif"} {
183 unset cond
184 continue
185 }
186 if {$l eq "@else"} {
187 set cond [expr {!$cond}]
188 continue
189 }
190 if {$cond} {
191 lappend result $line
192 }
193 continue
194 }
195 if {[regexp {^@if\s+(\w+)(.*)} $line -> name expression]} {
196 lassign $expression equal value
197 set varval [get-define $name ""]
198 if {$equal eq ""} {
199 set cond [expr {$varval ni {"" 0}}]
200 } else {
201 set cond [expr {$varval eq $value}]
202 if {$equal ne "=="} {
203 set cond [expr {!$cond}]
204 }
205 }
206 continue
207 }
208 lappend result $line
209 }
210 write-if-changed $out [string map $mapping [join $result \n]]\n {
211 msg-result "Created [relative-path $out] from [relative-path $template]"
212 }
213 }
214
215 # build/host tuples and cross-compilation prefix
216 set build [opt-val build]
217 define build_alias $build
218 if {$build eq ""} {
219 define build [config_guess]
220 } else {
221 define build [config_sub $build]
222 }
223
224 set host [opt-val host]
225 define host_alias $host
226 if {$host eq ""} {
227 define host [get-define build]
228 set cross ""
229 } else {
@@ -230,44 +331,67 @@
230 define host [config_sub $host]
231 set cross $host-
232 }
233 define cross [get-env CROSS $cross]
234
235 set prefix [opt-val prefix $defaultprefix]
 
 
 
 
 
 
 
 
 
 
 
236
237 # These are for compatibility with autoconf
238 define target [get-define host]
239 define prefix $prefix
240 define builddir $autosetup(builddir)
241 define srcdir $autosetup(srcdir)
242 # Allow this to come from the environment
243 define top_srcdir [get-env top_srcdir [get-define srcdir]]
 
244
245 # autoconf supports all of these
246 set exec_prefix [opt-val exec-prefix $prefix]
247 define exec_prefix $exec_prefix
248 foreach {name defpath} {
249 bindir /bin
250 sbindir /sbin
251 libexecdir /libexec
252 libdir /lib
253 } {
254 define $name [opt-val $name $exec_prefix$defpath]
255 }
256 foreach {name defpath} {
257 datadir /share
258 sysconfdir /etc
259 sharedstatedir /com
260 localstatedir /var
261 infodir /share/info
262 mandir /share/man
263 includedir /include
264 } {
265 define $name [opt-val $name $prefix$defpath]
 
 
 
 
 
266 }
 
 
 
 
267
268 define SHELL [get-env SHELL [find-an-executable sh bash ksh]]
 
 
 
 
 
269
270 # Windows vs. non-Windows
271 switch -glob -- [get-define host] {
272 *-*-ming* - *-*-cygwin - *-*-msys {
273 define-feature windows
274
275 ELETED autosetup/test-tclsh
--- autosetup/system.tcl
+++ autosetup/system.tcl
@@ -2,35 +2,40 @@
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # This module supports common system interrogation and options
7 # such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'.
8 #
9 # It also support the "feature" naming convention, where searching
10 # for a feature such as 'sys/type.h' defines 'HAVE_SYS_TYPES_H'.
11 #
12 # It defines the following variables, based on '--prefix' unless overridden by the user:
13 #
14 ## datadir
15 ## sysconfdir
16 ## sharedstatedir
17 ## localstatedir
18 ## infodir
19 ## mandir
20 ## includedir
21 #
22 # If '--prefix' is not supplied, it defaults to '/usr/local' unless 'defaultprefix' is defined *before*
23 # including the 'system' module.
24
25 if {[is-defined defaultprefix]} {
26 user-notice "Note: defaultprefix is deprecated. Use options-defaults to set default options"
27 options-defaults [list prefix [get-define defaultprefix]]
28 }
29
30 module-options [subst -noc -nob {
31 host:host-alias => {a complete or partial cpu-vendor-opsys for the system where
32 the application will run (defaults to the same value as --build)}
33 build:build-alias => {a complete or partial cpu-vendor-opsys for the system
34 where the application will be built (defaults to the
35 result of running config.guess)}
36 prefix:dir=/usr/local => {the target directory for the build (default: '@default@')}
37
38 # These (hidden) options are supported for autoconf/automake compatibility
39 exec-prefix:
40 bindir:
41 sbindir:
@@ -41,16 +46,26 @@
46 datadir:
47 libdir:
48 sysconfdir:
49 sharedstatedir:
50 localstatedir:
51 runstatedir:
52 maintainer-mode=0
53 dependency-tracking=0
54 silent-rules=0
55 }]
56
57 # @check-feature name { script }
58 #
59 # defines feature '$name' to the return value of '$script',
60 # which should be 1 if found or 0 if not found.
61 #
62 # e.g. the following will define 'HAVE_CONST' to 0 or 1.
63 #
64 ## check-feature const {
65 ## cctest -code {const int _x = 0;}
66 ## }
67 proc check-feature {name code} {
68 msg-checking "Checking for $name..."
69 set r [uplevel 1 $code]
70 define-feature $name $r
71 if {$r} {
@@ -61,49 +76,54 @@
76 return $r
77 }
78
79 # @have-feature name ?default=0?
80 #
81 # Returns the value of feature '$name' if defined, or '$default' if not.
82 #
83 # See 'feature-define-name' for how the "feature" name
84 # is translated into the "define" name.
85 #
86 proc have-feature {name {default 0}} {
87 get-define [feature-define-name $name] $default
88 }
89
90 # @define-feature name ?value=1?
91 #
92 # Sets the feature 'define' to '$value'.
93 #
94 # See 'feature-define-name' for how the "feature" name
95 # is translated into the "define" name.
96 #
97 proc define-feature {name {value 1}} {
98 define [feature-define-name $name] $value
99 }
100
101 # @feature-checked name
102 #
103 # Returns 1 if feature '$name' has been checked, whether true or not.
104 #
105 proc feature-checked {name} {
106 is-defined [feature-define-name $name]
107 }
108
109 # @feature-define-name name ?prefix=HAVE_?
110 #
111 # Converts a "feature" name to the corresponding "define",
112 # e.g. 'sys/stat.h' becomes 'HAVE_SYS_STAT_H'.
113 #
114 # Converts '*' to 'P' and all non-alphanumeric to underscore.
115 #
116 proc feature-define-name {name {prefix HAVE_}} {
117 string toupper $prefix[regsub -all {[^a-zA-Z0-9]} [regsub -all {[*]} $name p] _]
118 }
119
120 # @write-if-changed filename contents ?script?
121 #
122 # If '$filename' doesn't exist, or it's contents are different to '$contents',
123 # the file is written and '$script' is evaluated.
124 #
125 # Otherwise a "file is unchanged" message is displayed.
126 proc write-if-changed {file buf {script {}}} {
127 set old [readfile $file ""]
128 if {$old eq $buf && [file exists $file]} {
129 msg-result "$file is unchanged"
@@ -110,42 +130,142 @@
130 } else {
131 writefile $file $buf\n
132 uplevel 1 $script
133 }
134 }
135
136
137 # @include-file infile mapping
138 #
139 # The core of make-template, called recursively for each @include
140 # directive found within that template so that this proc's result
141 # is the fully-expanded template.
142 #
143 # The mapping parameter is how we expand @varname@ within the template.
144 # We do that inline within this step only for @include directives which
145 # can have variables in the filename arg. A separate substitution pass
146 # happens when this recursive function returns, expanding the rest of
147 # the variables.
148 #
149 proc include-file {infile mapping} {
150 # A stack of true/false conditions, one for each nested conditional
151 # starting with "true"
152 set condstack {1}
153 set result {}
154 set linenum 0
155 foreach line [split [readfile $infile] \n] {
156 incr linenum
157 if {[regexp {^@(if|else|endif)(\s*)(.*)} $line -> condtype condspace condargs]} {
158 if {$condtype eq "if"} {
159 if {[string length $condspace] == 0} {
160 autosetup-error "$infile:$linenum: Invalid expression: $line"
161 }
162 if {[llength $condargs] == 1} {
163 # ABC => [get-define ABC] ni {0 ""}
164 # !ABC => [get-define ABC] in {0 ""}
165 lassign $condargs condvar
166 if {[regexp {^!(.*)} $condvar -> condvar]} {
167 set op in
168 } else {
169 set op ni
170 }
171 set condexpr "\[[list get-define $condvar]\] $op {0 {}}"
172 } else {
173 # Translate alphanumeric ABC into [get-define ABC] and leave the
174 # rest of the expression untouched
175 regsub -all {([A-Z][[:alnum:]_]*)} $condargs {[get-define \1]} condexpr
176 }
177 if {[catch [list expr $condexpr] condval]} {
178 dputs $condval
179 autosetup-error "$infile:$linenum: Invalid expression: $line"
180 }
181 dputs "@$condtype: $condexpr => $condval"
182 }
183 if {$condtype ne "if"} {
184 if {[llength $condstack] <= 1} {
185 autosetup-error "$infile:$linenum: Error: @$condtype missing @if"
186 } elseif {[string length $condargs] && [string index $condargs 0] ne "#"} {
187 autosetup-error "$infile:$linenum: Error: Extra arguments after @$condtype"
188 }
189 }
190 switch -exact $condtype {
191 if {
192 # push condval
193 lappend condstack $condval
194 }
195 else {
196 # Toggle the last entry
197 set condval [lpop condstack]
198 set condval [expr {!$condval}]
199 lappend condstack $condval
200 }
201 endif {
202 if {[llength $condstack] == 0} {
203 user-notice "$infile:$linenum: Error: @endif missing @if"
204 }
205 lpop condstack
206 }
207 }
208 continue
209 } elseif {[regexp {^@include\s+(.*)} $line -> filearg]} {
210 set incfile [string map $mapping $filearg]
211 if {[file exists $incfile]} {
212 lappend ::autosetup(deps) [file-normalize $incfile]
213 lappend result {*}[include-file $incfile $mapping]
214 } else {
215 user-error "$infile:$linenum: Include file $incfile is missing"
216 }
217 continue
218 } elseif {[regexp {^@define\s+(\w+)\s+(.*)} $line -> var val]} {
219 define $var $val
220 continue
221 }
222 # Only output this line if the stack contains all "true"
223 if {"0" in $condstack} {
224 continue
225 }
226 lappend result $line
227 }
228 return $result
229 }
230
231
232 # @make-template template ?outfile?
233 #
234 # Reads the input file '<srcdir>/$template' and writes the output file '$outfile'
235 # (unless unchanged).
236 # If '$outfile' is blank/omitted, '$template' should end with '.in' which
237 # is removed to create the output file name.
238 #
239 # Each pattern of the form '@define@' is replaced with the corresponding
240 # "define", if it exists, or left unchanged if not.
241 #
242 # The special value '@srcdir@' is substituted with the relative
243 # path to the source directory from the directory where the output
244 # file is created, while the special value '@top_srcdir@' is substituted
245 # with the relative path to the top level source directory.
246 #
247 # Conditional sections may be specified as follows:
248 ## @if NAME eq "value"
249 ## lines
250 ## @else
251 ## lines
252 ## @endif
253 #
254 # Where 'NAME' is a defined variable name and '@else' is optional.
255 # Note that variables names *must* start with an uppercase letter.
256 # If the expression does not match, all lines through '@endif' are ignored.
257 #
258 # The alternative forms may also be used:
259 ## @if NAME (true if the variable is defined, but not empty and not "0")
260 ## @if !NAME (opposite of the form above)
261 ## @if <general-tcl-expression>
262 #
263 # In the general Tcl expression, any words beginning with an uppercase letter
264 # are translated into [get-define NAME]
265 #
266 # Expressions may be nested
267 #
268 proc make-template {template {out {}}} {
269 set infile [file join $::autosetup(srcdir) $template]
270
271 if {![file exists $infile]} {
@@ -169,61 +289,42 @@
289
290 # Set up srcdir and top_srcdir to be relative to the target dir
291 define srcdir [relative-path [file join $::autosetup(srcdir) $outdir] $outdir]
292 define top_srcdir [relative-path $::autosetup(srcdir) $outdir]
293
294 # Build map from global defines to their values so they can be
295 # substituted into @include file names.
296 proc build-define-mapping {} {
297 set mapping {}
298 foreach {n v} [array get ::define] {
299 lappend mapping @$n@ $v
300 }
301 return $mapping
302 }
303 set mapping [build-define-mapping]
304
305 set result [include-file $infile $mapping]
306
307 # Rebuild the define mapping in case we ran across @define
308 # directives in the template or a file it @included, then
309 # apply that mapping to the expanded template.
310 set mapping [build-define-mapping]
311 write-if-changed $out [string map $mapping [join $result \n]] {
312 msg-result "Created [relative-path $out] from [relative-path $template]"
313 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314 }
315
316 # build/host tuples and cross-compilation prefix
317 opt-str build build ""
318 define build_alias $build
319 if {$build eq ""} {
320 define build [config_guess]
321 } else {
322 define build [config_sub $build]
323 }
324
325 opt-str host host ""
326 define host_alias $host
327 if {$host eq ""} {
328 define host [get-define build]
329 set cross ""
330 } else {
@@ -230,44 +331,67 @@
331 define host [config_sub $host]
332 set cross $host-
333 }
334 define cross [get-env CROSS $cross]
335
336 # build/host _cpu, _vendor and _os
337 foreach type {build host} {
338 set v [get-define $type]
339 if {![regexp {^([^-]+)-([^-]+)-(.*)$} $v -> cpu vendor os]} {
340 user-error "Invalid canonical $type: $v"
341 }
342 define ${type}_cpu $cpu
343 define ${type}_vendor $vendor
344 define ${type}_os $os
345 }
346
347 opt-str prefix prefix /usr/local
348
349 # These are for compatibility with autoconf
350 define target [get-define host]
351 define prefix $prefix
352 define builddir $autosetup(builddir)
353 define srcdir $autosetup(srcdir)
354 define top_srcdir $autosetup(srcdir)
355 define abs_top_srcdir [file-normalize $autosetup(srcdir)]
356 define abs_top_builddir [file-normalize $autosetup(builddir)]
357
358 # autoconf supports all of these
359 define exec_prefix [opt-str exec-prefix exec_prefix $prefix]
 
360 foreach {name defpath} {
361 bindir /bin
362 sbindir /sbin
363 libexecdir /libexec
364 libdir /lib
365 } {
366 define $name [opt-str $name o $exec_prefix$defpath]
367 }
368 foreach {name defpath} {
369 datadir /share
 
370 sharedstatedir /com
 
371 infodir /share/info
372 mandir /share/man
373 includedir /include
374 } {
375 define $name [opt-str $name o $prefix$defpath]
376 }
377 if {$prefix ne {/usr}} {
378 opt-str sysconfdir sysconfdir $prefix/etc
379 } else {
380 opt-str sysconfdir sysconfdir /etc
381 }
382 define sysconfdir $sysconfdir
383
384 define localstatedir [opt-str localstatedir o /var]
385 define runstatedir [opt-str runstatedir o /run]
386
387 define SHELL [get-env SHELL [find-an-executable sh bash ksh]]
388
389 # These could be used to generate Makefiles following some automake conventions
390 define AM_SILENT_RULES [opt-bool silent-rules]
391 define AM_MAINTAINER_MODE [opt-bool maintainer-mode]
392 define AM_DEPENDENCY_TRACKING [opt-bool dependency-tracking]
393
394 # Windows vs. non-Windows
395 switch -glob -- [get-define host] {
396 *-*-ming* - *-*-cygwin - *-*-msys {
397 define-feature windows
398
399 ELETED autosetup/test-tclsh
D autosetup/test-tclsh
-20
--- a/autosetup/test-tclsh
+++ b/autosetup/test-tclsh
@@ -1,20 +0,0 @@
1
-# A small Tcl script to verify that the chosen
2
-# interpreter works. Sometimes we might e.g. pick up
3
-# an interpreter for a different arch.
4
-# Outputs the full path to the interpreter
5
-
6
-if {[catch {info version} version] == 0} {
7
- # This is Jim Tcl
8
- if {$version >= 0.72} {
9
- # Ensure that regexp works
10
- regexp (a.*?) a
11
- puts [info nameofexecutable]
12
- exit 0
13
- }
14
-} elseif {[catch {info tclversion} version] == 0} {
15
- if {$version >= 8.5 && ![string match 8.5a* [info patchlevel]]} {
16
- puts [info nameofexecutable]
17
- exit 0
18
- }
19
-}
20
-exit 1
--- a/autosetup/test-tclsh
+++ b/autosetup/test-tclsh
@@ -1,20 +0,0 @@
1 # A small Tcl script to verify that the chosen
2 # interpreter works. Sometimes we might e.g. pick up
3 # an interpreter for a different arch.
4 # Outputs the full path to the interpreter
5
6 if {[catch {info version} version] == 0} {
7 # This is Jim Tcl
8 if {$version >= 0.72} {
9 # Ensure that regexp works
10 regexp (a.*?) a
11 puts [info nameofexecutable]
12 exit 0
13 }
14 } elseif {[catch {info tclversion} version] == 0} {
15 if {$version >= 8.5 && ![string match 8.5a* [info patchlevel]]} {
16 puts [info nameofexecutable]
17 exit 0
18 }
19 }
20 exit 1
--- a/autosetup/test-tclsh
+++ b/autosetup/test-tclsh
@@ -1,20 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- autosetup/tmake.auto
+++ autosetup/tmake.auto
@@ -21,45 +21,34 @@
2121
cc-check-tools ar ranlib
2222
2323
set objdir [get-env BUILDDIR objdir]
2424
2525
make-config-header $objdir/include/autoconf.h
26
-make-tmake-settings $objdir/settings.conf {[A-Z]*}
26
+make-tmake-settings $objdir/settings.conf {[A-Z]*} *dir lib_*
2727
}
2828
2929
autosetup_check_create project.spec \
3030
{# Initial project.spec created by 'autosetup --init=tmake'
31
+
32
+tmake-require-version 0.7.3
3133
3234
# vim:set syntax=tcl:
3335
define? DESTDIR _install
3436
3537
# XXX If configure creates additional/different files than include/autoconf.h
3638
# that should be reflected here
37
-
38
-# We use [set AUTOREMAKE] here to avoid rebuilding settings.conf
39
-# if the AUTOREMAKE command changes
40
-Depends {settings.conf include/autoconf.h} auto.def -msg {note Configuring...} -do {
41
- run [set AUTOREMAKE] >$build/config.out
42
-} -onerror {puts [readfile $build/config.out]} -fatal
43
-Clean config.out
44
-DistClean --source config.log
45
-DistClean settings.conf include/autoconf.h
46
-
47
-# If not configured, configure with default options
48
-# Note that it is expected that configure will normally be run
49
-# separately. This is just a convenience for a host build
50
-define? AUTOREMAKE configure TOPBUILDDIR=$TOPBUILDDIR --conf=auto.def
51
-
52
-Load settings.conf
53
-
54
-# e.g. for up autoconf.h
39
+Autosetup include/autoconf.h
40
+
41
+# e.g. for autoconf.h
5542
IncludePaths include
5643
57
-ifconfig CONFIGURED
58
-
59
-# Hmmm, but should we turn off AutoSubDirs?
60
-#AutoSubDirs off
44
+ifconfig !CONFIGURED {
45
+ # Not configured, so don't process subdirs
46
+ AutoSubDirs off
47
+ # And don't process this file any further
48
+ ifconfig false
49
+}
6150
}
6251
6352
if {![file exists build.spec]} {
6453
puts "Note: I don't see build.spec. Try running: tmake --genie"
6554
}
6655
--- autosetup/tmake.auto
+++ autosetup/tmake.auto
@@ -21,45 +21,34 @@
21 cc-check-tools ar ranlib
22
23 set objdir [get-env BUILDDIR objdir]
24
25 make-config-header $objdir/include/autoconf.h
26 make-tmake-settings $objdir/settings.conf {[A-Z]*}
27 }
28
29 autosetup_check_create project.spec \
30 {# Initial project.spec created by 'autosetup --init=tmake'
 
 
31
32 # vim:set syntax=tcl:
33 define? DESTDIR _install
34
35 # XXX If configure creates additional/different files than include/autoconf.h
36 # that should be reflected here
37
38 # We use [set AUTOREMAKE] here to avoid rebuilding settings.conf
39 # if the AUTOREMAKE command changes
40 Depends {settings.conf include/autoconf.h} auto.def -msg {note Configuring...} -do {
41 run [set AUTOREMAKE] >$build/config.out
42 } -onerror {puts [readfile $build/config.out]} -fatal
43 Clean config.out
44 DistClean --source config.log
45 DistClean settings.conf include/autoconf.h
46
47 # If not configured, configure with default options
48 # Note that it is expected that configure will normally be run
49 # separately. This is just a convenience for a host build
50 define? AUTOREMAKE configure TOPBUILDDIR=$TOPBUILDDIR --conf=auto.def
51
52 Load settings.conf
53
54 # e.g. for up autoconf.h
55 IncludePaths include
56
57 ifconfig CONFIGURED
58
59 # Hmmm, but should we turn off AutoSubDirs?
60 #AutoSubDirs off
 
 
61 }
62
63 if {![file exists build.spec]} {
64 puts "Note: I don't see build.spec. Try running: tmake --genie"
65 }
66
--- autosetup/tmake.auto
+++ autosetup/tmake.auto
@@ -21,45 +21,34 @@
21 cc-check-tools ar ranlib
22
23 set objdir [get-env BUILDDIR objdir]
24
25 make-config-header $objdir/include/autoconf.h
26 make-tmake-settings $objdir/settings.conf {[A-Z]*} *dir lib_*
27 }
28
29 autosetup_check_create project.spec \
30 {# Initial project.spec created by 'autosetup --init=tmake'
31
32 tmake-require-version 0.7.3
33
34 # vim:set syntax=tcl:
35 define? DESTDIR _install
36
37 # XXX If configure creates additional/different files than include/autoconf.h
38 # that should be reflected here
39 Autosetup include/autoconf.h
40
41 # e.g. for autoconf.h
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42 IncludePaths include
43
44 ifconfig !CONFIGURED {
45 # Not configured, so don't process subdirs
46 AutoSubDirs off
47 # And don't process this file any further
48 ifconfig false
49 }
50 }
51
52 if {![file exists build.spec]} {
53 puts "Note: I don't see build.spec. Try running: tmake --genie"
54 }
55
--- autosetup/tmake.tcl
+++ autosetup/tmake.tcl
@@ -15,21 +15,21 @@
1515
1616
define CONFIGURED
1717
1818
# @make-tmake-settings outfile patterns ...
1919
#
20
-# Examines all defined variables which match the given patterns (defaults to "*")
20
+# Examines all defined variables which match the given patterns (defaults to '*')
2121
# and writes a tmake-compatible .conf file defining those variables.
22
-# For example, if ABC is "3 monkeys" and ABC matches a pattern, then the file will include:
22
+# For example, if 'ABC' is '"3 monkeys"' and 'ABC' matches a pattern, then the file will include:
2323
#
2424
## define ABC {3 monkeys}
2525
#
2626
# If the file would be unchanged, it is not written.
2727
#
2828
# Typical usage is:
2929
#
30
-# make-tmake-settings [get-env BUILDDIR objdir]/settings.conf {[A-Z]*}
30
+## make-tmake-settings [get-env BUILDDIR objdir]/settings.conf {[A-Z]*}
3131
proc make-tmake-settings {file args} {
3232
file mkdir [file dirname $file]
3333
set lines {}
3434
3535
if {[llength $args] == 0} {
3636
--- autosetup/tmake.tcl
+++ autosetup/tmake.tcl
@@ -15,21 +15,21 @@
15
16 define CONFIGURED
17
18 # @make-tmake-settings outfile patterns ...
19 #
20 # Examines all defined variables which match the given patterns (defaults to "*")
21 # and writes a tmake-compatible .conf file defining those variables.
22 # For example, if ABC is "3 monkeys" and ABC matches a pattern, then the file will include:
23 #
24 ## define ABC {3 monkeys}
25 #
26 # If the file would be unchanged, it is not written.
27 #
28 # Typical usage is:
29 #
30 # make-tmake-settings [get-env BUILDDIR objdir]/settings.conf {[A-Z]*}
31 proc make-tmake-settings {file args} {
32 file mkdir [file dirname $file]
33 set lines {}
34
35 if {[llength $args] == 0} {
36
--- autosetup/tmake.tcl
+++ autosetup/tmake.tcl
@@ -15,21 +15,21 @@
15
16 define CONFIGURED
17
18 # @make-tmake-settings outfile patterns ...
19 #
20 # Examines all defined variables which match the given patterns (defaults to '*')
21 # and writes a tmake-compatible .conf file defining those variables.
22 # For example, if 'ABC' is '"3 monkeys"' and 'ABC' matches a pattern, then the file will include:
23 #
24 ## define ABC {3 monkeys}
25 #
26 # If the file would be unchanged, it is not written.
27 #
28 # Typical usage is:
29 #
30 ## make-tmake-settings [get-env BUILDDIR objdir]/settings.conf {[A-Z]*}
31 proc make-tmake-settings {file args} {
32 file mkdir [file dirname $file]
33 set lines {}
34
35 if {[llength $args] == 0} {
36
+1 -1
--- configure
+++ configure
@@ -1,3 +1,3 @@
11
#!/bin/sh
22
dir="`dirname "$0"`/autosetup"
3
-WRAPPER="$0"; export WRAPPER; exec "`$dir/find-tclsh`" "$dir/autosetup" "$@"
3
+WRAPPER="$0"; export WRAPPER; exec "`"$dir/autosetup-find-tclsh"`" "$dir/autosetup" "$@"
44
--- configure
+++ configure
@@ -1,3 +1,3 @@
1 #!/bin/sh
2 dir="`dirname "$0"`/autosetup"
3 WRAPPER="$0"; export WRAPPER; exec "`$dir/find-tclsh`" "$dir/autosetup" "$@"
4
--- configure
+++ configure
@@ -1,3 +1,3 @@
1 #!/bin/sh
2 dir="`dirname "$0"`/autosetup"
3 WRAPPER="$0"; export WRAPPER; exec "`"$dir/autosetup-find-tclsh"`" "$dir/autosetup" "$@"
4

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button