diff: extras/graphics/samples cleanup.

Tyson Dowd trd at cs.mu.OZ.AU
Sun Sep 6 17:39:27 AEST 1998


Hi,

This is the other half of a change I started a long time ago
to clean up the extras graphics stuff.  

We need this fixed before we release, so I figure it comes in
regardless of the feature freeze (and extras probably doesn't really
count as frozen anyway).

I will check this in now.  It should be easy to add any suggested
changes.

===================================================================

Estimated hours taken: 3

samples/calc/Mmakefile:
samples/maze/Mmakefile:
samples/maze/globals.m:
samples/maze/maze.m:
	Clean up samples to use the library versions of the graphics
	packages.
	Use unsafe_promise_unique instead of "copy" (copy triggers a
	bug that I haven't yet tracked down).

cvs server: Diffing .
cvs server: Diffing Togl-1.2
cvs server: Diffing mercury_opengl
cvs server: Diffing mercury_tcltk
cvs server: Diffing samples
cvs server: Diffing samples/calc
Index: samples/calc/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/graphics/samples/calc/Mmakefile,v
retrieving revision 1.1
diff -u -r1.1 Mmakefile
--- Mmakefile	1997/09/29 17:55:04	1.1
+++ Mmakefile	1998/09/06 07:28:26
@@ -1,13 +1,25 @@
 
-MLLIBS	= -ltk -ltcl -L/usr/X11/lib -lX11 -lXmu -lXext -lm -ldl
+# To use shared libraries under Linux you need to add these:
+MGNUCFLAGS    = --pic-reg
+EXTRA_MLFLAGS = -shared
 
-default_target : calc
+# This will need to be modified according to the versions of 
+# tk and tcl you are using.
+EXTRA_MLLIBS  = -ltk8.0 -ltcl8.0 -L/usr/X11R6/lib -lX11 -lXmu \
+			-lXext -lm -ldl
+
+# Specify the location of the `mercury_tcltk' package.
+MERCURY_TCLTK_DIR	= ../../mercury_tcltk
 
-depend : links calc.depend
+# Tell mmake to use the `mercury_tcltk' library.
+VPATH 		= $(MERCURY_TCLTK_DIR):$(MMAKE_VPATH)
+MCFLAGS 	= -I$(MERCURY_TCLTK_DIR) $(EXTRA_MCFLAGS)
+MLFLAGS 	= -R$(MERCURY_TCLTK_DIR) $(EXTRA_MLFLAGS) \
+          	  -L$(MERCURY_TCLTK_DIR) 
+MLLIBS 		= -lmercury_tcltk $(EXTRA_MLLIBS)
+C2INITFLAGS 	= $(MERCURY_TCLTK_DIR)/mercury_tcltk.init 
 
-links :
-	ln -s ../../mtcltk.m ../../mtk.m .
+default_target : calc
 
-realclean :
-	rm -f mtcltk.m mtk.m
+depend : calc.dep
 
cvs server: Diffing samples/maze
Index: samples/maze/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/graphics/samples/maze/Mmakefile,v
retrieving revision 1.1
diff -u -r1.1 Mmakefile
--- Mmakefile	1997/09/29 17:55:20	1.1
+++ Mmakefile	1998/09/06 07:28:38
@@ -1,26 +1,27 @@
 
-MLLIBS	= togl.o -ltk -ltcl -lGLU -lGL -L/usr/X11/lib -lX11 -lXmu -lXext -ldl
+# To use static libraries under Linux you need this.
+MGNUCFLAGS    = --pic-reg
+EXTRA_MLFLAGS = -shared
+
+EXTRA_MLLIBS	= -ltk8.0 -ltcl8.0 -lMesaGLU -lMesaGL -L/usr/X11R6/lib -lX11 \
+			-lXmu -lXext -ldl
+
+# Specify the location of the `mercury_tcltk' and `mercury_opengl' packages.
+MERCURY_TCLTK_DIR   = ../../mercury_tcltk
+MERCURY_OPENGL_DIR  = ../../mercury_opengl
+
+# Tell mmake to use the `mercury_tcltk' and `mercury_opengl' libraries.
+VPATH           = $(MERCURY_OPENGL_DIR):$(MERCURY_TCLTK_DIR):$(MMAKE_VPATH)
+MCFLAGS         = -I$(MERCURY_TCLTK_DIR) -I$(MERCURY_OPENGL_DIR) \
+			$(EXTRA_MCFLAGS)
+MLFLAGS         = -R$(MERCURY_TCLTK_DIR) -R$(MERCURY_OPENGL_DIR) \
+			$(EXTRA_MLFLAGS) -L$(MERCURY_TCLTK_DIR)  \
+			-L$(MERCURY_OPENGL_DIR)
+MLLIBS          = -lmercury_opengl -lmercury_tcltk $(EXTRA_MLLIBS)
+C2INITFLAGS     = $(MERCURY_TCLTK_DIR)/mercury_tcltk.init \
+		  $(MERCURY_OPENGL_DIR)/mercury_opengl.init
 
-GFX_BINDINGS = ../../mtcltk.m ../../mogl.m ../../mglu.m ../../mtogl.m
-GFX_LINKS = mtcltk.m mogl.m mglu.m mtogl.m
-
-TOGL_STUFF = ../../Togl-1.2/tkInt4.0.h ../../Togl-1.2/tkInt4.1.h \
-	../../Togl-1.2/tkInt4.2.h ../../Togl-1.2/togl.h ../../Togl-1.2/togl.c
-TOGL_LINKS = tkInt4.0.h tkInt4.1.h tkInt4.2.h togl.h togl.c
-
 default_target : maze
-
-depend : links maze.depend
-
-links :
-	ln -s $(GFX_BINDINGS) .
-	ln -s $(TOGL_STUFF) .
-
-maze : togl.o
-
-clean :
-	rm -f togl.o
 
-realclean :
-	rm -f $(GFX_LINKS) $(TOGL_LINKS)
+depend : maze.depend
 
Index: samples/maze/globals.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/graphics/samples/maze/globals.m,v
retrieving revision 1.1
diff -u -r1.1 globals.m
--- globals.m	1997/07/18 05:04:26	1.1
+++ globals.m	1998/09/06 07:28:38
@@ -20,7 +20,7 @@
 init_globals -->
 	{ my_map_init(Map) },
 	{ type_to_univ(Map, UMap1) },
-	{ copy(UMap1, UMap) },
+	{ unsafe_promise_unique(UMap1, UMap) },
 	io__set_globals(UMap).
 
 get_global(Name, Value) -->
@@ -58,7 +58,7 @@
 		{ type_to_univ(Value, UValue) },
 		{ map__set(Map0, Name, UValue, Map) },
 		{ type_to_univ(Map, UMap1) },
-		{ copy(UMap1, UMap) },
+		{ unsafe_promise_unique(UMap1, UMap) },
 		io__set_globals(UMap)
 	;
 		{ error("globals: global store stuffed up") }
Index: samples/maze/maze.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/graphics/samples/maze/maze.m,v
retrieving revision 1.2
diff -u -r1.2 maze.m
--- maze.m	1997/09/11 22:08:55	1.2
+++ maze.m	1998/09/06 07:28:56
@@ -89,8 +89,9 @@
 			Rnd0, Rnd) },
 		io__write_string(" done.\n"),
 		io__flush_output,
+		set_global("Rnd", Rnd),
 			% enter Tcl/Tk.
-		main(doit(Maze1, Rnd), ["maze"])
+		main(doit(Maze1), ["maze"])
 
 	;
 		{ MOpts = error(Str) },
@@ -104,10 +105,10 @@
 
 	% Main callback from Tcl/Tk.
 
-:- pred doit(maze, random__supply, tcl_interp, io__state, io__state).
-:- mode doit(in, mdi, in, di, uo) is det.
+:- pred doit(maze, tcl_interp, io__state, io__state).
+:- mode doit(in, in, di, uo) is det.
 
-doit(Maze, Rnd0, Interp) -->
+doit(Maze, Interp) -->
 		% Initialize the Togl widget.
 	mtogl__init(Interp, Res0),
 	{ Res0 \= tcl_ok -> error("Mtogl__init failed") ; true },
@@ -118,7 +119,6 @@
 	set_global("Maze", Maze),
 	set_global("Pos", pos(0, 0)),
 	set_global("Dir", east),
-	set_global("Rnd", Rnd0),
 	set_global("Phi", 0.0),
 	set_global("Theta", 0.0),
 	{ set__init(Set) },


-- 
Those who would give up essential liberty to purchase a little temporary
safety deserve neither liberty nor safety.     - Benjamin Franklin

Tyson Dowd   <tyson at tyse.net>   http://tyse.net



More information about the developers mailing list