--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/micropolis-01-solaris.diff Thu Jan 24 10:48:52 2008 +0000
@@ -0,0 +1,464 @@
+diff -urN ../micropolis-activity/src/sim/makefile ./src/sim/makefile
+--- ../micropolis-activity/src/sim/makefile 2007-12-01 02:49:55.000000000 +0000
++++ ./src/sim/makefile 2008-01-22 21:08:46.000000000 +0000
+@@ -7,15 +7,16 @@
+
+ CC = gcc
+
+-OPTFLAGS = -O3
+-#OPTFLAGS = -g
++#OPTFLAGS = -O3
++OPTFLAGS = -g
+
+ #DEFINES = -DIS_LINUX -DIS_INTEL -DCAM -DNET
+-DEFINES = -DIS_LINUX -DIS_INTEL
++DEFINES = -DSOLARIS2 -Dsun -DIS_INTEL
+
+ CFLAGS = $(OPTFLAGS) $(DEFINES)
+
+ #LDFLAGS = -Bstatic
++LDFLAGS = -lsocket -lnsl
+
+ INSTALL = install -s
+
+diff -urN ../micropolis-activity/src/sim/w_tk.c ./src/sim/w_tk.c
+--- ../micropolis-activity/src/sim/w_tk.c 2007-12-01 02:49:55.000000000 +0000
++++ ./src/sim/w_tk.c 2008-01-22 22:30:24.000000000 +0000
+@@ -802,7 +802,17 @@
+ }
+
+ { char buf[1024];
+-
++ /* I don't know where HostName is supposed to come from, but Solaris
++ sprint doesn't allow sprinting NULL strings. GNU/Linux does
++ */
++ if (HostName == NULL)
++ {
++ if (HostName = getenv("HOSTNAME") == NULL)
++ {
++ HostName = malloc(_SC_HOST_NAME_MAX);
++ strcpy(HostName,"unknown");
++ }
++ }
+ sprintf(buf, "UIStartMicropolis {%s} {%s} {%s}",
+ HomeDir, ResourceDir, HostName);
+ filename2UNIX(buf);
+diff -urN ../micropolis-activity/src/sim/w_x.c ./src/sim/w_x.c
+--- ../micropolis-activity/src/sim/w_x.c 2007-12-01 02:49:55.000000000 +0000
++++ ./src/sim/w_x.c 2008-01-19 00:45:31.000000000 +0000
+@@ -67,8 +67,12 @@
+ #ifdef IS_LINUX
+ int FlushStyle = 3;
+ #else
++#ifdef SOLARIS2
++int FlushStyle = 3;
++#else
+ int FlushStyle = 4;
+ #endif
++#endif
+ int GotXError;
+
+
+@@ -189,6 +193,7 @@
+ case 4:
+ for (xd = XDisplays; xd != NULL; xd = xd->next) {
+ #ifndef IS_LINUX
++#ifndef SOLARIS2
+ /* XXX TODO: figure this out for linux and new x libs */
+ if ((xd->request != xd->dpy->request) ||
+ (xd->last_request_read != xd->dpy->last_request_read)) {
+@@ -197,6 +202,7 @@
+ xd->last_request_read = xd->dpy->last_request_read;
+ }
+ #endif
++#endif
+ }
+ break;
+
+@@ -281,6 +287,9 @@
+ Screen *screen = Tk_Screen(tkwin);
+ #ifdef IS_LINUX
+ char *display = ":0"; /* XXX TODO: fix this for new x libs */
++#endif
++#ifdef SOLARIS2
++ char *display = ":17.0"; /* XXX TODO: fix this for new x libs */
+ #else
+ char *display = dpy->display_name;
+ #endif
+diff -urN ../micropolis-activity/src/tcl/makefile ./src/tcl/makefile
+--- ../micropolis-activity/src/tcl/makefile 2007-12-01 02:49:55.000000000 +0000
++++ ./src/tcl/makefile 2008-01-22 22:56:34.000000000 +0000
+@@ -26,7 +26,7 @@
+
+ CC = gcc
+
+-CFLAGS = -O3 -I. -DTCL_LIBRARY=\"${TCL_LIBRARY}\" -DIS_LINUX
++CFLAGS = -O3 -I. -DTCL_LIBRARY=\"${TCL_LIBRARY}\" -DSOLARIS2
+ #CFLAGS = -g -I. -DTCL_LIBRARY=\"${TCL_LIBRARY}\" -DIS_LINUX
+
+ GENERIC_OBJS = \
+diff -urN ../micropolis-activity/src/tcl/tclenv.c ./src/tcl/tclenv.c
+--- ../micropolis-activity/src/tcl/tclenv.c 2007-12-01 02:49:55.000000000 +0000
++++ ./src/tcl/tclenv.c 2008-01-22 23:00:01.000000000 +0000
+@@ -57,7 +57,7 @@
+ int flags));
+ static int FindVariable _ANSI_ARGS_((char *name, int *lengthPtr));
+
+-#ifdef IS_LINUX
++#if defined(IS_LINUX) || defined(SOLARIS2)
+ int setenv _ANSI_ARGS_((const char *name, const char *value, int replace));
+ int unsetenv _ANSI_ARGS_((const char *name));
+ #else
+@@ -204,7 +204,7 @@
+ *----------------------------------------------------------------------
+ */
+
+-#ifdef IS_LINUX
++#if defined(IS_LINUX) || defined(SOLARIS2)
+ int
+ setenv(name, value, replace)
+ const char *name; /* Name of variable whose value is to be
+@@ -273,7 +273,7 @@
+ (void) Tcl_SetVar2(eiPtr->interp, "env", (char *)name, p+1, TCL_GLOBAL_ONLY);
+ }
+
+-#ifdef IS_LINUX
++#if defined(IS_LINUX) || defined(SOLARIS2)
+ return 0;
+ #endif
+
+@@ -298,7 +298,7 @@
+
+ int
+ unsetenv(name)
+-#ifdef IS_LINUX
++#if defined(IS_LINUX) || defined(SOLARIS2)
+ const char *name; /* Name of variable to remove. */
+ #else
+ char *name; /* Name of variable to remove. */
+diff -urN ../micropolis-activity/src/tclx/config.mk ./src/tclx/config.mk
+--- ../micropolis-activity/src/tclx/config.mk 2007-12-01 02:49:55.000000000 +0000
++++ ./src/tclx/config.mk 2008-01-22 23:42:16.000000000 +0000
+@@ -25,7 +25,7 @@
+ # them to us ([email protected]). At the end of this file is a
+ # description of all the flags that can be set in the config file.
+ #
+-TCL_CONFIG_FILE=linux
++TCL_CONFIG_FILE=solaris2
+
+ #==============================================================================
+ #
+@@ -62,7 +62,7 @@
+
+ CC=gcc
+
+-OPTIMIZE_FLAG=-O3 -DIS_LINUX
++OPTIMIZE_FLAG=-O3 -DSOLARIS2 -Dsun
+ #OPTIMIZE_FLAG=-g -DIS_LINUX
+
+ #------------------------------------------------------------------------------
+@@ -80,7 +80,7 @@
+ AR=ar
+ XCFLAGS=
+ XLDFLAGS=
+-YACC=yacc
++YACC=/usr/bin/yacc
+ #YACC=bison -b y
+
+ #------------------------------------------------------------------------------
+diff -urN ../micropolis-activity/src/tclx/makefile ./src/tclx/makefile
+--- ../micropolis-activity/src/tclx/makefile 2007-12-01 02:49:55.000000000 +0000
++++ ./src/tclx/makefile 2008-01-18 19:35:04.000000000 +0000
+@@ -33,6 +33,8 @@
+ CFLAGS= $(OPTIMIZE_FLAG) $(XCFLAGS) -I$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \
+ $(SYS_DEP_FLAGS)
+
++LDFLAGS= -lsocket -lnsl
++
+ #------------------------------------------------------------------------------
+
+ all: tcl tcldef runtcl $(TCL_TK_SHELL)
+diff -urN ../micropolis-activity/src/tclx/src/makefile ./src/tclx/src/makefile
+--- ../micropolis-activity/src/tclx/src/makefile 2007-12-01 02:49:55.000000000 +0000
++++ ./src/tclx/src/makefile 2008-01-22 23:27:12.000000000 +0000
+@@ -26,8 +26,9 @@
+ #------------------------------------------------------------------------------
+
+ CFLAGS= $(OPTIMIZE_FLAG) $(XCFLAGS) -I../$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \
+- $(SYS_DEP_FLAGS)
++ $(SYS_DEP_FLAGS) -DSOLARIS2
+
++LDFLAGS= -lsocket -lnsl
+ #------------------------------------------------------------------------------
+
+ OBJS= main.o tclxbsrc.o tclxcclk.o tclxchmd.o \
+@@ -48,10 +49,10 @@
+ touch made.tmp
+
+ tclxstup.o: patchlvl.h tclxstup.c
+- $(CC) -c $(CFLAGS) -DTCL_DEFAULT=\"$(TCL_DEFAULT)\" tclxstup.c
++ $(CC) -c $(CFLAGS) $(LDFLAGS) -DTCL_DEFAULT=\"$(TCL_DEFAULT)\" tclxstup.c
+
+ main.o: patchlvl.h main.c
+- $(CC) -c $(CFLAGS) $(HISTORY_FLAG) main.c
++ $(CC) -c $(CFLAGS) $(LDFLAGS) $(HISTORY_FLAG) main.c
+
+ tclxgdat.c: tclxgdat.y
+ $(YACC) tclxgdat.y
+@@ -59,7 +60,7 @@
+
+ ../tcl: ../libtcl.a made.tmp
+ $(RANLIB_CMD) ../libtcl.a
+- $(CC) $(CFLAGS) main.o ../libtcl.a $(LIBS) $(XLDFLAGS) -o ../tcl
++ $(CC) $(CFLAGS) $(LDFLAGS) main.o ../libtcl.a $(LIBS) $(XLDFLAGS) -o ../tcl
+ if $(DO_STRIPPING) ; then \
+ strip ../tcl; \
+ $(MCS_CMD) ../tcl; fi
+@@ -71,7 +72,7 @@
+ # C++ directories first.
+
+ tclplus.o: tclplus.c tclplus.h
+- $(CCPLUS) -c -I $(CCPLUSINCL) $(CFLAGS) $(HISTORY_FLAG) tclplus.cc
++ $(CCPLUS) -c -I $(CCPLUSINCL) $(CFLAGS) $(LDFLAGS) $(HISTORY_FLAG) tclplus.cc
+
+ #------------------------------------------------------------------------------
+ # This is just to test if it compiles.
+@@ -79,7 +80,7 @@
+ tclplus: ../tclplus
+
+ ../tclplus: mainplus.o
+- $(CCPLUS) $(CFLAGS) main++.o ../libtcl.a $(LIBS) $(XLDFLAGS) \
++ $(CCPLUS) $(CFLAGS) $(LDFLAGS) main++.o ../libtcl.a $(LIBS) $(XLDFLAGS) \
+ -o ../tcl++
+
+ mainplus.o: tclplus.h mainplus.c
+diff -urN ../micropolis-activity/src/tk/makefile ./src/tk/makefile
+--- ../micropolis-activity/src/tk/makefile 2007-12-01 02:49:55.000000000 +0000
++++ ./src/tk/makefile 2008-01-22 23:22:57.000000000 +0000
+@@ -29,9 +29,11 @@
+
+ CC = gcc
+
+-CFLAGS = -I. -I$(XINCLUDE) -I$(TCL_DIR) -O3 -DTK_VERSION=\"2.3\" -DUSE_XPM3 -DIS_LINUX
++CFLAGS = -I. -I$(XINCLUDE) -I$(TCL_DIR) -O3 -DTK_VERSION=\"2.3\" -DUSE_XPM3 -DSOLARIS2 -Dsun
+ #CFLAGS = -I. -I$(XINCLUDE) -I$(TCL_DIR) -g -DTK_VERSION=\"2.3\" -DUSE_XPM3 -DIS_LINUX
+
++LDFLAGS = -lsocket -lnsl
++
+ TCL_DIR = ../tcl
+ XINCLUDE = /usr/include/X11
+ XLIB = -L/usr/X11R6/lib -lX11 -lXpm
+@@ -167,7 +169,7 @@
+ all: wish
+
+ wish: main.o $(LIBS)
+- $(CC) $(CFLAGS) main.o $(LINKS) $(XLIB) -lm -o wish
++ $(CC) $(CFLAGS) $(LDFLAGS) main.o $(LINKS) $(XLIB) -lm -o wish
+
+ libtk.a: $(OBJS)
+ rm -f libtk.a
+diff -urN ../micropolis-activity/src/tk/makefile.bak ./src/tk/makefile.bak
+--- ../micropolis-activity/src/tk/makefile.bak 1970-01-01 01:00:00.000000000 +0100
++++ ./src/tk/makefile.bak 2008-01-22 23:12:29.000000000 +0000
+@@ -0,0 +1,189 @@
++#
++# This is a simplified Makefile for use in Tk distributions. Before using
++# it to compile Tk, you may wish to reset some of the following variables:
++#
++# TCL_DIR - Name of directory holding tcl.h and tcl.a.
++# XLIB - Name of archive containing Xlib binaries.
++#
++
++# You may also wish to add some of the following switches to the CFLAGS
++# variable:
++#
++# -DX11R3 Causes code that depends on R4 facilities not to
++# be compiled. I haven't tested Tk with R3 in quite
++# a while, so this switch may not be enough to
++# generate a working R3 version of Tk. Furthermore,
++# use of this switch will disable some of the facilities
++# of Tk related to window managers.
++# -DNO_PROTOTYPE Turns off ANSI-style procedure prototypes and the
++# corresponding compile-time checks. Without this
++# defininition, prototypes will be turned on if the
++# compiler supports ANSI C by defining __STDC__.
++# -DTK_LIBRARY=\"dir\" Arranges for dir, which must be the name of a
++# directory, to be the library directory for Tk scripts.
++# This value gets put into the variable $tk_library
++# when a new application is created. The library
++# defaults to /usr/local/lib/tk, so you don't need the
++# switch unless your library is in a non-standard place.
++#
++
++CC = gcc
++
++CFLAGS = -I. -I$(XINCLUDE) -I$(TCL_DIR) -O3 -DTK_VERSION=\"2.3\" -DUSE_XPM3 -DSOLARIS2 -Dsun
++#CFLAGS = -I. -I$(XINCLUDE) -I$(TCL_DIR) -g -DTK_VERSION=\"2.3\" -DUSE_XPM3 -DIS_LINUX
++
++LDFLAGS = -lsocket -lnsl
++
++TCL_DIR = ../tcl
++XINCLUDE = /usr/include/X11
++XLIB = -L/usr/X11R6/lib -lX11 -lXpm
++
++LIBS = libtk.a $(TCL_DIR)/libtcl.a
++LINKS = $(LIBS)
++
++WIDGOBJS = \
++ tkbutton.o \
++ tkentry.o \
++ tkframe.o \
++ tklist.o \
++ tkmenu.o \
++ tkmnbut.o \
++ tkmsg.o \
++ tkscale.o \
++ tkscrbar.o
++
++CANVOBJS = \
++ tkcanvas.o \
++ tkcvarc.o \
++ tkcvbmap.o \
++ tkcvline.o \
++ tkcvpoly.o \
++ tkcvtext.o \
++ tkcvwind.o \
++ tkrectov.o \
++ tktrig.o
++
++TEXTOBJS = \
++ tktext.o \
++ tktxbtre.o \
++ tktxdisp.o \
++ tktxidx.o \
++ tktxtag.o
++
++OBJS = \
++ tk3d.o \
++ tkargv.o \
++ tkatom.o \
++ tkbind.o \
++ tkbitmap.o \
++ tkcmds.o \
++ tkcolor.o \
++ tkconfig.o \
++ tkcursor.o \
++ tkerror.o \
++ tkevent.o \
++ tkfont.o \
++ tkget.o \
++ tkgc.o \
++ tkgeo.o \
++ tkgrab.o \
++ tkoption.o \
++ tkpack.o \
++ tkpixmap.o \
++ tkplace.o \
++ tkpresrv.o \
++ tkselect.o \
++ tksend.o \
++ tkshare.o \
++ tkwindow.o \
++ tkwm.o \
++ tkrawtcp.o \
++ $(WIDGOBJS) \
++ $(CANVOBJS) \
++ $(TEXTOBJS)
++
++WIDGSRCS = \
++ tkbutton.c \
++ tkentry.c \
++ tkframe.c \
++ tklist.c \
++ tkmenu.c \
++ tkmnbut.c \
++ tkmessage.c \
++ tkscale.c \
++ tkscrbar.c \
++ tktext.c \
++ tktxbtre.c \
++ tktxdisp.c \
++ tktextindex.c
++
++CANVSRCS = \
++ tkcanvas.c \
++ tkcvarc.c \
++ tkcvbmap.c \
++ tkcvline.c \
++ tkcvpoly.c \
++ tkcvtext.c \
++ tkcvwind.c \
++ tkrectov.c \
++ tktrig.c
++
++TEXTSRCS = \
++ tktext.c \
++ tktxbtre.c \
++ tktxdisp.c \
++ tktxidx.c \
++ tktxtag.c
++
++SRCS = \
++ tk3d.c \
++ tkargv.c \
++ tkatom.c \
++ tkbind.c \
++ tkbitmap.c \
++ tkcmds.c \
++ tkcolor.c \
++ tkconfig.c \
++ tkcursor.c \
++ tkerror.c \
++ tkevent.c \
++ tkfont.c \
++ tkget.c \
++ tkgc.c \
++ tkgeo.c \
++ tkgrab.c \
++ tkoption.c \
++ tkpack.c \
++ tkplace.c \
++ tkpresrv.c \
++ tkselect.c \
++ tksend.c \
++ tkshare.c \
++ tkwindow.c \
++ tkwm.c \
++ tkrawtcp.c \
++ $(widgsrcs) \
++ $(CANVSRCS) \
++ $(TEXTSRCS)
++
++all: wish
++
++wish: main.o $(LIBS)
++ $(CC) $(CFLAGS) $(LDFLAGS) main.o $(LINKS) $(XLIB) -lm -o wish
++
++libtk.a: $(OBJS)
++ rm -f libtk.a
++ ar cr libtk.a $(OBJS)
++ ranlib libtk.a
++
++$(TCL_DIR)/libtcl.a:
++ cd $(TCL_DIR); make libtcl.a
++
++clean:
++ touch junk~
++ rm -f $(OBJS) main.o libtk.a wish *~
++
++$(OBJS): tk.h tkint.h tkconfig.h
++$(WIDGOBJS): default.h
++$(CANVOBJS): default.h tkcanvas.h
++main.o: tk.h tkint.h
+diff -urN ../micropolis-activity/src/tk/tkbind.c ./src/tk/tkbind.c
+--- ../micropolis-activity/src/tk/tkbind.c 2007-12-01 02:49:55.000000000 +0000
++++ ./src/tk/tkbind.c 2008-01-22 23:17:01.000000000 +0000
+@@ -1490,7 +1490,7 @@
+ if (dispPtr->symsPerCode == 0) {
+ Display *dpy = dispPtr->display;
+
+-#ifdef IS_LINUX
++#if defined(IS_LINUX) || defined(SOLARIS2)
+ XDisplayKeycodes(dpy, &dispPtr->firstKeycode, &dispPtr->lastKeycode);
+ #else
+ dispPtr->firstKeycode =