Tcl-config

From ASCEND
Jump to: navigation, search

tcl-config.py is a script that undertakes to quickly and easily extract import Tcl/Tk configuration variables for the the system you're using. It's been tested on Windows XP running Active State Tcl/Tk 8.4 as well as on Ubuntu 8.10 running Tcl/Tk 8.4.

Get tcl-config.py: scons/tcl-config.py

Unfortunately, it's written in Python (requires version 2.4) because that's what the author's good at, but nevertheless, this script will be useful for users of SCons, at least, because those people will always have Python available, and this script saves a lot of other messing around with sniffing out the location of Tcl/Tk and corresponding files on any given system.

./tcl-config.py [--cflags] [--libs] [--var=TCL_VAR_NAME] [--vars]
Output configuration variables for the Tcl script interpreter.
Options:
	--cflags           Compiler flags for C code that uses Tcl
	--libs             Linker flags for code that uses Tcl
	--vars             List all variables defined in tclConfig.sh
	--var=VARNAME      Output the value of a specific variable

This 'tcl-config' script is based on the simple 'standard' approach implemented by other *-config scripts such as 'gsl-config' and 'pkg-config' and 'cppunit-config' and many others like it. These scripts are found on a system's PATH and can output various configuration information about a software library, for example:

john@thunder:~$ cppunit-config --libs
-lcppunit -ldl

john@thunder:~$ gsl-config --cflags

-I/usr/include

This makes linking to such libraries almost trivial even when using quite a wide range of tools on a wide range of platforms:

gcc `gsl-config --cflags --libs` myprog.c

Currently, Tcl/Tk provides all configuration data in a build-time-generated shell script called tclConfig.sh, the location of which can be determined only with a bit of guesswork, or from knowledge of the Tcl/Tk script path ($auto_path) for the system you're on. You also need to know what version of Tcl/Tk you're wanting. This design is rather broken, because one needs to run Tcl even in order to locate where that script is, but then, as whole additional step, one is supposed to parse that script using /bin/sh and then extract variables from the environment.


If someone would like to expand this script, or rewrite it in Tcl/Tk, that would be really great. Also, any suggestions much appreciated. John Pye