This page was prompted by a discussion started by Bob Techentin and Joe English on comp.lang.tcl [http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=b43qpj01sme%40enews4.newsguy.com&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Dcomp.lang.tcl%26btnG%3DGoogle%2BSearch]. -[jcw] The problem: how to generate a simple name which can be used as directory name when storing multiple shared library builds for different platforms next to each other. This has uses in [Critcl] and in [Starkit]s. The problem is hard, because it's not well specified. One could do "[[join [[array get tcl_platform]] { }]]", and end up with a name which is definitely unique, but huge. The trouble is that for shared libraries, this approach is in fact wrong - there are many details in tcl_platform which differ between machines, yet are irrelevant w.r.t. binary compatibility. An example from Joe English's post: IRIX has numerous variations with intricate compatibility issues, while Linux does not really care - all shared libs will load anywhere regardless of kernel version. So, let's try to come up with some logic, and extend / perfect it along the way. Here's a start: proc platform {} { global tcl_platform set plat [lindex $tcl_platform(os) 0] set mach $tcl_platform(machine) switch -glob -- $mach { sun4* { set mach sparc } intel - i*86* { set mach x86 } "Power Macintosh" { set mach ppc } } set mach [regsub -all {[ /]} $mach "-"] return "$plat-$mach" } Some output: Linux-x86 Darwin-ppc (Mac OSX) Windows-x86 The goal is to come up with a unique identifier which can be used as directory name (no slashes or colons, please), for each context which requires a different binary. For contexts which are compatible, the goal is to end up with the same identifier each time. Failures are not necessarily show-stoppers. If a specific shared library needs more differentiation than the identifier provides, one can always add add-hoc logic for it (example: a high-performance bianry which is built different for Pentium vs. Athlon cpu's). If it turns out that two different identifiers are produced for what is determined to be compatible after all (IRIX comes to mind), then one can either store copies, or post-process the output from the [[platform]] command. ---- Anyway, the idea for this page is to tweak the above [[platform]] command, so we can use it as "easy shared-lib discriminator" on more and more platforms. Here's a modified version with Bob's HPUX changes added: proc platform {} { global tcl_platform set plat [lindex $tcl_platform(os) 0] set mach $tcl_platform(machine) switch -glob -- $mach { sun4* { set mach sparc } intel - i*86* { set mach x86 } "Power Macintosh" { set mach ppc } 9000* {set mach 9000} } set mach [regsub -all {[ /]} $mach "-"] return "$plat-$mach" } Please feel free to alter the above (caerfully, so it doesn't break). The history of this page (warning: it only gets updated once per day) can be used to see all previous versions if you need to go back and check things out: http://mini.net/tclhist/8522