Posted to tcl by patthoyts at Wed Nov 01 15:16:36 GMT 2006view raw

  1. namespace eval ::platform {
  2. proc generic {} {
  3. global tcl_platform
  4.  
  5.  
  6. set plat [string tolower [lindex $tcl_platform(os) 0]]
  7. set cpu $tcl_platform(machine)
  8.  
  9. switch -glob -- $cpu {
  10. sun4* {
  11. set cpu sparc
  12. }
  13. intel -
  14. i*86* {
  15. set cpu ix86
  16. }
  17. x86_64 {
  18. if {$tcl_platform(wordSize) == 4} {
  19. # See Example <1> at the top of this file.
  20. set cpu ix86
  21. }
  22. }
  23. "Power*" {
  24. set cpu powerpc
  25. }
  26. "arm*" {
  27. set cpu arm
  28. }
  29. }
  30.  
  31. switch -- $plat {
  32. windows {
  33. set plat win32
  34. }
  35. sunos {
  36. set plat solaris
  37. if {$tcl_platform(wordSize) == 8} {
  38. append cpu 64
  39. }
  40. }
  41. darwin {
  42. set plat macosx
  43. }
  44. aix {
  45. set cpu powerpc
  46. if {$tcl_platform(wordSize) == 8} {
  47. append cpu 64
  48. }
  49. }
  50. hp-ux {
  51. set plat hpux
  52. if {$cpu ne "ia64"} {
  53. set cpu parisc
  54. if {$tcl_platform(wordSize) == 8} {
  55. append cpu 64
  56. }
  57. }
  58. }
  59. osf1 {
  60. set plat tru64
  61. }
  62. }
  63.  
  64. return "${cpu}-${plat}"
  65.  
  66. }
  67. }
  68.