Critcl started life as an experiment by Coen Siegerink and was a self-contained Tcl package to build C code into a Tcl/Tk extension on the fly. It was somewhat inspired by Brian Ingerson's Inline for Perl[3], but is considerably more lightweight.
The original idea was to wrap C code into something that could then be compiled into a Tcl extension, (if necessary) compile it using gcc when the end user runs the application and then dynamically load it into the running Tcl/Tk interpreter. Critcl used a MD5 checksum of the source code to decide if it needed recompiling, so subsequent use was almost instantaneous. Both the MD5 checksum for the generated source and the compiled shared library are cached.
The use of Tcl stubs, and the fact that Critcl had all the include files it needs to make compilation self-contained, means that this was a pure Tcl package, which worked with any (8.1 and up) installation of Tcl. Most importantly, Critcl did not care a bit where Tcl was installed, nor even whether it was built as a static or as a dynamic executable.
So, in one sense, Critcl (the library) permitted Tcl scripting to go that last few percent where raw performance becomes an issue.
The second chapter of the Critcl story is CritLib[4] - a set of Tcl extensions - and CritBind - a utility script that used the Critcl package to build a shared library out of the Critcl extensions.
This takes the Critcl story another step further - now, the developer could use Critcl to build common libraries, which are then available for deployment in environments without a C compiler. Critcl still required gcc - but at least this is commonly available to developers. And it is potentially only a small step to any C compiler with a command line interface.
CritLib provided valuable experience in building common compiled Tcl/Tk extensions. This includes blowfish, mathf, md5c, TkHtml and zlib. But CritBind was still relatively difficult to use, and so the third chapter of the Critcl story began.
Critcl (the command) makes Critcl trivially easy to use. For convenience, it is deployed as a Starkit [5] (although it can be unwrapped and used with a more traditional Tcl interpreter). It can be run in one of three modes - a "compile and run" mode (similar to the original Critcl experiment); a "build library" mode (similar to CritBind); and a "package" mode.
It is this latest incarnation of Critcl that will be discussed in detail by this paper - with particular focus on the package mode for generation of ready-to-run Tcl extensions for multiple platforms.