|
1
|
# For this project, disable the pager for --help and --ref |
|
2
|
# The user can still enable by using --nopager=0 or --disable-nopager |
|
3
|
dict set autosetup(optdefault) nopager 1 |
|
4
|
|
|
5
|
# Searches for a usable Tcl (prefer 8.6, 8.5, 8.4) in the given paths |
|
6
|
# Returns a dictionary of the contents of the tclConfig.sh file, or |
|
7
|
# empty if not found |
|
8
|
proc parse-tclconfig-sh {args} { |
|
9
|
foreach p $args { |
|
10
|
# Allow pointing directly to the path containing tclConfig.sh |
|
11
|
if {[file exists $p/tclConfig.sh]} { |
|
12
|
return [parse-tclconfig-sh-file $p/tclConfig.sh] |
|
13
|
} |
|
14
|
# Some systems allow for multiple versions |
|
15
|
foreach libpath {lib/tcl8.6 lib/tcl8.5 lib/tcl8.4 lib/tcl tcl lib} { |
|
16
|
if {[file exists $p/$libpath/tclConfig.sh]} { |
|
17
|
return [parse-tclconfig-sh-file $p/$libpath/tclConfig.sh] |
|
18
|
} |
|
19
|
} |
|
20
|
} |
|
21
|
} |
|
22
|
|
|
23
|
proc parse-tclconfig-sh-file {filename} { |
|
24
|
foreach line [split [readfile $filename] \n] { |
|
25
|
if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} { |
|
26
|
set value [regsub -all {\$\{.*\}} $value ""] |
|
27
|
set tclconfig($name) [string trim $value '] |
|
28
|
} |
|
29
|
} |
|
30
|
return [array get tclconfig] |
|
31
|
} |
|
32
|
|
|
33
|
# |
|
34
|
# Given a library link flag, e.g. -lfoo, returns 1 if that library can |
|
35
|
# actually be linked to, else returns 0. |
|
36
|
proc lib-actually-exists {linkFlag} { |
|
37
|
cctest -link 1 -code "void libActuallyExists(void){}" -libs $linkFlag |
|
38
|
} |
|
39
|
|
|
40
|
# |
|
41
|
# Given a library flag, e.g. -lfoo, a list of libs, e.g. {-lfoo -lbar |
|
42
|
# -lbaz}, and a target variable name, this function appends all |
|
43
|
# entries of $libList which do not match $flag to $tgtVar, then |
|
44
|
# appends $flag to the end of $tgtVar. Returns the number of matches |
|
45
|
# found. |
|
46
|
proc move-lib-to-end {flag libList tgtVar} { |
|
47
|
upvar $tgtVar tgt |
|
48
|
set tgt {} |
|
49
|
set found 0 |
|
50
|
foreach e $libList { |
|
51
|
if {$flag eq $e} { |
|
52
|
incr found |
|
53
|
} else { |
|
54
|
lappend tgt $e |
|
55
|
} |
|
56
|
} |
|
57
|
if {$found} { |
|
58
|
lappend tgt $flag |
|
59
|
} |
|
60
|
return $found |
|
61
|
} |
|
62
|
|