for review: add mercury_tcltk library

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Feb 17 02:00:50 AEDT 1998


On 16-Feb-1998, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> New File: extras/graphics/mercury_tcltk/README
> ===================================================================
> 
> This directory contains the package `mercury_tcltk', which is a Mercury
> binding for Tcl/Tk. You will need the Mercury compiler to build
> it (see http://www.cs.mu.oz.au/mercury to find out more about Mercury).

Please put the URL inside <angle brackets>.

> %	To use the Mercury interface to Tk/Tcl, you will need to
> %	link with the Tcl and Tk libraries. To do this, you'll need
> %	to add a line like the following to your Mmake file:

s/Mmake file/Mmakefile/

(The use of plain `Mmake' instead of `Mmakefile' should be discouraged,
due to problems on case-insensitive file systems.)

> %	If Tcl and Tk are installed in places that are not on the
> %	default search path for libraries then you'll need to add
> %	a -L flag to your MFLAGS to search there. You may also need
> %	to add flags to make the executable look in the right places
> %	for dynamic libraries. On the Solaris machines at cs.mu.oz.au
> %	I had to use the following MLFLAGS to get things going:
> %
> %	MLFLAGS = -Wl,-R,/usr/local/lib -L/usr/local/lib
> %	MLLIBS = -ltcl7.5 -ltk4.1

Why `-Wl,-R,...' instead of `-R ...'?
Did that just predate the addition support for `-R' to `ml'?
If so, it should be changed.

Also, I suggest that the `-L' options be put in MLLIBS rather than `MLFLAGS'. 

The reason for this is that if you don't do this, then it breaks
`mmake EXTRA_MLFLAGS=--no-strip'.  The reason for this is that `ml'
does not directly support `-L', and so treats `-L' as the end of its own
options; it passes that and all following options to the native linker.
Since $(EXTRA_MLFLAGS) are appended after $(MLFLAGS), this results in
`ml' passing `--no-strip' onto the native linker rather than interpreting
it itself.

Putting the `-L' options in MLLIBS is a work-around, not an ideal solution,
but it seems to be the right thing to do until the problem is fixed.

There's a couple of possible fixes.  One is to add support for `-L'
to `ml'.  Another is to add new variables LDFLAGS (and EXTRA_LDFLAGS),
and to have `mmake' invoke `ml' as `($ML) $(MLFLAGS) -- $(LDFLAGS)'.
Perhaps we should do both of these.

> :- pred mtcltk__eval(tcl_interp, string, tcl_status, string, io__state, io__state).

Please wrap long lines.

> :- pragma c_code(mtcltk__main(Closure::pred(in, di, uo) is det, Args::in,
> 		IO0::di, IO::uo), may_call_mercury, "
> {
>     Word l;
>     int argc, i;
>     char **argv;
> 
>     /*
>     ** convert arguments from a list of strings to an array of strings
>     */
>     argc = 0;
>     for(l = Args; l != list_empty(); l = list_tail(l))
> 	argc++;
>     incr_hp((Word)argv, argc+1);

That should be `incr_hp(LVALUE_CAST(Word, argv), argc + 1)',
otherwise it won't work on non-gcc compilers.

> int
> Tcl_AppInit(Tcl_Interp *interp)
> {
>     static char tk_str[] = ""Tk"";
>     static char tcl_rcFileName_str[] = ""tcl_rcFileName"";
>     static char gwarsrc_str[] = ""~/.gwarsrc"";

What is that gwars stuff doing here?

> % file: mtk.
> % main author: conway.
> %
> % This file provides an interface to the Tk widget set, [conceptually] bypassing
> % Tcl.

Please wrap long lines.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list