diff options
| author | cashmere <cashmere@autistici.org> | 2026-09-04 09:05:24 +0200 |
|---|---|---|
| committer | cashmere <cashmere@autistici.org> | 2026-09-04 09:05:24 +0200 |
| commit | 4f49b16079b27d7ce633619e4cddfdf2bffbc952 (patch) | |
| tree | c296c1e7f3c3e2f6859c6d3a1b1b208779b89679 /autosetup/local.tcl | |
| download | relic-4f49b16079b27d7ce633619e4cddfdf2bffbc952.tar.gz | |
Diffstat (limited to 'autosetup/local.tcl')
| -rw-r--r-- | autosetup/local.tcl | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/autosetup/local.tcl b/autosetup/local.tcl new file mode 100644 index 0000000..63b5743 --- /dev/null +++ b/autosetup/local.tcl @@ -0,0 +1,61 @@ +# For this project, disable the pager for --help and --ref +# The user can still enable by using --nopager=0 or --disable-nopager +dict set autosetup(optdefault) nopager 1 + +# Searches for a usable Tcl (prefer 8.6, 8.5, 8.4) in the given paths +# Returns a dictionary of the contents of the tclConfig.sh file, or +# empty if not found +proc parse-tclconfig-sh {args} { + foreach p $args { + # Allow pointing directly to the path containing tclConfig.sh + if {[file exists $p/tclConfig.sh]} { + return [parse-tclconfig-sh-file $p/tclConfig.sh] + } + # Some systems allow for multiple versions + foreach libpath {lib/tcl8.6 lib/tcl8.5 lib/tcl8.4 lib/tcl tcl lib} { + if {[file exists $p/$libpath/tclConfig.sh]} { + return [parse-tclconfig-sh-file $p/$libpath/tclConfig.sh] + } + } + } +} + +proc parse-tclconfig-sh-file {filename} { + foreach line [split [readfile $filename] \n] { + if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} { + set value [regsub -all {\$\{.*\}} $value ""] + set tclconfig($name) [string trim $value '] + } + } + return [array get tclconfig] +} + +# +# Given a library link flag, e.g. -lfoo, returns 1 if that library can +# actually be linked to, else returns 0. +proc lib-actually-exists {linkFlag} { + cctest -link 1 -code "void libActuallyExists(void){}" -libs $linkFlag +} + +# +# Given a library flag, e.g. -lfoo, a list of libs, e.g. {-lfoo -lbar +# -lbaz}, and a target variable name, this function appends all +# entries of $libList which do not match $flag to $tgtVar, then +# appends $flag to the end of $tgtVar. Returns the number of matches +# found. +proc move-lib-to-end {flag libList tgtVar} { + upvar $tgtVar tgt + set tgt {} + set found 0 + foreach e $libList { + if {$flag eq $e} { + incr found + } else { + lappend tgt $e + } + } + if {$found} { + lappend tgt $flag + } + return $found +} |
