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