|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace eval ::platform {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::platform::generic {} { |
|
global tcl_platform |
|
|
|
set plat [string tolower [lindex $tcl_platform(os) 0]] |
|
set cpu $tcl_platform(machine) |
|
|
|
switch -glob -- $cpu { |
|
sun4* { |
|
set cpu sparc |
|
} |
|
intel - |
|
ia32* - |
|
i*86* { |
|
set cpu ix86 |
|
} |
|
x86_64 { |
|
if {$tcl_platform(wordSize) == 4} { |
|
|
|
set cpu ix86 |
|
} |
|
} |
|
ppc - |
|
"Power*" { |
|
set cpu powerpc |
|
} |
|
"arm*" { |
|
set cpu arm |
|
} |
|
ia64 { |
|
if {$tcl_platform(wordSize) == 4} { |
|
append cpu _32 |
|
} |
|
} |
|
} |
|
|
|
switch -glob -- $plat { |
|
windows { |
|
if {$tcl_platform(platform) == "unix"} { |
|
set plat cygwin |
|
} else { |
|
set plat win32 |
|
} |
|
if {$cpu eq "amd64"} { |
|
|
|
set cpu x86_64 |
|
} |
|
} |
|
sunos { |
|
set plat solaris |
|
if {[string match "ix86" $cpu]} { |
|
if {$tcl_platform(wordSize) == 8} { |
|
set cpu x86_64 |
|
} |
|
} elseif {![string match "ia64*" $cpu]} { |
|
|
|
if {$tcl_platform(wordSize) == 8} { |
|
append cpu 64 |
|
} |
|
} |
|
} |
|
darwin { |
|
set plat macosx |
|
|
|
|
|
if {$cpu eq "ix86"} { |
|
if {$tcl_platform(wordSize) == 8} { |
|
set cpu x86_64 |
|
} |
|
} |
|
} |
|
aix { |
|
set cpu powerpc |
|
if {$tcl_platform(wordSize) == 8} { |
|
append cpu 64 |
|
} |
|
} |
|
hp-ux { |
|
set plat hpux |
|
if {![string match "ia64*" $cpu]} { |
|
set cpu parisc |
|
if {$tcl_platform(wordSize) == 8} { |
|
append cpu 64 |
|
} |
|
} |
|
} |
|
osf1 { |
|
set plat tru64 |
|
} |
|
default { |
|
set plat [lindex [split $plat _-] 0] |
|
} |
|
} |
|
|
|
return "${plat}-${cpu}" |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::platform::identify {} { |
|
global tcl_platform |
|
|
|
set id [generic] |
|
regexp {^([^-]+)-([^-]+)$} $id -> plat cpu |
|
|
|
switch -- $plat { |
|
solaris { |
|
regsub {^5} $tcl_platform(osVersion) 2 text |
|
append plat $text |
|
return "${plat}-${cpu}" |
|
} |
|
macosx { |
|
set major [lindex [split $tcl_platform(osVersion) .] 0] |
|
if {$major > 19} { |
|
set minor [lindex [split $tcl_platform(osVersion) .] 1] |
|
incr major -9 |
|
append plat $major.[expr {$minor - 1}] |
|
} else { |
|
incr major -4 |
|
append plat 10.$major |
|
return "${plat}-${cpu}" |
|
} |
|
return "${plat}-${cpu}" |
|
} |
|
linux { |
|
|
|
|
|
|
|
set v unknown |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch -exact -- $tcl_platform(wordSize) { |
|
4 { |
|
lappend bases /lib |
|
if {[catch { |
|
exec dpkg-architecture -qDEB_HOST_MULTIARCH |
|
} res]} { |
|
lappend bases /lib/i386-linux-gnu |
|
} else { |
|
|
|
lappend bases /lib/$res |
|
} |
|
} |
|
8 { |
|
lappend bases /lib64 |
|
if {[catch { |
|
exec dpkg-architecture -qDEB_HOST_MULTIARCH |
|
} res]} { |
|
lappend bases /lib/x86_64-linux-gnu |
|
} else { |
|
|
|
lappend bases /lib/$res |
|
} |
|
} |
|
default { |
|
return -code error "Bad wordSize $tcl_platform(wordSize), expected 4 or 8" |
|
} |
|
} |
|
|
|
foreach base $bases { |
|
if {[LibcVersion $base -> v]} break |
|
} |
|
|
|
append plat -$v |
|
return "${plat}-${cpu}" |
|
} |
|
} |
|
|
|
return $id |
|
} |
|
|
|
proc ::platform::LibcVersion {base _->_ vv} { |
|
upvar 1 $vv v |
|
set libclist [lsort [glob -nocomplain -directory $base libc*]] |
|
|
|
if {![llength $libclist]} { return 0 } |
|
|
|
set libc [lindex $libclist 0] |
|
|
|
|
|
|
|
|
|
|
|
if {![catch { |
|
set vdata [lindex [split [exec $libc] \n] 0] |
|
}]} { |
|
regexp {version ([0-9]+(\.[0-9]+)*)} $vdata -> v |
|
foreach {major minor} [split $v .] break |
|
set v glibc${major}.${minor} |
|
return 1 |
|
} else { |
|
|
|
|
|
|
|
|
|
if {[regexp -- {libc-([0-9]+)\.([0-9]+)} $libc -> major minor]} { |
|
set v glibc${major}.${minor} |
|
return 1 |
|
} |
|
} |
|
return 0 |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::platform::patterns {id} { |
|
set res [list $id] |
|
if {$id eq "tcl"} {return $res} |
|
|
|
switch -glob -- $id { |
|
solaris*-* { |
|
if {[regexp {solaris([^-]*)-(.*)} $id -> v cpu]} { |
|
if {$v eq ""} {return $id} |
|
foreach {major minor} [split $v .] break |
|
incr minor -1 |
|
for {set j $minor} {$j >= 6} {incr j -1} { |
|
lappend res solaris${major}.${j}-${cpu} |
|
} |
|
} |
|
} |
|
linux*-* { |
|
if {[regexp {linux-glibc([^-]*)-(.*)} $id -> v cpu]} { |
|
foreach {major minor} [split $v .] break |
|
incr minor -1 |
|
for {set j $minor} {$j >= 0} {incr j -1} { |
|
lappend res linux-glibc${major}.${j}-${cpu} |
|
} |
|
} |
|
} |
|
macosx-powerpc { |
|
lappend res macosx-universal |
|
} |
|
macosx-x86_64 { |
|
lappend res macosx-i386-x86_64 |
|
} |
|
macosx-ix86 { |
|
lappend res macosx-universal macosx-i386-x86_64 |
|
} |
|
macosx*-* { |
|
|
|
if {[regexp {macosx([^-]*)-(.*)} $id -> v cpu]} { |
|
|
|
switch -exact -- $cpu { |
|
ix86 { |
|
lappend alt i386-x86_64 |
|
lappend alt universal |
|
} |
|
x86_64 { |
|
if {[lindex [split $::tcl_platform(osVersion) .] 0] < 19} { |
|
set alt i386-x86_64 |
|
} else { |
|
set alt {} |
|
} |
|
} |
|
arm { |
|
lappend alt x86_64 |
|
} |
|
default { set alt {} } |
|
} |
|
|
|
if {$v ne ""} { |
|
foreach {major minor} [split $v .] break |
|
|
|
set res {} |
|
if {$major eq 12} { |
|
|
|
for {set j $minor} {$j >= 0} {incr j -1} { |
|
lappend res macosx${major}.${j}-${cpu} |
|
foreach a $alt { |
|
lappend res macosx${major}.${j}-$a |
|
} |
|
} |
|
set major 11 |
|
set minor 5 |
|
} |
|
if {$major eq 11} { |
|
|
|
for {set j $minor} {$j >= 0} {incr j -1} { |
|
lappend res macosx${major}.${j}-${cpu} |
|
foreach a $alt { |
|
lappend res macosx${major}.${j}-$a |
|
} |
|
} |
|
set major 10 |
|
set minor 15 |
|
} |
|
|
|
for {set j $minor} {$j >= 5} {incr j -1} { |
|
if {$cpu ne "arm"} { |
|
lappend res macosx${major}.${j}-${cpu} |
|
} |
|
foreach a $alt { |
|
lappend res macosx${major}.${j}-$a |
|
} |
|
} |
|
|
|
|
|
lappend res macosx-${cpu} |
|
foreach a $alt { |
|
lappend res macosx-$a |
|
} |
|
} else { |
|
|
|
foreach a $alt { |
|
lappend res macosx-$a |
|
} |
|
} |
|
} else { |
|
|
|
} |
|
} |
|
} |
|
lappend res tcl |
|
return $res |
|
} |
|
|
|
|
|
|
|
|
|
|
|
package provide platform 1.0.18 |
|
|
|
|
|
|
|
|
|
if {[info exists argv0] && ($argv0 eq [info script])} { |
|
puts ==================================== |
|
parray tcl_platform |
|
puts ==================================== |
|
puts Generic\ identification:\ [::platform::generic] |
|
puts Exact\ identification:\ \ \ [::platform::identify] |
|
puts ==================================== |
|
puts Search\ patterns: |
|
puts *\ [join [::platform::patterns [::platform::identify]] \n*\ ] |
|
puts ==================================== |
|
exit 0 |
|
} |
|
|